4288 lines
3.1 MiB
Plaintext
4288 lines
3.1 MiB
Plaintext
var x$=Object.defineProperty;var C$=(t,e,r)=>e in t?x$(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var xb=(t,e,r)=>C$(t,typeof e!="symbol"?e+"":e,r);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))n(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&n(a)}).observe(document,{childList:!0,subtree:!0});function r(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function n(i){if(i.ep)return;i.ep=!0;const o=r(i);fetch(i.href,o)}})();var Ai=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ll(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function S$(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var r=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}),r}var rO={exports:{}},A5={},iO={exports:{}},Pn={};/**
|
||
* @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 z1=Symbol.for("react.element"),T$=Symbol.for("react.portal"),_$=Symbol.for("react.fragment"),E$=Symbol.for("react.strict_mode"),b$=Symbol.for("react.profiler"),D$=Symbol.for("react.provider"),I$=Symbol.for("react.context"),O$=Symbol.for("react.forward_ref"),M$=Symbol.for("react.suspense"),P$=Symbol.for("react.memo"),R$=Symbol.for("react.lazy"),Cb=Symbol.iterator;function L$(t){return t===null||typeof t!="object"?null:(t=Cb&&t[Cb]||t["@@iterator"],typeof t=="function"?t:null)}var oO={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},aO=Object.assign,sO={};function kh(t,e,r){this.props=t,this.context=e,this.refs=sO,this.updater=r||oO}kh.prototype.isReactComponent={};kh.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=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,t,e,"setState")};kh.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function cO(){}cO.prototype=kh.prototype;function LT(t,e,r){this.props=t,this.context=e,this.refs=sO,this.updater=r||oO}var AT=LT.prototype=new cO;AT.constructor=LT;aO(AT,kh.prototype);AT.isPureReactComponent=!0;var Sb=Array.isArray,lO=Object.prototype.hasOwnProperty,NT={current:null},uO={key:!0,ref:!0,__self:!0,__source:!0};function fO(t,e,r){var n,i={},o=null,a=null;if(e!=null)for(n in e.ref!==void 0&&(a=e.ref),e.key!==void 0&&(o=""+e.key),e)lO.call(e,n)&&!uO.hasOwnProperty(n)&&(i[n]=e[n]);var s=arguments.length-2;if(s===1)i.children=r;else if(1<s){for(var c=Array(s),l=0;l<s;l++)c[l]=arguments[l+2];i.children=c}if(t&&t.defaultProps)for(n in s=t.defaultProps,s)i[n]===void 0&&(i[n]=s[n]);return{$$typeof:z1,type:t,key:o,ref:a,props:i,_owner:NT.current}}function A$(t,e){return{$$typeof:z1,type:t.type,key:e,ref:t.ref,props:t.props,_owner:t._owner}}function kT(t){return typeof t=="object"&&t!==null&&t.$$typeof===z1}function N$(t){var e={"=":"=0",":":"=2"};return"$"+t.replace(/[=:]/g,function(r){return e[r]})}var Tb=/\/+/g;function lx(t,e){return typeof t=="object"&&t!==null&&t.key!=null?N$(""+t.key):e.toString(36)}function tv(t,e,r,n,i){var o=typeof t;(o==="undefined"||o==="boolean")&&(t=null);var a=!1;if(t===null)a=!0;else switch(o){case"string":case"number":a=!0;break;case"object":switch(t.$$typeof){case z1:case T$:a=!0}}if(a)return a=t,i=i(a),t=n===""?"."+lx(a,0):n,Sb(i)?(r="",t!=null&&(r=t.replace(Tb,"$&/")+"/"),tv(i,e,r,"",function(l){return l})):i!=null&&(kT(i)&&(i=A$(i,r+(!i.key||a&&a.key===i.key?"":(""+i.key).replace(Tb,"$&/")+"/")+t)),e.push(i)),1;if(a=0,n=n===""?".":n+":",Sb(t))for(var s=0;s<t.length;s++){o=t[s];var c=n+lx(o,s);a+=tv(o,e,r,c,i)}else if(c=L$(t),typeof c=="function")for(t=c.call(t),s=0;!(o=t.next()).done;)o=o.value,c=n+lx(o,s++),a+=tv(o,e,r,c,i);else if(o==="object")throw e=String(t),Error("Objects are not valid as a React child (found: "+(e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)+"). If you meant to render a collection of children, use an array instead.");return a}function Nm(t,e,r){if(t==null)return t;var n=[],i=0;return tv(t,n,"","",function(o){return e.call(r,o,i++)}),n}function k$(t){if(t._status===-1){var e=t._result;e=e(),e.then(function(r){(t._status===0||t._status===-1)&&(t._status=1,t._result=r)},function(r){(t._status===0||t._status===-1)&&(t._status=2,t._result=r)}),t._status===-1&&(t._status=0,t._result=e)}if(t._status===1)return t._result.default;throw t._result}var Jo={current:null},nv={transition:null},V$={ReactCurrentDispatcher:Jo,ReactCurrentBatchConfig:nv,ReactCurrentOwner:NT};function dO(){throw Error("act(...) is not supported in production builds of React.")}Pn.Children={map:Nm,forEach:function(t,e,r){Nm(t,function(){e.apply(this,arguments)},r)},count:function(t){var e=0;return Nm(t,function(){e++}),e},toArray:function(t){return Nm(t,function(e){return e})||[]},only:function(t){if(!kT(t))throw Error("React.Children.only expected to receive a single React element child.");return t}};Pn.Component=kh;Pn.Fragment=_$;Pn.Profiler=b$;Pn.PureComponent=LT;Pn.StrictMode=E$;Pn.Suspense=M$;Pn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=V$;Pn.act=dO;Pn.cloneElement=function(t,e,r){if(t==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+t+".");var n=aO({},t.props),i=t.key,o=t.ref,a=t._owner;if(e!=null){if(e.ref!==void 0&&(o=e.ref,a=NT.current),e.key!==void 0&&(i=""+e.key),t.type&&t.type.defaultProps)var s=t.type.defaultProps;for(c in e)lO.call(e,c)&&!uO.hasOwnProperty(c)&&(n[c]=e[c]===void 0&&s!==void 0?s[c]:e[c])}var c=arguments.length-2;if(c===1)n.children=r;else if(1<c){s=Array(c);for(var l=0;l<c;l++)s[l]=arguments[l+2];n.children=s}return{$$typeof:z1,type:t.type,key:i,ref:o,props:n,_owner:a}};Pn.createContext=function(t){return t={$$typeof:I$,_currentValue:t,_currentValue2:t,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},t.Provider={$$typeof:D$,_context:t},t.Consumer=t};Pn.createElement=fO;Pn.createFactory=function(t){var e=fO.bind(null,t);return e.type=t,e};Pn.createRef=function(){return{current:null}};Pn.forwardRef=function(t){return{$$typeof:O$,render:t}};Pn.isValidElement=kT;Pn.lazy=function(t){return{$$typeof:R$,_payload:{_status:-1,_result:t},_init:k$}};Pn.memo=function(t,e){return{$$typeof:P$,type:t,compare:e===void 0?null:e}};Pn.startTransition=function(t){var e=nv.transition;nv.transition={};try{t()}finally{nv.transition=e}};Pn.unstable_act=dO;Pn.useCallback=function(t,e){return Jo.current.useCallback(t,e)};Pn.useContext=function(t){return Jo.current.useContext(t)};Pn.useDebugValue=function(){};Pn.useDeferredValue=function(t){return Jo.current.useDeferredValue(t)};Pn.useEffect=function(t,e){return Jo.current.useEffect(t,e)};Pn.useId=function(){return Jo.current.useId()};Pn.useImperativeHandle=function(t,e,r){return Jo.current.useImperativeHandle(t,e,r)};Pn.useInsertionEffect=function(t,e){return Jo.current.useInsertionEffect(t,e)};Pn.useLayoutEffect=function(t,e){return Jo.current.useLayoutEffect(t,e)};Pn.useMemo=function(t,e){return Jo.current.useMemo(t,e)};Pn.useReducer=function(t,e,r){return Jo.current.useReducer(t,e,r)};Pn.useRef=function(t){return Jo.current.useRef(t)};Pn.useState=function(t){return Jo.current.useState(t)};Pn.useSyncExternalStore=function(t,e,r){return Jo.current.useSyncExternalStore(t,e,r)};Pn.useTransition=function(){return Jo.current.useTransition()};Pn.version="18.3.1";iO.exports=Pn;var st=iO.exports;/**
|
||
* @license React
|
||
* react-jsx-runtime.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 F$=st,U$=Symbol.for("react.element"),B$=Symbol.for("react.fragment"),G$=Object.prototype.hasOwnProperty,W$=F$.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,z$={key:!0,ref:!0,__self:!0,__source:!0};function hO(t,e,r){var n,i={},o=null,a=null;r!==void 0&&(o=""+r),e.key!==void 0&&(o=""+e.key),e.ref!==void 0&&(a=e.ref);for(n in e)G$.call(e,n)&&!z$.hasOwnProperty(n)&&(i[n]=e[n]);if(t&&t.defaultProps)for(n in e=t.defaultProps,e)i[n]===void 0&&(i[n]=e[n]);return{$$typeof:U$,type:t,key:o,ref:a,props:i,_owner:W$.current}}A5.Fragment=B$;A5.jsx=hO;A5.jsxs=hO;rO.exports=A5;var ze=rO.exports,gO={exports:{}},$a={},pO={exports:{}},mO={};/**
|
||
* @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(t){function e(A,F){var G=A.length;A.push(F);e:for(;0<G;){var X=G-1>>>1,ee=A[X];if(0<i(ee,F))A[X]=F,A[G]=ee,G=X;else break e}}function r(A){return A.length===0?null:A[0]}function n(A){if(A.length===0)return null;var F=A[0],G=A.pop();if(G!==F){A[0]=G;e:for(var X=0,ee=A.length,ce=ee>>>1;X<ce;){var Se=2*(X+1)-1,we=A[Se],_e=Se+1,Ve=A[_e];if(0>i(we,G))_e<ee&&0>i(Ve,we)?(A[X]=Ve,A[_e]=G,X=_e):(A[X]=we,A[Se]=G,X=Se);else if(_e<ee&&0>i(Ve,G))A[X]=Ve,A[_e]=G,X=_e;else break e}}return F}function i(A,F){var G=A.sortIndex-F.sortIndex;return G!==0?G:A.id-F.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;t.unstable_now=function(){return o.now()}}else{var a=Date,s=a.now();t.unstable_now=function(){return a.now()-s}}var c=[],l=[],f=1,u=null,d=3,h=!1,g=!1,p=!1,v=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 w(A){for(var F=r(l);F!==null;){if(F.callback===null)n(l);else if(F.startTime<=A)n(l),F.sortIndex=F.expirationTime,e(c,F);else break;F=r(l)}}function x(A){if(p=!1,w(A),!g)if(r(c)!==null)g=!0,B(C);else{var F=r(l);F!==null&&H(x,F.startTime-A)}}function C(A,F){g=!1,p&&(p=!1,y(_),_=-1),h=!0;var G=d;try{for(w(F),u=r(c);u!==null&&(!(u.expirationTime>F)||A&&!D());){var X=u.callback;if(typeof X=="function"){u.callback=null,d=u.priorityLevel;var ee=X(u.expirationTime<=F);F=t.unstable_now(),typeof ee=="function"?u.callback=ee:u===r(c)&&n(c),w(F)}else n(c);u=r(c)}if(u!==null)var ce=!0;else{var Se=r(l);Se!==null&&H(x,Se.startTime-F),ce=!1}return ce}finally{u=null,d=G,h=!1}}var S=!1,T=null,_=-1,E=5,b=-1;function D(){return!(t.unstable_now()-b<E)}function I(){if(T!==null){var A=t.unstable_now();b=A;var F=!0;try{F=T(!0,A)}finally{F?P():(S=!1,T=null)}}else S=!1}var P;if(typeof m=="function")P=function(){m(I)};else if(typeof MessageChannel<"u"){var O=new MessageChannel,L=O.port2;O.port1.onmessage=I,P=function(){L.postMessage(null)}}else P=function(){v(I,0)};function B(A){T=A,S||(S=!0,P())}function H(A,F){_=v(function(){A(t.unstable_now())},F)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(A){A.callback=null},t.unstable_continueExecution=function(){g||h||(g=!0,B(C))},t.unstable_forceFrameRate=function(A){0>A||125<A?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):E=0<A?Math.floor(1e3/A):5},t.unstable_getCurrentPriorityLevel=function(){return d},t.unstable_getFirstCallbackNode=function(){return r(c)},t.unstable_next=function(A){switch(d){case 1:case 2:case 3:var F=3;break;default:F=d}var G=d;d=F;try{return A()}finally{d=G}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(A,F){switch(A){case 1:case 2:case 3:case 4:case 5:break;default:A=3}var G=d;d=A;try{return F()}finally{d=G}},t.unstable_scheduleCallback=function(A,F,G){var X=t.unstable_now();switch(typeof G=="object"&&G!==null?(G=G.delay,G=typeof G=="number"&&0<G?X+G:X):G=X,A){case 1:var ee=-1;break;case 2:ee=250;break;case 5:ee=1073741823;break;case 4:ee=1e4;break;default:ee=5e3}return ee=G+ee,A={id:f++,callback:F,priorityLevel:A,startTime:G,expirationTime:ee,sortIndex:-1},G>X?(A.sortIndex=G,e(l,A),r(c)===null&&A===r(l)&&(p?(y(_),_=-1):p=!0,H(x,G-X))):(A.sortIndex=ee,e(c,A),g||h||(g=!0,B(C))),A},t.unstable_shouldYield=D,t.unstable_wrapCallback=function(A){var F=d;return function(){var G=d;d=F;try{return A.apply(this,arguments)}finally{d=G}}}})(mO);pO.exports=mO;var $$=pO.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 j$=st,Ba=$$;function gt(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,r=1;r<arguments.length;r++)e+="&args[]="+encodeURIComponent(arguments[r]);return"Minified React error #"+t+"; visit "+e+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var vO=new Set,Gp={};function Nd(t,e){fh(t,e),fh(t+"Capture",e)}function fh(t,e){for(Gp[t]=e,t=0;t<e.length;t++)vO.add(e[t])}var ql=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),n3=Object.prototype.hasOwnProperty,H$=/^[: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]*$/,_b={},Eb={};function K$(t){return n3.call(Eb,t)?!0:n3.call(_b,t)?!1:H$.test(t)?Eb[t]=!0:(_b[t]=!0,!1)}function q$(t,e,r,n){if(r!==null&&r.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return n?!1:r!==null?!r.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function X$(t,e,r,n){if(e===null||typeof e>"u"||q$(t,e,r,n))return!0;if(n)return!1;if(r!==null)switch(r.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 Zo(t,e,r,n,i,o,a){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=n,this.attributeNamespace=i,this.mustUseProperty=r,this.propertyName=t,this.type=e,this.sanitizeURL=o,this.removeEmptyString=a}var co={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){co[t]=new Zo(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];co[e]=new Zo(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){co[t]=new Zo(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){co[t]=new Zo(t,2,!1,t,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(t){co[t]=new Zo(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){co[t]=new Zo(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){co[t]=new Zo(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){co[t]=new Zo(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){co[t]=new Zo(t,5,!1,t.toLowerCase(),null,!1,!1)});var VT=/[\-:]([a-z])/g;function FT(t){return t[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(t){var e=t.replace(VT,FT);co[e]=new Zo(e,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(VT,FT);co[e]=new Zo(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(VT,FT);co[e]=new Zo(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){co[t]=new Zo(t,1,!1,t.toLowerCase(),null,!1,!1)});co.xlinkHref=new Zo("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){co[t]=new Zo(t,1,!1,t.toLowerCase(),null,!0,!0)});function UT(t,e,r,n){var i=co.hasOwnProperty(e)?co[e]:null;(i!==null?i.type!==0:n||!(2<e.length)||e[0]!=="o"&&e[0]!=="O"||e[1]!=="n"&&e[1]!=="N")&&(X$(e,r,i,n)&&(r=null),n||i===null?K$(e)&&(r===null?t.removeAttribute(e):t.setAttribute(e,""+r)):i.mustUseProperty?t[i.propertyName]=r===null?i.type===3?!1:"":r:(e=i.attributeName,n=i.attributeNamespace,r===null?t.removeAttribute(e):(i=i.type,r=i===3||i===4&&r===!0?"":""+r,n?t.setAttributeNS(n,e,r):t.setAttribute(e,r))))}var cu=j$.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,km=Symbol.for("react.element"),u0=Symbol.for("react.portal"),f0=Symbol.for("react.fragment"),BT=Symbol.for("react.strict_mode"),r3=Symbol.for("react.profiler"),yO=Symbol.for("react.provider"),wO=Symbol.for("react.context"),GT=Symbol.for("react.forward_ref"),i3=Symbol.for("react.suspense"),o3=Symbol.for("react.suspense_list"),WT=Symbol.for("react.memo"),_u=Symbol.for("react.lazy"),xO=Symbol.for("react.offscreen"),bb=Symbol.iterator;function dg(t){return t===null||typeof t!="object"?null:(t=bb&&t[bb]||t["@@iterator"],typeof t=="function"?t:null)}var qr=Object.assign,ux;function Bg(t){if(ux===void 0)try{throw Error()}catch(r){var e=r.stack.trim().match(/\n( *(at )?)/);ux=e&&e[1]||""}return`
|
||
`+ux+t}var fx=!1;function dx(t,e){if(!t||fx)return"";fx=!0;var r=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(e)if(e=function(){throw Error()},Object.defineProperty(e.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(e,[])}catch(l){var n=l}Reflect.construct(t,[],e)}else{try{e.call()}catch(l){n=l}t.call(e.prototype)}else{try{throw Error()}catch(l){n=l}t()}}catch(l){if(l&&n&&typeof l.stack=="string"){for(var i=l.stack.split(`
|
||
`),o=n.stack.split(`
|
||
`),a=i.length-1,s=o.length-1;1<=a&&0<=s&&i[a]!==o[s];)s--;for(;1<=a&&0<=s;a--,s--)if(i[a]!==o[s]){if(a!==1||s!==1)do if(a--,s--,0>s||i[a]!==o[s]){var c=`
|
||
`+i[a].replace(" at new "," at ");return t.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",t.displayName)),c}while(1<=a&&0<=s);break}}}finally{fx=!1,Error.prepareStackTrace=r}return(t=t?t.displayName||t.name:"")?Bg(t):""}function Y$(t){switch(t.tag){case 5:return Bg(t.type);case 16:return Bg("Lazy");case 13:return Bg("Suspense");case 19:return Bg("SuspenseList");case 0:case 2:case 15:return t=dx(t.type,!1),t;case 11:return t=dx(t.type.render,!1),t;case 1:return t=dx(t.type,!0),t;default:return""}}function a3(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case f0:return"Fragment";case u0:return"Portal";case r3:return"Profiler";case BT:return"StrictMode";case i3:return"Suspense";case o3:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case wO:return(t.displayName||"Context")+".Consumer";case yO:return(t._context.displayName||"Context")+".Provider";case GT:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case WT:return e=t.displayName||null,e!==null?e:a3(t.type)||"Memo";case _u:e=t._payload,t=t._init;try{return a3(t(e))}catch{}}return null}function J$(t){var e=t.type;switch(t.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 t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return a3(e);case 8:return e===BT?"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 tf(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function CO(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function Z$(t){var e=CO(t)?"checked":"value",r=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),n=""+t[e];if(!t.hasOwnProperty(e)&&typeof r<"u"&&typeof r.get=="function"&&typeof r.set=="function"){var i=r.get,o=r.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return i.call(this)},set:function(a){n=""+a,o.call(this,a)}}),Object.defineProperty(t,e,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(a){n=""+a},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function Vm(t){t._valueTracker||(t._valueTracker=Z$(t))}function SO(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var r=e.getValue(),n="";return t&&(n=CO(t)?t.checked?"true":"false":t.value),t=n,t!==r?(e.setValue(t),!0):!1}function Wv(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function s3(t,e){var r=e.checked;return qr({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:r??t._wrapperState.initialChecked})}function Db(t,e){var r=e.defaultValue==null?"":e.defaultValue,n=e.checked!=null?e.checked:e.defaultChecked;r=tf(e.value!=null?e.value:r),t._wrapperState={initialChecked:n,initialValue:r,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function TO(t,e){e=e.checked,e!=null&&UT(t,"checked",e,!1)}function c3(t,e){TO(t,e);var r=tf(e.value),n=e.type;if(r!=null)n==="number"?(r===0&&t.value===""||t.value!=r)&&(t.value=""+r):t.value!==""+r&&(t.value=""+r);else if(n==="submit"||n==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?l3(t,e.type,r):e.hasOwnProperty("defaultValue")&&l3(t,e.type,tf(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function Ib(t,e,r){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var n=e.type;if(!(n!=="submit"&&n!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,r||e===t.value||(t.value=e),t.defaultValue=e}r=t.name,r!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,r!==""&&(t.name=r)}function l3(t,e,r){(e!=="number"||Wv(t.ownerDocument)!==t)&&(r==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+r&&(t.defaultValue=""+r))}var Gg=Array.isArray;function G0(t,e,r,n){if(t=t.options,e){e={};for(var i=0;i<r.length;i++)e["$"+r[i]]=!0;for(r=0;r<t.length;r++)i=e.hasOwnProperty("$"+t[r].value),t[r].selected!==i&&(t[r].selected=i),i&&n&&(t[r].defaultSelected=!0)}else{for(r=""+tf(r),e=null,i=0;i<t.length;i++){if(t[i].value===r){t[i].selected=!0,n&&(t[i].defaultSelected=!0);return}e!==null||t[i].disabled||(e=t[i])}e!==null&&(e.selected=!0)}}function u3(t,e){if(e.dangerouslySetInnerHTML!=null)throw Error(gt(91));return qr({},e,{value:void 0,defaultValue:void 0,children:""+t._wrapperState.initialValue})}function Ob(t,e){var r=e.value;if(r==null){if(r=e.children,e=e.defaultValue,r!=null){if(e!=null)throw Error(gt(92));if(Gg(r)){if(1<r.length)throw Error(gt(93));r=r[0]}e=r}e==null&&(e=""),r=e}t._wrapperState={initialValue:tf(r)}}function _O(t,e){var r=tf(e.value),n=tf(e.defaultValue);r!=null&&(r=""+r,r!==t.value&&(t.value=r),e.defaultValue==null&&t.defaultValue!==r&&(t.defaultValue=r)),n!=null&&(t.defaultValue=""+n)}function Mb(t){var e=t.textContent;e===t._wrapperState.initialValue&&e!==""&&e!==null&&(t.value=e)}function EO(t){switch(t){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function f3(t,e){return t==null||t==="http://www.w3.org/1999/xhtml"?EO(e):t==="http://www.w3.org/2000/svg"&&e==="foreignObject"?"http://www.w3.org/1999/xhtml":t}var Fm,bO=function(t){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(e,r,n,i){MSApp.execUnsafeLocalFunction(function(){return t(e,r,n,i)})}:t}(function(t,e){if(t.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in t)t.innerHTML=e;else{for(Fm=Fm||document.createElement("div"),Fm.innerHTML="<svg>"+e.valueOf().toString()+"</svg>",e=Fm.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function Wp(t,e){if(e){var r=t.firstChild;if(r&&r===t.lastChild&&r.nodeType===3){r.nodeValue=e;return}}t.textContent=e}var ap={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},Q$=["Webkit","ms","Moz","O"];Object.keys(ap).forEach(function(t){Q$.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),ap[e]=ap[t]})});function DO(t,e,r){return e==null||typeof e=="boolean"||e===""?"":r||typeof e!="number"||e===0||ap.hasOwnProperty(t)&&ap[t]?(""+e).trim():e+"px"}function IO(t,e){t=t.style;for(var r in e)if(e.hasOwnProperty(r)){var n=r.indexOf("--")===0,i=DO(r,e[r],n);r==="float"&&(r="cssFloat"),n?t.setProperty(r,i):t[r]=i}}var ej=qr({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 d3(t,e){if(e){if(ej[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(gt(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(gt(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(gt(61))}if(e.style!=null&&typeof e.style!="object")throw Error(gt(62))}}function h3(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){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 g3=null;function zT(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var p3=null,W0=null,z0=null;function Pb(t){if(t=H1(t)){if(typeof p3!="function")throw Error(gt(280));var e=t.stateNode;e&&(e=U5(e),p3(t.stateNode,t.type,e))}}function OO(t){W0?z0?z0.push(t):z0=[t]:W0=t}function MO(){if(W0){var t=W0,e=z0;if(z0=W0=null,Pb(t),e)for(t=0;t<e.length;t++)Pb(e[t])}}function PO(t,e){return t(e)}function RO(){}var hx=!1;function LO(t,e,r){if(hx)return t(e,r);hx=!0;try{return PO(t,e,r)}finally{hx=!1,(W0!==null||z0!==null)&&(RO(),MO())}}function zp(t,e){var r=t.stateNode;if(r===null)return null;var n=U5(r);if(n===null)return null;r=n[e];e:switch(e){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(n=!n.disabled)||(t=t.type,n=!(t==="button"||t==="input"||t==="select"||t==="textarea")),t=!n;break e;default:t=!1}if(t)return null;if(r&&typeof r!="function")throw Error(gt(231,e,typeof r));return r}var m3=!1;if(ql)try{var hg={};Object.defineProperty(hg,"passive",{get:function(){m3=!0}}),window.addEventListener("test",hg,hg),window.removeEventListener("test",hg,hg)}catch{m3=!1}function tj(t,e,r,n,i,o,a,s,c){var l=Array.prototype.slice.call(arguments,3);try{e.apply(r,l)}catch(f){this.onError(f)}}var sp=!1,zv=null,$v=!1,v3=null,nj={onError:function(t){sp=!0,zv=t}};function rj(t,e,r,n,i,o,a,s,c){sp=!1,zv=null,tj.apply(nj,arguments)}function ij(t,e,r,n,i,o,a,s,c){if(rj.apply(this,arguments),sp){if(sp){var l=zv;sp=!1,zv=null}else throw Error(gt(198));$v||($v=!0,v3=l)}}function kd(t){var e=t,r=t;if(t.alternate)for(;e.return;)e=e.return;else{t=e;do e=t,e.flags&4098&&(r=e.return),t=e.return;while(t)}return e.tag===3?r:null}function AO(t){if(t.tag===13){var e=t.memoizedState;if(e===null&&(t=t.alternate,t!==null&&(e=t.memoizedState)),e!==null)return e.dehydrated}return null}function Rb(t){if(kd(t)!==t)throw Error(gt(188))}function oj(t){var e=t.alternate;if(!e){if(e=kd(t),e===null)throw Error(gt(188));return e!==t?null:t}for(var r=t,n=e;;){var i=r.return;if(i===null)break;var o=i.alternate;if(o===null){if(n=i.return,n!==null){r=n;continue}break}if(i.child===o.child){for(o=i.child;o;){if(o===r)return Rb(i),t;if(o===n)return Rb(i),e;o=o.sibling}throw Error(gt(188))}if(r.return!==n.return)r=i,n=o;else{for(var a=!1,s=i.child;s;){if(s===r){a=!0,r=i,n=o;break}if(s===n){a=!0,n=i,r=o;break}s=s.sibling}if(!a){for(s=o.child;s;){if(s===r){a=!0,r=o,n=i;break}if(s===n){a=!0,n=o,r=i;break}s=s.sibling}if(!a)throw Error(gt(189))}}if(r.alternate!==n)throw Error(gt(190))}if(r.tag!==3)throw Error(gt(188));return r.stateNode.current===r?t:e}function NO(t){return t=oj(t),t!==null?kO(t):null}function kO(t){if(t.tag===5||t.tag===6)return t;for(t=t.child;t!==null;){var e=kO(t);if(e!==null)return e;t=t.sibling}return null}var VO=Ba.unstable_scheduleCallback,Lb=Ba.unstable_cancelCallback,aj=Ba.unstable_shouldYield,sj=Ba.unstable_requestPaint,li=Ba.unstable_now,cj=Ba.unstable_getCurrentPriorityLevel,$T=Ba.unstable_ImmediatePriority,FO=Ba.unstable_UserBlockingPriority,jv=Ba.unstable_NormalPriority,lj=Ba.unstable_LowPriority,UO=Ba.unstable_IdlePriority,N5=null,$c=null;function uj(t){if($c&&typeof $c.onCommitFiberRoot=="function")try{$c.onCommitFiberRoot(N5,t,void 0,(t.current.flags&128)===128)}catch{}}var ac=Math.clz32?Math.clz32:hj,fj=Math.log,dj=Math.LN2;function hj(t){return t>>>=0,t===0?32:31-(fj(t)/dj|0)|0}var Um=64,Bm=4194304;function Wg(t){switch(t&-t){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 t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function Hv(t,e){var r=t.pendingLanes;if(r===0)return 0;var n=0,i=t.suspendedLanes,o=t.pingedLanes,a=r&268435455;if(a!==0){var s=a&~i;s!==0?n=Wg(s):(o&=a,o!==0&&(n=Wg(o)))}else a=r&~i,a!==0?n=Wg(a):o!==0&&(n=Wg(o));if(n===0)return 0;if(e!==0&&e!==n&&!(e&i)&&(i=n&-n,o=e&-e,i>=o||i===16&&(o&4194240)!==0))return e;if(n&4&&(n|=r&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=n;0<e;)r=31-ac(e),i=1<<r,n|=t[r],e&=~i;return n}function gj(t,e){switch(t){case 1:case 2:case 4:return e+250;case 8:case 16:case 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 e+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function pj(t,e){for(var r=t.suspendedLanes,n=t.pingedLanes,i=t.expirationTimes,o=t.pendingLanes;0<o;){var a=31-ac(o),s=1<<a,c=i[a];c===-1?(!(s&r)||s&n)&&(i[a]=gj(s,e)):c<=e&&(t.expiredLanes|=s),o&=~s}}function y3(t){return t=t.pendingLanes&-1073741825,t!==0?t:t&1073741824?1073741824:0}function BO(){var t=Um;return Um<<=1,!(Um&4194240)&&(Um=64),t}function gx(t){for(var e=[],r=0;31>r;r++)e.push(t);return e}function $1(t,e,r){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-ac(e),t[e]=r}function mj(t,e){var r=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var n=t.eventTimes;for(t=t.expirationTimes;0<r;){var i=31-ac(r),o=1<<i;e[i]=0,n[i]=-1,t[i]=-1,r&=~o}}function jT(t,e){var r=t.entangledLanes|=e;for(t=t.entanglements;r;){var n=31-ac(r),i=1<<n;i&e|t[n]&e&&(t[n]|=e),r&=~i}}var nr=0;function GO(t){return t&=-t,1<t?4<t?t&268435455?16:536870912:4:1}var WO,HT,zO,$O,jO,w3=!1,Gm=[],Wu=null,zu=null,$u=null,$p=new Map,jp=new Map,Ou=[],vj="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Ab(t,e){switch(t){case"focusin":case"focusout":Wu=null;break;case"dragenter":case"dragleave":zu=null;break;case"mouseover":case"mouseout":$u=null;break;case"pointerover":case"pointerout":$p.delete(e.pointerId);break;case"gotpointercapture":case"lostpointercapture":jp.delete(e.pointerId)}}function gg(t,e,r,n,i,o){return t===null||t.nativeEvent!==o?(t={blockedOn:e,domEventName:r,eventSystemFlags:n,nativeEvent:o,targetContainers:[i]},e!==null&&(e=H1(e),e!==null&&HT(e)),t):(t.eventSystemFlags|=n,e=t.targetContainers,i!==null&&e.indexOf(i)===-1&&e.push(i),t)}function yj(t,e,r,n,i){switch(e){case"focusin":return Wu=gg(Wu,t,e,r,n,i),!0;case"dragenter":return zu=gg(zu,t,e,r,n,i),!0;case"mouseover":return $u=gg($u,t,e,r,n,i),!0;case"pointerover":var o=i.pointerId;return $p.set(o,gg($p.get(o)||null,t,e,r,n,i)),!0;case"gotpointercapture":return o=i.pointerId,jp.set(o,gg(jp.get(o)||null,t,e,r,n,i)),!0}return!1}function HO(t){var e=Qf(t.target);if(e!==null){var r=kd(e);if(r!==null){if(e=r.tag,e===13){if(e=AO(r),e!==null){t.blockedOn=e,jO(t.priority,function(){zO(r)});return}}else if(e===3&&r.stateNode.current.memoizedState.isDehydrated){t.blockedOn=r.tag===3?r.stateNode.containerInfo:null;return}}}t.blockedOn=null}function rv(t){if(t.blockedOn!==null)return!1;for(var e=t.targetContainers;0<e.length;){var r=x3(t.domEventName,t.eventSystemFlags,e[0],t.nativeEvent);if(r===null){r=t.nativeEvent;var n=new r.constructor(r.type,r);g3=n,r.target.dispatchEvent(n),g3=null}else return e=H1(r),e!==null&&HT(e),t.blockedOn=r,!1;e.shift()}return!0}function Nb(t,e,r){rv(t)&&r.delete(e)}function wj(){w3=!1,Wu!==null&&rv(Wu)&&(Wu=null),zu!==null&&rv(zu)&&(zu=null),$u!==null&&rv($u)&&($u=null),$p.forEach(Nb),jp.forEach(Nb)}function pg(t,e){t.blockedOn===e&&(t.blockedOn=null,w3||(w3=!0,Ba.unstable_scheduleCallback(Ba.unstable_NormalPriority,wj)))}function Hp(t){function e(i){return pg(i,t)}if(0<Gm.length){pg(Gm[0],t);for(var r=1;r<Gm.length;r++){var n=Gm[r];n.blockedOn===t&&(n.blockedOn=null)}}for(Wu!==null&&pg(Wu,t),zu!==null&&pg(zu,t),$u!==null&&pg($u,t),$p.forEach(e),jp.forEach(e),r=0;r<Ou.length;r++)n=Ou[r],n.blockedOn===t&&(n.blockedOn=null);for(;0<Ou.length&&(r=Ou[0],r.blockedOn===null);)HO(r),r.blockedOn===null&&Ou.shift()}var $0=cu.ReactCurrentBatchConfig,Kv=!0;function xj(t,e,r,n){var i=nr,o=$0.transition;$0.transition=null;try{nr=1,KT(t,e,r,n)}finally{nr=i,$0.transition=o}}function Cj(t,e,r,n){var i=nr,o=$0.transition;$0.transition=null;try{nr=4,KT(t,e,r,n)}finally{nr=i,$0.transition=o}}function KT(t,e,r,n){if(Kv){var i=x3(t,e,r,n);if(i===null)_x(t,e,n,qv,r),Ab(t,n);else if(yj(i,t,e,r,n))n.stopPropagation();else if(Ab(t,n),e&4&&-1<vj.indexOf(t)){for(;i!==null;){var o=H1(i);if(o!==null&&WO(o),o=x3(t,e,r,n),o===null&&_x(t,e,n,qv,r),o===i)break;i=o}i!==null&&n.stopPropagation()}else _x(t,e,n,null,r)}}var qv=null;function x3(t,e,r,n){if(qv=null,t=zT(n),t=Qf(t),t!==null)if(e=kd(t),e===null)t=null;else if(r=e.tag,r===13){if(t=AO(e),t!==null)return t;t=null}else if(r===3){if(e.stateNode.current.memoizedState.isDehydrated)return e.tag===3?e.stateNode.containerInfo:null;t=null}else e!==t&&(t=null);return qv=t,null}function KO(t){switch(t){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(cj()){case $T:return 1;case FO:return 4;case jv:case lj:return 16;case UO:return 536870912;default:return 16}default:return 16}}var Lu=null,qT=null,iv=null;function qO(){if(iv)return iv;var t,e=qT,r=e.length,n,i="value"in Lu?Lu.value:Lu.textContent,o=i.length;for(t=0;t<r&&e[t]===i[t];t++);var a=r-t;for(n=1;n<=a&&e[r-n]===i[o-n];n++);return iv=i.slice(t,1<n?1-n:void 0)}function ov(t){var e=t.keyCode;return"charCode"in t?(t=t.charCode,t===0&&e===13&&(t=13)):t=e,t===10&&(t=13),32<=t||t===13?t:0}function Wm(){return!0}function kb(){return!1}function ja(t){function e(r,n,i,o,a){this._reactName=r,this._targetInst=i,this.type=n,this.nativeEvent=o,this.target=a,this.currentTarget=null;for(var s in t)t.hasOwnProperty(s)&&(r=t[s],this[s]=r?r(o):o[s]);return this.isDefaultPrevented=(o.defaultPrevented!=null?o.defaultPrevented:o.returnValue===!1)?Wm:kb,this.isPropagationStopped=kb,this}return qr(e.prototype,{preventDefault:function(){this.defaultPrevented=!0;var r=this.nativeEvent;r&&(r.preventDefault?r.preventDefault():typeof r.returnValue!="unknown"&&(r.returnValue=!1),this.isDefaultPrevented=Wm)},stopPropagation:function(){var r=this.nativeEvent;r&&(r.stopPropagation?r.stopPropagation():typeof r.cancelBubble!="unknown"&&(r.cancelBubble=!0),this.isPropagationStopped=Wm)},persist:function(){},isPersistent:Wm}),e}var Vh={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(t){return t.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},XT=ja(Vh),j1=qr({},Vh,{view:0,detail:0}),Sj=ja(j1),px,mx,mg,k5=qr({},j1,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:YT,button:0,buttons:0,relatedTarget:function(t){return t.relatedTarget===void 0?t.fromElement===t.srcElement?t.toElement:t.fromElement:t.relatedTarget},movementX:function(t){return"movementX"in t?t.movementX:(t!==mg&&(mg&&t.type==="mousemove"?(px=t.screenX-mg.screenX,mx=t.screenY-mg.screenY):mx=px=0,mg=t),px)},movementY:function(t){return"movementY"in t?t.movementY:mx}}),Vb=ja(k5),Tj=qr({},k5,{dataTransfer:0}),_j=ja(Tj),Ej=qr({},j1,{relatedTarget:0}),vx=ja(Ej),bj=qr({},Vh,{animationName:0,elapsedTime:0,pseudoElement:0}),Dj=ja(bj),Ij=qr({},Vh,{clipboardData:function(t){return"clipboardData"in t?t.clipboardData:window.clipboardData}}),Oj=ja(Ij),Mj=qr({},Vh,{data:0}),Fb=ja(Mj),Pj={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Rj={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},Lj={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Aj(t){var e=this.nativeEvent;return e.getModifierState?e.getModifierState(t):(t=Lj[t])?!!e[t]:!1}function YT(){return Aj}var Nj=qr({},j1,{key:function(t){if(t.key){var e=Pj[t.key]||t.key;if(e!=="Unidentified")return e}return t.type==="keypress"?(t=ov(t),t===13?"Enter":String.fromCharCode(t)):t.type==="keydown"||t.type==="keyup"?Rj[t.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:YT,charCode:function(t){return t.type==="keypress"?ov(t):0},keyCode:function(t){return t.type==="keydown"||t.type==="keyup"?t.keyCode:0},which:function(t){return t.type==="keypress"?ov(t):t.type==="keydown"||t.type==="keyup"?t.keyCode:0}}),kj=ja(Nj),Vj=qr({},k5,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ub=ja(Vj),Fj=qr({},j1,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:YT}),Uj=ja(Fj),Bj=qr({},Vh,{propertyName:0,elapsedTime:0,pseudoElement:0}),Gj=ja(Bj),Wj=qr({},k5,{deltaX:function(t){return"deltaX"in t?t.deltaX:"wheelDeltaX"in t?-t.wheelDeltaX:0},deltaY:function(t){return"deltaY"in t?t.deltaY:"wheelDeltaY"in t?-t.wheelDeltaY:"wheelDelta"in t?-t.wheelDelta:0},deltaZ:0,deltaMode:0}),zj=ja(Wj),$j=[9,13,27,32],JT=ql&&"CompositionEvent"in window,cp=null;ql&&"documentMode"in document&&(cp=document.documentMode);var jj=ql&&"TextEvent"in window&&!cp,XO=ql&&(!JT||cp&&8<cp&&11>=cp),Bb=" ",Gb=!1;function YO(t,e){switch(t){case"keyup":return $j.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function JO(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var d0=!1;function Hj(t,e){switch(t){case"compositionend":return JO(e);case"keypress":return e.which!==32?null:(Gb=!0,Bb);case"textInput":return t=e.data,t===Bb&&Gb?null:t;default:return null}}function Kj(t,e){if(d0)return t==="compositionend"||!JT&&YO(t,e)?(t=qO(),iv=qT=Lu=null,d0=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1<e.char.length)return e.char;if(e.which)return String.fromCharCode(e.which)}return null;case"compositionend":return XO&&e.locale!=="ko"?null:e.data;default:return null}}var qj={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Wb(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e==="input"?!!qj[t.type]:e==="textarea"}function ZO(t,e,r,n){OO(n),e=Xv(e,"onChange"),0<e.length&&(r=new XT("onChange","change",null,r,n),t.push({event:r,listeners:e}))}var lp=null,Kp=null;function Xj(t){lM(t,0)}function V5(t){var e=p0(t);if(SO(e))return t}function Yj(t,e){if(t==="change")return e}var QO=!1;if(ql){var yx;if(ql){var wx="oninput"in document;if(!wx){var zb=document.createElement("div");zb.setAttribute("oninput","return;"),wx=typeof zb.oninput=="function"}yx=wx}else yx=!1;QO=yx&&(!document.documentMode||9<document.documentMode)}function $b(){lp&&(lp.detachEvent("onpropertychange",eM),Kp=lp=null)}function eM(t){if(t.propertyName==="value"&&V5(Kp)){var e=[];ZO(e,Kp,t,zT(t)),LO(Xj,e)}}function Jj(t,e,r){t==="focusin"?($b(),lp=e,Kp=r,lp.attachEvent("onpropertychange",eM)):t==="focusout"&&$b()}function Zj(t){if(t==="selectionchange"||t==="keyup"||t==="keydown")return V5(Kp)}function Qj(t,e){if(t==="click")return V5(e)}function eH(t,e){if(t==="input"||t==="change")return V5(e)}function tH(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var lc=typeof Object.is=="function"?Object.is:tH;function qp(t,e){if(lc(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;var r=Object.keys(t),n=Object.keys(e);if(r.length!==n.length)return!1;for(n=0;n<r.length;n++){var i=r[n];if(!n3.call(e,i)||!lc(t[i],e[i]))return!1}return!0}function jb(t){for(;t&&t.firstChild;)t=t.firstChild;return t}function Hb(t,e){var r=jb(t);t=0;for(var n;r;){if(r.nodeType===3){if(n=t+r.textContent.length,t<=e&&n>=e)return{node:r,offset:e-t};t=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=jb(r)}}function tM(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?tM(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function nM(){for(var t=window,e=Wv();e instanceof t.HTMLIFrameElement;){try{var r=typeof e.contentWindow.location.href=="string"}catch{r=!1}if(r)t=e.contentWindow;else break;e=Wv(t.document)}return e}function ZT(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function nH(t){var e=nM(),r=t.focusedElem,n=t.selectionRange;if(e!==r&&r&&r.ownerDocument&&tM(r.ownerDocument.documentElement,r)){if(n!==null&&ZT(r)){if(e=n.start,t=n.end,t===void 0&&(t=e),"selectionStart"in r)r.selectionStart=e,r.selectionEnd=Math.min(t,r.value.length);else if(t=(e=r.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var i=r.textContent.length,o=Math.min(n.start,i);n=n.end===void 0?o:Math.min(n.end,i),!t.extend&&o>n&&(i=n,n=o,o=i),i=Hb(r,o);var a=Hb(r,n);i&&a&&(t.rangeCount!==1||t.anchorNode!==i.node||t.anchorOffset!==i.offset||t.focusNode!==a.node||t.focusOffset!==a.offset)&&(e=e.createRange(),e.setStart(i.node,i.offset),t.removeAllRanges(),o>n?(t.addRange(e),t.extend(a.node,a.offset)):(e.setEnd(a.node,a.offset),t.addRange(e)))}}for(e=[],t=r;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof r.focus=="function"&&r.focus(),r=0;r<e.length;r++)t=e[r],t.element.scrollLeft=t.left,t.element.scrollTop=t.top}}var rH=ql&&"documentMode"in document&&11>=document.documentMode,h0=null,C3=null,up=null,S3=!1;function Kb(t,e,r){var n=r.window===r?r.document:r.nodeType===9?r:r.ownerDocument;S3||h0==null||h0!==Wv(n)||(n=h0,"selectionStart"in n&&ZT(n)?n={start:n.selectionStart,end:n.selectionEnd}:(n=(n.ownerDocument&&n.ownerDocument.defaultView||window).getSelection(),n={anchorNode:n.anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset}),up&&qp(up,n)||(up=n,n=Xv(C3,"onSelect"),0<n.length&&(e=new XT("onSelect","select",null,e,r),t.push({event:e,listeners:n}),e.target=h0)))}function zm(t,e){var r={};return r[t.toLowerCase()]=e.toLowerCase(),r["Webkit"+t]="webkit"+e,r["Moz"+t]="moz"+e,r}var g0={animationend:zm("Animation","AnimationEnd"),animationiteration:zm("Animation","AnimationIteration"),animationstart:zm("Animation","AnimationStart"),transitionend:zm("Transition","TransitionEnd")},xx={},rM={};ql&&(rM=document.createElement("div").style,"AnimationEvent"in window||(delete g0.animationend.animation,delete g0.animationiteration.animation,delete g0.animationstart.animation),"TransitionEvent"in window||delete g0.transitionend.transition);function F5(t){if(xx[t])return xx[t];if(!g0[t])return t;var e=g0[t],r;for(r in e)if(e.hasOwnProperty(r)&&r in rM)return xx[t]=e[r];return t}var iM=F5("animationend"),oM=F5("animationiteration"),aM=F5("animationstart"),sM=F5("transitionend"),cM=new Map,qb="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function vf(t,e){cM.set(t,e),Nd(e,[t])}for(var Cx=0;Cx<qb.length;Cx++){var Sx=qb[Cx],iH=Sx.toLowerCase(),oH=Sx[0].toUpperCase()+Sx.slice(1);vf(iH,"on"+oH)}vf(iM,"onAnimationEnd");vf(oM,"onAnimationIteration");vf(aM,"onAnimationStart");vf("dblclick","onDoubleClick");vf("focusin","onFocus");vf("focusout","onBlur");vf(sM,"onTransitionEnd");fh("onMouseEnter",["mouseout","mouseover"]);fh("onMouseLeave",["mouseout","mouseover"]);fh("onPointerEnter",["pointerout","pointerover"]);fh("onPointerLeave",["pointerout","pointerover"]);Nd("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));Nd("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));Nd("onBeforeInput",["compositionend","keypress","textInput","paste"]);Nd("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));Nd("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));Nd("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var zg="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),aH=new Set("cancel close invalid load scroll toggle".split(" ").concat(zg));function Xb(t,e,r){var n=t.type||"unknown-event";t.currentTarget=r,ij(n,e,void 0,t),t.currentTarget=null}function lM(t,e){e=(e&4)!==0;for(var r=0;r<t.length;r++){var n=t[r],i=n.event;n=n.listeners;e:{var o=void 0;if(e)for(var a=n.length-1;0<=a;a--){var s=n[a],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==o&&i.isPropagationStopped())break e;Xb(i,s,l),o=c}else for(a=0;a<n.length;a++){if(s=n[a],c=s.instance,l=s.currentTarget,s=s.listener,c!==o&&i.isPropagationStopped())break e;Xb(i,s,l),o=c}}}if($v)throw t=v3,$v=!1,v3=null,t}function wr(t,e){var r=e[D3];r===void 0&&(r=e[D3]=new Set);var n=t+"__bubble";r.has(n)||(uM(e,t,2,!1),r.add(n))}function Tx(t,e,r){var n=0;e&&(n|=4),uM(r,t,n,e)}var $m="_reactListening"+Math.random().toString(36).slice(2);function Xp(t){if(!t[$m]){t[$m]=!0,vO.forEach(function(r){r!=="selectionchange"&&(aH.has(r)||Tx(r,!1,t),Tx(r,!0,t))});var e=t.nodeType===9?t:t.ownerDocument;e===null||e[$m]||(e[$m]=!0,Tx("selectionchange",!1,e))}}function uM(t,e,r,n){switch(KO(e)){case 1:var i=xj;break;case 4:i=Cj;break;default:i=KT}r=i.bind(null,e,r,t),i=void 0,!m3||e!=="touchstart"&&e!=="touchmove"&&e!=="wheel"||(i=!0),n?i!==void 0?t.addEventListener(e,r,{capture:!0,passive:i}):t.addEventListener(e,r,!0):i!==void 0?t.addEventListener(e,r,{passive:i}):t.addEventListener(e,r,!1)}function _x(t,e,r,n,i){var o=n;if(!(e&1)&&!(e&2)&&n!==null)e:for(;;){if(n===null)return;var a=n.tag;if(a===3||a===4){var s=n.stateNode.containerInfo;if(s===i||s.nodeType===8&&s.parentNode===i)break;if(a===4)for(a=n.return;a!==null;){var c=a.tag;if((c===3||c===4)&&(c=a.stateNode.containerInfo,c===i||c.nodeType===8&&c.parentNode===i))return;a=a.return}for(;s!==null;){if(a=Qf(s),a===null)return;if(c=a.tag,c===5||c===6){n=o=a;continue e}s=s.parentNode}}n=n.return}LO(function(){var l=o,f=zT(r),u=[];e:{var d=cM.get(t);if(d!==void 0){var h=XT,g=t;switch(t){case"keypress":if(ov(r)===0)break e;case"keydown":case"keyup":h=kj;break;case"focusin":g="focus",h=vx;break;case"focusout":g="blur",h=vx;break;case"beforeblur":case"afterblur":h=vx;break;case"click":if(r.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":h=Vb;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":h=_j;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":h=Uj;break;case iM:case oM:case aM:h=Dj;break;case sM:h=Gj;break;case"scroll":h=Sj;break;case"wheel":h=zj;break;case"copy":case"cut":case"paste":h=Oj;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":h=Ub}var p=(e&4)!==0,v=!p&&t==="scroll",y=p?d!==null?d+"Capture":null:d;p=[];for(var m=l,w;m!==null;){w=m;var x=w.stateNode;if(w.tag===5&&x!==null&&(w=x,y!==null&&(x=zp(m,y),x!=null&&p.push(Yp(m,x,w)))),v)break;m=m.return}0<p.length&&(d=new h(d,g,null,r,f),u.push({event:d,listeners:p}))}}if(!(e&7)){e:{if(d=t==="mouseover"||t==="pointerover",h=t==="mouseout"||t==="pointerout",d&&r!==g3&&(g=r.relatedTarget||r.fromElement)&&(Qf(g)||g[Xl]))break e;if((h||d)&&(d=f.window===f?f:(d=f.ownerDocument)?d.defaultView||d.parentWindow:window,h?(g=r.relatedTarget||r.toElement,h=l,g=g?Qf(g):null,g!==null&&(v=kd(g),g!==v||g.tag!==5&&g.tag!==6)&&(g=null)):(h=null,g=l),h!==g)){if(p=Vb,x="onMouseLeave",y="onMouseEnter",m="mouse",(t==="pointerout"||t==="pointerover")&&(p=Ub,x="onPointerLeave",y="onPointerEnter",m="pointer"),v=h==null?d:p0(h),w=g==null?d:p0(g),d=new p(x,m+"leave",h,r,f),d.target=v,d.relatedTarget=w,x=null,Qf(f)===l&&(p=new p(y,m+"enter",g,r,f),p.target=w,p.relatedTarget=v,x=p),v=x,h&&g)t:{for(p=h,y=g,m=0,w=p;w;w=jd(w))m++;for(w=0,x=y;x;x=jd(x))w++;for(;0<m-w;)p=jd(p),m--;for(;0<w-m;)y=jd(y),w--;for(;m--;){if(p===y||y!==null&&p===y.alternate)break t;p=jd(p),y=jd(y)}p=null}else p=null;h!==null&&Yb(u,d,h,p,!1),g!==null&&v!==null&&Yb(u,v,g,p,!0)}}e:{if(d=l?p0(l):window,h=d.nodeName&&d.nodeName.toLowerCase(),h==="select"||h==="input"&&d.type==="file")var C=Yj;else if(Wb(d))if(QO)C=eH;else{C=Zj;var S=Jj}else(h=d.nodeName)&&h.toLowerCase()==="input"&&(d.type==="checkbox"||d.type==="radio")&&(C=Qj);if(C&&(C=C(t,l))){ZO(u,C,r,f);break e}S&&S(t,d,l),t==="focusout"&&(S=d._wrapperState)&&S.controlled&&d.type==="number"&&l3(d,"number",d.value)}switch(S=l?p0(l):window,t){case"focusin":(Wb(S)||S.contentEditable==="true")&&(h0=S,C3=l,up=null);break;case"focusout":up=C3=h0=null;break;case"mousedown":S3=!0;break;case"contextmenu":case"mouseup":case"dragend":S3=!1,Kb(u,r,f);break;case"selectionchange":if(rH)break;case"keydown":case"keyup":Kb(u,r,f)}var T;if(JT)e:{switch(t){case"compositionstart":var _="onCompositionStart";break e;case"compositionend":_="onCompositionEnd";break e;case"compositionupdate":_="onCompositionUpdate";break e}_=void 0}else d0?YO(t,r)&&(_="onCompositionEnd"):t==="keydown"&&r.keyCode===229&&(_="onCompositionStart");_&&(XO&&r.locale!=="ko"&&(d0||_!=="onCompositionStart"?_==="onCompositionEnd"&&d0&&(T=qO()):(Lu=f,qT="value"in Lu?Lu.value:Lu.textContent,d0=!0)),S=Xv(l,_),0<S.length&&(_=new Fb(_,t,null,r,f),u.push({event:_,listeners:S}),T?_.data=T:(T=JO(r),T!==null&&(_.data=T)))),(T=jj?Hj(t,r):Kj(t,r))&&(l=Xv(l,"onBeforeInput"),0<l.length&&(f=new Fb("onBeforeInput","beforeinput",null,r,f),u.push({event:f,listeners:l}),f.data=T))}lM(u,e)})}function Yp(t,e,r){return{instance:t,listener:e,currentTarget:r}}function Xv(t,e){for(var r=e+"Capture",n=[];t!==null;){var i=t,o=i.stateNode;i.tag===5&&o!==null&&(i=o,o=zp(t,r),o!=null&&n.unshift(Yp(t,o,i)),o=zp(t,e),o!=null&&n.push(Yp(t,o,i))),t=t.return}return n}function jd(t){if(t===null)return null;do t=t.return;while(t&&t.tag!==5);return t||null}function Yb(t,e,r,n,i){for(var o=e._reactName,a=[];r!==null&&r!==n;){var s=r,c=s.alternate,l=s.stateNode;if(c!==null&&c===n)break;s.tag===5&&l!==null&&(s=l,i?(c=zp(r,o),c!=null&&a.unshift(Yp(r,c,s))):i||(c=zp(r,o),c!=null&&a.push(Yp(r,c,s)))),r=r.return}a.length!==0&&t.push({event:e,listeners:a})}var sH=/\r\n?/g,cH=/\u0000|\uFFFD/g;function Jb(t){return(typeof t=="string"?t:""+t).replace(sH,`
|
||
`).replace(cH,"")}function jm(t,e,r){if(e=Jb(e),Jb(t)!==e&&r)throw Error(gt(425))}function Yv(){}var T3=null,_3=null;function E3(t,e){return t==="textarea"||t==="noscript"||typeof e.children=="string"||typeof e.children=="number"||typeof e.dangerouslySetInnerHTML=="object"&&e.dangerouslySetInnerHTML!==null&&e.dangerouslySetInnerHTML.__html!=null}var b3=typeof setTimeout=="function"?setTimeout:void 0,lH=typeof clearTimeout=="function"?clearTimeout:void 0,Zb=typeof Promise=="function"?Promise:void 0,uH=typeof queueMicrotask=="function"?queueMicrotask:typeof Zb<"u"?function(t){return Zb.resolve(null).then(t).catch(fH)}:b3;function fH(t){setTimeout(function(){throw t})}function Ex(t,e){var r=e,n=0;do{var i=r.nextSibling;if(t.removeChild(r),i&&i.nodeType===8)if(r=i.data,r==="/$"){if(n===0){t.removeChild(i),Hp(e);return}n--}else r!=="$"&&r!=="$?"&&r!=="$!"||n++;r=i}while(r);Hp(e)}function ju(t){for(;t!=null;t=t.nextSibling){var e=t.nodeType;if(e===1||e===3)break;if(e===8){if(e=t.data,e==="$"||e==="$!"||e==="$?")break;if(e==="/$")return null}}return t}function Qb(t){t=t.previousSibling;for(var e=0;t;){if(t.nodeType===8){var r=t.data;if(r==="$"||r==="$!"||r==="$?"){if(e===0)return t;e--}else r==="/$"&&e++}t=t.previousSibling}return null}var Fh=Math.random().toString(36).slice(2),Gc="__reactFiber$"+Fh,Jp="__reactProps$"+Fh,Xl="__reactContainer$"+Fh,D3="__reactEvents$"+Fh,dH="__reactListeners$"+Fh,hH="__reactHandles$"+Fh;function Qf(t){var e=t[Gc];if(e)return e;for(var r=t.parentNode;r;){if(e=r[Xl]||r[Gc]){if(r=e.alternate,e.child!==null||r!==null&&r.child!==null)for(t=Qb(t);t!==null;){if(r=t[Gc])return r;t=Qb(t)}return e}t=r,r=t.parentNode}return null}function H1(t){return t=t[Gc]||t[Xl],!t||t.tag!==5&&t.tag!==6&&t.tag!==13&&t.tag!==3?null:t}function p0(t){if(t.tag===5||t.tag===6)return t.stateNode;throw Error(gt(33))}function U5(t){return t[Jp]||null}var I3=[],m0=-1;function yf(t){return{current:t}}function Tr(t){0>m0||(t.current=I3[m0],I3[m0]=null,m0--)}function pr(t,e){m0++,I3[m0]=t.current,t.current=e}var nf={},Oo=yf(nf),fa=yf(!1),md=nf;function dh(t,e){var r=t.type.contextTypes;if(!r)return nf;var n=t.stateNode;if(n&&n.__reactInternalMemoizedUnmaskedChildContext===e)return n.__reactInternalMemoizedMaskedChildContext;var i={},o;for(o in r)i[o]=e[o];return n&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=i),i}function da(t){return t=t.childContextTypes,t!=null}function Jv(){Tr(fa),Tr(Oo)}function e6(t,e,r){if(Oo.current!==nf)throw Error(gt(168));pr(Oo,e),pr(fa,r)}function fM(t,e,r){var n=t.stateNode;if(e=e.childContextTypes,typeof n.getChildContext!="function")return r;n=n.getChildContext();for(var i in n)if(!(i in e))throw Error(gt(108,J$(t)||"Unknown",i));return qr({},r,n)}function Zv(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||nf,md=Oo.current,pr(Oo,t),pr(fa,fa.current),!0}function t6(t,e,r){var n=t.stateNode;if(!n)throw Error(gt(169));r?(t=fM(t,e,md),n.__reactInternalMemoizedMergedChildContext=t,Tr(fa),Tr(Oo),pr(Oo,t)):Tr(fa),pr(fa,r)}var Rl=null,B5=!1,bx=!1;function dM(t){Rl===null?Rl=[t]:Rl.push(t)}function gH(t){B5=!0,dM(t)}function wf(){if(!bx&&Rl!==null){bx=!0;var t=0,e=nr;try{var r=Rl;for(nr=1;t<r.length;t++){var n=r[t];do n=n(!0);while(n!==null)}Rl=null,B5=!1}catch(i){throw Rl!==null&&(Rl=Rl.slice(t+1)),VO($T,wf),i}finally{nr=e,bx=!1}}return null}var v0=[],y0=0,Qv=null,ey=0,cs=[],ls=0,vd=null,kl=1,Vl="";function Bf(t,e){v0[y0++]=ey,v0[y0++]=Qv,Qv=t,ey=e}function hM(t,e,r){cs[ls++]=kl,cs[ls++]=Vl,cs[ls++]=vd,vd=t;var n=kl;t=Vl;var i=32-ac(n)-1;n&=~(1<<i),r+=1;var o=32-ac(e)+i;if(30<o){var a=i-i%5;o=(n&(1<<a)-1).toString(32),n>>=a,i-=a,kl=1<<32-ac(e)+i|r<<i|n,Vl=o+t}else kl=1<<o|r<<i|n,Vl=t}function QT(t){t.return!==null&&(Bf(t,1),hM(t,1,0))}function e_(t){for(;t===Qv;)Qv=v0[--y0],v0[y0]=null,ey=v0[--y0],v0[y0]=null;for(;t===vd;)vd=cs[--ls],cs[ls]=null,Vl=cs[--ls],cs[ls]=null,kl=cs[--ls],cs[ls]=null}var Fa=null,Na=null,Rr=!1,Ys=null;function gM(t,e){var r=hs(5,null,null,0);r.elementType="DELETED",r.stateNode=e,r.return=t,e=t.deletions,e===null?(t.deletions=[r],t.flags|=16):e.push(r)}function n6(t,e){switch(t.tag){case 5:var r=t.type;return e=e.nodeType!==1||r.toLowerCase()!==e.nodeName.toLowerCase()?null:e,e!==null?(t.stateNode=e,Fa=t,Na=ju(e.firstChild),!0):!1;case 6:return e=t.pendingProps===""||e.nodeType!==3?null:e,e!==null?(t.stateNode=e,Fa=t,Na=null,!0):!1;case 13:return e=e.nodeType!==8?null:e,e!==null?(r=vd!==null?{id:kl,overflow:Vl}:null,t.memoizedState={dehydrated:e,treeContext:r,retryLane:1073741824},r=hs(18,null,null,0),r.stateNode=e,r.return=t,t.child=r,Fa=t,Na=null,!0):!1;default:return!1}}function O3(t){return(t.mode&1)!==0&&(t.flags&128)===0}function M3(t){if(Rr){var e=Na;if(e){var r=e;if(!n6(t,e)){if(O3(t))throw Error(gt(418));e=ju(r.nextSibling);var n=Fa;e&&n6(t,e)?gM(n,r):(t.flags=t.flags&-4097|2,Rr=!1,Fa=t)}}else{if(O3(t))throw Error(gt(418));t.flags=t.flags&-4097|2,Rr=!1,Fa=t}}}function r6(t){for(t=t.return;t!==null&&t.tag!==5&&t.tag!==3&&t.tag!==13;)t=t.return;Fa=t}function Hm(t){if(t!==Fa)return!1;if(!Rr)return r6(t),Rr=!0,!1;var e;if((e=t.tag!==3)&&!(e=t.tag!==5)&&(e=t.type,e=e!=="head"&&e!=="body"&&!E3(t.type,t.memoizedProps)),e&&(e=Na)){if(O3(t))throw pM(),Error(gt(418));for(;e;)gM(t,e),e=ju(e.nextSibling)}if(r6(t),t.tag===13){if(t=t.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(gt(317));e:{for(t=t.nextSibling,e=0;t;){if(t.nodeType===8){var r=t.data;if(r==="/$"){if(e===0){Na=ju(t.nextSibling);break e}e--}else r!=="$"&&r!=="$!"&&r!=="$?"||e++}t=t.nextSibling}Na=null}}else Na=Fa?ju(t.stateNode.nextSibling):null;return!0}function pM(){for(var t=Na;t;)t=ju(t.nextSibling)}function hh(){Na=Fa=null,Rr=!1}function t_(t){Ys===null?Ys=[t]:Ys.push(t)}var pH=cu.ReactCurrentBatchConfig;function vg(t,e,r){if(t=r.ref,t!==null&&typeof t!="function"&&typeof t!="object"){if(r._owner){if(r=r._owner,r){if(r.tag!==1)throw Error(gt(309));var n=r.stateNode}if(!n)throw Error(gt(147,t));var i=n,o=""+t;return e!==null&&e.ref!==null&&typeof e.ref=="function"&&e.ref._stringRef===o?e.ref:(e=function(a){var s=i.refs;a===null?delete s[o]:s[o]=a},e._stringRef=o,e)}if(typeof t!="string")throw Error(gt(284));if(!r._owner)throw Error(gt(290,t))}return t}function Km(t,e){throw t=Object.prototype.toString.call(e),Error(gt(31,t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t))}function i6(t){var e=t._init;return e(t._payload)}function mM(t){function e(y,m){if(t){var w=y.deletions;w===null?(y.deletions=[m],y.flags|=16):w.push(m)}}function r(y,m){if(!t)return null;for(;m!==null;)e(y,m),m=m.sibling;return null}function n(y,m){for(y=new Map;m!==null;)m.key!==null?y.set(m.key,m):y.set(m.index,m),m=m.sibling;return y}function i(y,m){return y=Xu(y,m),y.index=0,y.sibling=null,y}function o(y,m,w){return y.index=w,t?(w=y.alternate,w!==null?(w=w.index,w<m?(y.flags|=2,m):w):(y.flags|=2,m)):(y.flags|=1048576,m)}function a(y){return t&&y.alternate===null&&(y.flags|=2),y}function s(y,m,w,x){return m===null||m.tag!==6?(m=Lx(w,y.mode,x),m.return=y,m):(m=i(m,w),m.return=y,m)}function c(y,m,w,x){var C=w.type;return C===f0?f(y,m,w.props.children,x,w.key):m!==null&&(m.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===_u&&i6(C)===m.type)?(x=i(m,w.props),x.ref=vg(y,m,w),x.return=y,x):(x=dv(w.type,w.key,w.props,null,y.mode,x),x.ref=vg(y,m,w),x.return=y,x)}function l(y,m,w,x){return m===null||m.tag!==4||m.stateNode.containerInfo!==w.containerInfo||m.stateNode.implementation!==w.implementation?(m=Ax(w,y.mode,x),m.return=y,m):(m=i(m,w.children||[]),m.return=y,m)}function f(y,m,w,x,C){return m===null||m.tag!==7?(m=sd(w,y.mode,x,C),m.return=y,m):(m=i(m,w),m.return=y,m)}function u(y,m,w){if(typeof m=="string"&&m!==""||typeof m=="number")return m=Lx(""+m,y.mode,w),m.return=y,m;if(typeof m=="object"&&m!==null){switch(m.$$typeof){case km:return w=dv(m.type,m.key,m.props,null,y.mode,w),w.ref=vg(y,null,m),w.return=y,w;case u0:return m=Ax(m,y.mode,w),m.return=y,m;case _u:var x=m._init;return u(y,x(m._payload),w)}if(Gg(m)||dg(m))return m=sd(m,y.mode,w,null),m.return=y,m;Km(y,m)}return null}function d(y,m,w,x){var C=m!==null?m.key:null;if(typeof w=="string"&&w!==""||typeof w=="number")return C!==null?null:s(y,m,""+w,x);if(typeof w=="object"&&w!==null){switch(w.$$typeof){case km:return w.key===C?c(y,m,w,x):null;case u0:return w.key===C?l(y,m,w,x):null;case _u:return C=w._init,d(y,m,C(w._payload),x)}if(Gg(w)||dg(w))return C!==null?null:f(y,m,w,x,null);Km(y,w)}return null}function h(y,m,w,x,C){if(typeof x=="string"&&x!==""||typeof x=="number")return y=y.get(w)||null,s(m,y,""+x,C);if(typeof x=="object"&&x!==null){switch(x.$$typeof){case km:return y=y.get(x.key===null?w:x.key)||null,c(m,y,x,C);case u0:return y=y.get(x.key===null?w:x.key)||null,l(m,y,x,C);case _u:var S=x._init;return h(y,m,w,S(x._payload),C)}if(Gg(x)||dg(x))return y=y.get(w)||null,f(m,y,x,C,null);Km(m,x)}return null}function g(y,m,w,x){for(var C=null,S=null,T=m,_=m=0,E=null;T!==null&&_<w.length;_++){T.index>_?(E=T,T=null):E=T.sibling;var b=d(y,T,w[_],x);if(b===null){T===null&&(T=E);break}t&&T&&b.alternate===null&&e(y,T),m=o(b,m,_),S===null?C=b:S.sibling=b,S=b,T=E}if(_===w.length)return r(y,T),Rr&&Bf(y,_),C;if(T===null){for(;_<w.length;_++)T=u(y,w[_],x),T!==null&&(m=o(T,m,_),S===null?C=T:S.sibling=T,S=T);return Rr&&Bf(y,_),C}for(T=n(y,T);_<w.length;_++)E=h(T,y,_,w[_],x),E!==null&&(t&&E.alternate!==null&&T.delete(E.key===null?_:E.key),m=o(E,m,_),S===null?C=E:S.sibling=E,S=E);return t&&T.forEach(function(D){return e(y,D)}),Rr&&Bf(y,_),C}function p(y,m,w,x){var C=dg(w);if(typeof C!="function")throw Error(gt(150));if(w=C.call(w),w==null)throw Error(gt(151));for(var S=C=null,T=m,_=m=0,E=null,b=w.next();T!==null&&!b.done;_++,b=w.next()){T.index>_?(E=T,T=null):E=T.sibling;var D=d(y,T,b.value,x);if(D===null){T===null&&(T=E);break}t&&T&&D.alternate===null&&e(y,T),m=o(D,m,_),S===null?C=D:S.sibling=D,S=D,T=E}if(b.done)return r(y,T),Rr&&Bf(y,_),C;if(T===null){for(;!b.done;_++,b=w.next())b=u(y,b.value,x),b!==null&&(m=o(b,m,_),S===null?C=b:S.sibling=b,S=b);return Rr&&Bf(y,_),C}for(T=n(y,T);!b.done;_++,b=w.next())b=h(T,y,_,b.value,x),b!==null&&(t&&b.alternate!==null&&T.delete(b.key===null?_:b.key),m=o(b,m,_),S===null?C=b:S.sibling=b,S=b);return t&&T.forEach(function(I){return e(y,I)}),Rr&&Bf(y,_),C}function v(y,m,w,x){if(typeof w=="object"&&w!==null&&w.type===f0&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case km:e:{for(var C=w.key,S=m;S!==null;){if(S.key===C){if(C=w.type,C===f0){if(S.tag===7){r(y,S.sibling),m=i(S,w.props.children),m.return=y,y=m;break e}}else if(S.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===_u&&i6(C)===S.type){r(y,S.sibling),m=i(S,w.props),m.ref=vg(y,S,w),m.return=y,y=m;break e}r(y,S);break}else e(y,S);S=S.sibling}w.type===f0?(m=sd(w.props.children,y.mode,x,w.key),m.return=y,y=m):(x=dv(w.type,w.key,w.props,null,y.mode,x),x.ref=vg(y,m,w),x.return=y,y=x)}return a(y);case u0:e:{for(S=w.key;m!==null;){if(m.key===S)if(m.tag===4&&m.stateNode.containerInfo===w.containerInfo&&m.stateNode.implementation===w.implementation){r(y,m.sibling),m=i(m,w.children||[]),m.return=y,y=m;break e}else{r(y,m);break}else e(y,m);m=m.sibling}m=Ax(w,y.mode,x),m.return=y,y=m}return a(y);case _u:return S=w._init,v(y,m,S(w._payload),x)}if(Gg(w))return g(y,m,w,x);if(dg(w))return p(y,m,w,x);Km(y,w)}return typeof w=="string"&&w!==""||typeof w=="number"?(w=""+w,m!==null&&m.tag===6?(r(y,m.sibling),m=i(m,w),m.return=y,y=m):(r(y,m),m=Lx(w,y.mode,x),m.return=y,y=m),a(y)):r(y,m)}return v}var gh=mM(!0),vM=mM(!1),ty=yf(null),ny=null,w0=null,n_=null;function r_(){n_=w0=ny=null}function i_(t){var e=ty.current;Tr(ty),t._currentValue=e}function P3(t,e,r){for(;t!==null;){var n=t.alternate;if((t.childLanes&e)!==e?(t.childLanes|=e,n!==null&&(n.childLanes|=e)):n!==null&&(n.childLanes&e)!==e&&(n.childLanes|=e),t===r)break;t=t.return}}function j0(t,e){ny=t,n_=w0=null,t=t.dependencies,t!==null&&t.firstContext!==null&&(t.lanes&e&&(sa=!0),t.firstContext=null)}function ms(t){var e=t._currentValue;if(n_!==t)if(t={context:t,memoizedValue:e,next:null},w0===null){if(ny===null)throw Error(gt(308));w0=t,ny.dependencies={lanes:0,firstContext:t}}else w0=w0.next=t;return e}var ed=null;function o_(t){ed===null?ed=[t]:ed.push(t)}function yM(t,e,r,n){var i=e.interleaved;return i===null?(r.next=r,o_(e)):(r.next=i.next,i.next=r),e.interleaved=r,Yl(t,n)}function Yl(t,e){t.lanes|=e;var r=t.alternate;for(r!==null&&(r.lanes|=e),r=t,t=t.return;t!==null;)t.childLanes|=e,r=t.alternate,r!==null&&(r.childLanes|=e),r=t,t=t.return;return r.tag===3?r.stateNode:null}var Eu=!1;function a_(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function wM(t,e){t=t.updateQueue,e.updateQueue===t&&(e.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,effects:t.effects})}function zl(t,e){return{eventTime:t,lane:e,tag:0,payload:null,callback:null,next:null}}function Hu(t,e,r){var n=t.updateQueue;if(n===null)return null;if(n=n.shared,zn&2){var i=n.pending;return i===null?e.next=e:(e.next=i.next,i.next=e),n.pending=e,Yl(t,r)}return i=n.interleaved,i===null?(e.next=e,o_(n)):(e.next=i.next,i.next=e),n.interleaved=e,Yl(t,r)}function av(t,e,r){if(e=e.updateQueue,e!==null&&(e=e.shared,(r&4194240)!==0)){var n=e.lanes;n&=t.pendingLanes,r|=n,e.lanes=r,jT(t,r)}}function o6(t,e){var r=t.updateQueue,n=t.alternate;if(n!==null&&(n=n.updateQueue,r===n)){var i=null,o=null;if(r=r.firstBaseUpdate,r!==null){do{var a={eventTime:r.eventTime,lane:r.lane,tag:r.tag,payload:r.payload,callback:r.callback,next:null};o===null?i=o=a:o=o.next=a,r=r.next}while(r!==null);o===null?i=o=e:o=o.next=e}else i=o=e;r={baseState:n.baseState,firstBaseUpdate:i,lastBaseUpdate:o,shared:n.shared,effects:n.effects},t.updateQueue=r;return}t=r.lastBaseUpdate,t===null?r.firstBaseUpdate=e:t.next=e,r.lastBaseUpdate=e}function ry(t,e,r,n){var i=t.updateQueue;Eu=!1;var o=i.firstBaseUpdate,a=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,a===null?o=l:a.next=l,a=c;var f=t.alternate;f!==null&&(f=f.updateQueue,s=f.lastBaseUpdate,s!==a&&(s===null?f.firstBaseUpdate=l:s.next=l,f.lastBaseUpdate=c))}if(o!==null){var u=i.baseState;a=0,f=l=c=null,s=o;do{var d=s.lane,h=s.eventTime;if((n&d)===d){f!==null&&(f=f.next={eventTime:h,lane:0,tag:s.tag,payload:s.payload,callback:s.callback,next:null});e:{var g=t,p=s;switch(d=e,h=r,p.tag){case 1:if(g=p.payload,typeof g=="function"){u=g.call(h,u,d);break e}u=g;break e;case 3:g.flags=g.flags&-65537|128;case 0:if(g=p.payload,d=typeof g=="function"?g.call(h,u,d):g,d==null)break e;u=qr({},u,d);break e;case 2:Eu=!0}}s.callback!==null&&s.lane!==0&&(t.flags|=64,d=i.effects,d===null?i.effects=[s]:d.push(s))}else h={eventTime:h,lane:d,tag:s.tag,payload:s.payload,callback:s.callback,next:null},f===null?(l=f=h,c=u):f=f.next=h,a|=d;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;d=s,s=d.next,d.next=null,i.lastBaseUpdate=d,i.shared.pending=null}}while(!0);if(f===null&&(c=u),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=f,e=i.shared.interleaved,e!==null){i=e;do a|=i.lane,i=i.next;while(i!==e)}else o===null&&(i.shared.lanes=0);wd|=a,t.lanes=a,t.memoizedState=u}}function a6(t,e,r){if(t=e.effects,e.effects=null,t!==null)for(e=0;e<t.length;e++){var n=t[e],i=n.callback;if(i!==null){if(n.callback=null,n=r,typeof i!="function")throw Error(gt(191,i));i.call(n)}}}var K1={},jc=yf(K1),Zp=yf(K1),Qp=yf(K1);function td(t){if(t===K1)throw Error(gt(174));return t}function s_(t,e){switch(pr(Qp,e),pr(Zp,t),pr(jc,K1),t=e.nodeType,t){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:f3(null,"");break;default:t=t===8?e.parentNode:e,e=t.namespaceURI||null,t=t.tagName,e=f3(e,t)}Tr(jc),pr(jc,e)}function ph(){Tr(jc),Tr(Zp),Tr(Qp)}function xM(t){td(Qp.current);var e=td(jc.current),r=f3(e,t.type);e!==r&&(pr(Zp,t),pr(jc,r))}function c_(t){Zp.current===t&&(Tr(jc),Tr(Zp))}var $r=yf(0);function iy(t){for(var e=t;e!==null;){if(e.tag===13){var r=e.memoizedState;if(r!==null&&(r=r.dehydrated,r===null||r.data==="$?"||r.data==="$!"))return e}else if(e.tag===19&&e.memoizedProps.revealOrder!==void 0){if(e.flags&128)return e}else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break;for(;e.sibling===null;){if(e.return===null||e.return===t)return null;e=e.return}e.sibling.return=e.return,e=e.sibling}return null}var Dx=[];function l_(){for(var t=0;t<Dx.length;t++)Dx[t]._workInProgressVersionPrimary=null;Dx.length=0}var sv=cu.ReactCurrentDispatcher,Ix=cu.ReactCurrentBatchConfig,yd=0,Kr=null,Li=null,Xi=null,oy=!1,fp=!1,e1=0,mH=0;function yo(){throw Error(gt(321))}function u_(t,e){if(e===null)return!1;for(var r=0;r<e.length&&r<t.length;r++)if(!lc(t[r],e[r]))return!1;return!0}function f_(t,e,r,n,i,o){if(yd=o,Kr=e,e.memoizedState=null,e.updateQueue=null,e.lanes=0,sv.current=t===null||t.memoizedState===null?xH:CH,t=r(n,i),fp){o=0;do{if(fp=!1,e1=0,25<=o)throw Error(gt(301));o+=1,Xi=Li=null,e.updateQueue=null,sv.current=SH,t=r(n,i)}while(fp)}if(sv.current=ay,e=Li!==null&&Li.next!==null,yd=0,Xi=Li=Kr=null,oy=!1,e)throw Error(gt(300));return t}function d_(){var t=e1!==0;return e1=0,t}function Nc(){var t={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Xi===null?Kr.memoizedState=Xi=t:Xi=Xi.next=t,Xi}function vs(){if(Li===null){var t=Kr.alternate;t=t!==null?t.memoizedState:null}else t=Li.next;var e=Xi===null?Kr.memoizedState:Xi.next;if(e!==null)Xi=e,Li=t;else{if(t===null)throw Error(gt(310));Li=t,t={memoizedState:Li.memoizedState,baseState:Li.baseState,baseQueue:Li.baseQueue,queue:Li.queue,next:null},Xi===null?Kr.memoizedState=Xi=t:Xi=Xi.next=t}return Xi}function t1(t,e){return typeof e=="function"?e(t):e}function Ox(t){var e=vs(),r=e.queue;if(r===null)throw Error(gt(311));r.lastRenderedReducer=t;var n=Li,i=n.baseQueue,o=r.pending;if(o!==null){if(i!==null){var a=i.next;i.next=o.next,o.next=a}n.baseQueue=i=o,r.pending=null}if(i!==null){o=i.next,n=n.baseState;var s=a=null,c=null,l=o;do{var f=l.lane;if((yd&f)===f)c!==null&&(c=c.next={lane:0,action:l.action,hasEagerState:l.hasEagerState,eagerState:l.eagerState,next:null}),n=l.hasEagerState?l.eagerState:t(n,l.action);else{var u={lane:f,action:l.action,hasEagerState:l.hasEagerState,eagerState:l.eagerState,next:null};c===null?(s=c=u,a=n):c=c.next=u,Kr.lanes|=f,wd|=f}l=l.next}while(l!==null&&l!==o);c===null?a=n:c.next=s,lc(n,e.memoizedState)||(sa=!0),e.memoizedState=n,e.baseState=a,e.baseQueue=c,r.lastRenderedState=n}if(t=r.interleaved,t!==null){i=t;do o=i.lane,Kr.lanes|=o,wd|=o,i=i.next;while(i!==t)}else i===null&&(r.lanes=0);return[e.memoizedState,r.dispatch]}function Mx(t){var e=vs(),r=e.queue;if(r===null)throw Error(gt(311));r.lastRenderedReducer=t;var n=r.dispatch,i=r.pending,o=e.memoizedState;if(i!==null){r.pending=null;var a=i=i.next;do o=t(o,a.action),a=a.next;while(a!==i);lc(o,e.memoizedState)||(sa=!0),e.memoizedState=o,e.baseQueue===null&&(e.baseState=o),r.lastRenderedState=o}return[o,n]}function CM(){}function SM(t,e){var r=Kr,n=vs(),i=e(),o=!lc(n.memoizedState,i);if(o&&(n.memoizedState=i,sa=!0),n=n.queue,h_(EM.bind(null,r,n,t),[t]),n.getSnapshot!==e||o||Xi!==null&&Xi.memoizedState.tag&1){if(r.flags|=2048,n1(9,_M.bind(null,r,n,i,e),void 0,null),Yi===null)throw Error(gt(349));yd&30||TM(r,e,i)}return i}function TM(t,e,r){t.flags|=16384,t={getSnapshot:e,value:r},e=Kr.updateQueue,e===null?(e={lastEffect:null,stores:null},Kr.updateQueue=e,e.stores=[t]):(r=e.stores,r===null?e.stores=[t]:r.push(t))}function _M(t,e,r,n){e.value=r,e.getSnapshot=n,bM(e)&&DM(t)}function EM(t,e,r){return r(function(){bM(e)&&DM(t)})}function bM(t){var e=t.getSnapshot;t=t.value;try{var r=e();return!lc(t,r)}catch{return!0}}function DM(t){var e=Yl(t,1);e!==null&&sc(e,t,1,-1)}function s6(t){var e=Nc();return typeof t=="function"&&(t=t()),e.memoizedState=e.baseState=t,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t1,lastRenderedState:t},e.queue=t,t=t.dispatch=wH.bind(null,Kr,t),[e.memoizedState,t]}function n1(t,e,r,n){return t={tag:t,create:e,destroy:r,deps:n,next:null},e=Kr.updateQueue,e===null?(e={lastEffect:null,stores:null},Kr.updateQueue=e,e.lastEffect=t.next=t):(r=e.lastEffect,r===null?e.lastEffect=t.next=t:(n=r.next,r.next=t,t.next=n,e.lastEffect=t)),t}function IM(){return vs().memoizedState}function cv(t,e,r,n){var i=Nc();Kr.flags|=t,i.memoizedState=n1(1|e,r,void 0,n===void 0?null:n)}function G5(t,e,r,n){var i=vs();n=n===void 0?null:n;var o=void 0;if(Li!==null){var a=Li.memoizedState;if(o=a.destroy,n!==null&&u_(n,a.deps)){i.memoizedState=n1(e,r,o,n);return}}Kr.flags|=t,i.memoizedState=n1(1|e,r,o,n)}function c6(t,e){return cv(8390656,8,t,e)}function h_(t,e){return G5(2048,8,t,e)}function OM(t,e){return G5(4,2,t,e)}function MM(t,e){return G5(4,4,t,e)}function PM(t,e){if(typeof e=="function")return t=t(),e(t),function(){e(null)};if(e!=null)return t=t(),e.current=t,function(){e.current=null}}function RM(t,e,r){return r=r!=null?r.concat([t]):null,G5(4,4,PM.bind(null,e,t),r)}function g_(){}function LM(t,e){var r=vs();e=e===void 0?null:e;var n=r.memoizedState;return n!==null&&e!==null&&u_(e,n[1])?n[0]:(r.memoizedState=[t,e],t)}function AM(t,e){var r=vs();e=e===void 0?null:e;var n=r.memoizedState;return n!==null&&e!==null&&u_(e,n[1])?n[0]:(t=t(),r.memoizedState=[t,e],t)}function NM(t,e,r){return yd&21?(lc(r,e)||(r=BO(),Kr.lanes|=r,wd|=r,t.baseState=!0),e):(t.baseState&&(t.baseState=!1,sa=!0),t.memoizedState=r)}function vH(t,e){var r=nr;nr=r!==0&&4>r?r:4,t(!0);var n=Ix.transition;Ix.transition={};try{t(!1),e()}finally{nr=r,Ix.transition=n}}function kM(){return vs().memoizedState}function yH(t,e,r){var n=qu(t);if(r={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null},VM(t))FM(e,r);else if(r=yM(t,e,r,n),r!==null){var i=Ho();sc(r,t,n,i),UM(r,e,n)}}function wH(t,e,r){var n=qu(t),i={lane:n,action:r,hasEagerState:!1,eagerState:null,next:null};if(VM(t))FM(e,i);else{var o=t.alternate;if(t.lanes===0&&(o===null||o.lanes===0)&&(o=e.lastRenderedReducer,o!==null))try{var a=e.lastRenderedState,s=o(a,r);if(i.hasEagerState=!0,i.eagerState=s,lc(s,a)){var c=e.interleaved;c===null?(i.next=i,o_(e)):(i.next=c.next,c.next=i),e.interleaved=i;return}}catch{}finally{}r=yM(t,e,i,n),r!==null&&(i=Ho(),sc(r,t,n,i),UM(r,e,n))}}function VM(t){var e=t.alternate;return t===Kr||e!==null&&e===Kr}function FM(t,e){fp=oy=!0;var r=t.pending;r===null?e.next=e:(e.next=r.next,r.next=e),t.pending=e}function UM(t,e,r){if(r&4194240){var n=e.lanes;n&=t.pendingLanes,r|=n,e.lanes=r,jT(t,r)}}var ay={readContext:ms,useCallback:yo,useContext:yo,useEffect:yo,useImperativeHandle:yo,useInsertionEffect:yo,useLayoutEffect:yo,useMemo:yo,useReducer:yo,useRef:yo,useState:yo,useDebugValue:yo,useDeferredValue:yo,useTransition:yo,useMutableSource:yo,useSyncExternalStore:yo,useId:yo,unstable_isNewReconciler:!1},xH={readContext:ms,useCallback:function(t,e){return Nc().memoizedState=[t,e===void 0?null:e],t},useContext:ms,useEffect:c6,useImperativeHandle:function(t,e,r){return r=r!=null?r.concat([t]):null,cv(4194308,4,PM.bind(null,e,t),r)},useLayoutEffect:function(t,e){return cv(4194308,4,t,e)},useInsertionEffect:function(t,e){return cv(4,2,t,e)},useMemo:function(t,e){var r=Nc();return e=e===void 0?null:e,t=t(),r.memoizedState=[t,e],t},useReducer:function(t,e,r){var n=Nc();return e=r!==void 0?r(e):e,n.memoizedState=n.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},n.queue=t,t=t.dispatch=yH.bind(null,Kr,t),[n.memoizedState,t]},useRef:function(t){var e=Nc();return t={current:t},e.memoizedState=t},useState:s6,useDebugValue:g_,useDeferredValue:function(t){return Nc().memoizedState=t},useTransition:function(){var t=s6(!1),e=t[0];return t=vH.bind(null,t[1]),Nc().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,r){var n=Kr,i=Nc();if(Rr){if(r===void 0)throw Error(gt(407));r=r()}else{if(r=e(),Yi===null)throw Error(gt(349));yd&30||TM(n,e,r)}i.memoizedState=r;var o={value:r,getSnapshot:e};return i.queue=o,c6(EM.bind(null,n,o,t),[t]),n.flags|=2048,n1(9,_M.bind(null,n,o,r,e),void 0,null),r},useId:function(){var t=Nc(),e=Yi.identifierPrefix;if(Rr){var r=Vl,n=kl;r=(n&~(1<<32-ac(n)-1)).toString(32)+r,e=":"+e+"R"+r,r=e1++,0<r&&(e+="H"+r.toString(32)),e+=":"}else r=mH++,e=":"+e+"r"+r.toString(32)+":";return t.memoizedState=e},unstable_isNewReconciler:!1},CH={readContext:ms,useCallback:LM,useContext:ms,useEffect:h_,useImperativeHandle:RM,useInsertionEffect:OM,useLayoutEffect:MM,useMemo:AM,useReducer:Ox,useRef:IM,useState:function(){return Ox(t1)},useDebugValue:g_,useDeferredValue:function(t){var e=vs();return NM(e,Li.memoizedState,t)},useTransition:function(){var t=Ox(t1)[0],e=vs().memoizedState;return[t,e]},useMutableSource:CM,useSyncExternalStore:SM,useId:kM,unstable_isNewReconciler:!1},SH={readContext:ms,useCallback:LM,useContext:ms,useEffect:h_,useImperativeHandle:RM,useInsertionEffect:OM,useLayoutEffect:MM,useMemo:AM,useReducer:Mx,useRef:IM,useState:function(){return Mx(t1)},useDebugValue:g_,useDeferredValue:function(t){var e=vs();return Li===null?e.memoizedState=t:NM(e,Li.memoizedState,t)},useTransition:function(){var t=Mx(t1)[0],e=vs().memoizedState;return[t,e]},useMutableSource:CM,useSyncExternalStore:SM,useId:kM,unstable_isNewReconciler:!1};function Hs(t,e){if(t&&t.defaultProps){e=qr({},e),t=t.defaultProps;for(var r in t)e[r]===void 0&&(e[r]=t[r]);return e}return e}function R3(t,e,r,n){e=t.memoizedState,r=r(n,e),r=r==null?e:qr({},e,r),t.memoizedState=r,t.lanes===0&&(t.updateQueue.baseState=r)}var W5={isMounted:function(t){return(t=t._reactInternals)?kd(t)===t:!1},enqueueSetState:function(t,e,r){t=t._reactInternals;var n=Ho(),i=qu(t),o=zl(n,i);o.payload=e,r!=null&&(o.callback=r),e=Hu(t,o,i),e!==null&&(sc(e,t,i,n),av(e,t,i))},enqueueReplaceState:function(t,e,r){t=t._reactInternals;var n=Ho(),i=qu(t),o=zl(n,i);o.tag=1,o.payload=e,r!=null&&(o.callback=r),e=Hu(t,o,i),e!==null&&(sc(e,t,i,n),av(e,t,i))},enqueueForceUpdate:function(t,e){t=t._reactInternals;var r=Ho(),n=qu(t),i=zl(r,n);i.tag=2,e!=null&&(i.callback=e),e=Hu(t,i,n),e!==null&&(sc(e,t,n,r),av(e,t,n))}};function l6(t,e,r,n,i,o,a){return t=t.stateNode,typeof t.shouldComponentUpdate=="function"?t.shouldComponentUpdate(n,o,a):e.prototype&&e.prototype.isPureReactComponent?!qp(r,n)||!qp(i,o):!0}function BM(t,e,r){var n=!1,i=nf,o=e.contextType;return typeof o=="object"&&o!==null?o=ms(o):(i=da(e)?md:Oo.current,n=e.contextTypes,o=(n=n!=null)?dh(t,i):nf),e=new e(r,o),t.memoizedState=e.state!==null&&e.state!==void 0?e.state:null,e.updater=W5,t.stateNode=e,e._reactInternals=t,n&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=i,t.__reactInternalMemoizedMaskedChildContext=o),e}function u6(t,e,r,n){t=e.state,typeof e.componentWillReceiveProps=="function"&&e.componentWillReceiveProps(r,n),typeof e.UNSAFE_componentWillReceiveProps=="function"&&e.UNSAFE_componentWillReceiveProps(r,n),e.state!==t&&W5.enqueueReplaceState(e,e.state,null)}function L3(t,e,r,n){var i=t.stateNode;i.props=r,i.state=t.memoizedState,i.refs={},a_(t);var o=e.contextType;typeof o=="object"&&o!==null?i.context=ms(o):(o=da(e)?md:Oo.current,i.context=dh(t,o)),i.state=t.memoizedState,o=e.getDerivedStateFromProps,typeof o=="function"&&(R3(t,e,o,r),i.state=t.memoizedState),typeof e.getDerivedStateFromProps=="function"||typeof i.getSnapshotBeforeUpdate=="function"||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(e=i.state,typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount(),e!==i.state&&W5.enqueueReplaceState(i,i.state,null),ry(t,r,i,n),i.state=t.memoizedState),typeof i.componentDidMount=="function"&&(t.flags|=4194308)}function mh(t,e){try{var r="",n=e;do r+=Y$(n),n=n.return;while(n);var i=r}catch(o){i=`
|
||
Error generating stack: `+o.message+`
|
||
`+o.stack}return{value:t,source:e,stack:i,digest:null}}function Px(t,e,r){return{value:t,source:null,stack:r??null,digest:e??null}}function A3(t,e){try{console.error(e.value)}catch(r){setTimeout(function(){throw r})}}var TH=typeof WeakMap=="function"?WeakMap:Map;function GM(t,e,r){r=zl(-1,r),r.tag=3,r.payload={element:null};var n=e.value;return r.callback=function(){cy||(cy=!0,$3=n),A3(t,e)},r}function WM(t,e,r){r=zl(-1,r),r.tag=3;var n=t.type.getDerivedStateFromError;if(typeof n=="function"){var i=e.value;r.payload=function(){return n(i)},r.callback=function(){A3(t,e)}}var o=t.stateNode;return o!==null&&typeof o.componentDidCatch=="function"&&(r.callback=function(){A3(t,e),typeof n!="function"&&(Ku===null?Ku=new Set([this]):Ku.add(this));var a=e.stack;this.componentDidCatch(e.value,{componentStack:a!==null?a:""})}),r}function f6(t,e,r){var n=t.pingCache;if(n===null){n=t.pingCache=new TH;var i=new Set;n.set(e,i)}else i=n.get(e),i===void 0&&(i=new Set,n.set(e,i));i.has(r)||(i.add(r),t=VH.bind(null,t,e,r),e.then(t,t))}function d6(t){do{var e;if((e=t.tag===13)&&(e=t.memoizedState,e=e!==null?e.dehydrated!==null:!0),e)return t;t=t.return}while(t!==null);return null}function h6(t,e,r,n,i){return t.mode&1?(t.flags|=65536,t.lanes=i,t):(t===e?t.flags|=65536:(t.flags|=128,r.flags|=131072,r.flags&=-52805,r.tag===1&&(r.alternate===null?r.tag=17:(e=zl(-1,1),e.tag=2,Hu(r,e,1))),r.lanes|=1),t)}var _H=cu.ReactCurrentOwner,sa=!1;function zo(t,e,r,n){e.child=t===null?vM(e,null,r,n):gh(e,t.child,r,n)}function g6(t,e,r,n,i){r=r.render;var o=e.ref;return j0(e,i),n=f_(t,e,r,n,o,i),r=d_(),t!==null&&!sa?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~i,Jl(t,e,i)):(Rr&&r&&QT(e),e.flags|=1,zo(t,e,n,i),e.child)}function p6(t,e,r,n,i){if(t===null){var o=r.type;return typeof o=="function"&&!S_(o)&&o.defaultProps===void 0&&r.compare===null&&r.defaultProps===void 0?(e.tag=15,e.type=o,zM(t,e,o,n,i)):(t=dv(r.type,null,n,e,e.mode,i),t.ref=e.ref,t.return=e,e.child=t)}if(o=t.child,!(t.lanes&i)){var a=o.memoizedProps;if(r=r.compare,r=r!==null?r:qp,r(a,n)&&t.ref===e.ref)return Jl(t,e,i)}return e.flags|=1,t=Xu(o,n),t.ref=e.ref,t.return=e,e.child=t}function zM(t,e,r,n,i){if(t!==null){var o=t.memoizedProps;if(qp(o,n)&&t.ref===e.ref)if(sa=!1,e.pendingProps=n=o,(t.lanes&i)!==0)t.flags&131072&&(sa=!0);else return e.lanes=t.lanes,Jl(t,e,i)}return N3(t,e,r,n,i)}function $M(t,e,r){var n=e.pendingProps,i=n.children,o=t!==null?t.memoizedState:null;if(n.mode==="hidden")if(!(e.mode&1))e.memoizedState={baseLanes:0,cachePool:null,transitions:null},pr(C0,Ra),Ra|=r;else{if(!(r&1073741824))return t=o!==null?o.baseLanes|r:r,e.lanes=e.childLanes=1073741824,e.memoizedState={baseLanes:t,cachePool:null,transitions:null},e.updateQueue=null,pr(C0,Ra),Ra|=t,null;e.memoizedState={baseLanes:0,cachePool:null,transitions:null},n=o!==null?o.baseLanes:r,pr(C0,Ra),Ra|=n}else o!==null?(n=o.baseLanes|r,e.memoizedState=null):n=r,pr(C0,Ra),Ra|=n;return zo(t,e,i,r),e.child}function jM(t,e){var r=e.ref;(t===null&&r!==null||t!==null&&t.ref!==r)&&(e.flags|=512,e.flags|=2097152)}function N3(t,e,r,n,i){var o=da(r)?md:Oo.current;return o=dh(e,o),j0(e,i),r=f_(t,e,r,n,o,i),n=d_(),t!==null&&!sa?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~i,Jl(t,e,i)):(Rr&&n&&QT(e),e.flags|=1,zo(t,e,r,i),e.child)}function m6(t,e,r,n,i){if(da(r)){var o=!0;Zv(e)}else o=!1;if(j0(e,i),e.stateNode===null)lv(t,e),BM(e,r,n),L3(e,r,n,i),n=!0;else if(t===null){var a=e.stateNode,s=e.memoizedProps;a.props=s;var c=a.context,l=r.contextType;typeof l=="object"&&l!==null?l=ms(l):(l=da(r)?md:Oo.current,l=dh(e,l));var f=r.getDerivedStateFromProps,u=typeof f=="function"||typeof a.getSnapshotBeforeUpdate=="function";u||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(s!==n||c!==l)&&u6(e,a,n,l),Eu=!1;var d=e.memoizedState;a.state=d,ry(e,n,a,i),c=e.memoizedState,s!==n||d!==c||fa.current||Eu?(typeof f=="function"&&(R3(e,r,f,n),c=e.memoizedState),(s=Eu||l6(e,r,s,n,d,c,l))?(u||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount=="function"&&(e.flags|=4194308)):(typeof a.componentDidMount=="function"&&(e.flags|=4194308),e.memoizedProps=n,e.memoizedState=c),a.props=n,a.state=c,a.context=l,n=s):(typeof a.componentDidMount=="function"&&(e.flags|=4194308),n=!1)}else{a=e.stateNode,wM(t,e),s=e.memoizedProps,l=e.type===e.elementType?s:Hs(e.type,s),a.props=l,u=e.pendingProps,d=a.context,c=r.contextType,typeof c=="object"&&c!==null?c=ms(c):(c=da(r)?md:Oo.current,c=dh(e,c));var h=r.getDerivedStateFromProps;(f=typeof h=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(s!==u||d!==c)&&u6(e,a,n,c),Eu=!1,d=e.memoizedState,a.state=d,ry(e,n,a,i);var g=e.memoizedState;s!==u||d!==g||fa.current||Eu?(typeof h=="function"&&(R3(e,r,h,n),g=e.memoizedState),(l=Eu||l6(e,r,l,n,d,g,c)||!1)?(f||typeof a.UNSAFE_componentWillUpdate!="function"&&typeof a.componentWillUpdate!="function"||(typeof a.componentWillUpdate=="function"&&a.componentWillUpdate(n,g,c),typeof a.UNSAFE_componentWillUpdate=="function"&&a.UNSAFE_componentWillUpdate(n,g,c)),typeof a.componentDidUpdate=="function"&&(e.flags|=4),typeof a.getSnapshotBeforeUpdate=="function"&&(e.flags|=1024)):(typeof a.componentDidUpdate!="function"||s===t.memoizedProps&&d===t.memoizedState||(e.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||s===t.memoizedProps&&d===t.memoizedState||(e.flags|=1024),e.memoizedProps=n,e.memoizedState=g),a.props=n,a.state=g,a.context=c,n=l):(typeof a.componentDidUpdate!="function"||s===t.memoizedProps&&d===t.memoizedState||(e.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||s===t.memoizedProps&&d===t.memoizedState||(e.flags|=1024),n=!1)}return k3(t,e,r,n,o,i)}function k3(t,e,r,n,i,o){jM(t,e);var a=(e.flags&128)!==0;if(!n&&!a)return i&&t6(e,r,!1),Jl(t,e,o);n=e.stateNode,_H.current=e;var s=a&&typeof r.getDerivedStateFromError!="function"?null:n.render();return e.flags|=1,t!==null&&a?(e.child=gh(e,t.child,null,o),e.child=gh(e,null,s,o)):zo(t,e,s,o),e.memoizedState=n.state,i&&t6(e,r,!0),e.child}function HM(t){var e=t.stateNode;e.pendingContext?e6(t,e.pendingContext,e.pendingContext!==e.context):e.context&&e6(t,e.context,!1),s_(t,e.containerInfo)}function v6(t,e,r,n,i){return hh(),t_(i),e.flags|=256,zo(t,e,r,n),e.child}var V3={dehydrated:null,treeContext:null,retryLane:0};function F3(t){return{baseLanes:t,cachePool:null,transitions:null}}function KM(t,e,r){var n=e.pendingProps,i=$r.current,o=!1,a=(e.flags&128)!==0,s;if((s=a)||(s=t!==null&&t.memoizedState===null?!1:(i&2)!==0),s?(o=!0,e.flags&=-129):(t===null||t.memoizedState!==null)&&(i|=1),pr($r,i&1),t===null)return M3(e),t=e.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?(e.mode&1?t.data==="$!"?e.lanes=8:e.lanes=1073741824:e.lanes=1,null):(a=n.children,t=n.fallback,o?(n=e.mode,o=e.child,a={mode:"hidden",children:a},!(n&1)&&o!==null?(o.childLanes=0,o.pendingProps=a):o=j5(a,n,0,null),t=sd(t,n,r,null),o.return=e,t.return=e,o.sibling=t,e.child=o,e.child.memoizedState=F3(r),e.memoizedState=V3,t):p_(e,a));if(i=t.memoizedState,i!==null&&(s=i.dehydrated,s!==null))return EH(t,e,a,n,s,i,r);if(o){o=n.fallback,a=e.mode,i=t.child,s=i.sibling;var c={mode:"hidden",children:n.children};return!(a&1)&&e.child!==i?(n=e.child,n.childLanes=0,n.pendingProps=c,e.deletions=null):(n=Xu(i,c),n.subtreeFlags=i.subtreeFlags&14680064),s!==null?o=Xu(s,o):(o=sd(o,a,r,null),o.flags|=2),o.return=e,n.return=e,n.sibling=o,e.child=n,n=o,o=e.child,a=t.child.memoizedState,a=a===null?F3(r):{baseLanes:a.baseLanes|r,cachePool:null,transitions:a.transitions},o.memoizedState=a,o.childLanes=t.childLanes&~r,e.memoizedState=V3,n}return o=t.child,t=o.sibling,n=Xu(o,{mode:"visible",children:n.children}),!(e.mode&1)&&(n.lanes=r),n.return=e,n.sibling=null,t!==null&&(r=e.deletions,r===null?(e.deletions=[t],e.flags|=16):r.push(t)),e.child=n,e.memoizedState=null,n}function p_(t,e){return e=j5({mode:"visible",children:e},t.mode,0,null),e.return=t,t.child=e}function qm(t,e,r,n){return n!==null&&t_(n),gh(e,t.child,null,r),t=p_(e,e.pendingProps.children),t.flags|=2,e.memoizedState=null,t}function EH(t,e,r,n,i,o,a){if(r)return e.flags&256?(e.flags&=-257,n=Px(Error(gt(422))),qm(t,e,a,n)):e.memoizedState!==null?(e.child=t.child,e.flags|=128,null):(o=n.fallback,i=e.mode,n=j5({mode:"visible",children:n.children},i,0,null),o=sd(o,i,a,null),o.flags|=2,n.return=e,o.return=e,n.sibling=o,e.child=n,e.mode&1&&gh(e,t.child,null,a),e.child.memoizedState=F3(a),e.memoizedState=V3,o);if(!(e.mode&1))return qm(t,e,a,null);if(i.data==="$!"){if(n=i.nextSibling&&i.nextSibling.dataset,n)var s=n.dgst;return n=s,o=Error(gt(419)),n=Px(o,n,void 0),qm(t,e,a,n)}if(s=(a&t.childLanes)!==0,sa||s){if(n=Yi,n!==null){switch(a&-a){case 4:i=2;break;case 16:i=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:i=32;break;case 536870912:i=268435456;break;default:i=0}i=i&(n.suspendedLanes|a)?0:i,i!==0&&i!==o.retryLane&&(o.retryLane=i,Yl(t,i),sc(n,t,i,-1))}return C_(),n=Px(Error(gt(421))),qm(t,e,a,n)}return i.data==="$?"?(e.flags|=128,e.child=t.child,e=FH.bind(null,t),i._reactRetry=e,null):(t=o.treeContext,Na=ju(i.nextSibling),Fa=e,Rr=!0,Ys=null,t!==null&&(cs[ls++]=kl,cs[ls++]=Vl,cs[ls++]=vd,kl=t.id,Vl=t.overflow,vd=e),e=p_(e,n.children),e.flags|=4096,e)}function y6(t,e,r){t.lanes|=e;var n=t.alternate;n!==null&&(n.lanes|=e),P3(t.return,e,r)}function Rx(t,e,r,n,i){var o=t.memoizedState;o===null?t.memoizedState={isBackwards:e,rendering:null,renderingStartTime:0,last:n,tail:r,tailMode:i}:(o.isBackwards=e,o.rendering=null,o.renderingStartTime=0,o.last=n,o.tail=r,o.tailMode=i)}function qM(t,e,r){var n=e.pendingProps,i=n.revealOrder,o=n.tail;if(zo(t,e,n.children,r),n=$r.current,n&2)n=n&1|2,e.flags|=128;else{if(t!==null&&t.flags&128)e:for(t=e.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&y6(t,r,e);else if(t.tag===19)y6(t,r,e);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}n&=1}if(pr($r,n),!(e.mode&1))e.memoizedState=null;else switch(i){case"forwards":for(r=e.child,i=null;r!==null;)t=r.alternate,t!==null&&iy(t)===null&&(i=r),r=r.sibling;r=i,r===null?(i=e.child,e.child=null):(i=r.sibling,r.sibling=null),Rx(e,!1,i,r,o);break;case"backwards":for(r=null,i=e.child,e.child=null;i!==null;){if(t=i.alternate,t!==null&&iy(t)===null){e.child=i;break}t=i.sibling,i.sibling=r,r=i,i=t}Rx(e,!0,r,null,o);break;case"together":Rx(e,!1,null,null,void 0);break;default:e.memoizedState=null}return e.child}function lv(t,e){!(e.mode&1)&&t!==null&&(t.alternate=null,e.alternate=null,e.flags|=2)}function Jl(t,e,r){if(t!==null&&(e.dependencies=t.dependencies),wd|=e.lanes,!(r&e.childLanes))return null;if(t!==null&&e.child!==t.child)throw Error(gt(153));if(e.child!==null){for(t=e.child,r=Xu(t,t.pendingProps),e.child=r,r.return=e;t.sibling!==null;)t=t.sibling,r=r.sibling=Xu(t,t.pendingProps),r.return=e;r.sibling=null}return e.child}function bH(t,e,r){switch(e.tag){case 3:HM(e),hh();break;case 5:xM(e);break;case 1:da(e.type)&&Zv(e);break;case 4:s_(e,e.stateNode.containerInfo);break;case 10:var n=e.type._context,i=e.memoizedProps.value;pr(ty,n._currentValue),n._currentValue=i;break;case 13:if(n=e.memoizedState,n!==null)return n.dehydrated!==null?(pr($r,$r.current&1),e.flags|=128,null):r&e.child.childLanes?KM(t,e,r):(pr($r,$r.current&1),t=Jl(t,e,r),t!==null?t.sibling:null);pr($r,$r.current&1);break;case 19:if(n=(r&e.childLanes)!==0,t.flags&128){if(n)return qM(t,e,r);e.flags|=128}if(i=e.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),pr($r,$r.current),n)break;return null;case 22:case 23:return e.lanes=0,$M(t,e,r)}return Jl(t,e,r)}var XM,U3,YM,JM;XM=function(t,e){for(var r=e.child;r!==null;){if(r.tag===5||r.tag===6)t.appendChild(r.stateNode);else if(r.tag!==4&&r.child!==null){r.child.return=r,r=r.child;continue}if(r===e)break;for(;r.sibling===null;){if(r.return===null||r.return===e)return;r=r.return}r.sibling.return=r.return,r=r.sibling}};U3=function(){};YM=function(t,e,r,n){var i=t.memoizedProps;if(i!==n){t=e.stateNode,td(jc.current);var o=null;switch(r){case"input":i=s3(t,i),n=s3(t,n),o=[];break;case"select":i=qr({},i,{value:void 0}),n=qr({},n,{value:void 0}),o=[];break;case"textarea":i=u3(t,i),n=u3(t,n),o=[];break;default:typeof i.onClick!="function"&&typeof n.onClick=="function"&&(t.onclick=Yv)}d3(r,n);var a;r=null;for(l in i)if(!n.hasOwnProperty(l)&&i.hasOwnProperty(l)&&i[l]!=null)if(l==="style"){var s=i[l];for(a in s)s.hasOwnProperty(a)&&(r||(r={}),r[a]="")}else l!=="dangerouslySetInnerHTML"&&l!=="children"&&l!=="suppressContentEditableWarning"&&l!=="suppressHydrationWarning"&&l!=="autoFocus"&&(Gp.hasOwnProperty(l)?o||(o=[]):(o=o||[]).push(l,null));for(l in n){var c=n[l];if(s=i!=null?i[l]:void 0,n.hasOwnProperty(l)&&c!==s&&(c!=null||s!=null))if(l==="style")if(s){for(a in s)!s.hasOwnProperty(a)||c&&c.hasOwnProperty(a)||(r||(r={}),r[a]="");for(a in c)c.hasOwnProperty(a)&&s[a]!==c[a]&&(r||(r={}),r[a]=c[a])}else r||(o||(o=[]),o.push(l,r)),r=c;else l==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,s=s?s.__html:void 0,c!=null&&s!==c&&(o=o||[]).push(l,c)):l==="children"?typeof c!="string"&&typeof c!="number"||(o=o||[]).push(l,""+c):l!=="suppressContentEditableWarning"&&l!=="suppressHydrationWarning"&&(Gp.hasOwnProperty(l)?(c!=null&&l==="onScroll"&&wr("scroll",t),o||s===c||(o=[])):(o=o||[]).push(l,c))}r&&(o=o||[]).push("style",r);var l=o;(e.updateQueue=l)&&(e.flags|=4)}};JM=function(t,e,r,n){r!==n&&(e.flags|=4)};function yg(t,e){if(!Rr)switch(t.tailMode){case"hidden":e=t.tail;for(var r=null;e!==null;)e.alternate!==null&&(r=e),e=e.sibling;r===null?t.tail=null:r.sibling=null;break;case"collapsed":r=t.tail;for(var n=null;r!==null;)r.alternate!==null&&(n=r),r=r.sibling;n===null?e||t.tail===null?t.tail=null:t.tail.sibling=null:n.sibling=null}}function wo(t){var e=t.alternate!==null&&t.alternate.child===t.child,r=0,n=0;if(e)for(var i=t.child;i!==null;)r|=i.lanes|i.childLanes,n|=i.subtreeFlags&14680064,n|=i.flags&14680064,i.return=t,i=i.sibling;else for(i=t.child;i!==null;)r|=i.lanes|i.childLanes,n|=i.subtreeFlags,n|=i.flags,i.return=t,i=i.sibling;return t.subtreeFlags|=n,t.childLanes=r,e}function DH(t,e,r){var n=e.pendingProps;switch(e_(e),e.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return wo(e),null;case 1:return da(e.type)&&Jv(),wo(e),null;case 3:return n=e.stateNode,ph(),Tr(fa),Tr(Oo),l_(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(t===null||t.child===null)&&(Hm(e)?e.flags|=4:t===null||t.memoizedState.isDehydrated&&!(e.flags&256)||(e.flags|=1024,Ys!==null&&(K3(Ys),Ys=null))),U3(t,e),wo(e),null;case 5:c_(e);var i=td(Qp.current);if(r=e.type,t!==null&&e.stateNode!=null)YM(t,e,r,n,i),t.ref!==e.ref&&(e.flags|=512,e.flags|=2097152);else{if(!n){if(e.stateNode===null)throw Error(gt(166));return wo(e),null}if(t=td(jc.current),Hm(e)){n=e.stateNode,r=e.type;var o=e.memoizedProps;switch(n[Gc]=e,n[Jp]=o,t=(e.mode&1)!==0,r){case"dialog":wr("cancel",n),wr("close",n);break;case"iframe":case"object":case"embed":wr("load",n);break;case"video":case"audio":for(i=0;i<zg.length;i++)wr(zg[i],n);break;case"source":wr("error",n);break;case"img":case"image":case"link":wr("error",n),wr("load",n);break;case"details":wr("toggle",n);break;case"input":Db(n,o),wr("invalid",n);break;case"select":n._wrapperState={wasMultiple:!!o.multiple},wr("invalid",n);break;case"textarea":Ob(n,o),wr("invalid",n)}d3(r,o),i=null;for(var a in o)if(o.hasOwnProperty(a)){var s=o[a];a==="children"?typeof s=="string"?n.textContent!==s&&(o.suppressHydrationWarning!==!0&&jm(n.textContent,s,t),i=["children",s]):typeof s=="number"&&n.textContent!==""+s&&(o.suppressHydrationWarning!==!0&&jm(n.textContent,s,t),i=["children",""+s]):Gp.hasOwnProperty(a)&&s!=null&&a==="onScroll"&&wr("scroll",n)}switch(r){case"input":Vm(n),Ib(n,o,!0);break;case"textarea":Vm(n),Mb(n);break;case"select":case"option":break;default:typeof o.onClick=="function"&&(n.onclick=Yv)}n=i,e.updateQueue=n,n!==null&&(e.flags|=4)}else{a=i.nodeType===9?i:i.ownerDocument,t==="http://www.w3.org/1999/xhtml"&&(t=EO(r)),t==="http://www.w3.org/1999/xhtml"?r==="script"?(t=a.createElement("div"),t.innerHTML="<script><\/script>",t=t.removeChild(t.firstChild)):typeof n.is=="string"?t=a.createElement(r,{is:n.is}):(t=a.createElement(r),r==="select"&&(a=t,n.multiple?a.multiple=!0:n.size&&(a.size=n.size))):t=a.createElementNS(t,r),t[Gc]=e,t[Jp]=n,XM(t,e,!1,!1),e.stateNode=t;e:{switch(a=h3(r,n),r){case"dialog":wr("cancel",t),wr("close",t),i=n;break;case"iframe":case"object":case"embed":wr("load",t),i=n;break;case"video":case"audio":for(i=0;i<zg.length;i++)wr(zg[i],t);i=n;break;case"source":wr("error",t),i=n;break;case"img":case"image":case"link":wr("error",t),wr("load",t),i=n;break;case"details":wr("toggle",t),i=n;break;case"input":Db(t,n),i=s3(t,n),wr("invalid",t);break;case"option":i=n;break;case"select":t._wrapperState={wasMultiple:!!n.multiple},i=qr({},n,{value:void 0}),wr("invalid",t);break;case"textarea":Ob(t,n),i=u3(t,n),wr("invalid",t);break;default:i=n}d3(r,i),s=i;for(o in s)if(s.hasOwnProperty(o)){var c=s[o];o==="style"?IO(t,c):o==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&bO(t,c)):o==="children"?typeof c=="string"?(r!=="textarea"||c!=="")&&Wp(t,c):typeof c=="number"&&Wp(t,""+c):o!=="suppressContentEditableWarning"&&o!=="suppressHydrationWarning"&&o!=="autoFocus"&&(Gp.hasOwnProperty(o)?c!=null&&o==="onScroll"&&wr("scroll",t):c!=null&&UT(t,o,c,a))}switch(r){case"input":Vm(t),Ib(t,n,!1);break;case"textarea":Vm(t),Mb(t);break;case"option":n.value!=null&&t.setAttribute("value",""+tf(n.value));break;case"select":t.multiple=!!n.multiple,o=n.value,o!=null?G0(t,!!n.multiple,o,!1):n.defaultValue!=null&&G0(t,!!n.multiple,n.defaultValue,!0);break;default:typeof i.onClick=="function"&&(t.onclick=Yv)}switch(r){case"button":case"input":case"select":case"textarea":n=!!n.autoFocus;break e;case"img":n=!0;break e;default:n=!1}}n&&(e.flags|=4)}e.ref!==null&&(e.flags|=512,e.flags|=2097152)}return wo(e),null;case 6:if(t&&e.stateNode!=null)JM(t,e,t.memoizedProps,n);else{if(typeof n!="string"&&e.stateNode===null)throw Error(gt(166));if(r=td(Qp.current),td(jc.current),Hm(e)){if(n=e.stateNode,r=e.memoizedProps,n[Gc]=e,(o=n.nodeValue!==r)&&(t=Fa,t!==null))switch(t.tag){case 3:jm(n.nodeValue,r,(t.mode&1)!==0);break;case 5:t.memoizedProps.suppressHydrationWarning!==!0&&jm(n.nodeValue,r,(t.mode&1)!==0)}o&&(e.flags|=4)}else n=(r.nodeType===9?r:r.ownerDocument).createTextNode(n),n[Gc]=e,e.stateNode=n}return wo(e),null;case 13:if(Tr($r),n=e.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(Rr&&Na!==null&&e.mode&1&&!(e.flags&128))pM(),hh(),e.flags|=98560,o=!1;else if(o=Hm(e),n!==null&&n.dehydrated!==null){if(t===null){if(!o)throw Error(gt(318));if(o=e.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(gt(317));o[Gc]=e}else hh(),!(e.flags&128)&&(e.memoizedState=null),e.flags|=4;wo(e),o=!1}else Ys!==null&&(K3(Ys),Ys=null),o=!0;if(!o)return e.flags&65536?e:null}return e.flags&128?(e.lanes=r,e):(n=n!==null,n!==(t!==null&&t.memoizedState!==null)&&n&&(e.child.flags|=8192,e.mode&1&&(t===null||$r.current&1?Vi===0&&(Vi=3):C_())),e.updateQueue!==null&&(e.flags|=4),wo(e),null);case 4:return ph(),U3(t,e),t===null&&Xp(e.stateNode.containerInfo),wo(e),null;case 10:return i_(e.type._context),wo(e),null;case 17:return da(e.type)&&Jv(),wo(e),null;case 19:if(Tr($r),o=e.memoizedState,o===null)return wo(e),null;if(n=(e.flags&128)!==0,a=o.rendering,a===null)if(n)yg(o,!1);else{if(Vi!==0||t!==null&&t.flags&128)for(t=e.child;t!==null;){if(a=iy(t),a!==null){for(e.flags|=128,yg(o,!1),n=a.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),e.subtreeFlags=0,n=r,r=e.child;r!==null;)o=r,t=n,o.flags&=14680066,a=o.alternate,a===null?(o.childLanes=0,o.lanes=t,o.child=null,o.subtreeFlags=0,o.memoizedProps=null,o.memoizedState=null,o.updateQueue=null,o.dependencies=null,o.stateNode=null):(o.childLanes=a.childLanes,o.lanes=a.lanes,o.child=a.child,o.subtreeFlags=0,o.deletions=null,o.memoizedProps=a.memoizedProps,o.memoizedState=a.memoizedState,o.updateQueue=a.updateQueue,o.type=a.type,t=a.dependencies,o.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),r=r.sibling;return pr($r,$r.current&1|2),e.child}t=t.sibling}o.tail!==null&&li()>vh&&(e.flags|=128,n=!0,yg(o,!1),e.lanes=4194304)}else{if(!n)if(t=iy(a),t!==null){if(e.flags|=128,n=!0,r=t.updateQueue,r!==null&&(e.updateQueue=r,e.flags|=4),yg(o,!0),o.tail===null&&o.tailMode==="hidden"&&!a.alternate&&!Rr)return wo(e),null}else 2*li()-o.renderingStartTime>vh&&r!==1073741824&&(e.flags|=128,n=!0,yg(o,!1),e.lanes=4194304);o.isBackwards?(a.sibling=e.child,e.child=a):(r=o.last,r!==null?r.sibling=a:e.child=a,o.last=a)}return o.tail!==null?(e=o.tail,o.rendering=e,o.tail=e.sibling,o.renderingStartTime=li(),e.sibling=null,r=$r.current,pr($r,n?r&1|2:r&1),e):(wo(e),null);case 22:case 23:return x_(),n=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==n&&(e.flags|=8192),n&&e.mode&1?Ra&1073741824&&(wo(e),e.subtreeFlags&6&&(e.flags|=8192)):wo(e),null;case 24:return null;case 25:return null}throw Error(gt(156,e.tag))}function IH(t,e){switch(e_(e),e.tag){case 1:return da(e.type)&&Jv(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return ph(),Tr(fa),Tr(Oo),l_(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return c_(e),null;case 13:if(Tr($r),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(gt(340));hh()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return Tr($r),null;case 4:return ph(),null;case 10:return i_(e.type._context),null;case 22:case 23:return x_(),null;case 24:return null;default:return null}}var Xm=!1,Eo=!1,OH=typeof WeakSet=="function"?WeakSet:Set,Ot=null;function x0(t,e){var r=t.ref;if(r!==null)if(typeof r=="function")try{r(null)}catch(n){ti(t,e,n)}else r.current=null}function B3(t,e,r){try{r()}catch(n){ti(t,e,n)}}var w6=!1;function MH(t,e){if(T3=Kv,t=nM(),ZT(t)){if("selectionStart"in t)var r={start:t.selectionStart,end:t.selectionEnd};else e:{r=(r=t.ownerDocument)&&r.defaultView||window;var n=r.getSelection&&r.getSelection();if(n&&n.rangeCount!==0){r=n.anchorNode;var i=n.anchorOffset,o=n.focusNode;n=n.focusOffset;try{r.nodeType,o.nodeType}catch{r=null;break e}var a=0,s=-1,c=-1,l=0,f=0,u=t,d=null;t:for(;;){for(var h;u!==r||i!==0&&u.nodeType!==3||(s=a+i),u!==o||n!==0&&u.nodeType!==3||(c=a+n),u.nodeType===3&&(a+=u.nodeValue.length),(h=u.firstChild)!==null;)d=u,u=h;for(;;){if(u===t)break t;if(d===r&&++l===i&&(s=a),d===o&&++f===n&&(c=a),(h=u.nextSibling)!==null)break;u=d,d=u.parentNode}u=h}r=s===-1||c===-1?null:{start:s,end:c}}else r=null}r=r||{start:0,end:0}}else r=null;for(_3={focusedElem:t,selectionRange:r},Kv=!1,Ot=e;Ot!==null;)if(e=Ot,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,Ot=t;else for(;Ot!==null;){e=Ot;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 p=g.memoizedProps,v=g.memoizedState,y=e.stateNode,m=y.getSnapshotBeforeUpdate(e.elementType===e.type?p:Hs(e.type,p),v);y.__reactInternalSnapshotBeforeUpdate=m}break;case 3:var w=e.stateNode.containerInfo;w.nodeType===1?w.textContent="":w.nodeType===9&&w.documentElement&&w.removeChild(w.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(gt(163))}}catch(x){ti(e,e.return,x)}if(t=e.sibling,t!==null){t.return=e.return,Ot=t;break}Ot=e.return}return g=w6,w6=!1,g}function dp(t,e,r){var n=e.updateQueue;if(n=n!==null?n.lastEffect:null,n!==null){var i=n=n.next;do{if((i.tag&t)===t){var o=i.destroy;i.destroy=void 0,o!==void 0&&B3(e,r,o)}i=i.next}while(i!==n)}}function z5(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var r=e=e.next;do{if((r.tag&t)===t){var n=r.create;r.destroy=n()}r=r.next}while(r!==e)}}function G3(t){var e=t.ref;if(e!==null){var r=t.stateNode;switch(t.tag){case 5:t=r;break;default:t=r}typeof e=="function"?e(t):e.current=t}}function ZM(t){var e=t.alternate;e!==null&&(t.alternate=null,ZM(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[Gc],delete e[Jp],delete e[D3],delete e[dH],delete e[hH])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function QM(t){return t.tag===5||t.tag===3||t.tag===4}function x6(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||QM(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function W3(t,e,r){var n=t.tag;if(n===5||n===6)t=t.stateNode,e?r.nodeType===8?r.parentNode.insertBefore(t,e):r.insertBefore(t,e):(r.nodeType===8?(e=r.parentNode,e.insertBefore(t,r)):(e=r,e.appendChild(t)),r=r._reactRootContainer,r!=null||e.onclick!==null||(e.onclick=Yv));else if(n!==4&&(t=t.child,t!==null))for(W3(t,e,r),t=t.sibling;t!==null;)W3(t,e,r),t=t.sibling}function z3(t,e,r){var n=t.tag;if(n===5||n===6)t=t.stateNode,e?r.insertBefore(t,e):r.appendChild(t);else if(n!==4&&(t=t.child,t!==null))for(z3(t,e,r),t=t.sibling;t!==null;)z3(t,e,r),t=t.sibling}var ro=null,qs=!1;function du(t,e,r){for(r=r.child;r!==null;)eP(t,e,r),r=r.sibling}function eP(t,e,r){if($c&&typeof $c.onCommitFiberUnmount=="function")try{$c.onCommitFiberUnmount(N5,r)}catch{}switch(r.tag){case 5:Eo||x0(r,e);case 6:var n=ro,i=qs;ro=null,du(t,e,r),ro=n,qs=i,ro!==null&&(qs?(t=ro,r=r.stateNode,t.nodeType===8?t.parentNode.removeChild(r):t.removeChild(r)):ro.removeChild(r.stateNode));break;case 18:ro!==null&&(qs?(t=ro,r=r.stateNode,t.nodeType===8?Ex(t.parentNode,r):t.nodeType===1&&Ex(t,r),Hp(t)):Ex(ro,r.stateNode));break;case 4:n=ro,i=qs,ro=r.stateNode.containerInfo,qs=!0,du(t,e,r),ro=n,qs=i;break;case 0:case 11:case 14:case 15:if(!Eo&&(n=r.updateQueue,n!==null&&(n=n.lastEffect,n!==null))){i=n=n.next;do{var o=i,a=o.destroy;o=o.tag,a!==void 0&&(o&2||o&4)&&B3(r,e,a),i=i.next}while(i!==n)}du(t,e,r);break;case 1:if(!Eo&&(x0(r,e),n=r.stateNode,typeof n.componentWillUnmount=="function"))try{n.props=r.memoizedProps,n.state=r.memoizedState,n.componentWillUnmount()}catch(s){ti(r,e,s)}du(t,e,r);break;case 21:du(t,e,r);break;case 22:r.mode&1?(Eo=(n=Eo)||r.memoizedState!==null,du(t,e,r),Eo=n):du(t,e,r);break;default:du(t,e,r)}}function C6(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var r=t.stateNode;r===null&&(r=t.stateNode=new OH),e.forEach(function(n){var i=UH.bind(null,t,n);r.has(n)||(r.add(n),n.then(i,i))})}}function Us(t,e){var r=e.deletions;if(r!==null)for(var n=0;n<r.length;n++){var i=r[n];try{var o=t,a=e,s=a;e:for(;s!==null;){switch(s.tag){case 5:ro=s.stateNode,qs=!1;break e;case 3:ro=s.stateNode.containerInfo,qs=!0;break e;case 4:ro=s.stateNode.containerInfo,qs=!0;break e}s=s.return}if(ro===null)throw Error(gt(160));eP(o,a,i),ro=null,qs=!1;var c=i.alternate;c!==null&&(c.return=null),i.return=null}catch(l){ti(i,e,l)}}if(e.subtreeFlags&12854)for(e=e.child;e!==null;)tP(e,t),e=e.sibling}function tP(t,e){var r=t.alternate,n=t.flags;switch(t.tag){case 0:case 11:case 14:case 15:if(Us(e,t),Mc(t),n&4){try{dp(3,t,t.return),z5(3,t)}catch(p){ti(t,t.return,p)}try{dp(5,t,t.return)}catch(p){ti(t,t.return,p)}}break;case 1:Us(e,t),Mc(t),n&512&&r!==null&&x0(r,r.return);break;case 5:if(Us(e,t),Mc(t),n&512&&r!==null&&x0(r,r.return),t.flags&32){var i=t.stateNode;try{Wp(i,"")}catch(p){ti(t,t.return,p)}}if(n&4&&(i=t.stateNode,i!=null)){var o=t.memoizedProps,a=r!==null?r.memoizedProps:o,s=t.type,c=t.updateQueue;if(t.updateQueue=null,c!==null)try{s==="input"&&o.type==="radio"&&o.name!=null&&TO(i,o),h3(s,a);var l=h3(s,o);for(a=0;a<c.length;a+=2){var f=c[a],u=c[a+1];f==="style"?IO(i,u):f==="dangerouslySetInnerHTML"?bO(i,u):f==="children"?Wp(i,u):UT(i,f,u,l)}switch(s){case"input":c3(i,o);break;case"textarea":_O(i,o);break;case"select":var d=i._wrapperState.wasMultiple;i._wrapperState.wasMultiple=!!o.multiple;var h=o.value;h!=null?G0(i,!!o.multiple,h,!1):d!==!!o.multiple&&(o.defaultValue!=null?G0(i,!!o.multiple,o.defaultValue,!0):G0(i,!!o.multiple,o.multiple?[]:"",!1))}i[Jp]=o}catch(p){ti(t,t.return,p)}}break;case 6:if(Us(e,t),Mc(t),n&4){if(t.stateNode===null)throw Error(gt(162));i=t.stateNode,o=t.memoizedProps;try{i.nodeValue=o}catch(p){ti(t,t.return,p)}}break;case 3:if(Us(e,t),Mc(t),n&4&&r!==null&&r.memoizedState.isDehydrated)try{Hp(e.containerInfo)}catch(p){ti(t,t.return,p)}break;case 4:Us(e,t),Mc(t);break;case 13:Us(e,t),Mc(t),i=t.child,i.flags&8192&&(o=i.memoizedState!==null,i.stateNode.isHidden=o,!o||i.alternate!==null&&i.alternate.memoizedState!==null||(y_=li())),n&4&&C6(t);break;case 22:if(f=r!==null&&r.memoizedState!==null,t.mode&1?(Eo=(l=Eo)||f,Us(e,t),Eo=l):Us(e,t),Mc(t),n&8192){if(l=t.memoizedState!==null,(t.stateNode.isHidden=l)&&!f&&t.mode&1)for(Ot=t,f=t.child;f!==null;){for(u=Ot=f;Ot!==null;){switch(d=Ot,h=d.child,d.tag){case 0:case 11:case 14:case 15:dp(4,d,d.return);break;case 1:x0(d,d.return);var g=d.stateNode;if(typeof g.componentWillUnmount=="function"){n=d,r=d.return;try{e=n,g.props=e.memoizedProps,g.state=e.memoizedState,g.componentWillUnmount()}catch(p){ti(n,r,p)}}break;case 5:x0(d,d.return);break;case 22:if(d.memoizedState!==null){T6(u);continue}}h!==null?(h.return=d,Ot=h):T6(u)}f=f.sibling}e:for(f=null,u=t;;){if(u.tag===5){if(f===null){f=u;try{i=u.stateNode,l?(o=i.style,typeof o.setProperty=="function"?o.setProperty("display","none","important"):o.display="none"):(s=u.stateNode,c=u.memoizedProps.style,a=c!=null&&c.hasOwnProperty("display")?c.display:null,s.style.display=DO("display",a))}catch(p){ti(t,t.return,p)}}}else if(u.tag===6){if(f===null)try{u.stateNode.nodeValue=l?"":u.memoizedProps}catch(p){ti(t,t.return,p)}}else if((u.tag!==22&&u.tag!==23||u.memoizedState===null||u===t)&&u.child!==null){u.child.return=u,u=u.child;continue}if(u===t)break e;for(;u.sibling===null;){if(u.return===null||u.return===t)break e;f===u&&(f=null),u=u.return}f===u&&(f=null),u.sibling.return=u.return,u=u.sibling}}break;case 19:Us(e,t),Mc(t),n&4&&C6(t);break;case 21:break;default:Us(e,t),Mc(t)}}function Mc(t){var e=t.flags;if(e&2){try{e:{for(var r=t.return;r!==null;){if(QM(r)){var n=r;break e}r=r.return}throw Error(gt(160))}switch(n.tag){case 5:var i=n.stateNode;n.flags&32&&(Wp(i,""),n.flags&=-33);var o=x6(t);z3(t,o,i);break;case 3:case 4:var a=n.stateNode.containerInfo,s=x6(t);W3(t,s,a);break;default:throw Error(gt(161))}}catch(c){ti(t,t.return,c)}t.flags&=-3}e&4096&&(t.flags&=-4097)}function PH(t,e,r){Ot=t,nP(t)}function nP(t,e,r){for(var n=(t.mode&1)!==0;Ot!==null;){var i=Ot,o=i.child;if(i.tag===22&&n){var a=i.memoizedState!==null||Xm;if(!a){var s=i.alternate,c=s!==null&&s.memoizedState!==null||Eo;s=Xm;var l=Eo;if(Xm=a,(Eo=c)&&!l)for(Ot=i;Ot!==null;)a=Ot,c=a.child,a.tag===22&&a.memoizedState!==null?_6(i):c!==null?(c.return=a,Ot=c):_6(i);for(;o!==null;)Ot=o,nP(o),o=o.sibling;Ot=i,Xm=s,Eo=l}S6(t)}else i.subtreeFlags&8772&&o!==null?(o.return=i,Ot=o):S6(t)}}function S6(t){for(;Ot!==null;){var e=Ot;if(e.flags&8772){var r=e.alternate;try{if(e.flags&8772)switch(e.tag){case 0:case 11:case 15:Eo||z5(5,e);break;case 1:var n=e.stateNode;if(e.flags&4&&!Eo)if(r===null)n.componentDidMount();else{var i=e.elementType===e.type?r.memoizedProps:Hs(e.type,r.memoizedProps);n.componentDidUpdate(i,r.memoizedState,n.__reactInternalSnapshotBeforeUpdate)}var o=e.updateQueue;o!==null&&a6(e,o,n);break;case 3:var a=e.updateQueue;if(a!==null){if(r=null,e.child!==null)switch(e.child.tag){case 5:r=e.child.stateNode;break;case 1:r=e.child.stateNode}a6(e,a,r)}break;case 5:var s=e.stateNode;if(r===null&&e.flags&4){r=s;var c=e.memoizedProps;switch(e.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&r.focus();break;case"img":c.src&&(r.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(e.memoizedState===null){var l=e.alternate;if(l!==null){var f=l.memoizedState;if(f!==null){var u=f.dehydrated;u!==null&&Hp(u)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(gt(163))}Eo||e.flags&512&&G3(e)}catch(d){ti(e,e.return,d)}}if(e===t){Ot=null;break}if(r=e.sibling,r!==null){r.return=e.return,Ot=r;break}Ot=e.return}}function T6(t){for(;Ot!==null;){var e=Ot;if(e===t){Ot=null;break}var r=e.sibling;if(r!==null){r.return=e.return,Ot=r;break}Ot=e.return}}function _6(t){for(;Ot!==null;){var e=Ot;try{switch(e.tag){case 0:case 11:case 15:var r=e.return;try{z5(4,e)}catch(c){ti(e,r,c)}break;case 1:var n=e.stateNode;if(typeof n.componentDidMount=="function"){var i=e.return;try{n.componentDidMount()}catch(c){ti(e,i,c)}}var o=e.return;try{G3(e)}catch(c){ti(e,o,c)}break;case 5:var a=e.return;try{G3(e)}catch(c){ti(e,a,c)}}}catch(c){ti(e,e.return,c)}if(e===t){Ot=null;break}var s=e.sibling;if(s!==null){s.return=e.return,Ot=s;break}Ot=e.return}}var RH=Math.ceil,sy=cu.ReactCurrentDispatcher,m_=cu.ReactCurrentOwner,gs=cu.ReactCurrentBatchConfig,zn=0,Yi=null,Si=null,so=0,Ra=0,C0=yf(0),Vi=0,r1=null,wd=0,$5=0,v_=0,hp=null,aa=null,y_=0,vh=1/0,Ol=null,cy=!1,$3=null,Ku=null,Ym=!1,Au=null,ly=0,gp=0,j3=null,uv=-1,fv=0;function Ho(){return zn&6?li():uv!==-1?uv:uv=li()}function qu(t){return t.mode&1?zn&2&&so!==0?so&-so:pH.transition!==null?(fv===0&&(fv=BO()),fv):(t=nr,t!==0||(t=window.event,t=t===void 0?16:KO(t.type)),t):1}function sc(t,e,r,n){if(50<gp)throw gp=0,j3=null,Error(gt(185));$1(t,r,n),(!(zn&2)||t!==Yi)&&(t===Yi&&(!(zn&2)&&($5|=r),Vi===4&&Mu(t,so)),ha(t,n),r===1&&zn===0&&!(e.mode&1)&&(vh=li()+500,B5&&wf()))}function ha(t,e){var r=t.callbackNode;pj(t,e);var n=Hv(t,t===Yi?so:0);if(n===0)r!==null&&Lb(r),t.callbackNode=null,t.callbackPriority=0;else if(e=n&-n,t.callbackPriority!==e){if(r!=null&&Lb(r),e===1)t.tag===0?gH(E6.bind(null,t)):dM(E6.bind(null,t)),uH(function(){!(zn&6)&&wf()}),r=null;else{switch(GO(n)){case 1:r=$T;break;case 4:r=FO;break;case 16:r=jv;break;case 536870912:r=UO;break;default:r=jv}r=uP(r,rP.bind(null,t))}t.callbackPriority=e,t.callbackNode=r}}function rP(t,e){if(uv=-1,fv=0,zn&6)throw Error(gt(327));var r=t.callbackNode;if(H0()&&t.callbackNode!==r)return null;var n=Hv(t,t===Yi?so:0);if(n===0)return null;if(n&30||n&t.expiredLanes||e)e=uy(t,n);else{e=n;var i=zn;zn|=2;var o=oP();(Yi!==t||so!==e)&&(Ol=null,vh=li()+500,ad(t,e));do try{NH();break}catch(s){iP(t,s)}while(!0);r_(),sy.current=o,zn=i,Si!==null?e=0:(Yi=null,so=0,e=Vi)}if(e!==0){if(e===2&&(i=y3(t),i!==0&&(n=i,e=H3(t,i))),e===1)throw r=r1,ad(t,0),Mu(t,n),ha(t,li()),r;if(e===6)Mu(t,n);else{if(i=t.current.alternate,!(n&30)&&!LH(i)&&(e=uy(t,n),e===2&&(o=y3(t),o!==0&&(n=o,e=H3(t,o))),e===1))throw r=r1,ad(t,0),Mu(t,n),ha(t,li()),r;switch(t.finishedWork=i,t.finishedLanes=n,e){case 0:case 1:throw Error(gt(345));case 2:Gf(t,aa,Ol);break;case 3:if(Mu(t,n),(n&130023424)===n&&(e=y_+500-li(),10<e)){if(Hv(t,0)!==0)break;if(i=t.suspendedLanes,(i&n)!==n){Ho(),t.pingedLanes|=t.suspendedLanes&i;break}t.timeoutHandle=b3(Gf.bind(null,t,aa,Ol),e);break}Gf(t,aa,Ol);break;case 4:if(Mu(t,n),(n&4194240)===n)break;for(e=t.eventTimes,i=-1;0<n;){var a=31-ac(n);o=1<<a,a=e[a],a>i&&(i=a),n&=~o}if(n=i,n=li()-n,n=(120>n?120:480>n?480:1080>n?1080:1920>n?1920:3e3>n?3e3:4320>n?4320:1960*RH(n/1960))-n,10<n){t.timeoutHandle=b3(Gf.bind(null,t,aa,Ol),n);break}Gf(t,aa,Ol);break;case 5:Gf(t,aa,Ol);break;default:throw Error(gt(329))}}}return ha(t,li()),t.callbackNode===r?rP.bind(null,t):null}function H3(t,e){var r=hp;return t.current.memoizedState.isDehydrated&&(ad(t,e).flags|=256),t=uy(t,e),t!==2&&(e=aa,aa=r,e!==null&&K3(e)),t}function K3(t){aa===null?aa=t:aa.push.apply(aa,t)}function LH(t){for(var e=t;;){if(e.flags&16384){var r=e.updateQueue;if(r!==null&&(r=r.stores,r!==null))for(var n=0;n<r.length;n++){var i=r[n],o=i.getSnapshot;i=i.value;try{if(!lc(o(),i))return!1}catch{return!1}}}if(r=e.child,e.subtreeFlags&16384&&r!==null)r.return=e,e=r;else{if(e===t)break;for(;e.sibling===null;){if(e.return===null||e.return===t)return!0;e=e.return}e.sibling.return=e.return,e=e.sibling}}return!0}function Mu(t,e){for(e&=~v_,e&=~$5,t.suspendedLanes|=e,t.pingedLanes&=~e,t=t.expirationTimes;0<e;){var r=31-ac(e),n=1<<r;t[r]=-1,e&=~n}}function E6(t){if(zn&6)throw Error(gt(327));H0();var e=Hv(t,0);if(!(e&1))return ha(t,li()),null;var r=uy(t,e);if(t.tag!==0&&r===2){var n=y3(t);n!==0&&(e=n,r=H3(t,n))}if(r===1)throw r=r1,ad(t,0),Mu(t,e),ha(t,li()),r;if(r===6)throw Error(gt(345));return t.finishedWork=t.current.alternate,t.finishedLanes=e,Gf(t,aa,Ol),ha(t,li()),null}function w_(t,e){var r=zn;zn|=1;try{return t(e)}finally{zn=r,zn===0&&(vh=li()+500,B5&&wf())}}function xd(t){Au!==null&&Au.tag===0&&!(zn&6)&&H0();var e=zn;zn|=1;var r=gs.transition,n=nr;try{if(gs.transition=null,nr=1,t)return t()}finally{nr=n,gs.transition=r,zn=e,!(zn&6)&&wf()}}function x_(){Ra=C0.current,Tr(C0)}function ad(t,e){t.finishedWork=null,t.finishedLanes=0;var r=t.timeoutHandle;if(r!==-1&&(t.timeoutHandle=-1,lH(r)),Si!==null)for(r=Si.return;r!==null;){var n=r;switch(e_(n),n.tag){case 1:n=n.type.childContextTypes,n!=null&&Jv();break;case 3:ph(),Tr(fa),Tr(Oo),l_();break;case 5:c_(n);break;case 4:ph();break;case 13:Tr($r);break;case 19:Tr($r);break;case 10:i_(n.type._context);break;case 22:case 23:x_()}r=r.return}if(Yi=t,Si=t=Xu(t.current,null),so=Ra=e,Vi=0,r1=null,v_=$5=wd=0,aa=hp=null,ed!==null){for(e=0;e<ed.length;e++)if(r=ed[e],n=r.interleaved,n!==null){r.interleaved=null;var i=n.next,o=r.pending;if(o!==null){var a=o.next;o.next=i,n.next=a}r.pending=n}ed=null}return t}function iP(t,e){do{var r=Si;try{if(r_(),sv.current=ay,oy){for(var n=Kr.memoizedState;n!==null;){var i=n.queue;i!==null&&(i.pending=null),n=n.next}oy=!1}if(yd=0,Xi=Li=Kr=null,fp=!1,e1=0,m_.current=null,r===null||r.return===null){Vi=1,r1=e,Si=null;break}e:{var o=t,a=r.return,s=r,c=e;if(e=so,s.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var l=c,f=s,u=f.tag;if(!(f.mode&1)&&(u===0||u===11||u===15)){var d=f.alternate;d?(f.updateQueue=d.updateQueue,f.memoizedState=d.memoizedState,f.lanes=d.lanes):(f.updateQueue=null,f.memoizedState=null)}var h=d6(a);if(h!==null){h.flags&=-257,h6(h,a,s,o,e),h.mode&1&&f6(o,l,e),e=h,c=l;var g=e.updateQueue;if(g===null){var p=new Set;p.add(c),e.updateQueue=p}else g.add(c);break e}else{if(!(e&1)){f6(o,l,e),C_();break e}c=Error(gt(426))}}else if(Rr&&s.mode&1){var v=d6(a);if(v!==null){!(v.flags&65536)&&(v.flags|=256),h6(v,a,s,o,e),t_(mh(c,s));break e}}o=c=mh(c,s),Vi!==4&&(Vi=2),hp===null?hp=[o]:hp.push(o),o=a;do{switch(o.tag){case 3:o.flags|=65536,e&=-e,o.lanes|=e;var y=GM(o,c,e);o6(o,y);break e;case 1:s=c;var m=o.type,w=o.stateNode;if(!(o.flags&128)&&(typeof m.getDerivedStateFromError=="function"||w!==null&&typeof w.componentDidCatch=="function"&&(Ku===null||!Ku.has(w)))){o.flags|=65536,e&=-e,o.lanes|=e;var x=WM(o,s,e);o6(o,x);break e}}o=o.return}while(o!==null)}sP(r)}catch(C){e=C,Si===r&&r!==null&&(Si=r=r.return);continue}break}while(!0)}function oP(){var t=sy.current;return sy.current=ay,t===null?ay:t}function C_(){(Vi===0||Vi===3||Vi===2)&&(Vi=4),Yi===null||!(wd&268435455)&&!($5&268435455)||Mu(Yi,so)}function uy(t,e){var r=zn;zn|=2;var n=oP();(Yi!==t||so!==e)&&(Ol=null,ad(t,e));do try{AH();break}catch(i){iP(t,i)}while(!0);if(r_(),zn=r,sy.current=n,Si!==null)throw Error(gt(261));return Yi=null,so=0,Vi}function AH(){for(;Si!==null;)aP(Si)}function NH(){for(;Si!==null&&!aj();)aP(Si)}function aP(t){var e=lP(t.alternate,t,Ra);t.memoizedProps=t.pendingProps,e===null?sP(t):Si=e,m_.current=null}function sP(t){var e=t;do{var r=e.alternate;if(t=e.return,e.flags&32768){if(r=IH(r,e),r!==null){r.flags&=32767,Si=r;return}if(t!==null)t.flags|=32768,t.subtreeFlags=0,t.deletions=null;else{Vi=6,Si=null;return}}else if(r=DH(r,e,Ra),r!==null){Si=r;return}if(e=e.sibling,e!==null){Si=e;return}Si=e=t}while(e!==null);Vi===0&&(Vi=5)}function Gf(t,e,r){var n=nr,i=gs.transition;try{gs.transition=null,nr=1,kH(t,e,r,n)}finally{gs.transition=i,nr=n}return null}function kH(t,e,r,n){do H0();while(Au!==null);if(zn&6)throw Error(gt(327));r=t.finishedWork;var i=t.finishedLanes;if(r===null)return null;if(t.finishedWork=null,t.finishedLanes=0,r===t.current)throw Error(gt(177));t.callbackNode=null,t.callbackPriority=0;var o=r.lanes|r.childLanes;if(mj(t,o),t===Yi&&(Si=Yi=null,so=0),!(r.subtreeFlags&2064)&&!(r.flags&2064)||Ym||(Ym=!0,uP(jv,function(){return H0(),null})),o=(r.flags&15990)!==0,r.subtreeFlags&15990||o){o=gs.transition,gs.transition=null;var a=nr;nr=1;var s=zn;zn|=4,m_.current=null,MH(t,r),tP(r,t),nH(_3),Kv=!!T3,_3=T3=null,t.current=r,PH(r),sj(),zn=s,nr=a,gs.transition=o}else t.current=r;if(Ym&&(Ym=!1,Au=t,ly=i),o=t.pendingLanes,o===0&&(Ku=null),uj(r.stateNode),ha(t,li()),e!==null)for(n=t.onRecoverableError,r=0;r<e.length;r++)i=e[r],n(i.value,{componentStack:i.stack,digest:i.digest});if(cy)throw cy=!1,t=$3,$3=null,t;return ly&1&&t.tag!==0&&H0(),o=t.pendingLanes,o&1?t===j3?gp++:(gp=0,j3=t):gp=0,wf(),null}function H0(){if(Au!==null){var t=GO(ly),e=gs.transition,r=nr;try{if(gs.transition=null,nr=16>t?16:t,Au===null)var n=!1;else{if(t=Au,Au=null,ly=0,zn&6)throw Error(gt(331));var i=zn;for(zn|=4,Ot=t.current;Ot!==null;){var o=Ot,a=o.child;if(Ot.flags&16){var s=o.deletions;if(s!==null){for(var c=0;c<s.length;c++){var l=s[c];for(Ot=l;Ot!==null;){var f=Ot;switch(f.tag){case 0:case 11:case 15:dp(8,f,o)}var u=f.child;if(u!==null)u.return=f,Ot=u;else for(;Ot!==null;){f=Ot;var d=f.sibling,h=f.return;if(ZM(f),f===l){Ot=null;break}if(d!==null){d.return=h,Ot=d;break}Ot=h}}}var g=o.alternate;if(g!==null){var p=g.child;if(p!==null){g.child=null;do{var v=p.sibling;p.sibling=null,p=v}while(p!==null)}}Ot=o}}if(o.subtreeFlags&2064&&a!==null)a.return=o,Ot=a;else e:for(;Ot!==null;){if(o=Ot,o.flags&2048)switch(o.tag){case 0:case 11:case 15:dp(9,o,o.return)}var y=o.sibling;if(y!==null){y.return=o.return,Ot=y;break e}Ot=o.return}}var m=t.current;for(Ot=m;Ot!==null;){a=Ot;var w=a.child;if(a.subtreeFlags&2064&&w!==null)w.return=a,Ot=w;else e:for(a=m;Ot!==null;){if(s=Ot,s.flags&2048)try{switch(s.tag){case 0:case 11:case 15:z5(9,s)}}catch(C){ti(s,s.return,C)}if(s===a){Ot=null;break e}var x=s.sibling;if(x!==null){x.return=s.return,Ot=x;break e}Ot=s.return}}if(zn=i,wf(),$c&&typeof $c.onPostCommitFiberRoot=="function")try{$c.onPostCommitFiberRoot(N5,t)}catch{}n=!0}return n}finally{nr=r,gs.transition=e}}return!1}function b6(t,e,r){e=mh(r,e),e=GM(t,e,1),t=Hu(t,e,1),e=Ho(),t!==null&&($1(t,1,e),ha(t,e))}function ti(t,e,r){if(t.tag===3)b6(t,t,r);else for(;e!==null;){if(e.tag===3){b6(e,t,r);break}else if(e.tag===1){var n=e.stateNode;if(typeof e.type.getDerivedStateFromError=="function"||typeof n.componentDidCatch=="function"&&(Ku===null||!Ku.has(n))){t=mh(r,t),t=WM(e,t,1),e=Hu(e,t,1),t=Ho(),e!==null&&($1(e,1,t),ha(e,t));break}}e=e.return}}function VH(t,e,r){var n=t.pingCache;n!==null&&n.delete(e),e=Ho(),t.pingedLanes|=t.suspendedLanes&r,Yi===t&&(so&r)===r&&(Vi===4||Vi===3&&(so&130023424)===so&&500>li()-y_?ad(t,0):v_|=r),ha(t,e)}function cP(t,e){e===0&&(t.mode&1?(e=Bm,Bm<<=1,!(Bm&130023424)&&(Bm=4194304)):e=1);var r=Ho();t=Yl(t,e),t!==null&&($1(t,e,r),ha(t,r))}function FH(t){var e=t.memoizedState,r=0;e!==null&&(r=e.retryLane),cP(t,r)}function UH(t,e){var r=0;switch(t.tag){case 13:var n=t.stateNode,i=t.memoizedState;i!==null&&(r=i.retryLane);break;case 19:n=t.stateNode;break;default:throw Error(gt(314))}n!==null&&n.delete(e),cP(t,r)}var lP;lP=function(t,e,r){if(t!==null)if(t.memoizedProps!==e.pendingProps||fa.current)sa=!0;else{if(!(t.lanes&r)&&!(e.flags&128))return sa=!1,bH(t,e,r);sa=!!(t.flags&131072)}else sa=!1,Rr&&e.flags&1048576&&hM(e,ey,e.index);switch(e.lanes=0,e.tag){case 2:var n=e.type;lv(t,e),t=e.pendingProps;var i=dh(e,Oo.current);j0(e,r),i=f_(null,e,n,t,i,r);var o=d_();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,da(n)?(o=!0,Zv(e)):o=!1,e.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,a_(e),i.updater=W5,e.stateNode=i,i._reactInternals=e,L3(e,n,t,r),e=k3(null,e,n,!0,o,r)):(e.tag=0,Rr&&o&&QT(e),zo(null,e,i,r),e=e.child),e;case 16:n=e.elementType;e:{switch(lv(t,e),t=e.pendingProps,i=n._init,n=i(n._payload),e.type=n,i=e.tag=GH(n),t=Hs(n,t),i){case 0:e=N3(null,e,n,t,r);break e;case 1:e=m6(null,e,n,t,r);break e;case 11:e=g6(null,e,n,t,r);break e;case 14:e=p6(null,e,n,Hs(n.type,t),r);break e}throw Error(gt(306,n,""))}return e;case 0:return n=e.type,i=e.pendingProps,i=e.elementType===n?i:Hs(n,i),N3(t,e,n,i,r);case 1:return n=e.type,i=e.pendingProps,i=e.elementType===n?i:Hs(n,i),m6(t,e,n,i,r);case 3:e:{if(HM(e),t===null)throw Error(gt(387));n=e.pendingProps,o=e.memoizedState,i=o.element,wM(t,e),ry(e,n,null,r);var a=e.memoizedState;if(n=a.element,o.isDehydrated)if(o={element:n,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},e.updateQueue.baseState=o,e.memoizedState=o,e.flags&256){i=mh(Error(gt(423)),e),e=v6(t,e,n,r,i);break e}else if(n!==i){i=mh(Error(gt(424)),e),e=v6(t,e,n,r,i);break e}else for(Na=ju(e.stateNode.containerInfo.firstChild),Fa=e,Rr=!0,Ys=null,r=vM(e,null,n,r),e.child=r;r;)r.flags=r.flags&-3|4096,r=r.sibling;else{if(hh(),n===i){e=Jl(t,e,r);break e}zo(t,e,n,r)}e=e.child}return e;case 5:return xM(e),t===null&&M3(e),n=e.type,i=e.pendingProps,o=t!==null?t.memoizedProps:null,a=i.children,E3(n,i)?a=null:o!==null&&E3(n,o)&&(e.flags|=32),jM(t,e),zo(t,e,a,r),e.child;case 6:return t===null&&M3(e),null;case 13:return KM(t,e,r);case 4:return s_(e,e.stateNode.containerInfo),n=e.pendingProps,t===null?e.child=gh(e,null,n,r):zo(t,e,n,r),e.child;case 11:return n=e.type,i=e.pendingProps,i=e.elementType===n?i:Hs(n,i),g6(t,e,n,i,r);case 7:return zo(t,e,e.pendingProps,r),e.child;case 8:return zo(t,e,e.pendingProps.children,r),e.child;case 12:return zo(t,e,e.pendingProps.children,r),e.child;case 10:e:{if(n=e.type._context,i=e.pendingProps,o=e.memoizedProps,a=i.value,pr(ty,n._currentValue),n._currentValue=a,o!==null)if(lc(o.value,a)){if(o.children===i.children&&!fa.current){e=Jl(t,e,r);break e}}else for(o=e.child,o!==null&&(o.return=e);o!==null;){var s=o.dependencies;if(s!==null){a=o.child;for(var c=s.firstContext;c!==null;){if(c.context===n){if(o.tag===1){c=zl(-1,r&-r),c.tag=2;var l=o.updateQueue;if(l!==null){l=l.shared;var f=l.pending;f===null?c.next=c:(c.next=f.next,f.next=c),l.pending=c}}o.lanes|=r,c=o.alternate,c!==null&&(c.lanes|=r),P3(o.return,r,e),s.lanes|=r;break}c=c.next}}else if(o.tag===10)a=o.type===e.type?null:o.child;else if(o.tag===18){if(a=o.return,a===null)throw Error(gt(341));a.lanes|=r,s=a.alternate,s!==null&&(s.lanes|=r),P3(a,r,e),a=o.sibling}else a=o.child;if(a!==null)a.return=o;else for(a=o;a!==null;){if(a===e){a=null;break}if(o=a.sibling,o!==null){o.return=a.return,a=o;break}a=a.return}o=a}zo(t,e,i.children,r),e=e.child}return e;case 9:return i=e.type,n=e.pendingProps.children,j0(e,r),i=ms(i),n=n(i),e.flags|=1,zo(t,e,n,r),e.child;case 14:return n=e.type,i=Hs(n,e.pendingProps),i=Hs(n.type,i),p6(t,e,n,i,r);case 15:return zM(t,e,e.type,e.pendingProps,r);case 17:return n=e.type,i=e.pendingProps,i=e.elementType===n?i:Hs(n,i),lv(t,e),e.tag=1,da(n)?(t=!0,Zv(e)):t=!1,j0(e,r),BM(e,n,i),L3(e,n,i,r),k3(null,e,n,!0,t,r);case 19:return qM(t,e,r);case 22:return $M(t,e,r)}throw Error(gt(156,e.tag))};function uP(t,e){return VO(t,e)}function BH(t,e,r,n){this.tag=t,this.key=r,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=n,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function hs(t,e,r,n){return new BH(t,e,r,n)}function S_(t){return t=t.prototype,!(!t||!t.isReactComponent)}function GH(t){if(typeof t=="function")return S_(t)?1:0;if(t!=null){if(t=t.$$typeof,t===GT)return 11;if(t===WT)return 14}return 2}function Xu(t,e){var r=t.alternate;return r===null?(r=hs(t.tag,e,t.key,t.mode),r.elementType=t.elementType,r.type=t.type,r.stateNode=t.stateNode,r.alternate=t,t.alternate=r):(r.pendingProps=e,r.type=t.type,r.flags=0,r.subtreeFlags=0,r.deletions=null),r.flags=t.flags&14680064,r.childLanes=t.childLanes,r.lanes=t.lanes,r.child=t.child,r.memoizedProps=t.memoizedProps,r.memoizedState=t.memoizedState,r.updateQueue=t.updateQueue,e=t.dependencies,r.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},r.sibling=t.sibling,r.index=t.index,r.ref=t.ref,r}function dv(t,e,r,n,i,o){var a=2;if(n=t,typeof t=="function")S_(t)&&(a=1);else if(typeof t=="string")a=5;else e:switch(t){case f0:return sd(r.children,i,o,e);case BT:a=8,i|=8;break;case r3:return t=hs(12,r,e,i|2),t.elementType=r3,t.lanes=o,t;case i3:return t=hs(13,r,e,i),t.elementType=i3,t.lanes=o,t;case o3:return t=hs(19,r,e,i),t.elementType=o3,t.lanes=o,t;case xO:return j5(r,i,o,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case yO:a=10;break e;case wO:a=9;break e;case GT:a=11;break e;case WT:a=14;break e;case _u:a=16,n=null;break e}throw Error(gt(130,t==null?t:typeof t,""))}return e=hs(a,r,e,i),e.elementType=t,e.type=n,e.lanes=o,e}function sd(t,e,r,n){return t=hs(7,t,n,e),t.lanes=r,t}function j5(t,e,r,n){return t=hs(22,t,n,e),t.elementType=xO,t.lanes=r,t.stateNode={isHidden:!1},t}function Lx(t,e,r){return t=hs(6,t,null,e),t.lanes=r,t}function Ax(t,e,r){return e=hs(4,t.children!==null?t.children:[],t.key,e),e.lanes=r,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function WH(t,e,r,n,i){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=gx(0),this.expirationTimes=gx(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=gx(0),this.identifierPrefix=n,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function T_(t,e,r,n,i,o,a,s,c){return t=new WH(t,e,r,s,c),e===1?(e=1,o===!0&&(e|=8)):e=0,o=hs(3,null,null,e),t.current=o,o.stateNode=t,o.memoizedState={element:n,isDehydrated:r,cache:null,transitions:null,pendingSuspenseBoundaries:null},a_(o),t}function zH(t,e,r){var n=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:u0,key:n==null?null:""+n,children:t,containerInfo:e,implementation:r}}function fP(t){if(!t)return nf;t=t._reactInternals;e:{if(kd(t)!==t||t.tag!==1)throw Error(gt(170));var e=t;do{switch(e.tag){case 3:e=e.stateNode.context;break e;case 1:if(da(e.type)){e=e.stateNode.__reactInternalMemoizedMergedChildContext;break e}}e=e.return}while(e!==null);throw Error(gt(171))}if(t.tag===1){var r=t.type;if(da(r))return fM(t,r,e)}return e}function dP(t,e,r,n,i,o,a,s,c){return t=T_(r,n,!0,t,i,o,a,s,c),t.context=fP(null),r=t.current,n=Ho(),i=qu(r),o=zl(n,i),o.callback=e??null,Hu(r,o,i),t.current.lanes=i,$1(t,i,n),ha(t,n),t}function H5(t,e,r,n){var i=e.current,o=Ho(),a=qu(i);return r=fP(r),e.context===null?e.context=r:e.pendingContext=r,e=zl(o,a),e.payload={element:t},n=n===void 0?null:n,n!==null&&(e.callback=n),t=Hu(i,e,a),t!==null&&(sc(t,i,a,o),av(t,i,a)),a}function fy(t){if(t=t.current,!t.child)return null;switch(t.child.tag){case 5:return t.child.stateNode;default:return t.child.stateNode}}function D6(t,e){if(t=t.memoizedState,t!==null&&t.dehydrated!==null){var r=t.retryLane;t.retryLane=r!==0&&r<e?r:e}}function __(t,e){D6(t,e),(t=t.alternate)&&D6(t,e)}function $H(){return null}var hP=typeof reportError=="function"?reportError:function(t){console.error(t)};function E_(t){this._internalRoot=t}K5.prototype.render=E_.prototype.render=function(t){var e=this._internalRoot;if(e===null)throw Error(gt(409));H5(t,e,null,null)};K5.prototype.unmount=E_.prototype.unmount=function(){var t=this._internalRoot;if(t!==null){this._internalRoot=null;var e=t.containerInfo;xd(function(){H5(null,t,null,null)}),e[Xl]=null}};function K5(t){this._internalRoot=t}K5.prototype.unstable_scheduleHydration=function(t){if(t){var e=$O();t={blockedOn:null,target:t,priority:e};for(var r=0;r<Ou.length&&e!==0&&e<Ou[r].priority;r++);Ou.splice(r,0,t),r===0&&HO(t)}};function b_(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)}function q5(t){return!(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11&&(t.nodeType!==8||t.nodeValue!==" react-mount-point-unstable "))}function I6(){}function jH(t,e,r,n,i){if(i){if(typeof n=="function"){var o=n;n=function(){var l=fy(a);o.call(l)}}var a=dP(e,n,t,0,null,!1,!1,"",I6);return t._reactRootContainer=a,t[Xl]=a.current,Xp(t.nodeType===8?t.parentNode:t),xd(),a}for(;i=t.lastChild;)t.removeChild(i);if(typeof n=="function"){var s=n;n=function(){var l=fy(c);s.call(l)}}var c=T_(t,0,!1,null,null,!1,!1,"",I6);return t._reactRootContainer=c,t[Xl]=c.current,Xp(t.nodeType===8?t.parentNode:t),xd(function(){H5(e,c,r,n)}),c}function X5(t,e,r,n,i){var o=r._reactRootContainer;if(o){var a=o;if(typeof i=="function"){var s=i;i=function(){var c=fy(a);s.call(c)}}H5(e,a,t,i)}else a=jH(r,e,t,i,n);return fy(a)}WO=function(t){switch(t.tag){case 3:var e=t.stateNode;if(e.current.memoizedState.isDehydrated){var r=Wg(e.pendingLanes);r!==0&&(jT(e,r|1),ha(e,li()),!(zn&6)&&(vh=li()+500,wf()))}break;case 13:xd(function(){var n=Yl(t,1);if(n!==null){var i=Ho();sc(n,t,1,i)}}),__(t,1)}};HT=function(t){if(t.tag===13){var e=Yl(t,134217728);if(e!==null){var r=Ho();sc(e,t,134217728,r)}__(t,134217728)}};zO=function(t){if(t.tag===13){var e=qu(t),r=Yl(t,e);if(r!==null){var n=Ho();sc(r,t,e,n)}__(t,e)}};$O=function(){return nr};jO=function(t,e){var r=nr;try{return nr=t,e()}finally{nr=r}};p3=function(t,e,r){switch(e){case"input":if(c3(t,r),e=r.name,r.type==="radio"&&e!=null){for(r=t;r.parentNode;)r=r.parentNode;for(r=r.querySelectorAll("input[name="+JSON.stringify(""+e)+'][type="radio"]'),e=0;e<r.length;e++){var n=r[e];if(n!==t&&n.form===t.form){var i=U5(n);if(!i)throw Error(gt(90));SO(n),c3(n,i)}}}break;case"textarea":_O(t,r);break;case"select":e=r.value,e!=null&&G0(t,!!r.multiple,e,!1)}};PO=w_;RO=xd;var HH={usingClientEntryPoint:!1,Events:[H1,p0,U5,OO,MO,w_]},wg={findFiberByHostInstance:Qf,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},KH={bundleType:wg.bundleType,version:wg.version,rendererPackageName:wg.rendererPackageName,rendererConfig:wg.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:cu.ReactCurrentDispatcher,findHostInstanceByFiber:function(t){return t=NO(t),t===null?null:t.stateNode},findFiberByHostInstance:wg.findFiberByHostInstance||$H,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Jm=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Jm.isDisabled&&Jm.supportsFiber)try{N5=Jm.inject(KH),$c=Jm}catch{}}$a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=HH;$a.createPortal=function(t,e){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!b_(e))throw Error(gt(200));return zH(t,e,null,r)};$a.createRoot=function(t,e){if(!b_(t))throw Error(gt(299));var r=!1,n="",i=hP;return e!=null&&(e.unstable_strictMode===!0&&(r=!0),e.identifierPrefix!==void 0&&(n=e.identifierPrefix),e.onRecoverableError!==void 0&&(i=e.onRecoverableError)),e=T_(t,1,!1,null,null,r,!1,n,i),t[Xl]=e.current,Xp(t.nodeType===8?t.parentNode:t),new E_(e)};$a.findDOMNode=function(t){if(t==null)return null;if(t.nodeType===1)return t;var e=t._reactInternals;if(e===void 0)throw typeof t.render=="function"?Error(gt(188)):(t=Object.keys(t).join(","),Error(gt(268,t)));return t=NO(e),t=t===null?null:t.stateNode,t};$a.flushSync=function(t){return xd(t)};$a.hydrate=function(t,e,r){if(!q5(e))throw Error(gt(200));return X5(null,t,e,!0,r)};$a.hydrateRoot=function(t,e,r){if(!b_(t))throw Error(gt(405));var n=r!=null&&r.hydratedSources||null,i=!1,o="",a=hP;if(r!=null&&(r.unstable_strictMode===!0&&(i=!0),r.identifierPrefix!==void 0&&(o=r.identifierPrefix),r.onRecoverableError!==void 0&&(a=r.onRecoverableError)),e=dP(e,null,t,1,r??null,i,!1,o,a),t[Xl]=e.current,Xp(t),n)for(t=0;t<n.length;t++)r=n[t],i=r._getVersion,i=i(r._source),e.mutableSourceEagerHydrationData==null?e.mutableSourceEagerHydrationData=[r,i]:e.mutableSourceEagerHydrationData.push(r,i);return new K5(e)};$a.render=function(t,e,r){if(!q5(e))throw Error(gt(200));return X5(null,t,e,!1,r)};$a.unmountComponentAtNode=function(t){if(!q5(t))throw Error(gt(40));return t._reactRootContainer?(xd(function(){X5(null,null,t,!1,function(){t._reactRootContainer=null,t[Xl]=null})}),!0):!1};$a.unstable_batchedUpdates=w_;$a.unstable_renderSubtreeIntoContainer=function(t,e,r,n){if(!q5(r))throw Error(gt(200));if(t==null||t._reactInternals===void 0)throw Error(gt(38));return X5(t,e,r,!1,n)};$a.version="18.3.1-next-f1338f8080-20240426";function gP(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(gP)}catch(t){console.error(t)}}gP(),gO.exports=$a;var qH=gO.exports,pP,O6=qH;pP=O6.createRoot,O6.hydrateRoot;var et;(function(t){t.ERROR_EVENT="CORNERSTONE_ERROR",t.CACHE_SIZE_EXCEEDED="CACHE_SIZE_EXCEEDED",t.IMAGE_LOAD_ERROR="IMAGE_LOAD_ERROR",t.CAMERA_MODIFIED="CORNERSTONE_CAMERA_MODIFIED",t.CAMERA_RESET="CORNERSTONE_CAMERA_RESET",t.VOI_MODIFIED="CORNERSTONE_VOI_MODIFIED",t.PRESET_MODIFIED="CORNERSTONE_VIEWPORT_RENDERING_PRESET_MODIFIED",t.DISPLAY_AREA_MODIFIED="CORNERSTONE_DISPLAY_AREA_MODIFIED",t.ELEMENT_DISABLED="CORNERSTONE_ELEMENT_DISABLED",t.ELEMENT_ENABLED="CORNERSTONE_ELEMENT_ENABLED",t.IMAGE_RENDERED="CORNERSTONE_IMAGE_RENDERED",t.IMAGE_VOLUME_MODIFIED="CORNERSTONE_IMAGE_VOLUME_MODIFIED",t.IMAGE_VOLUME_LOADING_COMPLETED="CORNERSTONE_IMAGE_VOLUME_LOADING_COMPLETED",t.IMAGE_LOADED="CORNERSTONE_IMAGE_LOADED",t.IMAGE_RETRIEVAL_STAGE="CORNERSTONE_IMAGE_RETRIEVAL_STAGE",t.IMAGE_LOAD_FAILED="CORNERSTONE_IMAGE_LOAD_FAILED",t.VOLUME_VIEWPORT_NEW_VOLUME="CORNERSTONE_VOLUME_VIEWPORT_NEW_VOLUME",t.VOLUME_LOADED="CORNERSTONE_VOLUME_LOADED",t.VOLUME_LOADED_FAILED="CORNERSTONE_VOLUME_LOADED_FAILED",t.IMAGE_CACHE_IMAGE_ADDED="CORNERSTONE_IMAGE_CACHE_IMAGE_ADDED",t.IMAGE_CACHE_IMAGE_REMOVED="CORNERSTONE_IMAGE_CACHE_IMAGE_REMOVED",t.VOLUME_CACHE_VOLUME_ADDED="CORNERSTONE_VOLUME_CACHE_VOLUME_ADDED",t.VOLUME_CACHE_VOLUME_REMOVED="CORNERSTONE_VOLUME_CACHE_VOLUME_REMOVED",t.STACK_NEW_IMAGE="CORNERSTONE_STACK_NEW_IMAGE",t.VOLUME_NEW_IMAGE="CORNERSTONE_VOLUME_NEW_IMAGE",t.PRE_STACK_NEW_IMAGE="CORNERSTONE_PRE_STACK_NEW_IMAGE",t.IMAGE_SPACING_CALIBRATED="CORNERSTONE_IMAGE_SPACING_CALIBRATED",t.VIEWPORT_NEW_IMAGE_SET="CORNERSTONE_VIEWPORT_NEW_IMAGE_SET",t.STACK_VIEWPORT_SCROLL="CORNERSTONE_STACK_VIEWPORT_SCROLL",t.STACK_SCROLL_OUT_OF_BOUNDS="STACK_SCROLL_OUT_OF_BOUNDS",t.GEOMETRY_CACHE_GEOMETRY_ADDED="CORNERSTONE_GEOMETRY_CACHE_GEOMETRY_ADDED",t.GEOMETRY_CACHE_GEOMETRY_REMOVED="CORNERSTONE_GEOMETRY_CACHE_GEOMETRY_REMOVED",t.VOLUME_VIEWPORT_SCROLL_OUT_OF_BOUNDS="VOLUME_VIEWPORT_SCROLL_OUT_OF_BOUNDS",t.VOLUME_VIEWPORT_SCROLL="VOLUME_VIEWPORT_SCROLL",t.CLIPPING_PLANES_UPDATED="CORNERSTONE_CLIPPING_PLANES_UPDATED",t.WEB_WORKER_PROGRESS="CORNERSTONE_WEB_WORKER_PROGRESS",t.COLORMAP_MODIFIED="CORNERSTONE_COLORMAP_MODIFIED",t.DYNAMIC_VOLUME_DIMENSION_GROUP_CHANGED="DYNAMIC_VOLUME_DIMENSION_GROUP_CHANGED",t.DYNAMIC_VOLUME_TIME_POINT_INDEX_CHANGED="DYNAMIC_VOLUME_TIME_POINT_INDEX_CHANGED",t.DYNAMIC_VOLUME_DIMENSION_GROUP_LOADED="DYNAMIC_VOLUME_DIMENSION_GROUP_LOADED",t.DYNAMIC_VOLUME_TIME_POINT_LOADED="DYNAMIC_VOLUME_TIME_POINT_LOADED",t.GEOMETRY_LOADED="GEOMETRY_LOADED",t.GEOMETRY_LOAD_PROGRESS="GEOMETRY_LOAD_PROGRESS",t.GEOMETRY_LOADED_FAILED="GEOMETRY_LOADED_FAILED",t.ACTORS_CHANGED="CORNERSTONE_ACTORS_CHANGED"})(et||(et={}));var Qt;(function(t){t.Interaction="interaction",t.Thumbnail="thumbnail",t.Prefetch="prefetch",t.Compute="compute"})(Qt||(Qt={}));var ir;(function(t){t.STACK="stack",t.ORTHOGRAPHIC="orthographic",t.PERSPECTIVE="perspective",t.VOLUME_3D="volume3d",t.VIDEO="video",t.WHOLE_SLIDE="wholeSlide"})(ir||(ir={}));var Fl;(function(t){t[t.NEAREST=0]="NEAREST",t[t.LINEAR=1]="LINEAR",t[t.FAST_LINEAR=2]="FAST_LINEAR"})(Fl||(Fl={}));const hv={COMPOSITE_BLEND:0,MAXIMUM_INTENSITY_BLEND:1,MINIMUM_INTENSITY_BLEND:2,AVERAGE_INTENSITY_BLEND:3,ADDITIVE_INTENSITY_BLEND:4,RADON_TRANSFORM_BLEND:5,LABELMAP_EDGE_PROJECTION_BLEND:6},XH={OFF:0,NORMALIZED:1,RAW:2};var mP={BlendMode:hv,FilterMode:XH};const{BlendMode:xg}=mP;var Hc;(function(t){t[t.COMPOSITE=xg.COMPOSITE_BLEND]="COMPOSITE",t[t.MAXIMUM_INTENSITY_BLEND=xg.MAXIMUM_INTENSITY_BLEND]="MAXIMUM_INTENSITY_BLEND",t[t.MINIMUM_INTENSITY_BLEND=xg.MINIMUM_INTENSITY_BLEND]="MINIMUM_INTENSITY_BLEND",t[t.AVERAGE_INTENSITY_BLEND=xg.AVERAGE_INTENSITY_BLEND]="AVERAGE_INTENSITY_BLEND",t[t.LABELMAP_EDGE_PROJECTION_BLEND=xg.LABELMAP_EDGE_PROJECTION_BLEND]="LABELMAP_EDGE_PROJECTION_BLEND"})(Hc||(Hc={}));var Cd;(function(t){t.AXIAL="axial",t.CORONAL="coronal",t.SAGITTAL="sagittal",t.ACQUISITION="acquisition"})(Cd||(Cd={}));var Kc;(function(t){t.CONTOUR="CONTOUR",t.SURFACE="SURFACE",t.MESH="MESH"})(Kc||(Kc={}));var q3;(function(t){t.CLOSED_PLANAR="CLOSED_PLANAR",t.OPEN_PLANAR="OPEN_PLANAR"})(q3||(q3={}));const YH=q3;var ka;(function(t){t.PLY="PLY",t.STL="STL",t.OBJ="OBJ",t.VTP="VTP"})(ka||(ka={}));var oo;(function(t){t.LINEAR="LINEAR",t.SAMPLED_SIGMOID="SIGMOID",t.LINEAR_EXACT="LINEAR_EXACT"})(oo||(oo={}));var X3;(function(t){t.SUM="SUM",t.AVERAGE="AVERAGE",t.SUBTRACT="SUBTRACT"})(X3||(X3={}));const JH=X3;var Js;(function(t){t.NOT_APPLICABLE="",t.ERMF="ERMF",t.USER="User",t.PROJECTION="Proj",t.REGION="Region",t.ERROR="Error",t.UNCALIBRATED="Uncalibrated",t.CALIBRATED="Calibrated",t.UNKNOWN="Unknown"})(Js||(Js={}));var _o;(function(t){t.NO_DATA="noData",t.LOADING="loading",t.PRE_RENDER="preRender",t.RESIZE="resize",t.RENDERED="rendered"})(_o||(_o={}));var ca;(function(t){t[t.FAR_REPLICATE=1]="FAR_REPLICATE",t[t.ADJACENT_REPLICATE=3]="ADJACENT_REPLICATE",t[t.SUBRESOLUTION=6]="SUBRESOLUTION",t[t.LOSSY=7]="LOSSY",t[t.FULL_RESOLUTION=8]="FULL_RESOLUTION"})(ca||(ca={}));var i1;(function(t){t.FRAME="f",t.SECOND="s"})(i1||(i1={}));const ZH=Object.freeze(Object.defineProperty({__proto__:null,get SpeedUnit(){return i1}},Symbol.toStringTag,{value:"Module"}));var jo;(function(t){t.CALIBRATION="calibrationModule",t.CINE="cineModule",t.GENERAL_IMAGE="generalImageModule",t.GENERAL_SERIES="generalSeriesModule",t.GENERAL_STUDY="generalStudyModule",t.IMAGE_PIXEL="imagePixelModule",t.IMAGE_PLANE="imagePlaneModule",t.IMAGE_URL="imageUrlModule",t.MODALITY_LUT="modalityLutModule",t.MULTIFRAME="multiframeModule",t.NM_MULTIFRAME_GEOMETRY="nmMultiframeGeometryModule",t.OVERLAY_PLANE="overlayPlaneModule",t.PATIENT="patientModule",t.PATIENT_STUDY="patientStudyModule",t.PET_IMAGE="petImageModule",t.PET_ISOTOPE="petIsotopeModule",t.PET_SERIES="petSeriesModule",t.SOP_COMMON="sopCommonModule",t.ULTRASOUND_ENHANCED_REGION="ultrasoundEnhancedRegionModule",t.VOI_LUT="voiLutModule",t.WADO_WEB_CLIENT="wadoWebClient"})(jo||(jo={}));var K0;(function(t){t.SUM="SUM",t.SUBTRACT="SUBTRACT",t.AVERAGE="AVERAGE"})(K0||(K0={}));var dy;(function(t){t.RLE="RLE",t.Volume="Volume"})(dy||(dy={}));const Ha=Object.freeze(Object.defineProperty({__proto__:null,BlendModes:Hc,CalibrationTypes:Js,ContourType:YH,DynamicOperatorType:JH,Events:et,get GenerateImageType(){return K0},GeometryType:Kc,ImageQualityStatus:ca,InterpolationType:Fl,MeshType:ka,MetadataModules:jo,OrientationAxis:Cd,RequestType:Qt,VOILUTFunctionType:oo,VideoEnums:ZH,ViewportStatus:_o,ViewportType:ir,VoxelManagerEnum:dy},Symbol.toStringTag,{value:"Module"})),Y3={hotIron:{name:"Hot Iron",numOfColors:256,colors:[[0,0,0,255],[2,0,0,255],[4,0,0,255],[6,0,0,255],[8,0,0,255],[10,0,0,255],[12,0,0,255],[14,0,0,255],[16,0,0,255],[18,0,0,255],[20,0,0,255],[22,0,0,255],[24,0,0,255],[26,0,0,255],[28,0,0,255],[30,0,0,255],[32,0,0,255],[34,0,0,255],[36,0,0,255],[38,0,0,255],[40,0,0,255],[42,0,0,255],[44,0,0,255],[46,0,0,255],[48,0,0,255],[50,0,0,255],[52,0,0,255],[54,0,0,255],[56,0,0,255],[58,0,0,255],[60,0,0,255],[62,0,0,255],[64,0,0,255],[66,0,0,255],[68,0,0,255],[70,0,0,255],[72,0,0,255],[74,0,0,255],[76,0,0,255],[78,0,0,255],[80,0,0,255],[82,0,0,255],[84,0,0,255],[86,0,0,255],[88,0,0,255],[90,0,0,255],[92,0,0,255],[94,0,0,255],[96,0,0,255],[98,0,0,255],[100,0,0,255],[102,0,0,255],[104,0,0,255],[106,0,0,255],[108,0,0,255],[110,0,0,255],[112,0,0,255],[114,0,0,255],[116,0,0,255],[118,0,0,255],[120,0,0,255],[122,0,0,255],[124,0,0,255],[126,0,0,255],[128,0,0,255],[130,0,0,255],[132,0,0,255],[134,0,0,255],[136,0,0,255],[138,0,0,255],[140,0,0,255],[142,0,0,255],[144,0,0,255],[146,0,0,255],[148,0,0,255],[150,0,0,255],[152,0,0,255],[154,0,0,255],[156,0,0,255],[158,0,0,255],[160,0,0,255],[162,0,0,255],[164,0,0,255],[166,0,0,255],[168,0,0,255],[170,0,0,255],[172,0,0,255],[174,0,0,255],[176,0,0,255],[178,0,0,255],[180,0,0,255],[182,0,0,255],[184,0,0,255],[186,0,0,255],[188,0,0,255],[190,0,0,255],[192,0,0,255],[194,0,0,255],[196,0,0,255],[198,0,0,255],[200,0,0,255],[202,0,0,255],[204,0,0,255],[206,0,0,255],[208,0,0,255],[210,0,0,255],[212,0,0,255],[214,0,0,255],[216,0,0,255],[218,0,0,255],[220,0,0,255],[222,0,0,255],[224,0,0,255],[226,0,0,255],[228,0,0,255],[230,0,0,255],[232,0,0,255],[234,0,0,255],[236,0,0,255],[238,0,0,255],[240,0,0,255],[242,0,0,255],[244,0,0,255],[246,0,0,255],[248,0,0,255],[250,0,0,255],[252,0,0,255],[254,0,0,255],[255,0,0,255],[255,2,0,255],[255,4,0,255],[255,6,0,255],[255,8,0,255],[255,10,0,255],[255,12,0,255],[255,14,0,255],[255,16,0,255],[255,18,0,255],[255,20,0,255],[255,22,0,255],[255,24,0,255],[255,26,0,255],[255,28,0,255],[255,30,0,255],[255,32,0,255],[255,34,0,255],[255,36,0,255],[255,38,0,255],[255,40,0,255],[255,42,0,255],[255,44,0,255],[255,46,0,255],[255,48,0,255],[255,50,0,255],[255,52,0,255],[255,54,0,255],[255,56,0,255],[255,58,0,255],[255,60,0,255],[255,62,0,255],[255,64,0,255],[255,66,0,255],[255,68,0,255],[255,70,0,255],[255,72,0,255],[255,74,0,255],[255,76,0,255],[255,78,0,255],[255,80,0,255],[255,82,0,255],[255,84,0,255],[255,86,0,255],[255,88,0,255],[255,90,0,255],[255,92,0,255],[255,94,0,255],[255,96,0,255],[255,98,0,255],[255,100,0,255],[255,102,0,255],[255,104,0,255],[255,106,0,255],[255,108,0,255],[255,110,0,255],[255,112,0,255],[255,114,0,255],[255,116,0,255],[255,118,0,255],[255,120,0,255],[255,122,0,255],[255,124,0,255],[255,126,0,255],[255,128,4,255],[255,130,8,255],[255,132,12,255],[255,134,16,255],[255,136,20,255],[255,138,24,255],[255,140,28,255],[255,142,32,255],[255,144,36,255],[255,146,40,255],[255,148,44,255],[255,150,48,255],[255,152,52,255],[255,154,56,255],[255,156,60,255],[255,158,64,255],[255,160,68,255],[255,162,72,255],[255,164,76,255],[255,166,80,255],[255,168,84,255],[255,170,88,255],[255,172,92,255],[255,174,96,255],[255,176,100,255],[255,178,104,255],[255,180,108,255],[255,182,112,255],[255,184,116,255],[255,186,120,255],[255,188,124,255],[255,190,128,255],[255,192,132,255],[255,194,136,255],[255,196,140,255],[255,198,144,255],[255,200,148,255],[255,202,152,255],[255,204,156,255],[255,206,160,255],[255,208,164,255],[255,210,168,255],[255,212,172,255],[255,214,176,255],[255,216,180,255],[255,218,184,255],[255,220,188,255],[255,222,192,255],[255,224,196,255],[255,226,200,255],[255,228,204,255],[255,230,208,255],[255,232,212,255],[255,234,216,255],[255,236,220,255],[255,238,224,255],[255,240,228,255],[255,242,232,255],[255,244,236,255],[255,246,240,255],[255,248,244,255],[255,250,248,255],[255,252,252,255],[255,255,255,255]]},pet:{name:"PET",numColors:256,colors:[[0,0,0,255],[0,2,1,255],[0,4,3,255],[0,6,5,255],[0,8,7,255],[0,10,9,255],[0,12,11,255],[0,14,13,255],[0,16,15,255],[0,18,17,255],[0,20,19,255],[0,22,21,255],[0,24,23,255],[0,26,25,255],[0,28,27,255],[0,30,29,255],[0,32,31,255],[0,34,33,255],[0,36,35,255],[0,38,37,255],[0,40,39,255],[0,42,41,255],[0,44,43,255],[0,46,45,255],[0,48,47,255],[0,50,49,255],[0,52,51,255],[0,54,53,255],[0,56,55,255],[0,58,57,255],[0,60,59,255],[0,62,61,255],[0,65,63,255],[0,67,65,255],[0,69,67,255],[0,71,69,255],[0,73,71,255],[0,75,73,255],[0,77,75,255],[0,79,77,255],[0,81,79,255],[0,83,81,255],[0,85,83,255],[0,87,85,255],[0,89,87,255],[0,91,89,255],[0,93,91,255],[0,95,93,255],[0,97,95,255],[0,99,97,255],[0,101,99,255],[0,103,101,255],[0,105,103,255],[0,107,105,255],[0,109,107,255],[0,111,109,255],[0,113,111,255],[0,115,113,255],[0,117,115,255],[0,119,117,255],[0,121,119,255],[0,123,121,255],[0,125,123,255],[0,128,125,255],[1,126,127,255],[3,124,129,255],[5,122,131,255],[7,120,133,255],[9,118,135,255],[11,116,137,255],[13,114,139,255],[15,112,141,255],[17,110,143,255],[19,108,145,255],[21,106,147,255],[23,104,149,255],[25,102,151,255],[27,100,153,255],[29,98,155,255],[31,96,157,255],[33,94,159,255],[35,92,161,255],[37,90,163,255],[39,88,165,255],[41,86,167,255],[43,84,169,255],[45,82,171,255],[47,80,173,255],[49,78,175,255],[51,76,177,255],[53,74,179,255],[55,72,181,255],[57,70,183,255],[59,68,185,255],[61,66,187,255],[63,64,189,255],[65,63,191,255],[67,61,193,255],[69,59,195,255],[71,57,197,255],[73,55,199,255],[75,53,201,255],[77,51,203,255],[79,49,205,255],[81,47,207,255],[83,45,209,255],[85,43,211,255],[86,41,213,255],[88,39,215,255],[90,37,217,255],[92,35,219,255],[94,33,221,255],[96,31,223,255],[98,29,225,255],[100,27,227,255],[102,25,229,255],[104,23,231,255],[106,21,233,255],[108,19,235,255],[110,17,237,255],[112,15,239,255],[114,13,241,255],[116,11,243,255],[118,9,245,255],[120,7,247,255],[122,5,249,255],[124,3,251,255],[126,1,253,255],[128,0,255,255],[130,2,252,255],[132,4,248,255],[134,6,244,255],[136,8,240,255],[138,10,236,255],[140,12,232,255],[142,14,228,255],[144,16,224,255],[146,18,220,255],[148,20,216,255],[150,22,212,255],[152,24,208,255],[154,26,204,255],[156,28,200,255],[158,30,196,255],[160,32,192,255],[162,34,188,255],[164,36,184,255],[166,38,180,255],[168,40,176,255],[170,42,172,255],[171,44,168,255],[173,46,164,255],[175,48,160,255],[177,50,156,255],[179,52,152,255],[181,54,148,255],[183,56,144,255],[185,58,140,255],[187,60,136,255],[189,62,132,255],[191,64,128,255],[193,66,124,255],[195,68,120,255],[197,70,116,255],[199,72,112,255],[201,74,108,255],[203,76,104,255],[205,78,100,255],[207,80,96,255],[209,82,92,255],[211,84,88,255],[213,86,84,255],[215,88,80,255],[217,90,76,255],[219,92,72,255],[221,94,68,255],[223,96,64,255],[225,98,60,255],[227,100,56,255],[229,102,52,255],[231,104,48,255],[233,106,44,255],[235,108,40,255],[237,110,36,255],[239,112,32,255],[241,114,28,255],[243,116,24,255],[245,118,20,255],[247,120,16,255],[249,122,12,255],[251,124,8,255],[253,126,4,255],[255,128,0,255],[255,130,4,255],[255,132,8,255],[255,134,12,255],[255,136,16,255],[255,138,20,255],[255,140,24,255],[255,142,28,255],[255,144,32,255],[255,146,36,255],[255,148,40,255],[255,150,44,255],[255,152,48,255],[255,154,52,255],[255,156,56,255],[255,158,60,255],[255,160,64,255],[255,162,68,255],[255,164,72,255],[255,166,76,255],[255,168,80,255],[255,170,85,255],[255,172,89,255],[255,174,93,255],[255,176,97,255],[255,178,101,255],[255,180,105,255],[255,182,109,255],[255,184,113,255],[255,186,117,255],[255,188,121,255],[255,190,125,255],[255,192,129,255],[255,194,133,255],[255,196,137,255],[255,198,141,255],[255,200,145,255],[255,202,149,255],[255,204,153,255],[255,206,157,255],[255,208,161,255],[255,210,165,255],[255,212,170,255],[255,214,174,255],[255,216,178,255],[255,218,182,255],[255,220,186,255],[255,222,190,255],[255,224,194,255],[255,226,198,255],[255,228,202,255],[255,230,206,255],[255,232,210,255],[255,234,214,255],[255,236,218,255],[255,238,222,255],[255,240,226,255],[255,242,230,255],[255,244,234,255],[255,246,238,255],[255,248,242,255],[255,250,246,255],[255,252,250,255],[255,255,255,255]]},hotMetalBlue:{name:"Hot Metal Blue",numColors:256,colors:[[0,0,0,255],[0,0,2,255],[0,0,4,255],[0,0,6,255],[0,0,8,255],[0,0,10,255],[0,0,12,255],[0,0,14,255],[0,0,16,255],[0,0,17,255],[0,0,19,255],[0,0,21,255],[0,0,23,255],[0,0,25,255],[0,0,27,255],[0,0,29,255],[0,0,31,255],[0,0,33,255],[0,0,35,255],[0,0,37,255],[0,0,39,255],[0,0,41,255],[0,0,43,255],[0,0,45,255],[0,0,47,255],[0,0,49,255],[0,0,51,255],[0,0,53,255],[0,0,55,255],[0,0,57,255],[0,0,59,255],[0,0,61,255],[0,0,63,255],[0,0,65,255],[0,0,67,255],[0,0,69,255],[0,0,71,255],[0,0,73,255],[0,0,75,255],[0,0,77,255],[0,0,79,255],[0,0,81,255],[0,0,83,255],[0,0,84,255],[0,0,86,255],[0,0,88,255],[0,0,90,255],[0,0,92,255],[0,0,94,255],[0,0,96,255],[0,0,98,255],[0,0,100,255],[0,0,102,255],[0,0,104,255],[0,0,106,255],[0,0,108,255],[0,0,110,255],[0,0,112,255],[0,0,114,255],[0,0,116,255],[0,0,117,255],[0,0,119,255],[0,0,121,255],[0,0,123,255],[0,0,125,255],[0,0,127,255],[0,0,129,255],[0,0,131,255],[0,0,133,255],[0,0,135,255],[0,0,137,255],[0,0,139,255],[0,0,141,255],[0,0,143,255],[0,0,145,255],[0,0,147,255],[0,0,149,255],[0,0,151,255],[0,0,153,255],[0,0,155,255],[0,0,157,255],[0,0,159,255],[0,0,161,255],[0,0,163,255],[0,0,165,255],[0,0,167,255],[3,0,169,255],[6,0,171,255],[9,0,173,255],[12,0,175,255],[15,0,177,255],[18,0,179,255],[21,0,181,255],[24,0,183,255],[26,0,184,255],[29,0,186,255],[32,0,188,255],[35,0,190,255],[38,0,192,255],[41,0,194,255],[44,0,196,255],[47,0,198,255],[50,0,200,255],[52,0,197,255],[55,0,194,255],[57,0,191,255],[59,0,188,255],[62,0,185,255],[64,0,182,255],[66,0,179,255],[69,0,176,255],[71,0,174,255],[74,0,171,255],[76,0,168,255],[78,0,165,255],[81,0,162,255],[83,0,159,255],[85,0,156,255],[88,0,153,255],[90,0,150,255],[93,2,144,255],[96,4,138,255],[99,6,132,255],[102,8,126,255],[105,9,121,255],[108,11,115,255],[111,13,109,255],[114,15,103,255],[116,17,97,255],[119,19,91,255],[122,21,85,255],[125,23,79,255],[128,24,74,255],[131,26,68,255],[134,28,62,255],[137,30,56,255],[140,32,50,255],[143,34,47,255],[146,36,44,255],[149,38,41,255],[152,40,38,255],[155,41,35,255],[158,43,32,255],[161,45,29,255],[164,47,26,255],[166,49,24,255],[169,51,21,255],[172,53,18,255],[175,55,15,255],[178,56,12,255],[181,58,9,255],[184,60,6,255],[187,62,3,255],[190,64,0,255],[194,66,0,255],[198,68,0,255],[201,70,0,255],[205,72,0,255],[209,73,0,255],[213,75,0,255],[217,77,0,255],[221,79,0,255],[224,81,0,255],[228,83,0,255],[232,85,0,255],[236,87,0,255],[240,88,0,255],[244,90,0,255],[247,92,0,255],[251,94,0,255],[255,96,0,255],[255,98,3,255],[255,100,6,255],[255,102,9,255],[255,104,12,255],[255,105,15,255],[255,107,18,255],[255,109,21,255],[255,111,24,255],[255,113,26,255],[255,115,29,255],[255,117,32,255],[255,119,35,255],[255,120,38,255],[255,122,41,255],[255,124,44,255],[255,126,47,255],[255,128,50,255],[255,130,53,255],[255,132,56,255],[255,134,59,255],[255,136,62,255],[255,137,65,255],[255,139,68,255],[255,141,71,255],[255,143,74,255],[255,145,76,255],[255,147,79,255],[255,149,82,255],[255,151,85,255],[255,152,88,255],[255,154,91,255],[255,156,94,255],[255,158,97,255],[255,160,100,255],[255,162,103,255],[255,164,106,255],[255,166,109,255],[255,168,112,255],[255,169,115,255],[255,171,118,255],[255,173,121,255],[255,175,124,255],[255,177,126,255],[255,179,129,255],[255,181,132,255],[255,183,135,255],[255,184,138,255],[255,186,141,255],[255,188,144,255],[255,190,147,255],[255,192,150,255],[255,194,153,255],[255,196,156,255],[255,198,159,255],[255,200,162,255],[255,201,165,255],[255,203,168,255],[255,205,171,255],[255,207,174,255],[255,209,176,255],[255,211,179,255],[255,213,182,255],[255,215,185,255],[255,216,188,255],[255,218,191,255],[255,220,194,255],[255,222,197,255],[255,224,200,255],[255,226,203,255],[255,228,206,255],[255,229,210,255],[255,231,213,255],[255,233,216,255],[255,235,219,255],[255,237,223,255],[255,239,226,255],[255,240,229,255],[255,242,232,255],[255,244,236,255],[255,246,239,255],[255,248,242,255],[255,250,245,255],[255,251,249,255],[255,253,252,255],[255,255,255,255]]},pet20Step:{name:"PET 20 Step",numColors:256,colors:[[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[0,0,0,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[96,0,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,80,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[48,48,112,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[80,80,128,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[96,96,176,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[112,112,192,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[128,128,224,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,96,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[48,144,48,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[80,192,80,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[64,224,64,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[224,224,80,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,208,96,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,176,64,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[208,144,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[192,96,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[176,48,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,255],[255,0,0,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]]},gray:{name:"Gray",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[1,1,1]],green:[[0,0,0],[1,1,1]],blue:[[0,0,0],[1,1,1]]}},jet:{name:"Jet",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[.35,0,0],[.66,1,1],[.89,1,1],[1,.5,.5]],green:[[0,0,0],[.125,0,0],[.375,1,1],[.64,1,1],[.91,0,0],[1,0,0]],blue:[[0,.5,.5],[.11,1,1],[.34,1,1],[.65,0,0],[1,0,0]]}},hsv:{name:"HSV",numColors:256,gamma:1,segmentedData:{red:[[0,1,1],[.15873,1,1],[.174603,.96875,.96875],[.333333,.03125,.03125],[.349206,0,0],[.666667,0,0],[.68254,.03125,.03125],[.84127,.96875,.96875],[.857143,1,1],[1,1,1]],green:[[0,0,0],[.15873,.9375,.9375],[.174603,1,1],[.507937,1,1],[.666667,.0625,.0625],[.68254,0,0],[1,0,0]],blue:[[0,0,0],[.333333,0,0],[.349206,.0625,.0625],[.507937,1,1],[.84127,1,1],[.857143,.9375,.9375],[1,.09375,.09375]]}},hot:{name:"Hot",numColors:256,gamma:1,segmentedData:{red:[[0,.0416,.0416],[.365079,1,1],[1,1,1]],green:[[0,0,0],[.365079,0,0],[.746032,1,1],[1,1,1]],blue:[[0,0,0],[.746032,0,0],[1,1,1]]}},cool:{name:"Cool",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[1,1,1]],green:[[0,1,1],[1,0,0]],blue:[[0,1,1],[1,1,1]]}},spring:{name:"Spring",numColors:256,gamma:1,segmentedData:{red:[[0,1,1],[1,1,1]],green:[[0,0,0],[1,1,1]],blue:[[0,1,1],[1,0,0]]}},summer:{name:"Summer",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[1,1,1]],green:[[0,.5,.5],[1,1,1]],blue:[[0,.4,.4],[1,.4,.4]]}},autumn:{name:"Autumn",numColors:256,gamma:1,segmentedData:{red:[[0,1,1],[1,1,1]],green:[[0,0,0],[1,1,1]],blue:[[0,0,0],[1,0,0]]}},winter:{name:"Winter",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[1,0,0]],green:[[0,0,0],[1,1,1]],blue:[[0,1,1],[1,.5,.5]]}},bone:{name:"Bone",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[.746032,.652778,.652778],[1,1,1]],green:[[0,0,0],[.365079,.319444,.319444],[.746032,.777778,.777778],[1,1,1]],blue:[[0,0,0],[.365079,.444444,.444444],[1,1,1]]}},copper:{name:"Copper",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[.809524,1,1],[1,1,1]],green:[[0,0,0],[1,.7812,.7812]],blue:[[0,0,0],[1,.4975,.4975]]}},spectral:{name:"Spectral",numColors:256,gamma:1,segmentedData:{red:[[0,0,0],[.05,.4667,.4667],[.1,.5333,.5333],[.15,0,0],[.2,0,0],[.25,0,0],[.3,0,0],[.35,0,0],[.4,0,0],[.45,0,0],[.5,0,0],[.55,0,0],[.6,0,0],[.65,.7333,.7333],[.7,.9333,.9333],[.75,1,1],[.8,1,1],[.85,1,1],[.9,.8667,.8667],[.95,.8,.8],[1,.8,.8]],green:[[0,0,0],[.05,0,0],[.1,0,0],[.15,0,0],[.2,0,0],[.25,.4667,.4667],[.3,.6,.6],[.35,.6667,.6667],[.4,.6667,.6667],[.45,.6,.6],[.5,.7333,.7333],[.55,.8667,.8667],[.6,1,1],[.65,1,1],[.7,.9333,.9333],[.75,.8,.8],[.8,.6,.6],[.85,0,0],[.9,0,0],[.95,0,0],[1,.8,.8]],blue:[[0,0,0],[.05,.5333,.5333],[.1,.6,.6],[.15,.6667,.6667],[.2,.8667,.8667],[.25,.8667,.8667],[.3,.8667,.8667],[.35,.6667,.6667],[.4,.5333,.5333],[.45,0,0],[.5,0,0],[.55,0,0],[.6,0,0],[.65,0,0],[.7,0,0],[.75,0,0],[.8,0,0],[.85,0,0],[.9,0,0],[.95,0,0],[1,.8,.8]]}},coolwarm:{name:"CoolWarm",numColors:256,gamma:1,segmentedData:{red:[[0,.2298057,.2298057],[.03125,.26623388,.26623388],[.0625,.30386891,.30386891],[.09375,.342804478,.342804478],[.125,.38301334,.38301334],[.15625,.424369608,.424369608],[.1875,.46666708,.46666708],[.21875,.509635204,.509635204],[.25,.552953156,.552953156],[.28125,.596262162,.596262162],[.3125,.639176211,.639176211],[.34375,.681291281,.681291281],[.375,.722193294,.722193294],[.40625,.761464949,.761464949],[.4375,.798691636,.798691636],[.46875,.833466556,.833466556],[.5,.865395197,.865395197],[.53125,.897787179,.897787179],[.5625,.924127593,.924127593],[.59375,.944468518,.944468518],[.625,.958852946,.958852946],[.65625,.96732803,.96732803],[.6875,.969954137,.969954137],[.71875,.966811177,.966811177],[.75,.958003065,.958003065],[.78125,.943660866,.943660866],[.8125,.923944917,.923944917],[.84375,.89904617,.89904617],[.875,.869186849,.869186849],[.90625,.834620542,.834620542],[.9375,.795631745,.795631745],[.96875,.752534934,.752534934],[1,.705673158,.705673158]],green:[[0,.298717966,.298717966],[.03125,.353094838,.353094838],[.0625,.406535296,.406535296],[.09375,.458757618,.458757618],[.125,.50941904,.50941904],[.15625,.558148092,.558148092],[.1875,.604562568,.604562568],[.21875,.648280772,.648280772],[.25,.688929332,.688929332],[.28125,.726149107,.726149107],[.3125,.759599947,.759599947],[.34375,.788964712,.788964712],[.375,.813952739,.813952739],[.40625,.834302879,.834302879],[.4375,.849786142,.849786142],[.46875,.860207984,.860207984],[.5,.86541021,.86541021],[.53125,.848937047,.848937047],[.5625,.827384882,.827384882],[.59375,.800927443,.800927443],[.625,.769767752,.769767752],[.65625,.734132809,.734132809],[.6875,.694266682,.694266682],[.71875,.650421156,.650421156],[.75,.602842431,.602842431],[.78125,.551750968,.551750968],[.8125,.49730856,.49730856],[.84375,.439559467,.439559467],[.875,.378313092,.378313092],[.90625,.312874446,.312874446],[.9375,.24128379,.24128379],[.96875,.157246067,.157246067],[1,.01555616,.01555616]],blue:[[0,.753683153,.753683153],[.03125,.801466763,.801466763],[.0625,.84495867,.84495867],[.09375,.883725899,.883725899],[.125,.917387822,.917387822],[.15625,.945619588,.945619588],[.1875,.968154911,.968154911],[.21875,.98478814,.98478814],[.25,.995375608,.995375608],[.28125,.999836203,.999836203],[.3125,.998151185,.998151185],[.34375,.990363227,.990363227],[.375,.976574709,.976574709],[.40625,.956945269,.956945269],[.4375,.931688648,.931688648],[.46875,.901068838,.901068838],[.5,.865395561,.865395561],[.53125,.820880546,.820880546],[.5625,.774508472,.774508472],[.59375,.726736146,.726736146],[.625,.678007945,.678007945],[.65625,.628751763,.628751763],[.6875,.579375448,.579375448],[.71875,.530263762,.530263762],[.75,.481775914,.481775914],[.78125,.434243684,.434243684],[.8125,.387970225,.387970225],[.84375,.343229596,.343229596],[.875,.300267182,.300267182],[.90625,.259301199,.259301199],[.9375,.220525627,.220525627],[.96875,.184115123,.184115123],[1,.150232812,.150232812]]}},blues:{name:"Blues",numColors:256,gamma:1,segmentedData:{red:[[0,.9686274528503418,.9686274528503418],[.125,.8705882430076599,.8705882430076599],[.25,.7764706015586853,.7764706015586853],[.375,.6196078658103943,.6196078658103943],[.5,.41960784792900085,.41960784792900085],[.625,.25882354378700256,.25882354378700256],[.75,.12941177189350128,.12941177189350128],[.875,.0313725508749485,.0313725508749485],[1,.0313725508749485,.0313725508749485]],green:[[0,.9843137264251709,.9843137264251709],[.125,.9215686321258545,.9215686321258545],[.25,.8588235378265381,.8588235378265381],[.375,.7921568751335144,.7921568751335144],[.5,.6823529601097107,.6823529601097107],[.625,.572549045085907,.572549045085907],[.75,.4431372582912445,.4431372582912445],[.875,.3176470696926117,.3176470696926117],[1,.1882352977991104,.1882352977991104]],blue:[[0,1,1],[.125,.9686274528503418,.9686274528503418],[.25,.9372549057006836,.9372549057006836],[.375,.8823529481887817,.8823529481887817],[.5,.8392156958580017,.8392156958580017],[.625,.7764706015586853,.7764706015586853],[.75,.7098039388656616,.7098039388656616],[.875,.6117647290229797,.6117647290229797],[1,.41960784792900085,.41960784792900085]]}}},Wr={MINIMUM_SLAB_THICKNESS:.05,MAXIMUM_RAY_DISTANCE:1e6};Object.freeze(Wr);const Ga=.001;function vP(t){const e=Object.getOwnPropertyNames(t);for(const r of e){const n=t[r];n&&typeof n=="object"&&vP(n)}return Object.freeze(t)}const QH={axial:{viewPlaneNormal:[0,0,-1],viewUp:[0,-1,0],viewRight:[1,0,0]},sagittal:{viewPlaneNormal:[1,0,0],viewUp:[0,0,1],viewRight:[0,1,0]},coronal:{viewPlaneNormal:[0,-1,0],viewUp:[0,0,1],viewRight:[1,0,0]}},Nu=vP(QH),yP=[{name:"CT-AAA",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"12 -3024 0 143.556 0 166.222 0.686275 214.389 0.696078 419.736 0.833333 3071 0.803922",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"24 -3024 0 0 0 143.556 0.615686 0.356863 0.184314 166.222 0.882353 0.603922 0.290196 214.389 1 1 1 419.736 1 0.937033 0.954531 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-AAA2",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"16 -3024 0 129.542 0 145.244 0.166667 157.02 0.5 169.918 0.627451 395.575 0.8125 1578.73 0.8125 3071 0.8125",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"32 -3024 0 0 0 129.542 0.54902 0.25098 0.14902 145.244 0.6 0.627451 0.843137 157.02 0.890196 0.47451 0.6 169.918 0.992157 0.870588 0.392157 395.575 1 0.886275 0.658824 1578.73 1 0.829256 0.957922 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Bone",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"8 -3024 0 -16.4458 0 641.385 0.715686 3071 0.705882",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"16 -3024 0 0 0 -16.4458 0.729412 0.254902 0.301961 641.385 0.905882 0.815686 0.552941 3071 1 1 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Bones",gradientOpacity:"4 0 1 985.12 1",specularPower:"1",scalarOpacity:"8 -1000 0 152.19 0 278.93 0.190476 952 0.2",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"20 -1000 0.3 0.3 1 -488 0.3 1 0.3 463.28 1 0 0 659.15 1 0.912535 0.0374849 953 1 0.3 0.3",diffuse:"1",interpolation:"1"},{name:"CT-Cardiac",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"12 -3024 0 -77.6875 0 94.9518 0.285714 179.052 0.553571 260.439 0.848214 3071 0.875",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"24 -3024 0 0 0 -77.6875 0.54902 0.25098 0.14902 94.9518 0.882353 0.603922 0.290196 179.052 1 0.937033 0.954531 260.439 0.615686 0 0 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Cardiac2",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"12 -3024 0 42.8964 0 163.488 0.428571 277.642 0.776786 1587 0.754902 3071 0.754902",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"24 -3024 0 0 0 42.8964 0.54902 0.25098 0.14902 163.488 0.917647 0.639216 0.0588235 277.642 1 0.878431 0.623529 1587 1 1 1 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Cardiac3",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"14 -3024 0 -86.9767 0 45.3791 0.169643 139.919 0.589286 347.907 0.607143 1224.16 0.607143 3071 0.616071",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"28 -3024 0 0 0 -86.9767 0 0.25098 1 45.3791 1 0 0 139.919 1 0.894893 0.894893 347.907 1 1 0.25098 1224.16 1 1 1 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Chest-Contrast-Enhanced",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"10 -3024 0 67.0106 0 251.105 0.446429 439.291 0.625 3071 0.616071",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"20 -3024 0 0 0 67.0106 0.54902 0.25098 0.14902 251.105 0.882353 0.603922 0.290196 439.291 1 0.937033 0.954531 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Chest-Vessels",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"10 -3024 0 -1278.35 0 22.8277 0.428571 439.291 0.625 3071 0.616071",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"20 -3024 0 0 0 -1278.35 0.54902 0.25098 0.14902 22.8277 0.882353 0.603922 0.290196 439.291 1 0.937033 0.954531 3071 0.827451 0.658824 1",diffuse:"1",interpolation:"1"},{name:"CT-Coronary-Arteries",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"12 -2048 0 136.47 0 159.215 0.258929 318.43 0.571429 478.693 0.776786 3661 1",specular:"0",shade:"0",ambient:"0.2",colorTransfer:"24 -2048 0 0 0 136.47 0 0 0 159.215 0.159804 0.159804 0.159804 318.43 0.764706 0.764706 0.764706 478.693 1 1 1 3661 1 1 1",diffuse:"1",interpolation:"1"},{name:"CT-Coronary-Arteries-2",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"14 -2048 0 142.677 0 145.016 0.116071 192.174 0.5625 217.24 0.776786 384.347 0.830357 3661 0.830357",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"28 -2048 0 0 0 142.677 0 0 0 145.016 0.615686 0 0.0156863 192.174 0.909804 0.454902 0 217.24 0.972549 0.807843 0.611765 384.347 0.909804 0.909804 1 3661 1 1 1",diffuse:"1",interpolation:"1"},{name:"CT-Coronary-Arteries-3",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"14 -2048 0 128.643 0 129.982 0.0982143 173.636 0.669643 255.884 0.857143 584.878 0.866071 3661 1",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"28 -2048 0 0 0 128.643 0 0 0 129.982 0.615686 0 0.0156863 173.636 0.909804 0.454902 0 255.884 0.886275 0.886275 0.886275 584.878 0.968627 0.968627 0.968627 3661 1 1 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Cropped-Volume-Bone",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"10 -2048 0 -451 0 -450 1 1050 1 3661 1",specular:"0",shade:"0",ambient:"0.2",colorTransfer:"20 -2048 0 0 0 -451 0 0 0 -450 0.0556356 0.0556356 0.0556356 1050 1 1 1 3661 1 1 1",diffuse:"1",interpolation:"1"},{name:"CT-Fat",gradientOpacity:"6 0 1 985.12 1 988 1",specularPower:"1",scalarOpacity:"14 -1000 0 -100 0 -99 0.15 -60 0.15 -59 0 101.2 0 952 0",specular:"0",shade:"0",ambient:"0.2",colorTransfer:"36 -1000 0.3 0.3 1 -497.5 0.3 1 0.3 -99 0 0 1 -76.946 0 1 0 -65.481 0.835431 0.888889 0.0165387 83.89 1 0 0 463.28 1 0 0 659.15 1 0.912535 0.0374849 2952 1 0.300267 0.299886",diffuse:"1",interpolation:"1"},{name:"CT-Liver-Vasculature",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"14 -2048 0 149.113 0 157.884 0.482143 339.96 0.660714 388.526 0.830357 1197.95 0.839286 3661 0.848214",specular:"0",shade:"0",ambient:"0.2",colorTransfer:"28 -2048 0 0 0 149.113 0 0 0 157.884 0.501961 0.25098 0 339.96 0.695386 0.59603 0.36886 388.526 0.854902 0.85098 0.827451 1197.95 1 1 1 3661 1 1 1",diffuse:"1",interpolation:"1"},{name:"CT-Lung",gradientOpacity:"6 0 1 985.12 1 988 1",specularPower:"1",scalarOpacity:"12 -1000 0 -600 0 -599 0.15 -400 0.15 -399 0 2952 0",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"24 -1000 0.3 0.3 1 -600 0 0 1 -530 0.134704 0.781726 0.0724558 -460 0.929244 1 0.109473 -400 0.888889 0.254949 0.0240258 2952 1 0.3 0.3",diffuse:"1",interpolation:"1"},{name:"CT-MIP",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"8 -3024 0 -637.62 0 700 1 3071 1",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"16 -3024 0 0 0 -637.62 1 1 1 700 1 1 1 3071 1 1 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Muscle",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"10 -3024 0 -155.407 0 217.641 0.676471 419.736 0.833333 3071 0.803922",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"20 -3024 0 0 0 -155.407 0.54902 0.25098 0.14902 217.641 0.882353 0.603922 0.290196 419.736 1 0.937033 0.954531 3071 0.827451 0.658824 1",diffuse:"0.9",interpolation:"1"},{name:"CT-Pulmonary-Arteries",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"14 -2048 0 -568.625 0 -364.081 0.0714286 -244.813 0.401786 18.2775 0.607143 447.798 0.830357 3592.73 0.839286",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"28 -2048 0 0 0 -568.625 0 0 0 -364.081 0.396078 0.301961 0.180392 -244.813 0.611765 0.352941 0.0705882 18.2775 0.843137 0.0156863 0.156863 447.798 0.752941 0.752941 0.752941 3592.73 1 1 1",diffuse:"1",interpolation:"1"},{name:"CT-Soft-Tissue",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"10 -2048 0 -167.01 0 -160 1 240 1 3661 1",specular:"0",shade:"0",ambient:"0.2",colorTransfer:"20 -2048 0 0 0 -167.01 0 0 0 -160 0.0556356 0.0556356 0.0556356 240 1 1 1 3661 1 1 1",diffuse:"1",interpolation:"1"},{name:"CT-Air",gradientOpacity:"4 0 1 255 1",specularPower:"10",scalarOpacity:"8 -3024 0.705882 -900.0 0.715686 -500.0 0 3071 0",specular:"0.2",shade:"1",ambient:"0.1",colorTransfer:"16 -3024 1 1 1 -900.0 0.2 1.0 1.0 -500.0 0.3 0.3 1.0 3071 0 0 0 ",diffuse:"0.9",interpolation:"1"},{name:"MR-Angio",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"12 -2048 0 151.354 0 158.279 0.4375 190.112 0.580357 200.873 0.732143 3661 0.741071",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"24 -2048 0 0 0 151.354 0 0 0 158.279 0.74902 0.376471 0 190.112 1 0.866667 0.733333 200.873 0.937255 0.937255 0.937255 3661 1 1 1",diffuse:"1",interpolation:"1"},{name:"MR-Default",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"12 0 0 20 0 40 0.15 120 0.3 220 0.375 1024 0.5",specular:"0",shade:"1",ambient:"0.2",colorTransfer:"24 0 0 0 0 20 0.168627 0 0 40 0.403922 0.145098 0.0784314 120 0.780392 0.607843 0.380392 220 0.847059 0.835294 0.788235 1024 1 1 1",diffuse:"1",interpolation:"1"},{name:"MR-MIP",gradientOpacity:"4 0 1 255 1",specularPower:"1",scalarOpacity:"8 0 0 98.3725 0 416.637 1 2800 1",specular:"0",shade:"0",ambient:"0.2",colorTransfer:"16 0 1 1 1 98.3725 1 1 1 416.637 1 1 1 2800 1 1 1",diffuse:"1",interpolation:"1"},{name:"MR-T2-Brain",gradientOpacity:"4 0 1 160.25 1",specularPower:"40",scalarOpacity:"10 0 0 36.05 0 218.302 0.171429 412.406 1 641 1",specular:"0.5",shade:"1",ambient:"0.3",colorTransfer:"16 0 0 0 0 98.7223 0.956863 0.839216 0.192157 412.406 0 0.592157 0.807843 641 1 1 1",diffuse:"0.6",interpolation:"1"},{name:"DTI-FA-Brain",gradientOpacity:"4 0 1 0.9950 1",specularPower:"40",scalarOpacity:"16 0 0 0 0 0.3501 0.0158 0.49379 0.7619 0.6419 1 0.9920 1 0.9950 0 0.9950 0",specular:"0.5",shade:"1",ambient:"0.3",colorTransfer:"28 0 1 0 0 0 1 0 0 0.24974 0.4941 1 0 0.49949 0 0.9882 1 0.7492 0.51764 0 1 0.9950 1 0 0 0.9950 1 0 0",diffuse:"0.9",interpolation:"1"}],eK={slicer3D:[160/255,164/255,217/255]},xf=Object.freeze(Object.defineProperty({__proto__:null,BACKGROUND_COLORS:eK,CPU_COLORMAPS:Y3,EPSILON:Ga,MPR_CAMERA_VALUES:Nu,RENDERING_DEFAULTS:Wr,VIEWPORT_PRESETS:yP},Symbol.toStringTag,{value:"Module"})),Cg={},o1={get:t=>Cg[t],set:t=>{const e=t.id;Cg[e]=t},delete:t=>delete Cg[t],getAll:()=>{const e=Object.keys(Cg).map(r=>Cg[r]);return e.sort((r,n)=>r.id[0]==="_"&&n.id[0]!=="_"?1:r.id[0]!=="_"&&n.id[0]==="_"?-1:0),e}};class tK{constructor(){this.listeners={},this.debouncedListeners={}}reset(){this.listeners={},this.debouncedListeners={}}addEventListenerOnce(e,r){const n=i=>{this.removeEventListener(e,n),r.call(this,i)};this.addEventListener(e,n)}addEventListener(e,r){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].indexOf(r)===-1&&this.listeners[e].push(r)}addEventListenerDebounced(e,r,n){this.debouncedListeners[e]=this.debouncedListeners[e]||{};const i=this.debouncedListeners[e];if(!i[r]){const o=a=>{i[r]&&clearTimeout(i[r].timeoutId),i[r].timeoutId=setTimeout(()=>{r.call(this,a)},n)};i[r]={original:r,handle:o,timeoutId:null},this.addEventListener(e,o)}}removeEventListenerDebounced(e,r){var n;if((n=this.debouncedListeners[e])!=null&&n[r]){const i=this.debouncedListeners[e][r];this.removeEventListener(e,i.handle),clearTimeout(i.timeoutId),delete this.debouncedListeners[e][r]}}removeEventListener(e,r){if(!this.listeners[e])return;const n=this.listeners[e],i=n.length;for(let o=0;o<i;o++)if(n[o]===r){n.splice(o,1);return}}dispatchEvent(e){if(!this.listeners[e.type])return!e.defaultPrevented;const r=this.listeners[e.type].slice(),n=r.length;for(let i=0;i<n;i++)try{r[i].call(this,e)}catch(o){console.error(`error in event listener of type: ${e.type}`,o)}return!e.defaultPrevented}}const Ze=new tK;function gn(){return typeof crypto.randomUUID=="function"?crypto.randomUUID():("10000000-1000-4000-8000"+-1e11).replace(/[018]/g,t=>(t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>t/4).toString(16))}function it(t=Ze,e,r=null){if(!e)throw new Error("Event type was not defined");const n=new CustomEvent(e,{detail:r,cancelable:!0});return t==null?void 0:t.dispatchEvent(n)}var nK=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var n,i,o;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(i=n;i--!==0;)if(!t(e[i],r[i]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(o=Object.keys(e),n=o.length,n!==Object.keys(r).length)return!1;for(i=n;i--!==0;)if(!Object.prototype.hasOwnProperty.call(r,o[i]))return!1;for(i=n;i--!==0;){var a=o[i];if(!t(e[a],r[a]))return!1}return!0}return e!==e&&r!==r};const D_=ll(nK);var M6=Object.prototype.toString,wP=function(e){var r=M6.call(e),n=r==="[object Arguments]";return n||(n=r!=="[object Array]"&&e!==null&&typeof e=="object"&&typeof e.length=="number"&&e.length>=0&&M6.call(e.callee)==="[object Function]"),n},Nx,P6;function rK(){if(P6)return Nx;P6=1;var t;if(!Object.keys){var e=Object.prototype.hasOwnProperty,r=Object.prototype.toString,n=wP,i=Object.prototype.propertyIsEnumerable,o=!i.call({toString:null},"toString"),a=i.call(function(){},"prototype"),s=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],c=function(d){var h=d.constructor;return h&&h.prototype===d},l={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},f=function(){if(typeof window>"u")return!1;for(var d in window)try{if(!l["$"+d]&&e.call(window,d)&&window[d]!==null&&typeof window[d]=="object")try{c(window[d])}catch{return!0}}catch{return!0}return!1}(),u=function(d){if(typeof window>"u"||!f)return c(d);try{return c(d)}catch{return!1}};t=function(h){var g=h!==null&&typeof h=="object",p=r.call(h)==="[object Function]",v=n(h),y=g&&r.call(h)==="[object String]",m=[];if(!g&&!p&&!v)throw new TypeError("Object.keys called on a non-object");var w=a&&p;if(y&&h.length>0&&!e.call(h,0))for(var x=0;x<h.length;++x)m.push(String(x));if(v&&h.length>0)for(var C=0;C<h.length;++C)m.push(String(C));else for(var S in h)!(w&&S==="prototype")&&e.call(h,S)&&m.push(String(S));if(o)for(var T=u(h),_=0;_<s.length;++_)!(T&&s[_]==="constructor")&&e.call(h,s[_])&&m.push(s[_]);return m}}return Nx=t,Nx}var iK=Array.prototype.slice,oK=wP,R6=Object.keys,gv=R6?function(e){return R6(e)}:rK(),L6=Object.keys;gv.shim=function(){if(Object.keys){var e=function(){var r=Object.keys(arguments);return r&&r.length===arguments.length}(1,2);e||(Object.keys=function(n){return oK(n)?L6(iK.call(n)):L6(n)})}else Object.keys=gv;return Object.keys||gv};var aK=gv,pv=Object.defineProperty||!1;if(pv)try{pv({},"a",{value:1})}catch{pv=!1}var xP=pv,sK=SyntaxError,cK=TypeError,lK=Object.getOwnPropertyDescriptor,mv=lK;if(mv)try{mv([],"length")}catch{mv=null}var uK=mv,A6=xP,fK=sK,Hd=cK,N6=uK,dK=function(e,r,n){if(!e||typeof e!="object"&&typeof e!="function")throw new Hd("`obj` must be an object or a function`");if(typeof r!="string"&&typeof r!="symbol")throw new Hd("`property` must be a string or a symbol`");if(arguments.length>3&&typeof arguments[3]!="boolean"&&arguments[3]!==null)throw new Hd("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&typeof arguments[4]!="boolean"&&arguments[4]!==null)throw new Hd("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&typeof arguments[5]!="boolean"&&arguments[5]!==null)throw new Hd("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&typeof arguments[6]!="boolean")throw new Hd("`loose`, if provided, must be a boolean");var i=arguments.length>3?arguments[3]:null,o=arguments.length>4?arguments[4]:null,a=arguments.length>5?arguments[5]:null,s=arguments.length>6?arguments[6]:!1,c=!!N6&&N6(e,r);if(A6)A6(e,r,{configurable:a===null&&c?c.configurable:!a,enumerable:i===null&&c?c.enumerable:!i,value:n,writable:o===null&&c?c.writable:!o});else if(s||!i&&!o&&!a)e[r]=n;else throw new fK("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.")},J3=xP,CP=function(){return!!J3};CP.hasArrayLengthDefineBug=function(){if(!J3)return null;try{return J3([],"length",{value:1}).length!==1}catch{return!0}};var hK=CP,gK=aK,pK=typeof Symbol=="function"&&typeof Symbol("foo")=="symbol",mK=Object.prototype.toString,vK=Array.prototype.concat,k6=dK,yK=function(t){return typeof t=="function"&&mK.call(t)==="[object Function]"},SP=hK(),wK=function(t,e,r,n){if(e in t){if(n===!0){if(t[e]===r)return}else if(!yK(n)||!n())return}SP?k6(t,e,r,!0):k6(t,e,r)},TP=function(t,e){var r=arguments.length>2?arguments[2]:{},n=gK(e);pK&&(n=vK.call(n,Object.getOwnPropertySymbols(e)));for(var i=0;i<n.length;i+=1)wK(t,n[i],e[n[i]],r[n[i]])};TP.supportsDescriptors=!!SP;var _P=TP,vv={exports:{}};typeof self<"u"?vv.exports=self:typeof window<"u"?vv.exports=window:vv.exports=Function("return this")();var EP=vv.exports,xK=EP,bP=function(){return typeof Ai!="object"||!Ai||Ai.Math!==Math||Ai.Array!==Array?xK:Ai},CK=_P,SK=bP,TK=function(){var e=SK();if(CK.supportsDescriptors){var r=Object.getOwnPropertyDescriptor(e,"globalThis");(!r||r.configurable&&(r.enumerable||!r.writable||globalThis!==e))&&Object.defineProperty(e,"globalThis",{configurable:!0,enumerable:!1,value:e,writable:!0})}else(typeof globalThis!="object"||globalThis!==e)&&(e.globalThis=e);return e},_K=_P,EK=EP,DP=bP,bK=TK,DK=DP(),IP=function(){return DK};_K(IP,{getPolyfill:DP,implementation:EK,shim:bK});var IK=IP;const OK=ll(IK),Zs=OK(),OP={vtkObject:()=>null};function nc(t){if(t==null||t.isA)return t;if(!t.vtkClass)return Zs.console&&Zs.console.error&&Zs.console.error("Invalid VTK object"),null;const e=OP[t.vtkClass];if(!e)return Zs.console&&Zs.console.error&&Zs.console.error(`No vtk class found for Object of type ${t.vtkClass}`),null;const r={...t};Object.keys(r).forEach(i=>{r[i]&&typeof r[i]=="object"&&r[i].vtkClass&&(r[i]=nc(r[i]))});const n=e(r);return n&&n.modified&&n.modified(),n}function MK(t,e){OP[t]=e}nc.register=MK;class kx extends Array{push(){for(let e=0;e<arguments.length;e++)this.includes(arguments[e])||super.push(arguments[e]);return this.length}}let Z3=0;const MP=Symbol("void");function PK(){return Z3}const PP={};function jf(){}const RK=["log","debug","info","warn","error","time","timeEnd","group","groupEnd"];RK.forEach(t=>{PP[t]=jf});Zs.console=console.hasOwnProperty("log")?console:PP;const rf={debug:jf,error:Zs.console.error||jf,info:Zs.console.info||jf,log:Zs.console.log||jf,warn:Zs.console.warn||jf};function RP(t,e){rf[t]&&(rf[t]=e||jf)}function LP(){rf.log(...arguments)}function AP(){rf.info(...arguments)}function hy(){rf.debug(...arguments)}function vn(){rf.error(...arguments)}function Y5(){rf.warn(...arguments)}const V6={};function NP(t){V6[t]||(rf.error(t),V6[t]=!0)}const Mo=Object.create(null);Mo.Float32Array=Float32Array;Mo.Float64Array=Float64Array;Mo.Uint8Array=Uint8Array;Mo.Int8Array=Int8Array;Mo.Uint16Array=Uint16Array;Mo.Int16Array=Int16Array;Mo.Uint32Array=Uint32Array;Mo.Int32Array=Int32Array;Mo.Uint8ClampedArray=Uint8ClampedArray;try{Mo.BigInt64Array=BigInt64Array,Mo.BigUint64Array=BigUint64Array}catch{}function Uh(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];return new(Mo[t]||Float64Array)(...r)}function J5(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),n=1;n<e;n++)r[n-1]=arguments[n];return(Mo[t]||Float64Array).from(...r)}function Z5(t){return t.charAt(0).toUpperCase()+t.slice(1)}function ni(t){return Z5(t[0]==="_"?t.slice(1):t)}function kP(t){return t.charAt(0).toLowerCase()+t.slice(1)}function VP(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1e3;const n=["TB","GB","MB","KB"];let i=Number(t),o="B";for(;i>r;)i/=r,o=n.pop();return`${i.toFixed(e)} ${o}`}function FP(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:" ";const r=[];let n=t;for(;n>1e3;)r.push(`000${n%1e3}`.slice(-3)),n=Math.floor(n/1e3);return n>0&&r.push(n),r.reverse(),r.join(e)}function UP(t){Object.keys(t).forEach(e=>{Array.isArray(t[e])&&(t[e]=[].concat(t[e]))})}function LK(t){return Object.values(Mo).some(e=>t instanceof e)}function AK(t,e){if(t===e)return!0;if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}return!1}function NK(t,e){return Object.keys(t).find(r=>t[r]===e)}function BP(t){return t&&t.isA?t.getState():t}function I_(t){setTimeout(t,0)}function GP(t,e){const r=performance.now();t.finally(()=>{const n=performance.now()-r;e(n)})}function or(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};UP(e);const r=[];if(Number.isInteger(e.mtime)||(e.mtime=++Z3),!("classHierarchy"in e))e.classHierarchy=new kx("vtkObject");else if(!(e.classHierarchy instanceof kx)){const o=new kx;for(let a=0;a<e.classHierarchy.length;a++)o.push(e.classHierarchy[a]);e.classHierarchy=o}function n(o){r[o]=null}function i(o){function a(){n(o)}return Object.freeze({unsubscribe:a})}return t.isDeleted=()=>!!e.deleted,t.modified=o=>{if(e.deleted){vn("instance deleted - cannot call any method");return}o&&o<t.getMTime()||(e.mtime=++Z3,r.forEach(a=>a&&a(t)))},t.onModified=o=>{if(e.deleted)return vn("instance deleted - cannot call any method"),null;const a=r.length;return r.push(o),i(a)},t.getMTime=()=>e.mtime,t.isA=o=>{let a=e.classHierarchy.length;for(;a--;)if(e.classHierarchy[a]===o)return!0;return!1},t.getClassName=function(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return e.classHierarchy[e.classHierarchy.length-1-o]},t.set=function(){let o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,c=!1;return Object.keys(o).forEach(l=>{const f=s?null:t[`set${Z5(l)}`];f&&Array.isArray(o[l])&&f.length>1?c=f(...o[l])||c:f?c=f(o[l])||c:(["mtime"].indexOf(l)===-1&&!a&&Y5(`Warning: Set value to model directly ${l}, ${o[l]}`),c=e[l]!==o[l]||c,e[l]=o[l])}),c},t.get=function(){for(var o=arguments.length,a=new Array(o),s=0;s<o;s++)a[s]=arguments[s];if(!a.length)return e;const c={};return a.forEach(l=>{c[l]=e[l]}),c},t.getReferenceByName=o=>e[o],t.delete=()=>{Object.keys(e).forEach(o=>delete e[o]),r.forEach((o,a)=>n(a)),e.deleted=!0},t.getState=()=>{if(e.deleted)return null;const o={...e,vtkClass:t.getClassName()};Object.keys(o).forEach(s=>{o[s]===null||o[s]===void 0||s[0]==="_"?delete o[s]:o[s].isA?o[s]=o[s].getState():Array.isArray(o[s])?o[s]=o[s].map(BP):LK(o[s])&&(o[s]=Array.from(o[s]))});const a={};return Object.keys(o).sort().forEach(s=>{a[s]=o[s]}),a.mtime&&delete a.mtime,a},t.shallowCopy=function(o){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(o.getClassName()!==t.getClassName())throw new Error(`Cannot ShallowCopy ${o.getClassName()} into ${t.getClassName()}`);const s=o.get(),c=Object.keys(e).sort();Object.keys(s).sort().forEach(f=>{const u=c.indexOf(f);u===-1?a&&hy(`add ${f} in shallowCopy`):c.splice(u,1),e[f]=s[f]}),c.length&&a&&hy(`Untouched keys: ${c.join(", ")}`),t.modified()},t.toJSON=function(){return t.getState()},t}const kK={object(t,e,r){return function(){return{...e[r.name]}}}};function Ro(t,e,r){r.forEach(n=>{if(typeof n=="object"){const i=kK[n.type];i?t[`get${ni(n.name)}`]=i(t,e,n):t[`get${ni(n.name)}`]=()=>e[n.name]}else t[`get${ni(n)}`]=()=>e[n]})}const WP={enum(t,e,r){const n=`_on${ni(r.name)}Changed`;return i=>{var o;if(typeof i=="string"){if(r.enum[i]!==void 0)return e[r.name]!==r.enum[i]?(e[r.name]=r.enum[i],t.modified(),!0):!1;throw vn(`Set Enum with invalid argument ${r}, ${i}`),new RangeError("Set Enum with invalid string argument")}if(typeof i=="number"){if(e[r.name]!==i){if(Object.keys(r.enum).map(a=>r.enum[a]).indexOf(i)!==-1){const a=e[r.name];return e[r.name]=i,(o=e[n])==null||o.call(e,t,e,i,a),t.modified(),!0}throw vn(`Set Enum outside numeric range ${r}, ${i}`),new RangeError("Set Enum outside numeric range")}return!1}throw vn(`Set Enum with invalid argument (String/Number) ${r}, ${i}`),new TypeError("Set Enum with invalid argument (String/Number)")}},object(t,e,r){var i;((i=r.params)==null?void 0:i.length)===1&&Y5('Setter of type "object" with a single "param" field is not supported');const n=`_on${ni(r.name)}Changed`;return function(){var l,f;for(var o=arguments.length,a=new Array(o),s=0;s<o;s++)a[s]=arguments[s];let c;if(a.length>1&&((l=r.params)!=null&&l.length)?c=r.params.reduce((u,d,h)=>Object.assign(u,{[d]:a[h]}),{}):c=a[0],!D_(e[r.name],c)){const u=e[r.name];return e[r.name]=c,(f=e[n])==null||f.call(e,t,e,c,u),t.modified(),!0}return!1}}};function F6(t){if(typeof t=="object"){const e=WP[t.type];if(e)return(r,n)=>e(r,n,t);throw vn(`No setter for field ${t}`),new TypeError("No setter for field")}return function(r,n){const i=`_on${ni(t)}Changed`;return function(a){var s;if(n.deleted)return vn("instance deleted - cannot call any method"),!1;if(n[t]!==a){const c=n[t.name];return n[t]=a,(s=n[i])==null||s.call(n,r,n,a,c),r.modified(),!0}return!1}}}function q1(t,e,r){r.forEach(n=>{typeof n=="object"?t[`set${ni(n.name)}`]=F6(n)(t,e):t[`set${ni(n)}`]=F6(n)(t,e)})}function Jr(t,e,r){Ro(t,e,r),q1(t,e,r)}function Bh(t,e,r){r.forEach(n=>{t[`get${ni(n)}`]=()=>e[n]?Array.from(e[n]):e[n],t[`get${ni(n)}ByReference`]=()=>e[n]})}function O_(t,e,r,n){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:void 0;r.forEach(o=>{if(e[o]&&n&&e[o].length!==n)throw new RangeError(`Invalid initial number of values for array (${o})`);const a=`_on${ni(o)}Changed`;t[`set${ni(o)}`]=function(){var h;if(e.deleted)return vn("instance deleted - cannot call any method"),!1;for(var s=arguments.length,c=new Array(s),l=0;l<s;l++)c[l]=arguments[l];let f=c,u,d=!1;if(f.length===1&&(f[0]==null||f[0].length>=0)&&(f=f[0],d=!0),f==null)u=e[o]!==f;else{if(n&&f.length!==n)if(f.length<n&&i!==void 0)for(f=Array.from(f),d=!1;f.length<n;)f.push(i);else throw new RangeError(`Invalid number of values for array setter (${o})`);u=e[o]==null||e[o].length!==f.length;for(let g=0;!u&&g<f.length;++g)u=e[o][g]!==f[g];u&&d&&(f=Array.from(f))}if(u){const g=e[o.name];e[o]=f,(h=e[a])==null||h.call(e,t,e,f,g),t.modified()}return u},t[`set${ni(o)}From`]=s=>{const c=e[o];s.forEach((l,f)=>{c[f]=l})}})}function M_(t,e,r,n){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:void 0;Bh(t,e,r),O_(t,e,r,n,i)}function X1(t,e,r){for(let n=0;n<r.length;n++){const i=r[n];e[i]!==void 0&&(e[`_${i}`]=e[i],delete e[i])}}function P_(t,e,r,n){e.inputData?e.inputData=e.inputData.map(nc):e.inputData=[],e.inputConnection?e.inputConnection=e.inputConnection.map(nc):e.inputConnection=[],e.output?e.output=e.output.map(nc):e.output=[],e.inputArrayToProcess?e.inputArrayToProcess=e.inputArrayToProcess.map(nc):e.inputArrayToProcess=[],e.numberOfInputs=r;function i(h){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(e.deleted){vn("instance deleted - cannot call any method");return}if(g>=e.numberOfInputs){vn(`algorithm ${t.getClassName()} only has ${e.numberOfInputs} input ports. To add more input ports, use addInputData()`);return}(e.inputData[g]!==h||e.inputConnection[g])&&(e.inputData[g]=h,e.inputConnection[g]=null,t.modified&&t.modified())}function o(){let h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return e.inputConnection[h]&&(e.inputData[h]=e.inputConnection[h]()),e.inputData[h]}function a(h){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(e.deleted){vn("instance deleted - cannot call any method");return}if(g>=e.numberOfInputs){let p=`algorithm ${t.getClassName()} only has `;p+=`${e.numberOfInputs}`,p+=" input ports. To add more input ports, use addInputConnection()",vn(p);return}e.inputData[g]=null,e.inputConnection[g]=h}function s(){let h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return e.inputConnection[h]}function c(){let h=e.numberOfInputs;for(;h&&!e.inputData[h-1]&&!e.inputConnection[h-1];)h--;return h===e.numberOfInputs&&e.numberOfInputs++,h}function l(h){if(e.deleted){vn("instance deleted - cannot call any method");return}a(h,c())}function f(h){if(e.deleted){vn("instance deleted - cannot call any method");return}i(h,c())}function u(){let h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return e.deleted?(vn("instance deleted - cannot call any method"),null):(t.shouldUpdate()&&t.update(),e.output[h])}t.shouldUpdate=()=>{var v,y;const h=t.getMTime();let g=1/0,p=n;for(;p--;){if(!e.output[p]||e.output[p].isDeleted())return!0;const m=e.output[p].getMTime();if(m<h)return!0;m<g&&(g=m)}for(p=e.numberOfInputs;p--;)if((v=e.inputConnection[p])!=null&&v.filter.shouldUpdate()||((y=t.getInputData(p))==null?void 0:y.getMTime())>g)return!0;return!1};function d(){let h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;const g=()=>u(h);return g.filter=t,g}if(e.numberOfInputs){let h=e.numberOfInputs;for(;h--;)e.inputData.push(null),e.inputConnection.push(null);t.setInputData=i,t.setInputConnection=a,t.addInputData=f,t.addInputConnection=l,t.getInputData=o,t.getInputConnection=s}n&&(t.getOutputData=u,t.getOutputPort=d),t.update=()=>{const h=[];if(e.numberOfInputs){let g=0;for(;g<e.numberOfInputs;)h[g]=t.getInputData(g),g++}t.shouldUpdate()&&t.requestData&&t.requestData(h,e.output)},t.getNumberOfInputPorts=()=>e.numberOfInputs,t.getNumberOfOutputPorts=()=>n||e.output.length,t.getInputArrayToProcess=h=>{const g=e.inputArrayToProcess[h],p=e.inputData[h];return g&&p?p[`get${g.fieldAssociation}`]().getArray(g.arrayName):null},t.setInputArrayToProcess=function(h,g,p){let v=arguments.length>3&&arguments[3]!==void 0?arguments[3]:"Scalars";for(;e.inputArrayToProcess.length<h;)e.inputArrayToProcess.push(null);e.inputArrayToProcess[h]={arrayName:g,fieldAssociation:p,attributeType:v}}}const R_=Symbol("Event abort");function L_(t,e,r){const n=[],i=t.delete;let o=1;function a(l){for(let f=0;f<n.length;++f){const[u]=n[f];if(u===l){n.splice(f,1);return}}}function s(l){function f(){a(l)}return Object.freeze({unsubscribe:f})}function c(){if(e.deleted){vn("instance deleted - cannot call any method");return}const l=n.slice();for(let f=0;f<l.length;++f){const[,u,d]=l[f];if(u){if(d<0)setTimeout(()=>u.apply(t,arguments),1-d);else if(u.apply(t,arguments)===R_)break}}}t[`invoke${ni(r)}`]=c,t[`on${ni(r)}`]=function(l){let f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(!l.apply)return console.error(`Invalid callback for event ${r}`),null;if(e.deleted)return vn("instance deleted - cannot call any method"),null;const u=o++;return n.push([u,l,f]),n.sort((d,h)=>h[2]-d[2]),s(u)},t.delete=()=>{i(),n.forEach(l=>{let[f]=l;return a(f)})}}function Rn(t,e){const r=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const i={},o={};return t(o,i,n),Object.freeze(o)};return e&&nc.register(e,r),r}function Y1(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return function(){for(var n=arguments.length,i=new Array(n),o=0;o<n;o++)i[o]=arguments[o];return e.filter(a=>!!a).map(a=>a(...i))}}function A_(t){return t&&t.isA&&t.isA("vtkObject")}function gy(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:[];if(A_(t)){if(n.indexOf(t)>=0)return r;n.push(t);const i=e(t);i!==void 0&&r.push(i);const o=t.get();Object.keys(o).forEach(a=>{const s=o[a];Array.isArray(s)?s.forEach(c=>{gy(c,e,r,n)}):gy(s,e,r,n)})}return r}function zP(t,e,r){var n=this;let i;const o=function(){for(var a=arguments.length,s=new Array(a),c=0;c<a;c++)s[c]=arguments[c];const l=n,f=()=>{i=null,r||t.apply(l,s)},u=r&&!i;clearTimeout(i),i=setTimeout(f,e),u&&t.apply(l,s)};return o.cancel=()=>clearTimeout(i),o}function $P(t,e){let r=!1,n=null;function i(){r=!1,n!==null&&(o(...n),n=null)}function o(){for(var a=arguments.length,s=new Array(a),c=0;c<a;c++)s[c]=arguments[c];if(r){n=s;return}r=!0,t(...s),setTimeout(i,e)}return o}function N_(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};e.keystore=Object.assign(e.keystore||{},r),t.setKey=(n,i)=>{e.keystore[n]=i},t.getKey=n=>e.keystore[n],t.getAllKeys=()=>Object.keys(e.keystore),t.deleteKey=n=>delete e.keystore[n],t.clearKeystore=()=>t.getAllKeys().forEach(n=>delete e.keystore[n])}let VK=1;const Zm="__root__";function jP(t,e){N_(t,e);const r=t.delete;e.proxyId=`${VK++}`,e.ui=JSON.parse(JSON.stringify(e.ui||[])),Ro(t,e,["proxyId","proxyGroup","proxyName"]),Jr(t,e,["proxyManager"]);const n={},i={};function o(l,f){i[f]||(i[f]=[]);const u=i[f];for(let d=0;d<l.length;d++)u.push(l[d].name),n[l[d].name]=l[d],l[d].children&&l[d].children.length&&o(l[d].children,l[d].name)}o(e.ui,Zm),t.updateUI=l=>{e.ui=JSON.parse(JSON.stringify(l||[])),Object.keys(n).forEach(f=>delete n[f]),Object.keys(i).forEach(f=>delete i[f]),o(e.ui,Zm),t.modified()};function a(){let l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Zm;return i[l]}t.updateProxyProperty=(l,f)=>{const u=n[l];u?Object.assign(u,f):n[l]={...f}},t.activate=()=>{if(e.proxyManager){const l=`setActive${ni(t.getProxyGroup().slice(0,-1))}`;e.proxyManager[l]&&e.proxyManager[l](t)}},e.propertyLinkSubscribers={},t.registerPropertyLinkForGC=(l,f)=>{f in e.propertyLinkSubscribers||(e.propertyLinkSubscribers[f]=[]),e.propertyLinkSubscribers[f].push(l)},t.gcPropertyLinks=l=>{const f=e.propertyLinkSubscribers[l]||[];for(;f.length;)f.pop().unbind(t)},e.propertyLinkMap={},t.getPropertyLink=function(l){let f=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(e.propertyLinkMap[l])return e.propertyLinkMap[l];let u=null;const d=[];let h=0,g=!1;function p(x){let C=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(g)return null;const S=[];let T=null;for(h=d.length;h--;){const E=d[h];E.instance===x?T=E:S.push(E)}if(!T)return null;const _=T.instance[`get${ni(T.propertyName)}`]();if(!AK(_,u)||C){for(u=_,g=!0;S.length;){const E=S.pop();E.instance.set({[E.propertyName]:u})}g=!1}return e.propertyLinkMap[l].persistent&&(e.propertyLinkMap[l].value=_),_}function v(x,C){const S=[];for(h=d.length;h--;){const T=d[h];T.instance===x&&(T.propertyName===C||C===void 0)&&(T.subscription.unsubscribe(),S.push(h))}for(;S.length;)d.splice(S.pop(),1)}function y(x,C){let S=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const T=x.onModified(p),_=d[0];return d.push({instance:x,propertyName:C,subscription:T}),S&&(e.propertyLinkMap[l].persistent&&e.propertyLinkMap[l].value!==void 0?x.set({[C]:e.propertyLinkMap[l].value}):_&&p(_.instance,!0)),{unsubscribe:()=>v(x,C)}}function m(){for(;d.length;)d.pop().subscription.unsubscribe()}const w={bind:y,unbind:v,unsubscribe:m,persistent:f};return e.propertyLinkMap[l]=w,w};function s(){let l=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Zm;const f=[],u=e.proxyId,d=a(l)||[];for(let h=0;h<d.length;h++){const g=d[h],p=t[`get${ni(g)}`],v=p?p():void 0,y={id:u,name:g,value:v},m=s(g);m.length&&(y.children=m),f.push(y)}return f}t.listPropertyNames=()=>s().map(l=>l.name),t.getPropertyByName=l=>s().find(f=>f.name===l),t.getPropertyDomainByName=l=>(n[l]||{}).domain,t.getProxySection=()=>({id:e.proxyId,name:e.proxyGroup,ui:e.ui,properties:s()}),t.delete=()=>{const l=Object.keys(e.propertyLinkMap);let f=l.length;for(;f--;)e.propertyLinkMap[l[f]].unsubscribe();Object.keys(e.propertyLinkSubscribers).forEach(t.gcPropertyLinks),r()},t.getState=()=>null;function c(){if(e.links)for(let l=0;l<e.links.length;l++){const{link:f,property:u,persistent:d,updateOnBind:h,type:g}=e.links[l];if(g==="application"){const p=e.proxyManager.getPropertyLink(f,d);t.registerPropertyLinkForGC(p,"application"),p.bind(t,u,h)}}}I_(c)}function HP(t,e,r){const n=t.delete,i=[],o=Object.keys(r);let a=o.length;for(;a--;){const s=o[a],{modelKey:c,property:l,modified:f=!0}=r[s],u=ni(l),d=ni(s);t[`get${d}`]=e[c][`get${u}`],t[`set${d}`]=e[c][`set${u}`],f&&i.push(e[c].onModified(t.modified))}t.delete=()=>{for(;i.length;)i.pop().unsubscribe();n()}}function KP(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};e.this=t;function i(s){const c=Object.keys(s);let l=c.length;for(;l--;){const f=c[l];e[f].set(s[f])}}const o=Object.keys(n);let a=o.length;for(;a--;){const s=o[a];e[s]=n[s];const c=r[s];t[`set${ni(s)}`]=l=>{if(l!==e[s]){e[s]=l;const f=c[l];i(f),t.modified()}}}o.length&&Ro(t,e,o)}const U6=10,B6=40,G6=800;function qP(t){let e=0,r=0,n=0,i=0;return"detail"in t&&(r=t.detail),"wheelDelta"in t&&(r=-t.wheelDelta/120),"wheelDeltaY"in t&&(r=-t.wheelDeltaY/120),"wheelDeltaX"in t&&(e=-t.wheelDeltaX/120),"axis"in t&&t.axis===t.HORIZONTAL_AXIS&&(e=r,r=0),n=e*U6,i=r*U6,"deltaY"in t&&(i=t.deltaY),"deltaX"in t&&(n=t.deltaX),(n||i)&&t.deltaMode&&(t.deltaMode===1?(n*=B6,i*=B6):(n*=G6,i*=G6)),n&&!e&&(e=n<1?-1:1),i&&!r&&(r=i<1?-1:1),{spinX:e,spinY:r||e,pixelX:n,pixelY:i||n}}var Z={algo:P_,capitalize:Z5,chain:Y1,debounce:zP,enumToString:NK,event:L_,EVENT_ABORT:R_,formatBytesToProperUnit:VP,formatNumbersWithThousandSeparator:FP,get:Ro,getArray:Bh,getCurrentGlobalMTime:PK,getStateArrayMapFunc:BP,isVtkObject:A_,keystore:N_,measurePromiseExecution:GP,moveToProtected:X1,newInstance:Rn,newTypedArray:Uh,newTypedArrayFrom:J5,normalizeWheel:qP,obj:or,proxy:jP,proxyPropertyMapping:HP,proxyPropertyState:KP,safeArrays:UP,set:q1,setArray:O_,setGet:Jr,setGetArray:M_,setImmediate:I_,setLoggerFunction:RP,throttle:$P,traverseInstanceTree:gy,TYPED_ARRAYS:Mo,uncapitalize:kP,VOID:MP,vtkDebugMacro:hy,vtkErrorMacro:vn,vtkInfoMacro:AP,vtkLogMacro:LP,vtkOnceErrorMacro:NP,vtkWarningMacro:Y5,objectSetterMap:WP},uo=Object.freeze({__proto__:null,VOID:MP,setLoggerFunction:RP,vtkLogMacro:LP,vtkInfoMacro:AP,vtkDebugMacro:hy,vtkErrorMacro:vn,vtkWarningMacro:Y5,vtkOnceErrorMacro:NP,TYPED_ARRAYS:Mo,newTypedArray:Uh,newTypedArrayFrom:J5,capitalize:Z5,_capitalize:ni,uncapitalize:kP,formatBytesToProperUnit:VP,formatNumbersWithThousandSeparator:FP,setImmediateVTK:I_,measurePromiseExecution:GP,obj:or,get:Ro,set:q1,setGet:Jr,getArray:Bh,setArray:O_,setGetArray:M_,moveToProtected:X1,algo:P_,EVENT_ABORT:R_,event:L_,newInstance:Rn,chain:Y1,isVtkObject:A_,traverseInstanceTree:gy,debounce:zP,throttle:$P,keystore:N_,proxy:jP,proxyPropertyMapping:HP,proxyPropertyState:KP,normalizeWheel:qP,default:Z});const XP={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},rn={VOID:"",CHAR:"Int8Array",SIGNED_CHAR:"Int8Array",UNSIGNED_CHAR:"Uint8Array",UNSIGNED_CHAR_CLAMPED:"Uint8ClampedArray",SHORT:"Int16Array",UNSIGNED_SHORT:"Uint16Array",INT:"Int32Array",UNSIGNED_INT:"Uint32Array",FLOAT:"Float32Array",DOUBLE:"Float64Array"},FK=rn.FLOAT;var YP={DefaultDataType:FK,DataTypeByteSize:XP,VtkDataTypes:rn};const UK="WebGL",py=Object.create(null);function JP(t,e){py[t]=e}function BK(){return Object.keys(py)}function ZP(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return py[t]&&py[t](e)}function GK(t,e){e.classHierarchy.push("vtkRenderWindow"),t.addRenderer=r=>{t.hasRenderer(r)||(r.setRenderWindow(t),e.renderers.push(r),t.modified())},t.removeRenderer=r=>{e.renderers=e.renderers.filter(n=>n!==r),t.modified()},t.hasRenderer=r=>e.renderers.indexOf(r)!==-1,t.newAPISpecificView=function(r){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return ZP(r||e.defaultViewAPI,n)},t.addView=r=>{t.hasView(r)||(r.setRenderable(t),e._views.push(r),t.modified())},t.removeView=r=>{e._views=e._views.filter(n=>n!==r),t.modified()},t.hasView=r=>e._views.indexOf(r)!==-1,t.preRender=()=>{e.renderers.forEach(r=>{r.isActiveCameraCreated()||r.resetCamera()})},t.render=()=>{t.preRender(),e.interactor?e.interactor.render():e._views.forEach(r=>r.traverseAllPasses())},t.getStatistics=()=>{const r={propCount:0,invisiblePropCount:0,gpuMemoryMB:0};return e._views.forEach(n=>{n.getGraphicsMemoryInfo&&(r.gpuMemoryMB+=n.getGraphicsMemoryInfo()/1e6)}),e.renderers.forEach(n=>{const i=n.getViewProps(),o=e._views[0].getViewNodeFor(n);i.forEach(a=>{if(a.getVisibility()){r.propCount+=1;const s=a.getMapper&&a.getMapper();if(s&&s.getPrimitiveCount){const c=o.getViewNodeFor(s);if(c){c.getAllocatedGPUMemoryInBytes&&(r.gpuMemoryMB+=c.getAllocatedGPUMemoryInBytes()/1e6);const l=s.getPrimitiveCount();Object.keys(l).forEach(f=>{r[f]||(r[f]=0),r[f]+=l[f]})}}}else r.invisiblePropCount+=1})}),r.str=Object.keys(r).map(n=>`${n}: ${r[n]}`).join(`
|
||
`),r},t.captureImages=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"image/png",n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Z.setImmediate(t.render),e._views.map(i=>i.captureNextImage?i.captureNextImage(r,n):void 0).filter(i=>!!i)},t.addRenderWindow=r=>e.childRenderWindows.includes(r)?!1:(e.childRenderWindows.push(r),t.modified(),!0),t.removeRenderWindow=r=>{const n=e.childRenderWindows.findIndex(i=>i===r);return n<0?!1:(e.childRenderWindows.splice(n,1),t.modified(),!0)}}const WK={defaultViewAPI:UK,renderers:[],views:[],interactor:null,neverRendered:!0,numberOfLayers:1,childRenderWindows:[]};function QP(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,WK,r),Z.obj(t,e),Z.setGet(t,e,["interactor","numberOfLayers","_views","defaultViewAPI"]),Z.get(t,e,["neverRendered"]),Z.getArray(t,e,["renderers","childRenderWindows"]),Z.moveToProtected(t,e,["views"]),Z.event(t,e,"completion"),GK(t,e)}const zK=Z.newInstance(QP,"vtkRenderWindow");var $K={newInstance:zK,extend:QP,registerViewConstructor:JP,listViewAPIs:BK,newAPISpecificView:ZP};const a1={CLAMP_TO_EDGE:0,REPEAT:1,MIRRORED_REPEAT:2},Pt={NEAREST:0,LINEAR:1,NEAREST_MIPMAP_NEAREST:2,NEAREST_MIPMAP_LINEAR:3,LINEAR_MIPMAP_NEAREST:4,LINEAR_MIPMAP_LINEAR:5};var eR={Wrap:a1,Filter:Pt};const tR=new Float32Array(1),jK=new Int32Array(tR.buffer);function HK(t){tR[0]=t;const e=jK[0];let r=e>>16&32768,n=e>>12&2047;const i=e>>23&255;return i<103?r:i>142?(r|=31744,r|=(i===255?0:1)&&e&8388607,r):i<113?(n|=2048,r|=(n>>114-i)+(n>>113-i&1),r):(r|=i-112<<10|n>>1,r+=n&1,r)}function KK(t){const e=(t&32768)>>15,r=(t&31744)>>10,n=t&1023;return r===0?(e?-1:1)*2**-14*(n/2**10):r===31?n?NaN:(e?-1:1)*(1/0):(e?-1:1)*2**(r-15)*(1+n/2**10)}var Hf={fromHalf:KK,toHalf:HK},k_={exports:{}};k_.exports;(function(t){(function(e,r,n){function i(c){var l=this,f=s();l.next=function(){var u=2091639*l.s0+l.c*23283064365386963e-26;return l.s0=l.s1,l.s1=l.s2,l.s2=u-(l.c=u|0)},l.c=1,l.s0=f(" "),l.s1=f(" "),l.s2=f(" "),l.s0-=f(c),l.s0<0&&(l.s0+=1),l.s1-=f(c),l.s1<0&&(l.s1+=1),l.s2-=f(c),l.s2<0&&(l.s2+=1),f=null}function o(c,l){return l.c=c.c,l.s0=c.s0,l.s1=c.s1,l.s2=c.s2,l}function a(c,l){var f=new i(c),u=l&&l.state,d=f.next;return d.int32=function(){return f.next()*4294967296|0},d.double=function(){return d()+(d()*2097152|0)*11102230246251565e-32},d.quick=d,u&&(typeof u=="object"&&o(u,f),d.state=function(){return o(f,{})}),d}function s(){var c=4022871197,l=function(f){f=String(f);for(var u=0;u<f.length;u++){c+=f.charCodeAt(u);var d=.02519603282416938*c;c=d>>>0,d-=c,d*=c,c=d>>>0,d-=c,c+=d*4294967296}return(c>>>0)*23283064365386963e-26};return l}r&&r.exports?r.exports=a:this.alea=a})(Ai,t)})(k_);var qK=k_.exports,V_={exports:{}};V_.exports;(function(t){(function(e,r,n){function i(s){var c=this,l="";c.x=0,c.y=0,c.z=0,c.w=0,c.next=function(){var u=c.x^c.x<<11;return c.x=c.y,c.y=c.z,c.z=c.w,c.w^=c.w>>>19^u^u>>>8},s===(s|0)?c.x=s:l+=s;for(var f=0;f<l.length+64;f++)c.x^=l.charCodeAt(f)|0,c.next()}function o(s,c){return c.x=s.x,c.y=s.y,c.z=s.z,c.w=s.w,c}function a(s,c){var l=new i(s),f=c&&c.state,u=function(){return(l.next()>>>0)/4294967296};return u.double=function(){do var d=l.next()>>>11,h=(l.next()>>>0)/4294967296,g=(d+h)/(1<<21);while(g===0);return g},u.int32=l.next,u.quick=u,f&&(typeof f=="object"&&o(f,l),u.state=function(){return o(l,{})}),u}r&&r.exports?r.exports=a:this.xor128=a})(Ai,t)})(V_);var XK=V_.exports,F_={exports:{}};F_.exports;(function(t){(function(e,r,n){function i(s){var c=this,l="";c.next=function(){var u=c.x^c.x>>>2;return c.x=c.y,c.y=c.z,c.z=c.w,c.w=c.v,(c.d=c.d+362437|0)+(c.v=c.v^c.v<<4^(u^u<<1))|0},c.x=0,c.y=0,c.z=0,c.w=0,c.v=0,s===(s|0)?c.x=s:l+=s;for(var f=0;f<l.length+64;f++)c.x^=l.charCodeAt(f)|0,f==l.length&&(c.d=c.x<<10^c.x>>>4),c.next()}function o(s,c){return c.x=s.x,c.y=s.y,c.z=s.z,c.w=s.w,c.v=s.v,c.d=s.d,c}function a(s,c){var l=new i(s),f=c&&c.state,u=function(){return(l.next()>>>0)/4294967296};return u.double=function(){do var d=l.next()>>>11,h=(l.next()>>>0)/4294967296,g=(d+h)/(1<<21);while(g===0);return g},u.int32=l.next,u.quick=u,f&&(typeof f=="object"&&o(f,l),u.state=function(){return o(l,{})}),u}r&&r.exports?r.exports=a:this.xorwow=a})(Ai,t)})(F_);var YK=F_.exports,U_={exports:{}};U_.exports;(function(t){(function(e,r,n){function i(s){var c=this;c.next=function(){var f=c.x,u=c.i,d,h;return d=f[u],d^=d>>>7,h=d^d<<24,d=f[u+1&7],h^=d^d>>>10,d=f[u+3&7],h^=d^d>>>3,d=f[u+4&7],h^=d^d<<7,d=f[u+7&7],d=d^d<<13,h^=d^d<<9,f[u]=h,c.i=u+1&7,h};function l(f,u){var d,h=[];if(u===(u|0))h[0]=u;else for(u=""+u,d=0;d<u.length;++d)h[d&7]=h[d&7]<<15^u.charCodeAt(d)+h[d+1&7]<<13;for(;h.length<8;)h.push(0);for(d=0;d<8&&h[d]===0;++d);for(d==8?h[7]=-1:h[d],f.x=h,f.i=0,d=256;d>0;--d)f.next()}l(c,s)}function o(s,c){return c.x=s.x.slice(),c.i=s.i,c}function a(s,c){s==null&&(s=+new Date);var l=new i(s),f=c&&c.state,u=function(){return(l.next()>>>0)/4294967296};return u.double=function(){do var d=l.next()>>>11,h=(l.next()>>>0)/4294967296,g=(d+h)/(1<<21);while(g===0);return g},u.int32=l.next,u.quick=u,f&&(f.x&&o(f,l),u.state=function(){return o(l,{})}),u}r&&r.exports?r.exports=a:this.xorshift7=a})(Ai,t)})(U_);var JK=U_.exports,B_={exports:{}};B_.exports;(function(t){(function(e,r,n){function i(s){var c=this;c.next=function(){var f=c.w,u=c.X,d=c.i,h,g;return c.w=f=f+1640531527|0,g=u[d+34&127],h=u[d=d+1&127],g^=g<<13,h^=h<<17,g^=g>>>15,h^=h>>>12,g=u[d]=g^h,c.i=d,g+(f^f>>>16)|0};function l(f,u){var d,h,g,p,v,y=[],m=128;for(u===(u|0)?(h=u,u=null):(u=u+"\0",h=0,m=Math.max(m,u.length)),g=0,p=-32;p<m;++p)u&&(h^=u.charCodeAt((p+32)%u.length)),p===0&&(v=h),h^=h<<10,h^=h>>>15,h^=h<<4,h^=h>>>13,p>=0&&(v=v+1640531527|0,d=y[p&127]^=h+v,g=d==0?g+1:0);for(g>=128&&(y[(u&&u.length||0)&127]=-1),g=127,p=4*128;p>0;--p)h=y[g+34&127],d=y[g=g+1&127],h^=h<<13,d^=d<<17,h^=h>>>15,d^=d>>>12,y[g]=h^d;f.w=v,f.X=y,f.i=g}l(c,s)}function o(s,c){return c.i=s.i,c.w=s.w,c.X=s.X.slice(),c}function a(s,c){s==null&&(s=+new Date);var l=new i(s),f=c&&c.state,u=function(){return(l.next()>>>0)/4294967296};return u.double=function(){do var d=l.next()>>>11,h=(l.next()>>>0)/4294967296,g=(d+h)/(1<<21);while(g===0);return g},u.int32=l.next,u.quick=u,f&&(f.X&&o(f,l),u.state=function(){return o(l,{})}),u}r&&r.exports?r.exports=a:this.xor4096=a})(Ai,t)})(B_);var ZK=B_.exports,G_={exports:{}};G_.exports;(function(t){(function(e,r,n){function i(s){var c=this,l="";c.next=function(){var u=c.b,d=c.c,h=c.d,g=c.a;return u=u<<25^u>>>7^d,d=d-h|0,h=h<<24^h>>>8^g,g=g-u|0,c.b=u=u<<20^u>>>12^d,c.c=d=d-h|0,c.d=h<<16^d>>>16^g,c.a=g-u|0},c.a=0,c.b=0,c.c=-1640531527,c.d=1367130551,s===Math.floor(s)?(c.a=s/4294967296|0,c.b=s|0):l+=s;for(var f=0;f<l.length+20;f++)c.b^=l.charCodeAt(f)|0,c.next()}function o(s,c){return c.a=s.a,c.b=s.b,c.c=s.c,c.d=s.d,c}function a(s,c){var l=new i(s),f=c&&c.state,u=function(){return(l.next()>>>0)/4294967296};return u.double=function(){do var d=l.next()>>>11,h=(l.next()>>>0)/4294967296,g=(d+h)/(1<<21);while(g===0);return g},u.int32=l.next,u.quick=u,f&&(typeof f=="object"&&o(f,l),u.state=function(){return o(l,{})}),u}r&&r.exports?r.exports=a:this.tychei=a})(Ai,t)})(G_);var QK=G_.exports,nR={exports:{}};const eq={},tq=Object.freeze(Object.defineProperty({__proto__:null,default:eq},Symbol.toStringTag,{value:"Module"})),el=S$(tq);(function(t){(function(e,r,n){var i=256,o=6,a=52,s="random",c=n.pow(i,o),l=n.pow(2,a),f=l*2,u=i-1,d;function h(x,C,S){var T=[];C=C==!0?{entropy:!0}:C||{};var _=y(v(C.entropy?[x,w(r)]:x??m(),3),T),E=new g(T),b=function(){for(var D=E.g(o),I=c,P=0;D<l;)D=(D+P)*i,I*=i,P=E.g(1);for(;D>=f;)D/=2,I/=2,P>>>=1;return(D+P)/I};return b.int32=function(){return E.g(4)|0},b.quick=function(){return E.g(4)/4294967296},b.double=b,y(w(E.S),r),(C.pass||S||function(D,I,P,O){return O&&(O.S&&p(O,E),D.state=function(){return p(E,{})}),P?(n[s]=D,I):D})(b,_,"global"in C?C.global:this==n,C.state)}function g(x){var C,S=x.length,T=this,_=0,E=T.i=T.j=0,b=T.S=[];for(S||(x=[S++]);_<i;)b[_]=_++;for(_=0;_<i;_++)b[_]=b[E=u&E+x[_%S]+(C=b[_])],b[E]=C;(T.g=function(D){for(var I,P=0,O=T.i,L=T.j,B=T.S;D--;)I=B[O=u&O+1],P=P*i+B[u&(B[O]=B[L=u&L+I])+(B[L]=I)];return T.i=O,T.j=L,P})(i)}function p(x,C){return C.i=x.i,C.j=x.j,C.S=x.S.slice(),C}function v(x,C){var S=[],T=typeof x,_;if(C&&T=="object")for(_ in x)try{S.push(v(x[_],C-1))}catch{}return S.length?S:T=="string"?x:x+"\0"}function y(x,C){for(var S=x+"",T,_=0;_<S.length;)C[u&_]=u&(T^=C[u&_]*19)+S.charCodeAt(_++);return w(C)}function m(){try{var x;return d&&(x=d.randomBytes)?x=x(i):(x=new Uint8Array(i),(e.crypto||e.msCrypto).getRandomValues(x)),w(x)}catch{var C=e.navigator,S=C&&C.plugins;return[+new Date,e,S,e.screen,w(r)]}}function w(x){return String.fromCharCode.apply(0,x)}if(y(n.random(),r),t.exports){t.exports=h;try{d=el}catch{}}else n["seed"+s]=h})(typeof self<"u"?self:Ai,[],Math)})(nR);var nq=nR.exports,rq=qK,iq=XK,oq=YK,aq=JK,sq=ZK,cq=QK,Vd=nq;Vd.alea=rq;Vd.xor128=iq;Vd.xorwow=oq;Vd.xorshift7=aq;Vd.xor4096=sq;Vd.tychei=cq;var lq=Vd;const uq=ll(lq),W_=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],fq=[1,0,0,0,1,0,0,0,1],z_=1e-6,$_=1e-12,{vtkErrorMacro:rR,vtkWarningMacro:Sd}=Z;let iR=0;const W6=20;function J1(t){return()=>rR(`vtkMath::${t} - NOT IMPLEMENTED`)}function pp(t,e,r,n){let i;for(let o=0;o<e;o++)i=t[r*e+o],t[r*e+o]=t[n*e+o],t[n*e+o]=i}function $g(t,e,r,n){let i;for(let o=0;o<e;o++)i=t[o*e+r],t[o*e+r]=t[o*e+n],t[o*e+n]=i}function hr(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:3;const e=Array(t);for(let r=0;r<t;++r)e[r]=0;return e}const dq=()=>Math.PI;function hq(t,e){return e>1023?t*2**1023*2**(e-1023):e<-1074?t*2**-1074*2**(e+1074):t*2**e}function Gr(t){return t/180*Math.PI}function my(t){return t*180/Math.PI}const{round:jg,floor:j_,ceil:gq,min:pq,max:mq}=Math;function vq(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,n=1/0;for(let i=e,o=t.length;i<o;i+=r)t[i]<n&&(n=t[i]);return n}function yq(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,n=-1/0;for(let i=e,o=t.length;i<o;i+=r)n<t[i]&&(n=t[i]);return n}function wq(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,n=1/0,i=-1/0;for(let o=e,a=t.length;o<a;o+=r)t[o]<n&&(n=t[o]),i<t[o]&&(i=t[o]);return[n,i]}const xq=J1("ceilLog2"),Cq=J1("factorial");function us(t){let e=1;for(;e<t;)e*=2;return e}function Hg(t){return t===us(t)}function Sq(t,e){let r=1;for(let n=1;n<=e;++n)r*=(t-n+1)/n;return Math.floor(r)}function Tq(t,e){if(t<e)return 0;const r=hr(e);for(let n=0;n<e;++n)r[n]=n;return r}function _q(t,e,r){let n=0;for(let i=e-1;i>=0;--i)if(r[i]<t-e+i){let o=r[i]+1;for(;i<e;)r[i++]=o++;n=1;break}return n}function Eq(t){uq(`${t}`,{global:!0}),iR=t}function bq(){return iR}function Dq(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;const r=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:1)-t;return t+r*Math.random()}const Iq=J1("gaussian");function vy(t,e,r){return r[0]=t[0]+e[0],r[1]=t[1]+e[1],r[2]=t[2]+e[2],r}function $l(t,e,r){return r[0]=t[0]-e[0],r[1]=t[1]-e[1],r[2]=t[2]-e[2],r}function oR(t,e){return t[0]*=e,t[1]*=e,t[2]*=e,t}function aR(t,e){return t[0]*=e,t[1]*=e,t}function Q3(t,e,r,n){return n[0]=t[0]+e[0]*r,n[1]=t[1]+e[1]*r,n[2]=t[2]+e[2]*r,n}function Oq(t,e,r,n){return n[0]=t[0]+e[0]*r,n[1]=t[1]+e[1]*r,n}function cn(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Mq(t,e,r){r[0]=t[0]*e[0],r[1]=t[0]*e[1],r[2]=t[0]*e[2],r[3]=t[1]*e[0],r[4]=t[1]*e[1],r[5]=t[1]*e[2],r[6]=t[2]*e[0],r[7]=t[2]*e[1],r[8]=t[2]*e[2]}function tl(t,e,r){const n=t[1]*e[2]-t[2]*e[1],i=t[2]*e[0]-t[0]*e[2],o=t[0]*e[1]-t[1]*e[0];return r[0]=n,r[1]=i,r[2]=o,r}function ku(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:3;switch(e){case 1:return Math.abs(t);case 2:return Math.sqrt(t[0]*t[0]+t[1]*t[1]);case 3:return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);default:{let r=0;for(let n=0;n<e;n++)r+=t[n]*t[n];return Math.sqrt(r)}}}function Td(t){const e=ku(t);return e!==0&&(t[0]/=e,t[1]/=e,t[2]/=e),e}function Pq(t,e,r,n){const i=t[0]*t[0],o=t[1]*t[1],a=t[2]*t[2],s=Math.sqrt(i+o+a);let c,l,f;i>o&&i>a?(c=0,l=1,f=2):o>a?(c=1,l=2,f=0):(c=2,l=0,f=1);const u=t[c]/s,d=t[l]/s,h=t[f]/s,g=Math.sqrt(u*u+h*h);if(n!==0){const p=Math.sin(n),v=Math.cos(n);e&&(e[c]=(h*v-u*d*p)/g,e[l]=p*g,e[f]=(-(u*v)-d*h*p)/g),r&&(r[c]=(-(h*p)-u*d*v)/g,r[l]=v*g,r[f]=(u*p-d*h*v)/g)}else e&&(e[c]=h/g,e[l]=0,e[f]=-u/g),r&&(r[c]=-u*d/g,r[l]=g,r[f]=-d*h/g)}function Rq(t,e,r){const n=cn(e,e);if(n===0)return r[0]=0,r[1]=0,r[2]=0,!1;const i=cn(t,e)/n;for(let o=0;o<3;o++)r[o]=e[o];return oR(r,i),!0}function eS(t,e){return t[0]*e[0]+t[1]*e[1]}function Lq(t,e,r){const n=eS(e,e);if(n===0)return r[0]=0,r[1]=0,!1;const i=eS(t,e)/n;for(let o=0;o<2;o++)r[o]=e[o];return aR(r,i),!0}function Fc(t,e){return(t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1])+(t[2]-e[2])*(t[2]-e[2])}function Aq(t,e){const r=[0,0,0];return tl(t,e,r),Math.atan2(ku(r),cn(t,e))}function Nq(t,e,r){const n=Math.abs(t-r);return 1/Math.sqrt(2*Math.PI*e)*Math.exp(-(n**2)/(2*e))}function kq(t,e,r){const n=Math.abs(t-r);return Math.exp(-(n**2)/(2*e))}function Vq(t,e,r){r[0]=t[0]*e[0],r[1]=t[0]*e[1],r[2]=t[1]*e[0],r[3]=t[1]*e[1]}function sR(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function cR(t){const e=sR(t);return e!==0&&(t[0]/=e,t[1]/=e),e}function zr(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return e.length===2?e[0][0]*e[1][1]-e[1][0]*e[0][1]:e.length===4?e[0]*e[3]-e[1]*e[2]:Number.NaN}function Fq(t,e){let r,n,i;const o=[0,0,0];for(let a=0;a<3;a++)i=Math.abs(t[a*3]),(n=Math.abs(t[a*3+1]))>i&&(i=n),(n=Math.abs(t[a*3+2]))>i&&(i=n),o[a]=1/i;i=o[0]*Math.abs(t[0]),r=0,(n=o[1]*Math.abs(t[3]))>=i&&(i=n,r=1),(n=o[2]*Math.abs(t[6]))>=i&&(r=2),r!==0&&(pp(t,3,r,0),o[r]=o[0]),e[0]=r,t[3]/=t[0],t[6]/=t[0],t[4]-=t[3]*t[1],t[7]-=t[6]*t[1],i=o[1]*Math.abs(t[4]),r=1,(n=o[2]*Math.abs(t[7]))>=i&&(r=2,pp(t,3,1,2),o[2]=o[1]),e[1]=r,t[7]/=t[4],t[5]-=t[3]*t[2],t[8]-=t[6]*t[2]+t[7]*t[5],e[2]=2}function Uq(t,e,r){let n=r[e[0]];r[e[0]]=r[0],r[0]=n,n=r[e[1]],r[e[1]]=r[1],r[1]=n-t[3]*r[0],n=r[e[2]],r[e[2]]=r[2],r[2]=n-t[6]*r[0]-t[7]*r[1],r[2]/=t[8],r[1]=(r[1]-t[5]*r[2])/t[4],r[0]=(r[0]-t[1]*r[1]-t[2]*r[2])/t[0]}function Bq(t,e,r){const n=t[0],i=t[1],o=t[2],a=t[3],s=t[4],c=t[5],l=t[6],f=t[7],u=t[8],d=+zr(s,f,c,u),h=-zr(a,l,c,u),g=+zr(a,l,s,f),p=-zr(i,f,o,u),v=+zr(n,l,o,u),y=-zr(n,l,i,f),m=+zr(i,s,o,c),w=-zr(n,a,o,c),x=+zr(n,a,i,s),C=n*d+i*h+o*g,S=d*e[0]+p*e[1]+m*e[2],T=h*e[0]+v*e[1]+w*e[2],_=g*e[0]+y*e[1]+x*e[2];r[0]=S/C,r[1]=T/C,r[2]=_/C}function yv(t,e,r){const n=t[0]*e[0]+t[1]*e[1]+t[2]*e[2],i=t[3]*e[0]+t[4]*e[1]+t[5]*e[2],o=t[6]*e[0]+t[7]*e[1]+t[8]*e[2];r[0]=n,r[1]=i,r[2]=o}function tS(t,e,r){const n=[...t],i=[...e];for(let o=0;o<3;o++)r[o]=n[0]*i[o]+n[1]*i[o+3]+n[2]*i[o+6],r[o+3]=n[3]*i[o]+n[4]*i[o+3]+n[5]*i[o+6],r[o+6]=n[6]*i[o]+n[7]*i[o+3]+n[8]*i[o+6]}function Gq(t,e,r,n,i,o,a){n!==i&&rR("Number of columns of A must match number of rows of B.");const s=[...t],c=[...e];for(let l=0;l<r;l++)for(let f=0;f<o;f++){a[l*o+f]=0;for(let u=0;u<n;u++)a[l*o+f]+=s[l*n+u]*c[f+o*u]}}function q0(t,e){let r;r=t[3],e[3]=t[1],e[1]=r,r=t[6],e[6]=t[2],e[2]=r,r=t[7],e[7]=t[5],e[5]=r,e[0]=t[0],e[4]=t[4],e[8]=t[8]}function Wq(t,e){const r=t[0],n=t[1],i=t[2],o=t[3],a=t[4],s=t[5],c=t[6],l=t[7],f=t[8],u=+zr(a,l,s,f),d=-zr(o,c,s,f),h=+zr(o,c,a,l),g=-zr(n,l,i,f),p=+zr(r,c,i,f),v=-zr(r,c,n,l),y=+zr(n,a,i,s),m=-zr(r,o,i,s),w=+zr(r,o,n,a),x=r*u+n*d+i*h;x===0&&Sd("Matrix has 0 determinant"),e[0]=u/x,e[3]=d/x,e[6]=h/x,e[1]=g/x,e[4]=p/x,e[7]=v/x,e[2]=y/x,e[5]=m/x,e[8]=w/x}function Q5(t){return t[0]*t[4]*t[8]+t[3]*t[7]*t[2]+t[6]*t[1]*t[5]-t[0]*t[7]*t[5]-t[3]*t[1]*t[8]-t[6]*t[4]*t[2]}function lR(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:z_;if(t.length!==e.length)return!1;function n(i,o){return Math.abs(i-e[o])<=r}return t.every(n)}const Z1=lR;function uR(t){for(let e=0;e<3;e++)t[e*3]=t[e*3+1]=t[e*3+2]=0,t[e*3+e]=1}function fR(t,e){for(let r=0;r<t;r++){for(let n=0;n<t;n++)e[r*t+n]=0;e[r*t+r]=1}return e}function zq(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:z_;return Z1(t,W_,e)}function $q(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:z_;return Z1(t,fq,e)}function dR(t,e){const r=t[0]*t[0],n=t[0]*t[1],i=t[0]*t[2],o=t[0]*t[3],a=t[1]*t[1],s=t[2]*t[2],c=t[3]*t[3],l=t[1]*t[2],f=t[1]*t[3],u=t[2]*t[3],d=a+s+c;let h=1/(r+d);const g=(r-d)*h;h*=2,e[0]=a*h+g,e[3]=(l+o)*h,e[6]=(f-i)*h,e[1]=(l-o)*h,e[4]=s*h+g,e[7]=(u+n)*h,e[2]=(f+i)*h,e[5]=(u-n)*h,e[8]=c*h+g}function wv(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(!`${t}`.includes("e"))return+`${Math.round(`${t}e+${e}`)}e-${e}`;const r=`${t}`.split("e");let n="";return+r[1]+e>0&&(n="+"),+`${Math.round(`${+r[0]}e${n}${+r[1]+e}`)}e-${e}`}function nS(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[0,0,0],r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;return e[0]=wv(t[0],r),e[1]=wv(t[1],r),e[2]=wv(t[2],r),e}function Q1(t,e,r,n){let i,o,a,s,c,l,f,u,d,h,g,p,v,y,m,w;const x=hr(e),C=hr(e),S=(_,E,b)=>{y=_[E],v=_[b],_[E]=y-p*(v+y*h),_[b]=v+p*(y-v*h)};for(fR(e,n),c=0;c<e;c++)x[c]=r[c]=t[c+c*e],C[c]=0;for(i=0;i<W6;i++){for(g=0,c=0;c<e-1;c++)for(s=c+1;s<e;s++)g+=Math.abs(t[c*e+s]);if(g===0)break;for(i<3?f=.2*g/(e*e):f=0,c=0;c<e-1;c++)for(s=c+1;s<e;s++)if(y=100*Math.abs(t[c*e+s]),i>3&&Math.abs(r[c])+y===Math.abs(r[c])&&Math.abs(r[s])+y===Math.abs(r[s]))t[c*e+s]=0;else if(Math.abs(t[c*e+s])>f){for(v=r[s]-r[c],Math.abs(v)+y===Math.abs(v)?d=t[c*e+s]/v:(u=.5*v/t[c*e+s],d=1/(Math.abs(u)+Math.sqrt(1+u*u)),u<0&&(d=-d)),m=1/Math.sqrt(1+d*d),p=d*m,h=p/(1+m),v=d*t[c*e+s],C[c]-=v,C[s]+=v,r[c]-=v,r[s]+=v,t[c*e+s]=0,o=0;o<=c-1;o++)S(t,o*e+c,o*e+s);for(o=c+1;o<=s-1;o++)S(t,c*e+o,o*e+s);for(o=s+1;o<e;o++)S(t,c*e+o,s*e+o);for(o=0;o<e;o++)S(n,o*e+c,o*e+s)}for(c=0;c<e;c++)x[c]+=C[c],r[c]=x[c],C[c]=0}if(i>=W6)return Sd("vtkMath::Jacobi: Error extracting eigenfunctions"),0;for(o=0;o<e-1;o++){for(a=o,w=r[a],i=o+1;i<e;i++)(r[i]>=w||Math.abs(r[i]-w)<$_)&&(a=i,w=r[a]);a!==o&&(r[a]=r[o],r[o]=w,$g(n,e,o,a))}const T=(e>>1)+(e&1);for(l=0,i=0;i<e*e;i++)n[i]>=0&&l++;if(l<T)for(i=0;i<e;i++)n[i*e+o]*=-1;return 1}function hR(t,e){const r=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];r[0]=t[0]+t[4]+t[8],r[5]=t[0]-t[4]-t[8],r[10]=-t[0]+t[4]-t[8],r[15]=-t[0]-t[4]+t[8],r[1]=r[4]=t[7]-t[5],r[2]=r[8]=t[2]-t[6],r[3]=r[12]=t[3]-t[1],r[6]=r[9]=t[3]+t[1],r[7]=r[13]=t[2]+t[6],r[11]=r[14]=t[7]+t[5];const n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],i=[0,0,0,0],o=[...r];Q1(o,4,i,n),e[0]=n[0],e[1]=n[4],e[2]=n[8],e[3]=n[12]}function jq(t,e,r){const n=t[0]*e[0],i=t[0]*e[1],o=t[0]*e[2],a=t[0]*e[3],s=t[1]*e[0],c=t[1]*e[1],l=t[1]*e[2],f=t[1]*e[3],u=t[2]*e[0],d=t[2]*e[1],h=t[2]*e[2],g=t[2]*e[3],p=t[3]*e[0],v=t[3]*e[1],y=t[3]*e[2],m=t[3]*e[3];r[0]=n-c-h-m,r[1]=i+s+g-y,r[2]=o-f+u+v,r[3]=a+l-d+p}function gR(t,e){for(let d=0;d<9;d++)e[d]=t[d];const r=hr(3),n=hr(3);let i;for(let d=0;d<3;d++){const h=Math.abs(e[d*3]),g=Math.abs(e[d*3+1]),p=Math.abs(e[d*3+2]);i=g>h?g:h,i=p>i?p:i,r[d]=1,i!==0&&(r[d]/=i)}const o=Math.abs(e[0])*r[0],a=Math.abs(e[3])*r[1],s=Math.abs(e[6])*r[2];n[0]=0,i=o,a>=i&&(i=a,n[0]=1),s>=i&&(n[0]=2),n[0]!==0&&($g(e,3,n[0],0),r[n[0]]=r[0]);const c=Math.abs(e[4])*r[1],l=Math.abs(e[7])*r[2];n[1]=1,i=c,l>=i&&(n[1]=2,$g(e,3,1,2)),n[2]=2;let f=0;if(Q5(e)<0){f=1;for(let d=0;d<9;d++)e[d]=-e[d]}const u=hr(4);if(hR(e,u),dR(u,e),f)for(let d=0;d<9;d++)e[d]=-e[d];n[1]!==1&&$g(e,3,n[1],1),n[0]!==0&&$g(e,3,n[0],0)}function pR(t,e,r){let n,i,o,a,s,c;const l=[...t];if(Q1(l,3,e,r),e[0]===e[1]&&e[0]===e[2]){uR(r);return}for(q0(r,r),n=0;n<3;n++)if(e[(n+1)%3]===e[(n+2)%3]){for(c=Math.abs(r[n*3]),a=0,i=1;i<3;i++)c<(s=Math.abs(r[n*3+i]))&&(c=s,a=i);a!==n&&(s=e[a],e[a]=e[n],e[n]=s,pp(r,3,n,a)),r[a*3+a]<0&&(r[a*3]=-r[a*3],r[a*3+1]=-r[a*3+1],r[a*3+2]=-r[a*3+2]),i=(a+1)%3,o=(a+2)%3,r[i*3]=0,r[i*3+1]=0,r[i*3+2]=0,r[i*3+i]=1;const f=tl([r[a*3],r[a*3+1],r[a*3+2]],[r[i*3],r[i*3+1],r[i*3+2]],[]);Td(f);const u=tl(f,[r[a*3],r[a*3+1],r[a*3+2]],[]);for(let d=0;d<3;d++)r[o*3+d]=f[d],r[i*3+d]=u[d];q0(r,r);return}for(c=Math.abs(r[0]),a=0,n=1;n<3;n++)c<(s=Math.abs(r[n*3]))&&(c=s,a=n);if(a!==0){const f=e[a];e[a]=e[0],e[0]=f,pp(r,3,a,0)}if(Math.abs(r[4])<Math.abs(r[7])){const f=e[2];e[2]=e[1],e[1]=f,pp(r,3,1,2)}for(n=0;n<2;n++)r[n*3+n]<0&&(r[n*3]=-r[n*3],r[n*3+1]=-r[n*3+1],r[n*3+2]=-r[n*3+2]);Q5(r)<0&&(r[6]=-r[6],r[7]=-r[7],r[8]=-r[8]),q0(r,r)}function Hq(t,e,r,n){let i;const o=[...t],a=Q5(o);if(a<0)for(i=0;i<9;i++)o[i]=-o[i];gR(o,e),q0(o,o),tS(o,e,n),pR(n,r,n),tS(e,n,e),q0(n,n),a<0&&(r[0]=-r[0],r[1]=-r[1],r[2]=-r[2])}function H_(t,e,r){let n,i,o,a,s=0,c,l,f;const u=hr(r);for(n=0;n<r;n++){for(a=0,i=0;i<r;i++)(f=Math.abs(t[n*r+i]))>a&&(a=f);if(a===0)return Sd("Unable to factor linear system"),0;u[n]=1/a}for(i=0;i<r;i++){for(n=0;n<i;n++){for(c=t[n*r+i],o=0;o<n;o++)c-=t[n*r+o]*t[o*r+i];t[n*r+i]=c}for(a=0,n=i;n<r;n++){for(c=t[n*r+i],o=0;o<i;o++)c-=t[n*r+o]*t[o*r+i];t[n*r+i]=c,(l=u[n]*Math.abs(c))>=a&&(a=l,s=n)}if(i!==s){for(o=0;o<r;o++)l=t[s*r+o],t[s*r+o]=t[i*r+o],t[i*r+o]=l;u[s]=u[i]}if(e[i]=s,Math.abs(t[i*r+i])<=$_)return Sd("Unable to factor linear system"),0;if(i!==r-1)for(l=1/t[i*r+i],n=i+1;n<r;n++)t[n*r+i]*=l}return 1}function K_(t,e,r,n){let i,o,a,s,c;for(a=-1,i=0;i<n;i++){if(s=e[i],c=r[s],r[s]=r[i],a>=0)for(o=a;o<=i-1;o++)c-=t[i*n+o]*r[o];else c!==0&&(a=i);r[i]=c}for(i=n-1;i>=0;i--){for(c=r[i],o=i+1;o<n;o++)c-=t[i*n+o]*r[o];r[i]=c/t[i*n+i]}}function mR(t,e,r){if(r===2){const i=hr(2),o=zr(t[0],t[1],t[2],t[3]);return o===0?0:(i[0]=(t[3]*e[0]-t[1]*e[1])/o,i[1]=(-(t[2]*e[0])+t[0]*e[1])/o,e[0]=i[0],e[1]=i[1],1)}if(r===1)return t[0]===0?0:(e[0]/=t[0],1);const n=hr(r);return H_(t,n,r)===0?0:(K_(t,n,e,r),1)}function vR(t,e,r){let n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:null;const o=n||hr(r),a=i||hr(r);if(H_(t,o,r)===0)return null;for(let s=0;s<r;s++){for(let c=0;c<r;c++)a[c]=0;a[s]=1,K_(t,o,a,r);for(let c=0;c<r;c++)e[c*r+s]=a[c]}return e}function Kq(t,e){let r=+Number.MAX_VALUE,n=-Number.MAX_VALUE;for(let i=0;i<e;i++)for(let o=i;o<e;o++)Math.abs(t[i*e+o])>n&&(n=Math.abs(t[i*e+o]));for(let i=0;i<e;i++)Math.abs(t[i*e+i])<r&&(r=Math.abs(t[i*e+i]));return r===0?Number.MAX_VALUE:n/r}function qq(t,e,r){return Q1(t,3,e,r)}function rS(t,e,r,n){if(t<r)return Sd("Insufficient number of samples. Underdetermined."),0;let i,o,a;const s=hr(r*r),c=hr(r),l=hr(r*r);for(a=0;a<t;a++)for(i=0;i<r;i++)for(o=i;o<r;o++)s[i*r+o]+=e[a*r+i]*e[a*r+o];for(i=0;i<r;i++)for(o=0;o<i;o++)s[i*r+o]=s[o*r+i];for(Q1(s,r,c,l),i=0;i<r;i++)n[i]=l[i*r+r-1];return 1}function Xq(t,e,r,n,i,o){let a=arguments.length>6&&arguments[6]!==void 0?arguments[6]:!0;if(t<r||t<i)return Sd("Insufficient number of samples. Underdetermined."),0;const s=hr(i);let c=1,l,f=0,u,d,h,g=0;if(a){for(d=0;d<i;d++)s[d]=1;for(u=0;u<t;u++)for(d=0;d<i;d++)Math.abs(n[u*i+d])>$_&&(c=0,s[d]=0);if(c&&i===1)return Sd("Detected homogeneous system (Y=0), calling SolveHomogeneousLeastSquares()"),rS(t,e,r,o);if(c)g=1;else for(d=0;d<i;d++)s[d]&&(g=1)}g&&(l=hr(r),f=rS(t,e,r,l));const p=hr(r*r),v=hr(r*r),y=hr(r*i);for(h=0;h<t;h++)for(u=0;u<r;u++){for(d=u;d<r;d++)p[u*r+d]+=e[h*r+u]*e[h*r+d];for(d=0;d<i;d++)y[u*i+d]+=e[h*r+u]*n[h*i+d]}for(u=0;u<r;u++)for(d=0;d<u;d++)p[u*r+d]=p[d*r+u];const m=vR(p,v,r);if(m)for(u=0;u<r;u++)for(d=0;d<i;d++)for(o[u*i+d]=0,h=0;h<r;h++)o[u*i+d]+=v[u*r+h]*y[h*i+d];if(g){for(d=0;d<i;d++)if(s[d])for(u=0;u<r;u++)o[u*i+d]=l[u*i]}return g?f&&m:m}function Yq(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[0,.5,1];switch(t.length){case 3:return e[0]=parseInt(t[0],16)*17/255,e[1]=parseInt(t[1],16)*17/255,e[2]=parseInt(t[2],16)*17/255,e;case 4:return e[0]=parseInt(t[1],16)*17/255,e[1]=parseInt(t[2],16)*17/255,e[2]=parseInt(t[3],16)*17/255,e;case 6:return e[0]=parseInt(t.substr(0,2),16)/255,e[1]=parseInt(t.substr(2,2),16)/255,e[2]=parseInt(t.substr(4,2),16)/255,e;case 7:return e[0]=parseInt(t.substr(1,2),16)/255,e[1]=parseInt(t.substr(3,2),16)/255,e[2]=parseInt(t.substr(5,2),16)/255,e;case 9:return e[0]=parseInt(t.substr(1,2),16)/255,e[1]=parseInt(t.substr(3,2),16)/255,e[2]=parseInt(t.substr(5,2),16)/255,e[3]=parseInt(t.substr(7,2),16)/255,e;default:return e}}function Kg(t,e){let r,n;const[i,o,a]=t,s=1/3,c=1/6,l=2/3;let f=i,u=i;o>f?f=o:o<u&&(u=o),a>f?f=a:a<u&&(u=a);const d=f;d>0?n=(f-u)/f:n=0,n>0?(i===f?r=c*(o-a)/(f-u):o===f?r=s+c*(a-i)/(f-u):r=l+c*(i-o)/(f-u),r<0&&(r+=1)):r=0,e[0]=r,e[1]=n,e[2]=d}function Kf(t,e){const[r,n,i]=t,o=1/3,a=1/6,s=2/3,c=5/6;let l,f,u;r>a&&r<=o?(f=1,l=(o-r)/a,u=0):r>o&&r<=.5?(f=1,u=(r-o)/a,l=0):r>.5&&r<=s?(u=1,f=(s-r)/a,l=0):r>s&&r<=c?(u=1,l=(r-s)/a,f=0):r>c&&r<=1?(l=1,u=(1-r)/a,f=0):(l=1,f=r/a,u=0),l=n*l+(1-n),f=n*f+(1-n),u=n*u+(1-n),l*=i,f*=i,u*=i,e[0]=l,e[1]=f,e[2]=u}function yR(t,e){const[r,n,i]=t;let o=(r+16)/116,a=n/500+o,s=o-i/200;o**3>.008856?o**=3:o=(o-16/116)/7.787,a**3>.008856?a**=3:a=(a-16/116)/7.787,s**3>.008856?s**=3:s=(s-16/116)/7.787;const c=.9505,l=1,f=1.089;e[0]=c*a,e[1]=l*o,e[2]=f*s}function wR(t,e){const[r,n,i]=t,o=.9505,a=1,s=1.089;let c=r/o,l=n/a,f=i/s;c>.008856?c**=1/3:c=7.787*c+16/116,l>.008856?l**=1/3:l=7.787*l+16/116,f>.008856?f**=1/3:f=7.787*f+16/116,e[0]=116*l-16,e[1]=500*(c-l),e[2]=200*(l-f)}function xR(t,e){const[r,n,i]=t;let o=r*3.2406+n*-1.5372+i*-.4986,a=r*-.9689+n*1.8758+i*.0415,s=r*.0557+n*-.204+i*1.057;o>.0031308?o=1.055*o**(1/2.4)-.055:o*=12.92,a>.0031308?a=1.055*a**(1/2.4)-.055:a*=12.92,s>.0031308?s=1.055*s**(1/2.4)-.055:s*=12.92;let c=o;c<a&&(c=a),c<s&&(c=s),c>1&&(o/=c,a/=c,s/=c),o<0&&(o=0),a<0&&(a=0),s<0&&(s=0),e[0]=o,e[1]=a,e[2]=s}function CR(t,e){let[r,n,i]=t;r>.04045?r=((r+.055)/1.055)**2.4:r/=12.92,n>.04045?n=((n+.055)/1.055)**2.4:n/=12.92,i>.04045?i=((i+.055)/1.055)**2.4:i/=12.92,e[0]=r*.4124+n*.3576+i*.1805,e[1]=r*.2126+n*.7152+i*.0722,e[2]=r*.0193+n*.1192+i*.9505}function nd(t,e){const r=[0,0,0];CR(t,r),wR(r,e)}function yy(t,e){const r=[0,0,0];yR(t,r),xR(r,e)}function Gh(t){return t[0]=1,t[1]=-1,t[2]=1,t[3]=-1,t[4]=1,t[5]=-1,t}function xv(t){return!(t[1]-t[0]<0)}function Jq(t,e,r){return r[0]=Math.min(t[0],e[0]),r[1]=Math.max(t[0],e[0]),r[2]=Math.min(t[1],e[1]),r[3]=Math.max(t[1],e[1]),r[4]=Math.min(t[2],e[2]),r[5]=Math.max(t[2],e[2]),r}function rc(t,e,r){return t<e?e:t>r?r:t}function iS(t,e,r){let n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:[0,0,0];return n[0]=rc(t[0],e[0],r[0]),n[1]=rc(t[1],e[1],r[1]),n[2]=rc(t[2],e[2],r[2]),n}function Zq(t,e){let r=0;return e[0]!==e[1]&&(t<e[0]?r=e[0]:t>e[1]?r=e[1]:r=t,r=(r-e[0])/(e[1]-e[0])),r}const Qq=J1("GetScalarTypeFittingRange"),eX=J1("GetAdjustedScalarRange");function tX(t,e){if(!t||!e)return 0;for(let r=0;r<6;r+=2)if(t[r]<e[r]||t[r]>e[r+1]||t[r+1]<e[r]||t[r+1]>e[r+1])return 0;return 1}function nX(t,e,r){if(!t||!e)return 0;for(let n=0;n<6;n+=2)if(t[n]+r[n/2]<e[n]||t[n]-r[n/2]>e[n+1]||t[n+1]+r[n/2]<e[n]||t[n+1]-r[n/2]>e[n+1])return 0;return 1}function rX(t,e,r){if(!t||!e||!r)return 0;for(let n=0;n<3;n++)if(t[n]+r[n]<e[2*n]||t[n]-r[n]>e[2*n+1])return 0;return 1}function iX(t,e,r,n){const i=hr(3),o=hr(3),a=hr(3),s=hr(3),c=hr(3),l=hr(3);for(let x=0;x<3;++x)i[x]=t[x]-e[x],o[x]=e[x]-r[x],a[x]=r[x]-t[x],s[x]=-i[x],c[x]=-o[x],l[x]=-a[x];const f=ku(s),u=ku(c),d=ku(a),h=hr(3);tl(i,o,h);const g=ku(h),p=f*u*d/(2*g),v=2*g*g,y=u*u*cn(i,l)/v,m=d*d*cn(s,o)/v,w=f*f*cn(a,c)/v;for(let x=0;x<3;++x)n[x]=y*t[x]+m*e[x]+w*r[x];return p}const oX=1/0,aX=-1/0,SR=t=>!Number.isFinite(t),{isFinite:sX,isNaN:oS}=Number,wy=oS;function of(){return[].concat([Number.MAX_VALUE,-Number.MAX_VALUE,Number.MAX_VALUE,-Number.MAX_VALUE,Number.MAX_VALUE,-Number.MAX_VALUE])}function cX(t){let e=-1,r=-1;for(let n=0;n<t.length;n++){const i=Math.abs(t[n]);i>e&&(r=n,e=i)}return r}function TR(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:3;const r=new Array(e),n=new Array(e);for(let o=0;o<e;++o)r[o]=o,n[o]=o;for(let o=e-1;o>0;o--){let a=-1/0,s=0,c=0;for(let l=0;l<=o;++l){const f=r[l];for(let u=0;u<=o;++u){const d=n[u],h=Math.abs(t[f+e*d]);h>a&&(a=h,s=l,c=u)}}[r[o],r[s]]=[r[s],r[o]],[n[o],n[c]]=[n[c],n[o]]}const i=new Array(e*e).fill(0);for(let o=0;o<e;++o){const a=r[o]+e*n[o];i[a]=t[a]<0?-1:1}return i}function _R(t){const e=Math.floor(t*255);return e>15?e.toString(16):`0${e.toString(16)}`}function lX(t){return`${arguments.length>1&&arguments[1]!==void 0?arguments[1]:"#"}${t.map(_R).join("")}`}function Qm(t){return Math.round(t*255)}function uX(t){return t.length===3?`rgb(${t.map(Qm).join(", ")})`:`rgba(${Qm(t[0]||0)}, ${Qm(t[1]||0)}, ${Qm(t[2]||0)}, ${t[3]||0})`}var Gt={Pi:dq,ldexp:hq,radiansFromDegrees:Gr,degreesFromRadians:my,round:jg,floor:j_,ceil:gq,ceilLog2:xq,min:pq,max:mq,arrayMin:vq,arrayMax:yq,arrayRange:wq,isPowerOfTwo:Hg,nearestPowerOfTwo:us,factorial:Cq,binomial:Sq,beginCombination:Tq,nextCombination:_q,randomSeed:Eq,getSeed:bq,random:Dq,gaussian:Iq,add:vy,subtract:$l,multiplyScalar:oR,multiplyScalar2D:aR,multiplyAccumulate:Q3,multiplyAccumulate2D:Oq,dot:cn,outer:Mq,cross:tl,norm:ku,normalize:Td,perpendiculars:Pq,projectVector:Rq,projectVector2D:Lq,distance2BetweenPoints:Fc,angleBetweenVectors:Aq,gaussianAmplitude:Nq,gaussianWeight:kq,dot2D:eS,outer2D:Vq,norm2D:sR,normalize2D:cR,determinant2x2:zr,LUFactor3x3:Fq,LUSolve3x3:Uq,linearSolve3x3:Bq,multiply3x3_vect3:yv,multiply3x3_mat3:tS,multiplyMatrix:Gq,transpose3x3:q0,invert3x3:Wq,identity3x3:uR,identity:fR,isIdentity:zq,isIdentity3x3:$q,determinant3x3:Q5,quaternionToMatrix3x3:dR,areEquals:lR,areMatricesEqual:Z1,roundNumber:wv,roundVector:nS,matrix3x3ToQuaternion:hR,multiplyQuaternion:jq,orthogonalize3x3:gR,diagonalize3x3:pR,singularValueDecomposition3x3:Hq,solveLinearSystem:mR,invertMatrix:vR,luFactorLinearSystem:H_,luSolveLinearSystem:K_,estimateMatrixCondition:Kq,jacobi:qq,jacobiN:Q1,solveHomogeneousLeastSquares:rS,solveLeastSquares:Xq,hex2float:Yq,rgb2hsv:Kg,hsv2rgb:Kf,lab2xyz:yR,xyz2lab:wR,xyz2rgb:xR,rgb2xyz:CR,rgb2lab:nd,lab2rgb:yy,uninitializeBounds:Gh,areBoundsInitialized:xv,computeBoundsFromPoints:Jq,clampValue:rc,clampVector:iS,clampAndNormalizeValue:Zq,getScalarTypeFittingRange:Qq,getAdjustedScalarRange:eX,extentIsWithinOtherExtent:tX,boundsIsWithinOtherBounds:nX,pointIsWithinBounds:rX,solve3PointCircle:iX,inf:oX,negInf:aX,isInf:SR,isNan:oS,isNaN:oS,isFinite:sX,createUninitializedBounds:of,getMajorAxisIndex:cX,getSparseOrthogonalMatrix:TR,floatToHex2:_R,floatRGB2HexCode:lX,float2CssRGBA:uX};const{vtkErrorMacro:fX}=uo,{DefaultDataType:dX}=YP,hX=1e-6;function aS(t,e,r){const n=t.length;let i=Number.MAX_VALUE,o=-Number.MAX_VALUE,a,s;for(s=e;s<n;s+=r)if(!Number.isNaN(t[s])){i=t[s],o=i;break}for(;s<n;s+=r)a=t[s],a<i?i=a:a>o&&(o=a);return{min:i,max:o}}function gX(){let t=Number.MAX_VALUE,e=-Number.MAX_VALUE,r=0,n=0;return{add(i){t>i&&(t=i),e<i&&(e=i),r++,n+=i},get(){return{min:t,max:e,count:r,sum:n,mean:n/r}},getRange(){return{min:t,max:e}}}}function ER(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1;if(e<0&&r>1){const i=t.length/r,o=new Float64Array(i);for(let a=0,s=0;a<i;++a){for(let c=s+r;s<c;++s)o[a]+=t[s]*t[s];o[a]**=.5}return aS(o,0,1)}return aS(t,e<0?0:e,r)}function z6(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;const r=t||[];for(;r.length<=e;)r.push(null);return r}function q_(t){return Object.prototype.toString.call(t).slice(8,-1)}function pX(t){const e=t.getNumberOfComponents();let r=0;const n=new Array(e);for(let i=0;i<t.getNumberOfTuples();++i){t.getTuple(i,n);const o=ku(n,e);o>r&&(r=o)}return r}const mX={computeRange:ER,createRangeHelper:gX,fastComputeRange:aS,getDataType:q_,getMaxNorm:pX};function vX(t,e){e.classHierarchy.push("vtkDataArray");function r(n){if(n<0)return!1;const i=t.getNumberOfComponents(),o=e.values.length/(i>0?i:1);if(n===o)return!0;if(n>o){const a=e.values;return e.values=Uh(e.dataType,(n+o)*i),e.values.set(a),!0}return e.size>n*i&&(e.size=n*i,t.dataChange()),!0}t.dataChange=()=>{e.ranges=null,t.modified()},t.resize=n=>{r(n);const i=n*t.getNumberOfComponents();return e.size!==i?(e.size=i,t.dataChange(),!0):!1},t.initialize=()=>{t.resize(0)},t.getElementComponentSize=()=>e.values.BYTES_PER_ELEMENT,t.getComponent=function(n){let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return e.values[n*e.numberOfComponents+i]},t.setComponent=(n,i,o)=>{o!==e.values[n*e.numberOfComponents+i]&&(e.values[n*e.numberOfComponents+i]=o,t.dataChange())},t.getValue=n=>{const i=n/e.numberOfComponents,o=n%e.numberOfComponents;return t.getComponent(i,o)},t.setValue=(n,i)=>{const o=n/e.numberOfComponents,a=n%e.numberOfComponents;t.setComponent(o,a,i)},t.getData=()=>e.size===e.values.length?e.values:e.values.subarray(0,e.size),t.getRange=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:-1,i=n;i<0&&(i=e.numberOfComponents===1?0:e.numberOfComponents);let o=null;return e.ranges||(e.ranges=z6(e.ranges,e.numberOfComponents)),o=e.ranges[i],o?(e.rangeTuple[0]=o.min,e.rangeTuple[1]=o.max,e.rangeTuple):(o=ER(t.getData(),n,e.numberOfComponents),e.ranges[i]=o,e.rangeTuple[0]=o.min,e.rangeTuple[1]=o.max,e.rangeTuple)},t.setRange=(n,i)=>{e.ranges||(e.ranges=z6(e.ranges,e.numberOfComponents));const o={min:n.min,max:n.max};return e.ranges[i]=o,e.rangeTuple[0]=o.min,e.rangeTuple[1]=o.max,e.rangeTuple},t.getRanges=function(){if(!(arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0))return structuredClone(e.ranges);const i=[];for(let o=0;o<e.numberOfComponents;o++){const[a,s]=t.getRange(o),c={min:a,max:s};i.push(c)}if(e.numberOfComponents>1){const[o,a]=t.getRange(-1),s={min:o,max:a};i.push(s)}return i},t.setTuple=(n,i)=>{const o=n*e.numberOfComponents;for(let a=0;a<e.numberOfComponents;a++)e.values[o+a]=i[a]},t.setTuples=(n,i)=>{let o=n*e.numberOfComponents;const a=Math.min(i.length,e.size-o);for(let s=0;s<a;)e.values[o++]=i[s++]},t.insertTuple=(n,i)=>(e.size<=n*e.numberOfComponents&&(e.size=(n+1)*e.numberOfComponents,r(n+1)),t.setTuple(n,i),n),t.insertTuples=(n,i)=>{const o=n+i.length/e.numberOfComponents;return e.size<o*e.numberOfComponents&&(e.size=o*e.numberOfComponents,r(o)),t.setTuples(n,i),o},t.insertNextTuple=n=>{const i=e.size/e.numberOfComponents;return t.insertTuple(i,n)},t.insertNextTuples=n=>{const i=e.size/e.numberOfComponents;return t.insertTuples(i,n)},t.findTuple=function(n){let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:hX;for(let o=0;o<e.size;o+=e.numberOfComponents)if(Math.abs(n[0]-e.values[o])<=i){let a=!0;for(let s=1;s<e.numberOfComponents;++s)if(Math.abs(n[s]-e.values[o+s])>i){a=!1;break}if(a)return o/e.numberOfComponents}return-1},t.getTuple=function(n){let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];const o=e.numberOfComponents||1,a=n*o;switch(o){case 4:i[3]=e.values[a+3];case 3:i[2]=e.values[a+2];case 2:i[1]=e.values[a+1];case 1:i[0]=e.values[a];break;default:for(let s=o-1;s>=0;--s)i[s]=e.values[a+s]}return i},t.getTuples=(n,i)=>{const o=(n??0)*e.numberOfComponents,a=(i??t.getNumberOfTuples())*e.numberOfComponents,s=t.getData().subarray(o,a);return s.length>0?s:null},t.getTupleLocation=function(){return(arguments.length>0&&arguments[0]!==void 0?arguments[0]:1)*e.numberOfComponents},t.getNumberOfComponents=()=>e.numberOfComponents,t.getNumberOfValues=()=>e.size,t.getNumberOfTuples=()=>e.size/e.numberOfComponents,t.getDataType=()=>e.dataType,t.newClone=()=>DR({empty:!0,name:e.name,dataType:e.dataType,numberOfComponents:e.numberOfComponents}),t.getName=()=>(e.name||(t.modified(),e.name=`vtkDataArray${t.getMTime()}`),e.name),t.setData=(n,i)=>{e.values=n,e.size=n.length,e.dataType=q_(n),i&&(e.numberOfComponents=i),e.size%e.numberOfComponents!==0&&(e.numberOfComponents=1),t.dataChange()},t.getState=()=>{if(e.deleted)return null;const n={...e,vtkClass:t.getClassName()};n.values=Array.from(n.values),delete n.buffer,Object.keys(n).forEach(o=>{n[o]||delete n[o]});const i={};return Object.keys(n).sort().forEach(o=>{i[o]=n[o]}),i.mtime&&delete i.mtime,i},t.deepCopy=n=>{const i=t.getDataType(),o=e.values;t.shallowCopy(n),e.ranges=structuredClone(n.getRanges()),(o==null?void 0:o.length)>=n.getNumberOfValues()&&i===n.getDataType()?(o.set(n.getData()),e.values=o,t.dataChange()):t.setData(n.getData().slice())},t.interpolateTuple=(n,i,o,a,s,c)=>{const l=e.numberOfComponents||1;(l!==i.getNumberOfComponents()||l!==a.getNumberOfComponents())&&fX("numberOfComponents must match");const f=i.getTuple(o),u=a.getTuple(s),d=[];switch(d.length=l,l){case 4:d[3]=f[3]+(u[3]-f[3])*c;case 3:d[2]=f[2]+(u[2]-f[2])*c;case 2:d[1]=f[1]+(u[1]-f[1])*c;case 1:d[0]=f[0]+(u[0]-f[0])*c;break;default:for(let h=0;h<l;h++)d[h]=f[h]+(u[h]-f[h])*c}return t.insertTuple(n,d)}}const yX={name:"",numberOfComponents:1,dataType:dX,rangeTuple:[0,0]};function bR(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(Object.assign(e,yX,r),Array.isArray(r.values)&&r.dataType===void 0&&console.warn("vtkDataArray.newInstance: no dataType provided, converting to Float32Array"),!e.empty&&!e.values&&!e.size)throw new TypeError("Cannot create vtkDataArray object without: size > 0, values");if(e.values?Array.isArray(e.values)&&(e.values=J5(e.dataType,e.values)):e.values=Uh(e.dataType,e.size),e.values&&(e.size=e.size??e.values.length,e.dataType=q_(e.values)),or(t,e),q1(t,e,["name","numberOfComponents"]),e.size%e.numberOfComponents!==0)throw new RangeError("model.size is not a multiple of model.numberOfComponents");vX(t,e)}const DR=Rn(bR,"vtkDataArray");var bt={newInstance:DR,extend:bR,...mX,...YP};const{vtkErrorMacro:wX}=Z,xX=["Build","Render"];function CX(t,e){e.classHierarchy.push("vtkViewNode"),t.build=n=>{},t.render=n=>{},t.traverse=n=>{const i=n.getTraverseOperation(),o=t[i];if(o){o(n);return}t.apply(n,!0);for(let a=0;a<e.children.length;a++)e.children[a].traverse(n);t.apply(n,!1)},t.apply=(n,i)=>{const o=t[n.getOperation()];o&&o(i,n)},t.getViewNodeFor=n=>{if(e.renderable===n)return t;for(let i=0;i<e.children.length;++i){const a=e.children[i].getViewNodeFor(n);if(a)return a}},t.getFirstAncestorOfType=n=>e._parent?e._parent.isA(n)?e._parent:e._parent.getFirstAncestorOfType(n):null,t.getLastAncestorOfType=n=>{if(!e._parent)return null;const i=e._parent.getLastAncestorOfType(n);return i||(e._parent.isA(n)?e._parent:null)},t.addMissingNode=n=>{if(!n)return;const i=e._renderableChildMap.get(n);if(i!==void 0)return i.setVisited(!0),i;const o=t.createViewNode(n);if(o)return o.setParent(t),o.setVisited(!0),e._renderableChildMap.set(n,o),e.children.push(o),o},t.addMissingNodes=n=>{if(!(!n||!n.length))for(let i=0;i<n.length;++i){const o=n[i];t.addMissingNode(o)}},t.addMissingChildren=n=>{if(!(!n||!n.length))for(let i=0;i<n.length;++i){const o=n[i];if(e.children.indexOf(o)===-1){o.setParent(t),e.children.push(o);const s=o.getRenderable();s&&e._renderableChildMap.set(s,o)}o.setVisited(!0)}},t.removeNode=n=>{const i=e.children.findIndex(a=>a===n);if(i<0)return!1;const o=n.getRenderable();return o&&e._renderableChildMap.delete(o),n.delete(),e.children.splice(i,1),!0},t.prepareNodes=()=>{for(let n=0;n<e.children.length;++n)e.children[n].setVisited(!1)},t.setVisited=n=>{e.visited=n},t.removeUnusedNodes=()=>{let n=0;for(let i=0;i<e.children.length;++i){const o=e.children[i];if(o.getVisited())e.children[n++]=o,o.setVisited(!1);else{const s=o.getRenderable();s&&e._renderableChildMap.delete(s),o.delete()}}e.children.length=n},t.createViewNode=n=>{if(!e.myFactory)return wX("Cannot create view nodes without my own factory"),null;const i=e.myFactory.createNode(n);return i&&i.setRenderable(n),i};const r=t.delete;t.delete=()=>{for(let n=0;n<e.children.length;n++)e.children[n].delete();r()}}const SX={renderable:null,myFactory:null,children:[],visited:!1};function IR(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,SX,r),Z.obj(t,e),Z.event(t,e,"event"),e._renderableChildMap=new Map,Z.get(t,e,["visited"]),Z.setGet(t,e,["_parent","renderable","myFactory"]),Z.getArray(t,e,["children"]),Z.moveToProtected(t,e,["parent"]),CX(t,e)}const TX=Z.newInstance(IR,"vtkViewNode");var Qn={newInstance:TX,extend:IR,PASS_TYPES:xX};function _X(t,e){e.overrides||(e.overrides={}),e.classHierarchy.push("vtkViewNodeFactory"),t.createNode=r=>{if(r.isDeleted())return null;let n=0,i=r.getClassName(n++),o=!1;const a=Object.keys(e.overrides);for(;i&&!o;)a.indexOf(i)!==-1?o=!0:i=r.getClassName(n++);if(!o)return null;const s=e.overrides[i]();return s.setMyFactory(t),s}}const EX={};function OR(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,EX,r),Z.obj(t,e),_X(t,e)}const bX=Z.newInstance(OR,"vtkViewNodeFactory");var X_={newInstance:bX,extend:OR};const MR=Object.create(null);function di(t,e){MR[t]=e}function DX(t,e){e.classHierarchy.push("vtkOpenGLViewNodeFactory")}const IX={};function PR(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,IX,r),e.overrides=MR,X_.extend(t,e,r),DX(t,e)}const OX=Z.newInstance(PR,"vtkOpenGLViewNodeFactory");var MX={newInstance:OX,extend:PR};function PX(){try{const n=new Int16Array([0,32767]),i=[1,1],o=document.createElement("canvas");o.width=4,o.height=4;const a=o.getContext("webgl2");if(!a)return!1;const s=a.getExtension("EXT_texture_norm16");if(!s)return!1;const c=`#version 300 es
|
||
void main() {
|
||
gl_PointSize = ${4 .toFixed(1)};
|
||
gl_Position = vec4(0, 0, 0, 1);
|
||
}
|
||
`,l=`#version 300 es
|
||
precision highp float;
|
||
precision highp int;
|
||
precision highp sampler2D;
|
||
|
||
uniform sampler2D u_image;
|
||
|
||
out vec4 color;
|
||
|
||
void main() {
|
||
vec4 intColor = texture(u_image, gl_PointCoord.xy);
|
||
color = vec4(vec3(intColor.rrr), 1);
|
||
}
|
||
`,f=a.createShader(a.VERTEX_SHADER);if(a.shaderSource(f,c),a.compileShader(f),!a.getShaderParameter(f,a.COMPILE_STATUS))return!1;const u=a.createShader(a.FRAGMENT_SHADER);if(a.shaderSource(u,l),a.compileShader(u),!a.getShaderParameter(u,a.COMPILE_STATUS))return!1;const d=a.createProgram();if(a.attachShader(d,f),a.attachShader(d,u),a.linkProgram(d),!a.getProgramParameter(d,a.LINK_STATUS))return!1;const h=a.createTexture();a.bindTexture(a.TEXTURE_2D,h),a.texImage2D(a.TEXTURE_2D,0,s.R16_SNORM_EXT,2,1,0,a.RED,a.SHORT,n),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.useProgram(d),a.drawArrays(a.POINTS,0,1);const g=new Uint8Array(4);a.readPixels(i[0],i[1],1,1,a.RGBA,a.UNSIGNED_BYTE,g);const[p,v,y]=g,m=a.getExtension("WEBGL_lose_context");return m&&m.loseContext(),p===v&&v===y&&p!==0}catch{return!1}}let Vx;function RX(){return Vx===void 0&&(Vx=PX()),Vx}const{Wrap:Ll,Filter:Mi}=eR,{VtkDataTypes:kn}=bt,{vtkDebugMacro:Fx,vtkErrorMacro:Kd,vtkWarningMacro:$6}=uo,{toHalf:LX}=Hf;function AX(t,e){e.classHierarchy.push("vtkOpenGLTexture");function r(){return{internalFormat:e.internalFormat,format:e.format,openGLDataType:e.openGLDataType,width:e.width,height:e.height}}t.render=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null;if(g?e._openGLRenderWindow=g:(e._openGLRenderer=t.getFirstAncestorOfType("vtkOpenGLRenderer"),e._openGLRenderWindow=e._openGLRenderer.getLastAncestorOfType("vtkOpenGLRenderWindow")),e.context=e._openGLRenderWindow.getContext(),e.renderable.getInterpolate()?(e.generateMipmap?t.setMinificationFilter(Mi.LINEAR_MIPMAP_LINEAR):t.setMinificationFilter(Mi.LINEAR),t.setMagnificationFilter(Mi.LINEAR)):(t.setMinificationFilter(Mi.NEAREST),t.setMagnificationFilter(Mi.NEAREST)),e.renderable.getRepeat()&&(t.setWrapR(Ll.REPEAT),t.setWrapS(Ll.REPEAT),t.setWrapT(Ll.REPEAT)),e.renderable.getInputData()&&e.renderable.setImage(null),!e.handle||e.renderable.getMTime()>e.textureBuildTime.getMTime()){if(e.renderable.getImage()!==null&&(e.renderable.getInterpolate()&&(e.generateMipmap=!0,t.setMinificationFilter(Mi.LINEAR_MIPMAP_LINEAR)),e.renderable.getImage()&&e.renderable.getImageLoaded()&&(t.create2DFromImage(e.renderable.getImage()),t.activate(),t.sendParameters(),e.textureBuildTime.modified())),e.renderable.getCanvas()!==null){e.renderable.getInterpolate()&&(e.generateMipmap=!0,t.setMinificationFilter(Mi.LINEAR_MIPMAP_LINEAR));const v=e.renderable.getCanvas();t.create2DFromRaw(v.width,v.height,4,kn.UNSIGNED_CHAR,v,!0),t.activate(),t.sendParameters(),e.textureBuildTime.modified()}if(e.renderable.getJsImageData()!==null){const v=e.renderable.getJsImageData();e.renderable.getInterpolate()&&(e.generateMipmap=!0,t.setMinificationFilter(Mi.LINEAR_MIPMAP_LINEAR)),t.create2DFromRaw(v.width,v.height,4,kn.UNSIGNED_CHAR,v.data,!0),t.activate(),t.sendParameters(),e.textureBuildTime.modified()}const p=e.renderable.getInputData(0);if(p&&p.getPointData().getScalars()){const v=p.getExtent(),y=p.getPointData().getScalars(),m=[];for(let w=0;w<e.renderable.getNumberOfInputPorts();++w){const x=e.renderable.getInputData(w),C=x?x.getPointData().getScalars().getData():null;C&&m.push(C)}e.renderable.getInterpolate()&&y.getNumberOfComponents()===4&&(e.generateMipmap=!0,t.setMinificationFilter(Mi.LINEAR_MIPMAP_LINEAR)),m.length%6===0?t.createCubeFromRaw(v[1]-v[0]+1,v[3]-v[2]+1,y.getNumberOfComponents(),y.getDataType(),m):t.create2DFromRaw(v[1]-v[0]+1,v[3]-v[2]+1,y.getNumberOfComponents(),y.getDataType(),y.getData()),t.activate(),t.sendParameters(),e.textureBuildTime.modified()}}e.handle&&t.activate()};const n=()=>{if(!((e.minificationFilter===Mi.LINEAR||e.magnificationFilter===Mi.LINEAR)&&!RX()))return e.oglNorm16Ext};t.destroyTexture=()=>{t.deactivate(),e.context&&e.handle&&e.context.deleteTexture(e.handle),e._prevTexParams=null,e.handle=0,e.numberOfDimensions=0,e.target=0,e.components=0,e.width=0,e.height=0,e.depth=0,t.resetFormatAndType()},t.createTexture=()=>{e.handle||(e.handle=e.context.createTexture(),e.target&&(e.context.bindTexture(e.target,e.handle),e.context.texParameteri(e.target,e.context.TEXTURE_MIN_FILTER,t.getOpenGLFilterMode(e.minificationFilter)),e.context.texParameteri(e.target,e.context.TEXTURE_MAG_FILTER,t.getOpenGLFilterMode(e.magnificationFilter)),e.context.texParameteri(e.target,e.context.TEXTURE_WRAP_S,t.getOpenGLWrapMode(e.wrapS)),e.context.texParameteri(e.target,e.context.TEXTURE_WRAP_T,t.getOpenGLWrapMode(e.wrapT)),e._openGLRenderWindow.getWebgl2()&&e.context.texParameteri(e.target,e.context.TEXTURE_WRAP_R,t.getOpenGLWrapMode(e.wrapR)),e.context.bindTexture(e.target,null)))},t.getTextureUnit=()=>e._openGLRenderWindow?e._openGLRenderWindow.getTextureUnitForTexture(t):-1,t.activate=()=>{e._openGLRenderWindow.activateTexture(t),t.bind()},t.deactivate=()=>{e._openGLRenderWindow&&e._openGLRenderWindow.deactivateTexture(t)},t.releaseGraphicsResources=g=>{g&&e.handle&&(g.activateTexture(t),g.deactivateTexture(t),e.context.deleteTexture(e.handle),e._prevTexParams=null,e.handle=0,e.numberOfDimensions=0,e.target=0,e.internalFormat=0,e.format=0,e.openGLDataType=0,e.components=0,e.width=0,e.height=0,e.depth=0,e.allocatedGPUMemoryInBytes=0),e.shaderProgram&&(e.shaderProgram.releaseGraphicsResources(g),e.shaderProgram=null)},t.bind=()=>{e.context.bindTexture(e.target,e.handle),e.autoParameters&&t.getMTime()>e.sendParametersTime.getMTime()&&t.sendParameters()},t.isBound=()=>{let g=!1;if(e.context&&e.handle){let p=0;switch(e.target){case e.context.TEXTURE_2D:p=e.context.TEXTURE_BINDING_2D;break;default:$6("impossible case");break}g=e.context.getIntegerv(p)===e.handle}return g},t.sendParameters=()=>{e.context.texParameteri(e.target,e.context.TEXTURE_WRAP_S,t.getOpenGLWrapMode(e.wrapS)),e.context.texParameteri(e.target,e.context.TEXTURE_WRAP_T,t.getOpenGLWrapMode(e.wrapT)),e._openGLRenderWindow.getWebgl2()&&e.context.texParameteri(e.target,e.context.TEXTURE_WRAP_R,t.getOpenGLWrapMode(e.wrapR)),e.context.texParameteri(e.target,e.context.TEXTURE_MIN_FILTER,t.getOpenGLFilterMode(e.minificationFilter)),e.context.texParameteri(e.target,e.context.TEXTURE_MAG_FILTER,t.getOpenGLFilterMode(e.magnificationFilter)),e._openGLRenderWindow.getWebgl2()&&(e.context.texParameteri(e.target,e.context.TEXTURE_BASE_LEVEL,e.baseLevel),e.context.texParameteri(e.target,e.context.TEXTURE_MAX_LEVEL,e.maxLevel)),e.sendParametersTime.modified()},t.getInternalFormat=(g,p)=>(e._forceInternalFormat||(e.internalFormat=t.getDefaultInternalFormat(g,p)),e.internalFormat||Fx(`Unable to find suitable internal format for T=${g} NC= ${p}`),[e.context.R32F,e.context.RG32F,e.context.RGB32F,e.context.RGBA32F].includes(e.internalFormat)&&!e.context.getExtension("OES_texture_float_linear")&&$6("Failed to load OES_texture_float_linear. Texture filtering is not available for *32F internal formats."),e.internalFormat),t.getDefaultInternalFormat=(g,p)=>{let v=0;return v=e._openGLRenderWindow.getDefaultTextureInternalFormat(g,p,n(),t.useHalfFloat()),v||(v||(Fx("Unsupported internal texture type!"),Fx(`Unable to find suitable internal format for T=${g} NC= ${p}`)),v)},t.useHalfFloat=()=>e.enableUseHalfFloat&&e.canUseHalfFloat,t.setInternalFormat=g=>{e._forceInternalFormat=!0,g!==e.internalFormat&&(e.internalFormat=g,t.modified())},t.getFormat=(g,p)=>(e.format=t.getDefaultFormat(g,p),e.format),t.getDefaultFormat=(g,p)=>{if(e._openGLRenderWindow.getWebgl2())switch(p){case 1:return e.context.RED;case 2:return e.context.RG;case 3:return e.context.RGB;case 4:return e.context.RGBA;default:return e.context.RGB}else switch(p){case 1:return e.context.LUMINANCE;case 2:return e.context.LUMINANCE_ALPHA;case 3:return e.context.RGB;case 4:return e.context.RGBA;default:return e.context.RGB}},t.resetFormatAndType=()=>{e._prevTexParams=null,e.format=0,e.internalFormat=0,e._forceInternalFormat=!1,e.openGLDataType=0},t.getDefaultDataType=g=>{const p=t.useHalfFloat();if(e._openGLRenderWindow.getWebgl2())switch(g){case kn.UNSIGNED_CHAR:return e.context.UNSIGNED_BYTE;case(n()&&!p&&kn.SHORT):return e.context.SHORT;case(n()&&!p&&kn.UNSIGNED_SHORT):return e.context.UNSIGNED_SHORT;case(p&&kn.SHORT):return e.context.HALF_FLOAT;case(p&&kn.UNSIGNED_SHORT):return e.context.HALF_FLOAT;case kn.FLOAT:case kn.VOID:default:return e.context.FLOAT}switch(g){case kn.UNSIGNED_CHAR:return e.context.UNSIGNED_BYTE;case kn.FLOAT:case kn.VOID:default:if(e.context.getExtension("OES_texture_float")&&e.context.getExtension("OES_texture_float_linear"))return e.context.FLOAT;{const v=e.context.getExtension("OES_texture_half_float");if(v&&e.context.getExtension("OES_texture_half_float_linear"))return v.HALF_FLOAT_OES}return e.context.UNSIGNED_BYTE}},t.getOpenGLDataType=function(g){let p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return(!e.openGLDataType||p)&&(e.openGLDataType=t.getDefaultDataType(g)),e.openGLDataType},t.getShiftAndScale=()=>{let g=0,p=1;switch(e.openGLDataType){case e.context.BYTE:p=127.5,g=p-128;break;case e.context.UNSIGNED_BYTE:p=255,g=0;break;case e.context.SHORT:p=32767.5,g=p-32768;break;case e.context.UNSIGNED_SHORT:p=65536,g=0;break;case e.context.INT:p=21474836475e-1,g=p-2147483648;break;case e.context.UNSIGNED_INT:p=4294967295,g=0;break;case e.context.FLOAT:}return{shift:g,scale:p}},t.getOpenGLFilterMode=g=>{switch(g){case Mi.NEAREST:return e.context.NEAREST;case Mi.LINEAR:return e.context.LINEAR;case Mi.NEAREST_MIPMAP_NEAREST:return e.context.NEAREST_MIPMAP_NEAREST;case Mi.NEAREST_MIPMAP_LINEAR:return e.context.NEAREST_MIPMAP_LINEAR;case Mi.LINEAR_MIPMAP_NEAREST:return e.context.LINEAR_MIPMAP_NEAREST;case Mi.LINEAR_MIPMAP_LINEAR:return e.context.LINEAR_MIPMAP_LINEAR;default:return e.context.NEAREST}},t.getOpenGLWrapMode=g=>{switch(g){case Ll.CLAMP_TO_EDGE:return e.context.CLAMP_TO_EDGE;case Ll.REPEAT:return e.context.REPEAT;case Ll.MIRRORED_REPEAT:return e.context.MIRRORED_REPEAT;default:return e.context.CLAMP_TO_EDGE}};function i(g){const[p,v,y,m,w,x]=g;return[v-p+1,m-y+1,x-w+1]}function o(g){const[p,v,y]=i(g);return p*v*y}function a(g,p,v,y,m){const[w,x,C,S,T,_]=v,[E,b]=p,D=E*b;let I=m;for(let P=T;P<=_;P++){const O=P*D;for(let L=C;L<=S;L++){const B=O+L*E;for(let H=B+w,A=B+x;H<=A;H++,I++)y[I]=g[H]}}}function s(g,p){const y=(arguments.length>2&&arguments[2]!==void 0?arguments[2]:null)||g.constructor,m=p.reduce((S,T)=>S+o(T),0),w=new y(m),x=[e.width,e.height,e.depth];let C=0;return p.forEach(S=>{a(g,x,S,w,C),C+=o(S)}),w}t.updateArrayDataTypeForGL=function(g,p){let v=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,y=arguments.length>3&&arguments[3]!==void 0?arguments[3]:[];const m=[];let w=e.width*e.height*e.components;v&&(w*=e.depth);const x=!!y.length;if(g!==kn.FLOAT&&e.openGLDataType===e.context.FLOAT)for(let S=0;S<p.length;S++)if(p[S])if(x)m.push(s(p[S],y,Float32Array));else{const T=p[S].length>w?p[S].subarray(0,w):p[S];m.push(new Float32Array(T))}else m.push(null);if(g!==kn.UNSIGNED_CHAR&&e.openGLDataType===e.context.UNSIGNED_BYTE)for(let S=0;S<p.length;S++)if(p[S])if(x)m.push(s(p[S],y,Uint8Array));else{const T=p[S].length>w?p[S].subarray(0,w):p[S];m.push(new Uint8Array(T))}else m.push(null);let C=!1;if(e._openGLRenderWindow.getWebgl2())C=e.openGLDataType===e.context.HALF_FLOAT;else{const S=e.context.getExtension("OES_texture_half_float");C=S&&e.openGLDataType===S.HALF_FLOAT_OES}if(C)for(let S=0;S<p.length;S++)if(p[S]){const T=x?s(p[S],y):p[S],_=new Uint16Array(x?T.length:w),E=_.length;for(let b=0;b<E;b++)_[b]=LX(T[b]);m.push(_)}else m.push(null);if(m.length===0)for(let S=0;S<p.length;S++)m.push(x&&p[S]?s(p[S],y):p[S]);return m};function c(g){if(e._openGLRenderWindow.getWebgl2())return g;const p=[],v=e.width,y=e.height,m=e.components;if(g&&(!Hg(v)||!Hg(y))){const w=e.context.getExtension("OES_texture_half_float"),x=us(v),C=us(y),S=x*C*e.components;for(let T=0;T<g.length;T++)if(g[T]!==null){let _=null;const E=y/C,b=v/x;let D=!1;e.openGLDataType===e.context.FLOAT?_=new Float32Array(S):w&&e.openGLDataType===w.HALF_FLOAT_OES?(_=new Uint16Array(S),D=!0):_=new Uint8Array(S);for(let I=0;I<C;I++){const P=I*x*m,O=I*E;let L=Math.floor(O),B=Math.ceil(O);B>=y&&(B=y-1);const H=O-L,A=1-H;L=L*v*m,B=B*v*m;for(let F=0;F<x;F++){const G=F*m,X=F*b;let ee=Math.floor(X),ce=Math.ceil(X);ce>=v&&(ce=v-1);const Se=X-ee;ee*=m,ce*=m;for(let we=0;we<m;we++)D?_[P+G+we]=Hf.toHalf(Hf.fromHalf(g[T][L+ee+we])*A*(1-Se)+Hf.fromHalf(g[T][L+ce+we])*A*Se+Hf.fromHalf(g[T][B+ee+we])*H*(1-Se)+Hf.fromHalf(g[T][B+ce+we])*H*Se):_[P+G+we]=g[T][L+ee+we]*A*(1-Se)+g[T][L+ce+we]*A*Se+g[T][B+ee+we]*H*(1-Se)+g[T][B+ce+we]*H*Se}}p.push(_),e.width=x,e.height=C}else p.push(null)}if(p.length===0)for(let w=0;w<g.length;w++)p.push(g[w]);return p}function l(g){var p;return e._openGLRenderWindow?e.resizable||(p=e.renderable)!=null&&p.getResizable()?!1:e._openGLRenderWindow.getWebgl2()?!(e._openGLRenderWindow.getGLInformations().RENDERER.value.match(/WebKit/gi)&&navigator.platform.match(/Mac/gi)&&n()&&(g===kn.UNSIGNED_SHORT||g===kn.SHORT)):!1:!1}t.create2DFromRaw=function(g,p,v,y,m){let w=arguments.length>5&&arguments[5]!==void 0?arguments[5]:!1;if(t.getOpenGLDataType(y,!0),t.getInternalFormat(y,v),t.getFormat(y,v),!e.internalFormat||!e.format||!e.openGLDataType)return Kd("Failed to determine texture parameters."),!1;e.target=e.context.TEXTURE_2D,e.components=v,e.width=g,e.height=p,e.depth=1,e.numberOfDimensions=2,e._openGLRenderWindow.activateTexture(t),t.createTexture(),t.bind();const x=[m],C=t.updateArrayDataTypeForGL(y,x),S=c(C);return e.context.pixelStorei(e.context.UNPACK_FLIP_Y_WEBGL,w),e.context.pixelStorei(e.context.UNPACK_ALIGNMENT,1),l(y)?(e.context.texStorage2D(e.target,1,e.internalFormat,e.width,e.height),S[0]!=null&&e.context.texSubImage2D(e.target,0,0,0,e.width,e.height,e.format,e.openGLDataType,S[0])):e.context.texImage2D(e.target,0,e.internalFormat,e.width,e.height,0,e.format,e.openGLDataType,S[0]),e.generateMipmap&&e.context.generateMipmap(e.target),w&&e.context.pixelStorei(e.context.UNPACK_FLIP_Y_WEBGL,!1),e.allocatedGPUMemoryInBytes=e.width*e.height*e.depth*v*e._openGLRenderWindow.getDefaultTextureByteSize(y,n(),t.useHalfFloat()),t.deactivate(),!0},t.createCubeFromRaw=(g,p,v,y,m)=>{if(t.getOpenGLDataType(y),t.getInternalFormat(y,v),t.getFormat(y,v),!e.internalFormat||!e.format||!e.openGLDataType)return Kd("Failed to determine texture parameters."),!1;e.target=e.context.TEXTURE_CUBE_MAP,e.components=v,e.width=g,e.height=p,e.depth=1,e.numberOfDimensions=2,e._openGLRenderWindow.activateTexture(t),e.maxLevel=m.length/6-1,t.createTexture(),t.bind();const w=t.updateArrayDataTypeForGL(y,m),x=c(w),C=[];let S=e.width,T=e.height;for(let _=0;_<x.length;_++){_%6===0&&_!==0&&(S/=2,T/=2),C[_]=Uh(y,T*S*e.components);for(let E=0;E<T;++E){const b=E*S*e.components,D=(T-E-1)*S*e.components;C[_].set(x[_].slice(D,D+S*e.components),b)}}e.context.pixelStorei(e.context.UNPACK_ALIGNMENT,1),l(y)&&e.context.texStorage2D(e.target,6,e.internalFormat,e.width,e.height);for(let _=0;_<6;_++){let E=0,b=e.width,D=e.height;for(;b>=1&&D>=1;){let I=null;E<=e.maxLevel&&(I=C[6*E+_]),l(y)?I!=null&&e.context.texSubImage2D(e.context.TEXTURE_CUBE_MAP_POSITIVE_X+_,E,0,0,b,D,e.format,e.openGLDataType,I):e.context.texImage2D(e.context.TEXTURE_CUBE_MAP_POSITIVE_X+_,E,e.internalFormat,b,D,0,e.format,e.openGLDataType,I),E++,b/=2,D/=2}}return e.allocatedGPUMemoryInBytes=e.width*e.height*e.depth*v*e._openGLRenderWindow.getDefaultTextureByteSize(y,n(),t.useHalfFloat()),t.deactivate(),!0},t.createDepthFromRaw=(g,p,v,y)=>(t.getOpenGLDataType(v),e.format=e.context.DEPTH_COMPONENT,e._openGLRenderWindow.getWebgl2()?v===kn.FLOAT?e.internalFormat=e.context.DEPTH_COMPONENT32F:e.internalFormat=e.context.DEPTH_COMPONENT16:e.internalFormat=e.context.DEPTH_COMPONENT,!e.internalFormat||!e.format||!e.openGLDataType?(Kd("Failed to determine texture parameters."),!1):(e.target=e.context.TEXTURE_2D,e.components=1,e.width=g,e.height=p,e.depth=1,e.numberOfDimensions=2,e._openGLRenderWindow.activateTexture(t),t.createTexture(),t.bind(),e.context.pixelStorei(e.context.UNPACK_ALIGNMENT,1),l(v)?(e.context.texStorage2D(e.target,1,e.internalFormat,e.width,e.height),y!=null&&e.context.texSubImage2D(e.target,0,0,0,e.width,e.height,e.format,e.openGLDataType,y)):e.context.texImage2D(e.target,0,e.internalFormat,e.width,e.height,0,e.format,e.openGLDataType,y),e.generateMipmap&&e.context.generateMipmap(e.target),e.allocatedGPUMemoryInBytes=e.width*e.height*e.depth*e.components*e._openGLRenderWindow.getDefaultTextureByteSize(v,n(),t.useHalfFloat()),t.deactivate(),!0)),t.create2DFromImage=g=>{if(t.getOpenGLDataType(kn.UNSIGNED_CHAR),t.getInternalFormat(kn.UNSIGNED_CHAR,4),t.getFormat(kn.UNSIGNED_CHAR,4),!e.internalFormat||!e.format||!e.openGLDataType)return Kd("Failed to determine texture parameters."),!1;e.target=e.context.TEXTURE_2D,e.components=4,e.depth=1,e.numberOfDimensions=2,e._openGLRenderWindow.activateTexture(t),t.createTexture(),t.bind(),e.context.pixelStorei(e.context.UNPACK_ALIGNMENT,1);const p=!e._openGLRenderWindow.getWebgl2()&&(!Hg(g.width)||!Hg(g.height)),v=document.createElement("canvas");v.width=p?us(g.width):g.width,v.height=p?us(g.height):g.height,e.width=v.width,e.height=v.height;const y=v.getContext("2d");y.translate(0,v.height),y.scale(1,-1),y.drawImage(g,0,0,g.width,g.height,0,0,v.width,v.height);const m=v;return l(kn.UNSIGNED_CHAR)?(e.context.texStorage2D(e.target,1,e.internalFormat,e.width,e.height),m!=null&&e.context.texSubImage2D(e.target,0,0,0,e.width,e.height,e.format,e.openGLDataType,m)):e.context.texImage2D(e.target,0,e.internalFormat,e.width,e.height,0,e.format,e.openGLDataType,m),e.generateMipmap&&e.context.generateMipmap(e.target),e.allocatedGPUMemoryInBytes=e.width*e.height*e.depth*e.components*e._openGLRenderWindow.getDefaultTextureByteSize(kn.UNSIGNED_CHAR,n(),t.useHalfFloat()),t.deactivate(),!0};function f(g,p,v){const y=new Array(v),m=new Array(v);for(let w=0;w<v;++w)y[w]=g[w],m[w]=p[w]-g[w]||1;return{scale:m,offset:y}}function u(g,p){for(let v=0;v<g.length;v++){const y=g[v],m=p[v]+y;if(y<-2048||y>2048||m<-2048||m>2048)return!1}return!0}function d(g,p,v,y){t.getOpenGLDataType(g);const m=u(p,v)||y;let w=!1;if(e._openGLRenderWindow.getWebgl2())w=e.openGLDataType===e.context.FLOAT&&e.context.getExtension("OES_texture_float_linear")===null&&m||e.openGLDataType===e.context.HALF_FLOAT;else{const x=e.context.getExtension("OES_texture_half_float");w=x&&e.openGLDataType===x.HALF_FLOAT_OES}e.canUseHalfFloat=w&&m}function h(g,p){const v=g.getNumberOfComponents(),y=g.getDataType(),m=g.getData(),w=new Array(v),x=new Array(v);for(let S=0;S<v;++S){const[T,_]=g.getRange(S);w[S]=T,x[S]=_}const C=f(w,x,v);return d(y,C.offset,C.scale,p),t.useHalfFloat()||t.getOpenGLDataType(y,!0),{numComps:v,dataType:y,data:m,scaleOffsets:C}}t.create2DFilterableFromRaw=function(g,p,v,y,m){let w=arguments.length>5&&arguments[5]!==void 0?arguments[5]:!1,x=arguments.length>6&&arguments[6]!==void 0?arguments[6]:void 0;return t.create2DFilterableFromDataArray(g,p,bt.newInstance({numberOfComponents:v,dataType:y,values:m,ranges:x}),w)},t.create2DFilterableFromDataArray=function(g,p,v){let y=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;const{numComps:m,dataType:w,data:x}=h(v,y);t.create2DFromRaw(g,p,m,w,x)},t.updateVolumeInfoForGL=(g,p)=>{var m,w;let v=!1;const y=t.useHalfFloat();(!((m=e.volumeInfo)!=null&&m.scale)||!((w=e.volumeInfo)!=null&&w.offset))&&(e.volumeInfo={scale:new Array(p),offset:new Array(p)});for(let x=0;x<p;++x)e.volumeInfo.scale[x]=1,e.volumeInfo.offset[x]=0;if(n()&&!y&&g===kn.SHORT){for(let x=0;x<p;++x)e.volumeInfo.scale[x]=32767;v=!0}if(n()&&!y&&g===kn.UNSIGNED_SHORT){for(let x=0;x<p;++x)e.volumeInfo.scale[x]=65535;v=!0}if(g===kn.UNSIGNED_CHAR){for(let x=0;x<p;++x)e.volumeInfo.scale[x]=255;v=!0}return(g===kn.FLOAT||y&&(g===kn.SHORT||g===kn.UNSIGNED_SHORT))&&(v=!0),v},t.create3DFromRaw=function(g,p,v,y,m,w){let x=arguments.length>6&&arguments[6]!==void 0?arguments[6]:[],C=m,S=w;if(!t.updateVolumeInfoForGL(C,y)&&S){const P=g*p*v,O=structuredClone(e.volumeInfo),L=new Float32Array(P*y);e.volumeInfo.offset=O.offset,e.volumeInfo.scale=O.scale;let B=0;const H=O.scale.map(A=>1/A);for(let A=0;A<P;A++)for(let F=0;F<y;F++)L[B]=(S[B]-O.offset[F])*H[F],B++;C=kn.FLOAT,S=L}if(t.getOpenGLDataType(C),t.getInternalFormat(C,y),t.getFormat(C,y),!e.internalFormat||!e.format||!e.openGLDataType)return Kd("Failed to determine texture parameters."),!1;e.target=e.context.TEXTURE_3D,e.components=y,e.width=g,e.height=p,e.depth=v,e.numberOfDimensions=3,e._openGLRenderWindow.activateTexture(t),t.createTexture(),t.bind();const T=x.length>0,_=!T||!D_(e._prevTexParams,r()),E=[S],D=t.updateArrayDataTypeForGL(C,E,!0,_?[]:x),I=c(D);if(e.context.pixelStorei(e.context.UNPACK_ALIGNMENT,1),_)l(C)?(e.context.texStorage3D(e.target,1,e.internalFormat,e.width,e.height,e.depth),I[0]!=null&&e.context.texSubImage3D(e.target,0,0,0,0,e.width,e.height,e.depth,e.format,e.openGLDataType,I[0])):e.context.texImage3D(e.target,0,e.internalFormat,e.width,e.height,e.depth,0,e.format,e.openGLDataType,I[0]),e._prevTexParams=r();else if(T){const P=I[0];let O=0;for(let L=0;L<x.length;L++){const B=x[L],H=i(B),A=o(B),F=new P.constructor(P.buffer,O,A);O+=F.byteLength,e.context.texSubImage3D(e.target,0,B[0],B[2],B[4],H[0],H[1],H[2],e.format,e.openGLDataType,F)}}return e.generateMipmap&&e.context.generateMipmap(e.target),e.allocatedGPUMemoryInBytes=e.width*e.height*e.depth*e.components*e._openGLRenderWindow.getDefaultTextureByteSize(C,n(),t.useHalfFloat()),t.deactivate(),!0},t.create3DFilterableFromRaw=function(g,p,v,y,m,w){let x=arguments.length>6&&arguments[6]!==void 0?arguments[6]:!1,C=arguments.length>7&&arguments[7]!==void 0?arguments[7]:void 0,S=arguments.length>8&&arguments[8]!==void 0?arguments[8]:[];return t.create3DFilterableFromDataArray(g,p,v,bt.newInstance({numberOfComponents:y,dataType:m,values:w,ranges:C}),x,S)},t.create3DFilterableFromDataArray=function(g,p,v,y){let m=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1,w=arguments.length>5&&arguments[5]!==void 0?arguments[5]:[];const{numComps:x,dataType:C,data:S,scaleOffsets:T}=h(y,m),_=[],E=[];for(let _e=0;_e<x;++_e)_[_e]=0,E[_e]=1;if(e.volumeInfo={scale:E,offset:_,dataComputedScale:T.scale,dataComputedOffset:T.offset,width:g,height:p,depth:v},e._openGLRenderWindow.getWebgl2())return t.create3DFromRaw(g,p,v,x,C,S,w);const b=g*p*v,D=structuredClone(T);let I=(_e,Ve,Ge,Ne,j)=>{_e[Ve]=Ge},P=kn.UNSIGNED_CHAR;if(C===kn.UNSIGNED_CHAR)for(let _e=0;_e<x;++_e)D.offset[_e]=0,D.scale[_e]=255;else e.context.getExtension("OES_texture_float")&&e.context.getExtension("OES_texture_float_linear")?(P=kn.FLOAT,I=(_e,Ve,Ge,Ne,j)=>{_e[Ve]=(Ge-Ne)/j}):(P=kn.UNSIGNED_CHAR,I=(_e,Ve,Ge,Ne,j)=>{_e[Ve]=255*(Ge-Ne)/j});if(t.getOpenGLDataType(P),t.getInternalFormat(P,x),t.getFormat(P,x),!e.internalFormat||!e.format||!e.openGLDataType)return Kd("Failed to determine texture parameters."),!1;e.target=e.context.TEXTURE_2D,e.components=x,e.depth=1,e.numberOfDimensions=2;let O=e.context.getParameter(e.context.MAX_TEXTURE_SIZE);O>4096&&(P===kn.FLOAT||x>=3)&&(O=4096);let L=1,B=1;b>O*O&&(L=Math.ceil(Math.sqrt(b/(O*O))),B=L);let H=Math.sqrt(b)/L;H=us(H);const A=Math.floor(H*L/g),F=Math.ceil(v/A),G=us(p*F/B);e.width=H,e.height=G,e._openGLRenderWindow.activateTexture(t),t.createTexture(),t.bind(),e.volumeInfo.xreps=A,e.volumeInfo.yreps=F,e.volumeInfo.xstride=L,e.volumeInfo.ystride=B,e.volumeInfo.offset=D.offset,e.volumeInfo.scale=D.scale;let X;const ee=H*G*x;P===kn.FLOAT?X=new Float32Array(ee):X=new Uint8Array(ee);let ce=0;const Se=Math.floor(g/L),we=Math.floor(p/B);for(let _e=0;_e<F;_e++){const Ve=Math.min(A,v-_e*A),Ge=x*(e.width-Ve*Math.floor(g/L));for(let Ne=0;Ne<we;Ne++){for(let j=0;j<Ve;j++){const M=x*((_e*A+j)*g*p+B*Ne*g);for(let q=0;q<Se;q++)for(let K=0;K<x;K++)I(X,ce,S[M+L*q*x+K],D.offset[K],D.scale[K]),ce++}ce+=Ge}}return e.context.pixelStorei(e.context.UNPACK_ALIGNMENT,1),l(P)?(e.context.texStorage2D(e.target,1,e.internalFormat,e.width,e.height),X!=null&&e.context.texSubImage2D(e.target,0,0,0,e.width,e.height,e.format,e.openGLDataType,X)):e.context.texImage2D(e.target,0,e.internalFormat,e.width,e.height,0,e.format,e.openGLDataType,X),t.deactivate(),!0},t.setOpenGLRenderWindow=g=>{e._openGLRenderWindow!==g&&(t.releaseGraphicsResources(),e._openGLRenderWindow=g,e.context=null,g&&(e.context=e._openGLRenderWindow.getContext()))},t.getMaximumTextureSize=g=>g&&g.isCurrent()?g.getIntegerv(g.MAX_TEXTURE_SIZE):-1,t.enableUseHalfFloat=g=>{e.enableUseHalfFloat=g}}const NX={_openGLRenderWindow:null,_forceInternalFormat:!1,_prevTexParams:null,context:null,handle:0,sendParametersTime:null,textureBuildTime:null,numberOfDimensions:0,target:0,format:0,openGLDataType:0,components:0,width:0,height:0,depth:0,autoParameters:!0,wrapS:Ll.CLAMP_TO_EDGE,wrapT:Ll.CLAMP_TO_EDGE,wrapR:Ll.CLAMP_TO_EDGE,minificationFilter:Mi.NEAREST,magnificationFilter:Mi.NEAREST,minLOD:-1e3,maxLOD:1e3,baseLevel:0,maxLevel:1e3,generateMipmap:!1,oglNorm16Ext:null,allocatedGPUMemoryInBytes:0,enableUseHalfFloat:!0,canUseHalfFloat:!1};function RR(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,NX,r),Qn.extend(t,e,r),e.sendParametersTime={},or(e.sendParametersTime,{mtime:0}),e.textureBuildTime={},or(e.textureBuildTime,{mtime:0}),q1(t,e,["format","openGLDataType"]),Jr(t,e,["keyMatrixTime","minificationFilter","magnificationFilter","wrapS","wrapT","wrapR","generateMipmap","oglNorm16Ext"]),Ro(t,e,["width","height","volumeInfo","components","handle","target","allocatedGPUMemoryInBytes"]),X1(t,e,["openGLRenderWindow"]),AX(t,e)}const LR=Rn(RR,"vtkOpenGLTexture");var mr={newInstance:LR,extend:RR,...eR};di("vtkTexture",LR);function kX(t,e){e.classHierarchy.push("vtkFramebuffer"),t.getBothMode=()=>e.context.FRAMEBUFFER,t.saveCurrentBindingsAndBuffers=r=>{const n=typeof r<"u"?r:t.getBothMode();t.saveCurrentBindings(n),t.saveCurrentBuffers(n)},t.saveCurrentBindings=r=>{if(!e.context){vn("you must set the OpenGLRenderWindow before calling saveCurrentBindings");return}const n=e.context;e.previousDrawBinding=n.getParameter(e.context.FRAMEBUFFER_BINDING),e.previousActiveFramebuffer=e._openGLRenderWindow.getActiveFramebuffer()},t.saveCurrentBuffers=r=>{},t.restorePreviousBindingsAndBuffers=r=>{const n=typeof r<"u"?r:t.getBothMode();t.restorePreviousBindings(n),t.restorePreviousBuffers(n)},t.restorePreviousBindings=r=>{if(!e.context){vn("you must set the OpenGLRenderWindow before calling restorePreviousBindings");return}const n=e.context;n.bindFramebuffer(n.FRAMEBUFFER,e.previousDrawBinding),e._openGLRenderWindow.setActiveFramebuffer(e.previousActiveFramebuffer)},t.restorePreviousBuffers=r=>{},t.bind=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null;n===null&&(n=e.context.FRAMEBUFFER),e.context.bindFramebuffer(n,e.glFramebuffer);for(let i=0;i<e.colorBuffers.length;i++)e.colorBuffers[i].bind();e._openGLRenderWindow.setActiveFramebuffer(t)},t.create=(r,n)=>{if(!e.context){vn("you must set the OpenGLRenderWindow before calling create");return}e.glFramebuffer=e.context.createFramebuffer(),e.glFramebuffer.width=r,e.glFramebuffer.height=n},t.setColorBuffer=function(r){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;const i=e.context;if(!i){vn("you must set the OpenGLRenderWindow before calling setColorBuffer");return}let o=i.COLOR_ATTACHMENT0;if(n>0)if(e._openGLRenderWindow.getWebgl2())o+=n;else{vn("Using multiple framebuffer attachments requires WebGL 2");return}e.colorBuffers[n]=r,i.framebufferTexture2D(i.FRAMEBUFFER,o,i.TEXTURE_2D,r.getHandle(),0)},t.removeColorBuffer=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;const n=e.context;if(!n){vn("you must set the OpenGLRenderWindow before calling removeColorBuffer");return}let i=n.COLOR_ATTACHMENT0;if(r>0)if(e._openGLRenderWindow.getWebgl2())i+=r;else{vn("Using multiple framebuffer attachments requires WebGL 2");return}n.framebufferTexture2D(n.FRAMEBUFFER,i,n.TEXTURE_2D,null,0),e.colorBuffers=e.colorBuffers.splice(r,1)},t.setDepthBuffer=r=>{if(!e.context){vn("you must set the OpenGLRenderWindow before calling setDepthBuffer");return}if(e._openGLRenderWindow.getWebgl2()){const n=e.context;n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,r.getHandle(),0)}else vn("Attaching depth buffer textures to fbo requires WebGL 2")},t.removeDepthBuffer=()=>{if(!e.context){vn("you must set the OpenGLRenderWindow before calling removeDepthBuffer");return}if(e._openGLRenderWindow.getWebgl2()){const r=e.context;r.framebufferTexture2D(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.TEXTURE_2D,null,0)}else vn("Attaching depth buffer textures to framebuffers requires WebGL 2")},t.getGLFramebuffer=()=>e.glFramebuffer,t.setOpenGLRenderWindow=r=>{e._openGLRenderWindow!==r&&(t.releaseGraphicsResources(),e._openGLRenderWindow=r,e.context=null,r&&(e.context=e._openGLRenderWindow.getContext()))},t.releaseGraphicsResources=()=>{e.glFramebuffer&&e.context.deleteFramebuffer(e.glFramebuffer)},t.getSize=()=>e.glFramebuffer==null?null:[e.glFramebuffer.width,e.glFramebuffer.height],t.populateFramebuffer=()=>{if(!e.context){vn("you must set the OpenGLRenderWindow before calling populateFrameBuffer");return}t.bind();const r=e.context,n=mr.newInstance();n.setOpenGLRenderWindow(e._openGLRenderWindow),n.setMinificationFilter(Pt.LINEAR),n.setMagnificationFilter(Pt.LINEAR),n.create2DFromRaw(e.glFramebuffer.width,e.glFramebuffer.height,4,rn.UNSIGNED_CHAR,null),t.setColorBuffer(n),e.depthTexture=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,e.depthTexture),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_COMPONENT16,e.glFramebuffer.width,e.glFramebuffer.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.RENDERBUFFER,e.depthTexture)},t.getColorTexture=()=>e.colorBuffers[0]}const VX={glFramebuffer:null,colorBuffers:null,depthTexture:null,previousDrawBinding:0,previousReadBinding:0,previousDrawBuffer:0,previousReadBuffer:0,previousActiveFramebuffer:null};function AR(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,VX,r),or(t,e),e.colorBuffers&&vn("you cannot initialize colorBuffers through the constructor. You should call setColorBuffer() instead."),e.colorBuffers=[],Bh(t,e,["colorBuffers"]),kX(t,e)}const FX=Rn(AR,"vtkFramebuffer");var ew={newInstance:FX,extend:AR};function UX(t,e){e.classHierarchy.push("vtkRenderPass"),t.getOperation=()=>e.currentOperation,t.setCurrentOperation=r=>{e.currentOperation=r,e.currentTraverseOperation=`traverse${Z.capitalize(e.currentOperation)}`},t.getTraverseOperation=()=>e.currentTraverseOperation,t.traverse=function(r){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;e.deleted||(e._currentParent=n,e.preDelegateOperations.forEach(i=>{t.setCurrentOperation(i),r.traverse(t)}),e.delegates.forEach(i=>{i.traverse(r,t)}),e.postDelegateOperations.forEach(i=>{t.setCurrentOperation(i),r.traverse(t)}))}}const BX={delegates:[],currentOperation:null,preDelegateOperations:[],postDelegateOperations:[],currentParent:null};function NR(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,BX,r),Z.obj(t,e),Z.get(t,e,["currentOperation"]),Z.setGet(t,e,["delegates","_currentParent","preDelegateOperations","postDelegateOperations"]),Z.moveToProtected(t,e,["currentParent"]),UX(t,e)}const GX=Z.newInstance(NR,"vtkRenderPass");var Y_={newInstance:GX,extend:NR},An=1e-6,Xr=typeof Float32Array<"u"?Float32Array:Array,WX=Math.PI/180;function zX(t){return t*WX}function af(t,e){return Math.abs(t-e)<=An*Math.max(1,Math.abs(t),Math.abs(e))}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});function J_(){var t=new Xr(9);return Xr!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[5]=0,t[6]=0,t[7]=0),t[0]=1,t[4]=1,t[8]=1,t}function tw(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t}function $X(t){var e=new Xr(9);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}function jX(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}function qg(t,e,r,n,i,o,a,s,c){var l=new Xr(9);return l[0]=t,l[1]=e,l[2]=r,l[3]=n,l[4]=i,l[5]=o,l[6]=a,l[7]=s,l[8]=c,l}function kR(t,e,r,n,i,o,a,s,c,l){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t[4]=o,t[5]=a,t[6]=s,t[7]=c,t[8]=l,t}function ys(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t}function Z_(t,e){if(t===e){var r=e[1],n=e[2],i=e[5];t[1]=e[3],t[2]=e[6],t[3]=r,t[5]=e[7],t[6]=n,t[7]=i}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t}function em(t,e){var r=e[0],n=e[1],i=e[2],o=e[3],a=e[4],s=e[5],c=e[6],l=e[7],f=e[8],u=f*a-s*l,d=-f*o+s*c,h=l*o-a*c,g=r*u+n*d+i*h;return g?(g=1/g,t[0]=u*g,t[1]=(-f*n+i*l)*g,t[2]=(s*n-i*a)*g,t[3]=d*g,t[4]=(f*r-i*c)*g,t[5]=(-s*r+i*o)*g,t[6]=h*g,t[7]=(-l*r+n*c)*g,t[8]=(a*r-n*o)*g,t):null}function HX(t,e){var r=e[0],n=e[1],i=e[2],o=e[3],a=e[4],s=e[5],c=e[6],l=e[7],f=e[8];return t[0]=a*f-s*l,t[1]=i*l-n*f,t[2]=n*s-i*a,t[3]=s*c-o*f,t[4]=r*f-i*c,t[5]=i*o-r*s,t[6]=o*l-a*c,t[7]=n*c-r*l,t[8]=r*a-n*o,t}function Wf(t){var e=t[0],r=t[1],n=t[2],i=t[3],o=t[4],a=t[5],s=t[6],c=t[7],l=t[8];return e*(l*o-a*c)+r*(-l*i+a*s)+n*(c*i-o*s)}function yh(t,e,r){var n=e[0],i=e[1],o=e[2],a=e[3],s=e[4],c=e[5],l=e[6],f=e[7],u=e[8],d=r[0],h=r[1],g=r[2],p=r[3],v=r[4],y=r[5],m=r[6],w=r[7],x=r[8];return t[0]=d*n+h*a+g*l,t[1]=d*i+h*s+g*f,t[2]=d*o+h*c+g*u,t[3]=p*n+v*a+y*l,t[4]=p*i+v*s+y*f,t[5]=p*o+v*c+y*u,t[6]=m*n+w*a+x*l,t[7]=m*i+w*s+x*f,t[8]=m*o+w*c+x*u,t}function KX(t,e,r){var n=e[0],i=e[1],o=e[2],a=e[3],s=e[4],c=e[5],l=e[6],f=e[7],u=e[8],d=r[0],h=r[1];return t[0]=n,t[1]=i,t[2]=o,t[3]=a,t[4]=s,t[5]=c,t[6]=d*n+h*a+l,t[7]=d*i+h*s+f,t[8]=d*o+h*c+u,t}function qX(t,e,r){var n=e[0],i=e[1],o=e[2],a=e[3],s=e[4],c=e[5],l=e[6],f=e[7],u=e[8],d=Math.sin(r),h=Math.cos(r);return t[0]=h*n+d*a,t[1]=h*i+d*s,t[2]=h*o+d*c,t[3]=h*a-d*n,t[4]=h*s-d*i,t[5]=h*c-d*o,t[6]=l,t[7]=f,t[8]=u,t}function XX(t,e,r){var n=r[0],i=r[1];return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=i*e[3],t[4]=i*e[4],t[5]=i*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t}function YX(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=e[0],t[7]=e[1],t[8]=1,t}function JX(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=0,t[3]=-r,t[4]=n,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t}function ZX(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=e[1],t[5]=0,t[6]=0,t[7]=0,t[8]=1,t}function QX(t,e){return t[0]=e[0],t[1]=e[1],t[2]=0,t[3]=e[2],t[4]=e[3],t[5]=0,t[6]=e[4],t[7]=e[5],t[8]=1,t}function eY(t,e){var r=e[0],n=e[1],i=e[2],o=e[3],a=r+r,s=n+n,c=i+i,l=r*a,f=n*a,u=n*s,d=i*a,h=i*s,g=i*c,p=o*a,v=o*s,y=o*c;return t[0]=1-u-g,t[3]=f-y,t[6]=d+v,t[1]=f+y,t[4]=1-l-g,t[7]=h-p,t[2]=d-v,t[5]=h+p,t[8]=1-l-u,t}function tY(t,e){var r=e[0],n=e[1],i=e[2],o=e[3],a=e[4],s=e[5],c=e[6],l=e[7],f=e[8],u=e[9],d=e[10],h=e[11],g=e[12],p=e[13],v=e[14],y=e[15],m=r*s-n*a,w=r*c-i*a,x=r*l-o*a,C=n*c-i*s,S=n*l-o*s,T=i*l-o*c,_=f*p-u*g,E=f*v-d*g,b=f*y-h*g,D=u*v-d*p,I=u*y-h*p,P=d*y-h*v,O=m*P-w*I+x*D+C*b-S*E+T*_;return O?(O=1/O,t[0]=(s*P-c*I+l*D)*O,t[1]=(c*b-a*P-l*E)*O,t[2]=(a*I-s*b+l*_)*O,t[3]=(i*I-n*P-o*D)*O,t[4]=(r*P-i*b+o*E)*O,t[5]=(n*b-r*I-o*_)*O,t[6]=(p*T-v*S+y*C)*O,t[7]=(v*x-g*T-y*w)*O,t[8]=(g*S-p*x+y*m)*O,t):null}function nY(t,e,r){return t[0]=2/e,t[1]=0,t[2]=0,t[3]=0,t[4]=-2/r,t[5]=0,t[6]=-1,t[7]=1,t[8]=1,t}function rY(t){return"mat3("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+")"}function iY(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])}function oY(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t}function VR(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t}function aY(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t}function sY(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t[4]=e[4]+r[4]*n,t[5]=e[5]+r[5]*n,t[6]=e[6]+r[6]*n,t[7]=e[7]+r[7]*n,t[8]=e[8]+r[8]*n,t}function cY(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]}function lY(t,e){var r=t[0],n=t[1],i=t[2],o=t[3],a=t[4],s=t[5],c=t[6],l=t[7],f=t[8],u=e[0],d=e[1],h=e[2],g=e[3],p=e[4],v=e[5],y=e[6],m=e[7],w=e[8];return Math.abs(r-u)<=An*Math.max(1,Math.abs(r),Math.abs(u))&&Math.abs(n-d)<=An*Math.max(1,Math.abs(n),Math.abs(d))&&Math.abs(i-h)<=An*Math.max(1,Math.abs(i),Math.abs(h))&&Math.abs(o-g)<=An*Math.max(1,Math.abs(o),Math.abs(g))&&Math.abs(a-p)<=An*Math.max(1,Math.abs(a),Math.abs(p))&&Math.abs(s-v)<=An*Math.max(1,Math.abs(s),Math.abs(v))&&Math.abs(c-y)<=An*Math.max(1,Math.abs(c),Math.abs(y))&&Math.abs(l-m)<=An*Math.max(1,Math.abs(l),Math.abs(m))&&Math.abs(f-w)<=An*Math.max(1,Math.abs(f),Math.abs(w))}var uY=yh,fY=VR;const dY=Object.freeze(Object.defineProperty({__proto__:null,add:oY,adjoint:HX,clone:$X,copy:jX,create:J_,determinant:Wf,equals:lY,exactEquals:cY,frob:iY,fromMat2d:QX,fromMat4:tw,fromQuat:eY,fromRotation:JX,fromScaling:ZX,fromTranslation:YX,fromValues:qg,identity:ys,invert:em,mul:uY,multiply:yh,multiplyScalar:aY,multiplyScalarAndAdd:sY,normalFromMat4:tY,projection:nY,rotate:qX,scale:XX,set:kR,str:rY,sub:fY,subtract:VR,translate:KX,transpose:Z_},Symbol.toStringTag,{value:"Module"}));function ma(){var t=new Xr(16);return Xr!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function hY(t){var e=new Xr(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Cr(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function Q_(t,e,r,n,i,o,a,s,c,l,f,u,d,h,g,p){var v=new Xr(16);return v[0]=t,v[1]=e,v[2]=r,v[3]=n,v[4]=i,v[5]=o,v[6]=a,v[7]=s,v[8]=c,v[9]=l,v[10]=f,v[11]=u,v[12]=d,v[13]=h,v[14]=g,v[15]=p,v}function gY(t,e,r,n,i,o,a,s,c,l,f,u,d,h,g,p,v){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t[4]=o,t[5]=a,t[6]=s,t[7]=c,t[8]=l,t[9]=f,t[10]=u,t[11]=d,t[12]=h,t[13]=g,t[14]=p,t[15]=v,t}function It(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function un(t,e){if(t===e){var r=e[1],n=e[2],i=e[3],o=e[6],a=e[7],s=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=n,t[9]=o,t[11]=e[14],t[12]=i,t[13]=a,t[14]=s}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function Ar(t,e){var r=e[0],n=e[1],i=e[2],o=e[3],a=e[4],s=e[5],c=e[6],l=e[7],f=e[8],u=e[9],d=e[10],h=e[11],g=e[12],p=e[13],v=e[14],y=e[15],m=r*s-n*a,w=r*c-i*a,x=r*l-o*a,C=n*c-i*s,S=n*l-o*s,T=i*l-o*c,_=f*p-u*g,E=f*v-d*g,b=f*y-h*g,D=u*v-d*p,I=u*y-h*p,P=d*y-h*v,O=m*P-w*I+x*D+C*b-S*E+T*_;return O?(O=1/O,t[0]=(s*P-c*I+l*D)*O,t[1]=(i*I-n*P-o*D)*O,t[2]=(p*T-v*S+y*C)*O,t[3]=(d*S-u*T-h*C)*O,t[4]=(c*b-a*P-l*E)*O,t[5]=(r*P-i*b+o*E)*O,t[6]=(v*x-g*T-y*w)*O,t[7]=(f*T-d*x+h*w)*O,t[8]=(a*I-s*b+l*_)*O,t[9]=(n*b-r*I-o*_)*O,t[10]=(g*S-p*x+y*m)*O,t[11]=(u*x-f*S-h*m)*O,t[12]=(s*E-a*D-c*_)*O,t[13]=(r*D-n*E+i*_)*O,t[14]=(p*w-g*C-v*m)*O,t[15]=(f*C-u*w+d*m)*O,t):null}function pY(t,e){var r=e[0],n=e[1],i=e[2],o=e[3],a=e[4],s=e[5],c=e[6],l=e[7],f=e[8],u=e[9],d=e[10],h=e[11],g=e[12],p=e[13],v=e[14],y=e[15];return t[0]=s*(d*y-h*v)-u*(c*y-l*v)+p*(c*h-l*d),t[1]=-(n*(d*y-h*v)-u*(i*y-o*v)+p*(i*h-o*d)),t[2]=n*(c*y-l*v)-s*(i*y-o*v)+p*(i*l-o*c),t[3]=-(n*(c*h-l*d)-s*(i*h-o*d)+u*(i*l-o*c)),t[4]=-(a*(d*y-h*v)-f*(c*y-l*v)+g*(c*h-l*d)),t[5]=r*(d*y-h*v)-f*(i*y-o*v)+g*(i*h-o*d),t[6]=-(r*(c*y-l*v)-a*(i*y-o*v)+g*(i*l-o*c)),t[7]=r*(c*h-l*d)-a*(i*h-o*d)+f*(i*l-o*c),t[8]=a*(u*y-h*p)-f*(s*y-l*p)+g*(s*h-l*u),t[9]=-(r*(u*y-h*p)-f*(n*y-o*p)+g*(n*h-o*u)),t[10]=r*(s*y-l*p)-a*(n*y-o*p)+g*(n*l-o*s),t[11]=-(r*(s*h-l*u)-a*(n*h-o*u)+f*(n*l-o*s)),t[12]=-(a*(u*v-d*p)-f*(s*v-c*p)+g*(s*d-c*u)),t[13]=r*(u*v-d*p)-f*(n*v-i*p)+g*(n*d-i*u),t[14]=-(r*(s*v-c*p)-a*(n*v-i*p)+g*(n*c-i*s)),t[15]=r*(s*d-c*u)-a*(n*d-i*u)+f*(n*c-i*s),t}function mY(t){var e=t[0],r=t[1],n=t[2],i=t[3],o=t[4],a=t[5],s=t[6],c=t[7],l=t[8],f=t[9],u=t[10],d=t[11],h=t[12],g=t[13],p=t[14],v=t[15],y=e*a-r*o,m=e*s-n*o,w=e*c-i*o,x=r*s-n*a,C=r*c-i*a,S=n*c-i*s,T=l*g-f*h,_=l*p-u*h,E=l*v-d*h,b=f*p-u*g,D=f*v-d*g,I=u*v-d*p;return y*I-m*D+w*b+x*E-C*_+S*T}function yn(t,e,r){var n=e[0],i=e[1],o=e[2],a=e[3],s=e[4],c=e[5],l=e[6],f=e[7],u=e[8],d=e[9],h=e[10],g=e[11],p=e[12],v=e[13],y=e[14],m=e[15],w=r[0],x=r[1],C=r[2],S=r[3];return t[0]=w*n+x*s+C*u+S*p,t[1]=w*i+x*c+C*d+S*v,t[2]=w*o+x*l+C*h+S*y,t[3]=w*a+x*f+C*g+S*m,w=r[4],x=r[5],C=r[6],S=r[7],t[4]=w*n+x*s+C*u+S*p,t[5]=w*i+x*c+C*d+S*v,t[6]=w*o+x*l+C*h+S*y,t[7]=w*a+x*f+C*g+S*m,w=r[8],x=r[9],C=r[10],S=r[11],t[8]=w*n+x*s+C*u+S*p,t[9]=w*i+x*c+C*d+S*v,t[10]=w*o+x*l+C*h+S*y,t[11]=w*a+x*f+C*g+S*m,w=r[12],x=r[13],C=r[14],S=r[15],t[12]=w*n+x*s+C*u+S*p,t[13]=w*i+x*c+C*d+S*v,t[14]=w*o+x*l+C*h+S*y,t[15]=w*a+x*f+C*g+S*m,t}function er(t,e,r){var n=r[0],i=r[1],o=r[2],a,s,c,l,f,u,d,h,g,p,v,y;return e===t?(t[12]=e[0]*n+e[4]*i+e[8]*o+e[12],t[13]=e[1]*n+e[5]*i+e[9]*o+e[13],t[14]=e[2]*n+e[6]*i+e[10]*o+e[14],t[15]=e[3]*n+e[7]*i+e[11]*o+e[15]):(a=e[0],s=e[1],c=e[2],l=e[3],f=e[4],u=e[5],d=e[6],h=e[7],g=e[8],p=e[9],v=e[10],y=e[11],t[0]=a,t[1]=s,t[2]=c,t[3]=l,t[4]=f,t[5]=u,t[6]=d,t[7]=h,t[8]=g,t[9]=p,t[10]=v,t[11]=y,t[12]=a*n+f*i+g*o+e[12],t[13]=s*n+u*i+p*o+e[13],t[14]=c*n+d*i+v*o+e[14],t[15]=l*n+h*i+y*o+e[15]),t}function nl(t,e,r){var n=r[0],i=r[1],o=r[2];return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*i,t[5]=e[5]*i,t[6]=e[6]*i,t[7]=e[7]*i,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function To(t,e,r,n){var i=n[0],o=n[1],a=n[2],s=Math.hypot(i,o,a),c,l,f,u,d,h,g,p,v,y,m,w,x,C,S,T,_,E,b,D,I,P,O,L;return s<An?null:(s=1/s,i*=s,o*=s,a*=s,c=Math.sin(r),l=Math.cos(r),f=1-l,u=e[0],d=e[1],h=e[2],g=e[3],p=e[4],v=e[5],y=e[6],m=e[7],w=e[8],x=e[9],C=e[10],S=e[11],T=i*i*f+l,_=o*i*f+a*c,E=a*i*f-o*c,b=i*o*f-a*c,D=o*o*f+l,I=a*o*f+i*c,P=i*a*f+o*c,O=o*a*f-i*c,L=a*a*f+l,t[0]=u*T+p*_+w*E,t[1]=d*T+v*_+x*E,t[2]=h*T+y*_+C*E,t[3]=g*T+m*_+S*E,t[4]=u*b+p*D+w*I,t[5]=d*b+v*D+x*I,t[6]=h*b+y*D+C*I,t[7]=g*b+m*D+S*I,t[8]=u*P+p*O+w*L,t[9]=d*P+v*O+x*L,t[10]=h*P+y*O+C*L,t[11]=g*P+m*O+S*L,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function e4(t,e,r){var n=Math.sin(r),i=Math.cos(r),o=e[4],a=e[5],s=e[6],c=e[7],l=e[8],f=e[9],u=e[10],d=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=o*i+l*n,t[5]=a*i+f*n,t[6]=s*i+u*n,t[7]=c*i+d*n,t[8]=l*i-o*n,t[9]=f*i-a*n,t[10]=u*i-s*n,t[11]=d*i-c*n,t}function t4(t,e,r){var n=Math.sin(r),i=Math.cos(r),o=e[0],a=e[1],s=e[2],c=e[3],l=e[8],f=e[9],u=e[10],d=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*i-l*n,t[1]=a*i-f*n,t[2]=s*i-u*n,t[3]=c*i-d*n,t[8]=o*n+l*i,t[9]=a*n+f*i,t[10]=s*n+u*i,t[11]=c*n+d*i,t}function n4(t,e,r){var n=Math.sin(r),i=Math.cos(r),o=e[0],a=e[1],s=e[2],c=e[3],l=e[4],f=e[5],u=e[6],d=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*i+l*n,t[1]=a*i+f*n,t[2]=s*i+u*n,t[3]=c*i+d*n,t[4]=l*i-o*n,t[5]=f*i-a*n,t[6]=u*i-s*n,t[7]=d*i-c*n,t}function tm(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function r4(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function i4(t,e,r){var n=r[0],i=r[1],o=r[2],a=Math.hypot(n,i,o),s,c,l;return a<An?null:(a=1/a,n*=a,i*=a,o*=a,s=Math.sin(e),c=Math.cos(e),l=1-c,t[0]=n*n*l+c,t[1]=i*n*l+o*s,t[2]=o*n*l-i*s,t[3]=0,t[4]=n*i*l-o*s,t[5]=i*i*l+c,t[6]=o*i*l+n*s,t[7]=0,t[8]=n*o*l+i*s,t[9]=i*o*l-n*s,t[10]=o*o*l+c,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}function vY(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n,t[6]=r,t[7]=0,t[8]=0,t[9]=-r,t[10]=n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function yY(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=0,t[2]=-r,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=r,t[9]=0,t[10]=n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function wY(t,e){var r=Math.sin(e),n=Math.cos(e);return t[0]=n,t[1]=r,t[2]=0,t[3]=0,t[4]=-r,t[5]=n,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function FR(t,e,r){var n=e[0],i=e[1],o=e[2],a=e[3],s=n+n,c=i+i,l=o+o,f=n*s,u=n*c,d=n*l,h=i*c,g=i*l,p=o*l,v=a*s,y=a*c,m=a*l;return t[0]=1-(h+p),t[1]=u+m,t[2]=d-y,t[3]=0,t[4]=u-m,t[5]=1-(f+p),t[6]=g+v,t[7]=0,t[8]=d+y,t[9]=g-v,t[10]=1-(f+h),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function xY(t,e){var r=new Xr(3),n=-e[0],i=-e[1],o=-e[2],a=e[3],s=e[4],c=e[5],l=e[6],f=e[7],u=n*n+i*i+o*o+a*a;return u>0?(r[0]=(s*a+f*n+c*o-l*i)*2/u,r[1]=(c*a+f*i+l*n-s*o)*2/u,r[2]=(l*a+f*o+s*i-c*n)*2/u):(r[0]=(s*a+f*n+c*o-l*i)*2,r[1]=(c*a+f*i+l*n-s*o)*2,r[2]=(l*a+f*o+s*i-c*n)*2),FR(t,e,r),t}function CY(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function UR(t,e){var r=e[0],n=e[1],i=e[2],o=e[4],a=e[5],s=e[6],c=e[8],l=e[9],f=e[10];return t[0]=Math.hypot(r,n,i),t[1]=Math.hypot(o,a,s),t[2]=Math.hypot(c,l,f),t}function sS(t,e){var r=new Xr(3);UR(r,e);var n=1/r[0],i=1/r[1],o=1/r[2],a=e[0]*n,s=e[1]*i,c=e[2]*o,l=e[4]*n,f=e[5]*i,u=e[6]*o,d=e[8]*n,h=e[9]*i,g=e[10]*o,p=a+f+g,v=0;return p>0?(v=Math.sqrt(p+1)*2,t[3]=.25*v,t[0]=(u-h)/v,t[1]=(d-c)/v,t[2]=(s-l)/v):a>f&&a>g?(v=Math.sqrt(1+a-f-g)*2,t[3]=(u-h)/v,t[0]=.25*v,t[1]=(s+l)/v,t[2]=(d+c)/v):f>g?(v=Math.sqrt(1+f-a-g)*2,t[3]=(d-c)/v,t[0]=(s+l)/v,t[1]=.25*v,t[2]=(u+h)/v):(v=Math.sqrt(1+g-a-f)*2,t[3]=(s-l)/v,t[0]=(d+c)/v,t[1]=(u+h)/v,t[2]=.25*v),t}function BR(t,e,r,n){var i=e[0],o=e[1],a=e[2],s=e[3],c=i+i,l=o+o,f=a+a,u=i*c,d=i*l,h=i*f,g=o*l,p=o*f,v=a*f,y=s*c,m=s*l,w=s*f,x=n[0],C=n[1],S=n[2];return t[0]=(1-(g+v))*x,t[1]=(d+w)*x,t[2]=(h-m)*x,t[3]=0,t[4]=(d-w)*C,t[5]=(1-(u+v))*C,t[6]=(p+y)*C,t[7]=0,t[8]=(h+m)*S,t[9]=(p-y)*S,t[10]=(1-(u+g))*S,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function SY(t,e,r,n,i){var o=e[0],a=e[1],s=e[2],c=e[3],l=o+o,f=a+a,u=s+s,d=o*l,h=o*f,g=o*u,p=a*f,v=a*u,y=s*u,m=c*l,w=c*f,x=c*u,C=n[0],S=n[1],T=n[2],_=i[0],E=i[1],b=i[2],D=(1-(p+y))*C,I=(h+x)*C,P=(g-w)*C,O=(h-x)*S,L=(1-(d+y))*S,B=(v+m)*S,H=(g+w)*T,A=(v-m)*T,F=(1-(d+p))*T;return t[0]=D,t[1]=I,t[2]=P,t[3]=0,t[4]=O,t[5]=L,t[6]=B,t[7]=0,t[8]=H,t[9]=A,t[10]=F,t[11]=0,t[12]=r[0]+_-(D*_+O*E+H*b),t[13]=r[1]+E-(I*_+L*E+A*b),t[14]=r[2]+b-(P*_+B*E+F*b),t[15]=1,t}function xy(t,e){var r=e[0],n=e[1],i=e[2],o=e[3],a=r+r,s=n+n,c=i+i,l=r*a,f=n*a,u=n*s,d=i*a,h=i*s,g=i*c,p=o*a,v=o*s,y=o*c;return t[0]=1-u-g,t[1]=f+y,t[2]=d-v,t[3]=0,t[4]=f-y,t[5]=1-l-g,t[6]=h+p,t[7]=0,t[8]=d+v,t[9]=h-p,t[10]=1-l-u,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function TY(t,e,r,n,i,o,a){var s=1/(r-e),c=1/(i-n),l=1/(o-a);return t[0]=o*2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o*2*c,t[6]=0,t[7]=0,t[8]=(r+e)*s,t[9]=(i+n)*c,t[10]=(a+o)*l,t[11]=-1,t[12]=0,t[13]=0,t[14]=a*o*2*l,t[15]=0,t}function GR(t,e,r,n,i){var o=1/Math.tan(e/2),a;return t[0]=o/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,i!=null&&i!==1/0?(a=1/(n-i),t[10]=(i+n)*a,t[14]=2*i*n*a):(t[10]=-1,t[14]=-2*n),t}var _Y=GR;function EY(t,e,r,n,i){var o=1/Math.tan(e/2),a;return t[0]=o/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,i!=null&&i!==1/0?(a=1/(n-i),t[10]=i*a,t[14]=i*n*a):(t[10]=-1,t[14]=-n),t}function bY(t,e,r,n){var i=Math.tan(e.upDegrees*Math.PI/180),o=Math.tan(e.downDegrees*Math.PI/180),a=Math.tan(e.leftDegrees*Math.PI/180),s=Math.tan(e.rightDegrees*Math.PI/180),c=2/(a+s),l=2/(i+o);return t[0]=c,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=l,t[6]=0,t[7]=0,t[8]=-((a-s)*c*.5),t[9]=(i-o)*l*.5,t[10]=n/(r-n),t[11]=-1,t[12]=0,t[13]=0,t[14]=n*r/(r-n),t[15]=0,t}function WR(t,e,r,n,i,o,a){var s=1/(e-r),c=1/(n-i),l=1/(o-a);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*l,t[11]=0,t[12]=(e+r)*s,t[13]=(i+n)*c,t[14]=(a+o)*l,t[15]=1,t}var o4=WR;function DY(t,e,r,n,i,o,a){var s=1/(e-r),c=1/(n-i),l=1/(o-a);return t[0]=-2*s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=l,t[11]=0,t[12]=(e+r)*s,t[13]=(i+n)*c,t[14]=o*l,t[15]=1,t}function a4(t,e,r,n){var i,o,a,s,c,l,f,u,d,h,g=e[0],p=e[1],v=e[2],y=n[0],m=n[1],w=n[2],x=r[0],C=r[1],S=r[2];return Math.abs(g-x)<An&&Math.abs(p-C)<An&&Math.abs(v-S)<An?It(t):(f=g-x,u=p-C,d=v-S,h=1/Math.hypot(f,u,d),f*=h,u*=h,d*=h,i=m*d-w*u,o=w*f-y*d,a=y*u-m*f,h=Math.hypot(i,o,a),h?(h=1/h,i*=h,o*=h,a*=h):(i=0,o=0,a=0),s=u*a-d*o,c=d*i-f*a,l=f*o-u*i,h=Math.hypot(s,c,l),h?(h=1/h,s*=h,c*=h,l*=h):(s=0,c=0,l=0),t[0]=i,t[1]=s,t[2]=f,t[3]=0,t[4]=o,t[5]=c,t[6]=u,t[7]=0,t[8]=a,t[9]=l,t[10]=d,t[11]=0,t[12]=-(i*g+o*p+a*v),t[13]=-(s*g+c*p+l*v),t[14]=-(f*g+u*p+d*v),t[15]=1,t)}function IY(t,e,r,n){var i=e[0],o=e[1],a=e[2],s=n[0],c=n[1],l=n[2],f=i-r[0],u=o-r[1],d=a-r[2],h=f*f+u*u+d*d;h>0&&(h=1/Math.sqrt(h),f*=h,u*=h,d*=h);var g=c*d-l*u,p=l*f-s*d,v=s*u-c*f;return h=g*g+p*p+v*v,h>0&&(h=1/Math.sqrt(h),g*=h,p*=h,v*=h),t[0]=g,t[1]=p,t[2]=v,t[3]=0,t[4]=u*v-d*p,t[5]=d*g-f*v,t[6]=f*p-u*g,t[7]=0,t[8]=f,t[9]=u,t[10]=d,t[11]=0,t[12]=i,t[13]=o,t[14]=a,t[15]=1,t}function OY(t){return"mat4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+", "+t[9]+", "+t[10]+", "+t[11]+", "+t[12]+", "+t[13]+", "+t[14]+", "+t[15]+")"}function MY(t){return Math.hypot(t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8],t[9],t[10],t[11],t[12],t[13],t[14],t[15])}function PY(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t[9]=e[9]+r[9],t[10]=e[10]+r[10],t[11]=e[11]+r[11],t[12]=e[12]+r[12],t[13]=e[13]+r[13],t[14]=e[14]+r[14],t[15]=e[15]+r[15],t}function zR(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t[9]=e[9]-r[9],t[10]=e[10]-r[10],t[11]=e[11]-r[11],t[12]=e[12]-r[12],t[13]=e[13]-r[13],t[14]=e[14]-r[14],t[15]=e[15]-r[15],t}function $R(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t[9]=e[9]*r,t[10]=e[10]*r,t[11]=e[11]*r,t[12]=e[12]*r,t[13]=e[13]*r,t[14]=e[14]*r,t[15]=e[15]*r,t}function RY(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t[3]=e[3]+r[3]*n,t[4]=e[4]+r[4]*n,t[5]=e[5]+r[5]*n,t[6]=e[6]+r[6]*n,t[7]=e[7]+r[7]*n,t[8]=e[8]+r[8]*n,t[9]=e[9]+r[9]*n,t[10]=e[10]+r[10]*n,t[11]=e[11]+r[11]*n,t[12]=e[12]+r[12]*n,t[13]=e[13]+r[13]*n,t[14]=e[14]+r[14]*n,t[15]=e[15]+r[15]*n,t}function LY(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}function AY(t,e){var r=t[0],n=t[1],i=t[2],o=t[3],a=t[4],s=t[5],c=t[6],l=t[7],f=t[8],u=t[9],d=t[10],h=t[11],g=t[12],p=t[13],v=t[14],y=t[15],m=e[0],w=e[1],x=e[2],C=e[3],S=e[4],T=e[5],_=e[6],E=e[7],b=e[8],D=e[9],I=e[10],P=e[11],O=e[12],L=e[13],B=e[14],H=e[15];return Math.abs(r-m)<=An*Math.max(1,Math.abs(r),Math.abs(m))&&Math.abs(n-w)<=An*Math.max(1,Math.abs(n),Math.abs(w))&&Math.abs(i-x)<=An*Math.max(1,Math.abs(i),Math.abs(x))&&Math.abs(o-C)<=An*Math.max(1,Math.abs(o),Math.abs(C))&&Math.abs(a-S)<=An*Math.max(1,Math.abs(a),Math.abs(S))&&Math.abs(s-T)<=An*Math.max(1,Math.abs(s),Math.abs(T))&&Math.abs(c-_)<=An*Math.max(1,Math.abs(c),Math.abs(_))&&Math.abs(l-E)<=An*Math.max(1,Math.abs(l),Math.abs(E))&&Math.abs(f-b)<=An*Math.max(1,Math.abs(f),Math.abs(b))&&Math.abs(u-D)<=An*Math.max(1,Math.abs(u),Math.abs(D))&&Math.abs(d-I)<=An*Math.max(1,Math.abs(d),Math.abs(I))&&Math.abs(h-P)<=An*Math.max(1,Math.abs(h),Math.abs(P))&&Math.abs(g-O)<=An*Math.max(1,Math.abs(g),Math.abs(O))&&Math.abs(p-L)<=An*Math.max(1,Math.abs(p),Math.abs(L))&&Math.abs(v-B)<=An*Math.max(1,Math.abs(v),Math.abs(B))&&Math.abs(y-H)<=An*Math.max(1,Math.abs(y),Math.abs(H))}var Cy=yn,NY=zR;const s1=Object.freeze(Object.defineProperty({__proto__:null,add:PY,adjoint:pY,clone:hY,copy:Cr,create:ma,determinant:mY,equals:AY,exactEquals:LY,frob:MY,fromQuat:xy,fromQuat2:xY,fromRotation:i4,fromRotationTranslation:FR,fromRotationTranslationScale:BR,fromRotationTranslationScaleOrigin:SY,fromScaling:r4,fromTranslation:tm,fromValues:Q_,fromXRotation:vY,fromYRotation:yY,fromZRotation:wY,frustum:TY,getRotation:sS,getScaling:UR,getTranslation:CY,identity:It,invert:Ar,lookAt:a4,mul:Cy,multiply:yn,multiplyScalar:$R,multiplyScalarAndAdd:RY,ortho:o4,orthoNO:WR,orthoZO:DY,perspective:_Y,perspectiveFromFieldOfView:bY,perspectiveNO:GR,perspectiveZO:EY,rotate:To,rotateX:e4,rotateY:t4,rotateZ:n4,scale:nl,set:gY,str:OY,sub:NY,subtract:zR,targetTo:IY,translate:er,transpose:un},Symbol.toStringTag,{value:"Module"}));function Ke(){var t=new Xr(3);return Xr!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function jR(t){var e=new Xr(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function Ko(t){var e=t[0],r=t[1],n=t[2];return Math.hypot(e,r,n)}function Tt(t,e,r){var n=new Xr(3);return n[0]=t,n[1]=e,n[2]=r,n}function kY(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Wn(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t}function Hr(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function Nn(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function VY(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function FY(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function UY(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t}function BY(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t}function GY(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t}function gr(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function dn(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t[2]=e[2]+r[2]*n,t}function Fi(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return Math.hypot(r,n,i)}function HR(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return r*r+n*n+i*i}function qc(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function KR(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t}function Un(t,e){var r=e[0],n=e[1],i=e[2],o=r*r+n*n+i*i;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t}function xt(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Tn(t,e,r){var n=e[0],i=e[1],o=e[2],a=r[0],s=r[1],c=r[2];return t[0]=i*c-o*s,t[1]=o*a-n*c,t[2]=n*s-i*a,t}function At(t,e,r){var n=e[0],i=e[1],o=e[2],a=r[3]*n+r[7]*i+r[11]*o+r[15];return a=a||1,t[0]=(r[0]*n+r[4]*i+r[8]*o+r[12])/a,t[1]=(r[1]*n+r[5]*i+r[9]*o+r[13])/a,t[2]=(r[2]*n+r[6]*i+r[10]*o+r[14])/a,t}function Cv(t,e,r){var n=e[0],i=e[1],o=e[2];return t[0]=n*r[0]+i*r[3]+o*r[6],t[1]=n*r[1]+i*r[4]+o*r[7],t[2]=n*r[2]+i*r[5]+o*r[8],t}function WY(t,e,r){var n=r[0],i=r[1],o=r[2],a=r[3],s=e[0],c=e[1],l=e[2],f=i*l-o*c,u=o*s-n*l,d=n*c-i*s,h=i*d-o*u,g=o*f-n*d,p=n*u-i*f,v=a*2;return f*=v,u*=v,d*=v,h*=2,g*=2,p*=2,t[0]=s+f+h,t[1]=c+u+g,t[2]=l+d+p,t}function s4(t,e){var r=t[0],n=t[1],i=t[2],o=e[0],a=e[1],s=e[2],c=Math.sqrt(r*r+n*n+i*i),l=Math.sqrt(o*o+a*a+s*s),f=c*l,u=f&&xt(t,e)/f;return Math.acos(Math.min(Math.max(u,-1),1))}function zY(t){return t[0]=0,t[1]=0,t[2]=0,t}function j6(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function cS(t,e){var r=t[0],n=t[1],i=t[2],o=e[0],a=e[1],s=e[2];return Math.abs(r-o)<=An*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(n-a)<=An*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(i-s)<=An*Math.max(1,Math.abs(i),Math.abs(s))}var hn=Nn,$Y=VY,lS=HR,wh=Ko;(function(){var t=Ke();return function(e,r,n,i,o,a){var s,c;for(r||(r=3),n||(n=0),i?c=Math.min(i*r+n,e.length):c=e.length,s=n;s<c;s+=r)t[0]=e[s],t[1]=e[s+1],t[2]=e[s+2],o(t,t,a),e[s]=t[0],e[s+1]=t[1],e[s+2]=t[2];return e}})();function qR(){var t=new Xr(4);return Xr!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function Sv(t,e,r,n){var i=new Xr(4);return i[0]=t,i[1]=e,i[2]=r,i[3]=n,i}function H6(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}function jY(t,e){var r=e[0],n=e[1],i=e[2],o=e[3],a=r*r+n*n+i*i+o*o;return a>0&&(a=1/Math.sqrt(a)),t[0]=r*a,t[1]=n*a,t[2]=i*a,t[3]=o*a,t}function K6(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function Vu(t,e,r){var n=e[0],i=e[1],o=e[2],a=e[3];return t[0]=r[0]*n+r[4]*i+r[8]*o+r[12]*a,t[1]=r[1]*n+r[5]*i+r[9]*o+r[13]*a,t[2]=r[2]*n+r[6]*i+r[10]*o+r[14]*a,t[3]=r[3]*n+r[7]*i+r[11]*o+r[15]*a,t}(function(){var t=qR();return function(e,r,n,i,o,a){var s,c;for(r||(r=4),n||(n=0),i?c=Math.min(i*r+n,e.length):c=e.length,s=n;s<c;s+=r)t[0]=e[s],t[1]=e[s+1],t[2]=e[s+2],t[3]=e[s+3],o(t,t,a),e[s]=t[0],e[s+1]=t[1],e[s+2]=t[2],e[s+3]=t[3];return e}})();function sf(){var t=new Xr(4);return Xr!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function nw(t,e,r){r=r*.5;var n=Math.sin(r);return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(r),t}function HY(t,e){var r=Math.acos(e[3])*2,n=Math.sin(r/2);return n>An?(t[0]=e[0]/n,t[1]=e[1]/n,t[2]=e[2]/n):(t[0]=1,t[1]=0,t[2]=0),r}function q6(t,e,r){var n=e[0],i=e[1],o=e[2],a=e[3],s=r[0],c=r[1],l=r[2],f=r[3];return t[0]=n*f+a*s+i*l-o*c,t[1]=i*f+a*c+o*s-n*l,t[2]=o*f+a*l+n*c-i*s,t[3]=a*f-n*s-i*c-o*l,t}function Tv(t,e,r,n){var i=e[0],o=e[1],a=e[2],s=e[3],c=r[0],l=r[1],f=r[2],u=r[3],d,h,g,p,v;return h=i*c+o*l+a*f+s*u,h<0&&(h=-h,c=-c,l=-l,f=-f,u=-u),1-h>An?(d=Math.acos(h),g=Math.sin(d),p=Math.sin((1-n)*d)/g,v=Math.sin(n*d)/g):(p=1-n,v=n),t[0]=p*i+v*c,t[1]=p*o+v*l,t[2]=p*a+v*f,t[3]=p*s+v*u,t}function KY(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t}function qY(t,e){var r=e[0]+e[4]+e[8],n;if(r>0)n=Math.sqrt(r+1),t[3]=.5*n,n=.5/n,t[0]=(e[5]-e[7])*n,t[1]=(e[6]-e[2])*n,t[2]=(e[1]-e[3])*n;else{var i=0;e[4]>e[0]&&(i=1),e[8]>e[i*3+i]&&(i=2);var o=(i+1)%3,a=(i+2)%3;n=Math.sqrt(e[i*3+i]-e[o*3+o]-e[a*3+a]+1),t[i]=.5*n,n=.5/n,t[3]=(e[o*3+a]-e[a*3+o])*n,t[o]=(e[o*3+i]+e[i*3+o])*n,t[a]=(e[a*3+i]+e[i*3+a])*n}return t}var X6=Sv,XR=jY;(function(){var t=Ke(),e=Tt(1,0,0),r=Tt(0,1,0);return function(n,i,o){var a=xt(i,o);return a<-.999999?(Tn(t,e,i),wh(t)<1e-6&&Tn(t,r,i),Un(t,t),nw(n,t,Math.PI),n):a>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(Tn(t,i,o),n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=1+a,XR(n,n))}})();(function(){var t=sf(),e=sf();return function(r,n,i,o,a,s){return Tv(t,n,a,s),Tv(e,i,o,s),Tv(r,t,e,2*s*(1-s)),r}})();(function(){var t=J_();return function(e,r,n,i){return t[0]=n[0],t[3]=n[1],t[6]=n[2],t[1]=i[0],t[4]=i[1],t[7]=i[2],t[2]=-r[0],t[5]=-r[1],t[8]=-r[2],XR(e,qY(e,t))}})();function Wt(){var t=new Xr(2);return Xr!=Float32Array&&(t[0]=0,t[1]=0),t}function e2(t){var e=new Xr(2);return e[0]=t[0],e[1]=t[1],e}function Y6(t,e){var r=new Xr(2);return r[0]=t,r[1]=e,r}function fs(t,e,r){return t[0]=e,t[1]=r,t}function no(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t}function Br(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t}function Al(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t}function XY(t,e,r,n){return t[0]=e[0]+r[0]*n,t[1]=e[1]+r[1]*n,t}function ur(t,e){var r=e[0]-t[0],n=e[1]-t[1];return Math.hypot(r,n)}function Sy(t){var e=t[0],r=t[1];return Math.hypot(e,r)}function Ul(t,e){var r=e[0],n=e[1],i=r*r+n*n;return i>0&&(i=1/Math.sqrt(i)),t[0]=e[0]*i,t[1]=e[1]*i,t}function c4(t,e){return t[0]*e[0]+t[1]*e[1]}function YY(t,e,r,n){var i=e[0]-r[0],o=e[1]-r[1],a=Math.sin(n),s=Math.cos(n);return t[0]=i*s-o*a+r[0],t[1]=i*a+o*s+r[1],t}function JY(t,e){var r=t[0],n=t[1],i=e[0],o=e[1],a=Math.sqrt(r*r+n*n)*Math.sqrt(i*i+o*o),s=a&&(r*i+n*o)/a;return Math.acos(Math.min(Math.max(s,-1),1))}var ZY=Sy,ps=Br,l4=ur;(function(){var t=Wt();return function(e,r,n,i,o,a){var s,c;for(r||(r=2),n||(n=0),i?c=Math.min(i*r+n,e.length):c=e.length,s=n;s<c;s+=r)t[0]=e[s],t[1]=e[s+1],o(t,t,a),e[s]=t[0],e[s+1]=t[1];return e}})();const jl={ARRAY_BUFFER:0,ELEMENT_ARRAY_BUFFER:1,TEXTURE_BUFFER:2};var YR={ObjectType:jl};const{ObjectType:_v}=YR,QY={};function eJ(t,e){e.classHierarchy.push("vtkOpenGLBufferObject");function r(s){switch(s){case _v.ELEMENT_ARRAY_BUFFER:return e.context.ELEMENT_ARRAY_BUFFER;case _v.TEXTURE_BUFFER:if("TEXTURE_BUFFER"in e.context)return e.context.TEXTURE_BUFFER;case _v.ARRAY_BUFFER:default:return e.context.ARRAY_BUFFER}}let n=null,i=null,o=!0,a="";t.getType=()=>n,t.setType=s=>{n=s},t.getHandle=()=>i,t.isReady=()=>o===!1,t.generateBuffer=s=>{const c=r(s);return i===null&&(i=e.context.createBuffer(),n=s),r(n)===c},t.upload=(s,c)=>t.generateBuffer(c)?(e.context.bindBuffer(r(n),i),e.context.bufferData(r(n),s,e.context.STATIC_DRAW),e.allocatedGPUMemoryInBytes=s.length*s.BYTES_PER_ELEMENT,o=!1,!0):(a="Trying to upload array buffer to incompatible buffer.",!1),t.bind=()=>i?(e.context.bindBuffer(r(n),i),!0):!1,t.release=()=>i?(e.context.bindBuffer(r(n),null),!0):!1,t.releaseGraphicsResources=()=>{i!==null&&(e.context.bindBuffer(r(n),null),e.context.deleteBuffer(i),i=null,e.allocatedGPUMemoryInBytes=0)},t.setOpenGLRenderWindow=s=>{e._openGLRenderWindow!==s&&(t.releaseGraphicsResources(),e._openGLRenderWindow=s,e.context=null,s&&(e.context=e._openGLRenderWindow.getContext()))},t.getError=()=>a}const tJ={objectType:_v.ARRAY_BUFFER,context:null,allocatedGPUMemoryInBytes:0};function JR(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,tJ,r),Z.obj(t,e),Z.get(t,e,["_openGLRenderWindow","allocatedGPUMemoryInBytes"]),Z.moveToProtected(t,e,["openGLRenderWindow"]),eJ(t,e)}const nJ=Z.newInstance(JR);var Bl={newInstance:nJ,extend:JR,...QY,...YR};const ZR={FLAT:0,GOURAUD:1,PHONG:2},ao={POINTS:0,WIREFRAME:1,SURFACE:2},rJ=ZR;var QR={Shading:ZR,Representation:ao,Interpolation:rJ};const{vtkErrorMacro:J6}=Z;function iJ(t,e){const r=new Float64Array(3);KR(r,e);const n=new Float64Array(16);return BR(n,sf(),t,r),n}function oJ(t,e){return t===null||e===null?!1:!(j6(t,[0,0,0])&&j6(e,[1,1,1]))}function aJ(t,e){e.classHierarchy.push("vtkOpenGLCellArrayBufferObject"),t.setType(jl.ARRAY_BUFFER),t.createVBO=function(r,n,i,o){let a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:null;if(!r.getData()||!r.getData().length)return e.elementCount=0,0;e.blockSize=3,e.vertexOffset=0,e.normalOffset=0,e.tCoordOffset=0,e.tCoordComponents=0,e.colorComponents=0,e.colorOffset=0,e.customData=[];const s=o.points.getData();let c=null,l=null,f=null;const u=o.colors?o.colors.getNumberOfComponents():0,d=o.tcoords?o.tcoords.getNumberOfComponents():0;o.normals&&(e.normalOffset=4*e.blockSize,e.blockSize+=3,c=o.normals.getData()),o.customAttributes&&o.customAttributes.forEach(F=>{F&&(e.customData.push({data:F.getData(),offset:4*e.blockSize,components:F.getNumberOfComponents(),name:F.getName()}),e.blockSize+=F.getNumberOfComponents())}),o.tcoords&&(e.tCoordOffset=4*e.blockSize,e.tCoordComponents=d,e.blockSize+=d,l=o.tcoords.getData()),o.colors?(e.colorComponents=o.colors.getNumberOfComponents(),e.colorOffset=0,f=o.colors.getData(),e.colorBO||(e.colorBO=Bl.newInstance()),e.colorBO.setOpenGLRenderWindow(e._openGLRenderWindow)):e.colorBO=null,e.stride=4*e.blockSize;let h=0,g=0,p=0,v=0,y=0,m=0,w;const x={anythingToPoints(F,G,X,ee){for(let ce=0;ce<F;++ce)w(G[X+ce],ee)},linesToWireframe(F,G,X,ee){for(let ce=0;ce<F-1;++ce)w(G[X+ce],ee),w(G[X+ce+1],ee)},polysToWireframe(F,G,X,ee){if(F>2)for(let ce=0;ce<F;++ce)w(G[X+ce],ee),w(G[X+(ce+1)%F],ee)},stripsToWireframe(F,G,X,ee){if(F>2){for(let ce=0;ce<F-1;++ce)w(G[X+ce],ee),w(G[X+ce+1],ee);for(let ce=0;ce<F-2;ce++)w(G[X+ce],ee),w(G[X+ce+2],ee)}},polysToSurface(F,G,X,ee){for(let ce=0;ce<F-2;ce++)w(G[X+0],ee),w(G[X+ce+1],ee),w(G[X+ce+2],ee)},stripsToSurface(F,G,X,ee){for(let ce=0;ce<F-2;ce++)w(G[X+ce],ee),w(G[X+ce+1+ce%2],ee),w(G[X+ce+1+(ce+1)%2],ee)}},C={anythingToPoints(F,G){return F},linesToWireframe(F,G){return F>1?(F-1)*2:0},polysToWireframe(F,G){return F>2?F*2:0},stripsToWireframe(F,G){return F>2?F*4-6:0},polysToSurface(F,G){return F>2?(F-2)*3:0},stripsToSurface(F,G,X){return F>2?(F-2)*3:0}};let S=null,T=null;i===ao.POINTS||n==="verts"?(S=x.anythingToPoints,T=C.anythingToPoints):i===ao.WIREFRAME||n==="lines"?(S=x[`${n}ToWireframe`],T=C[`${n}ToWireframe`]):(S=x[`${n}ToSurface`],T=C[`${n}ToSurface`]);const _=r.getData(),E=_.length;let b=0;for(let F=0;F<E;)b+=T(_[F],_),F+=_[F]+1;let D=null;const I=new Float32Array(b*e.blockSize);f&&(D=new Uint8Array(b*4));let P=0,O=0,L=0,B=0;for(let F=0;F<3;++F){const G=o.points.getRange(F),X=G[1]-G[0];L+=X*X;const ee=.5*(G[1]+G[0]);B+=ee*ee}if(L>0&&(Math.abs(B)/L>1e6||Math.abs(Math.log10(L))>3||L===0&&B>1e6)){const F=new Float64Array(3),G=new Float64Array(3);for(let X=0;X<3;++X){const ee=o.points.getRange(X),ce=ee[1]-ee[0];F[X]=.5*(ee[1]+ee[0]),G[X]=ce>0?1/ce:1}t.setCoordShiftAndScale(F,G)}else e.coordShiftAndScaleEnabled===!0&&t.setCoordShiftAndScale(null,null);if(a)if(!a.points&&!a.cells)a.points=new Int32Array(b),a.cells=new Int32Array(b);else{const F=new Int32Array(b+a.points.length);F.set(a.points),a.points=F;const G=new Int32Array(b+a.cells.length);G.set(a.cells),a.cells=G}let A=o.vertexOffset;w=function(G,X){if(a&&(a.points[A]=G,a.cells[A]=m+o.cellOffset),++A,h=G*3,e.coordShiftAndScaleEnabled?(I[P++]=(s[h++]-e.coordShift[0])*e.coordScale[0],I[P++]=(s[h++]-e.coordShift[1])*e.coordScale[1],I[P++]=(s[h++]-e.coordShift[2])*e.coordScale[2]):(I[P++]=s[h++],I[P++]=s[h++],I[P++]=s[h++]),c!==null&&(o.haveCellNormals?g=(m+o.cellOffset)*3:g=G*3,I[P++]=c[g++],I[P++]=c[g++],I[P++]=c[g++]),e.customData.forEach(ee=>{y=G*ee.components;for(let ce=0;ce<ee.components;++ce)I[P++]=ee.data[y++]}),l!==null){o.useTCoordsPerCell?p=X*d:p=G*d;for(let ee=0;ee<d;++ee)I[P++]=l[p++]}f!==null&&(o.haveCellScalars?v=(m+o.cellOffset)*u:v=G*u,D[O++]=f[v++],D[O++]=f[v++],D[O++]=f[v++],D[O++]=u===4?f[v++]:255)};for(let F=0;F<E;F+=_[F]+1,m++)S(_[F],_,F+1,m+o.cellOffset);return e.elementCount=b,t.upload(I,jl.ARRAY_BUFFER),e.colorBO&&(e.colorBOStride=4,e.colorBO.upload(D,jl.ARRAY_BUFFER)),m},t.setCoordShiftAndScale=(r,n)=>{if(r!==null&&(r.constructor!==Float64Array||r.length!==3)){J6("Wrong type for coordShift, expected vec3 or null");return}if(n!==null&&(n.constructor!==Float64Array||n.length!==3)){J6("Wrong type for coordScale, expected vec3 or null");return}(e.coordShift===null||r===null||!cS(r,e.coordShift))&&(e.coordShift=r),(e.coordScale===null||n===null||!cS(n,e.coordScale))&&(e.coordScale=n),e.coordShiftAndScaleEnabled=oJ(e.coordShift,e.coordScale),e.coordShiftAndScaleEnabled?e.inverseShiftAndScaleMatrix=iJ(e.coordShift,e.coordScale):e.inverseShiftAndScaleMatrix=null}}const sJ={elementCount:0,stride:0,colorBOStride:0,vertexOffset:0,normalOffset:0,tCoordOffset:0,tCoordComponents:0,colorOffset:0,colorComponents:0,tcoordBO:null,customData:[],coordShift:null,coordScale:null,coordShiftAndScaleEnabled:!1,inverseShiftAndScaleMatrix:null};function eL(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,sJ,r),Bl.extend(t,e,r),Z.setGet(t,e,["colorBO","elementCount","stride","colorBOStride","vertexOffset","normalOffset","tCoordOffset","tCoordComponents","colorOffset","colorComponents","customData"]),Z.get(t,e,["coordShift","coordScale","coordShiftAndScaleEnabled","inverseShiftAndScaleMatrix"]),aJ(t,e)}const cJ=Z.newInstance(eL);var lJ={newInstance:cJ,extend:eL};const{vtkErrorMacro:uJ}=Z;function fJ(t,e){e.classHierarchy.push("vtkShader"),t.compile=()=>{let r=e.context.VERTEX_SHADER;if(!e.source||!e.source.length||e.shaderType==="Unknown")return!1;switch(e.handle!==0&&(e.context.deleteShader(e.handle),e.handle=0),e.shaderType){case"Fragment":r=e.context.FRAGMENT_SHADER;break;case"Vertex":default:r=e.context.VERTEX_SHADER;break}if(e.handle=e.context.createShader(r),e.context.shaderSource(e.handle,e.source),e.context.compileShader(e.handle),!e.context.getShaderParameter(e.handle,e.context.COMPILE_STATUS)){const i=e.context.getShaderInfoLog(e.handle);return uJ(`Error compiling shader '${e.source}': ${i}`),e.context.deleteShader(e.handle),e.handle=0,!1}return!0},t.cleanup=()=>{e.shaderType==="Unknown"||e.handle===0||(e.context.deleteShader(e.handle),e.handle=0,e.dirty=!0)}}const dJ={shaderType:"Unknown",source:"",error:"",handle:0,dirty:!1,context:null};function tL(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,dJ,r),Z.obj(t,e),Z.setGet(t,e,["shaderType","source","error","handle","context"]),fJ(t,e)}const hJ=Z.newInstance(tL,"vtkShader");var Ux={newInstance:hJ,extend:tL};const{vtkErrorMacro:Pc}=Z;function gJ(t,e,r,n){const i=typeof r=="string"?r:r.join(`
|
||
`),o=n===!1?e:new RegExp(e,"g"),a=t.replace(o,i);return{replace:a!==i,result:a}}function pJ(t,e){e.classHierarchy.push("vtkShaderProgram"),t.compileShader=()=>e.vertexShader.compile()?e.fragmentShader.compile()?!t.attachShader(e.vertexShader)||!t.attachShader(e.fragmentShader)?(Pc(e.error),0):t.link()?(t.setCompiled(!0),1):(Pc(`Links failed: ${e.error}`),0):(Pc(e.fragmentShader.getSource().split(`
|
||
`).map((r,n)=>`${n}: ${r}`).join(`
|
||
`)),Pc(e.fragmentShader.getError()),0):(Pc(e.vertexShader.getSource().split(`
|
||
`).map((r,n)=>`${n}: ${r}`).join(`
|
||
`)),Pc(e.vertexShader.getError()),0),t.cleanup=()=>{e.shaderType==="Unknown"||e.handle===0||(t.release(),e.vertexShaderHandle!==0&&(e.context.detachShader(e.handle,e.vertexShaderHandle),e.vertexShaderHandle=0),e.fragmentShaderHandle!==0&&(e.context.detachShader(e.handle,e.fragmentShaderHandle),e.fragmentShaderHandle=0),e.context.deleteProgram(e.handle),e.handle=0,t.setCompiled(!1))},t.bind=()=>!e.linked&&!t.link()?!1:(e.context.useProgram(e.handle),t.setBound(!0),!0),t.isBound=()=>!!e.bound,t.release=()=>{e.context.useProgram(null),t.setBound(!1)},t.setContext=r=>{e.vertexShader.setContext(r),e.fragmentShader.setContext(r),e.geometryShader.setContext(r)},t.link=()=>{if(e.linked)return!0;if(e.handle===0)return e.error="Program has not been initialized, and/or does not have shaders.",!1;if(e.uniformLocs={},e.context.linkProgram(e.handle),!e.context.getProgramParameter(e.handle,e.context.LINK_STATUS)){const n=e.context.getProgramInfoLog(e.handle);return Pc(`Error linking shader ${n}`),e.handle=0,!1}return t.setLinked(!0),e.attributeLocs={},!0},t.setUniformMatrix=(r,n)=>{const i=t.findUniform(r);if(i===-1)return e.error=`Could not set uniform ${r} . No such uniform.`,!1;const o=new Float32Array(n);return e.context.uniformMatrix4fv(i,!1,o),!0},t.setUniformMatrix3x3=(r,n)=>{const i=t.findUniform(r);if(i===-1)return e.error=`Could not set uniform ${r} . No such uniform.`,!1;const o=new Float32Array(n);return e.context.uniformMatrix3fv(i,!1,o),!0},t.setUniformf=(r,n)=>{const i=t.findUniform(r);return i===-1?(e.error=`Could not set uniform ${r} . No such uniform.`,!1):(e.context.uniform1f(i,n),!0)},t.setUniformfv=(r,n)=>{const i=t.findUniform(r);return i===-1?(e.error=`Could not set uniform ${r} . No such uniform.`,!1):(e.context.uniform1fv(i,n),!0)},t.setUniformi=(r,n)=>{const i=t.findUniform(r);return i===-1?(e.error=`Could not set uniform ${r} . No such uniform.`,!1):(e.context.uniform1i(i,n),!0)},t.setUniformiv=(r,n)=>{const i=t.findUniform(r);return i===-1?(e.error=`Could not set uniform ${r} . No such uniform.`,!1):(e.context.uniform1iv(i,n),!0)},t.setUniform2f=(r,n,i)=>{const o=t.findUniform(r);if(o===-1)return e.error=`Could not set uniform ${r} . No such uniform.`,!1;if(i===void 0)throw new RangeError("Invalid number of values for array");return e.context.uniform2f(o,n,i),!0},t.setUniform2fv=(r,n)=>{const i=t.findUniform(r);return i===-1?(e.error=`Could not set uniform ${r} . No such uniform.`,!1):(e.context.uniform2fv(i,n),!0)},t.setUniform2i=(r,n,i)=>{const o=t.findUniform(r);if(o===-1)return e.error=`Could not set uniform ${r} . No such uniform.`,!1;if(i===void 0)throw new RangeError("Invalid number of values for array");return e.context.uniform2i(o,n,i),!0},t.setUniform2iv=(r,n)=>{const i=t.findUniform(r);return i===-1?(e.error=`Could not set uniform ${r} . No such uniform.`,!1):(e.context.uniform2iv(i,n),!0)},t.setUniform3f=(r,n,i,o)=>{const a=t.findUniform(r);if(a===-1)return e.error=`Could not set uniform ${r} . No such uniform.`,!1;if(o===void 0)throw new RangeError("Invalid number of values for array");return e.context.uniform3f(a,n,i,o),!0},t.setUniform3fArray=(r,n)=>{const i=t.findUniform(r);if(i===-1)return e.error=`Could not set uniform ${r} . No such uniform.`,!1;if(!Array.isArray(n)||n.length!==3)throw new RangeError("Invalid number of values for array");return e.context.uniform3f(i,n[0],n[1],n[2]),!0},t.setUniform3fv=(r,n)=>{const i=t.findUniform(r);return i===-1?(e.error=`Could not set uniform ${r} . No such uniform.`,!1):(e.context.uniform3fv(i,n),!0)},t.setUniform3i=function(r){const n=t.findUniform(r);if(n===-1)return e.error=`Could not set uniform ${r} . No such uniform.`,!1;for(var i=arguments.length,o=new Array(i>1?i-1:0),a=1;a<i;a++)o[a-1]=arguments[a];let s=o;if(s.length===1&&Array.isArray(s[0])&&(s=s[0]),s.length!==3)throw new RangeError("Invalid number of values for array");return e.context.uniform3i(n,s[0],s[1],s[2]),!0},t.setUniform3iv=(r,n)=>{const i=t.findUniform(r);return i===-1?(e.error=`Could not set uniform ${r} . No such uniform.`,!1):(e.context.uniform3iv(i,n),!0)},t.setUniform4f=function(r){const n=t.findUniform(r);if(n===-1)return e.error=`Could not set uniform ${r} . No such uniform.`,!1;for(var i=arguments.length,o=new Array(i>1?i-1:0),a=1;a<i;a++)o[a-1]=arguments[a];let s=o;if(s.length===1&&Array.isArray(s[0])&&(s=s[0]),s.length!==4)throw new RangeError("Invalid number of values for array");return e.context.uniform4f(n,s[0],s[1],s[2],s[3]),!0},t.setUniform4fv=(r,n)=>{const i=t.findUniform(r);return i===-1?(e.error=`Could not set uniform ${r} . No such uniform.`,!1):(e.context.uniform4fv(i,n),!0)},t.setUniform4i=function(r){const n=t.findUniform(r);if(n===-1)return e.error=`Could not set uniform ${r} . No such uniform.`,!1;for(var i=arguments.length,o=new Array(i>1?i-1:0),a=1;a<i;a++)o[a-1]=arguments[a];let s=o;if(s.length===1&&Array.isArray(s[0])&&(s=s[0]),s.length!==4)throw new RangeError("Invalid number of values for array");return e.context.uniform4i(n,s[0],s[1],s[2],s[3]),!0},t.setUniform4iv=(r,n)=>{const i=t.findUniform(r);return i===-1?(e.error=`Could not set uniform ${r} . No such uniform.`,!1):(e.context.uniform4iv(i,n),!0)},t.findUniform=r=>{if(!r||!e.linked)return-1;let n=e.uniformLocs[r];return n!==void 0?n:(n=e.context.getUniformLocation(e.handle,r),n===null?(e.error=`Uniform ${r} not found in current shader program.`,e.uniformLocs[r]=-1,-1):(e.uniformLocs[r]=n,n))},t.isUniformUsed=r=>{if(!r)return!1;let n=e.uniformLocs[r];return n!==void 0?n!==null:e.linked?(n=e.context.getUniformLocation(e.handle,r),e.uniformLocs[r]=n,n!==null):(Pc("attempt to find uniform when the shader program is not linked"),!1)},t.isAttributeUsed=r=>{if(!r)return!1;if(r in e.attributeLocs)return!0;if(!e.linked)return Pc("attempt to find uniform when the shader program is not linked"),!1;const n=e.context.getAttribLocation(e.handle,r);return n===-1?!1:(e.attributeLocs[r]=n,!0)},t.attachShader=r=>{if(r.getHandle()===0)return e.error="Shader object was not initialized, cannot attach it.",!1;if(r.getShaderType()==="Unknown")return e.error="Shader object is of type Unknown and cannot be used.",!1;if(e.handle===0){const n=e.context.createProgram();if(n===0)return e.error="Could not create shader program.",!1;e.handle=n,e.linked=!1}return r.getShaderType()==="Vertex"&&(e.vertexShaderHandle!==0&&e.context.detachShader(e.handle,e.vertexShaderHandle),e.vertexShaderHandle=r.getHandle()),r.getShaderType()==="Fragment"&&(e.fragmentShaderHandle!==0&&e.context.detachShader(e.handle,e.fragmentShaderHandle),e.fragmentShaderHandle=r.getHandle()),e.context.attachShader(e.handle,r.getHandle()),t.setLinked(!1),!0},t.detachShader=r=>{if(r.getHandle()===0)return e.error="shader object was not initialized, cannot attach it.",!1;if(r.getShaderType()==="Unknown")return e.error="Shader object is of type Unknown and cannot be used.",!1;switch(e.handle===0&&(e.error="This shader program has not been initialized yet."),r.getShaderType()){case"Vertex":return e.vertexShaderHandle!==r.getHandle()?(e.error="The supplied shader was not attached to this program.",!1):(e.context.detachShader(e.handle,r.getHandle()),e.vertexShaderHandle=0,e.linked=!1,!0);case"Fragment":return e.fragmentShaderHandle!==r.getHandle()?(e.error="The supplied shader was not attached to this program.",!1):(e.context.detachShader(e.handle,r.getHandle()),e.fragmentShaderHandle=0,e.linked=!1,!0);default:return!1}},t.setContext=r=>{e.context=r,e.vertexShader.setContext(r),e.fragmentShader.setContext(r),e.geometryShader.setContext(r)},t.setLastCameraMTime=r=>{e.lastCameraMTime=r}}const mJ={vertexShaderHandle:0,fragmentShaderHandle:0,geometryShaderHandle:0,vertexShader:null,fragmentShader:null,geometryShader:null,linked:!1,bound:!1,compiled:!1,error:"",handle:0,numberOfOutputs:0,attributesLocs:null,uniformLocs:null,md5Hash:0,context:null,lastCameraMTime:null};function nL(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,mJ,r),e.attributesLocs={},e.uniformLocs={},e.vertexShader=Ux.newInstance(),e.vertexShader.setShaderType("Vertex"),e.fragmentShader=Ux.newInstance(),e.fragmentShader.setShaderType("Fragment"),e.geometryShader=Ux.newInstance(),e.geometryShader.setShaderType("Geometry"),Z.obj(t,e),Z.get(t,e,["lastCameraMTime"]),Z.setGet(t,e,["error","handle","compiled","bound","md5Hash","vertexShader","fragmentShader","geometryShader","linked"]),pJ(t,e)}const vJ=Z.newInstance(nL,"vtkShaderProgram");var Be={newInstance:vJ,extend:nL,substitute:gJ};function yJ(t,e){e.classHierarchy.push("vtkOpenGLVertexArrayObject"),t.exposedMethod=()=>{},t.initialize=()=>{e.instancingExtension=null,e._openGLRenderWindow.getWebgl2()||(e.instancingExtension=e.context.getExtension("ANGLE_instanced_arrays")),!e.forceEmulation&&e._openGLRenderWindow&&e._openGLRenderWindow.getWebgl2()?(e.extension=null,e.supported=!0,e.handleVAO=e.context.createVertexArray()):(e.extension=e.context.getExtension("OES_vertex_array_object"),!e.forceEmulation&&e.extension?(e.supported=!0,e.handleVAO=e.extension.createVertexArrayOES()):e.supported=!1)},t.isReady=()=>e.handleVAO!==0||e.supported===!1,t.bind=()=>{if(t.isReady()||t.initialize(),t.isReady()&&e.supported)e.extension?e.extension.bindVertexArrayOES(e.handleVAO):e.context.bindVertexArray(e.handleVAO);else if(t.isReady()){const r=e.context;for(let n=0;n<e.buffers.length;++n){const i=e.buffers[n];e.context.bindBuffer(r.ARRAY_BUFFER,i.buffer);for(let o=0;o<i.attributes.length;++o){const a=i.attributes[o],s=a.isMatrix?a.size:1;for(let c=0;c<s;++c)r.enableVertexAttribArray(a.index+c),r.vertexAttribPointer(a.index+c,a.size,a.type,a.normalize,a.stride,a.offset+a.stride*c/a.size),a.divisor>0&&(e.instancingExtension?e.instancingExtension.vertexAttribDivisorANGLE(a.index+c,1):r.vertexAttribDivisor(a.index+c,1))}}}},t.release=()=>{if(t.isReady()&&e.supported)e.extension?e.extension.bindVertexArrayOES(null):e.context.bindVertexArray(null);else if(t.isReady()){const r=e.context;for(let n=0;n<e.buffers.length;++n){const i=e.buffers[n];e.context.bindBuffer(r.ARRAY_BUFFER,i.buffer);for(let o=0;o<i.attributes.length;++o){const a=i.attributes[o],s=a.isMatrix?a.size:1;for(let c=0;c<s;++c)r.enableVertexAttribArray(a.index+c),r.vertexAttribPointer(a.index+c,a.size,a.type,a.normalize,a.stride,a.offset+a.stride*c/a.size),a.divisor>0&&(e.instancingExtension?e.instancingExtension.vertexAttribDivisorANGLE(a.index+c,0):r.vertexAttribDivisor(a.index+c,0)),r.disableVertexAttribArray(a.index+c)}}}},t.shaderProgramChanged=()=>{t.release(),e.handleVAO&&(e.extension?e.extension.deleteVertexArrayOES(e.handleVAO):e.context.deleteVertexArray(e.handleVAO)),e.handleVAO=0,e.handleProgram=0},t.releaseGraphicsResources=()=>{t.shaderProgramChanged(),e.handleVAO&&(e.extension?e.extension.deleteVertexArrayOES(e.handleVAO):e.context.deleteVertexArray(e.handleVAO)),e.handleVAO=0,e.supported=!0,e.handleProgram=0},t.addAttributeArray=(r,n,i,o,a,s,c,l)=>t.addAttributeArrayWithDivisor(r,n,i,o,a,s,c,l,0,!1),t.addAttributeArrayWithDivisor=(r,n,i,o,a,s,c,l,f,u)=>{if(!r||!r.isBound()||n.getHandle()===0||n.getType()!==jl.ARRAY_BUFFER||(e.handleProgram===0&&(e.handleProgram=r.getHandle()),t.isReady()||t.initialize(),!t.isReady()||e.handleProgram!==r.getHandle()))return!1;const d=e.context,h={};if(h.name=i,h.index=d.getAttribLocation(e.handleProgram,i),h.offset=o,h.stride=a,h.type=s,h.size=c,h.normalize=l,h.isMatrix=u,h.divisor=f,h.Index===-1)return!1;if(n.bind(),d.enableVertexAttribArray(h.index),d.vertexAttribPointer(h.index,h.size,h.type,h.normalize,h.stride,h.offset),f>0&&(e.instancingExtension?e.instancingExtension.vertexAttribDivisorANGLE(h.index,1):d.vertexAttribDivisor(h.index,1)),h.buffer=n.getHandle(),!e.supported){let g=!1;for(let p=0;p<e.buffers.length;++p){const v=e.buffers[p];if(v.buffer===h.buffer){g=!0;let y=!1;for(let m=0;m<v.attributes.length;++m)v.attributes[m].name===i&&(y=!0,v.attributes[m]=h);y||v.attributes.push(h)}}g||e.buffers.push({buffer:h.buffer,attributes:[h]})}return!0},t.addAttributeMatrixWithDivisor=(r,n,i,o,a,s,c,l,f)=>{const u=t.addAttributeArrayWithDivisor(r,n,i,o,a,s,c,l,f,!0);if(!u)return u;const d=e.context,h=d.getAttribLocation(e.handleProgram,i);for(let g=1;g<c;g++)d.enableVertexAttribArray(h+g),d.vertexAttribPointer(h+g,c,s,l,a,o+a*g/c),f>0&&(e.instancingExtension?e.instancingExtension.vertexAttribDivisorANGLE(h+g,1):d.vertexAttribDivisor(h+g,1));return!0},t.removeAttributeArray=r=>{if(!t.isReady()||e.handleProgram===0)return!1;if(!e.supported)for(let n=0;n<e.buffers.length;++n){const i=e.buffers[n];for(let o=0;o<i.attributes.length;++o)if(i.attributes[o].name===r)return i.attributes.splice(o,1),i.attributes.length||e.buffers.splice(n,1),!0}return!0},t.setOpenGLRenderWindow=r=>{e._openGLRenderWindow!==r&&(t.releaseGraphicsResources(),e._openGLRenderWindow=r,e.context=null,r&&(e.context=e._openGLRenderWindow.getContext()))}}const wJ={forceEmulation:!1,handleVAO:0,handleProgram:0,supported:!0,buffers:null,context:null};function rL(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,wJ,r),e.buffers=[],Z.obj(t,e),Z.get(t,e,["supported"]),Z.setGet(t,e,["forceEmulation"]),yJ(t,e)}const xJ=Z.newInstance(rL,"vtkOpenGLVertexArrayObject");var u4={newInstance:xJ,extend:rL};const Cu={Start:0,Points:0,Lines:1,Tris:2,TriStrips:3,TrisEdges:4,TriStripsEdges:5,End:6};function CJ(t,e){e.classHierarchy.push("vtkOpenGLHelper"),t.setOpenGLRenderWindow=r=>{e.context=r.getContext(),e.program.setContext(e.context),e.VAO.setOpenGLRenderWindow(r),e.CABO.setOpenGLRenderWindow(r)},t.releaseGraphicsResources=r=>{e.VAO.releaseGraphicsResources(),e.CABO.releaseGraphicsResources(),e.CABO.setElementCount(0)},t.drawArrays=(r,n,i,o)=>{if(e.CABO.getElementCount()){const a=t.getOpenGLMode(i),s=t.haveWideLines(r,n),c=e.context,l=c.getParameter(c.DEPTH_WRITEMASK);e.pointPicking&&c.depthMask(!1),a===c.LINES&&s?(t.updateShaders(r,n,o),c.drawArraysInstanced(a,0,e.CABO.getElementCount(),2*Math.ceil(n.getProperty().getLineWidth()))):(c.lineWidth(n.getProperty().getLineWidth()),t.updateShaders(r,n,o),c.drawArrays(a,0,e.CABO.getElementCount()),c.lineWidth(1));const u=(a===c.POINTS?1:0)||(a===c.LINES?2:3);return e.pointPicking&&c.depthMask(l),e.CABO.getElementCount()/u}return 0},t.getOpenGLMode=r=>{if(e.pointPicking)return e.context.POINTS;const n=e.primitiveType;return r===ao.POINTS||n===Cu.Points?e.context.POINTS:r===ao.WIREFRAME||n===Cu.Lines||n===Cu.TrisEdges||n===Cu.TriStripsEdges?e.context.LINES:e.context.TRIANGLES},t.haveWideLines=(r,n)=>n.getProperty().getLineWidth()>1?!(e.CABO.getOpenGLRenderWindow()&&e.CABO.getOpenGLRenderWindow().getHardwareMaximumLineWidth()>=n.getProperty().getLineWidth()):!1,t.getNeedToRebuildShaders=(r,n,i)=>!!(i.getNeedToRebuildShaders(t,r,n)||t.getProgram()===0||t.getShaderSourceTime().getMTime()<i.getMTime()||t.getShaderSourceTime().getMTime()<n.getMTime()),t.updateShaders=(r,n,i)=>{if(t.getNeedToRebuildShaders(r,n,i)){const o={Vertex:null,Fragment:null,Geometry:null};i.buildShaders(o,r,n);const a=e.CABO.getOpenGLRenderWindow().getShaderCache().readyShaderProgramArray(o.Vertex,o.Fragment,o.Geometry);a!==t.getProgram()&&(t.setProgram(a),t.getVAO().releaseGraphicsResources()),t.getShaderSourceTime().modified()}else e.CABO.getOpenGLRenderWindow().getShaderCache().readyShaderProgram(t.getProgram());t.getVAO().bind(),i.setMapperShaderParameters(t,r,n),i.setPropertyShaderParameters(t,r,n),i.setCameraShaderParameters(t,r,n),i.setLightingShaderParameters(t,r,n),i.invokeShaderCallbacks(t,r,n)},t.setMapperShaderParameters=(r,n,i)=>{if(t.haveWideLines(r,n)){t.getProgram().setUniform2f("viewportSize",i.usize,i.vsize);const o=parseFloat(n.getProperty().getLineWidth()),a=o/2;t.getProgram().setUniformf("lineWidthStepSize",o/Math.ceil(o)),t.getProgram().setUniformf("halfLineWidth",a)}e.primitiveType===Cu.Points||n.getProperty().getRepresentation()===ao.POINTS?t.getProgram().setUniformf("pointSize",n.getProperty().getPointSize()):e.pointPicking&&t.getProgram().setUniformf("pointSize",t.getPointPickingPrimitiveSize())},t.replaceShaderPositionVC=(r,n,i)=>{let o=r.Vertex;o=Be.substitute(o,"//VTK::PositionVC::Dec",["//VTK::PositionVC::Dec","uniform float pointSize;"]).result,o=Be.substitute(o,"//VTK::PositionVC::Impl",["//VTK::PositionVC::Impl"," gl_PointSize = pointSize;"],!1).result,t.getOpenGLMode(i.getProperty().getRepresentation())===e.context.LINES&&t.haveWideLines(n,i)&&(o=Be.substitute(o,"//VTK::PositionVC::Dec",["//VTK::PositionVC::Dec","uniform vec2 viewportSize;","uniform float lineWidthStepSize;","uniform float halfLineWidth;"]).result,o=Be.substitute(o,"//VTK::PositionVC::Impl",["//VTK::PositionVC::Impl"," if (halfLineWidth > 0.0)"," {"," float offset = float(gl_InstanceID / 2) * lineWidthStepSize - halfLineWidth;"," vec4 tmpPos = gl_Position;"," vec3 tmpPos2 = tmpPos.xyz / tmpPos.w;"," tmpPos2.x = tmpPos2.x + 2.0 * mod(float(gl_InstanceID), 2.0) * offset / viewportSize[0];"," tmpPos2.y = tmpPos2.y + 2.0 * mod(float(gl_InstanceID + 1), 2.0) * offset / viewportSize[1];"," gl_Position = vec4(tmpPos2.xyz * tmpPos.w, tmpPos.w);"," }"]).result),r.Vertex=o},t.getPointPickingPrimitiveSize=()=>e.primitiveType===Cu.Points?2:e.primitiveType===Cu.Lines?4:6,t.getAllocatedGPUMemoryInBytes=()=>t.getCABO().getAllocatedGPUMemoryInBytes()}const SJ={context:null,program:null,shaderSourceTime:null,VAO:null,attributeUpdateTime:null,CABO:null,primitiveType:0,pointPicking:!1};function iL(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,SJ,r),Z.obj(t,e),e.shaderSourceTime={},Z.obj(e.shaderSourceTime),e.attributeUpdateTime={},Z.obj(e.attributeUpdateTime),Z.setGet(t,e,["program","shaderSourceTime","VAO","attributeUpdateTime","CABO","primitiveType","pointPicking"]),e.program=Be.newInstance(),e.VAO=u4.newInstance(),e.CABO=lJ.newInstance(),CJ(t,e)}const TJ=Z.newInstance(iL);var ul={newInstance:TJ,extend:iL,primTypes:Cu};const{Representation:Xg,Interpolation:Yg}=QR;function Z6(t){return()=>Z.vtkErrorMacro(`vtkProperty::${t} - NOT IMPLEMENTED`)}function _J(t,e){e.classHierarchy.push("vtkProperty"),t.setColor=(r,n,i)=>{Array.isArray(r)?(e.color[0]!==r[0]||e.color[1]!==r[1]||e.color[2]!==r[2])&&(e.color[0]=r[0],e.color[1]=r[1],e.color[2]=r[2],t.modified()):(e.color[0]!==r||e.color[1]!==n||e.color[2]!==i)&&(e.color[0]=r,e.color[1]=n,e.color[2]=i,t.modified()),t.setDiffuseColor(e.color),t.setAmbientColor(e.color),t.setSpecularColor(e.color)},t.computeCompositeColor=Z6("ComputeCompositeColor"),t.getColor=()=>{let r=0;e.ambient+e.diffuse+e.specular>0&&(r=1/(e.ambient+e.diffuse+e.specular));for(let n=0;n<3;n++)e.color[n]=r*(e.ambient*e.ambientColor[n]+e.diffuse*e.diffuseColor[n]+e.specular*e.specularColor[n]);return[].concat(e.color)},t.setSpecularPower=r=>{const n=1/Math.max(1,r);(e.roughness!==n||e.specularPower!==r)&&(e.specularPower=r,e.roughness=n,t.modified())},t.addShaderVariable=Z6("AddShaderVariable"),t.setInterpolationToFlat=()=>t.setInterpolation(Yg.FLAT),t.setInterpolationToGouraud=()=>t.setInterpolation(Yg.GOURAUD),t.setInterpolationToPhong=()=>t.setInterpolation(Yg.PHONG),t.getInterpolationAsString=()=>Z.enumToString(Yg,e.interpolation),t.setRepresentationToWireframe=()=>t.setRepresentation(Xg.WIREFRAME),t.setRepresentationToSurface=()=>t.setRepresentation(Xg.SURFACE),t.setRepresentationToPoints=()=>t.setRepresentation(Xg.POINTS),t.getRepresentationAsString=()=>Z.enumToString(Xg,e.representation)}const EJ={color:[1,1,1],ambientColor:[1,1,1],diffuseColor:[1,1,1],specularColor:[1,1,1],edgeColor:[0,0,0],ambient:0,diffuse:1,metallic:0,roughness:.6,normalStrength:1,emission:1,baseIOR:1.45,specular:0,specularPower:1,opacity:1,interpolation:Yg.GOURAUD,representation:Xg.SURFACE,edgeVisibility:!1,backfaceCulling:!1,frontfaceCulling:!1,pointSize:1,lineWidth:1,lighting:!0,shading:!1,materialName:null};function oL(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,EJ,r),Z.obj(t,e),Z.setGet(t,e,["lighting","interpolation","ambient","diffuse","metallic","roughness","normalStrength","emission","baseIOR","specular","specularPower","opacity","edgeVisibility","lineWidth","pointSize","backfaceCulling","frontfaceCulling","representation","diffuseTexture","metallicTexture","roughnessTexture","normalTexture","ambientOcclusionTexture","emissionTexture"]),Z.setGetArray(t,e,["ambientColor","specularColor","diffuseColor","edgeColor"],3),_J(t,e)}const bJ=Z.newInstance(oL,"vtkProperty");var Fd={newInstance:bJ,extend:oL,...QR};const{Representation:DJ}=Fd,{vtkErrorMacro:Q6}=Z;function IJ(t){const e=Be.substitute(t.Fragment,"//VTK::RenderPassFragmentShader::Impl",`
|
||
float weight = gl_FragData[0].a * pow(max(1.1 - gl_FragCoord.z, 0.0), 2.0);
|
||
gl_FragData[0] = vec4(gl_FragData[0].rgb*weight, gl_FragData[0].a);
|
||
gl_FragData[1].r = weight;
|
||
`,!1);t.Fragment=e.result}const OJ=`//VTK::System::Dec
|
||
|
||
in vec2 tcoord;
|
||
|
||
uniform sampler2D translucentRTexture;
|
||
uniform sampler2D translucentRGBATexture;
|
||
|
||
// the output of this shader
|
||
//VTK::Output::Dec
|
||
|
||
void main()
|
||
{
|
||
vec4 t1Color = texture(translucentRGBATexture, tcoord);
|
||
float t2Color = texture(translucentRTexture, tcoord).r;
|
||
gl_FragData[0] = vec4(t1Color.rgb/max(t2Color,0.01), 1.0 - t1Color.a);
|
||
}
|
||
`;function MJ(t,e){e.classHierarchy.push("vtkOpenGLOrderIndependentTranslucentPass"),t.createVertexBuffer=()=>{const r=new Float32Array([-1,-1,-1,1,-1,-1,-1,1,-1,1,1,-1]),n=new Float32Array([0,0,1,0,0,1,1,1]),i=new Uint16Array([4,0,1,3,2]),o=bt.newInstance({numberOfComponents:3,values:r});o.setName("points");const a=bt.newInstance({numberOfComponents:2,values:n});a.setName("tcoords");const s=bt.newInstance({numberOfComponents:1,values:i});e.tris.getCABO().createVBO(s,"polys",DJ.SURFACE,{points:o,tcoords:a,cellOffset:0}),e.VBOBuildTime.modified()},t.createFramebuffer=r=>{const n=r.getSize(),i=r.getContext();e.framebuffer=ew.newInstance(),e.framebuffer.setOpenGLRenderWindow(r),e.framebuffer.create(...n),e.framebuffer.saveCurrentBindingsAndBuffers(),e.framebuffer.bind(),e.translucentRGBATexture=mr.newInstance(),e.translucentRGBATexture.setInternalFormat(i.RGBA16F),e.translucentRGBATexture.setFormat(i.RGBA),e.translucentRGBATexture.setOpenGLDataType(i.HALF_FLOAT),e.translucentRGBATexture.setOpenGLRenderWindow(r),e.translucentRGBATexture.create2DFromRaw(n[0],n[1],4,"Float32Array",null),e.translucentRTexture=mr.newInstance(),e.translucentRTexture.setInternalFormat(i.R16F),e.translucentRTexture.setFormat(i.RED),e.translucentRTexture.setOpenGLDataType(i.HALF_FLOAT),e.translucentRTexture.setOpenGLRenderWindow(r),e.translucentRTexture.create2DFromRaw(n[0],n[1],1,"Float32Array",null),e.translucentZTexture=mr.newInstance(),e.translucentZTexture.setOpenGLRenderWindow(r),e.translucentZTexture.createDepthFromRaw(n[0],n[1],"Float32Array",null),e.framebuffer.setColorBuffer(e.translucentRGBATexture,0),e.framebuffer.setColorBuffer(e.translucentRTexture,1),e.framebuffer.setDepthBuffer(e.translucentZTexture)},t.createCopyShader=r=>{e.copyShader=r.getShaderCache().readyShaderProgramArray(["//VTK::System::Dec","attribute vec4 vertexDC;","attribute vec2 tcoordTC;","varying vec2 tcoord;","void main() { tcoord = tcoordTC; gl_Position = vertexDC; }"].join(`
|
||
`),OJ,"")},t.createVBO=r=>{const n=r.getContext();e.tris.setOpenGLRenderWindow(r),t.createVertexBuffer();const i=e.copyShader;e.tris.getCABO().bind(),e.copyVAO.addAttributeArray(i,e.tris.getCABO(),"vertexDC",e.tris.getCABO().getVertexOffset(),e.tris.getCABO().getStride(),n.FLOAT,3,n.FALSE)||Q6("Error setting vertexDC in copy shader VAO."),e.copyVAO.addAttributeArray(i,e.tris.getCABO(),"tcoordTC",e.tris.getCABO().getTCoordOffset(),e.tris.getCABO().getStride(),n.FLOAT,2,n.FALSE)||Q6("Error setting vertexDC in copy shader VAO.")},t.traverse=(r,n,i)=>{if(e.deleted)return;const o=r.getSize(),a=r.getContext();if(e._supported=!1,n.getSelector()||!a||!r.getWebgl2()||!a.getExtension("EXT_color_buffer_half_float")&&!a.getExtension("EXT_color_buffer_float")){t.setCurrentOperation("translucentPass"),n.traverse(t);return}if(e._supported=!0,e.framebuffer===null)t.createFramebuffer(r);else{const c=e.framebuffer.getSize();c===null||c[0]!==o[0]||c[1]!==o[1]?(e.framebuffer.releaseGraphicsResources(),e.translucentRGBATexture.releaseGraphicsResources(r),e.translucentRTexture.releaseGraphicsResources(r),e.translucentZTexture.releaseGraphicsResources(r),t.createFramebuffer(r)):(e.framebuffer.saveCurrentBindingsAndBuffers(),e.framebuffer.bind())}a.drawBuffers([a.COLOR_ATTACHMENT0]),a.clearBufferfv(a.COLOR,0,[0,0,0,0]),a.clearBufferfv(a.DEPTH,0,[1]),a.colorMask(!1,!1,!1,!1),i.getOpaqueActorCount()>0&&(i.setCurrentOperation("opaqueZBufferPass"),n.traverse(i)),a.colorMask(!0,!0,!0,!0),a.drawBuffers([a.COLOR_ATTACHMENT0,a.COLOR_ATTACHMENT1]),a.viewport(0,0,o[0],o[1]),a.scissor(0,0,o[0],o[1]),a.clearBufferfv(a.COLOR,0,[0,0,0,1]),a.clearBufferfv(a.COLOR,1,[0,0,0,0]),a.enable(a.DEPTH_TEST),a.enable(a.BLEND),a.blendFuncSeparate(a.ONE,a.ONE,a.ZERO,a.ONE_MINUS_SRC_ALPHA),t.setCurrentOperation("translucentPass"),n.traverse(t),a.drawBuffers([a.NONE]),e.framebuffer.restorePreviousBindingsAndBuffers(),e.copyShader===null?t.createCopyShader(r):r.getShaderCache().readyShaderProgram(e.copyShader),e.copyVAO||(e.copyVAO=u4.newInstance(),e.copyVAO.setOpenGLRenderWindow(r)),e.copyVAO.bind(),e.VBOBuildTime.getMTime()<t.getMTime()&&t.createVBO(r),a.blendFuncSeparate(a.SRC_ALPHA,a.ONE_MINUS_SRC_ALPHA,a.ONE,a.ONE_MINUS_SRC_ALPHA),a.depthMask(!1),a.depthFunc(a.ALWAYS),a.viewport(0,0,o[0],o[1]),a.scissor(0,0,o[0],o[1]),e.translucentRGBATexture.activate(),e.copyShader.setUniformi("translucentRGBATexture",e.translucentRGBATexture.getTextureUnit()),e.translucentRTexture.activate(),e.copyShader.setUniformi("translucentRTexture",e.translucentRTexture.getTextureUnit()),a.drawArrays(a.TRIANGLES,0,e.tris.getCABO().getElementCount()),a.depthMask(!0),a.depthFunc(a.LEQUAL),e.translucentRGBATexture.deactivate(),e.translucentRTexture.deactivate();const s=n.getTiledSizeAndOrigin();a.scissor(s.lowerLeftU,s.lowerLeftV,s.usize,s.vsize),a.viewport(s.lowerLeftU,s.lowerLeftV,s.usize,s.vsize)},t.getShaderReplacement=()=>e._supported?IJ:null,t.releaseGraphicsResources=r=>{e.framebuffer&&(e.framebuffer.releaseGraphicsResources(r),e.framebuffer=null),e.translucentRGBATexture&&(e.translucentRGBATexture.releaseGraphicsResources(r),e.translucentRGBATexture=null),e.translucentRTexture&&(e.translucentRTexture.releaseGraphicsResources(r),e.translucentRTexture=null),e.translucentZTexture&&(e.translucentZTexture.releaseGraphicsResources(r),e.translucentZTexture=null),e.copyVAO&&(e.copyVAO.releaseGraphicsResources(r),e.copyVAO=null),e.copyShader&&(e.copyShader.releaseGraphicsResources(r),e.copyShader=null),e.tris&&(e.tris.releaseGraphicsResources(r),e.tris=null),t.modified()}}const PJ={framebuffer:null,copyShader:null,tris:null};function aL(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,PJ,r),Y_.extend(t,e,r),e.VBOBuildTime={},Z.obj(e.VBOBuildTime,{mtime:0}),e.tris=ul.newInstance(),Z.get(t,e,["framebuffer"]),MJ(t,e)}const RJ=Z.newInstance(aL,"vtkOpenGLOrderIndependentTranslucentPass");var LJ={newInstance:RJ,extend:aL};function AJ(t,e){e.classHierarchy.push("vtkForwardPass"),t.traverse=function(r){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;if(e.deleted)return;e._currentParent=n,t.setCurrentOperation("buildPass"),r.traverse(t);const i=r.getRenderable().getNumberOfLayers(),o=r.getRenderable().getRenderersByReference();for(let a=0;a<i;a++)for(let s=0;s<o.length;s++){const c=o[s],l=r.getViewNodeFor(c);if(c.getDraw()&&c.getLayer()===a){if(e.opaqueActorCount=0,e.translucentActorCount=0,e.volumeCount=0,e.overlayActorCount=0,t.setCurrentOperation("queryPass"),l.traverse(t),(e.opaqueActorCount>0||e.translucentActorCount>0)&&e.volumeCount>0||e.depthRequested){const f=r.getFramebufferSize();e.framebuffer===null&&(e.framebuffer=ew.newInstance()),e.framebuffer.setOpenGLRenderWindow(r),e.framebuffer.saveCurrentBindingsAndBuffers();const u=e.framebuffer.getSize();(u===null||u[0]!==f[0]||u[1]!==f[1])&&(e.framebuffer.create(f[0],f[1]),e.framebuffer.populateFramebuffer()),e.framebuffer.bind(),t.setCurrentOperation("zBufferPass"),l.traverse(t),e.framebuffer.restorePreviousBindingsAndBuffers(),e.depthRequested=!1}t.setCurrentOperation("cameraPass"),l.traverse(t),e.opaqueActorCount>0&&(t.setCurrentOperation("opaquePass"),l.traverse(t)),e.translucentActorCount>0&&(e.translucentPass||(e.translucentPass=LJ.newInstance()),e.translucentPass.traverse(r,l,t)),e.volumeCount>0&&(t.setCurrentOperation("volumePass"),l.traverse(t)),e.overlayActorCount>0&&(t.setCurrentOperation("overlayPass"),l.traverse(t))}}},t.getZBufferTexture=()=>e.framebuffer?e.framebuffer.getColorTexture():null,t.requestDepth=()=>{e.depthRequested=!0},t.incrementOpaqueActorCount=()=>e.opaqueActorCount++,t.incrementTranslucentActorCount=()=>e.translucentActorCount++,t.incrementVolumeCount=()=>e.volumeCount++,t.incrementOverlayActorCount=()=>e.overlayActorCount++}const NJ={opaqueActorCount:0,translucentActorCount:0,volumeCount:0,overlayActorCount:0,framebuffer:null,depthRequested:!1};function sL(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,NJ,r),Y_.extend(t,e,r),Z.get(t,e,["framebuffer","opaqueActorCount","translucentActorCount","volumeCount"]),AJ(t,e)}const kJ=Z.newInstance(sL,"vtkForwardPass");var VJ={newInstance:kJ,extend:sL};const $o={MIN_KNOWN_PASS:0,ACTOR_PASS:0,COMPOSITE_INDEX_PASS:1,ID_LOW24:2,ID_HIGH24:3,MAX_KNOWN_PASS:3};var cL={PassTypes:$o};const{vtkErrorMacro:eD,vtkWarningMacro:FJ}=Z;function UJ(t,e){e.classHierarchy.push("vtkFieldData");const r=t.getState;e.arrays&&(e.arrays=e.arrays.map(n=>({data:nc(n.data)}))),t.initialize=()=>{t.initializeFields(),t.copyAllOn(),t.clearFieldFlags()},t.initializeFields=()=>{e.arrays=[],e.copyFieldFlags={},t.modified()},t.copyStructure=n=>{t.initializeFields(),e.copyFieldFlags=n.getCopyFieldFlags().map(i=>i),e.arrays=n.arrays().map(i=>({array:i}))},t.getNumberOfArrays=()=>e.arrays.length,t.getNumberOfActiveArrays=()=>e.arrays.length,t.addArray=n=>{const i=n.getName(),{array:o,index:a}=t.getArrayWithIndex(i);return o!=null?(e.arrays[a]={data:n},a):(e.arrays=[].concat(e.arrays,{data:n}),e.arrays.length-1)},t.removeAllArrays=()=>{e.arrays=[]},t.removeArray=n=>{const i=e.arrays.findIndex(o=>o.data.getName()===n);return t.removeArrayByIndex(i)},t.removeArrayByIndex=n=>n!==-1&&n<e.arrays.length?(e.arrays.splice(n,1),!0):!1,t.getArrays=()=>e.arrays.map(n=>n.data),t.getArray=n=>typeof n=="number"?t.getArrayByIndex(n):t.getArrayByName(n),t.getArrayByName=n=>e.arrays.reduce((i,o,a)=>o.data.getName()===n?o.data:i,null),t.getArrayWithIndex=n=>{const i=e.arrays.findIndex(o=>o.data.getName()===n);return{array:i!==-1?e.arrays[i].data:null,index:i}},t.getArrayByIndex=n=>n>=0&&n<e.arrays.length?e.arrays[n].data:null,t.hasArray=n=>t.getArrayWithIndex(n).index>=0,t.getArrayName=n=>{const i=e.arrays[n];return i?i.data.getName():""},t.getCopyFieldFlags=()=>e.copyFieldFlags,t.getFlag=n=>e.copyFieldFlags[n],t.passData=function(n){let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:-1,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:-1;n.getArrays().forEach(a=>{const s=t.getFlag(a.getName());if(s!==!1&&!(e.doCopyAllOff&&s!==!0)&&a){let c=t.getArrayByName(a.getName());if(c)if(a.getNumberOfComponents()===c.getNumberOfComponents())if(i>-1&&i<a.getNumberOfTuples()){const l=o>-1?o:i;c.insertTuple(l,a.getTuple(i))}else c.insertTuples(0,a.getTuples());else eD("Unhandled case in passData");else if(i<0||i>a.getNumberOfTuples())t.addArray(a),n.getAttributes(a).forEach(l=>{t.setAttribute(a,l)});else{const l=a.getNumberOfComponents();let f=a.getNumberOfValues();const u=o>-1?o:i;f<=u*l&&(f=(u+1)*l),c=bt.newInstance({name:a.getName(),dataType:a.getDataType(),numberOfComponents:l,values:Z.newTypedArray(a.getDataType(),f),size:0}),c.insertTuple(u,a.getTuple(i)),t.addArray(c),n.getAttributes(a).forEach(d=>{t.setAttribute(c,d)})}}})},t.interpolateData=function(n){let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:-1,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:-1,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:-1,s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:.5;n.getArrays().forEach(c=>{const l=t.getFlag(c.getName());if(l!==!1&&!(e.doCopyAllOff&&l!==!0)&&c){let f=t.getArrayByName(c.getName());if(f)if(c.getNumberOfComponents()===f.getNumberOfComponents())if(i>-1&&i<c.getNumberOfTuples()){const u=a>-1?a:i;f.interpolateTuple(u,c,i,c,o,s),FJ("Unexpected case in interpolateData")}else f.insertTuples(c.getTuples());else eD("Unhandled case in interpolateData");else if(i<0||o<0||i>c.getNumberOfTuples())t.addArray(c),n.getAttributes(c).forEach(u=>{t.setAttribute(c,u)});else{const u=c.getNumberOfComponents();let d=c.getNumberOfValues();const h=a>-1?a:i;d<=h*u&&(d=(h+1)*u),f=bt.newInstance({name:c.getName(),dataType:c.getDataType(),numberOfComponents:u,values:Z.newTypedArray(c.getDataType(),d),size:0}),f.interpolateTuple(h,c,i,c,o,s),t.addArray(f),n.getAttributes(c).forEach(g=>{t.setAttribute(f,g)})}}})},t.copyFieldOn=n=>{e.copyFieldFlags[n]=!0},t.copyFieldOff=n=>{e.copyFieldFlags[n]=!1},t.copyAllOn=()=>{(!e.doCopyAllOn||e.doCopyAllOff)&&(e.doCopyAllOn=!0,e.doCopyAllOff=!1,t.modified())},t.copyAllOff=()=>{(e.doCopyAllOn||!e.doCopyAllOff)&&(e.doCopyAllOn=!1,e.doCopyAllOff=!0,t.modified())},t.clearFieldFlags=()=>{e.copyFieldFlags={}},t.deepCopy=n=>{e.arrays=n.getArrays().map(i=>{const o=i.newClone();return o.deepCopy(i),{data:o}})},t.copyFlags=n=>n.getCopyFieldFlags().map(i=>i),t.reset=()=>e.arrays.forEach(n=>n.data.reset()),t.getMTime=()=>e.arrays.reduce((n,i)=>i.data.getMTime()>n?i.data.getMTime():n,e.mtime),t.getNumberOfComponents=()=>e.arrays.reduce((n,i)=>n+i.data.getNumberOfComponents(),0),t.getNumberOfTuples=()=>e.arrays.length>0?e.arrays[0].getNumberOfTuples():0,t.getState=()=>{const n=r();return n&&(n.arrays=e.arrays.map(i=>({data:i.data.getState()}))),n}}const BJ={arrays:[],copyFieldFlags:[],doCopyAllOn:!0,doCopyAllOff:!1};function lL(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,BJ,r),Z.obj(t,e),UJ(t,e)}const GJ=Z.newInstance(lL,"vtkFieldData");var WJ={newInstance:GJ,extend:lL};const zJ={SCALARS:0,VECTORS:1,NORMALS:2,TCOORDS:3,TENSORS:4,GLOBALIDS:5,PEDIGREEIDS:6,EDGEFLAG:7,NUM_ATTRIBUTES:8},$J={MAX:0,EXACT:1,NOLIMIT:2},jJ={DUPLICATECELL:1,HIGHCONNECTIVITYCELL:2,LOWCONNECTIVITYCELL:4,REFINEDCELL:8,EXTERIORCELL:16,HIDDENCELL:32},HJ={DUPLICATEPOINT:1,HIDDENPOINT:2},KJ={COPYTUPLE:0,INTERPOLATE:1,PASSDATA:2,ALLCOPY:3},qJ="vtkGhostType",Ty={DEFAULT:0,SINGLE:1,DOUBLE:2};var uL={AttributeCopyOperations:KJ,AttributeLimitTypes:$J,AttributeTypes:zJ,CellGhostTypes:jJ,DesiredOutputPrecision:Ty,PointGhostTypes:HJ,ghostArrayName:qJ};const{AttributeTypes:hu,AttributeCopyOperations:Df}=uL,{vtkWarningMacro:t2}=Z;function XJ(t,e){const r=["Scalars","Vectors","Normals","TCoords","Tensors","GlobalIds","PedigreeIds"];function n(a){let s=r.find(c=>hu[c.toUpperCase()]===a||typeof a!="number"&&c.toLowerCase()===a.toLowerCase());return typeof s>"u"&&(s=null),s}e.classHierarchy.push("vtkDataSetAttributes");const i={...t};t.checkNumberOfComponents=a=>!0,t.setAttribute=(a,s)=>{const c=n(s);if(a&&c.toUpperCase()==="PEDIGREEIDS"&&!a.isA("vtkDataArray"))return t2(`Cannot set attribute ${c}. The attribute must be a vtkDataArray.`),-1;if(a&&!t.checkNumberOfComponents(a,c))return t2(`Cannot set attribute ${c}. Incorrect number of components.`),-1;let l=e[`active${c}`];if(l>=0&&l<e.arrays.length){if(e.arrays[l]===a)return l;t.removeArrayByIndex(l)}return a?(l=t.addArray(a),e[`active${c}`]=l):e[`active${c}`]=-1,t.modified(),e[`active${c}`]},t.getAttributes=a=>r.filter(s=>t[`get${s}`]()===a),t.setActiveAttributeByName=(a,s)=>t.setActiveAttributeByIndex(t.getArrayWithIndex(a).index,s),t.setActiveAttributeByIndex=(a,s)=>{const c=n(s);if(a>=0&&a<e.arrays.length){if(c.toUpperCase()!=="PEDIGREEIDS"){const l=t.getArrayByIndex(a);if(!l.isA("vtkDataArray"))return t2(`Cannot set attribute ${c}. Only vtkDataArray subclasses can be set as active attributes.`),-1;if(!t.checkNumberOfComponents(l,c))return t2(`Cannot set attribute ${c}. Incorrect number of components.`),-1}return e[`active${c}`]=a,t.modified(),a}return a===-1&&(e[`active${c}`]=a,t.modified()),-1},t.getActiveAttribute=a=>{const s=n(a);return t[`get${s}`]()},t.removeAllArrays=()=>{r.forEach(a=>{e[`active${a}`]=-1}),i.removeAllArrays()},t.removeArrayByIndex=a=>(a!==-1&&r.forEach(s=>{a===e[`active${s}`]?e[`active${s}`]=-1:a<e[`active${s}`]&&(e[`active${s}`]-=1)}),i.removeArrayByIndex(a)),r.forEach(a=>{const s=`active${a}`;t[`get${a}`]=()=>t.getArrayByIndex(e[s]),t[`set${a}`]=c=>t.setAttribute(c,a),t[`setActive${a}`]=c=>t.setActiveAttributeByIndex(t.getArrayWithIndex(c).index,a),t[`copy${a}Off`]=()=>{const c=a.toUpperCase();e.copyAttributeFlags[Df.PASSDATA][hu[c]]=!1},t[`copy${a}On`]=()=>{const c=a.toUpperCase();e.copyAttributeFlags[Df.PASSDATA][hu[c]]=!0}}),t.initializeAttributeCopyFlags=()=>{e.copyAttributeFlags=[],Object.keys(Df).filter(a=>a!=="ALLCOPY").forEach(a=>{e.copyAttributeFlags[Df[a]]=Object.keys(hu).filter(s=>s!=="NUM_ATTRIBUTES").reduce((s,c)=>(s[hu[c]]=!0,s),[])}),e.copyAttributeFlags[Df.COPYTUPLE][hu.GLOBALIDS]=!1,e.copyAttributeFlags[Df.INTERPOLATE][hu.GLOBALIDS]=!1,e.copyAttributeFlags[Df.COPYTUPLE][hu.PEDIGREEIDS]=!1},t.initialize=Z.chain(t.initialize,t.initializeAttributeCopyFlags),e.dataArrays&&Object.keys(e.dataArrays).length&&Object.keys(e.dataArrays).forEach(a=>{!e.dataArrays[a].ref&&e.dataArrays[a].type==="vtkDataArray"&&t.addArray(bt.newInstance(e.dataArrays[a]))});const o=t.shallowCopy;t.shallowCopy=(a,s)=>{o(a,s),e.arrays=a.getArrays().map(c=>{const l=c.newClone();return l.shallowCopy(c,s),{data:l}})},t.initializeAttributeCopyFlags()}const YJ={activeScalars:-1,activeVectors:-1,activeTensors:-1,activeNormals:-1,activeTCoords:-1,activeGlobalIds:-1,activePedigreeIds:-1};function fL(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,YJ,r),WJ.extend(t,e,r),Z.setGet(t,e,["activeScalars","activeNormals","activeTCoords","activeVectors","activeTensors","activeGlobalIds","activePedigreeIds"]),e.arrays||(e.arrays={}),XJ(t,e)}const JJ=Z.newInstance(fL,"vtkDataSetAttributes");var tD={newInstance:JJ,extend:fL,...uL};const ZJ={UNIFORM:0,DATA_OBJECT_FIELD:0,COORDINATE:1,POINT_DATA:1,POINT:2,POINT_FIELD_DATA:2,CELL:3,CELL_FIELD_DATA:3,VERTEX:4,VERTEX_FIELD_DATA:4,EDGE:5,EDGE_FIELD_DATA:5,ROW:6,ROW_DATA:6},QJ={FIELD_ASSOCIATION_POINTS:0,FIELD_ASSOCIATION_CELLS:1,FIELD_ASSOCIATION_NONE:2,FIELD_ASSOCIATION_POINTS_THEN_CELLS:3,FIELD_ASSOCIATION_VERTICES:4,FIELD_ASSOCIATION_EDGES:5,FIELD_ASSOCIATION_ROWS:6,NUMBER_OF_ASSOCIATIONS:7};var eZ={FieldDataTypes:ZJ,FieldAssociations:QJ};const uS=["pointData","cellData","fieldData"];function tZ(t,e){e.classHierarchy.push("vtkDataSet"),uS.forEach(n=>{e[n]?e[n]=nc(e[n]):e[n]=tD.newInstance()});const r=t.shallowCopy;t.shallowCopy=function(n){let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;r(n,i),uS.forEach(o=>{e[o]=tD.newInstance(),e[o].shallowCopy(n.getReferenceByName(o))})}}const nZ={};function dL(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,nZ,r),Z.obj(t,e),Z.setGet(t,e,uS),tZ(t,e)}const rZ=Z.newInstance(dL,"vtkDataSet");var Wh={newInstance:rZ,extend:dL,...eZ};const{FieldAssociations:iZ}=Wh;function oZ(t,e){e.classHierarchy.push("vtkHardwareSelector"),t.getSourceDataAsync=async(r,n,i,o,a)=>{},t.selectAsync=async(r,n,i,o,a)=>{const s=await t.getSourceDataAsync(r,n,i,o,a);return s?s.generateSelection(n,i,o,a):[]}}const aZ={fieldAssociation:iZ.FIELD_ASSOCIATION_CELLS,captureZValues:!1};function hL(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,aZ,r),Z.obj(t,e),Z.setGet(t,e,["fieldAssociation","captureZValues"]),oZ(t,e)}const sZ=Z.newInstance(hL,"vtkHardwareSelector");var cZ={newInstance:sZ,extend:hL};const lZ={GLOBALIDS:0,PEDIGREEIDS:1,VALUES:2,INDICES:3,FRUSTUM:4,LOCATIONS:5,THRESHOLDS:6,BLOCKS:7,QUERY:8},uZ={CELL:0,POINT:1,FIELD:2,VERTEX:3,EDGE:4,ROW:5};var fZ={SelectionContent:lZ,SelectionField:uZ};function dZ(t,e){e.classHierarchy.push("vtkSelectionNode"),t.getBounds=()=>e.points.getBounds()}const hZ={contentType:-1,fieldType:-1,properties:null,selectionList:[]};function gL(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,hZ,r),Z.obj(t,e),e.properties={},Z.setGet(t,e,["contentType","fieldType","properties","selectionList"]),dZ(t,e)}const gZ=Z.newInstance(gL,"vtkSelectionNode");var pL={newInstance:gZ,extend:gL,...fZ};const{PassTypes:si}=cL,{SelectionContent:pZ,SelectionField:nD}=pL,{FieldAssociations:mp}=Wh,{vtkErrorMacro:mL}=Z,Pu=1;function vL(t){return`${t.propID} ${t.compositeID}`}function yL(t,e,r,n){if(!r)return 0;const i=(e*(n[2]-n[0]+1)+t)*4;return r[i+3]}function Nl(t,e,r,n){if(!r)return 0;const i=(e*(n[2]-n[0]+1)+t)*4,o=r[i],a=r[i+1];return(r[i+2]*256+a)*256+o}function wL(t,e){let r=e;return r<<=24,r|=t,r}function mZ(t,e,r,n){{if(n[0]=e[0],n[1]=e[1],e[0]<t.area[0]||e[0]>t.area[2]||e[1]<t.area[1]||e[1]>t.area[3])return null;const i=[e[0]-t.area[0],e[1]-t.area[1]],o=Nl(i[0],i[1],t.pixBuffer[si.ACTOR_PASS],t.area);if(o<=0||o-Pu>=t.props.length)return null;const a={};a.valid=!0,a.propID=o-Pu,a.prop=t.props[a.propID];let s=Nl(i[0],i[1],t.pixBuffer[si.COMPOSITE_INDEX_PASS],t.area);if((s<0||s>16777215)&&(s=0),a.compositeID=s-Pu,t.captureZValues){const f=(i[1]*(t.area[2]-t.area[0]+1)+i[0])*4;a.zValue=(256*t.zBuffer[f]+t.zBuffer[f+1])/65535,a.displayPosition=e}if(t.pixBuffer[si.ID_LOW24]&&yL(i[0],i[1],t.pixBuffer[si.ID_LOW24],t.area)===0)return a;const c=Nl(i[0],i[1],t.pixBuffer[si.ID_LOW24],t.area),l=Nl(i[0],i[1],t.pixBuffer[si.ID_HIGH24],t.area);return a.attributeID=wL(c,l),a}}function xL(t,e,r,n,i){const o=[];let a=0;return e.forEach((s,c)=>{const l=pL.newInstance();switch(l.setContentType(pZ.INDICES),t){case mp.FIELD_ASSOCIATION_CELLS:l.setFieldType(nD.CELL);break;case mp.FIELD_ASSOCIATION_POINTS:l.setFieldType(nD.POINT);break;default:mL("Unknown field association")}l.getProperties().propID=s.info.propID,l.getProperties().prop=s.info.prop,l.getProperties().compositeID=s.info.compositeID,l.getProperties().attributeID=s.info.attributeID,l.getProperties().pixelCount=s.pixelCount,r&&(l.getProperties().displayPosition=[s.info.displayPosition[0],s.info.displayPosition[1],s.info.zValue],l.getProperties().worldPosition=i.displayToWorld(s.info.displayPosition[0],s.info.displayPosition[1],s.info.zValue,n)),l.setSelectionList(s.attributeIDs),o[a]=l,a++}),o}function vZ(t,e,r,n,i){const o=Math.floor(e),a=Math.floor(r),s=Math.floor(n),c=Math.floor(i),l=new Map,f=[0,0];for(let u=a;u<=c;u++)for(let d=o;d<=s;d++){const g=mZ(t,[d,u],0,f);if(g&&g.valid){const p=vL(g);if(!l.has(p))l.set(p,{info:g,pixelCount:1,attributeIDs:[g.attributeID]});else{const v=l.get(p);v.pixelCount++,t.captureZValues&&g.zValue<v.info.zValue&&(v.info=g),v.attributeIDs.indexOf(g.attributeID)===-1&&v.attributeIDs.push(g.attributeID)}}}return xL(t.fieldAssociation,l,t.captureZValues,t.renderer,t.openGLRenderWindow)}function yZ(t,e){e.classHierarchy.push("vtkOpenGLHardwareSelector"),t.releasePixBuffers=()=>{e.rawPixBuffer=[],e.pixBuffer=[],e.zBuffer=null},t.beginSelection=()=>{e._openGLRenderer=e._openGLRenderWindow.getViewNodeFor(e._renderer),e.maxAttributeId=0;const n=e._openGLRenderWindow.getSize();if(!e.framebuffer)e.framebuffer=ew.newInstance(),e.framebuffer.setOpenGLRenderWindow(e._openGLRenderWindow),e.framebuffer.saveCurrentBindingsAndBuffers(),e.framebuffer.create(n[0],n[1]),e.framebuffer.populateFramebuffer();else{e.framebuffer.setOpenGLRenderWindow(e._openGLRenderWindow),e.framebuffer.saveCurrentBindingsAndBuffers();const i=e.framebuffer.getSize();!i||i[0]!==n[0]||i[1]!==n[1]?(e.framebuffer.create(n[0],n[1]),e.framebuffer.populateFramebuffer()):e.framebuffer.bind()}if(e._openGLRenderer.clear(),e._openGLRenderer.setSelector(t),e.hitProps={},e.propPixels={},e.props=[],t.releasePixBuffers(),e.fieldAssociation===mp.FIELD_ASSOCIATION_POINTS){const i=e._openGLRenderWindow.getContext(),o=i.isEnabled(i.BLEND);i.disable(i.BLEND),e._openGLRenderWindow.traverseAllPasses(),o&&i.enable(i.BLEND)}},t.endSelection=()=>{e.hitProps={},e._openGLRenderer.setSelector(null),e.framebuffer.restorePreviousBindingsAndBuffers()},t.preCapturePass=()=>{const n=e._openGLRenderWindow.getContext();e.originalBlending=n.isEnabled(n.BLEND),n.disable(n.BLEND)},t.postCapturePass=()=>{const n=e._openGLRenderWindow.getContext();e.originalBlending&&n.enable(n.BLEND)},t.select=()=>{let n=null;return t.captureBuffers()&&(n=t.generateSelection(e.area[0],e.area[1],e.area[2],e.area[3]),t.releasePixBuffers()),n},t.getSourceDataAsync=async(n,i,o,a,s)=>{if(e._renderer=n,i===void 0){const l=e._openGLRenderWindow.getSize();t.setArea(0,0,l[0]-1,l[1]-1)}else t.setArea(i,o,a,s);if(!t.captureBuffers())return!1;const c={area:[...e.area],pixBuffer:[...e.pixBuffer],captureZValues:e.captureZValues,zBuffer:e.zBuffer,props:[...e.props],fieldAssociation:e.fieldAssociation,renderer:n,openGLRenderWindow:e._openGLRenderWindow};return c.generateSelection=function(){for(var l=arguments.length,f=new Array(l),u=0;u<l;u++)f[u]=arguments[u];return vZ(c,...f)},c},t.captureBuffers=()=>{if(!e._renderer||!e._openGLRenderWindow)return mL("Renderer and view must be set before calling Select."),!1;e._openGLRenderer=e._openGLRenderWindow.getViewNodeFor(e._renderer),e._openGLRenderWindow.getRenderable().preRender(),t.invokeEvent({type:"StartEvent"}),e.originalBackground=e._renderer.getBackgroundByReference(),e._renderer.setBackground(0,0,0,0);const n=e._openGLRenderWindow.getRenderPasses();t.beginSelection();const i=[];for(e.currentPass=si.MIN_KNOWN_PASS;e.currentPass<=si.MAX_KNOWN_PASS;e.currentPass++)t.passRequired(e.currentPass)&&(t.preCapturePass(e.currentPass),e.captureZValues&&e.currentPass===si.ACTOR_PASS&&typeof n[0].requestDepth=="function"&&typeof n[0].getFramebuffer=="function"&&n[0].requestDepth(),e._openGLRenderWindow.traverseAllPasses(),t.postCapturePass(e.currentPass),t.savePixelBuffer(e.currentPass),i.push(e.currentPass));return i.forEach(o=>{e.currentPass=o,t.processPixelBuffers()}),e.currentPass=si.MAX_KNOWN_PASS,t.endSelection(),e._renderer.setBackground(e.originalBackground),t.invokeEvent({type:"EndEvent"}),!0},t.processPixelBuffers=()=>{e.props.forEach((n,i)=>{t.isPropHit(i)&&n.processSelectorPixelBuffers(t,e.propPixels[i])})},t.passRequired=n=>{if(n===si.ID_HIGH24){if(e.fieldAssociation===mp.FIELD_ASSOCIATION_POINTS)return e.maximumPointId>16777215;if(e.fieldAssociation===mp.FIELD_ASSOCIATION_CELLS)return e.maximumCellId>16777215}return!0},t.savePixelBuffer=n=>{if(e.pixBuffer[n]=e._openGLRenderWindow.getPixelData(e.area[0],e.area[1],e.area[2],e.area[3]),!e.rawPixBuffer[n]){const i=(e.area[2]-e.area[0]+1)*(e.area[3]-e.area[1]+1)*4;e.rawPixBuffer[n]=new Uint8Array(i),e.rawPixBuffer[n].set(e.pixBuffer[n])}if(n===si.ACTOR_PASS){if(e.captureZValues){const i=e._openGLRenderWindow.getRenderPasses();if(typeof i[0].requestDepth=="function"&&typeof i[0].getFramebuffer=="function"){const o=i[0].getFramebuffer();o.saveCurrentBindingsAndBuffers(),o.bind(),e.zBuffer=e._openGLRenderWindow.getPixelData(e.area[0],e.area[1],e.area[2],e.area[3]),o.restorePreviousBindingsAndBuffers()}}t.buildPropHitList(e.rawPixBuffer[n])}},t.buildPropHitList=n=>{let i=0;for(let o=0;o<=e.area[3]-e.area[1];o++)for(let a=0;a<=e.area[2]-e.area[0];a++){let s=Nl(a,o,n,e.area);s>0&&(s--,s in e.hitProps||(e.hitProps[s]=!0,e.propPixels[s]=[]),e.propPixels[s].push(i*4)),++i}},t.renderProp=n=>{e.currentPass===si.ACTOR_PASS&&(t.setPropColorValueFromInt(e.props.length+Pu),e.props.push(n))},t.renderCompositeIndex=n=>{e.currentPass===si.COMPOSITE_INDEX_PASS&&t.setPropColorValueFromInt(n+Pu)},t.renderAttributeId=n=>{n<0||(e.maxAttributeId=n>e.maxAttributeId?n:e.maxAttributeId)},t.passTypeToString=n=>Z.enumToString(si,n),t.isPropHit=n=>!!e.hitProps[n],t.setPropColorValueFromInt=n=>{e.propColorValue[0]=n%256/255,e.propColorValue[1]=Math.floor(n/256)%256/255,e.propColorValue[2]=Math.floor(n/65536)%256/255},t.getPixelInformation=(n,i,o)=>{const a=i<0?0:i;if(a===0){if(o[0]=n[0],o[1]=n[1],n[0]<e.area[0]||n[0]>e.area[2]||n[1]<e.area[1]||n[1]>e.area[3])return null;const f=[n[0]-e.area[0],n[1]-e.area[1]],u=Nl(f[0],f[1],e.pixBuffer[si.ACTOR_PASS],e.area);if(u<=0||u-Pu>=e.props.length)return null;const d={};d.valid=!0,d.propID=u-Pu,d.prop=e.props[d.propID];let h=Nl(f[0],f[1],e.pixBuffer[si.COMPOSITE_INDEX_PASS],e.area);if((h<0||h>16777215)&&(h=0),d.compositeID=h-Pu,e.captureZValues){const v=(f[1]*(e.area[2]-e.area[0]+1)+f[0])*4;d.zValue=(256*e.zBuffer[v]+e.zBuffer[v+1])/65535,d.displayPosition=n}if(e.pixBuffer[si.ID_LOW24]&&yL(f[0],f[1],e.pixBuffer[si.ID_LOW24],e.area)===0)return d;const g=Nl(f[0],f[1],e.pixBuffer[si.ID_LOW24],e.area),p=Nl(f[0],f[1],e.pixBuffer[si.ID_HIGH24],e.area);return d.attributeID=wL(g,p),d}const s=[n[0],n[1]],c=[0,0];let l=t.getPixelInformation(n,0,o);if(l&&l.valid)return l;for(let f=1;f<a;++f){for(let u=s[1]>f?s[1]-f:0;u<=s[1]+f;++u)if(c[1]=u,s[0]>=f&&(c[0]=s[0]-f,l=t.getPixelInformation(c,0,o),l&&l.valid)||(c[0]=s[0]+f,l=t.getPixelInformation(c,0,o),l&&l.valid))return l;for(let u=s[0]>=f?s[0]-(f-1):0;u<=s[0]+(f-1);++u)if(c[0]=u,s[1]>=f&&(c[1]=s[1]-f,l=t.getPixelInformation(c,0,o),l&&l.valid)||(c[1]=s[1]+f,l=t.getPixelInformation(c,0,o),l&&l.valid))return l}return o[0]=n[0],o[1]=n[1],null},t.generateSelection=(n,i,o,a)=>{const s=Math.floor(n),c=Math.floor(i),l=Math.floor(o),f=Math.floor(a),u=new Map,d=[0,0];for(let h=c;h<=f;h++)for(let g=s;g<=l;g++){const p=[g,h],v=t.getPixelInformation(p,0,d);if(v&&v.valid){const y=vL(v);if(!u.has(y))u.set(y,{info:v,pixelCount:1,attributeIDs:[v.attributeID]});else{const m=u.get(y);m.pixelCount++,e.captureZValues&&v.zValue<m.info.zValue&&(m.info=v),m.attributeIDs.indexOf(v.attributeID)===-1&&m.attributeIDs.push(v.attributeID)}}}return xL(e.fieldAssociation,u,e.captureZValues,e._renderer,e._openGLRenderWindow)},t.getRawPixelBuffer=n=>e.rawPixBuffer[n],t.getPixelBuffer=n=>e.pixBuffer[n],t.attach=(n,i)=>{e._openGLRenderWindow=n,e._renderer=i};const r=t.setArea;t.setArea=function(){return r(...arguments)?(e.area[0]=Math.floor(e.area[0]),e.area[1]=Math.floor(e.area[1]),e.area[2]=Math.floor(e.area[2]),e.area[3]=Math.floor(e.area[3]),!0):!1}}const wZ={area:void 0,currentPass:-1,propColorValue:null,props:null,maximumPointId:0,maximumCellId:0,idOffset:1};function CL(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,wZ,r),cZ.extend(t,e,r),e.propColorValue=[0,0,0],e.props=[],e.area||(e.area=[0,0,0,0]),Z.setGetArray(t,e,["area"],4),Z.setGet(t,e,["_renderer","currentPass","_openGLRenderWindow","maximumPointId","maximumCellId"]),Z.setGetArray(t,e,["propColorValue"],3),Z.moveToProtected(t,e,["renderer","openGLRenderWindow"]),Z.event(t,e,"event"),yZ(t,e)}const xZ=Z.newInstance(CL,"vtkOpenGLHardwareSelector");var f4={newInstance:xZ,extend:CL,...cL},SL={exports:{}};(function(t,e){(function(r){t.exports=r()})(function(r){var n=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function i(y,m){var w=y[0],x=y[1],C=y[2],S=y[3];w+=(x&C|~x&S)+m[0]-680876936|0,w=(w<<7|w>>>25)+x|0,S+=(w&x|~w&C)+m[1]-389564586|0,S=(S<<12|S>>>20)+w|0,C+=(S&w|~S&x)+m[2]+606105819|0,C=(C<<17|C>>>15)+S|0,x+=(C&S|~C&w)+m[3]-1044525330|0,x=(x<<22|x>>>10)+C|0,w+=(x&C|~x&S)+m[4]-176418897|0,w=(w<<7|w>>>25)+x|0,S+=(w&x|~w&C)+m[5]+1200080426|0,S=(S<<12|S>>>20)+w|0,C+=(S&w|~S&x)+m[6]-1473231341|0,C=(C<<17|C>>>15)+S|0,x+=(C&S|~C&w)+m[7]-45705983|0,x=(x<<22|x>>>10)+C|0,w+=(x&C|~x&S)+m[8]+1770035416|0,w=(w<<7|w>>>25)+x|0,S+=(w&x|~w&C)+m[9]-1958414417|0,S=(S<<12|S>>>20)+w|0,C+=(S&w|~S&x)+m[10]-42063|0,C=(C<<17|C>>>15)+S|0,x+=(C&S|~C&w)+m[11]-1990404162|0,x=(x<<22|x>>>10)+C|0,w+=(x&C|~x&S)+m[12]+1804603682|0,w=(w<<7|w>>>25)+x|0,S+=(w&x|~w&C)+m[13]-40341101|0,S=(S<<12|S>>>20)+w|0,C+=(S&w|~S&x)+m[14]-1502002290|0,C=(C<<17|C>>>15)+S|0,x+=(C&S|~C&w)+m[15]+1236535329|0,x=(x<<22|x>>>10)+C|0,w+=(x&S|C&~S)+m[1]-165796510|0,w=(w<<5|w>>>27)+x|0,S+=(w&C|x&~C)+m[6]-1069501632|0,S=(S<<9|S>>>23)+w|0,C+=(S&x|w&~x)+m[11]+643717713|0,C=(C<<14|C>>>18)+S|0,x+=(C&w|S&~w)+m[0]-373897302|0,x=(x<<20|x>>>12)+C|0,w+=(x&S|C&~S)+m[5]-701558691|0,w=(w<<5|w>>>27)+x|0,S+=(w&C|x&~C)+m[10]+38016083|0,S=(S<<9|S>>>23)+w|0,C+=(S&x|w&~x)+m[15]-660478335|0,C=(C<<14|C>>>18)+S|0,x+=(C&w|S&~w)+m[4]-405537848|0,x=(x<<20|x>>>12)+C|0,w+=(x&S|C&~S)+m[9]+568446438|0,w=(w<<5|w>>>27)+x|0,S+=(w&C|x&~C)+m[14]-1019803690|0,S=(S<<9|S>>>23)+w|0,C+=(S&x|w&~x)+m[3]-187363961|0,C=(C<<14|C>>>18)+S|0,x+=(C&w|S&~w)+m[8]+1163531501|0,x=(x<<20|x>>>12)+C|0,w+=(x&S|C&~S)+m[13]-1444681467|0,w=(w<<5|w>>>27)+x|0,S+=(w&C|x&~C)+m[2]-51403784|0,S=(S<<9|S>>>23)+w|0,C+=(S&x|w&~x)+m[7]+1735328473|0,C=(C<<14|C>>>18)+S|0,x+=(C&w|S&~w)+m[12]-1926607734|0,x=(x<<20|x>>>12)+C|0,w+=(x^C^S)+m[5]-378558|0,w=(w<<4|w>>>28)+x|0,S+=(w^x^C)+m[8]-2022574463|0,S=(S<<11|S>>>21)+w|0,C+=(S^w^x)+m[11]+1839030562|0,C=(C<<16|C>>>16)+S|0,x+=(C^S^w)+m[14]-35309556|0,x=(x<<23|x>>>9)+C|0,w+=(x^C^S)+m[1]-1530992060|0,w=(w<<4|w>>>28)+x|0,S+=(w^x^C)+m[4]+1272893353|0,S=(S<<11|S>>>21)+w|0,C+=(S^w^x)+m[7]-155497632|0,C=(C<<16|C>>>16)+S|0,x+=(C^S^w)+m[10]-1094730640|0,x=(x<<23|x>>>9)+C|0,w+=(x^C^S)+m[13]+681279174|0,w=(w<<4|w>>>28)+x|0,S+=(w^x^C)+m[0]-358537222|0,S=(S<<11|S>>>21)+w|0,C+=(S^w^x)+m[3]-722521979|0,C=(C<<16|C>>>16)+S|0,x+=(C^S^w)+m[6]+76029189|0,x=(x<<23|x>>>9)+C|0,w+=(x^C^S)+m[9]-640364487|0,w=(w<<4|w>>>28)+x|0,S+=(w^x^C)+m[12]-421815835|0,S=(S<<11|S>>>21)+w|0,C+=(S^w^x)+m[15]+530742520|0,C=(C<<16|C>>>16)+S|0,x+=(C^S^w)+m[2]-995338651|0,x=(x<<23|x>>>9)+C|0,w+=(C^(x|~S))+m[0]-198630844|0,w=(w<<6|w>>>26)+x|0,S+=(x^(w|~C))+m[7]+1126891415|0,S=(S<<10|S>>>22)+w|0,C+=(w^(S|~x))+m[14]-1416354905|0,C=(C<<15|C>>>17)+S|0,x+=(S^(C|~w))+m[5]-57434055|0,x=(x<<21|x>>>11)+C|0,w+=(C^(x|~S))+m[12]+1700485571|0,w=(w<<6|w>>>26)+x|0,S+=(x^(w|~C))+m[3]-1894986606|0,S=(S<<10|S>>>22)+w|0,C+=(w^(S|~x))+m[10]-1051523|0,C=(C<<15|C>>>17)+S|0,x+=(S^(C|~w))+m[1]-2054922799|0,x=(x<<21|x>>>11)+C|0,w+=(C^(x|~S))+m[8]+1873313359|0,w=(w<<6|w>>>26)+x|0,S+=(x^(w|~C))+m[15]-30611744|0,S=(S<<10|S>>>22)+w|0,C+=(w^(S|~x))+m[6]-1560198380|0,C=(C<<15|C>>>17)+S|0,x+=(S^(C|~w))+m[13]+1309151649|0,x=(x<<21|x>>>11)+C|0,w+=(C^(x|~S))+m[4]-145523070|0,w=(w<<6|w>>>26)+x|0,S+=(x^(w|~C))+m[11]-1120210379|0,S=(S<<10|S>>>22)+w|0,C+=(w^(S|~x))+m[2]+718787259|0,C=(C<<15|C>>>17)+S|0,x+=(S^(C|~w))+m[9]-343485551|0,x=(x<<21|x>>>11)+C|0,y[0]=w+y[0]|0,y[1]=x+y[1]|0,y[2]=C+y[2]|0,y[3]=S+y[3]|0}function o(y){var m=[],w;for(w=0;w<64;w+=4)m[w>>2]=y.charCodeAt(w)+(y.charCodeAt(w+1)<<8)+(y.charCodeAt(w+2)<<16)+(y.charCodeAt(w+3)<<24);return m}function a(y){var m=[],w;for(w=0;w<64;w+=4)m[w>>2]=y[w]+(y[w+1]<<8)+(y[w+2]<<16)+(y[w+3]<<24);return m}function s(y){var m=y.length,w=[1732584193,-271733879,-1732584194,271733878],x,C,S,T,_,E;for(x=64;x<=m;x+=64)i(w,o(y.substring(x-64,x)));for(y=y.substring(x-64),C=y.length,S=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],x=0;x<C;x+=1)S[x>>2]|=y.charCodeAt(x)<<(x%4<<3);if(S[x>>2]|=128<<(x%4<<3),x>55)for(i(w,S),x=0;x<16;x+=1)S[x]=0;return T=m*8,T=T.toString(16).match(/(.*?)(.{0,8})$/),_=parseInt(T[2],16),E=parseInt(T[1],16)||0,S[14]=_,S[15]=E,i(w,S),w}function c(y){var m=y.length,w=[1732584193,-271733879,-1732584194,271733878],x,C,S,T,_,E;for(x=64;x<=m;x+=64)i(w,a(y.subarray(x-64,x)));for(y=x-64<m?y.subarray(x-64):new Uint8Array(0),C=y.length,S=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],x=0;x<C;x+=1)S[x>>2]|=y[x]<<(x%4<<3);if(S[x>>2]|=128<<(x%4<<3),x>55)for(i(w,S),x=0;x<16;x+=1)S[x]=0;return T=m*8,T=T.toString(16).match(/(.*?)(.{0,8})$/),_=parseInt(T[2],16),E=parseInt(T[1],16)||0,S[14]=_,S[15]=E,i(w,S),w}function l(y){var m="",w;for(w=0;w<4;w+=1)m+=n[y>>w*8+4&15]+n[y>>w*8&15];return m}function f(y){var m;for(m=0;m<y.length;m+=1)y[m]=l(y[m]);return y.join("")}f(s("hello")),typeof ArrayBuffer<"u"&&!ArrayBuffer.prototype.slice&&function(){function y(m,w){return m=m|0||0,m<0?Math.max(m+w,0):Math.min(m,w)}ArrayBuffer.prototype.slice=function(m,w){var x=this.byteLength,C=y(m,x),S=x,T,_,E,b;return w!==r&&(S=y(w,x)),C>S?new ArrayBuffer(0):(T=S-C,_=new ArrayBuffer(T),E=new Uint8Array(_),b=new Uint8Array(this,C,T),E.set(b),_)}}();function u(y){return/[\u0080-\uFFFF]/.test(y)&&(y=unescape(encodeURIComponent(y))),y}function d(y,m){var w=y.length,x=new ArrayBuffer(w),C=new Uint8Array(x),S;for(S=0;S<w;S+=1)C[S]=y.charCodeAt(S);return m?C:x}function h(y){return String.fromCharCode.apply(null,new Uint8Array(y))}function g(y,m,w){var x=new Uint8Array(y.byteLength+m.byteLength);return x.set(new Uint8Array(y)),x.set(new Uint8Array(m),y.byteLength),x}function p(y){var m=[],w=y.length,x;for(x=0;x<w-1;x+=2)m.push(parseInt(y.substr(x,2),16));return String.fromCharCode.apply(String,m)}function v(){this.reset()}return v.prototype.append=function(y){return this.appendBinary(u(y)),this},v.prototype.appendBinary=function(y){this._buff+=y,this._length+=y.length;var m=this._buff.length,w;for(w=64;w<=m;w+=64)i(this._hash,o(this._buff.substring(w-64,w)));return this._buff=this._buff.substring(w-64),this},v.prototype.end=function(y){var m=this._buff,w=m.length,x,C=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],S;for(x=0;x<w;x+=1)C[x>>2]|=m.charCodeAt(x)<<(x%4<<3);return this._finish(C,w),S=f(this._hash),y&&(S=p(S)),this.reset(),S},v.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},v.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},v.prototype.setState=function(y){return this._buff=y.buff,this._length=y.length,this._hash=y.hash,this},v.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},v.prototype._finish=function(y,m){var w=m,x,C,S;if(y[w>>2]|=128<<(w%4<<3),w>55)for(i(this._hash,y),w=0;w<16;w+=1)y[w]=0;x=this._length*8,x=x.toString(16).match(/(.*?)(.{0,8})$/),C=parseInt(x[2],16),S=parseInt(x[1],16)||0,y[14]=C,y[15]=S,i(this._hash,y)},v.hash=function(y,m){return v.hashBinary(u(y),m)},v.hashBinary=function(y,m){var w=s(y),x=f(w);return m?p(x):x},v.ArrayBuffer=function(){this.reset()},v.ArrayBuffer.prototype.append=function(y){var m=g(this._buff.buffer,y),w=m.length,x;for(this._length+=y.byteLength,x=64;x<=w;x+=64)i(this._hash,a(m.subarray(x-64,x)));return this._buff=x-64<w?new Uint8Array(m.buffer.slice(x-64)):new Uint8Array(0),this},v.ArrayBuffer.prototype.end=function(y){var m=this._buff,w=m.length,x=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],C,S;for(C=0;C<w;C+=1)x[C>>2]|=m[C]<<(C%4<<3);return this._finish(x,w),S=f(this._hash),y&&(S=p(S)),this.reset(),S},v.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},v.ArrayBuffer.prototype.getState=function(){var y=v.prototype.getState.call(this);return y.buff=h(y.buff),y},v.ArrayBuffer.prototype.setState=function(y){return y.buff=d(y.buff,!0),v.prototype.setState.call(this,y)},v.ArrayBuffer.prototype.destroy=v.prototype.destroy,v.ArrayBuffer.prototype._finish=v.prototype._finish,v.ArrayBuffer.hash=function(y,m){var w=c(new Uint8Array(y)),x=f(w);return m?p(x):x},v})})(SL);var CZ=SL.exports;const SZ=ll(CZ),TZ=["lastShaderProgramBound","context","_openGLRenderWindow"];function _Z(t,e){e.classHierarchy.push("vtkShaderCache"),t.replaceShaderValues=(r,n,i)=>{let o=n;i.length>0&&(o=Be.substitute(o,"VSOut","GSOut").result);const a=e._openGLRenderWindow.getWebgl2();let s=`
|
||
`,c=`#version 100
|
||
`;a?c=`#version 300 es
|
||
#define attribute in
|
||
#define textureCube texture
|
||
#define texture2D texture
|
||
#define textureCubeLod textureLod
|
||
#define texture2DLod textureLod
|
||
`:(e.context.getExtension("OES_standard_derivatives"),e.context.getExtension("EXT_frag_depth")&&(s=`#extension GL_EXT_frag_depth : enable
|
||
`),e.context.getExtension("EXT_shader_texture_lod")&&(s+=`#extension GL_EXT_shader_texture_lod : enable
|
||
#define textureCubeLod textureCubeLodEXT
|
||
#define texture2DLod texture2DLodEXT`)),o=Be.substitute(o,"//VTK::System::Dec",[`${c}
|
||
`,a?"":`#extension GL_OES_standard_derivatives : enable
|
||
`,s,"#ifdef GL_FRAGMENT_PRECISION_HIGH","precision highp float;","precision highp int;","#else","precision mediump float;","precision mediump int;","#endif"]).result;let l=Be.substitute(r,"//VTK::System::Dec",[`${c}
|
||
`,"#ifdef GL_FRAGMENT_PRECISION_HIGH","precision highp float;","precision highp int;","#else","precision mediump float;","precision mediump int;","#endif"]).result;if(a){l=Be.substitute(l,"varying","out").result,o=Be.substitute(o,"varying","in").result;let u="",d=0;for(;o.includes(`gl_FragData[${d}]`);)o=Be.substitute(o,`gl_FragData\\[${d}\\]`,`fragOutput${d}`).result,u+=`layout(location = ${d}) out vec4 fragOutput${d};
|
||
`,d++;o=Be.substitute(o,"//VTK::Output::Dec",u).result}const f=Be.substitute(i,"//VTK::System::Dec",c).result;return{VSSource:l,FSSource:o,GSSource:f}},t.readyShaderProgramArray=(r,n,i)=>{const o=t.replaceShaderValues(r,n,i),a=t.getShaderProgram(o.VSSource,o.FSSource,o.GSSource);return t.readyShaderProgram(a)},t.readyShaderProgram=r=>!r||!r.getCompiled()&&!r.compileShader()||!t.bindShaderProgram(r)?null:r,t.getShaderProgram=(r,n,i)=>{const o=`${r}${n}${i}`,a=SZ.hash(o);if(!(a in e.shaderPrograms)){const s=Be.newInstance();return s.setContext(e.context),s.getVertexShader().setSource(r),s.getFragmentShader().setSource(n),i&&s.getGeometryShader().setSource(i),s.setMd5Hash(a),e.shaderPrograms[a]=s,s}return e.shaderPrograms[a]},t.releaseGraphicsResources=r=>{t.releaseCurrentShaderProgram(),Object.keys(e.shaderPrograms).map(n=>e.shaderPrograms[n]).forEach(n=>n.cleanup()),e.shaderPrograms={}},t.releaseCurrentShaderProgram=()=>{e.lastShaderProgramBound&&(e.lastShaderProgramBound.cleanup(),e.lastShaderProgramBound=null)},t.bindShaderProgram=r=>(e.lastShaderProgramBound===r||(e.lastShaderProgramBound&&e.lastShaderProgramBound.release(),r.bind(),e.lastShaderProgramBound=r),1)}const EZ={lastShaderProgramBound:null,shaderPrograms:null,context:null};function TL(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,EZ,r),e.shaderPrograms={},Z.obj(t,e),Z.setGet(t,e,TZ),Z.moveToProtected(t,e,["openGLRenderWindow"]),_Z(t,e)}const bZ=Z.newInstance(TL,"vtkShaderCache");var DZ={newInstance:bZ,extend:TL};const{vtkErrorMacro:IZ}=Z;function OZ(t,e){e.classHierarchy.push("vtkOpenGLTextureUnitManager"),t.deleteTable=()=>{for(let r=0;r<e.numberOfTextureUnits;++r)e.textureUnits[r]===!0&&IZ("some texture units were not properly released");e.textureUnits=[],e.numberOfTextureUnits=0},t.setContext=r=>{if(e.context!==r){if(e.context!==0&&t.deleteTable(),e.context=r,e.context){e.numberOfTextureUnits=r.getParameter(r.MAX_TEXTURE_IMAGE_UNITS);for(let n=0;n<e.numberOfTextureUnits;++n)e.textureUnits[n]=!1}t.modified()}},t.allocate=()=>{for(let r=0;r<e.numberOfTextureUnits;r++)if(!t.isAllocated(r))return e.textureUnits[r]=!0,r;return-1},t.allocateUnit=r=>t.isAllocated(r)?-1:(e.textureUnits[r]=!0,r),t.isAllocated=r=>e.textureUnits[r],t.free=r=>{e.textureUnits[r]=!1},t.freeAll=()=>{for(let r=0;r<e.numberOfTextureUnits;++r)e.textureUnits[r]=!1}}const MZ={context:null,numberOfTextureUnits:0,textureUnits:0};function _L(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,MZ,r),Z.obj(t,e),e.textureUnits=[],Z.get(t,e,["numberOfTextureUnits"]),Z.setGet(t,e,["context"]),OZ(t,e)}const PZ=Z.newInstance(_L,"vtkOpenGLTextureUnitManager");var RZ={newInstance:PZ,extend:_L};function LZ(t,e){e.classHierarchy.push("vtkRenderWindowViewNode"),t.getViewNodeFactory=()=>null,t.getAspectRatio=()=>e.size[0]/e.size[1],t.getAspectRatioForRenderer=r=>{const n=r.getViewportByReference();return e.size[0]*(n[2]-n[0])/((n[3]-n[1])*e.size[1])},t.isInViewport=(r,n,i)=>{const o=i.getViewportByReference(),a=t.getFramebufferSize();return o[0]*a[0]<=r&&o[2]*a[0]>=r&&o[1]*a[1]<=n&&o[3]*a[1]>=n},t.getViewportSize=r=>{const n=r.getViewportByReference(),i=t.getFramebufferSize();return[(n[2]-n[0])*i[0],(n[3]-n[1])*i[1]]},t.getViewportCenter=r=>{const n=t.getViewportSize(r);return[n[0]*.5,n[1]*.5]},t.displayToNormalizedDisplay=(r,n,i)=>{const o=t.getFramebufferSize();return[r/o[0],n/o[1],i]},t.normalizedDisplayToDisplay=(r,n,i)=>{const o=t.getFramebufferSize();return[r*o[0],n*o[1],i]},t.worldToView=(r,n,i,o)=>o.worldToView(r,n,i),t.viewToWorld=(r,n,i,o)=>o.viewToWorld(r,n,i),t.worldToDisplay=(r,n,i,o)=>{const a=o.worldToView(r,n,i),s=t.getViewportSize(o),c=o.viewToProjection(a[0],a[1],a[2],s[0]/s[1]),l=o.projectionToNormalizedDisplay(c[0],c[1],c[2]);return t.normalizedDisplayToDisplay(l[0],l[1],l[2])},t.displayToWorld=(r,n,i,o)=>{const a=t.displayToNormalizedDisplay(r,n,i),s=o.normalizedDisplayToProjection(a[0],a[1],a[2]),c=t.getViewportSize(o),l=o.projectionToView(s[0],s[1],s[2],c[0]/c[1]);return o.viewToWorld(l[0],l[1],l[2])},t.normalizedDisplayToViewport=(r,n,i,o)=>{let a=o.getViewportByReference();a=t.normalizedDisplayToDisplay(a[0],a[1],0);const s=t.normalizedDisplayToDisplay(r,n,i);return[s[0]-a[0]-.5,s[1]-a[1]-.5,i]},t.viewportToNormalizedViewport=(r,n,i,o)=>{const a=t.getViewportSize(o);return a&&a[0]!==0&&a[1]!==0?[r/(a[0]-1),n/(a[1]-1),i]:[r,n,i]},t.normalizedViewportToViewport=(r,n,i,o)=>{const a=t.getViewportSize(o);return[r*(a[0]-1),n*(a[1]-1),i]},t.displayToLocalDisplay=(r,n,i)=>{const o=t.getFramebufferSize();return[r,o[1]-n-1,i]},t.viewportToNormalizedDisplay=(r,n,i,o)=>{let a=o.getViewportByReference();a=t.normalizedDisplayToDisplay(a[0],a[1],0);const s=r+a[0]+.5,c=n+a[1]+.5;return t.displayToNormalizedDisplay(s,c,i)},t.getComputedDevicePixelRatio=()=>e.size[0]/t.getContainerSize()[0],t.getContainerSize=()=>{Z.vtkErrorMacro("not implemented")},t.getPixelData=(r,n,i,o)=>{Z.vtkErrorMacro("not implemented")},t.createSelector=()=>{Z.vtkErrorMacro("not implemented")}}const AZ={size:void 0,selector:void 0};function EL(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,AZ,r),e.size||(e.size=[300,300]),Z.getArray(t,e,["size"],2),Z.get(t,e,["selector"]),Qn.extend(t,e,r),LZ(t,e)}const NZ=Z.newInstance(EL,"vtkRenderWindowViewNode");var kZ={newInstance:NZ,extend:EL};const VZ="__getUnderlyingContext";function FZ(){const t=new Map,e={apply(i,o,a){return t.has(a[0])?t.get(a[0]):i.apply(o,a)}};function r(i){return{apply(o,a,s){return t.set(i,s[0]),o.apply(a,s)}}}const n=Object.create(null);return n.getParameter=(i,o,a,s)=>new Proxy(s.bind(i),e),n.depthMask=(i,o,a,s)=>new Proxy(s.bind(i),r(i.DEPTH_WRITEMASK)),{get(i,o,a){if(o===VZ)return()=>i;let s=Reflect.get(i,o,i);s instanceof Function&&(s=s.bind(i));const c=n[o];return c?c(i,o,a,s):s}}}const{vtkDebugMacro:rD,vtkErrorMacro:iD}=Z,UZ={position:"absolute",top:0,left:0,width:"100%",height:"100%"},BZ=["activateTexture","deactivateTexture","disableCullFace","enableCullFace","get3DContext","getActiveFramebuffer","getContext","getDefaultTextureByteSize","getDefaultTextureInternalFormat","getDefaultToWebgl2","getGLInformations","getGraphicsMemoryInfo","getGraphicsResourceForObject","getHardwareMaximumLineWidth","getPixelData","getShaderCache","getTextureUnitForTexture","getTextureUnitManager","getWebgl2","makeCurrent","releaseGraphicsResources","registerGraphicsResourceUser","unregisterGraphicsResourceUser","restoreContext","setActiveFramebuffer","setContext","setDefaultToWebgl2","setGraphicsResourceForObject"];function Go(t,e,r){const n=t.createFramebuffer(),i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i),t.texImage2D(t.TEXTURE_2D,0,e,2,2,0,e,r,null),t.bindFramebuffer(t.FRAMEBUFFER,n),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,0);const o=t.checkFramebufferStatus(t.FRAMEBUFFER);return t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindTexture(t.TEXTURE_2D,null),o===t.FRAMEBUFFER_COMPLETE}let _y=0;const rw=[];function GZ(){_y++,rw.forEach(t=>t(_y))}function WZ(){_y--,rw.forEach(t=>t(_y))}function zZ(t){rw.push(t)}function $Z(t){return rw.pop()}function oD(t){t.preventDefault()}function jZ(t,e){e.classHierarchy.push("vtkOpenGLRenderWindow");let r;function n(){return r||(r=FZ()),r}t.getViewNodeFactory=()=>e.myFactory,e.canvas.addEventListener("webglcontextlost",oD,!1),e.canvas.addEventListener("webglcontextrestored",t.restoreContext,!1);const i=[0,0];function o(){e.renderable&&(e.size[0]!==i[0]||e.size[1]!==i[1])&&(i[0]=e.size[0],i[1]=e.size[1],e.canvas.setAttribute("width",e.size[0]),e.canvas.setAttribute("height",e.size[1])),e.viewStream&&e.viewStream.setSize(e.size[0],e.size[1]),e.canvas.style.display=e.useOffScreen?"none":"block",e.el&&(e.el.style.cursor=e.cursorVisibility?e.cursor:"none"),e.containerSize=null}t.onModified(o),t.buildPass=u=>{if(u){if(!e.renderable)return;t.prepareNodes(),t.addMissingNodes(e.renderable.getRenderersByReference()),t.addMissingNodes(e.renderable.getChildRenderWindowsByReference()),t.removeUnusedNodes(),t.initialize(),e.children.forEach(d=>{var h;(h=d.setOpenGLRenderWindow)==null||h.call(d,t)})}},t.initialize=()=>{if(!e.initialized){if(e.rootOpenGLRenderWindow=t.getLastAncestorOfType("vtkOpenGLRenderWindow"),e.rootOpenGLRenderWindow)e.context2D=t.get2DContext();else{e.context=t.get3DContext(),t.resizeFromChildRenderWindows(),e.context&&GZ(),e.textureUnitManager=RZ.newInstance(),e.textureUnitManager.setContext(e.context),e.shaderCache.setContext(e.context);const u=e.context;u.blendFuncSeparate(u.SRC_ALPHA,u.ONE_MINUS_SRC_ALPHA,u.ONE,u.ONE_MINUS_SRC_ALPHA),u.depthFunc(u.LEQUAL),u.enable(u.BLEND)}e.initialized=!0}},t.makeCurrent=()=>{e.context.makeCurrent()},t.setContainer=u=>{e.el&&e.el!==u&&(e.canvas.parentNode!==e.el&&iD("Error: canvas parent node does not match container"),e.el.removeChild(e.canvas),e.el.contains(e.bgImage)&&e.el.removeChild(e.bgImage)),e.el!==u&&(e.el=u,e.el&&(e.el.appendChild(e.canvas),e.useBackgroundImage&&e.el.appendChild(e.bgImage)),t.modified())},t.getContainer=()=>e.el,t.getContainerSize=()=>{if(!e.containerSize&&e.el){const{width:u,height:d}=e.el.getBoundingClientRect();e.containerSize=[u,d]}return e.containerSize||e.size},t.getFramebufferSize=()=>{var d;return((d=e.activeFramebuffer)==null?void 0:d.getSize())||e.size},t.getPixelData=(u,d,h,g)=>{const p=new Uint8Array((h-u+1)*(g-d+1)*4);return e.context.readPixels(u,d,h-u+1,g-d+1,e.context.RGBA,e.context.UNSIGNED_BYTE,p),p},t.get3DContext=function(){let u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{preserveDrawingBuffer:!1,depth:!0,alpha:!0,powerPreference:"high-performance"},d=null;const h=typeof WebGL2RenderingContext<"u";return e.webgl2=!1,e.defaultToWebgl2&&h&&(d=e.canvas.getContext("webgl2",u),d&&(e.webgl2=!0,rD("using webgl2"))),d||(rD("using webgl1"),d=e.canvas.getContext("webgl",u)||e.canvas.getContext("experimental-webgl",u)),new Proxy(d,n())},t.get2DContext=function(){let u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return e.canvas.getContext("2d",u)},t.restoreContext=()=>{const u=Y_.newInstance();u.setCurrentOperation("Release"),u.traverse(t,null)},t.activateTexture=u=>{const d=e._textureResourceIds.get(u);if(d!==void 0){e.context.activeTexture(e.context.TEXTURE0+d);return}const h=t.getTextureUnitManager().allocate();if(h<0){iD("Hardware does not support the number of textures defined.");return}e._textureResourceIds.set(u,h),e.context.activeTexture(e.context.TEXTURE0+h)},t.deactivateTexture=u=>{const d=e._textureResourceIds.get(u);d!==void 0&&(t.getTextureUnitManager().free(d),e._textureResourceIds.delete(u))},t.getTextureUnitForTexture=u=>{const d=e._textureResourceIds.get(u);return d!==void 0?d:-1},t.getDefaultTextureByteSize=function(u){let d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,h=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(e.webgl2)switch(u){case rn.CHAR:case rn.SIGNED_CHAR:case rn.UNSIGNED_CHAR:return 1;case d:case h:case rn.UNSIGNED_SHORT:case rn.SHORT:case rn.VOID:return 2;default:return 4}return 1},t.getDefaultTextureInternalFormat=function(u,d){let h=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,g=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(e.webgl2)switch(u){case rn.UNSIGNED_CHAR:switch(d){case 1:return e.context.R8;case 2:return e.context.RG8;case 3:return e.context.RGB8;case 4:default:return e.context.RGBA8}case(h&&!g&&rn.UNSIGNED_SHORT):switch(d){case 1:return h.R16_EXT;case 2:return h.RG16_EXT;case 3:return h.RGB16_EXT;case 4:default:return h.RGBA16_EXT}case(h&&!g&&rn.SHORT):switch(d){case 1:return h.R16_SNORM_EXT;case 2:return h.RG16_SNORM_EXT;case 3:return h.RGB16_SNORM_EXT;case 4:default:return h.RGBA16_SNORM_EXT}case rn.UNSIGNED_SHORT:case rn.SHORT:case rn.FLOAT:default:switch(d){case 1:return g?e.context.R16F:e.context.R32F;case 2:return g?e.context.RG16F:e.context.RG32F;case 3:return g?e.context.RGB16F:e.context.RGB32F;case 4:default:return g?e.context.RGBA16F:e.context.RGBA32F}}switch(d){case 1:return e.context.LUMINANCE;case 2:return e.context.LUMINANCE_ALPHA;case 3:return e.context.RGB;case 4:default:return e.context.RGBA}},t.setBackgroundImage=u=>{e.bgImage.src=u.src},t.setUseBackgroundImage=u=>{e.useBackgroundImage=u,e.useBackgroundImage&&!e.el.contains(e.bgImage)?e.el.appendChild(e.bgImage):!e.useBackgroundImage&&e.el.contains(e.bgImage)&&e.el.removeChild(e.bgImage)};function a(){let u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:e.imageFormat;const d=document.createElement("canvas"),h=d.getContext("2d");d.width=e.canvas.width,d.height=e.canvas.height,h.drawImage(e.canvas,0,0);const g=e.canvas.getBoundingClientRect();e.renderable.getRenderers().forEach(m=>{m.getViewProps().forEach(x=>{if(x.getContainer){const S=x.getContainer().getElementsByTagName("canvas");for(let T=0;T<S.length;T++){const _=S[T],E=_.getBoundingClientRect(),b=E.x-g.x,D=E.y-g.y;h.drawImage(_,b,D)}}})});const y=d.toDataURL(u);d.remove(),t.invokeImageReady(y)}t.captureNextImage=function(){let u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"image/png",{resetCamera:d=!1,size:h=null,scale:g=1}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(e.deleted)return null;e.imageFormat=u;const p=e.notifyStartCaptureImage;return e.notifyStartCaptureImage=!0,e._screenshot={size:h||g!==1?h||e.size.map(v=>v*g):null},new Promise((v,y)=>{const m=t.onImageReady(w=>{var x;if(e._screenshot.size===null)e.notifyStartCaptureImage=p,m.unsubscribe(),e._screenshot.placeHolder&&(e.size=e._screenshot.originalSize,t.modified(),e._screenshot.cameras&&e._screenshot.cameras.forEach(C=>{let{restoreParamsFn:S,arg:T}=C;return S(T)}),t.traverseAllPasses(),e.el.removeChild(e._screenshot.placeHolder),e._screenshot.placeHolder.remove(),e._screenshot=null),v(w);else{const C=document.createElement("img");if(C.style=UZ,C.src=w,e._screenshot.placeHolder=e.el.appendChild(C),e.canvas.style.display="none",e._screenshot.originalSize=e.size,e.size=e._screenshot.size,(x=e.rootOpenGLRenderWindow)==null||x.resizeFromChildRenderWindows(),e._screenshot.size=null,t.modified(),d){const S=d!==!0;e._screenshot.cameras=e.renderable.getRenderers().map(T=>{const _=T.getActiveCamera(),E=_.get("focalPoint","position","parallelScale");return{resetCameraArgs:S?{renderer:T}:void 0,resetCameraFn:S?d:T.resetCamera,restoreParamsFn:_.set,arg:JSON.parse(JSON.stringify(E))}}),e._screenshot.cameras.forEach(T=>{let{resetCameraFn:_,resetCameraArgs:E}=T;return _(E)})}t.traverseAllPasses()}})})};let s;t.getHardwareMaximumLineWidth=()=>{if(s!=null)return s;const u=t.get3DContext(),d=u.getParameter(u.ALIASED_LINE_WIDTH_RANGE);return s=d[1],d[1]},t.getGLInformations=()=>{if(e._glInformation)return e._glInformation;const u=t.get3DContext(),d=u.getExtension("OES_texture_float"),h=u.getExtension("OES_texture_half_float"),g=u.getExtension("WEBGL_debug_renderer_info"),p=u.getExtension("WEBGL_draw_buffers"),v=u.getExtension("EXT_texture_filter_anisotropic")||u.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),y=[["Max Vertex Attributes","MAX_VERTEX_ATTRIBS",u.getParameter(u.MAX_VERTEX_ATTRIBS)],["Max Varying Vectors","MAX_VARYING_VECTORS",u.getParameter(u.MAX_VARYING_VECTORS)],["Max Vertex Uniform Vectors","MAX_VERTEX_UNIFORM_VECTORS",u.getParameter(u.MAX_VERTEX_UNIFORM_VECTORS)],["Max Fragment Uniform Vectors","MAX_FRAGMENT_UNIFORM_VECTORS",u.getParameter(u.MAX_FRAGMENT_UNIFORM_VECTORS)],["Max Fragment Texture Image Units","MAX_TEXTURE_IMAGE_UNITS",u.getParameter(u.MAX_TEXTURE_IMAGE_UNITS)],["Max Vertex Texture Image Units","MAX_VERTEX_TEXTURE_IMAGE_UNITS",u.getParameter(u.MAX_VERTEX_TEXTURE_IMAGE_UNITS)],["Max Combined Texture Image Units","MAX_COMBINED_TEXTURE_IMAGE_UNITS",u.getParameter(u.MAX_COMBINED_TEXTURE_IMAGE_UNITS)],["Max 2D Texture Size","MAX_TEXTURE_SIZE",u.getParameter(u.MAX_TEXTURE_SIZE)],["Max Cube Texture Size","MAX_CUBE_MAP_TEXTURE_SIZE",u.getParameter(u.MAX_CUBE_MAP_TEXTURE_SIZE)],["Max Texture Anisotropy","MAX_TEXTURE_MAX_ANISOTROPY_EXT",v&&u.getParameter(v.MAX_TEXTURE_MAX_ANISOTROPY_EXT)],["Point Size Range","ALIASED_POINT_SIZE_RANGE",u.getParameter(u.ALIASED_POINT_SIZE_RANGE).join(" - ")],["Line Width Range","ALIASED_LINE_WIDTH_RANGE",u.getParameter(u.ALIASED_LINE_WIDTH_RANGE).join(" - ")],["Max Viewport Dimensions","MAX_VIEWPORT_DIMS",u.getParameter(u.MAX_VIEWPORT_DIMS).join(" - ")],["Max Renderbuffer Size","MAX_RENDERBUFFER_SIZE",u.getParameter(u.MAX_RENDERBUFFER_SIZE)],["Framebuffer Red Bits","RED_BITS",u.getParameter(u.RED_BITS)],["Framebuffer Green Bits","GREEN_BITS",u.getParameter(u.GREEN_BITS)],["Framebuffer Blue Bits","BLUE_BITS",u.getParameter(u.BLUE_BITS)],["Framebuffer Alpha Bits","ALPHA_BITS",u.getParameter(u.ALPHA_BITS)],["Framebuffer Depth Bits","DEPTH_BITS",u.getParameter(u.DEPTH_BITS)],["Framebuffer Stencil Bits","STENCIL_BITS",u.getParameter(u.STENCIL_BITS)],["Framebuffer Subpixel Bits","SUBPIXEL_BITS",u.getParameter(u.SUBPIXEL_BITS)],["MSAA Samples","SAMPLES",u.getParameter(u.SAMPLES)],["MSAA Sample Buffers","SAMPLE_BUFFERS",u.getParameter(u.SAMPLE_BUFFERS)],["Supported Formats for UByte Render Targets ","UNSIGNED_BYTE RENDER TARGET FORMATS",[d&&Go(u,u.RGBA,u.UNSIGNED_BYTE)?"RGBA":"",d&&Go(u,u.RGB,u.UNSIGNED_BYTE)?"RGB":"",d&&Go(u,u.LUMINANCE,u.UNSIGNED_BYTE)?"LUMINANCE":"",d&&Go(u,u.ALPHA,u.UNSIGNED_BYTE)?"ALPHA":"",d&&Go(u,u.LUMINANCE_ALPHA,u.UNSIGNED_BYTE)?"LUMINANCE_ALPHA":""].join(" ")],["Supported Formats for Half Float Render Targets","HALF FLOAT RENDER TARGET FORMATS",[h&&Go(u,u.RGBA,h.HALF_FLOAT_OES)?"RGBA":"",h&&Go(u,u.RGB,h.HALF_FLOAT_OES)?"RGB":"",h&&Go(u,u.LUMINANCE,h.HALF_FLOAT_OES)?"LUMINANCE":"",h&&Go(u,u.ALPHA,h.HALF_FLOAT_OES)?"ALPHA":"",h&&Go(u,u.LUMINANCE_ALPHA,h.HALF_FLOAT_OES)?"LUMINANCE_ALPHA":""].join(" ")],["Supported Formats for Full Float Render Targets","FLOAT RENDER TARGET FORMATS",[d&&Go(u,u.RGBA,u.FLOAT)?"RGBA":"",d&&Go(u,u.RGB,u.FLOAT)?"RGB":"",d&&Go(u,u.LUMINANCE,u.FLOAT)?"LUMINANCE":"",d&&Go(u,u.ALPHA,u.FLOAT)?"ALPHA":"",d&&Go(u,u.LUMINANCE_ALPHA,u.FLOAT)?"LUMINANCE_ALPHA":""].join(" ")],["Max Multiple Render Targets Buffers","MAX_DRAW_BUFFERS_WEBGL",p?u.getParameter(p.MAX_DRAW_BUFFERS_WEBGL):0],["High Float Precision in Vertex Shader","HIGH_FLOAT VERTEX_SHADER",[u.getShaderPrecisionFormat(u.VERTEX_SHADER,u.HIGH_FLOAT).precision," (-2<sup>",u.getShaderPrecisionFormat(u.VERTEX_SHADER,u.HIGH_FLOAT).rangeMin,"</sup> - 2<sup>",u.getShaderPrecisionFormat(u.VERTEX_SHADER,u.HIGH_FLOAT).rangeMax,"</sup>)"].join("")],["Medium Float Precision in Vertex Shader","MEDIUM_FLOAT VERTEX_SHADER",[u.getShaderPrecisionFormat(u.VERTEX_SHADER,u.MEDIUM_FLOAT).precision," (-2<sup>",u.getShaderPrecisionFormat(u.VERTEX_SHADER,u.MEDIUM_FLOAT).rangeMin,"</sup> - 2<sup>",u.getShaderPrecisionFormat(u.VERTEX_SHADER,u.MEDIUM_FLOAT).rangeMax,"</sup>)"].join("")],["Low Float Precision in Vertex Shader","LOW_FLOAT VERTEX_SHADER",[u.getShaderPrecisionFormat(u.VERTEX_SHADER,u.LOW_FLOAT).precision," (-2<sup>",u.getShaderPrecisionFormat(u.VERTEX_SHADER,u.LOW_FLOAT).rangeMin,"</sup> - 2<sup>",u.getShaderPrecisionFormat(u.VERTEX_SHADER,u.LOW_FLOAT).rangeMax,"</sup>)"].join("")],["High Float Precision in Fragment Shader","HIGH_FLOAT FRAGMENT_SHADER",[u.getShaderPrecisionFormat(u.FRAGMENT_SHADER,u.HIGH_FLOAT).precision," (-2<sup>",u.getShaderPrecisionFormat(u.FRAGMENT_SHADER,u.HIGH_FLOAT).rangeMin,"</sup> - 2<sup>",u.getShaderPrecisionFormat(u.FRAGMENT_SHADER,u.HIGH_FLOAT).rangeMax,"</sup>)"].join("")],["Medium Float Precision in Fragment Shader","MEDIUM_FLOAT FRAGMENT_SHADER",[u.getShaderPrecisionFormat(u.FRAGMENT_SHADER,u.MEDIUM_FLOAT).precision," (-2<sup>",u.getShaderPrecisionFormat(u.FRAGMENT_SHADER,u.MEDIUM_FLOAT).rangeMin,"</sup> - 2<sup>",u.getShaderPrecisionFormat(u.FRAGMENT_SHADER,u.MEDIUM_FLOAT).rangeMax,"</sup>)"].join("")],["Low Float Precision in Fragment Shader","LOW_FLOAT FRAGMENT_SHADER",[u.getShaderPrecisionFormat(u.FRAGMENT_SHADER,u.LOW_FLOAT).precision," (-2<sup>",u.getShaderPrecisionFormat(u.FRAGMENT_SHADER,u.LOW_FLOAT).rangeMin,"</sup> - 2<sup>",u.getShaderPrecisionFormat(u.FRAGMENT_SHADER,u.LOW_FLOAT).rangeMax,"</sup>)"].join("")],["High Int Precision in Vertex Shader","HIGH_INT VERTEX_SHADER",[u.getShaderPrecisionFormat(u.VERTEX_SHADER,u.HIGH_INT).precision," (-2<sup>",u.getShaderPrecisionFormat(u.VERTEX_SHADER,u.HIGH_INT).rangeMin,"</sup> - 2<sup>",u.getShaderPrecisionFormat(u.VERTEX_SHADER,u.HIGH_INT).rangeMax,"</sup>)"].join("")],["Medium Int Precision in Vertex Shader","MEDIUM_INT VERTEX_SHADER",[u.getShaderPrecisionFormat(u.VERTEX_SHADER,u.MEDIUM_INT).precision," (-2<sup>",u.getShaderPrecisionFormat(u.VERTEX_SHADER,u.MEDIUM_INT).rangeMin,"</sup> - 2<sup>",u.getShaderPrecisionFormat(u.VERTEX_SHADER,u.MEDIUM_INT).rangeMax,"</sup>)"].join("")],["Low Int Precision in Vertex Shader","LOW_INT VERTEX_SHADER",[u.getShaderPrecisionFormat(u.VERTEX_SHADER,u.LOW_INT).precision," (-2<sup>",u.getShaderPrecisionFormat(u.VERTEX_SHADER,u.LOW_INT).rangeMin,"</sup> - 2<sup>",u.getShaderPrecisionFormat(u.VERTEX_SHADER,u.LOW_INT).rangeMax,"</sup>)"].join("")],["High Int Precision in Fragment Shader","HIGH_INT FRAGMENT_SHADER",[u.getShaderPrecisionFormat(u.FRAGMENT_SHADER,u.HIGH_INT).precision," (-2<sup>",u.getShaderPrecisionFormat(u.FRAGMENT_SHADER,u.HIGH_INT).rangeMin,"</sup> - 2<sup>",u.getShaderPrecisionFormat(u.FRAGMENT_SHADER,u.HIGH_INT).rangeMax,"</sup>)"].join("")],["Medium Int Precision in Fragment Shader","MEDIUM_INT FRAGMENT_SHADER",[u.getShaderPrecisionFormat(u.FRAGMENT_SHADER,u.MEDIUM_INT).precision," (-2<sup>",u.getShaderPrecisionFormat(u.FRAGMENT_SHADER,u.MEDIUM_INT).rangeMin,"</sup> - 2<sup>",u.getShaderPrecisionFormat(u.FRAGMENT_SHADER,u.MEDIUM_INT).rangeMax,"</sup>)"].join("")],["Low Int Precision in Fragment Shader","LOW_INT FRAGMENT_SHADER",[u.getShaderPrecisionFormat(u.FRAGMENT_SHADER,u.LOW_INT).precision," (-2<sup>",u.getShaderPrecisionFormat(u.FRAGMENT_SHADER,u.LOW_INT).rangeMin,"</sup> - 2<sup>",u.getShaderPrecisionFormat(u.FRAGMENT_SHADER,u.LOW_INT).rangeMax,"</sup>)"].join("")],["Supported Extensions","EXTENSIONS",u.getSupportedExtensions().join("<br/> ")],["WebGL Renderer","RENDERER",u.getParameter(u.RENDERER)],["WebGL Vendor","VENDOR",u.getParameter(u.VENDOR)],["WebGL Version","VERSION",u.getParameter(u.VERSION)],["Shading Language Version","SHADING_LANGUAGE_VERSION",u.getParameter(u.SHADING_LANGUAGE_VERSION)],["Unmasked Renderer","UNMASKED_RENDERER",g&&u.getParameter(g.UNMASKED_RENDERER_WEBGL)],["Unmasked Vendor","UNMASKED_VENDOR",g&&u.getParameter(g.UNMASKED_VENDOR_WEBGL)],["WebGL Version","WEBGL_VERSION",e.webgl2?2:1]],m={};for(;y.length;){const[w,x,C]=y.pop();x&&(m[x]={label:w,value:C})}return e._glInformation=m,m},t.traverseAllPasses=()=>{var d;if(e.renderPasses)for(let h=0;h<e.renderPasses.length;++h)e.renderPasses[h].traverse(t,null);t.copyParentContent(),e.notifyStartCaptureImage&&a();const u=e.renderable.getChildRenderWindowsByReference();for(let h=0;h<u.length;++h)(d=t.getViewNodeFor(u[h]))==null||d.traverseAllPasses()},t.copyParentContent=()=>{const u=e.rootOpenGLRenderWindow;if(!u||!e.context2D||e.children.some(g=>{var p;return!!((p=g.getSelector)!=null&&p.call(g))}))return;const d=u.getCanvas(),h=e.canvas;e.context2D.drawImage(d,0,d.height-h.height,h.width,h.height,0,0,h.width,h.height)},t.resizeFromChildRenderWindows=()=>{var d;const u=e.renderable.getChildRenderWindowsByReference();if(u.length>0){const h=[0,0];for(let g=0;g<u.length;++g){const p=(d=t.getViewNodeFor(u[g]))==null?void 0:d.getSize();p&&(h[0]=p[0]>h[0]?p[0]:h[0],h[1]=p[1]>h[1]?p[1]:h[1])}t.setSize(...h)}},t.disableCullFace=()=>{e.cullFaceEnabled&&(e.context.disable(e.context.CULL_FACE),e.cullFaceEnabled=!1)},t.enableCullFace=()=>{e.cullFaceEnabled||(e.context.enable(e.context.CULL_FACE),e.cullFaceEnabled=!0)},t.setViewStream=u=>{if(e.viewStream===u)return!1;if(e.subscription&&(e.subscription.unsubscribe(),e.subscription=null),e.viewStream=u,e.viewStream){const d=e.renderable.getRenderers()[0];d.getBackgroundByReference()[3]=0,t.setUseBackgroundImage(!0),e.subscription=e.viewStream.onImageReady(h=>t.setBackgroundImage(h.image)),e.viewStream.setSize(e.size[0],e.size[1]),e.viewStream.invalidateCache(),e.viewStream.render(),t.modified()}return!0},t.createSelector=()=>{const u=f4.newInstance();return u.setOpenGLRenderWindow(t),u};function c(){e.canvas.removeEventListener("webglcontextlost",oD),e.canvas.removeEventListener("webglcontextrestored",t.restoreContext)}t.delete=Z.chain(()=>{e.context&&WZ(),t.setContainer(),t.setViewStream()},c,t.delete),t.setActiveFramebuffer=u=>{e.activeFramebuffer=u};const l=t.setSize;t.setSize=(u,d)=>{const h=l(u,d);return h&&t.invokeWindowResizeEvent({width:u,height:d}),h},t.registerGraphicsResourceUser=(u,d)=>{e._graphicsResources.has(u)||t.setGraphicsResourceForObject(u,null,null);const h=e._graphicsResources.get(u);h==null||h.users.add(d)},t.unregisterGraphicsResourceUser=(u,d)=>{var g;const h=e._graphicsResources.get(u);h&&(h.users.delete(d),h.users.size||((g=h.oglObject)==null||g.releaseGraphicsResources(t),e._graphicsResources.delete(u)))},t.getGraphicsResourceForObject=u=>e._graphicsResources.get(u),t.setGraphicsResourceForObject=(u,d,h)=>{var p;if(!u)return;const g=e._graphicsResources.get(u);(p=g==null?void 0:g.oglObject)==null||p.releaseGraphicsResources(t),e._graphicsResources.set(u,{coreObject:u,oglObject:d,hash:h,users:(g==null?void 0:g.users)??new Set})},t.getGraphicsMemoryInfo=()=>{let u=0;return e._graphicsResources.forEach(d=>{let{oglObject:h}=d;u+=h.getAllocatedGPUMemoryInBytes()}),u},t.releaseGraphicsResources=()=>{e.shaderCache!==null&&e.shaderCache.releaseGraphicsResources(t),e._graphicsResources.forEach(u=>{let{oglObject:d}=u;d.releaseGraphicsResources(t)}),e._graphicsResources.clear(),e.textureUnitManager!==null&&e.textureUnitManager.freeAll(),e.renderable.getRenderersByReference().forEach(u=>{const d=t.getViewNodeFor(u);d==null||d.releaseGraphicsResources()})};const f={...t};BZ.forEach(u=>{t[u]=function(){return e.rootOpenGLRenderWindow?e.rootOpenGLRenderWindow[u](...arguments):f[u](...arguments)}})}const HZ={cullFaceEnabled:!1,shaderCache:null,initialized:!1,context:null,context2D:null,canvas:null,cursorVisibility:!0,cursor:"pointer",textureUnitManager:null,textureResourceIds:null,containerSize:null,renderPasses:[],notifyStartCaptureImage:!1,webgl2:!1,defaultToWebgl2:!0,activeFramebuffer:null,imageFormat:"image/png",useOffScreen:!1,useBackgroundImage:!1};function bL(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,HZ,r),kZ.extend(t,e,r),e.canvas||(e.canvas=document.createElement("canvas"),e.canvas.style.width="100%"),e.selector||(e.selector=f4.newInstance(),e.selector.setOpenGLRenderWindow(t)),e.bgImage=new Image,e.bgImage.style.position="absolute",e.bgImage.style.left="0",e.bgImage.style.top="0",e.bgImage.style.width="100%",e.bgImage.style.height="100%",e.bgImage.style.zIndex="-1",e._textureResourceIds=new Map,e._graphicsResources=new Map,e._glInformation=null,e.myFactory=MX.newInstance(),e.shaderCache=DZ.newInstance(),e.shaderCache.setOpenGLRenderWindow(t),e.renderPasses[0]=VJ.newInstance(),Z.get(t,e,["shaderCache","textureUnitManager","webgl2","useBackgroundImage","activeFramebuffer","rootOpenGLRenderWindow"]),Z.setGet(t,e,["initialized","context","context2D","canvas","renderPasses","notifyStartCaptureImage","defaultToWebgl2","cursor","useOffScreen"]),Z.setGetArray(t,e,["size"],2),Z.event(t,e,"imageReady"),Z.event(t,e,"windowResizeEvent"),jZ(t,e)}const d4=Z.newInstance(bL,"vtkOpenGLRenderWindow");JP("WebGL",d4);var KZ={newInstance:d4,extend:bL,pushMonitorGLContextCount:zZ,popMonitorGLContextCount:$Z};di("vtkRenderWindow",d4);function qZ(t,e){e.classHierarchy.push("vtkOpenGLActor"),t.buildPass=r=>{if(r){e._openGLRenderWindow=t.getLastAncestorOfType("vtkOpenGLRenderWindow"),e._openGLRenderer=t.getFirstAncestorOfType("vtkOpenGLRenderer"),e.context=e._openGLRenderWindow.getContext(),t.prepareNodes(),t.addMissingNodes(e.renderable.getTextures()),t.addMissingNode(e.renderable.getMapper()),t.removeUnusedNodes(),e.ogltextures=null,e.activeTextures=null;for(let n=0;n<e.children.length;n++){const i=e.children[n];i.isA("vtkOpenGLTexture")?(e.ogltextures||(e.ogltextures=[]),e.ogltextures.push(i)):e.oglmapper=i}}},t.traverseZBufferPass=r=>{!e.renderable||!e.renderable.getNestedVisibility()||e._openGLRenderer.getSelector()&&!e.renderable.getNestedPickable()||(t.apply(r,!0),e.oglmapper.traverse(r),t.apply(r,!1))},t.traverseOpaqueZBufferPass=r=>t.traverseOpaquePass(r),t.traverseOpaquePass=r=>{!e.renderable||!e.renderable.getNestedVisibility()||!e.renderable.getIsOpaque()||e._openGLRenderer.getSelector()&&!e.renderable.getNestedPickable()||(t.apply(r,!0),e.oglmapper.traverse(r),t.apply(r,!1))},t.traverseTranslucentPass=r=>{!e.renderable||!e.renderable.getNestedVisibility()||e.renderable.getIsOpaque()||e._openGLRenderer.getSelector()&&!e.renderable.getNestedPickable()||(t.apply(r,!0),e.oglmapper.traverse(r),t.apply(r,!1))},t.activateTextures=()=>{if(e.ogltextures){e.activeTextures=[];for(let r=0;r<e.ogltextures.length;r++){const n=e.ogltextures[r];n.render(),n.getHandle()&&e.activeTextures.push(n)}}},t.queryPass=(r,n)=>{if(r){if(!e.renderable||!e.renderable.getVisibility())return;e.renderable.getIsOpaque()?n.incrementOpaqueActorCount():n.incrementTranslucentActorCount()}},t.zBufferPass=(r,n)=>t.opaquePass(r,n),t.opaqueZBufferPass=(r,n)=>t.opaquePass(r,n),t.opaquePass=(r,n)=>{if(r)e.context.depthMask(!0),t.activateTextures();else if(e.activeTextures)for(let i=0;i<e.activeTextures.length;i++)e.activeTextures[i].deactivate()},t.translucentPass=(r,n)=>{if(r)e.context.depthMask(e._openGLRenderer.getSelector()&&e.renderable.getNestedPickable()),t.activateTextures();else if(e.activeTextures)for(let i=0;i<e.activeTextures.length;i++)e.activeTextures[i].deactivate()},t.getKeyMatrices=()=>(e.renderable.getMTime()>e.keyMatrixTime.getMTime()&&(e.renderable.computeMatrix(),Cr(e.keyMatrices.mcwc,e.renderable.getMatrix()),un(e.keyMatrices.mcwc,e.keyMatrices.mcwc),e.renderable.getIsIdentity()?ys(e.keyMatrices.normalMatrix):(tw(e.keyMatrices.normalMatrix,e.keyMatrices.mcwc),em(e.keyMatrices.normalMatrix,e.keyMatrices.normalMatrix),Z_(e.keyMatrices.normalMatrix,e.keyMatrices.normalMatrix)),e.keyMatrixTime.modified()),e.keyMatrices)}const XZ={context:null,keyMatrixTime:null,keyMatrices:null,activeTextures:null};function YZ(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,XZ,r),Qn.extend(t,e,r),e.keyMatrixTime={},or(e.keyMatrixTime,{mtime:0}),e.keyMatrices={normalMatrix:ys(new Float64Array(9)),mcwc:It(new Float64Array(16))},Jr(t,e,["context"]),Ro(t,e,["activeTextures"]),qZ(t,e)}const DL=Rn(YZ);var JZ={newInstance:DL};di("vtkActor",DL);function ZZ(t,e){e.classHierarchy.push("vtkOpenGLActor2D"),t.buildPass=r=>{if(r){if(!e.renderable)return;e._openGLRenderWindow=t.getLastAncestorOfType("vtkOpenGLRenderWindow"),e._openGLRenderer=t.getFirstAncestorOfType("vtkOpenGLRenderer"),e.context=e._openGLRenderWindow.getContext(),t.prepareNodes(),t.addMissingNodes(e.renderable.getTextures()),t.addMissingNode(e.renderable.getMapper()),t.removeUnusedNodes(),e.ogltextures=null,e.activeTextures=null;for(let n=0;n<e.children.length;n++){const i=e.children[n];i.isA("vtkOpenGLTexture")?(e.ogltextures||(e.ogltextures=[]),e.ogltextures.push(i)):e.oglmapper=i}}},t.queryPass=(r,n)=>{if(r){if(!e.renderable||!e.renderable.getVisibility())return;n.incrementOverlayActorCount()}},t.traverseOpaquePass=r=>{!e.oglmapper||!e.renderable||!e.renderable.getNestedVisibility()||!e.renderable.getIsOpaque()||e._openGLRenderer.getSelector()&&!e.renderable.getNestedPickable()||(t.apply(r,!0),e.oglmapper.traverse(r),t.apply(r,!1))},t.traverseTranslucentPass=r=>{!e.oglmapper||!e.renderable||!e.renderable.getNestedVisibility()||e.renderable.getIsOpaque()||e._openGLRenderer.getSelector()&&!e.renderable.getNestedPickable()||(t.apply(r,!0),e.oglmapper.traverse(r),t.apply(r,!1))},t.traverseOverlayPass=r=>{!e.oglmapper||!e.renderable||!e.renderable.getNestedVisibility()||e._openGLRenderer.getSelector()&&!e.renderable.getNestedPickable||(t.apply(r,!0),e.oglmapper.traverse(r),t.apply(r,!1))},t.activateTextures=()=>{if(e.ogltextures){e.activeTextures=[];for(let r=0;r<e.ogltextures.length;r++){const n=e.ogltextures[r];n.render(),n.getHandle()&&e.activeTextures.push(n)}}},t.opaquePass=(r,n)=>{if(r)e.context.depthMask(!0),t.activateTextures();else if(e.activeTextures)for(let i=0;i<e.activeTextures.length;i++)e.activeTextures[i].deactivate()},t.translucentPass=(r,n)=>{if(r)e.context.depthMask(!1),t.activateTextures();else if(e.activeTextures)for(let i=0;i<e.activeTextures.length;i++)e.activeTextures[i].deactivate()},t.overlayPass=(r,n)=>{if(r)e.context.depthMask(!0),t.activateTextures();else if(e.activeTextures)for(let i=0;i<e.activeTextures.length;i++)e.activeTextures[i].deactivate()}}const QZ={context:null,activeTextures:null};function eQ(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,QZ,r),Qn.extend(t,e,r),Jr(t,e,["context"]),Ro(t,e,["activeTextures"]),ZZ(t,e)}const IL=Rn(eQ);var tQ={newInstance:IL};di("vtkActor2D",IL);function nQ(t,e){e.classHierarchy.push("vtkOpenGLCamera"),t.buildPass=r=>{r&&(e._openGLRenderer=t.getFirstAncestorOfType("vtkOpenGLRenderer"),e._openGLRenderWindow=e._openGLRenderer.getParent(),e.context=e._openGLRenderWindow.getContext())},t.opaquePass=r=>{if(r){const n=e._openGLRenderer.getTiledSizeAndOrigin();e.context.viewport(n.lowerLeftU,n.lowerLeftV,n.usize,n.vsize),e.context.scissor(n.lowerLeftU,n.lowerLeftV,n.usize,n.vsize)}},t.translucentPass=t.opaquePass,t.zBufferPass=t.opaquePass,t.opaqueZBufferPass=t.opaquePass,t.volumePass=t.opaquePass,t.getKeyMatrices=r=>{if(r!==e.lastRenderer||e._openGLRenderWindow.getMTime()>e.keyMatrixTime.getMTime()||t.getMTime()>e.keyMatrixTime.getMTime()||r.getMTime()>e.keyMatrixTime.getMTime()||e.renderable.getMTime()>e.keyMatrixTime.getMTime()){Cr(e.keyMatrices.wcvc,e.renderable.getViewMatrix()),tw(e.keyMatrices.normalMatrix,e.keyMatrices.wcvc),em(e.keyMatrices.normalMatrix,e.keyMatrices.normalMatrix),un(e.keyMatrices.wcvc,e.keyMatrices.wcvc);const n=e._openGLRenderer.getAspectRatio();Cr(e.keyMatrices.vcpc,e.renderable.getProjectionMatrix(n,-1,1)),un(e.keyMatrices.vcpc,e.keyMatrices.vcpc),yn(e.keyMatrices.wcpc,e.keyMatrices.vcpc,e.keyMatrices.wcvc),e.keyMatrixTime.modified(),e.lastRenderer=r}return e.keyMatrices}}const rQ={context:null,lastRenderer:null,keyMatrixTime:null,keyMatrices:null};function iQ(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,rQ,r),Qn.extend(t,e,r),e.keyMatrixTime={},or(e.keyMatrixTime),e.keyMatrices={normalMatrix:new Float64Array(9),vcpc:new Float64Array(16),wcvc:new Float64Array(16),wcpc:new Float64Array(16)},Jr(t,e,["context","keyMatrixTime"]),nQ(t,e)}const OL=Rn(iQ);var oQ={newInstance:OL};di("vtkCamera",OL);function aQ(t,e){e.classHierarchy.push("vtkAbstractMapper"),t.update=()=>{t.getInputData()},t.addClippingPlane=r=>r.isA("vtkPlane")?e.clippingPlanes.includes(r)?!1:(e.clippingPlanes.push(r),t.modified(),!0):!1,t.getNumberOfClippingPlanes=()=>e.clippingPlanes.length,t.removeAllClippingPlanes=()=>e.clippingPlanes.length===0?!1:(e.clippingPlanes.length=0,t.modified(),!0),t.removeClippingPlane=r=>{const n=e.clippingPlanes.indexOf(r);return n===-1?!1:(e.clippingPlanes.splice(n,1),t.modified(),!0)},t.getClippingPlanes=()=>e.clippingPlanes,t.setClippingPlanes=r=>{if(r)if(!Array.isArray(r))t.addClippingPlane(r);else{const n=r.length;for(let i=0;i<n&&i<6;i++)t.addClippingPlane(r[i])}},t.getClippingPlaneInDataCoords=(r,n,i)=>{const o=e.clippingPlanes,a=r;if(o){const s=o.length;if(n>=0&&n<s){const c=o[n],l=c.getNormal(),f=c.getOrigin(),u=l[0],d=l[1],h=l[2],g=-(u*f[0]+d*f[1]+h*f[2]);i[0]=u*a[0]+d*a[4]+h*a[8]+g*a[12],i[1]=u*a[1]+d*a[5]+h*a[9]+g*a[13],i[2]=u*a[2]+d*a[6]+h*a[10]+g*a[14],i[3]=u*a[3]+d*a[7]+h*a[11]+g*a[15];return}}Z.vtkErrorMacro(`Clipping plane index ${n} is out of range.`)}}const sQ={clippingPlanes:[]};function cQ(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,sQ,r),Z.obj(t,e),Z.algo(t,e,1,0),e.clippingPlanes||(e.clippingPlanes=[]),aQ(t,e)}var ML={extend:cQ};function lQ(t,e){e.classHierarchy.push("vtkImplicitFunction"),t.functionValue=r=>{if(!e.transform)return t.evaluateFunction(r);const n=[];return e.transform.transformPoint(r,n),t.evaluateFunction(n)},t.evaluateFunction=r=>{Z.vtkErrorMacro("not implemented")}}const uQ={};function PL(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,uQ,r),Z.obj(t,e),Z.setGet(t,e,["transform"]),lQ(t,e)}const fQ=Z.newInstance(PL,"vtkImplicitFunction");var dQ={newInstance:fQ,extend:PL};const fS=1e-6,RL="coincide",LL="disjoint";function hQ(t,e,r){return t[0]*(r[0]-e[0])+t[1]*(r[1]-e[1])+t[2]*(r[2]-e[2])}function AL(t,e,r){const n=r[0]*(t[0]-e[0])+r[1]*(t[1]-e[1])+r[2]*(t[2]-e[2]);return Math.abs(n)}function NL(t,e,r,n){const i=[];$l(t,e,i);const o=cn(r,i);n[0]=t[0]-o*r[0],n[1]=t[1]-o*r[1],n[2]=t[2]-o*r[2]}function kL(t,e,r){const n=cn(t,e);let i=cn(e,e);return i===0&&(i=1),r[0]=t[0]-n*e[0]/i,r[1]=t[1]-n*e[1]/i,r[2]=t[2]-n*e[2]/i,r}function VL(t,e,r,n){const i=[];$l(t,e,i);const o=cn(r,i),a=cn(r,r);a!==0?(n[0]=t[0]-o*r[0]/a,n[1]=t[1]-o*r[1]/a,n[2]=t[2]-o*r[2]/a):(n[0]=t[0],n[1]=t[1],n[2]=t[2])}function FL(t,e,r,n){const i={intersection:!1,betweenPoints:!1,t:Number.MAX_VALUE,x:[]},o=[],a=[];$l(e,t,o),$l(r,t,a);const s=cn(n,a),c=cn(n,o);let l,f;return c<0?l=-c:l=c,s<0?f=-s*fS:f=s*fS,l<=f||(i.t=s/c,i.x[0]=t[0]+i.t*o[0],i.x[1]=t[1]+i.t*o[1],i.x[2]=t[2]+i.t*o[2],i.intersection=!0,i.betweenPoints=i.t>=0&&i.t<=1),i}function UL(t,e,r,n){const i={intersection:!1,l0:[],l1:[],error:null},o=[];tl(e,n,o);const a=o.map(u=>Math.abs(u));if(a[0]+a[1]+a[2]<fS){const u=[];return $l(t,r,u),cn(e,u)===0?i.error=RL:i.error=LL,i}let s;a[0]>a[1]&&a[0]>a[2]?s="x":a[1]>a[2]?s="y":s="z";const c=[],l=-cn(e,t),f=-cn(n,r);switch(s){case"x":c[0]=0,c[1]=(f*e[2]-l*n[2])/o[0],c[2]=(l*n[1]-f*e[1])/o[0];break;case"y":c[0]=(l*n[2]-f*e[2])/o[1],c[1]=0,c[2]=(f*e[0]-l*n[0])/o[1];break;case"z":c[0]=(f*e[1]-l*n[1])/o[2],c[1]=(l*n[0]-f*e[0])/o[2],c[2]=0;break}return i.l0=c,vy(c,o,i.l1),i.intersection=!0,i}const gQ={evaluate:hQ,distanceToPlane:AL,projectPoint:NL,projectVector:kL,generalizedProjectPoint:VL,intersectWithLine:FL,intersectWithPlane:UL,DISJOINT:LL,COINCIDE:RL};function pQ(t,e){e.classHierarchy.push("vtkPlane"),t.distanceToPlane=r=>AL(r,e.origin,e.normal),t.projectPoint=(r,n)=>{NL(r,e.origin,e.normal,n)},t.projectVector=(r,n)=>kL(r,e.normal,n),t.push=r=>{if(r!==0)for(let n=0;n<3;n++)e.origin[n]+=r*e.normal[n]},t.generalizedProjectPoint=(r,n)=>{VL(r,e.origin,e.normal,n)},t.evaluateFunction=(r,n,i)=>Array.isArray(r)?e.normal[0]*(r[0]-e.origin[0])+e.normal[1]*(r[1]-e.origin[1])+e.normal[2]*(r[2]-e.origin[2]):e.normal[0]*(r-e.origin[0])+e.normal[1]*(n-e.origin[1])+e.normal[2]*(i-e.origin[2]),t.evaluateGradient=r=>[e.normal[0],e.normal[1],e.normal[2]],t.intersectWithLine=(r,n)=>FL(r,n,e.origin,e.normal),t.intersectWithPlane=(r,n)=>UL(r,n,e.origin,e.normal)}const mQ={normal:[0,0,1],origin:[0,0,0]};function BL(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,mQ,r),dQ.extend(t,e,r),Z.setGetArray(t,e,["normal","origin"],3),pQ(t,e)}const vQ=Z.newInstance(BL,"vtkPlane");var Io={newInstance:vQ,extend:BL,...gQ};const iw=[Number.MAX_VALUE,-Number.MAX_VALUE,Number.MAX_VALUE,-Number.MAX_VALUE,Number.MAX_VALUE,-Number.MAX_VALUE];function GL(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]}function Zl(t){return(t==null?void 0:t.length)>=6&&t[0]<=t[1]&&t[2]<=t[3]&&t[4]<=t[5]}function h4(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t}function g4(t){return h4(t,iw)}function Ey(t,e,r,n){const[i,o,a,s,c,l]=t;return t[0]=i<e?i:e,t[1]=o>e?o:e,t[2]=a<r?a:r,t[3]=s>r?s:r,t[4]=c<n?c:n,t[5]=l>n?l:n,t}function p4(t,e){if(e.length===0)return t;if(Array.isArray(e[0]))for(let r=0;r<e.length;++r)Ey(t,...e[r]);else for(let r=0;r<e.length;r+=3)Ey(t,...e.slice(r,r+3));return t}function WL(t,e,r,n,i,o,a){const[s,c,l,f,u,d]=t;return a===void 0?(t[0]=Math.min(e[0],s),t[1]=Math.max(e[1],c),t[2]=Math.min(e[2],l),t[3]=Math.max(e[3],f),t[4]=Math.min(e[4],u),t[5]=Math.max(e[5],d)):(t[0]=Math.min(e,s),t[1]=Math.max(r,c),t[2]=Math.min(n,l),t[3]=Math.max(i,f),t[4]=Math.min(o,u),t[5]=Math.max(a,d)),t}function zL(t,e,r,n){const[i,o,a,s,c,l]=t;return t[0]=e,t[1]=e>o?e:o,t[2]=r,t[3]=r>s?r:s,t[4]=n,t[5]=n>l?n:l,i!==e||a!==r||c!==n}function $L(t,e,r,n){const[i,o,a,s,c,l]=t;return t[0]=e<i?e:i,t[1]=e,t[2]=r<a?r:a,t[3]=r,t[4]=n<c?n:c,t[5]=n,o!==e||s!==r||l!==n}function jL(t,e){return t[0]-=e,t[1]+=e,t[2]-=e,t[3]+=e,t[4]-=e,t[5]+=e,t}function m4(t,e,r,n){return Zl(t)?(e>=0?(t[0]*=e,t[1]*=e):(t[0]=e*t[1],t[1]=e*t[0]),r>=0?(t[2]*=r,t[3]*=r):(t[2]=r*t[3],t[3]=r*t[2]),n>=0?(t[4]*=n,t[5]*=n):(t[4]=n*t[5],t[5]=n*t[4]),!0):!1}function v4(t){return[.5*(t[0]+t[1]),.5*(t[2]+t[3]),.5*(t[4]+t[5])]}function yQ(t,e,r,n){if(!Zl(t))return!1;const i=v4(t);return t[0]-=i[0],t[1]-=i[0],t[2]-=i[1],t[3]-=i[1],t[4]-=i[2],t[5]-=i[2],m4(t,e,r,n),t[0]+=i[0],t[1]+=i[0],t[2]+=i[1],t[3]+=i[1],t[4]+=i[2],t[5]+=i[2],!0}function vp(t,e){return t[e*2+1]-t[e*2]}function ow(t){return[vp(t,0),vp(t,1),vp(t,2)]}function HL(t){return t.slice(0,2)}function KL(t){return t.slice(2,4)}function qL(t){return t.slice(4,6)}function XL(t){const e=ow(t);return e[0]>e[1]?e[0]>e[2]?e[0]:e[2]:e[1]>e[2]?e[1]:e[2]}function YL(t){if(Zl(t)){const e=ow(t);return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2])}return null}function y4(t){return[t[0],t[2],t[4]]}function w4(t){return[t[1],t[3],t[5]]}function n2(t,e){return t<=0&&e>=0||t>=0&&e<=0}function x4(t,e){let r=0;for(let n=0;n<2;n++)for(let i=2;i<4;i++)for(let o=4;o<6;o++)e[r++]=[t[n],t[i],t[o]];return e}function JL(t,e,r){return e[0]=t[0],e[1]=t[2],e[2]=t[4],r[0]=t[1],r[1]=t[3],r[2]=t[5],e}function ZL(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];const n=x4(t,[]);for(let i=0;i<n.length;++i)At(n[i],n[i],e);return g4(r),p4(r,n)}function QL(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e[0]=.5*(t[1]-t[0]),e[1]=.5*(t[3]-t[2]),e[2]=.5*(t[5]-t[4]),e}function eA(t,e,r,n){const i=[].concat(iw),o=t.getData();for(let a=0;a<o.length;a+=3){const s=[o[a],o[a+1],o[a+2]],c=cn(s,e);i[0]=Math.min(c,i[0]),i[1]=Math.max(c,i[1]);const l=cn(s,r);i[2]=Math.min(l,i[2]),i[3]=Math.max(l,i[3]);const f=cn(s,n);i[4]=Math.min(f,i[4]),i[5]=Math.max(f,i[5])}return i}function tA(t,e,r,n,i){let o=!0;const a=[];let s=0;const c=[],l=[0,0,0],f=0,u=1,d=2;for(let h=0;h<3;h++)e[h]<t[2*h]?(a[h]=u,l[h]=t[2*h],o=!1):e[h]>t[2*h+1]?(a[h]=f,l[h]=t[2*h+1],o=!1):a[h]=d;if(o)return n[0]=e[0],n[1]=e[1],n[2]=e[2],i[0]=0,1;for(let h=0;h<3;h++)a[h]!==d&&r[h]!==0?c[h]=(l[h]-e[h])/r[h]:c[h]=-1;for(let h=0;h<3;h++)c[s]<c[h]&&(s=h);if(c[s]>1||c[s]<0)return 0;i[0]=c[s];for(let h=0;h<3;h++)if(s!==h){if(n[h]=e[h]+c[s]*r[h],n[h]<t[2*h]||n[h]>t[2*h+1])return 0}else n[h]=l[h];return 1}function nA(t,e,r){const n=[];let i=0,o=1,a=1;for(let s=4;s<=5;++s){n[2]=t[s];for(let c=2;c<=3;++c){n[1]=t[c];for(let l=0;l<=1;++l)if(n[0]=t[l],i=Io.evaluate(r,e,n),a&&(o=i>=0?1:-1,a=0),i===0||o>0&&i<0||o<0&&i>0)return 1}}return 0}function rA(t,e){if(!(Zl(t)&&Zl(e)))return!1;const r=[0,0,0,0,0,0];let n;for(let i=0;i<3;i++)if(n=!1,e[i*2]>=t[i*2]&&e[i*2]<=t[i*2+1]?(n=!0,r[i*2]=e[i*2]):t[i*2]>=e[i*2]&&t[i*2]<=e[i*2+1]&&(n=!0,r[i*2]=t[i*2]),e[i*2+1]>=t[i*2]&&e[i*2+1]<=t[i*2+1]?(n=!0,r[i*2+1]=e[2*i+1]):t[i*2+1]>=e[i*2]&&t[i*2+1]<=e[i*2+1]&&(n=!0,r[i*2+1]=t[i*2+1]),!n)return!1;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],!0}function by(t,e){if(!(Zl(t)&&Zl(e)))return!1;for(let r=0;r<3;r++)if(!(e[r*2]>=t[r*2]&&e[r*2]<=t[r*2+1])&&!(t[r*2]>=e[r*2]&&t[r*2]<=e[r*2+1])&&!(e[r*2+1]>=t[r*2]&&e[r*2+1]<=t[r*2+1])&&!(t[r*2+1]>=e[r*2]&&t[r*2+1]<=e[r*2+1]))return!1;return!0}function Dy(t,e,r,n){return!(e<t[0]||e>t[1]||r<t[2]||r>t[3]||n<t[4]||n>t[5])}function wQ(t,e){return!(!by(t,e)||!Dy(t,...y4(e))||!Dy(t,...w4(e)))}function iA(t,e,r){const n=[[0,1,2,3,4,5,6,7],[0,1,4,5,2,3,6,7],[0,2,4,6,1,3,5,7]],i=[0,0,0,0,0,0,0,0];let o=0;for(let u=0;u<2;u++)for(let d=2;d<4;d++)for(let h=4;h<6;h++){const g=[t[u],t[d],t[h]];i[o++]=Io.evaluate(r,e,g)}let a=2;for(;a--&&!(n2(i[n[a][0]],i[n[a][4]])&&n2(i[n[a][1]],i[n[a][5]])&&n2(i[n[a][2]],i[n[a][6]])&&n2(i[n[a][3]],i[n[a][7]])););if(a<0)return!1;const s=Math.sign(r[a]),c=Math.abs((t[a*2+1]-t[a*2])*r[a]);let l=s>0?1:0;for(let u=0;u<4;u++){if(c===0)continue;const d=Math.abs(i[n[a][u]])/c;s>0&&d<l&&(l=d),s<0&&d>l&&(l=d)}const f=(1-l)*t[a*2]+l*t[a*2+1];return s>0?t[a*2]=f:t[a*2+1]=f,!0}class xQ{constructor(e){this.bounds=e,this.bounds||(this.bounds=new Float64Array(iw))}getBounds(){return this.bounds}equals(e){return GL(this.bounds,e)}isValid(){return Zl(this.bounds)}setBounds(e){return h4(this.bounds,e)}reset(){return g4(this.bounds)}addPoint(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return Ey(this.bounds,...r)}addPoints(e){return p4(this.bounds,e)}addBounds(e,r,n,i,o,a){return WL(this.bounds,e,r,n,i,o,a)}setMinPoint(e,r,n){return zL(this.bounds,e,r,n)}setMaxPoint(e,r,n){return $L(this.bounds,e,r,n)}inflate(e){return jL(this.bounds,e)}scale(e,r,n){return m4(this.bounds,e,r,n)}getCenter(){return v4(this.bounds)}getLength(e){return vp(this.bounds,e)}getLengths(){return ow(this.bounds)}getMaxLength(){return XL(this.bounds)}getDiagonalLength(){return YL(this.bounds)}getMinPoint(){return y4(this.bounds)}getMaxPoint(){return w4(this.bounds)}getXRange(){return HL(this.bounds)}getYRange(){return KL(this.bounds)}getZRange(){return qL(this.bounds)}getCorners(e){return x4(this.bounds,e)}computeCornerPoints(e,r){return JL(this.bounds,e,r)}computeLocalBounds(e,r,n){return eA(this.bounds,e,r,n)}transformBounds(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return ZL(this.bounds,e,r)}computeScale3(e){return QL(this.bounds,e)}cutWithPlane(e,r){return iA(this.bounds,e,r)}intersectBox(e,r,n,i){return tA(this.bounds,e,r,n,i)}intersectPlane(e,r){return nA(this.bounds,e,r)}intersect(e){return rA(this.bounds,e)}intersects(e){return by(this.bounds,e)}containsPoint(e,r,n){return Dy(this.bounds,e,r,n)}contains(e){return by(this.bounds,e)}}function CQ(t){const e=t&&t.bounds;return new xQ(e)}const SQ={equals:GL,isValid:Zl,setBounds:h4,reset:g4,addPoint:Ey,addPoints:p4,addBounds:WL,setMinPoint:zL,setMaxPoint:$L,inflate:jL,scale:m4,scaleAboutCenter:yQ,getCenter:v4,getLength:vp,getLengths:ow,getMaxLength:XL,getDiagonalLength:YL,getMinPoint:y4,getMaxPoint:w4,getXRange:HL,getYRange:KL,getZRange:qL,getCorners:x4,computeCornerPoints:JL,computeLocalBounds:eA,transformBounds:ZL,computeScale3:QL,cutWithPlane:iA,intersectBox:tA,intersectPlane:nA,intersect:rA,intersects:by,containsPoint:Dy,contains:wQ,INIT_BOUNDS:iw};var Hn={newInstance:CQ,...SQ};function TQ(t,e){t.getBounds=()=>(Z.vtkErrorMacro("vtkAbstractMapper3D.getBounds - NOT IMPLEMENTED"),of()),t.getCenter=()=>{var n;const r=t.getBounds();return e.center=Hn.isValid(r)?Hn.getCenter(r):null,(n=e.center)==null?void 0:n.slice()},t.getLength=()=>{const r=t.getBounds();return Hn.getDiagonalLength(r)}}const _Q=t=>({bounds:[...Hn.INIT_BOUNDS],center:[0,0,0],viewSpecificProperties:{},...t});function EQ(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,_Q(r)),ML.extend(t,e,r),Z.setGet(t,e,["viewSpecificProperties"]),TQ(t,e)}var C4={extend:EQ};const $s={UNCHANGED:0,SINGLE_POINT:1,X_LINE:2,Y_LINE:3,Z_LINE:4,XY_PLANE:5,YZ_PLANE:6,XZ_PLANE:7,XYZ_GRID:8,EMPTY:9};var oA={StructuredType:$s};const{StructuredType:Sl}=oA;function bQ(t){let e=0;for(let r=0;r<3;++r)t[r*2]<t[r*2+1]&&e++;return t[0]>t[1]||t[2]>t[3]||t[4]>t[5]?Sl.EMPTY:e===3?Sl.XYZ_GRID:e===2?t[0]===t[1]?Sl.YZ_PLANE:t[2]===t[3]?Sl.XZ_PLANE:Sl.XY_PLANE:e===1?t[0]<t[1]?Sl.X_LINE:t[2]<t[3]?Sl.Y_LINE:Sl.Z_LINE:Sl.SINGLE_POINT}var DQ={getDataDescriptionFromExtent:bQ,...oA};const{vtkErrorMacro:If}=Z;function IQ(t,e){e.classHierarchy.push("vtkImageData"),t.setExtent=function(){if(e.deleted)return If("instance deleted - cannot call any method"),!1;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];const o=n.length===1?n[0]:n;if(o.length!==6)return!1;const a=e.extent.some((s,c)=>s!==o[c]);return a&&(e.extent=o.slice(),e.dataDescription=DQ.getDataDescriptionFromExtent(e.extent),t.modified()),a},t.setDimensions=function(){let r,n,i;if(e.deleted){If("instance deleted - cannot call any method");return}if(arguments.length===1){const o=arguments.length<=0?void 0:arguments[0];r=o[0],n=o[1],i=o[2]}else if(arguments.length===3)r=arguments.length<=0?void 0:arguments[0],n=arguments.length<=1?void 0:arguments[1],i=arguments.length<=2?void 0:arguments[2];else{If("Bad dimension specification");return}t.setExtent(0,r-1,0,n-1,0,i-1)},t.getDimensions=()=>[e.extent[1]-e.extent[0]+1,e.extent[3]-e.extent[2]+1,e.extent[5]-e.extent[4]+1],t.getNumberOfCells=()=>{const r=t.getDimensions();let n=1;for(let i=0;i<3;i++){if(r[i]===0)return 0;r[i]>1&&(n*=r[i]-1)}return n},t.getNumberOfPoints=()=>{const r=t.getDimensions();return r[0]*r[1]*r[2]},t.getPoint=r=>{const n=t.getDimensions();if(n[0]===0||n[1]===0||n[2]===0)return If("Requesting a point from an empty image."),null;const i=new Float64Array(3);switch(e.dataDescription){case $s.EMPTY:return null;case $s.SINGLE_POINT:break;case $s.X_LINE:i[0]=r;break;case $s.Y_LINE:i[1]=r;break;case $s.Z_LINE:i[2]=r;break;case $s.XY_PLANE:i[0]=r%n[0],i[1]=r/n[0];break;case $s.YZ_PLANE:i[1]=r%n[1],i[2]=r/n[1];break;case $s.XZ_PLANE:i[0]=r%n[0],i[2]=r/n[0];break;case $s.XYZ_GRID:i[0]=r%n[0],i[1]=r/n[0]%n[1],i[2]=r/(n[0]*n[1]);break;default:If("Invalid dataDescription");break}const o=[0,0,0];return t.indexToWorld(i,o),o},t.getBounds=()=>t.extentToBounds(t.getSpatialExtent()),t.extentToBounds=r=>Hn.transformBounds(r,e.indexToWorld),t.getSpatialExtent=()=>Hn.inflate([...e.extent],.5),t.computeTransforms=()=>{tm(e.indexToWorld,e.origin),e.indexToWorld[0]=e.direction[0],e.indexToWorld[1]=e.direction[1],e.indexToWorld[2]=e.direction[2],e.indexToWorld[4]=e.direction[3],e.indexToWorld[5]=e.direction[4],e.indexToWorld[6]=e.direction[5],e.indexToWorld[8]=e.direction[6],e.indexToWorld[9]=e.direction[7],e.indexToWorld[10]=e.direction[8],nl(e.indexToWorld,e.indexToWorld,e.spacing),Ar(e.worldToIndex,e.indexToWorld)},t.indexToWorld=function(r){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return At(n,r,e.indexToWorld),n},t.indexToWorldVec3=t.indexToWorld,t.worldToIndex=function(r){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return At(n,r,e.worldToIndex),n},t.worldToIndexVec3=t.worldToIndex,t.indexToWorldBounds=function(r){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return Hn.transformBounds(r,e.indexToWorld,n)},t.worldToIndexBounds=function(r){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return Hn.transformBounds(r,e.worldToIndex,n)},t.onModified(t.computeTransforms),t.computeTransforms(),t.getCenter=()=>Hn.getCenter(t.getBounds()),t.computeHistogram=function(r){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;const i=[0,0,0,0,0,0];t.worldToIndexBounds(r,i);const o=[0,0,0],a=[0,0,0];Hn.computeCornerPoints(i,o,a),nS(o,o),nS(a,a);const s=t.getDimensions();iS(o,[0,0,0],[s[0]-1,s[1]-1,s[2]-1],o),iS(a,[0,0,0],[s[0]-1,s[1]-1,s[2]-1],a);const c=s[0],l=s[0]*s[1],f=t.getPointData().getScalars().getData();let u=-1/0,d=1/0,h=0,g=0,p=0;for(let w=o[2];w<=a[2];w++)for(let x=o[1];x<=a[1];x++){let C=o[0]+x*c+w*l;for(let S=o[0];S<=a[0];S++){if(!n||n([S,x,w],i)){const T=f[C];T>u&&(u=T),T<d&&(d=T),h+=T*T,g+=T,p+=1}++C}}const v=p>0?g/p:0,y=p?Math.abs(h/p-v*v):0,m=Math.sqrt(y);return{minimum:d,maximum:u,average:v,variance:y,sigma:m,count:p}},t.computeIncrements=function(r){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1;const i=[];let o=n;for(let a=0;a<3;++a)i[a]=o,o*=r[a*2+1]-r[a*2]+1;return i},t.computeOffsetIndex=r=>{let[n,i,o]=r;const a=t.getExtent(),s=t.getPointData().getScalars().getNumberOfComponents(),c=t.computeIncrements(a,s);return Math.floor((Math.round(n)-a[0])*c[0]+(Math.round(i)-a[2])*c[1]+(Math.round(o)-a[4])*c[2])},t.getOffsetIndexFromWorld=r=>{const n=t.getExtent(),i=t.worldToIndex(r);for(let o=0;o<3;++o)if(i[o]<n[o*2]||i[o]>n[o*2+1])return If(`GetScalarPointer: Pixel ${i} is not in memory. Current extent = ${n}`),NaN;return t.computeOffsetIndex(i)},t.getScalarValueFromWorld=function(r){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;const i=t.getPointData().getScalars().getNumberOfComponents();if(n<0||n>=i)return If(`GetScalarPointer: Scalar Component ${n} is not within bounds. Current Scalar numberOfComponents: ${i}`),NaN;const o=t.getOffsetIndexFromWorld(r);return Number.isNaN(o)?o:t.getPointData().getScalars().getComponent(o,n)}}const OQ={direction:null,indexToWorld:null,worldToIndex:null,spacing:[1,1,1],origin:[0,0,0],extent:[0,-1,0,-1,0,-1],dataDescription:$s.EMPTY};function aA(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,OQ,r),Wh.extend(t,e,r),e.direction?Array.isArray(e.direction)&&(e.direction=new Float64Array(e.direction.slice(0,9))):e.direction=ys(new Float64Array(9)),e.indexToWorld=new Float64Array(16),e.worldToIndex=new Float64Array(16),Z.get(t,e,["indexToWorld","worldToIndex"]),Z.setGetArray(t,e,["origin","spacing"],3),Z.setGetArray(t,e,["direction"],9),Z.getArray(t,e,["extent"],6),IQ(t,e)}const MQ=Z.newInstance(aA,"vtkImageData");var nm={newInstance:MQ,extend:aA};const PQ={MAGNITUDE:0,COMPONENT:1,RGBCOLORS:2},dS={LUMINANCE:1,LUMINANCE_ALPHA:2,RGB:3,RGBA:4};var S4={VectorMode:PQ,ScalarMappingTarget:dS};const RQ={DEFAULT:0,MAP_SCALARS:1,DIRECT_SCALARS:2},LQ={DEFAULT:0,USE_POINT_DATA:1,USE_CELL_DATA:2,USE_POINT_FIELD_DATA:3,USE_CELL_FIELD_DATA:4,USE_FIELD_DATA:5},AQ={BY_ID:0,BY_NAME:1};var aw={ColorMode:RQ,GetArray:AQ,ScalarMode:LQ};const{ScalarMappingTarget:aD,VectorMode:Lc}=S4,{VtkDataTypes:gu}=bt,{ColorMode:r2}=aw,{vtkErrorMacro:sD}=Z;function NQ(t){return t}function cD(t){return Math.floor(t*255+.5)}function kQ(t,e){e.classHierarchy.push("vtkScalarsToColors"),t.setVectorModeToMagnitude=()=>t.setVectorMode(Lc.MAGNITUDE),t.setVectorModeToComponent=()=>t.setVectorMode(Lc.COMPONENT),t.setVectorModeToRGBColors=()=>t.setVectorMode(Lc.RGBCOLORS),t.build=()=>{},t.isOpaque=()=>!0,t.setAnnotations=(r,n)=>{if(!(r&&!n||!r&&n)){if(r&&n&&r.length!==n.length){sD("Values and annotations do not have the same number of tuples so ignoring");return}if(e.annotationArray=[],n&&r){const i=n.length;for(let o=0;o<i;o++)e.annotationArray.push({value:r[o],annotation:String(n[o])})}t.updateAnnotatedValueMap(),t.modified()}},t.setAnnotation=(r,n)=>{let i=t.checkForAnnotatedValue(r),o=!1;return i>=0?e.annotationArray[i].annotation!==n&&(e.annotationArray[i].annotation=n,o=!0):(e.annotationArray.push({value:r,annotation:n}),i=e.annotationArray.length-1,o=!0),o&&(t.updateAnnotatedValueMap(),t.modified()),i},t.getNumberOfAnnotatedValues=()=>e.annotationArray.length,t.getAnnotatedValue=r=>r<0||r>=e.annotationArray.length?null:e.annotationArray[r].value,t.getAnnotation=r=>e.annotationArray[r]===void 0?null:e.annotationArray[r].annotation,t.getAnnotatedValueIndex=r=>e.annotationArray.length?t.checkForAnnotatedValue(r):-1,t.removeAnnotation=r=>{const n=t.checkForAnnotatedValue(r),i=n>=0;return i&&(e.annotationArray.splice(n,1),t.updateAnnotatedValueMap(),t.modified()),i},t.resetAnnotations=()=>{e.annotationArray=[],e.annotatedValueMap=[],t.modified()},t.getAnnotationColor=(r,n)=>{if(e.indexedLookup){const i=t.getAnnotatedValueIndex(r);t.getIndexedColor(i,n)}else t.getColor(parseFloat(r),n),n[3]=1},t.checkForAnnotatedValue=r=>t.getAnnotatedValueIndexInternal(r),t.getAnnotatedValueIndexInternal=r=>{if(e.annotatedValueMap[r]!==void 0){const n=e.annotationArray.length;return e.annotatedValueMap[r]%n}return-1},t.getIndexedColor=(r,n)=>{n[0]=0,n[1]=0,n[2]=0,n[3]=0},t.updateAnnotatedValueMap=()=>{e.annotatedValueMap=[];const r=e.annotationArray.length;for(let n=0;n<r;n++)e.annotatedValueMap[e.annotationArray[n].value]=n},t.mapScalars=(r,n,i)=>{const o=r.getNumberOfComponents();let a=null;if(n===r2.DEFAULT&&(r.getDataType()===gu.UNSIGNED_CHAR||r.getDataType()===gu.UNSIGNED_CHAR_CLAMPED)||n===r2.DIRECT_SCALARS&&r)a=t.convertToRGBA(r,o,r.getNumberOfTuples());else{const s={type:"vtkDataArray",name:"temp",numberOfComponents:4,dataType:gu.UNSIGNED_CHAR},c=Z.newTypedArray(s.dataType,4*r.getNumberOfTuples());s.values=c,s.size=c.length,a=bt.newInstance(s);let l=i;l<0&&o>1?t.mapVectorsThroughTable(r,a,aD.RGBA,-1,-1):(l<0&&(l=0),l>=o&&(l=o-1),t.mapScalarsThroughTable(r,a,aD.RGBA,l))}return a},t.mapVectorsToMagnitude=(r,n,i)=>{const o=r.getNumberOfTuples(),a=r.getNumberOfComponents(),s=n.getData(),c=r.getData();for(let l=0;l<o;l++){let f=0;for(let u=0;u<i;u++)f+=c[l*a+u]*c[l*a+u];s[l]=Math.sqrt(f)}},t.mapVectorsThroughTable=(r,n,i,o,a)=>{let s=t.getVectorMode(),c=a,l=o;const f=r.getNumberOfComponents();s===Lc.COMPONENT?(l===-1&&(l=t.getVectorComponent()),l<0&&(l=0),l>=f&&(l=f-1)):(c===-1&&(c=t.getVectorSize()),c<=0?(l=0,c=f):(l<0&&(l=0),l>=f&&(l=f-1),l+c>f&&(c=f-l)),s===Lc.MAGNITUDE&&(f===1||c===1)&&(s=Lc.COMPONENT));let u=0;switch(l>0&&(u=l),s){case Lc.COMPONENT:{t.mapScalarsThroughTable(r,n,i,u);break}case Lc.RGBCOLORS:break;case Lc.MAGNITUDE:default:{const d=bt.newInstance({numberOfComponents:1,values:new Float32Array(r.getNumberOfTuples())});t.mapVectorsToMagnitude(r,d,c),t.mapScalarsThroughTable(d,n,i,0);break}}},t.luminanceToRGBA=(r,n,i,o)=>{const a=o(i),s=n.getData(),c=r.getData(),l=s.length,f=0,u=1;let d=0;for(let h=f;h<l;h+=u){const g=o(s[h]);c[d*4]=g,c[d*4+1]=g,c[d*4+2]=g,c[d*4+3]=a,d++}},t.luminanceAlphaToRGBA=(r,n,i,o)=>{const a=n.getData(),s=r.getData(),c=a.length,l=0,f=2;let u=0;for(let d=l;d<c;d+=f){const h=o(a[d]);s[u]=h,s[u+1]=h,s[u+2]=h,s[u+3]=o(a[d+1])*i,u+=4}},t.rGBToRGBA=(r,n,i,o)=>{const a=cD(i),s=n.getData(),c=r.getData(),l=s.length,f=0,u=3;let d=0;for(let h=f;h<l;h+=u)c[d*4]=o(s[h]),c[d*4+1]=o(s[h+1]),c[d*4+2]=o(s[h+2]),c[d*4+3]=a,d++},t.rGBAToRGBA=(r,n,i,o)=>{const a=n.getData(),s=r.getData(),c=a.length,l=0,f=4;let u=0;for(let d=l;d<c;d+=f)s[u*4]=o(a[d]),s[u*4+1]=o(a[d+1]),s[u*4+2]=o(a[d+2]),s[u*4+3]=o(a[d+3])*i,u++},t.convertToRGBA=(r,n,i)=>{let{alpha:o}=e;if(n===4&&o>=1&&r.getDataType()===gu.UNSIGNED_CHAR)return r;const a=bt.newInstance({numberOfComponents:4,empty:!0,size:4*i,dataType:gu.UNSIGNED_CHAR});if(i<=0)return a;o=o>0?o:0,o=o<1?o:1;let s=NQ;switch((r.getDataType()===gu.FLOAT||r.getDataType()===gu.DOUBLE)&&(s=cD),n){case 1:t.luminanceToRGBA(a,r,o,s);break;case 2:t.luminanceAlphaToRGBA(a,r,s);break;case 3:t.rGBToRGBA(a,r,o,s);break;case 4:t.rGBAToRGBA(a,r,o,s);break;default:return sD("Cannot convert colors"),null}return a},t.usingLogScale=()=>!1,t.getNumberOfAvailableColors=()=>256*256*256,t.setRange=(r,n)=>t.setMappingRange(r,n),t.getRange=()=>t.getMappingRange(),t.areScalarsOpaque=(r,n,i)=>{if(!r)return t.isOpaque();const o=r.getNumberOfComponents();return n===r2.DEFAULT&&r.getDataType()===gu.UNSIGNED_CHAR||n===r2.DIRECT_SCALARS?o===3||o===1?e.alpha>=1:r.getRange(o-1)[0]===255:!0}}const VQ={alpha:1,vectorComponent:0,vectorSize:-1,vectorMode:Lc.COMPONENT,mappingRange:null,annotationArray:null,annotatedValueMap:null,indexedLookup:!1};function sA(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,VQ,r),Z.obj(t,e),e.mappingRange=[0,255],e.annotationArray=[],e.annotatedValueMap=[],Z.setGet(t,e,["vectorSize","vectorComponent","vectorMode","alpha","indexedLookup"]),Z.setArray(t,e,["mappingRange"],2),Z.getArray(t,e,["mappingRange"]),kQ(t,e)}const FQ=Z.newInstance(sA,"vtkScalarsToColors");var sw={newInstance:FQ,extend:sA,...S4};const{vtkErrorMacro:lD}=Z,uD=0,fD=1,Bx=2;function UQ(t,e){e.classHierarchy.push("vtkLookupTable"),t.isOpaque=()=>{if(e.opaqueFlagBuildTime.getMTime()<t.getMTime()){let r=!0;e.nanColor[3]<1&&(r=0),e.useBelowRangeColor&&e.belowRangeColor[3]<1&&(r=0),e.useAboveRangeColor&&e.aboveRangeColor[3]<1&&(r=0);for(let n=3;n<e.table.length&&r;n+=4)e.table[n]<255&&(r=!1);e.opaqueFlag=r,e.opaqueFlagBuildTime.modified()}return e.opaqueFlag},t.usingLogScale=()=>!1,t.getNumberOfAvailableColors=()=>e.table.length/4-3,t.linearIndexLookup=(r,n)=>{let i=0;const o=Number(r);return o<n.range[0]?i=n.maxIndex+uD+1.5:o>n.range[1]?i=n.maxIndex+fD+1.5:(i=(o+n.shift)*n.scale,i=i<n.maxIndex?i:n.maxIndex),Math.floor(i)},t.linearLookup=(r,n,i)=>{let o=0;wy(r)?o=Math.floor(i.maxIndex+1.5+Bx):o=t.linearIndexLookup(r,i);const a=4*o;return n.slice(a,a+4)},t.indexedLookupFunction=(r,n,i)=>{let o=t.getAnnotatedValueIndexInternal(r);o===-1&&(o=e.numberOfColors+Bx);const a=4*o;return[n[a],n[a+1],n[a+2],n[a+3]]},t.lookupShiftAndScale=(r,n)=>{n.shift=-r[0],n.scale=Number.MAX_VALUE,r[1]>r[0]&&(n.scale=(n.maxIndex+1)/(r[1]-r[0]))},t.mapScalarsThroughTable=(r,n,i,o)=>{let a=t.linearLookup;e.indexedLookup&&(a=t.indexedLookupFunction);const s=t.getMappingRange(),c={maxIndex:t.getNumberOfColors()-1,range:s,shift:0,scale:0};t.lookupShiftAndScale(s,c);const l=t.getAlpha(),f=r.getNumberOfTuples(),u=r.getNumberOfComponents(),d=n.getData(),h=r.getData();if(l>=1){if(i===dS.RGBA)for(let g=0;g<f;g++){const p=a(h[g*u+o],e.table,c);d[g*4]=p[0],d[g*4+1]=p[1],d[g*4+2]=p[2],d[g*4+3]=p[3]}}else if(i===dS.RGBA)for(let g=0;g<f;g++){const p=a(h[g*u+o],e.table,c);d[g*4]=p[0],d[g*4+1]=p[1],d[g*4+2]=p[2],d[g*4+3]=Math.floor(p[3]*l+.5)}},t.forceBuild=()=>{let r=0,n=0,i=0,o=0;const a=e.numberOfColors-1;a&&(r=(e.hueRange[1]-e.hueRange[0])/a,n=(e.saturationRange[1]-e.saturationRange[0])/a,i=(e.valueRange[1]-e.valueRange[0])/a,o=(e.alphaRange[1]-e.alphaRange[0])/a),e.table.length=4*a+16;const s=[],c=[];for(let l=0;l<=a;l++)s[0]=e.hueRange[0]+l*r,s[1]=e.saturationRange[0]+l*n,s[2]=e.valueRange[0]+l*i,Kf(s,c),c[3]=e.alphaRange[0]+l*o,e.table[l*4]=c[0]*255+.5,e.table[l*4+1]=c[1]*255+.5,e.table[l*4+2]=c[2]*255+.5,e.table[l*4+3]=c[3]*255+.5;t.buildSpecialColors(),e.buildTime.modified()},t.setTable=r=>{if(Array.isArray(r)){const i=r[0].length;e.numberOfColors=r.length;const o=4-i;let a=0;for(let s=0;s<e.numberOfColors;s++)e.table[s*4]=255,e.table[s*4+1]=255,e.table[s*4+2]=255,e.table[s*4+3]=255;for(let s=0;s<r.length;s++){const c=r[s];for(let l=0;l<i;l++)e.table[a++]=c[l];a+=o}return t.buildSpecialColors(),e.insertTime.modified(),t.modified(),!0}if(r.getNumberOfComponents()!==4)return lD("Expected 4 components for RGBA colors"),!1;if(r.getDataType()!==rn.UNSIGNED_CHAR)return lD("Expected unsigned char values for RGBA colors"),!1;e.numberOfColors=r.getNumberOfTuples();const n=r.getData();e.table.length=n.length;for(let i=0;i<n.length;i++)e.table[i]=n[i];return t.buildSpecialColors(),e.insertTime.modified(),t.modified(),!0},t.buildSpecialColors=()=>{const{numberOfColors:r}=e,n=e.table;let i=(r+uD)*4;e.useBelowRangeColor||r===0?(n[i]=e.belowRangeColor[0]*255+.5,n[i+1]=e.belowRangeColor[1]*255+.5,n[i+2]=e.belowRangeColor[2]*255+.5,n[i+3]=e.belowRangeColor[3]*255+.5):(n[i]=n[0],n[i+1]=n[1],n[i+2]=n[2],n[i+3]=n[3]),i=(r+fD)*4,e.useAboveRangeColor||r===0?(n[i]=e.aboveRangeColor[0]*255+.5,n[i+1]=e.aboveRangeColor[1]*255+.5,n[i+2]=e.aboveRangeColor[2]*255+.5,n[i+3]=e.aboveRangeColor[3]*255+.5):(n[i]=n[4*(r-1)+0],n[i+1]=n[4*(r-1)+1],n[i+2]=n[4*(r-1)+2],n[i+3]=n[4*(r-1)+3]),i=(r+Bx)*4,n[i]=e.nanColor[0]*255+.5,n[i+1]=e.nanColor[1]*255+.5,n[i+2]=e.nanColor[2]*255+.5,n[i+3]=e.nanColor[3]*255+.5},t.build=()=>{(e.table.length<1||t.getMTime()>e.buildTime.getMTime()&&e.insertTime.getMTime()<=e.buildTime.getMTime())&&t.forceBuild()},e.table.length>0&&(t.buildSpecialColors(),e.insertTime.modified())}const BQ={numberOfColors:256,hueRange:[0,.66667],saturationRange:[1,1],valueRange:[1,1],alphaRange:[1,1],nanColor:[.5,0,0,1],belowRangeColor:[0,0,0,1],aboveRangeColor:[1,1,1,1],useAboveRangeColor:!1,useBelowRangeColor:!1,alpha:1};function cA(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,BQ,r),sw.extend(t,e,r),e.table||(e.table=[]),e.buildTime={},Z.obj(e.buildTime),e.opaqueFlagBuildTime={},Z.obj(e.opaqueFlagBuildTime,{mtime:0}),e.insertTime={},Z.obj(e.insertTime,{mtime:0}),Z.get(t,e,["buildTime"]),Z.setGet(t,e,["numberOfColors","useAboveRangeColor","useBelowRangeColor"]),Z.setArray(t,e,["alphaRange","hueRange","saturationRange","valueRange"],2),Z.setArray(t,e,["nanColor","belowRangeColor","aboveRangeColor"],4),Z.getArray(t,e,["hueRange","saturationRange","valueRange","alphaRange","nanColor","belowRangeColor","aboveRangeColor"]),UQ(t,e)}const GQ=Z.newInstance(cA,"vtkLookupTable");var Iy={newInstance:GQ,extend:cA};const pc={Off:0,PolygonOffset:1};let hS=pc.PolygonOffset,Oy=pc.Off;const WQ=["VTK_RESOLVE_OFF","VTK_RESOLVE_POLYGON_OFFSET"];function zQ(){return hS}function $Q(t){const e=hS===t;return hS=t,e}function jQ(){return Oy}function cw(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;const e=Oy===t;return Oy=t,e}function HQ(){return cw(pc.Off)}function KQ(){return cw(pc.Off)}function qQ(){return cw(pc.PolygonOffset)}function XQ(){return WQ[Oy]}var gS={Resolve:pc,getResolveCoincidentTopologyAsString:XQ,getResolveCoincidentTopologyPolygonOffsetFaces:zQ,getResolveCoincidentTopology:jQ,setResolveCoincidentTopology:cw,setResolveCoincidentTopologyPolygonOffsetFaces:$Q,setResolveCoincidentTopologyToDefault:HQ,setResolveCoincidentTopologyToOff:KQ,setResolveCoincidentTopologyToPolygonOffset:qQ};function lA(t,e,r){r.forEach(n=>{t[`get${n.method}`]=()=>e[n.key],t[`set${n.method}`]=Z.objectSetterMap.object(t,e,{name:n.key,params:["factor","offset"]})})}const T4=["Polygon","Line","Point"],YQ={Polygon:{factor:2,offset:0},Line:{factor:1,offset:-1},Point:{factor:0,offset:-2}},JQ=()=>{},qf={modified:JQ};lA(qf,YQ,T4.map(t=>({key:t,method:`ResolveCoincidentTopology${t}OffsetParameters`})));function ZQ(t,e){e.resolveCoincidentTopology===void 0&&(e.resolveCoincidentTopology=!1),Z.setGet(t,e,["resolveCoincidentTopology"]),e.topologyOffset={Polygon:{factor:0,offset:0},Line:{factor:0,offset:0},Point:{factor:0,offset:0}},Object.keys(gS).forEach(r=>{t[r]=gS[r]}),Object.keys(qf).filter(r=>r!=="modified").forEach(r=>{t[r]=qf[r]}),lA(t,e.topologyOffset,T4.map(r=>({key:r,method:`RelativeCoincidentTopology${r}OffsetParameters`}))),t.getCoincidentTopologyPolygonOffsetParameters=()=>{const r=qf.getResolveCoincidentTopologyPolygonOffsetParameters(),n=t.getRelativeCoincidentTopologyPolygonOffsetParameters();return{factor:r.factor+n.factor,offset:r.offset+n.offset}},t.getCoincidentTopologyLineOffsetParameters=()=>{const r=qf.getResolveCoincidentTopologyLineOffsetParameters(),n=t.getRelativeCoincidentTopologyLineOffsetParameters();return{factor:r.factor+n.factor,offset:r.offset+n.offset}},t.getCoincidentTopologyPointOffsetParameter=()=>{const r=qf.getResolveCoincidentTopologyPointOffsetParameters(),n=t.getRelativeCoincidentTopologyPointOffsetParameters();return{factor:r.factor+n.factor,offset:r.offset+n.offset}}}var lw={implementCoincidentTopologyMethods:ZQ,staticOffsetAPI:qf,otherStaticMethods:gS,CATEGORIES:T4,Resolve:pc};const{FieldAssociations:dD}=Wh,{staticOffsetAPI:QQ,otherStaticMethods:eee}=lw,{ColorMode:i2,ScalarMode:Of,GetArray:Gx}=aw,{VectorMode:tee}=S4,{VtkDataTypes:nee}=bt;function Sg(t){return()=>Z.vtkErrorMacro(`vtkMapper::${t} - NOT IMPLEMENTED`)}function ree(t,e){const r=t[1]%2===0?1:-1;if(t[0]+=r,t[0]>=e[0]||t[0]<0){const n=t[2]%2===0?1:-1;t[0]-=r,t[1]+=n,(t[1]>=e[1]||t[1]<0)&&(t[1]-=n,t[2]++)}}function iee(t,e){return t[0]+e[0]*(t[1]+e[1]*t[2])}function hD(t,e,r){const n=Math.floor(e),i=n%(2*r[0]);let o,a;i<r[0]?(t[0]=i,o=1,a=t[0]===r[0]-1):(t[0]=2*r[0]-1-i,o=-1,a=t[0]===0);const s=Math.floor(n/r[0]),c=s%(2*r[1]);let l,f;c<r[1]?(t[1]=c,l=1,f=t[1]===r[1]-1):(t[1]=2*r[1]-1-c,l=-1,f=t[1]===0),t[2]=Math.floor(s/r[1]);const u=e-n;a?f?t[2]+=u:t[1]+=l*u:t[0]+=o*u,t[0]=(t[0]+.5)/r[0],t[1]=(t[1]+.5)/r[1],t[2]=(t[2]+.5)/r[2]}const gD=new WeakMap;function oee(t,e,r,n,i,o,a){var I;const s=new Array(arguments.length);for(let P=0;P<arguments.length;++P){const O=arguments[P];s[P]=((I=O.getMTime)==null?void 0:I.call(O))??O}const c=s.join("/"),l=gD.get(t);if(l&&l.stringHash===c)return l.textureCoordinates;const f=(r[1]-r[0])/(n-1),[u,d]=[r[0]-f,r[1]+f],h=u-.5*f,g=1/(d-u+f),p=u,v=(n+1)/(d-u),y=t.getData(),m=t.getNumberOfTuples(),w=t.getNumberOfComponents(),x=e<0||e>=w,C=i[2]<=1?2:3,S=bt.newInstance({numberOfComponents:C,values:new Float32Array(m*C)}),T=S.getData(),_=[0,0,0];hD(_,n+2,i);let E=0,b=0;const D=[.5,.5,.5];for(let P=0;P<m;++P){let O;if(x){let L=0;for(let B=0;B<w;++B){const H=y[E+B];L+=H*H}O=Math.sqrt(L)}else O=y[E+e];if(E+=w,o&&(O=Iy.applyLogScale(O,r,r)),wy(O))D[0]=_[0],D[1]=_[1],D[2]=_[2];else if(a){let L=(O-p)*v;L<1?L=0:L>n&&(L=n+1),hD(D,L,i)}else{D[1]=.49;const L=(O-h)*g;L>1e3?D[0]=1e3:L<-1e3?D[0]=-1e3:D[0]=L}for(let L=0;L<C;++L)T[b++]=D[L]}return gD.set(t,{stringHash:c,textureCoordinates:S}),S}function aee(t,e){e.classHierarchy.push("vtkMapper"),t.getBounds=()=>{const r=t.getInputData();return r?(e.static||t.update(),e.bounds=r.getBounds()):e.bounds=of(),e.bounds},t.setForceCompileOnly=r=>{e.forceCompileOnly=r},t.setSelectionWebGLIdsToVTKIds=r=>{e.selectionWebGLIdsToVTKIds=r},t.createDefaultLookupTable=()=>{e.lookupTable=Iy.newInstance()},t.getColorModeAsString=()=>Z.enumToString(i2,e.colorMode),t.setColorModeToDefault=()=>t.setColorMode(0),t.setColorModeToMapScalars=()=>t.setColorMode(1),t.setColorModeToDirectScalars=()=>t.setColorMode(2),t.getScalarModeAsString=()=>Z.enumToString(Of,e.scalarMode),t.setScalarModeToDefault=()=>t.setScalarMode(0),t.setScalarModeToUsePointData=()=>t.setScalarMode(1),t.setScalarModeToUseCellData=()=>t.setScalarMode(2),t.setScalarModeToUsePointFieldData=()=>t.setScalarMode(3),t.setScalarModeToUseCellFieldData=()=>t.setScalarMode(4),t.setScalarModeToUseFieldData=()=>t.setScalarMode(5),t.getAbstractScalars=(r,n,i,o,a)=>{if(!r||!e.scalarVisibility)return{scalars:null,cellFlag:!1};let s=null,c=!1;if(n===Of.DEFAULT)s=r.getPointData().getScalars(),s||(s=r.getCellData().getScalars(),c=!0);else if(n===Of.USE_POINT_DATA)s=r.getPointData().getScalars();else if(n===Of.USE_CELL_DATA)s=r.getCellData().getScalars(),c=!0;else if(n===Of.USE_POINT_FIELD_DATA){const l=r.getPointData();i===Gx.BY_ID?s=l.getArrayByIndex(o):s=l.getArrayByName(a)}else if(n===Of.USE_CELL_FIELD_DATA){const l=r.getCellData();c=!0,i===Gx.BY_ID?s=l.getArrayByIndex(o):s=l.getArrayByName(a)}else if(n===Of.USE_FIELD_DATA){const l=r.getFieldData();i===Gx.BY_ID?s=l.getArrayByIndex(o):s=l.getArrayByName(a)}return{scalars:s,cellFlag:c}},t.mapScalars=(r,n)=>{const{scalars:i,cellFlag:o}=t.getAbstractScalars(r,e.scalarMode,e.arrayAccessMode,e.arrayId,e.colorByArrayName);if(e.areScalarsMappedFromCells=o,!i){e.colorCoordinates=null,e.colorTextureMap=null,e.colorMapColors=null;return}const a=`${t.getMTime()}${i.getMTime()}${n}`;if(e.colorBuildString!==a){if(e.useLookupTableScalarRange||t.getLookupTable().setRange(e.scalarRange[0],e.scalarRange[1]),t.canUseTextureMapForColoring(i,o))e.mapScalarsToTexture(i,o,n);else{e.colorCoordinates=null,e.colorTextureMap=null;const s=t.getLookupTable();s&&(s.build(),e.colorMapColors=s.mapScalars(i,e.colorMode,e.fieldDataTupleId))}e.colorBuildString=`${t.getMTime()}${i.getMTime()}${n}`}},e.mapScalarsToTexture=(r,n,i)=>{const o=e.lookupTable.getRange(),a=e.lookupTable.usingLogScale();a&&Iy.getLogRange(o,o);const s=e.lookupTable.getAlpha();if(e.colorMapColors=null,e.colorTextureMap==null||t.getMTime()>e.colorTextureMap.getMTime()||e.lookupTable.getMTime()>e.colorTextureMap.getMTime()||e.lookupTable.getAlpha()!==i){e.lookupTable.setAlpha(i),e.colorTextureMap=null,e.lookupTable.build();const l=e.lookupTable.getNumberOfAvailableColors(),f=2048,u=f**3-3,h=4096-2,g=2,p=n?u:h;e.numberOfColorsInRange=Math.min(Math.max(l,g),p);const v=e.numberOfColorsInRange+3,y=e.numberOfColorsInRange+2,m=n?[Math.min(Math.ceil(v/f**0),f),Math.min(Math.ceil(v/f**1),f),Math.min(Math.ceil(v/f**2),f)]:[y,2,1],w=m[0]*m[1]*m[2],x=new Float64Array(w);x.fill(NaN);const C=e.numberOfColorsInRange,S=C+2,T=[0,0,0],_=o[0],E=o[1]-o[0];for(let I=0;I<S;++I){const P=iee(T,m),O=_+E*(I-1)/(C-1);x[P]=a?10**O:O,ree(T,m)}const b=bt.newInstance({numberOfComponents:1,values:x}),D=e.lookupTable.mapScalars(b,e.colorMode,0);e.colorTextureMap=nm.newInstance(),e.colorTextureMap.setDimensions(m),e.colorTextureMap.getPointData().setScalars(D),e.lookupTable.setAlpha(s)}const c=e.lookupTable.getVectorMode()===tee.MAGNITUDE&&r.getNumberOfComponents()>1?-1:e.lookupTable.getVectorComponent();e.colorCoordinates=oee(r,c,o,e.numberOfColorsInRange,e.colorTextureMap.getDimensions(),a,n)},t.getIsOpaque=()=>{const r=t.getInputData(),i=t.getAbstractScalars(r,e.scalarMode,e.arrayAccessMode,e.arrayId,e.colorByArrayName).scalars;if(!e.scalarVisibility||i==null)return!0;const o=t.getLookupTable();return o?(o.build(),o.areScalarsOpaque(i,e.colorMode,-1)):!0},t.canUseTextureMapForColoring=(r,n)=>n&&e.colorMode!==i2.DIRECT_SCALARS?!0:!(!e.interpolateScalarsBeforeMapping||e.lookupTable&&e.lookupTable.getIndexedLookup()||!r||e.colorMode===i2.DEFAULT&&r.getDataType()===nee.UNSIGNED_CHAR||e.colorMode===i2.DIRECT_SCALARS),t.clearColorArrays=()=>{e.colorMapColors=null,e.colorCoordinates=null,e.colorTextureMap=null},t.getLookupTable=()=>(e.lookupTable||t.createDefaultLookupTable(),e.lookupTable),t.getMTime=()=>{let r=e.mtime;if(e.lookupTable!==null){const n=e.lookupTable.getMTime();r=n>r?n:r}return r},t.getPrimitiveCount=()=>{const r=t.getInputData();return{points:r.getPoints().getNumberOfValues()/3,verts:r.getVerts().getNumberOfValues()-r.getVerts().getNumberOfCells(),lines:r.getLines().getNumberOfValues()-2*r.getLines().getNumberOfCells(),triangles:r.getPolys().getNumberOfValues()-3*r.getPolys().getNumberOfCells()}},t.acquireInvertibleLookupTable=Sg("AcquireInvertibleLookupTable"),t.valueToColor=Sg("ValueToColor"),t.colorToValue=Sg("ColorToValue"),t.useInvertibleColorFor=Sg("UseInvertibleColorFor"),t.clearInvertibleColor=Sg("ClearInvertibleColor"),t.processSelectorPixelBuffers=(r,n)=>{if(!r||!e.selectionWebGLIdsToVTKIds||!e.populateSelectionSettings)return;const i=r.getRawPixelBuffer($o.ID_LOW24),o=r.getRawPixelBuffer($o.ID_HIGH24),a=r.getCurrentPass(),s=r.getFieldAssociation();let c=null;s===dD.FIELD_ASSOCIATION_POINTS?c=e.selectionWebGLIdsToVTKIds.points:s===dD.FIELD_ASSOCIATION_CELLS&&(c=e.selectionWebGLIdsToVTKIds.cells),c&&n.forEach(l=>{if(a===$o.ID_LOW24){let f=0;o&&(f+=o[l],f*=256),f+=i[l+2],f*=256,f+=i[l+1],f*=256,f+=i[l];const u=c[f],d=r.getPixelBuffer($o.ID_LOW24);d[l]=u&255,d[l+1]=(u&65280)>>8,d[l+2]=(u&16711680)>>16}else if(a===$o.ID_HIGH24&&o){let f=0;f+=o[l],f*=256,f+=i[l+2],f*=256,f+=i[l+1],f*=256,f+=i[l];const u=c[f],d=r.getPixelBuffer($o.ID_HIGH24);d[l]=(u&4278190080)>>24}})}}const see={colorMapColors:null,areScalarsMappedFromCells:!1,static:!1,lookupTable:null,scalarVisibility:!0,scalarRange:[0,1],useLookupTableScalarRange:!1,colorMode:0,scalarMode:0,arrayAccessMode:1,renderTime:0,colorByArrayName:null,fieldDataTupleId:-1,populateSelectionSettings:!0,selectionWebGLIdsToVTKIds:null,interpolateScalarsBeforeMapping:!1,colorCoordinates:null,colorTextureMap:null,numberOfColorsInRange:0,forceCompileOnly:0,useInvertibleColors:!1,invertibleScalars:null,customShaderAttributes:[]};function uA(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,see,r),C4.extend(t,e,r),Z.get(t,e,["areScalarsMappedFromCells","colorCoordinates","colorMapColors","colorTextureMap","numberOfColorsInRange","selectionWebGLIdsToVTKIds"]),Z.setGet(t,e,["colorByArrayName","arrayAccessMode","colorMode","fieldDataTupleId","interpolateScalarsBeforeMapping","lookupTable","populateSelectionSettings","renderTime","scalarMode","scalarVisibility","static","useLookupTableScalarRange","customShaderAttributes"]),Z.setGetArray(t,e,["scalarRange"],2),lw.implementCoincidentTopologyMethods(t,e),aee(t,e)}const cee=Z.newInstance(uA,"vtkMapper");var la={newInstance:cee,extend:uA,...QQ,...eee,...aw};const lee={DISPLAY:0,WORLD:1};var fA={CoordinateSystem:lee};const{CoordinateSystem:pS}=fA;function pD(t){return()=>Z.vtkErrorMacro(`vtkProp::${t} - NOT IMPLEMENTED`)}function uee(t,e){e.classHierarchy.push("vtkProp"),t.getMTime=()=>{let r=e.mtime;for(let n=0;n<e.textures.length;++n){const i=e.textures[n].getMTime();i>r&&(r=i)}return r},t.processSelectorPixelBuffers=(r,n)=>{},t.getNestedProps=()=>null,t.getActors=()=>[],t.getActors2D=()=>[],t.getVolumes=()=>[],t.pick=pD("pick"),t.hasKey=pD("hasKey"),t.getNestedVisibility=()=>e.visibility&&(!e._parentProp||e._parentProp.getNestedVisibility()),t.getNestedPickable=()=>e.pickable&&(!e._parentProp||e._parentProp.getNestedPickable()),t.getNestedDragable=()=>e.dragable&&(!e._parentProp||e._parentProp.getNestedDragable()),t.getRedrawMTime=()=>e.mtime,t.setEstimatedRenderTime=r=>{e.estimatedRenderTime=r,e.savedEstimatedRenderTime=r},t.restoreEstimatedRenderTime=()=>{e.estimatedRenderTime=e.savedEstimatedRenderTime},t.addEstimatedRenderTime=r=>{e.estimatedRenderTime+=r},t.setAllocatedRenderTime=r=>{e.allocatedRenderTime=r,e.savedEstimatedRenderTime=e.estimatedRenderTime,e.estimatedRenderTime=0},t.getSupportsSelection=()=>!1,t.getTextures=()=>e.textures,t.hasTexture=r=>e.textures.indexOf(r)!==-1,t.addTexture=r=>{r&&!t.hasTexture(r)&&(e.textures=e.textures.concat(r),t.modified())},t.removeTexture=r=>{const n=e.textures.filter(i=>i!==r);e.textures.length!==n.length&&(e.textures=n,t.modified())},t.removeAllTextures=()=>{e.textures=[],t.modified()},t.setCoordinateSystemToWorld=()=>t.setCoordinateSystem(pS.WORLD),t.setCoordinateSystemToDisplay=()=>t.setCoordinateSystem(pS.DISPLAY)}const fee={allocatedRenderTime:10,coordinateSystem:pS.WORLD,dragable:!0,estimatedRenderTime:0,paths:null,pickable:!0,renderTimeMultiplier:1,savedEstimatedRenderTime:0,textures:[],useBounds:!0,visibility:!0};function dA(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,fee,r),Z.obj(t,e),Z.get(t,e,["estimatedRenderTime","allocatedRenderTime"]),Z.setGet(t,e,["_parentProp","coordinateSystem","dragable","pickable","renderTimeMultiplier","useBounds","visibility"]),Z.moveToProtected(t,e,["parentProp"]),uee(t,e)}const dee=Z.newInstance(dA,"vtkProp");var rm={newInstance:dee,extend:dA,...fA},_4=`//VTK::System::Dec
|
||
|
||
/*=========================================================================
|
||
|
||
Program: Visualization Toolkit
|
||
Module: vtkPolyDataVS.glsl
|
||
|
||
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
|
||
All rights reserved.
|
||
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
|
||
|
||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||
PURPOSE. See the above copyright notice for more information.
|
||
|
||
=========================================================================*/
|
||
|
||
attribute vec4 vertexMC;
|
||
|
||
// frag position in VC
|
||
//VTK::PositionVC::Dec
|
||
|
||
// optional normal declaration
|
||
//VTK::Normal::Dec
|
||
|
||
// extra lighting parameters
|
||
//VTK::Light::Dec
|
||
|
||
// Texture coordinates
|
||
//VTK::TCoord::Dec
|
||
|
||
// material property values
|
||
//VTK::Color::Dec
|
||
|
||
// clipping plane vars
|
||
//VTK::Clip::Dec
|
||
|
||
// camera and actor matrix values
|
||
//VTK::Camera::Dec
|
||
|
||
// Apple Bug
|
||
//VTK::PrimID::Dec
|
||
|
||
// picking support
|
||
//VTK::Picking::Dec
|
||
|
||
void main()
|
||
{
|
||
//VTK::Color::Impl
|
||
|
||
//VTK::Normal::Impl
|
||
|
||
//VTK::TCoord::Impl
|
||
|
||
//VTK::Clip::Impl
|
||
|
||
//VTK::PrimID::Impl
|
||
|
||
//VTK::PositionVC::Impl
|
||
|
||
//VTK::Light::Impl
|
||
|
||
//VTK::Picking::Impl
|
||
}
|
||
`,im=`//VTK::System::Dec
|
||
|
||
/*=========================================================================
|
||
|
||
Program: Visualization Toolkit
|
||
Module: vtkPolyDataFS.glsl
|
||
|
||
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
|
||
All rights reserved.
|
||
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
|
||
|
||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||
PURPOSE. See the above copyright notice for more information.
|
||
|
||
=========================================================================*/
|
||
// Template for the polydata mappers fragment shader
|
||
|
||
uniform int PrimitiveIDOffset;
|
||
|
||
// VC position of this fragment
|
||
//VTK::PositionVC::Dec
|
||
|
||
// optional color passed in from the vertex shader, vertexColor
|
||
//VTK::Color::Dec
|
||
|
||
// optional surface normal declaration
|
||
//VTK::Normal::Dec
|
||
|
||
// extra lighting parameters
|
||
//VTK::Light::Dec
|
||
|
||
// define vtkImageLabelOutlineOn
|
||
//VTK::ImageLabelOutlineOn
|
||
|
||
// Texture coordinates
|
||
//VTK::TCoord::Dec
|
||
|
||
// picking support
|
||
//VTK::Picking::Dec
|
||
|
||
// Depth Peeling Support
|
||
//VTK::DepthPeeling::Dec
|
||
|
||
// clipping plane vars
|
||
//VTK::Clip::Dec
|
||
|
||
// label outline
|
||
//VTK::LabelOutline::Dec
|
||
|
||
// the output of this shader
|
||
//VTK::Output::Dec
|
||
|
||
// Apple Bug
|
||
//VTK::PrimID::Dec
|
||
|
||
// handle coincident offsets
|
||
//VTK::Coincident::Dec
|
||
|
||
//VTK::ZBuffer::Dec
|
||
|
||
//VTK::LabelOutlineHelperFunction
|
||
|
||
void main()
|
||
{
|
||
// VC position of this fragment. This should not branch/return/discard.
|
||
//VTK::PositionVC::Impl
|
||
|
||
// Place any calls that require uniform flow (e.g. dFdx) here.
|
||
//VTK::UniformFlow::Impl
|
||
|
||
// Set gl_FragDepth here (gl_FragCoord.z by default)
|
||
//VTK::Depth::Impl
|
||
|
||
// Early depth peeling abort:
|
||
//VTK::DepthPeeling::PreColor
|
||
|
||
// Apple Bug
|
||
//VTK::PrimID::Impl
|
||
|
||
//VTK::Clip::Impl
|
||
|
||
//VTK::Color::Impl
|
||
|
||
// Generate the normal if we are not passed in one
|
||
//VTK::Normal::Impl
|
||
|
||
//VTK::TCoord::Impl
|
||
|
||
//VTK::Light::Impl
|
||
|
||
if (gl_FragData[0].a <= 0.0)
|
||
{
|
||
discard;
|
||
}
|
||
|
||
//VTK::DepthPeeling::Impl
|
||
|
||
//VTK::Picking::Impl
|
||
|
||
// handle coincident offsets
|
||
//VTK::Coincident::Impl
|
||
|
||
//VTK::ZBuffer::Impl
|
||
|
||
//VTK::RenderPassFragmentShader::Impl
|
||
}
|
||
`;function hee(t,e){t.replaceShaderCoincidentOffset=(r,n,i)=>{const o=t.getCoincidentParameters(n,i);if(o&&(o.factor!==0||o.offset!==0)){let a=r.Fragment;a=Be.substitute(a,"//VTK::Coincident::Dec",["uniform float cfactor;","uniform float coffset;"]).result,e.context.getExtension("EXT_frag_depth")&&(o.factor!==0?(a=Be.substitute(a,"//VTK::UniformFlow::Impl",["float cscale = length(vec2(dFdx(gl_FragCoord.z),dFdy(gl_FragCoord.z)));","//VTK::UniformFlow::Impl"],!1).result,a=Be.substitute(a,"//VTK::Depth::Impl","gl_FragDepthEXT = gl_FragCoord.z + cfactor*cscale + 0.000016*coffset;").result):a=Be.substitute(a,"//VTK::Depth::Impl","gl_FragDepthEXT = gl_FragCoord.z + 0.000016*coffset;").result),e._openGLRenderWindow.getWebgl2()&&(o.factor!==0?(a=Be.substitute(a,"//VTK::UniformFlow::Impl",["float cscale = length(vec2(dFdx(gl_FragCoord.z),dFdy(gl_FragCoord.z)));","//VTK::UniformFlow::Impl"],!1).result,a=Be.substitute(a,"//VTK::Depth::Impl","gl_FragDepth = gl_FragCoord.z + cfactor*cscale + 0.000016*coffset;").result):a=Be.substitute(a,"//VTK::Depth::Impl","gl_FragDepth = gl_FragCoord.z + 0.000016*coffset;").result),r.Fragment=a}}}function gee(t,e){t.applyShaderReplacements=(r,n,i)=>{let o=null;if(n&&(o=n.ShaderReplacements),o)for(let a=0;a<o.length;a++){const s=o[a];if(i&&s.replaceFirst||!i&&!s.replaceFirst){const c=s.shaderType,l=r[c],f=Be.substitute(l,s.originalValue,s.replacementValue,s.replaceAll);r[c]=f.result}}},t.buildShaders=(r,n,i)=>{t.getReplacedShaderTemplate(r,n,i),e.lastRenderPassShaderReplacement=e.currentRenderPass?e.currentRenderPass.getShaderReplacement():null,e.lastRenderPassShaderReplacement&&e.lastRenderPassShaderReplacement(r);const o=e.renderable.getViewSpecificProperties().OpenGL;t.applyShaderReplacements(r,o,!0),t.replaceShaderValues(r,n,i),t.applyShaderReplacements(r,o)},t.getReplacedShaderTemplate=(r,n,i)=>{const o=e.renderable.getViewSpecificProperties().OpenGL;t.getShaderTemplate(r,n,i);let a=r.Vertex;if(o){const l=o.VertexShaderCode;l!==void 0&&l!==""&&(a=l)}r.Vertex=a;let s=r.Fragment;if(o){const l=o.FragmentShaderCode;l!==void 0&&l!==""&&(s=l)}r.Fragment=s;let c=r.Geometry;if(o){const l=o.GeometryShaderCode;l!==void 0&&(c=l)}r.Geometry=c}}var rl={implementReplaceShaderCoincidentOffset:hee,implementBuildShadersWithReplacements:gee};const{FieldAssociations:Wx}=Wh,{primTypes:Pi}=ul,{Representation:qd,Shading:mD}=Fd,{ScalarMode:o2}=la,{Filter:vD,Wrap:yD}=mr,{vtkErrorMacro:Mf}=uo,pee={type:"StartEvent"},mee={type:"EndEvent"},{CoordinateSystem:vee}=rm;function yee(t){const e=t.getSelector();return e?e.getCurrentPass():$o.MIN_KNOWN_PASS-1}function wee(t,e){e.classHierarchy.push("vtkOpenGLPolyDataMapper"),t.buildPass=n=>{n&&(e.currentRenderPass=null,e.openGLActor=t.getFirstAncestorOfType("vtkOpenGLActor"),e._openGLRenderer=e.openGLActor.getFirstAncestorOfType("vtkOpenGLRenderer"),e._openGLRenderWindow=e._openGLRenderer.getLastAncestorOfType("vtkOpenGLRenderWindow"),e.openGLCamera=e._openGLRenderer.getViewNodeFor(e._openGLRenderer.getRenderable().getActiveCamera()))},t.translucentPass=(n,i)=>{n&&(e.currentRenderPass=i,t.render())},t.zBufferPass=n=>{n&&(e.haveSeenDepthRequest=!0,e.renderDepth=!0,t.render(),e.renderDepth=!1)},t.opaqueZBufferPass=n=>t.zBufferPass(n),t.opaquePass=n=>{n&&t.render()},t.render=()=>{const n=e._openGLRenderWindow.getContext();if(e.context!==n){e.context=n;for(let a=Pi.Start;a<Pi.End;a++)e.primitives[a].setOpenGLRenderWindow(e._openGLRenderWindow)}const i=e.openGLActor.getRenderable(),o=e._openGLRenderer.getRenderable();t.renderPiece(o,i)},t.getShaderTemplate=(n,i,o)=>{n.Vertex=_4,n.Fragment=im,n.Geometry=""},t.replaceShaderColor=(n,i,o)=>{let a=n.Vertex,s=n.Geometry,c=n.Fragment;const l=e.lastBoundBO.getReferenceByName("lastLightComplexity");let f=["uniform float ambient;","uniform float diffuse;","uniform float specular;","uniform float opacityUniform; // the fragment opacity","uniform vec3 ambientColorUniform;","uniform vec3 diffuseColorUniform;"];l&&(f=f.concat(["uniform vec3 specularColorUniform;","uniform float specularPowerUniform;"]));let u=["vec3 ambientColor;"," vec3 diffuseColor;"," float opacity;"];l&&(u=u.concat([" vec3 specularColor;"," float specularPower;"])),u=u.concat([" ambientColor = ambientColorUniform;"," diffuseColor = diffuseColorUniform;"," opacity = opacityUniform;"]),l&&(u=u.concat([" specularColor = specularColorUniform;"," specularPower = specularPowerUniform;"])),e.lastBoundBO.getCABO().getColorComponents()!==0&&!e.drawingEdges&&(f=f.concat(["varying vec4 vertexColorVSOutput;"]),a=Be.substitute(a,"//VTK::Color::Dec",["attribute vec4 scalarColor;","varying vec4 vertexColorVSOutput;"]).result,a=Be.substitute(a,"//VTK::Color::Impl",["vertexColorVSOutput = scalarColor;"]).result,s=Be.substitute(s,"//VTK::Color::Dec",["in vec4 vertexColorVSOutput[];","out vec4 vertexColorGSOutput;"]).result,s=Be.substitute(s,"//VTK::Color::Impl",["vertexColorGSOutput = vertexColorVSOutput[i];"]).result),e.lastBoundBO.getCABO().getColorComponents()!==0&&!e.drawingEdges?c=Be.substitute(c,"//VTK::Color::Impl",u.concat([" diffuseColor = vertexColorVSOutput.rgb;"," ambientColor = vertexColorVSOutput.rgb;"," opacity = opacity*vertexColorVSOutput.a;"])).result:(e.renderable.getAreScalarsMappedFromCells()||e.renderable.getInterpolateScalarsBeforeMapping())&&e.renderable.getColorCoordinates()&&!e.drawingEdges?c=Be.substitute(c,"//VTK::Color::Impl",u.concat([" vec4 texColor = texture2D(texture1, tcoordVCVSOutput.st);"," diffuseColor = texColor.rgb;"," ambientColor = texColor.rgb;"," opacity = opacity*texColor.a;"])).result:(o.getBackfaceProperty()&&!e.drawingEdges&&(f=f.concat(["uniform float opacityUniformBF; // the fragment opacity","uniform float ambientIntensityBF; // the material ambient","uniform float diffuseIntensityBF; // the material diffuse","uniform vec3 ambientColorUniformBF; // ambient material color","uniform vec3 diffuseColorUniformBF; // diffuse material color"]),l?(f=f.concat(["uniform float specularIntensityBF; // the material specular intensity","uniform vec3 specularColorUniformBF; // intensity weighted color","uniform float specularPowerUniformBF;"]),u=u.concat(["if (gl_FrontFacing == false) {"," ambientColor = ambientIntensityBF * ambientColorUniformBF;"," diffuseColor = diffuseIntensityBF * diffuseColorUniformBF;"," specularColor = specularIntensityBF * specularColorUniformBF;"," specularPower = specularPowerUniformBF;"," opacity = opacityUniformBF; }"])):u=u.concat(["if (gl_FrontFacing == false) {"," ambientColor = ambientIntensityBF * ambientColorUniformBF;"," diffuseColor = diffuseIntensityBF * diffuseColorUniformBF;"," opacity = opacityUniformBF; }"])),e.haveCellScalars&&!e.drawingEdges&&(f=f.concat(["uniform samplerBuffer texture1;"])),c=Be.substitute(c,"//VTK::Color::Impl",u).result),c=Be.substitute(c,"//VTK::Color::Dec",f).result,n.Vertex=a,n.Geometry=s,n.Fragment=c},t.replaceShaderLight=(n,i,o)=>{let a=n.Fragment;const s="",c=e.lastBoundBO.getReferenceByName("lastLightComplexity"),l=e.lastBoundBO.getReferenceByName("lastLightCount");let f=[];switch(c){case 0:a=Be.substitute(a,"//VTK::Light::Impl",[" gl_FragData[0] = vec4(ambientColor * ambient + diffuseColor * diffuse, opacity);"," //VTK::Light::Impl"],!1).result;break;case 1:a=Be.substitute(a,"//VTK::Light::Impl",[" float df = max(0.0, normalVCVSOutput.z);"," float sf = pow(df, specularPower);"," vec3 diffuseL = df * diffuseColor;"," vec3 specularL = sf * specularColor;"," gl_FragData[0] = vec4(ambientColor * ambient + diffuseL * diffuse + specularL * specular, opacity);"," //VTK::Light::Impl"],!1).result;break;case 2:for(let u=0;u<l;++u)f=f.concat([`uniform vec3 lightColor${u};`,`uniform vec3 lightDirectionVC${u}; // normalized`,`uniform vec3 lightHalfAngleVC${u}; // normalized`]);a=Be.substitute(a,"//VTK::Light::Dec",f).result,f=["vec3 diffuseL = vec3(0,0,0);"," vec3 specularL = vec3(0,0,0);"," float df;"];for(let u=0;u<l;++u)f=f.concat([` df = max(0.0, dot(normalVCVSOutput, -lightDirectionVC${u}));`,` diffuseL += ((df${s}) * lightColor${u});`,` if (dot(normalVCVSOutput, lightDirectionVC${u}) < 0.0)`," {",` float sf = sign(df)*pow(max(1e-5,
|
||
dot(reflect(lightDirectionVC${u},normalVCVSOutput),
|
||
normalize(-vertexVC.xyz))),
|
||
specularPower);`,` specularL += (sf${s} * lightColor${u});`," }"]);f=f.concat([" diffuseL = diffuseL * diffuseColor;"," specularL = specularL * specularColor;"," gl_FragData[0] = vec4(ambientColor * ambient + diffuseL * diffuse + specularL * specular, opacity);"," //VTK::Light::Impl"]),a=Be.substitute(a,"//VTK::Light::Impl",f,!1).result;break;case 3:for(let u=0;u<l;++u)f=f.concat([`uniform vec3 lightColor${u};`,`uniform vec3 lightDirectionVC${u}; // normalized`,`uniform vec3 lightHalfAngleVC${u}; // normalized`,`uniform vec3 lightPositionVC${u};`,`uniform vec3 lightAttenuation${u};`,`uniform float lightConeAngle${u};`,`uniform float lightExponent${u};`,`uniform int lightPositional${u};`]);a=Be.substitute(a,"//VTK::Light::Dec",f).result,f=["vec3 diffuseL = vec3(0,0,0);"," vec3 specularL = vec3(0,0,0);"," vec3 vertLightDirectionVC;"," float attenuation;"," float df;"];for(let u=0;u<l;++u)f=f.concat([" attenuation = 1.0;",` if (lightPositional${u} == 0)`," {",` vertLightDirectionVC = lightDirectionVC${u};`," }"," else"," {",` vertLightDirectionVC = vertexVC.xyz - lightPositionVC${u};`," float distanceVC = length(vertLightDirectionVC);"," vertLightDirectionVC = normalize(vertLightDirectionVC);"," attenuation = 1.0 /",` (lightAttenuation${u}.x`,` + lightAttenuation${u}.y * distanceVC`,` + lightAttenuation${u}.z * distanceVC * distanceVC);`," // per OpenGL standard cone angle is 90 or less for a spot light",` if (lightConeAngle${u} <= 90.0)`," {",` float coneDot = dot(vertLightDirectionVC, lightDirectionVC${u});`," // if inside the cone",` if (coneDot >= cos(radians(lightConeAngle${u})))`," {",` attenuation = attenuation * pow(coneDot, lightExponent${u});`," }"," else"," {"," attenuation = 0.0;"," }"," }"," }"," df = max(0.0, attenuation*dot(normalVCVSOutput, -vertLightDirectionVC));",` diffuseL += ((df${s}) * lightColor${u});`," if (dot(normalVCVSOutput, vertLightDirectionVC) < 0.0)"," {",` float sf = sign(df)*attenuation*pow(max(1e-5,
|
||
dot(reflect(lightDirectionVC${u},
|
||
normalVCVSOutput),
|
||
normalize(-vertexVC.xyz))),
|
||
specularPower);`,` specularL += ((sf${s}) * lightColor${u});`," }"]);f=f.concat([" diffuseL = diffuseL * diffuseColor;"," specularL = specularL * specularColor;"," gl_FragData[0] = vec4(ambientColor * ambient + diffuseL * diffuse + specularL * specular, opacity);"," //VTK::Light::Impl"]),a=Be.substitute(a,"//VTK::Light::Impl",f,!1).result;break;default:Mf("bad light complexity")}n.Fragment=a},t.replaceShaderNormal=(n,i,o)=>{if(e.lastBoundBO.getReferenceByName("lastLightComplexity")>0){let s=n.Vertex,c=n.Geometry,l=n.Fragment;e.lastBoundBO.getCABO().getNormalOffset()?(s=Be.substitute(s,"//VTK::Normal::Dec",["attribute vec3 normalMC;","uniform mat3 normalMatrix;","varying vec3 normalVCVSOutput;"]).result,s=Be.substitute(s,"//VTK::Normal::Impl",["normalVCVSOutput = normalMatrix * normalMC;"]).result,c=Be.substitute(c,"//VTK::Normal::Dec",["in vec3 normalVCVSOutput[];","out vec3 normalVCGSOutput;"]).result,c=Be.substitute(c,"//VTK::Normal::Impl",["normalVCGSOutput = normalVCVSOutput[i];"]).result,l=Be.substitute(l,"//VTK::Normal::Dec",["varying vec3 normalVCVSOutput;"]).result,l=Be.substitute(l,"//VTK::Normal::Impl",["vec3 normalVCVSOutput = normalize(normalVCVSOutput);"," if (gl_FrontFacing == false) { normalVCVSOutput = -normalVCVSOutput; }"]).result):e.haveCellNormals?(l=Be.substitute(l,"//VTK::Normal::Dec",["uniform mat3 normalMatrix;","uniform samplerBuffer textureN;"]).result,l=Be.substitute(l,"//VTK::Normal::Impl",["vec3 normalVCVSOutput = normalize(normalMatrix *"," texelFetchBuffer(textureN, gl_PrimitiveID + PrimitiveIDOffset).xyz);"," if (gl_FrontFacing == false) { normalVCVSOutput = -normalVCVSOutput; }"]).result):e.lastBoundBO.getOpenGLMode(o.getProperty().getRepresentation())===e.context.LINES?(l=Be.substitute(l,"//VTK::UniformFlow::Impl",[" vec3 fdx = dFdx(vertexVC.xyz);"," vec3 fdy = dFdy(vertexVC.xyz);"," //VTK::UniformFlow::Impl"]).result,l=Be.substitute(l,"//VTK::Normal::Impl",["vec3 normalVCVSOutput;"," if (abs(fdx.x) > 0.0)"," { fdx = normalize(fdx); normalVCVSOutput = normalize(cross(vec3(fdx.y, -fdx.x, 0.0), fdx)); }"," else { fdy = normalize(fdy); normalVCVSOutput = normalize(cross(vec3(fdy.y, -fdy.x, 0.0), fdy));}"]).result):(l=Be.substitute(l,"//VTK::Normal::Dec",["uniform int cameraParallel;"]).result,l=Be.substitute(l,"//VTK::UniformFlow::Impl",[" vec3 fdx = dFdx(vertexVC.xyz);"," vec3 fdy = dFdy(vertexVC.xyz);"," //VTK::UniformFlow::Impl"]).result,l=Be.substitute(l,"//VTK::Normal::Impl",[" fdx = normalize(fdx);"," fdy = normalize(fdy);"," vec3 normalVCVSOutput = normalize(cross(fdx,fdy));"," if (cameraParallel == 1 && normalVCVSOutput.z < 0.0) { normalVCVSOutput = -1.0*normalVCVSOutput; }"," if (cameraParallel == 0 && dot(normalVCVSOutput,vertexVC.xyz) > 0.0) { normalVCVSOutput = -1.0*normalVCVSOutput; }"]).result),n.Vertex=s,n.Geometry=c,n.Fragment=l}},t.replaceShaderPositionVC=(n,i,o)=>{e.lastBoundBO.replaceShaderPositionVC(n,i,o);let a=n.Vertex,s=n.Geometry,c=n.Fragment;e.lastBoundBO.getReferenceByName("lastLightComplexity")>0?(a=Be.substitute(a,"//VTK::PositionVC::Dec",["varying vec4 vertexVCVSOutput;"]).result,a=Be.substitute(a,"//VTK::PositionVC::Impl",["vertexVCVSOutput = MCVCMatrix * vertexMC;"," gl_Position = MCPCMatrix * vertexMC;"]).result,a=Be.substitute(a,"//VTK::Camera::Dec",["uniform mat4 MCPCMatrix;","uniform mat4 MCVCMatrix;"]).result,s=Be.substitute(s,"//VTK::PositionVC::Dec",["in vec4 vertexVCVSOutput[];","out vec4 vertexVCGSOutput;"]).result,s=Be.substitute(s,"//VTK::PositionVC::Impl",["vertexVCGSOutput = vertexVCVSOutput[i];"]).result,c=Be.substitute(c,"//VTK::PositionVC::Dec",["varying vec4 vertexVCVSOutput;"]).result,c=Be.substitute(c,"//VTK::PositionVC::Impl",["vec4 vertexVC = vertexVCVSOutput;"]).result):(a=Be.substitute(a,"//VTK::Camera::Dec",["uniform mat4 MCPCMatrix;"]).result,a=Be.substitute(a,"//VTK::PositionVC::Impl",[" gl_Position = MCPCMatrix * vertexMC;"]).result),n.Vertex=a,n.Geometry=s,n.Fragment=c},t.replaceShaderTCoord=(n,i,o)=>{if(e.lastBoundBO.getCABO().getTCoordOffset()){let a=n.Vertex,s=n.Geometry,c=n.Fragment;if(e.drawingEdges)return;a=Be.substitute(a,"//VTK::TCoord::Impl","tcoordVCVSOutput = tcoordMC;").result;const l=e.openGLActor.getActiveTextures();let f=2,u=2;if(l&&l.length>0&&(f=l[0].getComponents(),l[0].getTarget()===e.context.TEXTURE_CUBE_MAP&&(u=3)),e.renderable.getColorTextureMap()&&(f=e.renderable.getColorTextureMap().getPointData().getScalars().getNumberOfComponents(),u=2),u===2){if(a=Be.substitute(a,"//VTK::TCoord::Dec","attribute vec2 tcoordMC; varying vec2 tcoordVCVSOutput;").result,s=Be.substitute(s,"//VTK::TCoord::Dec",["in vec2 tcoordVCVSOutput[];","out vec2 tcoordVCGSOutput;"]).result,s=Be.substitute(s,"//VTK::TCoord::Impl","tcoordVCGSOutput = tcoordVCVSOutput[i];").result,c=Be.substitute(c,"//VTK::TCoord::Dec",["varying vec2 tcoordVCVSOutput;","uniform sampler2D texture1;"]).result,l&&l.length>=1)switch(f){case 1:c=Be.substitute(c,"//VTK::TCoord::Impl",[" vec4 tcolor = texture2D(texture1, tcoordVCVSOutput);"," ambientColor = ambientColor*tcolor.r;"," diffuseColor = diffuseColor*tcolor.r;"]).result;break;case 2:c=Be.substitute(c,"//VTK::TCoord::Impl",[" vec4 tcolor = texture2D(texture1, tcoordVCVSOutput);"," ambientColor = ambientColor*tcolor.r;"," diffuseColor = diffuseColor*tcolor.r;"," opacity = opacity * tcolor.g;"]).result;break;default:c=Be.substitute(c,"//VTK::TCoord::Impl",[" vec4 tcolor = texture2D(texture1, tcoordVCVSOutput);"," ambientColor = ambientColor*tcolor.rgb;"," diffuseColor = diffuseColor*tcolor.rgb;"," opacity = opacity * tcolor.a;"]).result}}else switch(a=Be.substitute(a,"//VTK::TCoord::Dec","attribute vec3 tcoordMC; varying vec3 tcoordVCVSOutput;").result,s=Be.substitute(s,"//VTK::TCoord::Dec",["in vec3 tcoordVCVSOutput[];","out vec3 tcoordVCGSOutput;"]).result,s=Be.substitute(s,"//VTK::TCoord::Impl","tcoordVCGSOutput = tcoordVCVSOutput[i];").result,c=Be.substitute(c,"//VTK::TCoord::Dec",["varying vec3 tcoordVCVSOutput;","uniform samplerCube texture1;"]).result,f){case 1:c=Be.substitute(c,"//VTK::TCoord::Impl",[" vec4 tcolor = textureCube(texture1, tcoordVCVSOutput);"," ambientColor = ambientColor*tcolor.r;"," diffuseColor = diffuseColor*tcolor.r;"]).result;break;case 2:c=Be.substitute(c,"//VTK::TCoord::Impl",[" vec4 tcolor = textureCube(texture1, tcoordVCVSOutput);"," ambientColor = ambientColor*tcolor.r;"," diffuseColor = diffuseColor*tcolor.r;"," opacity = opacity * tcolor.g;"]).result;break;default:c=Be.substitute(c,"//VTK::TCoord::Impl",[" vec4 tcolor = textureCube(texture1, tcoordVCVSOutput);"," ambientColor = ambientColor*tcolor.rgb;"," diffuseColor = diffuseColor*tcolor.rgb;"," opacity = opacity * tcolor.a;"]).result}n.Vertex=a,n.Geometry=s,n.Fragment=c}},t.replaceShaderClip=(n,i,o)=>{let a=n.Vertex,s=n.Fragment;if(e.renderable.getNumberOfClippingPlanes()){const c=e.renderable.getNumberOfClippingPlanes();a=Be.substitute(a,"//VTK::Clip::Dec",["uniform int numClipPlanes;",`uniform vec4 clipPlanes[${c}];`,`varying float clipDistancesVSOutput[${c}];`]).result,a=Be.substitute(a,"//VTK::Clip::Impl",[`for (int planeNum = 0; planeNum < ${c}; planeNum++)`," {"," if (planeNum >= numClipPlanes)"," {"," break;"," }"," clipDistancesVSOutput[planeNum] = dot(clipPlanes[planeNum], vertexMC);"," }"]).result,s=Be.substitute(s,"//VTK::Clip::Dec",["uniform int numClipPlanes;",`varying float clipDistancesVSOutput[${c}];`]).result,s=Be.substitute(s,"//VTK::Clip::Impl",[`for (int planeNum = 0; planeNum < ${c}; planeNum++)`," {"," if (planeNum >= numClipPlanes)"," {"," break;"," }"," if (clipDistancesVSOutput[planeNum] < 0.0) discard;"," }"]).result}n.Vertex=a,n.Fragment=s},t.getCoincidentParameters=(n,i)=>{let o={factor:0,offset:0};const a=i.getProperty();if(e.renderable.getResolveCoincidentTopology()==pc.PolygonOffset||a.getEdgeVisibility()&&a.getRepresentation()===qd.SURFACE){const c=e.lastBoundBO.getPrimitiveType();c===Pi.Points||a.getRepresentation()===qd.POINTS?o=e.renderable.getCoincidentTopologyPointOffsetParameter():c===Pi.Lines||a.getRepresentation()===qd.WIREFRAME?o=e.renderable.getCoincidentTopologyLineOffsetParameters():(c===Pi.Tris||c===Pi.TriStrips)&&(o=e.renderable.getCoincidentTopologyPolygonOffsetParameters()),(c===Pi.TrisEdges||c===Pi.TriStripsEdges)&&(o=e.renderable.getCoincidentTopologyPolygonOffsetParameters(),o.factor/=2,o.offset/=2)}const s=e._openGLRenderer.getSelector();return s&&s.getFieldAssociation()===Wx.FIELD_ASSOCIATION_POINTS&&(o.offset-=2),o},t.replaceShaderPicking=(n,i,o)=>{let a=n.Fragment,s=n.Vertex;if(a=Be.substitute(a,"//VTK::Picking::Dec",["uniform int picking;","//VTK::Picking::Dec"]).result,!!e._openGLRenderer.getSelector()){switch((e.lastSelectionState===$o.ID_LOW24||e.lastSelectionState===$o.ID_HIGH24)&&(s=Be.substitute(s,"//VTK::Picking::Dec",[`flat out int vertexIDVSOutput;
|
||
`,`uniform int VertexIDOffset;
|
||
`]).result,s=Be.substitute(s,"//VTK::Picking::Impl",` vertexIDVSOutput = gl_VertexID + VertexIDOffset;
|
||
`).result,a=Be.substitute(a,"//VTK::Picking::Dec",`flat in int vertexIDVSOutput;
|
||
`).result,a=Be.substitute(a,"//VTK::Picking::Impl",[" int idx = vertexIDVSOutput;","//VTK::Picking::Impl"]).result),e.lastSelectionState){case $o.ID_LOW24:a=Be.substitute(a,"//VTK::Picking::Impl"," gl_FragData[0] = vec4(float(idx%256)/255.0, float((idx/256)%256)/255.0, float((idx/65536)%256)/255.0, 1.0);").result;break;case $o.ID_HIGH24:a=Be.substitute(a,"//VTK::Picking::Impl"," gl_FragData[0] = vec4(float((idx/16777216)%256)/255.0, 0.0, 0.0, 1.0);").result;break;default:a=Be.substitute(a,"//VTK::Picking::Dec","uniform vec3 mapperIndex;").result,a=Be.substitute(a,"//VTK::Picking::Impl"," gl_FragData[0] = picking != 0 ? vec4(mapperIndex,1.0) : gl_FragData[0];").result}n.Fragment=a,n.Vertex=s}},t.replaceShaderValues=(n,i,o)=>{if(t.replaceShaderColor(n,i,o),t.replaceShaderNormal(n,i,o),t.replaceShaderLight(n,i,o),t.replaceShaderTCoord(n,i,o),t.replaceShaderPicking(n,i,o),t.replaceShaderClip(n,i,o),t.replaceShaderCoincidentOffset(n,i,o),t.replaceShaderPositionVC(n,i,o),e.haveSeenDepthRequest){let a=n.Fragment;a=Be.substitute(a,"//VTK::ZBuffer::Dec","uniform int depthRequest;").result,a=Be.substitute(a,"//VTK::ZBuffer::Impl",["if (depthRequest == 1) {","float iz = floor(gl_FragCoord.z*65535.0 + 0.1);","float rf = floor(iz/256.0)/255.0;","float gf = mod(iz,256.0)/255.0;","gl_FragData[0] = vec4(rf, gf, 0.0, 1.0); }"]).result,n.Fragment=a}},t.getNeedToRebuildShaders=(n,i,o)=>{let a=0,s=0;const c=n.getPrimitiveType(),l=e.currentInput;let f=!1;const u=l.getPointData().getNormals(),d=l.getCellData().getNormals(),h=o.getProperty().getInterpolation()===mD.FLAT,g=o.getProperty().getRepresentation(),p=n.getOpenGLMode(g,c);if((p===e.context.TRIANGLES||d&&!u||!h&&u||!h&&p===e.context.LINES)&&(f=!0),o.getProperty().getLighting()&&f){a=0;const w=i.getLightsByReference();for(let x=0;x<w.length;++x){const C=w[x];C.getSwitch()>0&&(s++,a===0&&(a=1)),a===1&&(s>1||C.getIntensity()!==1||!C.lightTypeIsHeadLight())&&(a=2),a<3&&C.getPositional()&&(a=3)}}let v=!1;const y=e.lastBoundBO.getReferenceByName("lastLightComplexity"),m=e.lastBoundBO.getReferenceByName("lastLightCount");return(y!==a||m!==s)&&(e.lastBoundBO.set({lastLightComplexity:a},!0),e.lastBoundBO.set({lastLightCount:s},!0),v=!0),(!e.currentRenderPass&&e.lastRenderPassShaderReplacement||e.currentRenderPass&&e.currentRenderPass.getShaderReplacement()!==e.lastRenderPassShaderReplacement)&&(v=!0),e.lastHaveSeenDepthRequest!==e.haveSeenDepthRequest||n.getShaderSourceTime().getMTime()<e.renderable.getMTime()||n.getShaderSourceTime().getMTime()<e.currentInput.getMTime()||n.getShaderSourceTime().getMTime()<e.selectionStateChanged.getMTime()||v?(e.lastHaveSeenDepthRequest=e.haveSeenDepthRequest,!0):!1},t.invokeShaderCallbacks=(n,i,o)=>{const a=e.renderable.getViewSpecificProperties().ShadersCallbacks;a&&a.forEach(s=>{s.callback(s.userData,n,i,o)})},t.setMapperShaderParameters=(n,i,o)=>{if(n.getProgram().isUniformUsed("PrimitiveIDOffset")&&n.getProgram().setUniformi("PrimitiveIDOffset",e.primitiveIDOffset),n.getProgram().isUniformUsed("VertexIDOffset")&&n.getProgram().setUniformi("VertexIDOffset",e.vertexIDOffset),n.getCABO().getElementCount()&&(e.VBOBuildTime.getMTime()>n.getAttributeUpdateTime().getMTime()||n.getShaderSourceTime().getMTime()>n.getAttributeUpdateTime().getMTime())){const c=e.lastBoundBO.getReferenceByName("lastLightComplexity");n.getProgram().isAttributeUsed("vertexMC")&&(n.getVAO().addAttributeArray(n.getProgram(),n.getCABO(),"vertexMC",n.getCABO().getVertexOffset(),n.getCABO().getStride(),e.context.FLOAT,3,!1)||Mf("Error setting vertexMC in shader VAO.")),n.getProgram().isAttributeUsed("normalMC")&&n.getCABO().getNormalOffset()&&c>0?n.getVAO().addAttributeArray(n.getProgram(),n.getCABO(),"normalMC",n.getCABO().getNormalOffset(),n.getCABO().getStride(),e.context.FLOAT,3,!1)||Mf("Error setting normalMC in shader VAO."):n.getVAO().removeAttributeArray("normalMC"),e.renderable.getCustomShaderAttributes().forEach((l,f)=>{n.getProgram().isAttributeUsed(`${l}MC`)&&(n.getVAO().addAttributeArray(n.getProgram(),n.getCABO(),`${l}MC`,n.getCABO().getCustomData()[f].offset,n.getCABO().getStride(),e.context.FLOAT,n.getCABO().getCustomData()[f].components,!1)||Mf(`Error setting ${l}MC in shader VAO.`))}),n.getProgram().isAttributeUsed("tcoordMC")&&n.getCABO().getTCoordOffset()?n.getVAO().addAttributeArray(n.getProgram(),n.getCABO(),"tcoordMC",n.getCABO().getTCoordOffset(),n.getCABO().getStride(),e.context.FLOAT,n.getCABO().getTCoordComponents(),!1)||Mf("Error setting tcoordMC in shader VAO."):n.getVAO().removeAttributeArray("tcoordMC"),n.getProgram().isAttributeUsed("scalarColor")&&n.getCABO().getColorComponents()?n.getVAO().addAttributeArray(n.getProgram(),n.getCABO().getColorBO(),"scalarColor",n.getCABO().getColorOffset(),n.getCABO().getColorBOStride(),e.context.UNSIGNED_BYTE,4,!0)||Mf("Error setting scalarColor in shader VAO."):n.getVAO().removeAttributeArray("scalarColor"),n.getAttributeUpdateTime().modified()}if(e.renderable.getNumberOfClippingPlanes()){const c=e.renderable.getNumberOfClippingPlanes(),l=[],u=n.getCABO().getCoordShiftAndScaleEnabled()?n.getCABO().getInverseShiftAndScaleMatrix():null,d=u?Cr(e.tmpMat4,o.getMatrix()):o.getMatrix();u&&(un(d,d),yn(d,d,u),un(d,d));for(let h=0;h<c;h++){const g=[];e.renderable.getClippingPlaneInDataCoords(d,h,g);for(let p=0;p<4;p++)l.push(g[p])}n.getProgram().setUniformi("numClipPlanes",c),n.getProgram().setUniform4fv("clipPlanes",l)}e.internalColorTexture&&n.getProgram().isUniformUsed("texture1")&&n.getProgram().setUniformi("texture1",e.internalColorTexture.getTextureUnit());const a=e.openGLActor.getActiveTextures();if(a)for(let c=0;c<a.length;++c){const f=a[c].getTextureUnit(),u=`texture${f+1}`;n.getProgram().isUniformUsed(u)&&n.getProgram().setUniformi(u,f)}if(e.haveSeenDepthRequest&&n.getProgram().setUniformi("depthRequest",e.renderDepth?1:0),n.getProgram().isUniformUsed("coffset")){const c=t.getCoincidentParameters(i,o);n.getProgram().setUniformf("coffset",c.offset),n.getProgram().isUniformUsed("cfactor")&&n.getProgram().setUniformf("cfactor",c.factor)}n.setMapperShaderParameters(i,o,e._openGLRenderer.getTiledSizeAndOrigin());const s=e._openGLRenderer.getSelector();n.getProgram().setUniform3fArray("mapperIndex",s?s.getPropColorValue():[0,0,0]),n.getProgram().setUniformi("picking",s?s.getCurrentPass()+1:0)},t.setLightingShaderParameters=(n,i,o)=>{const a=e.lastBoundBO.getReferenceByName("lastLightComplexity");if(a<2)return;const s=n.getProgram();let c=0;const l=i.getLightsByReference();for(let d=0;d<l.length;++d){const h=l[d];if(h.getSwitch()>0){const p=h.getColorByReference(),v=h.getIntensity();e.lightColor[0]=p[0]*v,e.lightColor[1]=p[1]*v,e.lightColor[2]=p[2]*v;const y=h.getDirection(),m=i.getActiveCamera().getViewMatrix(),w=[...y];h.lightTypeIsSceneLight()&&(w[0]=m[0]*y[0]+m[1]*y[1]+m[2]*y[2],w[1]=m[4]*y[0]+m[5]*y[1]+m[6]*y[2],w[2]=m[8]*y[0]+m[9]*y[1]+m[10]*y[2],Td(w)),e.lightDirection[0]=w[0],e.lightDirection[1]=w[1],e.lightDirection[2]=w[2],Td(e.lightDirection),s.setUniform3fArray(`lightColor${c}`,e.lightColor),s.setUniform3fArray(`lightDirectionVC${c}`,e.lightDirection),c++}}if(a<3)return;const u=i.getActiveCamera().getViewMatrix();un(u,u),c=0;for(let d=0;d<l.length;++d){const h=l[d];if(h.getSwitch()>0){const p=h.getTransformedPosition(),v=new Float64Array(3);At(v,p,u),s.setUniform3fArray(`lightAttenuation${c}`,h.getAttenuationValuesByReference()),s.setUniformi(`lightPositional${c}`,h.getPositional()),s.setUniformf(`lightExponent${c}`,h.getExponent()),s.setUniformf(`lightConeAngle${c}`,h.getConeAngle()),s.setUniform3fArray(`lightPositionVC${c}`,[v[0],v[1],v[2]]),c++}}};function r(n,i,o){return i.identity(o),n.reduce((a,s,c)=>c===0?s?i.copy(a,s):i.identity(a):s?i.multiply(a,a,s):a,o)}t.setCameraShaderParameters=(n,i,o)=>{const a=n.getProgram(),s=e.openGLCamera.getKeyMatrices(i),c=i.getActiveCamera(),l=e.openGLCamera.getKeyMatrixTime().getMTime(),f=a.getLastCameraMTime(),d=n.getCABO().getCoordShiftAndScaleEnabled()?n.getCABO().getInverseShiftAndScaleMatrix():null,h=o.getIsIdentity(),g=h?{mcwc:null,normalMatrix:null}:e.openGLActor.getKeyMatrices();if(o.getCoordinateSystem()===vee.DISPLAY){const p=e._openGLRenderer.getTiledSizeAndOrigin();It(e.tmpMat4),e.tmpMat4[0]=2/p.usize,e.tmpMat4[12]=-1,e.tmpMat4[5]=2/p.vsize,e.tmpMat4[13]=-1,yn(e.tmpMat4,e.tmpMat4,d),a.setUniformMatrix("MCPCMatrix",e.tmpMat4)}else a.setUniformMatrix("MCPCMatrix",r([s.wcpc,g.mcwc,d],s1,e.tmpMat4));a.isUniformUsed("MCVCMatrix")&&a.setUniformMatrix("MCVCMatrix",r([s.wcvc,g.mcwc,d],s1,e.tmpMat4)),a.isUniformUsed("normalMatrix")&&a.setUniformMatrix3x3("normalMatrix",r([s.normalMatrix,g.normalMatrix],dY,e.tmpMat3)),f!==l&&(a.isUniformUsed("cameraParallel")&&a.setUniformi("cameraParallel",c.getParallelProjection()),a.setLastCameraMTime(l)),h||a.setLastCameraMTime(0)},t.setPropertyShaderParameters=(n,i,o)=>{const a=n.getProgram();let s=o.getProperty(),c=s.getOpacity(),l=e.drawingEdges?s.getEdgeColorByReference():s.getAmbientColorByReference(),f=e.drawingEdges?s.getEdgeColorByReference():s.getDiffuseColorByReference(),u=e.drawingEdges?1:s.getAmbient(),d=e.drawingEdges?0:s.getDiffuse(),h=e.drawingEdges?0:s.getSpecular();const g=s.getSpecularPower();a.setUniformf("opacityUniform",c),a.setUniform3fArray("ambientColorUniform",l),a.setUniform3fArray("diffuseColorUniform",f),a.setUniformf("ambient",u),a.setUniformf("diffuse",d);const p=e.lastBoundBO.getReferenceByName("lastLightComplexity");if(p<1)return;let v=s.getSpecularColorByReference();if(a.setUniform3fArray("specularColorUniform",v),a.setUniformf("specularPowerUniform",g),a.setUniformf("specular",h),a.isUniformUsed("ambientIntensityBF")){if(s=o.getBackfaceProperty(),c=s.getOpacity(),l=s.getAmbientColor(),u=s.getAmbient(),f=s.getDiffuseColor(),d=s.getDiffuse(),v=s.getSpecularColor(),h=s.getSpecular(),a.setUniformf("ambientIntensityBF",u),a.setUniformf("diffuseIntensityBF",d),a.setUniformf("opacityUniformBF",c),a.setUniform3fArray("ambientColorUniformBF",l),a.setUniform3fArray("diffuseColorUniformBF",f),p<1)return;a.setUniformf("specularIntensityBF",h),a.setUniform3fArray("specularColorUniformBF",v),a.setUniformf("specularPowerUniformBF",g)}},t.updateMaximumPointCellIds=(n,i)=>{var s,c,l,f;const o=e._openGLRenderer.getSelector();if(!o)return;if((c=(s=e.selectionWebGLIdsToVTKIds)==null?void 0:s.points)!=null&&c.length){const u=e.selectionWebGLIdsToVTKIds.points.length;o.setMaximumPointId(u-1)}if((f=(l=e.selectionWebGLIdsToVTKIds)==null?void 0:l.cells)!=null&&f.length){const u=e.selectionWebGLIdsToVTKIds.cells.length;o.setMaximumCellId(u-1)}o.getFieldAssociation()===Wx.FIELD_ASSOCIATION_POINTS&&(e.pointPicking=!0)},t.renderPieceStart=(n,i)=>{e.primitiveIDOffset=0,e.vertexIDOffset=0;const o=yee(e._openGLRenderer);if(e.lastSelectionState!==o&&(e.selectionStateChanged.modified(),e.lastSelectionState=o),e._openGLRenderer.getSelector())switch(o){default:e._openGLRenderer.getSelector().renderProp(i)}t.updateBufferObjects(n,i),e.renderable.getColorTextureMap()&&e.internalColorTexture.activate(),e.lastBoundBO=null},t.renderPieceDraw=(n,i)=>{const o=i.getProperty().getRepresentation(),a=i.getProperty().getEdgeVisibility()&&o===qd.SURFACE,s=e._openGLRenderer.getSelector(),c=s&&s.getFieldAssociation()===Wx.FIELD_ASSOCIATION_POINTS&&(e.lastSelectionState===$o.ID_LOW24||e.lastSelectionState===$o.ID_HIGH24);for(let l=Pi.Start;l<Pi.End;l++)e.primitives[l].setPointPicking(c),e.primitives[l].getCABO().getElementCount()&&(e.drawingEdges=a&&(l===Pi.TrisEdges||l===Pi.TriStripsEdges),(!e.drawingEdges||!(e.renderDepth||e.lastSelectionState>=0))&&(e.lastBoundBO=e.primitives[l],e.primitiveIDOffset+=e.primitives[l].drawArrays(n,i,o,t),e.vertexIDOffset+=e.primitives[l].getCABO().getElementCount()))},t.renderPieceFinish=(n,i)=>{e.LastBoundBO&&e.LastBoundBO.getVAO().release(),e.renderable.getColorTextureMap()&&e.internalColorTexture.deactivate()},t.renderPiece=(n,i)=>{if(t.invokeEvent(pee),e.renderable.getStatic()||e.renderable.update(),e.currentInput=e.renderable.getInputData(),t.invokeEvent(mee),!e.currentInput){Mf("No input!");return}if(!e.currentInput.getPoints||!e.currentInput.getPoints().getNumberOfValues())return;const o=e.context,a=i.getProperty().getBackfaceCulling(),s=i.getProperty().getFrontfaceCulling();!a&&!s?e._openGLRenderWindow.disableCullFace():s?(e._openGLRenderWindow.enableCullFace(),o.cullFace(o.FRONT)):(e._openGLRenderWindow.enableCullFace(),o.cullFace(o.BACK)),t.renderPieceStart(n,i),t.renderPieceDraw(n,i),t.renderPieceFinish(n,i)},t.computeBounds=(n,i)=>{if(!t.getInput()){Gh(e.bounds);return}e.bounds=t.getInput().getBounds()},t.updateBufferObjects=(n,i)=>{t.getNeedToRebuildBufferObjects(n,i)&&t.buildBufferObjects(n,i),t.updateMaximumPointCellIds()},t.getNeedToRebuildBufferObjects=(n,i)=>{const o=e.VBOBuildTime.getMTime();return o<t.getMTime()||o<e.renderable.getMTime()||o<i.getMTime()||o<e.currentInput.getMTime()},t.buildBufferObjects=(n,i)=>{const o=e.currentInput;if(o===null)return;e.renderable.mapScalars(o,1);const a=e.renderable.getColorMapColors();e.haveCellScalars=!1;const s=e.renderable.getScalarMode();e.renderable.getScalarVisibility()&&(s===o2.USE_CELL_DATA||s===o2.USE_CELL_FIELD_DATA||s===o2.USE_FIELD_DATA||!o.getPointData().getScalars())&&s!==o2.USE_POINT_FIELD_DATA&&a&&(e.haveCellScalars=!0);let c=i.getProperty().getInterpolation()!==mD.FLAT?o.getPointData().getNormals():null;c===null&&o.getCellData().getNormals()&&(e.haveCellNormals=!0,c=o.getCellData().getNormals());const l=i.getProperty().getRepresentation();let f=o.getPointData().getTCoords();e.openGLActor.getActiveTextures()||(f=null);let u=!1;if(e.renderable.getColorCoordinates()){f=e.renderable.getColorCoordinates(),u=e.renderable.getAreScalarsMappedFromCells(),e.internalColorTexture||(e.internalColorTexture=mr.newInstance({resizable:!0}));const h=e.internalColorTexture;h.setMinificationFilter(vD.NEAREST),h.setMagnificationFilter(vD.NEAREST),h.setWrapS(yD.CLAMP_TO_EDGE),h.setWrapT(yD.CLAMP_TO_EDGE),h.setOpenGLRenderWindow(e._openGLRenderWindow);const g=e.renderable.getColorTextureMap(),p=g.getExtent(),v=g.getPointData().getScalars();h.create2DFromRaw(p[1]-p[0]+1,p[3]-p[2]+1,v.getNumberOfComponents(),v.getDataType(),v.getData()),h.activate(),h.sendParameters(),h.deactivate()}const d=`${o.getMTime()}A${l}B${o.getMTime()}C${c?c.getMTime():1}D${a?a.getMTime():1}E${i.getProperty().getEdgeVisibility()}F${f?f.getMTime():1}`;if(e.VBOBuildString!==d){const g={points:o.getPoints(),normals:c,tcoords:f,colors:a,cellOffset:0,vertexOffset:0,useTCoordsPerCell:u,haveCellScalars:e.haveCellScalars,haveCellNormals:e.haveCellNormals,customAttributes:e.renderable.getCustomShaderAttributes().map(y=>o.getPointData().getArrayByName(y))};e.renderable.getPopulateSelectionSettings()&&(e.selectionWebGLIdsToVTKIds={points:null,cells:null});const p=[{inRep:"verts",cells:o.getVerts()},{inRep:"lines",cells:o.getLines()},{inRep:"polys",cells:o.getPolys()},{inRep:"strips",cells:o.getStrips()},{inRep:"polys",cells:o.getPolys()},{inRep:"strips",cells:o.getStrips()}],v=i.getProperty().getEdgeVisibility()&&l===qd.SURFACE;for(let y=Pi.Start;y<Pi.End;y++)y!==Pi.TrisEdges&&y!==Pi.TriStripsEdges?(g.cellOffset+=e.primitives[y].getCABO().createVBO(p[y].cells,p[y].inRep,l,g,e.selectionWebGLIdsToVTKIds),g.vertexOffset+=e.primitives[y].getCABO().getElementCount()):v?e.primitives[y].getCABO().createVBO(p[y].cells,p[y].inRep,qd.WIREFRAME,{...g,tcoords:null,colors:null,haveCellScalars:!1,haveCellNormals:!1}):e.primitives[y].releaseGraphicsResources();e.renderable.getPopulateSelectionSettings()&&e.renderable.setSelectionWebGLIdsToVTKIds(e.selectionWebGLIdsToVTKIds),e.VBOBuildString=d}e.VBOBuildTime.modified()},t.getAllocatedGPUMemoryInBytes=()=>{let n=0;return e.primitives.forEach(i=>{n+=i.getAllocatedGPUMemoryInBytes()}),n}}const xee={context:null,VBOBuildTime:0,VBOBuildString:null,primitives:null,primTypes:null,shaderRebuildString:null,tmpMat4:null,ambientColor:[],diffuseColor:[],specularColor:[],lightColor:[],lightDirection:[],lastHaveSeenDepthRequest:!1,haveSeenDepthRequest:!1,lastSelectionState:$o.MIN_KNOWN_PASS-1,selectionStateChanged:null,selectionWebGLIdsToVTKIds:null,pointPicking:!1};function hA(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,xee,r),Qn.extend(t,e,r),rl.implementReplaceShaderCoincidentOffset(t,e,r),rl.implementBuildShadersWithReplacements(t,e,r),e.primitives=[],e.primTypes=Pi,e.tmpMat3=ys(new Float64Array(9)),e.tmpMat4=It(new Float64Array(16));for(let n=Pi.Start;n<Pi.End;n++)e.primitives[n]=ul.newInstance(),e.primitives[n].setPrimitiveType(n),e.primitives[n].set({lastLightComplexity:0,lastLightCount:0,lastSelectionPass:!1},!0);Jr(t,e,["context"]),e.VBOBuildTime={},or(e.VBOBuildTime,{mtime:0}),e.selectionStateChanged={},or(e.selectionStateChanged,{mtime:0}),wee(t,e)}const gA=Rn(hA,"vtkOpenGLPolyDataMapper");var uw={newInstance:gA,extend:hA};di("vtkMapper",gA);const{vtkErrorMacro:Tg}=uo,{Representation:Cee}=Fd,{ObjectType:a2}=Bl,{PassTypes:See}=f4,Tee={type:"StartEvent"},_ee={type:"EndEvent"};function Eee(t,e){e.classHierarchy.push("vtkOpenGLGlyph3DMapper");const r={...t};t.renderPiece=(n,i)=>{if(t.invokeEvent(Tee),e.renderable.getStatic()||e.renderable.update(),e.currentInput=e.renderable.getInputData(1),t.invokeEvent(_ee),!e.currentInput){Tg("No input!");return}if(!e.currentInput.getPoints||!e.currentInput.getPoints().getNumberOfValues())return;const o=e.context;e._openGLRenderWindow.getWebgl2()?(e.hardwareSupport=!0,e.extension=null):e.extension||(e.extension=e.context.getExtension("ANGLE_instanced_arrays"),e.hardwareSupport=!!e.extension);const a=i.getProperty().getBackfaceCulling(),s=i.getProperty().getFrontfaceCulling();!a&&!s?e._openGLRenderWindow.disableCullFace():s?(e._openGLRenderWindow.enableCullFace(),o.cullFace(o.FRONT)):(e._openGLRenderWindow.enableCullFace(),o.cullFace(o.BACK)),t.renderPieceStart(n,i),t.renderPieceDraw(n,i),t.renderPieceFinish(n,i)},t.multiply4x4WithOffset=(n,i,o,a)=>{const s=i[0],c=i[1],l=i[2],f=i[3],u=i[4],d=i[5],h=i[6],g=i[7],p=i[8],v=i[9],y=i[10],m=i[11],w=i[12],x=i[13],C=i[14],S=i[15];let T=o[a],_=o[a+1],E=o[a+2],b=o[a+3];n[0]=T*s+_*u+E*p+b*w,n[1]=T*c+_*d+E*v+b*x,n[2]=T*l+_*h+E*y+b*C,n[3]=T*f+_*g+E*m+b*S,T=o[a+4],_=o[a+5],E=o[a+6],b=o[a+7],n[4]=T*s+_*u+E*p+b*w,n[5]=T*c+_*d+E*v+b*x,n[6]=T*l+_*h+E*y+b*C,n[7]=T*f+_*g+E*m+b*S,T=o[a+8],_=o[a+9],E=o[a+10],b=o[a+11],n[8]=T*s+_*u+E*p+b*w,n[9]=T*c+_*d+E*v+b*x,n[10]=T*l+_*h+E*y+b*C,n[11]=T*f+_*g+E*m+b*S,T=o[a+12],_=o[a+13],E=o[a+14],b=o[a+15],n[12]=T*s+_*u+E*p+b*w,n[13]=T*c+_*d+E*v+b*x,n[14]=T*l+_*h+E*y+b*C,n[15]=T*f+_*g+E*m+b*S},t.replaceShaderNormal=(n,i,o)=>{if(e.hardwareSupport&&e.lastBoundBO.getReferenceByName("lastLightComplexity")>0){let s=n.Vertex;e.lastBoundBO.getCABO().getNormalOffset()&&(s=Be.substitute(s,"//VTK::Normal::Dec",["attribute vec3 normalMC;","attribute mat3 gNormal;","uniform mat3 normalMatrix;","varying vec3 normalVCVSOutput;"]).result,s=Be.substitute(s,"//VTK::Normal::Impl",["normalVCVSOutput = normalMatrix * gNormal * normalMC;"]).result),n.Vertex=s}r.replaceShaderNormal(n,i,o)},t.replaceShaderColor=(n,i,o)=>{if(e.hardwareSupport&&e.renderable.getColorArray()){let a=n.Vertex,s=n.Geometry,c=n.Fragment;const l=e.lastBoundBO.getReferenceByName("lastLightComplexity");let f=["uniform float ambient;","uniform float diffuse;","uniform float specular;","uniform float opacityUniform; // the fragment opacity"];l&&(f=f.concat(["uniform vec3 specularColorUniform;","uniform float specularPowerUniform;"]));let u=["vec3 ambientColor;"," vec3 diffuseColor;"," float opacity;"];l&&(u=u.concat([" vec3 specularColor;"," float specularPower;"])),u=u.concat([" opacity = opacityUniform;"]),l&&(u=u.concat([" specularColor = specularColorUniform;"," specularPower = specularPowerUniform;"])),e.drawingEdges||(f=f.concat(["varying vec4 vertexColorVSOutput;"]),a=Be.substitute(a,"//VTK::Color::Dec",["attribute vec4 gColor;","varying vec4 vertexColorVSOutput;"]).result,a=Be.substitute(a,"//VTK::Color::Impl",["vertexColorVSOutput = gColor;"]).result,s=Be.substitute(s,"//VTK::Color::Dec",["in vec4 vertexColorVSOutput[];","out vec4 vertexColorGSOutput;"]).result,s=Be.substitute(s,"//VTK::Color::Impl",["vertexColorGSOutput = vertexColorVSOutput[i];"]).result,u=u.concat([" diffuseColor = vertexColorVSOutput.rgb;"," ambientColor = vertexColorVSOutput.rgb;"," opacity = opacity*vertexColorVSOutput.a;"])),c=Be.substitute(c,"//VTK::Color::Impl",u).result,c=Be.substitute(c,"//VTK::Color::Dec",f).result,n.Vertex=a,n.Geometry=s,n.Fragment=c}r.replaceShaderColor(n,i,o)},t.replaceShaderPositionVC=(n,i,o)=>{if(e.hardwareSupport){let a=n.Vertex;e.lastBoundBO.getReferenceByName("lastLightComplexity")>0?(a=Be.substitute(a,"//VTK::PositionVC::Impl",["vec4 gVertexMC = gMatrix * vertexMC;","vertexVCVSOutput = MCVCMatrix * gVertexMC;"," gl_Position = MCPCMatrix * gVertexMC;"]).result,a=Be.substitute(a,"//VTK::Camera::Dec",["attribute mat4 gMatrix;","uniform mat4 MCPCMatrix;","uniform mat4 MCVCMatrix;"]).result):(a=Be.substitute(a,"//VTK::Camera::Dec",["attribute mat4 gMatrix;","uniform mat4 MCPCMatrix;"]).result,a=Be.substitute(a,"//VTK::PositionVC::Impl",["vec4 gVertexMC = gMatrix * vertexMC;"," gl_Position = MCPCMatrix * gVertexMC;"]).result),n.Vertex=a}r.replaceShaderPositionVC(n,i,o)},t.replaceShaderPicking=(n,i,o)=>{if(e.hardwareSupport){let a=n.Fragment,s=n.Vertex;s=Be.substitute(s,"//VTK::Picking::Dec",["attribute vec3 mapperIndexVS;","varying vec3 mapperIndexVSOutput;"]).result,s=Be.substitute(s,"//VTK::Picking::Impl"," mapperIndexVSOutput = mapperIndexVS;").result,n.Vertex=s,a=Be.substitute(a,"//VTK::Picking::Dec",["varying vec3 mapperIndexVSOutput;","uniform vec3 mapperIndex;","uniform int picking;"]).result,a=Be.substitute(a,"//VTK::Picking::Impl",[" vec4 pickColor = picking == 2 ? vec4(mapperIndexVSOutput,1.0) : vec4(mapperIndex,1.0);"," gl_FragData[0] = picking != 0 ? pickColor : gl_FragData[0];"]).result,n.Fragment=a}else r.replaceShaderPicking(n,i,o)},t.updateGlyphShaderParameters=(n,i,o,a,s,c,l,f)=>{const u=o.getProgram();if(n){const d=e.normalMatrix,h=c,g=l*9,p=e.tmpMat3,v=d[0],y=d[1],m=d[2],w=d[3],x=d[4],C=d[5],S=d[6],T=d[7],_=d[8],E=h[g],b=h[g+1],D=h[g+2],I=h[g+3],P=h[g+4],O=h[g+5],L=h[g+6],B=h[g+7],H=h[g+8];p[0]=E*v+b*w+D*S,p[1]=E*y+b*x+D*T,p[2]=E*m+b*C+D*_,p[3]=I*v+P*w+O*S,p[4]=I*y+P*x+O*T,p[5]=I*m+P*C+O*_,p[6]=L*v+B*w+H*S,p[7]=L*y+B*x+H*T,p[8]=L*m+B*C+H*_,u.setUniformMatrix3x3("normalMatrix",e.tmpMat3)}if(t.multiply4x4WithOffset(e.tmpMat4,e.mcpcMatrix,s,l*16),u.setUniformMatrix("MCPCMatrix",e.tmpMat4),i&&(t.multiply4x4WithOffset(e.tmpMat4,e.mcvcMatrix,s,l*16),u.setUniformMatrix("MCVCMatrix",e.tmpMat4)),a){const d=a.getData();e.tmpColor[0]=d[l*4]/255,e.tmpColor[1]=d[l*4+1]/255,e.tmpColor[2]=d[l*4+2]/255,u.setUniform3fArray("ambientColorUniform",e.tmpColor),u.setUniform3fArray("diffuseColorUniform",e.tmpColor)}f&&u.setUniform3fArray("mapperIndex",f.getPropColorValue())},t.renderPieceDraw=(n,i)=>{const o=i.getProperty().getRepresentation(),a=e.context,s=i.getProperty().getEdgeVisibility()&&o===Cee.SURFACE,c=e.openGLCamera.getKeyMatrices(n),l=e.openGLActor.getKeyMatrices();yh(e.normalMatrix,c.normalMatrix,l.normalMatrix),yn(e.mcpcMatrix,c.wcpc,l.mcwc),yn(e.mcvcMatrix,c.wcvc,l.mcwc);const f=e.renderable.getMatrixArray(),u=e.renderable.getNormalArray(),d=e.renderable.getColorArray(),h=f.length/16;let g=!1;e._openGLRenderer.getSelector()&&e._openGLRenderer.getSelector().getCurrentPass()===See.COMPOSITE_INDEX_PASS&&(g=!0);for(let p=e.primTypes.Start;p<e.primTypes.End;p++){const v=e.primitives[p].getCABO();if(v.getElementCount()){e.drawingEdges=s&&(p===e.primTypes.TrisEdges||p===e.primTypes.TriStripsEdges),e.lastBoundBO=e.primitives[p],e.primitives[p].updateShaders(n,i,t);const y=e.primitives[p].getProgram(),m=e.primitives[p].getOpenGLMode(o),w=y.isUniformUsed("normalMatrix"),x=y.isUniformUsed("MCVCMatrix");if(e.hardwareSupport)e.extension?e.extension.drawArraysInstancedANGLE(m,0,v.getElementCount(),h):a.drawArraysInstanced(m,0,v.getElementCount(),h);else for(let C=0;C<h;++C)g&&e._openGLRenderer.getSelector().renderCompositeIndex(C),t.updateGlyphShaderParameters(w,x,e.primitives[p],d,f,u,C,g?e._openGLRenderer.getSelector():null),a.drawArrays(m,0,v.getElementCount())}}},t.setMapperShaderParameters=(n,i,o)=>{if(n.getCABO().getElementCount()&&(e.glyphBOBuildTime.getMTime()>n.getAttributeUpdateTime().getMTime()||n.getShaderSourceTime().getMTime()>n.getAttributeUpdateTime().getMTime())){n.getProgram().isAttributeUsed("gMatrix")?n.getVAO().addAttributeMatrixWithDivisor(n.getProgram(),e.matrixBuffer,"gMatrix",0,64,e.context.FLOAT,4,!1,1)||Tg("Error setting gMatrix in shader VAO."):n.getVAO().removeAttributeArray("gMatrix"),n.getProgram().isAttributeUsed("gNormal")?n.getVAO().addAttributeMatrixWithDivisor(n.getProgram(),e.normalBuffer,"gNormal",0,36,e.context.FLOAT,3,!1,1)||Tg("Error setting gNormal in shader VAO."):n.getVAO().removeAttributeArray("gNormal"),n.getProgram().isAttributeUsed("gColor")?n.getVAO().addAttributeArrayWithDivisor(n.getProgram(),e.colorBuffer,"gColor",0,4,e.context.UNSIGNED_BYTE,4,!0,1,!1)||Tg("Error setting gColor in shader VAO."):n.getVAO().removeAttributeArray("gColor"),n.getProgram().isAttributeUsed("mapperIndexVS")?n.getVAO().addAttributeArrayWithDivisor(n.getProgram(),e.pickBuffer,"mapperIndexVS",0,4,e.context.UNSIGNED_BYTE,4,!0,1,!1)||Tg("Error setting mapperIndexVS in shader VAO."):n.getVAO().removeAttributeArray("mapperIndexVS"),r.setMapperShaderParameters(n,i,o),n.getAttributeUpdateTime().modified();return}r.setMapperShaderParameters(n,i,o)},t.getNeedToRebuildBufferObjects=(n,i)=>(e.renderable.buildArrays(),e.VBOBuildTime.getMTime()<e.renderable.getBuildTime().getMTime()?!0:r.getNeedToRebuildBufferObjects(n,i)),t.getNeedToRebuildShaders=(n,i,o)=>!!(r.getNeedToRebuildShaders(n,i,o)||n.getShaderSourceTime().getMTime()<e.renderable.getMTime()||n.getShaderSourceTime().getMTime()<e.currentInput.getMTime()),t.buildBufferObjects=(n,i)=>{if(e.hardwareSupport){const o=e.renderable.getMatrixArray(),a=e.renderable.getNormalArray(),s=e.renderable.getColorArray();if(e.matrixBuffer||(e.matrixBuffer=Bl.newInstance(),e.matrixBuffer.setOpenGLRenderWindow(e._openGLRenderWindow),e.normalBuffer=Bl.newInstance(),e.normalBuffer.setOpenGLRenderWindow(e._openGLRenderWindow),e.colorBuffer=Bl.newInstance(),e.colorBuffer.setOpenGLRenderWindow(e._openGLRenderWindow),e.pickBuffer=Bl.newInstance(),e.pickBuffer.setOpenGLRenderWindow(e._openGLRenderWindow)),e.renderable.getBuildTime().getMTime()>e.glyphBOBuildTime.getMTime()){e.matrixBuffer.upload(o,a2.ARRAY_BUFFER),e.normalBuffer.upload(a,a2.ARRAY_BUFFER),s?e.colorBuffer.upload(s.getData(),a2.ARRAY_BUFFER):e.colorBuffer.releaseGraphicsResources();const c=o.length/16,l=new Uint8Array(4*c);for(let f=0;f<c;++f){let u=f+1;const d=f*4;l[d]=u%256,u-=l[d],u/=256,l[d+1]=u%256,u-=l[d+1],u/=256,l[d+2]=u%256,l[d+3]=255}e.pickBuffer.upload(l,a2.ARRAY_BUFFER),e.glyphBOBuildTime.modified()}}return r.buildBufferObjects(n,i)}}const bee={normalMatrix:null,mcpcMatrix:null,mcwcMatrix:null};function Dee(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,bee,r),uw.extend(t,e,r),e.tmpMat3=ys(new Float64Array(9)),e.normalMatrix=ys(new Float64Array(9)),e.mcpcMatrix=It(new Float64Array(16)),e.mcvcMatrix=It(new Float64Array(16)),e.tmpColor=[],e.glyphBOBuildTime={},or(e.glyphBOBuildTime,{mtime:0}),Eee(t,e)}const pA=Rn(Dee,"vtkOpenGLGlyph3DMapper");var Iee={newInstance:pA};di("vtkGlyph3DMapper",pA);const Oee={NONE:-1,I:0,J:1,K:2,X:3,Y:4,Z:5};var fw={SlicingMode:Oee};const cd={NEAREST:0,LINEAR:1};var Mee={InterpolationType:cd};function il(t,e,r){return t?`${t.getMTime()}-${e}-${r}`:"0"}function E4(t,e){return`${t.getMTime()}A${e.getMTime()}`}const{vtkErrorMacro:Xd}=uo,{SlicingMode:Oa}=fw;function Pee(t){const e=t.split(`
|
||
`),r=[];for(let n=0;n<e.length;++n){const i=e[n].trim();i.length>0&&r.push(i)}return r}function Ree(t,e){e.classHierarchy.push("vtkOpenGLImageMapper");function r(n){e.openGLTexture.releaseGraphicsResources(n),[e._colorTransferFunc,e._pwFunc,e._labelOutlineThicknessArray].forEach(i=>n.unregisterGraphicsResourceUser(i,t))}t.buildPass=n=>{if(n){e.currentRenderPass=null,e.openGLImageSlice=t.getFirstAncestorOfType("vtkOpenGLImageSlice"),e._openGLRenderer=t.getFirstAncestorOfType("vtkOpenGLRenderer");const i=e._openGLRenderWindow;e._openGLRenderWindow=e._openGLRenderer.getLastAncestorOfType("vtkOpenGLRenderWindow"),i&&!i.isDeleted()&&i!==e._openGLRenderWindow&&r(i),e.context=e._openGLRenderWindow.getContext(),e.tris.setOpenGLRenderWindow(e._openGLRenderWindow);const o=e._openGLRenderer.getRenderable();e.openGLCamera=e._openGLRenderer.getViewNodeFor(o.getActiveCamera()),e.renderable.isA("vtkImageMapper")&&e.renderable.getSliceAtFocalPoint()&&e.renderable.setSliceFromCamera(o.getActiveCamera())}},t.translucentPass=(n,i)=>{n&&(e.currentRenderPass=i,t.render())},t.zBufferPass=n=>{n&&(e.haveSeenDepthRequest=!0,e.renderDepth=!0,t.render(),e.renderDepth=!1)},t.opaqueZBufferPass=n=>t.zBufferPass(n),t.opaquePass=n=>{n&&t.render()},t.getCoincidentParameters=(n,i)=>e.renderable.getResolveCoincidentTopology()==pc.PolygonOffset?e.renderable.getCoincidentTopologyPolygonOffsetParameters():null,t.render=()=>{const n=e.openGLImageSlice.getRenderable(),i=e._openGLRenderer.getRenderable();t.renderPiece(i,n)},t.getShaderTemplate=(n,i,o)=>{n.Vertex=_4,n.Fragment=im,n.Geometry=""},t.replaceShaderValues=(n,i,o)=>{let a=n.Vertex,s=n.Fragment;a=Be.substitute(a,"//VTK::Camera::Dec",["uniform mat4 MCPCMatrix;"]).result,a=Be.substitute(a,"//VTK::PositionVC::Impl",[" gl_Position = MCPCMatrix * vertexMC;"]).result,a=Be.substitute(a,"//VTK::TCoord::Impl","tcoordVCVSOutput = tcoordMC;").result,a=Be.substitute(a,"//VTK::TCoord::Dec","attribute vec2 tcoordMC; varying vec2 tcoordVCVSOutput;").result;const c=e.openGLTexture.getComponents(),l=o.getProperty().getIndependentComponents();let f=["varying vec2 tcoordVCVSOutput;","uniform float cshift0;","uniform float cscale0;","uniform float pwfshift0;","uniform float pwfscale0;","uniform sampler2D texture1;","uniform sampler2D colorTexture1;","uniform sampler2D pwfTexture1;","uniform sampler2D labelOutlineTexture1;","uniform float opacity;","uniform float outlineOpacity;"];if(l){for(let d=1;d<c;d++)f=f.concat([`uniform float cshift${d};`,`uniform float cscale${d};`,`uniform float pwfshift${d};`,`uniform float pwfscale${d};`]);switch(c){case 1:f=f.concat(["uniform float mix0;","#define height0 0.5"]);break;case 2:f=f.concat(["uniform float mix0;","uniform float mix1;","#define height0 0.25","#define height1 0.75"]);break;case 3:f=f.concat(["uniform float mix0;","uniform float mix1;","uniform float mix2;","#define height0 0.17","#define height1 0.5","#define height2 0.83"]);break;case 4:f=f.concat(["uniform float mix0;","uniform float mix1;","uniform float mix2;","uniform float mix3;","#define height0 0.125","#define height1 0.375","#define height2 0.625","#define height3 0.875"]);break;default:Xd("Unsupported number of independent coordinates.")}}if(s=Be.substitute(s,"//VTK::TCoord::Dec",f).result,o.getProperty().getUseLabelOutline()===!0&&(s=Be.substitute(s,"//VTK::LabelOutline::Dec",["uniform int outlineThickness;","uniform float vpWidth;","uniform float vpHeight;","uniform float vpOffsetX;","uniform float vpOffsetY;","uniform mat4 PCWCMatrix;","uniform mat4 vWCtoIDX;","uniform ivec3 imageDimensions;","uniform int sliceAxis;"]).result,s=Be.substitute(s,"//VTK::ImageLabelOutlineOn","#define vtkImageLabelOutlineOn").result,s=Be.substitute(s,"//VTK::LabelOutlineHelperFunction",["#ifdef vtkImageLabelOutlineOn","vec3 fragCoordToIndexSpace(vec4 fragCoord) {"," vec4 pcPos = vec4("," (fragCoord.x / vpWidth - vpOffsetX - 0.5) * 2.0,"," (fragCoord.y / vpHeight - vpOffsetY - 0.5) * 2.0,"," (fragCoord.z - 0.5) * 2.0,"," 1.0);",""," vec4 worldCoord = PCWCMatrix * pcPos;"," vec4 vertex = (worldCoord/worldCoord.w);",""," vec3 index = (vWCtoIDX * vertex).xyz;",""," // half voxel fix for labelmapOutline"," return (index + vec3(0.5)) / vec3(imageDimensions);","}","vec2 getSliceCoords(vec3 coord, int axis) {"," if (axis == 0) return coord.yz;"," if (axis == 1) return coord.xz;"," if (axis == 2) return coord.xy;","}","#endif"]).result),l){const d=["r","g","b","a"];let h=["vec4 tvalue = texture2D(texture1, tcoordVCVSOutput);"];for(let g=0;g<c;g++)h=h.concat([`vec3 tcolor${g} = mix${g} * texture2D(colorTexture1, vec2(tvalue.${d[g]} * cscale${g} + cshift${g}, height${g})).rgb;`,`float compWeight${g} = mix${g} * texture2D(pwfTexture1, vec2(tvalue.${d[g]} * pwfscale${g} + pwfshift${g}, height${g})).r;`]);switch(c){case 1:h=h.concat(["gl_FragData[0] = vec4(tcolor0.rgb, opacity);"]);break;case 2:h=h.concat(["float weightSum = compWeight0 + compWeight1;","gl_FragData[0] = vec4(vec3((tcolor0.rgb * (compWeight0 / weightSum)) + (tcolor1.rgb * (compWeight1 / weightSum))), opacity);"]);break;case 3:h=h.concat(["float weightSum = compWeight0 + compWeight1 + compWeight2;","gl_FragData[0] = vec4(vec3((tcolor0.rgb * (compWeight0 / weightSum)) + (tcolor1.rgb * (compWeight1 / weightSum)) + (tcolor2.rgb * (compWeight2 / weightSum))), opacity);"]);break;case 4:h=h.concat(["float weightSum = compWeight0 + compWeight1 + compWeight2 + compWeight3;","gl_FragData[0] = vec4(vec3((tcolor0.rgb * (compWeight0 / weightSum)) + (tcolor1.rgb * (compWeight1 / weightSum)) + (tcolor2.rgb * (compWeight2 / weightSum)) + (tcolor3.rgb * (compWeight3 / weightSum))), opacity);"]);break;default:Xd("Unsupported number of independent coordinates.")}s=Be.substitute(s,"//VTK::TCoord::Impl",h).result}else switch(c){case 1:s=Be.substitute(s,"//VTK::TCoord::Impl",[...Pee(`
|
||
#ifdef vtkImageLabelOutlineOn
|
||
vec3 centerPosIS = fragCoordToIndexSpace(gl_FragCoord);
|
||
float centerValue = texture2D(texture1, getSliceCoords(centerPosIS, sliceAxis)).r;
|
||
bool pixelOnBorder = false;
|
||
vec3 tColor = texture2D(colorTexture1, vec2(centerValue * cscale0 + cshift0, 0.5)).rgb;
|
||
float scalarOpacity = texture2D(pwfTexture1, vec2(centerValue * pwfscale0 + pwfshift0, 0.5)).r;
|
||
float opacityToUse = scalarOpacity * opacity;
|
||
int segmentIndex = int(centerValue * 255.0);
|
||
float textureCoordinate = float(segmentIndex - 1) / 1024.0;
|
||
float textureValue = texture2D(labelOutlineTexture1, vec2(textureCoordinate, 0.5)).r;
|
||
int actualThickness = int(textureValue * 255.0);
|
||
|
||
if (segmentIndex == 0){
|
||
gl_FragData[0] = vec4(0.0, 0.0, 0.0, 0.0);
|
||
return;
|
||
}
|
||
|
||
for (int i = -actualThickness; i <= actualThickness; i++) {
|
||
for (int j = -actualThickness; j <= actualThickness; j++) {
|
||
if (i == 0 || j == 0) {
|
||
continue;
|
||
}
|
||
vec4 neighborPixelCoord = vec4(gl_FragCoord.x + float(i),
|
||
gl_FragCoord.y + float(j),
|
||
gl_FragCoord.z, gl_FragCoord.w);
|
||
vec3 neighborPosIS = fragCoordToIndexSpace(neighborPixelCoord);
|
||
float value = texture2D(texture1, getSliceCoords(neighborPosIS, sliceAxis)).r;
|
||
if (value != centerValue) {
|
||
pixelOnBorder = true;
|
||
break;
|
||
}
|
||
}
|
||
if (pixelOnBorder == true) {
|
||
break;
|
||
}
|
||
}
|
||
if (pixelOnBorder == true) {
|
||
gl_FragData[0] = vec4(tColor, outlineOpacity);
|
||
}
|
||
else {
|
||
gl_FragData[0] = vec4(tColor, opacityToUse);
|
||
}
|
||
#else
|
||
float intensity = texture2D(texture1, tcoordVCVSOutput).r;
|
||
vec3 tcolor = texture2D(colorTexture1, vec2(intensity * cscale0 + cshift0, 0.5)).rgb;
|
||
float scalarOpacity = texture2D(pwfTexture1, vec2(intensity * pwfscale0 + pwfshift0, 0.5)).r;
|
||
gl_FragData[0] = vec4(tcolor, scalarOpacity * opacity);
|
||
#endif
|
||
`)]).result;break;case 2:s=Be.substitute(s,"//VTK::TCoord::Impl",["vec4 tcolor = texture2D(texture1, tcoordVCVSOutput);","float intensity = tcolor.r*cscale0 + cshift0;","gl_FragData[0] = vec4(texture2D(colorTexture1, vec2(intensity, 0.5)).rgb, pwfscale0*tcolor.g + pwfshift0);"]).result;break;case 3:s=Be.substitute(s,"//VTK::TCoord::Impl",["vec4 tcolor = cscale0*texture2D(texture1, tcoordVCVSOutput.st) + cshift0;","gl_FragData[0] = vec4(texture2D(colorTexture1, vec2(tcolor.r,0.5)).r,"," texture2D(colorTexture1, vec2(tcolor.g,0.5)).r,"," texture2D(colorTexture1, vec2(tcolor.b,0.5)).r, opacity);"]).result;break;default:s=Be.substitute(s,"//VTK::TCoord::Impl",["vec4 tcolor = cscale0*texture2D(texture1, tcoordVCVSOutput.st) + cshift0;","gl_FragData[0] = vec4(texture2D(colorTexture1, vec2(tcolor.r,0.5)).r,"," texture2D(colorTexture1, vec2(tcolor.g,0.5)).r,"," texture2D(colorTexture1, vec2(tcolor.b,0.5)).r, tcolor.a);"]).result}e.haveSeenDepthRequest&&(s=Be.substitute(s,"//VTK::ZBuffer::Dec","uniform int depthRequest;").result,s=Be.substitute(s,"//VTK::ZBuffer::Impl",["if (depthRequest == 1) {","float iz = floor(gl_FragCoord.z*65535.0 + 0.1);","float rf = floor(iz/256.0)/255.0;","float gf = mod(iz,256.0)/255.0;","gl_FragData[0] = vec4(rf, gf, 0.0, 1.0); }"]).result),n.Vertex=a,n.Fragment=s,t.replaceShaderClip(n,i,o),t.replaceShaderCoincidentOffset(n,i,o)},t.replaceShaderClip=(n,i,o)=>{let a=n.Vertex,s=n.Fragment;if(e.renderable.getNumberOfClippingPlanes()){let c=e.renderable.getNumberOfClippingPlanes();c>6&&(vn("OpenGL has a limit of 6 clipping planes"),c=6),a=Be.substitute(a,"//VTK::Clip::Dec",["uniform int numClipPlanes;","uniform vec4 clipPlanes[6];","varying float clipDistancesVSOutput[6];"]).result,a=Be.substitute(a,"//VTK::Clip::Impl",["for (int planeNum = 0; planeNum < 6; planeNum++)"," {"," if (planeNum >= numClipPlanes)"," {"," break;"," }"," clipDistancesVSOutput[planeNum] = dot(clipPlanes[planeNum], vertexMC);"," }"]).result,s=Be.substitute(s,"//VTK::Clip::Dec",["uniform int numClipPlanes;","varying float clipDistancesVSOutput[6];"]).result,s=Be.substitute(s,"//VTK::Clip::Impl",["for (int planeNum = 0; planeNum < 6; planeNum++)"," {"," if (planeNum >= numClipPlanes)"," {"," break;"," }"," if (clipDistancesVSOutput[planeNum] < 0.0) discard;"," }"]).result}n.Vertex=a,n.Fragment=s},t.getNeedToRebuildShaders=(n,i,o)=>{var l;const a=e.openGLTexture.getComponents(),s=o.getProperty().getIndependentComponents();let c=!1;return(!e.currentRenderPass&&e.lastRenderPassShaderReplacement||e.currentRenderPass&&e.currentRenderPass.getShaderReplacement()!==e.lastRenderPassShaderReplacement)&&(c=!0),c||e.lastHaveSeenDepthRequest!==e.haveSeenDepthRequest||((l=n.getProgram())==null?void 0:l.getHandle())===0||e.lastTextureComponents!==a||e.lastIndependentComponents!==s?(e.lastHaveSeenDepthRequest=e.haveSeenDepthRequest,e.lastTextureComponents=a,e.lastIndependentComponents=s,!0):!1},t.updateShaders=(n,i,o)=>{if(e.lastBoundBO=n,t.getNeedToRebuildShaders(n,i,o)){const a={Vertex:null,Fragment:null,Geometry:null};t.buildShaders(a,i,o);const s=e._openGLRenderWindow.getShaderCache().readyShaderProgramArray(a.Vertex,a.Fragment,a.Geometry);s!==n.getProgram()&&(n.setProgram(s),n.getVAO().releaseGraphicsResources()),n.getShaderSourceTime().modified()}else e._openGLRenderWindow.getShaderCache().readyShaderProgram(n.getProgram());n.getVAO().bind(),t.setMapperShaderParameters(n,i,o),t.setCameraShaderParameters(n,i,o),t.setPropertyShaderParameters(n,i,o)},t.setMapperShaderParameters=(n,i,o)=>{n.getCABO().getElementCount()&&(e.VBOBuildTime>n.getAttributeUpdateTime().getMTime()||n.getShaderSourceTime().getMTime()>n.getAttributeUpdateTime().getMTime())&&(n.getProgram().isAttributeUsed("vertexMC")&&(n.getVAO().addAttributeArray(n.getProgram(),n.getCABO(),"vertexMC",n.getCABO().getVertexOffset(),n.getCABO().getStride(),e.context.FLOAT,3,e.context.FALSE)||Xd("Error setting vertexMC in shader VAO.")),n.getProgram().isAttributeUsed("tcoordMC")&&n.getCABO().getTCoordOffset()&&(n.getVAO().addAttributeArray(n.getProgram(),n.getCABO(),"tcoordMC",n.getCABO().getTCoordOffset(),n.getCABO().getStride(),e.context.FLOAT,n.getCABO().getTCoordComponents(),e.context.FALSE)||Xd("Error setting tcoordMC in shader VAO.")),n.getAttributeUpdateTime().modified());const a=e.openGLTexture.getTextureUnit();n.getProgram().setUniformi("texture1",a);const s=e.openGLTexture.getComponents(),c=o.getProperty().getIndependentComponents();if(c)for(let g=0;g<s;g++)n.getProgram().setUniformf(`mix${g}`,o.getProperty().getComponentWeight(g));const l=e.openGLTexture.getShiftAndScale();for(let g=0;g<s;g++){let p=o.getProperty().getColorWindow(),v=o.getProperty().getColorLevel();const y=c?g:0,m=o.getProperty().getRGBTransferFunction(y);if(m&&o.getProperty().getUseLookupTableScalarRange()){const C=m.getRange();p=C[1]-C[0],v=.5*(C[1]+C[0])}const w=l.scale/p,x=(l.shift-v)/p+.5;n.getProgram().setUniformf(`cshift${g}`,x),n.getProgram().setUniformf(`cscale${g}`,w)}for(let g=0;g<s;g++){let p=1,v=0;const y=c?g:0,m=o.getProperty().getPiecewiseFunction(y);if(m){const w=m.getRange(),x=w[1]-w[0],C=.5*(w[0]+w[1]);p=l.scale/x,v=(l.shift-C)/x+.5}n.getProgram().setUniformf(`pwfshift${g}`,v),n.getProgram().setUniformf(`pwfscale${g}`,p)}if(e.haveSeenDepthRequest&&n.getProgram().setUniformi("depthRequest",e.renderDepth?1:0),n.getProgram().isUniformUsed("coffset")){const g=t.getCoincidentParameters(i,o);n.getProgram().setUniformf("coffset",g.offset),n.getProgram().isUniformUsed("cfactor")&&n.getProgram().setUniformf("cfactor",g.factor)}const f=e.colorTexture.getTextureUnit();n.getProgram().setUniformi("colorTexture1",f);const u=e.pwfTexture.getTextureUnit();n.getProgram().setUniformi("pwfTexture1",u);const d=e.labelOutlineThicknessTexture.getTextureUnit();if(n.getProgram().setUniformi("labelOutlineTexture1",d),e.renderable.getNumberOfClippingPlanes()){let g=e.renderable.getNumberOfClippingPlanes();g>6&&(vn("OpenGL has a limit of 6 clipping planes"),g=6);const v=n.getCABO().getCoordShiftAndScaleEnabled()?n.getCABO().getInverseShiftAndScaleMatrix():null,y=v?Cr(e.imagematinv,o.getMatrix()):o.getMatrix();v&&(un(y,y),yn(y,y,v),un(y,y)),un(e.imagemat,e.currentInput.getIndexToWorld()),yn(e.imagematinv,y,e.imagemat);const m=[];for(let w=0;w<g;w++){const x=[];e.renderable.getClippingPlaneInDataCoords(e.imagematinv,w,x);for(let C=0;C<4;C++)m.push(x[C])}n.getProgram().setUniformi("numClipPlanes",g),n.getProgram().setUniform4fv("clipPlanes",m)}if(o.getProperty().getUseLabelOutline()===!0){const g=o.getProperty().getLabelOutlineOpacity();n.getProgram().setUniformf("outlineOpacity",g)}},t.setCameraShaderParameters=(n,i,o)=>{const a=n.getProgram(),s=e.openGLImageSlice.getKeyMatrices(),c=e.currentInput,l=c.getIndexToWorld();yn(e.imagemat,s.mcwc,l);const f=e.openGLCamera.getKeyMatrices(i);if(yn(e.imagemat,f.wcpc,e.imagemat),n.getCABO().getCoordShiftAndScaleEnabled()){const d=n.getCABO().getInverseShiftAndScaleMatrix();yn(e.imagemat,e.imagemat,d)}if(a.setUniformMatrix("MCPCMatrix",e.imagemat),o.getProperty().getUseLabelOutline()===!0){const d=c.getWorldToIndex(),h=c.getDimensions();let g=e.renderable.getClosestIJKAxis().ijkMode;g===Oa.NONE&&(g=Oa.K),a.setUniform3i("imageDimensions",h[0],h[1],h[2]),a.setUniformi("sliceAxis",g),a.setUniformMatrix("vWCtoIDX",d);const p=e.openGLCamera.getKeyMatrices(i);Ar(e.projectionToWorld,p.wcpc),e.openGLCamera.getKeyMatrices(i),a.setUniformMatrix("PCWCMatrix",e.projectionToWorld);const v=t.getRenderTargetSize();a.setUniformf("vpWidth",v[0]),a.setUniformf("vpHeight",v[1]);const y=t.getRenderTargetOffset();a.setUniformf("vpOffsetX",y[0]/v[0]),a.setUniformf("vpOffsetY",y[1]/v[1])}},t.setPropertyShaderParameters=(n,i,o)=>{const a=n.getProgram(),c=o.getProperty().getOpacity();a.setUniformf("opacity",c)},t.renderPieceStart=(n,i)=>{t.updateBufferObjects(n,i),e.lastBoundBO=null},t.renderPieceDraw=(n,i)=>{const o=e.context;e.openGLTexture.activate(),e.colorTexture.activate(),e.labelOutlineThicknessTexture.activate(),e.pwfTexture.activate(),e.tris.getCABO().getElementCount()&&(t.updateShaders(e.tris,n,i),o.drawArrays(o.TRIANGLES,0,e.tris.getCABO().getElementCount()),e.tris.getVAO().release()),e.openGLTexture.deactivate(),e.colorTexture.deactivate(),e.labelOutlineThicknessTexture.deactivate(),e.pwfTexture.deactivate()},t.renderPieceFinish=(n,i)=>{},t.renderPiece=(n,i)=>{if(t.invokeEvent({type:"StartEvent"}),e.renderable.update(),e.currentInput=e.renderable.getCurrentImage(),t.invokeEvent({type:"EndEvent"}),!e.currentInput){Xd("No input!");return}t.renderPieceStart(n,i),t.renderPieceDraw(n,i),t.renderPieceFinish(n,i)},t.computeBounds=(n,i)=>{if(!t.getInput()){Gh(e.bounds);return}e.bounds=t.getInput().getBounds()},t.updateBufferObjects=(n,i)=>{t.getNeedToRebuildBufferObjects(n,i)&&t.buildBufferObjects(n,i)},t.getNeedToRebuildBufferObjects=(n,i)=>{var o,a,s,c;return e.VBOBuildTime.getMTime()<t.getMTime()||e.VBOBuildTime.getMTime()<i.getMTime()||e.VBOBuildTime.getMTime()<e.renderable.getMTime()||e.VBOBuildTime.getMTime()<i.getProperty().getMTime()||e.VBOBuildTime.getMTime()<e.currentInput.getMTime()||!((o=e.openGLTexture)!=null&&o.getHandle())||!((a=e.colorTexture)!=null&&a.getHandle())||!((s=e.labelOutlineThicknessTexture)!=null&&s.getHandle())||!((c=e.pwfTexture)!=null&&c.getHandle())},t.buildBufferObjects=(n,i)=>{var I,P,O,L;const o=e.currentInput;if(!o)return;const a=o.getPointData()&&o.getPointData().getScalars();if(!a)return;const s=a.getDataType(),c=a.getNumberOfComponents(),l=i.getProperty(),f=l.getInterpolationType(),u=l.getIndependentComponents(),d=u?c:1,h=u?2*d:1,g=l.getRGBTransferFunction(),p=il(g,u,d),v=e._openGLRenderWindow.getGraphicsResourceForObject(g);if(!((I=v==null?void 0:v.oglObject)!=null&&I.getHandle())||(v==null?void 0:v.hash)!==p){e.colorTexture=mr.newInstance({resizable:!0}),e.colorTexture.setOpenGLRenderWindow(e._openGLRenderWindow);const B=1024,H=B*h*3,A=new Uint8ClampedArray(H);if(f===cd.NEAREST?(e.colorTexture.setMinificationFilter(Pt.NEAREST),e.colorTexture.setMagnificationFilter(Pt.NEAREST)):(e.colorTexture.setMinificationFilter(Pt.LINEAR),e.colorTexture.setMagnificationFilter(Pt.LINEAR)),g){const F=new Float32Array(B*3);for(let G=0;G<d;G++){const X=l.getRGBTransferFunction(G),ee=X.getRange();if(X.getTable(ee[0],ee[1],B,F,1),u)for(let ce=0;ce<B*3;ce++)A[G*B*6+ce]=255*F[ce],A[G*B*6+ce+B*3]=255*F[ce];else for(let ce=0;ce<B*3;ce++)A[G*B*6+ce]=255*F[ce]}e.colorTexture.resetFormatAndType(),e.colorTexture.create2DFromRaw(B,h,3,rn.UNSIGNED_CHAR,A)}else{for(let F=0;F<B*3;++F)A[F]=255*F/((B-1)*3),A[F+1]=255*F/((B-1)*3),A[F+2]=255*F/((B-1)*3);e.colorTexture.create2DFromRaw(B,1,3,rn.UNSIGNED_CHAR,A)}g&&(e._openGLRenderWindow.setGraphicsResourceForObject(g,e.colorTexture,p),g!==e._colorTransferFunc&&(e._openGLRenderWindow.registerGraphicsResourceUser(g,t),e._openGLRenderWindow.unregisterGraphicsResourceUser(e._colorTransferFunc,t)),e._colorTransferFunc=g)}else e.colorTexture=v.oglObject;const m=l.getPiecewiseFunction(),w=il(m,u,d),x=e._openGLRenderWindow.getGraphicsResourceForObject(m);if(!((P=x==null?void 0:x.oglObject)!=null&&P.getHandle())||(x==null?void 0:x.hash)!==w){const H=1024*h,A=new Uint8ClampedArray(H);if(e.pwfTexture=mr.newInstance({resizable:!0}),e.pwfTexture.setOpenGLRenderWindow(e._openGLRenderWindow),f===cd.NEAREST?(e.pwfTexture.setMinificationFilter(Pt.NEAREST),e.pwfTexture.setMagnificationFilter(Pt.NEAREST)):(e.pwfTexture.setMinificationFilter(Pt.LINEAR),e.pwfTexture.setMagnificationFilter(Pt.LINEAR)),m){const F=new Float32Array(H),G=new Float32Array(1024);for(let X=0;X<d;++X){const ee=l.getPiecewiseFunction(X);if(ee===null)F.fill(1);else{const ce=ee.getRange();if(ee.getTable(ce[0],ce[1],1024,G,1),u)for(let Se=0;Se<1024;Se++)F[X*1024*2+Se]=G[Se],F[X*1024*2+Se+1024]=G[Se];else for(let Se=0;Se<1024;Se++)F[X*1024*2+Se]=G[Se]}}e.pwfTexture.resetFormatAndType(),e.pwfTexture.create2DFromRaw(1024,h,1,rn.FLOAT,F)}else A.fill(255),e.pwfTexture.create2DFromRaw(1024,1,1,rn.UNSIGNED_CHAR,A);m&&(e._openGLRenderWindow.setGraphicsResourceForObject(m,e.pwfTexture,w),m!==e._pwFunc&&(e._openGLRenderWindow.registerGraphicsResourceUser(m,t),e._openGLRenderWindow.unregisterGraphicsResourceUser(e._pwFunc,t)),e._pwFunc=m)}else e.pwfTexture=x.oglObject;t.updatelabelOutlineThicknessTexture(i);const{ijkMode:S}=e.renderable.getClosestIJKAxis();let T=e.renderable.getSlice();S!==e.renderable.getSlicingMode()&&(T=e.renderable.getSliceAtPosition(T));const _=e.renderable.isA("vtkImageArrayMapper")?e.renderable.getSubSlice():Math.round(T),E=o.getExtent();let b;S===Oa.I&&(b=_-E[0]),S===Oa.J&&(b=_-E[2]),(S===Oa.K||S===Oa.NONE)&&(b=_-E[4]);const D=`${T}A${o.getMTime()}A${a.getMTime()}B${t.getMTime()}C${e.renderable.getSlicingMode()}D${i.getProperty().getInterpolationType()}`;if(e.VBOBuildString!==D){const B=o.getDimensions();e.openGLTexture||(e.openGLTexture=mr.newInstance({resizable:!0})),e.openGLTexture.setOpenGLRenderWindow(e._openGLRenderWindow),e.openGLTexture.setOglNorm16Ext(e.context.getExtension("EXT_texture_norm16")),f===cd.NEAREST?(new Set([1,3,4]).has(c)&&s===rn.UNSIGNED_CHAR&&!u&&e.openGLTexture.setGenerateMipmap(!0),e.openGLTexture.setMinificationFilter(Pt.NEAREST),e.openGLTexture.setMagnificationFilter(Pt.NEAREST)):(c===4&&s===rn.UNSIGNED_CHAR&&!u?(e.openGLTexture.setGenerateMipmap(!0),e.openGLTexture.setMinificationFilter(Pt.LINEAR_MIPMAP_LINEAR)):e.openGLTexture.setMinificationFilter(Pt.LINEAR),e.openGLTexture.setMagnificationFilter(Pt.LINEAR)),e.openGLTexture.setWrapS(a1.CLAMP_TO_EDGE),e.openGLTexture.setWrapT(a1.CLAMP_TO_EDGE);const H=B[0]*B[1]*c,A=new Float32Array(12),F=new Float32Array(8);for(let Ne=0;Ne<4;Ne++)F[Ne*2]=Ne%2?1:0,F[Ne*2+1]=Ne>1?1:0;const G=[Oa.X,Oa.Y,Oa.Z].includes(e.renderable.getSlicingMode())?T:_,X=o.getSpatialExtent(),ee=a.getData();let ce=null;if(S===Oa.I){ce=new ee.constructor(B[2]*B[1]*c);let Ne=0;for(let j=0;j<B[2];j++)for(let M=0;M<B[1];M++){let q=(b+M*B[0]+j*B[0]*B[1])*c;Ne=(j*B[1]+M)*c;const K=q+c;for(;q<K;)ce[Ne++]=ee[q++]}B[0]=B[1],B[1]=B[2],A[0]=G,A[1]=X[2],A[2]=X[4],A[3]=G,A[4]=X[3],A[5]=X[4],A[6]=G,A[7]=X[2],A[8]=X[5],A[9]=G,A[10]=X[3],A[11]=X[5]}else if(S===Oa.J){ce=new ee.constructor(B[2]*B[0]*c);let Ne=0;for(let j=0;j<B[2];j++)for(let M=0;M<B[0];M++){let q=(M+b*B[0]+j*B[0]*B[1])*c;Ne=(j*B[0]+M)*c;const K=q+c;for(;q<K;)ce[Ne++]=ee[q++]}B[1]=B[2],A[0]=X[0],A[1]=G,A[2]=X[4],A[3]=X[1],A[4]=G,A[5]=X[4],A[6]=X[0],A[7]=G,A[8]=X[5],A[9]=X[1],A[10]=G,A[11]=X[5]}else S===Oa.K||S===Oa.NONE?(ce=ee.subarray(b*H,(b+1)*H),A[0]=X[0],A[1]=X[2],A[2]=G,A[3]=X[1],A[4]=X[2],A[5]=G,A[6]=X[0],A[7]=X[3],A[8]=G,A[9]=X[1],A[10]=X[3],A[11]=G):Xd("Reformat slicing not yet supported.");const Se=a.getRanges();e.openGLTexture.resetFormatAndType(),e.openGLTexture.create2DFilterableFromRaw(B[0],B[1],c,a.getDataType(),ce,(L=(O=e.renderable).getPreferSizeOverAccuracy)==null?void 0:L.call(O),Se),e.openGLTexture.activate(),e.openGLTexture.sendParameters(),e.openGLTexture.deactivate();const we=bt.newInstance({numberOfComponents:3,values:A});we.setName("points");const _e=bt.newInstance({numberOfComponents:2,values:F});_e.setName("tcoords");const Ve=new Uint16Array(8);Ve[0]=3,Ve[1]=0,Ve[2]=1,Ve[3]=3,Ve[4]=3,Ve[5]=0,Ve[6]=3,Ve[7]=2;const Ge=bt.newInstance({numberOfComponents:1,values:Ve});e.tris.getCABO().createVBO(Ge,"polys",ao.SURFACE,{points:we,tcoords:_e,cellOffset:0}),e.VBOBuildTime.modified(),e.VBOBuildString=D}},t.updatelabelOutlineThicknessTexture=n=>{var c;const i=n.getProperty().getLabelOutlineThicknessByReference(),o=e._openGLRenderWindow.getGraphicsResourceForObject(i),a=`${i.join("-")}`;if(!((c=o==null?void 0:o.oglObject)!=null&&c.getHandle())||(o==null?void 0:o.hash)!==a){const d=new Uint8Array(1024);for(let h=0;h<1024;++h){const g=typeof i[h]<"u"?i[h]:i[0];d[h]=g}e.labelOutlineThicknessTexture=mr.newInstance({resizable:!1}),e.labelOutlineThicknessTexture.setOpenGLRenderWindow(e._openGLRenderWindow),e.labelOutlineThicknessTexture.resetFormatAndType(),e.labelOutlineThicknessTexture.setMinificationFilter(Pt.NEAREST),e.labelOutlineThicknessTexture.setMagnificationFilter(Pt.NEAREST),e.labelOutlineThicknessTexture.create2DFromRaw(1024,1,1,rn.UNSIGNED_CHAR,d),i&&(e._openGLRenderWindow.setGraphicsResourceForObject(i,e.labelOutlineThicknessTexture,a),i!==e._labelOutlineThicknessArray&&(e._openGLRenderWindow.registerGraphicsResourceUser(i,t),e._openGLRenderWindow.unregisterGraphicsResourceUser(e._labelOutlineThicknessArray,t)),e._labelOutlineThicknessArray=i)}else e.labelOutlineThicknessTexture=o.oglObject},t.getRenderTargetSize=()=>{if(e._useSmallViewport)return[e._smallViewportWidth,e._smallViewportHeight];const{usize:n,vsize:i}=e._openGLRenderer.getTiledSizeAndOrigin();return[n,i]},t.getRenderTargetOffset=()=>{const{lowerLeftU:n,lowerLeftV:i}=e._openGLRenderer.getTiledSizeAndOrigin();return[n,i]},t.delete=Y1(()=>{e._openGLRenderWindow&&r(e._openGLRenderWindow)},t.delete)}const Lee={VBOBuildTime:0,VBOBuildString:null,openGLTexture:null,tris:null,imagemat:null,imagematinv:null,colorTexture:null,pwfTexture:null,labelOutlineThicknessTexture:null,labelOutlineThicknessTextureString:null,lastHaveSeenDepthRequest:!1,haveSeenDepthRequest:!1,lastTextureComponents:0};function Aee(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Lee,r),Qn.extend(t,e,r),rl.implementReplaceShaderCoincidentOffset(t,e,r),rl.implementBuildShadersWithReplacements(t,e,r),e.tris=ul.newInstance(),e.imagemat=It(new Float64Array(16)),e.imagematinv=It(new Float64Array(16)),e.projectionToWorld=It(new Float64Array(16)),e.idxToView=It(new Float64Array(16)),e.idxNormalMatrix=ys(new Float64Array(9)),e.modelToView=It(new Float64Array(16)),e.projectionToView=It(new Float64Array(16)),Jr(t,e,[]),e.VBOBuildTime={},or(e.VBOBuildTime),Ree(t,e)}const mA=Rn(Aee,"vtkOpenGLImageMapper");var Nee={newInstance:mA};di("vtkAbstractImageMapper",mA);const Pf={MAX:0,MIN:1,AVERAGE:2},{vtkErrorMacro:s2}=Z;function kee(t,e){e.classHierarchy.push("vtkOpenGLImageCPRMapper");function r(n){[e._scalars,e._colorTransferFunc,e._pwFunc].forEach(i=>n.unregisterGraphicsResourceUser(i,t))}t.buildPass=n=>{if(n){e.currentRenderPass=null,e.openGLImageSlice=t.getFirstAncestorOfType("vtkOpenGLImageSlice"),e._openGLRenderer=t.getFirstAncestorOfType("vtkOpenGLRenderer");const i=e._openGLRenderWindow;e._openGLRenderWindow=e._openGLRenderer.getLastAncestorOfType("vtkOpenGLRenderWindow"),i&&!i.isDeleted()&&i!==e._openGLRenderWindow&&r(i),e.context=e._openGLRenderWindow.getContext(),e.openGLCamera=e._openGLRenderer.getViewNodeFor(e._openGLRenderer.getRenderable().getActiveCamera()),e.tris.setOpenGLRenderWindow(e._openGLRenderWindow)}},t.opaquePass=(n,i)=>{n&&(e.currentRenderPass=i,t.render())},t.opaqueZBufferPass=n=>{n&&(e.haveSeenDepthRequest=!0,e.renderDepth=!0,t.render(),e.renderDepth=!1)},t.getCoincidentParameters=(n,i)=>e.renderable.getResolveCoincidentTopology()===pc.PolygonOffset?e.renderable.getCoincidentTopologyPolygonOffsetParameters():null,t.render=()=>{const n=e.openGLImageSlice.getRenderable(),i=e._openGLRenderer.getRenderable();t.renderPiece(i,n)},t.renderPiece=(n,i)=>{t.invokeEvent({type:"StartEvent"}),e.renderable.update(),t.invokeEvent({type:"EndEvent"}),e.renderable.preRenderCheck()&&(e.currentImageDataInput=e.renderable.getInputData(0),e.currentCenterlineInput=e.renderable.getOrientedCenterline(),t.renderPieceStart(n,i),t.renderPieceDraw(n,i),t.renderPieceFinish(n,i))},t.renderPieceStart=(n,i)=>{t.updateBufferObjects(n,i)},t.renderPieceDraw=(n,i)=>{const o=e.context;e.volumeTexture.activate(),e.colorTexture.activate(),e.pwfTexture.activate(),e.tris.getCABO().getElementCount()&&(t.updateShaders(e.tris,n,i),o.drawArrays(o.TRIANGLES,0,e.tris.getCABO().getElementCount()),e.tris.getVAO().release()),e.volumeTexture.deactivate(),e.colorTexture.deactivate(),e.pwfTexture.deactivate()},t.renderPieceFinish=(n,i)=>{},t.updateBufferObjects=(n,i)=>{t.getNeedToRebuildBufferObjects(n,i)&&t.buildBufferObjects(n,i),i.getProperty().getInterpolationType()===cd.NEAREST?(e.volumeTexture.setMinificationFilter(Pt.NEAREST),e.volumeTexture.setMagnificationFilter(Pt.NEAREST),e.colorTexture.setMinificationFilter(Pt.NEAREST),e.colorTexture.setMagnificationFilter(Pt.NEAREST),e.pwfTexture.setMinificationFilter(Pt.NEAREST),e.pwfTexture.setMagnificationFilter(Pt.NEAREST)):(e.volumeTexture.setMinificationFilter(Pt.LINEAR),e.volumeTexture.setMagnificationFilter(Pt.LINEAR),e.colorTexture.setMinificationFilter(Pt.LINEAR),e.colorTexture.setMagnificationFilter(Pt.LINEAR),e.pwfTexture.setMinificationFilter(Pt.LINEAR),e.pwfTexture.setMagnificationFilter(Pt.LINEAR))},t.getNeedToRebuildBufferObjects=(n,i)=>{var a;const o=e.VBOBuildTime.getMTime();return o<t.getMTime()||o<e.renderable.getMTime()||o<i.getMTime()||o<e.currentImageDataInput.getMTime()||o<e.currentCenterlineInput.getMTime()||!((a=e.volumeTexture)!=null&&a.getHandle())},t.buildBufferObjects=(n,i)=>{var b,D,I,P;const o=e.currentImageDataInput,a=e.currentCenterlineInput,s=(b=o==null?void 0:o.getPointData())==null?void 0:b.getScalars();if(!s)return;const c=e._openGLRenderWindow.getGraphicsResourceForObject(s),l=E4(o,s),f=!((D=c==null?void 0:c.oglObject)!=null&&D.getHandle())||(c==null?void 0:c.hash)!==l,u=e.renderable.getUpdatedExtents(),d=!!u.length;if(f){e.volumeTexture=mr.newInstance(),e.volumeTexture.setOpenGLRenderWindow(e._openGLRenderWindow);const O=o.getDimensions();e.volumeTexture.setOglNorm16Ext(e.context.getExtension("EXT_texture_norm16")),e.volumeTexture.resetFormatAndType(),e.volumeTexture.create3DFilterableFromDataArray(O[0],O[1],O[2],s,e.renderable.getPreferSizeOverAccuracy()),e._openGLRenderWindow.setGraphicsResourceForObject(s,e.volumeTexture,l),s!==e._scalars&&(e._openGLRenderWindow.registerGraphicsResourceUser(s,t),e._openGLRenderWindow.unregisterGraphicsResourceUser(e._scalars,t)),e._scalars=s}else e.volumeTexture=c.oglObject;if(d){e.renderable.setUpdatedExtents([]);const O=o.getDimensions();e.volumeTexture.create3DFilterableFromDataArray(O[0],O[1],O[2],s,!1,u)}const h=s.getNumberOfComponents(),g=i.getProperty(),p=g.getIndependentComponents(),v=p?h:1,y=p?2*v:1,m=g.getRGBTransferFunction(),w=il(m,p,v),x=e._openGLRenderWindow.getGraphicsResourceForObject(m);if(!((I=x==null?void 0:x.oglObject)!=null&&I.getHandle())||(x==null?void 0:x.hash)!==w){const L=1024*y*3,B=new Uint8ClampedArray(L);if(e.colorTexture=mr.newInstance(),e.colorTexture.setOpenGLRenderWindow(e._openGLRenderWindow),m){const H=new Float32Array(3072);for(let A=0;A<v;A++){const F=g.getRGBTransferFunction(A),G=F.getRange();if(F.getTable(G[0],G[1],1024,H,1),p)for(let X=0;X<1024*3;X++)B[A*1024*6+X]=255*H[X],B[A*1024*6+X+1024*3]=255*H[X];else for(let X=0;X<1024*3;X++)B[A*1024*6+X]=255*H[X]}e.colorTexture.resetFormatAndType(),e.colorTexture.create2DFromRaw(1024,y,3,rn.UNSIGNED_CHAR,B)}else{for(let H=0;H<1024*3;++H)B[H]=255*H/(1023*3),B[H+1]=255*H/(1023*3),B[H+2]=255*H/(1023*3);e.colorTexture.resetFormatAndType(),e.colorTexture.create2DFromRaw(1024,1,3,rn.UNSIGNED_CHAR,B)}m&&(e._openGLRenderWindow.setGraphicsResourceForObject(m,e.colorTexture,w),m!==e._colorTransferFunc&&(e._openGLRenderWindow.registerGraphicsResourceUser(m,t),e._openGLRenderWindow.unregisterGraphicsResourceUser(e._colorTransferFunc,t)),e._colorTransferFunc=m)}else e.colorTexture=x.oglObject;const S=g.getPiecewiseFunction(),T=il(S,p,v),_=e._openGLRenderWindow.getGraphicsResourceForObject(S);if(!((P=_==null?void 0:_.oglObject)!=null&&P.getHandle())||(_==null?void 0:_.hash)!==T){const L=1024*y,B=new Uint8ClampedArray(L);if(e.pwfTexture=mr.newInstance(),e.pwfTexture.setOpenGLRenderWindow(e._openGLRenderWindow),S){const H=new Float32Array(L),A=new Float32Array(1024);for(let F=0;F<v;++F){const G=g.getPiecewiseFunction(F);if(G===null)H.fill(1);else{const X=G.getRange();if(G.getTable(X[0],X[1],1024,A,1),p)for(let ee=0;ee<1024;ee++)H[F*1024*2+ee]=A[ee],H[F*1024*2+ee+1024]=A[ee];else for(let ee=0;ee<1024;ee++)H[F*1024*2+ee]=A[ee]}}e.pwfTexture.resetFormatAndType(),e.pwfTexture.create2DFromRaw(1024,y,1,rn.FLOAT,H)}else B.fill(255),e.pwfTexture.resetFormatAndType(),e.pwfTexture.create2DFromRaw(1024,1,1,rn.UNSIGNED_CHAR,B);S&&(e._openGLRenderWindow.setGraphicsResourceForObject(S,e.pwfTexture,T),S!==e._pwFunc&&(e._openGLRenderWindow.registerGraphicsResourceUser(S,t),e._openGLRenderWindow.unregisterGraphicsResourceUser(e._pwFunc,t)),e._pwFunc=S)}else e.pwfTexture=_.oglObject;if(e.VBOBuildTime.getMTime()<e.renderable.getMTime()||e.VBOBuildTime.getMTime()<a.getMTime()){const O=a.getNumberOfPoints(),L=O<=1?0:O-1,B=a.getDistancesToFirstPoint(),H=e.renderable.getHeight(),A=4*L,F=new Float32Array(3*A),G=e.renderable.getWidth();for(let q=0,K=0;q<L;++q)F.set([0,H-B[q],0],K),K+=3,F.set([G,H-B[q],0],K),K+=3,F.set([G,H-B[q+1],0],K),K+=3,F.set([0,H-B[q+1],0],K),K+=3;const X=bt.newInstance({numberOfComponents:3,values:F});X.setName("points");const ee=new Uint16Array(5*L);for(let q=0,K=0,J=0;q<L;++q)ee.set([4,J+3,J+2,J+1,J],K),K+=5,J+=4;const ce=bt.newInstance({numberOfComponents:1,values:ee}),Se=a.getPoints(),we=new Float32Array(3*A),_e=new Array(3),Ve=new Array(3);for(let q=0,K=0;q<L;++q)Se.getPoint(q,_e),Se.getPoint(q+1,Ve),we.set(_e,K),K+=3,we.set(_e,K),K+=3,we.set(Ve,K),K+=3,we.set(Ve,K),K+=3;const Ge=bt.newInstance({numberOfComponents:3,values:we,name:"centerlinePosition"}),Ne=new Float32Array(A);for(let q=0,K=0;q<L;++q)Ne.set([0,1,3,2],K),K+=4;const j=bt.newInstance({numberOfComponents:1,values:Ne,name:"quadIndex"}),M=[Ge,j];if(!e.renderable.getUseUniformOrientation()){const q=e.renderable.getOrientedCenterline().getOrientations()??[],K=new Float32Array(4*A),J=new Float32Array(4*A);for(let Re=0;Re<L;++Re){const Fe=q[Re],je=q[Re+1];for(let Xe=0;Xe<4;++Xe){const ue=4*(Xe+4*Re);K.set(Fe,ue),J.set(je,ue)}}const re=bt.newInstance({numberOfComponents:4,values:K,name:"centerlineTopOrientation"}),ie=bt.newInstance({numberOfComponents:4,values:J,name:"centerlineBotOrientation"});M.push(re,ie)}e.tris.getCABO().createVBO(ce,"polys",ao.SURFACE,{points:X,customAttributes:M}),e.VBOBuildTime.modified()}},t.getNeedToRebuildShaders=(n,i,o)=>{const a=e.volumeTexture.getComponents(),s=o.getProperty().getIndependentComponents(),c=!!e.renderable.getCenterPoint(),l=e.renderable.getUseUniformOrientation(),f=e.renderable.isProjectionEnabled()&&e.renderable.getProjectionMode();return n.getProgram()===0||e.lastUseCenterPoint!==c||e.lastUseUniformOrientation!==l||e.lastProjectionMode!==f||e.lastHaveSeenDepthRequest!==e.haveSeenDepthRequest||e.lastTextureComponents!==a||e.lastIndependentComponents!==s?(e.lastUseCenterPoint=c,e.lastUseUniformOrientation=l,e.lastProjectionMode=f,e.lastHaveSeenDepthRequest=e.haveSeenDepthRequest,e.lastTextureComponents=a,e.lastIndependentComponents=s,!0):!1},t.buildShaders=(n,i,o)=>{t.getShaderTemplate(n,i,o),t.replaceShaderValues(n,i,o)},t.replaceShaderValues=(n,i,o)=>{let a=n.Vertex,s=n.Fragment;const c=["vec3 applyQuaternionToVec(vec4 q, vec3 v) {"," float uvx = q.y * v.z - q.z * v.y;"," float uvy = q.z * v.x - q.x * v.z;"," float uvz = q.x * v.y - q.y * v.x;"," float uuvx = q.y * uvz - q.z * uvy;"," float uuvy = q.z * uvx - q.x * uvz;"," float uuvz = q.x * uvy - q.y * uvx;"," float w2 = q.w * 2.0;"," uvx *= w2;"," uvy *= w2;"," uvz *= w2;"," uuvx *= 2.0;"," uuvy *= 2.0;"," uuvz *= 2.0;"," return vec3(v.x + uvx + uuvx, v.y + uvy + uuvy, v.z + uvz + uuvz);","}"];a=Be.substitute(a,"//VTK::Camera::Dec",["uniform mat4 MCPCMatrix;"]).result,a=Be.substitute(a,"//VTK::PositionVC::Impl",[" gl_Position = MCPCMatrix * vertexMC;"]).result;const l=["attribute vec3 centerlinePosition;","attribute float quadIndex;","uniform float width;","out vec2 quadOffsetVSOutput;","out vec3 centerlinePosVSOutput;"],f=e.renderable.isProjectionEnabled(),u=e.renderable.getUseUniformOrientation();u?(l.push("out vec3 samplingDirVSOutput;","uniform vec4 centerlineOrientation;","uniform vec3 tangentDirection;",...c),f&&l.push("out vec3 projectionDirVSOutput;","uniform vec3 bitangentDirection;")):l.push("out vec4 centerlineTopOrientationVSOutput;","out vec4 centerlineBotOrientationVSOutput;","attribute vec4 centerlineTopOrientation;","attribute vec4 centerlineBotOrientation;"),a=Be.substitute(a,"//VTK::Color::Dec",l).result;const d=["quadOffsetVSOutput = vec2(width * (mod(quadIndex, 2.0) == 0.0 ? -0.5 : 0.5), quadIndex > 1.0 ? 0.0 : 1.0);","centerlinePosVSOutput = centerlinePosition;"];u?(d.push("samplingDirVSOutput = applyQuaternionToVec(centerlineOrientation, tangentDirection);"),f&&d.push("projectionDirVSOutput = applyQuaternionToVec(centerlineOrientation, bitangentDirection);")):d.push("centerlineTopOrientationVSOutput = centerlineTopOrientation;","centerlineBotOrientationVSOutput = centerlineBotOrientation;"),a=Be.substitute(a,"//VTK::Color::Impl",d).result;const h=e.volumeTexture.getComponents(),g=o.getProperty().getIndependentComponents();let p=["uniform mat4 MCTCMatrix; // Model coordinates to texture coordinates","in vec2 quadOffsetVSOutput;","in vec3 centerlinePosVSOutput;","uniform highp sampler3D volumeTexture;","uniform sampler2D colorTexture1;","uniform sampler2D pwfTexture1;","uniform float opacity;","uniform vec4 backgroundColor;","uniform float cshift0;","uniform float cscale0;","uniform float pwfshift0;","uniform float pwfscale0;"];f&&p.push("uniform vec3 volumeSizeMC;","uniform int projectionSlabNumberOfSamples;","uniform float projectionConstantOffset;","uniform float projectionStepLength;"),u?(p.push("in vec3 samplingDirVSOutput;"),f&&p.push("in vec3 projectionDirVSOutput;")):(p.push("uniform vec3 tangentDirection;","in vec4 centerlineTopOrientationVSOutput;","in vec4 centerlineBotOrientationVSOutput;",...c),f&&p.push("uniform vec3 bitangentDirection;"));const v=e.renderable.getCenterPoint();if(v&&p.push("uniform vec3 globalCenterPoint;"),g){for(let m=1;m<h;m++)p=p.concat([`uniform float cshift${m};`,`uniform float cscale${m};`,`uniform float pwfshift${m};`,`uniform float pwfscale${m};`]);switch(h){case 1:p=p.concat(["uniform float mix0;","#define height0 0.5"]);break;case 2:p=p.concat(["uniform float mix0;","uniform float mix1;","#define height0 0.25","#define height1 0.75"]);break;case 3:p=p.concat(["uniform float mix0;","uniform float mix1;","uniform float mix2;","#define height0 0.17","#define height1 0.5","#define height2 0.83"]);break;case 4:p=p.concat(["uniform float mix0;","uniform float mix1;","uniform float mix2;","uniform float mix3;","#define height0 0.125","#define height1 0.375","#define height2 0.625","#define height3 0.875"]);break;default:s2("Unsupported number of independent coordinates.")}}s=Be.substitute(s,"//VTK::TCoord::Dec",p).result;let y=[];if(u?(y.push("vec3 samplingDirection = samplingDirVSOutput;"),f&&y.push("vec3 projectionDirection = projectionDirVSOutput;")):(y.push("vec4 q0 = centerlineBotOrientationVSOutput;","vec4 q1 = centerlineTopOrientationVSOutput;","float qCosAngle = dot(q0, q1);","vec4 interpolatedOrientation;","if (qCosAngle > 0.999 || qCosAngle < -0.999) {"," // Use LERP instead of SLERP when the two quaternions are close or opposite"," interpolatedOrientation = normalize(mix(q0, q1, quadOffsetVSOutput.y));","} else {"," float omega = acos(qCosAngle);"," interpolatedOrientation = normalize(sin((1.0 - quadOffsetVSOutput.y) * omega) * q0 + sin(quadOffsetVSOutput.y * omega) * q1);","}","vec3 samplingDirection = applyQuaternionToVec(interpolatedOrientation, tangentDirection);"),f&&y.push("vec3 projectionDirection = applyQuaternionToVec(interpolatedOrientation, bitangentDirection);")),v?y.push("float baseOffset = dot(samplingDirection, globalCenterPoint - centerlinePosVSOutput);","float horizontalOffset = quadOffsetVSOutput.x + baseOffset;"):y.push("float horizontalOffset = quadOffsetVSOutput.x;"),y.push("vec3 volumePosMC = centerlinePosVSOutput + horizontalOffset * samplingDirection;","vec3 volumePosTC = (MCTCMatrix * vec4(volumePosMC, 1.0)).xyz;","if (any(lessThan(volumePosTC, vec3(0.0))) || any(greaterThan(volumePosTC, vec3(1.0))))","{"," // set the background color and exit"," gl_FragData[0] = backgroundColor;"," return;","}"),f){const m=e.renderable.getProjectionMode();switch(m){case Pf.MIN:y.push("const vec4 initialProjectionTextureValue = vec4(1.0);");break;case Pf.MAX:case Pf.AVERAGE:default:y.push("const vec4 initialProjectionTextureValue = vec4(0.0);");break}switch(y.push("vec3 projectionScaledDirection = projectionDirection / volumeSizeMC;","vec3 projectionStep = projectionStepLength * projectionScaledDirection;","vec3 projectionStartPosition = volumePosTC + projectionConstantOffset * projectionScaledDirection;","vec4 tvalue = initialProjectionTextureValue;","for (int projectionSampleIdx = 0; projectionSampleIdx < projectionSlabNumberOfSamples; ++projectionSampleIdx) {"," vec3 projectionSamplePosition = projectionStartPosition + float(projectionSampleIdx) * projectionStep;"," vec4 sampledTextureValue = texture(volumeTexture, projectionSamplePosition);"),m){case Pf.MAX:y.push(" tvalue = max(tvalue, sampledTextureValue);");break;case Pf.MIN:y.push(" tvalue = min(tvalue, sampledTextureValue);");break;case Pf.AVERAGE:default:y.push(" tvalue = tvalue + sampledTextureValue;");break}y.push("}"),m===Pf.AVERAGE&&y.push("tvalue = tvalue / float(projectionSlabNumberOfSamples);")}else y.push("vec4 tvalue = texture(volumeTexture, volumePosTC);");if(g){const m=["r","g","b","a"];for(let w=0;w<h;++w)y=y.concat([`vec3 tcolor${w} = mix${w} * texture2D(colorTexture1, vec2(tvalue.${m[w]} * cscale${w} + cshift${w}, height${w})).rgb;`,`float compWeight${w} = mix${w} * texture2D(pwfTexture1, vec2(tvalue.${m[w]} * pwfscale${w} + pwfshift${w}, height${w})).r;`]);switch(h){case 1:y=y.concat(["gl_FragData[0] = vec4(tcolor0.rgb, compWeight0 * opacity);"]);break;case 2:y=y.concat(["float weightSum = compWeight0 + compWeight1;","gl_FragData[0] = vec4(vec3((tcolor0.rgb * (compWeight0 / weightSum)) + (tcolor1.rgb * (compWeight1 / weightSum))), opacity);"]);break;case 3:y=y.concat(["float weightSum = compWeight0 + compWeight1 + compWeight2;","gl_FragData[0] = vec4(vec3((tcolor0.rgb * (compWeight0 / weightSum)) + (tcolor1.rgb * (compWeight1 / weightSum)) + (tcolor2.rgb * (compWeight2 / weightSum))), opacity);"]);break;case 4:y=y.concat(["float weightSum = compWeight0 + compWeight1 + compWeight2 + compWeight3;","gl_FragData[0] = vec4(vec3((tcolor0.rgb * (compWeight0 / weightSum)) + (tcolor1.rgb * (compWeight1 / weightSum)) + (tcolor2.rgb * (compWeight2 / weightSum)) + (tcolor3.rgb * (compWeight3 / weightSum))), opacity);"]);break;default:s2("Unsupported number of independent coordinates.")}}else switch(h){case 1:y=y.concat(["// Dependent components","float intensity = tvalue.r;","vec3 tcolor = texture2D(colorTexture1, vec2(intensity * cscale0 + cshift0, 0.5)).rgb;","float scalarOpacity = texture2D(pwfTexture1, vec2(intensity * pwfscale0 + pwfshift0, 0.5)).r;","gl_FragData[0] = vec4(tcolor, scalarOpacity * opacity);"]);break;case 2:y=y.concat(["float intensity = tvalue.r*cscale0 + cshift0;","gl_FragData[0] = vec4(texture2D(colorTexture1, vec2(intensity, 0.5)).rgb, pwfscale0*tvalue.g + pwfshift0);"]);break;case 3:y=y.concat(["vec4 tcolor = cscale0*tvalue + cshift0;","gl_FragData[0] = vec4(texture2D(colorTexture1, vec2(tcolor.r,0.5)).r,"," texture2D(colorTexture1, vec2(tcolor.g,0.5)).r,"," texture2D(colorTexture1, vec2(tcolor.b,0.5)).r, opacity);"]);break;default:y=y.concat(["vec4 tcolor = cscale0*tvalue + cshift0;","gl_FragData[0] = vec4(texture2D(colorTexture1, vec2(tcolor.r,0.5)).r,"," texture2D(colorTexture1, vec2(tcolor.g,0.5)).r,"," texture2D(colorTexture1, vec2(tcolor.b,0.5)).r, tcolor.a);"])}s=Be.substitute(s,"//VTK::TCoord::Impl",y).result,e.haveSeenDepthRequest&&(s=Be.substitute(s,"//VTK::ZBuffer::Dec","uniform int depthRequest;").result,s=Be.substitute(s,"//VTK::ZBuffer::Impl",["if (depthRequest == 1) {","float iz = floor(gl_FragCoord.z*65535.0 + 0.1);","float rf = floor(iz/256.0)/255.0;","float gf = mod(iz,256.0)/255.0;","gl_FragData[0] = vec4(rf, gf, 0.0, 1.0); }"]).result),n.Vertex=a,n.Fragment=s,t.replaceShaderClip(n,i,o),t.replaceShaderCoincidentOffset(n,i,o)},t.replaceShaderClip=(n,i,o)=>{let a=n.Vertex,s=n.Fragment;if(e.renderable.getNumberOfClippingPlanes()){let c=e.renderable.getNumberOfClippingPlanes();c>6&&(Z.vtkErrorMacro("OpenGL has a limit of 6 clipping planes"),c=6),a=Be.substitute(a,"//VTK::Clip::Dec",["uniform int numClipPlanes;","uniform vec4 clipPlanes[6];","varying float clipDistancesVSOutput[6];"]).result,a=Be.substitute(a,"//VTK::Clip::Impl",["for (int planeNum = 0; planeNum < 6; planeNum++)"," {"," if (planeNum >= numClipPlanes)"," {"," break;"," }"," clipDistancesVSOutput[planeNum] = dot(clipPlanes[planeNum], vertexMC);"," }"]).result,s=Be.substitute(s,"//VTK::Clip::Dec",["uniform int numClipPlanes;","varying float clipDistancesVSOutput[6];"]).result,s=Be.substitute(s,"//VTK::Clip::Impl",["for (int planeNum = 0; planeNum < 6; planeNum++)"," {"," if (planeNum >= numClipPlanes)"," {"," break;"," }"," if (clipDistancesVSOutput[planeNum] < 0.0) discard;"," }"]).result}n.Vertex=a,n.Fragment=s},t.getShaderTemplate=(n,i,o)=>{n.Vertex=_4,n.Fragment=im,n.Geometry=""},t.setMapperShaderParameters=(n,i,o)=>{const a=n.getProgram(),s=n.getCABO();s.getElementCount()&&(e.VBOBuildTime.getMTime()>n.getAttributeUpdateTime().getMTime()||n.getShaderSourceTime().getMTime()>n.getAttributeUpdateTime().getMTime())&&(a.isAttributeUsed("vertexMC")&&(n.getVAO().addAttributeArray(a,s,"vertexMC",s.getVertexOffset(),s.getStride(),e.context.FLOAT,3,e.context.FALSE)||s2("Error setting vertexMC in shader VAO.")),n.getCABO().getCustomData().forEach(h=>{h&&a.isAttributeUsed(h.name)&&!n.getVAO().addAttributeArray(a,s,h.name,h.offset,s.getStride(),e.context.FLOAT,h.components,e.context.FALSE)&&s2(`Error setting ${h.name} in shader VAO.`)}),n.getAttributeUpdateTime().modified());const c=e.volumeTexture.getTextureUnit();if(a.setUniformi("volumeTexture",c),a.setUniformf("width",e.renderable.getWidth()),n.getProgram().setUniform4fv("backgroundColor",e.renderable.getBackgroundColor()),a.isUniformUsed("tangentDirection")){const h=e.renderable.getTangentDirection();n.getProgram().setUniform3fArray("tangentDirection",h)}if(a.isUniformUsed("bitangentDirection")){const h=e.renderable.getBitangentDirection();n.getProgram().setUniform3fArray("bitangentDirection",h)}if(a.isUniformUsed("centerlineOrientation")){const h=e.renderable.getUniformOrientation();n.getProgram().setUniform4fv("centerlineOrientation",h)}if(a.isUniformUsed("globalCenterPoint")){const h=e.renderable.getCenterPoint();a.setUniform3fArray("globalCenterPoint",h)}if(e.renderable.isProjectionEnabled()){const h=e.currentImageDataInput,g=h.getSpacing(),p=h.getDimensions(),v=e.renderable.getProjectionSlabThickness(),y=e.renderable.getProjectionSlabNumberOfSamples(),m=$Y([],g,p);a.setUniform3fArray("volumeSizeMC",m),a.setUniformi("projectionSlabNumberOfSamples",y);const w=-.5*v;a.setUniformf("projectionConstantOffset",w);const x=v/(y-1);a.setUniformf("projectionStepLength",x)}const l=e.currentImageDataInput,f=l.getWorldToIndex(),u=r4(new Float32Array(16),KR([],l.getDimensions())),d=Cy(u,u,f);if(a.setUniformMatrix("MCTCMatrix",d),e.haveSeenDepthRequest&&n.getProgram().setUniformi("depthRequest",e.renderDepth?1:0),e.renderable.getNumberOfClippingPlanes()){let h=e.renderable.getNumberOfClippingPlanes();h>6&&(Z.vtkErrorMacro("OpenGL has a limit of 6 clipping planes"),h=6);const p=s.getCoordShiftAndScaleEnabled()?s.getInverseShiftAndScaleMatrix():null,v=p?Cr(e.imagematinv,o.getMatrix()):o.getMatrix();p&&(un(v,v),yn(v,v,p),un(v,v)),un(e.imagemat,e.currentImageDataInput.getIndexToWorld()),yn(e.imagematinv,v,e.imagemat);const y=[];for(let m=0;m<h;m++){const w=[];e.renderable.getClippingPlaneInDataCoords(e.imagematinv,m,w);for(let x=0;x<4;x++)y.push(w[x])}a.setUniformi("numClipPlanes",h),a.setUniform4fv("clipPlanes",y)}if(a.isUniformUsed("coffset")){const h=t.getCoincidentParameters(i,o);a.setUniformf("coffset",h.offset),a.isUniformUsed("cfactor")&&a.setUniformf("cfactor",h.factor)}},t.setCameraShaderParameters=(n,i,o)=>{const a=e.openGLImageSlice.getKeyMatrices().mcwc,s=e.openGLCamera.getKeyMatrices(i).wcpc;if(yn(e.imagemat,s,a),n.getCABO().getCoordShiftAndScaleEnabled()){const c=n.getCABO().getInverseShiftAndScaleMatrix();yn(e.imagemat,e.imagemat,c)}n.getProgram().setUniformMatrix("MCPCMatrix",e.imagemat)},t.setPropertyShaderParameters=(n,i,o)=>{const a=n.getProgram(),s=o.getProperty(),c=s.getOpacity();a.setUniformf("opacity",c);const l=e.volumeTexture.getComponents(),f=s.getIndependentComponents();if(f)for(let g=0;g<l;++g)a.setUniformf(`mix${g}`,s.getComponentWeight(g));const u=e.volumeTexture.getVolumeInfo();for(let g=0;g<l;g++){let p=s.getColorWindow(),v=s.getColorLevel();const y=f?g:0,m=s.getRGBTransferFunction(y);if(m&&s.getUseLookupTableScalarRange()){const C=m.getRange();p=C[1]-C[0],v=.5*(C[1]+C[0])}const w=u.scale[g]/p,x=(u.offset[g]-v)/p+.5;a.setUniformf(`cshift${g}`,x),a.setUniformf(`cscale${g}`,w)}const d=e.colorTexture.getTextureUnit();a.setUniformi("colorTexture1",d);for(let g=0;g<l;g++){let p=1,v=0;const y=f?g:0,m=s.getPiecewiseFunction(y);if(m){const w=m.getRange(),x=w[1]-w[0],C=.5*(w[0]+w[1]);p=u.scale[g]/x,v=(u.offset[g]-C)/x+.5}a.setUniformf(`pwfshift${g}`,v),a.setUniformf(`pwfscale${g}`,p)}const h=e.pwfTexture.getTextureUnit();a.setUniformi("pwfTexture1",h)},t.updateShaders=(n,i,o)=>{if(t.getNeedToRebuildShaders(n,i,o)){const a={Vertex:null,Fragment:null,Geometry:null};t.buildShaders(a,i,o);const s=e._openGLRenderWindow.getShaderCache().readyShaderProgramArray(a.Vertex,a.Fragment,a.Geometry);s!==n.getProgram()&&(n.setProgram(s),n.getVAO().releaseGraphicsResources()),n.getShaderSourceTime().modified()}else e._openGLRenderWindow.getShaderCache().readyShaderProgram(n.getProgram());n.getVAO().bind(),t.setMapperShaderParameters(n,i,o),t.setCameraShaderParameters(n,i,o),t.setPropertyShaderParameters(n,i,o)},t.delete=Z.chain(()=>{e._openGLRenderWindow&&r(e._openGLRenderWindow)},t.delete)}const Vee={currentRenderPass:null,volumeTexture:null,colorTexture:null,pwfTexture:null,tris:null,lastHaveSeenDepthRequest:!1,haveSeenDepthRequest:!1,lastTextureComponents:0,lastIndependentComponents:0,imagemat:null,imagematinv:null};function Fee(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Vee,r),Qn.extend(t,e,r),rl.implementReplaceShaderCoincidentOffset(t,e,r),Z.algo(t,e,2,0),e.tris=ul.newInstance(),e.volumeTexture=null,e.colorTexture=null,e.pwfTexture=null,e.imagemat=It(new Float64Array(16)),e.imagematinv=It(new Float64Array(16)),e.VBOBuildTime={},Z.obj(e.VBOBuildTime,{mtime:0}),kee(t,e)}const vA=Z.newInstance(Fee,"vtkOpenGLImageCPRMapper"),Uee={};var Bee={newInstance:vA,...Uee};di("vtkImageCPRMapper",vA);function Gee(t,e){e.classHierarchy.push("vtkOpenGLImageSlice"),t.buildPass=r=>{if(!(!e.renderable||!e.renderable.getVisibility())&&r){if(!e.renderable)return;e._openGLRenderWindow=t.getLastAncestorOfType("vtkOpenGLRenderWindow"),e._openGLRenderer=t.getFirstAncestorOfType("vtkOpenGLRenderer"),e.context=e._openGLRenderWindow.getContext(),t.prepareNodes(),t.addMissingNode(e.renderable.getMapper()),t.removeUnusedNodes()}},t.traverseZBufferPass=r=>{!e.renderable||!e.renderable.getNestedVisibility()||e._openGLRenderer.getSelector()&&!e.renderable.getNestedPickable()||(t.apply(r,!0),e.children.forEach(n=>{n.traverse(r)}),t.apply(r,!1))},t.traverseOpaqueZBufferPass=r=>t.traverseOpaquePass(r),t.traverseOpaquePass=r=>{!e.renderable||!e.renderable.getNestedVisibility()||!e.renderable.getIsOpaque()||e._openGLRenderer.getSelector()&&!e.renderable.getNestedPickable()||(t.apply(r,!0),e.children.forEach(n=>{n.traverse(r)}),t.apply(r,!1))},t.traverseTranslucentPass=r=>{!e.renderable||!e.renderable.getNestedVisibility()||e.renderable.getIsOpaque()||e._openGLRenderer.getSelector()&&!e.renderable.getNestedPickable()||(t.apply(r,!0),e.children.forEach(n=>{n.traverse(r)}),t.apply(r,!1))},t.queryPass=(r,n)=>{if(r){if(!e.renderable||!e.renderable.getVisibility())return;e.renderable.getIsOpaque()?n.incrementOpaqueActorCount():n.incrementTranslucentActorCount()}},t.zBufferPass=(r,n)=>t.opaquePass(r,n),t.opaqueZBufferPass=(r,n)=>t.opaquePass(r,n),t.opaquePass=(r,n)=>{r&&e.context.depthMask(!0)},t.translucentPass=(r,n)=>{e.context.depthMask(!r)},t.getKeyMatrices=()=>(e.renderable.getMTime()>e.keyMatrixTime.getMTime()&&(Cr(e.keyMatrices.mcwc,e.renderable.getMatrix()),un(e.keyMatrices.mcwc,e.keyMatrices.mcwc),e.keyMatrixTime.modified()),e.keyMatrices)}const Wee={context:null,keyMatrixTime:null,keyMatrices:null};function zee(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Wee,r),Qn.extend(t,e,r),e.keyMatrixTime={},or(e.keyMatrixTime,{mtime:0}),e.keyMatrices={mcwc:It(new Float64Array(16))},Jr(t,e,["context"]),Gee(t,e)}const yA=Rn(zee,"vtkOpenGLImageSlice");var $ee={newInstance:yA};di("vtkImageSlice",yA);const{vtkDebugMacro:jee}=uo;function Hee(t,e){e.classHierarchy.push("vtkOpenGLPixelSpaceCallbackMapper"),t.opaquePass=(r,n)=>{e._openGLRenderer=t.getFirstAncestorOfType("vtkOpenGLRenderer"),e._openGLRenderWindow=e._openGLRenderer.getLastAncestorOfType("vtkOpenGLRenderWindow");const i=e._openGLRenderer.getAspectRatio(),o=e._openGLRenderer?e._openGLRenderer.getRenderable().getActiveCamera():null,a=e._openGLRenderer.getTiledSizeAndOrigin();let s=null;if(e.renderable.getUseZValues()){const c=n.getZBufferTexture(),l=Math.floor(c.getWidth()),f=Math.floor(c.getHeight()),u=e._openGLRenderWindow.getContext();c.bind();const d=n.getFramebuffer();d?d.saveCurrentBindingsAndBuffers():jee("No framebuffer to save/restore");const h=u.createFramebuffer();u.bindFramebuffer(u.FRAMEBUFFER,h),u.framebufferTexture2D(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0,u.TEXTURE_2D,c.getHandle(),0),u.checkFramebufferStatus(u.FRAMEBUFFER)===u.FRAMEBUFFER_COMPLETE&&(s=new Uint8Array(l*f*4),u.viewport(0,0,l,f),u.readPixels(0,0,l,f,u.RGBA,u.UNSIGNED_BYTE,s)),d&&d.restorePreviousBindingsAndBuffers(),u.deleteFramebuffer(h)}e.renderable.invokeCallback(e.renderable.getInputData(),o,i,a,s)},t.queryPass=(r,n)=>{r&&e.renderable.getUseZValues()&&n.requestDepth()}}const Kee={};function qee(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Kee,r),Qn.extend(t,e,r),Hee(t,e)}const wA=Rn(qee,"vtkOpenGLPixelSpaceCallbackMapper");var Xee={newInstance:wA};di("vtkPixelSpaceCallbackMapper",wA);const{vtkDebugMacro:Yee}=uo;function Jee(t,e){e.classHierarchy.push("vtkOpenGLRenderer"),t.buildPass=r=>{if(r){if(!e.renderable)return;t.updateLights(),t.prepareNodes(),t.addMissingNode(e.renderable.getActiveCamera()),t.addMissingNodes(e.renderable.getViewPropsWithNestedProps()),t.removeUnusedNodes()}},t.updateLights=()=>{let r=0;const n=e.renderable.getLightsByReference();for(let i=0;i<n.length;++i)n[i].getSwitch()>0&&r++;return r||(Yee("No lights are on, creating one."),e.renderable.createLight()),r},t.zBufferPass=r=>{if(r){let n=0;const i=e.context;e.renderable.getTransparent()||(e.context.clearColor(1,0,0,1),n|=i.COLOR_BUFFER_BIT),e.renderable.getPreserveDepthBuffer()||(i.clearDepth(1),n|=i.DEPTH_BUFFER_BIT,e.context.depthMask(!0));const o=t.getTiledSizeAndOrigin();i.enable(i.SCISSOR_TEST),i.scissor(o.lowerLeftU,o.lowerLeftV,o.usize,o.vsize),i.viewport(o.lowerLeftU,o.lowerLeftV,o.usize,o.vsize),i.colorMask(!0,!0,!0,!0),n&&i.clear(n),i.enable(i.DEPTH_TEST)}},t.opaqueZBufferPass=r=>t.zBufferPass(r),t.cameraPass=r=>{r&&t.clear()},t.getAspectRatio=()=>{const r=e._parent.getSizeByReference(),n=e.renderable.getViewportByReference();return r[0]*(n[2]-n[0])/((n[3]-n[1])*r[1])},t.getTiledSizeAndOrigin=()=>{const r=e.renderable.getViewportByReference(),n=[0,0,1,1],i=r[0]-n[0],o=r[1]-n[1],a=e._parent.normalizedDisplayToDisplay(i,o),s=Math.round(a[0]),c=Math.round(a[1]),l=r[2]-n[0],f=r[3]-n[1],u=e._parent.normalizedDisplayToDisplay(l,f);let d=Math.round(u[0])-s,h=Math.round(u[1])-c;return d<0&&(d=0),h<0&&(h=0),{usize:d,vsize:h,lowerLeftU:s,lowerLeftV:c}},t.clear=()=>{let r=0;const n=e.context;if(!e.renderable.getTransparent()){const o=e.renderable.getBackgroundByReference();n.clearColor(o[0],o[1],o[2],o[3]),r|=n.COLOR_BUFFER_BIT}e.renderable.getPreserveDepthBuffer()||(n.clearDepth(1),r|=n.DEPTH_BUFFER_BIT,n.depthMask(!0)),n.colorMask(!0,!0,!0,!0);const i=t.getTiledSizeAndOrigin();n.enable(n.SCISSOR_TEST),n.scissor(i.lowerLeftU,i.lowerLeftV,i.usize,i.vsize),n.viewport(i.lowerLeftU,i.lowerLeftV,i.usize,i.vsize),r&&n.clear(r),n.enable(n.DEPTH_TEST)},t.releaseGraphicsResources=()=>{e.selector!==null&&e.selector.releaseGraphicsResources(),e.renderable&&e.renderable.getViewProps().forEach(r=>{r.modified()})},t.setOpenGLRenderWindow=r=>{e._openGLRenderWindow!==r&&(t.releaseGraphicsResources(),e._openGLRenderWindow=r,e.context=null,r&&(e.context=e._openGLRenderWindow.getContext()))}}const Zee={context:null,_openGLRenderWindow:null,selector:null};function Qee(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Zee,r),Qn.extend(t,e,r),Ro(t,e,["shaderCache"]),Jr(t,e,["selector"]),X1(t,e,["openGLRenderWindow"]),Jee(t,e)}const xA=Rn(Qee,"vtkOpenGLRenderer");var ete={newInstance:xA};di("vtkRenderer",xA);const{vtkErrorMacro:wD}=uo;function tte(t,e){e.classHierarchy.push("vtkOpenGLSkybox"),t.buildPass=r=>{if(r){e._openGLRenderer=t.getFirstAncestorOfType("vtkOpenGLRenderer"),e._openGLRenderWindow=e._openGLRenderer.getParent(),e.context=e._openGLRenderWindow.getContext(),e.tris.setOpenGLRenderWindow(e._openGLRenderWindow),e.openGLTexture.setOpenGLRenderWindow(e._openGLRenderWindow);const n=e._openGLRenderer.getRenderable();e.openGLCamera=e._openGLRenderer.getViewNodeFor(n.getActiveCamera())}},t.queryPass=(r,n)=>{if(r){if(!e.renderable||!e.renderable.getVisibility())return;n.incrementOpaqueActorCount()}},t.opaquePass=(r,n)=>{if(r&&!e._openGLRenderer.getSelector()){t.updateBufferObjects(),e.context.depthMask(!0),e._openGLRenderWindow.getShaderCache().readyShaderProgram(e.tris.getProgram()),e.openGLTexture.render(e._openGLRenderWindow);const i=e.openGLTexture.getTextureUnit();e.tris.getProgram().setUniformi("sbtexture",i);const o=e._openGLRenderer.getRenderable(),a=e.openGLCamera.getKeyMatrices(o),s=new Float64Array(16);if(Ar(s,a.wcpc),e.tris.getProgram().setUniformMatrix("IMCPCMatrix",s),e.lastFormat==="box"){const c=o.getActiveCamera().getPosition();e.tris.getProgram().setUniform3f("camPos",c[0],c[1],c[2])}e.tris.getVAO().bind(),e.context.drawArrays(e.context.TRIANGLES,0,e.tris.getCABO().getElementCount()),e.tris.getVAO().release(),e.openGLTexture.deactivate()}},t.updateBufferObjects=()=>{if(!e.tris.getCABO().getElementCount()){const n=new Float32Array(12);for(let s=0;s<4;s++)n[s*3]=s%2*2-1,n[s*3+1]=s>1?1:-1,n[s*3+2]=1;const i=bt.newInstance({numberOfComponents:3,values:n});i.setName("points");const o=new Uint16Array(8);o[0]=3,o[1]=0,o[2]=1,o[3]=3,o[4]=3,o[5]=0,o[6]=3,o[7]=2;const a=bt.newInstance({numberOfComponents:1,values:o});e.tris.getCABO().createVBO(a,"polys",ao.SURFACE,{points:i,cellOffset:0})}e.renderable.getFormat()!==e.lastFormat&&(e.lastFormat=e.renderable.getFormat(),e.lastFormat==="box"&&e.tris.setProgram(e._openGLRenderWindow.getShaderCache().readyShaderProgramArray(`//VTK::System::Dec
|
||
attribute vec3 vertexMC;
|
||
uniform mat4 IMCPCMatrix;
|
||
varying vec3 TexCoords;
|
||
void main () {
|
||
gl_Position = vec4(vertexMC.xyz, 1.0);
|
||
vec4 wpos = IMCPCMatrix * gl_Position;
|
||
TexCoords = wpos.xyz/wpos.w;
|
||
}`,`//VTK::System::Dec
|
||
//VTK::Output::Dec
|
||
varying vec3 TexCoords;
|
||
uniform samplerCube sbtexture;
|
||
uniform vec3 camPos;
|
||
void main () {
|
||
// skybox looks from inside out
|
||
// which means we have to adjust
|
||
// our tcoords. Otherwise text would
|
||
// be flipped
|
||
vec3 tc = normalize(TexCoords - camPos);
|
||
if (abs(tc.z) < max(abs(tc.x),abs(tc.y)))
|
||
{
|
||
tc = vec3(1.0, 1.0, -1.0) * tc;
|
||
}
|
||
else
|
||
{
|
||
tc = vec3(-1.0, 1.0, 1.0) * tc;
|
||
}
|
||
gl_FragData[0] = textureCube(sbtexture, tc);
|
||
}`,"")),e.lastFormat==="background"&&e.tris.setProgram(e._openGLRenderWindow.getShaderCache().readyShaderProgramArray(`//VTK::System::Dec
|
||
attribute vec3 vertexMC;
|
||
uniform mat4 IMCPCMatrix;
|
||
varying vec2 TexCoords;
|
||
void main () {
|
||
gl_Position = vec4(vertexMC.xyz, 1.0);
|
||
vec4 wpos = IMCPCMatrix * gl_Position;
|
||
TexCoords = vec2(vertexMC.x, vertexMC.y)*0.5 + 0.5;
|
||
}`,`//VTK::System::Dec
|
||
//VTK::Output::Dec
|
||
varying vec2 TexCoords;
|
||
uniform sampler2D sbtexture;
|
||
void main () {
|
||
gl_FragData[0] = texture2D(sbtexture, TexCoords);
|
||
}`,"")),e.tris.getShaderSourceTime().modified(),e.tris.getVAO().bind(),e.tris.getVAO().addAttributeArray(e.tris.getProgram(),e.tris.getCABO(),"vertexMC",e.tris.getCABO().getVertexOffset(),e.tris.getCABO().getStride(),e.context.FLOAT,3,e.context.FALSE)||wD("Error setting vertexMC in shader VAO."));const r=e.renderable.getTextures();r.length||wD("vtkSkybox requires a texture map"),e.openGLTexture.getRenderable()!==r[0]&&(e.openGLTexture.releaseGraphicsResources(e._openGLRenderWindow),e.openGLTexture.setRenderable(r[0]))}}const nte={context:null};function rte(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,nte,r),Qn.extend(t,e,r),e.openGLTexture=mr.newInstance(),e.tris=ul.newInstance(),e.keyMatrixTime={},or(e.keyMatrixTime,{mtime:0}),e.keyMatrices={normalMatrix:ys(new Float64Array(9)),mcwc:It(new Float64Array(16))},Jr(t,e,["context"]),Ro(t,e,["activeTextures"]),tte(t,e)}const CA=Rn(rte);var ite={newInstance:CA};di("vtkSkybox",CA);var ote=`//VTK::System::Dec
|
||
|
||
/*=========================================================================
|
||
|
||
Program: Visualization Toolkit
|
||
Module: vtkSphereMapperVS.glsl
|
||
|
||
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
|
||
All rights reserved.
|
||
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
|
||
|
||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||
PURPOSE. See the above copyright notice for more information.
|
||
|
||
=========================================================================*/
|
||
// this shader implements imposters in OpenGL for Spheres
|
||
|
||
attribute vec4 vertexMC;
|
||
attribute vec2 offsetMC;
|
||
|
||
// optional normal declaration
|
||
//VTK::Normal::Dec
|
||
|
||
//VTK::Picking::Dec
|
||
|
||
// Texture coordinates
|
||
//VTK::TCoord::Dec
|
||
|
||
uniform mat3 normalMatrix; // transform model coordinate directions to view coordinates
|
||
|
||
// material property values
|
||
//VTK::Color::Dec
|
||
|
||
// clipping plane vars
|
||
//VTK::Clip::Dec
|
||
|
||
// camera and actor matrix values
|
||
//VTK::Camera::Dec
|
||
|
||
varying vec4 vertexVCVSOutput;
|
||
varying float radiusVCVSOutput;
|
||
varying vec3 centerVCVSOutput;
|
||
|
||
uniform int cameraParallel;
|
||
uniform float scaleFactor;
|
||
|
||
void main()
|
||
{
|
||
//VTK::Picking::Impl
|
||
|
||
//VTK::Color::Impl
|
||
|
||
//VTK::Normal::Impl
|
||
|
||
//VTK::TCoord::Impl
|
||
|
||
//VTK::Clip::Impl
|
||
|
||
// compute the projected vertex position
|
||
vec2 scaledOffsetMC = scaleFactor * offsetMC;
|
||
vertexVCVSOutput = MCVCMatrix * vertexMC;
|
||
centerVCVSOutput = vertexVCVSOutput.xyz;
|
||
radiusVCVSOutput = length(scaledOffsetMC)*0.5;
|
||
|
||
// make the triangle face the camera
|
||
if (cameraParallel == 0)
|
||
{
|
||
vec3 dir = normalize(-vertexVCVSOutput.xyz);
|
||
vec3 base2 = normalize(cross(dir,vec3(1.0,0.0,0.0)));
|
||
vec3 base1 = cross(base2,dir);
|
||
vertexVCVSOutput.xyz = vertexVCVSOutput.xyz + scaledOffsetMC.x*base1 + scaledOffsetMC.y*base2;
|
||
}
|
||
else
|
||
{
|
||
// add in the offset
|
||
vertexVCVSOutput.xy = vertexVCVSOutput.xy + scaledOffsetMC;
|
||
}
|
||
|
||
gl_Position = VCPCMatrix * vertexVCVSOutput;
|
||
}
|
||
`;const{vtkErrorMacro:ate}=uo;function ste(t,e){e.classHierarchy.push("vtkOpenGLSphereMapper");const r={...t};t.getShaderTemplate=(n,i,o)=>{n.Vertex=ote,n.Fragment=im,n.Geometry=""},t.replaceShaderValues=(n,i,o)=>{let a=n.Vertex,s=n.Fragment;a=Be.substitute(a,"//VTK::Camera::Dec",[`uniform mat4 VCPCMatrix;
|
||
`,"uniform mat4 MCVCMatrix;"]).result,s=Be.substitute(s,"//VTK::PositionVC::Dec",["varying vec4 vertexVCVSOutput;"]).result,s=Be.substitute(s,"//VTK::PositionVC::Impl",[`vec4 vertexVC = vertexVCVSOutput;
|
||
`]).result;const c=[`uniform float invertedDepth;
|
||
`,`uniform int cameraParallel;
|
||
`,`varying float radiusVCVSOutput;
|
||
`,`varying vec3 centerVCVSOutput;
|
||
`,`uniform mat4 VCPCMatrix;
|
||
`];s=Be.substitute(s,"//VTK::Normal::Dec",c).result;let l="";e.context.getExtension("EXT_frag_depth")&&(l=`gl_FragDepthEXT = (pos.z / pos.w + 1.0) / 2.0;
|
||
`),e._openGLRenderWindow.getWebgl2()&&(l=`gl_FragDepth = (pos.z / pos.w + 1.0) / 2.0;
|
||
`),s=Be.substitute(s,"//VTK::Depth::Impl",[` vec3 EyePos;
|
||
`,` vec3 EyeDir;
|
||
`,` if (cameraParallel != 0) {
|
||
`,` EyePos = vec3(vertexVC.x, vertexVC.y, vertexVC.z + 3.0*radiusVCVSOutput);
|
||
`,` EyeDir = vec3(0.0,0.0,-1.0); }
|
||
`,` else {
|
||
`,` EyeDir = vertexVC.xyz;
|
||
`,` EyePos = vec3(0.0,0.0,0.0);
|
||
`,` float lengthED = length(EyeDir);
|
||
`,` EyeDir = normalize(EyeDir);
|
||
`,` if (lengthED > radiusVCVSOutput*3.0) {
|
||
`,` EyePos = vertexVC.xyz - EyeDir*3.0*radiusVCVSOutput; }
|
||
`,` }
|
||
`,` EyePos = EyePos - centerVCVSOutput;
|
||
`,` EyePos = EyePos/radiusVCVSOutput;
|
||
`,` float b = 2.0*dot(EyePos,EyeDir);
|
||
`,` float c = dot(EyePos,EyePos) - 1.0;
|
||
`,` float d = b*b - 4.0*c;
|
||
`,` vec3 normalVCVSOutput = vec3(0.0,0.0,1.0);
|
||
`,` if (d < 0.0) { discard; }
|
||
`,` else {
|
||
`,` float t = (-b - invertedDepth*sqrt(d))*0.5;
|
||
`,` normalVCVSOutput = invertedDepth*normalize(EyePos + t*EyeDir);
|
||
`,` vertexVC.xyz = normalVCVSOutput*radiusVCVSOutput + centerVCVSOutput;
|
||
`,` }
|
||
`,` vec4 pos = VCPCMatrix * vertexVC;
|
||
`,l]).result,s=Be.substitute(s,"//VTK::Normal::Impl","").result,e.haveSeenDepthRequest&&(s=Be.substitute(s,"//VTK::ZBuffer::Impl",["if (depthRequest == 1) {","float computedZ = (pos.z / pos.w + 1.0) / 2.0;","float iz = floor(computedZ * 65535.0 + 0.1);","float rf = floor(iz/256.0)/255.0;","float gf = mod(iz,256.0)/255.0;","gl_FragData[0] = vec4(rf, gf, 0.0, 1.0); }"]).result),n.Vertex=a,n.Fragment=s,r.replaceShaderValues(n,i,o)},t.setMapperShaderParameters=(n,i,o)=>{if(n.getCABO().getElementCount()&&(e.VBOBuildTime>n.getAttributeUpdateTime().getMTime()||n.getShaderSourceTime().getMTime()>n.getAttributeUpdateTime().getMTime())&&n.getProgram().isAttributeUsed("offsetMC")&&(n.getVAO().addAttributeArray(n.getProgram(),n.getCABO(),"offsetMC",12,n.getCABO().getStride(),e.context.FLOAT,2,!1)||ate("Error setting 'offsetMC' in shader VAO.")),n.getProgram().isUniformUsed("invertedDepth")&&n.getProgram().setUniformf("invertedDepth",e.invert?-1:1),n.getProgram().isUniformUsed("scaleFactor")){const s=e.currentInput.getPointData();e.renderable.getScaleArray()!=null&&s.hasArray(e.renderable.getScaleArray())?n.getProgram().setUniformf("scaleFactor",e.renderable.getScaleFactor()):n.getProgram().setUniformf("scaleFactor",1)}r.setMapperShaderParameters(n,i,o)},t.setCameraShaderParameters=(n,i,o)=>{const a=n.getProgram(),s=i.getActiveCamera(),c=e.openGLCamera.getKeyMatrices(i);if(a.isUniformUsed("VCPCMatrix")&&a.setUniformMatrix("VCPCMatrix",c.vcpc),a.isUniformUsed("MCVCMatrix"))if(o.getIsIdentity())a.setUniformMatrix("MCVCMatrix",c.wcvc);else{const l=e.openGLActor.getKeyMatrices(),f=new Float64Array(16);yn(f,c.wcvc,l.mcwc),a.setUniformMatrix("MCVCMatrix",f)}a.isUniformUsed("cameraParallel")&&n.getProgram().setUniformi("cameraParallel",s.getParallelProjection())},t.getOpenGLMode=(n,i)=>e.context.TRIANGLES,t.buildBufferObjects=(n,i)=>{const o=e.currentInput;if(o===null)return;e.renderable.mapScalars(o,1);const a=e.renderable.getColorMapColors(),s=e.primitives[e.primTypes.Tris].getCABO(),c=o.getPointData(),l=o.getPoints(),f=l.getNumberOfPoints(),u=l.getData(),d=5;let h=null;e.renderable.getScaleArray()!=null&&c.hasArray(e.renderable.getScaleArray())&&(h=c.getArray(e.renderable.getScaleArray()).getData());let g=null,p=0,v=null;a?(p=a.getNumberOfComponents(),s.setColorOffset(0),s.setColorBOStride(4),g=a.getData(),v=new Uint8Array(3*f*4),s.getColorBO()||s.setColorBO(Bl.newInstance()),s.getColorBO().setOpenGLRenderWindow(e._openGLRenderWindow)):s.getColorBO()&&s.setColorBO(null),s.setColorComponents(p);const y=new Float32Array(d*f*3);s.setStride(d*4);const m=Math.cos(Gr(30));let w=0,x=0,C=0,S=0;for(let T=0;T<f;++T){let _=e.renderable.getRadius();h&&(_=h[T]),w=T*3,y[C++]=u[w++],y[C++]=u[w++],y[C++]=u[w++],y[C++]=-2*_*m,y[C++]=-_,g&&(x=T*p,v[S++]=g[x],v[S++]=g[x+1],v[S++]=g[x+2],v[S++]=g[x+3]),w=T*3,y[C++]=u[w++],y[C++]=u[w++],y[C++]=u[w++],y[C++]=2*_*m,y[C++]=-_,g&&(v[S++]=g[x],v[S++]=g[x+1],v[S++]=g[x+2],v[S++]=g[x+3]),w=T*3,y[C++]=u[w++],y[C++]=u[w++],y[C++]=u[w++],y[C++]=0,y[C++]=2*_,g&&(v[S++]=g[x],v[S++]=g[x+1],v[S++]=g[x+2],v[S++]=g[x+3])}s.setElementCount(C/d),s.upload(y,jl.ARRAY_BUFFER),a&&s.getColorBO().upload(v,jl.ARRAY_BUFFER),e.VBOBuildTime.modified()}}const cte={};function lte(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,cte,r),uw.extend(t,e,r),ste(t,e)}const SA=Rn(lte,"vtkOpenGLSphereMapper");var ute={newInstance:SA};di("vtkSphereMapper",SA);var fte=`//VTK::System::Dec
|
||
|
||
/*=========================================================================
|
||
|
||
Program: Visualization Toolkit
|
||
Module: vtkStickMapperVS.glsl
|
||
|
||
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
|
||
All rights reserved.
|
||
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
|
||
|
||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||
PURPOSE. See the above copyright notice for more information.
|
||
|
||
=========================================================================*/
|
||
// this shader implements imposters in OpenGL for Sticks
|
||
|
||
attribute vec4 vertexMC;
|
||
attribute vec3 orientMC;
|
||
attribute vec4 offsetMC;
|
||
attribute float radiusMC;
|
||
|
||
// optional normal declaration
|
||
//VTK::Normal::Dec
|
||
|
||
//VTK::Picking::Dec
|
||
|
||
// Texture coordinates
|
||
//VTK::TCoord::Dec
|
||
|
||
uniform mat3 normalMatrix; // transform model coordinate directions to view coordinates
|
||
|
||
// material property values
|
||
//VTK::Color::Dec
|
||
|
||
// clipping plane vars
|
||
//VTK::Clip::Dec
|
||
|
||
// camera and actor matrix values
|
||
//VTK::Camera::Dec
|
||
|
||
varying vec4 vertexVCVSOutput;
|
||
varying float radiusVCVSOutput;
|
||
varying float lengthVCVSOutput;
|
||
varying vec3 centerVCVSOutput;
|
||
varying vec3 orientVCVSOutput;
|
||
|
||
uniform int cameraParallel;
|
||
|
||
void main()
|
||
{
|
||
//VTK::Picking::Impl
|
||
|
||
//VTK::Color::Impl
|
||
|
||
//VTK::Normal::Impl
|
||
|
||
//VTK::TCoord::Impl
|
||
|
||
//VTK::Clip::Impl
|
||
|
||
vertexVCVSOutput = MCVCMatrix * vertexMC;
|
||
centerVCVSOutput = vertexVCVSOutput.xyz;
|
||
radiusVCVSOutput = radiusMC;
|
||
lengthVCVSOutput = length(orientMC);
|
||
orientVCVSOutput = normalMatrix * normalize(orientMC);
|
||
|
||
// make sure it is pointing out of the screen
|
||
if (orientVCVSOutput.z < 0.0)
|
||
{
|
||
orientVCVSOutput = -orientVCVSOutput;
|
||
}
|
||
|
||
// make the basis
|
||
vec3 xbase;
|
||
vec3 ybase;
|
||
vec3 dir = vec3(0.0,0.0,1.0);
|
||
if (cameraParallel == 0)
|
||
{
|
||
dir = normalize(-vertexVCVSOutput.xyz);
|
||
}
|
||
if (abs(dot(dir,orientVCVSOutput)) == 1.0)
|
||
{
|
||
xbase = normalize(cross(vec3(0.0,1.0,0.0),orientVCVSOutput));
|
||
ybase = cross(xbase,orientVCVSOutput);
|
||
}
|
||
else
|
||
{
|
||
xbase = normalize(cross(orientVCVSOutput,dir));
|
||
ybase = cross(orientVCVSOutput,xbase);
|
||
}
|
||
|
||
vec3 offsets = offsetMC.xyz*2.0-1.0;
|
||
vertexVCVSOutput.xyz = vertexVCVSOutput.xyz +
|
||
radiusVCVSOutput*offsets.x*xbase +
|
||
radiusVCVSOutput*offsets.y*ybase +
|
||
0.5*lengthVCVSOutput*offsets.z*orientVCVSOutput;
|
||
|
||
gl_Position = VCPCMatrix * vertexVCVSOutput;
|
||
}
|
||
`;const{vtkErrorMacro:c2}=uo;function dte(t,e){e.classHierarchy.push("vtkOpenGLStickMapper");const r={...t};t.getShaderTemplate=(n,i,o)=>{n.Vertex=fte,n.Fragment=im,n.Geometry=""},t.replaceShaderValues=(n,i,o)=>{let a=n.Vertex,s=n.Fragment;a=Be.substitute(a,"//VTK::Camera::Dec",[`uniform mat4 VCPCMatrix;
|
||
`,"uniform mat4 MCVCMatrix;"]).result,s=Be.substitute(s,"//VTK::PositionVC::Dec","varying vec4 vertexVCVSOutput;").result,s=Be.substitute(s,"//VTK::PositionVC::Impl",` vec4 vertexVC = vertexVCVSOutput;
|
||
`).result;const c=[`uniform int cameraParallel;
|
||
`,`varying float radiusVCVSOutput;
|
||
`,`varying vec3 orientVCVSOutput;
|
||
`,`varying float lengthVCVSOutput;
|
||
`,`varying vec3 centerVCVSOutput;
|
||
`,`uniform mat4 VCPCMatrix;
|
||
`];s=Be.substitute(s,"//VTK::Normal::Dec",c).result;let l="";e.context.getExtension("EXT_frag_depth")&&(l=` gl_FragDepthEXT = (pos.z / pos.w + 1.0) / 2.0;
|
||
`),e._openGLRenderWindow.getWebgl2()&&(l=`gl_FragDepth = (pos.z / pos.w + 1.0) / 2.0;
|
||
`),s=Be.substitute(s,"//VTK::Depth::Impl",[` vec3 EyePos;
|
||
`,` vec3 EyeDir;
|
||
`,` if (cameraParallel != 0) {
|
||
`,` EyePos = vec3(vertexVC.x, vertexVC.y, vertexVC.z + 3.0*radiusVCVSOutput);
|
||
`,` EyeDir = vec3(0.0,0.0,-1.0); }
|
||
`,` else {
|
||
`,` EyeDir = vertexVC.xyz;
|
||
`,` EyePos = vec3(0.0,0.0,0.0);
|
||
`,` float lengthED = length(EyeDir);
|
||
`,` EyeDir = normalize(EyeDir);
|
||
`,` if (lengthED > radiusVCVSOutput*3.0) {
|
||
`,` EyePos = vertexVC.xyz - EyeDir*3.0*radiusVCVSOutput; }
|
||
`,` }
|
||
`,` EyePos = EyePos - centerVCVSOutput;
|
||
`,` vec3 base1;
|
||
`,` if (abs(orientVCVSOutput.z) < 0.99) {
|
||
`,` base1 = normalize(cross(orientVCVSOutput,vec3(0.0,0.0,1.0))); }
|
||
`,` else {
|
||
`,` base1 = normalize(cross(orientVCVSOutput,vec3(0.0,1.0,0.0))); }
|
||
`,` vec3 base2 = cross(orientVCVSOutput,base1);
|
||
`,` EyePos = vec3(dot(EyePos,base1),dot(EyePos,base2),dot(EyePos,orientVCVSOutput));
|
||
`,` EyeDir = vec3(dot(EyeDir,base1),dot(EyeDir,base2),dot(EyeDir,orientVCVSOutput));
|
||
`,` EyePos = EyePos/radiusVCVSOutput;
|
||
`,` float a = EyeDir.x*EyeDir.x + EyeDir.y*EyeDir.y;
|
||
`,` float b = 2.0*(EyePos.x*EyeDir.x + EyePos.y*EyeDir.y);
|
||
`,` float c = EyePos.x*EyePos.x + EyePos.y*EyePos.y - 1.0;
|
||
`,` float d = b*b - 4.0*a*c;
|
||
`,` vec3 normalVCVSOutput = vec3(0.0,0.0,1.0);
|
||
`,` if (d < 0.0) { discard; }
|
||
`,` else {
|
||
`,` float t = (-b - sqrt(d))/(2.0*a);
|
||
`,` float tz = EyePos.z + t*EyeDir.z;
|
||
`,` vec3 iPoint = EyePos + t*EyeDir;
|
||
`,` if (abs(iPoint.z)*radiusVCVSOutput > lengthVCVSOutput*0.5) {
|
||
`,` float t2 = (-b + sqrt(d))/(2.0*a);
|
||
`,` float tz2 = EyePos.z + t2*EyeDir.z;
|
||
`,` if (tz2*radiusVCVSOutput > lengthVCVSOutput*0.5 || tz*radiusVCVSOutput < -0.5*lengthVCVSOutput) { discard; }
|
||
`,` else {
|
||
`,` normalVCVSOutput = orientVCVSOutput;
|
||
`,` float t3 = (lengthVCVSOutput*0.5/radiusVCVSOutput - EyePos.z)/EyeDir.z;
|
||
`,` iPoint = EyePos + t3*EyeDir;
|
||
`,` vertexVC.xyz = radiusVCVSOutput*(iPoint.x*base1 + iPoint.y*base2 + iPoint.z*orientVCVSOutput) + centerVCVSOutput;
|
||
`,` }
|
||
`,` }
|
||
`,` else {
|
||
`,` normalVCVSOutput = iPoint.x*base1 + iPoint.y*base2;
|
||
`,` vertexVC.xyz = radiusVCVSOutput*(normalVCVSOutput + iPoint.z*orientVCVSOutput) + centerVCVSOutput;
|
||
`,` }
|
||
`,` }
|
||
`,` vec4 pos = VCPCMatrix * vertexVC;
|
||
`,l]).result,s=Be.substitute(s,"//VTK::Normal::Impl","").result,e.haveSeenDepthRequest&&(s=Be.substitute(s,"//VTK::ZBuffer::Impl",["if (depthRequest == 1) {","float computedZ = (pos.z / pos.w + 1.0) / 2.0;","float iz = floor(computedZ * 65535.0 + 0.1);","float rf = floor(iz/256.0)/255.0;","float gf = mod(iz,256.0)/255.0;","gl_FragData[0] = vec4(rf, gf, 0.0, 1.0); }"]).result),n.Vertex=a,n.Fragment=s,r.replaceShaderValues(n,i,o)},t.setMapperShaderParameters=(n,i,o)=>{n.getCABO().getElementCount()&&(e.VBOBuildTime>n.getAttributeUpdateTime().getMTime()||n.getShaderSourceTime().getMTime()>n.getAttributeUpdateTime().getMTime())&&(n.getProgram().isAttributeUsed("orientMC")&&(n.getVAO().addAttributeArray(n.getProgram(),n.getCABO(),"orientMC",12,n.getCABO().getStride(),e.context.FLOAT,3,!1)||c2("Error setting 'orientMC' in shader VAO.")),n.getProgram().isAttributeUsed("offsetMC")&&(n.getVAO().addAttributeArray(n.getProgram(),n.getCABO().getColorBO(),"offsetMC",0,n.getCABO().getColorBOStride(),e.context.UNSIGNED_BYTE,3,!0)||c2("Error setting 'offsetMC' in shader VAO.")),n.getProgram().isAttributeUsed("radiusMC")&&(n.getVAO().addAttributeArray(n.getProgram(),n.getCABO(),"radiusMC",24,n.getCABO().getStride(),e.context.FLOAT,1,!1)||c2("Error setting 'radiusMC' in shader VAO."))),r.setMapperShaderParameters(n,i,o)},t.setCameraShaderParameters=(n,i,o)=>{const a=n.getProgram(),s=i.getActiveCamera(),c=e.openGLCamera.getKeyMatrices(i);if(a.isUniformUsed("VCPCMatrix")&&a.setUniformMatrix("VCPCMatrix",c.vcpc),o.getIsIdentity())a.isUniformUsed("MCVCMatrix")&&a.setUniformMatrix("MCVCMatrix",c.wcvc),a.isUniformUsed("normalMatrix")&&a.setUniformMatrix3x3("normalMatrix",c.normalMatrix);else{const l=e.openGLActor.getKeyMatrices();if(a.isUniformUsed("MCVCMatrix")){const f=new Float64Array(16);yn(f,c.wcvc,l.mcwc),a.setUniformMatrix("MCVCMatrix",f)}if(a.isUniformUsed("normalMatrix")){const f=new Float64Array(9);yh(f,c.normalMatrix,l.normalMatrix),a.setUniformMatrix3x3("normalMatrix",f)}}a.isUniformUsed("cameraParallel")&&n.getProgram().setUniformi("cameraParallel",s.getParallelProjection())},t.getOpenGLMode=(n,i)=>e.context.TRIANGLES,t.buildBufferObjects=(n,i)=>{const o=e.currentInput;if(o===null)return;e.renderable.mapScalars(o,1);const a=e.renderable.getColorMapColors(),s=e.primitives[e.primTypes.Tris].getCABO(),c=o.getPointData(),l=o.getPoints(),f=l.getNumberOfPoints(),u=l.getData();let d=3;d+=4;let h=null,g=0;s.setColorBOStride(4),s.getColorBO()||s.setColorBO(Bl.newInstance()),s.getColorBO().setOpenGLRenderWindow(e._openGLRenderWindow),a&&(g=a.getNumberOfComponents(),s.setColorOffset(4),h=a.getData(),s.setColorBOStride(8)),s.setColorComponents(g),s.setStride(d*4);const p=new Float32Array(d*f*12),v=new Uint8Array(12*f*(h?8:4));let y=null,m=null;e.renderable.getScaleArray()!=null&&c.hasArray(e.renderable.getScaleArray())&&(y=c.getArray(e.renderable.getScaleArray()).getData()),e.renderable.getOrientationArray()!=null&&c.hasArray(e.renderable.getOrientationArray())?m=c.getArray(e.renderable.getOrientationArray()).getData():c2([`Error setting orientationArray.
|
||
`,"You have to specify the stick orientation"]);const w=[0,1,3,0,3,2,2,3,5,2,5,4];let x=0,C=0,S=0,T=0;for(let _=0;_<f;++_){let E=e.renderable.getLength(),b=e.renderable.getRadius();y&&(E=y[_*2],b=y[_*2+1]);for(let D=0;D<w.length;++D)x=_*3,p[S++]=u[x++],p[S++]=u[x++],p[S++]=u[x++],x=_*3,p[S++]=m[x++]*E,p[S++]=m[x++]*E,p[S++]=m[x++]*E,p[S++]=b,v[T++]=255*(w[D]%2),v[T++]=w[D]>=4?255:0,v[T++]=w[D]>=2?255:0,v[T++]=255,C=_*g,h&&(v[T++]=h[C],v[T++]=h[C+1],v[T++]=h[C+2],v[T++]=h[C+3])}s.setElementCount(S/d),s.upload(p,jl.ARRAY_BUFFER),s.getColorBO().upload(v,jl.ARRAY_BUFFER),e.VBOBuildTime.modified()}}const hte={};function gte(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,hte,r),uw.extend(t,e,r),dte(t,e)}const TA=Rn(gte,"vtkOpenGLStickMapper");var pte={newInstance:TA};di("vtkStickMapper",TA);function mte(t,e){e.classHierarchy.push("vtkOpenGLVolume"),t.buildPass=r=>{!e.renderable||!e.renderable.getVisibility()||r&&(e._openGLRenderWindow=t.getLastAncestorOfType("vtkOpenGLRenderWindow"),e._openGLRenderer=t.getFirstAncestorOfType("vtkOpenGLRenderer"),e.context=e._openGLRenderWindow.getContext(),t.prepareNodes(),t.addMissingNode(e.renderable.getMapper()),t.removeUnusedNodes())},t.queryPass=(r,n)=>{if(r){if(!e.renderable||!e.renderable.getVisibility())return;n.incrementVolumeCount()}},t.traverseVolumePass=r=>{!e.renderable||!e.renderable.getNestedVisibility()||e._openGLRenderer.getSelector()&&!e.renderable.getNestedPickable()||(t.apply(r,!0),e.children[0].traverse(r),t.apply(r,!1))},t.volumePass=r=>{!e.renderable||!e.renderable.getVisibility()||e.context.depthMask(!r)},t.getKeyMatrices=()=>(e.renderable.getMTime()>e.keyMatrixTime.getMTime()&&(e.renderable.computeMatrix(),Cr(e.MCWCMatrix,e.renderable.getMatrix()),un(e.MCWCMatrix,e.MCWCMatrix),e.renderable.getIsIdentity()?ys(e.normalMatrix):(tw(e.normalMatrix,e.MCWCMatrix),em(e.normalMatrix,e.normalMatrix),Z_(e.normalMatrix,e.normalMatrix)),e.keyMatrixTime.modified()),{mcwc:e.MCWCMatrix,normalMatrix:e.normalMatrix})}const vte={};function yte(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,vte,r),Qn.extend(t,e,r),e.keyMatrixTime={},or(e.keyMatrixTime,{mtime:0}),e.normalMatrix=new Float64Array(9),e.MCWCMatrix=new Float64Array(16),Jr(t,e,["context"]),mte(t,e)}const _A=Rn(yte,"vtkOpenGLVolume");var wte={newInstance:_A};di("vtkVolume",_A);const mS={NEAREST:0,LINEAR:1,FAST_LINEAR:2},EA={FRACTIONAL:0,PROPORTIONAL:1},Ev={CUSTOM:0,ADDITIVE:1,COLORIZE:2};var bA={InterpolationType:mS,OpacityMode:EA,ColorMixPreset:Ev},xte=`//VTK::System::Dec
|
||
|
||
/*=========================================================================
|
||
|
||
Program: Visualization Toolkit
|
||
Module: vtkPolyDataVS.glsl
|
||
|
||
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
|
||
All rights reserved.
|
||
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
|
||
|
||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||
PURPOSE. See the above copyright notice for more information.
|
||
|
||
=========================================================================*/
|
||
|
||
attribute vec4 vertexDC;
|
||
|
||
varying vec3 vertexVCVSOutput;
|
||
uniform mat4 PCVCMatrix;
|
||
|
||
uniform float dcxmin;
|
||
uniform float dcxmax;
|
||
uniform float dcymin;
|
||
uniform float dcymax;
|
||
|
||
void main()
|
||
{
|
||
// dcsmall is the device coords reduced to the
|
||
// x y area covered by the volume
|
||
vec4 dcsmall = vec4(
|
||
dcxmin + 0.5 * (vertexDC.x + 1.0) * (dcxmax - dcxmin),
|
||
dcymin + 0.5 * (vertexDC.y + 1.0) * (dcymax - dcymin),
|
||
vertexDC.z,
|
||
vertexDC.w);
|
||
vec4 vcpos = PCVCMatrix * dcsmall;
|
||
vertexVCVSOutput = vcpos.xyz/vcpos.w;
|
||
gl_Position = dcsmall;
|
||
}
|
||
`,Cte=`//VTK::System::Dec
|
||
|
||
/*=========================================================================
|
||
|
||
Program: Visualization Toolkit
|
||
Module: vtkVolumeFS.glsl
|
||
|
||
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
|
||
All rights reserved.
|
||
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
|
||
|
||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||
PURPOSE. See the above copyright notice for more information.
|
||
|
||
=========================================================================*/
|
||
// Template for the volume mappers fragment shader
|
||
|
||
// the output of this shader
|
||
//VTK::Output::Dec
|
||
|
||
varying vec3 vertexVCVSOutput;
|
||
|
||
// first declare the settings from the mapper
|
||
// that impact the code paths in here
|
||
|
||
// always set vtkNumComponents 1,2,3,4
|
||
//VTK::NumComponents
|
||
|
||
// possibly define vtkTrilinearOn
|
||
//VTK::TrilinearOn
|
||
|
||
// possibly define UseIndependentComponents
|
||
//VTK::IndependentComponentsOn
|
||
|
||
// possibly define vtkCustomComponentsColorMix
|
||
//VTK::CustomComponentsColorMixOn
|
||
|
||
// possibly define any "proportional" components
|
||
//VTK::vtkProportionalComponents
|
||
|
||
// possibly define any components that are forced to nearest interpolation
|
||
//VTK::vtkForceNearestComponents
|
||
|
||
// Define the blend mode to use
|
||
#define vtkBlendMode //VTK::BlendMode
|
||
|
||
// Possibly define vtkImageLabelOutlineOn
|
||
//VTK::ImageLabelOutlineOn
|
||
|
||
// Possibly define vtkLabelEdgeProjectionOn
|
||
//VTK::LabelEdgeProjectionOn
|
||
|
||
|
||
#ifdef vtkImageLabelOutlineOn
|
||
uniform float outlineOpacity;
|
||
uniform float vpWidth;
|
||
uniform float vpHeight;
|
||
uniform float vpOffsetX;
|
||
uniform float vpOffsetY;
|
||
uniform mat4 PCWCMatrix;
|
||
uniform mat4 vWCtoIDX;
|
||
|
||
const int MAX_SEGMENT_INDEX = 256; // Define as per expected maximum
|
||
// bool seenSegmentsByOriginalPos[MAX_SEGMENT_INDEX];
|
||
#define MAX_SEGMENTS 256
|
||
#define UINT_SIZE 32
|
||
#define BITMASK_SIZE ((MAX_SEGMENTS + UINT_SIZE - 1) / UINT_SIZE)
|
||
|
||
uint bitmask[BITMASK_SIZE];
|
||
|
||
// Set the corresponding bit in the bitmask
|
||
void setBit(int segmentIndex) {
|
||
int index = segmentIndex / UINT_SIZE;
|
||
int bitIndex = segmentIndex % UINT_SIZE;
|
||
bitmask[index] |= 1u << bitIndex;
|
||
}
|
||
|
||
// Check if a bit is set in the bitmask
|
||
bool isBitSet(int segmentIndex) {
|
||
int index = segmentIndex / UINT_SIZE;
|
||
int bitIndex = segmentIndex % UINT_SIZE;
|
||
return ((bitmask[index] & (1u << bitIndex)) != 0u);
|
||
}
|
||
#endif
|
||
|
||
// define vtkLightComplexity
|
||
//VTK::LightComplexity
|
||
#if vtkLightComplexity > 0
|
||
uniform float vSpecularPower;
|
||
uniform float vAmbient;
|
||
uniform float vDiffuse;
|
||
uniform float vSpecular;
|
||
//VTK::Light::Dec
|
||
#endif
|
||
|
||
//VTK::VolumeShadowOn
|
||
//VTK::SurfaceShadowOn
|
||
//VTK::localAmbientOcclusionOn
|
||
//VTK::LAO::Dec
|
||
//VTK::VolumeShadow::Dec
|
||
|
||
// define vtkComputeNormalFromOpacity
|
||
//VTK::vtkComputeNormalFromOpacity
|
||
|
||
// possibly define vtkGradientOpacityOn
|
||
//VTK::GradientOpacityOn
|
||
#ifdef vtkGradientOpacityOn
|
||
uniform float goscale0;
|
||
uniform float goshift0;
|
||
uniform float gomin0;
|
||
uniform float gomax0;
|
||
#ifdef UseIndependentComponents
|
||
#if vtkNumComponents > 1
|
||
uniform float goscale1;
|
||
uniform float goshift1;
|
||
uniform float gomin1;
|
||
uniform float gomax1;
|
||
#if vtkNumComponents > 2
|
||
uniform float goscale2;
|
||
uniform float goshift2;
|
||
uniform float gomin2;
|
||
uniform float gomax2;
|
||
#if vtkNumComponents > 3
|
||
uniform float goscale3;
|
||
uniform float goshift3;
|
||
uniform float gomin3;
|
||
uniform float gomax3;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#endif
|
||
|
||
// if you want to see the raw tiled
|
||
// data in webgl1 uncomment the following line
|
||
// #define debugtile
|
||
|
||
// camera values
|
||
uniform float camThick;
|
||
uniform float camNear;
|
||
uniform float camFar;
|
||
uniform int cameraParallel;
|
||
|
||
// values describing the volume geometry
|
||
uniform vec3 vOriginVC;
|
||
uniform vec3 vSpacing;
|
||
uniform ivec3 volumeDimensions; // 3d texture dimensions
|
||
uniform vec3 vPlaneNormal0;
|
||
uniform float vPlaneDistance0;
|
||
uniform vec3 vPlaneNormal1;
|
||
uniform float vPlaneDistance1;
|
||
uniform vec3 vPlaneNormal2;
|
||
uniform float vPlaneDistance2;
|
||
uniform vec3 vPlaneNormal3;
|
||
uniform float vPlaneDistance3;
|
||
uniform vec3 vPlaneNormal4;
|
||
uniform float vPlaneDistance4;
|
||
uniform vec3 vPlaneNormal5;
|
||
uniform float vPlaneDistance5;
|
||
|
||
//VTK::ClipPlane::Dec
|
||
|
||
// opacity and color textures
|
||
uniform sampler2D otexture;
|
||
uniform float oshift0;
|
||
uniform float oscale0;
|
||
uniform sampler2D ctexture;
|
||
uniform float cshift0;
|
||
uniform float cscale0;
|
||
|
||
#if vtkNumComponents >= 2
|
||
uniform float oshift1;
|
||
uniform float oscale1;
|
||
uniform float cshift1;
|
||
uniform float cscale1;
|
||
#endif
|
||
#if vtkNumComponents >= 3
|
||
uniform float oshift2;
|
||
uniform float oscale2;
|
||
uniform float cshift2;
|
||
uniform float cscale2;
|
||
#endif
|
||
#if vtkNumComponents >= 4
|
||
uniform float oshift3;
|
||
uniform float oscale3;
|
||
uniform float cshift3;
|
||
uniform float cscale3;
|
||
#endif
|
||
|
||
// jitter texture
|
||
uniform sampler2D jtexture;
|
||
uniform sampler2D ttexture;
|
||
|
||
|
||
// some 3D texture values
|
||
uniform float sampleDistance;
|
||
uniform vec3 vVCToIJK;
|
||
uniform vec3 volumeSpacings; // spacing in the world coorindates
|
||
|
||
|
||
// the heights defined below are the locations
|
||
// for the up to four components of the tfuns
|
||
// the tfuns have a height of 2XnumComps pixels so the
|
||
// values are computed to hit the middle of the two rows
|
||
// for that component
|
||
#ifdef UseIndependentComponents
|
||
#if vtkNumComponents == 1
|
||
uniform float mix0;
|
||
#define height0 0.5
|
||
#endif
|
||
#if vtkNumComponents == 2
|
||
uniform float mix0;
|
||
uniform float mix1;
|
||
#define height0 0.25
|
||
#define height1 0.75
|
||
#endif
|
||
#if vtkNumComponents == 3
|
||
uniform float mix0;
|
||
uniform float mix1;
|
||
uniform float mix2;
|
||
#define height0 0.17
|
||
#define height1 0.5
|
||
#define height2 0.83
|
||
#endif
|
||
#if vtkNumComponents == 4
|
||
uniform float mix0;
|
||
uniform float mix1;
|
||
uniform float mix2;
|
||
uniform float mix3;
|
||
#define height0 0.125
|
||
#define height1 0.375
|
||
#define height2 0.625
|
||
#define height3 0.875
|
||
#endif
|
||
#endif
|
||
|
||
uniform vec4 ipScalarRangeMin;
|
||
uniform vec4 ipScalarRangeMax;
|
||
|
||
// declaration for intermixed geometry
|
||
//VTK::ZBuffer::Dec
|
||
|
||
//=======================================================================
|
||
// global and custom variables (a temporary section before photorealistics rendering module is complete)
|
||
vec3 rayDirVC;
|
||
float sampleDistanceISVS;
|
||
float sampleDistanceIS;
|
||
|
||
#define SQRT3 1.7321
|
||
#define INV4PI 0.0796
|
||
#define EPSILON 0.001
|
||
#define PI 3.1415
|
||
#define PI2 9.8696
|
||
|
||
//=======================================================================
|
||
// Webgl2 specific version of functions
|
||
#if __VERSION__ == 300
|
||
|
||
uniform highp sampler3D texture1;
|
||
|
||
vec4 getTextureValue(vec3 pos)
|
||
{
|
||
vec4 tmp = texture(texture1, pos);
|
||
|
||
#if defined(vtkComponent0ForceNearest) || \\
|
||
defined(vtkComponent1ForceNearest) || \\
|
||
defined(vtkComponent2ForceNearest) || \\
|
||
defined(vtkComponent3ForceNearest)
|
||
vec3 nearestPos = (floor(pos * vec3(volumeDimensions)) + 0.5) / vec3(volumeDimensions);
|
||
vec4 nearestValue = texture(texture1, nearestPos);
|
||
#ifdef vtkComponent0ForceNearest
|
||
tmp[0] = nearestValue[0];
|
||
#endif
|
||
#ifdef vtkComponent1ForceNearest
|
||
tmp[1] = nearestValue[1];
|
||
#endif
|
||
#ifdef vtkComponent2ForceNearest
|
||
tmp[2] = nearestValue[2];
|
||
#endif
|
||
#ifdef vtkComponent3ForceNearest
|
||
tmp[3] = nearestValue[3];
|
||
#endif
|
||
#endif
|
||
|
||
#ifndef UseIndependentComponents
|
||
#if vtkNumComponents == 1
|
||
tmp.a = tmp.r;
|
||
#endif
|
||
#if vtkNumComponents == 2
|
||
tmp.a = tmp.g;
|
||
#endif
|
||
#if vtkNumComponents == 3
|
||
tmp.a = length(tmp.rgb);
|
||
#endif
|
||
#endif
|
||
|
||
return tmp;
|
||
}
|
||
|
||
//=======================================================================
|
||
// WebGL1 specific version of functions
|
||
#else
|
||
|
||
uniform sampler2D texture1;
|
||
|
||
uniform float texWidth;
|
||
uniform float texHeight;
|
||
uniform int xreps;
|
||
uniform int xstride;
|
||
uniform int ystride;
|
||
|
||
// if computing trilinear values from multiple z slices
|
||
#ifdef vtkTrilinearOn
|
||
vec4 getTextureValue(vec3 ijk)
|
||
{
|
||
float zoff = 1.0/float(volumeDimensions.z);
|
||
vec4 val1 = getOneTextureValue(ijk);
|
||
vec4 val2 = getOneTextureValue(vec3(ijk.xy, ijk.z + zoff));
|
||
|
||
float indexZ = float(volumeDimensions)*ijk.z;
|
||
float zmix = indexZ - floor(indexZ);
|
||
|
||
return mix(val1, val2, zmix);
|
||
}
|
||
|
||
vec4 getOneTextureValue(vec3 ijk)
|
||
#else // nearest or fast linear
|
||
vec4 getTextureValue(vec3 ijk)
|
||
#endif
|
||
{
|
||
vec3 tdims = vec3(volumeDimensions);
|
||
|
||
#ifdef debugtile
|
||
vec2 tpos = vec2(ijk.x, ijk.y);
|
||
vec4 tmp = texture2D(texture1, tpos);
|
||
tmp.a = 1.0;
|
||
|
||
#else
|
||
int z = int(ijk.z * tdims.z);
|
||
int yz = z / xreps;
|
||
int xz = z - yz*xreps;
|
||
|
||
int tileWidth = volumeDimensions.x/xstride;
|
||
int tileHeight = volumeDimensions.y/ystride;
|
||
|
||
xz *= tileWidth;
|
||
yz *= tileHeight;
|
||
|
||
float ni = float(xz) + (ijk.x*float(tileWidth));
|
||
float nj = float(yz) + (ijk.y*float(tileHeight));
|
||
|
||
vec2 tpos = vec2(ni/texWidth, nj/texHeight);
|
||
|
||
vec4 tmp = texture2D(texture1, tpos);
|
||
|
||
#if vtkNumComponents == 1
|
||
tmp.a = tmp.r;
|
||
#endif
|
||
#if vtkNumComponents == 2
|
||
tmp.g = tmp.a;
|
||
#endif
|
||
#if vtkNumComponents == 3
|
||
tmp.a = length(tmp.rgb);
|
||
#endif
|
||
#endif
|
||
|
||
return tmp;
|
||
}
|
||
|
||
// End of Webgl1 specific code
|
||
//=======================================================================
|
||
#endif
|
||
|
||
//=======================================================================
|
||
// transformation between VC and IS space
|
||
|
||
// convert vector position from idx to vc
|
||
#if (vtkLightComplexity > 0) || (defined vtkClippingPlanesOn)
|
||
vec3 IStoVC(vec3 posIS){
|
||
vec3 posVC = posIS / vVCToIJK;
|
||
return posVC.x * vPlaneNormal0 +
|
||
posVC.y * vPlaneNormal2 +
|
||
posVC.z * vPlaneNormal4 +
|
||
vOriginVC;
|
||
}
|
||
|
||
// convert vector position from vc to idx
|
||
vec3 VCtoIS(vec3 posVC){
|
||
posVC = posVC - vOriginVC;
|
||
posVC = vec3(
|
||
dot(posVC, vPlaneNormal0),
|
||
dot(posVC, vPlaneNormal2),
|
||
dot(posVC, vPlaneNormal4));
|
||
return posVC * vVCToIJK;
|
||
}
|
||
#endif
|
||
|
||
//Rotate vector to view coordinate
|
||
#if (vtkLightComplexity > 0) || (defined vtkGradientOpacityOn)
|
||
void rotateToViewCoord(inout vec3 dirIS){
|
||
dirIS.xyz =
|
||
dirIS.x * vPlaneNormal0 +
|
||
dirIS.y * vPlaneNormal2 +
|
||
dirIS.z * vPlaneNormal4;
|
||
}
|
||
|
||
//Rotate vector to idx coordinate
|
||
vec3 rotateToIDX(vec3 dirVC){
|
||
vec3 dirIS;
|
||
dirIS.xyz = vec3(
|
||
dot(dirVC, vPlaneNormal0),
|
||
dot(dirVC, vPlaneNormal2),
|
||
dot(dirVC, vPlaneNormal4));
|
||
return dirIS;
|
||
}
|
||
#endif
|
||
|
||
//=======================================================================
|
||
// Given a normal compute the gradient opacity factors
|
||
float computeGradientOpacityFactor(
|
||
float normalMag, float goscale, float goshift, float gomin, float gomax)
|
||
{
|
||
return clamp(normalMag * goscale + goshift, gomin, gomax);
|
||
}
|
||
|
||
//=======================================================================
|
||
// compute the normal and gradient magnitude for a position, uses forward difference
|
||
#if (vtkLightComplexity > 0) || (defined vtkGradientOpacityOn)
|
||
#ifdef vtkClippingPlanesOn
|
||
void adjustClippedVoxelValues(vec3 pos, vec3 texPos[3], inout vec3 g1)
|
||
{
|
||
vec3 g1VC[3];
|
||
for (int i = 0; i < 3; ++i)
|
||
{
|
||
g1VC[i] = IStoVC(texPos[i]);
|
||
}
|
||
vec3 posVC = IStoVC(pos);
|
||
for (int i = 0; i < clip_numPlanes; ++i)
|
||
{
|
||
for (int j = 0; j < 3; ++j)
|
||
{
|
||
if(dot(vec3(vClipPlaneOrigins[i] - g1VC[j].xyz), vClipPlaneNormals[i]) > 0.0)
|
||
{
|
||
g1[j] = 0.0;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
#endif
|
||
|
||
#ifdef vtkComputeNormalFromOpacity
|
||
vec4 computeDensityNormal(vec3 opacityUCoords[2], float opactityTextureHeight, float gradientOpacity) {
|
||
vec3 opacityG1, opacityG2;
|
||
opacityG1.x = texture2D(otexture, vec2(opacityUCoords[0].x, opactityTextureHeight)).r;
|
||
opacityG1.y = texture2D(otexture, vec2(opacityUCoords[0].y, opactityTextureHeight)).r;
|
||
opacityG1.z = texture2D(otexture, vec2(opacityUCoords[0].z, opactityTextureHeight)).r;
|
||
opacityG2.x = texture2D(otexture, vec2(opacityUCoords[1].x, opactityTextureHeight)).r;
|
||
opacityG2.y = texture2D(otexture, vec2(opacityUCoords[1].y, opactityTextureHeight)).r;
|
||
opacityG2.z = texture2D(otexture, vec2(opacityUCoords[1].z, opactityTextureHeight)).r;
|
||
opacityG1.xyz *= gradientOpacity;
|
||
opacityG2.xyz *= gradientOpacity;
|
||
|
||
vec4 opacityG = vec4(opacityG1 - opacityG2, 1.0f);
|
||
// divide by spacing
|
||
opacityG.xyz /= vSpacing;
|
||
opacityG.w = length(opacityG.xyz);
|
||
// rotate to View Coords
|
||
rotateToViewCoord(opacityG.xyz);
|
||
if (!all(equal(opacityG.xyz, vec3(0.0)))) {
|
||
return vec4(normalize(opacityG.xyz),opacityG.w);
|
||
} else {
|
||
return vec4(0.0);
|
||
}
|
||
}
|
||
|
||
vec4 computeNormalForDensity(vec3 pos, vec3 tstep, out vec3 scalarInterp[2], const int opacityComponent)
|
||
{
|
||
vec3 xvec = vec3(tstep.x, 0.0, 0.0);
|
||
vec3 yvec = vec3(0.0, tstep.y, 0.0);
|
||
vec3 zvec = vec3(0.0, 0.0, tstep.z);
|
||
vec3 texPosPVec[3];
|
||
texPosPVec[0] = pos + xvec;
|
||
texPosPVec[1] = pos + yvec;
|
||
texPosPVec[2] = pos + zvec;
|
||
vec3 texPosNVec[3];
|
||
texPosNVec[0] = pos - xvec;
|
||
texPosNVec[1] = pos - yvec;
|
||
texPosNVec[2] = pos - zvec;
|
||
vec3 g1, g2;
|
||
|
||
scalarInterp[0].x = getTextureValue(texPosPVec[0])[opacityComponent];
|
||
scalarInterp[0].y = getTextureValue(texPosPVec[1])[opacityComponent];
|
||
scalarInterp[0].z = getTextureValue(texPosPVec[2])[opacityComponent];
|
||
scalarInterp[1].x = getTextureValue(texPosNVec[0])[opacityComponent];
|
||
scalarInterp[1].y = getTextureValue(texPosNVec[1])[opacityComponent];
|
||
scalarInterp[1].z = getTextureValue(texPosNVec[2])[opacityComponent];
|
||
|
||
#ifdef vtkClippingPlanesOn
|
||
adjustClippedVoxelValues(pos, texPosPVec, scalarInterp[0]);
|
||
adjustClippedVoxelValues(pos, texPosNVec, scalarInterp[1]);
|
||
#endif
|
||
vec4 result;
|
||
result.x = scalarInterp[0].x - scalarInterp[1].x;
|
||
result.y = scalarInterp[0].y - scalarInterp[1].y;
|
||
result.z = scalarInterp[0].z - scalarInterp[1].z;
|
||
// divide by spacing
|
||
result.xyz /= vSpacing;
|
||
result.w = length(result.xyz);
|
||
// rotate to View Coords
|
||
rotateToViewCoord(result.xyz);
|
||
if (length(result.xyz) > 0.0) {
|
||
return vec4(normalize(result.xyz),result.w);
|
||
} else {
|
||
return vec4(0.0);
|
||
}
|
||
}
|
||
#endif
|
||
|
||
// only works with dependent components
|
||
vec4 computeNormal(vec3 pos, vec3 tstep)
|
||
{
|
||
vec3 xvec = vec3(tstep.x, 0.0, 0.0);
|
||
vec3 yvec = vec3(0.0, tstep.y, 0.0);
|
||
vec3 zvec = vec3(0.0, 0.0, tstep.z);
|
||
vec3 texPosPVec[3];
|
||
texPosPVec[0] = pos + xvec;
|
||
texPosPVec[1] = pos + yvec;
|
||
texPosPVec[2] = pos + zvec;
|
||
vec3 texPosNVec[3];
|
||
texPosNVec[0] = pos - xvec;
|
||
texPosNVec[1] = pos - yvec;
|
||
texPosNVec[2] = pos - zvec;
|
||
vec3 g1, g2;
|
||
g1.x = getTextureValue(texPosPVec[0]).a;
|
||
g1.y = getTextureValue(texPosPVec[1]).a;
|
||
g1.z = getTextureValue(texPosPVec[2]).a;
|
||
g2.x = getTextureValue(texPosNVec[0]).a;
|
||
g2.y = getTextureValue(texPosNVec[1]).a;
|
||
g2.z = getTextureValue(texPosNVec[2]).a;
|
||
#ifdef vtkClippingPlanesOn
|
||
adjustClippedVoxelValues(pos, texPosPVec, g1);
|
||
adjustClippedVoxelValues(pos, texPosNVec, g2);
|
||
#endif
|
||
vec4 result;
|
||
result = vec4(g1 - g2, -1.0);
|
||
// divide by spacing
|
||
result.xyz /= vSpacing;
|
||
result.w = length(result.xyz);
|
||
if (result.w > 0.0){
|
||
// rotate to View Coords
|
||
rotateToViewCoord(result.xyz);
|
||
return vec4(normalize(result.xyz),result.w);
|
||
} else {
|
||
return vec4(0.0);
|
||
}
|
||
}
|
||
#endif
|
||
|
||
|
||
#ifdef vtkImageLabelOutlineOn
|
||
vec4 fragCoordToPCPos(vec4 fragCoord) {
|
||
return vec4(
|
||
(fragCoord.x / vpWidth - vpOffsetX - 0.5) * 2.0,
|
||
(fragCoord.y / vpHeight - vpOffsetY - 0.5) * 2.0,
|
||
(fragCoord.z - 0.5) * 2.0,
|
||
1.0);
|
||
}
|
||
|
||
vec4 pcPosToWorldCoord(vec4 pcPos) {
|
||
return PCWCMatrix * pcPos;
|
||
}
|
||
|
||
vec3 fragCoordToIndexSpace(vec4 fragCoord) {
|
||
vec4 pcPos = fragCoordToPCPos(fragCoord);
|
||
vec4 worldCoord = pcPosToWorldCoord(pcPos);
|
||
vec4 vertex = (worldCoord / worldCoord.w);
|
||
|
||
vec3 index = (vWCtoIDX * vertex).xyz;
|
||
|
||
// half voxel fix for labelmapOutline
|
||
return (index + vec3(0.5)) / vec3(volumeDimensions);
|
||
}
|
||
|
||
vec3 fragCoordToWorld(vec4 fragCoord) {
|
||
vec4 pcPos = fragCoordToPCPos(fragCoord);
|
||
vec4 worldCoord = pcPosToWorldCoord(pcPos);
|
||
return worldCoord.xyz;
|
||
}
|
||
#endif
|
||
|
||
//=======================================================================
|
||
// compute the normals and gradient magnitudes for a position
|
||
// for independent components
|
||
mat4 computeMat4Normal(vec3 pos, vec4 tValue, vec3 tstep)
|
||
{
|
||
mat4 result;
|
||
vec4 distX = getTextureValue(pos + vec3(tstep.x, 0.0, 0.0)) - tValue;
|
||
vec4 distY = getTextureValue(pos + vec3(0.0, tstep.y, 0.0)) - tValue;
|
||
vec4 distZ = getTextureValue(pos + vec3(0.0, 0.0, tstep.z)) - tValue;
|
||
|
||
// divide by spacing
|
||
distX /= vSpacing.x;
|
||
distY /= vSpacing.y;
|
||
distZ /= vSpacing.z;
|
||
|
||
mat3 rot;
|
||
rot[0] = vPlaneNormal0;
|
||
rot[1] = vPlaneNormal2;
|
||
rot[2] = vPlaneNormal4;
|
||
|
||
#if !defined(vtkComponent0Proportional)
|
||
result[0].xyz = vec3(distX.r, distY.r, distZ.r);
|
||
result[0].a = length(result[0].xyz);
|
||
result[0].xyz *= rot;
|
||
if (result[0].w > 0.0)
|
||
{
|
||
result[0].xyz /= result[0].w;
|
||
}
|
||
#endif
|
||
|
||
// optionally compute the 2nd component
|
||
#if vtkNumComponents >= 2 && !defined(vtkComponent1Proportional)
|
||
result[1].xyz = vec3(distX.g, distY.g, distZ.g);
|
||
result[1].a = length(result[1].xyz);
|
||
result[1].xyz *= rot;
|
||
if (result[1].w > 0.0)
|
||
{
|
||
result[1].xyz /= result[1].w;
|
||
}
|
||
#endif
|
||
|
||
// optionally compute the 3rd component
|
||
#if vtkNumComponents >= 3 && !defined(vtkComponent2Proportional)
|
||
result[2].xyz = vec3(distX.b, distY.b, distZ.b);
|
||
result[2].a = length(result[2].xyz);
|
||
result[2].xyz *= rot;
|
||
if (result[2].w > 0.0)
|
||
{
|
||
result[2].xyz /= result[2].w;
|
||
}
|
||
#endif
|
||
|
||
// optionally compute the 4th component
|
||
#if vtkNumComponents >= 4 && !defined(vtkComponent3Proportional)
|
||
result[3].xyz = vec3(distX.a, distY.a, distZ.a);
|
||
result[3].a = length(result[3].xyz);
|
||
result[3].xyz *= rot;
|
||
if (result[3].w > 0.0)
|
||
{
|
||
result[3].xyz /= result[3].w;
|
||
}
|
||
#endif
|
||
|
||
return result;
|
||
}
|
||
|
||
//=======================================================================
|
||
// global shadow - secondary ray
|
||
#if defined(VolumeShadowOn) || defined(localAmbientOcclusionOn)
|
||
float random()
|
||
{
|
||
float rand = fract(sin(dot(gl_FragCoord.xy,vec2(12.9898,78.233)))*43758.5453123);
|
||
float jitter=texture2D(jtexture,gl_FragCoord.xy/32.).r;
|
||
uint pcg_state = floatBitsToUint(jitter);
|
||
uint state = pcg_state;
|
||
pcg_state = pcg_state * uint(747796405) + uint(2891336453);
|
||
uint word = ((state >> ((state >> uint(28)) + uint(4))) ^ state) * uint(277803737);
|
||
return (float((((word >> uint(22)) ^ word) >> 1 ))/float(2147483647) + rand)/2.0;
|
||
}
|
||
#endif
|
||
|
||
#ifdef VolumeShadowOn
|
||
// henyey greenstein phase function
|
||
float phase_function(float cos_angle)
|
||
{
|
||
// divide by 2.0 instead of 4pi to increase intensity
|
||
return ((1.0-anisotropy2)/pow(1.0+anisotropy2-2.0*anisotropy*cos_angle, 1.5))/2.0;
|
||
}
|
||
|
||
// Computes the intersection between a ray and a box
|
||
struct Hit
|
||
{
|
||
float tmin;
|
||
float tmax;
|
||
};
|
||
|
||
struct Ray
|
||
{
|
||
vec3 origin;
|
||
vec3 dir;
|
||
vec3 invDir;
|
||
};
|
||
|
||
bool BBoxIntersect(vec3 boundMin, vec3 boundMax, const Ray r, out Hit hit)
|
||
{
|
||
vec3 tbot = r.invDir * (boundMin - r.origin);
|
||
vec3 ttop = r.invDir * (boundMax - r.origin);
|
||
vec3 tmin = min(ttop, tbot);
|
||
vec3 tmax = max(ttop, tbot);
|
||
vec2 t = max(tmin.xx, tmin.yz);
|
||
float t0 = max(t.x, t.y);
|
||
t = min(tmax.xx, tmax.yz);
|
||
float t1 = min(t.x, t.y);
|
||
hit.tmin = t0;
|
||
hit.tmax = t1;
|
||
return t1 > max(t0,0.0);
|
||
}
|
||
|
||
// As BBoxIntersect requires the inverse of the ray coords,
|
||
// this function is used to avoid numerical issues
|
||
void safe_0_vector(inout Ray ray)
|
||
{
|
||
if(abs(ray.dir.x) < EPSILON) ray.dir.x = sign(ray.dir.x) * EPSILON;
|
||
if(abs(ray.dir.y) < EPSILON) ray.dir.y = sign(ray.dir.y) * EPSILON;
|
||
if(abs(ray.dir.z) < EPSILON) ray.dir.z = sign(ray.dir.z) * EPSILON;
|
||
}
|
||
|
||
float volume_shadow(vec3 posIS, vec3 lightDirNormIS)
|
||
{
|
||
float shadow = 1.0;
|
||
float opacity = 0.0;
|
||
|
||
// modify sample distance with a random number between 1.5 and 3.0
|
||
float sampleDistanceISVS_jitter = sampleDistanceISVS * mix(1.5, 3.0, random());
|
||
float opacityPrev = texture2D(otexture, vec2(getTextureValue(posIS).r * oscale0 + oshift0, 0.5)).r;
|
||
|
||
// in case the first sample near surface has a very tiled light ray, we need to offset start position
|
||
posIS += sampleDistanceISVS_jitter * lightDirNormIS;
|
||
|
||
// compute the start and end points for the ray
|
||
Ray ray;
|
||
Hit hit;
|
||
ray.origin = posIS;
|
||
ray.dir = lightDirNormIS;
|
||
safe_0_vector(ray);
|
||
ray.invDir = 1.0/ray.dir;
|
||
|
||
if(!BBoxIntersect(vec3(0.0),vec3(1.0), ray, hit))
|
||
{
|
||
return 1.0;
|
||
}
|
||
float maxdist = hit.tmax;
|
||
|
||
// interpolate shadow ray length between: 1 unit of sample distance in IS to SQRT3, based on globalIlluminationReach
|
||
float maxgi = mix(sampleDistanceISVS_jitter,SQRT3,giReach);
|
||
maxdist = min(maxdist,maxgi);
|
||
if(maxdist < EPSILON) {
|
||
return 1.0;
|
||
}
|
||
|
||
float current_dist = 0.0;
|
||
float current_step = length(sampleDistanceISVS_jitter * lightDirNormIS);
|
||
float clamped_step = 0.0;
|
||
|
||
vec4 scalar = vec4(0.0);
|
||
while(current_dist < maxdist)
|
||
{
|
||
#ifdef vtkClippingPlanesOn
|
||
vec3 posVC = IStoVC(posIS);
|
||
for (int i = 0; i < clip_numPlanes; ++i)
|
||
{
|
||
if (dot(vec3(vClipPlaneOrigins[i] - posVC), vClipPlaneNormals[i]) > 0.0)
|
||
{
|
||
current_dist = maxdist;
|
||
}
|
||
}
|
||
#endif
|
||
scalar = getTextureValue(posIS);
|
||
opacity = texture2D(otexture, vec2(scalar.r * oscale0 + oshift0, 0.5)).r;
|
||
#if defined(vtkGradientOpacityOn) && !defined(UseIndependentComponents)
|
||
vec4 normal = computeNormal(posIS, vec3(1.0/vec3(volumeDimensions)));
|
||
opacity *= computeGradientOpacityFactor(normal.w, goscale0, goshift0, gomin0, gomax0);
|
||
#endif
|
||
shadow *= 1.0 - opacity;
|
||
|
||
// optimization: early termination
|
||
if (shadow < EPSILON){
|
||
return 0.0;
|
||
}
|
||
|
||
clamped_step = min(maxdist - current_dist, current_step);
|
||
posIS += clamped_step * lightDirNormIS;
|
||
current_dist += current_step;
|
||
}
|
||
|
||
return shadow;
|
||
}
|
||
|
||
vec3 applyShadowRay(vec3 tColor, vec3 posIS, vec3 viewDirectionVC)
|
||
{
|
||
vec3 vertLight = vec3(0.0);
|
||
vec3 secondary_contrib = vec3(0.0);
|
||
// here we assume only positional light, no effect of cones
|
||
for (int i = 0; i < lightNum; i++)
|
||
{
|
||
#if(vtkLightComplexity==3)
|
||
if (lightPositional[i] == 1){
|
||
vertLight = lightPositionVC[i] - IStoVC(posIS);
|
||
}else{
|
||
vertLight = - lightDirectionVC[i];
|
||
}
|
||
#else
|
||
vertLight = - lightDirectionVC[i];
|
||
#endif
|
||
// here we assume achromatic light, only intensity
|
||
float dDotL = dot(viewDirectionVC, normalize(vertLight));
|
||
// isotropic scatter returns 0.5 instead of 1/4pi to increase intensity
|
||
float phase_attenuation = 0.5;
|
||
if (abs(anisotropy) > EPSILON){
|
||
phase_attenuation = phase_function(dDotL);
|
||
}
|
||
float vol_shadow = volume_shadow(posIS, normalize(rotateToIDX(vertLight)));
|
||
secondary_contrib += tColor * vDiffuse * lightColor[i] * vol_shadow * phase_attenuation;
|
||
secondary_contrib += tColor * vAmbient;
|
||
}
|
||
return secondary_contrib;
|
||
}
|
||
#endif
|
||
|
||
//=======================================================================
|
||
// local ambient occlusion
|
||
#ifdef localAmbientOcclusionOn
|
||
vec3 sample_direction_uniform(int i)
|
||
{
|
||
float rand = random() * 0.5;
|
||
float theta = PI2 * (kernelSample[i][0] + rand);
|
||
float phi = acos(2.0 * (kernelSample[i][1] + rand) -1.0) / 2.5;
|
||
return normalize(vec3(cos(theta)*sin(phi), sin(theta)*sin(phi), cos(phi)));
|
||
}
|
||
|
||
// return a matrix that transform startDir into z axis; startDir should be normalized
|
||
mat3 zBaseRotationalMatrix(vec3 startDir){
|
||
vec3 axis = cross(startDir, vec3(0.0,0.0,1.0));
|
||
float cosA = startDir.z;
|
||
float k = 1.0 / (1.0 + cosA);
|
||
mat3 matrix = mat3((axis.x * axis.x * k) + cosA, (axis.y * axis.x * k) - axis.z, (axis.z * axis.x * k) + axis.y,
|
||
(axis.x * axis.y * k) + axis.z, (axis.y * axis.y * k) + cosA, (axis.z * axis.y * k) - axis.x,
|
||
(axis.x * axis.z * k) - axis.y, (axis.y * axis.z * k) + axis.x, (axis.z * axis.z * k) + cosA);
|
||
return matrix;
|
||
}
|
||
|
||
float computeLAO(vec3 posIS, float op, vec3 lightDir, vec4 normal){
|
||
// apply LAO only at selected locations, otherwise return full brightness
|
||
if (normal.w > 0.0 && op > 0.05){
|
||
float total_transmittance = 0.0;
|
||
mat3 inverseRotateBasis = inverse(zBaseRotationalMatrix(normalize(-normal.xyz)));
|
||
vec3 currPos, randomDirStep;
|
||
float weight, transmittance, opacity;
|
||
for (int i = 0; i < kernelSize; i++)
|
||
{
|
||
randomDirStep = inverseRotateBasis * sample_direction_uniform(i) * sampleDistanceIS;
|
||
weight = 1.0 - dot(normalize(lightDir), normalize(randomDirStep));
|
||
currPos = posIS;
|
||
transmittance = 1.0;
|
||
for (int j = 0; j < kernelRadius ; j++){
|
||
currPos += randomDirStep;
|
||
// check if it's at clipping plane, if so return full brightness
|
||
if (all(greaterThan(currPos, vec3(EPSILON))) && all(lessThan(currPos,vec3(1.0-EPSILON)))){
|
||
opacity = texture2D(otexture, vec2(getTextureValue(currPos).r * oscale0 + oshift0, 0.5)).r;
|
||
#ifdef vtkGradientOpacityOn
|
||
opacity *= computeGradientOpacityFactor(normal.w, goscale0, goshift0, gomin0, gomax0);
|
||
#endif
|
||
transmittance *= 1.0 - opacity;
|
||
}
|
||
else{
|
||
break;
|
||
}
|
||
}
|
||
total_transmittance += transmittance / float(kernelRadius) * weight;
|
||
|
||
// early termination if fully translucent
|
||
if (total_transmittance > 1.0 - EPSILON){
|
||
return 1.0;
|
||
}
|
||
}
|
||
// average transmittance and reduce variance
|
||
return clamp(total_transmittance / float(kernelSize), 0.3, 1.0);
|
||
} else {
|
||
return 1.0;
|
||
}
|
||
}
|
||
#endif
|
||
|
||
//=======================================================================
|
||
// surface light contribution
|
||
#if vtkLightComplexity > 0
|
||
void applyLighting(inout vec3 tColor, vec4 normal)
|
||
{
|
||
vec3 diffuse = vec3(0.0, 0.0, 0.0);
|
||
vec3 specular = vec3(0.0, 0.0, 0.0);
|
||
float df, sf = 0.0;
|
||
for (int i = 0; i < lightNum; i++){
|
||
df = abs(dot(normal.rgb, -lightDirectionVC[i]));
|
||
diffuse += df * lightColor[i];
|
||
sf = pow( abs(dot(lightHalfAngleVC[i],normal.rgb)), vSpecularPower);
|
||
specular += sf * lightColor[i];
|
||
}
|
||
tColor.rgb = tColor.rgb*(diffuse*vDiffuse + vAmbient) + specular*vSpecular;
|
||
}
|
||
#ifdef SurfaceShadowOn
|
||
#if vtkLightComplexity < 3
|
||
vec3 applyLightingDirectional(vec3 posIS, vec4 tColor, vec4 normal)
|
||
{
|
||
// everything in VC
|
||
vec3 diffuse = vec3(0.0);
|
||
vec3 specular = vec3(0.0);
|
||
#ifdef localAmbientOcclusionOn
|
||
vec3 ambient = vec3(0.0);
|
||
#endif
|
||
vec3 vertLightDirection;
|
||
for (int i = 0; i < lightNum; i++){
|
||
float ndotL,vdotR;
|
||
vertLightDirection = lightDirectionVC[i];
|
||
ndotL = dot(normal.xyz, vertLightDirection);
|
||
if (ndotL < 0.0 && twoSidedLighting)
|
||
{
|
||
ndotL = -ndotL;
|
||
}
|
||
if (ndotL > 0.0)
|
||
{
|
||
diffuse += ndotL * lightColor[i];
|
||
//specular
|
||
vdotR = dot(-rayDirVC, normalize(2.0 * ndotL * -normal.xyz + vertLightDirection));
|
||
if (vdotR > 0.0)
|
||
{
|
||
specular += pow(vdotR, vSpecularPower) * lightColor[i];
|
||
}
|
||
}
|
||
#ifdef localAmbientOcclusionOn
|
||
ambient += computeLAO(posIS, tColor.a, vertLightDirection, normal);
|
||
#endif
|
||
}
|
||
#ifdef localAmbientOcclusionOn
|
||
return tColor.rgb * (diffuse * vDiffuse + vAmbient * ambient) + specular*vSpecular;
|
||
#else
|
||
return tColor.rgb * (diffuse * vDiffuse + vAmbient) + specular*vSpecular;
|
||
#endif
|
||
}
|
||
#else
|
||
vec3 applyLightingPositional(vec3 posIS, vec4 tColor, vec4 normal, vec3 posVC)
|
||
{
|
||
// everything in VC
|
||
vec3 diffuse = vec3(0.0);
|
||
vec3 specular = vec3(0.0);
|
||
#ifdef localAmbientOcclusionOn
|
||
vec3 ambient = vec3(0.0);
|
||
#endif
|
||
vec3 vertLightDirection;
|
||
for (int i = 0; i < lightNum; i++){
|
||
float distance,attenuation,ndotL,vdotR;
|
||
vec3 lightDir;
|
||
if (lightPositional[i] == 1){
|
||
lightDir = lightDirectionVC[i];
|
||
vertLightDirection = posVC - lightPositionVC[i];
|
||
distance = length(vertLightDirection);
|
||
vertLightDirection = normalize(vertLightDirection);
|
||
attenuation = 1.0 / (lightAttenuation[i].x
|
||
+ lightAttenuation[i].y * distance
|
||
+ lightAttenuation[i].z * distance * distance);
|
||
// per OpenGL standard cone angle is 90 or less for a spot light
|
||
if (lightConeAngle[i] <= 90.0){
|
||
float coneDot = dot(vertLightDirection, lightDir);
|
||
if (coneDot >= cos(radians(lightConeAngle[i]))){ // if inside cone
|
||
attenuation = attenuation * pow(coneDot, lightExponent[i]);
|
||
}
|
||
else {
|
||
attenuation = 0.0;
|
||
}
|
||
}
|
||
ndotL = dot(normal.xyz, vertLightDirection);
|
||
if (ndotL < 0.0 && twoSidedLighting)
|
||
{
|
||
ndotL = -ndotL;
|
||
}
|
||
if (ndotL > 0.0)
|
||
{
|
||
diffuse += ndotL * attenuation * lightColor[i];
|
||
//specular
|
||
vdotR = dot(-rayDirVC, normalize(2.0 * ndotL * -normal.xyz + vertLightDirection));
|
||
if (vdotR > 0.0)
|
||
{
|
||
specular += pow(vdotR, vSpecularPower) * attenuation * lightColor[i];
|
||
}
|
||
}
|
||
#ifdef localAmbientOcclusionOn
|
||
ambient += computeLAO(posIS, tColor.a, vertLightDirection, normal);
|
||
#endif
|
||
} else {
|
||
vertLightDirection = lightDirectionVC[i];
|
||
ndotL = dot(normal.xyz, vertLightDirection);
|
||
if (ndotL < 0.0 && twoSidedLighting)
|
||
{
|
||
ndotL = -ndotL;
|
||
}
|
||
if (ndotL > 0.0)
|
||
{
|
||
diffuse += ndotL * lightColor[i];
|
||
//specular
|
||
vdotR = dot(-rayDirVC, normalize(2.0 * ndotL * -normal.xyz + vertLightDirection));
|
||
if (vdotR > 0.0)
|
||
{
|
||
specular += pow(vdotR, vSpecularPower) * lightColor[i];
|
||
}
|
||
}
|
||
#ifdef localAmbientOcclusionOn
|
||
ambient += computeLAO(posIS, tColor.a, vertLightDirection, normal);
|
||
#endif
|
||
}
|
||
}
|
||
#ifdef localAmbientOcclusionOn
|
||
return tColor.rgb * (diffuse * vDiffuse + vAmbient * ambient) + specular*vSpecular;
|
||
#else
|
||
return tColor.rgb * (diffuse * vDiffuse + vAmbient) + specular*vSpecular;
|
||
#endif
|
||
}
|
||
#endif
|
||
#endif
|
||
#endif
|
||
|
||
// LAO of surface shadows and volume shadows only work with dependent components
|
||
vec3 applyAllLightning(vec3 tColor, float alpha, vec3 posIS, vec4 normalLight) {
|
||
#if vtkLightComplexity > 0
|
||
// surface shadows if needed
|
||
#ifdef SurfaceShadowOn
|
||
#if vtkLightComplexity < 3
|
||
vec3 tColorS = applyLightingDirectional(posIS, vec4(tColor, alpha), normalLight);
|
||
#else
|
||
vec3 tColorS = applyLightingPositional(posIS, vec4(tColor, alpha), normalLight, IStoVC(posIS));
|
||
#endif
|
||
#endif
|
||
|
||
// volume shadows if needed
|
||
#ifdef VolumeShadowOn
|
||
vec3 tColorVS = applyShadowRay(tColor, posIS, rayDirVC);
|
||
#endif
|
||
|
||
// merge
|
||
#ifdef VolumeShadowOn
|
||
#ifdef SurfaceShadowOn
|
||
// surface shadows + volumetric shadows
|
||
float vol_coef = volumetricScatteringBlending * (1.0 - alpha / 2.0) * (1.0 - atan(normalLight.w) * INV4PI);
|
||
tColor = (1.0-vol_coef) * tColorS + vol_coef * tColorVS;
|
||
#else
|
||
// volumetric shadows only
|
||
tColor = tColorVS;
|
||
#endif
|
||
#else
|
||
#ifdef SurfaceShadowOn
|
||
// surface shadows only
|
||
tColor = tColorS;
|
||
#else
|
||
// no shadows
|
||
applyLighting(tColor, normal3);
|
||
#endif
|
||
#endif
|
||
#endif
|
||
return tColor;
|
||
}
|
||
|
||
|
||
vec4 getColorForValue(vec4 tValue, vec3 posIS, vec3 tstep)
|
||
{
|
||
|
||
// If labeloutline and not the edge labelmap, since in the edge labelmap blend
|
||
// we need the underlying data to sample through
|
||
#if defined(vtkImageLabelOutlineOn) && !defined(vtkLabelEdgeProjectionOn)
|
||
vec3 centerPosIS = fragCoordToIndexSpace(gl_FragCoord); // pos in texture space
|
||
vec4 centerValue = getTextureValue(centerPosIS);
|
||
bool pixelOnBorder = false;
|
||
vec4 tColor = texture2D(ctexture, vec2(centerValue.r * cscale0 + cshift0, 0.5));
|
||
|
||
// Get alpha of segment from opacity function.
|
||
tColor.a = texture2D(otexture, vec2(centerValue.r * oscale0 + oshift0, 0.5)).r;
|
||
|
||
int segmentIndex = int(centerValue.r * 255.0);
|
||
|
||
// Use texture sampling for outlineThickness
|
||
float textureCoordinate = float(segmentIndex - 1) / 1024.0;
|
||
float textureValue = texture2D(ttexture, vec2(textureCoordinate, 0.5)).r;
|
||
|
||
int actualThickness = int(textureValue * 255.0);
|
||
|
||
|
||
// If it is the background (segment index 0), we should quickly bail out.
|
||
// Previously, this was determined by tColor.a, which was incorrect as it
|
||
// prevented the outline from appearing when the fill is 0.
|
||
if (segmentIndex == 0){
|
||
return vec4(0, 0, 0, 0);
|
||
}
|
||
|
||
// Only perform outline check on fragments rendering voxels that aren't invisible.
|
||
// Saves a bunch of needless checks on the background.
|
||
// TODO define epsilon when building shader?
|
||
for (int i = -actualThickness; i <= actualThickness; i++) {
|
||
for (int j = -actualThickness; j <= actualThickness; j++) {
|
||
if (i == 0 || j == 0) {
|
||
continue;
|
||
}
|
||
|
||
vec4 neighborPixelCoord = vec4(gl_FragCoord.x + float(i),
|
||
gl_FragCoord.y + float(j),
|
||
gl_FragCoord.z, gl_FragCoord.w);
|
||
|
||
vec3 neighborPosIS = fragCoordToIndexSpace(neighborPixelCoord);
|
||
vec4 value = getTextureValue(neighborPosIS);
|
||
|
||
// If any of my neighbours are not the same value as I
|
||
// am, this means I am on the border of the segment.
|
||
// We can break the loops
|
||
if (any(notEqual(value, centerValue))) {
|
||
pixelOnBorder = true;
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (pixelOnBorder == true) {
|
||
break;
|
||
}
|
||
}
|
||
|
||
// If I am on the border, I am displayed at full opacity
|
||
if (pixelOnBorder == true) {
|
||
tColor.a = outlineOpacity;
|
||
}
|
||
|
||
return tColor;
|
||
|
||
#else
|
||
// compute the normal and gradient magnitude if needed
|
||
// We compute it as a vec4 if possible otherwise a mat4
|
||
|
||
#ifdef UseIndependentComponents
|
||
|
||
// sample textures
|
||
vec3 tColor0 = texture2D(ctexture, vec2(tValue.r * cscale0 + cshift0, height0)).rgb;
|
||
float pwfValue0 = texture2D(otexture, vec2(tValue.r * oscale0 + oshift0, height0)).r;
|
||
|
||
#if vtkNumComponents > 1
|
||
vec3 tColor1 = texture2D(ctexture, vec2(tValue.g * cscale1 + cshift1, height1)).rgb;
|
||
float pwfValue1 = texture2D(otexture, vec2(tValue.g * oscale1 + oshift1, height1)).r;
|
||
|
||
#if vtkNumComponents > 2
|
||
vec3 tColor2 = texture2D(ctexture, vec2(tValue.b * cscale2 + cshift2, height2)).rgb;
|
||
float pwfValue2 = texture2D(otexture, vec2(tValue.b * oscale2 + oshift2, height2)).r;
|
||
|
||
#if vtkNumComponents > 3
|
||
vec3 tColor3 = texture2D(ctexture, vec2(tValue.a * cscale3 + cshift3, height3)).rgb;
|
||
float pwfValue3 = texture2D(otexture, vec2(tValue.a * oscale3 + oshift3, height3)).r;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
|
||
#if !defined(vtkCustomComponentsColorMix)
|
||
// default path for component color mix
|
||
|
||
// compute the normal vectors as needed
|
||
#if (vtkLightComplexity > 0) || defined(vtkGradientOpacityOn)
|
||
mat4 normalMat = computeMat4Normal(posIS, tValue, tstep);
|
||
#endif
|
||
|
||
// compute gradient opacity factors as needed
|
||
vec4 goFactor = vec4(1.0, 1.0 ,1.0 ,1.0);
|
||
#if defined(vtkGradientOpacityOn)
|
||
#if !defined(vtkComponent0Proportional)
|
||
goFactor.x =
|
||
computeGradientOpacityFactor(normalMat[0].a, goscale0, goshift0, gomin0, gomax0);
|
||
#endif
|
||
#if vtkNumComponents > 1
|
||
#if !defined(vtkComponent1Proportional)
|
||
goFactor.y =
|
||
computeGradientOpacityFactor(normalMat[1].a, goscale1, goshift1, gomin1, gomax1);
|
||
#endif
|
||
#if vtkNumComponents > 2
|
||
#if !defined(vtkComponent2Proportional)
|
||
goFactor.z =
|
||
computeGradientOpacityFactor(normalMat[2].a, goscale2, goshift2, gomin2, gomax2);
|
||
#endif
|
||
#if vtkNumComponents > 3
|
||
#if !defined(vtkComponent3Proportional)
|
||
goFactor.w =
|
||
computeGradientOpacityFactor(normalMat[3].a, goscale3, goshift3, gomin3, gomax3);
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#endif
|
||
#endif
|
||
|
||
// process color and opacity for each component
|
||
#if !defined(vtkComponent0Proportional)
|
||
float alpha = goFactor.x*mix0*pwfValue0;
|
||
#if vtkLightComplexity > 0
|
||
applyLighting(tColor0, normalMat[0]);
|
||
#endif
|
||
#else
|
||
tColor0 *= pwfValue0;
|
||
float alpha = mix(pwfValue0, 1.0, (1.0 - mix0));
|
||
#endif
|
||
|
||
#if vtkNumComponents > 1
|
||
#if !defined(vtkComponent1Proportional)
|
||
alpha += goFactor.y*mix1*pwfValue1;
|
||
#if vtkLightComplexity > 0
|
||
applyLighting(tColor1, normalMat[1]);
|
||
#endif
|
||
#else
|
||
tColor1 *= pwfValue1;
|
||
alpha *= mix(pwfValue1, 1.0, (1.0 - mix1));
|
||
#endif
|
||
|
||
#if vtkNumComponents > 2
|
||
#if !defined(vtkComponent2Proportional)
|
||
alpha += goFactor.z*mix2*pwfValue2;
|
||
#if vtkLightComplexity > 0
|
||
applyLighting(tColor2, normalMat[2]);
|
||
#endif
|
||
#else
|
||
tColor2 *= pwfValue2;
|
||
alpha *= mix(pwfValue2, 1.0, (1.0 - mix2));
|
||
#endif
|
||
#endif
|
||
|
||
#if vtkNumComponents > 3
|
||
#if !defined(vtkComponent3Proportional)
|
||
alpha += goFactor.w*mix3*pwfValue3;
|
||
#if vtkLightComplexity > 0
|
||
applyLighting(tColor3, normalMat[3]);
|
||
#endif
|
||
#else
|
||
tColor3 *= pwfValue3;
|
||
alpha *= mix(pwfValue3, 1.0, (1.0 - mix3));
|
||
#endif
|
||
#endif
|
||
#endif
|
||
|
||
// perform final independent blend
|
||
vec3 tColor = mix0 * tColor0;
|
||
#if vtkNumComponents > 1
|
||
tColor += mix1 * tColor1;
|
||
#if vtkNumComponents > 2
|
||
tColor += mix2 * tColor2;
|
||
#if vtkNumComponents > 3
|
||
tColor += mix3 * tColor3;
|
||
#endif
|
||
#endif
|
||
#endif
|
||
|
||
return vec4(tColor, alpha);
|
||
#else
|
||
/*
|
||
* Mix the color information from all the independent components to get a single rgba output
|
||
* Gradient opactity factors and normals are not computed
|
||
*
|
||
* You can compute these using:
|
||
* - computeMat4Normal: always available, compute normal only for non proportional components, used by default independent component mix
|
||
* - computeDensityNormal & computeNormalForDensity: available if ((LightComplexity > 0) || GradientOpacityOn) && ComputeNormalFromOpacity),
|
||
* used by dependent component color mix, see code for Additive preset in OpenGl/VolumeMapper
|
||
* - computeGradientOpacityFactor: always available, used in a lot of places
|
||
*
|
||
* Using applyAllLightning() is advised for shading but some features don't work well with it (volume shadows, LAO)
|
||
* mix0, mix1, ... are defined for each component that is used and correspond to the componentWeight
|
||
*/
|
||
//VTK::CustomComponentsColorMix::Impl
|
||
#endif
|
||
#else
|
||
// dependent components
|
||
|
||
// compute normal if needed
|
||
#if (vtkLightComplexity > 0) || defined(vtkGradientOpacityOn)
|
||
// use component 3 of the opacity texture as getTextureValue() sets alpha to the opacity value
|
||
#ifdef vtkComputeNormalFromOpacity
|
||
vec3 scalarInterp[2];
|
||
vec4 normal0 = computeNormalForDensity(posIS, tstep, scalarInterp, 3);
|
||
#else
|
||
vec4 normal0 = computeNormal(posIS, tstep);
|
||
#endif
|
||
#endif
|
||
|
||
// compute gradient opacity factor enabled
|
||
#if defined(vtkGradientOpacityOn)
|
||
float gradientOpacity = computeGradientOpacityFactor(normal0.a, goscale0, goshift0, gomin0, gomax0);
|
||
#else
|
||
const float gradientOpacity = 1.0;
|
||
#endif
|
||
|
||
// get color and opacity
|
||
#if vtkNumComponents == 1
|
||
vec3 tColor = texture2D(ctexture, vec2(tValue.r * cscale0 + cshift0, 0.5)).rgb;
|
||
float alpha = gradientOpacity*texture2D(otexture, vec2(tValue.r * oscale0 + oshift0, 0.5)).r;
|
||
if (alpha < EPSILON){
|
||
return vec4(0.0);
|
||
}
|
||
#endif
|
||
#if vtkNumComponents == 2
|
||
vec3 tColor = vec3(tValue.r * cscale0 + cshift0);
|
||
float alpha = gradientOpacity*texture2D(otexture, vec2(tValue.a * oscale1 + oshift1, 0.5)).r;
|
||
#endif
|
||
#if vtkNumComponents == 3
|
||
vec3 tColor;
|
||
tColor.r = tValue.r * cscale0 + cshift0;
|
||
tColor.g = tValue.g * cscale1 + cshift1;
|
||
tColor.b = tValue.b * cscale2 + cshift2;
|
||
float alpha = gradientOpacity*texture2D(otexture, vec2(tValue.a * oscale0 + oshift0, 0.5)).r;
|
||
#endif
|
||
#if vtkNumComponents == 4
|
||
vec3 tColor;
|
||
tColor.r = tValue.r * cscale0 + cshift0;
|
||
tColor.g = tValue.g * cscale1 + cshift1;
|
||
tColor.b = tValue.b * cscale2 + cshift2;
|
||
float alpha = gradientOpacity*texture2D(otexture, vec2(tValue.a * oscale3 + oshift3, 0.5)).r;
|
||
#endif
|
||
|
||
// lighting
|
||
#if (vtkLightComplexity > 0)
|
||
#ifdef vtkComputeNormalFromOpacity
|
||
vec4 normalLight;
|
||
if (!all(equal(normal0, vec4(0.0)))) {
|
||
scalarInterp[0] = scalarInterp[0] * oscale0 + oshift0;
|
||
scalarInterp[1] = scalarInterp[1] * oscale0 + oshift0;
|
||
normalLight = computeDensityNormal(scalarInterp, 0.5, gradientOpacity);
|
||
if (all(equal(normalLight, vec4(0.0)))) {
|
||
normalLight = normal0;
|
||
}
|
||
}
|
||
#else
|
||
vec4 normalLight = normal0;
|
||
#endif
|
||
tColor = applyAllLightning(tColor, alpha, posIS, normalLight);
|
||
#endif
|
||
|
||
return vec4(tColor, alpha);
|
||
#endif // dependent
|
||
#endif
|
||
}
|
||
|
||
bool valueWithinScalarRange(vec4 val, vec4 min, vec4 max) {
|
||
bool withinRange = false;
|
||
#if vtkNumComponents == 1
|
||
if (val.r >= min.r && val.r <= max.r) {
|
||
withinRange = true;
|
||
}
|
||
#else
|
||
#ifdef UseIndependentComponents
|
||
#if vtkNumComponents == 2
|
||
if (val.r >= min.r && val.r <= max.r &&
|
||
val.g >= min.g && val.g <= max.g) {
|
||
withinRange = true;
|
||
}
|
||
#else
|
||
if (all(greaterThanEqual(val, ipScalarRangeMin)) &&
|
||
all(lessThanEqual(val, ipScalarRangeMax))) {
|
||
withinRange = true;
|
||
}
|
||
#endif
|
||
#endif
|
||
#endif
|
||
return withinRange;
|
||
}
|
||
|
||
#if vtkBlendMode == 6
|
||
bool checkOnEdgeForNeighbor(int i, int j, int s, vec3 stepIS) {
|
||
vec4 neighborPixelCoord = vec4(gl_FragCoord.x + float(i), gl_FragCoord.y + float(j), gl_FragCoord.z, gl_FragCoord.w);
|
||
vec3 originalNeighborPosIS = fragCoordToIndexSpace(neighborPixelCoord);
|
||
|
||
bool justSawIt = false;
|
||
|
||
vec3 neighborPosIS = originalNeighborPosIS;
|
||
|
||
float stepsTraveled = 0.0;
|
||
|
||
|
||
// float neighborValue;
|
||
for (int k = 0; k < //VTK::MaximumSamplesValue /2 ; ++k) {
|
||
ivec3 texCoord = ivec3(neighborPosIS * vec3(volumeDimensions));
|
||
vec4 texValue = texelFetch(texture1, texCoord, 0);
|
||
|
||
if (int(texValue.g) == s) {
|
||
justSawIt = true;
|
||
break;
|
||
}
|
||
neighborPosIS += stepIS;
|
||
}
|
||
|
||
if (justSawIt){
|
||
return false;
|
||
}
|
||
|
||
|
||
neighborPosIS = originalNeighborPosIS;
|
||
for (int k = 0; k < //VTK::MaximumSamplesValue /2 ; ++k) {
|
||
ivec3 texCoord = ivec3(neighborPosIS * vec3(volumeDimensions));
|
||
vec4 texValue = texelFetch(texture1, texCoord, 0);
|
||
|
||
if (int(texValue.g) == s) {
|
||
justSawIt = true;
|
||
break;
|
||
}
|
||
neighborPosIS -= stepIS;
|
||
}
|
||
|
||
|
||
if (!justSawIt) {
|
||
// onedge
|
||
vec3 tColorSegment = texture2D(ctexture, vec2(float(s) * cscale1 + cshift1, height1)).rgb;
|
||
float pwfValueSegment = texture2D(otexture, vec2(float(s) * oscale1 + oshift1, height1)).r;
|
||
gl_FragData[0] = vec4(tColorSegment, pwfValueSegment);
|
||
return true;
|
||
}
|
||
|
||
// not on edge
|
||
return false;
|
||
}
|
||
|
||
#endif
|
||
|
||
|
||
//=======================================================================
|
||
// Apply the specified blend mode operation along the ray's path.
|
||
//
|
||
void applyBlend(vec3 posIS, vec3 endIS, vec3 tdims)
|
||
{
|
||
vec3 tstep = 1.0/tdims;
|
||
|
||
// start slightly inside and apply some jitter
|
||
vec3 delta = endIS - posIS;
|
||
vec3 stepIS = normalize(delta)*sampleDistanceIS;
|
||
float raySteps = length(delta)/sampleDistanceIS;
|
||
|
||
// Initialize arrays to false
|
||
// avoid 0.0 jitter
|
||
float jitter = 0.01 + 0.99*texture2D(jtexture, gl_FragCoord.xy/32.0).r;
|
||
float stepsTraveled = jitter;
|
||
|
||
// local vars for the loop
|
||
vec4 color = vec4(0.0, 0.0, 0.0, 0.0);
|
||
vec4 tValue;
|
||
vec4 tColor;
|
||
|
||
// if we have less than one step then pick the middle point
|
||
// as our value
|
||
// if (raySteps <= 1.0)
|
||
// {
|
||
// posIS = (posIS + endIS)*0.5;
|
||
// }
|
||
|
||
// Perform initial step at the volume boundary
|
||
// compute the scalar
|
||
tValue = getTextureValue(posIS);
|
||
|
||
#if vtkBlendMode == 6
|
||
if (raySteps <= 1.0)
|
||
{
|
||
gl_FragData[0] = getColorForValue(tValue, posIS, tstep);
|
||
return;
|
||
}
|
||
|
||
vec4 value = tValue;
|
||
posIS += (jitter*stepIS);
|
||
vec3 maxPosIS = posIS; // Store the position of the max value
|
||
int segmentIndex = int(value.g);
|
||
bool originalPosHasSeenNonZero = false;
|
||
|
||
uint bitmask = 0u;
|
||
|
||
if (segmentIndex != 0) {
|
||
// Tried using the segment index in an boolean array but reading
|
||
// from the array by dynamic indexing was horrondously slow
|
||
// so use bit masking instead and assign 1 to the bit corresponding to the segment index
|
||
// and later check if the bit is set via bit operations
|
||
setBit(segmentIndex);
|
||
}
|
||
|
||
// Sample along the ray until MaximumSamplesValue,
|
||
// ending slightly inside the total distance
|
||
for (int i = 0; i < //VTK::MaximumSamplesValue ; ++i)
|
||
{
|
||
// If we have reached the last step, break
|
||
if (stepsTraveled + 1.0 >= raySteps) { break; }
|
||
|
||
// compute the scalar
|
||
tValue = getTextureValue(posIS);
|
||
segmentIndex = int(tValue.g);
|
||
|
||
if (segmentIndex != 0) {
|
||
originalPosHasSeenNonZero = true;
|
||
setBit(segmentIndex);
|
||
}
|
||
|
||
if (tValue.r > value.r) {
|
||
value = tValue; // Update the max value
|
||
maxPosIS = posIS; // Update the position where max occurred
|
||
}
|
||
|
||
// Otherwise, continue along the ray
|
||
stepsTraveled++;
|
||
posIS += stepIS;
|
||
}
|
||
|
||
// Perform the last step along the ray using the
|
||
// residual distance
|
||
posIS = endIS;
|
||
tValue = getTextureValue(posIS);
|
||
|
||
if (tValue.r > value.r) {
|
||
value = tValue; // Update the max value
|
||
maxPosIS = posIS; // Update the position where max occurred
|
||
}
|
||
|
||
// If we have not seen any non-zero segments, we can return early
|
||
// and grab color from the actual center value first component (image)
|
||
if (!originalPosHasSeenNonZero) {
|
||
gl_FragData[0] = getColorForValue(value, maxPosIS, tstep);
|
||
return;
|
||
}
|
||
|
||
// probably we can make this configurable but for now we will use the same
|
||
// sample distance as the original sample distance
|
||
float neighborSampleDistanceIS = sampleDistanceIS;
|
||
|
||
vec3 neighborRayStepsIS = stepIS;
|
||
float neighborRaySteps = raySteps;
|
||
bool shouldLookInAllNeighbors = false;
|
||
|
||
float minVoxelSpacing = min(volumeSpacings[0], min(volumeSpacings[1], volumeSpacings[2]));
|
||
vec4 base = vec4(gl_FragCoord.x, gl_FragCoord.y, gl_FragCoord.z, gl_FragCoord.w);
|
||
|
||
vec4 baseXPlus = vec4(gl_FragCoord.x + 1.0, gl_FragCoord.y, gl_FragCoord.z, gl_FragCoord.w);
|
||
vec4 baseYPlus = vec4(gl_FragCoord.x, gl_FragCoord.y + 1.0, gl_FragCoord.z, gl_FragCoord.w);
|
||
|
||
vec3 baseWorld = fragCoordToWorld(base);
|
||
vec3 baseXPlusWorld = fragCoordToWorld(baseXPlus);
|
||
vec3 baseYPlusWorld = fragCoordToWorld(baseYPlus);
|
||
|
||
float XPlusDiff = length(baseXPlusWorld - baseWorld);
|
||
float YPlusDiff = length(baseYPlusWorld - baseWorld);
|
||
|
||
float minFragSpacingWorld = min(XPlusDiff, YPlusDiff);
|
||
|
||
for (int s = 1; s < MAX_SEGMENT_INDEX; s++) {
|
||
// bail out quickly if the segment index has not
|
||
// been seen by the center segment
|
||
if (!isBitSet(s)) {
|
||
continue;
|
||
}
|
||
|
||
// Use texture sampling for outlineThickness so that we can have
|
||
// per segment thickness
|
||
float textureCoordinate = float(s - 1) / 1024.0;
|
||
float textureValue = texture2D(ttexture, vec2(textureCoordinate, 0.5)).r;
|
||
|
||
int actualThickness = int(textureValue * 255.0);
|
||
|
||
// check the extreme points in the neighborhood since there is a better
|
||
// chance of finding the edge there, so that we can bail out
|
||
// faster if we find the edge
|
||
bool onEdge =
|
||
checkOnEdgeForNeighbor(-actualThickness, -actualThickness, s, stepIS) ||
|
||
checkOnEdgeForNeighbor(actualThickness, actualThickness, s, stepIS) ||
|
||
checkOnEdgeForNeighbor(actualThickness, -actualThickness, s, stepIS) ||
|
||
checkOnEdgeForNeighbor(-actualThickness, +actualThickness, s, stepIS);
|
||
|
||
if (onEdge) {
|
||
return;
|
||
}
|
||
|
||
// since the next step is computationally expensive, we need to perform
|
||
// some optimizations to avoid it if possible. One of the optimizations
|
||
// is to check the whether the minimum of the voxel spacing is greater than
|
||
// the 2 * the thickness of the outline segment. If that is the case
|
||
// then we can safely skip the next step since we can be sure that the
|
||
// the previous 4 checks on the extreme points would caught the entirety
|
||
// of the all the fragments inside. i.e., this happens when we zoom out,
|
||
if (minVoxelSpacing > (2.0 * float(actualThickness) - 1.0) * minFragSpacingWorld) {
|
||
continue;
|
||
}
|
||
|
||
// Loop through the rest, skipping the processed extremes and the center
|
||
for (int i = -actualThickness; i <= actualThickness; i++) {
|
||
for (int j = -actualThickness; j <= actualThickness; j++) {
|
||
if (i == 0 && j == 0) continue; // Skip the center
|
||
if (abs(i) == actualThickness && abs(j) == actualThickness) continue; // Skip corners
|
||
if (checkOnEdgeForNeighbor(i, j, s, stepIS )) {
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
vec3 tColor0 = texture2D(ctexture, vec2(value.r * cscale0 + cshift0, height0)).rgb;
|
||
float pwfValue0 = texture2D(otexture, vec2(value.r * oscale0 + oshift0, height0)).r;
|
||
gl_FragData[0] = vec4(tColor0, pwfValue0);
|
||
#endif
|
||
#if vtkBlendMode == 0 // COMPOSITE_BLEND
|
||
// now map through opacity and color
|
||
tColor = getColorForValue(tValue, posIS, tstep);
|
||
|
||
// handle very thin volumes
|
||
if (raySteps <= 1.0)
|
||
{
|
||
tColor.a = 1.0 - pow(1.0 - tColor.a, raySteps);
|
||
gl_FragData[0] = tColor;
|
||
return;
|
||
}
|
||
|
||
tColor.a = 1.0 - pow(1.0 - tColor.a, jitter);
|
||
color = vec4(tColor.rgb*tColor.a, tColor.a);
|
||
posIS += (jitter*stepIS);
|
||
|
||
for (int i = 0; i < //VTK::MaximumSamplesValue ; ++i)
|
||
{
|
||
if (stepsTraveled + 1.0 >= raySteps) { break; }
|
||
|
||
// compute the scalar
|
||
tValue = getTextureValue(posIS);
|
||
|
||
// now map through opacity and color
|
||
tColor = getColorForValue(tValue, posIS, tstep);
|
||
|
||
float mix = (1.0 - color.a);
|
||
|
||
// this line should not be needed but nvidia seems to not handle
|
||
// the break correctly on windows/chrome 58 angle
|
||
//mix = mix * sign(max(raySteps - stepsTraveled - 1.0, 0.0));
|
||
|
||
color = color + vec4(tColor.rgb*tColor.a, tColor.a)*mix;
|
||
stepsTraveled++;
|
||
posIS += stepIS;
|
||
if (color.a > 0.99) { color.a = 1.0; break; }
|
||
}
|
||
|
||
if (color.a < 0.99 && (raySteps - stepsTraveled) > 0.0)
|
||
{
|
||
posIS = endIS;
|
||
|
||
// compute the scalar
|
||
tValue = getTextureValue(posIS);
|
||
|
||
// now map through opacity and color
|
||
tColor = getColorForValue(tValue, posIS, tstep);
|
||
tColor.a = 1.0 - pow(1.0 - tColor.a, raySteps - stepsTraveled);
|
||
|
||
float mix = (1.0 - color.a);
|
||
color = color + vec4(tColor.rgb*tColor.a, tColor.a)*mix;
|
||
}
|
||
|
||
gl_FragData[0] = vec4(color.rgb/color.a, color.a);
|
||
#endif
|
||
#if vtkBlendMode == 1 || vtkBlendMode == 2
|
||
// MAXIMUM_INTENSITY_BLEND || MINIMUM_INTENSITY_BLEND
|
||
// Find maximum/minimum intensity along the ray.
|
||
|
||
// Define the operation we will use (min or max)
|
||
#if vtkBlendMode == 1
|
||
#define OP max
|
||
#else
|
||
#define OP min
|
||
#endif
|
||
|
||
// If the clipping range is shorter than the sample distance
|
||
// we can skip the sampling loop along the ray.
|
||
if (raySteps <= 1.0)
|
||
{
|
||
gl_FragData[0] = getColorForValue(tValue, posIS, tstep);
|
||
return;
|
||
}
|
||
|
||
vec4 value = tValue;
|
||
posIS += (jitter*stepIS);
|
||
|
||
// Sample along the ray until MaximumSamplesValue,
|
||
// ending slightly inside the total distance
|
||
for (int i = 0; i < //VTK::MaximumSamplesValue ; ++i)
|
||
{
|
||
// If we have reached the last step, break
|
||
if (stepsTraveled + 1.0 >= raySteps) { break; }
|
||
|
||
// compute the scalar
|
||
tValue = getTextureValue(posIS);
|
||
|
||
// Update the maximum value if necessary
|
||
value = OP(tValue, value);
|
||
|
||
// Otherwise, continue along the ray
|
||
stepsTraveled++;
|
||
posIS += stepIS;
|
||
}
|
||
|
||
// Perform the last step along the ray using the
|
||
// residual distance
|
||
posIS = endIS;
|
||
tValue = getTextureValue(posIS);
|
||
value = OP(tValue, value);
|
||
|
||
// Now map through opacity and color
|
||
gl_FragData[0] = getColorForValue(value, posIS, tstep);
|
||
#endif
|
||
#if vtkBlendMode == 3 || vtkBlendMode == 4 //AVERAGE_INTENSITY_BLEND || ADDITIVE_BLEND
|
||
vec4 sum = vec4(0.);
|
||
|
||
if (valueWithinScalarRange(tValue, ipScalarRangeMin, ipScalarRangeMax)) {
|
||
sum += tValue;
|
||
}
|
||
|
||
if (raySteps <= 1.0) {
|
||
gl_FragData[0] = getColorForValue(sum, posIS, tstep);
|
||
return;
|
||
}
|
||
|
||
posIS += (jitter*stepIS);
|
||
|
||
// Sample along the ray until MaximumSamplesValue,
|
||
// ending slightly inside the total distance
|
||
for (int i = 0; i < //VTK::MaximumSamplesValue ; ++i)
|
||
{
|
||
// If we have reached the last step, break
|
||
if (stepsTraveled + 1.0 >= raySteps) { break; }
|
||
|
||
// compute the scalar
|
||
tValue = getTextureValue(posIS);
|
||
|
||
// One can control the scalar range by setting the AverageIPScalarRange to disregard scalar values, not in the range of interest, from the average computation.
|
||
// Notes:
|
||
// - We are comparing all values in the texture to see if any of them
|
||
// are outside of the scalar range. In the future we might want to allow
|
||
// scalar ranges for each component.
|
||
if (valueWithinScalarRange(tValue, ipScalarRangeMin, ipScalarRangeMax)) {
|
||
// Sum the values across each step in the path
|
||
sum += tValue;
|
||
}
|
||
stepsTraveled++;
|
||
posIS += stepIS;
|
||
}
|
||
|
||
// Perform the last step along the ray using the
|
||
// residual distance
|
||
posIS = endIS;
|
||
|
||
// compute the scalar
|
||
tValue = getTextureValue(posIS);
|
||
|
||
// One can control the scalar range by setting the IPScalarRange to disregard scalar values, not in the range of interest, from the average computation
|
||
if (valueWithinScalarRange(tValue, ipScalarRangeMin, ipScalarRangeMax)) {
|
||
sum += tValue;
|
||
|
||
stepsTraveled++;
|
||
}
|
||
|
||
#if vtkBlendMode == 3 // Average
|
||
sum /= vec4(stepsTraveled, stepsTraveled, stepsTraveled, 1.0);
|
||
#endif
|
||
|
||
gl_FragData[0] = getColorForValue(sum, posIS, tstep);
|
||
#endif
|
||
#if vtkBlendMode == 5 // RADON
|
||
float normalizedRayIntensity = 1.0;
|
||
|
||
// handle very thin volumes
|
||
if (raySteps <= 1.0)
|
||
{
|
||
tValue = getTextureValue(posIS);
|
||
normalizedRayIntensity = normalizedRayIntensity - sampleDistance*texture2D(otexture, vec2(tValue.r * oscale0 + oshift0, 0.5)).r;
|
||
gl_FragData[0] = texture2D(ctexture, vec2(normalizedRayIntensity, 0.5));
|
||
return;
|
||
}
|
||
|
||
posIS += (jitter*stepIS);
|
||
|
||
for (int i = 0; i < //VTK::MaximumSamplesValue ; ++i)
|
||
{
|
||
if (stepsTraveled + 1.0 >= raySteps) { break; }
|
||
|
||
// compute the scalar value
|
||
tValue = getTextureValue(posIS);
|
||
|
||
// Convert scalar value to normalizedRayIntensity coefficient and accumulate normalizedRayIntensity
|
||
normalizedRayIntensity = normalizedRayIntensity - sampleDistance*texture2D(otexture, vec2(tValue.r * oscale0 + oshift0, 0.5)).r;
|
||
|
||
posIS += stepIS;
|
||
stepsTraveled++;
|
||
}
|
||
|
||
// map normalizedRayIntensity to color
|
||
gl_FragData[0] = texture2D(ctexture, vec2(normalizedRayIntensity , 0.5));
|
||
|
||
#endif
|
||
}
|
||
|
||
//=======================================================================
|
||
// Compute a new start and end point for a given ray based
|
||
// on the provided bounded clipping plane (aka a rectangle)
|
||
void getRayPointIntersectionBounds(
|
||
vec3 rayPos, vec3 rayDir,
|
||
vec3 planeDir, float planeDist,
|
||
inout vec2 tbounds, vec3 vPlaneX, vec3 vPlaneY,
|
||
float vSize1, float vSize2)
|
||
{
|
||
float result = dot(rayDir, planeDir);
|
||
if (abs(result) < 1e-6)
|
||
{
|
||
return;
|
||
}
|
||
result = -1.0 * (dot(rayPos, planeDir) + planeDist) / result;
|
||
vec3 xposVC = rayPos + rayDir*result;
|
||
vec3 vxpos = xposVC - vOriginVC;
|
||
vec2 vpos = vec2(
|
||
dot(vxpos, vPlaneX),
|
||
dot(vxpos, vPlaneY));
|
||
|
||
// on some apple nvidia systems this does not work
|
||
// if (vpos.x < 0.0 || vpos.x > vSize1 ||
|
||
// vpos.y < 0.0 || vpos.y > vSize2)
|
||
// even just
|
||
// if (vpos.x < 0.0 || vpos.y < 0.0)
|
||
// fails
|
||
// so instead we compute a value that represents in and out
|
||
//and then compute the return using this value
|
||
float xcheck = max(0.0, vpos.x * (vpos.x - vSize1)); // 0 means in bounds
|
||
float check = sign(max(xcheck, vpos.y * (vpos.y - vSize2))); // 0 means in bounds, 1 = out
|
||
|
||
tbounds = mix(
|
||
vec2(min(tbounds.x, result), max(tbounds.y, result)), // in value
|
||
tbounds, // out value
|
||
check); // 0 in 1 out
|
||
}
|
||
|
||
//=======================================================================
|
||
// given a
|
||
// - ray direction (rayDir)
|
||
// - starting point (vertexVCVSOutput)
|
||
// - bounding planes of the volume
|
||
// - optionally depth buffer values
|
||
// - far clipping plane
|
||
// compute the start/end distances of the ray we need to cast
|
||
vec2 computeRayDistances(vec3 rayDir, vec3 tdims)
|
||
{
|
||
vec2 dists = vec2(100.0*camFar, -1.0);
|
||
|
||
vec3 vSize = vSpacing*tdims;
|
||
|
||
// all this is in View Coordinates
|
||
getRayPointIntersectionBounds(vertexVCVSOutput, rayDir,
|
||
vPlaneNormal0, vPlaneDistance0, dists, vPlaneNormal2, vPlaneNormal4,
|
||
vSize.y, vSize.z);
|
||
getRayPointIntersectionBounds(vertexVCVSOutput, rayDir,
|
||
vPlaneNormal1, vPlaneDistance1, dists, vPlaneNormal2, vPlaneNormal4,
|
||
vSize.y, vSize.z);
|
||
getRayPointIntersectionBounds(vertexVCVSOutput, rayDir,
|
||
vPlaneNormal2, vPlaneDistance2, dists, vPlaneNormal0, vPlaneNormal4,
|
||
vSize.x, vSize.z);
|
||
getRayPointIntersectionBounds(vertexVCVSOutput, rayDir,
|
||
vPlaneNormal3, vPlaneDistance3, dists, vPlaneNormal0, vPlaneNormal4,
|
||
vSize.x, vSize.z);
|
||
getRayPointIntersectionBounds(vertexVCVSOutput, rayDir,
|
||
vPlaneNormal4, vPlaneDistance4, dists, vPlaneNormal0, vPlaneNormal2,
|
||
vSize.x, vSize.y);
|
||
getRayPointIntersectionBounds(vertexVCVSOutput, rayDir,
|
||
vPlaneNormal5, vPlaneDistance5, dists, vPlaneNormal0, vPlaneNormal2,
|
||
vSize.x, vSize.y);
|
||
|
||
//VTK::ClipPlane::Impl
|
||
|
||
// do not go behind front clipping plane
|
||
dists.x = max(0.0,dists.x);
|
||
|
||
// do not go PAST far clipping plane
|
||
float farDist = -camThick/rayDir.z;
|
||
dists.y = min(farDist,dists.y);
|
||
|
||
// Do not go past the zbuffer value if set
|
||
// This is used for intermixing opaque geometry
|
||
//VTK::ZBuffer::Impl
|
||
|
||
return dists;
|
||
}
|
||
|
||
//=======================================================================
|
||
// Compute the index space starting position (pos) and end
|
||
// position
|
||
//
|
||
void computeIndexSpaceValues(out vec3 pos, out vec3 endPos, vec3 rayDir, vec2 dists)
|
||
{
|
||
// compute starting and ending values in volume space
|
||
pos = vertexVCVSOutput + dists.x*rayDir;
|
||
pos = pos - vOriginVC;
|
||
// convert to volume basis and origin
|
||
pos = vec3(
|
||
dot(pos, vPlaneNormal0),
|
||
dot(pos, vPlaneNormal2),
|
||
dot(pos, vPlaneNormal4));
|
||
|
||
endPos = vertexVCVSOutput + dists.y*rayDir;
|
||
endPos = endPos - vOriginVC;
|
||
endPos = vec3(
|
||
dot(endPos, vPlaneNormal0),
|
||
dot(endPos, vPlaneNormal2),
|
||
dot(endPos, vPlaneNormal4));
|
||
|
||
float delta = length(endPos - pos);
|
||
|
||
pos *= vVCToIJK;
|
||
endPos *= vVCToIJK;
|
||
|
||
float delta2 = length(endPos - pos);
|
||
sampleDistanceIS = sampleDistance*delta2/delta;
|
||
#ifdef VolumeShadowOn
|
||
sampleDistanceISVS = sampleDistanceIS * volumeShadowSamplingDistFactor;
|
||
#endif
|
||
}
|
||
|
||
void main()
|
||
{
|
||
|
||
if (cameraParallel == 1)
|
||
{
|
||
// Camera is parallel, so the rayDir is just the direction of the camera.
|
||
rayDirVC = vec3(0.0, 0.0, -1.0);
|
||
} else {
|
||
// camera is at 0,0,0 so rayDir for perspective is just the vc coord
|
||
rayDirVC = normalize(vertexVCVSOutput);
|
||
}
|
||
|
||
vec3 tdims = vec3(volumeDimensions);
|
||
|
||
// compute the start and end points for the ray
|
||
vec2 rayStartEndDistancesVC = computeRayDistances(rayDirVC, tdims);
|
||
|
||
// do we need to composite? aka does the ray have any length
|
||
// If not, bail out early
|
||
if (rayStartEndDistancesVC.y <= rayStartEndDistancesVC.x)
|
||
{
|
||
discard;
|
||
}
|
||
|
||
// IS = Index Space
|
||
vec3 posIS;
|
||
vec3 endIS;
|
||
computeIndexSpaceValues(posIS, endIS, rayDirVC, rayStartEndDistancesVC);
|
||
|
||
// Perform the blending operation along the ray
|
||
applyBlend(posIS, endIS, tdims);
|
||
}
|
||
`;const{vtkWarningMacro:Ste,vtkErrorMacro:zx}=uo;function Tte(t){switch(t){case Ev.CUSTOM:return"//VTK::CustomColorMix";case Ev.ADDITIVE:return`
|
||
// compute normals
|
||
mat4 normalMat = computeMat4Normal(posIS, tValue, tstep);
|
||
#if (vtkLightComplexity > 0) && defined(vtkComputeNormalFromOpacity)
|
||
vec3 scalarInterp0[2];
|
||
vec4 normalLight0 = computeNormalForDensity(posIS, tstep, scalarInterp0, 0);
|
||
scalarInterp0[0] = scalarInterp0[0] * oscale0 + oshift0;
|
||
scalarInterp0[1] = scalarInterp0[1] * oscale0 + oshift0;
|
||
normalLight0 = computeDensityNormal(scalarInterp0, height0, 1.0);
|
||
|
||
vec3 scalarInterp1[2];
|
||
vec4 normalLight1 = computeNormalForDensity(posIS, tstep, scalarInterp1, 1);
|
||
scalarInterp1[0] = scalarInterp1[0] * oscale1 + oshift1;
|
||
scalarInterp1[1] = scalarInterp1[1] * oscale1 + oshift1;
|
||
normalLight1 = computeDensityNormal(scalarInterp1, height1, 1.0);
|
||
#else
|
||
vec4 normalLight0 = normalMat[0];
|
||
vec4 normalLight1 = normalMat[1];
|
||
#endif
|
||
|
||
// compute opacities
|
||
float opacity0 = pwfValue0;
|
||
float opacity1 = pwfValue1;
|
||
#ifdef vtkGradientOpacityOn
|
||
float gof0 = computeGradientOpacityFactor(normalMat[0].a, goscale0, goshift0, gomin0, gomax0);
|
||
opacity0 *= gof0;
|
||
float gof1 = computeGradientOpacityFactor(normalMat[1].a, goscale1, goshift1, gomin1, gomax1);
|
||
opacity1 *= gof1;
|
||
#endif
|
||
float opacitySum = opacity0 + opacity1;
|
||
if (opacitySum <= 0.0) {
|
||
return vec4(0.0);
|
||
}
|
||
|
||
// mix the colors and opacities
|
||
tColor0 = applyAllLightning(tColor0, opacity0, posIS, normalLight0);
|
||
tColor1 = applyAllLightning(tColor1, opacity1, posIS, normalLight1);
|
||
vec3 mixedColor = (opacity0 * tColor0 + opacity1 * tColor1) / opacitySum;
|
||
return vec4(mixedColor, min(1.0, opacitySum));
|
||
`;case Ev.COLORIZE:return`
|
||
// compute normals
|
||
mat4 normalMat = computeMat4Normal(posIS, tValue, tstep);
|
||
#if (vtkLightComplexity > 0) && defined(vtkComputeNormalFromOpacity)
|
||
vec3 scalarInterp0[2];
|
||
vec4 normalLight0 = computeNormalForDensity(posIS, tstep, scalarInterp0, 0);
|
||
scalarInterp0[0] = scalarInterp0[0] * oscale0 + oshift0;
|
||
scalarInterp0[1] = scalarInterp0[1] * oscale0 + oshift0;
|
||
normalLight0 = computeDensityNormal(scalarInterp0, height0, 1.0);
|
||
#else
|
||
vec4 normalLight0 = normalMat[0];
|
||
#endif
|
||
|
||
// compute opacities
|
||
float opacity0 = pwfValue0;
|
||
#ifdef vtkGradientOpacityOn
|
||
float gof0 = computeGradientOpacityFactor(normalMat[0].a, goscale0, goshift0, gomin0, gomax0);
|
||
opacity0 *= gof0;
|
||
#endif
|
||
|
||
// mix the colors and opacities
|
||
vec3 color = tColor0 * mix(vec3(1.0), tColor1, pwfValue1);
|
||
color = applyAllLightning(color, opacity0, posIS, normalLight0);
|
||
return vec4(color, opacity0);
|
||
`;default:return null}}function _te(t,e){e.classHierarchy.push("vtkOpenGLVolumeMapper");function r(i){[e._scalars,e._scalarOpacityFunc,e._colorTransferFunc,e._labelOutlineThicknessArray].forEach(o=>i.unregisterGraphicsResourceUser(o,t))}t.buildPass=()=>{e.zBufferTexture=null},t.zBufferPass=(i,o)=>{if(i){const a=o.getZBufferTexture();a!==e.zBufferTexture&&(e.zBufferTexture=a)}},t.opaqueZBufferPass=(i,o)=>t.zBufferPass(i,o),t.volumePass=(i,o)=>{if(i){const a=e._openGLRenderWindow;e._openGLRenderWindow=t.getLastAncestorOfType("vtkOpenGLRenderWindow"),a&&!a.isDeleted()&&a!==e._openGLRenderWindow&&r(a),e.context=e._openGLRenderWindow.getContext(),e.tris.setOpenGLRenderWindow(e._openGLRenderWindow),e.jitterTexture.setOpenGLRenderWindow(e._openGLRenderWindow),e.framebuffer.setOpenGLRenderWindow(e._openGLRenderWindow),e.openGLVolume=t.getFirstAncestorOfType("vtkOpenGLVolume");const s=e.openGLVolume.getRenderable();e._openGLRenderer=t.getFirstAncestorOfType("vtkOpenGLRenderer");const c=e._openGLRenderer.getRenderable();e.openGLCamera=e._openGLRenderer.getViewNodeFor(c.getActiveCamera()),t.renderPiece(c,s)}},t.getShaderTemplate=(i,o,a)=>{i.Vertex=xte,i.Fragment=Cte,i.Geometry=""},t.useIndependentComponents=i=>{var l,f;const o=i.getIndependentComponents(),a=e.currentInput,s=(f=(l=a==null?void 0:a.getPointData())==null?void 0:l.getScalars())==null?void 0:f.getNumberOfComponents(),c=i.getColorMixPreset();return o&&s>=2||!!c},t.replaceShaderValues=(i,o,a)=>{const s=a.getProperty();let c=i.Fragment;s.getInterpolationType()===mS.LINEAR&&(c=Be.substitute(c,"//VTK::TrilinearOn","#define vtkTrilinearOn").result),t.isLabelmapOutlineRequired(a)===!0&&(c=Be.substitute(c,"//VTK::ImageLabelOutlineOn","#define vtkImageLabelOutlineOn").result),e.renderable.getBlendMode()===hv.LABELMAP_EDGE_PROJECTION_BLEND&&(c=Be.substitute(c,"//VTK::LabelEdgeProjectionOn","#define vtkLabelEdgeProjectionOn").result);const d=e.scalarTexture.getComponents();c=Be.substitute(c,"//VTK::NumComponents",`#define vtkNumComponents ${d}`).result;const h=t.useIndependentComponents(s);h&&(c=Be.substitute(c,"//VTK::IndependentComponentsOn","#define UseIndependentComponents").result);const g=[],p=[];for(let T=0;T<d;T++)s.getOpacityMode(T)===EA.PROPORTIONAL&&g.push(`#define vtkComponent${T}Proportional`),s.getForceNearestInterpolation(T)&&p.push(`#define vtkComponent${T}ForceNearest`);c=Be.substitute(c,"//VTK::vtkProportionalComponents",g.join(`
|
||
`)).result,c=Be.substitute(c,"//VTK::vtkForceNearestComponents",p.join(`
|
||
`)).result;const v=s.getColorMixPreset(),y=Tte(v);y&&(c=Be.substitute(c,"//VTK::CustomComponentsColorMixOn","#define vtkCustomComponentsColorMix").result,c=Be.substitute(c,"//VTK::CustomComponentsColorMix::Impl",y).result);const m=e.currentInput.getSpatialExtent(),w=e.currentInput.getSpacing(),x=new Float64Array(3);Wn(x,(m[1]-m[0])*w[0],(m[3]-m[2])*w[1],(m[5]-m[4])*w[2]);const C=Ko(x)/t.getCurrentSampleDistance(o);c=Be.substitute(c,"//VTK::MaximumSamplesValue",`${Math.ceil(C)}`).result,c=Be.substitute(c,"//VTK::LightComplexity",`#define vtkLightComplexity ${e.lightComplexity}`).result,e.lightComplexity>0&&(e.renderable.getVolumetricScatteringBlending()>0&&(c=Be.substitute(c,"//VTK::VolumeShadowOn","#define VolumeShadowOn").result),e.renderable.getVolumetricScatteringBlending()<1&&(c=Be.substitute(c,"//VTK::SurfaceShadowOn","#define SurfaceShadowOn").result),e.renderable.getLocalAmbientOcclusion()&&s.getAmbient()>0&&(c=Be.substitute(c,"//VTK::localAmbientOcclusionOn","#define localAmbientOcclusionOn").result));const S=h?d:1;e.gopacity=!1;for(let T=0;!e.gopacity&&T<S;++T)e.gopacity||(e.gopacity=s.getUseGradientOpacity(T));e.gopacity&&(c=Be.substitute(c,"//VTK::GradientOpacityOn","#define vtkGradientOpacityOn").result),e.renderable.getComputeNormalFromOpacity()&&(c=Be.substitute(c,"//VTK::vtkComputeNormalFromOpacity","#define vtkComputeNormalFromOpacity").result),e.zBufferTexture!==null&&(c=Be.substitute(c,"//VTK::ZBuffer::Dec",["uniform sampler2D zBufferTexture;","uniform float vpZWidth;","uniform float vpZHeight;"]).result,c=Be.substitute(c,"//VTK::ZBuffer::Impl",["vec4 depthVec = texture2D(zBufferTexture, vec2(gl_FragCoord.x / vpZWidth, gl_FragCoord.y/vpZHeight));","float zdepth = (depthVec.r*256.0 + depthVec.g)/257.0;","zdepth = zdepth * 2.0 - 1.0;","if (cameraParallel == 0) {","zdepth = -2.0 * camFar * camNear / (zdepth*(camFar-camNear)-(camFar+camNear)) - camNear;}","else {",`zdepth = (zdepth + 1.0) * 0.5 * (camFar - camNear);}
|
||
`,"zdepth = -zdepth/rayDir.z;","dists.y = min(zdepth,dists.y);"]).result),c=Be.substitute(c,"//VTK::BlendMode",`${e.renderable.getBlendMode()}`).result,i.Fragment=c,t.replaceShaderLight(i,o,a),t.replaceShaderClippingPlane(i,o,a)},t.replaceShaderLight=(i,o,a)=>{if(e.lightComplexity===0)return;let s=i.Fragment,c=0;o.getLights().forEach(l=>{l.getSwitch()&&(c+=1)}),s=Be.substitute(s,"//VTK::Light::Dec",["uniform int lightNum;","uniform bool twoSidedLighting;",`uniform vec3 lightColor[${c}];`,`uniform vec3 lightDirectionVC[${c}]; // normalized`,`uniform vec3 lightHalfAngleVC[${c}];`,"//VTK::Light::Dec"],!1).result,e.lightComplexity===3&&(s=Be.substitute(s,"//VTK::Light::Dec",[`uniform vec3 lightPositionVC[${c}];`,`uniform vec3 lightAttenuation[${c}];`,`uniform float lightConeAngle[${c}];`,`uniform float lightExponent[${c}];`,`uniform int lightPositional[${c}];`],!1).result),e.renderable.getVolumetricScatteringBlending()>0&&(s=Be.substitute(s,"//VTK::VolumeShadow::Dec",["uniform float volumetricScatteringBlending;","uniform float giReach;","uniform float volumeShadowSamplingDistFactor;","uniform float anisotropy;","uniform float anisotropy2;"],!1).result),e.renderable.getLocalAmbientOcclusion()&&a.getProperty().getAmbient()>0&&(s=Be.substitute(s,"//VTK::LAO::Dec",["uniform int kernelRadius;",`uniform vec2 kernelSample[${e.renderable.getLAOKernelRadius()}];`,"uniform int kernelSize;"],!1).result),i.Fragment=s},t.replaceShaderClippingPlane=(i,o,a)=>{let s=i.Fragment;if(e.renderable.getClippingPlanes().length>0){const c=e.renderable.getClippingPlanes().length;s=Be.substitute(s,"//VTK::ClipPlane::Dec",["uniform vec3 vClipPlaneNormals[6];","uniform float vClipPlaneDistances[6];","uniform vec3 vClipPlaneOrigins[6];","uniform int clip_numPlanes;","//VTK::ClipPlane::Dec","#define vtkClippingPlanesOn"],!1).result,s=Be.substitute(s,"//VTK::ClipPlane::Impl",[`for(int i = 0; i < ${c}; i++) {`," float rayDirRatio = dot(rayDir, vClipPlaneNormals[i]);"," float equationResult = dot(vertexVCVSOutput, vClipPlaneNormals[i]) + vClipPlaneDistances[i];"," if (rayDirRatio == 0.0)"," {"," if (equationResult < 0.0) dists.x = dists.y;"," continue;"," }"," float result = -1.0 * equationResult / rayDirRatio;"," if (rayDirRatio < 0.0) dists.y = min(dists.y, result);"," else dists.x = max(dists.x, result);","}","//VTK::ClipPlane::Impl"],!1).result}i.Fragment=s};const n=(i,o)=>{let a=0;i.getProperty().getShade()&&e.renderable.getBlendMode()===hv.COMPOSITE_BLEND&&(a=0,e.numberOfLights=0,o.forEach(s=>{s.getSwitch()>0&&(e.numberOfLights++,a===0&&(a=1)),a===1&&(e.numberOfLights>1||s.getIntensity()!==1||!s.lightTypeIsHeadLight())&&(a=2),a<3&&s.getPositional()&&(a=3)})),a!==e.lightComplexity&&(e.lightComplexity=a,t.modified())};t.getNeedToRebuildShaders=(i,o,a)=>{var y;const s=a.getProperty();n(a,o.getLights());const c=e.scalarTexture.getComponents(),l=[],f=[];for(let m=0;m<c;m++)l.push(s.getOpacityMode(m)),f.push(s.getForceNearestInterpolation(m));const u=e.currentInput.getSpatialExtent(),d=e.currentInput.getSpacing(),h=new Float64Array(3);Wn(h,(u[1]-u[0])*d[0],(u[3]-u[2])*d[1],(u[5]-u[4])*d[2]);const g=Ko(h)/t.getCurrentSampleDistance(o),p=!!e.zBufferTexture,v={iComps:s.getIndependentComponents(),colorMixPreset:s.getColorMixPreset(),interpolationType:s.getInterpolationType(),useLabelOutline:t.isLabelmapOutlineRequired(a),numComp:c,maxSamples:g,useGradientOpacity:s.getUseGradientOpacity(0),blendMode:e.renderable.getBlendMode(),hasZBufferTexture:p,opacityModes:l,forceNearestInterps:f};return((y=i.getProgram())==null?void 0:y.getHandle())===0||i.getShaderSourceTime().getMTime()<t.getMTime()||i.getShaderSourceTime().getMTime()<e.renderable.getMTime()||!e.previousState||!D_(e.previousState,v)?(e.previousState=v,!0):!1},t.updateShaders=(i,o,a)=>{if(t.getNeedToRebuildShaders(i,o,a)){const s={Vertex:null,Fragment:null,Geometry:null};t.buildShaders(s,o,a);const c=e._openGLRenderWindow.getShaderCache().readyShaderProgramArray(s.Vertex,s.Fragment,s.Geometry);c!==i.getProgram()&&(i.setProgram(c),i.getVAO().releaseGraphicsResources()),i.getShaderSourceTime().modified()}else e._openGLRenderWindow.getShaderCache().readyShaderProgram(i.getProgram());i.getVAO().bind(),t.setMapperShaderParameters(i,o,a),t.setCameraShaderParameters(i,o,a),t.setPropertyShaderParameters(i,o,a),t.getClippingPlaneShaderParameters(i,o,a)},t.setMapperShaderParameters=(i,o,a)=>{var f;const s=i.getProgram();i.getCABO().getElementCount()&&(e.VBOBuildTime.getMTime()>i.getAttributeUpdateTime().getMTime()||i.getShaderSourceTime().getMTime()>i.getAttributeUpdateTime().getMTime())&&(s.isAttributeUsed("vertexDC")&&(i.getVAO().addAttributeArray(s,i.getCABO(),"vertexDC",i.getCABO().getVertexOffset(),i.getCABO().getStride(),e.context.FLOAT,3,e.context.FALSE)||zx("Error setting vertexDC in shader VAO.")),i.getAttributeUpdateTime().modified()),s.setUniformi("texture1",e.scalarTexture.getTextureUnit()),s.setUniformf("sampleDistance",t.getCurrentSampleDistance(o));const c=e.scalarTexture.getVolumeInfo(),l=e.renderable.getIpScalarRange();if((f=c==null?void 0:c.dataComputedScale)!=null&&f.length){const u=[],d=[];for(let h=0;h<4;h++)u[h]=l[0]*c.dataComputedScale[h]+c.dataComputedOffset[h],d[h]=l[1]*c.dataComputedScale[h]+c.dataComputedOffset[h],u[h]=(u[h]-c.offset[h])/c.scale[h],d[h]=(d[h]-c.offset[h])/c.scale[h];s.setUniform4f("ipScalarRangeMin",u[0],u[1],u[2],u[3]),s.setUniform4f("ipScalarRangeMax",d[0],d[1],d[2],d[3])}if(e.zBufferTexture!==null){s.setUniformi("zBufferTexture",e.zBufferTexture.getTextureUnit());const u=e._useSmallViewport?[e._smallViewportWidth,e._smallViewportHeight]:e._openGLRenderWindow.getFramebufferSize();s.setUniformf("vpZWidth",u[0]),s.setUniformf("vpZHeight",u[1])}},t.setCameraShaderParameters=(i,o,a)=>{const s=e.openGLCamera.getKeyMatrices(o),c=e.openGLVolume.getKeyMatrices();yn(e.modelToView,s.wcvc,c.mcwc);const l=i.getProgram(),f=e.openGLCamera.getRenderable(),u=f.getClippingRange();l.setUniformf("camThick",u[1]-u[0]),l.setUniformf("camNear",u[0]),l.setUniformf("camFar",u[1]);const d=e.currentInput.getBounds(),h=e.currentInput.getDimensions(),g=new Float64Array(3),p=new Float64Array(3);let v=1,y=-1,m=1,w=-1;for(let B=0;B<8;++B){if(Wn(g,d[B%2],d[2+Math.floor(B/2)%2],d[4+Math.floor(B/4)]),At(g,g,e.modelToView),!f.getParallelProjection()){Un(p,g);const H=-u[0]/g[2];gr(g,p,H)}At(g,g,s.vcpc),v=Math.min(g[0],v),y=Math.max(g[0],y),m=Math.min(g[1],m),w=Math.max(g[1],w)}l.setUniformf("dcxmin",v),l.setUniformf("dcxmax",y),l.setUniformf("dcymin",m),l.setUniformf("dcymax",w),l.isUniformUsed("cameraParallel")&&l.setUniformi("cameraParallel",f.getParallelProjection());const x=e.currentInput.getSpatialExtent(),C=e.currentInput.getSpacing(),S=new Float64Array(3);Wn(S,(x[1]-x[0])*C[0],(x[3]-x[2])*C[1],(x[5]-x[4])*C[2]),l.setUniform3f("vSpacing",C[0],C[1],C[2]),Wn(g,x[0],x[2],x[4]),e.currentInput.indexToWorldVec3(g,g),At(g,g,e.modelToView),l.setUniform3f("vOriginVC",g[0],g[1],g[2]);const T=e.currentInput.getIndexToWorld();yn(e.idxToView,e.modelToView,T),yh(e.idxNormalMatrix,s.normalMatrix,c.normalMatrix),yh(e.idxNormalMatrix,e.idxNormalMatrix,e.currentInput.getDirectionByReference());const _=Ko(S)/t.getCurrentSampleDistance(o);_>e.renderable.getMaximumSamplesPerRay()&&Ste(`The number of steps required ${Math.ceil(_)} is larger than the
|
||
specified maximum number of steps ${e.renderable.getMaximumSamplesPerRay()}.
|
||
Please either change the
|
||
volumeMapper sampleDistance or its maximum number of samples.`);const E=new Float64Array(3);if(Wn(E,1,1,1),FY(E,E,S),l.setUniform3f("vVCToIJK",E[0],E[1],E[2]),l.setUniform3i("volumeDimensions",h[0],h[1],h[2]),l.setUniform3f("volumeSpacings",C[0],C[1],C[2]),!e._openGLRenderWindow.getWebgl2()){const B=e.scalarTexture.getVolumeInfo();l.setUniformf("texWidth",e.scalarTexture.getWidth()),l.setUniformf("texHeight",e.scalarTexture.getHeight()),l.setUniformi("xreps",B.xreps),l.setUniformi("xstride",B.xstride),l.setUniformi("ystride",B.ystride)}const b=new Float64Array(3),D=new Float64Array(3);for(let B=0;B<6;++B){switch(B){case 1:Wn(b,-1,0,0),Wn(D,x[0],x[2],x[4]);break;case 2:Wn(b,0,1,0),Wn(D,x[1],x[3],x[5]);break;case 3:Wn(b,0,-1,0),Wn(D,x[0],x[2],x[4]);break;case 4:Wn(b,0,0,1),Wn(D,x[1],x[3],x[5]);break;case 5:Wn(b,0,0,-1),Wn(D,x[0],x[2],x[4]);break;case 0:default:Wn(b,1,0,0),Wn(D,x[1],x[3],x[5]);break}Cv(b,b,e.idxNormalMatrix),At(D,D,e.idxToView);const H=-1*xt(D,b);l.setUniform3f(`vPlaneNormal${B}`,b[0],b[1],b[2]),l.setUniformf(`vPlaneDistance${B}`,H)}if(t.isLabelmapOutlineRequired(a)){const H=e.currentInput.getWorldToIndex();l.setUniformMatrix("vWCtoIDX",H);const A=o.getActiveCamera(),[F,G]=A.getClippingRange(),X=A.getDistance();A.setClippingRange(X,X+.1);const ee=e.openGLCamera.getKeyMatrices(o);Ar(e.projectionToWorld,ee.wcpc),A.setClippingRange(F,G),e.openGLCamera.getKeyMatrices(o),l.setUniformMatrix("PCWCMatrix",e.projectionToWorld);const ce=t.getRenderTargetSize();l.setUniformf("vpWidth",ce[0]),l.setUniformf("vpHeight",ce[1]);const Se=t.getRenderTargetOffset();l.setUniformf("vpOffsetX",Se[0]/ce[0]),l.setUniformf("vpOffsetY",Se[1]/ce[1])}if(Ar(e.projectionToView,s.vcpc),l.setUniformMatrix("PCVCMatrix",e.projectionToView),e.lightComplexity===0)return;let I=0;const P=[],O=[],L=[];if(o.getLights().forEach(B=>{if(B.getSwitch()>0){const A=B.getColor(),F=B.getIntensity();P[0+I*3]=A[0]*F,P[1+I*3]=A[1]*F,P[2+I*3]=A[2]*F;const G=B.getDirection();Wn(b,G[0],G[1],G[2]),Cv(b,b,s.normalMatrix),Un(b,b),O[0+I*3]=b[0],O[1+I*3]=b[1],O[2+I*3]=b[2],L[0+I*3]=-.5*b[0],L[1+I*3]=-.5*b[1],L[2+I*3]=-.5*(b[2]-1),I++}}),l.setUniformi("twoSidedLighting",o.getTwoSidedLighting()),l.setUniformi("lightNum",I),l.setUniform3fv("lightColor",P),l.setUniform3fv("lightDirectionVC",O),l.setUniform3fv("lightHalfAngleVC",L),e.lightComplexity===3){I=0;const B=[],H=[],A=[],F=[],G=[];o.getLights().forEach(X=>{if(X.getSwitch()>0){const ce=X.getAttenuationValues();H[0+I*3]=ce[0],H[1+I*3]=ce[1],H[2+I*3]=ce[2],F[I]=X.getExponent(),A[I]=X.getConeAngle(),G[I]=X.getPositional();const Se=X.getTransformedPosition();At(Se,Se,e.modelToView),B[0+I*3]=Se[0],B[1+I*3]=Se[1],B[2+I*3]=Se[2],I+=1}}),l.setUniform3fv("lightPositionVC",B),l.setUniform3fv("lightAttenuation",H),l.setUniformfv("lightConeAngle",A),l.setUniformfv("lightExponent",F),l.setUniformiv("lightPositional",G)}if(e.renderable.getVolumetricScatteringBlending()>0&&(l.setUniformf("giReach",e.renderable.getGlobalIlluminationReach()),l.setUniformf("volumetricScatteringBlending",e.renderable.getVolumetricScatteringBlending()),l.setUniformf("volumeShadowSamplingDistFactor",e.renderable.getVolumeShadowSamplingDistFactor()),l.setUniformf("anisotropy",e.renderable.getAnisotropy()),l.setUniformf("anisotropy2",e.renderable.getAnisotropy()**2)),e.renderable.getLocalAmbientOcclusion()&&a.getProperty().getAmbient()>0){const B=e.renderable.getLAOKernelSize();l.setUniformi("kernelSize",B);const H=[];for(let A=0;A<B;A++)H[A*2]=Math.random()*.5,H[A*2+1]=Math.random()*.5;l.setUniform2fv("kernelSample",H),l.setUniformi("kernelRadius",e.renderable.getLAOKernelRadius())}},t.setPropertyShaderParameters=(i,o,a)=>{const s=i.getProgram();s.setUniformi("ctexture",e.colorTexture.getTextureUnit()),s.setUniformi("otexture",e.opacityTexture.getTextureUnit()),s.setUniformi("jtexture",e.jitterTexture.getTextureUnit()),s.setUniformi("ttexture",e.labelOutlineThicknessTexture.getTextureUnit());const c=e.scalarTexture.getVolumeInfo(),l=a.getProperty(),f=e.scalarTexture.getComponents(),u=t.useIndependentComponents(l);if(u)for(let h=0;h<f;h++)s.setUniformf(`mix${h}`,a.getProperty().getComponentWeight(h));for(let h=0;h<f;h++){const g=u?h:0,p=c.scale[h],y=l.getScalarOpacity(g).getRange(),m=p/(y[1]-y[0]),w=(c.offset[h]-y[0])/(y[1]-y[0]);s.setUniformf(`oshift${h}`,w),s.setUniformf(`oscale${h}`,m);const C=l.getRGBTransferFunction(g).getRange(),S=(c.offset[h]-C[0])/(C[1]-C[0]),T=p/(C[1]-C[0]);s.setUniformf(`cshift${h}`,S),s.setUniformf(`cscale${h}`,T)}if(e.gopacity)if(u)for(let h=0;h<f;++h){const g=c.scale[h];if(l.getUseGradientOpacity(h)){const v=l.getGradientOpacityMinimumOpacity(h),y=l.getGradientOpacityMaximumOpacity(h);s.setUniformf(`gomin${h}`,v),s.setUniformf(`gomax${h}`,y);const m=[l.getGradientOpacityMinimumValue(h),l.getGradientOpacityMaximumValue(h)];s.setUniformf(`goscale${h}`,g*(y-v)/(m[1]-m[0])),s.setUniformf(`goshift${h}`,-m[0]*(y-v)/(m[1]-m[0])+v)}else s.setUniformf(`gomin${h}`,1),s.setUniformf(`gomax${h}`,1),s.setUniformf(`goscale${h}`,0),s.setUniformf(`goshift${h}`,1)}else{const h=c.scale[f-1],g=l.getGradientOpacityMinimumOpacity(0),p=l.getGradientOpacityMaximumOpacity(0);s.setUniformf("gomin0",g),s.setUniformf("gomax0",p);const v=[l.getGradientOpacityMinimumValue(0),l.getGradientOpacityMaximumValue(0)];s.setUniformf("goscale0",h*(p-g)/(v[1]-v[0])),s.setUniformf("goshift0",-v[0]*(p-g)/(v[1]-v[0])+g)}if(t.isLabelmapOutlineRequired(a)===!0){const h=a.getProperty().getLabelOutlineOpacity();s.setUniformf("outlineOpacity",h)}e.lightComplexity>0&&(s.setUniformf("vAmbient",l.getAmbient()),s.setUniformf("vDiffuse",l.getDiffuse()),s.setUniformf("vSpecular",l.getSpecular()),s.setUniformf("vSpecularPower",l.getSpecularPower()))},t.getClippingPlaneShaderParameters=(i,o,a)=>{if(e.renderable.getClippingPlanes().length>0){const s=e.openGLCamera.getKeyMatrices(o),c=[],l=[],f=[],u=e.renderable.getClippingPlanes(),d=u.length;for(let g=0;g<d;++g){const p=u[g].getNormal(),v=u[g].getOrigin();Cv(p,p,s.normalMatrix),At(v,v,s.wcvc);const y=-1*xt(v,p);c.push(p[0]),c.push(p[1]),c.push(p[2]),l.push(y),f.push(v[0]),f.push(v[1]),f.push(v[2])}const h=i.getProgram();h.setUniform3fv("vClipPlaneNormals",c),h.setUniformfv("vClipPlaneDistances",l),h.setUniform3fv("vClipPlaneOrigins",f),h.setUniformi("clip_numPlanes",d)}},t.delete=Y1(()=>{e._animationRateSubscription&&(e._animationRateSubscription.unsubscribe(),e._animationRateSubscription=null)},()=>{e._openGLRenderWindow&&r(e._openGLRenderWindow)},t.delete),t.getRenderTargetSize=()=>{if(e._useSmallViewport)return[e._smallViewportWidth,e._smallViewportHeight];const{usize:i,vsize:o}=e._openGLRenderer.getTiledSizeAndOrigin();return[i,o]},t.getRenderTargetOffset=()=>{const{lowerLeftU:i,lowerLeftV:o}=e._openGLRenderer.getTiledSizeAndOrigin();return[i,o]},t.getCurrentSampleDistance=i=>{const o=i.getVTKWindow().getInteractor(),a=e.renderable.getSampleDistance();if(o.isAnimating()){const s=e.renderable.getInteractionSampleDistanceFactor();return a*s}return a},t.renderPieceStart=(i,o)=>{const a=i.getVTKWindow().getInteractor();if(e._lastScale||(e._lastScale=e.renderable.getInitialInteractionScale()),e._useSmallViewport=!1,a.isAnimating()&&e._lastScale>1.5&&(e._useSmallViewport=!0),e._animationRateSubscription||(e._animationRateSubscription=a.onAnimationFrameRateUpdate(()=>{if(e.renderable.getAutoAdjustSampleDistances()){const c=a.getRecentAnimationFrameRate(),l=a.getDesiredUpdateRate()/c;(l>1.15||l<.85)&&(e._lastScale*=l),e._lastScale>400&&(e._lastScale=400),e._lastScale<1.5&&(e._lastScale=1.5)}else e._lastScale=e.renderable.getImageSampleDistance()*e.renderable.getImageSampleDistance()})),e._useSmallViewport){const c=e._openGLRenderWindow.getFramebufferSize(),l=1/Math.sqrt(e._lastScale);if(e._smallViewportWidth=Math.ceil(l*c[0]),e._smallViewportHeight=Math.ceil(l*c[1]),e._smallViewportHeight>c[1]&&(e._smallViewportHeight=c[1]),e._smallViewportWidth>c[0]&&(e._smallViewportWidth=c[0]),e.framebuffer.saveCurrentBindingsAndBuffers(),e.framebuffer.getGLFramebuffer()===null)e.framebuffer.create(c[0],c[1]),e.framebuffer.populateFramebuffer();else{const u=e.framebuffer.getSize();(!u||u[0]!==c[0]||u[1]!==c[1])&&(e.framebuffer.create(c[0],c[1]),e.framebuffer.populateFramebuffer())}e.framebuffer.bind();const f=e.context;f.clearColor(0,0,0,0),f.colorMask(!0,!0,!0,!0),f.clear(f.COLOR_BUFFER_BIT),f.viewport(0,0,e._smallViewportWidth,e._smallViewportHeight),e.fvp=[e._smallViewportWidth/c[0],e._smallViewportHeight/c[1]]}e.context.disable(e.context.DEPTH_TEST),t.updateBufferObjects(i,o),o.getProperty().getInterpolationType()===mS.NEAREST?(e.scalarTexture.setMinificationFilter(Pt.NEAREST),e.scalarTexture.setMagnificationFilter(Pt.NEAREST)):(e.scalarTexture.setMinificationFilter(Pt.LINEAR),e.scalarTexture.setMagnificationFilter(Pt.LINEAR)),e.zBufferTexture!==null&&e.zBufferTexture.activate()},t.renderPieceDraw=(i,o)=>{const a=e.context;e.scalarTexture.activate(),e.opacityTexture.activate(),e.labelOutlineThicknessTexture.activate(),e.colorTexture.activate(),e.jitterTexture.activate(),t.updateShaders(e.tris,i,o),a.drawArrays(a.TRIANGLES,0,e.tris.getCABO().getElementCount()),e.tris.getVAO().release(),e.scalarTexture.deactivate(),e.colorTexture.deactivate(),e.opacityTexture.deactivate(),e.labelOutlineThicknessTexture.deactivate(),e.jitterTexture.deactivate()},t.renderPieceFinish=(i,o)=>{if(e.zBufferTexture!==null&&e.zBufferTexture.deactivate(),e._useSmallViewport){if(e.framebuffer.restorePreviousBindingsAndBuffers(),e.copyShader===null){e.copyShader=e._openGLRenderWindow.getShaderCache().readyShaderProgramArray(["//VTK::System::Dec","attribute vec4 vertexDC;","uniform vec2 tfactor;","varying vec2 tcoord;","void main() { tcoord = vec2(vertexDC.x*0.5 + 0.5, vertexDC.y*0.5 + 0.5) * tfactor; gl_Position = vertexDC; }"].join(`
|
||
`),["//VTK::System::Dec","//VTK::Output::Dec","uniform sampler2D texture1;","varying vec2 tcoord;","void main() { gl_FragData[0] = texture2D(texture1,tcoord); }"].join(`
|
||
`),"");const l=e.copyShader;e.copyVAO=u4.newInstance(),e.copyVAO.setOpenGLRenderWindow(e._openGLRenderWindow),e.tris.getCABO().bind(),e.copyVAO.addAttributeArray(l,e.tris.getCABO(),"vertexDC",e.tris.getCABO().getVertexOffset(),e.tris.getCABO().getStride(),e.context.FLOAT,3,e.context.FALSE)||zx("Error setting vertexDC in copy shader VAO.")}else e._openGLRenderWindow.getShaderCache().readyShaderProgram(e.copyShader);const a=e._openGLRenderWindow.getFramebufferSize();e.context.viewport(0,0,a[0],a[1]);const s=e.framebuffer.getColorTexture();s.activate(),e.copyShader.setUniformi("texture",s.getTextureUnit()),e.copyShader.setUniform2f("tfactor",e.fvp[0],e.fvp[1]);const c=e.context;c.blendFuncSeparate(c.ONE,c.ONE_MINUS_SRC_ALPHA,c.ONE,c.ONE_MINUS_SRC_ALPHA),e.context.drawArrays(e.context.TRIANGLES,0,e.tris.getCABO().getElementCount()),s.deactivate(),c.blendFuncSeparate(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA,c.ONE,c.ONE_MINUS_SRC_ALPHA)}},t.renderPiece=(i,o)=>{if(t.invokeEvent({type:"StartEvent"}),e.renderable.update(),e.currentInput=e.renderable.getInputData(),t.invokeEvent({type:"EndEvent"}),!e.currentInput){zx("No input!");return}t.renderPieceStart(i,o),t.renderPieceDraw(i,o),t.renderPieceFinish(i,o)},t.computeBounds=(i,o)=>{if(!t.getInput()){Gh(e.Bounds);return}e.bounds=t.getInput().getBounds()},t.updateBufferObjects=(i,o)=>{t.getNeedToRebuildBufferObjects(i,o)&&t.buildBufferObjects(i,o)},t.getNeedToRebuildBufferObjects=(i,o)=>{var a,s,c;return e.VBOBuildTime.getMTime()<t.getMTime()||e.VBOBuildTime.getMTime()<o.getMTime()||e.VBOBuildTime.getMTime()<e.renderable.getMTime()||e.VBOBuildTime.getMTime()<o.getProperty().getMTime()||e.VBOBuildTime.getMTime()<e.currentInput.getMTime()||!((a=e.scalarTexture)!=null&&a.getHandle())||!((s=e.colorTexture)!=null&&s.getHandle())||!((c=e.labelOutlineThicknessTexture)!=null&&c.getHandle())},t.buildBufferObjects=(i,o)=>{var T,_;const a=e.currentInput;if(!a)return;const s=a.getPointData()&&a.getPointData().getScalars();if(!s)return;const c=o.getProperty();if(!e.jitterTexture.getHandle()){const E=new Uint8Array(1024);for(let b=0;b<32*32;++b)E[b]=255*Math.random();e.jitterTexture.setMinificationFilter(Pt.LINEAR),e.jitterTexture.setMagnificationFilter(Pt.LINEAR),e.jitterTexture.create2DFromRaw(32,32,1,rn.UNSIGNED_CHAR,E)}const l=s.getNumberOfComponents(),f=t.useIndependentComponents(c),u=f?l:1,d=c.getScalarOpacity(),h=e._openGLRenderWindow.getGraphicsResourceForObject(d);let g=il(d,f,u);if(!(h!=null&&h.oglObject)||h.hash!==g){e.opacityTexture=mr.newInstance(),e.opacityTexture.setOpenGLRenderWindow(e._openGLRenderWindow);const E=1024,b=E*2*u,D=new Float32Array(b),I=new Float32Array(E);for(let P=0;P<u;++P){const O=c.getScalarOpacity(P),L=t.getCurrentSampleDistance(i)/c.getScalarOpacityUnitDistance(P),B=O.getRange();O.getTable(B[0],B[1],E,I,1);for(let H=0;H<E;++H)D[P*E*2+H]=1-(1-I[H])**L,D[P*E*2+H+E]=D[P*E*2+H]}if(e.opacityTexture.resetFormatAndType(),e.opacityTexture.setMinificationFilter(Pt.LINEAR),e.opacityTexture.setMagnificationFilter(Pt.LINEAR),e._openGLRenderWindow.getWebgl2()||e.context.getExtension("OES_texture_float")&&e.context.getExtension("OES_texture_float_linear"))e.opacityTexture.create2DFromRaw(E,2*u,1,rn.FLOAT,D);else{const P=new Uint8ClampedArray(b);for(let O=0;O<b;++O)P[O]=255*D[O];e.opacityTexture.create2DFromRaw(E,2*u,1,rn.UNSIGNED_CHAR,P)}d&&(e._openGLRenderWindow.setGraphicsResourceForObject(d,e.opacityTexture,g),d!==e._scalarOpacityFunc&&(e._openGLRenderWindow.registerGraphicsResourceUser(d,t),e._openGLRenderWindow.unregisterGraphicsResourceUser(e._scalarOpacityFunc,t)),e._scalarOpacityFunc=d)}else e.opacityTexture=h.oglObject;const v=c.getRGBTransferFunction();g=il(v,f,u);const y=e._openGLRenderWindow.getGraphicsResourceForObject(v);if(!((T=y==null?void 0:y.oglObject)!=null&&T.getHandle())||(y==null?void 0:y.hash)!==g){e.colorTexture=mr.newInstance(),e.colorTexture.setOpenGLRenderWindow(e._openGLRenderWindow);const E=1024,b=E*2*u*3,D=new Uint8ClampedArray(b),I=new Float32Array(E*3);for(let P=0;P<u;++P){const O=c.getRGBTransferFunction(P),L=O.getRange();O.getTable(L[0],L[1],E,I,1);for(let B=0;B<E*3;++B)D[P*E*6+B]=255*I[B],D[P*E*6+B+E*3]=255*I[B]}e.colorTexture.resetFormatAndType(),e.colorTexture.setMinificationFilter(Pt.LINEAR),e.colorTexture.setMagnificationFilter(Pt.LINEAR),e.colorTexture.create2DFromRaw(E,2*u,3,rn.UNSIGNED_CHAR,D),v&&(e._openGLRenderWindow.setGraphicsResourceForObject(v,e.colorTexture,g),v!==e._colorTransferFunc&&(e._openGLRenderWindow.registerGraphicsResourceUser(v,t),e._openGLRenderWindow.unregisterGraphicsResourceUser(e._colorTransferFunc,t)),e._colorTransferFunc=v)}else e.colorTexture=y.oglObject;t.updateLabelOutlineThicknessTexture(o);const w=e._openGLRenderWindow.getGraphicsResourceForObject(s);g=E4(a,s);const x=!((_=w==null?void 0:w.oglObject)!=null&&_.getHandle())||(w==null?void 0:w.hash)!==g,C=e.renderable.getUpdatedExtents(),S=!!C.length;if(x&&!S){e.scalarTexture=mr.newInstance(),e.scalarTexture.setOpenGLRenderWindow(e._openGLRenderWindow);const E=a.getDimensions();e.scalarTexture.setOglNorm16Ext(e.context.getExtension("EXT_texture_norm16")),e.scalarTexture.resetFormatAndType(),e.scalarTexture.create3DFilterableFromDataArray(E[0],E[1],E[2],s),s&&(e._openGLRenderWindow.setGraphicsResourceForObject(s,e.scalarTexture,g),s!==e._scalars&&(e._openGLRenderWindow.registerGraphicsResourceUser(s,t),e._openGLRenderWindow.unregisterGraphicsResourceUser(e._scalars,t)),e._scalars=s)}else e.scalarTexture=w.oglObject;if(S){e.renderable.setUpdatedExtents([]);const E=a.getDimensions();e.scalarTexture.create3DFilterableFromDataArray(E[0],E[1],E[2],s,!1,C)}if(!e.tris.getCABO().getElementCount()){const E=new Float32Array(12);for(let P=0;P<4;P++)E[P*3]=P%2*2-1,E[P*3+1]=P>1?1:-1,E[P*3+2]=-1;const b=new Uint16Array(8);b[0]=3,b[1]=0,b[2]=1,b[3]=3,b[4]=3,b[5]=0,b[6]=3,b[7]=2;const D=bt.newInstance({numberOfComponents:3,values:E});D.setName("points");const I=bt.newInstance({numberOfComponents:1,values:b});e.tris.getCABO().createVBO(I,"polys",ao.SURFACE,{points:D,cellOffset:0})}e.VBOBuildTime.modified()},t.updateLabelOutlineThicknessTexture=i=>{var l;const o=i.getProperty().getLabelOutlineThickness(),a=e._openGLRenderWindow.getGraphicsResourceForObject(o),s=`${o.join("-")}`;if(!((l=a==null?void 0:a.oglObject)!=null&&l.getHandle())||(a==null?void 0:a.hash)!==s){e.labelOutlineThicknessTexture=mr.newInstance(),e.labelOutlineThicknessTexture.setOpenGLRenderWindow(e._openGLRenderWindow);const f=1024,u=1,d=f*u,h=new Uint8Array(d);for(let g=0;g<f;++g){const p=typeof o[g]<"u"?o[g]:o[0];h[g]=p}e.labelOutlineThicknessTexture.resetFormatAndType(),e.labelOutlineThicknessTexture.setMinificationFilter(Pt.NEAREST),e.labelOutlineThicknessTexture.setMagnificationFilter(Pt.NEAREST),e.labelOutlineThicknessTexture.create2DFromRaw(f,u,1,rn.UNSIGNED_CHAR,h),o&&(e._openGLRenderWindow.setGraphicsResourceForObject(o,e.labelOutlineThicknessTexture,s),o!==e._labelOutlineThicknessArray&&(e._openGLRenderWindow.registerGraphicsResourceUser(o,t),e._openGLRenderWindow.unregisterGraphicsResourceUser(e._labelOutlineThicknessArray,t)),e._labelOutlineThicknessArray=o)}else e.labelOutlineThicknessTexture=a.oglObject},t.isLabelmapOutlineRequired=i=>{const o=i.getProperty(),a=e.renderable;return o.getUseLabelOutline()||a.getBlendMode()===hv.LABELMAP_EDGE_PROJECTION_BLEND}}const Ete={context:null,VBOBuildTime:null,scalarTexture:null,opacityTexture:null,opacityTextureString:null,colorTexture:null,colorTextureString:null,jitterTexture:null,labelOutlineThicknessTexture:null,labelOutlineThicknessTextureString:null,tris:null,framebuffer:null,copyShader:null,copyVAO:null,lastXYF:1,targetXYF:1,zBufferTexture:null,lastZBufferTexture:null,lightComplexity:0,fullViewportTime:1,idxToView:null,idxNormalMatrix:null,modelToView:null,projectionToView:null,avgWindowArea:0,avgFrameTime:0};function DA(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Ete,r),Qn.extend(t,e,r),rl.implementBuildShadersWithReplacements(t,e,r),e.VBOBuildTime={},or(e.VBOBuildTime,{mtime:0}),e.tris=ul.newInstance(),e.jitterTexture=mr.newInstance(),e.jitterTexture.setWrapS(a1.REPEAT),e.jitterTexture.setWrapT(a1.REPEAT),e.framebuffer=ew.newInstance(),e.idxToView=It(new Float64Array(16)),e.idxNormalMatrix=ys(new Float64Array(9)),e.modelToView=It(new Float64Array(16)),e.projectionToView=It(new Float64Array(16)),e.projectionToWorld=It(new Float64Array(16)),Jr(t,e,["context"]),_te(t,e)}const IA=Rn(DA,"vtkOpenGLVolumeMapper");var OA={newInstance:IA,extend:DA};di("vtkVolumeMapper",IA);function b4(t,e){switch(t){case"Float32Array":return Float32Array;case"Uint8Array":return Uint8Array;case"Uint32Array":return Uint32Array;case"Uint16Array":case"Int16Array":return e?(console.debug(`${t} is not supported for volume rendering, switching back to Float32Array`),Float32Array):t==="Uint16Array"?Uint16Array:Int16Array;default:if(t)throw new Error("TargetBuffer should be Float32Array, Uint8Array, Uint16Array, Int16Array, or Uint32Array");return Float32Array}}function D4(t,e,r={}){const{isVolumeBuffer:n=!1}=r,i=b4(t,n),o=i.BYTES_PER_ELEMENT;return{numBytes:e*o,TypedArrayConstructor:i}}function Nr(t){return o1.get(t)}function Po(){return o1.getAll()}const My=t=>t&&typeof t=="object"&&Object.prototype.toString.call(t)!=="[object RegExp]"&&Object.prototype.toString.call(t)!=="[object Date]",bte=t=>Array.isArray(t)?[]:{},c1=(t,e)=>e&&e.clone===!0&&My(t)?Ti(bte(t),t,e):t,xD=(t,e,r)=>{const n=t.slice();return e.forEach(function(i,o){typeof n[o]>"u"?n[o]=c1(i,r):My(i)?n[o]=Ti(t[o],i,r):t.indexOf(i)===-1&&(n[o]=c1(i,r))}),n},Dte=(t,e,r)=>{const n={};return My(t)&&Object.keys(t).forEach(function(i){n[i]=c1(t[i],r)}),Object.keys(e).forEach(function(i){!My(e[i])||!t[i]?n[i]=c1(e[i],r):n[i]=Ti(t[i],e[i],r)}),n},Ti=(t={},e={},r=void 0)=>{const n=Array.isArray(e),o=(r||{arrayMerge:xD}).arrayMerge||xD;return n?Array.isArray(t)?o(t,e,r):c1(e,r):Dte(t,e,r)};/**
|
||
* @license
|
||
* Copyright 2019 Google LLC
|
||
* SPDX-License-Identifier: Apache-2.0
|
||
*/const MA=Symbol("Comlink.proxy"),Ite=Symbol("Comlink.endpoint"),PA=Symbol("Comlink.releaseProxy"),$x=Symbol("Comlink.finalizer"),bv=Symbol("Comlink.thrown"),RA=t=>typeof t=="object"&&t!==null||typeof t=="function",Ote={canHandle:t=>RA(t)&&t[MA],serialize(t){const{port1:e,port2:r}=new MessageChannel;return I4(t,e),[r,[r]]},deserialize(t){return t.start(),vS(t)}},Mte={canHandle:t=>RA(t)&&bv in t,serialize({value:t}){let e;return t instanceof Error?e={isError:!0,value:{message:t.message,name:t.name,stack:t.stack}}:e={isError:!1,value:t},[e,[]]},deserialize(t){throw t.isError?Object.assign(new Error(t.value.message),t.value):t.value}},LA=new Map([["proxy",Ote],["throw",Mte]]);function Pte(t,e){for(const r of t)if(e===r||r==="*"||r instanceof RegExp&&r.test(e))return!0;return!1}function I4(t,e=globalThis,r=["*"]){e.addEventListener("message",function n(i){if(!i||!i.data)return;if(!Pte(r,i.origin)){console.warn(`Invalid origin '${i.origin}' for comlink proxy`);return}const{id:o,type:a,path:s}=Object.assign({path:[]},i.data),c=(i.data.argumentList||[]).map(Xf);let l;try{const f=s.slice(0,-1).reduce((d,h)=>d[h],t),u=s.reduce((d,h)=>d[h],t);switch(a){case"GET":l=u;break;case"SET":f[s.slice(-1)[0]]=Xf(i.data.value),l=!0;break;case"APPLY":l=u.apply(f,c);break;case"CONSTRUCT":{const d=new u(...c);l=VA(d)}break;case"ENDPOINT":{const{port1:d,port2:h}=new MessageChannel;I4(t,h),l=kte(d,[d])}break;case"RELEASE":l=void 0;break;default:return}}catch(f){l={value:f,[bv]:0}}Promise.resolve(l).catch(f=>({value:f,[bv]:0})).then(f=>{const[u,d]=Ly(f);e.postMessage(Object.assign(Object.assign({},u),{id:o}),d),a==="RELEASE"&&(e.removeEventListener("message",n),AA(e),$x in t&&typeof t[$x]=="function"&&t[$x]())}).catch(f=>{const[u,d]=Ly({value:new TypeError("Unserializable return value"),[bv]:0});e.postMessage(Object.assign(Object.assign({},u),{id:o}),d)})}),e.start&&e.start()}function Rte(t){return t.constructor.name==="MessagePort"}function AA(t){Rte(t)&&t.close()}function vS(t,e){const r=new Map;return t.addEventListener("message",function(i){const{data:o}=i;if(!o||!o.id)return;const a=r.get(o.id);if(a)try{a(o)}finally{r.delete(o.id)}}),yS(t,r,[],e)}function l2(t){if(t)throw new Error("Proxy has been released and is not useable")}function NA(t){return s0(t,new Map,{type:"RELEASE"}).then(()=>{AA(t)})}const Py=new WeakMap,Ry="FinalizationRegistry"in globalThis&&new FinalizationRegistry(t=>{const e=(Py.get(t)||0)-1;Py.set(t,e),e===0&&NA(t)});function Lte(t,e){const r=(Py.get(e)||0)+1;Py.set(e,r),Ry&&Ry.register(t,e,t)}function Ate(t){Ry&&Ry.unregister(t)}function yS(t,e,r=[],n=function(){}){let i=!1;const o=new Proxy(n,{get(a,s){if(l2(i),s===PA)return()=>{Ate(o),NA(t),e.clear(),i=!0};if(s==="then"){if(r.length===0)return{then:()=>o};const c=s0(t,e,{type:"GET",path:r.map(l=>l.toString())}).then(Xf);return c.then.bind(c)}return yS(t,e,[...r,s])},set(a,s,c){l2(i);const[l,f]=Ly(c);return s0(t,e,{type:"SET",path:[...r,s].map(u=>u.toString()),value:l},f).then(Xf)},apply(a,s,c){l2(i);const l=r[r.length-1];if(l===Ite)return s0(t,e,{type:"ENDPOINT"}).then(Xf);if(l==="bind")return yS(t,e,r.slice(0,-1));const[f,u]=CD(c);return s0(t,e,{type:"APPLY",path:r.map(d=>d.toString()),argumentList:f},u).then(Xf)},construct(a,s){l2(i);const[c,l]=CD(s);return s0(t,e,{type:"CONSTRUCT",path:r.map(f=>f.toString()),argumentList:c},l).then(Xf)}});return Lte(o,t),o}function Nte(t){return Array.prototype.concat.apply([],t)}function CD(t){const e=t.map(Ly);return[e.map(r=>r[0]),Nte(e.map(r=>r[1]))]}const kA=new WeakMap;function kte(t,e){return kA.set(t,e),t}function VA(t){return Object.assign(t,{[MA]:!0})}function Ly(t){for(const[e,r]of LA)if(r.canHandle(t)){const[n,i]=r.serialize(t);return[{type:"HANDLER",name:e,value:n},i]}return[{type:"RAW",value:t},kA.get(t)||[]]}function Xf(t){switch(t.type){case"HANDLER":return LA.get(t.name).deserialize(t.value);case"RAW":return t.value}}function s0(t,e,r,n){return new Promise(i=>{const o=Vte();e.set(o,i),t.start&&t.start(),t.postMessage(Object.assign({id:o},r),n)})}function Vte(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}class O4{constructor(e){this.numRequests={[Qt.Interaction]:0,[Qt.Thumbnail]:0,[Qt.Prefetch]:0,[Qt.Compute]:0},this.id=e||gn(),this.requestPool={[Qt.Interaction]:{0:[]},[Qt.Thumbnail]:{0:[]},[Qt.Prefetch]:{0:[]},[Qt.Compute]:{0:[]}},this.grabDelay=5,this.awake=!1,this.numRequests={[Qt.Interaction]:0,[Qt.Thumbnail]:0,[Qt.Prefetch]:0,[Qt.Compute]:0},this.maxNumRequests={[Qt.Interaction]:6,[Qt.Thumbnail]:6,[Qt.Prefetch]:5,[Qt.Compute]:1e3}}setMaxSimultaneousRequests(e,r){this.maxNumRequests[e]=r}getMaxSimultaneousRequests(e){return this.maxNumRequests[e]}destroy(){this.timeoutHandle&&window.clearTimeout(this.timeoutHandle)}addRequest(e,r,n,i=0){const o={requestFn:e,type:r,additionalDetails:n};this.requestPool[r][i]===void 0&&(this.requestPool[r][i]=[]),this.requestPool[r][i].push(o),this.startGrabbing()}filterRequests(e){Object.keys(this.requestPool).forEach(r=>{const n=this.requestPool[r];Object.keys(n).forEach(i=>{n[i]=n[i].filter(o=>e(o))})})}clearRequestStack(e){if(!this.requestPool[e])throw new Error(`No category for the type ${e} found`);this.requestPool[e]={0:[]}}sendRequests(e){const r=this.maxNumRequests[e]-this.numRequests[e];let n=0;for(let i=0;i<r;i++){const o=this.getNextRequest(e);if(o===null)return!1;if(o){this.numRequests[e]++,this.awake=!0;let a;try{a=o.requestFn()}catch(s){console.warn("sendRequest failed",s)}a!=null&&a.finally?a.finally(()=>{this.numRequests[e]--,this.startAgain()}):(this.numRequests[e]--,n++)}}return n&&this.startAgain(),!0}getNextRequest(e){const r=this.getSortedPriorityGroups(e);for(const n of r)if(this.requestPool[e][n].length)return this.requestPool[e][n].shift();return null}startGrabbing(){const e=this.sendRequests(Qt.Interaction),r=this.sendRequests(Qt.Thumbnail),n=this.sendRequests(Qt.Prefetch),i=this.sendRequests(Qt.Compute);!e&&!r&&!n&&!i&&(this.awake=!1)}startAgain(){this.awake&&(this.grabDelay!==void 0?this.timeoutHandle||(this.timeoutHandle=window.setTimeout(()=>{this.timeoutHandle=null,this.startGrabbing()},this.grabDelay)):this.startGrabbing())}getSortedPriorityGroups(e){return Object.keys(this.requestPool[e]).map(Number).filter(n=>this.requestPool[e][n].length).sort((n,i)=>n-i)}getRequestPool(){return this.requestPool}}class FA{constructor(){this.workerRegistry={},this.workerPoolManager=new O4("webworker")}registerWorker(e,r,n={}){var c;const{maxWorkerInstances:i=1,overwrite:o=!1,autoTerminateOnIdle:a={enabled:!1,idleTimeThreshold:3e3}}=n;if(this.workerRegistry[e]&&!o){console.warn(`Worker type '${e}' is already registered...`);return}o&&((c=this.workerRegistry[e])!=null&&c.idleCheckIntervalId)&&clearInterval(this.workerRegistry[e].idleCheckIntervalId);const s={workerFn:null,instances:[],loadCounters:[],lastActiveTime:[],nativeWorkers:[],autoTerminateOnIdle:a.enabled,idleCheckIntervalId:null,idleTimeThreshold:a.idleTimeThreshold};s.loadCounters=Array(i).fill(0),s.lastActiveTime=Array(i).fill(null);for(let l=0;l<i;l++){const f=r();s.instances.push(vS(f)),s.nativeWorkers.push(f),s.workerFn=r}this.workerRegistry[e]=s}getNextWorkerAPI(e){const r=this.workerRegistry[e];if(!r)return console.error(`Worker type '${e}' is not registered.`),null;const n=r.instances.filter(a=>a!==null);let i=0,o=r.loadCounters[0]||0;for(let a=1;a<n.length;a++){const s=r.loadCounters[a]||0;s<o&&(i=a,o=s)}if(r.instances[i]===null){const a=r.workerFn();r.instances[i]=vS(a),r.nativeWorkers[i]=a}return r.loadCounters[i]+=1,{api:r.instances[i],index:i}}executeTask(e,r,n={},{requestType:i=Qt.Compute,priority:o=0,options:a={},callbacks:s=[]}={}){return new Promise((c,l)=>{const f=async()=>{const{api:u,index:d}=this.getNextWorkerAPI(e);if(!u){const h=new Error(`No available worker instance for '${e}'`);console.error(h),l(h);return}try{let h=[];s.length&&(h=s.map(v=>VA(v)));const g=this.workerRegistry[e];g.processing=!0;const p=await u[r](n,...h);g.processing=!1,g.lastActiveTime[d]=Date.now(),g.autoTerminateOnIdle&&!g.idleCheckIntervalId&&g.idleTimeThreshold&&(g.idleCheckIntervalId=setInterval(()=>{this.terminateIdleWorkers(e,g.idleTimeThreshold)},g.idleTimeThreshold)),c(p)}catch(h){console.error(`Error executing method '${r}' on worker '${e}':`,h),l(h)}finally{this.workerRegistry[e].loadCounters[d]--}};this.workerPoolManager.addRequest(f,i,a,o)})}terminateIdleWorkers(e,r){const n=this.workerRegistry[e];if(n.processing)return;const i=Date.now();n.instances.forEach((o,a)=>{const s=n.lastActiveTime[a],c=s!==null&&n.loadCounters[a]>0,l=i-s;!c&&l>r&&this.terminateWorkerInstance(e,a)})}terminate(e){const r=this.workerRegistry[e];if(!r){console.error(`Worker type '${e}' is not registered.`);return}r.instances.forEach((n,i)=>{this.terminateWorkerInstance(e,i)})}terminateWorkerInstance(e,r){const n=this.workerRegistry[e],i=n.instances[r];i!==null&&(i[PA](),n.nativeWorkers[r].terminate(),n.instances[r]=null,n.lastActiveTime[r]=null)}}const jx=4,Fte=5,Ute=1,SD=[1,1];function TD({ext:t,filterType:e,texData:r,internalFormat:n,glDataType:i}){try{const o=document.createElement("canvas");o.width=jx,o.height=jx;const a=o.getContext("webgl2");if(!a)return!1;const s=`#version 300 es
|
||
void main() {
|
||
gl_PointSize = ${jx.toFixed(1)};
|
||
gl_Position = vec4(0, 0, 0, 1);
|
||
}
|
||
`,c=`#version 300 es
|
||
precision highp float;
|
||
precision highp int;
|
||
precision highp sampler2D;
|
||
|
||
uniform sampler2D u_image;
|
||
|
||
out vec4 color;
|
||
|
||
void main() {
|
||
vec4 intColor = texture(u_image, gl_PointCoord.xy);
|
||
color = vec4(vec3(intColor.rrr), 1);
|
||
}
|
||
`;let l;if(t&&(l=a.getExtension(t),!l))return!1;const f=a.createShader(a.VERTEX_SHADER);if(a.shaderSource(f,s),a.compileShader(f),!a.getShaderParameter(f,a.COMPILE_STATUS))return!1;const u=a.createShader(a.FRAGMENT_SHADER);if(a.shaderSource(u,c),a.compileShader(u),!a.getShaderParameter(u,a.COMPILE_STATUS))return!1;const d=a.createProgram();if(a.attachShader(d,f),a.attachShader(d,u),a.linkProgram(d),!a.getProgramParameter(d,a.LINK_STATUS))return!1;const h=a.createTexture();a.bindTexture(a.TEXTURE_2D,h),a.texImage2D(a.TEXTURE_2D,0,n(a,l),Fte,Ute,0,a.RED,i(a,l),r);const g=e==="LINEAR"?a.LINEAR:a.NEAREST;a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,g),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,g),a.useProgram(d),a.drawArrays(a.POINTS,0,1);const p=new Uint8Array(4);a.readPixels(SD[0],SD[1],1,1,a.RGBA,a.UNSIGNED_BYTE,p);const[v,y,m]=p,w=a.getExtension("WEBGL_lose_context");return w&&w.loseContext(),v===y&&y===m&&v!==0}catch{return!1}}function Bte(){const t=new Int16Array([32767,2e3,3e3,4e3,5e3,16784,7e3,8e3,9e3,32767]);return{norm16:TD({ext:"EXT_texture_norm16",filterType:"NEAREST",texData:t,internalFormat:(e,r)=>r.R16_SNORM_EXT,glDataType:e=>e.SHORT}),norm16Linear:TD({ext:"EXT_texture_norm16",filterType:"LINEAR",texData:t,internalFormat:(e,r)=>r.R16_SNORM_EXT,glDataType:e=>e.SHORT})}}let Fu=!1;const wS={gpuTier:{tier:2},isMobile:!1,rendering:{useCPURendering:!1,preferSizeOverAccuracy:!1,strictZSpacingForVolumeViewport:!0},peerImport:t=>null};let ic={...wS,rendering:{...wS.rendering}},yp=null,UA=!1;function Gte(){const t=document.createElement("canvas");return t.getContext("webgl2")||t.getContext("webgl")||t.getContext("experimental-webgl")}function BA(){const t=Gte();return t instanceof WebGLRenderingContext||t instanceof WebGL2RenderingContext}function Wte(){const t=Bte();return t.norm16&&t.norm16Linear}function GA(){return/iPad|iPhone|iPod/.test(navigator.platform)?!0:navigator.maxTouchPoints&&navigator.maxTouchPoints>2&&navigator.platform.includes("MacIntel")}function WA(t=ic){var r;return Fu||(UA=Wte(),ic=Ti(wS,t),GA()&&((r=t.rendering)!=null&&r.preferSizeOverAccuracy?ic.rendering.preferSizeOverAccuracy=!0:console.log("norm16 texture not supported, you can turn on the preferSizeOverAccuracy flag to use native data type, but be aware of the inaccuracy of the rendering in high bits")),BA()?console.log("CornerstoneRender: using GPU rendering"):(console.log("CornerstoneRender: GPU not detected, using CPU rendering"),ic.rendering.useCPURendering=!0),Fu=!0,yp||(yp=new FA),Fu)}function zte(){return UA}function $te(t,e=!0){ic.rendering.useCPURendering=t,Fu=!0,e&&gw()}function jte(t){ic.rendering.preferSizeOverAccuracy=t,Fu=!0,gw()}function dw(){return!GA()}function Hte(){ic.rendering.useCPURendering=!BA(),gw()}function X0(){return ic.rendering.useCPURendering}function zA(){return Fu}function Kte(){Fu=!1}function hw(){return ic}function qte(t){ic=t,gw()}function gw(){Po().forEach(t=>{t.getViewports().forEach(e=>{e.updateRenderingPipeline()})})}function fl(){return yp||(yp=new FA),yp}async function $A(t){return ic.peerImport(t)}function Xte(t,e){e.classHierarchy.push("vtkStreamingOpenGLVolumeMapper"),t.buildBufferObjects=(r,n)=>{var p;const i=e.currentInput;if(!i)return;const o=n.getProperty();if(!e.jitterTexture.getHandle()){const v=new Uint8Array(1024);for(let y=0;y<32*32;++y)v[y]=255*Math.random();e.jitterTexture.setMinificationFilter(Pt.LINEAR),e.jitterTexture.setMagnificationFilter(Pt.LINEAR),e.jitterTexture.create2DFromRaw(32,32,1,rn.UNSIGNED_CHAR,v)}const{numberOfComponents:a}=i.get("numberOfComponents"),s=t.useIndependentComponents(o),c=o.getScalarOpacity(),l=e._openGLRenderWindow.getGraphicsResourceForObject(c);let f=il(c,s,a);if(!(l!=null&&l.oglObject)||l.hash!==f){e.opacityTexture=mr.newInstance(),e.opacityTexture.setOpenGLRenderWindow(e._openGLRenderWindow);const v=1024,y=v*2*a,m=new Float32Array(y),w=new Float32Array(v);for(let x=0;x<a;++x){const C=o.getScalarOpacity(x),S=t.getCurrentSampleDistance(r)/o.getScalarOpacityUnitDistance(x),T=C.getRange();C.getTable(T[0],T[1],v,w,1);for(let _=0;_<v;++_)m[x*v*2+_]=1-(1-w[_])**S,m[x*v*2+_+v]=m[x*v*2+_]}if(e.opacityTexture.resetFormatAndType(),e.opacityTexture.setMinificationFilter(Pt.LINEAR),e.opacityTexture.setMagnificationFilter(Pt.LINEAR),e._openGLRenderWindow.getWebgl2()&&e.context.getExtension("OES_texture_float")&&e.context.getExtension("OES_texture_float_linear"))e.opacityTexture.create2DFromRaw(v,2*a,1,rn.FLOAT,m);else{const x=new Uint8ClampedArray(y);for(let C=0;C<y;++C)x[C]=255*m[C];e.opacityTexture.create2DFromRaw(v,2*a,1,rn.UNSIGNED_CHAR,x)}c&&(e._openGLRenderWindow.setGraphicsResourceForObject(c,e.opacityTexture,f),c!==e._scalarOpacityFunc&&(e._openGLRenderWindow.registerGraphicsResourceUser(c,t),e._openGLRenderWindow.unregisterGraphicsResourceUser(e._scalarOpacityFunc,t)),e._scalarOpacityFunc=c)}else e.opacityTexture=l.oglObject;const d=o.getRGBTransferFunction();f=il(d,s,a);const h=e._openGLRenderWindow.getGraphicsResourceForObject(d);if(!((p=h==null?void 0:h.oglObject)!=null&&p.getHandle())||(h==null?void 0:h.hash)!==f){e.colorTexture=mr.newInstance(),e.colorTexture.setOpenGLRenderWindow(e._openGLRenderWindow);const v=1024,y=v*2*a*3,m=new Uint8ClampedArray(y),w=new Float32Array(v*3);for(let x=0;x<a;++x){const C=o.getRGBTransferFunction(x),S=C.getRange();C.getTable(S[0],S[1],v,w,1);for(let T=0;T<v*3;++T)m[x*v*6+T]=255*w[T],m[x*v*6+T+v*3]=255*w[T]}e.colorTexture.resetFormatAndType(),e.colorTexture.setMinificationFilter(Pt.LINEAR),e.colorTexture.setMagnificationFilter(Pt.LINEAR),e.colorTexture.create2DFromRaw(v,2*a,3,rn.UNSIGNED_CHAR,m),d&&(e._openGLRenderWindow.setGraphicsResourceForObject(d,e.colorTexture,f),d!==e._colorTransferFunc&&(e._openGLRenderWindow.registerGraphicsResourceUser(d,t),e._openGLRenderWindow.unregisterGraphicsResourceUser(e._colorTransferFunc,t)),e._colorTransferFunc=d)}else e.colorTexture=h.oglObject;if(t.updateLabelOutlineThicknessTexture(n),f=`${i.getMTime()}-${e.scalarTexture.getMTime()}`,e.scalarTextureString!==f){const v=i.getDimensions();e.scalarTexture.setOpenGLRenderWindow(e._openGLRenderWindow),e.scalarTexture.enableUseHalfFloat(!1);const y=e.scalarTexture.getTextureParameters(),m=i.get("dataType").dataType;let w=!0;if((y==null?void 0:y.dataType)===m&&(y==null?void 0:y.width)===v[0]&&(y==null?void 0:y.height)===v[1]&&(y==null?void 0:y.depth)===v[2]&&(w=!1),w){const x=e.context.getExtension("EXT_texture_norm16");e.scalarTexture.setOglNorm16Ext(zte()?x:null),e.scalarTexture.resetFormatAndType(),e.scalarTexture.setTextureParameters({width:v[0],height:v[1],depth:v[2],numberOfComponents:a,dataType:m}),e.scalarTexture.create3DFromRaw(v[0],v[1],v[2],a,m,null),e.scalarTexture.update3DFromRaw()}else e.scalarTexture.deactivate(),e.scalarTexture.update3DFromRaw();e.scalarTextureString=f}if(!e.tris.getCABO().getElementCount()){const v=new Float32Array(12);for(let x=0;x<4;x++)v[x*3]=x%2*2-1,v[x*3+1]=x>1?1:-1,v[x*3+2]=-1;const y=new Uint16Array(8);y[0]=3,y[1]=0,y[2]=1,y[3]=3,y[4]=3,y[5]=0,y[6]=3,y[7]=2;const m=bt.newInstance({numberOfComponents:3,values:v});m.setName("points");const w=bt.newInstance({numberOfComponents:1,values:y});e.tris.getCABO().createVBO(w,"polys",ao.SURFACE,{points:m,cellOffset:0})}e.VBOBuildTime.modified()},t.getNeedToRebuildBufferObjects=(r,n)=>{var i,o,a,s,c,l;return e.VBOBuildTime.getMTime()<t.getMTime()||e.VBOBuildTime.getMTime()<n.getMTime()||e.VBOBuildTime.getMTime()<e.renderable.getMTime()||e.VBOBuildTime.getMTime()<n.getProperty().getMTime()||e.VBOBuildTime.getMTime()<e.currentInput.getMTime()||e.VBOBuildTime.getMTime()<((i=e.scalarTexture)==null?void 0:i.getMTime())||e.VBOBuildTime.getMTime()<((o=e.colorTexture)==null?void 0:o.getMTime())||e.VBOBuildTime.getMTime()<((a=e.labelOutlineThicknessTexture)==null?void 0:a.getMTime())||!((s=e.scalarTexture)!=null&&s.getHandle())||!((c=e.colorTexture)!=null&&c.getHandle())||!((l=e.labelOutlineThicknessTexture)!=null&&l.getHandle())}}const Yte={};function Jte(t,e,r={}){Object.assign(e,Yte,r),OA.extend(t,e,r),e.scalarTexture=r.scalarTexture,e.previousState={},Xte(t,e)}const Zte=Z.newInstance(Jte,"vtkStreamingOpenGLVolumeMapper"),Qte={newInstance:Zte},jA=Object.create(null);function qi(t,e){jA[t]=e}function ene(t,e){e.classHierarchy.push("vtkStreamingOpenGLViewNodeFactory"),t.createNode=r=>{if(r.isDeleted())return null;let n=0,i=r.getClassName(n++),o=!1;const a=Object.keys(e.overrides);for(;i&&!o;)a.includes(i)?o=!0:i=r.getClassName(n++);if(!o)return null;const s=e.getModelInitialValues(r),c=e.overrides[i](s);return c.setMyFactory(t),c},e.overrides=jA,e.getModelInitialValues=r=>{const n={};return r.getClassName()==="vtkSharedVolumeMapper"&&(n.scalarTexture=r.getScalarTexture()),n}}const tne={};function HA(t,e,r={}){Object.assign(e,tne,r),X_.extend(t,e,r),ene(t,e),qi("vtkActor",JZ.newInstance),qi("vtkActor2D",tQ.newInstance),qi("vtkCamera",oQ.newInstance),qi("vtkGlyph3DMapper",Iee.newInstance),qi("vtkImageMapper",Nee.newInstance),qi("vtkImageCPRMapper",Bee.newInstance),qi("vtkImageSlice",$ee.newInstance),qi("vtkMapper",uw.newInstance),qi("vtkPixelSpaceCallbackMapper",Xee.newInstance),qi("vtkRenderer",ete.newInstance),qi("vtkSkybox",ite.newInstance),qi("vtkSphereMapper",ute.newInstance),qi("vtkStickMapper",pte.newInstance),qi("vtkTexture",mr.newInstance),qi("vtkVolume",wte.newInstance),qi("vtkVolumeMapper",OA.newInstance),qi("vtkSharedVolumeMapper",Qte.newInstance)}const nne=Z.newInstance(HA,"vtkStreamingOpenGLViewNodeFactory"),rne={newInstance:nne,extend:HA};function ine(t,e){e.classHierarchy.push("vtkStreamingOpenGLRenderWindow")}function KA(t,e,r={}){Object.assign(e,r),KZ.extend(t,e,r),e.myFactory=rne.newInstance(),qi("vtkRenderWindow",qA),ine(t,e)}const qA=Z.newInstance(KA,"vtkStreamingOpenGLRenderWindow"),one={newInstance:qA,extend:KA},{vtkDebugMacro:u2}=Z;function ane(t,e){e.classHierarchy.push("vtkCamera");const r=new Float64Array(3),n=new Float64Array([0,0,-1]),i=new Float64Array([0,1,0]),o=It(new Float64Array(16)),a=It(new Float64Array(16)),s=new Float64Array(3),c=new Float64Array(3),l=new Float64Array(3),f=It(new Float64Array(16)),u=It(new Float64Array(16)),d=new Float64Array(3),h=new Float64Array(3);function g(){e.viewPlaneNormal[0]=-e.directionOfProjection[0],e.viewPlaneNormal[1]=-e.directionOfProjection[1],e.viewPlaneNormal[2]=-e.directionOfProjection[2]}t.orthogonalizeViewUp=()=>{const p=t.getViewMatrix();e.viewUp[0]=p[4],e.viewUp[1]=p[5],e.viewUp[2]=p[6],t.modified()},t.setPosition=(p,v,y)=>{p===e.position[0]&&v===e.position[1]&&y===e.position[2]||(e.position[0]=p,e.position[1]=v,e.position[2]=y,t.computeDistance(),t.modified())},t.setFocalPoint=(p,v,y)=>{p===e.focalPoint[0]&&v===e.focalPoint[1]&&y===e.focalPoint[2]||(e.focalPoint[0]=p,e.focalPoint[1]=v,e.focalPoint[2]=y,t.computeDistance(),t.modified())},t.setDistance=p=>{if(e.distance===p)return;e.distance=p,e.distance<1e-20&&(e.distance=1e-20,u2("Distance is set to minimum."));const v=e.directionOfProjection;e.focalPoint[0]=e.position[0]+v[0]*e.distance,e.focalPoint[1]=e.position[1]+v[1]*e.distance,e.focalPoint[2]=e.position[2]+v[2]*e.distance,t.modified()},t.computeDistance=()=>{const p=e.focalPoint[0]-e.position[0],v=e.focalPoint[1]-e.position[1],y=e.focalPoint[2]-e.position[2];if(e.distance=Math.sqrt(p*p+v*v+y*y),e.distance<1e-20){e.distance=1e-20,u2("Distance is set to minimum.");const m=e.directionOfProjection;e.focalPoint[0]=e.position[0]+m[0]*e.distance,e.focalPoint[1]=e.position[1]+m[1]*e.distance,e.focalPoint[2]=e.position[2]+m[2]*e.distance}e.directionOfProjection[0]=p/e.distance,e.directionOfProjection[1]=v/e.distance,e.directionOfProjection[2]=y/e.distance,g()},t.dolly=p=>{if(p<=0)return;const v=e.distance/p;t.setPosition(e.focalPoint[0]-v*e.directionOfProjection[0],e.focalPoint[1]-v*e.directionOfProjection[1],e.focalPoint[2]-v*e.directionOfProjection[2])},t.roll=p=>{const v=e.position,y=e.focalPoint,m=e.viewUp,w=new Float64Array([m[0],m[1],m[2],0]);It(f);const x=new Float64Array([y[0]-v[0],y[1]-v[1],y[2]-v[2]]);To(f,f,Gr(p),x),Vu(w,w,f),e.viewUp[0]=w[0],e.viewUp[1]=w[1],e.viewUp[2]=w[2],t.modified()},t.azimuth=p=>{const v=e.focalPoint;It(u),er(u,u,v),To(u,u,Gr(p),e.viewUp),er(u,u,[-v[0],-v[1],-v[2]]),At(d,e.position,u),t.setPosition(d[0],d[1],d[2])},t.yaw=p=>{const v=e.position;It(u),er(u,u,v),To(u,u,Gr(p),e.viewUp),er(u,u,[-v[0],-v[1],-v[2]]),At(h,e.focalPoint,u),t.setFocalPoint(h[0],h[1],h[2])},t.elevation=p=>{const v=e.focalPoint,y=t.getViewMatrix(),m=[-y[0],-y[1],-y[2]];It(u),er(u,u,v),To(u,u,Gr(p),m),er(u,u,[-v[0],-v[1],-v[2]]),At(d,e.position,u),t.setPosition(d[0],d[1],d[2])},t.pitch=p=>{const v=e.position,y=t.getViewMatrix(),m=[y[0],y[1],y[2]];It(u),er(u,u,v),To(u,u,Gr(p),m),er(u,u,[-v[0],-v[1],-v[2]]),At(h,e.focalPoint,u),t.setFocalPoint(...h)},t.zoom=p=>{p<=0||(e.parallelProjection?e.parallelScale/=p:e.viewAngle/=p,t.modified())},t.translate=(p,v,y)=>{const m=[p,v,y];vy(e.position,m,e.position),vy(e.focalPoint,m,e.focalPoint),t.computeDistance(),t.modified()},t.applyTransform=p=>{const v=[...e.viewUp,1],y=[],m=[],w=[];v[0]+=e.position[0],v[1]+=e.position[1],v[2]+=e.position[2],Vu(y,[...e.position,1],p),Vu(m,[...e.focalPoint,1],p),Vu(w,v,p),w[0]-=y[0],w[1]-=y[1],w[2]-=y[2],t.setPosition(...y.slice(0,3)),t.setFocalPoint(...m.slice(0,3)),t.setViewUp(...w.slice(0,3))},t.getThickness=()=>e.clippingRange[1]-e.clippingRange[0],t.setThickness=p=>{let v=p;v<1e-20&&(v=1e-20,u2("Thickness is set to minimum.")),t.setClippingRange(e.clippingRange[0],e.clippingRange[0]+v)},t.setThicknessFromFocalPoint=p=>{let v=p;v<1e-20&&(v=1e-20,u2("Thickness is set to minimum.")),t.setClippingRange(e.distance-v/2,e.distance+v/2)},t.setRoll=p=>{},t.getRoll=()=>{},t.setObliqueAngles=(p,v)=>{},t.getOrientation=()=>{},t.getOrientationWXYZ=()=>{},t.getFrustumPlanes=p=>{},t.getCameraLightTransformMatrix=p=>(Cr(p,e.cameraLightTransform),p),t.computeCameraLightTransform=()=>{Cr(o,t.getViewMatrix()),Ar(o,o),r4(a,[e.distance,e.distance,e.distance]),yn(o,o,a),It(e.cameraLightTransform),er(e.cameraLightTransform,o,[0,0,-1])},t.deepCopy=p=>{},t.physicalOrientationToWorldDirection=p=>{const v=X6(p[0],p[1],p[2],p[3]),y=sf(),m=X6(0,0,1,0);return KY(y,v),q6(m,v,m),q6(m,m,y),[m[0],m[1],m[2]]},t.getPhysicalToWorldMatrix=p=>{t.getWorldToPhysicalMatrix(p),Ar(p,p)},t.getWorldToPhysicalMatrix=p=>{It(p);const v=[3];tl(e.physicalViewNorth,e.physicalViewUp,v),p[0]=v[0],p[1]=v[1],p[2]=v[2],p[4]=e.physicalViewUp[0],p[5]=e.physicalViewUp[1],p[6]=e.physicalViewUp[2],p[8]=-e.physicalViewNorth[0],p[9]=-e.physicalViewNorth[1],p[10]=-e.physicalViewNorth[2],un(p,p),Wn(s,1/e.physicalScale,1/e.physicalScale,1/e.physicalScale),nl(p,p,s),er(p,p,e.physicalTranslation)},t.computeViewParametersFromViewMatrix=p=>{Ar(o,p),At(s,r,o),t.computeDistance();const v=e.distance;t.setPosition(s[0],s[1],s[2]),At(c,n,o),Nn(c,c,s),Un(c,c),t.setDirectionOfProjection(c[0],c[1],c[2]),At(l,i,o),Nn(l,l,s),Un(l,l),t.setViewUp(l[0],l[1],l[2]),t.setDistance(v)},t.computeViewParametersFromPhysicalMatrix=p=>{t.getWorldToPhysicalMatrix(o),yn(o,p,o),t.computeViewParametersFromViewMatrix(o)},t.setViewMatrix=p=>{e.viewMatrix=p,e.viewMatrix&&(Cr(o,e.viewMatrix),t.computeViewParametersFromViewMatrix(o),un(e.viewMatrix,e.viewMatrix))},t.getViewMatrix=()=>{if(e.viewMatrix)return e.viewMatrix;a4(o,e.position,e.focalPoint,e.viewUp),un(o,o);const p=new Float64Array(16);return Cr(p,o),p},t.setProjectionMatrix=p=>{e.projectionMatrix=p},t.getProjectionMatrix=(p,v,y)=>{const m=new Float64Array(16);if(It(m),e.projectionMatrix){const C=1/e.physicalScale;return Wn(s,C,C,C),Cr(m,e.projectionMatrix),nl(m,m,s),un(m,m),m}It(o);const w=e.clippingRange[1]-e.clippingRange[0],x=[e.clippingRange[0]+(v+1)*w/2,e.clippingRange[0]+(y+1)*w/2];if(e.parallelProjection){const C=e.parallelScale*p,S=e.parallelScale,T=(e.windowCenter[0]-1)*C,_=(e.windowCenter[0]+1)*C,E=(e.windowCenter[1]-1)*S,b=(e.windowCenter[1]+1)*S;o4(o,T,_,E,b,x[0],x[1]),un(o,o)}else{if(e.useOffAxisProjection)throw new Error("Off-Axis projection is not supported at this time");{const C=Math.tan(Gr(e.viewAngle)/2);let S,T;e.useHorizontalViewAngle===!0?(S=e.clippingRange[0]*C,T=e.clippingRange[0]*C/p):(S=e.clippingRange[0]*C*p,T=e.clippingRange[0]*C);const _=(e.windowCenter[0]-1)*S,E=(e.windowCenter[0]+1)*S,b=(e.windowCenter[1]-1)*T,D=(e.windowCenter[1]+1)*T,I=x[0],P=x[1];o[0]=2*I/(E-_),o[5]=2*I/(D-b),o[2]=(_+E)/(E-_),o[6]=(b+D)/(D-b),o[10]=-(I+P)/(P-I),o[14]=-1,o[11]=-2*I*P/(P-I),o[15]=0}}return Cr(m,o),m},t.getCompositeProjectionMatrix=(p,v,y)=>{const m=t.getViewMatrix(),w=t.getProjectionMatrix(p,v,y);return yn(w,m,w),w},t.setDirectionOfProjection=(p,v,y)=>{if(e.directionOfProjection[0]===p&&e.directionOfProjection[1]===v&&e.directionOfProjection[2]===y)return;e.directionOfProjection[0]=p,e.directionOfProjection[1]=v,e.directionOfProjection[2]=y;const m=e.directionOfProjection;e.focalPoint[0]=e.position[0]+m[0]*e.distance,e.focalPoint[1]=e.position[1]+m[1]*e.distance,e.focalPoint[2]=e.position[2]+m[2]*e.distance,g()},t.setDeviceAngles=(p,v,y,m)=>{const w=[3];tl(e.physicalViewNorth,e.physicalViewUp,w);const x=It(new Float64Array(16));To(x,x,Gr(p),e.physicalViewUp),To(x,x,Gr(v),w),To(x,x,Gr(y),e.physicalViewNorth),To(x,x,Gr(-m),e.physicalViewUp);const C=new Float64Array([-e.physicalViewUp[0],-e.physicalViewUp[1],-e.physicalViewUp[2]]),S=new Float64Array(e.physicalViewNorth);At(C,C,x),At(S,S,x),t.setDirectionOfProjection(C[0],C[1],C[2]),t.setViewUp(S[0],S[1],S[2]),t.modified()},t.setOrientationWXYZ=(p,v,y,m)=>{const w=It(new Float64Array(16));if(p!==0&&(v!==0||y!==0||m!==0)){const S=Gr(p),T=sf();nw(T,[v,y,m],S),xy(w,T)}const x=new Float64Array(3);At(x,[0,0,-1],w);const C=new Float64Array(3);At(C,[0,1,0],w),t.setDirectionOfProjection(...x),t.setViewUp(...C),t.modified()},t.computeClippingRange=p=>{let v=null,y=null;v=e.viewPlaneNormal,y=e.position;const m=-v[0],w=-v[1],x=-v[2],C=-(m*y[0]+w*y[1]+x*y[2]),S=[m*p[0]+w*p[2]+x*p[4]+C,1e-18];for(let T=0;T<2;T++)for(let _=0;_<2;_++)for(let E=0;E<2;E++){const b=m*p[E]+w*p[2+_]+x*p[4+T]+C;S[0]=b<S[0]?b:S[0],S[1]=b>S[1]?b:S[1]}return S}}const sne={position:[0,0,1],focalPoint:[0,0,0],viewUp:[0,1,0],directionOfProjection:[0,0,-1],parallelProjection:!1,useHorizontalViewAngle:!1,viewAngle:30,parallelScale:1,clippingRange:[.01,1000.01],windowCenter:[0,0],viewPlaneNormal:[0,0,1],useOffAxisProjection:!1,screenBottomLeft:[-.5,-.5,-.5],screenBottomRight:[.5,-.5,-.5],screenTopRight:[.5,.5,-.5],freezeFocalPoint:!1,projectionMatrix:null,viewMatrix:null,cameraLightTransform:ma(),physicalTranslation:[0,0,0],physicalScale:1,physicalViewUp:[0,1,0],physicalViewNorth:[0,0,-1]};function XA(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,sne,r),Z.obj(t,e),Z.get(t,e,["distance"]),Z.setGet(t,e,["parallelProjection","useHorizontalViewAngle","viewAngle","parallelScale","useOffAxisProjection","freezeFocalPoint","physicalScale"]),Z.getArray(t,e,["directionOfProjection","viewPlaneNormal","position","focalPoint"]),Z.setGetArray(t,e,["clippingRange","windowCenter"],2),Z.setGetArray(t,e,["viewUp","screenBottomLeft","screenBottomRight","screenTopRight","physicalTranslation","physicalViewUp","physicalViewNorth"],3),ane(t,e)}const cne=Z.newInstance(XA,"vtkCamera");var M4={newInstance:cne,extend:XA};function lne(t,e){e.classHierarchy.push("vtkLight");const r=new Float64Array(3);t.getTransformedPosition=()=>(e.transformMatrix?At(r,e.position,e.transformMatrix):Wn(r,e.position[0],e.position[1],e.position[2]),r),t.getTransformedFocalPoint=()=>(e.transformMatrix?At(r,e.focalPoint,e.transformMatrix):Wn(r,e.focalPoint[0],e.focalPoint[1],e.focalPoint[2]),r),t.getDirection=()=>(e.directionMTime<e.mtime&&(hn(e.direction,e.focalPoint,e.position),Td(e.direction),e.directionMTime=e.mtime),e.direction),t.setDirection=n=>{const i=new Float64Array(3);hn(i,e.position,n),e.focalPoint=i},t.setDirectionAngle=(n,i)=>{const o=Gr(n),a=Gr(i);t.setPosition(Math.cos(o)*Math.sin(a),Math.sin(o),Math.cos(o)*Math.cos(a)),t.setFocalPoint(0,0,0),t.setPositional(0)},t.setLightTypeToHeadLight=()=>{t.setLightType("HeadLight")},t.setLightTypeToCameraLight=()=>{t.setLightType("CameraLight")},t.setLightTypeToSceneLight=()=>{t.setTransformMatrix(null),t.setLightType("SceneLight")},t.lightTypeIsHeadLight=()=>e.lightType==="HeadLight",t.lightTypeIsSceneLight=()=>e.lightType==="SceneLight",t.lightTypeIsCameraLight=()=>e.lightType==="CameraLight"}const une={switch:!0,intensity:1,color:[1,1,1],position:[0,0,1],focalPoint:[0,0,0],positional:!1,exponent:1,coneAngle:30,coneFalloff:5,attenuationValues:[1,0,0],transformMatrix:null,lightType:"SceneLight",shadowAttenuation:1,direction:[0,0,0],directionMTime:0};function fne(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,une,r),Z.obj(t,e),Z.setGet(t,e,["intensity","switch","positional","exponent","coneAngle","coneFalloff","transformMatrix","lightType","shadowAttenuation","attenuationValues"]),Z.setGetArray(t,e,["color","position","focalPoint","attenuationValues"],3),lne(t,e)}const dne=Z.newInstance(fne,"vtkLight");var hne={newInstance:dne};const{vtkErrorMacro:Dv}=Z;function gne(t){return()=>Dv(`vtkViewport::${t} - NOT IMPLEMENTED`)}function pne(t,e){e.classHierarchy.push("vtkViewport"),t.getViewProps=()=>e.props,t.hasViewProp=n=>e.props.includes(n),t.addViewProp=n=>{n&&!t.hasViewProp(n)&&e.props.push(n)},t.removeViewProp=n=>{const i=e.props.filter(o=>o!==n);e.props.length!==i.length&&(e.props=i)},t.removeAllViewProps=()=>{e.props=[]};function r(n){let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];i.push(n);const o=n.getNestedProps();if(o&&o.length)for(let a=0;a<o.length;a++)r(o[a],i);return i}t.getViewPropsWithNestedProps=()=>{const n=[];for(let i=0;i<e.props.length;i++)r(e.props[i],n);return n},t.addActor2D=t.addViewProp,t.removeActor2D=n=>{t.removeViewProp(n)},t.getActors2D=()=>(e.actors2D=[],e.props.forEach(n=>{e.actors2D=e.actors2D.concat(n.getActors2D())}),e.actors2D),t.displayToView=()=>Dv("call displayToView on your view instead"),t.viewToDisplay=()=>Dv("callviewtodisplay on your view instead"),t.getSize=()=>Dv("call getSize on your View instead"),t.normalizedDisplayToProjection=(n,i,o)=>{const a=t.normalizedDisplayToNormalizedViewport(n,i,o);return t.normalizedViewportToProjection(a[0],a[1],a[2])},t.normalizedDisplayToNormalizedViewport=(n,i,o)=>{const a=[e.viewport[2]-e.viewport[0],e.viewport[3]-e.viewport[1]];return[(n-e.viewport[0])/a[0],(i-e.viewport[1])/a[1],o]},t.normalizedViewportToProjection=(n,i,o)=>[n*2-1,i*2-1,o*2-1],t.projectionToNormalizedDisplay=(n,i,o)=>{const a=t.projectionToNormalizedViewport(n,i,o);return t.normalizedViewportToNormalizedDisplay(a[0],a[1],a[2])},t.normalizedViewportToNormalizedDisplay=(n,i,o)=>{const a=[e.viewport[2]-e.viewport[0],e.viewport[3]-e.viewport[1]];return[n*a[0]+e.viewport[0],i*a[1]+e.viewport[1],o]},t.projectionToNormalizedViewport=(n,i,o)=>[(n+1)*.5,(i+1)*.5,(o+1)*.5],t.PickPropFrom=gne("PickPropFrom")}const mne={background:[0,0,0],background2:[.2,.2,.2],gradientBackground:!1,viewport:[0,0,1,1],aspect:[1,1],pixelAspect:[1,1],props:[],actors2D:[]};function YA(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,mne,r),Z.obj(t,e),Z.event(t,e,"event"),Z.setGetArray(t,e,["viewport"],4),Z.setGetArray(t,e,["background","background2"],3),pne(t,e)}const vne=Z.newInstance(YA,"vtkViewport");var yne={newInstance:vne,extend:YA};const{vtkDebugMacro:_g,vtkErrorMacro:Su,vtkWarningMacro:wne}=uo;function _D(t){return()=>Su(`vtkRenderer::${t} - NOT IMPLEMENTED`)}function xne(t,e){e.classHierarchy.push("vtkRenderer");const r={type:"ComputeVisiblePropBoundsEvent",renderer:t},n={type:"ResetCameraClippingRangeEvent",renderer:t},i={type:"ResetCameraEvent",renderer:t};t.updateCamera=()=>(e.activeCamera||(_g("No cameras are on, creating one."),t.getActiveCameraAndResetIfCreated()),e.activeCamera.render(t),!0),t.updateLightsGeometryToFollowCamera=()=>{const o=t.getActiveCameraAndResetIfCreated();e.lights.forEach(a=>{a.lightTypeIsSceneLight()||(a.lightTypeIsHeadLight()?(a.setPositionFrom(o.getPositionByReference()),a.setFocalPointFrom(o.getFocalPointByReference()),a.modified(o.getMTime())):a.lightTypeIsCameraLight()?a.setTransformMatrix(o.getCameraLightTransformMatrix(ma())):Su("light has unknown light type",a.get()))})},t.updateLightGeometry=()=>e.lightFollowCamera?t.updateLightsGeometryToFollowCamera():!0,t.allocateTime=_D("allocateTime"),t.updateGeometry=_D("updateGeometry"),t.getVTKWindow=()=>e._renderWindow,t.setLayer=o=>{_g(t.getClassName(),t,"setting Layer to ",o),e.layer!==o&&(e.layer=o,t.modified()),t.setPreserveColorBuffer(!!o)},t.setActiveCamera=o=>e.activeCamera===o?!1:(e.activeCamera=o,t.modified(),t.invokeEvent({type:"ActiveCameraEvent",camera:o}),!0),t.makeCamera=()=>{const o=M4.newInstance();return t.invokeEvent({type:"CreateCameraEvent",camera:o}),o},t.getActiveCamera=()=>(e.activeCamera||(e.activeCamera=t.makeCamera()),e.activeCamera),t.getActiveCameraAndResetIfCreated=()=>(e.activeCamera||(t.getActiveCamera(),t.resetCamera()),e.activeCamera),t.getActors=()=>(e.actors=[],e.props.forEach(o=>{e.actors=e.actors.concat(o.getActors())}),e.actors),t.addActor=t.addViewProp,t.removeActor=o=>{e.actors=e.actors.filter(a=>a!==o),t.removeViewProp(o),t.modified()},t.removeAllActors=()=>{t.getActors().forEach(a=>{t.removeViewProp(a)}),e.actors=[],t.modified()},t.getVolumes=()=>(e.volumes=[],e.props.forEach(o=>{e.volumes=e.volumes.concat(o.getVolumes())}),e.volumes),t.addVolume=t.addViewProp,t.removeVolume=o=>{e.volumes=e.volumes.filter(a=>a!==o),t.removeViewProp(o),t.modified()},t.removeAllVolumes=()=>{t.getVolumes().forEach(a=>{t.removeViewProp(a)}),e.volumes=[],t.modified()},t.hasLight=o=>e.lights.includes(o),t.addLight=o=>{o&&!t.hasLight(o)&&(e.lights.push(o),t.modified())},t.removeLight=o=>{e.lights=e.lights.filter(a=>a!==o),t.modified()},t.removeAllLights=()=>{e.lights=[],t.modified()},t.setLightCollection=o=>{e.lights=o,t.modified()},t.makeLight=hne.newInstance,t.createLight=()=>{e.automaticLightCreation&&(e._createdLight&&(t.removeLight(e._createdLight),e._createdLight.delete(),e._createdLight=null),e._createdLight=t.makeLight(),t.addLight(e._createdLight),e._createdLight.setLightTypeToHeadLight(),e._createdLight.setPosition(t.getActiveCamera().getPosition()),e._createdLight.setFocalPoint(t.getActiveCamera().getFocalPoint()))},t.normalizedDisplayToWorld=(o,a,s,c)=>{let l=t.normalizedDisplayToProjection(o,a,s);return l=t.projectionToView(l[0],l[1],l[2],c),t.viewToWorld(l[0],l[1],l[2])},t.worldToNormalizedDisplay=(o,a,s,c)=>{let l=t.worldToView(o,a,s);return l=t.viewToProjection(l[0],l[1],l[2],c),t.projectionToNormalizedDisplay(l[0],l[1],l[2])},t.viewToWorld=(o,a,s)=>{if(e.activeCamera===null)return Su("ViewToWorld: no active camera, cannot compute view to world, returning 0,0,0"),[0,0,0];const c=e.activeCamera.getViewMatrix();Ar(c,c),un(c,c);const l=new Float64Array([o,a,s]);return At(l,l,c),l},t.projectionToView=(o,a,s,c)=>{if(e.activeCamera===null)return Su("ProjectionToView: no active camera, cannot compute projection to view, returning 0,0,0"),[0,0,0];const l=e.activeCamera.getProjectionMatrix(c,-1,1);Ar(l,l),un(l,l);const f=new Float64Array([o,a,s]);return At(f,f,l),f},t.worldToView=(o,a,s)=>{if(e.activeCamera===null)return Su("WorldToView: no active camera, cannot compute view to world, returning 0,0,0"),[0,0,0];const c=e.activeCamera.getViewMatrix();un(c,c);const l=new Float64Array([o,a,s]);return At(l,l,c),l},t.viewToProjection=(o,a,s,c)=>{if(e.activeCamera===null)return Su("ViewToProjection: no active camera, cannot compute view to projection, returning 0,0,0"),[0,0,0];const l=e.activeCamera.getProjectionMatrix(c,-1,1);un(l,l);const f=new Float64Array([o,a,s]);return At(f,f,l),f},t.computeVisiblePropBounds=()=>{e.allBounds[0]=Hn.INIT_BOUNDS[0],e.allBounds[1]=Hn.INIT_BOUNDS[1],e.allBounds[2]=Hn.INIT_BOUNDS[2],e.allBounds[3]=Hn.INIT_BOUNDS[3],e.allBounds[4]=Hn.INIT_BOUNDS[4],e.allBounds[5]=Hn.INIT_BOUNDS[5];let o=!0;t.invokeEvent(r);for(let a=0;a<e.props.length;++a){const s=e.props[a];if(s.getVisibility()&&s.getUseBounds()){const c=s.getBounds();c&&xv(c)&&(o=!1,c[0]<e.allBounds[0]&&(e.allBounds[0]=c[0]),c[1]>e.allBounds[1]&&(e.allBounds[1]=c[1]),c[2]<e.allBounds[2]&&(e.allBounds[2]=c[2]),c[3]>e.allBounds[3]&&(e.allBounds[3]=c[3]),c[4]<e.allBounds[4]&&(e.allBounds[4]=c[4]),c[5]>e.allBounds[5]&&(e.allBounds[5]=c[5]))}}return o&&(Gh(e.allBounds),_g("Can't compute bounds, no 3D props are visible")),e.allBounds},t.resetCamera=function(){const a=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:null)||t.computeVisiblePropBounds(),s=[0,0,0];if(!xv(a))return _g("Cannot reset camera!"),!1;let c=null;if(t.getActiveCamera())c=e.activeCamera.getViewPlaneNormal();else return Su("Trying to reset non-existent camera"),!1;e.activeCamera.setViewAngle(30),s[0]=(a[0]+a[1])/2,s[1]=(a[2]+a[3])/2,s[2]=(a[4]+a[5])/2;let l=a[1]-a[0],f=a[3]-a[2],u=a[5]-a[4];l*=l,f*=f,u*=u;let d=l+f+u;d=d===0?1:d,d=Math.sqrt(d)*.5;const h=Gr(e.activeCamera.getViewAngle()),g=d,p=d/Math.sin(h*.5),v=e.activeCamera.getViewUp();return Math.abs(cn(v,c))>.999&&(wne("Resetting view-up since view plane normal is parallel"),e.activeCamera.setViewUp(-v[2],v[0],v[1])),e.activeCamera.setFocalPoint(s[0],s[1],s[2]),e.activeCamera.setPosition(s[0]+p*c[0],s[1]+p*c[1],s[2]+p*c[2]),t.resetCameraClippingRange(a),e.activeCamera.setParallelScale(g),e.activeCamera.setPhysicalScale(d),e.activeCamera.setPhysicalTranslation(-s[0],-s[1],-s[2]),t.invokeEvent(i),!0},t.resetCameraClippingRange=function(){const a=(arguments.length>0&&arguments[0]!==void 0?arguments[0]:null)||t.computeVisiblePropBounds();if(!xv(a))return _g("Cannot reset camera clipping range!"),!1;if(t.getActiveCameraAndResetIfCreated(),!e.activeCamera)return Su("Trying to reset clipping range of non-existent camera"),!1;const s=e.activeCamera.computeClippingRange(a);let c=0;if(e.activeCamera.getParallelProjection())c=.2*e.activeCamera.getParallelScale();else{const l=Gr(e.activeCamera.getViewAngle());c=.2*Math.tan(l/2)*s[1]}return s[1]-s[0]<c&&(c=c-s[1]+s[0],s[1]+=c/2,s[0]-=c/2),s[0]<0&&(s[0]=0),s[0]=.99*s[0]-(s[1]-s[0])*e.clippingRangeExpansion,s[1]=1.01*s[1]+(s[1]-s[0])*e.clippingRangeExpansion,s[0]=s[0]>=s[1]?.01*s[1]:s[0],e.nearClippingPlaneTolerance||(e.nearClippingPlaneTolerance=.01),s[0]<e.nearClippingPlaneTolerance*s[1]&&(s[0]=e.nearClippingPlaneTolerance*s[1]),e.activeCamera.setClippingRange(s[0],s[1]),t.invokeEvent(n),!1},t.setRenderWindow=o=>{o!==e._renderWindow&&(e._vtkWindow=o,e._renderWindow=o)},t.visibleActorCount=()=>e.props.filter(o=>o.getVisibility()).length,t.visibleVolumeCount=t.visibleActorCount,t.getMTime=()=>{let o=e.mtime;const a=e.activeCamera?e.activeCamera.getMTime():0;a>o&&(o=a);const s=e._createdLight?e._createdLight.getMTime():0;return s>o&&(o=s),o},t.getTransparent=()=>!!e.preserveColorBuffer,t.isActiveCameraCreated=()=>!!e.activeCamera}const Cne={pickedProp:null,activeCamera:null,allBounds:[],ambient:[1,1,1],allocatedRenderTime:100,timeFactor:1,automaticLightCreation:!0,twoSidedLighting:!0,lastRenderTimeInSeconds:-1,renderWindow:null,lights:[],actors:[],volumes:[],lightFollowCamera:!0,numberOfPropsRendered:0,propArray:null,pathArray:null,layer:0,preserveColorBuffer:!1,preserveDepthBuffer:!1,computeVisiblePropBounds:of(),interactive:!0,nearClippingPlaneTolerance:0,clippingRangeExpansion:.05,erase:!0,draw:!0,useShadows:!1,useDepthPeeling:!1,occlusionRatio:0,maximumNumberOfPeels:4,selector:null,delegate:null,texturedBackground:!1,backgroundTexture:null,environmentTexture:null,environmentTextureDiffuseStrength:1,environmentTextureSpecularStrength:1,useEnvironmentTextureAsBackground:!1,pass:0};function JA(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};for(Object.assign(e,Cne,r),yne.extend(t,e,r),e.background||(e.background=[0,0,0,1]);e.background.length<3;)e.background.push(0);e.background.length===3&&e.background.push(1),Ro(t,e,["_renderWindow","allocatedRenderTime","timeFactor","lastRenderTimeInSeconds","numberOfPropsRendered","lastRenderingUsedDepthPeeling","selector"]),Jr(t,e,["twoSidedLighting","lightFollowCamera","automaticLightCreation","erase","draw","nearClippingPlaneTolerance","clippingRangeExpansion","backingStore","interactive","layer","preserveColorBuffer","preserveDepthBuffer","useDepthPeeling","occlusionRatio","maximumNumberOfPeels","delegate","backgroundTexture","texturedBackground","environmentTexture","environmentTextureDiffuseStrength","environmentTextureSpecularStrength","useEnvironmentTextureAsBackground","useShadows","pass"]),Bh(t,e,["actors","volumes","lights"]),M_(t,e,["background"],4,1),X1(t,e,["renderWindow"]),xne(t,e)}const Sne=Rn(JA,"vtkRenderer");var ZA={newInstance:Sne,extend:JA};const Tne={Unknown:0,LeftController:1,RightController:2},_ne={Unknown:0,Trigger:1,TrackPad:2,Grip:3,Thumbstick:4,A:5,B:6,ApplicationMenu:7},Ene={Unknown:0,TouchpadX:1,TouchpadY:2,ThumbstickX:3,ThumbstickY:4};var QA={Device:Tne,Input:_ne,Axis:Ene};const{Device:f2,Input:zf}=QA,{vtkWarningMacro:d2,vtkErrorMacro:h2,normalizeWheel:bne,vtkOnceErrorMacro:Dne}=Z,Yd={ctrlKey:!1,altKey:!1,shiftKey:!1},Hx={"xr-standard":[zf.Trigger,zf.Grip,zf.TrackPad,zf.Thumbstick,zf.A,zf.B]},P4=["StartAnimation","Animation","EndAnimation","PointerEnter","PointerLeave","MouseEnter","MouseLeave","StartMouseMove","MouseMove","EndMouseMove","LeftButtonPress","LeftButtonRelease","MiddleButtonPress","MiddleButtonRelease","RightButtonPress","RightButtonRelease","KeyPress","KeyDown","KeyUp","StartMouseWheel","MouseWheel","EndMouseWheel","StartPinch","Pinch","EndPinch","StartPan","Pan","EndPan","StartRotate","Rotate","EndRotate","Button3D","Move3D","StartPointerLock","EndPointerLock","StartInteraction","Interaction","EndInteraction","AnimationFrameRateUpdate"];function Eg(t){t.cancelable&&t.preventDefault()}function g2(t){const e=Object.create(null);return t.forEach(r=>{let{pointerId:n,position:i}=r;e[n]=i}),e}function Ine(t,e){e.classHierarchy.push("vtkRenderWindowInteractor");const r={...t},n=new Set,i=new Map;let o=1;t.start=()=>{!e.initialized&&(t.initialize(),!e.initialized)||t.startEventLoop()},t.setRenderWindow=p=>{h2("you want to call setView(view) instead of setRenderWindow on a vtk.js interactor")},t.setInteractorStyle=p=>{e.interactorStyle!==p&&(e.interactorStyle!=null&&e.interactorStyle.setInteractor(null),e.interactorStyle=p,e.interactorStyle!=null&&e.interactorStyle.getInteractor()!==t&&e.interactorStyle.setInteractor(t))},t.initialize=()=>{e.initialized=!0,t.enable(),t.render()},t.enable=()=>t.setEnabled(!0),t.disable=()=>t.setEnabled(!1),t.startEventLoop=()=>d2("empty event loop");function a(p,v){e._forcedRenderer||(e.currentRenderer=t.findPokedRenderer(p,v))}t.getCurrentRenderer=()=>(e.currentRenderer||a(0,0),e.currentRenderer);function s(p){const v=e._view.getCanvas(),y=v.getBoundingClientRect(),m=v.width/y.width,w=v.height/y.height,x={x:m*(p.clientX-y.left),y:w*(y.height-p.clientY+y.top),z:0};return(i.size<=1||!e.currentRenderer)&&a(x.x,x.y),x}const c=e._getScreenEventPositionFor||s;function l(p){return{controlKey:p.ctrlKey,altKey:p.altKey,shiftKey:p.shiftKey}}function f(p){const v=l(p);return{key:p.key,keyCode:p.charCode,...v}}function u(p){return p.pointerType||""}const d=()=>{if(e.container===null)return;const{container:p}=e;p.addEventListener("contextmenu",Eg),p.addEventListener("wheel",t.handleWheel),p.addEventListener("DOMMouseScroll",t.handleWheel),p.addEventListener("pointerenter",t.handlePointerEnter),p.addEventListener("pointerleave",t.handlePointerLeave),p.addEventListener("pointermove",t.handlePointerMove,{passive:!1}),p.addEventListener("pointerdown",t.handlePointerDown,{passive:!1}),p.addEventListener("pointerup",t.handlePointerUp),p.addEventListener("pointercancel",t.handlePointerCancel),document.addEventListener("keypress",t.handleKeyPress),document.addEventListener("keydown",t.handleKeyDown),document.addEventListener("keyup",t.handleKeyUp),document.addEventListener("pointerlockchange",t.handlePointerLockChange),p.style.touchAction="none",p.style.userSelect="none",p.style.webkitTapHighlightColor="rgba(0,0,0,0)"};t.bindEvents=p=>{if(p===null)return;r.setContainer(p)&&d()};const h=()=>{clearTimeout(e.moveTimeoutID),clearTimeout(e.wheelTimeoutID),e.moveTimeoutID=0,e.wheelTimeoutID=0,o=1;const{container:p}=e;p&&(p.removeEventListener("contextmenu",Eg),p.removeEventListener("wheel",t.handleWheel),p.removeEventListener("DOMMouseScroll",t.handleWheel),p.removeEventListener("pointerenter",t.handlePointerEnter),p.removeEventListener("pointerleave",t.handlePointerLeave),p.removeEventListener("pointermove",t.handlePointerMove,{passive:!1}),p.removeEventListener("pointerdown",t.handlePointerDown,{passive:!1}),p.removeEventListener("pointerup",t.handlePointerUp),p.removeEventListener("pointercancel",t.handlePointerCancel)),document.removeEventListener("keypress",t.handleKeyPress),document.removeEventListener("keydown",t.handleKeyDown),document.removeEventListener("keyup",t.handleKeyUp),document.removeEventListener("pointerlockchange",t.handlePointerLockChange),i.clear()};t.unbindEvents=()=>{h(),r.setContainer(null)},t.handleKeyPress=p=>{const v=f(p);t.keyPressEvent(v)},t.handleKeyDown=p=>{const v=f(p);t.keyDownEvent(v)},t.handleKeyUp=p=>{const v=f(p);t.keyUpEvent(v)},t.handlePointerEnter=p=>{const v={...l(p),position:c(p),deviceType:u(p)};t.pointerEnterEvent(v),v.deviceType==="mouse"&&t.mouseEnterEvent(v)},t.handlePointerLeave=p=>{const v={...l(p),position:c(p),deviceType:u(p)};t.pointerLeaveEvent(v),v.deviceType==="mouse"&&t.mouseLeaveEvent(v)},t.handlePointerDown=p=>{if(!(p.button>2||t.isPointerLocked()))switch(e.preventDefaultOnPointerDown&&Eg(p),p.target.hasPointerCapture(p.pointerId)&&p.target.releasePointerCapture(p.pointerId),e.container.setPointerCapture(p.pointerId),i.has(p.pointerId)&&d2("[RenderWindowInteractor] duplicate pointerId detected"),i.set(p.pointerId,{pointerId:p.pointerId,position:c(p)}),p.pointerType){case"pen":case"touch":t.handleTouchStart(p);break;case"mouse":default:t.handleMouseDown(p);break}},t.handlePointerUp=p=>{if(i.has(p.pointerId))switch(e.preventDefaultOnPointerUp&&Eg(p),i.delete(p.pointerId),e.container.releasePointerCapture(p.pointerId),p.pointerType){case"pen":case"touch":t.handleTouchEnd(p);break;case"mouse":default:t.handleMouseUp(p);break}},t.handlePointerCancel=p=>{if(i.has(p.pointerId))switch(i.delete(p.pointerId),p.pointerType){case"pen":case"touch":t.handleTouchEnd(p);break;case"mouse":default:t.handleMouseUp(p);break}},t.handlePointerMove=p=>{if(i.has(p.pointerId)){const v=i.get(p.pointerId);v.position=c(p)}switch(p.pointerType){case"pen":case"touch":t.handleTouchMove(p);break;case"mouse":default:t.handleMouseMove(p);break}},t.handleMouseDown=p=>{const v={...l(p),position:c(p),deviceType:u(p)};switch(p.button){case 0:t.leftButtonPressEvent(v);break;case 1:t.middleButtonPressEvent(v);break;case 2:t.rightButtonPressEvent(v);break;default:h2(`Unknown mouse button pressed: ${p.button}`);break}},t.requestPointerLock=()=>{e.container&&e.container.requestPointerLock()},t.exitPointerLock=()=>{var p;return(p=document.exitPointerLock)==null?void 0:p.call(document)},t.isPointerLocked=()=>!!e.container&&document.pointerLockElement===e.container,t.handlePointerLockChange=()=>{t.isPointerLocked()?t.startPointerLockEvent():t.endPointerLockEvent()};function g(){e._view&&e.enabled&&e.enableRender&&(e.inRender=!0,e._view.traverseAllPasses(),e.inRender=!1),t.invokeRenderEvent()}t.requestAnimation=p=>{if(p===void 0){h2("undefined requester, can not start animating");return}if(n.has(p)){d2("requester is already registered for animating");return}n.add(p),!e.animationRequest&&n.size===1&&!e.xrAnimation&&(e._animationStartTime=Date.now(),e._animationFrameCount=0,e.animationRequest=requestAnimationFrame(t.handleAnimation),t.startAnimationEvent())},t.extendAnimation=p=>{const v=Date.now()+p;e._animationExtendedEnd=Math.max(e._animationExtendedEnd,v),!e.animationRequest&&n.size===0&&!e.xrAnimation&&(e._animationStartTime=Date.now(),e._animationFrameCount=0,e.animationRequest=requestAnimationFrame(t.handleAnimation),t.startAnimationEvent())},t.isAnimating=()=>e.xrAnimation||e.animationRequest!==null,t.cancelAnimation=function(p){let v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(!n.has(p)){if(!v){const y=p&&p.getClassName?p.getClassName():p;d2(`${y} did not request an animation`)}return}n.delete(p),e.animationRequest&&n.size===0&&Date.now()>e._animationExtendedEnd&&(cancelAnimationFrame(e.animationRequest),e.animationRequest=null,t.endAnimationEvent(),t.render())},t.switchToXRAnimation=()=>{e.animationRequest&&(cancelAnimationFrame(e.animationRequest),e.animationRequest=null),e.xrAnimation=!0},t.returnFromXRAnimation=()=>{e.xrAnimation=!1,n.size!==0&&(e.recentAnimationFrameRate=10,e.animationRequest=requestAnimationFrame(t.handleAnimation))},t.updateXRGamepads=(p,v,y)=>{p.inputSources.forEach(m=>{const w=m.gripSpace==null?null:v.getPose(m.gripSpace,y),x=m.gripSpace==null?null:v.getPose(m.targetRaySpace,y),C=m.gamepad,S=m.handedness;if(C){C.index in e.lastGamepadValues||(e.lastGamepadValues[C.index]={left:{buttons:{}},right:{buttons:{}},none:{buttons:{}}});for(let T=0;T<C.buttons.length;++T)T in e.lastGamepadValues[C.index][S].buttons||(e.lastGamepadValues[C.index][S].buttons[T]=!1),e.lastGamepadValues[C.index][S].buttons[T]!==C.buttons[T].pressed&&w!=null&&(t.button3DEvent({gamepad:C,position:w.transform.position,orientation:w.transform.orientation,targetPosition:x.transform.position,targetOrientation:x.transform.orientation,pressed:C.buttons[T].pressed,device:m.handedness==="left"?f2.LeftController:f2.RightController,input:Hx[C.mapping]&&Hx[C.mapping][T]?Hx[C.mapping][T]:zf.Trigger}),e.lastGamepadValues[C.index][S].buttons[T]=C.buttons[T].pressed),e.lastGamepadValues[C.index][S].buttons[T]&&w!=null&&t.move3DEvent({gamepad:C,position:w.transform.position,orientation:w.transform.orientation,targetPosition:x.transform.position,targetOrientation:x.transform.orientation,device:m.handedness==="left"?f2.LeftController:f2.RightController})}})},t.handleMouseMove=p=>{const v={...l(p),position:c(p),deviceType:u(p)};e.moveTimeoutID===0?t.startMouseMoveEvent(v):(t.mouseMoveEvent(v),clearTimeout(e.moveTimeoutID)),e.moveTimeoutID=setTimeout(()=>{t.endMouseMoveEvent(),e.moveTimeoutID=0},200)},t.handleAnimation=()=>{const p=Date.now();e._animationFrameCount++,p-e._animationStartTime>1e3&&e._animationFrameCount>1&&(e.recentAnimationFrameRate=1e3*(e._animationFrameCount-1)/(p-e._animationStartTime),e.lastFrameTime=1/e.recentAnimationFrameRate,t.animationFrameRateUpdateEvent(),e._animationStartTime=p,e._animationFrameCount=1),t.animationEvent(),g(),n.size>0||Date.now()<e._animationExtendedEnd?e.animationRequest=requestAnimationFrame(t.handleAnimation):(cancelAnimationFrame(e.animationRequest),e.animationRequest=null,t.endAnimationEvent(),t.render())},t.handleWheel=p=>{Eg(p);const v={...bne(p),...l(p),position:c(p),deviceType:u(p)};e.wheelTimeoutID===0&&(Math.abs(v.spinY)>=.3?o=Math.abs(v.spinY):o=1),v.spinY/=o,e.wheelTimeoutID===0?(t.startMouseWheelEvent(v),t.mouseWheelEvent(v)):(t.mouseWheelEvent(v),clearTimeout(e.wheelTimeoutID)),e.mouseScrollDebounceByPass?(t.extendAnimation(600),t.endMouseWheelEvent(),e.wheelTimeoutID=0):e.wheelTimeoutID=setTimeout(()=>{t.extendAnimation(600),t.endMouseWheelEvent(),e.wheelTimeoutID=0},200)},t.handleMouseUp=p=>{const v={...l(p),position:c(p),deviceType:u(p)};switch(p.button){case 0:t.leftButtonReleaseEvent(v);break;case 1:t.middleButtonReleaseEvent(v);break;case 2:t.rightButtonReleaseEvent(v);break;default:h2(`Unknown mouse button released: ${p.button}`);break}},t.handleTouchStart=p=>{const v=[...i.values()];if(e.recognizeGestures&&v.length>1){const y=g2(i);if(v.length===2){const m={...l(Yd),position:v[0].position,deviceType:u(p)};t.leftButtonReleaseEvent(m)}t.recognizeGesture("TouchStart",y)}else if(v.length===1){const y={...l(Yd),position:c(p),deviceType:u(p)};t.leftButtonPressEvent(y)}},t.handleTouchMove=p=>{const v=[...i.values()];if(e.recognizeGestures&&v.length>1){const y=g2(i);t.recognizeGesture("TouchMove",y)}else if(v.length===1){const y={...l(Yd),position:v[0].position,deviceType:u(p)};t.mouseMoveEvent(y)}},t.handleTouchEnd=p=>{const v=[...i.values()];if(e.recognizeGestures)if(v.length===0){const y={...l(Yd),position:c(p),deviceType:u(p)};t.leftButtonReleaseEvent(y)}else if(v.length===1){const y=g2(i);t.recognizeGesture("TouchEnd",y);const m={...l(Yd),position:v[0].position,deviceType:u(p)};t.leftButtonPressEvent(m)}else{const y=g2(i);t.recognizeGesture("TouchMove",y)}else if(v.length===1){const y={...l(Yd),position:v[0].position,deviceType:u(p)};t.leftButtonReleaseEvent(y)}},t.setView=p=>{e._view!==p&&(e._view=p,e._view.getRenderable().setInteractor(t),t.modified())},t.getFirstRenderer=()=>{var p,v,y;return(y=(v=(p=e._view)==null?void 0:p.getRenderable())==null?void 0:v.getRenderersByReference())==null?void 0:y[0]},t.findPokedRenderer=function(){var S,T;let p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;if(!e._view)return null;const y=(T=(S=e._view)==null?void 0:S.getRenderable())==null?void 0:T.getRenderers();if(!y||y.length===0)return null;y.sort((_,E)=>_.getLayer()-E.getLayer());let m=null,w=null,x=null,C=y.length;for(;C--;){const _=y[C];if(e._view.isInViewport(p,v,_)&&_.getInteractive()){x=_;break}m===null&&_.getInteractive()&&(m=_),w===null&&e._view.isInViewport(p,v,_)&&(w=_)}return x===null&&(x=m),x===null&&(x=w),x==null&&(x=y[0]),x},t.render=()=>{!t.isAnimating()&&!e.inRender&&g()},P4.forEach(p=>{const v=p.charAt(0).toLowerCase()+p.slice(1);t[`${v}Event`]=y=>{if(!e.enabled)return;if(!t.getCurrentRenderer()){Dne(`
|
||
Can not forward events without a current renderer on the interactor.
|
||
`);return}const w={type:p,pokedRenderer:e.currentRenderer,firstRenderer:t.getFirstRenderer(),...y};t[`invoke${p}`](w)}}),t.recognizeGesture=(p,v)=>{if(Object.keys(v).length>2)return;if(e.startingEventPositions||(e.startingEventPositions={}),p==="TouchStart"){Object.keys(v).forEach(b=>{e.startingEventPositions[b]=v[b]}),e.currentGesture="Start";return}if(p==="TouchEnd"){e.currentGesture==="Pinch"&&(t.render(),t.endPinchEvent()),e.currentGesture==="Rotate"&&(t.render(),t.endRotateEvent()),e.currentGesture==="Pan"&&(t.render(),t.endPanEvent()),e.currentGesture="Start",e.startingEventPositions={};return}let y=0;const m=[],w=[];Object.keys(v).forEach(b=>{m[y]=v[b],w[y]=e.startingEventPositions[b],y++});const x=Math.sqrt((w[0].x-w[1].x)*(w[0].x-w[1].x)+(w[0].y-w[1].y)*(w[0].y-w[1].y)),C=Math.sqrt((m[0].x-m[1].x)*(m[0].x-m[1].x)+(m[0].y-m[1].y)*(m[0].y-m[1].y));let S=my(Math.atan2(w[1].y-w[0].y,w[1].x-w[0].x)),T=my(Math.atan2(m[1].y-m[0].y,m[1].x-m[0].x)),_=T-S;T=T+180>=360?T-180:T+180,S=S+180>=360?S-180:S+180,Math.abs(T-S)<Math.abs(_)&&(_=T-S);const E=[];if(E[0]=(m[0].x-w[0].x+m[1].x-w[1].x)/2,E[1]=(m[0].y-w[0].y+m[1].y-w[1].y)/2,p==="TouchMove")if(e.currentGesture==="Start"){let b=.01*Math.sqrt(e.container.clientWidth*e.container.clientWidth+e.container.clientHeight*e.container.clientHeight);b<15&&(b=15);const D=Math.abs(C-x),I=C*3.1415926*Math.abs(_)/360,P=Math.sqrt(E[0]*E[0]+E[1]*E[1]);if(D>b&&D>I&&D>P){e.currentGesture="Pinch";const O={scale:1,touches:v};t.startPinchEvent(O)}else if(I>b&&I>P){e.currentGesture="Rotate";const O={rotation:0,touches:v};t.startRotateEvent(O)}else if(P>b){e.currentGesture="Pan";const O={translation:[0,0],touches:v};t.startPanEvent(O)}}else{if(e.currentGesture==="Rotate"){const b={rotation:_,touches:v};t.rotateEvent(b)}if(e.currentGesture==="Pinch"){const b={scale:C/x,touches:v};t.pinchEvent(b)}if(e.currentGesture==="Pan"){const b={translation:E,touches:v};t.panEvent(b)}}},t.handleVisibilityChange=()=>{e._animationStartTime=Date.now(),e._animationFrameCount=0},t.setCurrentRenderer=p=>{e._forcedRenderer=!!p,e.currentRenderer=p},t.setContainer=p=>{h();const v=r.setContainer(p??null);return v&&d(),v},t.delete=()=>{for(;n.size;)t.cancelAnimation(n.values().next().value);typeof document.hidden<"u"&&document.removeEventListener("visibilitychange",t.handleVisibilityChange),e.container&&t.setContainer(null),r.delete()},typeof document.hidden<"u"&&document.addEventListener("visibilitychange",t.handleVisibilityChange,!1)}const One={renderWindow:null,interactorStyle:null,picker:null,pickingManager:null,initialized:!1,enabled:!1,enableRender:!0,currentRenderer:null,lightFollowCamera:!0,desiredUpdateRate:30,stillUpdateRate:2,container:null,recognizeGestures:!0,currentGesture:"Start",animationRequest:null,lastFrameTime:.1,recentAnimationFrameRate:10,wheelTimeoutID:0,moveTimeoutID:0,lastGamepadValues:{},preventDefaultOnPointerDown:!1,preventDefaultOnPointerUp:!1,mouseScrollDebounceByPass:!1};function eN(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,One,r),Z.obj(t,e),e._animationExtendedEnd=0,Z.event(t,e,"RenderEvent"),P4.forEach(n=>Z.event(t,e,n)),Z.get(t,e,["initialized","interactorStyle","lastFrameTime","recentAnimationFrameRate","_view"]),Z.setGet(t,e,["container","lightFollowCamera","enabled","enableRender","recognizeGestures","desiredUpdateRate","stillUpdateRate","picker","preventDefaultOnPointerDown","preventDefaultOnPointerUp","mouseScrollDebounceByPass"]),Z.moveToProtected(t,e,["view"]),Ine(t,e)}const Mne=Z.newInstance(eN,"vtkRenderWindowInteractor");var Pne={newInstance:Mne,extend:eN,handledEvents:P4,...QA};const{vtkErrorMacro:Rne}=Z,Lne=[1,-1,1,-1,1,-1];function Ane(t,e){e.classHierarchy.push("vtkPoints"),t.getNumberOfPoints=t.getNumberOfTuples,t.setNumberOfPoints=function(r){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:3;t.getNumberOfPoints()!==r&&(e.size=r*n,e.values=Z.newTypedArray(e.dataType,e.size),t.setNumberOfComponents(n),t.modified())},t.setPoint=function(r){for(var n=arguments.length,i=new Array(n>1?n-1:0),o=1;o<n;o++)i[o-1]=arguments[o];t.setTuple(r,i)},t.getPoint=t.getTuple,t.findPoint=t.findTuple,t.insertNextPoint=(r,n,i)=>t.insertNextTuple([r,n,i]),t.getBounds=()=>{if(t.getNumberOfComponents()===3){const i=t.getRange(0);e.bounds[0]=i[0],e.bounds[1]=i[1];const o=t.getRange(1);e.bounds[2]=o[0],e.bounds[3]=o[1];const a=t.getRange(2);return e.bounds[4]=a[0],e.bounds[5]=a[1],e.bounds}if(t.getNumberOfComponents()!==2)return Rne(`getBounds called on an array with components of
|
||
${t.getNumberOfComponents()}`),Lne;const r=t.getRange(0);e.bounds[0]=r[0],e.bounds[1]=r[1];const n=t.getRange(1);return e.bounds[2]=n[0],e.bounds[3]=n[1],e.bounds[4]=0,e.bounds[5]=0,e.bounds},t.computeBounds=t.getBounds,t.setNumberOfComponents(e.numberOfComponents<2?3:e.numberOfComponents)}const Nne={empty:!0,numberOfComponents:3,dataType:rn.FLOAT,bounds:[1,-1,1,-1,1,-1]};function tN(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Nne,r),bt.extend(t,e,r),Ane(t,e)}const kne=Z.newInstance(tN,"vtkPoints");var l1={newInstance:kne,extend:tN};function nN(t){let e=0;return t.filter((r,n)=>n===e?(e+=r+1,!0):!1)}function rN(t){let e=0;for(let r=0;r<t.length;)r+=t[r]+1,e++;return e}const Vne={extractCellSizes:nN,getNumberOfCells:rN};function Fne(t,e){e.classHierarchy.push("vtkCellArray");const r={...t};t.getNumberOfCells=n=>(e.numberOfCells!==void 0&&!n||(e.cellSizes?e.numberOfCells=e.cellSizes.length:e.numberOfCells=rN(t.getData())),e.numberOfCells),t.getCellSizes=n=>(e.cellSizes!==void 0&&!n||(e.cellSizes=nN(t.getData())),e.cellSizes),t.resize=n=>{const i=t.getNumberOfTuples();r.resize(n);const o=t.getNumberOfTuples();o<i&&(o===0?(e.numberOfCells=0,e.cellSizes=[]):(e.numberOfCells=void 0,e.cellSizes=void 0))},t.setData=n=>{r.setData(n,1),e.numberOfCells=void 0,e.cellSizes=void 0},t.getCell=n=>{let i=n;const o=e.values[i++];return e.values.subarray(i,i+o)},t.insertNextCell=n=>{const i=t.getNumberOfCells();return t.insertNextTuples([n.length,...n]),++e.numberOfCells,e.cellSizes!=null&&e.cellSizes.push(n.length),i}}function Une(t){return{empty:!0,numberOfComponents:1,dataType:rn.UNSIGNED_INT,...t}}function iN(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};bt.extend(t,e,Une(r)),Fne(t,e)}const Bne=Z.newInstance(iN,"vtkCellArray");var _d={newInstance:Bne,extend:iN,...Vne};function Gne(t,e){e.classHierarchy.push("vtkCell"),t.initialize=function(r){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;if(n){e.pointsIds=n;let i=e.points.getData();i.length!==3*e.pointsIds.length&&(i=Z.newTypedArray(r.getDataType(),3*e.pointsIds.length));const o=r.getData();e.pointsIds.forEach((a,s)=>{let c=3*a,l=3*s;i[l]=o[c],i[++l]=o[++c],i[++l]=o[++c]}),e.points.setData(i)}else{e.points=r,e.pointsIds=new Array(r.getNumberOfPoints());for(let i=r.getNumberOfPoints()-1;i>=0;--i)e.pointsIds[i]=i}},t.getBounds=()=>{const r=e.points.getNumberOfPoints(),n=[];if(r){e.points.getPoint(0,n),e.bounds[0]=n[0],e.bounds[1]=n[0],e.bounds[2]=n[1],e.bounds[3]=n[1],e.bounds[4]=n[2],e.bounds[5]=n[2];for(let i=1;i<r;i++)e.points.getPoint(i,n),e.bounds[0]=n[0]<e.bounds[0]?n[0]:e.bounds[0],e.bounds[1]=n[0]>e.bounds[1]?n[0]:e.bounds[1],e.bounds[2]=n[1]<e.bounds[2]?n[1]:e.bounds[2],e.bounds[3]=n[1]>e.bounds[3]?n[1]:e.bounds[3],e.bounds[4]=n[2]<e.bounds[4]?n[2]:e.bounds[4],e.bounds[5]=n[2]>e.bounds[5]?n[2]:e.bounds[5]}else Gh(e.bounds);return e.bounds},t.getLength2=()=>{t.getBounds();let r=0,n=0;for(let i=0;i<3;i++)n=e.bounds[2*i+1]-e.bounds[2*i],r+=n*n;return r},t.getParametricDistance=r=>{let n,i=0;for(let o=0;o<3;o++)r[o]<0?n=-r[o]:r[o]>1?n=r[o]-1:n=0,n>i&&(i=n);return i},t.getNumberOfPoints=()=>e.points.getNumberOfPoints(),t.deepCopy=r=>{r.initialize(e.points,e.pointsIds)},t.getCellDimension=()=>{},t.intersectWithLine=(r,n,i,o,a,s,c)=>{},t.evaluatePosition=(r,n,i,o,a,s)=>{Z.vtkErrorMacro("vtkCell.evaluatePosition is not implemented.")}}const Wne={bounds:[-1,-1,-1,-1,-1,-1],pointsIds:[]};function oN(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Wne,r),Z.obj(t,e),e.points||(e.points=l1.newInstance()),Z.get(t,e,["points","pointsIds"]),Gne(t,e)}const zne=Z.newInstance(oN,"vtkCell");var Ay={newInstance:zne,extend:oN};function $ne(t,e){let r=e;for(e>=t.array.length&&(r+=t.array.length);r>t.array.length;)t.array.push({ncells:0,cells:null});t.array.length=r}function jne(t,e){e.classHierarchy.push("vtkCellLinks"),t.buildLinks=r=>{const n=r.getPoints().getNumberOfPoints(),i=r.getNumberOfCells(),o=new Uint32Array(n);if(r.isA("vtkPolyData")){for(let a=0;a<i;++a){const{cellPointIds:s}=r.getCellPoints(a);s.forEach(c=>{t.incrementLinkCount(c)})}t.allocateLinks(n),e.maxId=n-1;for(let a=0;a<i;++a){const{cellPointIds:s}=r.getCellPoints(a);s.forEach(c=>{t.insertCellReference(c,o[c]++,a)})}}else{for(let a=0;a<i;a++)Ay.newInstance().getPointsIds().forEach(c=>{t.incrementLinkCount(c)});t.allocateLinks(n),e.maxId=n-1;for(let a=0;a<i;++a)Ay.newInstance().getPointsIds().forEach(c=>{t.insertCellReference(c,o[c]++,a)})}},t.allocate=function(r){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1e3;e.array=Array(r).fill().map(()=>({ncells:0,cells:null})),e.extend=n,e.maxId=-1},t.initialize=()=>{e.array=null},t.getLink=r=>e.array[r],t.getNcells=r=>e.array[r].ncells,t.getCells=r=>e.array[r].cells,t.insertNextPoint=r=>{e.array.push({ncells:r,cells:Array(r)}),++e.maxId},t.insertNextCellReference=(r,n)=>{e.array[r].cells[e.array[r].ncells++]=n},t.deletePoint=r=>{e.array[r].ncells=0,e.array[r].cells=null},t.removeCellReference=(r,n)=>{e.array[n].cells=e.array[n].cells.filter(i=>i!==r),e.array[n].ncells=e.array[n].cells.length},t.addCellReference=(r,n)=>{e.array[n].cells[e.array[n].ncells++]=r},t.resizeCellList=(r,n)=>{e.array[r].cells.length=n},t.squeeze=()=>{$ne(e,e.maxId+1)},t.reset=()=>{e.maxId=-1},t.deepCopy=r=>{e.array=[...r.array],e.extend=r.extend,e.maxId=r.maxId},t.incrementLinkCount=r=>{++e.array[r].ncells},t.allocateLinks=r=>{for(let n=0;n<r;++n)e.array[n].cells=new Array(e.array[n].ncells)},t.insertCellReference=(r,n,i)=>{e.array[r].cells[n]=i}}const Hne={array:null,maxId:0,extend:0};function aN(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Hne,r),Z.obj(t,e),jne(t,e)}const Kne=Z.newInstance(aN,"vtkCellLinks");var qne={newInstance:Kne,extend:aN};const dr={VTK_EMPTY_CELL:0,VTK_VERTEX:1,VTK_POLY_VERTEX:2,VTK_LINE:3,VTK_POLY_LINE:4,VTK_TRIANGLE:5,VTK_TRIANGLE_STRIP:6,VTK_POLYGON:7,VTK_QUAD:9,VTK_QUADRATIC_EDGE:21,VTK_CONVEX_POINT_SET:41,VTK_POLYHEDRON:42},xS=["vtkEmptyCell","vtkVertex","vtkPolyVertex","vtkLine","vtkPolyLine","vtkTriangle","vtkTriangleStrip","vtkPolygon","vtkPixel","vtkQuad","vtkTetra","vtkVoxel","vtkHexahedron","vtkWedge","vtkPyramid","vtkPentagonalPrism","vtkHexagonalPrism","UnknownClass","UnknownClass","UnknownClass","UnknownClass","vtkQuadraticEdge","vtkQuadraticTriangle","vtkQuadraticQuad","vtkQuadraticTetra","vtkQuadraticHexahedron","vtkQuadraticWedge","vtkQuadraticPyramid","vtkBiQuadraticQuad","vtkTriQuadraticHexahedron","vtkQuadraticLinearQuad","vtkQuadraticLinearWedge","vtkBiQuadraticQuadraticWedge","vtkBiQuadraticQuadraticHexahedron","vtkBiQuadraticTriangle","vtkCubicLine","vtkQuadraticPolygon","UnknownClass","UnknownClass","UnknownClass","UnknownClass","vtkConvexPointSet","UnknownClass","UnknownClass","UnknownClass","UnknownClass","UnknownClass","UnknownClass","UnknownClass","UnknownClass","UnknownClass","vtkParametricCurve","vtkParametricSurface","vtkParametricTriSurface","vtkParametricQuadSurface","vtkParametricTetraRegion","vtkParametricHexRegion","UnknownClass","UnknownClass","UnknownClass","vtkHigherOrderEdge","vtkHigherOrderTriangle","vtkHigherOrderQuad","vtkHigherOrderPolygon","vtkHigherOrderTetrahedron","vtkHigherOrderWedge","vtkHigherOrderPyramid","vtkHigherOrderHexahedron"];function Xne(t){return t<xS.length?xS[t]:"UnknownClass"}function Yne(t){return xS.findIndex(t)}function Jne(t){return t<dr.VTK_QUADRATIC_EDGE||t===dr.VTK_CONVEX_POINT_SET||t===dr.VTK_POLYHEDRON}function Zne(t){return t===dr.VTK_TRIANGLE_STRIP||t===dr.VTK_POLY_LINE||t===dr.VTK_POLY_VERTEX}const Qne={getClassNameFromTypeId:Xne,getTypeIdFromClassName:Yne,isLinear:Jne,hasSubCells:Zne};function ere(t,e){e.classHierarchy.push("vtkCellTypes"),t.allocate=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:512,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1e3;e.size=r>0?r:1,e.extend=n>0?n:1,e.maxId=-1,e.typeArray=new Uint8Array(r),e.locationArray=new Uint32Array(r)},t.insertCell=(r,n,i)=>{e.typeArray[r]=n,e.locationArray[r]=i,r>e.maxId&&(e.maxId=r)},t.insertNextCell=(r,n)=>(t.insertCell(++e.maxId,r,n),e.maxId),t.setCellTypes=(r,n,i)=>{e.size=r,e.typeArray=n,e.locationArray=i,e.maxId=r-1},t.getCellLocation=r=>e.locationArray[r],t.deleteCell=r=>{e.typeArray[r]=dr.VTK_EMPTY_CELL},t.getNumberOfTypes=()=>e.maxId+1,t.isType=r=>{const n=t.getNumberOfTypes();for(let i=0;i<n;++i)if(r===t.getCellType(i))return!0;return!1},t.insertNextType=r=>t.insertNextCell(r,-1),t.getCellType=r=>e.typeArray[r],t.reset=()=>{e.maxId=-1},t.deepCopy=r=>{t.allocate(r.getSize(),r.getExtend()),e.typeArray.set(r.getTypeArray()),e.locationArray.set(r.getLocationArray()),e.maxId=r.getMaxId()}}const tre={size:0,maxId:-1,extend:1e3};function sN(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,tre,r),Z.obj(t,e),Z.get(t,e,["size","maxId","extend"]),Z.getArray(t,e,["typeArray","locationArray"]),ere(t,e)}const nre=Z.newInstance(sN,"vtkCellTypes");var rre={newInstance:nre,extend:sN,...Qne};const ire={NO_INTERSECTION:0,YES_INTERSECTION:1,ON_LINE:2};var cN={IntersectionState:ire};const{IntersectionState:Iv}=cN;function S0(t,e,r){let n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null;const i={t:Number.MIN_VALUE,distance:0},o=[];let a;o[0]=r[0]-e[0],o[1]=r[1]-e[1],o[2]=r[2]-e[2];const s=o[0]*(t[0]-e[0])+o[1]*(t[1]-e[1])+o[2]*(t[2]-e[2]),c=cn(o,o);let l=1e-5*s;return c!==0&&(i.t=s/c),l<0&&(l=-l),-l<c&&c<l||c<=0||i.t<0?a=e:i.t>1?a=r:(a=o,o[0]=e[0]+i.t*o[0],o[1]=e[1]+i.t*o[1],o[2]=e[2]+i.t*o[2]),n&&(n[0]=a[0],n[1]=a[1],n[2]=a[2]),i.distance=Fc(a,t),i}function lN(t,e,r,n,i,o){const a=[],s=[],c=[];i[0]=0,o[0]=0,$l(e,t,a),$l(n,r,s),$l(r,t,c);const l=[cn(a,a),-cn(a,s),-cn(a,s),cn(s,s)],f=[];if(f[0]=cn(a,c),f[1]=-cn(s,c),mR(l,f,2)===0){let u=Number.MAX_VALUE;const d=[t,e,r,n],h=[r,r,t,t],g=[n,n,e,e];o[0],o[0],i[0],i[0],i[0],i[0],o[0],o[0];let p;for(let v=0;v<4;v++)p=S0(d[v],h[v],g[v]),p.distance<u&&(u=p.distance,p.t);return Iv.ON_LINE}return i[0]=f[0],o[0]=f[1],i[0]>=0&&i[0]<=1&&o[0]>=0&&o[0]<=1?Iv.YES_INTERSECTION:Iv.NO_INTERSECTION}const ore={distanceToLine:S0,intersection:lN};function are(t,e){e.classHierarchy.push("vtkLine");function r(n){return n>=0&&n<=1}t.getCellDimension=()=>1,t.intersectWithLine=(n,i,o,a,s)=>{const c={intersect:0,t:Number.MAX_VALUE,subId:0,betweenPoints:null};s[1]=0,s[2]=0;const l=[],f=[],u=[];e.points.getPoint(0,f),e.points.getPoint(1,u);const d=[],h=[],g=lN(n,i,f,u,d,h);if(c.t=d[0],c.betweenPoints=r(c.t),s[0]=h[0],g===Iv.YES_INTERSECTION){for(let p=0;p<3;p++)a[p]=f[p]+s[0]*(u[p]-f[p]),l[p]=n[p]+c.t*(i[p]-n[p]);if(Fc(a,l)<=o*o)return c.intersect=1,c}else{let p;if(c.t<0)return p=S0(n,f,u,a),p.distance<=o*o&&(c.t=0,c.intersect=1,c.betweenPoints=!0),c;if(c.t>1)return p=S0(i,f,u,a),p.distance<=o*o&&(c.t=1,c.intersect=1,c.betweenPoints=!0),c;if(s[0]<0)return s[0]=0,p=S0(f,n,i,a),c.t=p.t,p.distance<=o*o&&(c.intersect=1),c;if(s[0]>1)return s[0]=1,p=S0(u,n,i,a),c.t=p.t,p.distance<=o*o&&(c.intersect=1),c}return c},t.evaluateLocation=(n,i,o)=>{const a=[],s=[];e.points.getPoint(0,a),e.points.getPoint(1,s);for(let c=0;c<3;c++)i[c]=a[c]+n[0]*(s[c]-a[c]);o[0]=1-n[0],o[1]=n[0]},t.evaluateOrientation=(n,i,o)=>e.orientations?(Tv(i,e.orientations[0],e.orientations[1],n[0]),o[0]=1-n[0],o[1]=n[0],!0):!1}const sre={orientations:null};function uN(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,sre,r),Ay.extend(t,e,r),Z.setGet(t,e,["orientations"]),are(t,e)}const cre=Z.newInstance(uN,"vtkLine");var os={newInstance:cre,extend:uN,...ore,...cN};function lre(t,e){e.classHierarchy.push("vtkPointSet"),e.points?e.points=nc(e.points):e.points=l1.newInstance(),t.getNumberOfPoints=()=>e.points.getNumberOfPoints(),t.getBounds=()=>e.points.getBounds(),t.computeBounds=()=>{t.getBounds()};const r=t.shallowCopy;t.shallowCopy=function(n){let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;r(n,i),e.points=l1.newInstance(),e.points.shallowCopy(n.getPoints())}}const ure={};function fN(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,ure,r),Wh.extend(t,e,r),Z.setGet(t,e,["points"]),lre(t,e)}const fre=Z.newInstance(fN,"vtkPointSet");var dre={newInstance:fre,extend:fN};function R4(t,e,r,n){const i=r[0]-e[0],o=r[1]-e[1],a=r[2]-e[2],s=t[0]-e[0],c=t[1]-e[1],l=t[2]-e[2];n[0]=o*l-a*c,n[1]=a*s-i*l,n[2]=i*c-o*s}function Ny(t,e,r,n){R4(t,e,r,n);const i=Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]);i!==0&&(n[0]/=i,n[1]/=i,n[2]/=i)}function hre(t,e,r,n,i,o){let a=arguments.length>6&&arguments[6]!==void 0?arguments[6]:1e-6,s=!1;const c=[],l=[],f=[],u=[],d=[];Ny(t,e,r,u),Ny(n,i,o,d);const h=-cn(u,t),g=-cn(d,n),p=[cn(d,t)+g,cn(d,e)+g,cn(d,r)+g];if(p[0]*p[1]>a&&p[0]*p[2]>a)return{intersect:!1,coplanar:s,pt1:c,pt2:l,surfaceId:f};const v=[cn(u,n)+h,cn(u,i)+h,cn(u,o)+h];if(v[0]*v[1]>a&&v[0]*v[2]>a)return{intersect:!1,coplanar:s,pt1:c,pt2:l,surfaceId:f};if(Math.abs(u[0]-d[0])<1e-9&&Math.abs(u[1]-d[1])<1e-9&&Math.abs(u[2]-d[2])<1e-9&&Math.abs(h-g)<1e-9)return s=!0,{intersect:!1,coplanar:s,pt1:c,pt2:l,surfaceId:f};const y=[t,e,r],m=[n,i,o],w=cn(u,d),x=(h-g*w)/(w*w-1),C=(g-h*w)/(w*w-1),S=[x*u[0]+C*d[0],x*u[1]+C*d[1],x*u[2]+C*d[2]],T=tl(u,d,[]);Td(T);let _=0,E=0;const b=[],D=[];let I=50,P=50;for(let B=0;B<3;B++){const H=B,A=(B+1)%3,F=Io.intersectWithLine(y[H],y[A],n,d);F.intersection&&F.t>0-a&&F.t<1+a&&(F.t<1+a&&F.t>1-a&&(I=_),b[_++]=cn(F.x,T)-cn(S,T));const G=Io.intersectWithLine(m[H],m[A],t,u);G.intersection&&G.t>0-a&&G.t<1+a&&(G.t<1+a&&G.t>1-a&&(P=E),D[E++]=cn(G.x,T)-cn(S,T))}if(_>2){_--;const B=b[2];b[2]=b[I],b[I]=B}if(E>2){E--;const B=D[2];D[2]=D[P],D[P]=B}if(_!==2||E!==2)return{intersect:!1,coplanar:s,pt1:c,pt2:l,surfaceId:f};if(Number.isNaN(b[0])||Number.isNaN(b[1])||Number.isNaN(D[0])||Number.isNaN(D[1]))return{intersect:!1,coplanar:s,pt1:c,pt2:l,surfaceId:f};if(b[0]>b[1]){const B=b[1];b[1]=b[0],b[0]=B}if(D[0]>D[1]){const B=D[1];D[1]=D[0],D[0]=B}let O,L;return b[1]<D[0]||D[1]<b[0]?{intersect:!1,coplanar:s,pt1:c,pt2:l,surfaceId:f}:(b[0]<D[0]?b[1]<D[1]?(f[0]=2,f[1]=1,O=D[0],L=b[1]):(f[0]=2,f[1]=2,O=D[0],L=D[1]):b[1]<D[1]?(f[0]=1,f[1]=1,O=b[0],L=b[1]):(f[0]=1,f[1]=2,O=b[0],L=D[1]),Q3(S,T,O,c),Q3(S,T,L,l),{intersect:!0,coplanar:s,pt1:c,pt2:l,surfaceId:f})}const gre={computeNormalDirection:R4,computeNormal:Ny,intersectWithTriangle:hre};function pre(t,e){e.classHierarchy.push("vtkTriangle"),t.getCellDimension=()=>2,t.intersectWithLine=(r,n,i,o,a)=>{const s={subId:0,t:Number.MAX_VALUE,intersect:0,betweenPoints:!1};a[2]=0;const c=[],l=i*i,f=[],u=[],d=[];e.points.getPoint(0,f),e.points.getPoint(1,u),e.points.getPoint(2,d);const h=[],g=[];if(Ny(f,u,d,h),h[0]!==0||h[1]!==0||h[2]!==0){const w=Io.intersectWithLine(r,n,f,h);if(s.betweenPoints=w.betweenPoints,s.t=w.t,o[0]=w.x[0],o[1]=w.x[1],o[2]=w.x[2],!w.intersection)return a[0]=0,a[1]=0,s.intersect=0,s;const x=t.evaluatePosition(o,c,a,g);if(x.evaluation>=0)return x.dist2<=l?(s.intersect=1,s):(s.intersect=x.evaluation,s)}const p=Fc(f,u),v=Fc(u,d),y=Fc(d,f);e.line||(e.line=os.newInstance()),p>v&&p>y?(e.line.getPoints().setPoint(0,f),e.line.getPoints().setPoint(1,u)):v>y&&v>p?(e.line.getPoints().setPoint(0,u),e.line.getPoints().setPoint(1,d)):(e.line.getPoints().setPoint(0,d),e.line.getPoints().setPoint(1,f));const m=e.line.intersectWithLine(r,n,i,o,a);if(s.betweenPoints=m.betweenPoints,s.t=m.t,m.intersect){const w=[],x=[],C=[];for(let S=0;S<3;S++)w[S]=f[S]-d[S],x[S]=u[S]-d[S],C[S]=o[S]-d[S];return a[0]=cn(C,w)/y,a[1]=cn(C,x)/v,s.intersect=1,s}return a[0]=0,a[1]=0,s.intersect=0,s},t.evaluatePosition=(r,n,i,o)=>{const a={subId:0,dist2:0,evaluation:-1};let s,c;const l=[],f=[],u=[],d=[];let h;const g=[],p=[],v=[];let y=0,m=0;const w=[];let x,C,S,T=[];const _=[],E=[],b=[];a.subId=0,i[2]=0,e.points.getPoint(1,l),e.points.getPoint(2,f),e.points.getPoint(0,u),R4(l,f,u,d),Io.generalizedProjectPoint(r,l,d,b);let D=0;for(s=0;s<3;s++)d[s]<0?h=-d[s]:h=d[s],h>D&&(D=h,m=s);for(c=0,s=0;s<3;s++)s!==m&&(w[c++]=s);for(s=0;s<2;s++)g[s]=b[w[s]]-u[w[s]],p[s]=l[w[s]]-u[w[s]],v[s]=f[w[s]]-u[w[s]];if(y=zr(p,v),y===0)return i[0]=0,i[1]=0,a.evaluation=-1,a;if(i[0]=zr(g,v)/y,i[1]=zr(p,g)/y,o[0]=1-(i[0]+i[1]),o[1]=i[0],o[2]=i[1],o[0]>=0&&o[0]<=1&&o[1]>=0&&o[1]<=1&&o[2]>=0&&o[2]<=1)n&&(a.dist2=Fc(b,r),n[0]=b[0],n[1]=b[1],n[2]=b[2]),a.evaluation=1;else{let I;if(n){if(o[1]<0&&o[2]<0)for(x=Fc(r,u),C=os.distanceToLine(r,l,u,I,_),S=os.distanceToLine(r,u,f,I,E),x<C?(a.dist2=x,T=u):(a.dist2=C,T=_),S<a.dist2&&(a.dist2=S,T=E),s=0;s<3;s++)n[s]=T[s];else if(o[2]<0&&o[0]<0)for(x=Fc(r,l),C=os.distanceToLine(r,l,u,I,_),S=os.distanceToLine(r,l,f,I,E),x<C?(a.dist2=x,T=l):(a.dist2=C,T=_),S<a.dist2&&(a.dist2=S,T=E),s=0;s<3;s++)n[s]=T[s];else if(o[1]<0&&o[0]<0)for(x=Fc(r,f),C=os.distanceToLine(r,f,u,I,_),S=os.distanceToLine(r,l,f,I,E),x<C?(a.dist2=x,T=f):(a.dist2=C,T=_),S<a.dist2&&(a.dist2=S,T=E),s=0;s<3;s++)n[s]=T[s];else if(o[0]<0){const P=os.distanceToLine(r,l,f,n);a.dist2=P.distance}else if(o[1]<0){const P=os.distanceToLine(r,f,u,n);a.dist2=P.distance}else if(o[2]<0){const P=os.distanceToLine(r,l,u,n);a.dist2=P.distance}}a.evaluation=0}return a},t.evaluateLocation=(r,n,i)=>{const o=[],a=[],s=[];e.points.getPoint(0,o),e.points.getPoint(1,a),e.points.getPoint(2,s);const c=1-r[0]-r[1];for(let l=0;l<3;l++)n[l]=o[l]*c+a[l]*r[0]+s[l]*r[1];i[0]=c,i[1]=r[0],i[2]=r[1]},t.getParametricDistance=r=>{let n,i=0;const o=[];o[0]=r[0],o[1]=r[1],o[2]=1-r[0]-r[1];for(let a=0;a<3;a++)o[a]<0?n=-o[a]:o[a]>1?n=o[a]-1:n=0,n>i&&(i=n);return i}}const mre={};function dN(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,mre,r),Ay.extend(t,e,r),pre(t,e)}const vre=Z.newInstance(dN,"vtkTriangle");var hN={newInstance:vre,extend:dN,...gre};const Kx=["verts","lines","polys","strips"],{vtkWarningMacro:ED}=Z,yre={[dr.VTK_LINE]:os,[dr.VTK_POLY_LINE]:os,[dr.VTK_TRIANGLE]:hN};function wre(t,e){e.classHierarchy.push("vtkPolyData");function r(i){return i.replace(/(?:^\w|[A-Z]|\b\w)/g,o=>o.toUpperCase()).replace(/\s+/g,"")}Kx.forEach(i=>{t[`getNumberOf${r(i)}`]=()=>e[i].getNumberOfCells(),e[i]?e[i]=nc(e[i]):e[i]=_d.newInstance()}),t.getNumberOfCells=()=>Kx.reduce((i,o)=>i+e[o].getNumberOfCells(),0);const n=t.shallowCopy;t.shallowCopy=function(i){let o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;n(i,o),Kx.forEach(a=>{e[a]=_d.newInstance(),e[a].shallowCopy(i.getReferenceByName(a))})},t.buildCells=()=>{const i=t.getNumberOfVerts(),o=t.getNumberOfLines(),a=t.getNumberOfPolys(),s=t.getNumberOfStrips(),c=i+o+a+s,l=new Uint8Array(c);let f=l;const u=new Uint32Array(c);let d=u;if(i){let h=0;e.verts.getCellSizes().forEach((g,p)=>{d[p]=h,f[p]=g>1?dr.VTK_POLY_VERTEX:dr.VTK_VERTEX,h+=g+1}),d=d.subarray(i),f=f.subarray(i)}if(o){let h=0;e.lines.getCellSizes().forEach((g,p)=>{d[p]=h,f[p]=g>2?dr.VTK_POLY_LINE:dr.VTK_LINE,g===1&&ED("Building VTK_LINE ",p," with only one point, but VTK_LINE needs at least two points. Check the input."),h+=g+1}),d=d.subarray(o),f=f.subarray(o)}if(a){let h=0;e.polys.getCellSizes().forEach((g,p)=>{switch(d[p]=h,g){case 3:f[p]=dr.VTK_TRIANGLE;break;case 4:f[p]=dr.VTK_QUAD;break;default:f[p]=dr.VTK_POLYGON;break}g<3&&ED("Building VTK_TRIANGLE ",p," with less than three points, but VTK_TRIANGLE needs at least three points. Check the input."),h+=g+1}),d+=d.subarray(a),f+=f.subarray(a)}if(s){let h=0;f.fill(dr.VTK_TRIANGLE_STRIP,0,s),e.strips.getCellSizes().forEach((g,p)=>{d[p]=h,h+=g+1})}e.cells=rre.newInstance(),e.cells.setCellTypes(c,l,u)},t.buildLinks=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;e.cells===void 0&&t.buildCells(),e.links=qne.newInstance(),i>0?e.links.allocate(i):e.links.allocate(t.getPoints().getNumberOfPoints()),e.links.buildLinks(t)},t.getCellType=i=>e.cells.getCellType(i),t.getCellPoints=i=>{const o=t.getCellType(i);let a=null;switch(o){case dr.VTK_VERTEX:case dr.VTK_POLY_VERTEX:a=e.verts;break;case dr.VTK_LINE:case dr.VTK_POLY_LINE:a=e.lines;break;case dr.VTK_TRIANGLE:case dr.VTK_QUAD:case dr.VTK_POLYGON:a=e.polys;break;case dr.VTK_TRIANGLE_STRIP:a=e.strips;break;default:return a=null,{type:0,cellPointIds:null}}const s=e.cells.getCellLocation(i),c=a.getCell(s);return{cellType:o,cellPointIds:c}},t.getPointCells=i=>e.links.getCells(i),t.getCellEdgeNeighbors=(i,o,a)=>{const s=e.links.getLink(o),c=e.links.getLink(a);return s.cells.filter(l=>l!==i&&c.cells.indexOf(l)!==-1)},t.getCell=function(i){let o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;const a=t.getCellPoints(i),s=o||yre[a.cellType].newInstance();return s.initialize(t.getPoints(),a.cellPointIds),s}}const xre={};function gN(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,xre,r),dre.extend(t,e,r),Z.get(t,e,["cells","links"]),Z.setGet(t,e,["verts","lines","polys","strips"]),wre(t,e)}const Cre=Z.newInstance(gN,"vtkPolyData");var Er={newInstance:Cre,extend:gN};const Sre=1e-6;function Tre(t,e){e.classHierarchy.push("vtkProp3D"),t.addPosition=n=>{e.position=e.position.map((i,o)=>i+n[o]),t.modified()},t.getOrientationWXYZ=()=>{const n=sf();sS(n,e.rotation);const i=new Float64Array(3),o=HY(i,n);return[my(o),i[0],i[1],i[2]]},t.getOrientationQuaternion=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];return sS(n,e.rotation)},t.rotateX=n=>{n!==0&&(e4(e.rotation,e.rotation,Gr(n)),t.modified())},t.rotateY=n=>{n!==0&&(t4(e.rotation,e.rotation,Gr(n)),t.modified())},t.rotateZ=n=>{n!==0&&(n4(e.rotation,e.rotation,Gr(n)),t.modified())},t.rotateWXYZ=(n,i,o,a)=>{if(n===0||i===0&&o===0&&a===0)return;const s=Gr(n),c=sf();nw(c,[i,o,a],s);const l=new Float64Array(16);xy(l,c),yn(e.rotation,e.rotation,l),t.modified()},t.rotateQuaternion=n=>{if(Math.abs(n[3])>=1-Sre)return;const i=xy(new Float64Array(16),n);yn(e.rotation,e.rotation,i),t.modified()},t.setOrientation=(n,i,o)=>n===e.orientation[0]&&i===e.orientation[1]&&o===e.orientation[2]?!1:(e.orientation=[n,i,o],It(e.rotation),t.rotateZ(o),t.rotateX(n),t.rotateY(i),t.modified(),!0),t.setUserMatrix=n=>Z1(e.userMatrix,n)?!1:(Cr(e.userMatrix,n),t.modified(),!0),t.getMatrix=()=>(t.computeMatrix(),e.matrix),t.computeMatrix=()=>{if(t.getMTime()>e.matrixMTime.getMTime()){It(e.matrix),e.userMatrix&&yn(e.matrix,e.matrix,e.userMatrix),er(e.matrix,e.matrix,e.origin),er(e.matrix,e.matrix,e.position),yn(e.matrix,e.matrix,e.rotation),nl(e.matrix,e.matrix,e.scale),er(e.matrix,e.matrix,[-e.origin[0],-e.origin[1],-e.origin[2]]),un(e.matrix,e.matrix),e.isIdentity=!0;for(let n=0;n<4;++n)for(let i=0;i<4;++i)(n===i?1:0)!==e.matrix[n+i*4]&&(e.isIdentity=!1);e.matrixMTime.modified()}},t.getCenter=()=>Hn.getCenter(e.bounds),t.getLength=()=>Hn.getLength(e.bounds),t.getXRange=()=>Hn.getXRange(e.bounds),t.getYRange=()=>Hn.getYRange(e.bounds),t.getZRange=()=>Hn.getZRange(e.bounds),t.getUserMatrix=()=>e.userMatrix;function r(){t.computeMatrix()}t.onModified(r)}const _re={origin:[0,0,0],position:[0,0,0],orientation:[0,0,0],rotation:null,scale:[1,1,1],bounds:[1,-1,1,-1,1,-1],userMatrix:null,userMatrixMTime:null,cachedProp3D:null,isIdentity:!0,matrixMTime:null};function pN(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,_re,r),rm.extend(t,e,r),e.matrixMTime={},Z.obj(e.matrixMTime),Z.get(t,e,["bounds","isIdentity"]),Z.getArray(t,e,["orientation"]),Z.setGetArray(t,e,["origin","position","scale"],3),e.matrix=It(new Float64Array(16)),e.rotation=It(new Float64Array(16)),e.userMatrix=It(new Float64Array(16)),e.transform=null,Tre(t,e)}const Ere=Z.newInstance(pN,"vtkProp3D");var L4={newInstance:Ere,extend:pN};const{vtkDebugMacro:bre}=Z;function Dre(t,e){e.classHierarchy.push("vtkActor");const r={...t};t.getActors=()=>[t],t.getIsOpaque=()=>{if(e.forceOpaque)return!0;if(e.forceTranslucent)return!1;e.property||t.getProperty();let n=e.property.getOpacity()>=1;return n=n&&(!e.texture||!e.texture.isTranslucent()),n=n&&(!e.mapper||e.mapper.getIsOpaque()),n},t.hasTranslucentPolygonalGeometry=()=>e.mapper===null?!1:(e.property===null&&t.setProperty(t.makeProperty()),!t.getIsOpaque()),t.makeProperty=Fd.newInstance,t.getProperty=()=>(e.property===null&&(e.property=t.makeProperty()),e.property),t.getBounds=()=>{if(e.mapper===null)return e.bounds;const n=e.mapper.getBounds();if(!n||n.length!==6)return n;if(n[0]>n[1])return e.mapperBounds=n.concat(),e.bounds=[1,-1,1,-1,1,-1],e.boundsMTime.modified(),n;if(!e.mapperBounds||n[0]!==e.mapperBounds[0]||n[1]!==e.mapperBounds[1]||n[2]!==e.mapperBounds[2]||n[3]!==e.mapperBounds[3]||n[4]!==e.mapperBounds[4]||n[5]!==e.mapperBounds[5]||t.getMTime()>e.boundsMTime.getMTime()){bre("Recomputing bounds..."),e.mapperBounds=n.concat();const i=[];Hn.getCorners(n,i),t.computeMatrix();const o=new Float64Array(16);un(o,e.matrix),i.forEach(a=>At(a,a,o)),e.bounds[0]=e.bounds[2]=e.bounds[4]=Number.MAX_VALUE,e.bounds[1]=e.bounds[3]=e.bounds[5]=-Number.MAX_VALUE,e.bounds=e.bounds.map((a,s)=>s%2===0?i.reduce((c,l)=>c>l[s/2]?l[s/2]:c,a):i.reduce((c,l)=>c<l[(s-1)/2]?l[(s-1)/2]:c,a)),e.boundsMTime.modified()}return e.bounds},t.getMTime=()=>{let n=r.getMTime();if(e.property!==null){const i=e.property.getMTime();n=i>n?i:n}if(e.backfaceProperty!==null){const i=e.backfaceProperty.getMTime();n=i>n?i:n}return n},t.getRedrawMTime=()=>{let n=e.mtime;if(e.mapper!==null){let i=e.mapper.getMTime();n=i>n?i:n,e.mapper.getInput()!==null&&(e.mapper.getInputAlgorithm().update(),i=e.mapper.getInput().getMTime(),n=i>n?i:n)}return n},t.getSupportsSelection=()=>e.mapper?e.mapper.getSupportsSelection():!1,t.processSelectorPixelBuffers=(n,i)=>{e.mapper&&e.mapper.processSelectorPixelBuffers&&e.mapper.processSelectorPixelBuffers(n,i)}}const Ire={mapper:null,property:null,backfaceProperty:null,forceOpaque:!1,forceTranslucent:!1,bounds:[1,-1,1,-1,1,-1]};function mN(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Ire,r),L4.extend(t,e,r),e.boundsMTime={},Z.obj(e.boundsMTime),Z.set(t,e,["property"]),Z.setGet(t,e,["backfaceProperty","forceOpaque","forceTranslucent","mapper"]),Dre(t,e)}const Ore=Z.newInstance(mN,"vtkActor");var uc={newInstance:Ore,extend:mN};function Mre(t,e){const r=t.invokeResize;delete t.invokeResize,e.renderWindow=$K.newInstance(),e.rendererMap={},e.openGLRenderWindow=one.newInstance(),e.renderWindow.addView(e.openGLRenderWindow),e.interactor=Pne.newInstance(),e.interactor.setView(e.openGLRenderWindow),e.interactor.initialize(),t.addRenderer=({viewport:n,id:i,background:o})=>{const a=ZA.newInstance({viewport:n,background:o||e.background});e.renderWindow.addRenderer(a),e.rendererMap[i]=a},t.destroy=()=>{e.renderWindow.getInteractor().delete()},t.removeRenderer=n=>{const i=t.getRenderer(n);e.renderWindow.removeRenderer(i),i.delete(),delete e.rendererMap[n]},t.getRenderer=n=>e.rendererMap[n],t.getRenderers=()=>{const{rendererMap:n}=e;return Object.keys(n).map(o=>({id:o,renderer:n[o]}))},t.resize=()=>{if(e.container){const{width:n,height:i}=e.container;e.openGLRenderWindow.setSize(Math.floor(n),Math.floor(i)),r(),e.renderWindow.render()}},t.setContainer=n=>{e.container=n,e.openGLRenderWindow.setContainer(e.container)},t.delete=Z.chain(t.setContainer,t.destroy,e.openGLRenderWindow.delete,t.delete),t.resize()}const Pre={background:[0,0,0],container:null};function vN(t,e,r={}){Object.assign(e,Pre,r),Z.obj(t,e),Z.get(t,e,["renderWindow","openGLRenderWindow","interactor","container"]),Z.event(t,e,"resize"),Mre(t,e)}const Rre=Z.newInstance(vN),Lre={newInstance:Rre,extend:vN},{vtkErrorMacro:p2}=Z;function Are(t,e){e.classHierarchy.push("vtkPiecewiseFunction"),t.getSize=()=>e.nodes.length,t.getType=()=>{let r,n=0,i=0;e.nodes.length>0&&(n=e.nodes[0].y);for(let o=1;o<e.nodes.length;o++){if(r=e.nodes[o].y,r!==n)if(r>n)switch(i){case 0:case 1:i=1;break;case 2:default:i=3;break}else switch(i){case 0:case 2:i=2;break;case 1:default:i=3;break}if(n=r,i===3)break}switch(i){case 0:return"Constant";case 1:return"NonDecreasing";case 2:return"NonIncreasing";case 3:default:return"Varied"}},t.getDataPointer=()=>{const r=e.nodes.length;if(e.function=null,r>0){e.function=[];for(let n=0;n<r;n++)e.function[2*n]=e.nodes[n].x,e.function[2*n+1]=e.nodes[n].y}return e.function},t.getFirstNonZeroValue=()=>{if(e.nodes.length===0)return 0;let r=1,n=0,i=0;for(;i<e.nodes.length;i++)if(e.nodes[i].y!==0){r=0;break}return r?n=Number.MAX_VALUE:i>0?n=e.nodes[i-1].x:e.clamping?n=-Number.MAX_VALUE:n=e.nodes[0].x,n},t.getNodeValue=(r,n)=>{const i=e.nodes.length;return r<0||r>=i?(p2("Index out of range!"),-1):(n[0]=e.nodes[r].x,n[1]=e.nodes[r].y,n[2]=e.nodes[r].midpoint,n[3]=e.nodes[r].sharpness,1)},t.setNodeValue=(r,n)=>{const i=e.nodes.length;if(r<0||r>=i)return p2("Index out of range!"),-1;const o=e.nodes[r].x;return e.nodes[r].x=n[0],e.nodes[r].y=n[1],e.nodes[r].midpoint=n[2],e.nodes[r].sharpness=n[3],o!==n[0]?t.sortAndUpdateRange():t.modified(),1},t.addPoint=(r,n)=>t.addPointLong(r,n,.5,0),t.addPointLong=(r,n,i,o)=>{if(i<0||i>1)return p2("Midpoint outside range [0.0, 1.0]"),-1;if(o<0||o>1)return p2("Sharpness outside range [0.0, 1.0]"),-1;e.allowDuplicateScalars||t.removePoint(r);const a={x:r,y:n,midpoint:i,sharpness:o};e.nodes.push(a),t.sortAndUpdateRange();let s;for(s=0;s<e.nodes.length&&e.nodes[s].x!==r;s++);return s<e.nodes.length?s:-1},t.setNodes=r=>{e.nodes!==r&&(e.nodes=r,t.sortAndUpdateRange())},t.sortAndUpdateRange=()=>{e.nodes.sort((n,i)=>n.x-i.x),t.updateRange()||t.modified()},t.updateRange=()=>{const r=e.range.slice(),n=e.nodes.length;return n?(e.range[0]=e.nodes[0].x,e.range[1]=e.nodes[n-1].x):(e.range[0]=0,e.range[1]=0),r[0]===e.range[0]&&r[1]===e.range[1]?!1:(t.modified(),!0)},t.removePoint=r=>{let n;for(n=0;n<e.nodes.length&&e.nodes[n].x!==r;n++);if(n>=e.nodes.length)return-1;const i=n;let o=!1;return e.nodes.splice(n,1),(n===0||n===e.nodes.length)&&(o=t.updateRange()),o||t.modified(),i},t.removeAllPoints=()=>{e.nodes=[],t.sortAndUpdateRange()},t.addSegment=(r,n,i,o)=>{t.sortAndUpdateRange();for(let a=0;a<e.nodes.length;)e.nodes[a].x>=r&&e.nodes[a].x<=i?e.nodes.splice(a,1):a++;t.addPoint(r,n,.5,0),t.addPoint(i,o,.5,0)},t.getValue=r=>{const n=[];return t.getTable(r,r,1,n),n[0]},t.adjustRange=r=>{if(r.length<2)return 0;const n=t.getRange();n[0]<r[0]?t.addPoint(r[0],t.getValue(r[0])):t.addPoint(r[0],t.getValue(n[0])),n[1]>r[1]?t.addPoint(r[1],t.getValue(r[1])):t.addPoint(r[1],t.getValue(n[1])),t.sortAndUpdateRange();for(let i=0;i<e.nodes.length;)e.nodes[i].x>=r[0]&&e.nodes[i].x<=r[1]?e.nodes.splice(i,1):++i;return t.sortAndUpdateRange(),1},t.estimateMinNumberOfSamples=(r,n)=>{const i=t.findMinimumXDistance();return Math.ceil((n-r)/i)},t.findMinimumXDistance=()=>{const r=e.nodes.length;if(r<2)return-1;let n=e.nodes[1].x-e.nodes[0].x;for(let i=0;i<r-1;i++){const o=e.nodes[i+1].x-e.nodes[i].x;o<n&&(n=o)}return n},t.getTable=function(r,n,i,o){let a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:1,s,c=0;const l=e.nodes.length;let f=0;l!==0&&(f=e.nodes[l-1].y);let u=0,d=0,h=0,g=0,p=0,v=0,y=0;for(s=0;s<i;s++){const m=a*s;for(i>1?u=r+s/(i-1)*(n-r):u=.5*(r+n);c<l&&u>e.nodes[c].x;)c++,c<l&&(d=e.nodes[c-1].x,h=e.nodes[c].x,g=e.nodes[c-1].y,p=e.nodes[c].y,v=e.nodes[c-1].midpoint,y=e.nodes[c-1].sharpness,v<1e-5&&(v=1e-5),v>.99999&&(v=.99999));if(c>=l)o[m]=e.clamping?f:0;else if(c===0)o[m]=e.clamping?e.nodes[0].y:0;else{let w=(u-d)/(h-d);if(w<v?w=.5*w/v:w=.5+.5*(w-v)/(1-v),y>.99)if(w<.5){o[m]=g;continue}else{o[m]=p;continue}if(y<.01){o[m]=(1-w)*g+w*p;continue}w<.5?w=.5*(w*2)**(1+10*y):w>.5&&(w=1-.5*((1-w)*2)**(1+10*y));const x=w*w,C=x*w,S=2*C-3*x+1,T=-2*C+3*x,_=C-2*x+w,E=C-x,b=p-g,D=(1-y)*b;o[m]=S*g+T*p+_*D+E*D;const I=g<p?g:p,P=g>p?g:p;o[m]=o[m]<I?I:o[m],o[m]=o[m]>P?P:o[m]}}}}const Nre={range:[0,0],clamping:!0,allowDuplicateScalars:!1};function yN(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Nre,r),Z.obj(t,e),e.nodes=[],Z.setGet(t,e,["allowDuplicateScalars","clamping"]),Z.setArray(t,e,["range"],2),Z.getArray(t,e,["range"]),Are(t,e)}const kre=Z.newInstance(yN,"vtkPiecewiseFunction");var Ed={newInstance:kre,extend:yN};const{BlendMode:Tu,FilterMode:Jg}=mP;function Vre(t,e,r,n,i){let o=null;return i?(o=i,o.removeAllPoints()):o=Ed.newInstance(),o.addPointLong(-1024,0,1,1),o.addPoint(t,e),o.addPoint(r,n),o}const Fre={createRadonTransferFunction:Vre};function Ure(t,e){e.classHierarchy.push("vtkVolumeMapper");const r={...t};t.getBounds=()=>{const n=t.getInputData();return n?(e.static||t.update(),e.bounds=n.getBounds()):e.bounds=of(),e.bounds},t.update=()=>{t.getInputData()},t.setBlendModeToComposite=()=>{t.setBlendMode(Tu.COMPOSITE_BLEND)},t.setBlendModeToMaximumIntensity=()=>{t.setBlendMode(Tu.MAXIMUM_INTENSITY_BLEND)},t.setBlendModeToMinimumIntensity=()=>{t.setBlendMode(Tu.MINIMUM_INTENSITY_BLEND)},t.setBlendModeToAverageIntensity=()=>{t.setBlendMode(Tu.AVERAGE_INTENSITY_BLEND)},t.setBlendModeToAdditiveIntensity=()=>{t.setBlendMode(Tu.ADDITIVE_INTENSITY_BLEND)},t.setBlendModeToRadonTransform=()=>{t.setBlendMode(Tu.RADON_TRANSFORM_BLEND)},t.getBlendModeAsString=()=>Z.enumToString(Tu,e.blendMode),t.setAverageIPScalarRange=(n,i)=>{console.warn("setAverageIPScalarRange is deprecated use setIpScalarRange"),t.setIpScalarRange(n,i)},t.getFilterModeAsString=()=>Z.enumToString(Jg,e.filterMode),t.setFilterModeToOff=()=>{t.setFilterMode(Jg.OFF)},t.setFilterModeToNormalized=()=>{t.setFilterMode(Jg.NORMALIZED)},t.setFilterModeToRaw=()=>{t.setFilterMode(Jg.RAW)},t.setGlobalIlluminationReach=n=>r.setGlobalIlluminationReach(rc(n,0,1)),t.setVolumetricScatteringBlending=n=>r.setVolumetricScatteringBlending(rc(n,0,1)),t.setVolumeShadowSamplingDistFactor=n=>r.setVolumeShadowSamplingDistFactor(n>=1?n:1),t.setAnisotropy=n=>r.setAnisotropy(rc(n,-.99,.99)),t.setLAOKernelSize=n=>r.setLAOKernelSize(j_(rc(n,1,32))),t.setLAOKernelRadius=n=>r.setLAOKernelRadius(n>=1?n:1)}const Bre=t=>({bounds:[1,-1,1,-1,1,-1],sampleDistance:1,imageSampleDistance:1,maximumSamplesPerRay:1e3,autoAdjustSampleDistances:!0,initialInteractionScale:1,interactionSampleDistanceFactor:1,blendMode:Tu.COMPOSITE_BLEND,ipScalarRange:[-1e6,1e6],filterMode:Jg.OFF,preferSizeOverAccuracy:!1,computeNormalFromOpacity:!1,volumetricScatteringBlending:0,globalIlluminationReach:0,volumeShadowSamplingDistFactor:5,anisotropy:0,localAmbientOcclusion:!1,LAOKernelSize:15,LAOKernelRadius:7,updatedExtents:[],...t});function wN(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Bre(r)),C4.extend(t,e,r),Z.setGet(t,e,["sampleDistance","imageSampleDistance","maximumSamplesPerRay","autoAdjustSampleDistances","initialInteractionScale","interactionSampleDistanceFactor","blendMode","filterMode","preferSizeOverAccuracy","computeNormalFromOpacity","volumetricScatteringBlending","globalIlluminationReach","volumeShadowSamplingDistFactor","anisotropy","localAmbientOcclusion","LAOKernelSize","LAOKernelRadius","updatedExtents"]),Z.setGetArray(t,e,["ipScalarRange"],2),Z.event(t,e,"lightingActivated"),Ure(t,e)}const Gre=Z.newInstance(wN,"vtkVolumeMapper");var xN={newInstance:Gre,extend:wN,...Fre};function Wre(t,e){e.classHierarchy.push("vtkSharedVolumeMapper");const r=t.delete;t.delete=()=>{e.scalarTexture=null,r()}}const zre={scalarTexture:null};function CN(t,e,r={}){Object.assign(e,zre,r),xN.extend(t,e,r),Z.setGet(t,e,["scalarTexture"]),Wre(t,e)}const $re=Z.newInstance(CN,"vtkSharedVolumeMapper"),jre={newInstance:$re,extend:CN};function _r(t){const e=t.indexOf(":");return t.substring(e+1)}function SN(t){let e=2166136261;for(let r=0;r<t.length;r++)e^=t.charCodeAt(r),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return(e>>>0).toString(36)}const Hre=1073741824;class Kre{constructor(){this._imageCache=new Map,this._volumeCache=new Map,this._imageIdsToVolumeIdCache=new Map,this._referencedImageIdToImageIdCache=new Map,this._geometryCache=new Map,this._imageCacheSize=0,this._maxCacheSize=3*Hre,this._geometryCacheSize=0,this.setMaxCacheSize=e=>{if(!e||typeof e!="number"){const r=`New max cacheSize ${this._maxCacheSize} should be defined and should be a number.`;throw new Error(r)}this._maxCacheSize=e},this.isCacheable=e=>{const r=this.getBytesAvailable(),n=Array.from(this._imageCache.values()).reduce((o,a)=>a.sharedCacheKey?o:o+a.sizeInBytes,0);return r+n>=e},this.getMaxCacheSize=()=>this._maxCacheSize,this.getCacheSize=()=>this._imageCacheSize,this._decacheImage=(e,r=!1)=>{var o;const n=this._imageCache.get(e);if(!n)return;if(n.sharedCacheKey&&!r)throw new Error("Cannot decache an image with a shared cache key. You need to manually decache the volume first.");const{imageLoadObject:i}=n;(o=n.image)!=null&&o.referencedImageId&&this._referencedImageIdToImageIdCache.delete(n.image.referencedImageId),i!=null&&i.cancelFn&&i.cancelFn(),i!=null&&i.decache&&i.decache(),this._imageCache.delete(e)},this._decacheVolume=e=>{const r=this._volumeCache.get(e);if(!r)return;const{volumeLoadObject:n,volume:i}=r;i&&(i.cancelLoading&&i.cancelLoading(),i.imageData&&i.imageData.delete(),n.cancelFn&&n.cancelFn(),i.imageIds&&i.imageIds.forEach(o=>{const a=this._imageCache.get(o);a&&a.sharedCacheKey===e&&(a.sharedCacheKey=void 0)}),this._volumeCache.delete(e))},this.purgeCache=()=>{const e=this._imageCache.keys();for(this.purgeVolumeCache();;){const{value:r,done:n}=e.next();if(n)break;this.removeImageLoadObject(r,{force:!0}),it(Ze,et.IMAGE_CACHE_IMAGE_REMOVED,{imageId:r})}},this.purgeVolumeCache=()=>{const e=this._volumeCache.keys();for(;;){const{value:r,done:n}=e.next();if(n)break;this.removeVolumeLoadObject(r),it(Ze,et.VOLUME_CACHE_VOLUME_REMOVED,{volumeId:r})}},this.getVolumeLoadObject=e=>{if(e===void 0)throw new Error("getVolumeLoadObject: volumeId must not be undefined");const r=this._volumeCache.get(e);if(r)return r.timeStamp=Date.now(),r.volumeLoadObject},this.putGeometryLoadObject=(e,r)=>{if(e===void 0)throw new Error("putGeometryLoadObject: geometryId must not be undefined");if(r.promise===void 0)throw new Error("putGeometryLoadObject: geometryLoadObject.promise must not be undefined");if(this._geometryCache.has(e))throw new Error("putGeometryLoadObject: geometryId already present in geometryCache");if(r.cancelFn&&typeof r.cancelFn!="function")throw new Error("putGeometryLoadObject: geometryLoadObject.cancel must be a function");const n={loaded:!1,geometryId:e,geometryLoadObject:r,timeStamp:Date.now(),sizeInBytes:0};return this._geometryCache.set(e,n),r.promise.then(i=>{try{this._putGeometryCommon(e,i,n)}catch(o){throw console.debug(`Error in _putGeometryCommon for geometry ${e}:`,o),o}}).catch(i=>{throw console.debug(`Error caching geometry ${e}:`,i),this._geometryCache.delete(e),i})},this.getGeometry=e=>{if(e===void 0)throw new Error("getGeometry: geometryId must not be undefined");const r=this._geometryCache.get(e);if(r)return r.timeStamp=Date.now(),r.geometry},this.removeGeometryLoadObject=e=>{if(e===void 0)throw new Error("removeGeometryLoadObject: geometryId must not be undefined");const r=this._geometryCache.get(e);if(!r)throw new Error("removeGeometryLoadObject: geometryId was not present in geometryCache");this.decrementGeometryCacheSize(r.sizeInBytes);const n={geometry:r,geometryId:e};it(Ze,et.GEOMETRY_CACHE_GEOMETRY_REMOVED,n),this._decacheGeometry(e)},this._decacheGeometry=e=>{const r=this._geometryCache.get(e);if(!r)return;const{geometryLoadObject:n}=r;n.cancelFn&&n.cancelFn(),n.decache&&n.decache(),this._geometryCache.delete(e)},this.incrementGeometryCacheSize=e=>{this._geometryCacheSize+=e},this.decrementGeometryCacheSize=e=>{this._geometryCacheSize-=e},this.getImageByReferencedImageId=e=>{var n;const r=this._referencedImageIdToImageIdCache.get(e);if(r)return(n=this._imageCache.get(r))==null?void 0:n.image},this.getImage=(e,r=ca.FAR_REPLICATE)=>{var i;if(e===void 0)throw new Error("getImage: imageId must not be undefined");const n=this._imageCache.get(e);if(n&&(n.timeStamp=Date.now(),!(((i=n.image)==null?void 0:i.imageQualityStatus)<r)))return n.image},this.getVolume=(e,r=!1)=>{var i;if(e===void 0)throw new Error("getVolume: volumeId must not be undefined");const n=this._volumeCache.get(e);return n?(n.timeStamp=Date.now(),n.volume):r?(i=[...this._volumeCache.values()].find(o=>o.volumeId.includes(e)))==null?void 0:i.volume:void 0},this.getVolumes=()=>Array.from(this._volumeCache.values()).map(r=>r.volume),this.filterVolumesByReferenceId=e=>this.getVolumes().filter(n=>n.referencedVolumeId===e),this.removeImageLoadObject=(e,{force:r=!1}={})=>{if(e===void 0)throw new Error("removeImageLoadObject: imageId must not be undefined");const n=this._imageCache.get(e);if(!n)throw new Error("removeImageLoadObject: imageId was not present in imageCache");this._decacheImage(e,r),this.incrementImageCacheSize(-n.sizeInBytes);const i={image:n,imageId:e};it(Ze,et.IMAGE_CACHE_IMAGE_REMOVED,i)},this.removeVolumeLoadObject=e=>{if(e===void 0)throw new Error("removeVolumeLoadObject: volumeId must not be undefined");const r=this._volumeCache.get(e);if(!r)throw new Error("removeVolumeLoadObject: volumeId was not present in volumeCache");const n={volume:r,volumeId:e};it(Ze,et.VOLUME_CACHE_VOLUME_REMOVED,n),this._decacheVolume(e)},this.incrementImageCacheSize=e=>{this._imageCacheSize+=e},this.decrementImageCacheSize=e=>{this._imageCacheSize-=e},this.getGeometryLoadObject=e=>{if(e===void 0)throw new Error("getGeometryLoadObject: geometryId must not be undefined");const r=this._geometryCache.get(e);if(r)return r.timeStamp=Date.now(),r.geometryLoadObject}}generateVolumeId(e){const r=e.map(_r).sort();let n=2166136261;for(const i of r){const o=SN(i);for(let a=0;a<o.length;a++)n^=o.charCodeAt(a),n+=(n<<1)+(n<<4)+(n<<7)+(n<<8)+(n<<24)}return`volume-${(n>>>0).toString(36)}`}getImageIdsForVolumeId(e){return Array.from(this._imageIdsToVolumeIdCache.entries()).filter(([r,n])=>n===e).map(([r])=>r)}getBytesAvailable(){return this.getMaxCacheSize()-this.getCacheSize()}decacheIfNecessaryUntilBytesAvailable(e,r){let n=this.getBytesAvailable();if(n>=e)return n;const i=Array.from(this._imageCache.values()).filter(c=>!c.sharedCacheKey);function o(c,l){return c.timeStamp>l.timeStamp?1:c.timeStamp<l.timeStamp?-1:0}i.sort(o);const a=i.map(c=>c.imageId);let s=a;r&&(s=a.filter(c=>!r.includes(c)));for(const c of s)if(this.removeImageLoadObject(c),it(Ze,et.IMAGE_CACHE_IMAGE_REMOVED,{imageId:c}),n=this.getBytesAvailable(),n>=e)return n;for(const c of a)if(this.removeImageLoadObject(c),it(Ze,et.IMAGE_CACHE_IMAGE_REMOVED,{imageId:c}),n=this.getBytesAvailable(),n>=e)return n}_putImageCommon(e,r,n){if(!this._imageCache.has(e)){console.warn("The image was purged from the cache before it completed loading.");return}if(!r){console.warn("Image is undefined");return}if(r.sizeInBytes===void 0||Number.isNaN(r.sizeInBytes))throw new Error("_putImageCommon: image.sizeInBytes must not be undefined");if(r.sizeInBytes.toFixed===void 0)throw new Error("_putImageCommon: image.sizeInBytes is not a number");if(!this.isCacheable(r.sizeInBytes))throw new Error(et.CACHE_SIZE_EXCEEDED);this.decacheIfNecessaryUntilBytesAvailable(r.sizeInBytes),n.loaded=!0,n.image=r,n.sizeInBytes=r.sizeInBytes,this.incrementImageCacheSize(n.sizeInBytes);const i={image:n};r.referencedImageId&&this._referencedImageIdToImageIdCache.set(r.referencedImageId,e),it(Ze,et.IMAGE_CACHE_IMAGE_ADDED,i),n.sharedCacheKey=r.sharedCacheKey}async putImageLoadObject(e,r){if(e===void 0)throw console.error("putImageLoadObject: imageId must not be undefined"),new Error("putImageLoadObject: imageId must not be undefined");if(r.promise===void 0)throw console.error("putImageLoadObject: imageLoadObject.promise must not be undefined"),new Error("putImageLoadObject: imageLoadObject.promise must not be undefined");const n=this._imageCache.get(e);if(n!=null&&n.imageLoadObject)throw console.warn(`putImageLoadObject: imageId ${e} already in cache`),new Error("putImageLoadObject: imageId already in cache");if(r.cancelFn&&typeof r.cancelFn!="function")throw console.error("putImageLoadObject: imageLoadObject.cancel must be a function"),new Error("putImageLoadObject: imageLoadObject.cancel must be a function");const i={...n,loaded:!1,imageId:e,sharedCacheKey:void 0,imageLoadObject:r,timeStamp:Date.now(),sizeInBytes:0};return this._imageCache.set(e,i),this._imageCache.set(e,i),r.promise.then(o=>{try{this._putImageCommon(e,o,i)}catch(a){throw console.debug(`Error in _putImageCommon for image ${e}:`,a),a}}).catch(o=>{throw console.debug(`Error caching image ${e}:`,o),this._imageCache.delete(e),o})}putImageSync(e,r){if(e===void 0)throw new Error("putImageSync: imageId must not be undefined");if(this._imageCache.has(e))throw new Error("putImageSync: imageId already in cache");const n={loaded:!1,imageId:e,sharedCacheKey:void 0,imageLoadObject:{promise:Promise.resolve(r)},timeStamp:Date.now(),sizeInBytes:0};this._imageCache.set(e,n);try{this._putImageCommon(e,r,n)}catch(i){throw this._imageCache.delete(e),i}}getImageLoadObject(e){if(e===void 0)throw new Error("getImageLoadObject: imageId must not be undefined");const r=this._imageCache.get(e);if(r)return r.timeStamp=Date.now(),r.imageLoadObject}isLoaded(e){const r=this._imageCache.get(e);return r?r.loaded:!1}getVolumeContainingImageId(e){const r=Array.from(this._volumeCache.keys()),n=_r(e);for(const i of r){const o=this._volumeCache.get(i);if(!o)return;const{volume:a}=o;if(!a.imageIds.length)return;const s=a.getImageURIIndex(n);if(s>-1)return{volume:a,imageIdIndex:s}}}getCachedImageBasedOnImageURI(e){const r=_r(e),i=Array.from(this._imageCache.keys()).find(o=>_r(o)===r);if(i)return this._imageCache.get(i)}_putVolumeCommon(e,r,n){var o;if(!this._volumeCache.get(e)){console.warn("The volume was purged from the cache before it completed loading.");return}n.loaded=!0,n.volume=r,(o=r.imageIds)==null||o.forEach(a=>{const s=this._imageCache.get(a);s&&(s.sharedCacheKey=e)});const i={volume:n};it(Ze,et.VOLUME_CACHE_VOLUME_ADDED,i)}putVolumeSync(e,r){if(e===void 0)throw new Error("putVolumeSync: volumeId must not be undefined");if(this._volumeCache.has(e))throw new Error("putVolumeSync: volumeId already in cache");const n={loaded:!1,volumeId:e,volumeLoadObject:{promise:Promise.resolve(r)},timeStamp:Date.now(),sizeInBytes:0};this._volumeCache.set(e,n);try{this._putVolumeCommon(e,r,n)}catch(i){throw this._volumeCache.delete(e),i}}async putVolumeLoadObject(e,r){if(e===void 0)throw new Error("putVolumeLoadObject: volumeId must not be undefined");if(r.promise===void 0)throw new Error("putVolumeLoadObject: volumeLoadObject.promise must not be undefined");if(this._volumeCache.has(e))throw new Error(`putVolumeLoadObject: volumeId:${e} already in cache`);if(r.cancelFn&&typeof r.cancelFn!="function")throw new Error("putVolumeLoadObject: volumeLoadObject.cancel must be a function");const n={loaded:!1,volumeId:e,volumeLoadObject:r,timeStamp:Date.now(),sizeInBytes:0};return this._volumeCache.set(e,n),r.promise.then(i=>{try{this._putVolumeCommon(e,i,n)}catch(o){throw console.error(`Error in _putVolumeCommon for volume ${e}:`,o),this._volumeCache.delete(e),o}}).catch(i=>{throw this._volumeCache.delete(e),i})}_putGeometryCommon(e,r,n){if(!this._geometryCache.get(e)){console.warn("The geometry was purged from the cache before it completed loading.");return}if(!r){console.warn("Geometry is undefined");return}if(r.sizeInBytes===void 0||Number.isNaN(r.sizeInBytes))throw new Error("_putGeometryCommon: geometry.sizeInBytes must not be undefined");if(r.sizeInBytes.toFixed===void 0)throw new Error("_putGeometryCommon: geometry.sizeInBytes is not a number");if(!this.isCacheable(r.sizeInBytes))throw new Error(et.CACHE_SIZE_EXCEEDED);this.decacheIfNecessaryUntilBytesAvailable(r.sizeInBytes),n.loaded=!0,n.geometry=r,n.sizeInBytes=r.sizeInBytes,this.incrementGeometryCacheSize(n.sizeInBytes);const i={geometry:n};it(Ze,et.GEOMETRY_CACHE_GEOMETRY_ADDED,i)}putGeometrySync(e,r){if(e===void 0)throw new Error("putGeometrySync: geometryId must not be undefined");if(this._geometryCache.has(e))throw new Error("putGeometrySync: geometryId already in cache");const n={loaded:!1,geometryId:e,geometryLoadObject:{promise:Promise.resolve(r)},timeStamp:Date.now(),sizeInBytes:0};this._geometryCache.set(e,n);try{this._putGeometryCommon(e,r,n)}catch(i){throw this._geometryCache.delete(e),i}}setPartialImage(e,r){const n=this._imageCache.get(e);if(!n){r&&this._imageCache.set(e,{image:r,imageId:e,loaded:!1,timeStamp:Date.now(),sizeInBytes:0});return}n.loaded&&(n.loaded=!1,n.imageLoadObject=null,this.incrementImageCacheSize(-n.sizeInBytes),n.sizeInBytes=0),n.image=r||n.image}getImageQuality(e){var n;const r=(n=this._imageCache.get(e))==null?void 0:n.image;return r?r.imageQualityStatus||ca.FULL_RESOLUTION:void 0}}const $e=new Kre;function bD(t,e){const r=b4(e),n=new r(t.length);return n.set(t),n}function qre(t,e){e.classHierarchy.push("vtkStreamingOpenGLTexture"),e.updatedFrames=[],e.volumeId=null;const r=t.create3DFilterableFromRaw;t.create3DFilterableFromRaw=(s,c,l,f,u,d,h)=>{e.inputDataType=u,e.inputNumComps=f,r(s,c,l,f,u,d,h)};const n=t.updateVolumeInfoForGL;t.updateVolumeInfoForGL=(s,c)=>{const l=n(s,c);return e.volumeInfo.dataComputedScale=[1],e.volumeInfo.dataComputedOffset=[0],l},t.update3DFromRaw=()=>{const{volumeId:s}=e;if(!s)return;const c=$e.getVolume(s);if(e._openGLRenderWindow.activateTexture(t),t.createTexture(),t.bind(),c.isDynamicVolume()){a();return}return t.hasUpdatedFrames()&&o()};const i=t.modified;t.setUpdatedFrame=s=>{e.updatedFrames[s]=!0,i()},t.modified=()=>{i();const s=$e.getVolume(e.volumeId);if(!s)return;const c=s.imageIds;for(let l=0;l<c.length;l++)e.updatedFrames[l]=!0};function o(){const s=$e.getVolume(e.volumeId),c=s.imageIds;for(let l=0;l<e.updatedFrames.length;l++)if(e.updatedFrames[l]){const f=$e.getImage(c[l]);if(!f)continue;let u=f.voxelManager.getScalarData();const d=e.context;s.dataType!==u.constructor.name&&(u=bD(u,s.dataType));const[h]=t.updateArrayDataTypeForGL(s.dataType,[u]);t.bind();const g=l;d.texSubImage3D(e.target,0,0,0,g,e.width,e.height,1,e.format,e.openGLDataType,h),t.deactivate(),e.updatedFrames[l]=null}return e.generateMipmap&&e.context.generateMipmap(e.target),t.deactivate(),!0}function a(){const s=$e.getVolume(e.volumeId),c=s.getCurrentDimensionGroupImageIds();if(!c.length)return!1;let l;for(let f=0;f<c.length;f++){const u=c[f],d=$e.getImage(u);let h;d?(h=d.voxelManager.getScalarData(),l=h.constructor):(l=b4(s.dataType,!0),h=new l(e.width*e.height));const g=e.context;s.dataType!==h.constructor.name&&(h=bD(h,s.dataType));const[p]=t.updateArrayDataTypeForGL(s.dataType,[h]);t.bind();let v=f;g.texSubImage3D(e.target,0,0,0,v,e.width,e.height,1,e.format,e.openGLDataType,p),t.deactivate()}return e.generateMipmap&&e.context.generateMipmap(e.target),t.deactivate(),!0}t.hasUpdatedFrames=()=>!e.updatedFrames.length||e.updatedFrames.some(s=>s),t.getUpdatedFrames=()=>e.updatedFrames,t.setVolumeId=s=>{e.volumeId=s},t.getVolumeId=()=>e.volumeId,t.setTextureParameters=({width:s,height:c,depth:l,numberOfComponents:f,dataType:u})=>{e.width??(e.width=s),e.height??(e.height=c),e.depth??(e.depth=l),e.inputNumComps??(e.inputNumComps=f),e.inputDataType??(e.inputDataType=u)},t.getTextureParameters=()=>({width:e.width,height:e.height,depth:e.depth,numberOfComponents:e.inputNumComps,dataType:e.inputDataType})}const Xre={updatedFrames:[]};function TN(t,e,r={}){Object.assign(e,Xre,r),mr.extend(t,e,r),qre(t,e)}const Yre=Z.newInstance(TN,"vtkStreamingOpenGLTexture"),Jre={newInstance:Yre,extend:TN},Zre={isPerformingCoordinateTransformation:!1};function _N(t,e,r={}){Object.assign(e,Zre,r),M4.extend(t,e,r),Z.setGet(t,e,["isPerformingCoordinateTransformation"]),eie(t,e)}const Qre=Z.newInstance(_N,"vtkSlabCamera");function eie(t,e){e.classHierarchy.push("vtkSlabCamera");const r=It(new Float64Array(16)),n=new Float64Array(3);t.getProjectionMatrix=(i,o,a)=>{const s=ma();if(e.projectionMatrix){const d=1/e.physicalScale;return Wn(n,d,d,d),Cr(s,e.projectionMatrix),nl(s,s,n),un(s,s),s}It(r);let c=e.clippingRange[0],l=e.clippingRange[1];e.isPerformingCoordinateTransformation&&(c=e.distance,l=e.distance+.1);const f=l-c,u=[c+(o+1)*f/2,c+(a+1)*f/2];if(e.parallelProjection){const d=e.parallelScale*i,h=e.parallelScale,g=(e.windowCenter[0]-1)*d,p=(e.windowCenter[0]+1)*d,v=(e.windowCenter[1]-1)*h,y=(e.windowCenter[1]+1)*h;o4(r,g,p,v,y,u[0],u[1]),un(r,r)}else{if(e.useOffAxisProjection)throw new Error("Off-Axis projection is not supported at this time");{const d=Math.tan(Gt.radiansFromDegrees(e.viewAngle)/2);let h,g;e.useHorizontalViewAngle===!0?(h=c*d,g=c*d/i):(h=c*d*i,g=c*d);const p=(e.windowCenter[0]-1)*h,v=(e.windowCenter[0]+1)*h,y=(e.windowCenter[1]-1)*g,m=(e.windowCenter[1]+1)*g,w=u[0],x=u[1];r[0]=2*w/(v-p),r[5]=2*w/(m-y),r[2]=(p+v)/(v-p),r[6]=(y+m)/(m-y),r[10]=-(w+x)/(x-w),r[14]=-1,r[11]=-2*w*x/(x-w),r[15]=0}}return Cr(s,r),s}}const tie={newInstance:Qre,extend:_N};function Qs(t){return ga(t,"vtkVolume")||ga(t,"vtkImageSlice")}function ga(t,e){const r="isA"in t?t:t.actor;return r?!!r.isA(e):!1}const Xc=[];function zh(t,e=0){let r;for(r=0;r<Xc.length&&!(Xc[r].priority<=e);r++);Xc.splice(r,0,{priority:e,provider:t})}function nie(t){for(let e=0;e<Xc.length;e++)if(Xc[e].provider===t){Xc.splice(e,1);break}}function rie(){for(;Xc.length>0;)Xc.pop()}function ct(t,...e){for(let r=0;r<Xc.length;r++){const n=Xc[r].provider(t,...e);if(n!==void 0)return n}}const A4=Object.freeze(Object.defineProperty({__proto__:null,addProvider:zh,get:ct,removeAllProviders:rie,removeProvider:nie},Symbol.toStringTag,{value:"Module"}));var EN={exports:{}};(function(t){(function(e,r){t.exports?t.exports=r():e.log=r()})(Ai,function(){var e=function(){},r="undefined",n=typeof window!==r&&typeof window.navigator!==r&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"],o={},a=null;function s(p,v){var y=p[v];if(typeof y.bind=="function")return y.bind(p);try{return Function.prototype.bind.call(y,p)}catch{return function(){return Function.prototype.apply.apply(y,[p,arguments])}}}function c(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function l(p){return p==="debug"&&(p="log"),typeof console===r?!1:p==="trace"&&n?c:console[p]!==void 0?s(console,p):console.log!==void 0?s(console,"log"):e}function f(){for(var p=this.getLevel(),v=0;v<i.length;v++){var y=i[v];this[y]=v<p?e:this.methodFactory(y,p,this.name)}if(this.log=this.debug,typeof console===r&&p<this.levels.SILENT)return"No console available for logging"}function u(p){return function(){typeof console!==r&&(f.call(this),this[p].apply(this,arguments))}}function d(p,v,y){return l(p)||u.apply(this,arguments)}function h(p,v){var y=this,m,w,x,C="loglevel";typeof p=="string"?C+=":"+p:typeof p=="symbol"&&(C=void 0);function S(D){var I=(i[D]||"silent").toUpperCase();if(!(typeof window===r||!C)){try{window.localStorage[C]=I;return}catch{}try{window.document.cookie=encodeURIComponent(C)+"="+I+";"}catch{}}}function T(){var D;if(!(typeof window===r||!C)){try{D=window.localStorage[C]}catch{}if(typeof D===r)try{var I=window.document.cookie,P=encodeURIComponent(C),O=I.indexOf(P+"=");O!==-1&&(D=/^([^;]+)/.exec(I.slice(O+P.length+1))[1])}catch{}return y.levels[D]===void 0&&(D=void 0),D}}function _(){if(!(typeof window===r||!C)){try{window.localStorage.removeItem(C)}catch{}try{window.document.cookie=encodeURIComponent(C)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function E(D){var I=D;if(typeof I=="string"&&y.levels[I.toUpperCase()]!==void 0&&(I=y.levels[I.toUpperCase()]),typeof I=="number"&&I>=0&&I<=y.levels.SILENT)return I;throw new TypeError("log.setLevel() called with invalid level: "+D)}y.name=p,y.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},y.methodFactory=v||d,y.getLevel=function(){return x??w??m},y.setLevel=function(D,I){return x=E(D),I!==!1&&S(x),f.call(y)},y.setDefaultLevel=function(D){w=E(D),T()||y.setLevel(D,!1)},y.resetLevel=function(){x=null,_(),f.call(y)},y.enableAll=function(D){y.setLevel(y.levels.TRACE,D)},y.disableAll=function(D){y.setLevel(y.levels.SILENT,D)},y.rebuild=function(){if(a!==y&&(m=E(a.getLevel())),f.call(y),a===y)for(var D in o)o[D].rebuild()},m=E(a?a.getLevel():"WARN");var b=T();b!=null&&(x=E(b)),f.call(y)}a=new h,a.getLogger=function(v){if(typeof v!="symbol"&&typeof v!="string"||v==="")throw new TypeError("You must supply a name when creating a logger.");var y=o[v];return y||(y=o[v]=new h(v,a.methodFactory)),y};var g=typeof window!==r?window.log:void 0;return a.noConflict=function(){return typeof window!==r&&window.log===a&&(window.log=g),a},a.getLoggers=function(){return o},a.default=a,a})})(EN);var iie=EN.exports;const oie=ll(iie),bN=oie.noConflict();typeof window<"u"&&(window.log=bN);function pw(t){const e=bN.getLogger(t[0]);return e.getLogger=(...r)=>pw(`${t}.${r.join(".")}`),e}function N4(...t){return pw(t.join("."))}const $h=pw("cs3d"),k4=$h.getLogger("core"),aie=$h.getLogger("tools"),sie=$h.getLogger("dicomImageLoader"),cie=$h.getLogger("ai"),lie=$h.getLogger("examples"),uie=N4("consistency","dicom"),fie=N4("consistency","image"),die=Object.freeze(Object.defineProperty({__proto__:null,aiLog:cie,coreLog:k4,cs3dLog:$h,dicomConsistencyLog:uie,examplesLog:lie,getLogger:N4,getRootLogger:pw,imageConsistencyLog:fie,loaderLog:sie,toolsLog:aie},Symbol.toStringTag,{value:"Module"}));function Cf(t,e){const{direction:r,spacing:n}=t,i=r.slice(0,3),o=r.slice(3,6),a=r.slice(6,9),s=[xt(i,e),xt(o,e),xt(a,e)],c=Ke();return Wn(c,s[0]*n[0],s[1]*n[1],s[2]*n[2]),Ko(c)}const DD=k4.getLogger("utilities","getClosestImageId");function Ql(t,e,r,n){const{direction:i,spacing:o,imageIds:a}=t,{ignoreSpacing:s=!1}=n||{};if(!(a!=null&&a.length))return;const c=i.slice(6,9),l=xt(c,r);if(Math.abs(l)<1-Ga)return;let f;s||(f=Cf({direction:i,spacing:o},r)/2);let u,d=1/0;for(let h=0;h<a.length;h++){const g=a[h],p=ct("imagePlaneModule",g);if(!(p!=null&&p.imagePositionPatient)){DD.warn(`Missing imagePositionPatient for imageId: ${g}`);continue}const{imagePositionPatient:v}=p,y=Ke();hn(y,e,v);const m=Math.abs(xt(y,r));s?m<d&&(d=m,u=g):m<f&&m<d&&(d=m,u=g)}return u===void 0&&DD.warn("No imageId found within the specified criteria (half spacing or absolute closest)."),u}const hie=t=>t,ID=1e-6;let DN=class{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;this.matrix=It(new Float64Array(16)),this.tmp=new Float64Array(3),this.angleConv=e?zX:hie}rotateFromDirections(e,r){const n=new Float64Array(3),i=new Float64Array(3),o=new Float64Array(16);Wn(n,e[0],e[1],e[2]),Wn(i,r[0],r[1],r[2]),Un(n,n),Un(i,i);const a=xt(n,i);return a>=1?this:(Tn(this.tmp,n,i),Ko(this.tmp)<ID&&(Tn(this.tmp,[1,0,0],e),Ko(this.tmp)<ID&&Tn(this.tmp,[0,1,0],e)),i4(o,Math.acos(a),this.tmp),yn(this.matrix,this.matrix,o),this)}rotate(e,r){return Wn(this.tmp,...r),Un(this.tmp,this.tmp),To(this.matrix,this.matrix,this.angleConv(e),this.tmp),this}rotateX(e){return e4(this.matrix,this.matrix,this.angleConv(e)),this}rotateY(e){return t4(this.matrix,this.matrix,this.angleConv(e)),this}rotateZ(e){return n4(this.matrix,this.matrix,this.angleConv(e)),this}translate(e,r,n){return Wn(this.tmp,e,r,n),er(this.matrix,this.matrix,this.tmp),this}scale(e,r,n){return Wn(this.tmp,e,r,n),nl(this.matrix,this.matrix,this.tmp),this}multiply(e){return yn(this.matrix,this.matrix,e),this}multiply3x3(e){return yn(this.matrix,this.matrix,[e[0],e[1],e[2],0,e[3],e[4],e[5],0,e[6],e[7],e[8],0,0,0,0,1]),this}invert(){return Ar(this.matrix,this.matrix),this}identity(){return It(this.matrix),this}apply(e){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:-1;if(Z1(W_,this.matrix))return this;const i=n===-1?e.length:r+n*3;for(let o=r;o<i;o+=3)Wn(this.tmp,e[o],e[o+1],e[o+2]),At(this.tmp,this.tmp,this.matrix),e[o]=this.tmp[0],e[o+1]=this.tmp[1],e[o+2]=this.tmp[2];return this}getMatrix(){return this.matrix}setMatrix(e){return e&&e.length===16&&Cr(this.matrix,e),this}};function gie(){return new DN(!0)}function pie(){return new DN(!1)}var Ni={buildFromDegree:gie,buildFromRadian:pie};function IN(t){const e=t.getMapper().getInputData(),r=e.extentToBounds(e.getExtent());return[[r[0],r[2],r[4]],[r[0],r[2],r[5]],[r[0],r[3],r[4]],[r[0],r[3],r[5]],[r[1],r[2],r[4]],[r[1],r[2],r[5]],[r[1],r[3],r[4]],[r[1],r[3],r[5]]]}const mie=Ga*Ga,qx=t=>Math.abs(Math.abs(t)-1)<mie,Xx=(t,e)=>qx(t[e])||qx(t[e+1])||qx(t[e+2]),vie=t=>Xx(t,0)&&Xx(t,3)&&Xx(t,6);function mw(t,e,r){const n=t.getMapper().getInputData();let i;const o=n.getDirection();if(vie(o))i=IN(t);else{const[u,d,h]=n.getDimensions();i=[[0,0,0],[u-1,0,0],[0,d-1,0],[u-1,d-1,0],[0,0,h-1],[u-1,0,h-1],[0,d-1,h-1],[u-1,d-1,h-1]].map(p=>n.indexToWorld(p))}const a=Ni.buildFromDegree().identity().rotateFromDirections(e,[1,0,0]);i.forEach(u=>a.apply(u));const s=[...r];a.apply(s);const c=s[0];let l=1/0,f=-1/0;for(let u=0;u<8;u++){const d=i[u][0];d>f&&(f=d),d<l&&(l=d)}return{min:l,max:f,current:c,actor:t,viewPlaneNormal:e,focalPoint:r}}function Y0(t,e,r,n,i,o){const{min:a,max:s,current:c}=r,l=Ke();hn(l,e,t);const f=Math.round((s-a)/i),d=(c-a)/(s-a)*f;let h=Math.round(d),g=[t[0]-n[0]*d*i,t[1]-n[1]*d*i,t[2]-n[2]*d*i];h+=o,h>f?h=f:h<0&&(h=0);const p=h*i;g=[g[0]+n[0]*p,g[1]+n[1]*p,g[2]+n[2]*p];const v=[g[0]+l[0],g[1]+l[1],g[2]+l[2]];return{newFocalPoint:g,newPosition:v}}const yie={RGB:0,HSV:1,LAB:2,DIVERGING:3},wie={LINEAR:0,LOG10:1};var ON={ColorSpace:yie,Scale:wie};const{ColorSpace:as,Scale:V4}=ON,{ScalarMappingTarget:m2}=sw,{vtkDebugMacro:xie,vtkErrorMacro:Tl,vtkWarningMacro:Cie}=Z;function OD(t,e){const r=t[0],n=t[1],i=t[2],o=Math.sqrt(r*r+n*n+i*i),a=o>.001?Math.acos(r/o):0,s=a>.001?Math.atan2(i,n):0;e[0]=o,e[1]=a,e[2]=s}function Sie(t,e){const r=t[0],n=t[1],i=t[2];e[0]=r*Math.cos(n),e[1]=r*Math.sin(n)*Math.cos(i),e[2]=r*Math.sin(n)*Math.sin(i)}function MD(t,e){if(t[0]>=e-.1)return t[2];const r=t[1]*Math.sqrt(e*e-t[0]*t[0])/(t[0]*Math.sin(t[1]));return t[2]>-.3*Math.PI?t[2]+r:t[2]-r}function Tie(t,e){let r=t-e;for(r<0&&(r=-r);r>=2*Math.PI;)r-=2*Math.PI;return r>Math.PI&&(r=2*Math.PI-r),r}function PD(t,e,r,n){const i=[],o=[];nd(e,i),nd(r,o);const a=[],s=[];OD(i,a),OD(o,s);let c=t;if(a[1]>.05&&s[1]>.05&&Tie(a[2],s[2])>.33*Math.PI){let u=Math.max(a[0],s[0]);u=Math.max(88,u),t<.5?(s[0]=u,s[1]=0,s[2]=0,c*=2):(a[0]=u,a[1]=0,a[2]=0,c=2*c-1)}a[1]<.05&&s[1]>.05?a[2]=MD(s,a[0]):s[1]<.05&&a[1]>.05&&(s[2]=MD(a,s[0]));const l=[];l[0]=(1-c)*a[0]+c*s[0],l[1]=(1-c)*a[1]+c*s[1],l[2]=(1-c)*a[2]+c*s[2];const f=[];Sie(l,f),yy(f,n)}function _ie(t,e){e.classHierarchy.push("vtkColorTransferFunction"),t.getSize=()=>e.nodes.length,t.addRGBPoint=(r,n,i,o)=>t.addRGBPointLong(r,n,i,o,.5,0),t.addRGBPointLong=function(r,n,i,o){let a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:.5,s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:0;if(a<0||a>1)return Tl("Midpoint outside range [0.0, 1.0]"),-1;if(s<0||s>1)return Tl("Sharpness outside range [0.0, 1.0]"),-1;e.allowDuplicateScalars||t.removePoint(r);const c={x:r,r:n,g:i,b:o,midpoint:a,sharpness:s};e.nodes.push(c),t.sortAndUpdateRange();let l=0;for(;l<e.nodes.length&&e.nodes[l].x!==r;l++);return l<e.nodes.length?l:-1},t.addHSVPoint=(r,n,i,o)=>t.addHSVPointLong(r,n,i,o,.5,0),t.addHSVPointLong=function(r,n,i,o){let a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:.5,s=arguments.length>5&&arguments[5]!==void 0?arguments[5]:0;const c=[];return Kf([n,i,o],c),t.addRGBPoint(r,c[0],c[1],c[2],a,s)},t.setNodes=r=>{if(e.nodes!==r){const n=JSON.stringify(e.nodes);e.nodes=r;const i=JSON.stringify(e.nodes);if(t.sortAndUpdateRange()||n!==i)return t.modified(),!0}return!1},t.sortAndUpdateRange=()=>{const r=JSON.stringify(e.nodes);e.nodes.sort((o,a)=>o.x-a.x);const n=JSON.stringify(e.nodes),i=t.updateRange();return!i&&r!==n?(t.modified(),!0):i},t.updateRange=()=>{const r=[2];r[0]=e.mappingRange[0],r[1]=e.mappingRange[1];const n=e.nodes.length;return n?(e.mappingRange[0]=e.nodes[0].x,e.mappingRange[1]=e.nodes[n-1].x):(e.mappingRange[0]=0,e.mappingRange[1]=0),r[0]===e.mappingRange[0]&&r[1]===e.mappingRange[1]?!1:(t.modified(),!0)},t.removePoint=r=>{let n=0;for(;n<e.nodes.length&&e.nodes[n].x!==r;n++);const i=n;if(n>=e.nodes.length)return-1;let o=!1;return e.nodes.splice(n,1),(n===0||n===e.nodes.length)&&(o=t.updateRange()),o||t.modified(),i},t.movePoint=(r,n)=>{if(r!==n){t.removePoint(n);for(let i=0;i<e.nodes.length;i++)if(e.nodes[i].x===r){e.nodes[i].x=n,t.sortAndUpdateRange();break}}},t.removeAllPoints=()=>{e.nodes=[],t.sortAndUpdateRange()},t.addRGBSegment=(r,n,i,o,a,s,c,l)=>{t.sortAndUpdateRange();for(let f=0;f<e.nodes.length;)e.nodes[f].x>=r&&e.nodes[f].x<=a?e.nodes.splice(f,1):f++;t.addRGBPointLong(r,n,i,o,.5,0),t.addRGBPointLong(a,s,c,l,.5,0),t.modified()},t.addHSVSegment=(r,n,i,o,a,s,c,l)=>{const f=[n,i,o],u=[s,c,l],d=[],h=[];Kf(f,d),Kf(u,h),t.addRGBSegment(r,d[0],d[1],d[2],a,h[0],h[1],h[2])},t.mapValue=r=>{const n=[];return t.getColor(r,n),[Math.floor(255*n[0]+.5),Math.floor(255*n[1]+.5),Math.floor(255*n[2]+.5),255]},t.getColor=(r,n)=>{if(e.indexedLookup){const i=t.getSize(),o=t.getAnnotatedValueIndexInternal(r);if(o<0||i===0){const a=t.getNanColorByReference();n[0]=a[0],n[1]=a[1],n[2]=a[2]}else{const a=[];t.getNodeValue(o%i,a),n[0]=a[1],n[1]=a[2],n[2]=a[3]}return}t.getTable(r,r,1,n)},t.getRedValue=r=>{const n=[];return t.getColor(r,n),n[0]},t.getGreenValue=r=>{const n=[];return t.getColor(r,n),n[1]},t.getBlueValue=r=>{const n=[];return t.getColor(r,n),n[2]},t.getTable=(r,n,i,o)=>{const a=Number(r),s=Number(n);if(wy(a)||wy(s)){for(let E=0;E<i;E++)o[E*3+0]=e.nanColor[0],o[E*3+1]=e.nanColor[1],o[E*3+2]=e.nanColor[2];return}let c=0;const l=e.nodes.length;let f=0,u=0,d=0;l!==0&&(f=e.nodes[l-1].r,u=e.nodes[l-1].g,d=e.nodes[l-1].b);let h=0,g=0,p=0;const v=[0,0,0],y=[0,0,0];let m=0,w=0;const x=[];let C=e.scale===V4.LOG10;C&&(C=e.mappingRange[0]>0);let S=0,T=0,_=0;C&&(S=Math.log10(a),T=Math.log10(s));for(let E=0;E<i;E++){const b=3*E;if(i>1?C?(_=S+E/(i-1)*(T-S),h=10**_):h=a+E/(i-1)*(s-a):C?(_=.5*(S+T),h=10**_):h=.5*(a+s),e.discretize){const D=e.mappingRange;if(h>=D[0]&&h<=D[1]){const I=e.numberOfValues,P=D[1]-D[0];if(I<=1)h=D[0]+P/2;else{const O=(h-D[0])/P,L=j_(I*O);h=D[0]+L/(I-1)*P}}}for(;c<l&&h>e.nodes[c].x;)c++,c<l&&(g=e.nodes[c-1].x,p=e.nodes[c].x,C&&(g=Math.log10(g),p=Math.log10(p)),v[0]=e.nodes[c-1].r,y[0]=e.nodes[c].r,v[1]=e.nodes[c-1].g,y[1]=e.nodes[c].g,v[2]=e.nodes[c-1].b,y[2]=e.nodes[c].b,m=e.nodes[c-1].midpoint,w=e.nodes[c-1].sharpness,m<1e-5&&(m=1e-5),m>.99999&&(m=.99999));if(h>e.mappingRange[1])o[b]=0,o[b+1]=0,o[b+2]=0,e.clamping&&(t.getUseAboveRangeColor()?(o[b]=e.aboveRangeColor[0],o[b+1]=e.aboveRangeColor[1],o[b+2]=e.aboveRangeColor[2]):(o[b]=f,o[b+1]=u,o[b+2]=d));else if(h<e.mappingRange[0]||SR(h)&&h<0)o[b]=0,o[b+1]=0,o[b+2]=0,e.clamping&&(t.getUseBelowRangeColor()?(o[b]=e.belowRangeColor[0],o[b+1]=e.belowRangeColor[1],o[b+2]=e.belowRangeColor[2]):l>0&&(o[b]=e.nodes[0].r,o[b+1]=e.nodes[0].g,o[b+2]=e.nodes[0].b));else if(c===0&&(Math.abs(h-a)<1e-6||e.discretize))l>0?(o[b]=e.nodes[0].r,o[b+1]=e.nodes[0].g,o[b+2]=e.nodes[0].b):(o[b]=0,o[b+1]=0,o[b+2]=0);else{let D=0;if(C?D=(_-g)/(p-g):D=(h-g)/(p-g),D<m?D=.5*D/m:D=.5+.5*(D-m)/(1-m),w>.99)if(D<.5){o[b]=v[0],o[b+1]=v[1],o[b+2]=v[2];continue}else{o[b]=y[0],o[b+1]=y[1],o[b+2]=y[2];continue}if(w<.01){if(e.colorSpace===as.RGB)o[b]=(1-D)*v[0]+D*y[0],o[b+1]=(1-D)*v[1]+D*y[1],o[b+2]=(1-D)*v[2]+D*y[2];else if(e.colorSpace===as.HSV){const G=[],X=[];Kg(v,G),Kg(y,X),e.hSVWrap&&(G[0]-X[0]>.5||X[0]-G[0]>.5)&&(G[0]>X[0]?G[0]-=1:X[0]-=1);const ee=[];ee[0]=(1-D)*G[0]+D*X[0],ee[0]<0&&(ee[0]+=1),ee[1]=(1-D)*G[1]+D*X[1],ee[2]=(1-D)*G[2]+D*X[2],Kf(ee,x),o[b]=x[0],o[b+1]=x[1],o[b+2]=x[2]}else if(e.colorSpace===as.LAB){const G=[],X=[];nd(v,G),nd(y,X);const ee=[];ee[0]=(1-D)*G[0]+D*X[0],ee[1]=(1-D)*G[1]+D*X[1],ee[2]=(1-D)*G[2]+D*X[2],yy(ee,x),o[b]=x[0],o[b+1]=x[1],o[b+2]=x[2]}else e.colorSpace===as.DIVERGING?(PD(D,v,y,x),o[b]=x[0],o[b+1]=x[1],o[b+2]=x[2]):Tl("ColorSpace set to invalid value.",e.colorSpace);continue}D<.5?D=.5*(D*2)**(1+10*w):D>.5&&(D=1-.5*((1-D)*2)**(1+10*w));const I=D*D,P=I*D,O=2*P-3*I+1,L=-2*P+3*I,B=P-2*I+D,H=P-I;let A,F;if(e.colorSpace===as.RGB)for(let G=0;G<3;G++)A=y[G]-v[G],F=(1-w)*A,o[b+G]=O*v[G]+L*y[G]+B*F+H*F;else if(e.colorSpace===as.HSV){const G=[],X=[];Kg(v,G),Kg(y,X),e.hSVWrap&&(G[0]-X[0]>.5||X[0]-G[0]>.5)&&(G[0]>X[0]?G[0]-=1:X[0]-=1);const ee=[];for(let ce=0;ce<3;ce++)A=X[ce]-G[ce],F=(1-w)*A,ee[ce]=O*G[ce]+L*X[ce]+B*F+H*F,ce===0&&ee[ce]<0&&(ee[ce]+=1);Kf(ee,x),o[b]=x[0],o[b+1]=x[1],o[b+2]=x[2]}else if(e.colorSpace===as.LAB){const G=[],X=[];nd(v,G),nd(y,X);const ee=[];for(let ce=0;ce<3;ce++)A=X[ce]-G[ce],F=(1-w)*A,ee[ce]=O*G[ce]+L*X[ce]+B*F+H*F;yy(ee,x),o[b]=x[0],o[b+1]=x[1],o[b+2]=x[2]}else e.colorSpace===as.DIVERGING?(PD(D,v,y,x),o[b]=x[0],o[b+1]=x[1],o[b+2]=x[2]):Tl("ColorSpace set to invalid value.");for(let G=0;G<3;G++)o[b+G]=o[b+G]<0?0:o[b+G],o[b+G]=o[b+G]>1?1:o[b+G]}}},t.getUint8Table=function(r,n,i){let o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(t.getMTime()<=e.buildTime&&e.tableSize===i&&e.tableWithAlpha!==o)return e.table;if(e.nodes.length===0)return Tl("Attempting to lookup a value with no points in the function"),e.table;const a=o?4:3;(e.tableSize!==i||e.tableWithAlpha!==o)&&(e.table=new Uint8Array(i*a),e.tableSize=i,e.tableWithAlpha=o);const s=[];t.getTable(r,n,i,s);for(let c=0;c<i;c++)e.table[c*a+0]=Math.floor(s[c*3+0]*255+.5),e.table[c*a+1]=Math.floor(s[c*3+1]*255+.5),e.table[c*a+2]=Math.floor(s[c*3+2]*255+.5),o&&(e.table[c*a+3]=255);return e.buildTime.modified(),e.table},t.buildFunctionFromArray=r=>{t.removeAllPoints();const n=r.getNumberOfComponents();for(let i=0;i<r.getNumberOfTuples();i++)switch(n){case 3:{e.nodes.push({x:i,r:r.getComponent(i,0),g:r.getComponent(i,1),b:r.getComponent(i,2),midpoint:.5,sharpness:0});break}case 4:{e.nodes.push({x:r.getComponent(i,0),r:r.getComponent(i,1),g:r.getComponent(i,2),b:r.getComponent(i,3),midpoint:.5,sharpness:0});break}case 5:{e.nodes.push({x:i,r:r.getComponent(i,0),g:r.getComponent(i,1),b:r.getComponent(i,2),midpoint:r.getComponent(i,4),sharpness:r.getComponent(i,5)});break}case 6:{e.nodes.push({x:r.getComponent(i,0),r:r.getComponent(i,1),g:r.getComponent(i,2),b:r.getComponent(i,3),midpoint:r.getComponent(i,4),sharpness:r.getComponent(i,5)});break}}t.sortAndUpdateRange()},t.buildFunctionFromTable=(r,n,i,o)=>{let a=0;t.removeAllPoints(),i>1&&(a=(n-r)/(i-1));for(let s=0;s<i;s++){const c={x:r+a*s,r:o[s*3],g:o[s*3+1],b:o[s*3+2],sharpness:0,midpoint:.5};e.nodes.push(c)}t.sortAndUpdateRange()},t.getNodeValue=(r,n)=>r<0||r>=e.nodes.length?(Tl("Index out of range!"),-1):(n[0]=e.nodes[r].x,n[1]=e.nodes[r].r,n[2]=e.nodes[r].g,n[3]=e.nodes[r].b,n[4]=e.nodes[r].midpoint,n[5]=e.nodes[r].sharpness,1),t.setNodeValue=(r,n)=>{if(r<0||r>=e.nodes.length)return Tl("Index out of range!"),-1;const i=e.nodes[r].x;return e.nodes[r].x=n[0],e.nodes[r].r=n[1],e.nodes[r].g=n[2],e.nodes[r].b=n[3],e.nodes[r].midpoint=n[4],e.nodes[r].sharpness=n[5],i!==n[0]?t.sortAndUpdateRange():t.modified(),1},t.getNumberOfAvailableColors=()=>{var n;if(e.indexedLookup&&t.getSize())return t.getSize();if(e.tableSize)return e.tableSize;const r=((n=e.nodes)==null?void 0:n.length)??0;return Math.max(4094,r)},t.getIndexedColor=(r,n)=>{const i=t.getSize();if(i>0&&r>=0){const a=[];t.getNodeValue(r%i,a);for(let s=0;s<3;++s)n[s]=a[s+1];n[3]=1;return}const o=t.getNanColorByReference();n[0]=o[0],n[1]=o[1],n[2]=o[2],n[3]=1},t.fillFromDataPointer=(r,n)=>{if(!(r<=0||!n)){t.removeAllPoints();for(let i=0;i<r;i++)t.addRGBPoint(n[i*4],n[i*4+1],n[i*4+2],n[i*4+3])}},t.setMappingRange=(r,n)=>{const i=[r,n],o=t.getRange();if(o[1]===i[1]&&o[0]===i[0])return;if(i[1]===i[0]){Tl("attempt to set zero width color range");return}const a=(i[1]-i[0])/(o[1]-o[0]),s=i[0]-o[0]*a;for(let c=0;c<e.nodes.length;++c)e.nodes[c].x=e.nodes[c].x*a+s;e.mappingRange[0]=i[0],e.mappingRange[1]=i[1],t.modified()},t.adjustRange=r=>{const n=t.getRange(),i=[];n[0]<r[0]?(t.getColor(r[0],i),t.addRGBPoint(r[0],i[0],i[1],i[2])):(t.getColor(n[0],i),t.addRGBPoint(r[0],i[0],i[1],i[2])),n[1]>r[1]?(t.getColor(r[1],i),t.addRGBPoint(r[1],i[0],i[1],i[2])):(t.getColor(n[1],i),t.addRGBPoint(r[1],i[0],i[1],i[2])),t.sortAndUpdateRange();for(let o=0;o<e.nodes.length;)e.nodes[o].x>=r[0]&&e.nodes[o].x<=r[1]?e.nodes.splice(o,1):++o;return 1},t.estimateMinNumberOfSamples=(r,n)=>{const i=t.findMinimumXDistance();return Math.ceil((n-r)/i)},t.findMinimumXDistance=()=>{if(e.nodes.length<2)return-1;let r=Number.MAX_VALUE;for(let n=0;n<e.nodes.length-1;n++){const i=e.nodes[n+1].x-e.nodes[n].x;i<r&&(r=i)}return r},t.mapScalarsThroughTable=(r,n,i,o)=>{if(t.getSize()===0){xie("Transfer Function Has No Points!");return}e.indexedLookup?t.mapDataIndexed(r,n,i,o):t.mapData(r,n,i,o)},t.mapData=(r,n,i,o)=>{if(t.getSize()===0){Cie("Transfer Function Has No Points!");return}const a=Math.floor(t.getAlpha()*255+.5),s=r.getNumberOfTuples(),c=r.getNumberOfComponents(),l=n.getData(),f=r.getData(),u=[];if(i===m2.RGBA)for(let d=0;d<s;d++){const h=f[d*c+o];t.getColor(h,u),l[d*4]=Math.floor(u[0]*255+.5),l[d*4+1]=Math.floor(u[1]*255+.5),l[d*4+2]=Math.floor(u[2]*255+.5),l[d*4+3]=a}if(i===m2.RGB)for(let d=0;d<s;d++){const h=f[d*c+o];t.getColor(h,u),l[d*3]=Math.floor(u[0]*255+.5),l[d*3+1]=Math.floor(u[1]*255+.5),l[d*3+2]=Math.floor(u[2]*255+.5)}if(i===m2.LUMINANCE)for(let d=0;d<s;d++){const h=f[d*c+o];t.getColor(h,u),l[d]=Math.floor(u[0]*76.5+u[1]*150.45+u[2]*28.05+.5)}if(i===m2.LUMINANCE_ALPHA)for(let d=0;d<s;d++){const h=f[d*c+o];t.getColor(h,u),l[d*2]=Math.floor(u[0]*76.5+u[1]*150.45+u[2]*28.05+.5),l[d*2+1]=a}},t.applyColorMap=r=>{const n=JSON.stringify(e.colorSpace);r.ColorSpace&&(e.colorSpace=as[r.ColorSpace.toUpperCase()],e.colorSpace===void 0&&(Tl(`ColorSpace ${r.ColorSpace} not supported, using RGB instead`),e.colorSpace=as.RGB));let i=n!==JSON.stringify(e.colorSpace);const o=i||JSON.stringify(e.nanColor);if(r.NanColor)for(e.nanColor=[].concat(r.NanColor);e.nanColor.length<4;)e.nanColor.push(1);i=i||o!==JSON.stringify(e.nanColor);const a=i||JSON.stringify(e.nodes);if(r.RGBPoints){const l=r.RGBPoints.length;e.nodes=[];const f=.5,u=0;for(let d=0;d<l;d+=4)e.nodes.push({x:r.RGBPoints[d],r:r.RGBPoints[d+1],g:r.RGBPoints[d+2],b:r.RGBPoints[d+3],midpoint:f,sharpness:u})}const s=t.sortAndUpdateRange(),c=!s&&(i||a!==JSON.stringify(e.nodes));return c&&t.modified(),s||c}}const Eie={clamping:!0,colorSpace:as.RGB,hSVWrap:!0,scale:V4.LINEAR,nanColor:null,belowRangeColor:null,aboveRangeColor:null,useAboveRangeColor:!1,useBelowRangeColor:!1,allowDuplicateScalars:!1,table:null,tableSize:0,buildTime:null,nodes:null,discretize:!1,numberOfValues:256};function MN(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Eie,r),sw.extend(t,e,r),e.table=[],e.nodes=[],e.nanColor=[.5,0,0,1],e.belowRangeColor=[0,0,0,1],e.aboveRangeColor=[1,1,1,1],e.buildTime={},Z.obj(e.buildTime),Z.get(t,e,["buildTime","mappingRange"]),Z.setGet(t,e,["useAboveRangeColor","useBelowRangeColor","discretize","numberOfValues",{type:"enum",name:"colorSpace",enum:as},{type:"enum",name:"scale",enum:V4}]),Z.setArray(t,e,["nanColor","belowRangeColor","aboveRangeColor"],4),Z.getArray(t,e,["nanColor","belowRangeColor","aboveRangeColor"]),_ie(t,e)}const bie=Z.newInstance(MN,"vtkColorTransferFunction");var eu={newInstance:bie,extend:MN,...ON},Die=[{Name:"KAAMS",IndexedColors:[1,1,1,1,0,0,0,1,0,0,0,1,1,1,0,1,0,1,0,1,1,.63,.63,1,.67,.5,.33,1,.5,.75,.53,.35,.7,1,.75,.5],Annotations:[0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11]},{ColorSpace:"Diverging",Name:"Cool to Warm",NanColor:[1,1,0],RGBPoints:[0,.23137254902,.298039215686,.752941176471,.5,.865,.865,.865,1,.705882352941,.0156862745098,.149019607843]},{ColorSpace:"Lab",Creator:"Francesca Samsel",Name:"Cool to Warm (Extended)",NanColor:[.25,0,0],RGBPoints:[0,0,0,.34902,.03125,.039216,.062745,.380392,.0625,.062745,.117647,.411765,.09375,.090196,.184314,.45098,.125,.12549,.262745,.501961,.15625,.160784,.337255,.541176,.1875,.2,.396078,.568627,.21875,.239216,.454902,.6,.25,.286275,.521569,.65098,.28125,.337255,.592157,.701961,.3125,.388235,.654902,.74902,.34375,.466667,.737255,.819608,.375,.572549,.819608,.878431,.40625,.654902,.866667,.909804,.4375,.752941,.917647,.941176,.46875,.823529,.956863,.968627,.5,.988235,.960784,.901961,.5,.941176,.984314,.988235,.52,.988235,.945098,.85098,.54,.980392,.898039,.784314,.5625,.968627,.835294,.698039,.59375,.94902,.733333,.588235,.625,.929412,.65098,.509804,.65625,.909804,.564706,.435294,.6875,.878431,.458824,.352941,.71875,.839216,.388235,.286275,.75,.760784,.294118,.211765,.78125,.701961,.211765,.168627,.8125,.65098,.156863,.129412,.84375,.6,.094118,.094118,.875,.54902,.066667,.098039,.90625,.501961,.05098,.12549,.9375,.45098,.054902,.172549,.96875,.4,.054902,.192157,1,.34902,.070588,.211765]},{ColorSpace:"Diverging",Name:"Warm to Cool",NanColor:[1,1,0],RGBPoints:[0,.705882352941,.0156862745098,.149019607843,.5,.865,.865,.865,1,.23137254902,.298039215686,.752941176471]},{ColorSpace:"Lab",Creator:"Francesca Samsel",Name:"Warm to Cool (Extended)",NanColor:[.250004,0,0],RGBPoints:[0,.34902,0,.129412,.025,.4,.00392157,.101961,.05,.470588,.0156863,.0901961,.075,.54902,.027451,.0705882,.1,.619608,.0627451,.0431373,.125,.690196,.12549,.0627451,.15,.741176,.184314,.0745098,.175,.788235,.266667,.0941176,.2,.811765,.345098,.113725,.225,.831373,.411765,.133333,.25,.85098,.47451,.145098,.275,.870588,.54902,.156863,.3,.878431,.619608,.168627,.325,.890196,.658824,.196078,.35,.909804,.717647,.235294,.375,.929412,.776471,.278431,.395522,.94902,.823529,.321569,.418905,.968627,.87451,.407843,.444278,.980392,.917647,.509804,.470149,.988235,.956863,.643137,.483582,.992157,.964706,.713725,.499,.988235,.980392,.870588,.5,1,1,1,.501,.913725,.988235,.937255,.516418,.827451,.980392,.886275,.531343,.764706,.980392,.866667,.546766,.658824,.980392,.843137,.564179,.572549,.964706,.835294,.587562,.423529,.941176,.87451,.60597,.262745,.901961,.862745,.629851,.0705882,.854902,.870588,.651741,.0509804,.8,.85098,.681592,.0235294,.709804,.831373,.712935,.0313725,.615686,.811765,.75,.0313725,.537255,.788235,.775,.0392157,.466667,.768627,.8,.0509804,.396078,.741176,.825,.054902,.317647,.709804,.85,.054902,.243137,.678431,.875,.0431373,.164706,.639216,.9,.0313725,.0980392,.6,.925,.0392157,.0392157,.560784,.95,.105882,.0509804,.509804,.975,.113725,.0235294,.45098,1,.12549,0,.380392]},{ColorSpace:"RGB",Name:"Rainbow Desaturated",NanColor:[1,1,0],RGBPoints:[0,.278431372549,.278431372549,.858823529412,.143,0,0,.360784313725,.285,0,1,1,.429,0,.501960784314,0,.571,1,1,0,.714,1,.380392156863,0,.857,.419607843137,0,0,1,.878431372549,.301960784314,.301960784314]},{ColorSpace:"RGB",Name:"Cold and Hot",NanColor:[1,1,0],RGBPoints:[0,0,1,1,.45,0,0,1,.5,0,0,.501960784314,.55,1,0,0,1,1,1,0]},{ColorSpace:"RGB",Name:"Black-Body Radiation",NanColor:[0,.498039215686,1],RGBPoints:[0,0,0,0,.4,.901960784314,0,0,.8,.901960784314,.901960784314,0,1,1,1,1]},{ColorSpace:"RGB",Name:"X Ray",NanColor:[1,0,0],RGBPoints:[0,1,1,1,1,0,0,0]},{ColorSpace:"RGB",Name:"Grayscale",NanColor:[1,0,0],RGBPoints:[0,0,0,0,1,1,1,1]},{ColorSpace:"RGB",Name:"BkRd",NanColor:[0,1,1],RGBPoints:[0,0,0,0,1,1,0,0]},{ColorSpace:"RGB",Name:"BkGn",NanColor:[1,0,1],RGBPoints:[0,0,0,0,1,0,1,0]},{ColorSpace:"RGB",Name:"BkBu",NanColor:[1,1,0],RGBPoints:[0,0,0,0,1,0,0,1]},{ColorSpace:"RGB",Name:"BkMa",NanColor:[0,1,0],RGBPoints:[0,0,0,0,1,1,0,1]},{ColorSpace:"RGB",Name:"BkCy",NanColor:[0,1,1],RGBPoints:[0,0,0,0,1,0,1,1]},{ColorSpace:"RGB",Name:"Black, Blue and White",NanColor:[1,1,0],RGBPoints:[0,0,0,0,.333,0,0,.501960784314,.666,0,.501960784314,1,1,1,1,1]},{ColorSpace:"RGB",Name:"Black, Orange and White",NanColor:[1,1,0],RGBPoints:[0,0,0,0,.333,.501960784314,0,0,.666,1,.501960784314,0,1,1,1,1]},{ColorSpace:"Lab",Creator:"Francesca Samsel",Name:"Linear YGB 1211g",NanColor:[.25,0,0],RGBPoints:[0,1,.988235,.968627,.02,1,.952941,.878431,.05,.968627,.905882,.776471,.1,.94902,.898039,.647059,.15,.901961,.878431,.556863,.2,.847059,.858824,.482353,.25,.690196,.819608,.435294,.3,.513725,.768627,.384314,.35,.337255,.721569,.337255,.4,.278431,.658824,.392157,.45,.231373,.639216,.435294,.5,.203922,.6,.486275,.55,.172549,.568627,.537255,.6,.141176,.517647,.54902,.65,.133333,.458824,.541176,.7,.12549,.396078,.529412,.75,.117647,.321569,.521569,.8,.121569,.258824,.509804,.85,.133333,.227451,.501961,.9,.145098,.192157,.490196,.95,.188235,.164706,.470588,1,.258824,.196078,.439216]},{ColorSpace:"CIELAB",Creator:"Francesca Samsel",Name:"Linear Green (Gr4L)",NanColor:[.25,0,0],RGBPoints:[0,.054902,.109804,.121569,.05,.07451,.172549,.180392,.1,.086275,.231373,.219608,.15,.094118,.278431,.25098,.2,.109804,.34902,.278431,.25,.113725,.4,.278431,.3,.117647,.45098,.270588,.35,.117647,.490196,.243137,.4,.113725,.521569,.203922,.45,.109804,.54902,.152941,.5,.082353,.588235,.082353,.55,.109804,.631373,.05098,.6,.211765,.678431,.082353,.65,.317647,.721569,.113725,.7,.431373,.760784,.160784,.75,.556863,.8,.239216,.8,.666667,.839216,.294118,.85,.784314,.878431,.396078,.9,.886275,.921569,.533333,.95,.960784,.94902,.670588,1,1,.984314,.901961]},{ColorSpace:"Lab",Creator:"Francesca Samsel",Name:"Linear Blue (8_31f)",NanColor:[.25,0,0],RGBPoints:[0,.960784,1,.980392,.05,.815686,.960784,.913725,.1,.670588,.929412,.870588,.15,.556863,.901961,.843137,.2,.478431,.870588,.823529,.25,.439216,.831373,.803922,.3,.4,.8,.788235,.35,.376471,.768627,.768627,.4,.34902,.709804,.729412,.45,.32549,.654902,.690196,.5,.301961,.607843,.658824,.55,.247059,.545098,.619608,.6,.239216,.494118,.580392,.65,.227451,.439216,.541176,.7,.227451,.403922,.521569,.75,.231373,.368627,.501961,.8,.227451,.321569,.470588,.85,.219608,.282353,.439216,.9,.192157,.235294,.4,.95,.160784,.184314,.34902,1,.133333,.12549,.301961]},{ColorSpace:"HSV",Name:"Blue to Red Rainbow",NanColor:[.498039215686,.498039215686,.498039215686],RGBPoints:[0,0,0,1,1,1,0,0]},{ColorSpace:"HSV",Name:"Red to Blue Rainbow",NanColor:[.498039215686,.498039215686,.498039215686],RGBPoints:[0,1,0,0,1,0,0,1]},{ColorSpace:"RGB",Name:"Rainbow Blended White",NanColor:[1,1,0],RGBPoints:[0,1,1,1,.17,0,0,1,.34,0,1,1,.5,0,1,0,.67,1,1,0,.84,1,0,0,1,.878431372549,0,1]},{ColorSpace:"RGB",Name:"Rainbow Blended Grey",NanColor:[1,1,0],RGBPoints:[0,.317647058824,.341176470588,.43137254902,.17,0,0,1,.34,0,1,1,.5,0,1,0,.67,1,1,0,.84,1,0,0,1,.878431372549,0,1]},{ColorSpace:"RGB",Name:"Rainbow Blended Black",NanColor:[1,1,0],RGBPoints:[0,0,0,0,.17,0,0,1,.34,0,1,1,.5,0,1,0,.67,1,1,0,.84,1,0,0,1,.878431372549,0,1]},{ColorSpace:"RGB",Name:"Blue to Yellow",NanColor:[1,0,0],RGBPoints:[0,.0392156862745,.0392156862745,.949019607843,1,.949019607843,.949019607843,.0392156862745]},{ColorSpace:"HSV",Name:"blot",RGBPoints:[0,0,0,1,.166,0,0,1,.167,1,0,1,.332,1,0,1,.333,0,1,1,.5,0,1,1,.501,0,1,0,.666,0,1,0,.667,1,1,0,.832,1,1,0,.833,1,0,0,1,1,0,0]},{ColorSpace:"Lab",Name:"CIELab Blue to Red",NanColor:[1,1,0],RGBPoints:[0,0,.6,.749019607843,1,.76862745098,.466666666667,.341176470588]},{ColorSpace:"RGB",Name:"jet",RGBPoints:[-1,0,0,.5625,-.777778,0,0,1,-.269841,0,1,1,-.015873,.5,1,.5,.238095,1,1,0,.746032,1,0,0,1,.5,0,0]},{ColorSpace:"RGB",Name:"rainbow",RGBPoints:[-1,0,0,1,-.5,0,1,1,0,0,1,0,.5,1,1,0,1,1,0,0]},{ColorSpace:"Lab",Name:"erdc_rainbow_bright",RGBPoints:[-1,.32549,.14902,.960784,-.866221,.297047,.375586,.963836,-.732441,.180302,.536818,.964627,-.598662,.1302,.649207,.929647,-.464883,.0445143,.749654,.855998,-.331104,.0271325,.830713,.721527,-.197324,.259504,.866145,.543555,-.0635452,.428364,.890725,.329819,.0702341,.568503,.898508,.187623,.204013,.738259,.890317,.0825461,.337793,.84546,.86136,.0147555,.471572,.912191,.808018,0,.605351,.962848,.710445,0,.73913,.999469,.600258,.0176284,.87291,.994156,.445975,.193912,1,.980407,.247105,.262699]},{ColorSpace:"Lab",Name:"erdc_rainbow_dark",RGBPoints:[-1,0,0,.423499,-.866221,0,.119346,.529237,-.732441,0,.238691,.634976,-.598662,0,.346852,.68788,-.464883,0,.45022,.718141,-.331104,0,.553554,.664839,-.197324,0,.651082,.519303,-.0635452,.115841,.72479,.352857,.0702341,.326771,.781195,.140187,.204013,.522765,.798524,.0284624,.337793,.703162,.788685,.00885756,.471572,.845118,.751133,0,.605351,.955734,.690825,0,.73913,.995402,.567916,.0618524,.87291,.987712,.403398,.164851,1,.980407,.247105,.262699]},{ColorSpace:"Lab",Name:"nic_CubicL",RGBPoints:[-1,.479965,.0118108,.5307,-.87451,.522213,.0551282,.706919,-.74902,.50839,.237278,.867764,-.623529,.451617,.373834,.987255,-.498039,.39365,.497255,.97506,-.372549,.328631,.599639,.891843,-.247059,.250043,.690286,.778553,-.121569,.249656,.764905,.645857,.00392157,.297954,.821466,.50449,.129412,.337509,.872595,.358447,.254902,.430011,.913789,.297079,.380392,.587191,.931381,.333353,.505882,.727937,.93591,.353742,.631373,.826403,.921081,.365066,.756863,.893201,.846317,.372662,.882353,.965347,.73884,.378506,1,.983235,.597451,.366856]},{ColorSpace:"Lab",Name:"nic_CubicYF",RGBPoints:[-1,.5151,.0482,.6697,-.87451,.520711,.168955,.800574,-.74902,.493694,.278596,.911824,-.623529,.440026,.369475,.984978,-.498039,.398932,.457593,.987053,-.372549,.350651,.540644,.929608,-.247059,.298827,.615625,.857729,-.121569,.239928,.685061,.769531,.00392157,.228832,.739349,.673287,.129412,.263297,.78608,.569988,.254902,.298107,.828337,.460214,.380392,.33092,.864071,.352674,.505882,.38306,.898169,.287309,.631373,.49023,.917481,.307961,.756863,.62372,.926026,.332309,.882353,.717458,.92527,.342476,1,.8,.9255,.3529]},{ColorSpace:"Lab",Name:"gist_earth",RGBPoints:[-1,0,0,0,-.87451,.239216,.027451,.415686,-.74902,.0901961,.254902,.556863,-.623529,.0941176,.352941,.54902,-.498039,.105882,.435294,.533333,-.372549,.12549,.52549,.501961,-.247059,.156863,.596078,.443137,-.121569,.196078,.65098,.380392,.00392157,.282353,.717647,.301961,.129412,.466667,.772549,.27451,.254902,.678431,.784314,.309804,.380392,.901961,.756863,.376471,.505882,.992157,.705882,.521569,.631373,1,.721569,.701961,.756863,1,.784314,.784314,.882353,1,.866667,.866667,1,1,1,1]},{ColorSpace:"Lab",Name:"2hot",RGBPoints:[-1,.0416667,0,0,-.873016,.208333,0,0,-.746032,.375,0,0,-.619048,.541667,0,0,-.492063,.708333,0,0,-.365079,.854137,0,0,-.238095,.937488,.039062,0,-.111111,1,.208333,0,.015873,1,.375,0,.142857,1,.541667,0,.269841,1,.708333,0,.396825,1,.858805,.03125,.52381,1,.947392,.15625,.650794,1,1,.3125,.777778,1,1,.5625,.904762,1,1,.8125,1,1,1,1]},{ColorSpace:"Lab",Name:"erdc_red2yellow_BW",RGBPoints:[-1,754296e-12,0,109827e-10,-.87451,.18285,.0264094,0,-.74902,.3066,0,0,-.623529,.422841,0,0,-.498039,.522945,0,0,-.372549,.605721,0,0,-.247059,.672502,.14168,0,-.121569,.728167,.244025,0,.00392157,.781215,.333454,0,.129412,.825,.423586,0,.254902,.855893,.516793,0,.380392,.880491,.608846,0,.505882,.910305,.695505,0,.631373,.94109,.779067,.223528,.756863,.967873,.858572,.473521,.882353,.986815,.933211,.751583,1,1,1,.999997]},{ColorSpace:"Lab",Name:"erdc_marine2gold_BW",RGBPoints:[-1,111641e-12,0,162551e-11,-.87451,.0413146,.0619808,.209857,-.74902,.0185557,.101341,.350684,-.623529,.00486405,.149847,.461054,-.498039,.0836345,.210845,.517906,-.372549,.173222,.276134,.541793,-.247059,.259857,.343877,.535869,-.121569,.362299,.408124,.504293,.00392157,.468266,.468276,.468257,.129412,.582781,.527545,.374914,.254902,.691591,.585251,.274266,.380392,.784454,.645091,.247332,.505882,.862299,.710383,.27518,.631373,.920863,.782923,.351563,.756863,.955792,.859699,.533541,.882353,.976162,.93433,.780671,1,1,1,.999983]},{ColorSpace:"Lab",Name:"erdc_blue2gold_BW",RGBPoints:[-1,0,0,0,-.87451,.0742735,.0440331,.230013,-.74902,.125276,.0258685,.415826,-.623529,.143879,.0163031,.591346,-.498039,.212261,.0627855,.705239,-.372549,.306048,.141178,.763636,-.247059,.391537,.232286,.773263,-.121569,.461734,.336633,.708321,.00392157,.54209,.427581,.590007,.129412,.61704,.508623,.460978,.254902,.702703,.579586,.309117,.380392,.790336,.644811,.170397,.505882,.870173,.710733,.117134,.631373,.93656,.781991,.157144,.756863,.965672,.862068,.409836,.882353,.985751,.936296,.714162,1,1,1,.999999]},{ColorSpace:"Lab",Name:"erdc_sapphire2gold_BW",RGBPoints:[-1,.107704,.107708,.107694,-.87451,.1851,.112354,.308554,-.74902,.236782,.114233,.48788,-.623529,.28296,.126187,.639464,-.498039,.344787,.171643,.739713,-.372549,.413325,.242371,.76913,-.247059,.481863,.3131,.719841,-.121569,.550402,.383829,.612222,.00392157,.61894,.454558,.51126,.129412,.687478,.525287,.39993,.254902,.756017,.596016,.289923,.380392,.824555,.666745,.255498,.505882,.892979,.736822,.27696,.631373,.938851,.804966,.351734,.756863,.966491,.874853,.53572,.882353,.982105,.94153,.782579,1,1,1,.999986]},{ColorSpace:"Lab",Name:"erdc_red2purple_BW",RGBPoints:[-1,0,0,0,-.87451,.167793,.0166271,.0431278,-.74902,.262608,.0107595,.0791181,-.623529,.351902,.0101858,.100926,-.498039,.441257,.0160835,.131919,-.372549,.5221,.0555972,.195625,-.247059,.593852,.104294,.310234,-.121569,.654628,.158115,.448486,.00392157,.707443,.220914,.570253,.129412,.749504,.293268,.67897,.254902,.781587,.370517,.779269,.380392,.809951,.451099,.855831,.505882,.84424,.531462,.900451,.631373,.865174,.620901,.91606,.756863,.875041,.714054,.910284,.882353,.880764,.80554,.896276,1,.887572,.887591,.887556]},{ColorSpace:"Lab",Name:"erdc_purple2pink_BW",RGBPoints:[-1,0,0,0,-.87451,.117562,.0291202,.175876,-.74902,.178368,.0458476,.285454,-.623529,.237731,.0680173,.387717,-.498039,.300877,.0956291,.484802,-.372549,.370929,.136858,.554985,-.247059,.449033,.189273,.58863,-.121569,.529971,.245796,.598587,.00392157,.609914,.300643,.610244,.129412,.697079,.351286,.616371,.254902,.785858,.401991,.617376,.380392,.862517,.45745,.64463,.505882,.91359,.525462,.705336,.631373,.932583,.61064,.767412,.756863,.922478,.706966,.817522,.882353,.901302,.803071,.856311,1,.887571,.887591,.887549]},{ColorSpace:"Lab",Name:"erdc_pbj_lin",RGBPoints:[-1,0,0,0,-.87451,.091821,.0611476,.10617,-.74902,.160311,.0900022,.192713,-.623529,.22484,.12126,.272128,-.498039,.291263,.157469,.340828,-.372549,.360015,.200388,.388903,-.247059,.437497,.250058,.387201,-.121569,.512636,.304969,.355955,.00392157,.582603,.360874,.33488,.129412,.655126,.416374,.306351,.254902,.725889,.473329,.279051,.380392,.778125,.537928,.302697,.505882,.815894,.606931,.382431,.631373,.839159,.679308,.497608,.756863,.854748,.751666,.631792,.882353,.869483,.822508,.768592,1,.887572,.887589,.887565]},{ColorSpace:"Lab",Name:"erdc_blue2green_muted",RGBPoints:[-1,.107704,.107708,.107695,-.87451,.141522,.13066,.270741,-.74902,.180123,.146119,.42308,-.623529,.210161,.169674,.551795,-.498039,.239701,.212939,.634969,-.372549,.253916,.282947,.653641,-.247059,.242791,.366933,.608521,-.121569,.226302,.446776,.52693,.00392157,.236237,.514689,.458798,.129412,.274641,.577589,.376069,.254902,.349625,.633993,.288131,.380392,.4437,.683677,.260497,.505882,.536247,.731214,.285424,.631373,.628472,.777128,.349151,.756863,.718259,.819287,.496825,.882353,.804768,.856164,.703299,1,.887571,.887591,.887548]},{ColorSpace:"Lab",Name:"erdc_blue2green_BW",RGBPoints:[-1,363578e-12,0,529374e-11,-.87451,.0539915,.0577948,.212806,-.74902,.0620393,.0758942,.388959,-.623529,.0697499,.102032,.54177,-.498039,.113295,.156156,.64334,-.372549,.152047,.243196,.670283,-.247059,.158096,.344084,.622864,-.121569,.151142,.43922,.532767,.00392157,.17155,.521588,.457719,.129412,.225861,.599141,.363997,.254902,.32328,.67007,.259083,.380392,.442344,.733697,.223754,.505882,.558409,.794941,.257411,.631373,.673875,.854344,.340822,.756863,.787244,.909326,.524717,.882353,.896483,.958063,.775914,1,1,1,.999982]},{ColorSpace:"Lab",Name:"GREEN-WHITE_LINEAR",RGBPoints:[-1,0,0,0,-.87451,0,.062745,0,-.74902,0,.12549,0,-.623529,0,.188235,0,-.498039,0,.25098,0,-.372549,0,.313725,0,-.247059,0,.376471,0,-.121569,.094118,.439216,0,.00392157,.196078,.501961,0,.129412,.294118,.564706,0,.254902,.396078,.627451,0,.380392,.498039,.690196,0,.505882,.6,.752941,.145098,.631373,.701961,.815686,.364706,.756863,.8,.878431,.580392,.882353,.901961,.941176,.796078,1,1,1,1]},{ColorSpace:"Lab",Name:"erdc_green2yellow_BW",RGBPoints:[-1,0,0,0,-.87451,0,.105542,.0603919,-.74902,0,.159454,.104148,-.623529,0,.219502,.15542,-.498039,0,.282276,.203811,-.372549,0,.346331,.235652,-.247059,0,.411765,.235428,-.121569,0,.477177,.217977,.00392157,.0593644,.541635,.21361,.129412,.233081,.604722,.210591,.254902,.369803,.664942,.226536,.380392,.498446,.722367,.288237,.505882,.601929,.782244,.380815,.631373,.703207,.840497,.512134,.756863,.803186,.896433,.674462,.882353,.903834,.950266,.846715,1,1,1,.999981]},{ColorSpace:"Lab",Name:"blue2cyan",RGBPoints:[-1,0,0,0,-.87451,0,.152941,.364706,-.74902,0,.254902,.470588,-.623529,0,.34902,.572549,-.498039,0,.443137,.670588,-.372549,0,.537255,.772549,-.247059,0,.627451,.870588,-.121569,0,.717647,.964706,.00392157,.0784314,.772549,1,.129412,.207843,.858824,1,.254902,.32549,.941176,1,.380392,.45098,1,1,.505882,.560784,1,1,.631373,.662745,1,1,.756863,.760784,1,1,.882353,.870588,1,1,1,1,1,1]},{ColorSpace:"Lab",Name:"erdc_blue2cyan_BW",RGBPoints:[-1,405298e-12,0,59012e-10,-.87451,.0207526,.0740933,.18093,-.74902,0,.121033,.30343,-.623529,0,.166892,.416095,-.498039,0,.216768,.524796,-.372549,.0164769,.275471,.608585,-.247059,.0544527,.344824,.659267,-.121569,.0880643,.419118,.688675,.00392157,.127938,.492556,.720256,.129412,.149476,.566946,.756918,.254902,.188961,.641333,.792122,.380392,.245482,.715336,.827609,.505882,.329216,.786235,.874761,.631373,.453558,.852803,.918466,.756863,.626281,.910493,.954,.882353,.82257,.958709,.980146,1,1,1,.999989]},{ColorSpace:"Lab",Name:"erdc_blue_BW",RGBPoints:[-1,0,0,0,-.87451,.0425591,.0763529,.150682,-.74902,.0569472,.119154,.275403,-.623529,.0635978,.164772,.395427,-.498039,.0774342,.213851,.510014,-.372549,.106815,.267034,.615102,-.247059,.122093,.324649,.720068,-.121569,.160851,.387068,.806956,.00392157,.213754,.453516,.878012,.129412,.26722,.524656,.932436,.254902,.326844,.599279,.968038,.380392,.403403,.674712,.984784,.505882,.499703,.745519,1,.631373,.615055,.813983,1,.756863,.74405,.879228,1,.882353,.877909,.941913,1,1,1,1,.999996]},{ColorSpace:"Lab",Name:"BLUE-WHITE",RGBPoints:[-1,0,0,0,-.87451,0,0,.082353,-.74902,0,0,.168627,-.623529,0,0,.254902,-.498039,0,0,.337255,-.372549,0,0,.423529,-.247059,0,0,.509804,-.121569,0,.101961,.592157,.00392157,0,.203922,.678431,.129412,0,.301961,.764706,.254902,0,.403922,.85098,.380392,0,.505882,.933333,.505882,0,.603922,1,.631373,.254902,.705882,1,.756863,.509804,.807843,1,.882353,.764706,.905882,1,1,1,1,1]},{ColorSpace:"Lab",Name:"erdc_purple_BW",RGBPoints:[-1,4264e-11,0,620844e-12,-.87451,.100579,.0593111,.145666,-.74902,.167794,.0889224,.254953,-.623529,.231446,.123339,.360511,-.498039,.296699,.163027,.461278,-.372549,.363211,.209286,.55306,-.247059,.431136,.260776,.637195,-.121569,.498202,.320012,.705799,.00392157,.567456,.380459,.778091,.129412,.629381,.445284,.8448,.254902,.688373,.517374,.895694,.380392,.74891,.590906,.93976,.505882,.805017,.667956,.977626,.631373,.850914,.752618,.992396,.756863,.89724,.838454,.994093,.882353,.948461,.922603,.994449,1,1,1,.999967]},{ColorSpace:"Lab",Name:"erdc_magenta_BW",RGBPoints:[-1,0,0,254023e-10,-.87451,.128696,.0456782,.11635,-.74902,.228133,.0476299,.201452,-.623529,.327273,.0374065,.282107,-.498039,.420953,.0408166,.35709,-.372549,.511562,.0642203,.430511,-.247059,.599552,.102686,.504257,-.121569,.684646,.150536,.579429,.00392157,.765817,.205978,.656062,.129412,.839176,.27229,.731807,.254902,.89536,.357594,.797309,.380392,.930238,.457825,.846984,.505882,.945921,.564536,.880571,.631373,.948995,.670753,.902279,.756863,.947124,.772819,.918171,.882353,.947265,.869424,.934352,1,.954719,.95475,.954726]},{ColorSpace:"Lab",Name:"magenta",RGBPoints:[-1,0,0,0,-.87451,.364706,0,.152941,-.74902,.470588,0,.254902,-.623529,.572549,0,.34902,-.498039,.670588,0,.443137,-.372549,.772549,0,.537255,-.247059,.870588,0,.627451,-.121569,.964706,0,.717647,.00392157,1,.0784314,.772549,.129412,1,.207843,.858824,.254902,1,.32549,.941176,.380392,1,.45098,1,.505882,1,.560784,1,.631373,1,.662745,1,.756863,1,.760784,1,.882353,1,.870588,1,1,1,1,1]},{ColorSpace:"Lab",Name:"RED-PURPLE",RGBPoints:[-1,0,0,0,-.87451,.188235,0,.007843,-.74902,.345098,0,.035294,-.623529,.439216,0,.098039,-.498039,.533333,0,.152941,-.372549,.627451,.015686,.211765,-.247059,.721569,.031373,.266667,-.121569,.8,.047059,.329412,.00392157,.862745,.047059,.403922,.129412,.941176,.062745,.466667,.254902,.988235,.078431,.54902,.380392,.988235,.141176,.643137,.505882,.988235,.25098,.729412,.631373,.988235,.376471,.811765,.756863,.988235,.54902,.886275,.882353,.988235,.752941,.952941,1,.996078,.996078,.996078]},{ColorSpace:"Lab",Name:"erdc_red_BW",RGBPoints:[-1,0,0,0,-.87451,.147204,.0480135,.0401815,-.74902,.253411,.0617478,.0301333,-.623529,.356059,.0746331,.0446897,-.498039,.457731,.0934935,.0636931,-.372549,.557199,.122714,.0860013,-.247059,.665179,.144238,.105585,-.121569,.763833,.187056,.138326,.00392157,.847035,.254558,.189407,.129412,.905663,.345937,.258215,.254902,.941431,.447111,.346277,.380392,.962608,.546927,.457571,.505882,.987833,.637276,.569944,.631373,.994202,.732176,.687958,.756863,.993304,.826268,.800567,.882353,.994413,.917205,.906393,1,1,1,.999979]},{ColorSpace:"Lab",Name:"RED_TEMPERATURE",RGBPoints:[-1,0,0,0,-.87451,.090196,0,0,-.74902,.180392,0,0,-.623529,.270588,0,0,-.498039,.360784,0,0,-.372549,.45098,0,0,-.247059,.545098,0,0,-.121569,.635294,0,0,.00392157,.72549,.058824,0,.129412,.815686,.176471,0,.254902,.905882,.294118,0,.380392,1,.411765,0,.505882,1,.533333,.027451,.631373,1,.65098,.27451,.756863,1,.768627,.521569,.882353,1,.886275,.768627,1,1,1,1]},{ColorSpace:"Lab",Name:"erdc_orange_BW",RGBPoints:[-1,0,0,253806e-10,-.87451,.135871,.0593824,0,-.74902,.224328,.0907216,0,-.623529,.318083,.119647,0,-.498039,.414443,.150246,0,-.372549,.511077,.184884,0,-.247059,.605501,.226033,0,-.121569,.695274,.275491,0,.00392157,.777826,.334445,0,.129412,.851498,.402441,0,.254902,.915899,.47759,602975e-9,.380392,.971984,.557882,.0361443,.505882,1,.641287,.135967,.631373,1,.725198,.27997,.756863,1,.808205,.438135,.882353,1,.89306,.587036,1,1,.977928,.721599]},{ColorSpace:"Lab",Name:"heated_object",RGBPoints:[-1,0,0,0,-.87451,.34902,.0862745,0,-.74902,.45098,.172549,0,-.623529,.52549,.231373,0,-.498039,.580392,.278431,0,-.372549,.623529,.313725,0,-.247059,.670588,.352941,0,-.121569,.717647,.392157,0,.00392157,.772549,.439216,0,.129412,.839216,.494118,0,.254902,.901961,.541176,0,.380392,.968627,.6,0,.505882,1,.658824,0,.631373,1,.721569,0,.756863,1,.827451,.298039,.882353,1,.976471,.72549,1,1,1,1]},{ColorSpace:"Lab",Name:"erdc_gold_BW",RGBPoints:[-1,0,0,190933e-10,-.87451,.128363,.0636265,0,-.74902,.193795,.111057,0,-.623529,.25976,.15987,0,-.498039,.328546,.210589,0,-.372549,.399726,.26332,0,-.247059,.472969,.318261,0,-.121569,.546245,.375827,0,.00392157,.61745,.436719,0,.129412,.685545,.501113,0,.254902,.749578,.568799,0,.380392,.80962,.6394,0,.505882,.865572,.712699,.10257,.631373,.917709,.787569,.233665,.756863,.966914,.863138,.369608,.882353,1,.939405,.496104,1,.999225,1,.612275]},{ColorSpace:"Lab",Name:"erdc_brown_BW",RGBPoints:[-1,33216e-11,0,483629e-11,-.87451,.14693,.0518172,0,-.74902,.225806,.0814996,0,-.623529,.301681,.111452,0,-.498039,.370487,.150664,0,-.372549,.43108,.199477,0,-.247059,.4849,.255107,0,-.121569,.536798,.313486,0,.00392157,.59286,.371167,0,.129412,.653119,.428135,0,.254902,.714589,.485917,.0379541,.380392,.774667,.54565,.116634,.505882,.831222,.608047,.183895,.631373,.880305,.674199,.260298,.756863,.922314,.742472,.367086,.882353,.959408,.811222,.497258,1,.993548,.875183,.622093]},{ColorSpace:"Lab",Name:"copper_Matlab",RGBPoints:[-1,0,0,0,-.87451,.0784314,.0501961,.0313725,-.74902,.156863,.100392,.0627451,-.623529,.235294,.150588,.0941176,-.498039,.313725,.200784,.12549,-.372549,.392157,.25098,.156863,-.247059,.470588,.301176,.188235,-.121569,.54902,.351373,.219608,.00392157,.627451,.401569,.25098,.129412,.705882,.451765,.282353,.254902,.784314,.501961,.313725,.380392,.862745,.552157,.345098,.505882,.941176,.602353,.376471,.631373,1,.652549,.407843,.756863,1,.702745,.439216,.882353,1,.752941,.470588,1,1,.8,.5]},{ColorSpace:"Lab",Name:"pink_Matlab",RGBPoints:[-1,0,0,0,-.87451,.312416,.204524,.204524,-.74902,.441822,.289241,.289241,-.623529,.54112,.354246,.354246,-.498039,.624831,.409048,.409048,-.372549,.698582,.45733,.45733,-.247059,.764404,.502282,.500979,-.121569,.791292,.591516,.54112,.00392157,.817297,.66895,.578481,.129412,.842499,.738308,.613572,.254902,.866968,.801687,.646762,.380392,.890766,.86041,.678329,.505882,.913944,.913944,.711254,.631373,.936549,.936549,.79459,.756863,.958621,.958621,.869979,.882353,.980196,.980196,.939336,1,1,1,1]},{ColorSpace:"Lab",Name:"bone_Matlab",RGBPoints:[-1,0,0,0,-.87451,.054902,.054902,.075817,-.74902,.109804,.109804,.151634,-.623529,.164706,.164706,.227451,-.498039,.219608,.219608,.303268,-.372549,.27451,.27451,.379085,-.247059,.329412,.329902,.454412,-.121569,.384314,.405719,.509314,.00392157,.439216,.481536,.564216,.129412,.494118,.557353,.619118,.254902,.54902,.63317,.67402,.380392,.603922,.708987,.728922,.505882,.660294,.783824,.783824,.631373,.746569,.838725,.838725,.756863,.832843,.893627,.893627,.882353,.919118,.948529,.948529,1,1,1,1]},{ColorSpace:"Lab",Name:"gray_Matlab",RGBPoints:[-1,0,0,0,-.87451,.0627451,.0627451,.0627451,-.74902,.12549,.12549,.12549,-.623529,.188235,.188235,.188235,-.498039,.25098,.25098,.25098,-.372549,.313725,.313725,.313725,-.247059,.376471,.376471,.376471,-.121569,.439216,.439216,.439216,.00392157,.501961,.501961,.501961,.129412,.564706,.564706,.564706,.254902,.627451,.627451,.627451,.380392,.690196,.690196,.690196,.505882,.752941,.752941,.752941,.631373,.815686,.815686,.815686,.756863,.878431,.878431,.878431,.882353,.941176,.941176,.941176,1,1,1,1]},{ColorSpace:"Lab",Name:"Purples",RGBPoints:[-1,.247059,0,.490196,-.87451,.288397,.07677,.525629,-.74902,.32975,.153587,.561092,-.623529,.373057,.236263,.600461,-.498039,.416363,.319,.639923,-.372549,.459669,.405613,.685198,-.247059,.503345,.491534,.730058,-.121569,.562399,.54862,.757616,.00392157,.621453,.606075,.785544,.129412,.680508,.674971,.824914,.254902,.739562,.743406,.863899,.380392,.798616,.800492,.893426,.505882,.85684,.856655,.922491,.631373,.898178,.894056,.942176,.756863,.938654,.930919,.961646,.882353,.964245,.958478,.977393,1,.988235,.984314,.992157]},{ColorSpace:"Lab",Name:"Blues",RGBPoints:[-1,.031373,.188235,.419608,-.87451,.031373,.253195,.516063,-.74902,.031757,.318139,.612149,-.623529,.080969,.38113,.661361,-.498039,.130427,.444152,.710327,-.372549,.195386,.509112,.743791,-.247059,.260715,.573841,.777209,-.121569,.341423,.628958,.808704,.00392157,.422745,.684075,.839892,.129412,.523137,.739193,.861546,.254902,.622684,.793464,.883429,.380392,.701423,.826928,.910988,.505882,.778685,.8603,.937993,.631373,.825928,.891795,.953741,.756863,.87328,.923291,.969489,.882353,.922491,.954787,.985236,1,.968627,.984314,1]},{ColorSpace:"Lab",Name:"Greens",RGBPoints:[-1,0,.266667,.105882,-.87451,0,.347374,.139346,-.74902,538e-6,.427912,.172933,-.623529,.069435,.486967,.222145,-.498039,.138178,.546082,.271326,-.372549,.197232,.609073,.31857,-.247059,.257255,.671742,.365859,-.121569,.357647,.720953,.415071,.00392157,.45767,.769919,.465021,.129412,.546251,.811257,.537855,.254902,.634295,.852211,.610688,.380392,.709097,.883706,.683522,.505882,.78316,.914833,.755894,.631373,.842215,.938454,.818885,.756863,.899977,.961538,.880692,.882353,.935409,.975317,.92203,1,.968627,.988235,.960784]},{ColorSpace:"Lab",Name:"PuBu",RGBPoints:[-1,.301961,0,.294118,-.87451,.404321,.029527,.390573,-.74902,.50599,.059592,.486782,-.623529,.519769,.158016,.551742,-.498039,.533456,.256194,.616301,-.372549,.54133,.33887,.655671,-.247059,.54902,.421592,.695087,-.121569,.54902,.506236,.736424,.00392157,.550127,.590573,.777701,.129412,.585559,.665375,.81707,.254902,.622145,.739023,.855825,.380392,.687105,.784298,.879446,.505882,.752065,.829758,.903253,.631373,.817024,.87897,.930811,.756863,.880907,.927213,.957832,.882353,.926182,.958708,.975548,1,.968627,.988235,.992157]},{ColorSpace:"Lab",Name:"BuPu",RGBPoints:[-1,.007843,.219608,.345098,-.87451,.01178,.286536,.449427,-.74902,.015702,.35328,.553479,-.623529,.01767,.396586,.622376,-.498039,.021115,.4402,.690688,-.372549,.11757,.503191,.722184,-.247059,.214625,.565859,.753633,-.121569,.336671,.615071,.78316,.00392157,.457978,.663975,.812503,.129412,.556401,.703345,.836125,.254902,.65421,.742714,.859669,.380392,.736886,.782084,.881323,.505882,.81827,.821638,.903068,.631373,.873387,.864944,.92669,.756863,.927536,.907605,.949988,.882353,.964937,.9391,.967705,1,1,.968627,.984314]},{ColorSpace:"Lab",Name:"BuGn",RGBPoints:[-1,.031373,.25098,.505882,-.87451,.031373,.329719,.590527,-.74902,.031911,.408397,.674787,-.623529,.100807,.479262,.710219,-.498039,.169704,.550219,.745744,-.372549,.238601,.62699,.787082,-.247059,.307958,.703114,.826759,-.121569,.39654,.752326,.797232,.00392157,.485121,.801046,.767705,.129412,.573702,.83451,.738178,.254902,.661592,.867743,.711034,.380392,.732457,.895302,.74253,.505882,.801845,.922307,.774579,.631373,.841215,.938055,.817885,.756863,.880907,.95391,.861084,.882353,.926182,.971626,.902422,1,.968627,.988235,.941176]},{ColorSpace:"Lab",Name:"GnBu",RGBPoints:[-1,0,.266667,.105882,-.87451,0,.347374,.139346,-.74902,538e-6,.427912,.172933,-.623529,.069435,.486967,.222145,-.498039,.138178,.546175,.272095,-.372549,.197232,.615071,.368551,-.247059,.256609,.683276,.464867,-.121569,.329443,.722645,.555417,.00392157,.403137,.762138,.645413,.129412,.503529,.805444,.718247,.254902,.603922,.848597,.790465,.380392,.704314,.887966,.847551,.505882,.802307,.926321,.903714,.631373,.851519,.944037,.941115,.756863,.899977,.961538,.976901,.882353,.935409,.975317,.984775,1,.968627,.988235,.992157]},{ColorSpace:"Lab",Name:"GnBuPu",RGBPoints:[-1,.003922,.27451,.211765,-.87451,.003922,.349312,.280661,-.74902,.003937,.423852,.349773,-.623529,.005905,.46519,.446228,-.498039,.009443,.506344,.542837,-.372549,.111803,.535871,.649135,-.247059,.214025,.565859,.753633,-.121569,.310481,.615071,.78316,.00392157,.407797,.663975,.812503,.129412,.531811,.703345,.836125,.254902,.65421,.742714,.859669,.380392,.736886,.782084,.881323,.505882,.81827,.821176,.902884,.631373,.873387,.854641,.922568,.756863,.927536,.888535,.942361,.882353,.964937,.929873,.964014,1,1,.968627,.984314]},{ColorSpace:"Lab",Name:"BuGnYl",RGBPoints:[-1,.031373,.113725,.345098,-.87451,.088458,.159,.463206,-.74902,.145052,.204567,.5807,-.623529,.139146,.287243,.620069,-.498039,.13318,.370196,.659562,-.372549,.123337,.470588,.706805,-.247059,.115386,.570335,.753126,-.121569,.186251,.643168,.761,.00392157,.258716,.71514,.768074,.129412,.380761,.760415,.750358,.254902,.503576,.806075,.732795,.380392,.645306,.861192,.719016,.505882,.783899,.91511,.705606,.631373,.858701,.944637,.6997,.756863,.931349,.973303,.698424,.882353,.966782,.987082,.777163,1,1,1,.85098]},{ColorSpace:"Lab",Name:"PuRd",RGBPoints:[-1,.286275,0,.415686,-.87451,.38273,.001968,.441276,-.74902,.479231,.003922,.466774,-.623529,.581592,.003922,.480554,-.498039,.683799,.00549,.494887,-.372549,.776317,.105882,.544098,-.247059,.867866,.206321,.592618,-.121569,.919047,.308681,.612303,.00392157,.968812,.411226,.632603,.129412,.974717,.519493,.671972,.254902,.980546,.626451,.71065,.380392,.984483,.701253,.732303,.505882,.988328,.77504,.755617,.631373,.990296,.828189,.812703,.756863,.992372,.880907,.869035,.882353,.996309,.926182,.912341,1,1,.968627,.952941]},{ColorSpace:"Lab",Name:"RdPu",RGBPoints:[-1,.403922,0,.121569,-.87451,.500377,0,.192434,-.74902,.596909,277e-6,.263037,-.623529,.703206,.035709,.300438,-.498039,.808612,.071296,.338854,-.372549,.857824,.116571,.441215,-.247059,.905513,.163552,.54293,-.121569,.889765,.281661,.617732,.00392157,.873156,.39897,.691611,.129412,.82985,.491488,.736886,.254902,.789081,.583237,.781853,.380392,.810734,.656071,.819254,.505882,.833126,.729181,.85684,.631373,.870527,.80792,.898178,.756863,.907605,.884398,.938331,.882353,.9391,.921799,.958016,1,.968627,.956863,.976471]},{ColorSpace:"Lab",Name:"Oranges",RGBPoints:[-1,.498039,.152941,.015686,-.87451,.57481,.182468,.013718,-.74902,.651765,.212042,.011734,-.623529,.752157,.247474,.007797,-.498039,.851719,.283368,.004475,-.372549,.898962,.348328,.039908,-.247059,.945652,.413426,.076401,-.121569,.969273,.484291,.157109,.00392157,.992157,.554971,.238185,.129412,.992157,.619931,.330704,.254902,.992157,.684967,.423837,.380392,.992157,.751895,.532103,.505882,.992249,.817716,.639354,.631373,.994218,.861023,.725967,.756863,.996186,.903576,.810965,.882353,.998155,.933103,.868051,1,1,.960784,.921569]},{ColorSpace:"Lab",Name:"Reds",RGBPoints:[-1,.403922,0,.05098,-.87451,.525967,.029527,.066728,-.74902,.647643,.058962,.082476,-.623529,.722445,.076678,.098224,-.498039,.797186,.095194,.114187,-.372549,.868051,.164091,.143714,-.247059,.937809,.233541,.173933,-.121569,.96143,.326059,.232987,.00392157,.984375,.418147,.292657,.129412,.986344,.496886,.371396,.254902,.988235,.575702,.450673,.380392,.988235,.656409,.543191,.505882,.98842,.736747,.635894,.631373,.992357,.809581,.732349,.756863,.996186,.880692,.826759,.882353,.998155,.92203,.885813,1,1,.960784,.941176]},{ColorSpace:"Lab",Name:"RdOr",RGBPoints:[-1,.498039,0,0,-.87451,.6004,0,0,-.74902,.702514,738e-6,477e-6,-.623529,.773379,.095225,.061499,-.498039,.843875,.189865,.12283,-.372549,.891119,.294195,.203537,-.247059,.937855,.397924,.283137,-.121569,.963445,.476663,.316601,.00392157,.988297,.555771,.351665,.129412,.990265,.646321,.436309,.254902,.992157,.735256,.519646,.380392,.992157,.784468,.570827,.505882,.992249,.833218,.623483,.631373,.994218,.872587,.706159,.756863,.996186,.911419,.788189,.882353,.998155,.940946,.859054,1,1,.968627,.92549]},{ColorSpace:"Lab",Name:"BrOrYl",RGBPoints:[-1,.4,.145098,.023529,-.87451,.500392,.174625,.019592,-.74902,.600784,.204291,.015656,-.623529,.701176,.251534,.011719,-.498039,.800984,.299146,.008397,-.372549,.863975,.370012,.043829,-.247059,.926321,.441107,.0794,-.121569,.961753,.521815,.120738,.00392157,.996078,.602645,.163122,.129412,.996078,.68729,.237924,.254902,.996078,.771011,.314879,.380392,.996078,.832034,.444798,.505882,.996171,.892042,.572595,.631373,.998139,.931411,.65724,.756863,1,.969489,.741669,.882353,1,.985236,.822376,1,1,1,.898039]},{ColorSpace:"Lab",Name:"RdOrYl",RGBPoints:[-1,.501961,0,.14902,-.87451,.622038,0,.14902,-.74902,.741761,4e-4,.148866,-.623529,.816563,.05158,.129181,-.498039,.890965,.10356,.110235,-.372549,.940177,.205921,.137793,-.247059,.988281,.308789,.165536,-.121569,.99025,.432803,.200969,.00392157,.992218,.555217,.236278,.129412,.994187,.628051,.267774,.254902,.996078,.701038,.301269,.380392,.996078,.777809,.383945,.505882,.996171,.852826,.466621,.631373,.998139,.892195,.549296,.756863,1,.931349,.632188,.882353,1,.966782,.7188,1,1,1,.8]},{ColorSpace:"Lab",Name:"CIELab_blue2red",RGBPoints:[-1,0,.6,.74902,1,.76863,.46667,.34118]},{ColorSpace:"Lab",Name:"blue2yellow",RGBPoints:[-1,0,0,1,0,.5,.5,.5,1,1,1,0]},{ColorSpace:"Lab",Name:"erdc_blue2gold",RGBPoints:[-1,.175119,.0438468,1,-.874016,.22383,.159771,.94557,-.748031,.27254,.233611,.891216,-.622047,.321251,.296526,.836857,-.496063,.369962,.354296,.782359,-.370079,.418672,.409139,.72754,-.244094,.467383,.462152,.672148,-.11811,.51609,.51396,.615825,.00787402,.572863,.55452,.559172,.133858,.630269,.593822,.517729,.259843,.689588,.624668,.47446,.385827,.745394,.656113,.428638,.511811,.798624,.688104,.379105,.637795,.849926,.720593,.323834,.76378,.899765,.753543,.258657,.889764,.948487,.78692,.171778,1,.990413,.816451,.00729848]},{ColorSpace:"Lab",Name:"erdc_blue2yellow",RGBPoints:[-1,.0830122,0,.495617,-.87451,.141973,.0551288,.57363,-.74902,.193048,.110258,.604561,-.623529,.234231,.165386,.57643,-.498039,.275413,.220515,.548299,-.372549,.316596,.275644,.520169,-.247059,.357778,.330773,.492038,-.121569,.398961,.385901,.463908,.00392157,.449929,.438487,.426815,.129412,.511572,.488299,.379944,.254902,.581222,.53603,.325741,.380392,.650871,.583761,.271538,.505882,.720521,.631493,.217335,.631373,.79017,.679224,.163132,.756863,.85982,.726955,.108929,.882353,.910254,.774159,.14112,1,.927513,.81759,.306289]},{ColorSpace:"Lab",Name:"erdc_cyan2orange",RGBPoints:[-1,.0471513,.213874,.414329,-.87451,.0674702,.256648,.439027,-.74902,.0959957,.299331,.462089,-.623529,.132428,.341872,.483212,-.498039,.188743,.38277,.500597,-.372549,.268511,.420229,.512179,-.247059,.352945,.455602,.519101,-.121569,.43893,.489368,.521538,.00392157,.522445,.522495,.522436,.129412,.600089,.555682,.53205,.254902,.67988,.587981,.539163,.380392,.761011,.619586,.544439,.505882,.84278,.650741,.548567,.631373,.910713,.687347,.557822,.756863,.952232,.734972,.577775,.882353,.975642,.789858,.604868,1,.990752,.843643,.632857]},{ColorSpace:"Lab",Name:"erdc_purple2green",RGBPoints:[-1,.235006,.0483128,.530899,-.87451,.302968,.108419,.552391,-.74902,.360241,.166059,.569502,-.623529,.406746,.226782,.579373,-.498039,.444073,.28964,.582094,-.372549,.473648,.353774,.577947,-.247059,.497636,.418154,.567911,-.121569,.519086,.481741,.553968,.00392157,.542884,.542914,.542875,.129412,.566303,.603989,.527499,.254902,.595218,.662965,.516857,.380392,.628641,.720701,.510673,.505882,.665373,.777849,.508165,.631373,.704182,.834921,.508303,.756863,.743846,.892328,.50999,.882353,.783158,.950422,.512181,1,.818617,1,.513888]},{ColorSpace:"Lab",Name:"erdc_purple2green_dark",RGBPoints:[-1,.107656,0,.428682,-.87451,.1924,0,.449799,-.74902,.255118,.0648939,.466726,-.623529,.304256,.133066,.476703,-.498039,.343202,.19716,.479793,-.372549,.373876,.260353,.476241,-.247059,.398497,.322872,.466953,-.121569,.420016,.384252,.453785,.00392157,.44319,.443216,.443186,.129412,.465553,.502139,.428233,.254902,.492959,.559151,.417591,.380392,.524654,.615092,.411016,.505882,.55959,.670583,.40779,.631373,.596614,.726102,.406948,.756863,.634544,.782032,.407439,.882353,.672183,.838703,.408237,1,.706131,.892759,.408452]},{ColorSpace:"Lab",Name:"coolwarm",RGBPoints:[-1,.229806,.298718,.753683,-.875,.303869,.406535,.844959,-.75,.383013,.509419,.917388,-.625,.466667,.604563,.968155,-.5,.552953,.688929,.995376,-.375,.639176,.7596,.998151,-.25,.722193,.813953,.976575,-.125,.798692,.849786,.931689,0,.865395,.86541,.865396,.125,.924128,.827385,.774508,.25,.958853,.769768,.678008,.375,.969954,.694267,.579375,.5,.958003,.602842,.481776,.625,.923945,.497309,.38797,.75,.869187,.378313,.300267,.875,.795632,.241284,.220526,1,.705673,.0155562,.150233]},{ColorSpace:"Lab",Name:"BuRd",RGBPoints:[-1,.019608,.188235,.380392,-.87451,.088504,.321107,.564937,-.74902,.163399,.444983,.697501,-.623529,.247059,.555709,.754095,-.498039,.420684,.676432,.818685,-.372549,.606459,.789773,.880277,-.247059,.761476,.868512,.924567,-.121569,.878047,.925721,.951942,.00392157,.969089,.966474,.964937,.129412,.983852,.897578,.846828,.254902,.982468,.800692,.706113,.380392,.960323,.66782,.536332,.505882,.894579,.503806,.399769,.631373,.81707,.33218,.281046,.756863,.728489,.155017,.197386,.882353,.576932,.055363,.14925,1,.403922,0,.121569]},{ColorSpace:"Lab",Name:"Spectral_lowBlue",RGBPoints:[-1,.368627,.309804,.635294,-.87451,.260361,.450058,.70173,-.74902,.248058,.591311,.717186,-.623529,.376009,.734025,.658132,-.498039,.537947,.814764,.64506,-.372549,.702345,.879585,.636678,-.247059,.84752,.938639,.607151,-.121569,.940408,.976163,.656055,.00392157,.999923,.997616,.745021,.129412,.997463,.921338,.61707,.254902,.995002,.824606,.499885,.380392,.992541,.701576,.39654,.505882,.973472,.547405,.318108,.631373,.937793,.398539,.270127,.756863,.861515,.282891,.299654,.882353,.746482,.144637,.288812,1,.619608,.003922,.258824]},{ColorSpace:"Lab",Name:"GnRP",RGBPoints:[-1,0,.266667,.105882,-.87451,.066436,.394617,.174779,-.74902,.168858,.524567,.25767,-.623529,.323875,.657439,.361015,-.498039,.504883,.772318,.506344,-.372549,.678431,.870127,.654902,-.247059,.803922,.921799,.780392,-.121569,.897116,.951942,.882814,.00392157,.967397,.965936,.967474,.129412,.928028,.879815,.930565,.254902,.866052,.780777,.882891,.380392,.77501,.665129,.821376,.505882,.675663,.537024,.737024,.631373,.57847,.396155,.645982,.756863,.492349,.223914,.547559,.882353,.375548,.096886,.423299,1,.25098,0,.294118]},{ColorSpace:"Lab",Name:"GYPi",RGBPoints:[-1,.152941,.392157,.098039,-.87451,.246444,.505344,.117724,-.74902,.351942,.614533,.161399,-.623529,.474971,.717878,.240138,-.498039,.611995,.811226,.392849,-.372549,.746328,.893118,.565321,-.247059,.859516,.94233,.747405,-.121569,.928105,.96386,.875663,.00392157,.969089,.966859,.968012,.129412,.983852,.910265,.948328,.254902,.979239,.833218,.914648,.380392,.949712,.729873,.862976,.505882,.905652,.58293,.763552,.631373,.85521,.410073,.652211,.756863,.793695,.183699,.531642,.882353,.683737,.063899,.420761,1,.556863,.003922,.321569]},{ColorSpace:"Lab",Name:"GnYlRd",RGBPoints:[-1,0,.407843,.215686,-.87451,.063975,.525952,.277201,-.74902,.177932,.633064,.332718,-.623529,.364937,.724106,.379469,-.498039,.527951,.797155,.40223,-.372549,.678431,.862822,.433449,-.247059,.803922,.916955,.514648,-.121569,.909419,.961861,.625067,.00392157,.999923,.997616,.745021,.129412,.997463,.921338,.61707,.254902,.995002,.824606,.499885,.380392,.992541,.701576,.39654,.505882,.973472,.547405,.318108,.631373,.939023,.389927,.245521,.756863,.867666,.239831,.176624,.882353,.762399,.110727,.151326,1,.647059,0,.14902]},{ColorSpace:"Lab",Name:"GBBr",RGBPoints:[-1,0,.235294,.188235,-.87451,.002461,.338639,.301423,-.74902,.055902,.448981,.417609,-.623529,.183852,.56955,.538178,-.498039,.357785,.700115,.660746,-.372549,.540177,.819531,.77624,-.247059,.714879,.890888,.864821,-.121569,.851134,.934564,.922645,.00392157,.960861,.959785,.95694,.129412,.963322,.927797,.83391,.254902,.939946,.868897,.68935,.380392,.883353,.775394,.517109,.505882,.808074,.625836,.324106,.631373,.717647,.476355,.15494,.756863,.592157,.358247,.06882,.882353,.458593,.26436,.031142,1,.329412,.188235,.019608]},{ColorSpace:"Lab",Name:"PuOr",RGBPoints:[-1,.498039,.231373,.031373,-.87451,.62599,.30273,.026451,-.74902,.746943,.387082,.037524,-.623529,.85767,.490427,.071972,-.498039,.936409,.617762,.236371,-.372549,.992695,.743099,.43291,-.247059,.995156,.841523,.63714,-.121569,.985313,.913802,.813687,.00392157,.966244,.966398,.967705,.129412,.889965,.89504,.938178,.254902,.806151,.804306,.894656,.380392,.712649,.688658,.833141,.505882,.594233,.554325,.744637,.631373,.474894,.404229,.652364,.756863,.366628,.217224,.563783,.882353,.266436,.089965,.434833,1,.176471,0,.294118]},{ColorSpace:"Lab",Name:"PRGn",RGBPoints:[-1,.25098,0,.294118,-.87451,.383852,.103345,.431911,-.74902,.497732,.234679,.55371,-.623529,.583852,.40692,.652134,-.498039,.681968,.545175,.742561,-.372549,.7807,.672357,.825221,-.247059,.871742,.788005,.886736,-.121569,.930488,.885198,.932872,.00392157,.966321,.968089,.965859,.129412,.892503,.950865,.877278,.254902,.796078,.91857,.772549,.380392,.670588,.866897,.647059,.505882,.493195,.765398,.496655,.631373,.314187,.649135,.354556,.756863,.15917,.516263,.251211,.882353,.062284,.386621,.170473,1,0,.266667,.105882]},{ColorSpace:"Lab",Name:"PiYG",RGBPoints:[-1,.556863,.003922,.321569,-.87451,.692195,.067897,.427374,-.74902,.797539,.197847,.539177,-.623529,.859054,.424221,.659746,-.498039,.908574,.592618,.770319,-.372549,.951557,.736332,.866205,-.247059,.981084,.839677,.917878,-.121569,.98293,.913802,.949558,.00392157,.96732,.968474,.965629,.129412,.92549,.963552,.869666,.254902,.852441,.939254,.736025,.380392,.739254,.890042,.553941,.505882,.60323,.805536,.382238,.631373,.467282,.711419,.235217,.756863,.344252,.608074,.156478,.882353,.2406,.49827,.116494,1,.152941,.392157,.098039]},{ColorSpace:"Lab",Name:"OrPu",RGBPoints:[-1,.176471,0,.294118,-.87451,.272434,.095963,.444214,-.74902,.373395,.228912,.56932,-.623529,.481661,.415917,.657901,-.498039,.601922,.562937,.750481,-.372549,.718493,.695886,.836986,-.247059,.811995,.811534,.898501,-.121569,.894733,.8995,.940023,.00392157,.969166,.966859,.963629,.129412,.98639,.910265,.803691,.254902,.995002,.835371,.624375,.380392,.992541,.736947,.420146,.505882,.931949,.609458,.224221,.631373,.85075,.483968,.069819,.756863,.740023,.380623,.035371,.882353,.617993,.29827,.026759,1,.498039,.231373,.031373]},{ColorSpace:"Lab",Name:"BrBG",RGBPoints:[-1,.329412,.188235,.019608,-.87451,.467205,.269435,.031911,-.74902,.6,.365629,.074202,-.623529,.72549,.483737,.160323,-.498039,.812995,.635832,.336409,-.372549,.88689,.781238,.527874,-.247059,.943483,.87474,.700115,-.121569,.963168,.929796,.841599,.00392157,.957247,.959938,.959554,.129412,.84406,.932872,.920185,.254902,.70396,.886428,.859285,.380392,.529258,.815071,.770704,.505882,.346251,.691811,.653057,.631373,.175855,.562015,.530642,.756863,.047905,.441446,.410073,.882353,.002307,.33218,.294348,1,0,.235294,.188235]},{ColorSpace:"Lab",Name:"GyRd",RGBPoints:[-1,.101961,.101961,.101961,-.87451,.227451,.227451,.227451,-.74902,.359939,.359939,.359939,-.623529,.502653,.502653,.502653,-.498039,.631373,.631373,.631373,-.372549,.749865,.749865,.749865,-.247059,.843368,.843368,.843368,-.121569,.926105,.926105,.926105,.00392157,.999846,.997232,.995694,.129412,.994925,.908651,.857901,.254902,.982468,.800692,.706113,.380392,.960323,.66782,.536332,.505882,.894579,.503806,.399769,.631373,.81707,.33218,.281046,.756863,.728489,.155017,.197386,.882353,.576932,.055363,.14925,1,.403922,0,.121569]},{ColorSpace:"Lab",Name:"erdc_divHi_purpleGreen",RGBPoints:[-1,.297553,0,.489074,-.87451,.40259,.151146,.567754,-.74902,.516038,.284843,.658231,-.623529,.629783,.423646,.750938,-.498039,.735198,.563697,.835956,-.372549,.82408,.695541,.903582,-.247059,.889091,.807454,.944862,-.121569,.92334,.886917,.951839,.00392157,.921045,.921084,.921003,.129412,.877324,.907455,.845381,.254902,.797649,.849713,.734695,.380392,.691646,.75964,.600532,.505882,.568981,.649159,.453807,.631373,.438945,.529756,.304259,.756863,.30973,.412001,.158303,.882353,.187078,.305111,.00251458,1,.101655,.220836,0]},{ColorSpace:"Lab",Name:"erdc_divHi_purpleGreen_dim",RGBPoints:[-1,.404088,.131038,.592767,-.87451,.486469,.230957,.651243,-.74902,.575165,.339335,.717723,-.623529,.662741,.454332,.784263,-.498039,.742071,.570213,.842918,-.372549,.806935,.678992,.886227,-.247059,.852219,.771315,.90763,-.121569,.873345,.837327,.901572,.00392157,.866783,.86682,.866745,.129412,.82839,.858225,.796812,.254902,.762578,.814287,.700202,.380392,.676429,.744229,.585735,.505882,.577033,.65732,.461526,.631373,.47128,.562476,.33476,.756863,.365461,.467957,.21076,.882353,.264758,.381138,.0878313,1,.182591,.312249,0]},{ColorSpace:"Lab",Name:"erdc_divLow_icePeach",RGBPoints:[-1,.480048,.817441,.998056,-.87451,.425898,.726921,.883187,-.74902,.366682,.629445,.761936,-.623529,.308756,.531002,.640217,-.498039,.258021,.43705,.523433,-.372549,.219244,.352381,.416348,-.247059,.195127,.281032,.322979,-.121569,.186286,.22627,.246525,.00392157,.192352,.19236,.192364,.129412,.255927,.214469,.191756,.254902,.340459,.254426,.206666,.380392,.444655,.309315,.234029,.505882,.565353,.376004,.270969,.631373,.697917,.450748,.314293,.756863,.836657,.529064,.360227,.882353,.972695,.614884,.413123,1,1,.705904,.472699]},{ColorSpace:"Lab",Name:"erdc_divLow_purpleGreen",RGBPoints:[-1,.956034,.666487,.952663,-.87451,.874457,.572698,.936352,-.74902,.753465,.488253,.909063,-.623529,.63309,.413507,.763833,-.498039,.514491,.345878,.620015,-.372549,.405008,.288141,.484376,-.247059,.311388,.241986,.363556,-.121569,.238722,.209044,.263449,.00392157,.192352,.192366,.192362,.129412,.200379,.233201,.168618,.254902,.230151,.291737,.165227,.380392,.279481,.366076,.178607,.505882,.344927,.453267,.205703,.631373,.421554,.549449,.242643,.756863,.503334,.649999,.284377,.882353,.583497,.749672,.324969,1,.650705,.837228,.356264]},{ColorSpace:"Lab",Name:"Haze_green",RGBPoints:[-1,1,.835294,.886275,-.87451,.937255,.756863,.870443,-.74902,.875817,.666376,.857807,-.623529,.778359,.583007,.808134,-.498039,.676253,.494118,.745098,-.372549,.561365,.390123,.682353,-.247059,.438344,.262745,.621496,-.121569,.321133,.141031,.558751,.00392157,.203922,.0217865,.495861,.129412,.265505,.129412,.433261,.254902,.311692,.255338,.37008,.380392,.356282,.377342,.310821,.505882,.39971,.488889,.258243,.631373,.442556,.604357,.205519,.756863,.48671,.71968,.152941,.882353,.529847,.830356,.100944,1,.572549,.933333,.054902]},{ColorSpace:"Lab",Name:"Haze_lime",RGBPoints:[-1,.704034,.784196,1,-.87451,.633111,.691418,.956078,-.74902,.564021,.600606,.912157,-.623529,.496827,.51189,.868235,-.498039,.43157,.425416,.824314,-.372549,.368248,.341347,.780392,-.247059,.306767,.259855,.736471,-.121569,.246862,.181069,.692549,.00392157,.191619,.109542,.648627,.129412,.257404,.194031,.604706,.254902,.321794,.278775,.560784,.380392,.387909,.364617,.516863,.505882,.456569,.451881,.472941,.631373,.527424,.540773,.42902,.756863,.599759,.631427,.385098,.882353,.673065,.723898,.341176,1,.742751,.812252,.3]},{ColorSpace:"RGB",Name:"Haze",RGBPoints:[-1,1,.835294,.996078,-.00392157,.023529,.141176,.498039,.00392157,.015686,.137255,.494118,1,.984314,.764706,0]},{ColorSpace:"Lab",Name:"Haze_cyan",RGBPoints:[-1,.956863,1,.835294,-.87451,.933188,.921714,.760784,-.74902,.870588,.803486,.671605,-.623529,.807843,.684096,.583297,-.498039,.745098,.569208,.494118,-.372549,.682353,.437763,.390123,-.247059,.621496,.288163,.262745,-.121569,.558751,.144517,.141031,.00392157,.495861,.0217865,.0413943,.129412,.433261,.137255,.129412,.254902,.37008,.263181,.255338,.380392,.306318,.381845,.372694,.505882,.243137,.503994,.494263,.631373,.180392,.629484,.619753,.756863,.117647,.754975,.747131,.882353,.054902,.876398,.866812,1,0,.988235,.976471]},{ColorSpace:"Lab",Name:"nic_Edge",RGBPoints:[-1,.191208,.191208,.191208,-.87451,.239484,.00545035,.614821,-.74902,.220593,.0617459,.863547,-.623529,.17509,.278988,.97794,-.498039,.143526,.576069,.998553,-.372549,.166456,.871883,.96594,-.247059,.376202,.993555,.981833,-.121569,.681996,.991297,.999239,.00392157,.954172,.952734,.94374,.129412,.999735,.99301,.662896,.254902,.979399,.991466,.357973,.380392,.968771,.854967,.162659,.505882,.999245,.556697,.144323,.631373,.973959,.26223,.177946,.756863,.852358,.0526707,.222974,.882353,.593889,.00912724,.238855,1,.191208,.191208,.191208]},{ColorSpace:"Lab",Name:"erdc_iceFire_H",RGBPoints:[-1,405432e-12,0,590122e-11,-.87451,0,.120401,.302675,-.74902,0,.216583,.524574,-.623529,.0552475,.345025,.6595,-.498039,.128047,.492588,.720288,-.372549,.188955,.641309,.792092,-.247059,.327673,.784935,.873434,-.121569,.60824,.892164,.935547,.00392157,.881371,.912178,.818099,.129412,.951407,.835621,.449279,.254902,.904481,.690489,0,.380392,.85407,.510864,0,.505882,.777093,.33018,88199e-8,.631373,.672862,.139087,.00269398,.756863,.508815,0,0,.882353,.299417,366289e-9,547829e-9,1,.0157519,.00332021,455569e-13]},{ColorSpace:"Lab",Name:"erdc_iceFire_L",RGBPoints:[-1,.870485,.913768,.832905,-.87451,.586919,.887865,.934003,-.74902,.31583,.776442,.867858,-.623529,.18302,.632034,.787722,-.498039,.117909,.484134,.713825,-.372549,.0507239,.335979,.654741,-.247059,0,.209874,.511832,-.121569,0,.114689,.28935,.00392157,.0157519,.00332021,455569e-13,.129412,.312914,0,0,.254902,.520865,0,0,.380392,.680105,.15255,.0025996,.505882,.785109,.339479,797922e-9,.631373,.857354,.522494,0,.756863,.910974,.699774,0,.882353,.951921,.842817,.478545,1,.881371,.912178,.818099]},{ColorSpace:"RGB",Name:"hsv",RGBPoints:[-1,1,0,0,-.666666,1,0,1,-.333333,0,0,1,0,0,1,1,.33333,0,1,0,.66666,1,1,0,1,1,0,0]},{ColorSpace:"Lab",Name:"hue_L60",RGBPoints:[-1,.964784,.400592,.349549,-.87451,.964915,.372498,.53785,-.74902,.892353,.401039,.759569,-.623529,.79263,.446956,.903017,-.498039,.682208,.49954,.966673,-.372549,.56392,.553082,.968836,-.247059,.442031,.606396,.901601,-.121569,.305499,.65701,.765784,.00392157,.197251,.687914,.620914,.129412,.193882,.701887,.472654,.254902,.249866,.706123,.320005,.380392,.35132,.697417,.202919,.505882,.498097,.669467,.125232,.631373,.637477,.626239,.107431,.756863,.762115,.56872,.155812,.882353,.889434,.481116,.240445,1,.964784,.400592,.349549]},{IndexedColors:[0,0,0,.8941176470588236,.1019607843137255,.1098039215686274,.2156862745098039,.4941176470588236,.7215686274509804,.3019607843137255,.6862745098039216,.2901960784313726,.596078431372549,.3058823529411765,.6392156862745098,1,.4980392156862745,0,.6509803921568628,.3372549019607843,.1568627450980392],Name:"Spectrum",NanColor:[.6509803921568628,.3372549019607843,.1568627450980392]},{IndexedColors:[.4745098039215686,.09019607843137255,.09019607843137255,.7098039215686275,.00392156862745098,.00392156862745098,.9372549019607843,.2784313725490196,.09803921568627451,.9764705882352941,.5137254901960784,.1411764705882353,1,.7058823529411765,0,1,.8980392156862745,.02352941176470588],Name:"Warm",NanColor:[1,.8980392156862745,.02352941176470588]},{IndexedColors:[.4588235294117647,.6941176470588235,.00392156862745098,.3450980392156863,.5019607843137255,.1607843137254902,.3137254901960784,.8431372549019608,.7490196078431373,.1098039215686274,.5843137254901961,.803921568627451,.2313725490196079,.407843137254902,.6705882352941176,.6039215686274509,.407843137254902,1,.3725490196078431,.2,.5019607843137255],Name:"Cool",NanColor:[.3725490196078431,.2,.5019607843137255]},{IndexedColors:[.2313725490196079,.407843137254902,.6705882352941176,.1098039215686274,.5843137254901961,.803921568627451,.3058823529411765,.8509803921568627,.9176470588235294,.4509803921568628,.6039215686274509,.8352941176470589,.2588235294117647,.2392156862745098,.6627450980392157,.3137254901960784,.3294117647058823,.5294117647058824,.06274509803921569,.1647058823529412,.3215686274509804],Name:"Blues",NanColor:[.06274509803921569,.1647058823529412,.3215686274509804]},{IndexedColors:[.1098039215686274,.5843137254901961,.803921568627451,.2313725490196079,.407843137254902,.6705882352941176,.4,.2431372549019608,.7176470588235294,.6352941176470588,.3294117647058823,.8117647058823529,.8705882352941177,.3803921568627451,.807843137254902,.8627450980392157,.3803921568627451,.5843137254901961,.2392156862745098,.06274509803921569,.3215686274509804],Name:"Wild Flower",NanColor:[.2392156862745098,.06274509803921569,.3215686274509804]},{IndexedColors:[.396078431372549,.4862745098039216,.2156862745098039,.4588235294117647,.6941176470588235,.00392156862745098,.6980392156862745,.7294117647058823,.1882352941176471,1,.8980392156862745,.02352941176470588,1,.7058823529411765,0,.9764705882352941,.5137254901960784,.1411764705882353],Name:"Citrus",NanColor:[.9764705882352941,.5137254901960784,.1411764705882353]},{IndexedColors:[.4980392156862745,.2313725490196079,.03137254901960784,.7019607843137254,.3450980392156863,.02352941176470588,.8784313725490196,.5098039215686274,.0784313725490196,.9921568627450981,.7215686274509804,.3882352941176471,.996078431372549,.8784313725490196,.7137254901960784,.9686274509803922,.9686274509803922,.9686274509803922,.8470588235294118,.8549019607843137,.9215686274509803,.6980392156862745,.6705882352941176,.8235294117647058,.5019607843137255,.4509803921568628,.6745098039215687,.3294117647058823,.1529411764705882,.5333333333333333,.1764705882352941,0,.2941176470588235],Name:"Brewer Diverging Purple-Orange (11)",NanColor:[.1764705882352941,0,.2941176470588235]},{IndexedColors:[.4980392156862745,.2313725490196079,.03137254901960784,.7019607843137254,.3450980392156863,.02352941176470588,.8784313725490196,.5098039215686274,.0784313725490196,.9921568627450981,.7215686274509804,.3882352941176471,.996078431372549,.8784313725490196,.7137254901960784,.8470588235294118,.8549019607843137,.9215686274509803,.6980392156862745,.6705882352941176,.8235294117647058,.5019607843137255,.4509803921568628,.6745098039215687,.3294117647058823,.1529411764705882,.5333333333333333,.1764705882352941,0,.2941176470588235],Name:"Brewer Diverging Purple-Orange (10)",NanColor:[.1764705882352941,0,.2941176470588235]},{IndexedColors:[.7019607843137254,.3450980392156863,.02352941176470588,.8784313725490196,.5098039215686274,.0784313725490196,.9921568627450981,.7215686274509804,.3882352941176471,.996078431372549,.8784313725490196,.7137254901960784,.9686274509803922,.9686274509803922,.9686274509803922,.8470588235294118,.8549019607843137,.9215686274509803,.6980392156862745,.6705882352941176,.8235294117647058,.5019607843137255,.4509803921568628,.6745098039215687,.3294117647058823,.1529411764705882,.5333333333333333],Name:"Brewer Diverging Purple-Orange (9)",NanColor:[.3294117647058823,.1529411764705882,.5333333333333333]},{IndexedColors:[.7019607843137254,.3450980392156863,.02352941176470588,.8784313725490196,.5098039215686274,.0784313725490196,.9921568627450981,.7215686274509804,.3882352941176471,.996078431372549,.8784313725490196,.7137254901960784,.8470588235294118,.8549019607843137,.9215686274509803,.6980392156862745,.6705882352941176,.8235294117647058,.5019607843137255,.4509803921568628,.6745098039215687,.3294117647058823,.1529411764705882,.5333333333333333],Name:"Brewer Diverging Purple-Orange (8)",NanColor:[.3294117647058823,.1529411764705882,.5333333333333333]},{IndexedColors:[.7019607843137254,.3450980392156863,.02352941176470588,.9450980392156862,.6392156862745098,.2509803921568627,.996078431372549,.8784313725490196,.7137254901960784,.9686274509803922,.9686274509803922,.9686274509803922,.8470588235294118,.8549019607843137,.9215686274509803,.6,.5568627450980392,.7647058823529411,.3294117647058823,.1529411764705882,.5333333333333333],Name:"Brewer Diverging Purple-Orange (7)",NanColor:[.3294117647058823,.1529411764705882,.5333333333333333]},{IndexedColors:[.7019607843137254,.3450980392156863,.02352941176470588,.9450980392156862,.6392156862745098,.2509803921568627,.996078431372549,.8784313725490196,.7137254901960784,.8470588235294118,.8549019607843137,.9215686274509803,.6,.5568627450980392,.7647058823529411,.3294117647058823,.1529411764705882,.5333333333333333],Name:"Brewer Diverging Purple-Orange (6)",NanColor:[.3294117647058823,.1529411764705882,.5333333333333333]},{IndexedColors:[.9019607843137255,.3803921568627451,.00392156862745098,.9921568627450981,.7215686274509804,.3882352941176471,.9686274509803922,.9686274509803922,.9686274509803922,.6980392156862745,.6705882352941176,.8235294117647058,.3686274509803922,.2352941176470588,.6],Name:"Brewer Diverging Purple-Orange (5)",NanColor:[.3686274509803922,.2352941176470588,.6]},{IndexedColors:[.9019607843137255,.3803921568627451,.00392156862745098,.9921568627450981,.7215686274509804,.3882352941176471,.6980392156862745,.6705882352941176,.8235294117647058,.3686274509803922,.2352941176470588,.6],Name:"Brewer Diverging Purple-Orange (4)",NanColor:[.3686274509803922,.2352941176470588,.6]},{IndexedColors:[.9450980392156862,.6392156862745098,.2509803921568627,.9686274509803922,.9686274509803922,.9686274509803922,.6,.5568627450980392,.7647058823529411],Name:"Brewer Diverging Purple-Orange (3)",NanColor:[.6,.5568627450980392,.7647058823529411]},{IndexedColors:[.6196078431372549,.00392156862745098,.2588235294117647,.8352941176470589,.2431372549019608,.3098039215686275,.9568627450980393,.4274509803921568,.2627450980392157,.9921568627450981,.6823529411764706,.3803921568627451,.996078431372549,.8784313725490196,.5450980392156862,1,1,.7490196078431373,.9019607843137255,.9607843137254902,.596078431372549,.6705882352941176,.8666666666666667,.6431372549019608,.4,.7607843137254902,.6470588235294118,.196078431372549,.5333333333333333,.7411764705882353,.3686274509803922,.3098039215686275,.6352941176470588],Name:"Brewer Diverging Spectral (11)",NanColor:[.3686274509803922,.3098039215686275,.6352941176470588]},{IndexedColors:[.6196078431372549,.00392156862745098,.2588235294117647,.8352941176470589,.2431372549019608,.3098039215686275,.9568627450980393,.4274509803921568,.2627450980392157,.9921568627450981,.6823529411764706,.3803921568627451,.996078431372549,.8784313725490196,.5450980392156862,.9019607843137255,.9607843137254902,.596078431372549,.6705882352941176,.8666666666666667,.6431372549019608,.4,.7607843137254902,.6470588235294118,.196078431372549,.5333333333333333,.7411764705882353,.3686274509803922,.3098039215686275,.6352941176470588],Name:"Brewer Diverging Spectral (10)",NanColor:[.3686274509803922,.3098039215686275,.6352941176470588]},{IndexedColors:[.8352941176470589,.2431372549019608,.3098039215686275,.9568627450980393,.4274509803921568,.2627450980392157,.9921568627450981,.6823529411764706,.3803921568627451,.996078431372549,.8784313725490196,.5450980392156862,1,1,.7490196078431373,.9019607843137255,.9607843137254902,.596078431372549,.6705882352941176,.8666666666666667,.6431372549019608,.4,.7607843137254902,.6470588235294118,.196078431372549,.5333333333333333,.7411764705882353],Name:"Brewer Diverging Spectral (9)",NanColor:[.196078431372549,.5333333333333333,.7411764705882353]},{IndexedColors:[.8352941176470589,.2431372549019608,.3098039215686275,.9568627450980393,.4274509803921568,.2627450980392157,.9921568627450981,.6823529411764706,.3803921568627451,.996078431372549,.8784313725490196,.5450980392156862,.9019607843137255,.9607843137254902,.596078431372549,.6705882352941176,.8666666666666667,.6431372549019608,.4,.7607843137254902,.6470588235294118,.196078431372549,.5333333333333333,.7411764705882353],Name:"Brewer Diverging Spectral (8)",NanColor:[.196078431372549,.5333333333333333,.7411764705882353]},{IndexedColors:[.8352941176470589,.2431372549019608,.3098039215686275,.9882352941176471,.5529411764705883,.3490196078431372,.996078431372549,.8784313725490196,.5450980392156862,1,1,.7490196078431373,.9019607843137255,.9607843137254902,.596078431372549,.6,.8352941176470589,.5803921568627451,.196078431372549,.5333333333333333,.7411764705882353],Name:"Brewer Diverging Spectral (7)",NanColor:[.196078431372549,.5333333333333333,.7411764705882353]},{IndexedColors:[.8352941176470589,.2431372549019608,.3098039215686275,.9882352941176471,.5529411764705883,.3490196078431372,.996078431372549,.8784313725490196,.5450980392156862,.9019607843137255,.9607843137254902,.596078431372549,.6,.8352941176470589,.5803921568627451,.196078431372549,.5333333333333333,.7411764705882353],Name:"Brewer Diverging Spectral (6)",NanColor:[.196078431372549,.5333333333333333,.7411764705882353]},{IndexedColors:[.8431372549019608,.09803921568627451,.1098039215686274,.9921568627450981,.6823529411764706,.3803921568627451,1,1,.7490196078431373,.6705882352941176,.8666666666666667,.6431372549019608,.1686274509803922,.5137254901960784,.7294117647058823],Name:"Brewer Diverging Spectral (5)",NanColor:[.1686274509803922,.5137254901960784,.7294117647058823]},{IndexedColors:[.8431372549019608,.09803921568627451,.1098039215686274,.9921568627450981,.6823529411764706,.3803921568627451,.6705882352941176,.8666666666666667,.6431372549019608,.1686274509803922,.5137254901960784,.7294117647058823],Name:"Brewer Diverging Spectral (4)",NanColor:[.1686274509803922,.5137254901960784,.7294117647058823]},{IndexedColors:[.9882352941176471,.5529411764705883,.3490196078431372,1,1,.7490196078431373,.6,.8352941176470589,.5803921568627451],Name:"Brewer Diverging Spectral (3)",NanColor:[.6,.8352941176470589,.5803921568627451]},{IndexedColors:[.3294117647058823,.1882352941176471,.0196078431372549,.5490196078431373,.3176470588235294,.0392156862745098,.7490196078431373,.5058823529411764,.1764705882352941,.8745098039215686,.7607843137254902,.4901960784313725,.9647058823529412,.9098039215686274,.7647058823529411,.9607843137254902,.9607843137254902,.9607843137254902,.7803921568627451,.9176470588235294,.8980392156862745,.5019607843137255,.803921568627451,.7568627450980392,.207843137254902,.592156862745098,.5607843137254902,.00392156862745098,.4,.3686274509803922,0,.2352941176470588,.1882352941176471],Name:"Brewer Diverging Brown-Blue-Green (11)",NanColor:[0,.2352941176470588,.1882352941176471]},{IndexedColors:[.3294117647058823,.1882352941176471,.0196078431372549,.5490196078431373,.3176470588235294,.0392156862745098,.7490196078431373,.5058823529411764,.1764705882352941,.8745098039215686,.7607843137254902,.4901960784313725,.9647058823529412,.9098039215686274,.7647058823529411,.7803921568627451,.9176470588235294,.8980392156862745,.5019607843137255,.803921568627451,.7568627450980392,.207843137254902,.592156862745098,.5607843137254902,.00392156862745098,.4,.3686274509803922,0,.2352941176470588,.1882352941176471],Name:"Brewer Diverging Brown-Blue-Green (10)",NanColor:[0,.2352941176470588,.1882352941176471]},{IndexedColors:[.5490196078431373,.3176470588235294,.0392156862745098,.7490196078431373,.5058823529411764,.1764705882352941,.8745098039215686,.7607843137254902,.4901960784313725,.9647058823529412,.9098039215686274,.7647058823529411,.9607843137254902,.9607843137254902,.9607843137254902,.7803921568627451,.9176470588235294,.8980392156862745,.5019607843137255,.803921568627451,.7568627450980392,.207843137254902,.592156862745098,.5607843137254902,.00392156862745098,.4,.3686274509803922],Name:"Brewer Diverging Brown-Blue-Green (9)",NanColor:[.00392156862745098,.4,.3686274509803922]},{IndexedColors:[.5490196078431373,.3176470588235294,.0392156862745098,.7490196078431373,.5058823529411764,.1764705882352941,.8745098039215686,.7607843137254902,.4901960784313725,.9647058823529412,.9098039215686274,.7647058823529411,.7803921568627451,.9176470588235294,.8980392156862745,.5019607843137255,.803921568627451,.7568627450980392,.207843137254902,.592156862745098,.5607843137254902,.00392156862745098,.4,.3686274509803922],Name:"Brewer Diverging Brown-Blue-Green (8)",NanColor:[.00392156862745098,.4,.3686274509803922]},{IndexedColors:[.5490196078431373,.3176470588235294,.0392156862745098,.8470588235294118,.7019607843137254,.396078431372549,.9647058823529412,.9098039215686274,.7647058823529411,.9607843137254902,.9607843137254902,.9607843137254902,.7803921568627451,.9176470588235294,.8980392156862745,.3529411764705883,.7058823529411765,.6745098039215687,.00392156862745098,.4,.3686274509803922],Name:"Brewer Diverging Brown-Blue-Green (7)",NanColor:[.00392156862745098,.4,.3686274509803922]},{IndexedColors:[.5490196078431373,.3176470588235294,.0392156862745098,.8470588235294118,.7019607843137254,.396078431372549,.9647058823529412,.9098039215686274,.7647058823529411,.7803921568627451,.9176470588235294,.8980392156862745,.3529411764705883,.7058823529411765,.6745098039215687,.00392156862745098,.4,.3686274509803922],Name:"Brewer Diverging Brown-Blue-Green (6)",NanColor:[.00392156862745098,.4,.3686274509803922]},{IndexedColors:[.6509803921568628,.3803921568627451,.1019607843137255,.8745098039215686,.7607843137254902,.4901960784313725,.9607843137254902,.9607843137254902,.9607843137254902,.5019607843137255,.803921568627451,.7568627450980392,.00392156862745098,.5215686274509804,.4431372549019608],Name:"Brewer Diverging Brown-Blue-Green (5)",NanColor:[.00392156862745098,.5215686274509804,.4431372549019608]},{IndexedColors:[.6509803921568628,.3803921568627451,.1019607843137255,.8745098039215686,.7607843137254902,.4901960784313725,.5019607843137255,.803921568627451,.7568627450980392,.00392156862745098,.5215686274509804,.4431372549019608],Name:"Brewer Diverging Brown-Blue-Green (4)",NanColor:[.00392156862745098,.5215686274509804,.4431372549019608]},{IndexedColors:[.8470588235294118,.7019607843137254,.396078431372549,.9607843137254902,.9607843137254902,.9607843137254902,.3529411764705883,.7058823529411765,.6745098039215687],Name:"Brewer Diverging Brown-Blue-Green (3)",NanColor:[.3529411764705883,.7058823529411765,.6745098039215687]},{IndexedColors:[.9686274509803922,.9882352941176471,.9921568627450981,.8980392156862745,.9607843137254902,.9764705882352941,.8,.9254901960784314,.9019607843137255,.6,.8470588235294118,.788235294117647,.4,.7607843137254902,.6431372549019608,.2549019607843137,.6823529411764706,.4627450980392157,.1372549019607843,.5450980392156862,.2705882352941176,0,.4274509803921568,.1725490196078431,0,.2666666666666667,.1058823529411765],Name:"Brewer Sequential Blue-Green (9)",NanColor:[0,.2666666666666667,.1058823529411765]},{IndexedColors:[.9686274509803922,.9882352941176471,.9921568627450981,.8980392156862745,.9607843137254902,.9764705882352941,.8,.9254901960784314,.9019607843137255,.6,.8470588235294118,.788235294117647,.4,.7607843137254902,.6431372549019608,.2549019607843137,.6823529411764706,.4627450980392157,.1372549019607843,.5450980392156862,.2705882352941176,0,.3450980392156863,.1411764705882353],Name:"Brewer Sequential Blue-Green (8)",NanColor:[0,.3450980392156863,.1411764705882353]},{IndexedColors:[.9294117647058824,.9725490196078431,.984313725490196,.8,.9254901960784314,.9019607843137255,.8,.9254901960784314,.9019607843137255,.4,.7607843137254902,.6431372549019608,.2549019607843137,.6823529411764706,.4627450980392157,.1372549019607843,.5450980392156862,.2705882352941176,0,.3450980392156863,.1411764705882353],Name:"Brewer Sequential Blue-Green (7)",NanColor:[0,.3450980392156863,.1411764705882353]},{IndexedColors:[.9294117647058824,.9725490196078431,.984313725490196,.8,.9254901960784314,.9019607843137255,.6,.8470588235294118,.788235294117647,.4,.7607843137254902,.6431372549019608,.1725490196078431,.6352941176470588,.3725490196078431,0,.4274509803921568,.1725490196078431],Name:"Brewer Sequential Blue-Green (6)",NanColor:[0,.4274509803921568,.1725490196078431]},{IndexedColors:[.9294117647058824,.9725490196078431,.984313725490196,.6980392156862745,.8862745098039215,.8862745098039215,.4,.7607843137254902,.6431372549019608,.1725490196078431,.6352941176470588,.3725490196078431,0,.4274509803921568,.1725490196078431],Name:"Brewer Sequential Blue-Green (5)",NanColor:[0,.4274509803921568,.1725490196078431]},{IndexedColors:[.9294117647058824,.9725490196078431,.984313725490196,.6980392156862745,.8862745098039215,.8862745098039215,.4,.7607843137254902,.6431372549019608,.1372549019607843,.5450980392156862,.2705882352941176],Name:"Brewer Sequential Blue-Green (4)",NanColor:[.1372549019607843,.5450980392156862,.2705882352941176]},{IndexedColors:[.8980392156862745,.9607843137254902,.9764705882352941,.6,.8470588235294118,.788235294117647,.1725490196078431,.6352941176470588,.3725490196078431],Name:"Brewer Sequential Blue-Green (3)",NanColor:[.1725490196078431,.6352941176470588,.3725490196078431]},{IndexedColors:[1,1,.8980392156862745,1,.9686274509803922,.7372549019607844,.996078431372549,.8901960784313725,.5686274509803921,.996078431372549,.7686274509803922,.3098039215686275,.996078431372549,.6,.1607843137254902,.9254901960784314,.4392156862745098,.0784313725490196,.8,.2980392156862745,.00784313725490196,.6,.203921568627451,.01568627450980392,.4,.1450980392156863,.02352941176470588],Name:"Brewer Sequential Yellow-Orange-Brown (9)",NanColor:[.4,.1450980392156863,.02352941176470588]},{IndexedColors:[1,1,.8980392156862745,1,.9686274509803922,.7372549019607844,.996078431372549,.8901960784313725,.5686274509803921,.996078431372549,.7686274509803922,.3098039215686275,.996078431372549,.6,.1607843137254902,.9254901960784314,.4392156862745098,.0784313725490196,.8,.2980392156862745,.00784313725490196,.5490196078431373,.1764705882352941,.01568627450980392],Name:"Brewer Sequential Yellow-Orange-Brown (8)",NanColor:[.5490196078431373,.1764705882352941,.01568627450980392]},{IndexedColors:[1,1,.8313725490196079,.996078431372549,.8901960784313725,.5686274509803921,.996078431372549,.7686274509803922,.3098039215686275,.996078431372549,.6,.1607843137254902,.9254901960784314,.4392156862745098,.0784313725490196,.8,.2980392156862745,.00784313725490196,.5490196078431373,.1764705882352941,.01568627450980392],Name:"Brewer Sequential Yellow-Orange-Brown (7)",NanColor:[.5490196078431373,.1764705882352941,.01568627450980392]},{IndexedColors:[1,1,.8313725490196079,.996078431372549,.8901960784313725,.5686274509803921,.996078431372549,.7686274509803922,.3098039215686275,.996078431372549,.6,.1607843137254902,.8509803921568627,.3725490196078431,.05490196078431372,.6,.203921568627451,.01568627450980392],Name:"Brewer Sequential Yellow-Orange-Brown (6)",NanColor:[.6,.203921568627451,.01568627450980392]},{IndexedColors:[1,1,.8313725490196079,.996078431372549,.8509803921568627,.5568627450980392,.996078431372549,.6,.1607843137254902,.8509803921568627,.3725490196078431,.05490196078431372,.6,.203921568627451,.01568627450980392],Name:"Brewer Sequential Yellow-Orange-Brown (5)",NanColor:[.6,.203921568627451,.01568627450980392]},{IndexedColors:[1,1,.8313725490196079,.996078431372549,.8509803921568627,.5568627450980392,.996078431372549,.6,.1607843137254902,.8,.2980392156862745,.00784313725490196],Name:"Brewer Sequential Yellow-Orange-Brown (4)",NanColor:[.8,.2980392156862745,.00784313725490196]},{IndexedColors:[1,.9686274509803922,.7372549019607844,.996078431372549,.7686274509803922,.3098039215686275,.8509803921568627,.3725490196078431,.05490196078431372],Name:"Brewer Sequential Yellow-Orange-Brown (3)",NanColor:[.8509803921568627,.3725490196078431,.05490196078431372]},{IndexedColors:[.9686274509803922,.9882352941176471,.9921568627450981,.8784313725490196,.9254901960784314,.9568627450980393,.7490196078431373,.8274509803921568,.9019607843137255,.6196078431372549,.7372549019607844,.8549019607843137,.5490196078431373,.5882352941176471,.7764705882352941,.5490196078431373,.4196078431372549,.6941176470588235,.5333333333333333,.2549019607843137,.615686274509804,.5058823529411764,.05882352941176471,.4862745098039216,.3019607843137255,0,.2941176470588235],Name:"Brewer Sequential Blue-Purple (9)",NanColor:[.3019607843137255,0,.2941176470588235]},{IndexedColors:[.9686274509803922,.9882352941176471,.9921568627450981,.8784313725490196,.9254901960784314,.9568627450980393,.7490196078431373,.8274509803921568,.9019607843137255,.6196078431372549,.7372549019607844,.8549019607843137,.5490196078431373,.5882352941176471,.7764705882352941,.5490196078431373,.4196078431372549,.6941176470588235,.5333333333333333,.2549019607843137,.615686274509804,.4313725490196079,.00392156862745098,.4196078431372549],Name:"Brewer Sequential Blue-Purple (8)",NanColor:[.4313725490196079,.00392156862745098,.4196078431372549]},{IndexedColors:[.9294117647058824,.9725490196078431,.984313725490196,.7490196078431373,.8274509803921568,.9019607843137255,.6196078431372549,.7372549019607844,.8549019607843137,.5490196078431373,.5882352941176471,.7764705882352941,.5490196078431373,.4196078431372549,.6941176470588235,.5333333333333333,.2549019607843137,.615686274509804,.4313725490196079,.00392156862745098,.4196078431372549],Name:"Brewer Sequential Blue-Purple (7)",NanColor:[.4313725490196079,.00392156862745098,.4196078431372549]},{IndexedColors:[.9294117647058824,.9725490196078431,.984313725490196,.7490196078431373,.8274509803921568,.9019607843137255,.6196078431372549,.7372549019607844,.8549019607843137,.5490196078431373,.5882352941176471,.7764705882352941,.5333333333333333,.3372549019607843,.6549019607843137,.5058823529411764,.05882352941176471,.4862745098039216],Name:"Brewer Sequential Blue-Purple (6)",NanColor:[.5058823529411764,.05882352941176471,.4862745098039216]},{IndexedColors:[.9294117647058824,.9725490196078431,.984313725490196,.7019607843137254,.803921568627451,.8901960784313725,.5490196078431373,.5882352941176471,.7764705882352941,.5333333333333333,.3372549019607843,.6549019607843137,.5058823529411764,.05882352941176471,.4862745098039216],Name:"Brewer Sequential Blue-Purple (5)",NanColor:[.5058823529411764,.05882352941176471,.4862745098039216]},{IndexedColors:[.9294117647058824,.9725490196078431,.984313725490196,.7019607843137254,.803921568627451,.8901960784313725,.5490196078431373,.5882352941176471,.7764705882352941,.5333333333333333,.2549019607843137,.615686274509804],Name:"Brewer Sequential Blue-Purple (4)",NanColor:[.5333333333333333,.2549019607843137,.615686274509804]},{IndexedColors:[.8784313725490196,.9254901960784314,.9568627450980393,.6196078431372549,.7372549019607844,.8549019607843137,.5333333333333333,.3372549019607843,.6549019607843137],Name:"Brewer Sequential Blue-Purple (3)",NanColor:[.5333333333333333,.3372549019607843,.6549019607843137]},{IndexedColors:[.4980392156862745,.788235294117647,.4980392156862745,.7450980392156863,.6823529411764706,.8313725490196079,.9921568627450981,.7529411764705882,.5254901960784314,1,1,.6,.2196078431372549,.4235294117647059,.6901960784313725,.9411764705882353,.00784313725490196,.4980392156862745,.7490196078431373,.3568627450980392,.09019607843137255,.4,.4,.4],Name:"Brewer Qualitative Accent",NanColor:[.4,.4,.4]},{IndexedColors:[.1058823529411765,.6196078431372549,.4666666666666667,.8509803921568627,.3725490196078431,.00784313725490196,.4588235294117647,.4392156862745098,.7019607843137254,.9058823529411765,.1607843137254902,.5411764705882353,.4,.6509803921568628,.1176470588235294,.9019607843137255,.6705882352941176,.00784313725490196,.6509803921568628,.4627450980392157,.1137254901960784,.4,.4,.4],Name:"Brewer Qualitative Dark2",NanColor:[.4,.4,.4]},{IndexedColors:[.4,.7607843137254902,.6470588235294118,.9882352941176471,.5529411764705883,.3843137254901961,.5529411764705883,.6274509803921569,.796078431372549,.9058823529411765,.5411764705882353,.7647058823529411,.6509803921568628,.8470588235294118,.3294117647058823,1,.8509803921568627,.1843137254901961,.8980392156862745,.7686274509803922,.5803921568627451,.7019607843137254,.7019607843137254,.7019607843137254],Name:"Brewer Qualitative Set2",NanColor:[.7019607843137254,.7019607843137254,.7019607843137254]},{IndexedColors:[.7019607843137254,.8862745098039215,.803921568627451,.9921568627450981,.803921568627451,.6745098039215687,.796078431372549,.8352941176470589,.9098039215686274,.9568627450980393,.792156862745098,.8941176470588236,.9019607843137255,.9607843137254902,.788235294117647,1,.9490196078431372,.6823529411764706,.9450980392156862,.8862745098039215,.8,.8,.8,.8],Name:"Brewer Qualitative Pastel2",NanColor:[.8,.8,.8]},{IndexedColors:[.984313725490196,.7058823529411765,.6823529411764706,.7019607843137254,.803921568627451,.8901960784313725,.8,.9215686274509803,.7725490196078432,.8705882352941177,.796078431372549,.8941176470588236,.996078431372549,.8509803921568627,.6509803921568628,1,1,.8,.8980392156862745,.8470588235294118,.7411764705882353,.9921568627450981,.8549019607843137,.9254901960784314,.9490196078431372,.9490196078431372,.9490196078431372],Name:"Brewer Qualitative Pastel1",NanColor:[.9490196078431372,.9490196078431372,.9490196078431372]},{IndexedColors:[.8941176470588236,.1019607843137255,.1098039215686274,.2156862745098039,.4941176470588236,.7215686274509804,.3019607843137255,.6862745098039216,.2901960784313726,.596078431372549,.3058823529411765,.6392156862745098,1,.4980392156862745,0,1,1,.2,.6509803921568628,.3372549019607843,.1568627450980392,.9686274509803922,.5058823529411764,.7490196078431373,.6,.6,.6],Name:"Brewer Qualitative Set1",NanColor:[.6,.6,.6]},{IndexedColors:[.6509803921568628,.807843137254902,.8901960784313725,.1215686274509804,.4705882352941176,.7058823529411765,.6980392156862745,.8745098039215686,.5411764705882353,.2,.6274509803921569,.1725490196078431,.984313725490196,.6039215686274509,.6,.8901960784313725,.1019607843137255,.1098039215686274,.9921568627450981,.7490196078431373,.4352941176470588,1,.4980392156862745,0,.792156862745098,.6980392156862745,.8392156862745098,.4156862745098039,.2392156862745098,.6039215686274509,1,1,.6],Name:"Brewer Qualitative Paired",NanColor:[1,1,.6]},{IndexedColors:[.5529411764705883,.8274509803921568,.7803921568627451,1,1,.7019607843137254,.7450980392156863,.7294117647058823,.8549019607843137,.984313725490196,.5019607843137255,.4470588235294118,.5019607843137255,.6941176470588235,.8274509803921568,.9921568627450981,.7058823529411765,.3843137254901961,.7019607843137254,.8705882352941177,.4117647058823529,.9882352941176471,.803921568627451,.8980392156862745,.8509803921568627,.8509803921568627,.8509803921568627,.7372549019607844,.5019607843137255,.7411764705882353,.8,.9215686274509803,.7725490196078432,1,.9294117647058824,.4352941176470588],Name:"Brewer Qualitative Set3",NanColor:[1,.9294117647058824,.4352941176470588]},{IndexedColors:[1,0,0,1,.862745,0,0,.695201,0],Name:"Traffic Lights",NanColor:[.803922,0,.803922]},{IndexedColors:[.908659,.604013,.581857,1,.862745,0,0,.695201,0],Name:"Traffic Lights For Deuteranopes",NanColor:[.803922,0,.803922]},{IndexedColors:[.4196078431372549,0,.07058823529411765,.9019607843137255,.9411764705882353,.0196078431372549,.01568627450980392,.6196078431372549,.00784313725490196],Name:"Traffic Lights For Deuteranopes 2",NanColor:[.803922,0,.803922]},{ColorSpace:"Lab",Creator:"Francesca Samsel",Name:"Muted Blue-Green",NanColor:[.25,0,0],RGBPoints:[0,.109804,.27451,.301961,.02,.129412,.309804,.341176,.05,.14902,.341176,.380392,.1,.188235,.403922,.458824,.15,.227451,.447059,.521569,.2,.290196,.494118,.588235,.25,.368627,.552941,.670588,.3,.458824,.619608,.74902,.35,.588235,.713725,.85098,.4,.72549,.815686,.941176,.45,.831373,.882353,.980392,.475,.909804,.933333,1,.5,.980392,.984314,1,.5,.996078,1,.94902,.5,1,1,.980392,.5,.980392,.984314,1,.525,.972549,.988235,.890196,.55,.917647,.960784,.835294,.6,.835294,.921569,.772549,.65,.768627,.901961,.737255,.7,.670588,.831373,.654902,.75,.576471,.760784,.584314,.8,.498039,.678431,.521569,.85,.392157,.560784,.427451,.9,.294118,.45098,.333333,.95,.211765,.34902,.254902,1,.152941,.278431,.196078]},{ColorSpace:"Lab",Creator:"Francesca Samsel",Name:"Green-Blue Asymmetric Divergent (62Blbc)",NanColor:[.25,0,0],RGBPoints:[0,.121569,.2,.145098,.05,.196078,.301961,.223529,.1,.258824,.4,.278431,.2,.341176,.54902,.341176,.25,.419608,.619608,.376471,.3,.545098,.701961,.392157,.35,.643137,.780392,.403922,.4,.729412,.819608,.45098,.45,.811765,.870588,.521569,.5,.898039,.909804,.564706,.55,.941176,.92549,.686275,.6,.960784,.94902,.776471,.64,1,1,1,.65,.890196,.988235,.972549,.7,.721569,.894118,.901961,.75,.631373,.823529,.839216,.8,.517647,.662745,.701961,.85,.384314,.494118,.54902,.9,.298039,.360784,.45098,.95,.223529,.25098,.34902,.99,.156863,.172549,.25098,1,.137255,.137255,.188235]},{ColorSpace:"Lab",Creator:"Francesca Samsel",Name:"Asymmtrical Earth Tones (6_21b)",NanColor:[.25,0,0],RGBPoints:[0,.141176,.14902,.2,.05,.215686,.258824,.321569,.1,.243137,.368627,.380392,.15,.27451,.439216,.4,.2,.32549,.501961,.384314,.25,.403922,.6,.419608,.3,.486275,.701961,.454902,.35,.556863,.74902,.494118,.4,.670588,.8,.545098,.5,.854902,.901961,.631373,.55,.92549,.941176,.694118,.6,.960784,.94902,.776471,.65,.988235,.968627,.909804,.7,.839216,.815686,.772549,.75,.701961,.662745,.615686,.8,.6,.529412,.478431,.85,.501961,.403922,.360784,.9,.439216,.313725,.290196,1,.301961,.164706,.176471]},{ColorSpace:"Lab",Creator:"Francesca Samsel",Name:"Yellow 15",NanColor:[.25,0,0],RGBPoints:[0,1,1,.988235,.002,1,1,.988235,.05,.984314,.988235,.843137,.1,.988235,.988235,.741176,.15,.980392,.968627,.654902,.2,.980392,.945098,.576471,.25,.968627,.905882,.486275,.3,.968627,.862745,.388235,.35,.960784,.803922,.286275,.4,.94902,.741176,.219608,.45,.941176,.678431,.14902,.5,.929412,.607843,.094118,.55,.921569,.545098,.054902,.6,.909804,.486275,.035294,.65,.890196,.411765,.019608,.7,.8,.305882,0,.75,.760784,.239216,0,.8,.678431,.180392,.011765,.85,.6,.121569,.023529,.9,.501961,.054902,.031373,.95,.4,.039216,.058824,1,.301961,.047059,.090196]},{ColorSpace:"Diverging",Name:"Magma (matplotlib)",NanColor:[0,1,0],Source:"https://github.com/BIDS/colormap/blob/master/colormaps.py",License:"CC0",Creator:"Nathaniel J. Smith & Stefan van der Walt",RGBPoints:[0,.001462,466e-6,.013866,.003922,.002258,.001295,.018331,.007843,.003279,.002305,.023708,.011765,.004512,.00349,.029965,.015686,.00595,.004843,.03713,.019608,.007588,.006356,.044973,.023529,.009426,.008022,.052844,.027451,.011465,.009828,.06075,.031373,.013708,.011771,.068667,.035294,.016156,.01384,.076603,.039216,.018815,.016026,.084584,.043137,.021692,.01832,.09261,.047059,.024792,.020715,.100676,.05098,.028123,.023201,.108787,.054902,.031696,.025765,.116965,.058824,.03552,.028397,.125209,.062745,.039608,.03109,.133515,.066667,.04383,.03383,.141886,.070588,.048062,.036607,.150327,.07451,.05232,.039407,.158841,.078431,.056615,.04216,.167446,.082353,.060949,.044794,.176129,.086275,.06533,.047318,.184892,.090196,.069764,.049726,.193735,.094118,.074257,.052017,.20266,.098039,.078815,.054184,.211667,.101961,.083446,.056225,.220755,.105882,.088155,.058133,.229922,.109804,.092949,.059904,.239164,.113725,.097833,.061531,.248477,.117647,.102815,.06301,.257854,.121569,.107899,.064335,.267289,.12549,.113094,.065492,.276784,.129412,.118405,.066479,.286321,.133333,.123833,.067295,.295879,.137255,.12938,.067935,.305443,.141176,.135053,.068391,.315,.145098,.140858,.068654,.324538,.14902,.146785,.068738,.334011,.152941,.152839,.068637,.343404,.156863,.159018,.068354,.352688,.160784,.165308,.067911,.361816,.164706,.171713,.067305,.370771,.168627,.178212,.066576,.379497,.172549,.184801,.065732,.387973,.176471,.19146,.064818,.396152,.180392,.198177,.063862,.404009,.184314,.204935,.062907,.411514,.188235,.211718,.061992,.418647,.192157,.218512,.061158,.425392,.196078,.225302,.060445,.431742,.2,.232077,.059889,.437695,.203922,.238826,.059517,.443256,.207843,.245543,.059352,.448436,.211765,.25222,.059415,.453248,.215686,.258857,.059706,.45771,.219608,.265447,.060237,.46184,.223529,.271994,.060994,.46566,.227451,.278493,.061978,.46919,.231373,.284951,.063168,.472451,.235294,.291366,.064553,.475462,.239216,.29774,.066117,.478243,.243137,.304081,.067835,.480812,.247059,.310382,.069702,.483186,.25098,.316654,.07169,.48538,.254902,.322899,.073782,.487408,.258824,.329114,.075972,.489287,.262745,.335308,.078236,.491024,.266667,.341482,.080564,.492631,.270588,.347636,.082946,.494121,.27451,.353773,.085373,.495501,.278431,.359898,.087831,.496778,.282353,.366012,.090314,.49796,.286275,.372116,.092816,.499053,.290196,.378211,.095332,.500067,.294118,.384299,.097855,.501002,.298039,.390384,.100379,.501864,.301961,.396467,.102902,.502658,.305882,.402548,.10542,.503386,.309804,.408629,.10793,.504052,.313725,.414709,.110431,.504662,.317647,.420791,.11292,.505215,.321569,.426877,.115395,.505714,.32549,.432967,.117855,.50616,.329412,.439062,.120298,.506555,.333333,.445163,.122724,.506901,.337255,.451271,.125132,.507198,.341176,.457386,.127522,.507448,.345098,.463508,.129893,.507652,.34902,.46964,.132245,.507809,.352941,.47578,.134577,.507921,.356863,.481929,.136891,.507989,.360784,.488088,.139186,.508011,.364706,.494258,.141462,.507988,.368627,.500438,.143719,.50792,.372549,.506629,.145958,.507806,.376471,.512831,.148179,.507648,.380392,.519045,.150383,.507443,.384314,.52527,.152569,.507192,.388235,.531507,.154739,.506895,.392157,.537755,.156894,.506551,.396078,.544015,.159033,.506159,.4,.550287,.161158,.505719,.403922,.556571,.163269,.50523,.407843,.562866,.165368,.504692,.411765,.569172,.167454,.504105,.415686,.57549,.16953,.503466,.419608,.581819,.171596,.502777,.423529,.588158,.173652,.502035,.427451,.594508,.175701,.501241,.431373,.600868,.177743,.500394,.435294,.607238,.179779,.499492,.439216,.613617,.181811,.498536,.443137,.620005,.18384,.497524,.447059,.626401,.185867,.496456,.45098,.632805,.187893,.495332,.454902,.639216,.189921,.49415,.458824,.645633,.191952,.49291,.462745,.652056,.193986,.491611,.466667,.658483,.196027,.490253,.470588,.664915,.198075,.488836,.47451,.671349,.200133,.487358,.478431,.677786,.202203,.485819,.482353,.684224,.204286,.484219,.486275,.690661,.206384,.482558,.490196,.697098,.208501,.480835,.494118,.703532,.210638,.479049,.498039,.709962,.212797,.477201,.501961,.716387,.214982,.47529,.505882,.722805,.217194,.473316,.509804,.729216,.219437,.471279,.513725,.735616,.221713,.46918,.517647,.742004,.224025,.467018,.521569,.748378,.226377,.464794,.52549,.754737,.228772,.462509,.529412,.761077,.231214,.460162,.533333,.767398,.233705,.457755,.537255,.773695,.236249,.455289,.541176,.779968,.238851,.452765,.545098,.786212,.241514,.450184,.54902,.792427,.244242,.447543,.552941,.798608,.24704,.444848,.556863,.804752,.249911,.442102,.560784,.810855,.252861,.439305,.564706,.816914,.255895,.436461,.568627,.822926,.259016,.433573,.572549,.828886,.262229,.430644,.576471,.834791,.26554,.427671,.580392,.840636,.268953,.424666,.584314,.846416,.272473,.421631,.588235,.852126,.276106,.418573,.592157,.857763,.279857,.415496,.596078,.86332,.283729,.412403,.6,.868793,.287728,.409303,.603922,.874176,.291859,.406205,.607843,.879464,.296125,.403118,.611765,.884651,.30053,.400047,.615686,.889731,.305079,.397002,.619608,.8947,.309773,.393995,.623529,.899552,.314616,.391037,.627451,.904281,.31961,.388137,.631373,.908884,.324755,.385308,.635294,.913354,.330052,.382563,.639216,.917689,.3355,.379915,.643137,.921884,.341098,.377376,.647059,.925937,.346844,.374959,.65098,.929845,.352734,.372677,.654902,.933606,.358764,.370541,.658824,.937221,.364929,.368567,.662745,.940687,.371224,.366762,.666667,.944006,.377643,.365136,.670588,.94718,.384178,.363701,.67451,.95021,.39082,.362468,.678431,.953099,.397563,.361438,.682353,.955849,.4044,.360619,.686275,.958464,.411324,.360014,.690196,.960949,.418323,.35963,.694118,.96331,.42539,.359469,.698039,.965549,.432519,.359529,.701961,.967671,.439703,.35981,.705882,.96968,.446936,.360311,.709804,.971582,.45421,.36103,.713725,.973381,.46152,.361965,.717647,.975082,.468861,.363111,.721569,.97669,.476226,.364466,.72549,.97821,.483612,.366025,.729412,.979645,.491014,.367783,.733333,.981,.498428,.369734,.737255,.982279,.505851,.371874,.741176,.983485,.51328,.374198,.745098,.984622,.520713,.376698,.74902,.985693,.528148,.379371,.752941,.9867,.535582,.38221,.756863,.987646,.543015,.38521,.760784,.988533,.550446,.388365,.764706,.989363,.557873,.391671,.768627,.990138,.565296,.395122,.772549,.990871,.572706,.398714,.776471,.991558,.580107,.402441,.780392,.992196,.587502,.406299,.784314,.992785,.594891,.410283,.788235,.993326,.602275,.41439,.792157,.993834,.609644,.418613,.796078,.994309,.616999,.42295,.8,.994738,.62435,.427397,.803922,.995122,.631696,.431951,.807843,.99548,.639027,.436607,.811765,.99581,.646344,.441361,.815686,.996096,.653659,.446213,.819608,.996341,.660969,.45116,.823529,.99658,.668256,.456192,.827451,.996775,.675541,.461314,.831373,.996925,.682828,.466526,.835294,.997077,.690088,.471811,.839216,.997186,.697349,.477182,.843137,.997254,.704611,.482635,.847059,.997325,.711848,.488154,.85098,.997351,.719089,.493755,.854902,.997351,.726324,.499428,.858824,.997341,.733545,.505167,.862745,.997285,.740772,.510983,.866667,.997228,.747981,.516859,.870588,.997138,.75519,.522806,.87451,.997019,.762398,.528821,.878431,.996898,.769591,.534892,.882353,.996727,.776795,.541039,.886275,.996571,.783977,.547233,.890196,.996369,.791167,.553499,.894118,.996162,.798348,.55982,.898039,.995932,.805527,.566202,.901961,.99568,.812706,.572645,.905882,.995424,.819875,.57914,.909804,.995131,.827052,.585701,.913725,.994851,.834213,.592307,.917647,.994524,.841387,.598983,.921569,.994222,.84854,.605696,.92549,.993866,.855711,.612482,.929412,.993545,.862859,.619299,.933333,.99317,.870024,.626189,.937255,.992831,.877168,.633109,.941176,.99244,.88433,.640099,.945098,.992089,.89147,.647116,.94902,.991688,.898627,.654202,.952941,.991332,.905763,.661309,.956863,.99093,.912915,.668481,.960784,.99057,.920049,.675675,.964706,.990175,.927196,.682926,.968627,.989815,.934329,.690198,.972549,.989434,.94147,.697519,.976471,.989077,.948604,.704863,.980392,.988717,.955742,.712242,.984314,.988367,.962878,.719649,.988235,.988033,.970012,.727077,.992157,.987691,.977154,.734536,.996078,.987387,.984288,.742002,1,.987053,.991438,.749504]},{ColorSpace:"Diverging",Name:"Inferno (matplotlib)",NanColor:[0,1,0],Source:"https://github.com/BIDS/colormap/blob/master/colormaps.py",License:"CC0",Creator:"Nathaniel J. Smith & Stefan van der Walt",RGBPoints:[0,.001462,466e-6,.013866,.003922,.002267,.00127,.01857,.007843,.003299,.002249,.024239,.011765,.004547,.003392,.030909,.015686,.006006,.004692,.038558,.019608,.007676,.006136,.046836,.023529,.009561,.007713,.055143,.027451,.011663,.009417,.06346,.031373,.013995,.011225,.071862,.035294,.016561,.013136,.080282,.039216,.019373,.015133,.088767,.043137,.022447,.017199,.097327,.047059,.025793,.019331,.10593,.05098,.029432,.021503,.114621,.054902,.033385,.023702,.123397,.058824,.037668,.025921,.132232,.062745,.042253,.028139,.141141,.066667,.046915,.030324,.150164,.070588,.051644,.032474,.159254,.07451,.056449,.034569,.168414,.078431,.06134,.03659,.177642,.082353,.066331,.038504,.186962,.086275,.071429,.040294,.196354,.090196,.076637,.041905,.205799,.094118,.081962,.043328,.215289,.098039,.087411,.044556,.224813,.101961,.09299,.045583,.234358,.105882,.098702,.046402,.243904,.109804,.104551,.047008,.25343,.113725,.110536,.047399,.262912,.117647,.116656,.047574,.272321,.121569,.122908,.047536,.281624,.12549,.129285,.047293,.290788,.129412,.135778,.046856,.299776,.133333,.142378,.046242,.308553,.137255,.149073,.045468,.317085,.141176,.15585,.044559,.325338,.145098,.162689,.043554,.333277,.14902,.169575,.042489,.340874,.152941,.176493,.041402,.348111,.156863,.183429,.040329,.354971,.160784,.190367,.039309,.361447,.164706,.197297,.0384,.367535,.168627,.204209,.037632,.373238,.172549,.211095,.03703,.378563,.176471,.217949,.036615,.383522,.180392,.224763,.036405,.388129,.184314,.231538,.036405,.3924,.188235,.238273,.036621,.396353,.192157,.244967,.037055,.400007,.196078,.25162,.037705,.403378,.2,.258234,.038571,.406485,.203922,.26481,.039647,.409345,.207843,.271347,.040922,.411976,.211765,.27785,.042353,.414392,.215686,.284321,.043933,.416608,.219608,.290763,.045644,.418637,.223529,.297178,.04747,.420491,.227451,.303568,.049396,.422182,.231373,.309935,.051407,.423721,.235294,.316282,.05349,.425116,.239216,.32261,.055634,.426377,.243137,.328921,.057827,.427511,.247059,.335217,.06006,.428524,.25098,.3415,.062325,.429425,.254902,.347771,.064616,.430217,.258824,.354032,.066925,.430906,.262745,.360284,.069247,.431497,.266667,.366529,.071579,.431994,.270588,.372768,.073915,.4324,.27451,.379001,.076253,.432719,.278431,.385228,.078591,.432955,.282353,.391453,.080927,.433109,.286275,.397674,.083257,.433183,.290196,.403894,.08558,.433179,.294118,.410113,.087896,.433098,.298039,.416331,.090203,.432943,.301961,.422549,.092501,.432714,.305882,.428768,.09479,.432412,.309804,.434987,.097069,.432039,.313725,.441207,.099338,.431594,.317647,.447428,.101597,.43108,.321569,.453651,.103848,.430498,.32549,.459875,.106089,.429846,.329412,.4661,.108322,.429125,.333333,.472328,.110547,.428334,.337255,.478558,.112764,.427475,.341176,.484789,.114974,.426548,.345098,.491022,.117179,.425552,.34902,.497257,.119379,.424488,.352941,.503493,.121575,.423356,.356863,.50973,.123769,.422156,.360784,.515967,.12596,.420887,.364706,.522206,.12815,.419549,.368627,.528444,.130341,.418142,.372549,.534683,.132534,.416667,.376471,.54092,.134729,.415123,.380392,.547157,.136929,.413511,.384314,.553392,.139134,.411829,.388235,.559624,.141346,.410078,.392157,.565854,.143567,.408258,.396078,.572081,.145797,.406369,.4,.578304,.148039,.404411,.403922,.584521,.150294,.402385,.407843,.590734,.152563,.40029,.411765,.59694,.154848,.398125,.415686,.603139,.157151,.395891,.419608,.60933,.159474,.393589,.423529,.615513,.161817,.391219,.427451,.621685,.164184,.388781,.431373,.627847,.166575,.386276,.435294,.633998,.168992,.383704,.439216,.640135,.171438,.381065,.443137,.64626,.173914,.378359,.447059,.652369,.176421,.375586,.45098,.658463,.178962,.372748,.454902,.66454,.181539,.369846,.458824,.670599,.184153,.366879,.462745,.676638,.186807,.363849,.466667,.682656,.189501,.360757,.470588,.688653,.192239,.357603,.47451,.694627,.195021,.354388,.478431,.700576,.197851,.351113,.482353,.7065,.200728,.347777,.486275,.712396,.203656,.344383,.490196,.718264,.206636,.340931,.494118,.724103,.20967,.337424,.498039,.729909,.212759,.333861,.501961,.735683,.215906,.330245,.505882,.741423,.219112,.326576,.509804,.747127,.222378,.322856,.513725,.752794,.225706,.319085,.517647,.758422,.229097,.315266,.521569,.76401,.232554,.311399,.52549,.769556,.236077,.307485,.529412,.775059,.239667,.303526,.533333,.780517,.243327,.299523,.537255,.785929,.247056,.295477,.541176,.791293,.250856,.29139,.545098,.796607,.254728,.287264,.54902,.801871,.258674,.283099,.552941,.807082,.262692,.278898,.556863,.812239,.266786,.274661,.560784,.817341,.270954,.27039,.564706,.822386,.275197,.266085,.568627,.827372,.279517,.26175,.572549,.832299,.283913,.257383,.576471,.837165,.288385,.252988,.580392,.841969,.292933,.248564,.584314,.846709,.297559,.244113,.588235,.851384,.30226,.239636,.592157,.855992,.307038,.235133,.596078,.860533,.311892,.230606,.6,.865006,.316822,.226055,.603922,.869409,.321827,.221482,.607843,.873741,.326906,.216886,.611765,.878001,.33206,.212268,.615686,.882188,.337287,.207628,.619608,.886302,.342586,.202968,.623529,.890341,.347957,.198286,.627451,.894305,.353399,.193584,.631373,.898192,.358911,.18886,.635294,.902003,.364492,.184116,.639216,.905735,.37014,.17935,.643137,.90939,.375856,.174563,.647059,.912966,.381636,.169755,.65098,.916462,.387481,.164924,.654902,.919879,.393389,.16007,.658824,.923215,.399359,.155193,.662745,.92647,.405389,.150292,.666667,.929644,.411479,.145367,.670588,.932737,.417627,.140417,.67451,.935747,.423831,.13544,.678431,.938675,.430091,.130438,.682353,.941521,.436405,.125409,.686275,.944285,.442772,.120354,.690196,.946965,.449191,.115272,.694118,.949562,.45566,.110164,.698039,.952075,.462178,.105031,.701961,.954506,.468744,.099874,.705882,.956852,.475356,.094695,.709804,.959114,.482014,.089499,.713725,.961293,.488716,.084289,.717647,.963387,.495462,.079073,.721569,.965397,.502249,.073859,.72549,.967322,.509078,.068659,.729412,.969163,.515946,.063488,.733333,.970919,.522853,.058367,.737255,.97259,.529798,.053324,.741176,.974176,.53678,.048392,.745098,.975677,.543798,.043618,.74902,.977092,.55085,.03905,.752941,.978422,.557937,.034931,.756863,.979666,.565057,.031409,.760784,.980824,.572209,.028508,.764706,.981895,.579392,.02625,.768627,.982881,.586606,.024661,.772549,.983779,.593849,.02377,.776471,.984591,.601122,.023606,.780392,.985315,.608422,.024202,.784314,.985952,.61575,.025592,.788235,.986502,.623105,.027814,.792157,.986964,.630485,.030908,.796078,.987337,.63789,.034916,.8,.987622,.64532,.039886,.803922,.987819,.652773,.045581,.807843,.987926,.66025,.05175,.811765,.987945,.667748,.058329,.815686,.987874,.675267,.065257,.819608,.987714,.682807,.072489,.823529,.987464,.690366,.07999,.827451,.987124,.697944,.087731,.831373,.986694,.70554,.095694,.835294,.986175,.713153,.103863,.839216,.985566,.720782,.112229,.843137,.984865,.728427,.120785,.847059,.984075,.736087,.129527,.85098,.983196,.743758,.138453,.854902,.982228,.751442,.147565,.858824,.981173,.759135,.156863,.862745,.980032,.766837,.166353,.866667,.978806,.774545,.176037,.870588,.977497,.782258,.185923,.87451,.976108,.789974,.196018,.878431,.974638,.797692,.206332,.882353,.973088,.805409,.216877,.886275,.971468,.813122,.227658,.890196,.969783,.820825,.238686,.894118,.968041,.828515,.249972,.898039,.966243,.836191,.261534,.901961,.964394,.843848,.273391,.905882,.962517,.851476,.285546,.909804,.960626,.859069,.29801,.913725,.95872,.866624,.31082,.917647,.956834,.874129,.323974,.921569,.954997,.881569,.337475,.92549,.953215,.888942,.351369,.929412,.951546,.896226,.365627,.933333,.950018,.903409,.380271,.937255,.948683,.910473,.395289,.941176,.947594,.917399,.410665,.945098,.946809,.924168,.426373,.94902,.946392,.930761,.442367,.952941,.946403,.937159,.458592,.956863,.946903,.943348,.47497,.960784,.947937,.949318,.491426,.964706,.949545,.955063,.50786,.968627,.95174,.960587,.524203,.972549,.954529,.965896,.540361,.976471,.957896,.971003,.556275,.980392,.961812,.975924,.571925,.984314,.966249,.980678,.587206,.988235,.971162,.985282,.602154,.992157,.976511,.989753,.61676,.996078,.982257,.994109,.631017,1,.988362,.998364,.644924]},{ColorSpace:"Diverging",Name:"Plasma (matplotlib)",NanColor:[0,1,0],Source:"https://github.com/BIDS/colormap/blob/master/colormaps.py",License:"CC0",Creator:"Nathaniel J. Smith & Stefan van der Walt",RGBPoints:[0,.050383,.029803,.527975,.003922,.063536,.028426,.533124,.007843,.075353,.027206,.538007,.011765,.086222,.026125,.542658,.015686,.096379,.025165,.547103,.019608,.10598,.024309,.551368,.023529,.115124,.023556,.555468,.027451,.123903,.022878,.559423,.031373,.132381,.022258,.56325,.035294,.140603,.021687,.566959,.039216,.148607,.021154,.570562,.043137,.156421,.020651,.574065,.047059,.16407,.020171,.577478,.05098,.171574,.019706,.580806,.054902,.17895,.019252,.584054,.058824,.186213,.018803,.587228,.062745,.193374,.018354,.59033,.066667,.200445,.017902,.593364,.070588,.207435,.017442,.596333,.07451,.21435,.016973,.599239,.078431,.221197,.016497,.602083,.082353,.227983,.016007,.604867,.086275,.234715,.015502,.607592,.090196,.241396,.014979,.610259,.094118,.248032,.014439,.612868,.098039,.254627,.013882,.615419,.101961,.261183,.013308,.617911,.105882,.267703,.012716,.620346,.109804,.274191,.012109,.622722,.113725,.280648,.011488,.625038,.117647,.287076,.010855,.627295,.121569,.293478,.010213,.62949,.12549,.299855,.009561,.631624,.129412,.30621,.008902,.633694,.133333,.312543,.008239,.6357,.137255,.318856,.007576,.63764,.141176,.32515,.006915,.639512,.145098,.331426,.006261,.641316,.14902,.337683,.005618,.643049,.152941,.343925,.004991,.64471,.156863,.35015,.004382,.646298,.160784,.356359,.003798,.64781,.164706,.362553,.003243,.649245,.168627,.368733,.002724,.650601,.172549,.374897,.002245,.651876,.176471,.381047,.001814,.653068,.180392,.387183,.001434,.654177,.184314,.393304,.001114,.655199,.188235,.399411,859e-6,.656133,.192157,.405503,678e-6,.656977,.196078,.41158,577e-6,.65773,.2,.417642,564e-6,.65839,.203922,.423689,646e-6,.658956,.207843,.429719,831e-6,.659425,.211765,.435734,.001127,.659797,.215686,.441732,.00154,.660069,.219608,.447714,.00208,.66024,.223529,.453677,.002755,.66031,.227451,.459623,.003574,.660277,.231373,.46555,.004545,.660139,.235294,.471457,.005678,.659897,.239216,.477344,.00698,.659549,.243137,.48321,.00846,.659095,.247059,.489055,.010127,.658534,.25098,.494877,.01199,.657865,.254902,.500678,.014055,.657088,.258824,.506454,.016333,.656202,.262745,.512206,.018833,.655209,.266667,.517933,.021563,.654109,.270588,.523633,.024532,.652901,.27451,.529306,.027747,.651586,.278431,.534952,.031217,.650165,.282353,.54057,.03495,.64864,.286275,.546157,.038954,.64701,.290196,.551715,.043136,.645277,.294118,.557243,.047331,.643443,.298039,.562738,.051545,.641509,.301961,.568201,.055778,.639477,.305882,.573632,.060028,.637349,.309804,.579029,.064296,.635126,.313725,.584391,.068579,.632812,.317647,.589719,.072878,.630408,.321569,.595011,.07719,.627917,.32549,.600266,.081516,.625342,.329412,.605485,.085854,.622686,.333333,.610667,.090204,.619951,.337255,.615812,.094564,.61714,.341176,.620919,.098934,.614257,.345098,.625987,.103312,.611305,.34902,.631017,.107699,.608287,.352941,.636008,.112092,.605205,.356863,.640959,.116492,.602065,.360784,.645872,.120898,.598867,.364706,.650746,.125309,.595617,.368627,.65558,.129725,.592317,.372549,.660374,.134144,.588971,.376471,.665129,.138566,.585582,.380392,.669845,.142992,.582154,.384314,.674522,.147419,.578688,.388235,.67916,.151848,.575189,.392157,.683758,.156278,.57166,.396078,.688318,.160709,.568103,.4,.69284,.165141,.564522,.403922,.697324,.169573,.560919,.407843,.701769,.174005,.557296,.411765,.706178,.178437,.553657,.415686,.710549,.182868,.550004,.419608,.714883,.187299,.546338,.423529,.719181,.191729,.542663,.427451,.723444,.196158,.538981,.431373,.72767,.200586,.535293,.435294,.731862,.205013,.531601,.439216,.736019,.209439,.527908,.443137,.740143,.213864,.524216,.447059,.744232,.218288,.520524,.45098,.748289,.222711,.516834,.454902,.752312,.227133,.513149,.458824,.756304,.231555,.509468,.462745,.760264,.235976,.505794,.466667,.764193,.240396,.502126,.470588,.76809,.244817,.498465,.47451,.771958,.249237,.494813,.478431,.775796,.253658,.491171,.482353,.779604,.258078,.487539,.486275,.783383,.2625,.483918,.490196,.787133,.266922,.480307,.494118,.790855,.271345,.476706,.498039,.794549,.27577,.473117,.501961,.798216,.280197,.469538,.505882,.801855,.284626,.465971,.509804,.805467,.289057,.462415,.513725,.809052,.293491,.45887,.517647,.812612,.297928,.455338,.521569,.816144,.302368,.451816,.52549,.819651,.306812,.448306,.529412,.823132,.311261,.444806,.533333,.826588,.315714,.441316,.537255,.830018,.320172,.437836,.541176,.833422,.324635,.434366,.545098,.836801,.329105,.430905,.54902,.840155,.33358,.427455,.552941,.843484,.338062,.424013,.556863,.846788,.342551,.420579,.560784,.850066,.347048,.417153,.564706,.853319,.351553,.413734,.568627,.856547,.356066,.410322,.572549,.85975,.360588,.406917,.576471,.862927,.365119,.403519,.580392,.866078,.36966,.400126,.584314,.869203,.374212,.396738,.588235,.872303,.378774,.393355,.592157,.875376,.383347,.389976,.596078,.878423,.387932,.3866,.6,.881443,.392529,.383229,.603922,.884436,.397139,.37986,.607843,.887402,.401762,.376494,.611765,.89034,.406398,.37313,.615686,.89325,.411048,.369768,.619608,.896131,.415712,.366407,.623529,.898984,.420392,.363047,.627451,.901807,.425087,.359688,.631373,.904601,.429797,.356329,.635294,.907365,.434524,.35297,.639216,.910098,.439268,.34961,.643137,.9128,.444029,.346251,.647059,.915471,.448807,.34289,.65098,.918109,.453603,.339529,.654902,.920714,.458417,.336166,.658824,.923287,.463251,.332801,.662745,.925825,.468103,.329435,.666667,.928329,.472975,.326067,.670588,.930798,.477867,.322697,.67451,.933232,.48278,.319325,.678431,.93563,.487712,.315952,.682353,.93799,.492667,.312575,.686275,.940313,.497642,.309197,.690196,.942598,.502639,.305816,.694118,.944844,.507658,.302433,.698039,.947051,.512699,.299049,.701961,.949217,.517763,.295662,.705882,.951344,.52285,.292275,.709804,.953428,.52796,.288883,.713725,.95547,.533093,.28549,.717647,.957469,.53825,.282096,.721569,.959424,.543431,.278701,.72549,.961336,.548636,.275305,.729412,.963203,.553865,.271909,.733333,.965024,.559118,.268513,.737255,.966798,.564396,.265118,.741176,.968526,.5697,.261721,.745098,.970205,.575028,.258325,.74902,.971835,.580382,.254931,.752941,.973416,.585761,.25154,.756863,.974947,.591165,.248151,.760784,.976428,.596595,.244767,.764706,.977856,.602051,.241387,.768627,.979233,.607532,.238013,.772549,.980556,.613039,.234646,.776471,.981826,.618572,.231287,.780392,.983041,.624131,.227937,.784314,.984199,.629718,.224595,.788235,.985301,.63533,.221265,.792157,.986345,.640969,.217948,.796078,.987332,.646633,.214648,.8,.98826,.652325,.211364,.803922,.989128,.658043,.2081,.807843,.989935,.663787,.204859,.811765,.990681,.669558,.201642,.815686,.991365,.675355,.198453,.819608,.991985,.681179,.195295,.823529,.992541,.68703,.19217,.827451,.993032,.692907,.189084,.831373,.993456,.69881,.186041,.835294,.993814,.704741,.183043,.839216,.994103,.710698,.180097,.843137,.994324,.716681,.177208,.847059,.994474,.722691,.174381,.85098,.994553,.728728,.171622,.854902,.994561,.734791,.168938,.858824,.994495,.74088,.166335,.862745,.994355,.746995,.163821,.866667,.994141,.753137,.161404,.870588,.993851,.759304,.159092,.87451,.993482,.765499,.156891,.878431,.993033,.77172,.154808,.882353,.992505,.777967,.152855,.886275,.991897,.784239,.151042,.890196,.991209,.790537,.149377,.894118,.990439,.796859,.14787,.898039,.989587,.803205,.146529,.901961,.988648,.809579,.145357,.905882,.987621,.815978,.144363,.909804,.986509,.822401,.143557,.913725,.985314,.828846,.142945,.917647,.984031,.835315,.142528,.921569,.982653,.841812,.142303,.92549,.98119,.848329,.142279,.929412,.979644,.854866,.142453,.933333,.977995,.861432,.142808,.937255,.976265,.868016,.143351,.941176,.974443,.874622,.144061,.945098,.97253,.88125,.144923,.94902,.970533,.887896,.145919,.952941,.968443,.894564,.147014,.956863,.966271,.901249,.14818,.960784,.964021,.90795,.14937,.964706,.961681,.914672,.15052,.968627,.959276,.921407,.151566,.972549,.956808,.928152,.152409,.976471,.954287,.934908,.152921,.980392,.951726,.941671,.152925,.984314,.949151,.948435,.152178,.988235,.946602,.95519,.150328,.992157,.944152,.961916,.146861,.996078,.941896,.96859,.140956,1,.940015,.975158,.131326]},{ColorSpace:"Diverging",Name:"Viridis (matplotlib)",NanColor:[1,0,0],Source:"https://github.com/BIDS/colormap/blob/master/colormaps.py",License:"CC0",Creator:"Eric Firing",RGBPoints:[0,.267004,.004874,.329415,.003922,.26851,.009605,.335427,.007843,.269944,.014625,.341379,.011765,.271305,.019942,.347269,.015686,.272594,.025563,.353093,.019608,.273809,.031497,.358853,.023529,.274952,.037752,.364543,.027451,.276022,.044167,.370164,.031373,.277018,.050344,.375715,.035294,.277941,.056324,.381191,.039216,.278791,.062145,.386592,.043137,.279566,.067836,.391917,.047059,.280267,.073417,.397163,.05098,.280894,.078907,.402329,.054902,.281446,.08432,.407414,.058824,.281924,.089666,.412415,.062745,.282327,.094955,.417331,.066667,.282656,.100196,.42216,.070588,.28291,.105393,.426902,.07451,.283091,.110553,.431554,.078431,.283197,.11568,.436115,.082353,.283229,.120777,.440584,.086275,.283187,.125848,.44496,.090196,.283072,.130895,.449241,.094118,.282884,.13592,.453427,.098039,.282623,.140926,.457517,.101961,.28229,.145912,.46151,.105882,.281887,.150881,.465405,.109804,.281412,.155834,.469201,.113725,.280868,.160771,.472899,.117647,.280255,.165693,.476498,.121569,.279574,.170599,.479997,.12549,.278826,.17549,.483397,.129412,.278012,.180367,.486697,.133333,.277134,.185228,.489898,.137255,.276194,.190074,.493001,.141176,.275191,.194905,.496005,.145098,.274128,.199721,.498911,.14902,.273006,.20452,.501721,.152941,.271828,.209303,.504434,.156863,.270595,.214069,.507052,.160784,.269308,.218818,.509577,.164706,.267968,.223549,.512008,.168627,.26658,.228262,.514349,.172549,.265145,.232956,.516599,.176471,.263663,.237631,.518762,.180392,.262138,.242286,.520837,.184314,.260571,.246922,.522828,.188235,.258965,.251537,.524736,.192157,.257322,.25613,.526563,.196078,.255645,.260703,.528312,.2,.253935,.265254,.529983,.203922,.252194,.269783,.531579,.207843,.250425,.27429,.533103,.211765,.248629,.278775,.534556,.215686,.246811,.283237,.535941,.219608,.244972,.287675,.53726,.223529,.243113,.292092,.538516,.227451,.241237,.296485,.539709,.231373,.239346,.300855,.540844,.235294,.237441,.305202,.541921,.239216,.235526,.309527,.542944,.243137,.233603,.313828,.543914,.247059,.231674,.318106,.544834,.25098,.229739,.322361,.545706,.254902,.227802,.326594,.546532,.258824,.225863,.330805,.547314,.262745,.223925,.334994,.548053,.266667,.221989,.339161,.548752,.270588,.220057,.343307,.549413,.27451,.21813,.347432,.550038,.278431,.21621,.351535,.550627,.282353,.214298,.355619,.551184,.286275,.212395,.359683,.55171,.290196,.210503,.363727,.552206,.294118,.208623,.367752,.552675,.298039,.206756,.371758,.553117,.301961,.204903,.375746,.553533,.305882,.203063,.379716,.553925,.309804,.201239,.38367,.554294,.313725,.19943,.387607,.554642,.317647,.197636,.391528,.554969,.321569,.19586,.395433,.555276,.32549,.1941,.399323,.555565,.329412,.192357,.403199,.555836,.333333,.190631,.407061,.556089,.337255,.188923,.41091,.556326,.341176,.187231,.414746,.556547,.345098,.185556,.41857,.556753,.34902,.183898,.422383,.556944,.352941,.182256,.426184,.55712,.356863,.180629,.429975,.557282,.360784,.179019,.433756,.55743,.364706,.177423,.437527,.557565,.368627,.175841,.44129,.557685,.372549,.174274,.445044,.557792,.376471,.172719,.448791,.557885,.380392,.171176,.45253,.557965,.384314,.169646,.456262,.55803,.388235,.168126,.459988,.558082,.392157,.166617,.463708,.558119,.396078,.165117,.467423,.558141,.4,.163625,.471133,.558148,.403922,.162142,.474838,.55814,.407843,.160665,.47854,.558115,.411765,.159194,.482237,.558073,.415686,.157729,.485932,.558013,.419608,.15627,.489624,.557936,.423529,.154815,.493313,.55784,.427451,.153364,.497,.557724,.431373,.151918,.500685,.557587,.435294,.150476,.504369,.55743,.439216,.149039,.508051,.55725,.443137,.147607,.511733,.557049,.447059,.14618,.515413,.556823,.45098,.144759,.519093,.556572,.454902,.143343,.522773,.556295,.458824,.141935,.526453,.555991,.462745,.140536,.530132,.555659,.466667,.139147,.533812,.555298,.470588,.13777,.537492,.554906,.47451,.136408,.541173,.554483,.478431,.135066,.544853,.554029,.482353,.133743,.548535,.553541,.486275,.132444,.552216,.553018,.490196,.131172,.555899,.552459,.494118,.129933,.559582,.551864,.498039,.128729,.563265,.551229,.501961,.127568,.566949,.550556,.505882,.126453,.570633,.549841,.509804,.125394,.574318,.549086,.513725,.124395,.578002,.548287,.517647,.123463,.581687,.547445,.521569,.122606,.585371,.546557,.52549,.121831,.589055,.545623,.529412,.121148,.592739,.544641,.533333,.120565,.596422,.543611,.537255,.120092,.600104,.54253,.541176,.119738,.603785,.5414,.545098,.119512,.607464,.540218,.54902,.119423,.611141,.538982,.552941,.119483,.614817,.537692,.556863,.119699,.61849,.536347,.560784,.120081,.622161,.534946,.564706,.120638,.625828,.533488,.568627,.12138,.629492,.531973,.572549,.122312,.633153,.530398,.576471,.123444,.636809,.528763,.580392,.12478,.640461,.527068,.584314,.126326,.644107,.525311,.588235,.128087,.647749,.523491,.592157,.130067,.651384,.521608,.596078,.132268,.655014,.519661,.6,.134692,.658636,.517649,.603922,.137339,.662252,.515571,.607843,.14021,.665859,.513427,.611765,.143303,.669459,.511215,.615686,.146616,.67305,.508936,.619608,.150148,.676631,.506589,.623529,.153894,.680203,.504172,.627451,.157851,.683765,.501686,.631373,.162016,.687316,.499129,.635294,.166383,.690856,.496502,.639216,.170948,.694384,.493803,.643137,.175707,.6979,.491033,.647059,.180653,.701402,.488189,.65098,.185783,.704891,.485273,.654902,.19109,.708366,.482284,.658824,.196571,.711827,.479221,.662745,.202219,.715272,.476084,.666667,.20803,.718701,.472873,.670588,.214,.722114,.469588,.67451,.220124,.725509,.466226,.678431,.226397,.728888,.462789,.682353,.232815,.732247,.459277,.686275,.239374,.735588,.455688,.690196,.24607,.73891,.452024,.694118,.252899,.742211,.448284,.698039,.259857,.745492,.444467,.701961,.266941,.748751,.440573,.705882,.274149,.751988,.436601,.709804,.281477,.755203,.432552,.713725,.288921,.758394,.428426,.717647,.296479,.761561,.424223,.721569,.304148,.764704,.419943,.72549,.311925,.767822,.415586,.729412,.319809,.770914,.411152,.733333,.327796,.77398,.40664,.737255,.335885,.777018,.402049,.741176,.344074,.780029,.397381,.745098,.35236,.783011,.392636,.74902,.360741,.785964,.387814,.752941,.369214,.788888,.382914,.756863,.377779,.791781,.377939,.760784,.386433,.794644,.372886,.764706,.395174,.797475,.367757,.768627,.404001,.800275,.362552,.772549,.412913,.803041,.357269,.776471,.421908,.805774,.35191,.780392,.430983,.808473,.346476,.784314,.440137,.811138,.340967,.788235,.449368,.813768,.335384,.792157,.458674,.816363,.329727,.796078,.468053,.818921,.323998,.8,.477504,.821444,.318195,.803922,.487026,.823929,.312321,.807843,.496615,.826376,.306377,.811765,.506271,.828786,.300362,.815686,.515992,.831158,.294279,.819608,.525776,.833491,.288127,.823529,.535621,.835785,.281908,.827451,.545524,.838039,.275626,.831373,.555484,.840254,.269281,.835294,.565498,.84243,.262877,.839216,.575563,.844566,.256415,.843137,.585678,.846661,.249897,.847059,.595839,.848717,.243329,.85098,.606045,.850733,.236712,.854902,.616293,.852709,.230052,.858824,.626579,.854645,.223353,.862745,.636902,.856542,.21662,.866667,.647257,.8584,.209861,.870588,.657642,.860219,.203082,.87451,.668054,.861999,.196293,.878431,.678489,.863742,.189503,.882353,.688944,.865448,.182725,.886275,.699415,.867117,.175971,.890196,.709898,.868751,.169257,.894118,.720391,.87035,.162603,.898039,.730889,.871916,.156029,.901961,.741388,.873449,.149561,.905882,.751884,.874951,.143228,.909804,.762373,.876424,.137064,.913725,.772852,.877868,.131109,.917647,.783315,.879285,.125405,.921569,.79376,.880678,.120005,.92549,.804182,.882046,.114965,.929412,.814576,.883393,.110347,.933333,.82494,.88472,.106217,.937255,.83527,.886029,.102646,.941176,.845561,.887322,.099702,.945098,.85581,.888601,.097452,.94902,.866013,.889868,.095953,.952941,.876168,.891125,.09525,.956863,.886271,.892374,.095374,.960784,.89632,.893616,.096335,.964706,.906311,.894855,.098125,.968627,.916242,.896091,.100717,.972549,.926106,.89733,.104071,.976471,.935904,.89857,.108131,.980392,.945636,.899815,.112838,.984314,.9553,.901065,.118128,.988235,.964894,.902323,.123941,.992157,.974417,.90359,.130215,.996078,.983868,.904867,.136897,1,.993248,.906157,.143936]},{ShowIndexedColorActiveValues:1,IndexedColors:[.07,.5,.7,1,1,1,.85,1,1,.8,.5,1,.76,1,0,1,.71,.71,.5,.5,.5,.05,.05,1,1,.05,.05,.7,1,1,.7,.89,.96,.67,.36,.95,.54,1,0,.75,.65,.65,.5,.6,.6,1,.5,0,1,1,.19,.12,.94,.12,.5,.82,.89,.56,.25,.83,.24,1,0,.9,.9,.9,.75,.76,.78,.65,.65,.67,.54,.6,.78,.61,.48,.78,.5,.48,.78,.44,.48,.78,.36,.48,.76,1,.48,.38,.49,.5,.69,.76,.56,.56,.4,.56,.56,.74,.5,.89,1,.63,0,.65,.16,.16,.36,.72,.82,.44,.18,.69,0,1,0,.58,1,1,.58,.88,.88,.45,.76,.79,.33,.71,.71,.23,.62,.62,.14,.56,.56,.04,.49,.55,0,.41,.52,.88,.88,1,1,.85,.56,.65,.46,.45,.4,.5,.5,.62,.39,.71,.83,.48,0,.58,0,.58,.26,.62,.69,.34,.09,.56,0,.79,0,.44,.83,1,1,1,.78,.85,1,.78,.78,1,.78,.64,1,.78,.56,1,.78,.38,1,.78,.27,1,.78,.19,1,.78,.12,1,.78,0,1,.61,0,.9,.46,0,.83,.32,0,.75,.22,0,.67,.14,.3,.76,1,.3,.65,1,.13,.58,.84,.15,.49,.67,.15,.4,.59,.09,.33,.53,.96,.93,.82,.8,.82,.12,.71,.71,.76,.65,.33,.3,.34,.35,.38,.62,.31,.71,.67,.36,0,.46,.31,.27,.26,.51,.59,.26,0,.4,0,.49,0,.44,.67,.98,0,.73,1,0,.63,1,0,.56,1,0,.5,1,0,.42,1,.33,.36,.95,.47,.36,.89,.54,.31,.89,.63,.21,.83,.7,.12,.83,.7,.12,.73,.7,.05,.65,.74,.05,.53,.78,0,.4,.8,0,.35,.82,0,.31,.85,0,.27,.88,0,.22,.9,0,.18,.91,0,.15,.92,0,.14,.93,0,.13,.94,0,.12,.95,0,.11,.96,0,.1,.97,0,.09,.98,0,.08,.99,0,.07,1,0,.06],Annotations:[0,"Xx",1,"H",2,"He",3,"Li",4,"Be",5,"B",6,"C",7,"N",8,"O",9,"F",10,"Ne",11,"Na",12,"Mg",13,"Al",14,"Si",15,"P",16,"S",17,"Cl",18,"Ar",19,"K",20,"Ca",21,"Sc",22,"Ti",23,"V",24,"Cr",25,"Mn",26,"Fe",27,"Co",28,"Ni",29,"Cu",30,"Zn",31,"Ga",32,"Ge",33,"As",34,"Se",35,"Br",36,"Kr",37,"Rb",38,"Sr",39,"Y",40,"Zr",41,"Nb",42,"Mo",43,"Tc",44,"Ru",45,"Rh",46,"Pd",47,"Ag",48,"Cd",49,"In",50,"Sn",51,"Sb",52,"Te",53,"I",54,"Xe",55,"Cs",56,"Ba",57,"La",58,"Ce",59,"Pr",60,"Nd",61,"Pm",62,"Sm",63,"Eu",64,"Gd",65,"Tb",66,"Dy",67,"Ho",68,"Er",69,"Tm",70,"Yb",71,"Lu",72,"Hf",73,"Ta",74,"W",75,"Re",76,"Os",77,"Ir",78,"Pt",79,"Au",80,"Hg",81,"Tl",82,"Pb",83,"Bi",84,"Po",85,"At",86,"Rn",87,"Fr",88,"Ra",89,"Ac",90,"Th",91,"Pa",92,"U",93,"Np",94,"Pu",95,"Am",96,"Cm",97,"Bk",98,"Cf",99,"Es",100,"Fm",101,"Md",102,"No",103,"Lr",104,"Rf",105,"Db",106,"Sg",107,"Bh",108,"Hs",109,"Mt",110,"Ds",111,"Rg",112,"Cn",113,"Uut",114,"Uuq",115,"Uup",116,"Uuh",117,"Uus",118,"Uuo"],Name:"BlueObeliskElements"}];const xh=Object.create(null);Die.filter(t=>t.RGBPoints).filter(t=>t.ColorSpace!=="CIELAB").forEach(t=>{xh[t.Name]=t});const Ch=Object.keys(xh);Ch.sort();function Iie(t){return xh[t]}function Oie(t){!t.RGBPoints||t.ColorSpace==="CIELAB"||(xh[t.Name]||(Ch.push(t.Name),Ch.sort()),xh[t.Name]=t)}function Mie(t){const e=Ch.indexOf(t);e>-1&&Ch.splice(e,1),delete xh[t]}var u1={addPreset:Oie,removePresetByName:Mie,getPresetByName:Iie,rgbPresetNames:Ch};function PN(t,e,r){return Math.abs(t-e)<=r}function Pie(t,e,r=1e-5){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!PN(t[n],e[n],r))return!1;return!0}function RD(t){return typeof t=="number"}function LD(t){return t&&typeof t=="object"&&"length"in t&&typeof t.length=="number"&&t.length>0&&typeof t[0]=="number"}function Vt(t,e,r=1e-5){return typeof t!=typeof e||t===null||e===null?!1:RD(t)&&RD(e)?PN(t,e,r):LD(t)&&LD(e)?Pie(t,e,r):!1}const RN=t=>typeof t=="number"?-t:t!=null&&t.map?t.map(RN):!t,CS=t=>typeof t=="number"?Math.abs(t):t!=null&&t.map?t.map(CS):t,LN=(t,e,r=void 0)=>Vt(t,RN(e),r),Rie=(t,e,r=void 0)=>Vt(CS(t),CS(e),r);function xr(t){return Array.isArray(t)?xr(t[0]):isFinite(t)&&!isNaN(t)}const F4=new Map;function Lie(t){t.name=t.name||t.Name,F4.set(t.name,t)}function f1(t){return F4.get(t)}function AN(){return Array.from(F4.keys())}function U4(t,e){const r=u1.rgbPresetNames.map(s=>u1.getPresetByName(s)),n=AN().map(s=>f1(s)),o=r.concat(n).find(s=>{const{RGBPoints:c}=s;if(c.length!==t.length)return!1;for(let l=0;l<c.length;l+=4)if(!Vt(c.slice(l+1,l+4),t.slice(l+1,l+4)))return!1;return!0});if(!o)return null;const a=[];if(ga(e,"vtkVolume")){const s=e.getProperty().getScalarOpacity(0).getDataPointer();if(!s)return{name:o.Name};for(let c=0;c<s.length;c+=2)a.push({value:s[c],opacity:s[c+1]})}return{name:o.Name,opacity:a}}function Aie(t){const{volumeActor:e,preset:r,opacity:n=.9,threshold:i=null,colorRange:o=[0,5]}=t;e.getMapper().setSampleDistance(1);const s=eu.newInstance(),c=r||u1.getPresetByName("hsv");s.applyColorMap(c),s.setMappingRange(o[0],o[1]),e.getProperty().setRGBTransferFunction(0,s),B4(e,n,i)}function NN(t,e){const r=G4(t);B4(t,e,r)}function kN(t,e){const r=W4(t);B4(t,r,e)}function B4(t,e,r){const n=t.getMapper().getInputData().get("voxelManager");if(!(n!=null&&n.voxelManager))throw new Error("No voxel manager was found for the volume actor, or you cannot yet update opacity with a threshold using stacked images");const i=n.voxelManager.getRange(),o=Ed.newInstance();if(r!==null){const a=Math.abs(i[1]-i[0])*.001,s=Math.max(i[0],Math.min(i[1],r));o.addPoint(i[0],0),o.addPoint(s-a,0),o.addPoint(s,e),o.addPoint(i[1],e)}else o.addPoint(i[0],e),o.addPoint(i[1],e);t.getProperty().setScalarOpacity(0,o)}function G4(t){const e=t.getProperty().getScalarOpacity(0);if(!e)return null;const r=e.getDataPointer();if(!r||r.length<=4)return null;for(let n=0;n<r.length-2;n+=2){r[n];const i=r[n+1],o=r[n+2],a=r[n+3];if(i===0&&a>0)return o}return null}function W4(t){const e=t.getProperty().getScalarOpacity(0);if(!e)return 1;const r=e.getDataPointer();if(!r||r.length===0)return 1;let n=0;for(let i=1;i<r.length;i+=2)r[i]>n&&(n=r[i]);return n}const Nie=Object.freeze(Object.defineProperty({__proto__:null,findMatchingColormap:U4,getColormap:f1,getColormapNames:AN,getMaxOpacity:W4,getThresholdValue:G4,registerColormap:Lie,setColorMapTransferFunctionForVolumeActor:Aie,updateOpacity:NN,updateThreshold:kN},Symbol.toStringTag,{value:"Module"}));function wp(t){if(!t)return;const e=t.getSize();for(let r=0;r<e;r++){const n=[];t.getNodeValue(r,n),n[1]=1-n[1],n[2]=1-n[2],n[3]=1-n[3],t.setNodeValue(r,n)}}const SS=(t,e,r)=>e-r/4*Math.log((1-t)/t);function om(t,e){const r=Math.abs(e-t)+1,n=(t+e+1)/2;return{windowWidth:r,windowCenter:n}}function Yu(t,e,r=oo.LINEAR){if(r===oo.LINEAR)return{lower:e-.5-(t-1)/2,upper:e-.5+(t-1)/2};if(r===oo.LINEAR_EXACT)return{lower:e-t/2,upper:e+t/2};if(r===oo.SAMPLED_SIGMOID){const n=SS(.01,e,t),i=SS(.99,e,t);return{lower:n,upper:i}}else throw new Error("Invalid VOI LUT function")}const kie=Object.freeze(Object.defineProperty({__proto__:null,toLowHighRange:Yu,toWindowLevel:om},Symbol.toStringTag,{value:"Module"}));function z4(t,e=1024){const{windowWidth:r,windowCenter:n}=om(t.lower,t.upper),o=Array.from({length:e},(s,c)=>(c+1)/(e+2)).flatMap(s=>[SS(s,n,r),s,s,s,.5,0]),a=eu.newInstance();return a.buildFunctionFromArray(bt.newInstance({values:o,numberOfComponents:6})),a}function Lr(t,e){return t.worldToIndex(e).map(Math.round)}function Ov(t,e){return t.worldToIndex(e)}function ky(t){const e=t.getSize(),r=[];for(let n=0;n<e;n++){const i=[];t.getNodeValue(n,i),r.push(i)}return r}function vw(t,e){e!=null&&e.length&&(t.removeAllPoints(),e.forEach(r=>{t.addRGBPoint(...r)}))}const Vie=Object.freeze(Object.defineProperty({__proto__:null,getTransferFunctionNodes:ky,setTransferFunctionNodes:vw},Symbol.toStringTag,{value:"Module"})),{InterpolationType:Zg,OpacityMode:Fie}=bA,{vtkErrorMacro:Yx}=Z,Mv=4;function Uie(t,e){e.classHierarchy.push("vtkVolumeProperty"),t.getMTime=()=>{let i=e.mtime,o;for(let a=0;a<Mv;a++)e.componentData[a].colorChannels===1?e.componentData[a].grayTransferFunction&&(o=e.componentData[a].grayTransferFunction.getMTime(),i=i>o?i:o):e.componentData[a].colorChannels===3&&e.componentData[a].rGBTransferFunction&&(o=e.componentData[a].rGBTransferFunction.getMTime(),i=i>o?i:o),e.componentData[a].scalarOpacity&&(o=e.componentData[a].scalarOpacity.getMTime(),i=i>o?i:o),e.componentData[a].gradientOpacity&&(e.componentData[a].disableGradientOpacity||(o=e.componentData[a].gradientOpacity.getMTime(),i=i>o?i:o));return i},t.getColorChannels=i=>i<0||i>3?(Yx("Bad index - must be between 0 and 3"),0):e.componentData[i].colorChannels,t.setGrayTransferFunction=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,a=!1;return e.componentData[i].grayTransferFunction!==o&&(e.componentData[i].grayTransferFunction=o,a=!0),e.componentData[i].colorChannels!==1&&(e.componentData[i].colorChannels=1,a=!0),a&&t.modified(),a},t.getGrayTransferFunction=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return e.componentData[i].grayTransferFunction===null&&(e.componentData[i].grayTransferFunction=Ed.newInstance(),e.componentData[i].grayTransferFunction.addPoint(0,0),e.componentData[i].grayTransferFunction.addPoint(1024,1),e.componentData[i].colorChannels!==1&&(e.componentData[i].colorChannels=1),t.modified()),e.componentData[i].grayTransferFunction},t.setRGBTransferFunction=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,a=!1;return e.componentData[i].rGBTransferFunction!==o&&(e.componentData[i].rGBTransferFunction=o,a=!0),e.componentData[i].colorChannels!==3&&(e.componentData[i].colorChannels=3,a=!0),a&&t.modified(),a},t.getRGBTransferFunction=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return e.componentData[i].rGBTransferFunction===null&&(e.componentData[i].rGBTransferFunction=eu.newInstance(),e.componentData[i].rGBTransferFunction.addRGBPoint(0,0,0,0),e.componentData[i].rGBTransferFunction.addRGBPoint(1024,1,1,1),e.componentData[i].colorChannels!==3&&(e.componentData[i].colorChannels=3),t.modified()),e.componentData[i].rGBTransferFunction},t.setScalarOpacity=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;return e.componentData[i].scalarOpacity!==o?(e.componentData[i].scalarOpacity=o,t.modified(),!0):!1},t.getScalarOpacity=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return e.componentData[i].scalarOpacity===null&&(e.componentData[i].scalarOpacity=Ed.newInstance(),e.componentData[i].scalarOpacity.addPoint(0,1),e.componentData[i].scalarOpacity.addPoint(1024,1),t.modified()),e.componentData[i].scalarOpacity},t.setComponentWeight=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1;if(i<0||i>=Mv)return Yx("Invalid index"),!1;const a=Math.min(1,Math.max(0,o));return e.componentData[i].componentWeight!==a?(e.componentData[i].componentWeight=a,t.modified(),!0):!1},t.getComponentWeight=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return i<0||i>=Mv?(Yx("Invalid index"),0):e.componentData[i].componentWeight},t.setInterpolationTypeToNearest=()=>t.setInterpolationType(Zg.NEAREST),t.setInterpolationTypeToLinear=()=>t.setInterpolationType(Zg.LINEAR),t.setInterpolationTypeToFastLinear=()=>t.setInterpolationType(Zg.FAST_LINEAR),t.getInterpolationTypeAsString=()=>Z.enumToString(Zg,e.interpolationType),["useGradientOpacity","scalarOpacityUnitDistance","gradientOpacityMinimumValue","gradientOpacityMinimumOpacity","gradientOpacityMaximumValue","gradientOpacityMaximumOpacity","opacityMode","forceNearestInterpolation"].forEach(i=>{const o=Z.capitalize(i);t[`set${o}`]=(a,s)=>e.componentData[a][`${i}`]!==s?(e.componentData[a][`${i}`]=s,t.modified(),!0):!1}),["useGradientOpacity","scalarOpacityUnitDistance","gradientOpacityMinimumValue","gradientOpacityMinimumOpacity","gradientOpacityMaximumValue","gradientOpacityMaximumOpacity","opacityMode","forceNearestInterpolation"].forEach(i=>{const o=Z.capitalize(i);t[`get${o}`]=a=>e.componentData[a][`${i}`]})}const Bie={colorMixPreset:null,independentComponents:!0,interpolationType:Zg.FAST_LINEAR,shade:!1,ambient:.1,diffuse:.7,specular:.2,specularPower:10,useLabelOutline:!1,labelOutlineThickness:[1],labelOutlineOpacity:1};function Gie(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(Object.assign(e,Bie,r),Z.obj(t,e),!e.componentData){e.componentData=[];for(let n=0;n<Mv;++n)e.componentData.push({colorChannels:1,grayTransferFunction:null,rGBTransferFunction:null,scalarOpacity:null,scalarOpacityUnitDistance:1,opacityMode:Fie.FRACTIONAL,gradientOpacityMinimumValue:0,gradientOpacityMinimumOpacity:0,gradientOpacityMaximumValue:1,gradientOpacityMaximumOpacity:1,useGradientOpacity:!1,componentWeight:1,forceNearestInterpolation:!1})}Z.setGet(t,e,["colorMixPreset","independentComponents","interpolationType","shade","ambient","diffuse","specular","specularPower","useLabelOutline","labelOutlineOpacity"]),Z.setGetArray(t,e,["labelOutlineThickness"]),Uie(t,e)}const Wie=Z.newInstance(Gie,"vtkVolumeProperty");var zie={newInstance:Wie,...bA};const{vtkDebugMacro:$ie}=Z;function jie(t,e){e.classHierarchy.push("vtkVolume"),t.getVolumes=()=>t,t.makeProperty=zie.newInstance,t.getProperty=()=>(e.property===null&&(e.property=t.makeProperty()),e.property),t.getBounds=()=>{if(e.mapper===null)return e.bounds;const r=e.mapper.getBounds();if(!r||r.length!==6)return r;if(r[0]>r[1])return e.mapperBounds=r.concat(),e.bounds=[1,-1,1,-1,1,-1],e.boundsMTime.modified(),r;const n=i=>i[0].map((o,a)=>i.map(s=>s[a]));if(!e.mapperBounds||!n([r,e.mapperBounds]).reduce((i,o)=>i&&o[0]===o[1],!0)||t.getMTime()>e.boundsMTime.getMTime()){$ie("Recomputing bounds..."),e.mapperBounds=r.map(a=>a);const i=[];Hn.getCorners(r,i),t.computeMatrix();const o=new Float64Array(16);un(o,e.matrix),i.forEach(a=>At(a,a,o)),e.bounds[0]=e.bounds[2]=e.bounds[4]=Number.MAX_VALUE,e.bounds[1]=e.bounds[3]=e.bounds[5]=-Number.MAX_VALUE,e.bounds=e.bounds.map((a,s)=>s%2===0?i.reduce((c,l)=>c>l[s/2]?l[s/2]:c,a):i.reduce((c,l)=>c<l[(s-1)/2]?l[(s-1)/2]:c,a)),e.boundsMTime.modified()}return e.bounds},t.getMTime=()=>{let r=e.mtime;if(e.property!==null){const n=e.property.getMTime();r=n>r?n:r}return r},t.getRedrawMTime=()=>{let r=e.mtime;if(e.mapper!==null){let n=e.mapper.getMTime();r=n>r?n:r,e.mapper.getInput()!==null&&(e.mapper.getInputAlgorithm().update(),n=e.mapper.getInput().getMTime(),r=n>r?n:r)}return r}}const Hie={mapper:null,property:null,bounds:[1,-1,1,-1,1,-1]};function VN(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Hie,r),L4.extend(t,e,r),e.boundsMTime={},Z.obj(e.boundsMTime),Z.set(t,e,["property"]),Z.setGet(t,e,["mapper"]),Z.getArray(t,e,["bounds"],6),jie(t,e)}const Kie=Z.newInstance(VN,"vtkVolume");var qie={newInstance:Kie,extend:VN};const{vtkErrorMacro:Xie}=Z;class Yie{constructor(){this.segmentMapping={},this.segments=[null],this.faces=[]}addSegment(e){const r=e[0],n=e[e.length-1];if(r===n||e.length<2)return;const i=this.segmentMapping[r],o=this.segmentMapping[n];if(i!==void 0&&o!==void 0)if(Math.abs(i)===Math.abs(o)){const a=i<o?o:i,s=this.segments[a];if(i>0)for(let c=1;c<e.length-1;c++)s.push(e[c]);else for(let c=1;c<e.length-1;c++)s.unshift(e[e.length-1-c]);this.faces.push(s),this.segments[a]=null,this.segmentMapping[r]=void 0,this.segmentMapping[n]=void 0}else{const a=Math.abs(i),s=Math.abs(o),c=this.segments[a],l=this.segments[s];this.segments[a]=null,this.segments[s]=null,this.segmentMapping[c[0]]=void 0,this.segmentMapping[l[0]]=void 0,this.segmentMapping[c[c.length-1]]=void 0,this.segmentMapping[l[l.length-1]]=void 0,this.addSegment(e),this.addSegment(c),this.addSegment(l)}else if(i!==void 0){if(i>0){const a=this.segments[i];for(let s=1;s<e.length;s++)a.push(e[s]);this.segmentMapping[n]=i}else{const a=this.segments[-i];this.segmentMapping[n]=i;for(let s=1;s<e.length;s++)a.unshift(e[s])}this.segmentMapping[r]=void 0}else if(o!==void 0){if(o>0){const a=this.segments[o];for(let s=1;s<e.length;s++)a.push(e[e.length-1-s]);this.segmentMapping[r]=o}else{const a=this.segments[-o];this.segmentMapping[r]=o;for(let s=1;s<e.length;s++)a.unshift(e[e.length-s-1])}this.segmentMapping[n]=void 0}else{const a=this.segments.length;this.segments.push(e),this.segmentMapping[r]=-a,this.segmentMapping[n]=a}}}function Jie(t,e){e.classHierarchy.push("vtkClosedPolyLineToSurfaceFilter"),t.requestData=(r,n)=>{const i=r[0];if(!i){Xie("Invalid or missing input");return}const o=Er.newInstance();o.shallowCopy(i);const a=new Yie,s=i.getLines().getData();let c=0;for(;c<s.length;){const d=s[c++],h=[];for(let g=0;g<d;g++)h.push(s[c+g]);a.addSegment(h),c+=d}const{faces:l}=a;let f=l.length;for(let d=0;d<l.length;d++)f+=l[d].length;const u=new Uint16Array(f);c=0;for(let d=0;d<l.length;d++){const h=l[d];u[c++]=h.length;for(let g=0;g<h.length;g++)u[c++]=h[g]}o.setPolys(_d.newInstance({values:u,name:"faces"})),n[0]=o}}const Zie={};function FN(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Zie,r),Z.obj(t,e),Z.algo(t,e,1,1),Jie(t,e)}const Qie=Z.newInstance(FN,"vtkClosedPolyLineToSurfaceFilter");var eoe={newInstance:Qie,extend:FN};const{vtkErrorMacro:AD}=uo;function toe(t){const e=t.getPolys().getData(),r=t.getStrips().getData(),n={cellSize:0,cell:[],done:!1,polyIdx:0,stripIdx:0,remainingStripLength:0,next(){if(n.polyIdx<e.length){n.cellSize=e[n.polyIdx];const i=n.polyIdx+1,o=i+n.cellSize;n.polyIdx=o;let a=0;for(let s=i;s<o;++s)n.cell[a++]=e[s]}else if(n.stripIdx<r.length){n.cellSize=3,n.remainingStripLength===0&&(n.remainingStripLength=r[n.stripIdx]-2,n.stripIdx+=3);const i=n.stripIdx-2,o=n.stripIdx+1;n.stripIdx++,n.remainingStripLength--;let a=0;for(let s=i;s<o;++s)n.cell[a++]=r[s]}else if(!n.done)n.done=!0;else throw new Error("Iterator is done")}};return n.next(),n}function noe(t,e){e.classHierarchy.push("vtkCutter");const r={...t};t.getMTime=()=>{let i=r.getMTime();return e.cutFunction&&(i=Math.max(i,e.cutFunction.getMTime())),i};function n(i,o){const a=i.getPoints(),s=a.getData(),c=a.getNumberOfPoints(),l=[],f=[],u=[];(!e.cutScalars||e.cutScalars.length<c)&&(e.cutScalars=new Float32Array(c));let d=0,h=0;for(;d<s.length;)e.cutScalars[h++]=e.cutFunction.evaluateFunction(s[d++],s[d++],s[d++]);const g=[],p=new Array(3),v=new Array(3),y=[];for(const w=toe(i);!w.done;w.next()){if(w.cellSize<=2)continue;for(let _=0;_<w.cellSize;)y[_]=e.cutScalars[w.cell[_++]];const x=y[0]>0;let C=!0;for(let _=1;_<w.cell.length;_++)if(y[_]>0!==x){C=!1;break}if(C)continue;const S=[];for(let _=0;_<w.cellSize;_++){const E=_+1===w.cellSize?0:_+1,b=y[_]>0;if(y[E]>0===b)continue;let I=_,P=E,O=y[P]-y[I];O<=0&&(I=E,P=_,O*=-1);let L=0;O!==0&&(L=(e.cutValue-y[I])/O);const B=w.cell[I],H=w.cell[P];p[0]=s[B*3],p[1]=s[B*3+1],p[2]=s[B*3+2],v[0]=s[H*3],v[1]=s[H*3+1],v[2]=s[H*3+2];const A=[p[0]+L*(v[0]-p[0]),p[1]+L*(v[1]-p[1]),p[2]+L*(v[2]-p[2])];S.push({pointEdge1:B,pointEdge2:H,intersectedPoint:A,newPointID:-1})}for(let _=0;_<S.length;_++){const E=S[_];let b=!1;for(let D=0;D<g.length;D++){const I=g[D],P=E.pointEdge1===I.pointEdge1&&E.pointEdge2===I.pointEdge2,O=E.intersectedPoint[0]===I.intersectedPoint[0]&&E.intersectedPoint[1]===I.intersectedPoint[1]&&E.intersectedPoint[2]===I.intersectedPoint[2];if(P||O){b=!0,S[_].newPointID=g[D].newPointID;break}}b||(l.push(E.intersectedPoint[0]),l.push(E.intersectedPoint[1]),l.push(E.intersectedPoint[2]),S[_].newPointID=l.length/3-1,g.push(S[_]))}const T=S.length;T===2?f.push(T,S[0].newPointID,S[1].newPointID):T>2&&(u.push(T),S.forEach(_=>{u.push(_.newPointID)}))}o.getPoints().setData(J5(a.getDataType(),l),3),f.length!==0&&o.getLines().setData(Uint16Array.from(f)),u.length!==0&&o.getPolys().setData(Uint16Array.from(u))}t.requestData=(i,o)=>{const a=i[0];if(!a){AD("Invalid or missing input");return}if(!e.cutFunction){AD("Missing cut function");return}const s=Er.newInstance();n(a,s),o[0]=s}}const roe={cutFunction:null,cutScalars:null,cutValue:0};function UN(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,roe,r),or(t,e),P_(t,e,1,1),Jr(t,e,["cutFunction","cutValue"]),noe(t,e)}const ioe=Rn(UN,"vtkCutter");var ooe={newInstance:ioe,extend:UN};const aoe=[2,0,1,2,2,3,2,4,5,2,6,7,2,0,2,2,1,3,2,4,6,2,5,7,2,0,4,2,1,5,2,2,6,2,3,7],soe=[4,0,1,3,2,4,4,6,7,5,4,8,10,11,9,4,12,13,15,14,4,16,18,19,17,4,20,21,23,22];function coe(t,e){e.classHierarchy.push("vtkCubeSource");function r(n,i){if(e.deleted)return;const o=Er.newInstance();i[0]=o;const a=24,s=Z.newTypedArray(e.pointType,a*3);o.getPoints().setData(s,3);const c=Z.newTypedArray(e.pointType,a*3),l=bt.newInstance({name:"Normals",values:c,numberOfComponents:3});o.getPointData().setNormals(l);let f=2;e.generate3DTextureCoordinates===!0&&(f=3);const u=Z.newTypedArray(e.pointType,a*f),d=bt.newInstance({name:"TextureCoordinates",values:u,numberOfComponents:f});o.getPointData().setTCoords(d);const h=[0,0,0],g=[0,0,0],p=[0,0];let v=0;h[0]=-e.xLength/2,g[0]=-1,g[1]=0,g[2]=0;for(let y=0;y<2;y++){h[1]=-e.yLength/2;for(let m=0;m<2;m++){p[1]=h[1]+.5,h[2]=-e.zLength/2;for(let w=0;w<2;w++)p[0]=(h[2]+.5)*(1-2*y),s[v*3]=h[0],s[v*3+1]=h[1],s[v*3+2]=h[2],c[v*3]=g[0],c[v*3+1]=g[1],c[v*3+2]=g[2],f===2?(u[v*f]=p[0],u[v*f+1]=p[1]):(u[v*f]=2*y-1,u[v*f+1]=2*m-1,u[v*f+2]=2*w-1),v++,h[2]+=e.zLength;h[1]+=e.yLength}h[0]+=e.xLength,g[0]+=2}h[1]=-e.yLength/2,g[1]=-1,g[0]=0,g[2]=0;for(let y=0;y<2;y++){h[0]=-e.xLength/2;for(let m=0;m<2;m++){p[0]=(h[0]+.5)*(2*y-1),h[2]=-e.zLength/2;for(let w=0;w<2;w++)p[1]=(h[2]+.5)*-1,s[v*3]=h[0],s[v*3+1]=h[1],s[v*3+2]=h[2],c[v*3]=g[0],c[v*3+1]=g[1],c[v*3+2]=g[2],f===2?(u[v*f]=p[0],u[v*f+1]=p[1]):(u[v*f]=2*m-1,u[v*f+1]=2*y-1,u[v*f+2]=2*w-1),v++,h[2]+=e.zLength;h[0]+=e.xLength}h[1]+=e.yLength,g[1]+=2}h[2]=-e.zLength/2,g[2]=-1,g[0]=0,g[1]=0;for(let y=0;y<2;y++){h[1]=-e.yLength/2;for(let m=0;m<2;m++){p[1]=h[1]+.5,h[0]=-e.xLength/2;for(let w=0;w<2;w++)p[0]=(h[0]+.5)*(2*y-1),s[v*3]=h[0],s[v*3+1]=h[1],s[v*3+2]=h[2],c[v*3]=g[0],c[v*3+1]=g[1],c[v*3+2]=g[2],f===2?(u[v*f]=p[0],u[v*f+1]=p[1]):(u[v*f]=2*w-1,u[v*f+1]=2*m-1,u[v*f+2]=2*y-1),v++,h[0]+=e.xLength;h[1]+=e.yLength}h[2]+=e.zLength,g[2]+=2}if(e.rotations&&Ni.buildFromDegree().rotateX(e.rotations[0]).rotateY(e.rotations[1]).rotateZ(e.rotations[2]).apply(s).apply(c),e.center&&Ni.buildFromRadian().translate(...e.center).apply(s),e.matrix){Ni.buildFromRadian().setMatrix(e.matrix).apply(s);const y=[e.matrix[0],e.matrix[1],e.matrix[2],0,e.matrix[4],e.matrix[5],e.matrix[6],0,e.matrix[8],e.matrix[9],e.matrix[10],0,0,0,0,1];Ni.buildFromRadian().setMatrix(y).apply(c)}e.generateFaces?o.getPolys().deepCopy(e._polys):o.getPolys().initialize(),e.generateLines?(o.getLines().deepCopy(e._lineCells),o.getPointData().setNormals(null)):o.getLines().initialize(),o.modified()}t.setBounds=function(){let n=[];if(Array.isArray(arguments.length<=0?void 0:arguments[0]))n=arguments.length<=0?void 0:arguments[0];else for(let i=0;i<arguments.length;i++)n.push(i<0||arguments.length<=i?void 0:arguments[i]);n.length===6&&(t.setXLength(n[1]-n[0]),t.setYLength(n[3]-n[2]),t.setZLength(n[5]-n[4]),t.setCenter([(n[0]+n[1])/2,(n[2]+n[3])/2,(n[4]+n[5])/2]))},t.requestData=r}const loe={xLength:1,yLength:1,zLength:1,pointType:"Float64Array",generate3DTextureCoordinates:!1,generateFaces:!0,generateLines:!1};function BN(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,loe,r),Z.obj(t,e),Z.setGet(t,e,["xLength","yLength","zLength","generate3DTextureCoordinates","generateFaces","generateLines"]),Z.setGetArray(t,e,["center","rotations"],3),Z.setGetArray(t,e,["matrix"],16),e._polys=_d.newInstance({values:Uint16Array.from(soe)}),e._lineCells=_d.newInstance({values:Uint16Array.from(aoe)}),Z.moveToProtected(t,e,["polys","lineCells"]),Z.algo(t,e,0,1),coe(t,e)}const uoe=Z.newInstance(BN,"vtkCubeSource");var GN={newInstance:uoe,extend:BN};const{vtkErrorMacro:ND}=Z;function foe(t,e){e.classHierarchy.push("vtkImageDataOutlineFilter");const r={...t};t.requestData=(n,i)=>{const o=n[0];if(!o||!o.isA("vtkImageData")){ND("Invalid or missing input");return}const a=o.getSpatialExtent();if(!a){ND("Unable to fetch spatial extents of input image.");return}e._cubeSource.setBounds(a),e._cubeSource.setMatrix(o.getIndexToWorld()),i[0]=e._cubeSource.getOutputData()},t.getMTime=()=>Math.max(r.getMTime(),e._cubeSource.getMTime()),t.setGenerateFaces=e._cubeSource.setGenerateFaces,t.setGenerateLines=e._cubeSource.setGenerateLines,t.getGenerateFaces=e._cubeSource.getGenerateFaces,t.getGenerateLines=e._cubeSource.getGenerateLines}const doe={};function WN(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,doe,r),Z.obj(t,e),Z.algo(t,e,1,1),e._cubeSource=GN.newInstance(),Z.moveToProtected(t,e,["cubeSource","tmpOut"]),foe(t,e)}const hoe=Z.newInstance(WN,"vtkImageDataOutlineFilter");var goe={newInstance:hoe,extend:WN};let $4;function poe(t,e){e.classHierarchy.push("vtkAbstractTransform","vtkHomogeneousTransform","vtkTransform"),t.transformPoint=(r,n)=>(At(n,r,e.matrix),n),t.transformPoints=(r,n)=>{const i=new Float64Array(3),o=new Float64Array(3);for(let a=0;a<r.length;a+=3)i[0]=r[a],i[1]=r[a+1],i[2]=r[a+2],At(o,i,e.matrix),n[a]=o[0],n[a+1]=o[1],n[a+2]=o[2];return n},t.preMultiply=()=>{t.setPreMultiplyFlag(!0)},t.postMultiply=()=>{t.setPreMultiplyFlag(!1)},t.transformMatrix=(r,n)=>(e.preMultiplyFlag?yn(n,e.matrix,r):yn(n,r,e.matrix),n),t.transformMatrices=(r,n)=>{const i=new Float64Array(16),o=new Float64Array(16),a=e.preMultiplyFlag?()=>yn(o,e.matrix,i):()=>yn(o,i,e.matrix);for(let s=0;s<r.length;s+=16){for(let c=0;c<16;++c)i[c]=r[s+c];a();for(let c=0;c<16;++c)n[s+c]=o[c]}return n},t.getInverse=()=>$4({matrix:Gt.invertMatrix(Array.from(e.matrix),[],4),preMultiplyFlag:e.preMultiplyFlag})}const moe={preMultiplyFlag:!1,matrix:[...W_]};function zN(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,moe,r),Z.obj(t,e),Z.setGet(t,e,["preMultiplyFlag"]),Z.setGetArray(t,e,["matrix"],16),poe(t,e)}$4=Z.newInstance(zN,"vtkTransform");var voe={newInstance:$4,extend:zN},yoe=`//VTK::System::Dec
|
||
|
||
/*=========================================================================
|
||
|
||
Program: Visualization Toolkit
|
||
Module: vtkImageResliceMapperVS.glsl
|
||
|
||
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
|
||
All rights reserved.
|
||
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
|
||
|
||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||
PURPOSE. See the above copyright notice for more information.
|
||
|
||
=========================================================================*/
|
||
|
||
// all variables that represent positions or directions have a suffix
|
||
// indicating the coordinate system they are in. The possible values are
|
||
// MC - Model coordinates
|
||
// WC - World coordinates
|
||
// VC - View coordinates
|
||
// DC - Display coordinates
|
||
// TC - Texture coordinates
|
||
|
||
// frag position in VC
|
||
//VTK::PositionVC::Dec
|
||
|
||
// Texture coordinates
|
||
//VTK::TCoord::Dec
|
||
|
||
// picking support
|
||
//VTK::Picking::Dec
|
||
|
||
// camera and actor matrix values
|
||
//VTK::Camera::Dec
|
||
|
||
void main()
|
||
{
|
||
//VTK::PositionVC::Impl
|
||
|
||
//VTK::TCoord::Impl
|
||
|
||
//VTK::Picking::Impl
|
||
}
|
||
`,woe=`//VTK::System::Dec
|
||
|
||
/*=========================================================================
|
||
|
||
Program: Visualization Toolkit
|
||
Module: vtkImageResliceMapperFS.glsl
|
||
|
||
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
|
||
All rights reserved.
|
||
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
|
||
|
||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||
PURPOSE. See the above copyright notice for more information.
|
||
|
||
=========================================================================*/
|
||
// Template for the gpu image mapper fragment shader
|
||
|
||
// VC position of this fragment
|
||
//VTK::PositionVC::Dec
|
||
|
||
// Texture coordinates
|
||
//VTK::TCoord::Dec
|
||
|
||
// picking support
|
||
//VTK::Picking::Dec
|
||
|
||
// handle coincident offsets
|
||
//VTK::Coincident::Dec
|
||
|
||
//VTK::ZBuffer::Dec
|
||
|
||
// the output of this shader
|
||
//VTK::Output::Dec
|
||
|
||
void main()
|
||
{
|
||
// VC position of this fragment. This should not branch/return/discard.
|
||
//VTK::PositionVC::Impl
|
||
|
||
// Place any calls that require uniform flow (e.g. dFdx) here.
|
||
//VTK::UniformFlow::Impl
|
||
|
||
// Set gl_FragDepth here (gl_FragCoord.z by default)
|
||
//VTK::Depth::Impl
|
||
|
||
// Early depth peeling abort:
|
||
//VTK::DepthPeeling::PreColor
|
||
|
||
//VTK::TCoord::Impl
|
||
|
||
if (gl_FragData[0].a <= 0.0)
|
||
{
|
||
discard;
|
||
}
|
||
|
||
//VTK::DepthPeeling::Impl
|
||
|
||
//VTK::Picking::Impl
|
||
|
||
// handle coincident offsets
|
||
//VTK::Coincident::Impl
|
||
|
||
//VTK::ZBuffer::Impl
|
||
|
||
//VTK::RenderPassFragmentShader::Impl
|
||
}
|
||
`;const{vtkErrorMacro:Rf}=uo;function kD(t,e,r){return e.identity(r),t.reduce((n,i,o)=>o===0?i?e.copy(n,i):e.identity(n):i?e.multiply(n,n,i):n,r)}function xoe(t,e){e.classHierarchy.push("vtkOpenGLImageResliceMapper");function r(i){[e._scalars,e._colorTransferFunc,e._pwFunc].forEach(o=>i.unregisterGraphicsResourceUser(o,t))}t.buildPass=i=>{if(i){e.currentRenderPass=null,e._openGLImageSlice=t.getFirstAncestorOfType("vtkOpenGLImageSlice"),e._openGLRenderer=t.getFirstAncestorOfType("vtkOpenGLRenderer");const o=e._openGLRenderer.getRenderable();e._openGLCamera=e._openGLRenderer.getViewNodeFor(o.getActiveCamera());const a=e._openGLRenderWindow;e._openGLRenderWindow=e._openGLRenderer.getLastAncestorOfType("vtkOpenGLRenderWindow"),a&&!a.isDeleted()&&a!==e._openGLRenderWindow&&r(a),e.context=e._openGLRenderWindow.getContext(),e.tris.setOpenGLRenderWindow(e._openGLRenderWindow)}},t.translucentPass=(i,o)=>{i&&(e.currentRenderPass=o,t.render())},t.zBufferPass=i=>{i&&(e.haveSeenDepthRequest=!0,e.renderDepth=!0,t.render(),e.renderDepth=!1)},t.opaqueZBufferPass=i=>t.zBufferPass(i),t.opaquePass=i=>{i&&t.render()},t.getCoincidentParameters=(i,o)=>e.renderable.getResolveCoincidentTopology()==pc.PolygonOffset?e.renderable.getCoincidentTopologyPolygonOffsetParameters():null,t.render=()=>{const i=e._openGLImageSlice.getRenderable(),o=e._openGLRenderer.getRenderable();t.renderPiece(o,i)},t.renderPiece=(i,o)=>{if(t.invokeEvent({type:"StartEvent"}),e.renderable.update(),e.currentInput=e.renderable.getInputData(),!e.currentInput){Rf("No input!");return}t.updateResliceGeometry(),t.renderPieceStart(i,o),t.renderPieceDraw(i,o),t.renderPieceFinish(i,o),t.invokeEvent({type:"EndEvent"})},t.renderPieceStart=(i,o)=>{t.updateBufferObjects(i,o),o.getProperty().getInterpolationType()===cd.NEAREST?(e.openGLTexture.setMinificationFilter(Pt.NEAREST),e.openGLTexture.setMagnificationFilter(Pt.NEAREST),e.colorTexture.setMinificationFilter(Pt.NEAREST),e.colorTexture.setMagnificationFilter(Pt.NEAREST),e.pwfTexture.setMinificationFilter(Pt.NEAREST),e.pwfTexture.setMagnificationFilter(Pt.NEAREST)):(e.openGLTexture.setMinificationFilter(Pt.LINEAR),e.openGLTexture.setMagnificationFilter(Pt.LINEAR),e.colorTexture.setMinificationFilter(Pt.LINEAR),e.colorTexture.setMagnificationFilter(Pt.LINEAR),e.pwfTexture.setMinificationFilter(Pt.LINEAR),e.pwfTexture.setMagnificationFilter(Pt.LINEAR)),e.lastBoundBO=null},t.renderPieceDraw=(i,o)=>{const a=e.context;e.openGLTexture.activate(),e.colorTexture.activate(),e.pwfTexture.activate(),t.updateShaders(e.tris,i,o),a.drawArrays(a.TRIANGLES,0,e.tris.getCABO().getElementCount()),e.tris.getVAO().release(),e.openGLTexture.deactivate(),e.colorTexture.deactivate(),e.pwfTexture.deactivate()},t.renderPieceFinish=(i,o)=>{},t.updateBufferObjects=(i,o)=>{t.getNeedToRebuildBufferObjects(i,o)&&t.buildBufferObjects(i,o)},t.getNeedToRebuildBufferObjects=(i,o)=>{var a,s,c;return e.VBOBuildTime.getMTime()<t.getMTime()||e.VBOBuildTime.getMTime()<o.getMTime()||e.VBOBuildTime.getMTime()<e.renderable.getMTime()||e.VBOBuildTime.getMTime()<o.getProperty().getMTime()||e.VBOBuildTime.getMTime()<e.currentInput.getMTime()||e.VBOBuildTime.getMTime()<e.resliceGeom.getMTime()||!((a=e.openGLTexture)!=null&&a.getHandle())||!((s=e.colorTexture)!=null&&s.getHandle())||!((c=e.pwfTexture)!=null&&c.getHandle())},t.buildBufferObjects=(i,o)=>{var E,b,D,I;const a=e.currentInput;if(!a)return;const s=(E=a.getPointData())==null?void 0:E.getScalars();if(!s)return;const c=s.getNumberOfComponents();let l=E4(a,s);const f=e._openGLRenderWindow.getGraphicsResourceForObject(s),u=!((b=f==null?void 0:f.oglObject)!=null&&b.getHandle())||(f==null?void 0:f.hash)!==l,d=e.renderable.getUpdatedExtents(),h=!!d.length;if(u&&!h){e.openGLTexture=mr.newInstance(),e.openGLTexture.setOpenGLRenderWindow(e._openGLRenderWindow),e.openGLTexture.setOglNorm16Ext(e.context.getExtension("EXT_texture_norm16")),e.openGLTexture.resetFormatAndType();const P=a.getDimensions();e.openGLTexture.create3DFilterableFromDataArray(P[0],P[1],P[2],s,!1,d),e._openGLRenderWindow.setGraphicsResourceForObject(s,e.openGLTexture,l),s!==e._scalars&&(e._openGLRenderWindow.registerGraphicsResourceUser(s,t),e._openGLRenderWindow.unregisterGraphicsResourceUser(e._scalars,t)),e._scalars=s}else e.openGLTexture=f.oglObject;if(h){e.renderable.setUpdatedExtents([]);const P=a.getDimensions();e.openGLTexture.create3DFilterableFromDataArray(P[0],P[1],P[2],s,!1,d)}const g=o.getProperty(),p=g.getIndependentComponents(),v=p?c:1,y=p?2*v:1,m=g.getRGBTransferFunction();l=il(m,p,v);const w=e._openGLRenderWindow.getGraphicsResourceForObject(m);if(!((D=w==null?void 0:w.oglObject)!=null&&D.getHandle())||(w==null?void 0:w.hash)!==l){const O=1024*y*3,L=new Uint8ClampedArray(O);if(e.colorTexture=mr.newInstance(),e.colorTexture.setOpenGLRenderWindow(e._openGLRenderWindow),m){const B=new Float32Array(3072);for(let H=0;H<v;H++){const A=g.getRGBTransferFunction(H),F=A.getRange();if(A.getTable(F[0],F[1],1024,B,1),p)for(let G=0;G<1024*3;G++)L[H*1024*6+G]=255*B[G],L[H*1024*6+G+1024*3]=255*B[G];else for(let G=0;G<1024*3;G++)L[H*1024*6+G]=255*B[G]}e.colorTexture.resetFormatAndType(),e.colorTexture.create2DFromRaw(1024,y,3,rn.UNSIGNED_CHAR,L)}else{for(let B=0;B<1024*3;++B)L[B]=255*B/(1023*3),L[B+1]=255*B/(1023*3),L[B+2]=255*B/(1023*3);e.colorTexture.resetFormatAndType(),e.colorTexture.create2DFromRaw(1024,1,3,rn.UNSIGNED_CHAR,L)}m&&(e._openGLRenderWindow.setGraphicsResourceForObject(m,e.colorTexture,l),m!==e._colorTransferFunc&&(e._openGLRenderWindow.registerGraphicsResourceUser(m,t),e._openGLRenderWindow.unregisterGraphicsResourceUser(e._colorTransferFunc,t)),e._colorTransferFunc=m)}else e.colorTexture=w.oglObject;const C=g.getPiecewiseFunction();l=il(C,p,v);const S=e._openGLRenderWindow.getGraphicsResourceForObject(C);if(!((I=S==null?void 0:S.oglObject)!=null&&I.getHandle())||(S==null?void 0:S.hash)!==l){const O=1024*y,L=new Uint8ClampedArray(O);if(e.pwfTexture=mr.newInstance(),e.pwfTexture.setOpenGLRenderWindow(e._openGLRenderWindow),C){const B=new Float32Array(O),H=new Float32Array(1024);for(let A=0;A<v;++A){const F=g.getPiecewiseFunction(A);if(F===null)B.fill(1);else{const G=F.getRange();if(F.getTable(G[0],G[1],1024,H,1),p)for(let X=0;X<1024;X++)B[A*1024*2+X]=H[X],B[A*1024*2+X+1024]=H[X];else for(let X=0;X<1024;X++)B[A*1024*2+X]=H[X]}}e.pwfTexture.resetFormatAndType(),e.pwfTexture.create2DFromRaw(1024,y,1,rn.FLOAT,B)}else L.fill(255),e.pwfTexture.resetFormatAndType(),e.pwfTexture.create2DFromRaw(1024,1,1,rn.UNSIGNED_CHAR,L);C&&(e._openGLRenderWindow.setGraphicsResourceForObject(C,e.pwfTexture,l),C!==e._pwFunc&&(e._openGLRenderWindow.registerGraphicsResourceUser(C,t),e._openGLRenderWindow.unregisterGraphicsResourceUser(e._pwFunc,t)),e._pwFunc=C)}else e.pwfTexture=S.oglObject;const _=`${e.resliceGeom.getMTime()}A${e.renderable.getSlabThickness()}`;if(!e.tris.getCABO().getElementCount()||e.VBOBuildString!==_){const P=bt.newInstance({numberOfComponents:3,values:e.resliceGeom.getPoints().getData()});P.setName("points");const O=bt.newInstance({numberOfComponents:1,values:e.resliceGeom.getPolys().getData()}),L={points:P,cellOffset:0};if(e.renderable.getSlabThickness()>0){const B=e.resliceGeom.getPointData().getNormals();B?L.normals=B:Rf("Slab mode requested without normals")}e.tris.getCABO().createVBO(O,"polys",ao.SURFACE,L)}e.VBOBuildString=_,e.VBOBuildTime.modified()},t.updateShaders=(i,o,a)=>{if(e.lastBoundBO=i,t.getNeedToRebuildShaders(i,o,a)){const s={Vertex:null,Fragment:null,Geometry:null};t.buildShaders(s,o,a);const c=e._openGLRenderWindow.getShaderCache().readyShaderProgramArray(s.Vertex,s.Fragment,s.Geometry);c!==i.getProgram()&&(i.setProgram(c),i.getVAO().releaseGraphicsResources()),i.getShaderSourceTime().modified()}else e._openGLRenderWindow.getShaderCache().readyShaderProgram(i.getProgram());i.getVAO().bind(),t.setMapperShaderParameters(i,o,a),t.setCameraShaderParameters(i,o,a),t.setPropertyShaderParameters(i,o,a)},t.setMapperShaderParameters=(i,o,a)=>{const s=i.getProgram();if(i.getCABO().getElementCount()&&(e.VBOBuildTime.getMTime()>i.getAttributeUpdateTime().getMTime()||i.getShaderSourceTime().getMTime()>i.getAttributeUpdateTime().getMTime())){s.isUniformUsed("texture1")&&s.setUniformi("texture1",e.openGLTexture.getTextureUnit()),s.isAttributeUsed("vertexWC")&&(i.getVAO().addAttributeArray(s,i.getCABO(),"vertexWC",i.getCABO().getVertexOffset(),i.getCABO().getStride(),e.context.FLOAT,3,e.context.FALSE)||Rf("Error setting vertexWC in shader VAO.")),s.isAttributeUsed("normalWC")&&(i.getVAO().addAttributeArray(s,i.getCABO(),"normalWC",i.getCABO().getNormalOffset(),i.getCABO().getStride(),e.context.FLOAT,3,e.context.FALSE)||Rf("Error setting normalWC in shader VAO.")),s.isUniformUsed("slabThickness")&&s.setUniformf("slabThickness",e.renderable.getSlabThickness()),s.isUniformUsed("spacing")&&s.setUniform3fv("spacing",e.currentInput.getSpacing()),s.isUniformUsed("slabType")&&s.setUniformi("slabType",e.renderable.getSlabType()),s.isUniformUsed("slabType")&&s.setUniformi("slabType",e.renderable.getSlabType()),s.isUniformUsed("slabTrapezoid")&&s.setUniformi("slabTrapezoid",e.renderable.getSlabTrapezoidIntegration());const l=i.getCABO().getCoordShiftAndScaleEnabled()?i.getCABO().getInverseShiftAndScaleMatrix():null;if(s.isUniformUsed("WCTCMatrix")){const f=e.currentInput,u=f.getDimensions();Cr(e.tmpMat4,f.getIndexToWorld()),er(e.tmpMat4,e.tmpMat4,[-.5,-.5,-.5]),nl(e.tmpMat4,e.tmpMat4,u),Ar(e.tmpMat4,e.tmpMat4),l&&yn(e.tmpMat4,e.tmpMat4,l),s.setUniformMatrix("WCTCMatrix",e.tmpMat4)}s.isUniformUsed("vboScaling")&&s.setUniform3fv("vboScaling",i.getCABO().getCoordScale()??[1,1,1]),i.getAttributeUpdateTime().modified()}if(e.haveSeenDepthRequest&&i.getProgram().setUniformi("depthRequest",e.renderDepth?1:0),i.getProgram().isUniformUsed("coffset")){const c=t.getCoincidentParameters(o,a);i.getProgram().setUniformf("coffset",c.offset),i.getProgram().isUniformUsed("cfactor")&&i.getProgram().setUniformf("cfactor",c.factor)}},t.setCameraShaderParameters=(i,o,a)=>{const s=e._openGLCamera.getKeyMatrices(o),c=e._openGLImageSlice.getKeyMatrices(),f=i.getCABO().getCoordShiftAndScaleEnabled()?i.getCABO().getInverseShiftAndScaleMatrix():null,u=i.getProgram();u.isUniformUsed("MCPCMatrix")&&(It(e.tmpMat4),u.setUniformMatrix("MCPCMatrix",kD([s.wcpc,c.mcwc,f],s1,e.tmpMat4))),u.isUniformUsed("MCVCMatrix")&&(It(e.tmpMat4),u.setUniformMatrix("MCVCMatrix",kD([s.wcvc,c.mcwc,f],s1,e.tmpMat4)))},t.setPropertyShaderParameters=(i,o,a)=>{const s=i.getProgram(),c=a.getProperty(),l=c.getOpacity();s.setUniformf("opacity",l);const f=e.openGLTexture.getComponents(),u=c.getIndependentComponents();if(u)for(let p=0;p<f;++p)s.setUniformf(`mix${p}`,c.getComponentWeight(p));const d=e.openGLTexture.getVolumeInfo();for(let p=0;p<f;p++){let v=c.getColorWindow(),y=c.getColorLevel();const m=u?p:0,w=c.getRGBTransferFunction(m);if(w&&c.getUseLookupTableScalarRange()){const S=w.getRange();v=S[1]-S[0],y=.5*(S[1]+S[0])}const x=d.scale[p]/v,C=(d.offset[p]-y)/v+.5;s.setUniformf(`cshift${p}`,C),s.setUniformf(`cscale${p}`,x)}const h=e.colorTexture.getTextureUnit();s.setUniformi("colorTexture1",h);for(let p=0;p<f;p++){let v=1,y=0;const m=u?p:0,w=c.getPiecewiseFunction(m);if(w){const x=w.getRange(),C=x[1]-x[0],S=.5*(x[0]+x[1]);v=d.scale[p]/C,y=(d.offset[p]-S)/C+.5}s.setUniformf(`pwfshift${p}`,y),s.setUniformf(`pwfscale${p}`,v)}const g=e.pwfTexture.getTextureUnit();s.setUniformi("pwfTexture1",g),s.setUniform4fv("backgroundColor",e.renderable.getBackgroundColor())},t.getNeedToRebuildShaders=(i,o,a)=>{var h;const s=e.openGLTexture.getComponents(),c=a.getProperty().getIndependentComponents(),l=e.renderable.getSlabThickness(),f=e.renderable.getSlabType(),u=e.renderable.getSlabTrapezoidIntegration();let d=!1;return(!e.currentRenderPass&&e.lastRenderPassShaderReplacement||e.currentRenderPass&&e.currentRenderPass.getShaderReplacement()!==e.lastRenderPassShaderReplacement)&&(d=!0),d||e.lastHaveSeenDepthRequest!==e.haveSeenDepthRequest||((h=i.getProgram())==null?void 0:h.getHandle())===0||e.lastTextureComponents!==s||e.lastIndependentComponents!==c||e.lastSlabThickness!==l||e.lastSlabType!==f||e.lastSlabTrapezoidIntegration!==u?(e.lastHaveSeenDepthRequest=e.haveSeenDepthRequest,e.lastTextureComponents=s,e.lastIndependentComponents=c,e.lastSlabThickness=l,e.lastSlabType=f,e.lastSlabTrapezoidIntegration=u,!0):!1},t.getShaderTemplate=(i,o,a)=>{i.Vertex=yoe,i.Fragment=woe,i.Geometry=""},t.replaceShaderValues=(i,o,a)=>{if(t.replaceShaderTCoord(i,o,a),t.replaceShaderPositionVC(i,o,a),e.haveSeenDepthRequest){let s=i.Fragment;s=Be.substitute(s,"//VTK::ZBuffer::Dec","uniform int depthRequest;").result,s=Be.substitute(s,"//VTK::ZBuffer::Impl",["if (depthRequest == 1) {","float iz = floor(gl_FragCoord.z*65535.0 + 0.1);","float rf = floor(iz/256.0)/255.0;","float gf = mod(iz,256.0)/255.0;","gl_FragData[0] = vec4(rf, gf, 0.0, 1.0); }"]).result,i.Fragment=s}t.replaceShaderCoincidentOffset(i,o,a)},t.replaceShaderTCoord=(i,o,a)=>{let s=i.Vertex;const c=i.Geometry;let l=i.Fragment;const f=["uniform mat4 WCTCMatrix;","out vec3 fragTexCoord;"],u=e.renderable.getSlabThickness();s=Be.substitute(s,"//VTK::TCoord::Dec",f).result;const d=["fragTexCoord = (WCTCMatrix * vertexWC).xyz;"];s=Be.substitute(s,"//VTK::TCoord::Impl",d).result;const h=e.openGLTexture.getComponents(),g=a.getProperty().getIndependentComponents();let p=["in vec3 fragTexCoord;","uniform highp sampler3D texture1;","uniform mat4 WCTCMatrix;","uniform float cshift0;","uniform float cscale0;","uniform float pwfshift0;","uniform float pwfscale0;","uniform sampler2D colorTexture1;","uniform sampler2D pwfTexture1;","uniform float opacity;","uniform vec4 backgroundColor;"];if(g){for(let y=1;y<h;y++)p=p.concat([`uniform float cshift${y};`,`uniform float cscale${y};`,`uniform float pwfshift${y};`,`uniform float pwfscale${y};`]);switch(h){case 1:p=p.concat(["uniform float mix0;","#define height0 0.5"]);break;case 2:p=p.concat(["uniform float mix0;","uniform float mix1;","#define height0 0.25","#define height1 0.75"]);break;case 3:p=p.concat(["uniform float mix0;","uniform float mix1;","uniform float mix2;","#define height0 0.17","#define height1 0.5","#define height2 0.83"]);break;case 4:p=p.concat(["uniform float mix0;","uniform float mix1;","uniform float mix2;","uniform float mix3;","#define height0 0.125","#define height1 0.375","#define height2 0.625","#define height3 0.875"]);break;default:Rf("Unsupported number of independent coordinates.")}}u>0&&(p=p.concat(["uniform vec3 spacing;","uniform float slabThickness;","uniform int slabType;","uniform int slabTrapezoid;","uniform vec3 vboScaling;"]),p=p.concat(["vec4 compositeValue(vec4 currVal, vec4 valToComp, int trapezoid)","{"," vec4 retVal = vec4(1.0);"," if (slabType == 0) // min"," {"," retVal = min(currVal, valToComp);"," }"," else if (slabType == 1) // max"," {"," retVal = max(currVal, valToComp);"," }"," else if (slabType == 3) // sum"," {"," retVal = currVal + (trapezoid > 0 ? 0.5 * valToComp : valToComp); "," }"," else // mean"," {"," retVal = currVal + (trapezoid > 0 ? 0.5 * valToComp : valToComp); "," }"," return retVal;","}"])),l=Be.substitute(l,"//VTK::TCoord::Dec",p).result;let v=["if (any(greaterThan(fragTexCoord, vec3(1.0))) || any(lessThan(fragTexCoord, vec3(0.0))))","{"," // set the background color and exit"," gl_FragData[0] = backgroundColor;"," return;","}","vec4 tvalue = texture(texture1, fragTexCoord);"];if(u>0&&(v=v.concat(["// Get the first and last samples","int numSlices = 1;","float scaling = min(min(spacing.x, spacing.y), spacing.z) * 0.5;","vec3 normalxspacing = scaling * normalWCVSOutput;","float distTraveled = length(normalxspacing);","int trapezoid = 0;","while (distTraveled < slabThickness * 0.5)","{"," distTraveled += length(normalxspacing);"," float fnumSlices = float(numSlices);"," if (distTraveled > slabThickness * 0.5)"," {"," // Before stepping outside the slab, sample at the boundaries"," normalxspacing = normalWCVSOutput * slabThickness * 0.5 / fnumSlices;"," trapezoid = slabTrapezoid;"," }"," vec3 fragTCoordNeg = (WCTCMatrix * vec4(vertexWCVSOutput.xyz - fnumSlices * normalxspacing * vboScaling, 1.0)).xyz;"," if (!any(greaterThan(fragTCoordNeg, vec3(1.0))) && !any(lessThan(fragTCoordNeg, vec3(0.0))))"," {"," vec4 newVal = texture(texture1, fragTCoordNeg);"," tvalue = compositeValue(tvalue, newVal, trapezoid);"," numSlices += 1;"," }"," vec3 fragTCoordPos = (WCTCMatrix * vec4(vertexWCVSOutput.xyz + fnumSlices * normalxspacing * vboScaling, 1.0)).xyz;"," if (!any(greaterThan(fragTCoordNeg, vec3(1.0))) && !any(lessThan(fragTCoordNeg, vec3(0.0))))"," {"," vec4 newVal = texture(texture1, fragTCoordPos);"," tvalue = compositeValue(tvalue, newVal, trapezoid);"," numSlices += 1;"," }","}","// Finally, if slab type is *mean*, divide the sum by the numSlices","if (slabType == 2)","{"," tvalue = tvalue / float(numSlices);","}"])),g){const y=["r","g","b","a"];for(let m=0;m<h;++m)v=v.concat([`vec3 tcolor${m} = mix${m} * texture2D(colorTexture1, vec2(tvalue.${y[m]} * cscale${m} + cshift${m}, height${m})).rgb;`,`float compWeight${m} = mix${m} * texture2D(pwfTexture1, vec2(tvalue.${y[m]} * pwfscale${m} + pwfshift${m}, height${m})).r;`]);switch(h){case 1:v=v.concat(["gl_FragData[0] = vec4(tcolor0.rgb, compWeight0 * opacity);"]);break;case 2:v=v.concat(["float weightSum = compWeight0 + compWeight1;","gl_FragData[0] = vec4(vec3((tcolor0.rgb * (compWeight0 / weightSum)) + (tcolor1.rgb * (compWeight1 / weightSum))), opacity);"]);break;case 3:v=v.concat(["float weightSum = compWeight0 + compWeight1 + compWeight2;","gl_FragData[0] = vec4(vec3((tcolor0.rgb * (compWeight0 / weightSum)) + (tcolor1.rgb * (compWeight1 / weightSum)) + (tcolor2.rgb * (compWeight2 / weightSum))), opacity);"]);break;case 4:v=v.concat(["float weightSum = compWeight0 + compWeight1 + compWeight2 + compWeight3;","gl_FragData[0] = vec4(vec3((tcolor0.rgb * (compWeight0 / weightSum)) + (tcolor1.rgb * (compWeight1 / weightSum)) + (tcolor2.rgb * (compWeight2 / weightSum)) + (tcolor3.rgb * (compWeight3 / weightSum))), opacity);"]);break;default:Rf("Unsupported number of independent coordinates.")}}else switch(h){case 1:v=v.concat(["// Dependent components","float intensity = tvalue.r;","vec3 tcolor = texture2D(colorTexture1, vec2(intensity * cscale0 + cshift0, 0.5)).rgb;","float scalarOpacity = texture2D(pwfTexture1, vec2(intensity * pwfscale0 + pwfshift0, 0.5)).r;","gl_FragData[0] = vec4(tcolor, scalarOpacity * opacity);"]);break;case 2:v=v.concat(["float intensity = tvalue.r*cscale0 + cshift0;","gl_FragData[0] = vec4(texture2D(colorTexture1, vec2(intensity, 0.5)).rgb, pwfscale0*tvalue.g + pwfshift0);"]);break;case 3:v=v.concat(["vec4 tcolor = cscale0*tvalue + cshift0;","gl_FragData[0] = vec4(texture2D(colorTexture1, vec2(tcolor.r,0.5)).r,"," texture2D(colorTexture1, vec2(tcolor.g,0.5)).r,"," texture2D(colorTexture1, vec2(tcolor.b,0.5)).r, opacity);"]);break;default:v=v.concat(["vec4 tcolor = cscale0*tvalue + cshift0;","gl_FragData[0] = vec4(texture2D(colorTexture1, vec2(tcolor.r,0.5)).r,"," texture2D(colorTexture1, vec2(tcolor.g,0.5)).r,"," texture2D(colorTexture1, vec2(tcolor.b,0.5)).r, tcolor.a);"])}l=Be.substitute(l,"//VTK::TCoord::Impl",v).result,i.Vertex=s,i.Fragment=l,i.Geometry=c},t.replaceShaderPositionVC=(i,o,a)=>{let s=i.Vertex;const c=i.Geometry;let l=i.Fragment;const f=e.renderable.getSlabThickness();let u=["attribute vec4 vertexWC;"];u=u.concat([`//${t.getMTime()}${e.resliceGeomUpdateString}`]),f>0&&(u=u.concat(["attribute vec3 normalWC;","varying vec3 normalWCVSOutput;","varying vec4 vertexWCVSOutput;"])),s=Be.substitute(s,"//VTK::PositionVC::Dec",u).result;let d=["gl_Position = MCPCMatrix * vertexWC;"];f>0&&(d=d.concat(["normalWCVSOutput = normalWC;","vertexWCVSOutput = vertexWC;"])),s=Be.substitute(s,"//VTK::PositionVC::Impl",d).result,s=Be.substitute(s,"//VTK::Camera::Dec",["uniform mat4 MCPCMatrix;","uniform mat4 MCVCMatrix;"]).result;let h=[];f>0&&(h=h.concat(["varying vec3 normalWCVSOutput;","varying vec4 vertexWCVSOutput;"])),l=Be.substitute(l,"//VTK::PositionVC::Dec",h).result,i.Vertex=s,i.Geometry=c,i.Fragment=l};function n(i){Gt.normalize(i);const o=[0,0,0];for(let a=0;a<3;++a){zY(o),o[a]=1;const s=Gt.dot(i,o);if(s<-.999999||s>.999999)return[!0,a]}return[!1,2]}t.updateResliceGeometry=()=>{var u;let i="";const o=e.currentInput,a=o==null?void 0:o.getBounds();let s=!0,c=2;const l=e.renderable.getSlicePolyData(),f=e.renderable.getSlicePlane();if(l)i=i.concat(`PolyData${l.getMTime()}`);else if(f){i=i.concat(`Plane${f.getMTime()}`);const d=J_();o&&(i=i.concat(`Image${o.getMTime()}`),kR(d,...o.getDirection()),em(d,d));const h=[...f.getNormal()];Cv(h,h,d),[s,c]=n(h)}else{const d=Io.newInstance();d.setNormal(0,0,1);let h=[0,1,0,1,0,1];o&&(h=a),d.setOrigin(h[0],h[2],.5*(h[5]+h[4])),e.renderable.setSlicePlane(d),i=i.concat(`Plane${f==null?void 0:f.getMTime()}`),o&&(i=i.concat(`Image${o.getMTime()}`))}if(!e.resliceGeom||e.resliceGeomUpdateString!==i){if(l)e.resliceGeom||(e.resliceGeom=Er.newInstance()),e.resliceGeom.getPoints().setData(l.getPoints().getData(),3),e.resliceGeom.getPolys().setData(l.getPolys().getData(),1),e.resliceGeom.getPointData().setNormals(l.getPointData().getNormals());else if(f)if(s){const d=new Float32Array(12),h=o.worldToIndex(f.getOrigin(),[0,0,0]),g=[(c+1)%3,(c+2)%3].sort(),p=o.getSpatialExtent();let v=0;for(let C=0;C<2;++C)for(let S=0;S<2;++S)d[v+c]=h[c],d[v+g[0]]=p[2*g[0]+S],d[v+g[1]]=p[2*g[1]+C],v+=3;e.transform.setMatrix(o.getIndexToWorld()),e.transform.transformPoints(d,d);const y=new Uint16Array(8);y[0]=3,y[1]=0,y[2]=1,y[3]=3,y[4]=3,y[5]=0,y[6]=3,y[7]=2;const m=f.getNormal();Gt.normalize(m);const w=new Float32Array(12);for(let C=0;C<4;++C)w[3*C]=m[0],w[3*C+1]=m[1],w[3*C+2]=m[2];e.resliceGeom||(e.resliceGeom=Er.newInstance()),e.resliceGeom.getPoints().setData(d,3),e.resliceGeom.getPolys().setData(y,1);const x=bt.newInstance({numberOfComponents:3,values:w,name:"Normals"});e.resliceGeom.getPointData().setNormals(x)}else{e.outlineFilter.setInputData(o),e.cutter.setInputConnection(e.outlineFilter.getOutputPort()),e.cutter.setCutFunction(f),e.lineToSurfaceFilter.setInputConnection(e.cutter.getOutputPort()),e.lineToSurfaceFilter.update(),e.resliceGeom||(e.resliceGeom=Er.newInstance());const d=e.lineToSurfaceFilter.getOutputData();e.resliceGeom.getPoints().setData(d.getPoints().getData(),3),e.resliceGeom.getPolys().setData(d.getPolys().getData(),1),e.resliceGeom.getPointData().setNormals(d.getPointData().getNormals());const h=f.getNormal(),g=e.resliceGeom.getNumberOfPoints();Gt.normalize(h);const p=new Float32Array(g*3);for(let y=0;y<g;++y)p[3*y]=h[0],p[3*y+1]=h[1],p[3*y+2]=h[2];const v=bt.newInstance({numberOfComponents:3,values:p,name:"Normals"});e.resliceGeom.getPointData().setNormals(v)}else Rf("Something went wrong.","A default slice plane should have been created in the beginning of","updateResliceGeometry.");e.resliceGeomUpdateString=i,(u=e.resliceGeom)==null||u.modified()}},t.setOpenGLTexture=i=>{i&&(e.openGLTexture=i,e._externalOpenGLTexture=!0)},t.delete=Y1(()=>{e._openGLRenderWindow&&r(e._openGLRenderWindow)},t.delete)}const Coe={VBOBuildTime:{},VBOBuildString:null,haveSeenDepthRequest:!1,lastHaveSeenDepthRequest:!1,lastIndependentComponents:!1,lastTextureComponents:0,lastSlabThickness:0,lastSlabTrapezoidIntegration:0,lastSlabType:-1,openGLTexture:null,colorTextureString:null,pwfTextureString:null,resliceGeom:null,resliceGeomUpdateString:null,tris:null,colorTexture:null,pwfTexture:null,_externalOpenGLTexture:!1};function Soe(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Coe,r),Qn.extend(t,e,r),rl.implementReplaceShaderCoincidentOffset(t,e,r),rl.implementBuildShadersWithReplacements(t,e,r),e.tris=ul.newInstance(),e.openGLTexture=null,e.colorTexture=null,e.pwfTexture=null,e.VBOBuildTime={},or(e.VBOBuildTime),e.tmpMat4=It(new Float64Array(16)),e.outlineFilter=goe.newInstance(),e.outlineFilter.setGenerateFaces(!0),e.outlineFilter.setGenerateLines(!1),e.cubePolyData=Er.newInstance(),e.cutter=ooe.newInstance(),e.lineToSurfaceFilter=eoe.newInstance(),e.transform=voe.newInstance(),Ro(t,e,["openGLTexture"]),xoe(t,e)}const Toe=Rn(Soe,"vtkOpenGLImageResliceMapper");di("vtkImageResliceMapper",Toe);const $N=Object.create(null);function xs(t,e){$N[t]=e}function _oe(t,e){e.classHierarchy.push("vtkWebGPUViewNodeFactory")}const Eoe={};function boe(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Eoe,r),e.overrides=$N,X_.extend(t,e,r),_oe(t,e)}Z.newInstance(boe,"vtkWebGPUViewNodeFactory");function Doe(t,e){e.classHierarchy.push("vtkWebGPUCamera"),t.getProjectionMatrix=(r,n,i,o)=>{if(It(r),e.renderable.getParallelProjection()){const a=e.renderable.getParallelScale(),s=a*n,c=a,l=(o[0]-1)*s,f=(o[0]+1)*s,u=(o[1]-1)*c,d=(o[1]+1)*c,h=1/(f-l),g=1/(d-u);r[0]=2*h,r[5]=2*g,r[10]=1/(i[1]-i[0]),r[12]=(f+l)*h,r[13]=(d+u)*g,r[14]=i[1]/(i[1]-i[0])}else{const a=Math.tan(Math.PI*e.renderable.getViewAngle()/360);let s,c;e.renderable.getUseHorizontalViewAngle()===!0?(s=i[0]*a,c=i[0]*a/n):(s=i[0]*a*n,c=i[0]*a);const l=(o[0]-1)*s,f=(o[0]+1)*s,u=(o[1]-1)*c,d=(o[1]+1)*c;r[0]=2*i[0]/(f-l),r[5]=2*i[0]/(d-u),r[12]=(l+f)/(f-l),r[13]=(u+d)/(d-u),r[10]=0,r[14]=i[0],r[11]=-1,r[15]=0}},t.convertToOpenGLDepth=r=>{if(e.renderable.getParallelProjection())return 1-r;const n=e.renderable.getClippingRangeByReference();let i=-n[0]/r;return i=(n[0]+n[1])/(n[1]-n[0])+2*n[0]*n[1]/(i*(n[1]-n[0])),.5*i+.5},t.getKeyMatrices=r=>{const n=r.getRenderable(),i=r.getParent();if(Math.max(i.getMTime(),t.getMTime(),n.getMTime(),e.renderable.getMTime(),r.getStabilizedTime())>e.keyMatrixTime.getMTime()){const o=e.renderable.getViewMatrix();Cr(e.keyMatrices.normalMatrix,o),e.keyMatrices.normalMatrix[3]=0,e.keyMatrices.normalMatrix[7]=0,e.keyMatrices.normalMatrix[11]=0,Ar(e.keyMatrices.normalMatrix,e.keyMatrices.normalMatrix),un(e.keyMatrices.wcvc,o);const a=r.getStabilizedCenterByReference();er(e.keyMatrices.scvc,e.keyMatrices.wcvc,a);const s=r.getAspectRatio(),c=e.renderable.getClippingRangeByReference();t.getProjectionMatrix(e.keyMatrices.vcpc,s,c,e.renderable.getWindowCenterByReference()),yn(e.keyMatrices.scpc,e.keyMatrices.vcpc,e.keyMatrices.scvc),Ar(e.keyMatrices.pcsc,e.keyMatrices.scpc),e.keyMatrixTime.modified()}return e.keyMatrices}}const Ioe={keyMatrixTime:null,keyMatrices:null};function Ooe(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Ioe,r),Qn.extend(t,e,r),e.keyMatrixTime={},Z.obj(e.keyMatrixTime),e.keyMatrices={normalMatrix:new Float64Array(16),vcpc:new Float64Array(16),pcsc:new Float64Array(16),wcvc:new Float64Array(16),scpc:new Float64Array(16),scvc:new Float64Array(16)},Z.setGet(t,e,["keyMatrixTime"]),Doe(t,e)}const Moe=Z.newInstance(Ooe);xs("vtkCamera",Moe);function Poe(t,e){e.classHierarchy.push("vtkWebGPUBindGroup"),t.setBindables=r=>{if(e.bindables.length===r.length){let n=!0;for(let i=0;i<e.bindables.length;i++)e.bindables[i]!==r[i]&&(n=!1);if(n)return}e.bindables=r,t.modified()},t.getBindGroupLayout=r=>{const n=[];for(let i=0;i<e.bindables.length;i++){const o=e.bindables[i].getBindGroupLayoutEntry();o.binding=i,n.push(o)}return r.getBindGroupLayout({entries:n})},t.getBindGroup=r=>{let n=t.getMTime();for(let o=0;o<e.bindables.length;o++){const a=e.bindables[o].getBindGroupTime().getMTime();n=a>n?a:n}if(n<e.bindGroupTime.getMTime())return e.bindGroup;const i=[];for(let o=0;o<e.bindables.length;o++){const a=e.bindables[o].getBindGroupEntry();a.binding=o,i.push(a)}return e.bindGroup=r.getHandle().createBindGroup({layout:t.getBindGroupLayout(r),entries:i,label:e.label}),e.bindGroupTime.modified(),e.bindGroup},t.getShaderCode=r=>{const n=[],i=r.getBindGroupLayoutCount(e.label);for(let o=0;o<e.bindables.length;o++)n.push(e.bindables[o].getShaderCode(o,i));return n.join(`
|
||
`)}}const Roe={device:null,handle:null,label:null};function jN(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Roe,r),Z.obj(t,e),e.bindables=[],e.bindGroupTime={},Z.obj(e.bindGroupTime,{mtime:0}),Z.get(t,e,["bindGroupTime","handle","sizeInBytes","usage"]),Z.setGet(t,e,["label","device","arrayInformation"]),Poe(t,e)}const Loe=Z.newInstance(jN);var HN={newInstance:Loe,extend:jN};function Aoe(t,e){e.classHierarchy.push("vtkWebGPUShaderModule"),t.initialize=(r,n)=>{e.device=r,e.handle=e.device.getHandle().createShaderModule({code:n.getCode()})}}const Noe={device:null,handle:null};function KN(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Noe,r),Z.obj(t,e),Z.get(t,e,["lastCameraMTime"]),Z.setGet(t,e,["device","handle"]),Aoe(t,e)}const koe=Z.newInstance(KN,"vtkWebGPUShaderModule");var Voe={newInstance:koe,extend:KN};function Foe(t,e,r){let n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0;const i=Array.isArray(r)?r.join(`
|
||
`):r;let o=!1;t.search(e)!==-1&&(o=!0);let a="";n&&(a="g");const s=new RegExp(e,a),c=t.replace(s,i);return{replace:o,result:c}}function Uoe(t,e){e.classHierarchy.push("vtkWebGPUShaderCache"),t.getShaderModule=r=>{const n=r.getType(),i=r.getHash(),o=e._shaderModules.keys();for(let s=0;s<o.length;s++){const c=o[s];if(c.getHash()===i&&c.getType()===n)return e._shaderModules.get(c)}const a=Voe.newInstance();return a.initialize(e.device,r),e._shaderModules.set(r,a),a}}const Boe={shaderModules:null,device:null,window:null};function qN(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Boe,r),e._shaderModules=new Map,Z.obj(t,e),Z.setGet(t,e,["device","window"]),Uoe(t,e)}const Goe=Z.newInstance(qN,"vtkWebGPUShaderCache");var Xn={newInstance:Goe,extend:qN,substitute:Foe};function Woe(t,e){e.classHierarchy.push("vtkWebGPUPipeline"),t.getShaderDescriptions=()=>e.shaderDescriptions,t.initialize=(r,n)=>{e.pipelineDescription=e.renderEncoder.getPipelineSettings(),e.pipelineDescription.primitive.topology=e.topology,e.pipelineDescription.vertex=e.vertexState,e.pipelineDescription.label=n;const i=[];for(let o=0;o<e.layouts.length;o++)i.push(e.layouts[o].layout);e.pipelineLayout=r.getHandle().createPipelineLayout({bindGroupLayouts:i}),e.pipelineDescription.layout=e.pipelineLayout;for(let o=0;o<e.shaderDescriptions.length;o++){const a=e.shaderDescriptions[o],s=r.getShaderModule(a);a.getType()==="vertex"&&(e.pipelineDescription.vertex.module=s.getHandle(),e.pipelineDescription.vertex.entryPoint="main"),a.getType()==="fragment"&&(e.pipelineDescription.fragment.module=s.getHandle(),e.pipelineDescription.fragment.entryPoint="main")}e.handle=r.getHandle().createRenderPipeline(e.pipelineDescription)},t.getShaderDescription=r=>{for(let n=0;n<e.shaderDescriptions.length;n++)if(e.shaderDescriptions[n].getType()===r)return e.shaderDescriptions[n];return null},t.addBindGroupLayout=r=>{r&&e.layouts.push({layout:r.getBindGroupLayout(e.device),label:r.getLabel()})},t.getBindGroupLayout=r=>e.layouts[r].layout,t.getBindGroupLayoutCount=r=>{for(let n=0;n<e.layouts.length;n++)if(e.layouts[n].label===r)return n;return 0},t.bindVertexInput=(r,n)=>{n.bindBuffers(r)}}const zoe={handle:null,layouts:null,renderEncoder:null,shaderDescriptions:null,vertexState:null,topology:null,pipelineDescription:null};function XN(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,zoe,r),or(t,e),e.layouts=[],e.shaderDescriptions=[],Ro(t,e,["handle","pipelineDescription"]),Jr(t,e,["device","renderEncoder","topology","vertexState"]),Woe(t,e)}const $oe=Rn(XN,"vtkWebGPUPipeline");var joe={newInstance:$oe,extend:XN};function Hoe(t,e){e.classHierarchy.push("vtkWebGPUShaderDescription"),t.hasOutput=r=>e.outputNames.includes(r),t.addOutput=function(r,n){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0;e.outputTypes.push(r),e.outputNames.push(n),e.outputInterpolations.push(i)},t.addBuiltinOutput=(r,n)=>{e.builtinOutputTypes.push(r),e.builtinOutputNames.push(n)},t.addBuiltinInput=(r,n)=>{e.builtinInputTypes.push(r),e.builtinInputNames.push(n)},t.replaceShaderCode=(r,n)=>{const i=[];let o=[];if(n&&i.push(n.getShaderCode()),r||e.builtinInputNames.length){const a=[];if(a.push(`struct ${e.type}Input
|
||
{`),r){const s=r.getOutputNamesByReference(),c=r.getOutputTypesByReference(),l=r.getOutputInterpolationsByReference();for(let f=0;f<s.length;f++)l[f]!==void 0?a.push(` @location(${f}) @interpolate(${l[f]}) ${s[f]} : ${c[f]},`):a.push(` @location(${f}) ${s[f]} : ${c[f]},`)}for(let s=0;s<e.builtinInputNames.length;s++)a.push(` ${e.builtinInputNames[s]} : ${e.builtinInputTypes[s]},`);a.length>1&&(a.push("};"),o=a,i[i.length-1]+=",",i.push(`input: ${e.type}Input`))}if(i.length&&(e.code=Xn.substitute(e.code,"//VTK::IOStructs::Input",i).result),e.outputNames.length+e.builtinOutputNames.length){const a=[`struct ${e.type}Output
|
||
{`];for(let s=0;s<e.outputNames.length;s++)e.outputInterpolations[s]!==void 0?a.push(` @location(${s}) @interpolate(${e.outputInterpolations[s]}) ${e.outputNames[s]} : ${e.outputTypes[s]},`):a.push(` @location(${s}) ${e.outputNames[s]} : ${e.outputTypes[s]},`);for(let s=0;s<e.builtinOutputNames.length;s++)a.push(` ${e.builtinOutputNames[s]} : ${e.builtinOutputTypes[s]},`);a.push("};"),o=o.concat(a),e.code=Xn.substitute(e.code,"//VTK::IOStructs::Output",[`-> ${e.type}Output`]).result}e.code=Xn.substitute(e.code,"//VTK::IOStructs::Dec",o).result}}const Koe={type:null,hash:null,code:null,outputNames:null,outputTypes:null};function YN(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Koe,r),e.outputNames=[],e.outputTypes=[],e.outputInterpolations=[],e.builtinOutputNames=[],e.builtinOutputTypes=[],e.builtinInputNames=[],e.builtinInputTypes=[],Z.obj(t,e),Z.setGet(t,e,["type","hash","code"]),Z.getArray(t,e,["outputTypes","outputNames","outputInterpolations"]),Hoe(t,e)}const qoe=Z.newInstance(YN,"vtkWebGPUShaderDescription");var VD={newInstance:qoe,extend:YN};const FD={r8unorm:{numComponents:1,nativeType:Uint8Array,stride:1,elementSize:1,sampleType:"float"},r8snorm:{numComponents:1,nativeType:Int8Array,stride:1,elementSize:1,sampleType:"float"},r8uint:{numComponents:1,nativeType:Uint8Array,stride:1,elementSize:1,sampleType:"uint"},r8sint:{numComponents:1,nativeType:Int8Array,stride:1,elementSize:1,sampleType:"sint"},r16uint:{numComponents:1,nativeType:Uint16Array,stride:2,elementSize:2,sampleType:"uint"},r16sint:{numComponents:1,nativeType:Int16Array,stride:2,elementSize:2,sampleType:"sint"},r16float:{numComponents:1,nativeType:Float32Array,stride:2,elementSize:2,sampleType:"float"},rg8unorm:{numComponents:2,nativeType:Uint8Array,stride:2,elementSize:1,sampleType:"float"},rg8snorm:{numComponents:2,nativeType:Int8Array,stride:2,elementSize:1,sampleType:"float"},rg8uint:{numComponents:2,nativeType:Uint8Array,stride:2,elementSize:1,sampleType:"uint"},rg8sint:{numComponents:2,nativeType:Int8Array,stride:2,elementSize:1,sampleType:"sint"},r32uint:{numComponents:1,nativeType:Uint32Array,stride:4,elementSize:4,sampleType:"uint"},r32sint:{numComponents:1,nativeType:Int32Array,stride:4,elementSize:4,sampleType:"sint"},r32float:{numComponents:1,nativeType:Float32Array,stride:4,elementSize:4,sampleType:"unfilterable-float"},rg16uint:{numComponents:2,nativeType:Uint16Array,stride:4,elementSize:2,sampleType:"uint"},rg16sint:{numComponents:2,nativeType:Int16Array,stride:4,elementSize:2,sampleType:"sint"},rg16float:{numComponents:2,nativeType:Float32Array,stride:4,elementSize:2,sampleType:"float"},rgba8unorm:{numComponents:4,nativeType:Uint8Array,stride:4,elementSize:1,sampleType:"float"},"rgba8unorm-srgb":{numComponents:4,nativeType:Uint8Array,stride:4,elementSize:1,sampleType:"float"},rgba8snorm:{numComponents:4,nativeType:Int8Array,stride:4,elementSize:1,sampleType:"float"},rgba8uint:{numComponents:4,nativeType:Uint8Array,stride:4,elementSize:1,sampleType:"uint"},rgba8sint:{numComponents:4,nativeType:Int8Array,stride:4,elementSize:1,sampleType:"sint"},bgra8unorm:{numComponents:4,nativeType:Uint8Array,stride:4,elementSize:1,sampleType:"float"},"bgra8unorm-srgb":{numComponents:4,nativeType:Uint8Array,stride:4,elementSize:1,sampleType:"float"},rgb9e5ufloat:{numComponents:4,nativeType:Uint32Array,stride:4,sampleType:"float"},rgb10a2unorm:{numComponents:4,nativeType:Uint32Array,stride:4,sampleType:"float"},rg11b10ufloat:{numComponents:4,nativeType:Float32Array,stride:4,sampleType:"float"},rg32uint:{numComponents:2,nativeType:Uint32Array,stride:8,elementSize:4,sampleType:"uint"},rg32sint:{numComponents:2,nativeType:Int32Array,stride:8,elementSize:4,sampleType:"sint"},rg32float:{numComponents:2,nativeType:Float32Array,stride:8,elementSize:4,sampleType:"unfilterable-float"},rgba16uint:{numComponents:4,nativeType:Uint16Array,stride:8,elementSize:2,sampleType:"uint"},rgba16sint:{numComponents:4,nativeType:Int16Array,stride:8,elementSize:2,sampleType:"sint"},rgba16float:{numComponents:4,nativeType:Float32Array,stride:8,elementSize:2,sampleType:"float"},rgba32uint:{numComponents:4,nativeType:Uint32Array,stride:16,elementSize:4,sampleType:"uint"},rgba32sint:{numComponents:4,nativeType:Int32Array,stride:16,elementSize:4,sampleType:"sint"},rgba32float:{numComponents:4,nativeType:Float32Array,stride:16,elementSize:4,sampleType:"unfilterable-float"},stencil8:{numComponents:1,nativeType:Uint8Array,stride:1,elementSize:1,sampleType:"uint"},depth16unorm:{numComponents:1,nativeType:Uint16Array,stride:2,elementSize:2,sampleType:"depth"},depth24plus:{numComponents:1,nativeType:Uint32Array,stride:4,elementSize:3,sampleType:"depth"},"depth24plus-stencil8":{numComponents:2,nativeType:Uint32Array,stride:4,sampleType:"mixed"},depth32float:{numComponents:1,nativeType:Float32Array,stride:4,elementSize:4,sampleType:"depth"}};function Xoe(t){return!t||t.length<6?0:t in FD?FD[t]:(vn(`unknown format ${t}`),null)}function Yoe(t){if(!t||t.length<5)return 0;let e=1;t[t.length-2]==="x"&&(e=Number(t[t.length-1]));const r=e===1?t.length-1:t.length-3,n=Number(t[r]);if(Number.isNaN(n))return vn(`unknown format ${t}`),0;const i=5-n/2;return e*i}function Joe(t){if(!t||t.length<5)return 0;let e=1;return t[t.length-2]==="x"&&(e=Number(t[t.length-1])),e}function Zoe(t){if(!t||t.length<5)return 0;let e;if(t[0]==="f")e="Float";else if(t[0]==="s")e="Int";else if(t[0]==="u")e="Uint";else{vn(`unknown format ${t}`);return}const r=t.split("x")[0],n=Number(r[r.length-1]);if(Number.isNaN(n)){vn(`unknown format ${t}`);return}return e+=8*(5-n/2),e+="Array",e}function Qoe(t){let e;if(t[0]==="f"||t[1]==="n")e="f32";else if(t[0]==="s"&&t[1]==="i")e="i32";else if(t[0]==="u"&&t[1]==="i")e="u32";else{vn(`unknown format ${t}`);return}let r=1;return t[t.length-2]==="x"&&(r=Number(t[t.length-1])),r===4?`vec4<${e}>`:r===3?`vec3<${e}>`:r===2?`vec2<${e}>`:e}function eae(t){if(!t)return 0;let e=1;return t.substring(0,3)==="vec"?e=Number(t[3]):t.substring(0,3)==="mat"&&(e=t[3]*t[5]),e*4}function tae(t){if(t){if(t.includes("f32"))return"Float32Array";if(t.includes("i32"))return"Int32Array";if(t.includes("u32"))return"Uint32Array";vn(`unknown format ${t}`)}}var io={getDetailsFromTextureFormat:Xoe,getByteStrideFromBufferFormat:Yoe,getNumberOfComponentsFromBufferFormat:Joe,getNativeTypeFromBufferFormat:Zoe,getShaderTypeFromBufferFormat:Qoe,getByteStrideFromShaderFormat:eae,getNativeTypeFromShaderFormat:tae};function nae(t,e){if(t===e)return!0;if(t==null||e==null||t.length!==e.length)return!1;for(let r=0;r<t.length;++r)if(!e.includes(t[r]))return!1;return!0}function rae(t,e){e.classHierarchy.push("vtkWebGPUVertexInput"),t.addBuffer=function(r,n){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"vertex",o=n;Array.isArray(o)||(o=[o]);for(let a=0;a<e.inputs.length;a++)if(nae(e.inputs[a].names,o)){if(e.inputs[a].buffer===r)return;e.inputs[a].buffer=r;return}e.inputs.push({buffer:r,stepMode:i,names:o}),e.inputs=e.inputs.sort((a,s)=>a.names[0]<s.names[0]?-1:a.names[0]>s.names[0]?1:0)},t.removeBufferIfPresent=r=>{for(let n=0;n<e.inputs.length;n++)e.inputs[n].names.includes(r)&&e.inputs.splice(n,1)},t.getBuffer=r=>{for(let n=0;n<e.inputs.length;n++)if(e.inputs[n].names.includes(r))return e.inputs[n].buffer;return null},t.hasAttribute=r=>{for(let n=0;n<e.inputs.length;n++)if(e.inputs[n].names.includes(r))return!0;return!1},t.getAttributeTime=r=>{for(let n=0;n<e.inputs.length;n++)if(e.inputs[n].names.includes(r))return e.inputs[n].buffer.getSourceTime();return 0},t.getShaderCode=()=>{let r="",n=0;for(let i=0;i<e.inputs.length;i++)for(let o=0;o<e.inputs[i].names.length;o++){const a=e.inputs[i].buffer.getArrayInformation()[o],s=io.getShaderTypeFromBufferFormat(a.format);n>0&&(r+=`,
|
||
`),r=`${r} @location(${n}) ${e.inputs[i].names[o]} : ${s}`,n++}return r},t.getVertexInputInformation=()=>{const r={};if(e.inputs.length){const n=[];let i=0;for(let o=0;o<e.inputs.length;o++){const a=e.inputs[o].buffer,s={arrayStride:a.getStrideInBytes(),stepMode:e.inputs[o].stepMode,attributes:[]},c=a.getArrayInformation();for(let l=0;l<e.inputs[o].names.length;l++)s.attributes.push({shaderLocation:i,offset:c[l].offset,format:c[l].format}),i++;n.push(s)}r.buffers=n}return r},t.bindBuffers=r=>{for(let n=0;n<e.inputs.length;n++)r.setVertexBuffer(n,e.inputs[n].buffer.getHandle());e.indexBuffer&&r.setIndexBuffer(e.indexBuffer.getHandle(),e.indexBuffer.getArrayInformation()[0].format)},t.getReady=()=>{},t.releaseGraphicsResources=()=>{e.created&&(e.inputs=[],e.bindingDescriptions=[],e.attributeDescriptions=[])}}const iae={inputs:null,bindingDescriptions:!1,attributeDescriptions:null,indexBuffer:null};function JN(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,iae,r),or(t,e),e.bindingDescriptions=[],e.attributeDescriptions=[],e.inputs=[],Jr(t,e,["created","device","handle","indexBuffer"]),rae(t,e)}const oae=Rn(JN,"vtkWebGPUVertexInput");var aae={newInstance:oae,extend:JN};const sae=`
|
||
//VTK::Renderer::Dec
|
||
|
||
//VTK::Color::Dec
|
||
|
||
//VTK::Normal::Dec
|
||
|
||
//VTK::TCoord::Dec
|
||
|
||
//VTK::Select::Dec
|
||
|
||
//VTK::Mapper::Dec
|
||
|
||
//VTK::IOStructs::Dec
|
||
|
||
@vertex
|
||
fn main(
|
||
//VTK::IOStructs::Input
|
||
)
|
||
//VTK::IOStructs::Output
|
||
{
|
||
var output : vertexOutput;
|
||
|
||
// var vertex: vec4<f32> = vertexBC;
|
||
|
||
//VTK::Color::Impl
|
||
|
||
//VTK::Normal::Impl
|
||
|
||
//VTK::TCoord::Impl
|
||
|
||
//VTK::Select::Impl
|
||
|
||
//VTK::Position::Impl
|
||
|
||
return output;
|
||
}
|
||
`,cae=`
|
||
//VTK::Renderer::Dec
|
||
|
||
//VTK::Color::Dec
|
||
|
||
//VTK::Normal::Dec
|
||
|
||
//VTK::TCoord::Dec
|
||
|
||
//VTK::Select::Dec
|
||
|
||
//VTK::RenderEncoder::Dec
|
||
|
||
//VTK::Mapper::Dec
|
||
|
||
//VTK::IOStructs::Dec
|
||
|
||
@fragment
|
||
fn main(
|
||
//VTK::IOStructs::Input
|
||
)
|
||
//VTK::IOStructs::Output
|
||
{
|
||
var output : fragmentOutput;
|
||
|
||
//VTK::Color::Impl
|
||
|
||
//VTK::Normal::Impl
|
||
|
||
//VTK::Light::Impl
|
||
|
||
//VTK::TCoord::Impl
|
||
|
||
//VTK::Select::Impl
|
||
|
||
// var computedColor:vec4<f32> = vec4<f32>(1.0,0.5,0.5,1.0);
|
||
|
||
//VTK::RenderEncoder::Impl
|
||
return output;
|
||
}
|
||
`;function lae(t,e){e.classHierarchy.push("vtkWebGPUSimpleMapper"),t.generateShaderDescriptions=(r,n,i)=>{const o=VD.newInstance({type:"vertex",hash:r,code:e.vertexShaderTemplate}),a=VD.newInstance({type:"fragment",hash:r,code:e.fragmentShaderTemplate}),s=n.getShaderDescriptions();s.push(o),s.push(a);const c=e.vertexShaderTemplate+e.fragmentShaderTemplate,l=new RegExp("//VTK::[^:]*::","g"),u=c.match(l).filter((d,h,g)=>g.indexOf(d)===h).map(d=>`replaceShader${d.substring(7,d.length-2)}`);for(let d=0;d<u.length;d++){const h=u[d];h!=="replaceShaderIOStructs"&&e.shaderReplacements.has(h)&&e.shaderReplacements.get(h)(r,n,i)}t.replaceShaderIOStructs(r,n,i)},t.replaceShaderIOStructs=(r,n,i)=>{const o=n.getShaderDescription("vertex");o.replaceShaderCode(null,i),n.getShaderDescription("fragment").replaceShaderCode(o)},t.replaceShaderRenderEncoder=(r,n,i)=>{e.renderEncoder.replaceShaderCode(n)},e.shaderReplacements.set("replaceShaderRenderEncoder",t.replaceShaderRenderEncoder),t.replaceShaderRenderer=(r,n,i)=>{if(!e.WebGPURenderer)return;const o=e.WebGPURenderer.getBindGroup().getShaderCode(n),a=n.getShaderDescription("vertex");let s=a.getCode();s=Xn.substitute(s,"//VTK::Renderer::Dec",[o]).result,a.setCode(s);const c=n.getShaderDescription("fragment");s=c.getCode(),s=Xn.substitute(s,"//VTK::Renderer::Dec",[o]).result,c.setCode(s)},e.shaderReplacements.set("replaceShaderRenderer",t.replaceShaderRenderer),t.replaceShaderMapper=(r,n,i)=>{const o=e.bindGroup.getShaderCode(n),a=n.getShaderDescription("vertex");let s=a.getCode();s=Xn.substitute(s,"//VTK::Mapper::Dec",[o]).result,a.setCode(s);const c=n.getShaderDescription("fragment");c.addBuiltinInput("bool","@builtin(front_facing) frontFacing"),s=c.getCode(),s=Xn.substitute(s,"//VTK::Mapper::Dec",[o]).result,c.setCode(s)},e.shaderReplacements.set("replaceShaderMapper",t.replaceShaderMapper),t.replaceShaderPosition=(r,n,i)=>{const o=n.getShaderDescription("vertex");o.addBuiltinOutput("vec4<f32>","@builtin(position) Position");let a=o.getCode();a=Xn.substitute(a,"//VTK::Position::Impl",[" output.Position = rendererUBO.SCPCMatrix*vertexBC;"]).result,o.setCode(a)},e.shaderReplacements.set("replaceShaderPosition",t.replaceShaderPosition),t.replaceShaderTCoord=(r,n,i)=>{n.getShaderDescription("vertex").addOutput("vec2<f32>","tcoordVS")},e.shaderReplacements.set("replaceShaderTCoord",t.replaceShaderTCoord),t.addTextureView=r=>{e.textureViews.includes(r)||e.textureViews.push(r)},t.prepareToDraw=r=>{e.renderEncoder=r,t.updateInput(),t.updateBuffers(),t.updateBindings(),t.updatePipeline()},t.updateInput=()=>{},t.updateBuffers=()=>{},t.updateBindings=()=>{e.bindGroup.setBindables(t.getBindables())},t.computePipelineHash=()=>{},t.registerDrawCallback=r=>{r.registerDrawCallback(e.pipeline,t.draw)},t.prepareAndDraw=r=>{t.prepareToDraw(r),r.setPipeline(e.pipeline),t.draw(r)},t.draw=r=>{const n=r.getBoundPipeline();r.activateBindGroup(e.bindGroup),e.WebGPURenderer&&e.WebGPURenderer.bindUBO(r),n.bindVertexInput(r,e.vertexInput);const i=e.vertexInput.getIndexBuffer();i?r.drawIndexed(i.getIndexCount(),e.numberOfInstances,0,0,0):r.draw(e.numberOfVertices,e.numberOfInstances,0,0)},t.getBindables=()=>{const r=[...e.additionalBindables];e.UBO&&r.push(e.UBO),e.SSBO&&r.push(e.SSBO);for(let n=0;n<e.textureViews.length;n++){r.push(e.textureViews[n]);const i=e.textureViews[n].getSampler();i&&r.push(i)}return r},t.updatePipeline=()=>{t.computePipelineHash(),e.pipeline=e.device.getPipeline(e.pipelineHash),e.pipeline||(e.pipeline=joe.newInstance(),e.pipeline.setDevice(e.device),e.WebGPURenderer&&e.pipeline.addBindGroupLayout(e.WebGPURenderer.getBindGroup()),e.pipeline.addBindGroupLayout(e.bindGroup),t.generateShaderDescriptions(e.pipelineHash,e.pipeline,e.vertexInput),e.pipeline.setTopology(e.topology),e.pipeline.setRenderEncoder(e.renderEncoder),e.pipeline.setVertexState(e.vertexInput.getVertexInputInformation()),e.device.createPipeline(e.pipelineHash,e.pipeline))}}const uae={additionalBindables:void 0,bindGroup:null,device:null,fragmentShaderTemplate:null,numberOfInstances:1,numberOfVertices:0,pipelineHash:null,shaderReplacements:null,SSBO:null,textureViews:null,topology:"triangle-list",UBO:null,vertexShaderTemplate:null,WebGPURenderer:null};function ZN(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,uae,r),Qn.extend(t,e,r),e.textureViews=[],e.vertexInput=aae.newInstance(),e.bindGroup=HN.newInstance({label:"mapperBG"}),e.additionalBindables=[],e.fragmentShaderTemplate=e.fragmentShaderTemplate||cae,e.vertexShaderTemplate=e.vertexShaderTemplate||sae,e.shaderReplacements=new Map,Z.get(t,e,["pipeline","vertexInput"]),Z.setGet(t,e,["additionalBindables","device","fragmentShaderTemplate","interpolate","numberOfInstances","numberOfVertices","pipelineHash","shaderReplacements","SSBO","textureViews","topology","UBO","vertexShaderTemplate","WebGPURenderer"]),lae(t,e)}const fae=Z.newInstance(ZN,"vtkWebGPUSimpleMapper");var QN={newInstance:fae,extend:ZN};function dae(t,e){e.classHierarchy.push("vtkWebGPUFullScreenQuad"),t.replaceShaderPosition=(r,n,i)=>{const o=n.getShaderDescription("vertex");o.addBuiltinOutput("vec4<f32>","@builtin(position) Position"),o.addOutput("vec4<f32>","vertexVC");let a=o.getCode();a=Xn.substitute(a,"//VTK::Position::Impl",["output.tcoordVS = vec2<f32>(vertexBC.x * 0.5 + 0.5, 1.0 - vertexBC.y * 0.5 - 0.5);","output.Position = vec4<f32>(vertexBC, 1.0);","output.vertexVC = vec4<f32>(vertexBC, 1);"]).result,o.setCode(a)},e.shaderReplacements.set("replaceShaderPosition",t.replaceShaderPosition),t.updateBuffers=()=>{const r=e.device.getBufferManager().getFullScreenQuadBuffer();e.vertexInput.addBuffer(r,["vertexBC"]),e.numberOfVertices=6}}const hae={};function ek(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,hae,r),QN.extend(t,e,r),dae(t,e)}const gae=Z.newInstance(ek,"vtkWebGPUFullScreenQuad");var TS={newInstance:gae,extend:ek};const pae={Verts:0,Lines:1,Triangles:2,Strips:3,LinesFromStrips:4,LinesFromTriangles:5,Points:6,UniformArray:7,PointArray:8,NormalsFromPoints:9,Texture:10,RawVertex:11,Storage:12,Index:13},mae={Start:0,Points:0,Lines:1,Triangles:2,TriangleStrips:3,TriangleEdges:4,TriangleStripEdges:5,End:6};var am={BufferUsage:pae,PrimitiveTypes:mae};const Jx=["getMappedRange","mapAsync","unmap"];function vae(t,e,r,n){const i=n.byteLength,o=t.createBuffer({size:i,usage:GPUBufferUsage.COPY_SRC,mappedAtCreation:!0}),a=o.getMappedRange(0,i);new Uint8Array(a).set(new Uint8Array(n)),o.unmap();const s=t.createCommandEncoder();s.copyBufferToBuffer(o,0,e,r,i);const c=s.finish();t.queue.submit([c]),o.destroy()}function yae(t,e){e.classHierarchy.push("vtkWebGPUBuffer"),t.create=(r,n)=>{e.handle=e.device.getHandle().createBuffer({size:r,usage:n,label:e.label}),e.sizeInBytes=r,e.usage=n},t.write=r=>{vae(e.device.getHandle(),e.handle,0,r.buffer)},t.createAndWrite=(r,n)=>{e.handle=e.device.getHandle().createBuffer({size:r.byteLength,usage:n,mappedAtCreation:!0,label:e.label}),e.sizeInBytes=r.byteLength,e.usage=n,new Uint8Array(e.handle.getMappedRange()).set(new Uint8Array(r.buffer)),e.handle.unmap()};for(let r=0;r<Jx.length;r++)t[Jx[r]]=function(){return e.handle[Jx[r]](...arguments)}}const wae={device:null,handle:null,sizeInBytes:0,strideInBytes:0,arrayInformation:null,usage:null,label:null,sourceTime:null};function tk(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,wae,r),Z.obj(t,e),Z.get(t,e,["handle","sizeInBytes","usage"]),Z.setGet(t,e,["strideInBytes","device","arrayInformation","label","sourceTime"]),yae(t,e)}const xae=Z.newInstance(tk);var _S={newInstance:xae,extend:tk,...am};const{Representation:UD}=Fd,{PrimitiveTypes:bu}=am;class Cae{constructor(){this.keys=new Uint32Array(10),this.values=new Uint32Array(10),this.count=0}clear(){this.count=0}has(e){for(let r=0;r<this.count;r++)if(this.keys[r]===e)return!0}get(e){for(let r=0;r<this.count;r++)if(this.keys[r]===e)return this.values[r]}set(e,r){this.count<9&&(this.keys[this.count]=e,this.values[this.count++]=r)}}function Sae(t){switch(t){case bu.Points:return"points";case bu.Lines:return"lines";case bu.Triangles:case bu.TriangleEdges:return"polys";case bu.TriangleStripEdges:case bu.TriangleStrips:return"strips";default:return""}}function v2(t,e,r){let n=t.pointIdToFlatId[e];return n<0&&(n=t.flatId,t.pointIdToFlatId[e]=n,t.flatIdToPointId[t.flatId]=e,t.flatIdToCellId[t.flatId]=r,t.flatId++),n}function Tae(t,e,r){const n=t.length;for(let a=0;a<n;a++){let s=t[a];if(r.cellProvokedMap.has(s)){r.ibo[r.iboId++]=r.cellProvokedMap.get(s);for(let c=a+1;c<a+n;c++){s=t[c%n];const l=v2(r,s,e);r.ibo[r.iboId++]=l}return}}for(let a=0;a<n;a++){let s=t[a];if(!r.provokedPointIds[s]){let c=v2(r,s,e);r.provokedPointIds[s]=1,r.cellProvokedMap.set(s,c),r.flatIdToCellId[c]=e,r.ibo[r.iboId++]=c;for(let l=a+1;l<a+n;l++)s=t[l%n],c=v2(r,s,e),r.ibo[r.iboId++]=c;return}}let i=t[0],o=r.flatId;r.cellProvokedMap.set(i,o),r.flatIdToPointId[r.flatId]=i,r.flatIdToCellId[r.flatId]=e,r.flatId++,r.ibo[r.iboId++]=o;for(let a=1;a<n;a++)i=t[a],o=v2(r,i,e),r.ibo[r.iboId++]=o}function _ae(t,e,r){const n=t.length;r.iboSize+=n;for(let i=0;i<n;i++){const o=t[i];if(r.cellProvokedMap.has(o))return}for(let i=0;i<n;i++){const o=t[i];if(!r.provokedPointIds[o]){r.provokedPointIds[o]=1,r.cellProvokedMap.set(o,1);return}}r.cellProvokedMap.set(t[0],1),r.extraPoints++}let Ml;const BD=new Uint32Array(1),is=new Uint32Array(2),pu=new Uint32Array(3),Zx={anythingToPoints(t,e,r,n,i){for(let o=0;o<t;++o)BD[0]=e[r+o],Ml(BD,n,i)},linesToWireframe(t,e,r,n,i){for(let o=0;o<t-1;++o)is[0]=e[r+o],is[1]=e[r+o+1],Ml(is,n,i)},polysToWireframe(t,e,r,n,i){if(t>2)for(let o=0;o<t;++o)is[0]=e[r+o],is[1]=e[r+(o+1)%t],Ml(is,n,i)},stripsToWireframe(t,e,r,n,i){if(t>2){for(let o=0;o<t-1;++o)is[0]=e[r+o],is[1]=e[r+o+1],Ml(is,n,i);for(let o=0;o<t-2;o++)is[0]=e[r+o],is[1]=e[r+o+2],Ml(is,n,i)}},polysToSurface(t,e,r,n,i){for(let o=0;o<t-2;o++)pu[0]=e[r],pu[1]=e[r+o+1],pu[2]=e[r+o+2],Ml(pu,n,i)},stripsToSurface(t,e,r,n,i){for(let o=0;o<t-2;o++)pu[0]=e[r+o],pu[1]=e[r+o+1+o%2],pu[2]=e[r+o+1+(o+1)%2],Ml(pu,n,i)}};function Eae(t,e){e.classHierarchy.push("vtkWebGPUIndexBuffer"),t.buildIndexBuffer=r=>{const n=r.cells,i=r.primitiveType,o=r.representation,a=r.cellOffset,s=n.getData(),c=s.length,l=Sae(i),f=r.numberOfPoints,u={provokedPointIds:new Uint8Array(f),extraPoints:0,iboSize:0,flatId:0,iboId:0,cellProvokedMap:new Cae};let d=null;o===UD.POINTS||i===bu.Points?d=Zx.anythingToPoints:o===UD.WIREFRAME||i===bu.Lines?d=Zx[`${l}ToWireframe`]:d=Zx[`${l}ToSurface`],Ml=_ae;let h=a||0;for(let g=0;g<c;)u.cellProvokedMap.clear(),d(s[g],s,g+1,h,u),g+=s[g]+1,h++;f<=65535?u.flatIdToPointId=new Uint16Array(f+u.extraPoints):u.flatIdToPointId=new Uint32Array(f+u.extraPoints),f+u.extraPoints<36863?u.pointIdToFlatId=new Int16Array(f):u.pointIdToFlatId=new Int32Array(f),f+u.extraPoints<=65535?(u.ibo=new Uint16Array(u.iboSize),r.format="uint16"):(u.ibo=new Uint32Array(u.iboSize),r.format="uint32"),h<=65535?u.flatIdToCellId=new Uint16Array(f+u.extraPoints):u.flatIdToCellId=new Uint32Array(f+u.extraPoints),u.pointIdToFlatId.fill(-1),u.provokedPointIds.fill(0),Ml=Tae,h=a||0;for(let g=0;g<c;)u.cellProvokedMap.clear(),d(s[g],s,g+1,h,u),g+=s[g]+1,h++;delete u.provokedPointIds,delete u.pointIdToFlatId,r.nativeArray=u.ibo,e.flatIdToPointId=u.flatIdToPointId,e.flatIdToCellId=u.flatIdToCellId,e.flatSize=u.flatId,e.indexCount=u.iboId}}const bae={flatIdToPointId:null,flatIdToCellId:null,flatSize:0,indexCount:0};function nk(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,bae,r),_S.extend(t,e,r),Z.setGet(t,e,["flatIdToPointId","flatIdToCellId","flatSize","indexCount"]),Eae(t,e)}const Dae=Z.newInstance(nk);var Iae={newInstance:Dae,extend:nk,...am};const{BufferUsage:mu}=am,{vtkErrorMacro:Oae}=uo,{VtkDataTypes:Lf}=bt,Mae={};function Pae(t){let e;switch(t.getDataType()){case Lf.UNSIGNED_CHAR:e="uint8";break;case Lf.FLOAT:e="float32";break;case Lf.UNSIGNED_INT:e="uint32";break;case Lf.INT:e="sint32";break;case Lf.DOUBLE:e="float32";break;case Lf.UNSIGNED_SHORT:e="uint16";break;case Lf.SHORT:e="sin16";break;default:e="float32";break}switch(t.getNumberOfComponents()){case 2:e+="x2";break;case 3:e.includes("32")||Oae(`unsupported x3 type for ${e}`),e+="x3";break;case 4:e+="x4";break}return e}function GD(t,e,r,n,i){const o={},a=t.getFlatSize();if(!a)return o;let s=[0,0,0,0];i.shift&&(i.shift.length?s=i.shift:s.fill(i.shift));let c=[1,1,1,1];i.scale&&(i.scale.length?c=i.scale:c.fill(i.scale));const l=Object.prototype.hasOwnProperty.call(i,"packExtra")?i.packExtra:!1;let f,u=0;const d=r+(l?1:0),h=Uh(n,a*d);let g=t.getFlatIdToPointId();i.cellData&&(g=t.getFlatIdToCellId()),r===1?f=function(v){h[u++]=c[0]*e[v]+s[0]}:r===2?f=function(v){h[u++]=c[0]*e[v]+s[0],h[u++]=c[1]*e[v+1]+s[1]}:r===3&&!l?f=function(v){h[u++]=c[0]*e[v]+s[0],h[u++]=c[1]*e[v+1]+s[1],h[u++]=c[2]*e[v+2]+s[2]}:r===3&&l?f=function(v){h[u++]=c[0]*e[v]+s[0],h[u++]=c[1]*e[v+1]+s[1],h[u++]=c[2]*e[v+2]+s[2],h[u++]=c[3]*1+s[3]}:r===4&&(f=function(v){h[u++]=c[0]*e[v]+s[0],h[u++]=c[1]*e[v+1]+s[1],h[u++]=c[2]*e[v+2]+s[2],h[u++]=c[3]*e[v+3]+s[3]});for(let p=0;p<a;p++){const v=r*g[p];f(v)}return o.nativeArray=h,o}function Rae(t,e,r,n){const i=[t[n*3]-t[r*3],t[n*3+1]-t[r*3+1],t[n*3+2]-t[r*3+2]],o=[t[e*3]-t[r*3],t[e*3+1]-t[r*3+1],t[e*3+2]-t[r*3+2]],a=[];return tl(i,o,a),Td(a),a}function Lae(t,e){const r=e.getData(),n=t.getData();if(!n||!r)return null;const i=new Int8Array(t.getNumberOfCells()*4),o=n.length;let a=0;for(let s=0;s<o;){const c=Rae(r,n[s+1],n[s+2],n[s+3]);i[a++]=127*c[0],i[a++]=127*c[1],i[a++]=127*c[2],i[a++]=127,s+=n[s]+1}return i}function Aae(t,e){e.classHierarchy.push("vtkWebGPUBufferManager");function r(n){n.dataArray&&!n.nativeArray&&(n.nativeArray=n.dataArray.getData());let i,o;if(n.usage===mu.Index&&(i=Iae.newInstance({label:n.label}),i.setDevice(e.device),o=GPUBufferUsage.INDEX|GPUBufferUsage.COPY_DST,i.buildIndexBuffer(n),i.createAndWrite(n.nativeArray,o),i.setArrayInformation([{format:n.format}])),i||(i=_S.newInstance({label:n.label}),i.setDevice(e.device)),n.usage===mu.UniformArray&&(o=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,i.createAndWrite(n.nativeArray,o)),n.usage===mu.Storage&&(o=GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST,i.createAndWrite(n.nativeArray,o)),n.usage===mu.Texture&&(o=GPUBufferUsage.COPY_SRC,i.createAndWrite(n.nativeArray,o)),n.usage===mu.PointArray){o=GPUBufferUsage.VERTEX;const a=io.getNativeTypeFromBufferFormat(n.format),s=GD(n.indexBuffer,n.dataArray.getData(),n.dataArray.getNumberOfComponents(),a,{packExtra:n.packExtra,shift:n.shift,scale:n.scale,cellData:n.cellData,cellOffset:n.cellOffset});i.createAndWrite(s.nativeArray,o),i.setStrideInBytes(io.getByteStrideFromBufferFormat(n.format)),i.setArrayInformation([{offset:0,format:n.format,interpolation:n.cellData?"flat":"perspective"}])}if(n.usage===mu.NormalsFromPoints){o=GPUBufferUsage.VERTEX;const a=io.getNativeTypeFromBufferFormat(n.format),s=Lae(n.cells,n.dataArray),c=GD(n.indexBuffer,s,4,a,{cellData:!0});i.createAndWrite(c.nativeArray,o),i.setStrideInBytes(io.getByteStrideFromBufferFormat(n.format)),i.setArrayInformation([{offset:0,format:n.format,interpolation:"flat"}])}return n.usage===mu.RawVertex&&(o=GPUBufferUsage.VERTEX,i.createAndWrite(n.nativeArray,o),i.setStrideInBytes(io.getByteStrideFromBufferFormat(n.format)),i.setArrayInformation([{offset:0,format:n.format}])),i.setSourceTime(n.time),i}t.hasBuffer=n=>e.device.hasCachedObject(n),t.getBuffer=n=>n.hash?e.device.getCachedObject(n.hash,r,n):r(n),t.getBufferForPointArray=(n,i)=>{const o=Pae(n),a={hash:`${n.getMTime()}I${i.getMTime()}${o}`,usage:mu.PointArray,format:o,dataArray:n,indexBuffer:i};return t.getBuffer(a)},t.getFullScreenQuadBuffer=()=>{if(e.fullScreenQuadBuffer)return e.fullScreenQuadBuffer;e.fullScreenQuadBuffer=_S.newInstance(),e.fullScreenQuadBuffer.setDevice(e.device);const n=new Float32Array([-1,-1,0,1,-1,0,1,1,0,-1,-1,0,1,1,0,-1,1,0]);return e.fullScreenQuadBuffer.createAndWrite(n,GPUBufferUsage.VERTEX),e.fullScreenQuadBuffer.setStrideInBytes(12),e.fullScreenQuadBuffer.setArrayInformation([{offset:0,format:"float32x3"}]),e.fullScreenQuadBuffer}}const Nae={device:null,fullScreenQuadBuffer:null};function kae(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Nae,r),or(t,e),Jr(t,e,["device"]),Aae(t,e)}Rn(kae);var jh={...Mae,...am};const{BufferUsage:Vae}=jh,{vtkErrorMacro:Jd}=Z;function Fae(t,e){e.classHierarchy.push("vtkWebGPUStorageBuffer"),t.addEntry=(r,n)=>{if(e._bufferEntryNames.has(r)){Jd(`entry named ${r} already exists`);return}e._bufferEntryNames.set(r,e.bufferEntries.length);const i=io.getByteStrideFromShaderFormat(n);e.bufferEntries.push({name:r,type:n,sizeInBytes:i,offset:e.sizeInBytes,nativeType:io.getNativeTypeFromShaderFormat(n)}),e.sizeInBytes+=i},t.send=r=>{if(!e._buffer){const n={nativeArray:e.Float32Array,usage:Vae.Storage,label:e.label};e._buffer=r.getBufferManager().getBuffer(n),e.bindGroupTime.modified(),e._sendTime.modified();return}r.getHandle().queue.writeBuffer(e._buffer.getHandle(),0,e.arrayBuffer,0,e.sizeInBytes*e.numberOfInstances),e._sendTime.modified()},t.createView=r=>{r in e||(e.arrayBuffer||(e.arrayBuffer=new ArrayBuffer(e.sizeInBytes*e.numberOfInstances)),e[r]=Z.newTypedArray(r,e.arrayBuffer))},t.setValue=(r,n,i)=>{const o=e._bufferEntryNames.get(r);if(o===void 0){Jd(`entry named ${r} not found in UBO`);return}const a=e.bufferEntries[o];t.createView(a.nativeType);const s=e[a.nativeType];s[(a.offset+n*e.sizeInBytes)/s.BYTES_PER_ELEMENT]=i},t.setArray=(r,n,i)=>{const o=e._bufferEntryNames.get(r);if(o===void 0){Jd(`entry named ${r} not found in UBO`);return}const a=e.bufferEntries[o];t.createView(a.nativeType);const s=e[a.nativeType],c=(a.offset+n*e.sizeInBytes)/s.BYTES_PER_ELEMENT;for(let l=0;l<i.length;l++)s[c+l]=i[l]},t.setAllInstancesFromArray=(r,n)=>{const i=e._bufferEntryNames.get(r);if(i===void 0){Jd(`entry named ${r} not found in UBO`);return}const o=e.bufferEntries[i];t.createView(o.nativeType);const a=e[o.nativeType],s=n.length/e.numberOfInstances;for(let c=0;c<e.numberOfInstances;c++){const l=(o.offset+c*e.sizeInBytes)/a.BYTES_PER_ELEMENT;for(let f=0;f<s;f++)a[l+f]=n[c*s+f]}},t.setAllInstancesFromArrayColorToFloat=(r,n)=>{const i=e._bufferEntryNames.get(r);if(i===void 0){Jd(`entry named ${r} not found in UBO`);return}const o=e.bufferEntries[i];t.createView(o.nativeType);const a=e[o.nativeType],s=n.length/e.numberOfInstances;for(let c=0;c<e.numberOfInstances;c++){const l=(o.offset+c*e.sizeInBytes)/a.BYTES_PER_ELEMENT;for(let f=0;f<s;f++)a[l+f]=n[c*s+f]/255}},t.setAllInstancesFromArray3x3To4x4=(r,n)=>{const i=e._bufferEntryNames.get(r);if(i===void 0){Jd(`entry named ${r} not found in UBO`);return}const o=e.bufferEntries[i];t.createView(o.nativeType);const a=e[o.nativeType],s=9;for(let c=0;c<e.numberOfInstances;c++){const l=(o.offset+c*e.sizeInBytes)/a.BYTES_PER_ELEMENT;for(let f=0;f<3;f++)for(let u=0;u<3;u++)a[l+f*4+u]=n[c*s+f*3+u]}},t.getSendTime=()=>e._sendTime.getMTime(),t.getShaderCode=(r,n)=>{const i=[`struct ${e.label}StructEntry
|
||
{`];for(let o=0;o<e.bufferEntries.length;o++){const a=e.bufferEntries[o];i.push(` ${a.name}: ${a.type},`)}return i.push(`
|
||
};
|
||
struct ${e.label}Struct
|
||
{
|
||
values: array<${e.label}StructEntry>,
|
||
};
|
||
@binding(${r}) @group(${n}) var<storage, read> ${e.label}: ${e.label}Struct;
|
||
`),i.join(`
|
||
`)},t.getBindGroupEntry=()=>({resource:{buffer:e._buffer.getHandle()}}),t.clearData=()=>{e.numberOfInstances=0,e.sizeInBytes=0,e.bufferEntries=[],e._bufferEntryNames=new Map,e._buffer=null,delete e.arrayBuffer,delete e.Float32Array}}const Uae={bufferEntries:null,bufferEntryNames:null,sizeInBytes:0,label:null,numberOfInstances:1};function rk(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Uae,r),Z.obj(t,e),e._bufferEntryNames=new Map,e.bufferEntries=[],e._sendTime={},Z.obj(e._sendTime,{mtime:0}),e.bindGroupTime={},Z.obj(e.bindGroupTime,{mtime:0}),e.bindGroupLayoutEntry=e.bindGroupLayoutEntry||{buffer:{type:"read-only-storage"}},Z.get(t,e,["bindGroupTime"]),Z.setGet(t,e,["device","bindGroupLayoutEntry","label","numberOfInstances","sizeInBytes"]),Fae(t,e)}const Bae=Z.newInstance(rk,"vtkWebGPUStorageBuffer");var Gae={newInstance:Bae,extend:rk};const{BufferUsage:Wae}=jh,{vtkErrorMacro:Qx}=Z;function zae(t,e){e.classHierarchy.push("vtkWebGPUUniformBuffer"),t.addEntry=(r,n)=>{if(e._bufferEntryNames.has(r)){Qx(`entry named ${r} already exists`);return}e.sortDirty=!0,e._bufferEntryNames.set(r,e.bufferEntries.length),e.bufferEntries.push({name:r,type:n,sizeInBytes:io.getByteStrideFromShaderFormat(n),offset:-1,nativeType:io.getNativeTypeFromShaderFormat(n),packed:!1})},t.sortBufferEntries=()=>{if(!e.sortDirty)return;let r=0;const n=[];let i=4;for(let o=0;o<e.bufferEntries.length;o++){const a=e.bufferEntries[o];a.sizeInBytes%16===0&&(i=Math.max(16,i)),a.sizeInBytes%8===0&&(i=Math.max(8,i))}for(let o=0;o<e.bufferEntries.length;o++){const a=e.bufferEntries[o];a.packed===!1&&a.sizeInBytes%16===0&&(a.packed=!0,a.offset=r,n.push(a),r+=a.sizeInBytes)}for(let o=0;o<e.bufferEntries.length;o++){const a=e.bufferEntries[o];if(a.packed===!1&&a.sizeInBytes===12)for(let s=0;s<e.bufferEntries.length;s++){const c=e.bufferEntries[s];if(c.packed===!1&&c.sizeInBytes===4){a.packed=!0,a.offset=r,n.push(a),r+=a.sizeInBytes,c.packed=!0,c.offset=r,n.push(c),r+=c.sizeInBytes;break}}}for(let o=0;o<e.bufferEntries.length;o++){const a=e.bufferEntries[o];if(!a.packed&&a.sizeInBytes%8===0)for(let s=o+1;s<e.bufferEntries.length;s++){const c=e.bufferEntries[s];if(!c.packed&&c.sizeInBytes%8===0){a.packed=!0,a.offset=r,n.push(a),r+=a.sizeInBytes,c.packed=!0,c.offset=r,n.push(c),r+=c.sizeInBytes;break}}}for(let o=0;o<e.bufferEntries.length;o++){const a=e.bufferEntries[o];if(!a.packed&&a.sizeInBytes%8===0){let s=!1;for(let c=0;!s&&c<e.bufferEntries.length;c++){const l=e.bufferEntries[c];if(!l.packed&&l.sizeInBytes===4)for(let f=c+1;f<e.bufferEntries.length;f++){const u=e.bufferEntries[f];if(!u.packed&&u.sizeInBytes===4){a.packed=!0,a.offset=r,n.push(a),r+=a.sizeInBytes,l.packed=!0,l.offset=r,n.push(l),r+=l.sizeInBytes,u.packed=!0,u.offset=r,n.push(u),r+=u.sizeInBytes,s=!0;break}}}}}for(let o=0;o<e.bufferEntries.length;o++){const a=e.bufferEntries[o];!a.packed&&a.sizeInBytes>4&&(a.packed=!0,a.offset=r,n.push(a),r+=a.sizeInBytes)}for(let o=0;o<e.bufferEntries.length;o++){const a=e.bufferEntries[o];a.packed||(a.packed=!0,a.offset=r,n.push(a),r+=a.sizeInBytes)}e.bufferEntries=n,e._bufferEntryNames.clear();for(let o=0;o<e.bufferEntries.length;o++)e._bufferEntryNames.set(e.bufferEntries[o].name,o);e.sizeInBytes=r,e.sizeInBytes=i*Math.ceil(e.sizeInBytes/i),e.sortDirty=!1},t.sendIfNeeded=r=>{if(!e.UBO){const n={nativeArray:e.Float32Array,usage:Wae.UniformArray,label:e.label};e.UBO=r.getBufferManager().getBuffer(n),e.bindGroupTime.modified(),e.sendDirty=!1}e.sendDirty&&(r.getHandle().queue.writeBuffer(e.UBO.getHandle(),0,e.arrayBuffer,0,e.sizeInBytes),e.sendDirty=!1),e.sendTime.modified()},t.createView=r=>{r in e||(e.arrayBuffer||(e.arrayBuffer=new ArrayBuffer(e.sizeInBytes)),e[r]=Z.newTypedArray(r,e.arrayBuffer))},t.setValue=(r,n)=>{t.sortBufferEntries();const i=e._bufferEntryNames.get(r);if(i===void 0){Qx(`entry named ${r} not found in UBO`);return}const o=e.bufferEntries[i];t.createView(o.nativeType);const a=e[o.nativeType];o.lastValue!==n&&(a[o.offset/a.BYTES_PER_ELEMENT]=n,e.sendDirty=!0),o.lastValue=n},t.setArray=(r,n)=>{t.sortBufferEntries();const i=e._bufferEntryNames.get(r);if(i===void 0){Qx(`entry named ${r} not found in UBO`);return}const o=e.bufferEntries[i];t.createView(o.nativeType);const a=e[o.nativeType];let s=!1;for(let c=0;c<n.length;c++)(!o.lastValue||o.lastValue[c]!==n[c])&&(a[o.offset/a.BYTES_PER_ELEMENT+c]=n[c],s=!0);s&&(e.sendDirty=!0,o.lastValue=[...n])},t.getBindGroupEntry=()=>({resource:{buffer:e.UBO.getHandle()}}),t.getSendTime=()=>e.sendTime.getMTime(),t.getShaderCode=(r,n)=>{t.sortBufferEntries();const i=[`struct ${e.label}Struct
|
||
{`];for(let o=0;o<e.bufferEntries.length;o++){const a=e.bufferEntries[o];i.push(` ${a.name}: ${a.type},`)}return i.push(`};
|
||
@binding(${r}) @group(${n}) var<uniform> ${e.label}: ${e.label}Struct;`),i.join(`
|
||
`)}}const $ae={bufferEntries:null,bufferEntryNames:null,sizeInBytes:0,label:null,bindGroupLayoutEntry:null,bindGroupEntry:null};function ik(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,$ae,r),Z.obj(t,e),e._bufferEntryNames=new Map,e.bufferEntries=[],e.bindGroupLayoutEntry=e.bindGroupLayoutEntry||{buffer:{type:"uniform"}},e.sendTime={},Z.obj(e.sendTime,{mtime:0}),e.bindGroupTime={},Z.obj(e.bindGroupTime,{mtime:0}),e.sendDirty=!0,e.sortDirty=!0,Z.get(t,e,["binding","bindGroupTime"]),Z.setGet(t,e,["bindGroupLayoutEntry","device","label","sizeInBytes"]),zae(t,e)}const jae=Z.newInstance(ik,"vtkWebGPUUniformBuffer");var J0={newInstance:jae,extend:ik};const{vtkDebugMacro:Hae}=uo,WD=`
|
||
//VTK::Renderer::Dec
|
||
|
||
//VTK::Mapper::Dec
|
||
|
||
//VTK::TCoord::Dec
|
||
|
||
//VTK::RenderEncoder::Dec
|
||
|
||
//VTK::IOStructs::Dec
|
||
|
||
@fragment
|
||
fn main(
|
||
//VTK::IOStructs::Input
|
||
)
|
||
//VTK::IOStructs::Output
|
||
{
|
||
var output: fragmentOutput;
|
||
|
||
var computedColor: vec4<f32> = mapperUBO.BackgroundColor;
|
||
|
||
//VTK::RenderEncoder::Impl
|
||
return output;
|
||
}
|
||
`,Kae=`
|
||
fn vecToRectCoord(dir: vec3<f32>) -> vec2<f32> {
|
||
var tau: f32 = 6.28318530718;
|
||
var pi: f32 = 3.14159265359;
|
||
var out: vec2<f32> = vec2<f32>(0.0);
|
||
|
||
out.x = atan2(dir.z, dir.x) / tau;
|
||
out.x += 0.5;
|
||
|
||
var phix: f32 = length(vec2(dir.x, dir.z));
|
||
out.y = atan2(dir.y, phix) / pi + 0.5;
|
||
|
||
return out;
|
||
}
|
||
|
||
//VTK::Renderer::Dec
|
||
|
||
//VTK::Mapper::Dec
|
||
|
||
//VTK::TCoord::Dec
|
||
|
||
//VTK::RenderEncoder::Dec
|
||
|
||
//VTK::IOStructs::Dec
|
||
|
||
@fragment
|
||
fn main(
|
||
//VTK::IOStructs::Input
|
||
)
|
||
//VTK::IOStructs::Output
|
||
{
|
||
var output: fragmentOutput;
|
||
|
||
var tcoord: vec4<f32> = vec4<f32>(input.vertexVC.xy, -1, 1);
|
||
var V: vec4<f32> = normalize(mapperUBO.FSQMatrix * tcoord); // vec2<f32>((input.tcoordVS.x - 0.5) * 2, -(input.tcoordVS.y - 0.5) * 2);
|
||
// textureSampleLevel gets rid of some ugly artifacts
|
||
var background = textureSampleLevel(EnvironmentTexture, EnvironmentTextureSampler, vecToRectCoord(V.xyz), 0.0);
|
||
var computedColor: vec4<f32> = vec4<f32>(background.rgb, 1);
|
||
|
||
//VTK::RenderEncoder::Impl
|
||
return output;
|
||
}
|
||
`,y2=new Float64Array(16),zD=new Float64Array(16);function qae(t){return t.getPositional()?t.getConeAngle()>=90?0:2:1}function Xae(t,e){e.classHierarchy.push("vtkWebGPURenderer"),t.buildPass=r=>{if(r){if(!e.renderable)return;e.camera=e.renderable.getActiveCamera(),t.updateLights(),t.prepareNodes(),t.addMissingNode(e.camera),t.addMissingNodes(e.renderable.getViewPropsWithNestedProps()),t.removeUnusedNodes(),e.webgpuCamera=t.getViewNodeFor(e.camera),t.updateStabilizedMatrix()}},t.updateStabilizedMatrix=()=>{const r=e.camera.getClippingRange(),n=e.camera.getPositionByReference(),i=e.camera.getDirectionOfProjectionByReference(),o=[],a=[];gr(a,i,.5*(r[0]+r[1])),Hr(o,n,a),hn(a,o,e.stabilizedCenter),wh(a)/(r[1]-r[0])>e.recenterThreshold&&(e.stabilizedCenter=o,e.stabilizedTime.modified())},t.updateLights=()=>{let r=0;const n=e.renderable.getLightsByReference();for(let i=0;i<n.length;++i)n[i].getSwitch()>0&&r++;return r||(Hae("No lights are on, creating one."),e.renderable.createLight()),r},t.updateUBO=()=>{var n;const r=e.UBO.getSendTime();if(e._parent.getMTime()>r||t.getMTime()>r||e.camera.getMTime()>r||e.renderable.getMTime()>r){const i=e.webgpuCamera.getKeyMatrices(t);e.UBO.setArray("WCVCMatrix",i.wcvc),e.UBO.setArray("SCPCMatrix",i.scpc),e.UBO.setArray("PCSCMatrix",i.pcsc),e.UBO.setArray("SCVCMatrix",i.scvc),e.UBO.setArray("VCPCMatrix",i.vcpc),e.UBO.setArray("WCVCNormals",i.normalMatrix),e.UBO.setValue("LightCount",e.renderable.getLights().length),e.UBO.setValue("MaxEnvironmentMipLevel",(n=e.renderable.getEnvironmentTexture())==null?void 0:n.getMipLevel()),e.UBO.setValue("BackgroundDiffuseStrength",e.renderable.getEnvironmentTextureDiffuseStrength()),e.UBO.setValue("BackgroundSpecularStrength",e.renderable.getEnvironmentTextureSpecularStrength());const o=t.getYInvertedTiledSizeAndOrigin();e.UBO.setArray("viewportSize",[o.usize,o.vsize]),e.UBO.setValue("cameraParallel",e.camera.getParallelProjection());const a=e._parent.getDevice();e.UBO.sendIfNeeded(a)}},t.updateSSBO=()=>{const r=e.renderable.getLights(),n=e.webgpuCamera.getKeyMatrices(t);let i=`${e.renderable.getMTime()}`;for(let o=0;o<r.length;o++)i+=r[o].getMTime();if(i!==e.lightTimeString){const o=new Float32Array(r.length*4),a=new Float32Array(r.length*4),s=new Float32Array(r.length*4),c=new Float32Array(r.length*4);for(let f=0;f<r.length;f++){const u=f*4,d=r[f].getPosition();At(d,d,n.wcvc),o[u]=d[0],o[u+1]=d[1],o[u+2]=d[2],o[u+3]=0,a[u]=-r[f].getDirection()[0],a[u+1]=-r[f].getDirection()[1],a[u+2]=-r[f].getDirection()[2],a[u+3]=0,s[u]=r[f].getColor()[0],s[u+1]=r[f].getColor()[1],s[u+2]=r[f].getColor()[2],s[u+3]=r[f].getIntensity()*5,c[u]=qae(r[f]),c[u+1]=Math.cos(Gr(r[f].getConeAngle())),c[u+2]=Math.cos(Gr(r[f].getConeAngle()+r[f].getConeFalloff())),c[u+3]=0}e.SSBO.clearData(),e.SSBO.setNumberOfInstances(r.length),e.SSBO.addEntry("LightPos","vec4<f32>"),e.SSBO.addEntry("LightDir","vec4<f32>"),e.SSBO.addEntry("LightColor","vec4<f32>"),e.SSBO.addEntry("LightData","vec4<f32>"),e.SSBO.setAllInstancesFromArray("LightPos",o),e.SSBO.setAllInstancesFromArray("LightDir",a),e.SSBO.setAllInstancesFromArray("LightColor",s),e.SSBO.setAllInstancesFromArray("LightData",c);const l=e._parent.getDevice();e.SSBO.send(l)}e.lightTimeString=i},t.scissorAndViewport=r=>{const n=t.getYInvertedTiledSizeAndOrigin();r.getHandle().setViewport(n.lowerLeftU,n.lowerLeftV,n.usize,n.vsize,0,1),r.getHandle().setScissorRect(n.lowerLeftU,n.lowerLeftV,n.usize,n.vsize)},t.bindUBO=r=>{r.activateBindGroup(e.bindGroup)},t.opaquePass=r=>{r?(e.renderEncoder.begin(e._parent.getCommandEncoder()),t.updateUBO(),t.updateSSBO()):(t.scissorAndViewport(e.renderEncoder),t.clear(),e.renderEncoder.end())},t.clear=()=>{var o;if(e.renderable.getTransparent()||e.suppressClear)return;const r=e._parent.getDevice();if(!e.clearFSQ){e.clearFSQ=TS.newInstance(),e.clearFSQ.setDevice(r),e.clearFSQ.setPipelineHash("clearfsq"),e.clearFSQ.setFragmentShaderTemplate(WD);const a=J0.newInstance({label:"mapperUBO"});a.addEntry("FSQMatrix","mat4x4<f32>"),a.addEntry("BackgroundColor","vec4<f32>"),e.clearFSQ.setUBO(a),e.backgroundTex=e.renderable.getEnvironmentTexture()}if(e.clearFSQ.getPipelineHash()!=="clearfsqwithtexture"&&e.renderable.getUseEnvironmentTextureAsBackground()&&((o=e.backgroundTex)!=null&&o.getImageLoaded())){e.clearFSQ.setFragmentShaderTemplate(Kae);const a=J0.newInstance({label:"mapperUBO"});a.addEntry("FSQMatrix","mat4x4<f32>"),a.addEntry("BackgroundColor","vec4<f32>"),e.clearFSQ.setUBO(a);const s=r.getTextureManager().getTextureForVTKTexture(e.backgroundTex);if(s.getReady()){const c=s.createView("EnvironmentTexture");e.clearFSQ.setTextureViews([c]),e.backgroundTexLoaded=!0;const l=e.backgroundTex.getInterpolate()?"linear":"nearest";c.addSampler(r,{addressModeU:"repeat",addressModeV:"clamp-to-edge",addressModeW:"repeat",minFilter:l,magFilter:l,mipmapFilter:"linear"})}e.clearFSQ.setPipelineHash("clearfsqwithtexture")}else if(e.clearFSQ.getPipelineHash()==="clearfsqwithtexture"&&!e.renderable.getUseEnvironmentTextureAsBackground()){e.clearFSQ=TS.newInstance(),e.clearFSQ.setDevice(r),e.clearFSQ.setPipelineHash("clearfsq"),e.clearFSQ.setFragmentShaderTemplate(WD);const a=J0.newInstance({label:"mapperUBO"});a.addEntry("FSQMatrix","mat4x4<f32>"),a.addEntry("BackgroundColor","vec4<f32>"),e.clearFSQ.setUBO(a)}const n=e.webgpuCamera.getKeyMatrices(t),i=e.renderable.getBackgroundByReference();e.clearFSQ.getUBO().setArray("BackgroundColor",i),un(zD,n.normalMatrix),Cy(y2,n.scvc,n.pcsc),Cy(y2,zD,y2),e.clearFSQ.getUBO().setArray("FSQMatrix",y2),e.clearFSQ.getUBO().sendIfNeeded(r),e.clearFSQ.prepareAndDraw(e.renderEncoder)},t.translucentPass=r=>{r?e.renderEncoder.begin(e._parent.getCommandEncoder()):(t.scissorAndViewport(e.renderEncoder),e.renderEncoder.end())},t.volumeDepthRangePass=r=>{r?e.renderEncoder.begin(e._parent.getCommandEncoder()):(t.scissorAndViewport(e.renderEncoder),e.renderEncoder.end())},t.getAspectRatio=()=>{const r=e._parent.getSizeByReference(),n=e.renderable.getViewportByReference();return r[0]*(n[2]-n[0])/((n[3]-n[1])*r[1])},t.convertToOpenGLDepth=r=>e.webgpuCamera.convertToOpenGLDepth(r),t.getYInvertedTiledSizeAndOrigin=()=>{const r=t.getTiledSizeAndOrigin(),n=e._parent.getSizeByReference();return r.lowerLeftV=n[1]-r.vsize-r.lowerLeftV,r},t.getTiledSizeAndOrigin=()=>{const r=e.renderable.getViewportByReference(),n=[0,0,1,1],i=r[0]-n[0],o=r[1]-n[1],a=e._parent.normalizedDisplayToDisplay(i,o),s=Math.round(a[0]),c=Math.round(a[1]),l=r[2]-n[0],f=r[3]-n[1],u=e._parent.normalizedDisplayToDisplay(l,f);let d=Math.round(u[0])-s,h=Math.round(u[1])-c;return d<0&&(d=0),h<0&&(h=0),{usize:d,vsize:h,lowerLeftU:s,lowerLeftV:c}},t.getPropFromID=r=>{for(let n=0;n<e.children.length;n++)if((e.children[n].getPropID?e.children[n].getPropID():-1)===r)return e.children[n];return null},t.getStabilizedTime=()=>e.stabilizedTime.getMTime(),t.releaseGraphicsResources=()=>{e.selector!==null&&e.selector.releaseGraphicsResources()}}const Yae={bindGroup:null,selector:null,renderEncoder:null,recenterThreshold:20,suppressClear:!1,stabilizedCenter:[0,0,0]};function Jae(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Yae,r),Qn.extend(t,e,r),e.UBO=J0.newInstance({label:"rendererUBO"}),e.UBO.addEntry("WCVCMatrix","mat4x4<f32>"),e.UBO.addEntry("SCPCMatrix","mat4x4<f32>"),e.UBO.addEntry("PCSCMatrix","mat4x4<f32>"),e.UBO.addEntry("SCVCMatrix","mat4x4<f32>"),e.UBO.addEntry("VCPCMatrix","mat4x4<f32>"),e.UBO.addEntry("WCVCNormals","mat4x4<f32>"),e.UBO.addEntry("viewportSize","vec2<f32>"),e.UBO.addEntry("LightCount","i32"),e.UBO.addEntry("MaxEnvironmentMipLevel","f32"),e.UBO.addEntry("BackgroundDiffuseStrength","f32"),e.UBO.addEntry("BackgroundSpecularStrength","f32"),e.UBO.addEntry("cameraParallel","u32"),e.SSBO=Gae.newInstance({label:"rendererLightSSBO"}),e.lightTimeString="",e.bindGroup=HN.newInstance({label:"rendererBG"}),e.bindGroup.setBindables([e.UBO,e.SSBO]),e.tmpMat4=It(new Float64Array(16)),e.stabilizedTime={},or(e.stabilizedTime,{mtime:0}),Ro(t,e,["bindGroup","stabilizedTime"]),Bh(t,e,["stabilizedCenter"]),Jr(t,e,["renderEncoder","selector","suppressClear","UBO"]),Xae(t,e)}const Zae=Rn(Jae,"vtkWebGPURenderer");xs("vtkRenderer",Zae);function Qae(t,e){e.classHierarchy.push("vtkWebGPUSampler"),t.create=function(r){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};e.device=r,e.options.addressModeU=n.addressModeU?n.addressModeU:"clamp-to-edge",e.options.addressModeV=n.addressModeV?n.addressModeV:"clamp-to-edge",e.options.addressModeW=n.addressModeW?n.addressModeW:"clamp-to-edge",e.options.magFilter=n.magFilter?n.magFilter:"nearest",e.options.minFilter=n.minFilter?n.minFilter:"nearest",e.options.mipmapFilter=n.mipmapFilter?n.mipmapFilter:"nearest",e.options.label=e.label,e.handle=e.device.getHandle().createSampler(e.options),e.bindGroupTime.modified()},t.getShaderCode=(r,n)=>`@binding(${r}) @group(${n}) var ${e.label}: sampler;`,t.getBindGroupEntry=()=>({resource:e.handle})}const ese={device:null,handle:null,label:null,options:null};function ok(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,ese,r),Z.obj(t,e),e.options={},e.bindGroupLayoutEntry={visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,sampler:{}},e.bindGroupTime={},Z.obj(e.bindGroupTime,{mtime:0}),Z.get(t,e,["bindGroupTime","handle","options"]),Z.setGet(t,e,["bindGroupLayoutEntry","device","label"]),Qae(t,e)}const tse=Z.newInstance(ok);var ak={newInstance:tse,extend:ok};const{SlicingMode:$D}=fw,nse=`
|
||
//VTK::Renderer::Dec
|
||
|
||
//VTK::Mapper::Dec
|
||
|
||
//VTK::TCoord::Dec
|
||
|
||
//VTK::Image::Dec
|
||
|
||
//VTK::RenderEncoder::Dec
|
||
|
||
//VTK::IOStructs::Dec
|
||
|
||
@fragment
|
||
fn main(
|
||
//VTK::IOStructs::Input
|
||
)
|
||
//VTK::IOStructs::Output
|
||
{
|
||
var output: fragmentOutput;
|
||
|
||
//VTK::Image::Sample
|
||
|
||
// var computedColor: vec4<f32> = vec4<f32>(1.0,0.7, 0.5, 1.0);
|
||
|
||
//VTK::RenderEncoder::Impl
|
||
|
||
return output;
|
||
}
|
||
`;function rse(t,e,r){if(e.apply(t)){const i=t.getIndependentComponents();return`${t.getMTime()}-${i}-${r}`}return"0"}const Ma=new Float64Array(16),Rc=new Float64Array(16),w2=new Float64Array(16),_l=new Float64Array(4),yi=new Float64Array(4);function ise(t,e){e.classHierarchy.push("vtkWebGPUImageMapper"),t.buildPass=i=>{if(i){e.WebGPUImageSlice=t.getFirstAncestorOfType("vtkWebGPUImageSlice"),e.WebGPURenderer=e.WebGPUImageSlice.getFirstAncestorOfType("vtkWebGPURenderer"),e.WebGPURenderWindow=e.WebGPURenderer.getParent(),e.device=e.WebGPURenderWindow.getDevice();const o=e.WebGPURenderer.getRenderable();e.renderable.getSliceAtFocalPoint()&&e.renderable.setSliceFromCamera(o.getActiveCamera())}},t.translucentPass=i=>{i&&t.render()},t.opaquePass=i=>{i&&t.render()},t.render=()=>{e.renderable.update(),e.currentInput=e.renderable.getInputData(),t.prepareToDraw(e.WebGPURenderer.getRenderEncoder()),e.renderEncoder.registerDrawCallback(e.pipeline,t.draw)},t.computePipelineHash=()=>{const i=e.currentInput.getExtent();i[0]===i[1]||i[2]===i[3]||i[4]===i[5]?(e.dimensions=2,e.pipelineHash="img2"):(e.dimensions=3,e.pipelineHash="img3")},t.updateUBO=()=>{const i=e.UBO.getSendTime(),o=e.WebGPUImageSlice.getRenderable(),a=o.getMapper();if(t.getMTime()>i||e.renderable.getMTime()>i||o.getProperty().getMTime()>i){const s=a.getInputData(),c=e.WebGPURenderer.getStabilizedCenterByReference();It(Ma),er(Ma,Ma,c);const l=o.getMatrix();un(Rc,l),Ar(Rc,Rc),yn(Ma,Rc,Ma);const f=s.getWorldToIndex();yn(Ma,f,Ma),Ar(w2,Ma),tm(Rc,[.5,.5,.5]),yn(Ma,Rc,Ma);const u=s.getDimensions();It(Rc),nl(Rc,Rc,[1/u[0],1/u[1],1/u[2]]),yn(Ma,Rc,Ma),e.UBO.setArray("SCTCMatrix",Ma);const d=e.currentInput.getExtent(),{ijkMode:h}=e.renderable.getClosestIJKAxis();let g=e.renderable.getSlice();h!==e.renderable.getSlicingMode()&&(g=e.renderable.getSliceAtPosition(g));let p=2,v=0,y=1;h===$D.I?(p=0,v=1,y=2):h===$D.J&&(p=1,v=2,y=0),_l[p]=g,_l[v]=d[v*2]-.5,_l[y]=d[y*2]-.5,_l[3]=1,Vu(_l,_l,w2),e.UBO.setArray("Origin",_l),yi[p]=g,yi[v]=d[v*2+1]+.5,yi[y]=d[y*2]-.5,yi[3]=1,Vu(yi,yi,w2),H6(yi,yi,_l),yi[3]=1,e.UBO.setArray("Axis1",yi),yi[p]=g,yi[v]=d[v*2]-.5,yi[y]=d[y*2+1]+.5,yi[3]=1,Vu(yi,yi,w2),H6(yi,yi,_l),yi[3]=1,e.UBO.setArray("Axis2",yi);const m=[1,1,1,1],w=[0,0,0,0],x=e.textureViews[0],C=x.getTexture().getScale(),S=x.getTexture().getNumberOfComponents();for(let T=0;T<S;T++){let _=o.getProperty().getColorWindow(),E=o.getProperty().getColorLevel();const D=o.getProperty().getRGBTransferFunction(0);if(D){const I=D.getRange();_=I[1]-I[0],E=.5*(I[1]+I[0])}m[T]=C/_,w[T]=-E/_+.5}e.UBO.setArray("cScale",m),e.UBO.setArray("cShift",w),e.UBO.sendIfNeeded(e.device)}},t.updateLUTImage=()=>{const i=e.WebGPUImageSlice.getRenderable().getProperty();t.getTextureViews()[0].getTexture().getNumberOfComponents();const a=1,s=rse(i,i.getRGBTransferFunction,a);if(e.colorTextureString!==s){e.numRows=a;const c=new Uint8ClampedArray(e.numRows*2*e.rowLength*4);let l=i.getRGBTransferFunction();if(l){const f=new Float32Array(e.rowLength*3);for(let u=0;u<a;u++){l=i.getRGBTransferFunction(u);const d=l.getRange();l.getTable(d[0],d[1],e.rowLength,f,1);for(let h=0;h<e.rowLength;h++){const g=u*e.rowLength*8+h*4;c[g]=255*f[h*3],c[g+1]=255*f[h*3+1],c[g+2]=255*f[h*3+2],c[g+3]=255;for(let p=0;p<4;p++)c[g+e.rowLength*4+p]=c[g+p]}}}else for(let f=0;f<e.rowLength;++f){const u=255*f/(e.rowLength-1);c[f*4]=u,c[f*4+1]=u,c[f*4+2]=u,c[f*4+3]=255;for(let d=0;d<4;d++)c[f*4+e.rowLength*4+d]=c[f*4+d]}{const f={nativeArray:c,width:e.rowLength,height:e.numRows*2,depth:1,format:"rgba8unorm"},d=e.device.getTextureManager().getTexture(f).createView("tfunTexture");e.textureViews[1]=d}e.colorTextureString=s}};const r=t.updateBuffers;t.updateBuffers=()=>{r();const i=e.device.getTextureManager().getTextureForImageData(e.currentInput),o=e.textureViews;if(!o[0]||o[0].getTexture()!==i){const c=i.createView("imgTexture");o[0]=c}t.updateLUTImage(),t.updateUBO();const s=e.WebGPUImageSlice.getRenderable().getProperty().getInterpolationType()===cd.NEAREST?"nearest":"linear";(!e.clampSampler||s!==e.clampSampler.getOptions().minFilter)&&(e.clampSampler=ak.newInstance({label:"clampSampler"}),e.clampSampler.create(e.device,{minFilter:s,magFilter:s}),e.additionalBindables=[e.clampSampler])};const n=t.getShaderReplacements();t.replaceShaderPosition=(i,o,a)=>{const s=o.getShaderDescription("vertex");s.addBuiltinOutput("vec4<f32>","@builtin(position) Position");let c=s.getCode();const l=["var pos: vec4<f32> = mapperUBO.Origin +"," (vertexBC.x * 0.5 + 0.5) * mapperUBO.Axis1 + (vertexBC.y * 0.5 + 0.5) * mapperUBO.Axis2;","pos.w = 1.0;"];e.dimensions===2?l.push("var tcoord : vec2<f32> = (mapperUBO.SCTCMatrix * pos).xy;"):l.push("var tcoord : vec3<f32> = (mapperUBO.SCTCMatrix * pos).xyz;"),l.push("output.tcoordVS = tcoord;","output.Position = rendererUBO.SCPCMatrix * pos;"),c=Xn.substitute(c,"//VTK::Position::Impl",l).result,s.setCode(c)},n.set("replaceShaderPosition",t.replaceShaderPosition),t.replaceShaderTCoord=(i,o,a)=>{const s=o.getShaderDescription("vertex");e.dimensions===2?s.addOutput("vec2<f32>","tcoordVS"):s.addOutput("vec3<f32>","tcoordVS")},n.set("replaceShaderTCoord",t.replaceShaderTCoord),t.replaceShaderImage=(i,o,a)=>{const s=o.getShaderDescription("fragment");let c=s.getCode();e.dimensions===3?c=Xn.substitute(c,"//VTK::Image::Sample",[" var computedColor: vec4<f32> ="," textureSampleLevel(imgTexture, clampSampler, input.tcoordVS, 0.0);","//VTK::Image::Sample"]).result:c=Xn.substitute(c,"//VTK::Image::Sample",[" var computedColor: vec4<f32> ="," textureSampleLevel(imgTexture, clampSampler, input.tcoordVS, 0.0);","//VTK::Image::Sample"]).result,c=Xn.substitute(c,"//VTK::Image::Sample",[" var coord: vec2<f32> ="," vec2<f32>(computedColor.r * mapperUBO.cScale.r + mapperUBO.cShift.r, 0.5);"," computedColor = textureSampleLevel(tfunTexture, clampSampler, coord, 0.0);"]).result,s.setCode(c)},n.set("replaceShaderImage",t.replaceShaderImage)}const ose={rowLength:1024};function ase(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,ose,r),TS.extend(t,e,r),t.setFragmentShaderTemplate(nse),e.UBO=J0.newInstance({label:"mapperUBO"}),e.UBO.addEntry("SCTCMatrix","mat4x4<f32>"),e.UBO.addEntry("Origin","vec4<f32>"),e.UBO.addEntry("Axis2","vec4<f32>"),e.UBO.addEntry("Axis1","vec4<f32>"),e.UBO.addEntry("cScale","vec4<f32>"),e.UBO.addEntry("cShift","vec4<f32>"),e.lutBuildTime={},or(e.lutBuildTime,{mtime:0}),e.imagemat=It(new Float64Array(16)),e.imagematinv=It(new Float64Array(16)),e.VBOBuildTime={},or(e.VBOBuildTime),ise(t,e)}const sse=Rn(ase,"vtkWebGPUImageMapper");xs("vtkImageMapper",sse);function cse(t,e){e.classHierarchy.push("vtkWebGPUImageSlice"),t.buildPass=r=>{if(!(!e.renderable||!e.renderable.getVisibility())&&r){if(!e.renderable)return;e.WebGPURenderer=t.getFirstAncestorOfType("vtkWebGPURenderer"),e.WebGPURenderWindow=e.WebGPURenderer.getFirstAncestorOfType("vtkWebGPURenderWindow"),e.propID===void 0&&(e.propID=e.WebGPURenderWindow.getUniquePropID()),t.prepareNodes(),t.addMissingNode(e.renderable.getMapper()),t.removeUnusedNodes()}},t.traverseOpaquePass=r=>{!e.renderable||!e.renderable.getNestedVisibility()||!e.renderable.getIsOpaque()||e.WebGPURenderer.getSelector()&&!e.renderable.getNestedPickable()||(t.apply(r,!0),e.children.forEach(n=>{n.traverse(r)}),t.apply(r,!1))},t.traverseTranslucentPass=r=>{!e.renderable||!e.renderable.getNestedVisibility()||e.renderable.getIsOpaque()||e.WebGPURenderer.getSelector()&&!e.renderable.getNestedPickable()||(t.apply(r,!0),e.children.forEach(n=>{n.traverse(r)}),t.apply(r,!1))},t.queryPass=(r,n)=>{if(r){if(!e.renderable||!e.renderable.getVisibility())return;e.renderable.getIsOpaque()?n.incrementOpaqueActorCount():n.incrementTranslucentActorCount()}},t.getBufferShift=r=>(t.getKeyMatrices(r),e.bufferShift),t.getKeyMatrices=r=>{if(Math.max(e.renderable.getMTime(),r.getStabilizedTime())>e.keyMatricesTime.getMTime()){e.renderable.computeMatrix();const n=e.renderable.getMatrix(),i=r.getStabilizedCenterByReference();e.bufferShift[0]=n[3]-i[0],e.bufferShift[1]=n[7]-i[1],e.bufferShift[2]=n[11]-i[2],un(e.keyMatrices.bcwc,n),e.renderable.getIsIdentity()?It(e.keyMatrices.normalMatrix):(Cr(e.keyMatrices.normalMatrix,e.keyMatrices.bcwc),e.keyMatrices.normalMatrix[3]=0,e.keyMatrices.normalMatrix[7]=0,e.keyMatrices.normalMatrix[11]=0,Ar(e.keyMatrices.normalMatrix,e.keyMatrices.normalMatrix),un(e.keyMatrices.normalMatrix,e.keyMatrices.normalMatrix)),er(e.keyMatrices.bcwc,e.keyMatrices.bcwc,[-e.bufferShift[0],-e.bufferShift[1],-e.bufferShift[2]]),er(e.keyMatrices.bcsc,e.keyMatrices.bcwc,[-i[0],-i[1],-i[2]]),e.keyMatricesTime.modified()}return e.keyMatrices}}const lse={bufferShift:void 0,keyMatrixTime:null,keyMatrices:null,propID:void 0};function use(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,lse,r),Qn.extend(t,e,r),e.keyMatricesTime={},or(e.keyMatricesTime,{mtime:0}),e.keyMatrices={normalMatrix:new Float64Array(16),bcwc:new Float64Array(16),bcsc:new Float64Array(16)},e.keyMatrixTime={},or(e.keyMatrixTime,{mtime:0}),e.keyMatrices={mcwc:It(new Float64Array(16))},e.bufferShift=[0,0,0,0],Ro(t,e,["propID","keyMatricesTime"]),cse(t,e)}const fse=Rn(use,"vtkWebGPUImageSlice");xs("vtkImageSlice",fse);function dse(t,e){e.classHierarchy.push("vtkWebGPUVolume"),t.buildPass=i=>{!e.renderable||!e.renderable.getVisibility()||i&&(e.WebGPURenderer=t.getFirstAncestorOfType("vtkWebGPURenderer"),e.WebGPURenderWindow=e.WebGPURenderer.getFirstAncestorOfType("vtkWebGPURenderWindow"),e.propID===void 0&&(e.propID=e.WebGPURenderWindow.getUniquePropID()),e.renderable.getMapper().update())},t.queryPass=(i,o)=>{if(i){if(!e.renderable||!e.renderable.getVisibility())return;const a=e.renderable.getMapper().getBounds();if(!a||a.length!==6||a[0]>a[1])return;o.addVolume(t)}};const r=new Float64Array(3),n=new Float64Array(3);t.getBoundingCubePoints=(i,o)=>{const a=e.renderable.getMapper().getInputData();if(!a)return;const s=a.getExtent(),c=e.renderable.getMatrix();let l=0;for(let f=4;f<6;f++){r[2]=s[f];for(let u=2;u<4;u++){r[1]=s[u];for(let d=0;d<2;d++){r[0]=s[d],a.indexToWorld(r,n);let h=o+l*3;i[h++]=c[0]*n[0]+c[1]*n[1]+c[2]*n[2]+c[3],i[h++]=c[4]*n[0]+c[5]*n[1]+c[6]*n[2]+c[7],i[h++]=c[8]*n[0]+c[9]*n[1]+c[10]*n[2]+c[11],l++}}}},t.getKeyMatrices=i=>{if(Math.max(e.renderable.getMTime(),i.getStabilizedTime())>e.keyMatricesTime.getMTime()){e.renderable.computeMatrix();const o=e.renderable.getMatrix(),a=i.getStabilizedCenterByReference();un(e.keyMatrices.bcwc,o),er(e.keyMatrices.bcsc,e.keyMatrices.bcwc,[-a[0],-a[1],-a[2]]),e.keyMatricesTime.modified()}return e.keyMatrices}}const hse={propID:void 0,keyMatricesTime:null};function gse(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,hse,r),Qn.extend(t,e,r),e.keyMatricesTime={},Z.obj(e.keyMatricesTime,{mtime:0}),e.keyMatrices={bcwc:new Float64Array(16),bcsc:new Float64Array(16)},Z.get(t,e,["propID","keyMatricesTime"]),dse(t,e)}const pse=Z.newInstance(gse,"vtkWebGPUVolume");xs("vtkVolume",pse);function mse(t,e){e.classHierarchy.push("vtkWebGPUPixelSpaceCallbackMapper"),t.opaquePass=(r,n)=>{e.WebGPURenderer=t.getFirstAncestorOfType("vtkWebGPURenderer"),e.WebGPURenderWindow=e.WebGPURenderer.getParent();const i=e.WebGPURenderer.getAspectRatio(),o=e.WebGPURenderer?e.WebGPURenderer.getRenderable().getActiveCamera():null,a=e.WebGPURenderer.getTiledSizeAndOrigin(),s=null;e.renderable.getUseZValues(),e.renderable.invokeCallback(e.renderable.getInputData(),o,i,a,s)}}const vse={};function yse(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,vse,r),Qn.extend(t,e,r),mse(t,e)}const wse=Z.newInstance(yse,"vtkWebGPUPixelSpaceCallbackMapper");xs("vtkPixelSpaceCallbackMapper",wse);const jD=[[0,-1,0],[0,1,0],[0,0,-1],[0,0,1]],HD=[[0,-1,0],[0,1,0]],xse=[[0,-1,0],[0,1,0],[0,0,-1]],Cse=[[0,-1,0],[0,1,0],[0,0,1]];var uh;let c0=(uh=class{static copyMap(e,r){for(const[n,i]of r.rows)e.rows.set(n,structuredClone(i))}constructor(e,r,n=1){this.rows=new Map,this.height=1,this.width=1,this.depth=1,this.jMultiple=1,this.kMultiple=1,this.numComps=1,this.pixelDataConstructor=Uint8Array,this.updateScalarData=function(i){i.fill(0);const o=(a,s,c)=>{const{start:l,end:f,value:u}=s;for(let d=l;d<f;d++)i[a+d]=u};this.forEach(o)},this.get=i=>{const o=i%this.jMultiple,a=(i-o)/this.jMultiple,s=this.getRLE(o,a);return(s==null?void 0:s.value)??this.defaultValue},this.getRun=(i,o)=>{const a=i+o*this.height;return this.rows.get(a)},this.set=(i,o)=>{if(o===void 0)return;const a=i%this.width,s=(i-a)/this.width,c=this.rows.get(s);if(!c){this.rows.set(s,[{start:a,end:a+1,value:o}]);return}const l=this.findIndex(c,a),f=c[l],u=c[l-1];if(!f){if(!u||u.value!==o||u.end!==a){c[l]={start:a,end:a+1,value:o};return}u.end++;return}const{start:d,end:h,value:g}=f;if(o===g&&a>=d)return;const p={start:a,end:a+1,value:o},v=a>d,y=v?l+1:l,m=v?f:u;let w=v?c[l+1]:f;if((m==null?void 0:m.value)===o&&(m==null?void 0:m.end)===a){m.end++,(w==null?void 0:w.value)===o&&w.start===a+1?(m.end=w.end,c.splice(l,1)):(w==null?void 0:w.start)===a&&(w.start++,w.start===w.end&&(c.splice(l,1),w=c[l],(w==null?void 0:w.start)===a+1&&w.value===o&&(m.end=w.end,c.splice(l,1))));return}if((w==null?void 0:w.value)===o&&w.start===a+1){w.start--,(m==null?void 0:m.end)>a&&(m.end=a,m.end===m.start&&c.splice(l,1));return}if((w==null?void 0:w.start)===a&&w.end===a+1){w.value=o;const x=c[l+1];(x==null?void 0:x.start)==a+1&&x.value===o&&(c.splice(l+1,1),w.end=x.end);return}a===(w==null?void 0:w.start)&&w.start++,v&&h>a+1?c.splice(y,0,p,{start:a+1,end:m.end,value:m.value}):c.splice(y,0,p),(m==null?void 0:m.end)>a&&(m.end=a)},this.width=e,this.height=r,this.depth=n,this.jMultiple=e,this.kMultiple=this.jMultiple*r}toIJK(e){const r=e%this.jMultiple,n=(e-r)/this.jMultiple%this.height,i=Math.floor(e/this.kMultiple);return[r,n,i]}toIndex([e,r,n]){return e+n*this.kMultiple+r*this.jMultiple}getRLE(e,r,n=0){const i=this.rows.get(r+n*this.height);if(!i)return;const o=this.findIndex(i,e),a=i[o];return e>=(a==null?void 0:a.start)?a:void 0}has(e){const r=e%this.jMultiple,n=(e-r)/this.jMultiple,i=this.getRLE(r,n);return(i==null?void 0:i.value)!==void 0}delete(e){const r=e%this.width,n=(e-r)/this.width,i=this.rows.get(n);if(!i)return;const o=this.findIndex(i,r),a=i[o];if(!a||a.start>r)return;if(a.end===r+1){a.end--,a.start>=a.end&&(i.splice(o,1),i.length||this.rows.delete(n));return}if(a.start===r){a.start++;return}const s={value:a.value,start:r+1,end:a.end};a.end=r,i.splice(o+1,0,s)}findIndex(e,r){for(let n=0;n<e.length;n++){const{end:i}=e[n];if(r<i)return n}return e.length}forEach(e,r){const n=r==null?void 0:r.rowModified;for(const[i,o]of this.rows){const a=n?[...o]:o;for(const s of a)e(i*this.width,s,o)}}forEachRow(e){for(const[r,n]of this.rows)e(r*this.width,n)}clear(){this.rows.clear()}keys(){return[...this.rows.keys()]}getPixelData(e=0,r){r?r.fill(0):r=new this.pixelDataConstructor(this.width*this.height*this.numComps);const{width:n,height:i,numComps:o}=this;for(let a=0;a<i;a++){const s=this.getRun(a,e);if(s)if(o===1)for(const c of s){const l=a*n,{start:f,end:u,value:d}=c;for(let h=f;h<u;h++)r[l+h]=d}else for(const c of s){const l=a*n*o,{start:f,end:u,value:d}=c;for(let h=f;h<u;h+=o)for(let g=0;g<o;g++)r[l+h+g]=d[g]}}return r}floodFill(e,r,n,i,o){const a=this.getRLE(e,r,n);if(!a)throw new Error(`Initial point ${e},${r},${n} isn't in the RLE`);const s=[[a,r,n]],c=a.value;if(c===i)throw new Error(`source (${c}) and destination (${i}) are identical`);return this.flood(s,c,i,o)}flood(e,r,n,i){let o=0;const{planar:a=!0,diagonals:s=!0,singlePlane:c=!1}=i||{},l={planar:a,diagonals:s,singlePlane:c};for(;e.length;){const f=e.pop(),[u]=f;if(u.value!==r)continue;u.value=n,o+=u.end-u.start;const d=this.findAdjacents(f,l).filter(h=>h&&h[0].value===r);e.push(...d)}return o}fillFrom(e,r){for(let n=r[2][0];n<=r[2][1];n++)for(let i=r[1][0];i<=r[1][1];i++){let o,a;for(let s=r[0][0];s<=r[0][1];s++){const c=e(s,i,n);if(c===void 0){o=void 0;continue}a||(a=[],this.rows.set(i+n*this.height,a)),o&&o.value!==c&&(o=void 0),o||(o={start:s,end:s,value:c},a.push(o)),o.end++}}}findAdjacents(e,{diagonals:r=!0,planar:n=!0,singlePlane:i=!1}){const[o,a,s,c]=e,{start:l,end:f}=o,u=l>0&&this.getRLE(l-1,a,s),d=f<this.width&&this.getRLE(f,a,s),h=r?[l>0?l-1:l,f<this.width?f+1:f]:[l,f],g=[];u&&g.push([u,a,s]),d&&g.push([d,a,s]);for(const p of c||(i?HD:jD)){const[,v,y]=p,m=v+a,w=y+s;if(m<0||m>=this.height||w<0||w>=this.depth)continue;const x=this.getRun(m,w);if(x)for(const C of x){const S=c||i&&HD||n&&y>0&&Cse||n&&y<0&&xse||jD;C.end<=h[0]||C.start>=h[1]||g.push([C,m,w,S])}}return g}},uh.getScalarData=function(e=Uint8ClampedArray){const r=new e(this.frameSize);return this.map.updateScalarData(r),r},uh),Pv=class Qg{constructor(e={}){this._dimensions=3,this._length=0,this._byteSize=4,this.growSize=128;const{initialSize:r=1024,dimensions:n=3,growSize:i=128}=e,o=r*n;this.growSize=i,this.array=new ArrayBuffer(o*this._byteSize),this.data=new Float32Array(this.array),this._dimensions=n}forEach(e){for(let r=0;r<this._length;r++)e(this.getPoint(r),r)}get length(){return this._length}get dimensions(){return this._dimensions}get dimensionLength(){return this._length*this._dimensions}getPoint(e){if(e<0&&(e+=this._length),e<0||e>=this._length)return;const r=this._dimensions*e;return this.data.subarray(r,r+this._dimensions)}getPointArray(e){const r=[];if(e<0&&(e+=this._length),e<0||e>=this._length)return;const n=this._dimensions*e;for(let i=0;i<this._dimensions;i++)r.push(this.data[i+n]);return r}grow(e=1,r=this.growSize){if(this.dimensionLength+e*this._dimensions<=this.data.length)return;const n=this.data.length+r,i=new ArrayBuffer(n*this._dimensions*this._byteSize),o=new Float32Array(i);o.set(this.data),this.data=o,this.array=i}reverse(){const e=Math.floor(this._length/2);for(let r=0;r<e;r++){const n=r*this._dimensions,i=(this._length-1-r)*this._dimensions;for(let o=0;o<this._dimensions;o++){const a=this.data[n+o];this.data[n+o]=this.data[i+o],this.data[i+o]=a}}}getTypedArray(){return this.data}push(e){this.grow(1);const r=this.length*this._dimensions;for(let n=0;n<this._dimensions;n++)this.data[n+r]=e[n];this._length++}map(e){const r=[];for(let n=0;n<this._length;n++)r.push(e(this.getPoint(n),n));return r}get points(){return this.map(e=>e)}toXYZ(){const e={x:[],y:[]};this._dimensions>=3&&(e.z=[]);const{x:r,y:n,z:i}=e;return this.forEach(o=>{r.push(o[0]),n.push(o[1]),i&&i.push(o[2])}),e}static fromXYZ({x:e,y:r,z:n}){const i=Qg.create3(e.length);let o=0;for(let a=0;a<e.length;a++)i.data[o++]=e[a],i.data[o++]=r[a],i.data[o++]=n?n[a]:0;return i._length=e.length,i}subselect(e=10,r=0){const n=new Qg({initialSize:e,dimensions:this._dimensions});for(let i=0;i<e;i++){const o=(r+Math.floor(this.length*i/e))%this.length;n.push(this.getPoint(o))}return n}static create3(e=128,r){e=Math.max(e,(r==null?void 0:r.length)||0);const n=new Qg({initialSize:e,dimensions:3});return r&&r.forEach(i=>n.push(i)),n}static create2(e=128){return new Qg({initialSize:e,dimensions:2})}};function sk(t){const e=Ke(),r=t.getDimensions(),n=Pv.create3(r[0]),i=Pv.create3(r[1]),o=Pv.create3(r[2]),a=t.getDirection(),s=a.slice(0,3),c=a.slice(3,6),l=a.slice(6,9),f=t.getSpacing(),[u,d,h]=f,g=t.indexToWorld([0,0,0]),p=Tt(s[0]*u,s[1]*u,s[2]*u),v=Tt(c[0]*d,c[1]*d,c[2]*d),y=Tt(l[0]*h,l[1]*h,l[2]*h),m=Ke();for(let S=0;S<r[0];S++)n.push(Hr(m,g,gr(m,p,S)));for(let S=0;S<r[1];S++)i.push(gr(m,v,S));for(let S=0;S<r[2];S++)o.push(gr(m,y,S));const w=n.getTypedArray(),x=i.getTypedArray(),C=o.getTypedArray();return(S,T=e)=>{const[_,E,b]=S,D=_*3,I=E*3,P=b*3;return T[0]=w[D]+x[I]+C[P],T[1]=w[D+1]+x[I+1]+C[P+1],T[2]=w[D+2]+x[I+2]+C[P+2],T}}function j4(t,e){const{pointInShapeFn:r,callback:n,boundsIJK:i,returnPoints:o=!1}=e;let a;if(t.getScalarData)a=t.getScalarData();else{const u=t.getPointData().getScalars();if(u)a=u.getData();else{const{voxelManager:d}=t.get("voxelManager")||{};d&&(a=d.getCompleteScalarDataArray())}}const s=t.getDimensions(),c=[[0,s[0]],[0,s[1]],[0,s[2]]],f=Sse({imageData:t,bounds:i||c,scalarData:a,pointInShapeFn:r,callback:n});return o?f:void 0}function Sse({imageData:t,bounds:e,scalarData:r,pointInShapeFn:n,callback:i}){const[[o,a],[s,c],[l,f]]=e,{numComps:u}=t,d=t.getDimensions(),h=sk(t),g=[0,0,0],p=u||r.length/d[2]/d[1]/d[0],v=d[0]*p,y=d[1]*v,m=[];for(let w=l;w<=f;w++){g[2]=w;const x=w*y;for(let C=s;C<=c;C++){g[1]=C;const S=x+C*v;for(let T=o;T<=a;T++){g[0]=T;const _=h(g);if(n(_,g)){const E=S+T*p;let b;p>2?b=[r[E],r[E+1],r[E+2]]:b=r[E],m.push({value:b,index:E,pointIJK:g,pointLPS:_.slice()}),i({value:b,index:E,pointIJK:g,pointLPS:_})}}}}return m}function Tse({voxelManager:t,bounds:e,imageData:r,pointInShapeFn:n,callback:i,returnPoints:o}){const[[a,s],[c,l],[f,u]]=e,d=sk(r),h=[0,0,0],g=[];for(let p=f;p<=u;p++){h[2]=p;for(let v=c;v<=l;v++){h[1]=v;for(let y=a;y<=s;y++){h[0]=y;const m=d(h);if(n(m,h)){const w=t.toIndex(h),x=t.getAtIndex(w);o&&g.push({value:x,index:w,pointIJK:[...h],pointLPS:m.slice()}),i==null||i({value:x,index:w,pointIJK:h,pointLPS:m})}}}}return g}const _se=5*1024;let fc=class wi{get id(){return this._id}constructor(e,r){this.modifiedSlices=new Set,this.boundsIJK=[[1/0,-1/0],[1/0,-1/0],[1/0,-1/0]],this.scalarData=null,this._sliceDataCache=null,this.getAtIJK=(n,i,o)=>{const a=this.toIndex([n,i,o]);return this._get(a)},this.setAtIJK=(n,i,o,a)=>{const s=this.toIndex([n,i,o]),c=this._set(s,a);return c!==!1&&(this.modifiedSlices.add(o),wi.addBounds(this.boundsIJK,[n,i,o])),c},this.getAtIJKPoint=([n,i,o])=>this.getAtIJK(n,i,o),this.setAtIJKPoint=([n,i,o],a)=>{this.setAtIJK(n,i,o,a)},this.getAtIndex=n=>this._get(n),this.setAtIndex=(n,i)=>{const o=this._set(n,i);if(o!==!1){const a=this.toIJK(n);this.modifiedSlices.add(a[2]),wi.addBounds(this.boundsIJK,a)}return o},this.getMiddleSliceData=()=>{const n=Math.floor(this.dimensions[2]/2);return this.getSliceData({sliceIndex:n,slicePlane:2})},this.forEach=(n,i={})=>{const o=i.boundsIJK||this.getBoundsIJK(),a=i.isInObject||this.isInObject||(()=>!0),s=i.returnPoints||!1,c=i.imageData,l=Math.min(o[0][0],o[0][1]),f=Math.max(o[0][0],o[0][1]),u=Math.min(o[1][0],o[1][1]),d=Math.max(o[1][0],o[1][1]),h=Math.min(o[2][0],o[2][1]),g=Math.max(o[2][0],o[2][1]),p=[];if(c)return Tse({voxelManager:this,imageData:i.imageData,bounds:[[l,f],[u,d],[h,g]],pointInShapeFn:a,callback:n,returnPoints:s});if(this.map){if(this.map instanceof c0)return this.rleForEach(n,i);for(const v of this.map.keys()){const y=this.toIJK(v);if(!a(null,y))continue;const m=this._get(v);s&&p.push({value:m,index:v,pointIJK:y,pointLPS:null}),n({value:m,index:v,pointIJK:y,pointLPS:null})}return p}else{for(let v=h;v<=g;v++){const y=v*this.frameSize;for(let m=u;m<=d;m++){const w=y+m*this.width;for(let x=l,C=w+x;x<=f;x++,C++){const S=this.getAtIndex(C),T=[x,m,v];a(null,T)&&(s&&p.push({value:S,index:C,pointIJK:T,pointLPS:null}),n({value:S,index:C,pointIJK:[x,m,v],pointLPS:null}))}}}return p}},this.getSliceData=({sliceIndex:n,slicePlane:i})=>{const[o,a,s]=this.dimensions,c=o*a,l=n*c;let f;const u=this.getConstructor();function d(g){return typeof g=="function"}if(!d(u))return new Uint8Array(0);let h;switch(i){case 0:f=a*s,h=new u(f);for(let g=0;g<a;g++)for(let p=0;p<s;p++){const v=n+g*o+p*c;this.setSliceDataValue(h,g*s+p,this._get(v))}break;case 1:f=o*s,h=new u(f);for(let g=0;g<o;g++)for(let p=0;p<s;p++){const v=g+n*o+p*c;this.setSliceDataValue(h,g+p*o,this._get(v))}break;case 2:f=o*a,h=new u(f);for(let g=0;g<f;g++)this.setSliceDataValue(h,g,this._get(l+g));break;default:throw new Error("Oblique plane - todo - implement as ortho normal vector")}return h},this.dimensions=e,this.width=e[0],this.frameSize=this.width*e[1],this._get=r._get,this._set=r._set,this._id=r._id||"",this._getConstructor=r._getConstructor,this.numberOfComponents=this.numberOfComponents||1,this.scalarData=r.scalarData,this._getScalarData=r._getScalarData,this._updateScalarData=r._updateScalarData}getMinMax(){let e,r;const n=({value:i})=>{const o=Array.isArray(i);if(e===void 0&&(e=o?[...i]:i,r=o?[...i]:i),o)for(let a=0;a<i.length;a++)e[a]=Math.min(e[a],i[a]),r[a]=Math.max(r[a],i[a]);else e=Math.min(e,i),r=Math.max(r,i)};return this.forEach(n,{boundsIJK:this.getDefaultBounds()}),{min:e,max:r}}toIJK(e){return[e%this.width,Math.floor(e%this.frameSize/this.width),Math.floor(e/this.frameSize)]}toIndex(e){return e[0]+e[1]*this.width+e[2]*this.frameSize}getDefaultBounds(){return this.dimensions.map(e=>[0,e-1])}getBoundsIJK(){return this.boundsIJK[0][0]<this.dimensions[0]?this.boundsIJK:this.getDefaultBounds()}rleForEach(e,r){const n=(r==null?void 0:r.boundsIJK)||this.getBoundsIJK(),{isWithinObject:i}=r||{},o=this.map;if(!o){console.warn("No map found, you need to use a map voxel manager to use rleForEach");return}o.defaultValue=void 0;for(let a=n[2][0];a<=n[2][1];a++)for(let s=n[1][0];s<=n[1][1];s++){const c=o.getRun(s,a);if(c)for(const l of c){const{start:f,end:u,value:d}=l,h=this.toIndex([0,s,a]);for(let g=f;g<u;g++){const p={value:d,index:h+g,pointIJK:[g,s,a]};(i==null?void 0:i(p))!==!1&&e(p)}}}}getScalarData(e=!1){var r;if(this.scalarData)return(r=this._updateScalarData)==null||r.call(this,this.scalarData),this.scalarData;if(this._getScalarData){const n=this._getScalarData();return e&&console.log("Not transient, should store value",n),n}throw new Error("No scalar data available")}setScalarData(e){this.scalarData=e}getScalarDataLength(){if(this.scalarData)return this.scalarData.length;if(this._getScalarDataLength)return this._getScalarDataLength();throw new Error("No scalar data available")}get sizeInBytes(){return this.getScalarDataLength()*this.bytePerVoxel}get bytePerVoxel(){return this.scalarData?this.scalarData.BYTES_PER_ELEMENT:this._get(0).BYTES_PER_ELEMENT}clearBounds(){this.boundsIJK.map(e=>{e[0]=1/0,e[1]=-1/0})}clear(){var e,r;(e=this.map)==null||e.clear(),this.clearBounds(),this.modifiedSlices.clear(),(r=this.points)==null||r.clear()}getConstructor(){return this.scalarData?this.scalarData.constructor:this._getConstructor?this._getConstructor():(console.warn("No scalar data available or can be used to get the constructor"),Float32Array)}getArrayOfModifiedSlices(){return Array.from(this.modifiedSlices)}resetModifiedSlices(){this.modifiedSlices.clear()}setBounds(e){this.boundsIJK=e}static addBounds(e,r){e||(e=[[1/0,-1/0],[1/0,-1/0],[1/0,-1/0]]),e[0][0]=Math.min(r[0],e[0][0]),e[0][1]=Math.max(r[0],e[0][1]),e[1][0]=Math.min(r[1],e[1][0]),e[1][1]=Math.max(r[1],e[1][1]),e[2][0]=Math.min(r[2],e[2][0]),e[2][1]=Math.max(r[2],e[2][1])}addPoint(e){const r=Array.isArray(e)?e[0]+this.width*e[1]+this.frameSize*e[2]:e;this.points||(this.points=new Set),this.points.add(r)}getPoints(){return this.points?[...this.points].map(e=>this.toIJK(e)):[]}setSliceDataValue(e,r,n){if(Array.isArray(n))for(let i=0;i<n.length;i++)e[r*n.length+i]=this.toNumber(n[i]);else e[r]=this.toNumber(n)}toNumber(e){return typeof e=="number"?e:Array.isArray(e)&&e[0]||0}static _createRGBScalarVolumeVoxelManager({dimensions:e,scalarData:r,numberOfComponents:n=3,id:i}){const o=new wi(e,{_get:a=>(a*=n,[r[a++],r[a++],r[a++]]),_id:i||"_createRGBScalarVolumeVoxelManager",_set:(a,s)=>{a*=3;const c=!Vt(r[a],s);return r[a++]=s[0],r[a++]=s[1],r[a++]=s[2],c},numberOfComponents:n,scalarData:r});return o.clear=()=>{r.fill(0)},o}static createImageVolumeVoxelManager({dimensions:e,imageIds:r,numberOfComponents:n=1,id:i}){const o=e[0]*e[1];function a(u){const d=Math.floor(u/o);if(d<0||d>=e[2])return{};const h=r[d];if(!h)return console.warn(`ImageId not found for sliceIndex: ${d}`),{pixelData:null,pixelIndex:null};const g=$e.getImage(h);if(!g)return console.warn(`Image not found for imageId: ${h}`),{pixelData:null,pixelIndex:null};const p=g.voxelManager,v=u%o;return{voxelManager:p,pixelIndex:v}}function s(u){const{voxelManager:d,pixelIndex:h}=a(u);return!d||h===null?null:d.getAtIndex(h)}function c(u,d){const{voxelManager:h,pixelIndex:g}=a(u);if(!h||g===null)return!1;const p=h.getAtIndex(g),v=!Vt(d,p);return v&&(h.setAtIndex(g,d),!0)}const l=()=>{const{voxelManager:u,pixelIndex:d}=a(0);return!u||d===null?null:u.getConstructor()},f=new wi(e,{_get:s,_set:c,numberOfComponents:n,_getConstructor:l,_id:i||"createImageVolumeVoxelManager"});return f.getMiddleSliceData=()=>{const u=Math.floor(e[2]/2);return f.getSliceData({sliceIndex:u,slicePlane:2})},f.clear=()=>{for(const u of r)$e.getImage(u).voxelManager.clear()},f.getRange=()=>{let u=1/0,d=-1/0;for(const h of r){const g=$e.getImage(h);g&&(g.minPixelValue<u&&(u=g.minPixelValue),g.maxPixelValue>d&&(d=g.maxPixelValue))}return u===1/0&&d===-1/0?[0,0]:[u,d]},f._getScalarDataLength=()=>{const{voxelManager:u,pixelIndex:d}=a(0);return!u||d===null?0:u.getScalarDataLength()*e[2]},f.getCompleteScalarDataArray=()=>{const u=f._getConstructor();if(!u)return new Uint8Array(0);const d=f.getScalarDataLength(),h=new u(d),g=e[0]*e[1]*n;for(let p=0;p<e[2];p++){const{voxelManager:v,pixelIndex:y}=a(p*g/n);if(v&&y!==null){const m=p*g,w=v.getScalarData();if(n===1)h.set(w,m);else for(let x=0;x<w.length;x+=n)for(let C=0;C<n;C++)h[m+x+C]=w[x+C]}}return h},f.setCompleteScalarDataArray=u=>{const d=e[0]*e[1]*n,h=f._getConstructor();let g=1/0,p=-1/0;for(let v=0;v<e[2];v++){const{voxelManager:y}=a(v*d/n);if(y&&h){const m=v*d,w=m+d,x=new h(d);if(x.set(u.subarray(m,w)),y.scalarData)y.scalarData.set(x),y.modifiedSlices.add(v);else for(let T=0;T<d;T++)y.setAtIndex(T,x[T]);for(let T=0;T<x.length;T++){const _=x[T];g=Math.min(g,_),p=Math.max(p,_)}const C=r[v],S=$e.getImage(C);S&&(S.minPixelValue=g,S.maxPixelValue=p)}}for(let v=0;v<e[2];v++)f.modifiedSlices.add(v);f.boundsIJK=[[0,e[0]-1],[0,e[1]-1],[0,e[2]-1]]},f}static createScalarVolumeVoxelManager({dimensions:e,scalarData:r,numberOfComponents:n,id:i}){if(e.length!==3)throw new Error("Dimensions must be provided as [number, number, number] for [width, height, depth]");if(!n&&(n=r.length/e[0]/e[1]/e[2],n>4||n<1||n===2))throw new Error(`Number of components ${n} must be 1, 3 or 4`);return n>1?wi._createRGBScalarVolumeVoxelManager({dimensions:e,scalarData:r,numberOfComponents:n,id:i}):wi._createNumberVolumeVoxelManager({dimensions:e,scalarData:r,id:i})}static createScalarDynamicVolumeVoxelManager({imageIdGroups:e,dimensions:r,dimensionGroupNumber:n=1,timePoint:i=0,numberOfComponents:o=1,id:a}){let s=0;if(n!==void 0?s=n-1:i!==void 0&&(console.warn("Warning: timePoint parameter is deprecated. Please use dimensionGroupNumber instead. timePoint is zero-based while dimensionGroupNumber starts at 1."),s=i),!o){const f=$e.getImage(e[0][0]);if(!f)throw new Error("Unable to determine number of components: No image found");if(o=f.getPixelData().length/(r[0]*r[1]),o>4||o<1||o===2)throw new Error(`Number of components ${o} must be 1, 3 or 4`)}const c=e.map(f=>wi.createImageVolumeVoxelManager({dimensions:r,imageIds:f,numberOfComponents:o,id:a})),l=new wi(r,{_get:f=>c[s]._get(f),_set:(f,u)=>c[s]._set(f,u),numberOfComponents:o,_id:a||"createScalarDynamicVolumeVoxelManager"});return l.getScalarDataLength=()=>c[s].getScalarDataLength(),l.getConstructor=()=>c[s].getConstructor(),l.getRange=()=>c[s].getRange(),l.getMiddleSliceData=()=>c[s].getMiddleSliceData(),l.setTimePoint=f=>{console.warn("Warning: setTimePoint is deprecated. Please use setDimensionGroupNumber instead. Note that timePoint is zero-based while dimensionGroupNumber starts at 1."),l.setDimensionGroupNumber(f+1)},l.setDimensionGroupNumber=f=>{s=f-1,l._get=u=>c[s]._get(u),l._set=(u,d)=>c[s]._set(u,d)},l.getAtIndexAndTimePoint=(f,u)=>(console.warn("Warning: getAtIndexAndTimePoint is deprecated. Please use getAtIndexAndDimensionGroup instead. Note that timePoint is zero-based while dimensionGroupNumber starts at 1."),l.getAtIndexAndDimensionGroup(f,u+1)),l.getAtIndexAndDimensionGroup=(f,u)=>c[u-1]._get(f),l.getTimePointScalarData=f=>(console.warn("Warning: getTimePointScalarData is deprecated. Please use getDimensionGroupScalarData instead. Note that timePoint is zero-based while dimensionGroupNumber starts at 1."),l.getDimensionGroupScalarData(f+1)),l.getDimensionGroupScalarData=f=>c[f-1].getCompleteScalarDataArray(),l.getCurrentTimePointScalarData=()=>(console.warn("Warning: getCurrentTimePointScalarData is deprecated. Please use getCurrentDimensionGroupScalarData instead."),l.getCurrentDimensionGroupScalarData()),l.getCurrentDimensionGroupScalarData=()=>c[s].getCompleteScalarDataArray(),l.getCurrentTimePoint=()=>(console.warn("Warning: getCurrentTimePoint is deprecated. Please use getCurrentDimensionGroupNumber instead. Note that timePoint is zero-based while dimensionGroupNumber starts at 1."),s),l.getCurrentDimensionGroupNumber=()=>s+1,l}static createImageVoxelManager({width:e,height:r,scalarData:n,numberOfComponents:i=1,id:o}){const a=[e,r,1];if(!i&&(i=n.length/e/r,i>4||i<1||i===2))throw new Error(`Number of components ${i} must be 1, 3 or 4`);return i>1?wi._createRGBScalarVolumeVoxelManager({dimensions:a,scalarData:n,numberOfComponents:i,id:o}):wi._createNumberVolumeVoxelManager({dimensions:a,scalarData:n,id:o})}static _createNumberVolumeVoxelManager({dimensions:e,scalarData:r,id:n}){const i=new wi(e,{_get:o=>r[o],_set:(o,a)=>{const s=r[o]!==a;return r[o]=a,s},_getConstructor:()=>r.constructor,_id:n||"_createNumberVolumeVoxelManager"});return i.scalarData=r,i.clear=()=>{i.scalarData.fill(0)},i.getMiddleSliceData=()=>{const o=Math.floor(e[2]/2);return i.getSliceData({sliceIndex:o,slicePlane:2})},i}static createMapVoxelManager({dimension:e,id:r}){const n=new Map,i=new wi(e,{_get:n.get.bind(n),_set:(o,a)=>n.set(o,a)&&!0,_id:r||"createMapVoxelManager"});return i.map=n,i}static createHistoryVoxelManager(e,r){const n=new Map,{dimensions:i}=e,o=new wi(i,{_get:a=>n.get(a),_set:function(a,s){if(n.has(a))s===n.get(a)&&n.delete(a);else{const c=this.sourceVoxelManager.getAtIndex(a);if(c===s)return!1;n.set(a,c)}this.sourceVoxelManager.setAtIndex(a,s)},_id:r||"createHistoryVoxelManager"});return o.map=n,o.scalarData=e.scalarData,o.sourceVoxelManager=e,o}static createRLEHistoryVoxelManager(e,r){const{dimensions:n}=e,i=new c0(n[0],n[1],n[2]),o=new wi(n,{_get:a=>i.get(a),_set:function(a,s){const c=i.get(a);if(c===void 0){const l=this.sourceVoxelManager.getAtIndex(a);if(l===s||l===void 0&&s===0||s===null)return!1;i.set(a,l??0)}else(s===c||s===null)&&(i.delete(a),s=c);this.sourceVoxelManager.setAtIndex(a,s)},_getScalarData:c0.getScalarData,_updateScalarData:a=>(i.updateScalarData(a),a),_id:r||"createRLEHistoryVoxelManager"});return o.map=i,o.sourceVoxelManager=e,o}static createLazyVoxelManager({dimensions:e,planeFactory:r,id:n}){const i=new Map,[o,a]=e,s=o*a,c=new wi(e,{_get:l=>i.get(Math.floor(l/s))[l%s],_set:(l,f)=>{const u=Math.floor(l/s);let d=i.get(u);return d||(d=r(o,a),i.set(u,d)),d[l%s]=f,!0},_id:n||"createLazyVoxelManager"});return c.map=i,c}static createRLEVolumeVoxelManager({dimensions:e,id:r}){const[n,i,o]=e,a=new c0(n,i,o),s=new wi(e,{_get:c=>a.get(c),_set:(c,l)=>(a.set(c,l),!0),_getScalarData:c0.getScalarData,_updateScalarData:c=>(a.updateScalarData(c),c),_id:r||"createRLEVolumeVoxelManager"});return s.map=a,s.getPixelData=a.getPixelData.bind(a),s}static createRLEImageVoxelManager({dimensions:e,id:r}){const[n,i]=e;return wi.createRLEVolumeVoxelManager({dimensions:[n,i,1],id:r})}static addInstanceToImage(e){const{width:r,height:n}=e,i=e.voxelManager.getScalarData();if(i.length>=r*n){e.voxelManager=wi.createScalarVolumeVoxelManager({dimensions:[r,n,1],scalarData:i});return}e.voxelManager=wi.createRLEVolumeVoxelManager({dimensions:[r,n,1]}),e.getPixelData=e.voxelManager.getPixelData,e.sizeInBytes=_se}};class Ud{constructor(e){this._imageIdsIndexMap=new Map,this._imageURIsIndexMap=new Map,this.cornerstoneImageMetaData=null,this.isPreScaled=!1,this.numTimePoints=null,this.numFrames=null;const{imageIds:r,scaling:n,dimensions:i,spacing:o,origin:a,direction:s,dataType:c,volumeId:l,referencedVolumeId:f,metadata:u,referencedImageIds:d,additionalDetails:h,voxelManager:g,numberOfComponents:p}=e;if(!c)throw new Error('Data type is required, please provide a data type as string such as "Uint8Array", "Float32Array", etc.');let{imageData:v}=e;this.imageIds=r,this.volumeId=l,this.metadata=u,this.dimensions=i,this.spacing=o,this.origin=a,this.direction=s,this.dataType=c,this.vtkOpenGLTexture=Jre.newInstance(),this.vtkOpenGLTexture.setVolumeId(l),this.voxelManager=g??fc.createImageVolumeVoxelManager({dimensions:i,imageIds:r,numberOfComponents:p}),this.numVoxels=this.dimensions[0]*this.dimensions[1]*this.dimensions[2],v||(v=nm.newInstance(),v.setDimensions(i),v.setSpacing(o),v.setDirection(s),v.setOrigin(a)),v.set({dataType:c,voxelManager:this.voxelManager,id:l,numberOfComponents:p||1}),v.set({hasScalarVolume:!1}),this.imageData=v,this.numFrames=this._getNumFrames(),this._reprocessImageIds(),n&&(this.scaling=n),f&&(this.referencedVolumeId=f),d&&(this.referencedImageIds=d),h&&(this.additionalDetails=h)}get sizeInBytes(){return this.voxelManager.sizeInBytes}get imageIds(){return this._imageIds}set imageIds(e){this._imageIds=e,this._reprocessImageIds()}_reprocessImageIds(){this._imageIdsIndexMap.clear(),this._imageURIsIndexMap.clear(),this._imageIds.forEach((e,r)=>{const n=_r(e);this._imageIdsIndexMap.set(e,r),this._imageURIsIndexMap.set(n,r)})}isDynamicVolume(){return this.numTimePoints>1}getImageIdIndex(e){return this._imageIdsIndexMap.get(e)}getImageIdByIndex(e){return this._imageIds[e]}getImageURIIndex(e){return this._imageURIsIndexMap.get(e)}load(e){}destroy(){this.imageData.delete(),this.imageData=null,this.voxelManager.clear(),this.vtkOpenGLTexture.releaseGraphicsResources(),this.vtkOpenGLTexture.delete()}invalidate(){for(let e=0;e<this.imageIds.length;e++)this.vtkOpenGLTexture.setUpdatedFrame(e);this.imageData.modified()}modified(){this.imageData.modified(),this.vtkOpenGLTexture.modified(),this.numFrames=this._getNumFrames()}removeFromCache(){$e.removeVolumeLoadObject(this.volumeId)}getScalarDataLength(){return this.voxelManager.getScalarDataLength()}_getNumFrames(){return this.isDynamicVolume()?this.numTimePoints:this.imageIds.length}imageIdIndexToFrameIndex(e){return e%this.numFrames}getCornerstoneImages(){const{imageIds:e}=this;return e.map(r=>$e.getImage(r))}}let bg={};const Uu={add:(t,e)=>{Uu.addRaw(t,{...e,metadata:structuredClone(e.metadata)})},addRaw:(t,e)=>{const r=e.type;bg[t]||(bg[t]={}),bg[t][r]=e.metadata},get:(t,e)=>{var r;return(r=bg[e])==null?void 0:r[t]},clear:()=>{bg={}}};zh(Uu.get);const _i=new O4("imageLoadPool");_i.grabDelay=0;_i.setMaxSimultaneousRequests(Qt.Interaction,1e3);_i.setMaxSimultaneousRequests(Qt.Thumbnail,1e3);_i.setMaxSimultaneousRequests(Qt.Prefetch,1e3);const Vy={};let Fy;function ck(t,e){const r=$e.getImageLoadObject(t);if(r)return KD(r.promise,t),r;const n=t.split(":")[0],i=Vy[n]||Fy;if(!i)throw new Error(`loadImageFromImageLoader: No image loader found for scheme '${n}'`);const o=i(t,e);return KD(o.promise,t),o}function KD(t,e){Promise.resolve(t).then(r=>{Ese(r),it(Ze,et.IMAGE_LOADED,{image:r})}).catch(r=>{const n={imageId:e,error:r};it(Ze,et.IMAGE_LOAD_FAILED,n)})}function Ese(t){if(!t.voxelManager){const{width:e,height:r,numberOfComponents:n}=t,i=fc.createImageVoxelManager({scalarData:t.getPixelData(),width:e,height:r,numberOfComponents:n});t.voxelManager=i,t.getPixelData=()=>i.getScalarData(),delete t.imageFrame.pixelData}}function lk(t,e={priority:0,requestType:"prefetch"}){if(t===void 0)throw new Error("loadImage: parameter imageId must not be undefined");return ck(t,e).promise}function ws(t,e={priority:0,requestType:"prefetch"}){if(t===void 0)throw new Error("loadAndCacheImage: parameter imageId must not be undefined");const r=ck(t,e);return $e.getImageLoadObject(t)||$e.putImageLoadObject(t,r),r.promise}function bse(t,e={priority:0,requestType:"prefetch"}){if(!t||t.length===0)throw new Error("loadAndCacheImages: parameter imageIds must be list of image Ids");return t.map(n=>ws(n,e))}function d1(t,e={}){var p;if(t===void 0)throw new Error("createAndCacheDerivedImage: parameter imageId must not be undefined");e.imageId===void 0&&(e.imageId=`derived:${gn()}`);const{imageId:r,skipCreateBuffer:n,onCacheAdd:i,voxelRepresentation:o}=e,a=ct("imagePlaneModule",t),s=a.rows*a.columns,{TypedArrayConstructor:c}=D4((p=e.targetBuffer)==null?void 0:p.type,s),l=new c(n?1:s),f=r,u=ct("imagePlaneModule",t);Uu.add(f,{type:"imagePlaneModule",metadata:u});const d=ct("generalSeriesModule",t);Uu.add(f,{type:"generalSeriesModule",metadata:d}),Uu.add(f,{type:"generalImageModule",metadata:{instanceNumber:e.instanceNumber}});const h=ct("imagePixelModule",t);Uu.add(f,{type:"imagePixelModule",metadata:{...h,bitsAllocated:8,bitsStored:8,highBit:7,samplesPerPixel:1,pixelRepresentation:0}});const g=K4(r,{scalarData:l,onCacheAdd:i,skipCreateBuffer:n,targetBuffer:{type:l.constructor.name},voxelRepresentation:o,dimensions:[a.columns,a.rows],spacing:[a.columnPixelSpacing,a.rowPixelSpacing],origin:a.imagePositionPatient,direction:a.imageOrientationPatient,frameOfReferenceUID:a.frameOfReferenceUID,referencedImageId:t});return g.referencedImageId=t,$e.getImageLoadObject(r)||$e.putImageSync(r,g),g}function H4(t,e={}){if(t.length===0)throw new Error("createAndCacheDerivedImages: parameter imageIds must be list of image Ids");return t.map((n,i)=>{var a;const o={imageId:((a=e==null?void 0:e.getDerivedImageId)==null?void 0:a.call(e,n))||`derived:${gn()}`,...e};return d1(n,{...o,instanceNumber:i+1})})}function K4(t,e){const{scalarData:r,origin:n,direction:i,targetBuffer:o,skipCreateBuffer:a,onCacheAdd:s,frameOfReferenceUID:c,voxelRepresentation:l,referencedImageId:f}=e,u=e.dimensions,d=e.spacing;if(!u||!d)throw new Error("createAndCacheLocalImage: dimensions and spacing are required");const h=u[0],g=u[1],p=d[0],v=d[1],y={frameOfReferenceUID:c,rows:g,columns:h,imageOrientationPatient:i??[1,0,0,0,1,0],rowCosines:i?i.slice(0,3):[1,0,0],columnCosines:i?i.slice(3,6):[0,1,0],imagePositionPatient:n??[0,0,0],pixelSpacing:[v,p],rowPixelSpacing:v,columnPixelSpacing:p},m=h*g,w=r.length/m;let x;if(r){if(!(r instanceof Uint8Array||r instanceof Float32Array||r instanceof Uint16Array||r instanceof Int16Array))throw new Error("createAndCacheLocalImage: scalarData must be of type Uint8Array, Uint16Array, Int16Array or Float32Array");x=r}else if(!a){const{TypedArrayConstructor:L}=D4(o==null?void 0:o.type,m);x=new L(m)}let C,S,T;if(x instanceof Uint8Array)C=8,S=8,T=7;else if(x instanceof Uint16Array)C=16,S=16,T=15;else if(x instanceof Int16Array)C=16,S=16,T=15;else if(x instanceof Float32Array)C=32,S=32,T=31;else throw new Error("Unsupported scalarData type");const _={samplesPerPixel:1,photometricInterpretation:x.length>u[0]*u[1]?"RGB":"MONOCHROME2",rows:g,columns:h,bitsAllocated:C,bitsStored:S,highBit:T},E={imagePlaneModule:y,imagePixelModule:_};["imagePlaneModule","imagePixelModule"].forEach(L=>{Uu.add(t,{type:L,metadata:E[L]||{}})});const b=t,D=l===dy.RLE&&fc.createRLEImageVoxelManager({dimensions:u,id:b})||fc.createImageVoxelManager({height:g,width:h,numberOfComponents:w,scalarData:x,id:b});let I=x[0],P=x[0];for(let L=1;L<x.length;L++)x[L]<I&&(I=x[L]),x[L]>P&&(P=x[L]);const O={imageId:t,intercept:0,windowCenter:0,windowWidth:0,color:_.photometricInterpretation==="RGB",numberOfComponents:_.samplesPerPixel,dataType:o==null?void 0:o.type,slope:1,minPixelValue:I,maxPixelValue:P,rows:_.rows,columns:_.columns,getCanvas:void 0,height:_.rows,width:_.columns,rgba:void 0,columnPixelSpacing:y.columnPixelSpacing,rowPixelSpacing:y.rowPixelSpacing,FrameOfReferenceUID:y.frameOfReferenceUID,invert:!1,getPixelData:()=>D.getScalarData(),voxelManager:D,sizeInBytes:r.byteLength,referencedImageId:f};return s==null||s(O),$e.putImageSync(O.imageId,O),O}function uk(t){const e=({additionalDetails:n})=>n.imageId?n.imageId!==t:!0;_i.filterRequests(e);const r=$e.getImageLoadObject(t);r&&r.cancelFn()}function Dse(t){t.forEach(e=>{uk(e)})}function Ise(){const t=_i.getRequestPool();Object.keys(t).forEach(e=>{const r=t[e];Object.keys(r).forEach(n=>{const i=r[n].pop();if(!i)return;const o=i.additionalDetails,{imageId:a,volumeId:s}=o;let c;a?c=$e.getImageLoadObject(a):s&&(c=$e.getVolumeLoadObject(s)),c&&c.cancel()}),_i.clearRequestStack(e)})}function ld(t,e){Vy[t]=e}function Ose(t){const e=Fy;return Fy=t,e}function Mse(){Object.keys(Vy).forEach(t=>delete Vy[t]),Fy=void 0}function Pse(t,e={}){return H4(t,{...e,targetBuffer:{type:"Uint8Array"}})}function Rse(t,e={}){return d1(t,{...e,targetBuffer:{type:"Uint8Array"}})}const Lse=Object.freeze(Object.defineProperty({__proto__:null,cancelLoadAll:Ise,cancelLoadImage:uk,cancelLoadImages:Dse,createAndCacheDerivedImage:d1,createAndCacheDerivedImages:H4,createAndCacheDerivedLabelmapImage:Rse,createAndCacheDerivedLabelmapImages:Pse,createAndCacheLocalImage:K4,loadAndCacheImage:ws,loadAndCacheImages:bse,loadImage:lk,registerImageLoader:ld,registerUnknownImageLoader:Ose,unregisterAllImageLoaders:Mse},Symbol.toStringTag,{value:"Module"}));function fk(t){const e=t[0],{pixelRepresentation:r,bitsAllocated:n,bitsStored:i,highBit:o,photometricInterpretation:a,samplesPerPixel:s}=ct("imagePixelModule",e),c=[],l=ct("voiLutModule",e);let f;if(l){const{windowWidth:m,windowCenter:w}=l;if(f=l==null?void 0:l.voiLUTFunction,Array.isArray(m))for(let x=0;x<m.length;x++)c.push({windowWidth:m[x],windowCenter:w[x]});else c.push({windowWidth:m,windowCenter:w})}else c.push({windowWidth:void 0,windowCenter:void 0});const{modality:u,seriesInstanceUID:d}=ct("generalSeriesModule",e),{imageOrientationPatient:h,pixelSpacing:g,frameOfReferenceUID:p,columns:v,rows:y}=ct("imagePlaneModule",e);return{BitsAllocated:n,BitsStored:i,SamplesPerPixel:s,HighBit:o,PhotometricInterpretation:a,PixelRepresentation:r,Modality:u,ImageOrientationPatient:h,PixelSpacing:g,FrameOfReferenceUID:p,Columns:v,Rows:y,voiLut:c,VOILUTFunction:f,SeriesInstanceUID:d}}function dk(t){const{imagePositionPatient:e,imageOrientationPatient:r}=ct("imagePlaneModule",t[0]),n=Tt(r[0],r[1],r[2]),i=Tt(r[3],r[4],r[5]),o=Ke();Tn(o,n,i);const a=Tt(e[0],e[1],e[2]),s=t[0].split(":")[0]==="wadouri";let c;function l(h){const{imagePositionPatient:g}=ct("imagePlaneModule",h),p=Ke(),v=Tt(g[0],g[1],g[2]);return hn(p,a,v),xt(p,o)}if(s){const h=[t[0],t[Math.floor(t.length/2)]];l(h[0]),l(h[1]);const g=ct("imagePlaneModule",h[1]);if(!g)throw new Error("Incomplete metadata required for volume construction.");const p=Ke(),v=Tt(g.imagePositionPatient[0],g.imagePositionPatient[1],g.imagePositionPatient[2]);hn(p,a,v);const y=xt(p,o);c=Math.abs(y)/Math.floor(t.length/2)}else{const h=t.map(p=>({distance:l(p),imageId:p}));h.sort((p,v)=>v.distance-p.distance);const g=h.length;c=Math.abs(h[g-1].distance-h[0].distance)/(g-1)}const{sliceThickness:f,spacingBetweenSlices:u}=ct("imagePlaneModule",t[0]),{strictZSpacingForVolumeViewport:d}=hw().rendering;return(c===0||isNaN(c))&&!d&&(u?(console.debug("Could not calculate spacing. Using spacingBetweenSlices"),c=u):f?(console.debug("Could not calculate spacing and no spacingBetweenSlices. Using sliceThickness"),c=f):(console.debug("Could not calculate spacing. The VolumeViewport visualization is compromised. Setting spacing to 1 to render"),c=1)),c}function q4(t,e){const{imagePositionPatient:r,imageOrientationPatient:n}=ct("imagePlaneModule",t[0]);if(!e){const f=Tt(n[0],n[1],n[2]),u=Tt(n[3],n[4],n[5]);e=Ke(),Tn(e,f,u)}const i=t[0].split(":")[0]==="wadouri",o=dk(t);let a;function s(f){const{imagePositionPatient:u}=ct("imagePlaneModule",f),d=Ke();return hn(d,r,u),xt(d,e)}if(i){const f=[t[0],t[Math.floor(t.length/2)]];a=t;const u=s(f[0]),d=s(f[1]);u-d<0&&a.reverse()}else{const f=t.map(u=>({distance:s(u),imageId:u}));f.sort((u,d)=>d.distance-u.distance),a=f.map(u=>u.imageId)}const{imagePositionPatient:c}=ct("imagePlaneModule",a[0]);return{zSpacing:o,origin:c,sortedImageIds:a}}function hk(t){const e=ct("modalityLutModule",t)||{},r=ct("generalSeriesModule",t)||{},{modality:n}=r,i={rescaleSlope:e.rescaleSlope||1,rescaleIntercept:e.rescaleIntercept??0,modality:n},o=ct("scalingModule",t)||{};return{...i,...n==="PT"&&{suvbw:o.suvbw,suvbsa:o.suvbsa,suvlbm:o.suvlbm},...n==="RTDOSE"&&{doseGridScaling:o.DoseGridScaling,doseSummation:o.DoseSummation,doseType:o.DoseType,doseUnit:o.DoseUnit}}}const X4=t=>Object.values(t).some(r=>typeof r=="number"&&!Number.isInteger(r)),qD={Uint8Array:"Uint8Array",Int16Array:"Int16Array",Uint16Array:"Uint16Array",Float32Array:"Float32Array"};function sm(t,e){const r=fk(t),{ImageOrientationPatient:n,PixelSpacing:i,Columns:o,Rows:a}=r,s=Tt(n[0],n[1],n[2]),c=Tt(n[3],n[4],n[5]),l=Ke();Tn(l,s,c);const{zSpacing:f,origin:u,sortedImageIds:d}=q4(t,l),h=t.length,g=[i[1],i[0],f],p=[o,a,h].map(y=>Math.floor(y)),v=[...s,...c,...l];return{dimensions:p,spacing:g,origin:u,dataType:Ase(d,r),direction:v,metadata:r,imageIds:d,volumeId:e,voxelManager:null,numberOfComponents:r.PhotometricInterpretation==="RGB"?3:1}}function Ase(t,e){const{BitsAllocated:r,PixelRepresentation:n}=e,i=n===1,o=Nse(t);if(o)return o;const[a,s,c]=[0,Math.floor(t.length/2),t.length-1],l=[a,s,c].map(h=>hk(t[h])),f=l.some(h=>h.rescaleIntercept<0||h.rescaleSlope<0),u=l.some(h=>X4(h)),d=dw();switch(r){case 8:return"Uint8Array";case 16:return d&&u?"Float32Array":i||f?"Int16Array":!i&&!f?"Uint16Array":"Float32Array";case 24:return"Uint8Array";case 32:return"Float32Array";default:throw new Error(`Bits allocated of ${r} is not defined to generate scalarData for the volume.`)}}function Nse(t){const r=[0,Math.floor(t.length/2),t.length-1].map(i=>$e.getImage(t[i]));if(!r.every(Boolean))return null;const n=r[0].getPixelData().constructor.name;return r.every(i=>i.getPixelData().constructor.name===n)&&n in qD?qD[n]:null}let Uy=class gk{constructor(e){this.name=e||"unknown"}static as(e){if(e.iterator)return e.iterator;const r=new gk("as iterator");return e.then(n=>{try{r.add(n,!0)}catch(i){r.reject(i)}},n=>{r.reject(n)}),r}add(e,r=!1){this.nextValue=e,this.done||(this.done=r),this.waiting&&(this.waiting.resolve(e),this.waiting=void 0)}resolve(){this.done=!0,this.waiting&&(this.waiting.resolve(this.nextValue),this.waiting=void 0)}reject(e){var r;this.rejectReason=e,(r=this.waiting)==null||r.reject(e)}getRecent(){if(this.rejectReason)throw this.rejectReason;return this.nextValue}async*[Symbol.asyncIterator](){for(;!this.done;){if(this.rejectReason)throw this.rejectReason;if(this.nextValue!==void 0&&(yield this.nextValue,this.done))break;this.waiting||(this.waiting={},this.waiting.promise=new Promise((e,r)=>{this.waiting.resolve=e,this.waiting.reject=r})),await this.waiting.promise}yield this.nextValue}async forEach(e,r){let n=0;try{for await(const i of this){const{done:o}=this;try{await e(i,o,n),n++}catch(a){if(!o){console.warn("Caught exception in intermediate value",a);continue}if(r)r(a,o);else throw a}}}catch(i){if(r)r(i,!0);else throw i}}generate(e,r){return e(this,this.reject.bind(this)).then(()=>{this.done||this.resolve()},n=>{this.reject(n),r?r(n):console.warn("Couldn't process because",n)})}async nextPromise(){for await(const e of this)if(e)return e;return this.nextValue}async donePromise(){for await(const e of this);return this.nextValue}getNextPromise(){const e=this.nextPromise();return e.iterator=this,e}getDonePromise(){const e=this.donePromise();return e.iterator=this,e}};const Zd=new Map,XD="imageRetrieveConfiguration",h1={IMAGE_RETRIEVE_CONFIGURATION:XD,clear:()=>{Zd.clear()},add:(t,e)=>{Zd.set(t,e)},clone:()=>new Map(Zd),restore:t=>{Zd.clear(),t.forEach((e,r)=>{Zd.set(r,e)})},get:(t,...e)=>{if(t===XD)return e.map(r=>Zd.get(r)).find(r=>r!==void 0)}};zh(h1.get.bind(h1));function cm(t){const e=Po(),r=[];return e.forEach(n=>{const o=n.getVolumeViewports().filter(a=>a.hasVolumeId(t));r.push(...o)}),r}const ES=t=>{const e=kse(t);e!=null&&e.length&&e.forEach(({renderingEngine:r,viewportIds:n})=>{r.hasBeenDestroyed||r.renderViewports(n)})};function kse(t){const e=Po(),r=[];return e.forEach(n=>{const i=cm(t);i.length&&r.push({renderingEngine:n,viewportIds:i.map(o=>o.id)})}),r}const YD=[{id:"initialImages",retrieveType:"single"}],Vse=[{id:"lossySequential",retrieveType:"singleFast"},{id:"finalSequential",retrieveType:"singleFinal"}],eC=[{offset:-1,imageQualityStatus:ca.ADJACENT_REPLICATE},{offset:1,imageQualityStatus:ca.ADJACENT_REPLICATE},{offset:2,imageQualityStatus:ca.FAR_REPLICATE}],Fse=[{id:"initialImages",positions:[.5,0,-1],retrieveType:"default",requestType:Qt.Thumbnail,priority:5,nearbyFrames:eC},{id:"quarterThumb",decimate:4,offset:3,requestType:Qt.Thumbnail,retrieveType:"multipleFast",priority:6,nearbyFrames:eC},{id:"halfThumb",decimate:4,offset:1,priority:7,requestType:Qt.Thumbnail,retrieveType:"multipleFast",nearbyFrames:eC},{id:"quarterFull",decimate:4,offset:2,priority:8,requestType:Qt.Thumbnail,retrieveType:"multipleFinal"},{id:"halfFull",decimate:4,offset:0,priority:9,requestType:Qt.Thumbnail,retrieveType:"multipleFinal"},{id:"threeQuarterFull",decimate:4,offset:1,priority:10,requestType:Qt.Thumbnail,retrieveType:"multipleFinal"},{id:"finalFull",decimate:4,offset:3,priority:11,requestType:Qt.Thumbnail,retrieveType:"multipleFinal"},{id:"errorRetrieve"}];function pk(t,e,r=0){const n=[];for(let i=r;i<t.length;i+=e)n.push(i);return n}function Use(t,e,r){var n;if((n=e==null?void 0:e.nearbyRequests)!=null&&n.length)for(const i of e.nearbyRequests)try{const{itemId:o,imageQualityStatus:a}=i,s=$e.getImageQuality(o);if(s!==void 0&&s>=a)continue;const c={...r,imageId:o,imageQualityStatus:a};$e.setPartialImage(o,c),t.successCallback(o,c)}catch(o){console.warn("Couldn't fill nearby item ",i.itemId,o)}}const P0=class P0{constructor(e){this.stages=e.stages||YD,this.retrieveOptions=e.retrieveOptions||{}}loadImages(e,r){return new Bse(this,e,r).loadImages()}};P0.createProgressive=mk,P0.interleavedRetrieveStages={stages:Fse},P0.singleRetrieveStages={stages:YD},P0.sequentialRetrieveStages={stages:Vse};let g1=P0;class Bse{constructor(e,r,n){this.outstandingRequests=0,this.stageStatusMap=new Map,this.displayedIterator=new Uy("displayed"),this.stages=e.stages,this.retrieveOptions=e.retrieveOptions,this.imageIds=r,this.listener=n}async loadImages(){const e=this.createStageRequests();this.outstandingRequests=e.length;for(const r of e)this.addRequest(r);return this.outstandingRequests===0?Promise.resolve(null):this.displayedIterator.getDonePromise()}sendRequest(e,r){const{imageId:n,next:i}=e,o=(f,u)=>{this.listener.errorCallback(n,c||!i,f),u&&this.updateStageStatus(e.stage,f)},a=(r.loader||ws)(n,r),s=Uy.as(a);let c=!1;return s.forEach(async(f,u)=>{const d=$e.getImageQuality(n);if(!f){console.warn("No image retrieved",n);return}const{imageQualityStatus:h}=f;if(c||(c=h===ca.FULL_RESOLUTION),d!==void 0&&d>h){this.updateStageStatus(e.stage,null,!0);return}this.listener.successCallback(n,f),this.displayedIterator.add(f),u&&this.updateStageStatus(e.stage),Use(this.listener,e,f)},o).finally(()=>{if(!c&&i)$e.setPartialImage(n),this.addRequest(i,r.streamingData);else{c||this.listener.errorCallback(n,!0,"Couldn't decode"),this.outstandingRequests--;for(let f=i;f;f=f.next)this.updateStageStatus(f.stage,null,!0)}this.outstandingRequests<=0&&this.displayedIterator.resolve()}),s.getDonePromise().catch(f=>null)}addRequest(e,r={}){const{imageId:n,stage:i}=e,o=this.listener.getLoaderImageOptions(n);if(!o)return;const{retrieveType:a="default"}=i,{retrieveOptions:s}=this,c=s[a]||s.default,l={...o,retrieveType:a,retrieveOptions:c,streamingData:r},f=i.priority??-5,u=i.requestType||Qt.Interaction,d={imageId:n};_i.addRequest(this.sendRequest.bind(this,e,l),u,d,f)}updateStageStatus(e,r,n=!1){const{id:i}=e,o=this.stageStatusMap.get(i);if(o&&(o.imageLoadPendingCount--,r?o.imageLoadFailedCount++:n||o.totalImageCount++,!n&&!o.stageStartTime&&(o.stageStartTime=Date.now()),!o.imageLoadPendingCount)){const{imageLoadFailedCount:a,totalImageCount:s,stageStartTime:c=Date.now(),startTime:l}=o,f={stageId:i,numberOfFailures:a,numberOfImages:s,stageDurationInMS:c?Date.now()-c:null,startDurationInMS:Date.now()-l};it(Ze,et.IMAGE_RETRIEVAL_STAGE,f),this.stageStatusMap.delete(i)}}createStageRequests(){const e=new Array,r=new Map,n=(i,o)=>{const a=o<0?this.imageIds.length+o:o<1?Math.floor((this.imageIds.length-1)*o):o,s=this.imageIds[a];if(!s)throw new Error(`No value found to add to requests at ${o}`);const c={imageId:s,stage:i,index:a,nearbyRequests:this.findNearbyRequests(a,i)};this.addStageStatus(i);const l=r.get(s);l?l.next=c:e.push(c),r.set(s,c)};for(const i of this.stages)(i.positions||pk(this.imageIds,i.decimate||1,i.offset??0)).forEach(a=>{n(i,a)});return e}findNearbyRequests(e,r){const n=new Array;if(!r.nearbyFrames)return n;for(const i of r.nearbyFrames){const o=e+i.offset;o<0||o>=this.imageIds.length||n.push({itemId:this.imageIds[o],imageQualityStatus:i.imageQualityStatus,index:o})}return n}addStageStatus(e){const{id:r}=e,n=this.stageStatusMap.get(r)||{stageId:r,startTime:Date.now(),stageStartTime:null,totalImageCount:0,imageLoadFailedCount:0,imageLoadPendingCount:0};return n.imageLoadPendingCount++,this.stageStatusMap.set(r,n),n}}function mk(t){return new g1(t)}const JD=Qt.Prefetch;class vk extends Ud{constructor(e,r){super(e),this.framesLoaded=0,this.framesProcessed=0,this.framesUpdated=0,this.autoRenderOnLoad=!0,this.cachedFrames=[],this.reRenderTarget=0,this.reRenderFraction=2,this.imagesLoader=this,this.cancelLoading=()=>{const{loadStatus:n}=this;if(!n||!n.loading)return;n.loading=!1,n.cancelled=!0,this.clearLoadCallbacks();const i=({additionalDetails:o})=>o.volumeId!==this.volumeId;_i.filterRequests(i)},this.loadStatus=r.loadStatus}invalidateVolume(e){const{vtkOpenGLTexture:r}=this,{numFrames:n}=this;for(let i=0;i<n;i++)r.setUpdatedFrame(i);this.modified(),e&&ES(this.volumeId)}clearLoadCallbacks(){this.loadStatus.callbacks=[]}callLoadStatusCallback(e){const{framesUpdated:r,framesProcessed:n,totalNumFrames:i}=e,{volumeId:o,reRenderFraction:a,loadStatus:s,metadata:c}=this,{FrameOfReferenceUID:l}=c;if(this.autoRenderOnLoad&&(r>this.reRenderTarget||n===i)&&(this.reRenderTarget+=a,ES(o)),n===i){s.callbacks.forEach(u=>u(e));const f={FrameOfReferenceUID:l,volumeId:o};it(Ze,et.IMAGE_VOLUME_LOADING_COMPLETED,f)}}updateTextureAndTriggerEvents(e,r,n=ca.FULL_RESOLUTION){const i=this.imageIdIndexToFrameIndex(e),{cachedFrames:o,numFrames:a,totalNumFrames:s}=this,{FrameOfReferenceUID:c}=this.metadata;if(o[i]>n||o[i]===ca.FULL_RESOLUTION)return;const f=n===ca.FULL_RESOLUTION;o[e]=n,this.framesUpdated++,f&&(this.framesLoaded++,this.framesProcessed++);const u={FrameOfReferenceUID:c,volumeId:this.volumeId,numberOfFrames:a,framesProcessed:this.framesProcessed};it(Ze,et.IMAGE_VOLUME_MODIFIED,u),f&&this.framesProcessed===this.totalNumFrames&&(this.loadStatus.loaded=!0,this.loadStatus.loading=!1),this.callLoadStatusCallback({success:!0,imageIdIndex:e,imageId:r,framesLoaded:this.framesLoaded,framesProcessed:this.framesProcessed,framesUpdated:this.framesUpdated,numFrames:a,totalNumFrames:s,complete:f,imageQualityStatus:n}),this.vtkOpenGLTexture.setUpdatedFrame(i),this.loadStatus.loaded&&(this.loadStatus.callbacks=[])}successCallback(e,r){const n=this.getImageIdIndex(e),{imageQualityStatus:i}=r;if(this.loadStatus.cancelled){console.warn("volume load cancelled, returning for imageIdIndex: ",n);return}this.updateTextureAndTriggerEvents(n,e,i),this.isDynamicVolume()&&this.checkDimensionGroupCompletion(n)}errorCallback(e,r,n){if(!r)return;const{totalNumFrames:i,numFrames:o}=this,a=this.getImageIdIndex(e);this.framesProcessed++,this.framesProcessed===i&&(this.loadStatus.loaded=!0,this.loadStatus.loading=!1),this.callLoadStatusCallback({success:!1,imageId:e,imageIdIndex:a,error:n,framesLoaded:this.framesLoaded,framesProcessed:this.framesProcessed,framesUpdated:this.framesUpdated,numFrames:o,totalNumFrames:i}),this.loadStatus.loaded&&(this.loadStatus.callbacks=[]);const s={error:n,imageIdIndex:a,imageId:e};it(Ze,et.IMAGE_LOAD_ERROR,s)}load(e){const{imageIds:r,loadStatus:n,numFrames:i}=this,{transferSyntaxUID:o}=ct("transferSyntax",r[0])||{},a=ct(h1.IMAGE_RETRIEVE_CONFIGURATION,this.volumeId,o,"volume");if(this.imagesLoader=this.isDynamicVolume()?this:a?(a.create||g1.createProgressive)(a):this,n.loading===!0)return;const{loaded:s}=this.loadStatus,c=r.length;if(s){e&&e({success:!0,framesLoaded:c,framesProcessed:c,numFrames:i,totalNumFrames:c});return}e&&this.loadStatus.callbacks.push(e),this._prefetchImageIds()}getLoaderImageOptions(e){const{transferSyntaxUID:r}=ct("transferSyntax",e)||{},n=ct("imagePlaneModule",e)||{},{rows:i,columns:o}=n,a=this.getImageIdIndex(e),s=ct("modalityLutModule",e)||{},c=ct("generalSeriesModule",e)||{},l={rescaleSlope:s.rescaleSlope,rescaleIntercept:s.rescaleIntercept,modality:c.modality},f=l.modality;if(f==="PT"||f==="RTDOSE"){const g=ct("scalingModule",e);g&&(this._addScalingToVolume(g),Object.assign(l,g))}const u=X4(l),d=dw();if(this.isPreScaled=!0,l&&l.rescaleSlope!==void 0&&l.rescaleIntercept!==void 0){const{rescaleSlope:g,rescaleIntercept:p}=l;this.isPreScaled=typeof g=="number"&&typeof p=="number"}return!d&&u&&(this.isPreScaled=!1),{targetBuffer:{type:this.dataType,rows:i,columns:o},allowFloatRendering:d,preScale:{enabled:this.isPreScaled,scalingParameters:l},transferPixelData:!0,requestType:JD,transferSyntaxUID:r,additionalDetails:{imageId:e,imageIdIndex:a,volumeId:this.volumeId}}}callLoadImage(e,r,n){const{cachedFrames:i}=this;if(i[r]===ca.FULL_RESOLUTION)return;const o=s=>{const{image:c}=s.detail;c.imageId===e&&(this.vtkOpenGLTexture.setUpdatedFrame(r),Ze.removeEventListener(et.IMAGE_CACHE_IMAGE_ADDED,o))};return Ze.addEventListener(et.IMAGE_CACHE_IMAGE_ADDED,o),Uy.as(ws(e,n)).forEach(s=>{this.successCallback(e,s)},this.errorCallback.bind(this,r,e))}getImageIdsRequests(e,r){this.totalNumFrames=this.imageIds.length;const n=2;return this.autoRenderOnLoad&&(this.reRenderFraction=this.totalNumFrames*(n/100),this.reRenderTarget=this.reRenderFraction),e.map(o=>{const a=this.getImageIdIndex(o),s=JD,c=r,l=this.getLoaderImageOptions(o);return{callLoadImage:this.callLoadImage.bind(this),imageId:o,imageIdIndex:a,options:l,priority:c,requestType:s,additionalDetails:{volumeId:this.volumeId}}})}getImageLoadRequests(e){throw new Error("Abstract method")}getImageIdsToLoad(){throw new Error("Abstract method")}loadImages(){return this.loadStatus.loading=!0,this.getImageLoadRequests(5).reverse().forEach(r=>{if(!r)return;const{callLoadImage:n,imageId:i,imageIdIndex:o,options:a,priority:s,requestType:c,additionalDetails:l}=r;_i.addRequest(n.bind(this,i,o,a),c,l,s)}),Promise.resolve(!0)}_prefetchImageIds(){this.loadStatus.loading=!0;const e=[...this.getImageIdsToLoad()];this.totalNumFrames=this.imageIds.length;const r=2;return this.autoRenderOnLoad&&(this.reRenderFraction=this.totalNumFrames*(r/100),this.reRenderTarget=this.reRenderFraction),this.imagesLoader.loadImages(e,this).catch(n=>{console.debug("progressive loading failed to complete",n)})}_addScalingToVolume(e){if(this.scaling)return;const{suvbw:r,suvlbm:n,suvbsa:i}=e,o={};n&&(o.suvbwToSuvlbm=n/r),i&&(o.suvbwToSuvbsa=i/r),r&&(o.suvbw=r),this.scaling={PT:o}}checkDimensionGroupCompletion(e){}}class yk extends vk{constructor(e,r){e.imageIds||(e.imageIds=r.imageIds),super(e,r),this.getImageIdsToLoad=()=>{const{imageIds:n}=this;return this.numFrames=n.length,n}}getScalarData(){return this.voxelManager.getScalarData()}getImageLoadRequests(e){const{imageIds:r}=this;return this.getImageIdsRequests(r,e)}}function wk(t,e){if(!e||!e.imageIds||!e.imageIds.length)throw new Error("ImageIds must be provided to create a streaming image volume");async function r(){if(e.imageIds[0].split(":")[0]==="wadouri"){const[g,p]=[Math.floor(e.imageIds.length/2),e.imageIds.length-1],v=[0,g,p];await Promise.all(v.map(y=>$e.isLoaded(e.imageIds[y])?Promise.resolve(!0):new Promise((m,w)=>{const x=e.imageIds[y];_i.addRequest(async()=>{lk(x).then(()=>{console.log(`Prefetched imageId: ${x}`),m(!0)}).catch(C=>{w(C)})},Qt.Prefetch,{volumeId:t},1)}))).catch(console.error)}const i=sm(e.imageIds,t),{dimensions:o,spacing:a,origin:s,direction:c,metadata:l,imageIds:f,dataType:u,numberOfComponents:d}=i;return new yk({volumeId:t,metadata:l,dimensions:o,spacing:a,origin:s,direction:c,imageIds:f,dataType:u,numberOfComponents:d},{imageIds:f,loadStatus:{loaded:!1,loading:!1,cancelled:!1,cachedFrames:[],callbacks:[]}})}const n=r();return{promise:n,decache:()=>{n.then(i=>{i.destroy(),i=null})},cancel:()=>{n.then(i=>{i.cancelLoading()})}}}const Y4={};let Z0=wk;function xk(t,e){const r=t.indexOf(":"),n=t.substring(0,r);let i=Y4[n];if(i==null){if(Z0==null||typeof Z0!="function")throw new Error(`No volume loader for scheme ${n} has been registered`);i=Z0}const o=i(t,e);return o.promise.then(function(a){it(Ze,et.VOLUME_LOADED,{volume:a})},function(a){const s={volumeId:t,error:a};it(Ze,et.VOLUME_LOADED_FAILED,s)}),o}function J4(t,e={imageIds:[]}){if(t===void 0)throw new Error("loadVolume: parameter volumeId must not be undefined");let r=$e.getVolumeLoadObject(t);return r!==void 0?r.promise:(r=xk(t,e),r.promise.then(n=>n))}async function p1(t,e){if(t===void 0)throw new Error("createAndCacheVolume: parameter volumeId must not be undefined");let r=$e.getVolumeLoadObject(t);return r!==void 0||(r=xk(t,e),$e.putVolumeLoadObject(t,r)),r.promise}function Ck(t,e){const r=$e.getVolume(t);if(!r)throw new Error(`Cannot created derived volume: Referenced volume with id ${t} does not exist.`);let{volumeId:n}=e;const{voxelRepresentation:i}=e;n===void 0&&(n=gn());const{metadata:o,dimensions:a,spacing:s,origin:c,direction:l}=r,f=r.isDynamicVolume()?r.getCurrentDimensionGroupImageIds():r.imageIds??[],u=H4(f,{targetBuffer:e.targetBuffer,voxelRepresentation:i}),d=u[0].dataType,h=u.map(p=>p.imageId),g=new Ud({volumeId:n,dataType:d,metadata:structuredClone(o),dimensions:[a[0],a[1],a[2]],spacing:s,origin:c,direction:l,referencedVolumeId:t,imageIds:h,referencedImageIds:r.imageIds??[]});return $e.putVolumeSync(n,g),g}async function Z4(t,e){if(e===void 0)throw new Error("createAndCacheVolumeFromImages: parameter imageIds must not be undefined");if(t===void 0)throw new Error("createAndCacheVolumeFromImages: parameter volumeId must not be undefined");const r=$e.getVolume(t);return r||(e.filter(o=>!$e.getImage(o)).length===0?lm(t,e):await p1(t,{imageIds:e}))}function lm(t,e){if(e===void 0)throw new Error("createAndCacheVolumeFromImagesSync: parameter imageIds must not be undefined");if(t===void 0)throw new Error("createAndCacheVolumeFromImagesSync: parameter volumeId must not be undefined");const r=$e.getVolume(t);if(r)return r;const n=sm(e,t),i=new Ud({volumeId:t,dataType:n.dataType,metadata:structuredClone(n.metadata),dimensions:n.dimensions,spacing:n.spacing,origin:n.origin,direction:n.direction,referencedVolumeId:n.referencedVolumeId,imageIds:n.imageIds,referencedImageIds:n.referencedImageIds});return $e.putVolumeSync(t,i),i}function um(t,e={}){const{metadata:r,dimensions:n,spacing:i,origin:o,direction:a,scalarData:s,targetBuffer:c,preventCache:l=!1}=e,f=$e.getVolume(t);if(f)return f;const u=n[0]*n[1],d=s?s.constructor.name:(c==null?void 0:c.type)??"Float32Array",h=u*n[2];let g;switch(d){case"Uint8Array":case"Int8Array":g=h;break;case"Uint16Array":case"Int16Array":g=h*2;break;case"Float32Array":g=h*4;break}if(!$e.isCacheable(g))throw new Error(`Cannot created derived volume: Volume with id ${t} is not cacheable.`);const v=[];for(let w=0;w<n[2];w++){const x=`${t}_slice_${w}`;v.push(x);const C=s.subarray(w*u,(w+1)*u);K4(x,{scalarData:C,dimensions:[n[0],n[1]],spacing:[i[0],i[1]],origin:o,direction:a,targetBuffer:{type:d}})}const y=new Ud({volumeId:t,metadata:structuredClone(r),dimensions:[n[0],n[1],n[2]],spacing:i,origin:o,direction:a,imageIds:v,dataType:d}),m=fc.createImageVolumeVoxelManager({imageIds:v,dimensions:n,numberOfComponents:1,id:t});return y.voxelManager=m,l||$e.putVolumeSync(t,y),y}function Gse(t,e){Y4[t]=e}function Sk(){return Object.keys(Y4)}function Wse(t){const e=Z0;return Z0=t,e}function Tk(){return Z0.name}function fm(t,e={}){return Ck(t,{...e,targetBuffer:{type:"Uint8Array",...e==null?void 0:e.targetBuffer}})}function zse(t,e,r=!1){return t.scalarData||(t.scalarData=new Uint8Array(t.dimensions[0]*t.dimensions[1]*t.dimensions[2])),um(e,{...t,preventCache:r})}const $se=Object.freeze(Object.defineProperty({__proto__:null,createAndCacheDerivedLabelmapVolume:fm,createAndCacheDerivedVolume:Ck,createAndCacheVolume:p1,createAndCacheVolumeFromImages:Z4,createAndCacheVolumeFromImagesSync:lm,createLocalLabelmapVolume:zse,createLocalVolume:um,getUnknownVolumeLoaderSchema:Tk,getVolumeLoaderSchemes:Sk,loadVolume:J4,registerUnknownVolumeLoader:Wse,registerVolumeLoader:Gse},Symbol.toStringTag,{value:"Module"}));function _k(t,e){const r=jre.newInstance();hw().rendering.preferSizeOverAccuracy&&r.setPreferSizeOverAccuracy(!0),r.setInputData(t);const n=t.getSpacing(),i=(n[0]+n[1]+n[2])/6;return r.setMaximumSamplesPerRay(4e3),r.setSampleDistance(i),r.setScalarTexture(e),r}function Ek(t){const e=xN.newInstance();e.setBlendMode(t.getBlendMode());const r=t.getInputData(),{voxelManager:n}=r.get("voxelManager"),i=n.getCompleteScalarDataArray(),o=bt.newInstance({name:"Pixels",values:i});return r.getPointData().setScalars(o),e.setInputData(r),e.setMaximumSamplesPerRay(t.getMaximumSamplesPerRay()),e.setSampleDistance(t.getSampleDistance()),e}const jse=0,Hse=Qt.Prefetch;async function Q4(t,e){let r=qse(e);!r&&e.imageIds.length&&(r=await Xse(e),r=Kse(e,r)),!(r.lower===0&&r.upper===0||r.lower===void 0||r.upper===void 0)&&t.getProperty().getRGBTransferFunction(0).setMappingRange(r.lower,r.upper)}function Kse(t,e){const r=t.imageIds,n=Math.floor(r.length/2),i=r[n],o=ct("generalSeriesModule",i)||{};return Yse(o.modality,t)?{lower:0,upper:5}:e}function qse(t){const{imageIds:e,metadata:r}=t;let n;if(e!=null&&e.length){const i=Math.floor(e.length/2),o=e[i],a=ct("voiLutModule",o);if(a&&a.windowWidth&&a.windowCenter){a!=null&&a.voiLUTFunction&&(n={},n.voiLUTFunction=a==null?void 0:a.voiLUTFunction);const{windowWidth:s,windowCenter:c}=a,l=Array.isArray(s)?s[0]:s,f=Array.isArray(c)?c[0]:c;l!==0&&(n={windowWidth:l,windowCenter:f})}}else n=r.voiLut[0];if(n&&(n.windowWidth!==0||n.windowCenter!==0)){const{lower:i,upper:o}=Yu(Number(n.windowWidth),Number(n.windowCenter),n.voiLUTFunction);return{lower:i,upper:o}}}async function Xse(t){var h;const{imageIds:e}=t,r=Math.floor(e.length/2),n=t.imageIds[r],i=ct("generalSeriesModule",n)||{},{modality:o}=i,a=ct("modalityLutModule",n)||{},s={rescaleSlope:a.rescaleSlope,rescaleIntercept:a.rescaleIntercept,modality:o};let c;if(o==="PT"){const g=ct("scalingModule",n);g&&(c={...s,suvbw:g.suvbw})}const l={priority:jse,requestType:Hse,preScale:{scalingParameters:c}};let f=$e.getImage(n);(h=t.referencedImageIds)!=null&&h.length||(f=await ws(n,{...l,ignoreCache:!0}));let{min:u,max:d}=f.voxelManager.getMinMax();return(u==null?void 0:u.length)>1&&(u=Math.min(...u),d=Math.max(...d)),{lower:u,upper:d}}function Yse(t,e){var r;return!(t!=="PT"||!e.isPreScaled||!((r=e.scaling)!=null&&r.PT.suvbw))}async function By(t,e,r,n=!1){const{volumeId:i,callback:o,blendMode:a}=t,s=await J4(i);if(!s)throw new Error(`imageVolume with id: ${s.volumeId} does not exist`);const{imageData:c,vtkOpenGLTexture:l}=s,f=_k(c,l);a&&f.setBlendMode(a);const u=qie.newInstance();u.setMapper(f);const{numberOfComponents:d}=c.get("numberOfComponents");return u.getProperty().set({viewportId:r}),d===3&&u.getProperty().setIndependentComponents(!1),await Q4(u,s),o&&o({volumeActor:u,volumeId:i}),n||Jse(e,r,u,i),u}function Jse(t,e,r,n){const i=r.getProperty().getRGBTransferFunction(0).getRange(),o={viewportId:e,range:{lower:i[0],upper:i[1]},volumeId:n};it(t,et.VOI_MODIFIED,o)}const dl=t=>{const e="volumeId:",r=t.includes(e)?t.substring(e.length):t,n=r.indexOf("sliceIndex=");return n===-1?r:r.substring(0,n-1)},Zse=1+Ga,Qse=(t,e)=>e===t.substring(0,Math.min(t.length,e.length)),ZD=t=>!!Sk().find(e=>Qse(t.volumeId,e));function Hh(t,e,r,n=!1){const{viewPlaneNormal:i}=e,o=t.getActors();if(!o.length)return{spacingInNormalDirection:null,imageVolume:null,actorUID:null};const a=o.map(l=>{const f=l.referencedId??l.uid;return $e.getVolume(f)}).filter(l=>!!l);if(r){const l=dl(r),f=a.findIndex(g=>l.includes(g.volumeId)),u=a[f],{uid:d}=o[f],h=QD(u,i,t,n);return{imageVolume:u,spacingInNormalDirection:h,actorUID:d}}if(!a.length)return{spacingInNormalDirection:null,imageVolume:null,actorUID:null};const s={spacingInNormalDirection:1/0,imageVolume:null,actorUID:null},c=a.find(ZD);for(let l=0;l<a.length;l++){const f=a[l];if(c&&!ZD(f))continue;const u=QD(f,i,t);u*Zse<s.spacingInNormalDirection&&(s.spacingInNormalDirection=u,s.imageVolume=f,s.actorUID=o[l].uid)}return s}function QD(t,e,r,n=!1){const{slabThickness:i}=r.getProperties();let o=i;return(!i||!n)&&(o=Cf(t,e)),o}function Gy(t){const e=t.getCamera(),{spacingInNormalDirection:r,imageVolume:n}=Hh(t,e);if(!n)return;const{viewPlaneNormal:i,focalPoint:o}=e,a=t.getActors().find(g=>g.referencedId===n.volumeId||g.uid===n.volumeId);a||console.warn("No actor found for with actorUID of",n.volumeId);const s=a.actor,c=mw(s,i,o),{min:l,max:f,current:u}=c,d=Math.round((f-l)/r)+1;let h=(u-l)/(f-l)*d;return h=Math.floor(h),h>d-1?h=d-1:h<0&&(h=0),{numberOfSlices:d,imageIndex:h}}const T0={};function ece(t){T0[t]!==void 0&&delete T0[t]}function tce(t){const{renderingEngineId:e,viewportId:r}=t.detail,i=Nr(e).getViewport(r);if(!("setVolumes"in i))throw new Error("volumeNewImageEventDispatcher: viewport does not have setVolumes method");T0[i.id]===void 0&&(T0[i.id]=0);const o=Gy(i);if(!o){console.warn(`volumeNewImageEventDispatcher: sliceData is undefined for viewport ${i.id}`);return}const{numberOfSlices:a,imageIndex:s}=o;if(T0[i.id]===s)return;T0[i.id]=s;const c={imageIndex:s,viewportId:r,renderingEngineId:e,numberOfSlices:a};it(i.element,et.VOLUME_NEW_IMAGE,c)}function Sh(t,e,r){const[n,i,o]=t,[a,s,c]=e,[l,f,u,d]=r,h=a-n,g=s-i,p=c-o,v=-1*(l*n+f*i+u*o-d)/(l*h+f*g+u*p),y=h*v+n,m=g*v+i,w=p*v+o;return[y,m,w]}function Yc(t,e,r=!1){const[n,i,o]=t,a=n*e[0]+i*e[1]+o*e[2];if(r){const s=Math.sqrt(n*n+i*i+o*o);return[n/s,i/s,o/s,a/s]}return[n,i,o,a]}function bk(t,e,r){const[n,i,o,a]=t,[s,c,l,f]=e,[u,d,h,g]=r,p=qg(n,s,u,i,c,d,o,l,h),v=qg(a,f,g,i,c,d,o,l,h),y=qg(n,s,u,a,f,g,o,l,h),m=qg(n,s,u,i,c,d,a,f,g),w=Wf(v)/Wf(p),x=Wf(y)/Wf(p),C=Wf(m)/Wf(p);return[w,x,C]}function m1(t,e,r=!1){const[n,i,o,a]=t,[s,c,l]=e,f=n*s+i*c+o*l-a,u=Math.abs(f)/Math.sqrt(n*n+i*i+o*o);return(r?Math.sign(f):1)*u}function Dk(t,e,r=Ga){return m1(e,t)<r}const nce=Object.freeze(Object.defineProperty({__proto__:null,isPointOnPlane:Dk,linePlaneIntersection:Sh,planeDistanceToPoint:m1,planeEquation:Yc,threePlaneIntersection:bk},Symbol.toStringTag,{value:"Module"}));function bS(t){return Array.isArray(t)?t.some(e=>Number.isNaN(e)):Number.isNaN(t)}function ds(t){if(t===null||typeof t!="object"||typeof t=="function"||typeof structuredClone=="function")return t;if(Array.isArray(t))return t.map(ds);{const e={};for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=ds(t[r]));return e}}const Pp=class Pp{constructor(e){this.insetImageMultiplier=1.1,this.flipHorizontal=!1,this.flipVertical=!1,this.viewportStatus=_o.NO_DATA,this._suppressCameraModifiedEvents=!1,this.hasPixelSpacing=!0,this.getProperties=()=>({}),this.setRotation=r=>{},this.viewportWidgets=new Map,this.addWidget=(r,n)=>{this.viewportWidgets.set(r,n)},this.getWidget=r=>this.viewportWidgets.get(r),this.getWidgets=()=>Array.from(this.viewportWidgets.values()),this.removeWidgets=()=>{this.getWidgets().forEach(n=>{if(n.getEnabled()&&n.setEnabled(!1),n.getActor&&n.getRenderer){const i=n.getActor(),o=n.getRenderer();o&&i&&o.removeActor(i)}})},this.id=e.id,this.renderingEngineId=e.renderingEngineId,this.type=e.type,this.element=e.element,this.canvas=e.canvas,this.sx=e.sx,this.sy=e.sy,this.sWidth=e.sWidth,this.sHeight=e.sHeight,this._actors=new Map,this.element.setAttribute("data-viewport-uid",this.id),this.element.setAttribute("data-rendering-engine-uid",this.renderingEngineId),this.defaultOptions=ds(e.defaultOptions),this.suppressEvents=e.defaultOptions.suppressEvents?e.defaultOptions.suppressEvents:!1,this.options=ds(e.defaultOptions),this.isDisabled=!1}static get useCustomRenderingPipeline(){return!1}setRendered(){this.viewportStatus===_o.NO_DATA||this.viewportStatus===_o.LOADING||(this.viewportStatus=_o.RENDERED)}setColorTransform(e,r){let n=null;if(!e&&!r)return;const i=r||[255,255,255],o=Math.max(...i),a=i.map(u=>o/u),{lower:s=0,upper:c=255}=e||{},l=(c-s+1)/255,f=s/255;return n=`url('data:image/svg+xml, <svg xmlns="http://www.w3.org/2000/svg"> <filter id="colour" color-interpolation-filters="linearRGB"> <feColorMatrix type="matrix" values=" ${a[0]*l} 0 0 0 ${f} 0 ${a[1]*l} 0 0 ${f} 0 0 ${a[2]*l} 0 ${f} 0 0 0 1 0" /> </filter> </svg>#colour')`,n}getRenderingEngine(){return o1.get(this.renderingEngineId)}getRenderer(){var r;const e=this.getRenderingEngine();if(!e||e.hasBeenDestroyed)throw new Error("Rendering engine has been destroyed");return(r=e.offscreenMultiRenderWindow)==null?void 0:r.getRenderer(this.id)}render(){this.getRenderingEngine().renderViewport(this.id)}setOptions(e,r=!1){var n,i;this.options=structuredClone(e),(n=this.options)!=null&&n.displayArea&&this.setDisplayArea((i=this.options)==null?void 0:i.displayArea),r&&this.render()}reset(e=!1){this.options=structuredClone(this.defaultOptions),e&&this.render()}getSliceViewInfo(){throw new Error("Method not implemented.")}flip({flipHorizontal:e,flipVertical:r}){const n=this.getDefaultImageData();if(!n)return;const i=this.getCamera(),{viewPlaneNormal:o,viewUp:a,focalPoint:s,position:c}=i,l=Tn(Ke(),o,a);let f=kY(Ke(),a);const u=qc(Ke(),o),d=Fi(c,s),g=n.getDimensions().map(C=>Math.floor(C/2)),p=[g[0],g[1],g[2]],v=n.indexToWorld(p,Ke()),y=this._getFocalPointForResetCamera(v,i,{resetPan:!0,resetToCenter:!1}),m=Nn(Ke(),s,y),w=Ko(m),x=C=>{const S=gr(Ke(),C,2*xt(m,C));return Nn(S,S,m),Un(S,S),S};if(e){const C=x(f),S=dn(Ke(),y,C,w),T=dn(Ke(),S,u,d);this.setCamera({viewPlaneNormal:u,position:T,focalPoint:S}),this.flipHorizontal=!this.flipHorizontal}if(r){f=qc(f,a);const C=x(l),S=dn(Ke(),y,C,w),T=dn(Ke(),S,u,d);this.setCamera({focalPoint:S,viewPlaneNormal:u,viewUp:f,position:T}),this.flipVertical=!this.flipVertical}this.render()}getDefaultImageData(){const e=this.getDefaultActor();if(e&&Qs(e))return e.actor.getMapper().getInputData()}getDefaultActor(){return this.getActors()[0]}getActors(){return Array.from(this._actors.values())}getActorUIDs(){return Array.from(this._actors.keys())}getActor(e){return this._actors.get(e)}getImageActor(e){const r=this.getActors();let n=r[0];return e&&(n=r.find(o=>o.referencedId===e)),!n||!Qs(n)?null:n.actor}getActorUIDByIndex(e){const r=this.getActors()[e];if(r)return r.uid}getActorByIndex(e){return this.getActors()[e]}setActors(e){const r=this.getActors();this.removeAllActors(),this.addActors(e,{resetCamera:!0}),it(this.element,et.ACTORS_CHANGED,{viewportId:this.id,removedActors:r,addedActors:e,currentActors:e})}_removeActor(e){const r=this.getActor(e);if(!r){console.warn(`Actor ${e} does not exist in ${this.id}, can't remove`);return}return this.getRenderer().removeActor(r.actor),this._actors.delete(e),r}removeActors(e){const r=[];e.forEach(i=>{const o=this._removeActor(i);o&&r.push(o)});const n=this.getActors();it(this.element,et.ACTORS_CHANGED,{viewportId:this.id,removedActors:r,addedActors:[],currentActors:n})}addActors(e,r={}){const{resetCamera:n=!1}=r,i=this.getRenderingEngine();if(!i||i.hasBeenDestroyed){console.warn("Viewport::addActors::Rendering engine has not been initialized or has been destroyed");return}e.forEach(s=>{this.addActor(s)});const o=this.getViewPresentation(),a=this.getViewReference();this.resetCamera(),n||(this.setViewReference(a),this.setViewPresentation(o)),it(this.element,et.ACTORS_CHANGED,{viewportId:this.id,removedActors:[],addedActors:e,currentActors:this.getActors()})}addActor(e){const{uid:r,actor:n}=e,i=this.getRenderingEngine();if(!i||i.hasBeenDestroyed){console.warn(`Cannot add actor UID of ${r} Rendering Engine has been destroyed`);return}if(!r||!n)throw new Error("Actors should have uid and vtk Actor properties");if(this.getActor(r)){console.warn(`Actor ${r} already exists for this viewport`);return}const o=this.getRenderer();o==null||o.addActor(n),this._actors.set(r,Object.assign({},e)),this.updateCameraClippingPlanesAndRange(),it(this.element,et.ACTORS_CHANGED,{viewportId:this.id,removedActors:[],addedActors:[e],currentActors:this.getActors()})}removeAllActors(){var r;const e=this.getActors();(r=this.getRenderer())==null||r.removeAllViewProps(),this._actors=new Map,it(this.element,et.ACTORS_CHANGED,{viewportId:this.id,removedActors:e,addedActors:[],currentActors:[]})}resetCameraNoEvent(){this._suppressCameraModifiedEvents=!0,this.resetCamera(),this._suppressCameraModifiedEvents=!1}setCameraNoEvent(e){this._suppressCameraModifiedEvents=!0,this.setCamera(e),this._suppressCameraModifiedEvents=!1}_getViewImageDataIntersections(e,r,n){const i=n[0],o=n[1],a=n[2],s=i*r[0]+o*r[1]+a*r[2],c=e.getBounds(),l=this._getEdges(c),f=[];for(const u of l){const[[d,h,g],[p,v,y]]=u;if(i*(p-d)+o*(v-h)+a*(y-g)===0)continue;const m=Sh([d,h,g],[p,v,y],[i,o,a,s]);this._isInBounds(m,c)&&f.push(m)}return f}setInterpolationType(e,r){}setDisplayArea(e,r=!1){var a;if(!e)return;const{storeAsInitialCamera:n,type:i}=e;n&&(this.options.displayArea=e);const{_suppressCameraModifiedEvents:o}=this;if(this._suppressCameraModifiedEvents=!0,this.setCamera(this.fitToCanvasCamera),i==="SCALE"?this.setDisplayAreaScale(e):(this.setInterpolationType(((a=this.getProperties())==null?void 0:a.interpolationType)??Fl.LINEAR),this.setDisplayAreaFit(e)),n&&(this.initialCamera=this.getCamera()),this._suppressCameraModifiedEvents=o,!r&&!o){const s={viewportId:this.id,displayArea:e,storeAsInitialCamera:n};it(this.element,et.DISPLAY_AREA_MODIFIED,s),this.setCamera(this.getCamera())}}setDisplayAreaScale(e){const{scale:r=1}=e,n=this.canvas,i=n.height,o=n.width;if(i<8||o<8)return;const c=this.getDefaultImageData().getSpacing()[1];this.setInterpolationType(Fl.NEAREST),this.setCamera({parallelScale:i*c/(2*r)}),delete e.imageArea,this.setDisplayAreaFit(e);const{focalPoint:l,position:f,viewUp:u,viewPlaneNormal:d}=this.getCamera(),h=Ke();if(n.height%2&&dn(h,h,u,r*.5*c),n.width%2){const g=Tn(Ke(),u,d);dn(h,h,g,r*.5*c)}!h[0]&&!h[1]&&!h[2]||this.setCamera({focalPoint:Hr(Ke(),l,h),position:Hr(Ke(),f,h)})}setDisplayAreaFit(e){const{imageArea:r,imageCanvasPoint:n}=e,i=(window==null?void 0:window.devicePixelRatio)||1,o=this.getDefaultImageData();if(!o)return;const a=this.sWidth/i,s=this.sHeight/i,c=o.getDimensions(),l=this.worldToCanvas(o.indexToWorld([0,0,0])),f=this.worldToCanvas(o.indexToWorld([c[0],c[1],c[2]])),u=[Math.abs(f[0]-l[0]),Math.abs(f[1]-l[1])],[d,h]=u;let g=this.getZoom()/this.insetImageMultiplier;if(r){const[p,v]=r,y=Math.max(Math.abs(d/a),Math.abs(h/s)),m=Math.abs(p*d/a),w=Math.abs(v*h/s),x=this.getZoom(),C=this.getZoom(this.fitToCanvasCamera);g=(m>w?y/m:y/w)*x/C,this.setZoom(this.insetImageMultiplier*g,!1)}if(n){const{imagePoint:p,canvasPoint:v=p||[.5,.5]}=n,[y,m]=v,w=a*(y-.5),x=s*(m-.5),[C,S]=p||v,T=g,_=this.insetImageMultiplier*T*d*(.5-C),E=this.insetImageMultiplier*T*h*(.5-S),b=_+w,D=E+x,I=[b,D];no(I,I,this.getPan()),this.setPan(I,!1)}}getDisplayArea(){var e;return(e=this.options)==null?void 0:e.displayArea}resetCamera(e){const{resetPan:r=!0,resetZoom:n=!0,resetToCenter:i=!0,storeAsInitialCamera:o=!0}=e||{},a=this.getRenderer();this.setCameraNoEvent({flipHorizontal:!1,flipVertical:!1});const s=this.getCamera();let c;const l=this.getDefaultActor();l&&Qs(l)?c=l.actor.getMapper().getInputData().getBounds():c=a.computeVisiblePropBounds();const f=[0,0,0],u=this.getDefaultImageData();if(u){const O=u.getSpacing();c[0]=c[0]+O[0]/2,c[1]=c[1]-O[0]/2,c[2]=c[2]+O[1]/2,c[3]=c[3]-O[1]/2,c[4]=c[4]+O[2]/2,c[5]=c[5]-O[2]/2}const d=this.getVtkActiveCamera(),h=d.getViewPlaneNormal(),g=d.getViewUp();if(f[0]=(c[0]+c[1])/2,f[1]=(c[2]+c[3])/2,f[2]=(c[4]+c[5])/2,u){const L=u.getDimensions().map(H=>Math.floor(H/2)),B=[L[0],L[1],L[2]];u.indexToWorld(B,f)}const{widthWorld:p,heightWorld:v}=this._getWorldDistanceViewUpAndViewRight(c,g,h),y=[this.sWidth,this.sHeight],m=p/v,w=y[0]/y[1],x=m/w,C=x<1?this.insetImageMultiplier*v/2:this.insetImageMultiplier*v*x/2,S=Pp.boundsRadius(c)*(this.type===ir.VOLUME_3D?10:1),T=this.insetImageMultiplier*S,_=Math.abs(Gt.dot(g,h))>.999?[-g[2],g[0],g[1]]:g,E=this._getFocalPointForResetCamera(f,s,{resetPan:r,resetToCenter:i}),b=[E[0]+T*h[0],E[1]+T*h[1],E[2]+T*h[2]];a.resetCameraClippingRange(c);const D=[-Wr.MAXIMUM_RAY_DISTANCE,Wr.MAXIMUM_RAY_DISTANCE];d.setPhysicalScale(S),d.setPhysicalTranslation(-E[0],-E[1],-E[2]),this.setCamera({parallelScale:n?C:s.parallelScale,focalPoint:E,position:b,viewAngle:90,viewUp:_,clippingRange:D});const I=this.getCamera();this.setFitToCanvasCamera(this.getCamera()),o&&this.setInitialCamera(I),n&&this.setZoom(1,o);const P={type:"ResetCameraEvent",renderer:a};return a.invokeEvent(P),this.triggerCameraModifiedEventIfNecessary(s,I),u&&this.options.displayArea&&n&&r&&i&&this.setDisplayArea(this.options.displayArea),!0}setInitialCamera(e){this.initialCamera=e}setFitToCanvasCamera(e){this.fitToCanvasCamera=e}getPan(e=this.initialCamera){if(!e)return[0,0];const n=this.getVtkActiveCamera().getFocalPoint(),i=this.canvasToWorld([0,0]),o=this.worldToCanvas(Nn([0,0,0],e.focalPoint,i)),a=this.worldToCanvas(Nn([0,0,0],n,i));return Br([0,0],o,a)}getCurrentImageIdIndex(){throw new Error("Not implemented")}getSliceIndex(){throw new Error("Not implemented")}getImageData(){throw new Error("Not implemented")}getViewReferenceId(e){return null}setPan(e,r=!1){const n=this.getCamera(),{focalPoint:i,position:o}=n,a=this.canvasToWorld([0,0]),s=Br([0,0],e,this.getPan());if(Math.abs(s[0])<1&&Math.abs(s[1])<1&&!r)return;const c=Nn(Ke(),this.canvasToWorld(s),a),l=Nn(Ke(),i,c),f=Nn(Ke(),o,c);this.setCamera({...n,focalPoint:l,position:f},r)}getZoom(e=this.initialCamera){if(!e)return 1;const r=this.getVtkActiveCamera(),{parallelScale:n}=e;return n/r.getParallelScale()}setZoom(e,r=!1){const n=this.getCamera(),{parallelScale:i}=this.initialCamera,o=i/e;n.parallelScale===o&&!r||this.setCamera({...n,parallelScale:o},r)}_getFocalPointForViewPlaneReset(e){const{focalPoint:r,viewPlaneNormal:n}=this.getCamera(),i=this._getViewImageDataIntersections(e,r,n);let o=0,a=0,s=0;return i.forEach(([l,f,u])=>{o+=l,a+=f,s+=u}),[o/i.length,a/i.length,s/i.length]}getCanvas(){return this.canvas}getVtkActiveCamera(){const e=this.getRenderer();return e?e.getActiveCamera():(console.warn("No renderer found for the viewport"),null)}getCameraNoRotation(){const e=this.getVtkActiveCamera(),r=(s,c)=>s.some(l=>isNaN(l))?c:s,n=r([...e.getViewUp()],[0,1,0]),i=r([...e.getViewPlaneNormal()],[0,0,-1]),o=r([...e.getPosition()],[0,0,1]),a=r([...e.getFocalPoint()],[0,0,0]);return{viewUp:n,viewPlaneNormal:i,position:o,focalPoint:a,parallelProjection:e.getParallelProjection(),parallelScale:e.getParallelScale(),viewAngle:e.getViewAngle(),flipHorizontal:this.flipHorizontal,flipVertical:this.flipVertical}}getCamera(){return{...this.getCameraNoRotation(),rotation:this.getRotation()}}setCamera(e,r=!1){const n=this.getVtkActiveCamera(),i=this.getCamera(),o=Object.assign({},i,e),{viewUp:a,viewPlaneNormal:s,position:c,focalPoint:l,parallelScale:f,viewAngle:u,flipHorizontal:d,flipVertical:h,clippingRange:g}=e;if(d!==void 0){const y=d&&!this.flipHorizontal||!d&&this.flipHorizontal;y&&this.flip({flipHorizontal:y})}if(h!==void 0){const y=h&&!this.flipVertical||!h&&this.flipVertical;y&&this.flip({flipVertical:y})}a!==void 0&&n.setViewUp(a),s!==void 0&&n.setDirectionOfProjection(-s[0],-s[1],-s[2]),c!==void 0&&n.setPosition(...c),l!==void 0&&n.setFocalPoint(...l),f!==void 0&&n.setParallelScale(f),u!==void 0&&n.setViewAngle(u),g!==void 0&&n.setClippingRange(g);const p=i.focalPoint,v=i.viewUp;if(p&&l||v&&a){const y=n.getViewPlaneNormal(),m=n.getViewUp();let w=!1,x=!1;if(l){const C=[l[0]-p[0],l[1]-p[1],l[2]-p[2]];w=Math.abs(Gt.dot(C,y))>0}if(a&&(x=!Vt(m,v)),w||x){const C=this.getDefaultActor();if(!(C!=null&&C.actor))return;ga(C,"vtkActor")||this.updateClippingPlanesForActors(o),(ga(C,"vtkImageSlice")||this.type===ir.VOLUME_3D)&&this.getRenderer().resetCameraClippingRange()}}r&&this.setInitialCamera(o),this.triggerCameraModifiedEventIfNecessary(i,this.getCamera())}triggerCameraModifiedEventIfNecessary(e,r){if(!this._suppressCameraModifiedEvents&&!this.suppressEvents){const n={previousCamera:e,camera:r,element:this.element,viewportId:this.id,renderingEngineId:this.renderingEngineId};it(this.element,et.CAMERA_MODIFIED,n)}}updateCameraClippingPlanesAndRange(){const e=this.getCamera();this.updateClippingPlanesForActors(e),this.getRenderer().resetCameraClippingRange()}async updateClippingPlanesForActors(e){this.getActors().map(n=>{if(!n.actor)return;const i=n.actor.getMapper();let o=n!=null&&n.clippingFilter?n==null?void 0:n.clippingFilter.getClippingPlanes():i.getClippingPlanes();o.length===0&&(n!=null&&n.clippingFilter)&&(o=[Io.newInstance(),Io.newInstance()]);let a=Wr.MINIMUM_SLAB_THICKNESS;n.slabThickness&&(a=n.slabThickness);const{viewPlaneNormal:s,focalPoint:c}=e;this.setOrientationOfClippingPlanes(o,a,s,c),it(this.element,et.CLIPPING_PLANES_UPDATED,{actorEntry:n,focalPoint:c,vtkPlanes:o,viewport:this})})}setOrientationOfClippingPlanes(e,r,n,i){if(e.length<2)return;const o=[n[0],n[1],n[2]];Gt.multiplyScalar(o,r),e[0].setNormal(n);const a=[0,0,0];Gt.subtract(i,o,a),e[0].setOrigin(a),e[1].setNormal(-n[0],-n[1],-n[2]);const s=[0,0,0];Gt.add(i,o,s),e[1].setOrigin(s)}getClippingPlanesForActor(e){if(e||(e=this.getDefaultActor()),!e.actor)throw new Error("Invalid actor entry: Actor is undefined");const r=e.actor.getMapper();let n=e!=null&&e.clippingFilter?e==null?void 0:e.clippingFilter.getClippingPlanes():r.getClippingPlanes();return n.length===0&&(e!=null&&e.clippingFilter)&&(n=[Io.newInstance(),Io.newInstance()]),n}_getWorldDistanceViewUpAndViewRight(e,r,n){const i=this._getCorners(e),o=this._getCorners(e),a=Tn(Ke(),r,n);let s=Ni.buildFromDegree().identity().rotateFromDirections(r,[1,0,0]);i.forEach(d=>s.apply(d));let c=1/0,l=-1/0;for(let d=0;d<8;d++){const h=i[d][0];h>l&&(l=h),h<c&&(c=h)}s=Ni.buildFromDegree().identity().rotateFromDirections([a[0],a[1],a[2]],[1,0,0]),o.forEach(d=>s.apply(d));let f=1/0,u=-1/0;for(let d=0;d<8;d++){const h=o[d][0];h>u&&(u=h),h<f&&(f=h)}return{widthWorld:u-f,heightWorld:l-c}}getViewReference(e){const{focalPoint:r,viewPlaneNormal:n,viewUp:i}=this.getCamera();return{FrameOfReferenceUID:this.getFrameOfReferenceUID(),cameraFocalPoint:r,viewPlaneNormal:n,viewUp:i,sliceIndex:(e==null?void 0:e.sliceIndex)??this.getSliceIndex()}}isReferenceViewable(e,r){if(e.FrameOfReferenceUID&&e.FrameOfReferenceUID!==this.getFrameOfReferenceUID())return!1;const{viewPlaneNormal:n}=e,i=this.getCamera();return n&&!Vt(n,i.viewPlaneNormal)&&!Vt(qc(i.viewPlaneNormal,i.viewPlaneNormal),n)?r==null?void 0:r.withOrientation:!0}getViewPresentation(e={rotation:!0,displayArea:!0,zoom:!0,pan:!0,flipHorizontal:!0,flipVertical:!0}){const r={},{rotation:n,displayArea:i,zoom:o,pan:a,flipHorizontal:s,flipVertical:c}=e;n&&(r.rotation=this.getRotation()),i&&(r.displayArea=this.getDisplayArea());const l=this.getZoom();return o&&(r.zoom=l),a&&(r.pan=this.getPan(),Al(r.pan,r.pan,1/l)),s&&(r.flipHorizontal=this.flipHorizontal),c&&(r.flipVertical=this.flipVertical),r}setViewReference(e){}setViewPresentation(e){if(!e)return;const{displayArea:r,zoom:n=this.getZoom(),pan:i,rotation:o,flipHorizontal:a=this.flipHorizontal,flipVertical:s=this.flipVertical}=e;r!==this.getDisplayArea()&&this.setDisplayArea(r),this.setZoom(n),i&&this.setPan(Al([0,0],i,n)),a!==void 0&&a!==this.flipHorizontal&&this.flip({flipHorizontal:a}),s!==void 0&&s!==this.flipVertical&&this.flip({flipVertical:s}),o>=0&&this.setRotation(o)}_getCorners(e){return[[e[0],e[2],e[4]],[e[0],e[2],e[5]],[e[0],e[3],e[4]],[e[0],e[3],e[5]],[e[1],e[2],e[4]],[e[1],e[2],e[5]],[e[1],e[3],e[4]],[e[1],e[3],e[5]]]}_getFocalPointForResetCamera(e,r,{resetPan:n=!0,resetToCenter:i=!0}){if(i&&n)return e;if(i&&!n)return bS(r.focalPoint)?e:r.focalPoint;if(!i&&n){const o=r,a=o.focalPoint,s=o.viewPlaneNormal,c=Nn(Ke(),e,a),l=xt(c,s),f=dn(Ke(),e,s,-1*l);return[f[0],f[1],f[2]]}if(!n&&!i)return bS(r.focalPoint)?e:r.focalPoint}_isInBounds(e,r){const[n,i,o,a,s,c]=r,[l,f,u]=e;return!(l<n||l>i||f<o||f>a||u<s||u>c)}_getEdges(e){const[r,n,i,o,a,s,c,l]=this._getCorners(e);return[[r,n],[r,a],[r,i],[n,o],[n,s],[i,o],[i,c],[o,l],[a,c],[a,s],[s,l],[c,l]]}static boundsRadius(e){const r=(e[1]-e[0])**2,n=(e[3]-e[2])**2,i=(e[5]-e[4])**2;return Math.sqrt(r+n+i||1)*.5}setDataIds(e,r){throw new Error("Unsupported operatoin setDataIds")}};Pp.CameraViewPresentation={rotation:!0,pan:!0,zoom:!0,displayArea:!0},Pp.TransferViewPresentation={windowLevel:!0,paletteLut:!0};let bd=Pp;function Ik(t,e,r=!1){const n=t.getCamera(),{focalPoint:i,viewPlaneNormal:o}=n,{spacingInNormalDirection:a,actorUID:s}=Hh(t,n,e,r);if(!s)throw new Error(`Could not find image volume with id ${e} in the viewport`);const c=t.getActor(s);if(!c)return console.warn("No actor found for with actorUID of",s),null;const l=c.actor;return{sliceRange:mw(l,o,i),spacingInNormalDirection:a,camera:n}}function ud(t,e,r=!1){const{sliceRange:n,spacingInNormalDirection:i,camera:o}=Ik(t,e,r),{min:a,max:s,current:c}=n,l=Math.round((s-a)/i),u=(c-a)/(s-a)*l,d=Math.round(u);return{numScrollSteps:l,currentStepIndex:d,sliceRangeInfo:{sliceRange:n,spacingInNormalDirection:i,camera:o}}}function Ok(t){let e=[];const[r,n]=t.getRange();t.getTable(r,n,1024,e),e=e.filter((h,g)=>g%3===0);const i=[...Array(1024).keys()].map((h,g)=>r+(n-r)/1023*g),o=e[256],a=Math.log((1-o)/o),s=i[256],c=e[256*3],l=Math.log((1-c)/c),f=i[256*3],u=Math.round(4*(f-s)/(a-l)),d=Math.round(s+u*a/4);return[Math.round(d-u/2),Math.round(d+u/2)]}function Mk(t,e){const r=e.colorTransfer.split(" ").splice(1).map(parseFloat),{shiftRange:n}=rce(r),i=n[0],o=n[1]-n[0],a=eu.newInstance(),s=[];for(let x=0;x<r.length;x+=4){let C=r[x];const S=r[x+1],T=r[x+2],_=r[x+3];C=(C-i)/o,s.push([C,S,T,_])}ice(s,n,a),t.getProperty().setRGBTransferFunction(0,a);const c=e.scalarOpacity.split(" ").splice(1).map(parseFloat),l=Ed.newInstance(),f=[];for(let x=0;x<c.length;x+=2){let C=c[x];const S=c[x+1];C=(C-i)/o,f.push([C,S])}oce(f,n,l);const u=t.getProperty();u.setScalarOpacity(0,l);const[d,h,g,p]=e.gradientOpacity.split(" ").splice(1).map(parseFloat);u.setUseGradientOpacity(0,!0),u.setGradientOpacityMinimumValue(0,d),u.setGradientOpacityMinimumOpacity(0,h),u.setGradientOpacityMaximumValue(0,g),u.setGradientOpacityMaximumOpacity(0,p),e.interpolation==="1"&&u.setInterpolationTypeToFastLinear(),u.setShade(e.shade==="1");const v=parseFloat(e.ambient),y=parseFloat(e.diffuse),m=parseFloat(e.specular),w=parseFloat(e.specularPower);u.setAmbient(v),u.setDiffuse(y),u.setSpecular(m),u.setSpecularPower(w)}function rce(t){let e=1/0,r=-1/0;for(let i=0;i<t.length;i+=4)e=Math.min(e,t[i]),r=Math.max(r,t[i]);const n=(r-e)/2;return{shiftRange:[-n,n],min:e,max:r}}function ice(t,e,r){const n=e[1]-e[0],i=t.map(([o,a,s,c])=>[o*n+e[0],a,s,c]);return r.removeAllPoints(),i.forEach(([o,a,s,c])=>r.addRGBPoint(o,a,s,c)),i}function oce(t,e,r){const n=e[1]-e[0],i=t.map(([o,a])=>[o*n+e[0],a]);return r.removeAllPoints(),i.forEach(([o,a])=>r.addPoint(o,a)),i}class fr extends bd{constructor(e){if(super(e),this.useCPURendering=!1,this.perVolumeIdDefaultProperties=new Map,this.viewportProperties={},this.volumeIds=new Set,this.setRotation=i=>{const o=this.getPan(this.fitToCanvasCamera),a=this.getPan(),s=this.getCamera(),c=ps([0,0],o,a);this.setPan(c,!1);const{flipVertical:l}=this.getCamera(),f=l?qc([0,0,0],this.initialViewUp):this.initialViewUp;this.setCameraNoEvent({viewUp:f}),this.rotateCamera(i);const u=this.getPan(),d=this.getPan(this.fitToCanvasCamera),h=ps([0,0],u,d),g=no([0,0],o,h);if(this.setPan(g,!1),this._suppressCameraModifiedEvents)return;const p=this.getCamera(),v={previousCamera:s,camera:p,element:this.element,viewportId:this.id,renderingEngineId:this.renderingEngineId};it(this.element,et.CAMERA_MODIFIED,v)},this.getDefaultProperties=i=>{let o;return i!==void 0&&(o=this.perVolumeIdDefaultProperties.get(i)),o!==void 0?o:{...this.globalDefaultProperties}},this.getProperties=i=>{var C;if(!this._getApplicableVolumeActor(i))return;const{colormap:a,VOILUTFunction:s,interpolationType:c,invert:l,slabThickness:f,preset:u}=this.viewportProperties;if(i||(i=this.getVolumeId()),!$e.getVolume(i))return null;const h=this.getActors().find(S=>S.referencedId===i);if(!h)return;const p=h.actor.getProperty().getRGBTransferFunction(0),[v,y]=((C=this.viewportProperties)==null?void 0:C.VOILUTFunction)==="SIGMOID"?Ok(p):p.getRange(),m={lower:v,upper:y},w=this.getColormap(i);return{colormap:i&&w?w:a,voiRange:m,VOILUTFunction:s,interpolationType:c,invert:l,slabThickness:f,preset:u}},this.getColormap=i=>{const o=this._getApplicableVolumeActor(i);if(!o)return;const{volumeActor:a}=o,s=this._getOrCreateColorTransferFunction(i),{nodes:c}=s.getState(),l=c.reduce((h,g)=>(h.push(g.x,g.r,g.g,g.b),h),[]),f=U4(l,a)||{},u=G4(a),d=W4(a);return f.threshold=u,f.opacity=d,f},this.getRotation=()=>{const{viewUp:i,viewPlaneNormal:o,flipVertical:a}=this.getCameraNoRotation(),s=a?qc([0,0,0],this.initialViewUp):this.initialViewUp;if(!s)return 0;const c=s4(s,i)*180/Math.PI,l=Tn([0,0,0],s,i);return xt(l,o)>=0?c:(360-c)%360},this.getFrameOfReferenceUID=()=>this._FrameOfReferenceUID,this.canvasToWorld=i=>{var u,d;const o=this.getVtkActiveCamera();(u=o.setIsPerformingCoordinateTransformation)==null||u.call(o,!0);const a=this.getRenderer(),s=this.getVtkDisplayCoords(i),f=this.getRenderingEngine().offscreenMultiRenderWindow.getOpenGLRenderWindow().displayToWorld(s[0],s[1],s[2],a);return(d=o.setIsPerformingCoordinateTransformation)==null||d.call(o,!1),[f[0],f[1],f[2]]},this.getVtkDisplayCoords=i=>{const o=window.devicePixelRatio||1,a=[i[0]*o,i[1]*o],l=this.getRenderingEngine().offscreenMultiRenderWindow.getOpenGLRenderWindow().getSize(),f=[a[0]+this.sx,a[1]+this.sy];return f[1]=l[1]-f[1],[f[0],f[1],0]},this.worldToCanvas=i=>{var g;const o=this.getVtkActiveCamera();(g=o.setIsPerformingCoordinateTransformation)==null||g.call(o,!0);const a=this.getRenderer(),c=this.getRenderingEngine().offscreenMultiRenderWindow.getOpenGLRenderWindow(),l=c.getSize(),f=c.worldToDisplay(...i,a);f[1]=l[1]-f[1];const u=[f[0]-this.sx,f[1]-this.sy],d=window.devicePixelRatio||1,h=[u[0]/d,u[1]/d];return o.setIsPerformingCoordinateTransformation(!1),h},this.hasImageURI=i=>this.getActors().filter(a=>ga(a,"vtkVolume")).some(({uid:a,referencedId:s})=>{const c=$e.getVolume(s||a);return c!=null&&c.imageIds?c.imageIds.map(_r).includes(i):!1}),this.getImageIds=i=>{const o=this._getApplicableVolumeActor(i);if(!o)throw new Error(`No actor found for the given volumeId: ${i}`);const a=o.volumeId,s=$e.getVolume(a);if(!s)throw new Error(`imageVolume with id: ${a} does not exist in cache`);return s.imageIds},this.useCPURendering=X0(),this.useCPURendering)throw new Error("VolumeViewports cannot be used whilst CPU Fallback Rendering is enabled.");const r=this.getRenderer(),n=tie.newInstance();switch(r.setActiveCamera(n),this.type){case ir.ORTHOGRAPHIC:n.setParallelProjection(!0);break;case ir.VOLUME_3D:n.setParallelProjection(!0);break;case ir.PERSPECTIVE:n.setParallelProjection(!1);break;default:throw new Error(`Unrecognized viewport type: ${this.type}`)}this.initializeVolumeNewImageEventDispatcher()}static get useCustomRenderingPipeline(){return!1}getSliceViewInfo(){throw new Error("Method not implemented.")}applyViewOrientation(e,r=!0){const{viewPlaneNormal:n,viewUp:i}=this._getOrientationVectors(e),o=this.getVtkActiveCamera();o.setDirectionOfProjection(-n[0],-n[1],-n[2]),o.setViewUpFrom(i),this.initialViewUp=i,r&&this.resetCamera({resetOrientation:!1,resetRotation:!1})}initializeVolumeNewImageEventDispatcher(){const e=n.bind(this),r=i.bind(this);function n(o){const{viewportId:a}=o.detail;a!==this.id||this.isDisabled||!this.getImageData()||tce(o)}function i(o){const{viewportId:a}=o.detail;a===this.id&&(this.element.removeEventListener(et.CAMERA_MODIFIED,e),Ze.removeEventListener(et.ELEMENT_DISABLED,r),ece(a))}this.element.removeEventListener(et.CAMERA_MODIFIED,e),this.element.addEventListener(et.CAMERA_MODIFIED,e),Ze.addEventListener(et.ELEMENT_DISABLED,r)}setVOILUTFunction(e,r,n){Object.values(oo).includes(e)||(e=oo.LINEAR);const{voiRange:i}=this.getProperties();this.setVOI(i,r,n),this.viewportProperties.VOILUTFunction=e}setColormap(e,r,n){const i=this._getApplicableVolumeActor(r);if(!i)return;const{volumeActor:o}=i,a=eu.newInstance();let s=f1(e.name);const{name:c}=e;if(s||(s=u1.getPresetByName(c)),!s)throw new Error(`Colormap ${e} not found`);const l=o.getProperty().getRGBTransferFunction(0).getRange();if(a.applyColorMap(s),a.setMappingRange(l[0],l[1]),o.getProperty().setRGBTransferFunction(0,a),this.viewportProperties.colormap=e,!n){const f=this.getColormap(r),u={viewportId:this.id,colormap:f,volumeId:r};it(this.element,et.VOI_MODIFIED,u),it(this.element,et.COLORMAP_MODIFIED,u)}}setOpacity(e,r){const n=this._getApplicableVolumeActor(r);if(!n)return;const{volumeActor:i}=n,o=Ed.newInstance();typeof e.opacity=="number"?NN(i,e.opacity):(e.opacity.forEach(({opacity:c,value:l})=>{o.addPoint(l,c)}),i.getProperty().setScalarOpacity(0,o)),this.viewportProperties.colormap||(this.viewportProperties.colormap={}),this.viewportProperties.colormap.opacity=e.opacity;const a=this.getColormap(r),s={viewportId:this.id,colormap:a,volumeId:r};it(this.element,et.COLORMAP_MODIFIED,s)}setInvert(e,r,n){const i=this._getApplicableVolumeActor(r);if(!i)return;const o=i.volumeId,a=this._getOrCreateColorTransferFunction(o);if(wp(a),this.viewportProperties.invert=e,!n){const s={...this.getVOIModifiedEventDetail(o),invertStateChanged:!0};it(this.element,et.VOI_MODIFIED,s)}}getVOIModifiedEventDetail(e){const r=this._getApplicableVolumeActor(e);if(!r)throw new Error(`No actor found for the given volumeId: ${e}`);const o=r.volumeActor.getProperty().getRGBTransferFunction(0).getMappingRange(),a=this.getColormap(e),{VOILUTFunction:s,invert:c}=this.getProperties(e);return{viewportId:this.id,range:{lower:o[0],upper:o[1]},volumeId:r.volumeId,VOILUTFunction:s,colormap:a,invert:c}}_getOrCreateColorTransferFunction(e){const r=this._getApplicableVolumeActor(e);if(!r)return null;const{volumeActor:n}=r,i=n.getProperty().getRGBTransferFunction(0);if(i)return i;const o=eu.newInstance();return n.getProperty().setRGBTransferFunction(0,o),o}setInterpolationType(e,r){const n=this._getApplicableVolumeActor(r);if(!n)return;const{volumeActor:i}=n;i.getProperty().setInterpolationType(e),this.viewportProperties.interpolationType=e}setVOI(e,r,n=!1){const i=this._getApplicableVolumeActor(r);if(!i)return;const{volumeActor:o}=i,a=i.volumeId,s=e;if(typeof s>"u")throw new Error("voiRangeToUse is undefined, need to implement this in the new volume model");const{VOILUTFunction:c}=this.getProperties(a);if(c===oo.SAMPLED_SIGMOID){const l=z4(s);o.getProperty().setRGBTransferFunction(0,l)}else{const{lower:l,upper:f}=s;o.getProperty().getRGBTransferFunction(0).setRange(l,f)}if(!n){const l={...this.getVOIModifiedEventDetail(a)};it(this.element,et.VOI_MODIFIED,l)}this.viewportProperties.voiRange=s}rotateCamera(e){const r=e-this.getRotation();this.getVtkActiveCamera().roll(-r)}setDefaultProperties(e,r){r==null?this.globalDefaultProperties=e:this.perVolumeIdDefaultProperties.set(r,e)}clearDefaultProperties(e){e==null?(this.globalDefaultProperties={},this.resetProperties()):(this.perVolumeIdDefaultProperties.delete(e),this.resetToDefaultProperties(e))}getViewReference(e={}){const r=super.getViewReference(e),n=this.getVolumeId(e);if((e==null?void 0:e.forFrameOfReference)!==!1&&(r.volumeId=n),typeof(e==null?void 0:e.sliceIndex)!="number")return r;const{viewPlaneNormal:i}=r,o=(e==null?void 0:e.sliceIndex)-this.getSliceIndex(),{sliceRangeInfo:a}=ud(this,n,!0),{sliceRange:s,spacingInNormalDirection:c,camera:l}=a,{focalPoint:f,position:u}=l,{newFocalPoint:d}=Y0(f,u,s,i,c,o);return r.cameraFocalPoint=d,r}isReferenceViewable(e,r){if(!e.FrameOfReferenceUID||!super.isReferenceViewable(e,r))return!1;if(r!=null&&r.withNavigation)return!0;const n=this.getSliceIndex(),{sliceIndex:i}=e;return Array.isArray(i)?i[0]<=n&&n<=i[1]:i===void 0||i===n}scroll(e=1){const r=this.getVolumeId(),{sliceRangeInfo:n}=ud(this,r,!0);if(!n)return;const{sliceRange:i,spacingInNormalDirection:o,camera:a}=n,{focalPoint:s,viewPlaneNormal:c,position:l}=a,{newFocalPoint:f,newPosition:u}=Y0(s,l,i,c,o,e);this.setCamera({focalPoint:f,position:u}),this.render()}setViewReference(e){if(!e)return;const r=this.getVolumeId(),{viewPlaneNormal:n,FrameOfReferenceUID:i,cameraFocalPoint:o,referencedImageId:a,viewUp:s}=e;let{sliceIndex:c}=e;const{focalPoint:l,viewPlaneNormal:f,position:u}=this.getCamera(),d=LN(f,n),h=Vt(f,n);if(typeof c=="number"&&r!==void 0&&e.volumeId===r&&(d||h)){const{currentStepIndex:g,sliceRangeInfo:p,numScrollSteps:v}=ud(this,r,!0),{sliceRange:y,spacingInNormalDirection:m}=p;d&&(c=v-c-1);const w=c-g,{newFocalPoint:x,newPosition:C}=Y0(l,u,y,f,m,w);this.setCamera({focalPoint:x,position:C})}else if(i===this.getFrameOfReferenceUID()){if(n&&!d&&!h){this.setOrientation({viewPlaneNormal:n,viewUp:s}),this.setViewReference(e);return}if(a&&this.isInAcquisitionPlane()){const g=ct(jo.IMAGE_PLANE,a),{imagePositionPatient:p}=g,{focalPoint:v}=this.getCamera(),y=Nn(Ke(),v,p),m=xt(y,f),w=dn(Ke(),v,[-f[0],-f[1],-f[2]],m);this.setCamera({focalPoint:w}),this.render();return}if(o){const g=Nn([0,0,0],o,l),p=n??f,v=xt(g,p);Vt(v,0)||gr(g,p,v);const y=Hr([0,0,0],l,g),m=Hr([0,0,0],u,g);this.setCamera({focalPoint:y,position:m})}}else throw new Error(`Incompatible view refs: ${i}!==${this.getFrameOfReferenceUID()}`)}setThreshold(e,r){const n=this._getApplicableVolumeActor(r);if(!n)return;const{volumeActor:i}=n;kN(i,e.threshold),this.viewportProperties.colormap||(this.viewportProperties.colormap={}),this.viewportProperties.colormap.threshold=e.threshold;const o=this.getColormap(r),a={viewportId:this.id,colormap:o,volumeId:r};it(this.element,et.COLORMAP_MODIFIED,a)}setProperties({voiRange:e,VOILUTFunction:r,invert:n,colormap:i,preset:o,interpolationType:a,slabThickness:s}={},c,l=!1){this.globalDefaultProperties==null&&this.setDefaultProperties({voiRange:e,VOILUTFunction:r,invert:n,colormap:i,preset:o,slabThickness:s}),n!==void 0&&this.viewportProperties.invert!==n&&this.setInvert(n,c,l),i!=null&&i.name&&this.setColormap(i,c,l),(i==null?void 0:i.opacity)!=null&&this.setOpacity(i,c),(i==null?void 0:i.threshold)!=null&&this.setThreshold(i,c),e!==void 0&&this.setVOI(e,c,l),typeof a<"u"&&this.setInterpolationType(a),r!==void 0&&this.setVOILUTFunction(r,c,l),o!==void 0&&this.setPreset(o,c,l),s!==void 0&&this.setSlabThickness(s)}resetToDefaultProperties(e){var n,i;const r=this.globalDefaultProperties;(n=r.colormap)!=null&&n.name&&this.setColormap(r.colormap,e),((i=r.colormap)==null?void 0:i.opacity)!=null&&this.setOpacity(r.colormap,e),r.voiRange!==void 0&&this.setVOI(r.voiRange,e),r.VOILUTFunction!==void 0&&this.setVOILUTFunction(r.VOILUTFunction,e),r.invert!==void 0&&this.setInvert(r.invert,e),r.slabThickness!==void 0&&(this.setSlabThickness(r.slabThickness),this.viewportProperties.slabThickness=r.slabThickness),r.preset!==void 0&&this.setPreset(r.preset,e,!1),r.preset!==void 0&&this.setPreset(r.preset,e,!1),this.render()}setPreset(e,r,n){const i=this._getApplicableVolumeActor(r);if(!i)return;const{volumeActor:o}=i;let a=e;typeof a=="string"&&(a=yP.find(s=>s.name===e)),a&&(Mk(o,a),this.viewportProperties.preset=a,this.render(),n||it(this.element,et.PRESET_MODIFIED,{viewportId:this.id,volumeId:i.volumeId,actor:o,presetName:a.name}))}async setVolumes(e,r=!1,n=!1){const i=$e.getVolume(e[0].volumeId);if(!i)throw new Error(`imageVolume with id: ${i.volumeId} does not exist, you need to create/allocate the volume first`);const o=i.metadata.FrameOfReferenceUID;this._isValidVolumeInputArray(e,o),this._FrameOfReferenceUID=o,e.forEach(s=>{this._addVolumeId(s.volumeId)});const a=[];for(let s=0;s<e.length;s++){const{volumeId:c,actorUID:l,slabThickness:f,...u}=e[s],d=await By(e[s],this.element,this.id,n),h=l||gn();a.push({uid:h,actor:d,slabThickness:f,referencedId:c,...u})}this._setVolumeActors(a),this.viewportStatus=_o.PRE_RENDER,this.initializeColorTransferFunction(e),it(this.element,et.VOLUME_VIEWPORT_NEW_VOLUME,{viewportId:this.id,volumeActors:a}),r&&this.render()}async addVolumes(e,r=!1,n=!1){const i=$e.getVolume(e[0].volumeId);if(!i)throw new Error(`imageVolume with id: ${i.volumeId} does not exist`);const o=[];this._isValidVolumeInputArray(e,this._FrameOfReferenceUID),e.forEach(a=>{this._addVolumeId(a.volumeId)});for(let a=0;a<e.length;a++){const{volumeId:s,visibility:c,actorUID:l,slabThickness:f,...u}=e[a],d=await By(e[a],this.element,this.id,n);c||d.setVisibility(!1);const h=l||gn();o.push({uid:h,actor:d,slabThickness:f,referencedId:s,...u})}this.addActors(o),this.initializeColorTransferFunction(e),r&&this.render()}removeVolumeActors(e,r=!1){this.removeActors(e),r&&this.render()}setOrientation(e,r=!0){console.warn('Method "setOrientation" needs implementation')}initializeColorTransferFunction(e){const r=e[0].volumeId,n=this._getOrCreateColorTransferFunction(r);!this.initialTransferFunctionNodes&&n&&(this.initialTransferFunctionNodes=ky(n))}_getApplicableVolumeActor(e){const r=this.getActors();if(!(r!=null&&r.length))return;if(e){const i=r.find(o=>o.referencedId===e);return i?{volumeActor:i.actor,volumeId:e,actorUID:i.uid}:void 0}const n=r[0];return{volumeActor:n.actor,volumeId:n.referencedId,actorUID:n.uid}}async _isValidVolumeInputArray(e,r){const n=e.length;for(let i=1;i<n;i++){const o=$e.getVolume(e[i].volumeId);if(r!==o.metadata.FrameOfReferenceUID)throw new Error(`Volumes being added to viewport ${this.id} do not share the same FrameOfReferenceUID. This is not yet supported`)}return!0}getBounds(){return this.getRenderer().computeVisiblePropBounds()}flip(e){super.flip(e)}hasVolumeId(e){return this.volumeIds.has(e)}hasVolumeURI(e){for(const r of this.volumeIds)if(r.includes(e))return!0;return!1}getImageData(e){var s,c,l;if(!this.getDefaultActor())return;e||(e=this.getVolumeId());const n=(s=this.getActors())==null?void 0:s.find(f=>f.referencedId===e);if(!ga(n,"vtkVolume"))return;const i=n.actor,o=$e.getVolume(e),a=i.getMapper().getInputData();return{dimensions:a.getDimensions(),spacing:a.getSpacing(),origin:a.getOrigin(),direction:a.getDirection(),imageData:i.getMapper().getInputData(),metadata:{Modality:(c=o==null?void 0:o.metadata)==null?void 0:c.Modality,FrameOfReferenceUID:(l=o==null?void 0:o.metadata)==null?void 0:l.FrameOfReferenceUID},get scalarData(){var f;return(f=o==null?void 0:o.voxelManager)==null?void 0:f.getScalarData()},scaling:o==null?void 0:o.scaling,hasPixelSpacing:!0,voxelManager:o==null?void 0:o.voxelManager}}setCameraClippingRange(){throw new Error("Method not implemented.")}getSliceIndex(){throw new Error("Method not implemented.")}setCamera(e,r){super.setCamera(e,r),this.setCameraClippingRange()}_setVolumeActors(e){for(let r=0;r<e.length;r++)this.viewportProperties.invert=!1;this.setActors(e)}_getOrientationVectors(e){if(typeof e=="object"){if(e.viewPlaneNormal&&e.viewUp)return e;throw new Error("Invalid orientation object. It must contain viewPlaneNormal and viewUp")}else if(typeof e=="string"){if(e==="acquisition")return this._getAcquisitionPlaneOrientation();if(Nu[e])return this.viewportProperties.orientation=e,Nu[e]}throw new Error(`Invalid orientation: ${e}. Valid orientations are: ${Object.keys(Nu).join(", ")}`)}_getAcquisitionPlaneOrientation(){if(!this.getDefaultActor())return;const r=this.getVolumeId(),n=$e.getVolume(r);if(!n)throw new Error(`imageVolume with id: ${r} does not exist in cache`);const{direction:i}=n,o=i.slice(6,9).map(s=>-s),a=i.slice(3,6).map(s=>-s);return{viewPlaneNormal:o,viewUp:a}}getSlabThickness(){const e=this.getActors();let r=Wr.MINIMUM_SLAB_THICKNESS;return e.forEach(n=>{n.slabThickness>r&&(r=n.slabThickness)}),r}getIntensityFromWorld(e){const r=this.getDefaultActor();if(!ga(r,"vtkVolume"))return;const{actor:n}=r,i=n.getMapper().getInputData(),o=$e.getVolume(this.getVolumeId()),a=Lr(i,e);return o.voxelManager.getAtIJKPoint(a)}getVolumeId(e){const r=this.getActors();if(!r)return;if(!(e!=null&&e.volumeId)){const i=r.find(o=>o.actor.getClassName()==="vtkVolume");return(i==null?void 0:i.referencedId)||(i==null?void 0:i.uid)}const n=r.find(i=>i.actor.getClassName()==="vtkVolume"&&i.referencedId===(e==null?void 0:e.volumeId));return(n==null?void 0:n.referencedId)||(n==null?void 0:n.uid)}getViewReferenceId(e={}){var c;let{volumeId:r,sliceIndex:n}=e;if(!r){const l=this.getActors();if(!l)return;r=(c=l.find(f=>f.actor.getClassName()==="vtkVolume"))==null?void 0:c.referencedId}const i=this.getSliceIndex();n??(n=i);const{viewPlaneNormal:o,focalPoint:a}=this.getCamera(),s=r.includes("?")?"&":"?";return`volumeId:${r}${s}sliceIndex=${n}&viewPlaneNormal=${o.join(",")}`}_addVolumeId(e){this.volumeIds.add(e)}getAllVolumeIds(){return Array.from(this.volumeIds)}}function Ru(t,e){const{imageData:r}=t.getImageData(),n=t.canvasToWorld(e);return Lr(r,n)}function Th(t,e){return t.indexToWorld(e)}function ace(t,e){const{imageData:r}=t.getImageData(),n=Th(r,e);return t.worldToCanvas(n)}class Zn extends fr{constructor(e){super(e),this._useAcquisitionPlaneForViewPlane=!1,this.getNumberOfSlices=()=>{const{numberOfSlices:n}=Gy(this)||{};return n},this.resetCameraForResize=()=>this.resetCamera({resetPan:!0,resetZoom:!0,resetToCenter:!0,resetRotation:!1,suppressEvents:!0}),this.getCurrentImageIdIndex=(n,i=!0)=>{const{currentStepIndex:o}=ud(this,n||this.getVolumeId(),i);return o},this.getSliceIndex=()=>{const{imageIndex:n}=Gy(this)||{};return n},this.getCurrentImageId=()=>{const n=this.getDefaultActor();if(!n||!ga(n,"vtkVolume"))return;const i=$e.getVolume(this.getVolumeId());if(!i)return;const{viewPlaneNormal:o,focalPoint:a}=this.getCamera();return Ql(i,a,o)},this.getSlicePlaneCoordinates=()=>{const n=this.getDefaultActor();if(!(n!=null&&n.actor))return console.warn("No image data found for calculating vtkPlanes."),[];const i=this.getVolumeId(),o=$e.getVolume(i),a=this.getCamera(),{focalPoint:s,position:c,viewPlaneNormal:l}=a,f=Cf(o,l),u=mw(n.actor,l,s),d=Math.round((u.current-u.min)/f),h=Math.round((u.max-u.current)/f),g=this.getSliceIndex(),p=[];for(let v=-d;v<=h;v++){const{newFocalPoint:y}=Y0(s,c,u,l,f,v);p.push({sliceIndex:g+v,point:y})}return p};const{orientation:r}=this.options;if(r&&r!==Cd.ACQUISITION){this.applyViewOrientation(r);return}this._useAcquisitionPlaneForViewPlane=!0}async setVolumes(e,r=!1,n=!1){const i=$e.getVolume(e[0].volumeId);if(!i)throw new Error(`imageVolume with id: ${i.volumeId} does not exist`);return this._useAcquisitionPlaneForViewPlane&&(this._setViewPlaneToAcquisitionPlane(i),this._useAcquisitionPlaneForViewPlane=!1),super.setVolumes(e,r,n)}async addVolumes(e,r=!1,n=!1){const i=$e.getVolume(e[0].volumeId);if(!i)throw new Error(`imageVolume with id: ${i.volumeId} does not exist`);return this._useAcquisitionPlaneForViewPlane&&(this._setViewPlaneToAcquisitionPlane(i),this._useAcquisitionPlaneForViewPlane=!1),super.addVolumes(e,r,n)}jumpToWorld(e){const{focalPoint:r}=this.getCamera(),n=[0,0,0];hn(n,e,r);const i=this.getCamera(),o=i.viewPlaneNormal,a=xt(n,o),s=Tt(o[0],o[1],o[2]);if(gr(s,s,a),Math.abs(s[0])>.001||Math.abs(s[1])>.001||Math.abs(s[2])>.001){const c=[0,0,0],l=[0,0,0];Hr(c,i.focalPoint,s),Hr(l,i.position,s),this.setCamera({focalPoint:c,position:l}),this.render()}return!0}setOrientation(e,r=!0){let n,i;if(typeof e=="string"){if(e===Cd.ACQUISITION)({viewPlaneNormal:n,viewUp:i}=super._getAcquisitionPlaneOrientation());else if(Nu[e])({viewPlaneNormal:n,viewUp:i}=Nu[e]);else throw new Error(`Invalid orientation: ${e}. Use Enums.OrientationAxis instead.`);this.setCamera({viewPlaneNormal:n,viewUp:i}),this.viewportProperties.orientation=e,this.resetCamera()}else({viewPlaneNormal:n,viewUp:i}=e),this.applyViewOrientation(e);r&&this.render()}setCameraClippingRange(){const e=this.getVtkActiveCamera();if(!e){console.warn("No active camera found");return}e.getParallelProjection()?e.setClippingRange(-Wr.MAXIMUM_RAY_DISTANCE,Wr.MAXIMUM_RAY_DISTANCE):e.setClippingRange(Wr.MINIMUM_SLAB_THICKNESS,Wr.MAXIMUM_RAY_DISTANCE)}_setViewPlaneToAcquisitionPlane(e){let r,n;if(e){const{direction:i}=e;r=i.slice(6,9).map(o=>-o),n=i.slice(3,6).map(o=>-o)}else({viewPlaneNormal:r,viewUp:n}=this._getAcquisitionPlaneOrientation());this.setCamera({viewPlaneNormal:r,viewUp:n}),this.initialViewUp=n,this.resetCamera()}getBlendMode(e){const r=this.getActors(),n=(e==null?void 0:e.length)>0?r.find(i=>e.includes(i.uid)):r[0];return(n==null?void 0:n.blendMode)||(n==null?void 0:n.actor.getMapper().getBlendMode())}setBlendMode(e,r=[],n=!1){let i=this.getActors();(r==null?void 0:r.length)>0&&(i=i.filter(o=>r.includes(o.uid))),i.forEach(o=>{var c;const{actor:a}=o,s=a.getMapper();(c=s.setBlendMode)==null||c.call(s,e),o.blendMode=e}),n&&this.render()}resetCamera(e){const{resetPan:r=!0,resetZoom:n=!0,resetRotation:i=!0,resetToCenter:o=!0,suppressEvents:a=!1,resetOrientation:s=!0}=e||{},{orientation:c}=this.viewportProperties;c&&s&&this.applyViewOrientation(c,!1),super.resetCamera({resetPan:r,resetZoom:n,resetToCenter:o});const l=this.getVtkActiveCamera(),f=l.getViewPlaneNormal(),u=l.getFocalPoint();if(this.getActors().forEach(h=>{if(!h.actor)return;const g=h.actor.getMapper();if(g.getClippingPlanes().length===0&&!(h!=null&&h.clippingFilter)){const v=Io.newInstance(),y=Io.newInstance(),m=[v,y];let w=Wr.MINIMUM_SLAB_THICKNESS;h.slabThickness&&(w=h.slabThickness),this.setOrientationOfClippingPlanes(m,w,f,u),g.addClippingPlane(v),g.addClippingPlane(y)}}),i&&Nu[this.viewportProperties.orientation]!==void 0){const h=Nu[this.viewportProperties.orientation];this.setCameraNoEvent({viewUp:h.viewUp,viewPlaneNormal:h.viewPlaneNormal})}if(!a){const h={viewportId:this.id,camera:this.getCamera(),renderingEngineId:this.renderingEngineId,element:this.element};it(this.element,et.CAMERA_RESET,h)}return!0}setSlabThickness(e,r=[]){e<.1&&(e=.1);let n=this.getActors();(r==null?void 0:r.length)>0&&(n=n.filter(o=>r.includes(o.uid))),n.forEach(o=>{ga(o,"vtkVolume")&&(o.slabThickness=e)});const i=this.getCamera();this.updateClippingPlanesForActors(i),this.triggerCameraModifiedEventIfNecessary(i,i),this.viewportProperties.slabThickness=e}resetSlabThickness(){this.getActors().forEach(n=>{ga(n,"vtkVolume")&&(n.slabThickness=Wr.MINIMUM_SLAB_THICKNESS)});const r=this.getCamera();this.updateClippingPlanesForActors(r),this.triggerCameraModifiedEventIfNecessary(r,r),this.viewportProperties.slabThickness=void 0}isInAcquisitionPlane(){const e=this.getImageData();if(!e)return!1;const{direction:r}=e,{viewPlaneNormal:n}=this.getCamera(),i=[r[6],r[7],r[8]];return Math.abs(xt(n,i))>.99}getSliceViewInfo(){const{width:e,height:r}=this.getCanvas(),n=Ru(this,[0,0]),i=Ru(this,[e-1,0]),o=Ru(this,[0,r-1]),a=hn(Ke(),i,n),s=hn(Ke(),o,n),c=Tn(Ke(),a,s);Un(a,a),Un(s,s),Un(c,c);const{dimensions:l}=this.getImageData(),[f,u,d]=l,p=[[0,0,0],[f-1,0,0],[0,u-1,0],[f-1,u-1,0],[0,0,d-1],[f-1,0,d-1],[0,u-1,d-1],[f-1,u-1,d-1]].map(b=>ace(this,b)).reduce((b,D)=>(b.minX=Math.min(b.minX,D[0]),b.minY=Math.min(b.minY,D[1]),b.maxX=Math.max(b.maxX,D[0]),b.maxY=Math.max(b.maxY,D[1]),b),{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}),v=Ru(this,[p.minX,p.minY]),y=Q_(a[0],a[1],a[2],0,s[0],s[1],s[2],0,c[0],c[1],c[2],0,v[0],v[1],v[2],1),m=Ru(this,[p.maxX,p.maxY]),w=hn(Ke(),m,v),x=Ar(ma(),y),{viewPlaneNormal:C}=this.getCamera();if(C.filter(b=>Math.abs(b)>Ga).length>1)throw new Error("getSliceInfo is not supported for oblique views");const T=C.findIndex(b=>Math.abs(b)>1-Ga);if(T===-1)throw new Error("Unable to determine slice axis");const _=xt(a,w)+1,E=xt(s,w)+1;return{sliceIndex:this.getSliceIndex(),width:_,height:E,slicePlane:T,sliceToIndexMatrix:y,indexToSliceMatrix:x}}getCurrentSlicePixelData(){const{voxelManager:e}=this.getImageData();return e.getSliceData(this.getSliceViewInfo())}getViewReference(e={}){const r=super.getViewReference(e);if(!(r!=null&&r.volumeId))return;const n=$e.getVolume(r.volumeId);return r.referencedImageId=Ql(n,r.cameraFocalPoint,r.viewPlaneNormal),r}resetProperties(e){this._resetProperties(e)}_resetProperties(e){const r=e?this.getActor(e):this.getDefaultActor();if(!r)throw new Error(`No actor found for the given volumeId: ${e}`);r.slabThickness&&(r.slabThickness=Wr.MINIMUM_SLAB_THICKNESS,this.viewportProperties.slabThickness=void 0,this.updateClippingPlanesForActors(this.getCamera())),e||(e=this.getVolumeId());const n=$e.getVolume(e);if(!n)throw new Error(`imageVolume with id: ${e} does not exist in cache`);if(Q4(r.actor,n),Qs(r)){const l=r.actor.getProperty().getRGBTransferFunction(0);vw(l,this.initialTransferFunctionNodes)}const i={...super.getVOIModifiedEventDetail(e)};this.resetCamera({resetPan:!0,resetZoom:!0,resetToCenter:!0,resetCameraRotation:!0}),it(this.element,et.VOI_MODIFIED,i)}getSlicesClippingPlanes(){const e=this.getSlicePlaneCoordinates(),{viewPlaneNormal:r}=this.getCamera(),n=Wr.MINIMUM_SLAB_THICKNESS;return e.map(({point:i,sliceIndex:o})=>{const a=[Io.newInstance(),Io.newInstance()];return this.setOrientationOfClippingPlanes(a,n,r,i),{sliceIndex:o,planes:a.map(s=>({normal:s.getNormal(),origin:s.getOrigin()}))}})}}function sce(t,e){e.classHierarchy.push("vtkAbstractImageMapper"),t.getIsOpaque=()=>!0,t.getCurrentImage=()=>null,t.getBoundsForSlice=()=>(Z.vtkErrorMacro("vtkAbstractImageMapper.getBoundsForSlice - NOT IMPLEMENTED"),of())}const cce={slice:0,customDisplayExtent:[0,0,0,0,0,0],useCustomExtents:!1,backgroundColor:[0,0,0,1]};function lce(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,cce,r),C4.extend(t,e,r),Z.setGet(t,e,["slice","useCustomExtents"]),Z.setGetArray(t,e,["customDisplayExtent"],6),Z.setGetArray(t,e,["backgroundColor"],4),sce(t,e)}var uce={extend:lce};function Pk(t,e,r){const n=r.getCurrentImage(),i=n.getExtent(),o=[i[0],i[2],i[4]],{ijkMode:a}=r.getClosestIJKAxis();let s=r.isA("vtkImageArrayMapper")?r.getSubSlice():r.getSlice();a!==r.getSlicingMode()&&(s=r.getSliceAtPosition(s)),o[a]+=s;const c=[0,0,0];n.indexToWorld(o,c),o[a]+=1;const l=[0,0,0];n.indexToWorld(o,l),l[0]-=c[0],l[1]-=c[1],l[2]-=c[2],Un(l,l);const f=Io.intersectWithLine(t,e,c,l);if(f.intersection){const u=f.x,d=[0,0,0];return n.worldToIndex(u,d),{t:f.t,absoluteIJK:d}}return null}function fce(t,e,r){const n=Pk(t,e,r);if(n){const o=r.getCurrentImage().getExtent(),a=[Math.round(n.absoluteIJK[0]),Math.round(n.absoluteIJK[1]),Math.round(n.absoluteIJK[2])];return a[0]<o[0]||a[0]>o[1]||a[1]<o[2]||a[1]>o[3]||a[2]<o[4]||a[2]>o[5]?null:{t:n.t,ijk:a}}return null}function dce(t,e,r){const n=Pk(t,e,r);if(n){const o=r.getCurrentImage().getExtent(),a=n.absoluteIJK,s=[Math.floor(a[0]),Math.floor(a[1]),Math.floor(a[2])];if(s[0]<o[0]||s[0]>o[1]-1||s[1]<o[2]||s[1]>o[3]-1||s[2]<o[4]||s[2]>(o[5]?o[5]-1:o[5]))return null;const c=[a[0]-s[0],a[1]-s[1],a[2]-s[2]];return{t:n.t,ijk:s,pCoords:c}}return null}const{staticOffsetAPI:hce,otherStaticMethods:gce}=lw,{SlicingMode:Ln}=fw;function pce(t,e){e.classHierarchy.push("vtkImageMapper"),t.getSliceAtPosition=n=>{const i=t.getCurrentImage();let o;if(n.length===3)o=n;else if(Number.isFinite(n)){const f=i.getBounds();switch(e.slicingMode){case Ln.X:o=[n,(f[3]+f[2])/2,(f[5]+f[4])/2];break;case Ln.Y:o=[(f[1]+f[0])/2,n,(f[5]+f[4])/2];break;case Ln.Z:o=[(f[1]+f[0])/2,(f[3]+f[2])/2,n];break}}const a=[0,0,0];i.worldToIndex(o,a);const s=i.getExtent(),{ijkMode:c}=t.getClosestIJKAxis();let l=0;switch(c){case Ln.I:l=rc(a[0],s[0],s[1]);break;case Ln.J:l=rc(a[1],s[2],s[3]);break;case Ln.K:l=rc(a[2],s[4],s[5]);break;default:return 0}return l},t.setSliceFromCamera=n=>{const i=n.getFocalPoint();switch(e.slicingMode){case Ln.I:case Ln.J:case Ln.K:{const o=t.getSliceAtPosition(i);t.setSlice(o)}break;case Ln.X:t.setSlice(i[0]);break;case Ln.Y:t.setSlice(i[1]);break;case Ln.Z:t.setSlice(i[2]);break}},t.setXSlice=n=>{t.setSlicingMode(Ln.X),t.setSlice(n)},t.setYSlice=n=>{t.setSlicingMode(Ln.Y),t.setSlice(n)},t.setZSlice=n=>{t.setSlicingMode(Ln.Z),t.setSlice(n)},t.setISlice=n=>{t.setSlicingMode(Ln.I),t.setSlice(n)},t.setJSlice=n=>{t.setSlicingMode(Ln.J),t.setSlice(n)},t.setKSlice=n=>{t.setSlicingMode(Ln.K),t.setSlice(n)},t.getSlicingModeNormal=()=>{const n=[0,0,0],i=t.getCurrentImage().getDirection();switch(e.slicingMode){case Ln.X:n[0]=1;break;case Ln.Y:n[1]=1;break;case Ln.Z:n[2]=1;break;case Ln.I:yv(i,[1,0,0],n);break;case Ln.J:yv(i,[0,1,0],n);break;case Ln.K:yv(i,[0,0,1],n);break}return n};function r(){let n;switch(e.slicingMode){case Ln.X:n=0;break;case Ln.Y:n=1;break;case Ln.Z:n=2;break;default:e.closestIJKAxis={ijkMode:e.slicingMode,flip:!1};return}const i=t.getCurrentImage().getDirection(),o=TR(i);let a=0;for(;a<3&&o[n+3*a]===0;++a);const s=o[n+3*a]<0;e.closestIJKAxis={ijkMode:a,flip:s}}t.setSlicingMode=n=>{e.slicingMode!==n&&(e.slicingMode=n,t.getCurrentImage()&&r(),t.modified())},t.getClosestIJKAxis=()=>((e.closestIJKAxis===void 0||e.closestIJKAxis.ijkMode===Ln.NONE)&&t.getCurrentImage()&&r(),e.closestIJKAxis),t.getBounds=()=>{const n=t.getCurrentImage();if(!n)return of();if(!e.useCustomExtents)return n.getBounds();const i=e.customDisplayExtent.slice(),{ijkMode:o}=t.getClosestIJKAxis();let a=e.slice;switch(o!==e.slicingMode&&(a=t.getSliceAtPosition(e.slice)),o){case Ln.I:i[0]=a,i[1]=a;break;case Ln.J:i[2]=a,i[3]=a;break;case Ln.K:i[4]=a,i[5]=a;break}return n.extentToBounds(i)},t.getBoundsForSlice=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:e.slice,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;const o=t.getCurrentImage();if(!o)return of();const a=o.getSpatialExtent(),{ijkMode:s}=t.getClosestIJKAxis();let c=n;switch(s!==e.slicingMode&&(c=t.getSliceAtPosition(n)),s){case Ln.I:a[0]=c-i,a[1]=c+i;break;case Ln.J:a[2]=c-i,a[3]=c+i;break;case Ln.K:a[4]=c-i,a[5]=c+i;break}return o.extentToBounds(a)},t.intersectWithLineForPointPicking=(n,i)=>fce(n,i,t),t.intersectWithLineForCellPicking=(n,i)=>dce(n,i,t),t.getCurrentImage=()=>t.getInputData()}const mce={slicingMode:Ln.NONE,closestIJKAxis:{ijkMode:Ln.NONE,flip:!1},renderToRectangle:!1,sliceAtFocalPoint:!1,preferSizeOverAccuracy:!1};function Rk(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,mce,r),uce.extend(t,e,r),Z.get(t,e,["slicingMode"]),Z.setGet(t,e,["closestIJKAxis","renderToRectangle","sliceAtFocalPoint","preferSizeOverAccuracy"]),lw.implementCoincidentTopologyMethods(t,e),pce(t,e)}const vce=Z.newInstance(Rk,"vtkImageMapper");var yce={newInstance:vce,extend:Rk,...hce,...gce,...fw};const{InterpolationType:Rv}=Mee,{vtkErrorMacro:e9}=Z,Lv=4;function wce(t,e){e.classHierarchy.push("vtkImageProperty"),t.getMTime=()=>{let r=e.mtime,n;for(let i=0;i<Lv;i++)e.componentData[i].rGBTransferFunction&&(n=e.componentData[i].rGBTransferFunction.getMTime(),r=r>n?r:n),e.componentData[i].piecewiseFunction&&(n=e.componentData[i].piecewiseFunction.getMTime(),r=r>n?r:n);return r},t.setRGBTransferFunction=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,i=r,o=n;return Number.isInteger(r)||(o=r,i=0),e.componentData[i].rGBTransferFunction!==o?(e.componentData[i].rGBTransferFunction=o,t.modified(),!0):!1},t.getRGBTransferFunction=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return e.componentData[r].rGBTransferFunction},t.setPiecewiseFunction=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,i=r,o=n;return Number.isInteger(r)||(o=r,i=0),e.componentData[i].piecewiseFunction!==o?(e.componentData[i].piecewiseFunction=o,t.modified(),!0):!1},t.getPiecewiseFunction=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return e.componentData[r].piecewiseFunction},t.setScalarOpacity=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,i=r,o=n;return Number.isInteger(r)||(o=r,i=0),t.setPiecewiseFunction(i,o)},t.getScalarOpacity=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return t.getPiecewiseFunction(r)},t.setComponentWeight=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1;if(r<0||r>=Lv)return e9("Invalid index"),!1;const i=Math.min(1,Math.max(0,n));return e.componentData[r].componentWeight!==i?(e.componentData[r].componentWeight=i,t.modified(),!0):!1},t.getComponentWeight=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return r<0||r>=Lv?(e9("Invalid index"),0):e.componentData[r].componentWeight},t.setInterpolationTypeToNearest=()=>t.setInterpolationType(Rv.NEAREST),t.setInterpolationTypeToLinear=()=>t.setInterpolationType(Rv.LINEAR),t.getInterpolationTypeAsString=()=>Z.enumToString(Rv,e.interpolationType)}const xce={independentComponents:!1,interpolationType:Rv.LINEAR,colorWindow:255,colorLevel:127.5,ambient:1,diffuse:0,opacity:1,useLookupTableScalarRange:!1,useLabelOutline:!1,labelOutlineThickness:[1],labelOutlineOpacity:1};function Cce(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(Object.assign(e,xce,r),Z.obj(t,e),!e.componentData){e.componentData=[];for(let n=0;n<Lv;n++)e.componentData.push({rGBTransferFunction:null,piecewiseFunction:null,componentWeight:1})}Z.setGet(t,e,["independentComponents","interpolationType","colorWindow","colorLevel","ambient","diffuse","opacity","useLookupTableScalarRange","useLabelOutline","labelOutlineOpacity"]),Z.setGetArray(t,e,["labelOutlineThickness"]),wce(t,e)}const Sce=Z.newInstance(Cce,"vtkImageProperty");var Tce={newInstance:Sce};const{vtkDebugMacro:_ce}=Z;function Ece(t,e){e.classHierarchy.push("vtkImageSlice"),t.getActors=()=>t,t.getImages=()=>t,t.getIsOpaque=()=>{if(e.forceOpaque)return!0;if(e.forceTranslucent)return!1;e.property||t.getProperty();let r=e.property.getOpacity()>=1;return r=r&&(!e.mapper||e.mapper.getIsOpaque()),r},t.hasTranslucentPolygonalGeometry=()=>!1,t.makeProperty=Tce.newInstance,t.getProperty=()=>(e.property===null&&(e.property=t.makeProperty()),e.property),t.getBounds=()=>{if(e.mapper===null)return e.bounds;const r=e.mapper.getBounds();if(!r||r.length!==6)return r;if(r[0]>r[1])return e.mapperBounds=r.concat(),e.bounds=[1,-1,1,-1,1,-1],e.boundsMTime.modified(),r;const n=i=>i[0].map((o,a)=>i.map(s=>s[a]));if(!e.mapperBounds||!n([r,e.mapperBounds]).reduce((i,o)=>i&&o[0]===o[1],!0)||t.getMTime()>e.boundsMTime.getMTime()){_ce("Recomputing bounds..."),e.mapperBounds=r.map(o=>o),t.computeMatrix();const i=new Float64Array(16);un(i,e.matrix),Hn.transformBounds(r,i,e.bounds),e.boundsMTime.modified()}return e.bounds},t.getBoundsForSlice=(r,n)=>{const i=e.mapper.getBoundsForSlice(r,n);if(!Hn.isValid(i))return i;t.computeMatrix();const o=new Float64Array(16);return un(o,e.matrix),Hn.transformBounds(i,o)},t.getMinXBound=()=>t.getBounds()[0],t.getMaxXBound=()=>t.getBounds()[1],t.getMinYBound=()=>t.getBounds()[2],t.getMaxYBound=()=>t.getBounds()[3],t.getMinZBound=()=>t.getBounds()[4],t.getMaxZBound=()=>t.getBounds()[5],t.getMTime=()=>{let r=e.mtime;if(e.property!==null){const n=e.property.getMTime();r=n>r?n:r}return r},t.getRedrawMTime=()=>{let r=e.mtime;if(e.mapper!==null){let n=e.mapper.getMTime();r=n>r?n:r,e.mapper.getInput()!==null&&(e.mapper.getInputAlgorithm().update(),n=e.mapper.getInput().getMTime(),r=n>r?n:r)}if(e.property!==null){let n=e.property.getMTime();r=n>r?n:r,e.property.getRGBTransferFunction()!==null&&(n=e.property.getRGBTransferFunction().getMTime(),r=n>r?n:r)}return r},t.getSupportsSelection=()=>e.mapper?e.mapper.getSupportsSelection():!1}const bce={mapper:null,property:null,forceOpaque:!1,forceTranslucent:!1,bounds:[...Hn.INIT_BOUNDS]};function Lk(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,bce,r),L4.extend(t,e,r),e.boundsMTime={},Z.obj(e.boundsMTime),Z.set(t,e,["property"]),Z.setGet(t,e,["mapper","forceOpaque","forceTranslucent"]),Z.getArray(t,e,["bounds"],6),Ece(t,e)}const Dce=Z.newInstance(Lk,"vtkImageSlice");var Ice={newInstance:Dce,extend:Lk};function Oce(t){return Object.values(oo).includes(t)?t:oo.LINEAR}function Ak(t){const r={...ct(jo.IMAGE_PLANE,t)};return r.columnPixelSpacing||(r.columnPixelSpacing=1),r.rowPixelSpacing||(r.rowPixelSpacing=1),r.columnCosines||(r.columnCosines=[0,1,0]),r.rowCosines||(r.rowCosines=[1,0,0]),r.imagePositionPatient||(r.imagePositionPatient=[0,0,0]),r.imageOrientationPatient||(r.imageOrientationPatient=new Float32Array([1,0,0,0,1,0])),r}function Nk(t){const e=t.imageId,{pixelRepresentation:r,bitsAllocated:n,bitsStored:i,highBit:o,photometricInterpretation:a,samplesPerPixel:s}=ct("imagePixelModule",e),{windowWidth:c,windowCenter:l,voiLUTFunction:f}=t,{modality:u}=ct("generalSeriesModule",e),d=ct("scalingModule",e),h=ct(jo.CALIBRATION,e),g=Oce(f),p=Ak(e);return{calibration:h,scalingFactor:d,voiLUTFunction:g,modality:u,imagePlaneModule:p,imagePixelModule:{bitsAllocated:n,bitsStored:i,samplesPerPixel:s,highBit:o,photometricInterpretation:a,pixelRepresentation:r,windowWidth:c,windowCenter:l,modality:u,voiLUTFunction:g}}}function yw(t){const{imagePlaneModule:e,imagePixelModule:r,voiLUTFunction:n,modality:i,scalingFactor:o,calibration:a}=Nk(t);let{rowCosines:s,columnCosines:c}=e;(s==null||c==null)&&(s=[1,0,0],c=[0,1,0]);const l=Tt(s[0],s[1],s[2]),f=Tt(c[0],c[1],c[2]),u=Ke();Tn(u,l,f);let d=e.imagePositionPatient;d==null&&(d=[0,0,0]);const h=e.columnPixelSpacing||t.columnPixelSpacing,g=e.rowPixelSpacing||t.rowPixelSpacing,p=t.columns,v=t.rows,y=Ga,m=1;return!r.photometricInterpretation&&t.sizeInBytes===3*t.width*t.height&&(t.numberOfComponents=3),{numberOfComponents:t.numberOfComponents||Mce(r.photometricInterpretation),origin:d,direction:[...l,...f,...u],dimensions:[p,v,m],spacing:[h,g,y],numVoxels:p*v*m,imagePlaneModule:e,imagePixelModule:r,bitsAllocated:r.bitsAllocated,voiLUTFunction:n,modality:i,scalingFactor:o,calibration:a,scanAxisNormal:u}}function Mce(t){let e=1;return(t==="RGB"||t!=null&&t.includes("YBR")||t==="PALETTE COLOR")&&(e=3),e}function kk(t){const e=eu.newInstance();let r=0,n=1024;return t.lower!==void 0&&t.upper!==void 0&&(r=t.lower,n=t.upper),e.addRGBPoint(r,0,0,0),e.addRGBPoint(n,1,1,1),e}function ww(t,e){const r=e.voxelManager.getScalarData();if(!t.getPointData)return;const n=t.getPointData().getScalars().getData();if(e.color&&e.rgba){const i=new Uint8Array(e.columns*e.rows*3);for(let o=0;o<e.columns*e.rows;o++)i[o*3]=r[o*4],i[o*3+1]=r[o*4+1],i[o*3+2]=r[o*4+2];e.rgba=!1,e.getPixelData=()=>i,n.set(i)}else n.set(r);t.modified()}function fn(){return window.performance?performance.now():Date.now()}function Pce(t,e){return function(r){const n=((r-(e-.5))/(t-1)+.5)*255;return Math.min(Math.max(n,0),255)}}function Rce(t){const r=Math.max(...t.lut).toString(2).length-8,n=t.lut[0]>>r,i=t.lut[t.lut.length-1]>>r,o=t.firstValueMapped+t.lut.length-1;return function(a){return a<t.firstValueMapped?n:a>=o?i:t.lut[a-t.firstValueMapped]>>r}}function Vk(t,e,r){return r?Rce(r):Pce(t,e)}function Lce(t,e,r,n,i){const o=t.maxPixelValue,a=t.minPixelValue,s=Math.min(a,0);if(t.cachedLut===void 0){const f=o-s+1;t.cachedLut={},t.cachedLut.lutArray=new Uint8ClampedArray(f)}const c=t.cachedLut.lutArray,l=Vk(Array.isArray(e)?e[0]:e,Array.isArray(r)?r[0]:r,i);if(n)for(let f=a;f<=o;f++)c[f+-s]=255-l(f);else for(let f=a;f<=o;f++)c[f+-s]=l(f);return c}function Ace(t,e,r){let n=fn();const i=t.voxelManager.getScalarData();t.stats.lastGetPixelDataTime=fn()-n;const o=t.minPixelValue;let a=0,s=0;const c=i.length;if(n=fn(),o<0)for(;s<c;)r[a++]=e[i[s++]+-o],r[a++]=e[i[s++]+-o],r[a++]=e[i[s++]+-o],r[a++]=255;else for(;s<c;)r[a++]=e[i[s++]],r[a++]=e[i[s++]],r[a++]=e[i[s++]],r[a++]=255;t.stats.lastStoredPixelDataToCanvasImageDataTime=fn()-n}function Nce(t,e,r){let n=fn();const i=t.getPixelData();t.stats.lastGetPixelDataTime=fn()-n;const o=t.minPixelValue;let a=0,s=0;const c=i.length;if(n=fn(),o<0)for(;s<c;)r[a++]=e[i[s++]+-o],r[a++]=e[i[s++]+-o],r[a++]=e[i[s++]+-o],r[a++]=i[s++];else for(;s<c;)r[a++]=e[i[s++]],r[a++]=e[i[s++]],r[a++]=e[i[s++]],r[a++]=i[s++];t.stats.lastStoredPixelDataToCanvasImageDataTime=fn()-n}class Kh{constructor(){this.reset()}getMatrix(){return this.m}reset(){this.m=[1,0,0,1,0,0]}clone(){const e=new Kh;return e.m[0]=this.m[0],e.m[1]=this.m[1],e.m[2]=this.m[2],e.m[3]=this.m[3],e.m[4]=this.m[4],e.m[5]=this.m[5],e}multiply(e){const r=this.m[0]*e[0]+this.m[2]*e[1],n=this.m[1]*e[0]+this.m[3]*e[1],i=this.m[0]*e[2]+this.m[2]*e[3],o=this.m[1]*e[2]+this.m[3]*e[3],a=this.m[0]*e[4]+this.m[2]*e[5]+this.m[4],s=this.m[1]*e[4]+this.m[3]*e[5]+this.m[5];this.m[0]=r,this.m[1]=n,this.m[2]=i,this.m[3]=o,this.m[4]=a,this.m[5]=s}invert(){const e=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),r=this.m[3]*e,n=-this.m[1]*e,i=-this.m[2]*e,o=this.m[0]*e,a=e*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),s=e*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);this.m[0]=r,this.m[1]=n,this.m[2]=i,this.m[3]=o,this.m[4]=a,this.m[5]=s}rotate(e){const r=Math.cos(e),n=Math.sin(e),i=this.m[0]*r+this.m[2]*n,o=this.m[1]*r+this.m[3]*n,a=this.m[0]*-n+this.m[2]*r,s=this.m[1]*-n+this.m[3]*r;this.m[0]=i,this.m[1]=o,this.m[2]=a,this.m[3]=s}translate(e,r){this.m[4]+=this.m[0]*e+this.m[2]*r,this.m[5]+=this.m[1]*e+this.m[3]*r}scale(e,r){this.m[0]*=e,this.m[1]*=e,this.m[2]*=r,this.m[3]*=r}transformPoint(e){const r=e[0],n=e[1];return[r*this.m[0]+n*this.m[2]+this.m[4],r*this.m[1]+n*this.m[3]+this.m[5]]}}function v1(t,e){const r=new Kh;if(!t.viewport.displayedArea)return r;r.translate(t.canvas.width/2,t.canvas.height/2);const n=t.viewport.rotation;n!==0&&r.rotate(n*Math.PI/180);let i=t.viewport.scale,o=t.viewport.scale;const a=t.viewport.displayedArea.brhc.x-(t.viewport.displayedArea.tlhc.x-1),s=t.viewport.displayedArea.brhc.y-(t.viewport.displayedArea.tlhc.y-1);if(t.viewport.displayedArea.presentationSizeMode==="NONE")t.image.rowPixelSpacing<t.image.columnPixelSpacing?i*=t.image.columnPixelSpacing/t.image.rowPixelSpacing:t.image.columnPixelSpacing<t.image.rowPixelSpacing&&(o*=t.image.rowPixelSpacing/t.image.columnPixelSpacing);else if(i=t.viewport.displayedArea.columnPixelSpacing,o=t.viewport.displayedArea.rowPixelSpacing,t.viewport.displayedArea.presentationSizeMode==="SCALE TO FIT"){const c=t.canvas.height/(s*o),l=t.canvas.width/(a*i);i=o=Math.min(l,c),t.viewport.displayedArea.rowPixelSpacing<t.viewport.displayedArea.columnPixelSpacing?i*=t.viewport.displayedArea.columnPixelSpacing/t.viewport.displayedArea.rowPixelSpacing:t.viewport.displayedArea.columnPixelSpacing<t.viewport.displayedArea.rowPixelSpacing&&(o*=t.viewport.displayedArea.rowPixelSpacing/t.viewport.displayedArea.columnPixelSpacing)}return r.scale(i,o),n!==0&&r.rotate(-n*Math.PI/180),r.translate(t.viewport.translation.x,t.viewport.translation.y),n!==0&&r.rotate(n*Math.PI/180),t.viewport.hflip&&r.scale(-1,1),t.viewport.vflip&&r.scale(1,-1),r.translate(-a/2,-s/2),r}function eE(t,e,r){if(t===void 0)throw new Error("setToPixelCoordinateSystem: parameter enabledElement must not be undefined");if(e===void 0)throw new Error("setToPixelCoordinateSystem: parameter context must not be undefined");const i=v1(t).getMatrix();e.setTransform(i[0],i[1],i[2],i[3],i[4],i[5])}function tE(t,e){const r=t.renderingTools.lastRenderedImageId,n=t.renderingTools.lastRenderedViewport;return e.imageId!==r||!n||n.windowCenter!==t.viewport.voi.windowCenter||n.windowWidth!==t.viewport.voi.windowWidth||n.invert!==t.viewport.invert||n.rotation!==t.viewport.rotation||n.hflip!==t.viewport.hflip||n.vflip!==t.viewport.vflip||n.modalityLUT!==t.viewport.modalityLUT||n.voiLUT!==t.viewport.voiLUT||n.colormap!==t.viewport.colormap}function Wy(t,e){const r=t.renderingTools.renderCanvas;r.width=e.width,r.height=e.height;const n=r.getContext("2d");n.fillStyle="white",n.fillRect(0,0,r.width,r.height);const i=n.getImageData(0,0,e.width,e.height);t.renderingTools.renderCanvasContext=n,t.renderingTools.renderCanvasData=i}function nE(t){const e=t.image.imageId,r=t.viewport,n=t.image.color;return t.renderingTools.lastRenderedImageId=e,t.renderingTools.lastRenderedIsColor=n,t.renderingTools.lastRenderedViewport={windowCenter:r.voi.windowCenter,windowWidth:r.voi.windowWidth,invert:r.invert,rotation:r.rotation,hflip:r.hflip,vflip:r.vflip,modalityLUT:r.modalityLUT,voiLUT:r.voiLUT,colormap:r.colormap},t.renderingTools}const Fk="viewport-element",Uk="cornerstone-canvas",Q0=1e-4;let DS;function dm(t,e=512,r=512){const n=DS?DS(e,r):document.createElement("canvas");return t&&(n.style.position="absolute",n.style.width="100%",n.style.height="100%",n.style.imageRendering="pixelated",n.classList.add(Uk),t.appendChild(n)),n}function Bk(t){const e=document.createElement("div");return e.style.position="relative",e.style.width="100%",e.style.height="100%",e.style.overflow="hidden",e.classList.add(Fk),t.appendChild(e),e}function kce(t){DS=t}function Bc(t){const e=`canvas.${Uk}`,r=`div.${Fk}`,n=t.querySelector(r)||Bk(t),i=n.querySelector(e);if(i)return i;const o=dm(n),a=n.getBoundingClientRect(),s=window.devicePixelRatio||1,c=Math.ceil(a.width*s),l=Math.ceil(a.height*s);return o.width=c,o.height=l,o}function Vce(t,e){return t.cachedLut!==void 0&&t.cachedLut.windowCenter===e.voi.windowCenter&&t.cachedLut.windowWidth===e.voi.windowWidth&&t.cachedLut.invert===e.invert||(Lce(t,e.voi.windowWidth,e.voi.windowCenter,e.invert),t.cachedLut.windowWidth=e.voi.windowWidth,t.cachedLut.windowCenter=e.voi.windowCenter,t.cachedLut.invert=e.invert),t.cachedLut.lutArray}function Fce(t,e,r){const n=t.renderingTools.lastRenderedIsColor;(!t.renderingTools.renderCanvas||!n)&&(t.renderingTools.renderCanvas=dm(null,e.width,e.height));const i=t.renderingTools.renderCanvas,{windowWidth:o,windowCenter:a}=t.viewport.voi;if((o===256||o===255)&&(a===128||a===127)&&!t.viewport.invert&&e.getCanvas&&e.getCanvas())return e.getCanvas();if(!tE(t,e)&&!r)return i;(!t.renderingTools.renderCanvasContext||i.width!==e.width||i.height!==e.height)&&Wy(t,e);let s=fn();const c=Vce(e,t.viewport);e.stats=e.stats||{},e.stats.lastLutGenerateTime=fn()-s;const l=t.renderingTools.renderCanvasData,f=t.renderingTools.renderCanvasContext;return e.rgba?Nce(e,c,l.data):Ace(e,c,l.data),s=fn(),f.putImageData(l,0,0),e.stats.lastPutImageDataTime=fn()-s,i}function Uce(t,e){if(t===void 0)throw new Error("renderColorImage: enabledElement parameter must not be undefined");const r=t.image;if(r===void 0)throw new Error("renderColorImage: image must be loaded before it can be drawn");const n=t.canvas.getContext("2d");n.setTransform(1,0,0,1,0,0),n.fillStyle="black",n.fillRect(0,0,t.canvas.width,t.canvas.height),n.imageSmoothingEnabled=!t.viewport.pixelReplication,eE(t,n);const i=Fce(t,r,e),o=t.viewport.displayedArea.tlhc.x-1,a=t.viewport.displayedArea.tlhc.y-1,s=t.viewport.displayedArea.brhc.x-o,c=t.viewport.displayedArea.brhc.y-a;n.drawImage(i,o,a,s,c,0,0,s,c),t.renderingTools=nE(t)}function Bce(t,e,r){let n=fn();const i=t.voxelManager.getScalarData();t.stats.lastGetPixelDataTime=fn()-n;const o=i.length,a=t.minPixelValue;let s=3,c=0;if(n=fn(),i instanceof Int16Array)if(a<0)for(;c<o;)r[s]=e[i[c++]+-a],s+=4;else for(;c<o;)r[s]=e[i[c++]],s+=4;else if(i instanceof Uint16Array)for(;c<o;)r[s]=e[i[c++]],s+=4;else if(a<0)for(;c<o;)r[s]=e[i[c++]+-a],s+=4;else for(;c<o;)r[s]=e[i[c++]],s+=4;t.stats.lastStoredPixelDataToCanvasImageDataTime=fn()-n}function Gce(t,e,r){let n=fn();const i=t.voxelManager.getScalarData();t.stats.lastGetPixelDataTime=fn()-n;const o=i.length;let a=3,s=0;for(n=fn();s<o;)r[a]=e(i[s++]),a+=4;t.stats.lastStoredPixelDataToCanvasImageDataTime=fn()-n}function Wce(t,e,r){let n=fn();const i=t.voxelManager.getScalarData();t.stats.lastGetPixelDataTime=fn()-n;const o=i.length,a=t.minPixelValue;let s=0,c=0,l;if(n=fn(),i instanceof Int16Array)if(a<0)for(;c<o;)l=e[i[c++]+-a],r[s++]=l,r[s++]=l,r[s++]=l,r[s++]=255;else for(;c<o;)l=e[i[c++]],r[s++]=l,r[s++]=l,r[s++]=l,r[s++]=255;else if(i instanceof Uint16Array)for(;c<o;)l=e[i[c++]],r[s++]=l,r[s++]=l,r[s++]=l,r[s++]=255;else if(a<0)for(;c<o;)l=e[i[c++]+-a],r[s++]=l,r[s++]=l,r[s++]=l,r[s++]=255;else for(;c<o;)l=e[i[c++]],r[s++]=l,r[s++]=l,r[s++]=l,r[s++]=255;t.stats.lastStoredPixelDataToCanvasImageDataTime=fn()-n}function zce(t,e){if($ce(t))return;const r=e.maxPixelValue*e.slope+e.intercept,n=e.minPixelValue*e.slope+e.intercept,i=r-n,o=(r+n)/2;t.voi===void 0?t.voi={windowWidth:i,windowCenter:o,voiLUTFunction:e.voiLUTFunction}:(t.voi.windowWidth=i,t.voi.windowCenter=o)}function $ce(t){return t.voiLUT&&t.voiLUT.lut&&t.voiLUT.lut.length>0||t.voi.windowWidth!==void 0&&t.voi.windowCenter!==void 0}function t9(t,e){return!t&&!e?!0:!t||!e?!1:t.id===e.id}function jce(t,e){return r=>r*t+e}function Hce(t){const e=t.lut[0],r=t.lut[t.lut.length-1],n=t.firstValueMapped+t.lut.length;return i=>i<t.firstValueMapped?e:i>=n?r:t.lut[i]}function Kce(t,e,r){return r?Hce(r):jce(t,e)}function qce(t,e,r,n,i,o){const a=t.maxPixelValue,s=t.minPixelValue,c=Math.min(s,0);if(t.cachedLut===void 0){const d=a-c+1;t.cachedLut={},t.cachedLut.lutArray=new Uint8ClampedArray(d)}const l=t.cachedLut.lutArray,f=Kce(t.slope,t.intercept,i),u=Vk(e,r,o);if(t.isPreScaled)if(n)for(let d=s;d<=a;d++)l[d+-c]=255-u(d);else for(let d=s;d<=a;d++)l[d+-c]=u(d);else if(n)for(let d=s;d<=a;d++)l[d+-c]=255-u(f(d));else for(let d=s;d<=a;d++)l[d+-c]=u(f(d));return l}function Gk(t,e,r){return t.cachedLut!==void 0&&t.cachedLut.windowCenter===e.voi.windowCenter&&t.cachedLut.windowWidth===e.voi.windowWidth&&t9(t.cachedLut.modalityLUT,e.modalityLUT)&&t9(t.cachedLut.voiLUT,e.voiLUT)&&t.cachedLut.invert===e.invert&&!r||(zce(e,t),qce(t,e.voi.windowWidth,e.voi.windowCenter,e.invert,e.modalityLUT,e.voiLUT),t.cachedLut.windowWidth=e.voi.windowWidth,t.cachedLut.windowCenter=e.voi.windowCenter,t.cachedLut.invert=e.invert,t.cachedLut.voiLUT=e.voiLUT,t.cachedLut.modalityLUT=e.modalityLUT),t.cachedLut.lutArray}function Xce(t,e,r,n=!0){const i=t.renderingTools.lastRenderedIsColor;(!t.renderingTools.renderCanvas||i)&&(t.renderingTools.renderCanvas=dm(null,e.width,e.height),Wy(t,e));const o=t.renderingTools.renderCanvas;if(!tE(t,e)&&!r)return o;(o.width!==e.width||o.height!==e.height)&&Wy(t,e),e.stats=e.stats||{};const a=t.renderingTools.renderCanvasData,s=t.renderingTools.renderCanvasContext;let c=fn();e.stats.lastLutGenerateTime=fn()-c;const{viewport:l}=t;if(l.modality==="PT"&&e.isPreScaled){const{windowWidth:f,windowCenter:u}=l.voi,d=u-f/2,p=255/(u+f/2-d);let v;l.invert?v=y=>255-(y-d)*p:v=y=>(y-d)*p,Gce(e,v,a.data)}else{const f=Gk(e,l,r);n?Bce(e,f,a.data):Wce(e,f,a.data)}return c=fn(),s.putImageData(a,0,0),e.stats.lastPutImageDataTime=fn()-c,o}function Yce(t,e){if(t===void 0)throw new Error("drawImage: enabledElement parameter must not be undefined");const r=t.image;if(r===void 0)throw new Error("drawImage: image must be loaded before it can be drawn");const n=t.canvas.getContext("2d");n.setTransform(1,0,0,1,0,0),n.fillStyle="black",n.fillRect(0,0,t.canvas.width,t.canvas.height),n.imageSmoothingEnabled=!t.viewport.pixelReplication,eE(t,n);const i=Xce(t,r,e),o=t.viewport.displayedArea.tlhc.x-1,a=t.viewport.displayedArea.tlhc.y-1,s=t.viewport.displayedArea.brhc.x-o,c=t.viewport.displayedArea.brhc.y-a;n.drawImage(i,o,a,s,c,0,0,s,c),t.renderingTools=nE(t)}const IS=0,OS=1,Jce=2;function Zce(t,e,r){if(t>1)throw new Error("HSVToRGB expects hue < 1");const n=[];if(e===0)return n[0]=r,n[1]=r,n[2]=r,n;const i=Math.floor(t*6),o=6*t-i,a=r*(1-e),s=r*(1-e*o),c=r*(1-e*(1-o));switch(i){case 0:case 6:n[0]=r,n[1]=c,n[2]=a;break;case 1:n[0]=s,n[1]=r,n[2]=a;break;case 2:n[0]=a,n[1]=r,n[2]=c;break;case 3:n[0]=a,n[1]=s,n[2]=r;break;case 4:n[0]=c,n[1]=a,n[2]=r;break;case 5:n[0]=r,n[1]=a,n[2]=s;break}return n}function Qce(t,e){let r;return t<e.Range[0]?r=e.MaxIndex+IS+1.5:t>e.Range[1]?r=e.MaxIndex+OS+1.5:r=(t+e.Shift)*e.Scale,Math.floor(r)}class rE{constructor(){this.NumberOfColors=256,this.Ramp="linear",this.TableRange=[0,255],this.HueRange=[0,.66667],this.SaturationRange=[1,1],this.ValueRange=[1,1],this.AlphaRange=[1,1],this.NaNColor=[128,0,0,255],this.BelowRangeColor=[0,0,0,255],this.UseBelowRangeColor=!0,this.AboveRangeColor=[255,255,255,255],this.UseAboveRangeColor=!0,this.InputRange=[0,255],this.Table=[]}setNumberOfTableValues(e){this.NumberOfColors=e}setRamp(e){this.Ramp=e}setTableRange(e,r){this.TableRange[0]=e,this.TableRange[1]=r}setHueRange(e,r){this.HueRange[0]=e,this.HueRange[1]=r}setSaturationRange(e,r){this.SaturationRange[0]=e,this.SaturationRange[1]=r}setValueRange(e,r){this.ValueRange[0]=e,this.ValueRange[1]=r}setRange(e,r){this.InputRange[0]=e,this.InputRange[1]=r}setAlphaRange(e,r){this.AlphaRange[0]=e,this.AlphaRange[1]=r}getColor(e){return this.mapValue(e)}build(e){if(this.Table.length>1&&!e)return;this.Table=[];const r=this.NumberOfColors-1;let n,i,o,a;r?(n=(this.HueRange[1]-this.HueRange[0])/r,i=(this.SaturationRange[1]-this.SaturationRange[0])/r,o=(this.ValueRange[1]-this.ValueRange[0])/r,a=(this.AlphaRange[1]-this.AlphaRange[0])/r):n=i=o=a=0;for(let s=0;s<=r;s++){const c=this.HueRange[0]+s*n,l=this.SaturationRange[0]+s*i,f=this.ValueRange[0]+s*o,u=this.AlphaRange[0]+s*a,d=Zce(c,l,f),h=[0,0,0,0];switch(this.Ramp){case"scurve":h[0]=Math.floor(127.5*(1+Math.cos((1-d[0])*Math.PI))),h[1]=Math.floor(127.5*(1+Math.cos((1-d[1])*Math.PI))),h[2]=Math.floor(127.5*(1+Math.cos((1-d[2])*Math.PI))),h[3]=Math.floor(u*255);break;case"linear":h[0]=Math.floor(d[0]*255+.5),h[1]=Math.floor(d[1]*255+.5),h[2]=Math.floor(d[2]*255+.5),h[3]=Math.floor(u*255+.5);break;case"sqrt":h[0]=Math.floor(Math.sqrt(d[0])*255+.5),h[1]=Math.floor(Math.sqrt(d[1])*255+.5),h[2]=Math.floor(Math.sqrt(d[2])*255+.5),h[3]=Math.floor(Math.sqrt(u)*255+.5);break;default:throw new Error(`Invalid Ramp value (${this.Ramp})`)}this.Table.push(h)}this.buildSpecialColors()}buildSpecialColors(){const e=this.NumberOfColors,r=e+IS,n=e+OS,i=e+Jce;this.UseBelowRangeColor||e===0?this.Table[r]=this.BelowRangeColor:this.Table[r]=this.Table[0],this.UseAboveRangeColor||e===0?this.Table[n]=this.AboveRangeColor:this.Table[n]=this.Table[e-1],this.Table[i]=this.NaNColor}mapValue(e){const r=this.getIndex(e);if(r<0)return this.NaNColor;if(r===0){if(this.UseBelowRangeColor&&e<this.TableRange[0])return this.BelowRangeColor}else if(r===this.NumberOfColors-1&&this.UseAboveRangeColor&&e>this.TableRange[1])return this.AboveRangeColor;return this.Table[r]}getIndex(e){const r={Range:[],MaxIndex:this.NumberOfColors-1,Shift:-this.TableRange[0],Scale:1};if(this.TableRange[1]<=this.TableRange[0]?r.Scale=Number.MAX_VALUE:r.Scale=r.MaxIndex/(this.TableRange[1]-this.TableRange[0]),r.Range[0]=this.TableRange[0],r.Range[1]=this.TableRange[1],isNaN(e))return-1;let n=Qce(e,r);return n===this.NumberOfColors+IS?n=0:n===this.NumberOfColors+OS&&(n=this.NumberOfColors-1),n}setTableValue(e,r,n,i,o){let a;if(typeof r=="number"&&n!==void 0&&i!==void 0&&o!==void 0)a=[r,n,i,o];else if(Array.isArray(r))a=r;else throw new Error("Invalid arguments for setTableValue");if(e<0)throw new Error(`Can't set the table value for negative index (${e})`);if(e>=this.NumberOfColors)throw new Error(`Index ${e} is greater than the number of colors ${this.NumberOfColors}`);this.Table[e]=a,(e===0||e===this.NumberOfColors-1)&&this.buildSpecialColors()}}const n9=[0,0,0,0];function ele(t,e,r){r=r===null?100:r;const n=(e-t)/(r-1),i=[];for(;r-- >0;)i.push(t),t+=n;return i[i.length-1]=e,i}function tle(t,e){let r=0,n=t.length-1;for(;r<=n;){const i=r+Math.floor((n-r)/2),o=t[i];if(o===e)return i;e<o?n=i-1:r=i+1}return r}function nle(t,e){let r;const n=[],i=e.length;for(t.sort(function(o,a){return o-a}),r=0;r<i;r++)n[r]=tle(t,e[r]);return n}function tC(t,e,r){let n;const i=[],o=[],a=[],s=[];for(r=r===null?1:r,n=0;n<e.length;n++){const f=e[n];i.push((t-1)*f[0]),o.push(f[1]),a.push(f[1])}const c=ele(0,1,t);for(n=0;n<t;n++)c[n]=(t-1)*Math.pow(c[n],r);const l=nle(i,c);for(n=1;n<t-1;n++){const f=l[n],u=(c[n]-i[f-1])/(i[f]-i[f-1]),d=o[f]-a[f-1];s[n]=u*d+a[f-1]}return s[0]=a[0],s[t-1]=o[e.length-1],s}function rle(t,e,r){let n;const i=[];e=e===null?256:e,r=r===null?1:r;const o=tC(e,t.red,r),a=tC(e,t.green,r),s=tC(e,t.blue,r);for(n=0;n<e;n++){const c=Math.round(o[n]*255),l=Math.round(a[n]*255),f=Math.round(s[n]*255),u=[c,l,f,255];i.push(u)}return i}function ile(t,e){let r=Y3[t];return r||(r=Y3[t]={name:"",colors:[]}),!r.colors&&r.segmentedData&&(r.colors=rle(r.segmentedData,r.numColors,r.gamma)),{getId(){return t},getColorSchemeName(){return r.name},setColorSchemeName(i){r.name=i},getNumberOfColors(){return r.colors.length},setNumberOfColors(i){for(;r.colors.length<i;)r.colors.push(n9);r.colors.length=i},getColor(i){return this.isValidIndex(i)?r.colors[i]:n9},getColorRepeating(i){const o=r.colors.length;return i=o?i%o:0,this.getColor(i)},setColor(i,o){this.isValidIndex(i)&&(r.colors[i]=o)},addColor(i){r.colors.push(i)},insertColor(i,o){this.isValidIndex(i)&&r.colors.splice(i,1,o)},removeColor(i){this.isValidIndex(i)&&r.colors.splice(i,1)},clearColors(){r.colors=[]},buildLookupTable(i){if(!i)return;const o=r.colors.length;i.setNumberOfTableValues(o);for(let a=0;a<o;a++)i.setTableValue(a,r.colors[a])},createLookupTable(){const i=new rE;return this.buildLookupTable(i),i},isValidIndex(i){return i>=0&&i<r.colors.length}}}function ole(t,e,r,n){let i=fn();const o=t.voxelManager.getScalarData();t.stats.lastGetPixelDataTime=fn()-i;const a=o.length,s=t.minPixelValue;let c=0,l=0,f,u,d;if(i=fn(),r instanceof rE?d=r.Table:d=r,s<0)for(;l<a;)f=e[o[l++]+-s],u=d[f],n[c++]=u[0],n[c++]=u[1],n[c++]=u[2],n[c++]=u[3];else for(;l<a;)f=e[o[l++]],u=d[f],n[c++]=u[0],n[c++]=u[1],n[c++]=u[2],n[c++]=u[3];t.stats.lastStoredPixelDataToCanvasImageDataTime=fn()-i}function ale(t,e,r,n){let i=fn();const o=t.voxelManager.getScalarData();t.stats.lastGetPixelDataTime=fn()-i;const a=o.length,s=t.minPixelValue;let c=0,l=0,f,u,d;if(i=fn(),r instanceof rE?d=r.Table:d=r,s<0)for(;l<a;)f=e(o[l++]+-s),u=d[f],n[c++]=u[0],n[c++]=u[1],n[c++]=u[2],n[c++]=u[3];else for(;l<a;)f=e(o[l++]),u=d[f],n[c++]=u[0],n[c++]=u[1],n[c++]=u[2],n[c++]=u[3];t.stats.lastStoredPixelDataToCanvasImageDataTime=fn()-i}function MS(t,e,r){return Math.max(e,Math.min(r,t))}function sle(t,e,r){t.renderingTools.renderCanvas||(t.renderingTools.renderCanvas=dm(null,e.width,e.height));const n=t.renderingTools.renderCanvas;let i=t.viewport.colormap||t.options.colormap;if(t.options&&t.options.colormap&&console.warn("enabledElement.options.colormap is deprecated. Use enabledElement.viewport.colormap instead"),i&&typeof i=="string"&&(i=ile(i)),!i)throw new Error("renderPseudoColorImage: colormap not found.");const o=i.getId();if(!tE(t,e)&&!r&&t.renderingTools.colormapId===o)return n;(!t.renderingTools.renderCanvasContext||n.width!==e.width||n.height!==e.height)&&Wy(t,e);let a=fn();(!t.renderingTools.colorLUT||r||t.renderingTools.colormapId!==o)&&(i.setNumberOfColors(256),t.renderingTools.colorLUT=i.createLookupTable(),t.renderingTools.colormapId=o);const s=t.renderingTools.renderCanvasData,c=t.renderingTools.renderCanvasContext,{viewport:l}=t,f=t.renderingTools.colorLUT;if(l.modality==="PT"){const{windowWidth:u,windowCenter:d}=l.voi,h=d-u/2,v=255/(d+u/2-h);let y;l.invert?y=m=>MS(Math.floor(255-(m-h)*v),0,255):y=m=>MS(Math.floor((m-h)*v),0,255),ale(e,y,f,s.data)}else{const u=Gk(e,t.viewport,r);e.stats=e.stats||{},e.stats.lastLutGenerateTime=fn()-a,ole(e,u,f,s.data)}return a=fn(),c.putImageData(s,0,0),e.stats.lastPutImageDataTime=fn()-a,n}function cle(t,e){if(t===void 0)throw new Error("drawImage: enabledElement parameter must not be undefined");const r=t.image;if(r===void 0)throw new Error("drawImage: image must be loaded before it can be drawn");const n=t.canvas.getContext("2d");n.setTransform(1,0,0,1,0,0),n.fillStyle="black",n.fillRect(0,0,t.canvas.width,t.canvas.height),n.imageSmoothingEnabled=!t.viewport.pixelReplication,eE(t,n);const i=sle(t,r,e),o=t.viewport.displayedArea.tlhc.x-1,a=t.viewport.displayedArea.tlhc.y-1,s=t.viewport.displayedArea.brhc.x-o,c=t.viewport.displayedArea.brhc.y-a;n.drawImage(i,o,a,s,c,0,0,s,c),t.renderingTools=nE(t)}function Wk(t,e){const r=t.image;if(!t.canvas||!t.image)return;const n=fn();if(r.stats={lastGetPixelDataTime:-1,lastStoredPixelDataToCanvasImageDataTime:-1,lastPutImageDataTime:-1,lastRenderTime:-1,lastLutGenerateTime:-1},r){let o=r.render;o||(t.viewport.colormap?o=cle:r.color?o=Uce:o=Yce),o(t,e)}const i=fn()-n;r.stats.lastRenderTime=i,t.invalid=!1,t.needsRedraw=!1}function zk(t){return v1(t)}function x2(t,e){const r=zk(t);return r.invert(),r.transformPoint(e)}const lle={viewport:{}};function ule(){return{tlhc:{x:1,y:1},brhc:{x:1,y:1},rowPixelSpacing:1,columnPixelSpacing:1,presentationSizeMode:"NONE"}}function fle(){const t=ule(),e={scale:1,translation:{x:0,y:0},voi:{windowWidth:void 0,windowCenter:void 0,voiLUTFunction:oo.LINEAR},invert:!1,pixelReplication:!1,rotation:0,hflip:!1,vflip:!1,modalityLUT:void 0,voiLUT:void 0,colormap:void 0,labelmap:!1,displayedArea:t};return Object.assign({},e,lle.viewport)}function xp(t,e){if(t==null)throw new Error(e)}function dle(t){return!(t==null||t===0||t===180)}function $k(t,e=null){return xp(t,"getImageSize: parameter image must not be undefined"),xp(t.width,"getImageSize: parameter image must have width"),xp(t.height,"getImageSize: parameter image must have height"),dle(e)?{height:t.width,width:t.height}:{width:t.width,height:t.height}}function iE(t,e,r=null){xp(t,"getImageScale: parameter canvas must not be undefined"),xp(e,"getImageScale: parameter image must not be undefined");const n=$k(e,r),i=e.rowPixelSpacing||1,o=e.columnPixelSpacing||1;let a=1,s=1;i<o?s=o/i:a=i/o;const c=t.height/n.height/a,l=t.width/n.width/s;return{verticalScale:c,horizontalScale:l,scaleFactor:Math.min(l,c)}}function jk(t,e,r,n){if(t===void 0)throw new Error("getDefaultViewport: parameter canvas must not be undefined");if(e===void 0)return fle();const i=iE(t,e,0).scaleFactor;let o;return r==="PT"&&e.isPreScaled?o={windowWidth:5,windowCenter:2.5}:e.windowWidth!==void 0&&e.windowCenter!==void 0&&(o={windowWidth:Array.isArray(e.windowWidth)?e.windowWidth[0]:e.windowWidth,windowCenter:Array.isArray(e.windowCenter)?e.windowCenter[0]:e.windowCenter}),{scale:i,translation:{x:0,y:0},voi:o,invert:e.invert,pixelReplication:!1,rotation:0,hflip:!1,vflip:!1,modalityLUT:e.modalityLUT,modality:r,voiLUT:e.voiLUT,colormap:n!==void 0?n:e.colormap,displayedArea:{tlhc:{x:1,y:1},brhc:{x:e.columns,y:e.rows},rowPixelSpacing:e.rowPixelSpacing===void 0?1:e.rowPixelSpacing,columnPixelSpacing:e.columnPixelSpacing===void 0?1:e.columnPixelSpacing,presentationSizeMode:"NONE"}}}function r9(t,e){return zk(t).transformPoint(e)}function hle(t){const{image:e}=t;t.viewport.scale=iE(t.canvas,e,t.viewport.rotation).scaleFactor,t.viewport.translation.x=0,t.viewport.translation.y=0}function gle(t){const{canvas:e}=t,{clientWidth:r,clientHeight:n}=e;(e.width!==r||e.height!==n)&&(e.width=r,e.height=n)}function ple(t,e,r){const n=t.viewport.scale,i=$k(t.image,t.viewport.rotation),o=Math.round(i.width*n),a=Math.round(i.height*n),s=t.viewport.translation.x,c=t.viewport.translation.y;return o===e&&a<=r||o<=e&&a===r&&s===0&&c===0}function mle(t,e,r){const n=t.viewport.scale,i=t.canvas.width,o=t.canvas.height,a=i/e,s=o/r,c=Math.sqrt(a*s);t.viewport.scale=c*n}function vle(t,e=!1){const r=t.canvas.width,n=t.canvas.height;gle(t),t.image!==void 0&&(e||ple(t,r,n)?hle(t):mle(t,r,n))}function yle(t,e){const{hflip:r,vflip:n,rotation:i}=e;if(t.x*=r?-1:1,t.y*=n?-1:1,i!==0){const o=i*Math.PI/180,a=Math.cos(o),s=Math.sin(o),c=t.x*a-t.y*s,l=t.x*s+t.y*a;t.x=c,t.y=l}return t}function wle(t,e=!0,r=!0){const{canvas:n,image:i,viewport:o}=t,a=iE(n,i,0).scaleFactor;o.vflip=!1,o.hflip=!1,e&&(o.translation.x=0,o.translation.y=0),r&&(o.displayedArea.tlhc.x=1,o.displayedArea.tlhc.y=1,o.displayedArea.brhc.x=i.columns,o.displayedArea.brhc.y=i.rows,o.scale=a)}function xle(t,e){const r=xt(t,e),n=gr(Ke(),e,2*r);return hn(Ke(),t,n)}function i9(t,e,r,n){let i=jR(t);if(r&&qc(i,i),e){const o=Tn(Ke(),n,i);Un(o,o),i=xle(i,o)}return i}const o9=k4.getLogger("RenderingEngine","StackViewport");class Jn extends bd{constructor(e){super(e),this.imageIds=[],this.imageKeyToIndexMap=new Map,this.currentImageIdIndex=0,this.targetImageIdIndex=0,this.imagesLoader=this,this.globalDefaultProperties={},this.perImageIdDefaultProperties=new Map,this.voiUpdatedWithSetProperties=!1,this.invert=!1,this.initialInvert=!1,this.initialTransferFunctionNodes=null,this.stackInvalidated=!1,this._publishCalibratedEvent=!1,this.updateRenderingPipeline=()=>{this._configureRenderingPipeline()},this.resize=()=>{this.useCPURendering&&this._resizeCPU()},this._resizeCPU=()=>{this._cpuFallbackEnabledElement.viewport&&vle(this._cpuFallbackEnabledElement)},this.getFrameOfReferenceUID=r=>{var n;return(n=this.getImagePlaneReferenceData(r))==null?void 0:n.FrameOfReferenceUID},this.getCornerstoneImage=()=>this.csImage,this.createActorMapper=r=>{const n=yce.newInstance();n.setInputData(r);const i=Ice.newInstance();i.setMapper(n);const{preferSizeOverAccuracy:o}=hw().rendering;return o&&n.setPreferSizeOverAccuracy(!0),r.getPointData().getScalars().getNumberOfComponents()>1&&i.getProperty().setIndependentComponents(!1),i},this.getNumberOfSlices=()=>this.imageIds.length,this.getDefaultProperties=r=>{let n;return r!==void 0&&(n=this.perImageIdDefaultProperties.get(r)),n!==void 0?n:{...this.globalDefaultProperties}},this.getProperties=()=>{const{colormap:r,voiRange:n,VOILUTFunction:i,interpolationType:o,invert:a,voiUpdatedWithSetProperties:s}=this;return{colormap:r,voiRange:n,VOILUTFunction:i,interpolationType:o,invert:a,isComputedVOI:!s}},this.resetCameraForResize=()=>this.resetCamera({resetPan:!0,resetZoom:!0,resetToCenter:!0,suppressEvents:!0}),this.getRotationCPU=()=>{const{viewport:r}=this._cpuFallbackEnabledElement;return r.rotation},this.getRotationGPU=()=>{const{viewUp:r,viewPlaneNormal:n,flipVertical:i,flipHorizontal:o}=this.getCameraNoRotation(),a=i9(this.initialViewUp,o,i,n),c=s4(a,r)*180/Math.PI,l=Tn(Ke(),a,r);return xt(l,n)>=0?c:(360-c)%360},this.setRotation=r=>{const n=this.getCamera();if(this.useCPURendering?this.setRotationCPU(r):this.setRotationGPU(r),this._suppressCameraModifiedEvents)return;const i=this.getCamera(),o={previousCamera:n,camera:i,element:this.element,viewportId:this.id,renderingEngineId:this.renderingEngineId};it(this.element,et.CAMERA_MODIFIED,o)},this.renderImageObject=r=>{this._setCSImage(r),(this.useCPURendering?this._updateToDisplayImageCPU:this._updateActorToDisplayImageId).call(this,r)},this._setCSImage=r=>{var n;r.isPreScaled=(n=r.preScale)==null?void 0:n.scaled,this.csImage=r},this.canvasToWorldCPU=(r,n=[0,0,0])=>{if(!this._cpuFallbackEnabledElement.image)return;const[i,o]=x2(this._cpuFallbackEnabledElement,r),{origin:a,spacing:s,direction:c}=this.getImageData(),l=c.slice(0,3),f=c.slice(3,6);return dn(n,a,l,i*s[0]),dn(n,n,f,o*s[1]),n},this.worldToCanvasCPU=r=>{const{spacing:n,direction:i,origin:o}=this.getImageData(),a=i.slice(0,3),s=i.slice(3,6),c=Nn(Ke(),r,o),l=[xt(c,a)/n[0],xt(c,s)/n[1]];return r9(this._cpuFallbackEnabledElement,l)},this.canvasToWorldGPU=r=>{const n=this.getRenderer(),i=this.getVtkActiveCamera(),o=i.getClippingRange(),a=i.getDistance();i.setClippingRange(a,a+.1);const c=this.getRenderingEngine().offscreenMultiRenderWindow.getOpenGLRenderWindow(),l=c.getSize(),f=window.devicePixelRatio||1,u=[r[0]*f,r[1]*f],d=[u[0]+this.sx,u[1]+this.sy];d[1]=l[1]-d[1];const h=c.displayToWorld(d[0],d[1],0,n);return i.setClippingRange(o[0],o[1]),[h[0],h[1],h[2]]},this.worldToCanvasGPU=r=>{const n=this.getRenderer(),i=this.getVtkActiveCamera(),o=i.getClippingRange(),a=i.getDistance();i.setClippingRange(a,a+.1);const c=this.getRenderingEngine().offscreenMultiRenderWindow.getOpenGLRenderWindow(),l=c.getSize(),f=c.worldToDisplay(...r,n);f[1]=l[1]-f[1];const u=[f[0]-this.sx,f[1]-this.sy];i.setClippingRange(o[0],o[1]);const d=window.devicePixelRatio||1;return[u[0]/d,u[1]/d]},this.getCurrentImageIdIndex=()=>this.currentImageIdIndex,this.getSliceIndex=()=>this.currentImageIdIndex,this.getTargetImageIdIndex=()=>this.targetImageIdIndex,this.getImageIds=()=>this.imageIds,this.getCurrentImageId=(r=this.getCurrentImageIdIndex())=>this.imageIds[r],this.hasImageId=r=>this.imageKeyToIndexMap.has(r),this.hasImageURI=r=>this.imageKeyToIndexMap.has(r),this.customRenderViewportToCanvas=()=>{if(!this.useCPURendering)throw new Error("Custom cpu rendering pipeline should only be hit in CPU rendering mode");return this._cpuFallbackEnabledElement.image?(Wk(this._cpuFallbackEnabledElement,this.cpuRenderingInvalidated),this.cpuRenderingInvalidated=!1):this.fillWithBackgroundColor(),{canvas:this.canvas,element:this.element,viewportId:this.id,renderingEngineId:this.renderingEngineId,viewportStatus:this.viewportStatus}},this.renderingPipelineFunctions={getImageData:{cpu:this.getImageDataCPU,gpu:this.getImageDataGPU},setColormap:{cpu:this.setColormapCPU,gpu:this.setColormapGPU},getCamera:{cpu:this.getCameraCPU,gpu:super.getCamera},setCamera:{cpu:this.setCameraCPU,gpu:super.setCamera},getPan:{cpu:this.getPanCPU,gpu:super.getPan},setPan:{cpu:this.setPanCPU,gpu:super.setPan},getZoom:{cpu:this.getZoomCPU,gpu:super.getZoom},setZoom:{cpu:this.setZoomCPU,gpu:super.setZoom},setVOI:{cpu:this.setVOICPU,gpu:this.setVOIGPU},getRotation:{cpu:this.getRotationCPU,gpu:this.getRotationGPU},setInterpolationType:{cpu:this.setInterpolationTypeCPU,gpu:this.setInterpolationTypeGPU},setInvertColor:{cpu:this.setInvertColorCPU,gpu:this.setInvertColorGPU},resetCamera:{cpu:(r={})=>{const{resetPan:n=!0,resetZoom:i=!0}=r;return this.resetCameraCPU({resetPan:n,resetZoom:i}),!0},gpu:(r={})=>{const{resetPan:n=!0,resetZoom:i=!0}=r;return this.resetCameraGPU({resetPan:n,resetZoom:i}),!0}},canvasToWorld:{cpu:this.canvasToWorldCPU,gpu:this.canvasToWorldGPU},worldToCanvas:{cpu:this.worldToCanvasCPU,gpu:this.worldToCanvasGPU},getRenderer:{cpu:()=>this.getCPUFallbackError("getRenderer"),gpu:super.getRenderer},getDefaultActor:{cpu:()=>this.getCPUFallbackError("getDefaultActor"),gpu:super.getDefaultActor},getActors:{cpu:()=>this.getCPUFallbackError("getActors"),gpu:super.getActors},getActor:{cpu:()=>this.getCPUFallbackError("getActor"),gpu:super.getActor},setActors:{cpu:()=>this.getCPUFallbackError("setActors"),gpu:super.setActors},addActors:{cpu:()=>this.getCPUFallbackError("addActors"),gpu:super.addActors},addActor:{cpu:()=>this.getCPUFallbackError("addActor"),gpu:super.addActor},removeAllActors:{cpu:()=>this.getCPUFallbackError("removeAllActors"),gpu:super.removeAllActors},unsetColormap:{cpu:this.unsetColormapCPU,gpu:this.unsetColormapGPU}},this.scaling={},this.modality=null,this.useCPURendering=X0(),this._configureRenderingPipeline(),this.useCPURendering?this._resetCPUFallbackElement():this._resetGPUViewport(),this.currentImageIdIndex=0,this.targetImageIdIndex=0,this.resetCamera(),this.initializeElementDisabledHandler()}setUseCPURendering(e){this.useCPURendering=e,this._configureRenderingPipeline(e)}static get useCustomRenderingPipeline(){return X0()}_configureRenderingPipeline(e){this.useCPURendering=e??X0();for(const r in this.renderingPipelineFunctions)if(Object.prototype.hasOwnProperty.call(this.renderingPipelineFunctions,r)){const n=this.renderingPipelineFunctions[r];this[r]=this.useCPURendering?n.cpu:n.gpu}this.useCPURendering?this._resetCPUFallbackElement():this._resetGPUViewport()}_resetCPUFallbackElement(){this._cpuFallbackEnabledElement={canvas:this.canvas,renderingTools:{},transform:new Kh,viewport:{rotation:0}}}_resetGPUViewport(){const e=this.getRenderer(),r=M4.newInstance();e.setActiveCamera(r),this.initialViewUp=[0,-1,0],r.setDirectionOfProjection(-0,-0,1),r.setViewUp(...this.initialViewUp),r.setParallelProjection(!0),r.setThicknessFromFocalPoint(.1),r.setFreezeFocalPoint(!0)}initializeElementDisabledHandler(){Ze.addEventListener(et.ELEMENT_DISABLED,function e(){clearTimeout(this.debouncedTimeout),Ze.removeEventListener(et.ELEMENT_DISABLED,e)})}getImageDataGPU(){const e=this.getDefaultActor();if(!e||!Qs(e))return;const{actor:r}=e,n=r.getMapper().getInputData(),i=this.csImage;return{dimensions:n.getDimensions(),spacing:n.getSpacing(),origin:n.getOrigin(),direction:n.getDirection(),get scalarData(){return i==null?void 0:i.voxelManager.getScalarData()},imageData:r.getMapper().getInputData(),metadata:{Modality:this.modality,FrameOfReferenceUID:this.getFrameOfReferenceUID()},scaling:this.scaling,hasPixelSpacing:this.hasPixelSpacing,calibration:{...i==null?void 0:i.calibration,...this.calibration},preScale:{...i==null?void 0:i.preScale},voxelManager:i==null?void 0:i.voxelManager}}getImageDataCPU(){const{metadata:e}=this._cpuFallbackEnabledElement;if(!e)return;const r=e.spacing,n=this.csImage;return{dimensions:e.dimensions,spacing:r,origin:e.origin,direction:e.direction,metadata:{Modality:this.modality,FrameOfReferenceUID:this.getFrameOfReferenceUID()},scaling:this.scaling,imageData:{getDirection:()=>e.direction,getDimensions:()=>e.dimensions,getScalarData:()=>this.cpuImagePixelData,getSpacing:()=>r,worldToIndex:i=>{const o=this.worldToCanvasCPU(i),a=x2(this._cpuFallbackEnabledElement,o);return[a[0],a[1],0]},indexToWorld:(i,o)=>{const a=r9(this._cpuFallbackEnabledElement,[i[0],i[1]]);return this.canvasToWorldCPU(a,o)}},scalarData:this.cpuImagePixelData,hasPixelSpacing:this.hasPixelSpacing,calibration:{...n==null?void 0:n.calibration,...this.calibration},preScale:{...n==null?void 0:n.preScale},voxelManager:n==null?void 0:n.voxelManager}}calibrateIfNecessary(e,r){const n=ct("calibratedPixelSpacing",e),i=this.calibration!==n,{scale:o}=n||{};return this.hasPixelSpacing=o>0||r.rowPixelSpacing>0,r.calibration=n,i&&(this.calibration=n,this._publishCalibratedEvent=!0,this._calibrationEvent={scale:o,calibration:n}),r}setDefaultProperties(e,r){r==null?this.globalDefaultProperties=e:(this.perImageIdDefaultProperties.set(r,e),this.getCurrentImageId()===r&&this.setProperties(e))}clearDefaultProperties(e){e==null?(this.globalDefaultProperties={},this.resetProperties()):(this.perImageIdDefaultProperties.delete(e),this.resetToDefaultProperties())}setProperties({colormap:e,voiRange:r,VOILUTFunction:n,invert:i,interpolationType:o}={},a=!1){this.viewportStatus=this.csImage?_o.PRE_RENDER:_o.LOADING,this.globalDefaultProperties={colormap:this.globalDefaultProperties.colormap??e,voiRange:this.globalDefaultProperties.voiRange??r,VOILUTFunction:this.globalDefaultProperties.VOILUTFunction??n,invert:this.globalDefaultProperties.invert??i,interpolationType:this.globalDefaultProperties.interpolationType??o},typeof e<"u"&&this.setColormap(e),typeof r<"u"&&this.setVOI(r,{suppressEvents:a,voiUpdatedWithSetProperties:!0}),typeof n<"u"&&this.setVOILUTFunction(n,a),typeof i<"u"&&this.setInvertColor(i),typeof o<"u"&&this.setInterpolationType(o)}resetProperties(){this.cpuRenderingInvalidated=!0,this.voiUpdatedWithSetProperties=!1,this.viewportStatus=_o.PRE_RENDER,this.fillWithBackgroundColor(),this.useCPURendering&&(this._cpuFallbackEnabledElement.renderingTools={}),this._resetProperties(),this.render()}_resetProperties(){let e;if(this._isCurrentImagePTPrescaled()?e=this._getDefaultPTPrescaledVOIRange():e=this._getVOIRangeForCurrentImage(),this.setVOI(e),this.setInvertColor(this.initialInvert),this.setInterpolationType(Fl.LINEAR),!this.useCPURendering){const r=this.getTransferFunction();vw(r,this.initialTransferFunctionNodes);const i=ky(r).reduce((s,c)=>(s.push(c[0],c[1],c[2],c[3]),s),[]),o=this.getDefaultActor(),a=U4(i,o.actor);this.setColormap(a)}}resetToDefaultProperties(){var i;this.cpuRenderingInvalidated=!0,this.viewportStatus=_o.PRE_RENDER,this.fillWithBackgroundColor(),this.useCPURendering&&(this._cpuFallbackEnabledElement.renderingTools={});const e=this.getCurrentImageId(),r=this.perImageIdDefaultProperties.get(e)||this.globalDefaultProperties;(i=r.colormap)!=null&&i.name&&this.setColormap(r.colormap);let n;r.voiRange==null?n=this._getVOIRangeForCurrentImage():n=r.voiRange,this.setVOI(n),this.setInterpolationType(Fl.LINEAR),this.setInvertColor(!1),this.render()}_getVOIFromCache(){let e;return this.voiUpdatedWithSetProperties?e=this.voiRange:this._isCurrentImagePTPrescaled()?e=this._getDefaultPTPrescaledVOIRange():e=this._getVOIRangeForCurrentImage()??this.voiRange,e}_setPropertiesFromCache(){const e=this._getVOIFromCache(),{interpolationType:r,invert:n}=this;this.setVOI(e),this.setInterpolationType(r),this.setInvertColor(n)}getCameraCPU(){const{metadata:e,viewport:r}=this._cpuFallbackEnabledElement;if(!e)return{};const{direction:n}=e,i=n.slice(6,9).map(u=>-u);let o=n.slice(3,6).map(u=>-u);if(r.rotation){const u=i4(ma(),r.rotation*Math.PI/180,i);o=At(Ke(),o,u)}const a=[this.element.clientWidth/2,this.element.clientHeight/2],s=this.canvasToWorld(a),c=this.canvasToWorld([0,0]),l=this.canvasToWorld([0,this.element.clientHeight]),f=Fi(c,l)/2;return{parallelProjection:!0,focalPoint:s,position:[0,0,0],parallelScale:f,scale:r.scale,viewPlaneNormal:[i[0],i[1],i[2]],viewUp:[o[0],o[1],o[2]],flipHorizontal:this.flipHorizontal,flipVertical:this.flipVertical}}setCameraCPU(e){const{viewport:r,image:n}=this._cpuFallbackEnabledElement,i=this.getCameraCPU(),{focalPoint:o,parallelScale:a,scale:s,flipHorizontal:c,flipVertical:l}=e,{clientHeight:f}=this.element;if(o){const d=this.worldToCanvasCPU(o),h=x2(this._cpuFallbackEnabledElement,d),g=this.worldToCanvasCPU(i.focalPoint),p=x2(this._cpuFallbackEnabledElement,g),v=Wt();Br(v,Y6(h[0],h[1]),Y6(p[0],p[1]));const y=yle({x:v[0],y:v[1]},r);r.translation.x-=y.x,r.translation.y-=y.y}if(a){const{rowPixelSpacing:d}=n,h=f*d*.5/a;r.scale=h,r.parallelScale=a}if(s){const{rowPixelSpacing:d}=n;r.scale=s,r.parallelScale=f*d*.5/s}(c!==void 0||l!==void 0)&&this.setFlipCPU({flipHorizontal:c,flipVertical:l}),this._cpuFallbackEnabledElement.transform=v1(this._cpuFallbackEnabledElement);const u={previousCamera:i,camera:this.getCamera(),element:this.element,viewportId:this.id,renderingEngineId:this.renderingEngineId};it(this.element,et.CAMERA_MODIFIED,u)}getPanCPU(){const{viewport:e}=this._cpuFallbackEnabledElement;return[e.translation.x,e.translation.y]}setPanCPU(e){const r=this.getCameraCPU();this.setCameraCPU({...r,focalPoint:[...e.map(n=>-n),0]})}getZoomCPU(){const{viewport:e}=this._cpuFallbackEnabledElement;return e.scale}setZoomCPU(e){const r=this.getCameraCPU();this.setCameraCPU({...r,scale:e})}setFlipCPU({flipHorizontal:e,flipVertical:r}){const{viewport:n}=this._cpuFallbackEnabledElement;e!==void 0&&(n.hflip=e,this.flipHorizontal=n.hflip),r!==void 0&&(n.vflip=r,this.flipVertical=n.vflip)}setVOILUTFunction(e,r){if(this.useCPURendering)throw new Error("VOI LUT function is not supported in CPU rendering");const n=this._getValidVOILUTFunction(e);let i=!1;this.VOILUTFunction!==n&&(i=!0),this.VOILUTFunction=n;const{voiRange:o}=this.getProperties();this.setVOI(o,{suppressEvents:r,forceRecreateLUTFunction:i})}setRotationCPU(e){const{viewport:r}=this._cpuFallbackEnabledElement;r.rotation=e}setRotationGPU(e){const r=this.getPan(this.fitToCanvasCamera),n=this.getPan(),i=ps([0,0],r,n);this.setPan(i,!1);const{flipVertical:o,flipHorizontal:a,viewPlaneNormal:s}=this.getCamera(),c=i9(this.initialViewUp,a,o,s);this.setCameraNoEvent({viewUp:c}),this.getVtkActiveCamera().roll(-e);const l=this.getPan(),f=this.getPan(this.fitToCanvasCamera),u=ps([0,0],l,f),d=no([0,0],r,u);this.setPan(d,!1)}setInterpolationTypeGPU(e){const r=this.getDefaultActor();if(!r||!Qs(r))return;const{actor:n}=r;n.getProperty().setInterpolationType(e),this.interpolationType=e}setInterpolationTypeCPU(e){const{viewport:r}=this._cpuFallbackEnabledElement;r.pixelReplication=e!==Fl.LINEAR,this.interpolationType=e}setInvertColorCPU(e){const{viewport:r}=this._cpuFallbackEnabledElement;r&&(r.invert=e,this.invert=e)}setInvertColorGPU(e){const r=this.getDefaultActor();if(r&&Qs(r)){if(ga(r,"vtkVolume")){const i=r.actor.getProperty().getRGBTransferFunction(0);(!this.invert&&e||this.invert&&!e)&&wp(i),this.invert=e}else if(ga(r,"vtkImageSlice")){const i=r.actor.getProperty().getRGBTransferFunction(0);(!this.invert&&e||this.invert&&!e)&&wp(i),this.invert=e}}}setVOICPU(e,r={}){const{suppressEvents:n=!1}=r,{viewport:i,image:o}=this._cpuFallbackEnabledElement;if(!i||!o)return;if(typeof e>"u"){const{windowWidth:s,windowCenter:c}=o,l=Array.isArray(s)?s[0]:s,f=Array.isArray(c)?c[0]:c;i.voi={windowWidth:l,windowCenter:f,voiLUTFunction:o.voiLUTFunction};const{lower:u,upper:d}=Yu(l,f,o.voiLUTFunction);e={lower:u,upper:d}}else{const{lower:s,upper:c}=e,{windowCenter:l,windowWidth:f}=om(s,c);i.voi||(i.voi={windowWidth:0,windowCenter:0,voiLUTFunction:o.voiLUTFunction}),i.voi.windowWidth=f,i.voi.windowCenter=l}this.voiRange=e;const a={viewportId:this.id,range:e};n||it(this.element,et.VOI_MODIFIED,a)}getTransferFunction(){const e=this.getDefaultActor();return!e||!Qs(e)?void 0:e.actor.getProperty().getRGBTransferFunction(0)}setVOIGPU(e,r={}){const{suppressEvents:n=!1,forceRecreateLUTFunction:i=!1,voiUpdatedWithSetProperties:o=!1}=r;if(e&&this.voiRange&&this.voiRange.lower===e.lower&&this.voiRange.upper===e.upper&&!i&&!this.stackInvalidated)return;const a=this.getDefaultActor();if(!a||!Qs(a))return;const s=a.actor;let c=e;if(typeof c>"u"){const h=s.getMapper().getInputData().getPointData().getScalars().getRange();c={lower:h[0],upper:h[1]}}s.getProperty().setUseLookupTableScalarRange(!0);let l=s.getProperty().getRGBTransferFunction(0);const f=this.VOILUTFunction===oo.SAMPLED_SIGMOID;if((f||!l||i)&&(l=(f?z4:kk)(c),this.invert&&wp(l),s.getProperty().setRGBTransferFunction(0,l),this.initialTransferFunctionNodes=ky(l)),f||l.setRange(c.lower,c.upper),this.voiRange=c,this.voiUpdatedWithSetProperties||(this.voiUpdatedWithSetProperties=o),n)return;const u={viewportId:this.id,range:c,VOILUTFunction:this.VOILUTFunction};it(this.element,et.VOI_MODIFIED,u)}_addScalingToViewport(e){if(this.scaling.PT)return;const{suvbw:r,suvlbm:n,suvbsa:i}=e,o={};n&&(o.suvbwToSuvlbm=n/r),i&&(o.suvbwToSuvbsa=i/r),this.scaling.PT=o}getImageDataMetadata(e){const r=e.imageId,n=yw(e),{numberOfComponents:i,origin:o,direction:a,dimensions:s,spacing:c,numVoxels:l,imagePixelModule:f,voiLUTFunction:u,modality:d,scalingFactor:h,calibration:g}=n;d==="PT"&&h&&this._addScalingToViewport(h),this.modality=d;const p=this._getValidVOILUTFunction(u);this.VOILUTFunction=p,this.calibration=g;let v=this._getImagePlaneModule(r);return this.useCPURendering||(v=this.calibrateIfNecessary(r,v)),{bitsAllocated:f.bitsAllocated,numberOfComponents:i,origin:o,direction:a,dimensions:s,spacing:c,numVoxels:l,imagePlaneModule:v,imagePixelModule:f}}matchImagesForOverlay(e,r){return(i=>{const o=ct(jo.IMAGE_PLANE,r),a=ct(jo.IMAGE_PLANE,i),s=o.imageOrientationPatient,c=a.imageOrientationPatient;if(s&&c){if(Vt(o.imageOrientationPatient,a.imageOrientationPatient)){const f=o.imagePositionPatient,u=a.imagePositionPatient;if(f&&u&&Vt(f,u)){const h=o.rows,g=o.columns,p=a.rows,v=a.columns;if(h===p&&g===v)return i}}}else{const l=o.rows,f=o.columns,u=a.rows,d=a.columns;if(l===u&&f===d)return i}})(e)}getImagePlaneReferenceData(e=this.getCurrentImageIdIndex()){const r=this.imageIds[e];if(!r)return;const n=ct(jo.IMAGE_PLANE,r);if(!n)return;const{imagePositionPatient:i,frameOfReferenceUID:o}=n;let{rowCosines:a,columnCosines:s}=n;a||(a=[1,0,0]),s||(s=[0,1,0]);const c=Tn([0,0,0],s,a);return{FrameOfReferenceUID:o,viewPlaneNormal:c,cameraFocalPoint:i,referencedImageId:r,sliceIndex:e}}_getCameraOrientation(e){const r=e.slice(6,9).map(i=>-i),n=e.slice(3,6).map(i=>-i);return{viewPlaneNormal:[r[0],r[1],r[2]],viewUp:[n[0],n[1],n[2]]}}createVTKImageData({origin:e,direction:r,dimensions:n,spacing:i,numberOfComponents:o,pixelArray:a}){const s=new a.constructor(a.length),c=bt.newInstance({name:"Pixels",numberOfComponents:o,values:s}),l=nm.newInstance();return l.setDimensions(n),l.setSpacing(i),l.setDirection(r),l.setOrigin(e),l.getPointData().setScalars(c),l}_createVTKImageData({origin:e,direction:r,dimensions:n,spacing:i,numberOfComponents:o,pixelArray:a}){try{this._imageData=this.createVTKImageData({origin:e,direction:r,dimensions:n,spacing:i,numberOfComponents:o,pixelArray:a})}catch(s){o9.error(s)}}async setStack(e,r=0){if(this._throwIfDestroyed(),this.imageIds=e,r>e.length)throw new Error("Current image index is greater than the number of images in the stack");this.imageKeyToIndexMap.clear(),e.forEach((a,s)=>{this.imageKeyToIndexMap.set(a,s),this.imageKeyToIndexMap.set(_r(a),s)}),this.currentImageIdIndex=r,this.targetImageIdIndex=r;const n=ct(h1.IMAGE_RETRIEVE_CONFIGURATION,e[r],"stack");this.imagesLoader=n?(n.create||mk)(n):this,this.stackInvalidated=!0,this.flipVertical=!1,this.flipHorizontal=!1,this.voiRange=null,this.interpolationType=Fl.LINEAR,this.invert=!1,this.viewportStatus=_o.LOADING,this.fillWithBackgroundColor(),this.useCPURendering&&(this._cpuFallbackEnabledElement.renderingTools={},delete this._cpuFallbackEnabledElement.viewport.colormap);const i=await this._setImageIdIndex(r),o={imageIds:e,viewportId:this.id,element:this.element,currentImageIdIndex:r};return it(this.element,et.VIEWPORT_NEW_IMAGE_SET,o),i}_throwIfDestroyed(){if(this.isDisabled)throw new Error("The stack viewport has been destroyed and is no longer usable. Renderings will not be performed. If you are using the same viewportId and have re-enabled the viewport, you need to grab the new viewport instance using renderingEngine.getViewport(viewportId), instead of using your lexical scoped reference to the viewport instance.")}_checkVTKImageDataMatchesCornerstoneImage(e,r){if(!r)return!1;const[n,i]=r.getSpacing(),[o,a]=r.getDimensions(),s=this._getImagePlaneModule(e.imageId),c=r.getDirection(),l=c.slice(0,3),f=c.slice(3,6),u=r.getPointData().getScalars().getDataType(),d=Vt(n,e.columnPixelSpacing),h=Vt(i,e.rowPixelSpacing),g=d||e.columnPixelSpacing===null&&n===1,p=h||e.rowPixelSpacing===null&&i===1,v=o===e.columns,y=a===e.rows,m=Vt(s.rowCosines,l),w=Vt(s.columnCosines,f),x=u===e.voxelManager.getScalarData().constructor.name;return g&&p&&v&&y&&m&&w&&x}_updateVTKImageDataFromCornerstoneImage(e){let n=this._getImagePlaneModule(e.imageId).imagePositionPatient;n==null&&(n=[0,0,0]),this._imageData.setOrigin(n);const i=this.getActor(this.id);i&&(i.referencedId=e.imageId),ww(this._imageData,e)}_loadAndDisplayImage(e,r){return this.useCPURendering?this._loadAndDisplayImageCPU(e,r):this._loadAndDisplayImageGPU(e,r)}_loadAndDisplayImageCPU(e,r){return new Promise((n,i)=>{function o(h,g,p){if(this.currentImageIdIndex!==g)return;const v=h.voxelManager.getScalarData(),y=h.preScale,m=y==null?void 0:y.scalingParameters,w=(y==null?void 0:y.scaled)&&(m==null?void 0:m.rescaleIntercept)%1!==0||(m==null?void 0:m.rescaleSlope)%1!==0;if(v instanceof Float32Array&&w){const C={min:h.minPixelValue,max:h.maxPixelValue},_=Math.abs(C.max-C.min)/65535,E=C.min,b=v.length,D=new Uint16Array(b);let I=65535,P=0;for(let O=0;O<b;O++){const L=Math.floor((v[O]-E)/_);D[O]=L,I=Math.min(I,L),P=Math.max(P,L)}h.minPixelValue=I,h.maxPixelValue=P,h.slope=_,h.intercept=E,h.voxelManager?h.voxelManager.getScalarData=()=>D:h.getPixelData=()=>D,h.preScale={...h.preScale,scaled:!1}}this._setCSImage(h),this.viewportStatus=_o.PRE_RENDER;const x={image:h,imageId:p,imageIdIndex:g,viewportId:this.id,renderingEngineId:this.renderingEngineId};it(this.element,et.STACK_NEW_IMAGE,x),this._updateToDisplayImageCPU(h),this.render(),this.currentImageIdIndex=g,n(p)}function a(h,g,p){const v={error:h,imageIdIndex:g,imageId:p};this.suppressEvents||it(Ze,et.IMAGE_LOAD_ERROR,v),i(h)}function s(h,g,p){return ws(h,p).then(v=>{o.call(this,v,g,h)},v=>{a.call(this,v,g,h)})}const c=-5,l=Qt.Interaction,f={imageId:e,imageIdIndex:r},u={useRGBA:!0,requestType:l},d={imageId:e,imageIdIndex:r,viewportId:this.id,renderingEngineId:this.renderingEngineId};it(this.element,et.PRE_STACK_NEW_IMAGE,d),_i.addRequest(s.bind(this,e,r,u),l,f,c)})}successCallback(e,r){var l,f;const n=this.imageIds.indexOf(e);if(this.currentImageIdIndex!==n)return;const i=(l=this.csImage)==null?void 0:l.imageFrame,o=r==null?void 0:r.imageFrame,a=(i==null?void 0:i.photometricInterpretation)||((f=this.csImage)==null?void 0:f.photometricInterpretation),s=(o==null?void 0:o.photometricInterpretation)||(r==null?void 0:r.photometricInterpretation);a!==s&&(this.stackInvalidated=!0),this._setCSImage(r);const c={image:r,imageId:e,imageIdIndex:n,viewportId:this.id,renderingEngineId:this.renderingEngineId};this._updateActorToDisplayImageId(r),it(this.element,et.STACK_NEW_IMAGE,c),this.render(),this.currentImageIdIndex=n}errorCallback(e,r,n){if(!r)return;const i=this.imageIds.indexOf(e),o={error:n,imageIdIndex:i,imageId:e};it(Ze,et.IMAGE_LOAD_ERROR,o)}getLoaderImageOptions(e){const r=this.imageIds.indexOf(e),{transferSyntaxUID:n}=ct("transferSyntax",e)||{};return{useRGBA:!1,transferSyntaxUID:n,priority:5,requestType:Qt.Interaction,additionalDetails:{imageId:e,imageIdIndex:r}}}async loadImages(e,r){const n=await Promise.allSettled(e.map(o=>{const a=this.getLoaderImageOptions(o);return ws(o,a).then(s=>(r.successCallback(o,s),o),s=>(r.errorCallback(o,!0,s),o))})),i=n.filter(o=>o.status==="rejected");if(i&&i.length){const o=new CustomEvent(et.IMAGE_LOAD_ERROR,{detail:i,cancelable:!0});Ze.dispatchEvent(o)}return n}_loadAndDisplayImageGPU(e,r){if(!e){console.warn("No image id set yet to load");return}const n={imageId:e,imageIdIndex:r,viewportId:this.id,renderingEngineId:this.renderingEngineId};return it(this.element,et.PRE_STACK_NEW_IMAGE,n),this.imagesLoader.loadImages([e],this).then(i=>e)}_updateToDisplayImageCPU(e){const r=this.getImageDataMetadata(e),n=jk(this.canvas,e,this.modality,this._cpuFallbackEnabledElement.viewport.colormap),{windowCenter:i,windowWidth:o,voiLUTFunction:a}=n.voi;this.voiRange=Yu(o,i,a),this._cpuFallbackEnabledElement.image=e,this._cpuFallbackEnabledElement.metadata={...r},this.cpuImagePixelData=e.voxelManager.getScalarData();const s=Object.assign({},n,this._cpuFallbackEnabledElement.viewport);this._cpuFallbackEnabledElement.viewport=this.stackInvalidated?n:s,this.stackInvalidated=!1,this.cpuRenderingInvalidated=!0,this._cpuFallbackEnabledElement.transform=v1(this._cpuFallbackEnabledElement)}getSliceViewInfo(){throw new Error("Method not implemented.")}addImages(e){const r=[];e.forEach(n=>{const{imageId:i,...o}=n,a=$e.getImage(i),{origin:s,dimensions:c,direction:l,spacing:f,numberOfComponents:u}=this.getImageDataMetadata(a),d=this.createVTKImageData({origin:s,dimensions:c,direction:l,spacing:f,numberOfComponents:u,pixelArray:a.voxelManager.getScalarData()}),h=this.createActorMapper(d);h&&(r.push({uid:n.actorUID??gn(),actor:h,referencedId:i,...o}),n.callback&&n.callback({imageActor:h,imageId:n.imageId}))}),this.addActors(r)}_updateActorToDisplayImageId(e){const r=this._checkVTKImageDataMatchesCornerstoneImage(e,this._imageData),n=this.getViewPresentation();if(r&&!this.stackInvalidated){this._updateVTKImageDataFromCornerstoneImage(e),this.resetCameraNoEvent(),this.setViewPresentation(n),this._setPropertiesFromCache(),this.stackActorReInitialized=!1;return}const{origin:i,direction:o,dimensions:a,spacing:s,numberOfComponents:c,imagePixelModule:l}=this.getImageDataMetadata(e),f=e.voxelManager.getScalarData();this._createVTKImageData({origin:i,direction:o,dimensions:a,spacing:s,numberOfComponents:c,pixelArray:f}),this._updateVTKImageDataFromCornerstoneImage(e);const u=this.createActorMapper(this._imageData),d=this.getActors();d.length&&d[0].uid===this.id?d[0].actor=u:d.unshift({uid:this.id,actor:u,referencedId:e.imageId}),this.setActors(d);const{viewPlaneNormal:h,viewUp:g}=this._getCameraOrientation(o),p=this.getCamera();this.setCameraNoEvent({viewUp:g,viewPlaneNormal:h}),this.initialViewUp=g,this.resetCameraNoEvent(),this.setViewPresentation(n),this.triggerCameraEvent(this.getCamera(),p);const v=l.photometricInterpretation==="MONOCHROME1";this.stackInvalidated=!0;const y=this._getInitialVOIRange(e);this.setVOI(y,{forceRecreateLUTFunction:!!v}),this.initialInvert=!!v,this.setInvertColor(this.invert||this.initialInvert),this.stackInvalidated=!1,this.stackActorReInitialized=!0,this._publishCalibratedEvent&&this.triggerCalibrationEvent()}_getInitialVOIRange(e){if(this.voiRange&&this.voiUpdatedWithSetProperties)return this.voiRange;const{windowCenter:r,windowWidth:n,voiLUTFunction:i}=e;let o=this._getVOIRangeFromWindowLevel(n,r,i);return o=this._getPTPreScaledRange()||o,o}_getPTPreScaledRange(){if(this._isCurrentImagePTPrescaled())return this._getDefaultPTPrescaledVOIRange()}_isCurrentImagePTPrescaled(){var e;return!(this.modality!=="PT"||!this.csImage.isPreScaled||!((e=this.csImage.preScale)!=null&&e.scalingParameters.suvbw))}_getDefaultPTPrescaledVOIRange(){return{lower:0,upper:5}}_getVOIRangeFromWindowLevel(e,r,n=oo.LINEAR){let i,o;if(typeof r=="number"&&typeof e=="number"?(i=r,o=e):Array.isArray(r)&&Array.isArray(e)&&(i=r[0],o=e[0]),i!==void 0&&o!==void 0)return Yu(o,i,n)}async _setImageIdIndex(e){if(e>=this.imageIds.length)throw new Error(`ImageIdIndex provided ${e} is invalid, the stack only has ${this.imageIds.length} elements`);this.currentImageIdIndex=e,this.hasPixelSpacing=!0,this.viewportStatus=_o.PRE_RENDER;const r=await this._loadAndDisplayImage(this.imageIds[e],e);if(this.perImageIdDefaultProperties.size>=1){const n=this.perImageIdDefaultProperties.get(r);n!==void 0?this.setProperties(n):this.globalDefaultProperties!==void 0&&this.setProperties(this.globalDefaultProperties)}return r}resetCameraCPU({resetPan:e=!0,resetZoom:r=!0}){const{image:n}=this._cpuFallbackEnabledElement;if(!n)return;wle(this._cpuFallbackEnabledElement,e,r);const{scale:i}=this._cpuFallbackEnabledElement.viewport,{clientWidth:o,clientHeight:a}=this.element,s=[o/2,a/2],c=this.canvasToWorldCPU(s);this.setCameraCPU({focalPoint:c,scale:i})}resetCameraGPU({resetPan:e,resetZoom:r}){return this.setCamera({flipHorizontal:!1,flipVertical:!1,viewUp:this.initialViewUp}),super.resetCamera({resetPan:e,resetZoom:r,resetToCenter:!0})}scroll(e,r=!0,n=!1){const i=this.imageIds;if(isNaN(this.targetImageIdIndex))return;const o=this.targetImageIdIndex,a=i.length;let s=o+e;n?s=(s+a)%a:s=Math.max(0,Math.min(a-1,s)),this.targetImageIdIndex=s;const c=i[s];$e.isLoaded(c)||!r?this.setImageIdIndex(s):(clearTimeout(this.debouncedTimeout),this.debouncedTimeout=window.setTimeout(()=>{this.setImageIdIndex(s)},40));const f={newImageIdIndex:s,imageId:c,direction:e};s!==o&&it(this.element,et.STACK_VIEWPORT_SCROLL,f)}setImageIdIndex(e){if(this._throwIfDestroyed(),this.currentImageIdIndex===e)return Promise.resolve(this.getCurrentImageId());const r=this._setImageIdIndex(e);return this.targetImageIdIndex=e,r}calibrateSpacing(e){const r=this.getImageIds().indexOf(e);this.stackInvalidated=!0,this._loadAndDisplayImage(e,r)}triggerCameraEvent(e,r){const n={previousCamera:r,camera:e,element:this.element,viewportId:this.id,renderingEngineId:this.renderingEngineId};this.suppressEvents||it(this.element,et.CAMERA_MODIFIED,n)}triggerCalibrationEvent(){const{imageData:e}=this.getImageData(),r={element:this.element,viewportId:this.id,renderingEngineId:this.renderingEngineId,imageId:this.getCurrentImageId(),imageData:e,worldToIndex:e.getWorldToIndex(),...this._calibrationEvent};this.suppressEvents||it(this.element,et.IMAGE_SPACING_CALIBRATED,r),this._publishCalibratedEvent=!1}jumpToWorld(e){const r=this.getImageIds(),n=this.getImageData(),{direction:i,spacing:o}=n,a=Ql({direction:i,spacing:o,imageIds:r},e,this.getCamera().viewPlaneNormal,{ignoreSpacing:!0}),s=r.indexOf(a);return s===-1?!1:(this.setImageIdIndex(s),this.render(),!0)}_getVOIRangeForCurrentImage(){const{windowCenter:e,windowWidth:r,voiLUTFunction:n}=this.csImage;return this._getVOIRangeFromWindowLevel(r,e,n)}_getValidVOILUTFunction(e){return Object.values(oo).includes(e)?e:oo.LINEAR}getSliceInfo(){const e=this.getSliceIndex(),{dimensions:r}=this.getImageData();return{width:r[0],height:r[1],sliceIndex:e,slicePlane:2}}isReferenceViewable(e,r={}){const n=this.getCurrentImageIdIndex(),i=this.imageIds[n];if(!i||!e)return!1;const{referencedImageId:o,multiSliceReference:a}=e;if(o){if(o===i)return!0;e.referencedImageURI||(e.referencedImageURI=_r(o));const{referencedImageURI:c}=e,l=this.imageKeyToIndexMap.get(c);if(r.asOverlay&&this.matchImagesForOverlay(i,o))return!0;if(l===void 0)return!1;if(r.withNavigation)return!0;const f=a&&this.imageKeyToIndexMap.get(a.referencedImageId);return n<=f&&n>=l}if(!super.isReferenceViewable(e,r))return!1;if(e.volumeId)return r.asVolume;const{cameraFocalPoint:s}=e;if(r.asNearbyProjection&&s){const{spacing:c,direction:l,origin:f}=this.getImageData(),u=l.slice(6,9),d=Cf({direction:l,spacing:c},u),h=Nn(Ke(),s,f),g=xt(h,u),p=d/2;if(Math.abs(g)<=p)return!0}return!1}getViewReference(e={}){const{sliceIndex:r=this.getCurrentImageIdIndex()}=e,n=super.getViewReference(e),i=this.getCurrentImageId(r);if(i){if(n.referencedImageId=i,this.getCurrentImageIdIndex()!==r){const o=this.getImagePlaneReferenceData(r);if(!o)return;Object.assign(n,o)}return n}}setViewReference(e){if(!(e!=null&&e.referencedImageId)){(e==null?void 0:e.sliceIndex)!==void 0&&this.scroll(e.sliceIndex-this.targetImageIdIndex);return}const{referencedImageId:r}=e;e.referencedImageURI||(e.referencedImageURI=_r(r));const{referencedImageURI:n}=e,i=this.imageKeyToIndexMap.get(n);if(i===void 0){o9.error(`No image URI found for ${n}`);return}this.scroll(i-this.targetImageIdIndex)}getViewReferenceId(e={}){const{sliceIndex:r=this.currentImageIdIndex}=e;return`imageId:${this.imageIds[r]}`}getSliceIndexForImage(e){if(e){if(typeof e=="string")return this.imageKeyToIndexMap.get(e);if(e.referencedImageId)return this.imageKeyToIndexMap.get(e.referencedImageId)}}getCPUFallbackError(e){return new Error(`method ${e} cannot be used during CPU Fallback mode`)}fillWithBackgroundColor(){const e=this.getRenderingEngine();e&&e.fillCanvasWithBackgroundColor(this.canvas,this.options.background)}unsetColormapCPU(){delete this._cpuFallbackEnabledElement.viewport.colormap,this._cpuFallbackEnabledElement.renderingTools={},this.cpuRenderingInvalidated=!0,this.fillWithBackgroundColor(),this.render()}setColormapCPU(e){this.colormap=e;const r=f1(e.name);this._cpuFallbackEnabledElement.viewport.colormap=r,this._cpuFallbackEnabledElement.renderingTools={},this.fillWithBackgroundColor(),this.cpuRenderingInvalidated=!0,this.render();const n={viewportId:this.id,colormap:e};it(this.element,et.COLORMAP_MODIFIED,n)}setColormapGPU(e){const i=this.getDefaultActor().actor.getProperty(),o=i.getRGBTransferFunction(),a=f1(e.name)||u1.getPresetByName(e.name);if(o)o.applyColorMap(a),o.setMappingRange(this.voiRange.lower,this.voiRange.upper),i.setRGBTransferFunction(0,o);else{const c=eu.newInstance();c.applyColorMap(a),c.setMappingRange(this.voiRange.lower,this.voiRange.upper),i.setRGBTransferFunction(0,c)}this.colormap=e,this.render();const s={viewportId:this.id,colormap:e};it(this.element,et.COLORMAP_MODIFIED,s)}unsetColormapGPU(){throw new Error("unsetColormapGPU not implemented.")}_getImagePlaneModule(e){var n,i;const r=Ak(e);return this.hasPixelSpacing=!r.usingDefaultValues||((n=this.calibration)==null?void 0:n.scale)>0||((i=this.calibration)==null?void 0:i.rowPixelSpacing)>0,this.calibration||(this.calibration=r.calibration),r}isInAcquisitionPlane(){return!0}}class oE extends fr{constructor(e){super(e),this.getNumberOfSlices=()=>1,this.getRotation=()=>0,this.getCurrentImageIdIndex=()=>0,this.getCurrentImageId=()=>null,this.resetCameraForResize=()=>this.resetCamera({resetPan:!0,resetZoom:!0,resetToCenter:!0});const{parallelProjection:r,orientation:n}=this.options,i=this.getVtkActiveCamera();r!=null&&i.setParallelProjection(r),n&&n!==Cd.ACQUISITION&&this.applyViewOrientation(n)}isInAcquisitionPlane(){return!1}resetCamera({resetPan:e=!0,resetZoom:r=!0,resetToCenter:n=!0}={}){super.resetCamera({resetPan:e,resetZoom:r,resetToCenter:n});const i=this.getVtkActiveCamera();return i.getParallelProjection()?i.setClippingRange(-Wr.MAXIMUM_RAY_DISTANCE,Wr.MAXIMUM_RAY_DISTANCE):i.setClippingRange(Wr.MINIMUM_SLAB_THICKNESS,Wr.MAXIMUM_RAY_DISTANCE),this.getRenderer().resetCameraClippingRange(),!0}setSlabThickness(e,r){return null}setBlendMode(e,r,n){return null}resetProperties(e){const r=e?this.getActor(e):this.getDefaultActor();if(!r)throw new Error(`No actor found for the given volumeId: ${e}`);r.slabThickness&&(r.slabThickness=Wr.MINIMUM_SLAB_THICKNESS,this.viewportProperties.slabThickness=void 0,this.updateClippingPlanesForActors(this.getCamera())),e||(e=this.getVolumeId());const n=$e.getVolume(e);if(!n)throw new Error(`imageVolume with id: ${e} does not exist in cache`);if(Q4(r.actor,n),Qs(r)){const i=r.actor.getProperty().getRGBTransferFunction(0);vw(i,this.initialTransferFunctionNodes)}this.setCamera(this.initialCamera),it(this.element,et.VOI_MODIFIED,super.getVOIModifiedEventDetail(e))}getSliceIndex(){return null}setCamera(e){super.setCamera(e),this.getRenderer().resetCameraClippingRange(),this.render()}setCameraClippingRange(){const e=this.getVtkActiveCamera();e.getParallelProjection()?e.setClippingRange(-Wr.MAXIMUM_RAY_DISTANCE,Wr.MAXIMUM_RAY_DISTANCE):e.setClippingRange(Wr.MINIMUM_SLAB_THICKNESS,Wr.MAXIMUM_RAY_DISTANCE)}resetSlabThickness(){return null}}async function Hk(t,e,r,n=!1,i=!1){r.forEach(a=>{const s=t.getViewport(a);if(!s)throw new Error(`Viewport with Id ${a} does not exist`);if(!(s instanceof fr))throw new Error("setVolumesForViewports only supports VolumeViewport and VolumeViewport3D")});const o=r.map(async a=>{await t.getViewport(a).setVolumes(e,n,i)});await Promise.all(o)}async function Kk(t,e,r,n=!1,i=!1){for(const a of r){const s=t.getViewport(a);if(!s)throw new Error(`Viewport with Id ${a} does not exist`);if(!(s instanceof fr)){console.warn(`Viewport with Id ${a} is not a BaseVolumeViewport. Cannot add volume to this viewport.`);return}}const o=r.map(async a=>{await t.getViewport(a).addVolumes(e,n,i)});await Promise.all(o)}function qk(t,e,r){for(const n of r){const i=t.getViewport(n);if(!i)throw new Error(`Viewport with Id ${n} does not exist`);if(!i.addImages){console.warn(`Viewport with Id ${n} does not have addImages. Cannot add image segmentation to this viewport.`);return}}r.forEach(n=>{t.getViewport(n).addImages(e)})}class Cle{constructor(e){this.opacity=.4,this.outlineOpacity=.4,this.transferFunction=[],this.actor=e}setRGBTransferFunction(e,r){this.transferFunction[e]=r}setScalarOpacity(e){}setInterpolationTypeToNearest(){}setUseLabelOutline(){}setLabelOutlineOpacity(e){this.outlineOpacity=e}setLabelOutlineThickness(){}getColor(e){const r=this.transferFunction[0],n=r.getRedValue(e),i=r.getGreenValue(e),o=r.getBlueValue(e);return[n,i,o,this.opacity]}}class Sle{constructor(e){this.actor=e}getInputData(){return this.actor.getImage()}}class Tle{constructor(e,r){this.canvasProperties=new Cle(this),this.visibility=!1,this.mapper=new Sle(this),this.className="CanvasActor",this.derivedImage=r,this.viewport=e}renderRLE(e,r,n){const{width:i,height:o}=this.image;let{canvas:a}=this;(!a||a.width!==i||a.height!==o)&&(this.canvas=a=new window.OffscreenCanvas(i,o));const s=a.getContext("2d"),c=s.createImageData(i,o),{data:l}=c;l.fill(0);const{map:f}=n;let u=1/0,d=1/0,h=-1/0,g=-1/0;for(let y=0;y<o;y++){const m=f.getRun(y,0);if(!m)continue;d=Math.min(d,y),g=Math.max(g,y);const w=y*i<<2;let x;for(const C of m){const{start:S,end:T,value:_}=C;if(_===0){x||(x=[]),x.push(m.indexOf(C));continue}u=Math.min(u,S),h=Math.max(h,T);const E=this.canvasProperties.getColor(_).map(D=>D*255);let b=w+(S<<2);for(let D=S;D<T;D++)l[b++]=E[0],l[b++]=E[1],l[b++]=E[2],l[b++]=E[3]}}if(u>i)return;const p=h-u,v=g-d;s.putImageData(c,0,0,u-1,d-1,p+2,v+2),r.drawImage(a,u,d,p,v,u,d,p,v)}setMapper(e){this.mapper=e}render(e,r){if(!this.visibility)return;const n=this.image||this.getImage(),{width:i,height:o}=n,a=n.getScalarData();if(!a)return;const{voxelManager:s}=n;if(s&&s.map.getRun){this.renderRLE(e,r,s);return}let{canvas:c}=this;(!c||c.width!==i||c.height!==o)&&(this.canvas=c=new window.OffscreenCanvas(i,o));const l=c.getContext("2d"),f=l.createImageData(i,o),{data:u}=f;let d=0,h=0,g=1/0,p=1/0,v=-1/0,y=-1/0;for(let x=0;x<o;x++)for(let C=0;C<i;C++){const S=a[d++];if(S){g=Math.min(C,g),p=Math.min(x,p),v=Math.max(C,v),y=Math.max(x,y);const T=this.canvasProperties.getColor(S);u[h]=T[0]*255,u[h+1]=T[1]*255,u[h+2]=T[2]*255,u[h+3]=127}h+=4}if(g>i)return;const m=v-g+1,w=y-p+1;l.putImageData(f,0,0,g,p,m,w),r.drawImage(c,g,p,m,w,g,p,m,w)}getClassName(){return this.className}getProperty(){return this.canvasProperties}setVisibility(e){this.visibility=e}getMapper(){return this.mapper}isA(e){return e===this.className}getImage(){if(this.image)return this.image;this.image={...this.derivedImage};const e=this.viewport.getImageData();return Object.assign(this.image,{worldToIndex:r=>e.imageData.worldToIndex(r),indexToWorld:(r,n)=>e.imageData.indexToWorld(r,n),getDimensions:()=>e.dimensions,getScalarData:()=>{var r;return(r=this.derivedImage)==null?void 0:r.getPixelData()},getDirection:()=>e.direction,getSpacing:()=>e.spacing,setOrigin:()=>null,setDerivedImage:r=>{this.derivedImage=r,this.image=null},modified:()=>null}),this.image}}const tb=class tb{static imageIdToFrames(e){const r=e.match(this.frameRangeExtractor);if(!r||!r[2])return null;const n=r[2].split("-").map(i=>Number(i));return n.length===1?n[0]:n}static imageIdToFrameEnd(e){const r=this.imageIdToFrames(e);return Array.isArray(r)?r[1]:r}static imageIdToFrameStart(e){const r=this.imageIdToFrames(e);return Array.isArray(r)?r[0]:r}static framesToString(e){return Array.isArray(e)?`${e[0]}-${e[1]}`:String(e)}static framesToImageId(e,r){const n=e.match(this.frameRangeExtractor);if(!n||!n[2])return null;const i=this.framesToString(r);return e.replace(this.frameRangeExtractor,`${n[1]}${i}`)}};tb.frameRangeExtractor=/(\/frames\/|[&?]frameNumber=)([^/&?]*)/i;let eh=tb;const Rp=class Rp extends bd{constructor(e){super({...e,canvas:e.canvas||Bc(e.element)}),this.videoWidth=0,this.videoHeight=0,this.loop=!0,this.mute=!0,this.isPlaying=!1,this.scrollSpeed=1,this.playbackRate=1,this.frameRange=[0,0],this.fps=30,this.videoCamera={panWorld:[0,0],parallelScale:1},this.voiRange={lower:0,upper:255},this.getProperties=()=>({loop:this.videoElement.loop,muted:this.videoElement.muted,playbackRate:this.playbackRate,scrollSpeed:this.scrollSpeed,voiRange:{...this.voiRange}}),this.getMiddleSliceData=()=>{throw new Error("Method not implemented.")},this.useCustomRenderingPipeline=!0,this.resetCamera=()=>(this.refreshRenderValues(),this.canvasContext.fillRect(0,0,this.canvas.width,this.canvas.height),this.isPlaying||this.renderFrame(),!0),this.getNumberOfSlices=()=>{const r=Math.round(this.videoElement.duration*this.fps/this.scrollSpeed);return isNaN(r)?this.numberOfFrames:r},this.getFrameOfReferenceUID=()=>this.videoElement.src,this.resize=()=>{const r=this.canvas,{clientWidth:n,clientHeight:i}=r;(r.width!==n||r.height!==i)&&(r.width=n,r.height=i),this.refreshRenderValues(),this.isPlaying||this.renderFrame()},this.canvasToWorld=(r,n=[0,0,0])=>{const i=this.videoCamera.panWorld,o=this.getWorldToCanvasRatio(),a=[i[0]*o,i[1]*o],s=[r[0]-a[0],r[1]-a[1]];return n.splice(0,2,s[0]/o,s[1]/o),n},this.worldToCanvas=r=>{const n=this.videoCamera.panWorld,i=this.getWorldToCanvasRatio();return[(r[0]+n[0])*i,(r[1]+n[1])*i]},this.getRotation=()=>0,this.canvasToIndex=r=>{const n=this.getTransform();return n.invert(),n.transformPoint(r.map(i=>i*devicePixelRatio))},this.indexToCanvas=r=>this.getTransform().transformPoint(r).map(i=>i/devicePixelRatio),this.customRenderViewportToCanvas=()=>{this.renderFrame()},this.renderFrame=()=>{var s;const r=window.devicePixelRatio||1,i=this.getTransform().getMatrix(),o=this.canvasContext;o.resetTransform(),o.clearRect(0,0,this.canvas.width,this.canvas.height),o.transform(i[0]/r,i[1]/r,i[2]/r,i[3]/r,i[4]/r,i[5]/r),o.drawImage(this.videoElement,0,0,this.videoWidth,this.videoHeight);for(const c of this.getActors())c.actor.render(this,this.canvasContext);this.canvasContext.resetTransform(),it(this.element,et.STACK_NEW_IMAGE,{element:this.element,viewportId:this.id,viewport:this,renderingEngineId:this.renderingEngineId,time:this.videoElement.currentTime,duration:this.videoElement.duration}),it(this.element,et.IMAGE_RENDERED,{element:this.element,viewportId:this.id,viewport:this,imageIndex:this.getCurrentImageIdIndex(),numberOfSlices:this.numberOfFrames,renderingEngineId:this.renderingEngineId,time:this.videoElement.currentTime,duration:this.videoElement.duration}),(s=this.initialRender)==null||s.call(this);const a=this.getFrameNumber();this.isPlaying&&(a<this.frameRange[0]?this.setFrameNumber(this.frameRange[0]):a>this.frameRange[1]&&(this.loop?this.setFrameNumber(this.frameRange[0]):this.pause()))},this.renderWhilstPlaying=()=>{this.renderFrame(),this.isPlaying&&requestAnimationFrame(this.renderWhilstPlaying)},this.canvasContext=this.canvas.getContext("2d"),this.renderingEngineId=e.renderingEngineId,this.element.setAttribute("data-viewport-uid",this.id),this.element.setAttribute("data-rendering-engine-uid",this.renderingEngineId),this.videoElement=document.createElement("video"),this.videoElement.muted=this.mute,this.videoElement.loop=this.loop,this.videoElement.autoplay=!0,this.videoElement.crossOrigin="anonymous",this.addEventListeners(),this.resize()}static get useCustomRenderingPipeline(){return!0}addEventListeners(){this.canvas.addEventListener(et.ELEMENT_DISABLED,this.elementDisabledHandler)}removeEventListeners(){this.canvas.removeEventListener(et.ELEMENT_DISABLED,this.elementDisabledHandler)}elementDisabledHandler(){this.removeEventListeners(),this.videoElement.remove()}getImageDataMetadata(e){const r=typeof e=="string"?e:e.imageId,n=ct(jo.IMAGE_PLANE,r);let i=n.rowCosines,o=n.columnCosines;(n.usingDefaultValues||i==null||o==null)&&(i=[1,0,0],o=[0,1,0]);const s=Tt(i[0],i[1],i[2]),c=Tt(o[0],o[1],o[2]),{rows:l,columns:f}=n,u=Ke();Tn(u,s,c);let d=n.imagePositionPatient;d==null&&(d=[0,0,0]);const h=n.columnPixelSpacing||1,g=n.rowPixelSpacing||1,p=n.columns,v=n.rows,y=1,m=1;return this.hasPixelSpacing=!!n.columnPixelSpacing,{bitsAllocated:8,numberOfComponents:3,origin:d,rows:l,columns:f,direction:[...s,...c,...u],dimensions:[p,v,m],spacing:[h,g,y],hasPixelSpacing:this.hasPixelSpacing,numVoxels:p*v*m,imagePlaneModule:n}}setDataIds(e,r){var n;this.setVideo(e[0],(((n=r.viewReference)==null?void 0:n.sliceIndex)||0)+1)}setVideo(e,r){this.imageId=Array.isArray(e)?e[0]:e;const n=ct(jo.IMAGE_URL,e);if(!(n!=null&&n.rendered))throw new Error(`Video Image ID ${e} does not have a rendered video view`);const{rendered:i}=n,o=ct(jo.GENERAL_SERIES,e);this.modality=o==null?void 0:o.Modality,this.metadata=this.getImageDataMetadata(e);let{cineRate:a,numberOfFrames:s}=ct(jo.CINE,e);return this.numberOfFrames=s,this.setVideoURL(i).then(()=>((!s||s===1)&&(s=Math.round(this.videoElement.duration*(a||30))),a||(a=Math.round(s/this.videoElement.duration)),this.fps=a,this.numberOfFrames=s,this.setFrameRange([1,s]),this.initialRender=()=>{this.initialRender=null,this.pause(),this.setFrameNumber(r||1)},new Promise(c=>{window.setTimeout(()=>{this.setFrameNumber(r||1),c(this)},25)})))}async setVideoURL(e){return new Promise(r=>{this.videoElement.src=e,this.videoElement.preload="auto";const n=()=>{this.videoWidth=this.videoElement.videoWidth,this.videoHeight=this.videoElement.videoHeight,this.videoElement.removeEventListener("loadedmetadata",n),this.refreshRenderValues(),r(!0)};this.videoElement.addEventListener("loadedmetadata",n)})}getImageIds(){const e=new Array(this.numberOfFrames),r=this.imageId.replace(/[0-9]+$/,"");for(let n=0;n<this.numberOfFrames;n++)e[n]=`${r}${n+1}`;return e}togglePlayPause(){return this.isPlaying?(this.pause(),!1):(this.play(),!0)}async play(){try{this.isPlaying||(this.isPlaying=!0,await this.videoElement.play(),this.renderWhilstPlaying())}catch{}}pause(){try{this.isPlaying=!1,this.videoElement.pause()}catch{}}async scroll(e=1){await this.pause();const r=this.videoElement,n=this.renderFrame,o=r.currentTime+e*this.scrollSpeed/this.fps;r.currentTime=o;const a=s=>{n(),r.removeEventListener("seeked",a)};r.addEventListener("seeked",a)}async start(){const e=this.videoElement,r=this.renderFrame;if(e.currentTime=0,e.paused){const n=i=>{r(),e.removeEventListener("seeked",n)};e.addEventListener("seeked",n)}}async end(){const e=this.videoElement,r=this.renderFrame;if(e.currentTime=e.duration,e.paused){const n=i=>{r(),e.removeEventListener("seeked",n)};e.addEventListener("seeked",n)}}async setTime(e){const r=this.videoElement,n=this.renderFrame;if(r.currentTime=e,r.paused){const i=o=>{n(),r.removeEventListener("seeked",i)};r.addEventListener("seeked",i)}}getSliceViewInfo(){throw new Error("Method not implemented.")}async setFrameNumber(e){this.setTime((e-1)/this.fps)}setFrameRange(e){if(!e){this.frameRange=[1,this.numberOfFrames];return}e.length!==2||e[0]===e[1]||(this.frameRange=[e[0],e[1]])}getSliceIndexForImage(e){if(e){if(typeof e=="string")return eh.imageIdToFrameStart(e);if(e.referencedImageId)return eh.imageIdToFrameStart(e.referencedImageId)}}getFrameRange(){return this.frameRange}setProperties(e){e.loop!==void 0&&(this.videoElement.loop=e.loop),e.muted!==void 0&&(this.videoElement.muted=e.muted),e.playbackRate!==void 0&&this.setPlaybackRate(e.playbackRate),e.scrollSpeed!==void 0&&this.setScrollSpeed(e.scrollSpeed),e.voiRange&&this.setVOI(e.voiRange)}setPlaybackRate(e=1){if(this.playbackRate=e,e<.0625){this.pause();return}this.videoElement&&(this.videoElement.playbackRate=e,this.play())}setScrollSpeed(e=1,r=i1.FRAME){this.scrollSpeed=r===i1.SECOND?e*this.fps:e}resetProperties(){this.setProperties({loop:!1,muted:!0,voiRange:{lower:0,upper:255}})}getScalarData(){var o;if(((o=this.scalarData)==null?void 0:o.frameNumber)===this.getFrameNumber())return this.scalarData;if(!this.videoElement||!this.videoElement.videoWidth||!this.videoElement.videoHeight){console.debug("Video not ready yet, returning empty scalar data");const a=new Uint8ClampedArray;return a.getRange=()=>[0,255],a.frameNumber=-1,a}const e=document.createElement("canvas");e.width=this.videoElement.videoWidth,e.height=this.videoElement.videoHeight;const r=e.getContext("2d");r.drawImage(this.videoElement,0,0);const i=r.getImageData(0,0,e.width,e.height).data;return i.getRange=()=>[0,255],i.frameNumber=this.getFrameNumber(),this.scalarData=i,i}getImageData(){const{metadata:e}=this,r=e.spacing,n={getDirection:()=>e.direction,getDimensions:()=>e.dimensions,getRange:()=>[0,255],getScalarData:()=>this.getScalarData(),getSpacing:()=>e.spacing,worldToIndex:o=>{const a=this.worldToCanvas(o),s=this.canvasToIndex(a);return[s[0],s[1],0]},indexToWorld:(o,a)=>{const s=this.indexToCanvas([o[0],o[1]]);return this.canvasToWorld(s,a)}},i={dimensions:e.dimensions,spacing:r,origin:e.origin,direction:e.direction,metadata:{Modality:this.modality,FrameOfReferenceUID:e.FrameOfReferenceUID},getScalarData:()=>this.getScalarData(),scalarData:this.getScalarData(),imageData:n,voxelManager:{forEach:(o,a)=>j4(a.imageData,{pointInShapeFn:a.isInObject??(()=>!0),callback:o,boundsIJK:a.boundsIJK,returnPoints:a.returnPoints??!1})},hasPixelSpacing:this.hasPixelSpacing,calibration:this.calibration,preScale:{scaled:!1}};return Object.defineProperty(n,"scalarData",{get:()=>this.getScalarData(),enumerable:!0}),i}hasImageURI(e){const r=e.match(Rp.frameRangeExtractor),n=r?e.substring(0,r.index):e;return this.imageId.includes(n)}setVOI(e){this.voiRange=e;const r=this.setColorTransform(e,this.averageWhite);this.canvas.style.filter=r}setWindowLevel(e=256,r=128){const n=r-e/2,i=r+e/2-1;this.setVOI({lower:n,upper:i}),this.setColorTransform({lower:n,upper:i},this.averageWhite)}setAverageWhite(e){this.averageWhite=e,this.setColorTransform(this.voiRange,e)}setCamera(e){const{parallelScale:r,focalPoint:n}=e;if(r&&(this.videoCamera.parallelScale=this.element.clientHeight/2/r),n!==void 0){const i=this.worldToCanvas(n),o=[this.element.clientWidth/2,this.element.clientHeight/2],a=[(i[0]-o[0])/this.videoCamera.parallelScale,(i[1]-o[1])/this.videoCamera.parallelScale];this.videoCamera.panWorld=[this.videoCamera.panWorld[0]-a[0],this.videoCamera.panWorld[1]-a[1]]}this.canvasContext.fillStyle="rgba(0,0,0,1)",this.canvasContext.fillRect(0,0,this.canvas.width,this.canvas.height),this.isPlaying||this.renderFrame()}getCurrentImageId(e=this.getCurrentImageIdIndex()){return this.imageId.replace("/frames/1",`/frames/${e+1}`)}getViewReferenceId(e={}){const{sliceIndex:r}=e;return r===void 0?`videoId:${this.getCurrentImageId()}`:Array.isArray(r)?`videoId:${this.imageId.substring(0,this.imageId.length-1)}${r[0]+1}-${r[1]+1}`:`videoId:${this.imageId.replace("/frames/1",`/frames/${1+r}`)}`}isReferenceViewable(e,r={}){let{imageURI:n}=r;const{referencedImageId:i,sliceIndex:o,multiSliceReference:a}=e;if(!super.isReferenceViewable(e))return!1;const s=this.getCurrentImageId();if(!n){const d=s.indexOf(":");n=s.substring(d+1,s.length-1)}if(r.withNavigation)return!0;const c=this.getSliceIndex();if(a){const d=eh.imageIdToFrameEnd(a.referencedImageId);return c>=o&&c<=d}if(o!==void 0)return c===o;if(!i)return!1;const l=i.match(Rp.frameRangeExtractor);if(!l||!l[2])return!0;const f=l[2].split("-").map(d=>Number(d)),u=c+1;return f[0]<=u&&u<=(f[1]??f[0])}setViewReference(e){typeof e.sliceIndex=="number"?this.setFrameNumber(e.sliceIndex+1):Array.isArray(e.sliceIndex)&&this.setFrameRange(e.sliceIndex)}getViewReference(e){const r=(e==null?void 0:e.sliceIndex)??(this.isPlaying?this.frameRange[0]:this.getCurrentImageIdIndex()),n=(e==null?void 0:e.rangeEndSliceIndex)??(this.isPlaying?this.frameRange[1]-1:void 0),i=n>r?{sliceIndex:n,referencedImageId:this.getCurrentImageId(n)}:void 0;return{...super.getViewReference(e),referencedImageId:this.getViewReferenceId(e),sliceIndex:r,multiSliceReference:i}}getFrameNumber(){return 1+this.getCurrentImageIdIndex()}getCurrentImageIdIndex(){return Math.round(this.videoElement.currentTime*this.fps)}getSliceIndex(){return this.getCurrentImageIdIndex()/this.scrollSpeed}getCamera(){const{parallelScale:e}=this.videoCamera,r=[this.element.clientWidth/2,this.element.clientHeight/2];return{parallelProjection:!0,focalPoint:this.canvasToWorld(r),position:[0,0,0],viewUp:[0,-1,0],parallelScale:this.element.clientHeight/2/e,viewPlaneNormal:[0,0,1]}}getFrameRate(){return this.fps}getPan(){const e=this.videoCamera.panWorld;return[e[0],e[1]]}refreshRenderValues(){let e=this.canvas.offsetWidth/this.videoWidth;this.videoHeight*e>this.canvas.height&&(e=this.canvas.offsetHeight/this.videoHeight);const r=Math.floor(this.videoWidth*e),n=Math.floor(this.videoHeight*e),i=(this.canvas.offsetWidth-r)/2,o=(this.canvas.offsetHeight-n)/2,a=i/e,s=o/e;this.videoCamera.panWorld=[a,s],this.videoCamera.parallelScale=e}getWorldToCanvasRatio(){return this.videoCamera.parallelScale}getCanvasToWorldRatio(){return 1/this.videoCamera.parallelScale}getTransform(){const e=this.videoCamera.panWorld,r=window.devicePixelRatio||1,n=this.getWorldToCanvasRatio(),i=this.getCanvasToWorldRatio(),o=[this.canvas.offsetWidth/2,this.canvas.offsetHeight/2],a=[o[0]*i,o[1]*i],s=new Kh;return s.scale(r,r),s.translate(o[0],o[1]),s.scale(n,n),s.translate(e[0],e[1]),s.translate(-a[0],-a[1]),s}updateCameraClippingPlanesAndRange(){}addImages(e){const r=this.getActors();e.forEach(n=>{const{imageId:i,...o}=n,a=$e.getImage(i),s=this.createActorMapper(a),c=n.actorUID??gn();s&&(r.push({uid:c,actor:s,referencedId:i,...o}),n.callback&&n.callback({imageActor:s,imageId:i}))}),this.setActors(r)}createActorMapper(e){return new Tle(this,e)}};Rp.frameRangeExtractor=/(\/frames\/|[&?]frameNumber=)([^/&?]*)/i;let _h=Rp;const _le=`
|
||
.DicomMicroscopyViewer {
|
||
--ol-partial-background-color: rgba(127, 127, 127, 0.7);
|
||
--ol-foreground-color: #000000;
|
||
--ol-subtle-foreground-color: #000;
|
||
--ol-subtle-background-color: rgba(78, 78, 78, 0.5);
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-box {
|
||
box-sizing: border-box;
|
||
border-radius: 2px;
|
||
border: 1.5px solid var(--ol-background-color);
|
||
background-color: var(--ol-partial-background-color);
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-mouse-position {
|
||
top: 8px;
|
||
right: 8px;
|
||
position: absolute;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-scale-line {
|
||
background: var(--ol-partial-background-color);
|
||
border-radius: 4px;
|
||
bottom: 8px;
|
||
left: 8px;
|
||
padding: 2px;
|
||
position: absolute;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-scale-line-inner {
|
||
border: 1px solid var(--ol-subtle-foreground-color);
|
||
border-top: none;
|
||
color: var(--ol-foreground-color);
|
||
font-size: 10px;
|
||
text-align: center;
|
||
margin: 1px;
|
||
will-change: contents, width;
|
||
transition: all 0.25s;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-scale-bar {
|
||
position: absolute;
|
||
bottom: 8px;
|
||
left: 8px;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-scale-bar-inner {
|
||
display: flex;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-scale-step-marker {
|
||
width: 1px;
|
||
height: 15px;
|
||
background-color: var(--ol-foreground-color);
|
||
float: right;
|
||
z-index: 10;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-scale-step-text {
|
||
position: absolute;
|
||
bottom: -5px;
|
||
font-size: 10px;
|
||
z-index: 11;
|
||
color: var(--ol-foreground-color);
|
||
text-shadow:
|
||
-1.5px 0 var(--ol-partial-background-color),
|
||
0 1.5px var(--ol-partial-background-color),
|
||
1.5px 0 var(--ol-partial-background-color),
|
||
0 -1.5px var(--ol-partial-background-color);
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-scale-text {
|
||
position: absolute;
|
||
font-size: 12px;
|
||
text-align: center;
|
||
bottom: 25px;
|
||
color: var(--ol-foreground-color);
|
||
text-shadow:
|
||
-1.5px 0 var(--ol-partial-background-color),
|
||
0 1.5px var(--ol-partial-background-color),
|
||
1.5px 0 var(--ol-partial-background-color),
|
||
0 -1.5px var(--ol-partial-background-color);
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-scale-singlebar {
|
||
position: relative;
|
||
height: 10px;
|
||
z-index: 9;
|
||
box-sizing: border-box;
|
||
border: 1px solid var(--ol-foreground-color);
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-scale-singlebar-even {
|
||
background-color: var(--ol-subtle-foreground-color);
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-scale-singlebar-odd {
|
||
background-color: var(--ol-background-color);
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-unsupported {
|
||
display: none;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-viewport,
|
||
.DicomMicroscopyViewer .ol-unselectable {
|
||
-webkit-touch-callout: none;
|
||
-webkit-user-select: none;
|
||
-moz-user-select: none;
|
||
user-select: none;
|
||
-webkit-tap-highlight-color: transparent;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-viewport canvas {
|
||
all: unset;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-selectable {
|
||
-webkit-touch-callout: default;
|
||
-webkit-user-select: text;
|
||
-moz-user-select: text;
|
||
user-select: text;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-grabbing {
|
||
cursor: -webkit-grabbing;
|
||
cursor: -moz-grabbing;
|
||
cursor: grabbing;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-grab {
|
||
cursor: move;
|
||
cursor: -webkit-grab;
|
||
cursor: -moz-grab;
|
||
cursor: grab;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-control {
|
||
position: absolute;
|
||
background-color: var(--ol-subtle-background-color);
|
||
border-radius: 4px;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-zoom {
|
||
top: 0.5em;
|
||
left: 0.5em;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-rotate {
|
||
top: 0.5em;
|
||
right: 0.5em;
|
||
transition:
|
||
opacity 0.25s linear,
|
||
visibility 0s linear;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-rotate.ol-hidden {
|
||
opacity: 0;
|
||
visibility: hidden;
|
||
transition:
|
||
opacity 0.25s linear,
|
||
visibility 0s linear 0.25s;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-zoom-extent {
|
||
top: 4.643em;
|
||
left: 0.5em;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-full-screen {
|
||
right: 0.5em;
|
||
top: 0.5em;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-control button {
|
||
display: block;
|
||
margin: 1px;
|
||
padding: 0;
|
||
color: var(--ol-subtle-foreground-color);
|
||
font-weight: bold;
|
||
text-decoration: none;
|
||
font-size: inherit;
|
||
text-align: center;
|
||
height: 1.375em;
|
||
width: 1.375em;
|
||
line-height: 0.4em;
|
||
background-color: var(--ol-background-color);
|
||
border: none;
|
||
border-radius: 2px;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-control button::-moz-focus-inner {
|
||
border: none;
|
||
padding: 0;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-zoom-extent button {
|
||
line-height: 1.4em;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-compass {
|
||
display: block;
|
||
font-weight: normal;
|
||
will-change: transform;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-touch .ol-control button {
|
||
font-size: 1.5em;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-touch .ol-zoom-extent {
|
||
top: 5.5em;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-control button:hover,
|
||
.DicomMicroscopyViewer .ol-control button:focus {
|
||
text-decoration: none;
|
||
outline: 1px solid var(--ol-subtle-foreground-color);
|
||
color: var(--ol-foreground-color);
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-zoom .ol-zoom-in {
|
||
border-radius: 2px 2px 0 0;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-zoom .ol-zoom-out {
|
||
border-radius: 0 0 2px 2px;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-attribution {
|
||
text-align: right;
|
||
bottom: 0.5em;
|
||
right: 0.5em;
|
||
max-width: calc(100% - 1.3em);
|
||
display: flex;
|
||
flex-flow: row-reverse;
|
||
align-items: center;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-attribution a {
|
||
color: var(--ol-subtle-foreground-color);
|
||
text-decoration: none;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-attribution ul {
|
||
margin: 0;
|
||
padding: 1px 0.5em;
|
||
color: var(--ol-foreground-color);
|
||
text-shadow: 0 0 2px var(--ol-background-color);
|
||
font-size: 12px;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-attribution li {
|
||
display: inline;
|
||
list-style: none;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-attribution li:not(:last-child):after {
|
||
content: ' ';
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-attribution img {
|
||
max-height: 2em;
|
||
max-width: inherit;
|
||
vertical-align: middle;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-attribution button {
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-attribution.ol-collapsed ul {
|
||
display: none;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-attribution:not(.ol-collapsed) {
|
||
background: var(--ol-partial-background-color);
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-attribution.ol-uncollapsible {
|
||
bottom: 0;
|
||
right: 0;
|
||
border-radius: 4px 0 0;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-attribution.ol-uncollapsible img {
|
||
margin-top: -0.2em;
|
||
max-height: 1.6em;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-attribution.ol-uncollapsible button {
|
||
display: none;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-zoomslider {
|
||
top: 4.5em;
|
||
left: 0.5em;
|
||
height: 200px;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-zoomslider button {
|
||
position: relative;
|
||
height: 10px;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-touch .ol-zoomslider {
|
||
top: 5.5em;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-overviewmap {
|
||
left: 0.5em;
|
||
bottom: 0.5em;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-overviewmap.ol-uncollapsible {
|
||
bottom: 0;
|
||
left: 0;
|
||
border-radius: 0 4px 0 0;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-overviewmap .ol-overviewmap-map,
|
||
.DicomMicroscopyViewer .ol-overviewmap button {
|
||
display: block;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-overviewmap .ol-overviewmap-map {
|
||
border: 1px solid var(--ol-subtle-foreground-color);
|
||
height: 150px;
|
||
width: 150px;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-overviewmap:not(.ol-collapsed) button {
|
||
bottom: 0;
|
||
left: 0;
|
||
position: absolute;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-overviewmap.ol-collapsed .ol-overviewmap-map,
|
||
.DicomMicroscopyViewer .ol-overviewmap.ol-uncollapsible button {
|
||
display: none;
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-overviewmap:not(.ol-collapsed) {
|
||
background: var(--ol-subtle-background-color);
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-overviewmap-box {
|
||
border: 0.5px dotted var(--ol-subtle-foreground-color);
|
||
}
|
||
|
||
.DicomMicroscopyViewer .ol-overviewmap .ol-overviewmap-box:hover {
|
||
cursor: move;
|
||
}
|
||
|
||
@layout-header-background: #007ea3;
|
||
@primary-color: #007ea3;
|
||
@processing-color: #8cb8c6;
|
||
@success-color: #3f9c35;
|
||
@warning-color: #eeaf30;
|
||
@error-color: #96172e;
|
||
@font-size-base: 14px;
|
||
|
||
.DicomMicroscopyViewer .ol-tooltip {
|
||
font-size: 16px !important;
|
||
}
|
||
`;let Dg=null;const a9=Symbol.for("map"),s9=Symbol.for("affine"),Ele="postrender",R0=class R0 extends bd{constructor(e){super({...e,canvas:e.canvas||Bc(e.element)}),this.internalCamera={rotation:0,centerIndex:[0,0],extent:[0,-2,1,-1],xSpacing:1,ySpacing:1,resolution:1,zoom:1},this.voiRange={lower:0,upper:255},this.getProperties=()=>({voiRange:{...this.voiRange}}),this.resetCamera=()=>!0,this.getNumberOfSlices=()=>1,this.getFrameOfReferenceUID=()=>this.frameOfReferenceUID,this.resize=()=>{const n=this.canvas,{clientWidth:i,clientHeight:o}=n;(n.width!==i||n.height!==o)&&(n.width=i,n.height=o),this.refreshRenderValues()},this.canvasToWorld=n=>{if(!this.metadata)return;const i=this.canvasToIndex(n);return i[1]=-i[1],this.indexToWorld(i)},this.worldToCanvas=n=>{if(!this.metadata)return;const i=this.worldToIndex(n);return i[1]=-i[1],this.indexToCanvas([i[0],i[1],0])},this.postrender=()=>{this.refreshRenderValues(),it(this.element,et.IMAGE_RENDERED,{element:this.element,viewportId:this.id,viewport:this,renderingEngineId:this.renderingEngineId})},this.getRotation=()=>0,this.canvasToIndex=n=>{const i=this.getTransform();i.invert();const o=i.transformPoint(n.map(a=>a*devicePixelRatio));return[o[0],o[1],0]},this.indexToCanvas=n=>this.getTransform().transformPoint([n[0],n[1]]).map(o=>o/devicePixelRatio),this.customRenderViewportToCanvas=()=>{},this.getImageIds=()=>[this.imageIds[0]],this.renderingEngineId=e.renderingEngineId,this.element.setAttribute("data-viewport-uid",this.id),this.element.setAttribute("data-rendering-engine-uid",this.renderingEngineId),this.element.style.position="relative",this.microscopyElement=document.createElement("div"),this.microscopyElement.setAttribute("class","DicomMicroscopyViewer"),this.microscopyElement.id=gn(),this.microscopyElement.innerText="Initial",this.microscopyElement.style.background="grey",this.microscopyElement.style.width="100%",this.microscopyElement.style.height="100%",this.microscopyElement.style.position="absolute",this.microscopyElement.style.left="0",this.microscopyElement.style.top="0";const r=this.element.firstElementChild;r.insertBefore(this.microscopyElement,r.childNodes[1]),this.addEventListeners(),this.addWidget("DicomMicroscopyViewer",{getEnabled:()=>!!this.viewer,setEnabled:()=>{this.elementDisabledHandler()}}),this.resize()}static get useCustomRenderingPipeline(){return!0}addEventListeners(){this.canvas.addEventListener(et.ELEMENT_DISABLED,this.elementDisabledHandler)}removeEventListeners(){this.canvas.removeEventListener(et.ELEMENT_DISABLED,this.elementDisabledHandler)}elementDisabledHandler(){var r;this.removeEventListeners(),(r=this.viewer)==null||r.cleanup(),this.viewer=null,this.element.firstElementChild.removeChild(this.microscopyElement),this.microscopyElement=null}getImageDataMetadata(e=0){var E;const r=this.metadataDicomweb.reduce((b,D)=>(b==null?void 0:b.NumberOfFrames)<D.NumberOfFrames?D:b),{TotalPixelMatrixColumns:n,TotalPixelMatrixRows:i,ImageOrientationSlide:o,ImagedVolumeWidth:a,ImagedVolumeHeight:s,ImagedVolumeDepth:c}=r,l=ct(jo.IMAGE_PLANE,this.imageIds[e]);let f=o.slice(0,3),u=o.slice(3,6);(f==null||u==null)&&(f=[1,0,0],u=[0,1,0]);const d=Tt(f[0],f[1],f[2]),h=Tt(u[0],u[1],u[2]),g=Ke();Tn(g,d,h);const{XOffsetInSlideCoordinateSystem:p=0,YOffsetInSlideCoordinateSystem:v=0,ZOffsetInSlideCoordinateSystem:y=0}=((E=r.TotalPixelMatrixOriginSequence)==null?void 0:E[0])||{},m=[p,v,y],w=a/n,x=s/i,C=n,S=i,T=c,_=1;return this.hasPixelSpacing=!!(a&&s),{bitsAllocated:8,numberOfComponents:3,origin:m,direction:[...d,...h,...g],dimensions:[C,S,_],spacing:[w,x,T],hasPixelSpacing:this.hasPixelSpacing,numVoxels:C*S*_,imagePlaneModule:l}}async setFrameNumber(e){}setProperties(e){e.voiRange&&this.setVOI(e.voiRange)}resetProperties(){this.setProperties({voiRange:{lower:0,upper:255}})}setVOI(e){this.voiRange=e;const r=this.setColorTransform(e,this.averageWhite);this.map.getViewport().querySelectorAll(".ol-layers canvas").forEach(i=>{i.style.filter=r})}setAverageWhite(e){this.averageWhite=e,this.setColorTransform(this.voiRange,e)}getScalarData(){return null}computeTransforms(){const e=ma(),r=ma();return tm(e,this.metadata.origin),e[0]=this.metadata.direction[0],e[1]=this.metadata.direction[1],e[2]=this.metadata.direction[2],e[4]=this.metadata.direction[3],e[5]=this.metadata.direction[4],e[6]=this.metadata.direction[5],e[8]=this.metadata.direction[6],e[9]=this.metadata.direction[7],e[10]=this.metadata.direction[8],nl(e,e,this.metadata.spacing),Ar(r,e),{indexToWorld:e,worldToIndex:r}}getImageData(){const{metadata:e}=this;if(!e)return null;const{spacing:r}=e,n={getDirection:()=>e.direction,getDimensions:()=>e.dimensions,getRange:()=>[0,255],getScalarData:()=>this.getScalarData(),getSpacing:()=>e.spacing,worldToIndex:o=>this.worldToIndex(o),indexToWorld:o=>this.indexToWorld(o)};return{dimensions:e.dimensions,spacing:r,numberOfComponents:3,origin:e.origin,direction:e.direction,metadata:{Modality:this.modality,FrameOfReferenceUID:this.frameOfReferenceUID},hasPixelSpacing:this.hasPixelSpacing,calibration:this.calibration,preScale:{scaled:!1},scalarData:this.getScalarData(),imageData:n}}hasImageURI(e){return!0}setCamera(e){const r=this.getCamera(),{parallelScale:n,focalPoint:i}=e,o=this.getView(),{xSpacing:a}=this.internalCamera;if(n){const c=this.element.clientHeight/n,l=1/a/c;o.setResolution(l)}if(i){const c=this.worldToCanvas(i),l=this.canvasToIndex(c);o.setCenter(l)}const s=this.getCamera();this.triggerCameraModifiedEventIfNecessary(r,s)}getCurrentImageId(){return this.imageIds[0]}getFrameNumber(){return 1}getCamera(){this.refreshRenderValues();const{resolution:e,xSpacing:r,centerIndex:n}=this.internalCamera,i=e*r,o=this.indexToCanvas([n[0],n[1],0]),a=this.canvasToWorld(o);return{parallelProjection:!0,focalPoint:a,position:a,viewUp:[0,-1,0],parallelScale:this.element.clientHeight*i,viewPlaneNormal:[0,0,1]}}worldToIndexWSI(e){if(!Dg)return;const r=this.viewer[s9],n=Dg.applyInverseTransform({coordinate:[e[0],e[1]],affine:r});return[n[0],n[1]]}indexToWorldWSI(e){if(!Dg)return;const r=Dg.applyTransform({coordinate:[e[0],e[1]],affine:this.viewer[s9]});return[r[0],r[1],0]}worldToIndex(e){const{worldToIndex:r}=this.computeTransforms(),n=Ke();return At(n,e,r),n}indexToWorld(e){const{indexToWorld:r}=this.computeTransforms(),n=Ke(),i=Tt(...e);return At(n,i,r),[n[0],n[1],n[2]]}setDataIds(e,r){(r==null?void 0:r.miniNavigationOverlay)!==!1&&R0.addMiniNavigationOverlayCss();const n=(r==null?void 0:r.webClient)||ct(jo.WADO_WEB_CLIENT,e[0]);if(!n)throw new Error(`To use setDataIds on WSI data, you must provide metaData.webClient for ${e[0]}`);return this.setWSI(e,n)}async setWSI(e,r){this.microscopyElement.style.background="black",this.microscopyElement.innerText="Loading",this.imageIds=e;const n=await R0.getDicomMicroscopyViewer();Dg||(Dg=n.utils),this.frameOfReferenceUID=null;const i=this.imageIds.map(s=>{var u,d,h;const c=r.getDICOMwebMetadata(s);Object.defineProperty(c,"isMultiframe",{value:c.isMultiframe,enumerable:!1}),Object.defineProperty(c,"frameNumber",{value:void 0,enumerable:!1});const l=(u=c["00080008"])==null?void 0:u.Value;(l==null?void 0:l.length)===1&&(c["00080008"].Value=l[0].split("\\"));const f=(h=(d=c["00200052"])==null?void 0:d.Value)==null?void 0:h[0];return this.frameOfReferenceUID?f!==this.frameOfReferenceUID&&(c["00200052"].Value=[this.frameOfReferenceUID]):this.frameOfReferenceUID=f,c}),o=[];i.forEach(s=>{const c=new n.metadata.VLWholeSlideMicroscopyImage({metadata:s}),l=c.ImageType[2];l==="VOLUME"||l==="THUMBNAIL"?o.push(c):console.log("Unknown image type",c.ImageType)}),this.metadataDicomweb=o;const a=new n.viewer.VolumeImageViewer({client:r,metadata:o,controls:["overview","position"],retrieveRendered:!1,bindings:{}});a.render({container:this.microscopyElement}),this.metadata=this.getImageDataMetadata(),a.deactivateDragPanInteraction(),this.viewer=a,this.map=a[a9],this.map.on(Ele,this.postrender),this.resize(),this.microscopyElement.innerText="",Object.assign(this.microscopyElement.style,{"--ol-partial-background-color":"rgba(127, 127, 127, 0.7)","--ol-foreground-color":"#000000","--ol-subtle-foreground-color":"#000","--ol-subtle-background-color":"rgba(78, 78, 78, 0.5)",background:"none"})}scroll(e){const r=this.getCamera();this.setCamera({parallelScale:r.parallelScale*(1+.1*e)})}getSliceIndex(){return 0}getView(){if(!this.viewer)return;const e=this.viewer[a9],r=window;return r.map=e,r.viewer=this.viewer,r.view=e==null?void 0:e.getView(),r.wsi=this,e==null?void 0:e.getView()}refreshRenderValues(){const e=this.getView();if(!e)return;const r=e.getResolution();if(!r||r<Ga)return;const n=e.getCenter(),i=e.getProjection().getExtent(),o=e.getRotation(),a=e.getZoom(),{metadata:{spacing:[s,c]}}=this,l=1/r/s;Object.assign(this.internalCamera,{extent:i,centerIndex:n,worldToCanvasRatio:l,xSpacing:s,ySpacing:c,resolution:r,rotation:o,zoom:a})}getZoom(){var e;return(e=this.getView())==null?void 0:e.getZoom()}setZoom(e){var r;(r=this.getView())==null||r.setZoom(e)}getTransform(){this.refreshRenderValues();const{centerIndex:e,resolution:r,rotation:n}=this.internalCamera,i=[this.canvas.width/2,this.canvas.height/2],o=new Kh;return o.translate(i[0],i[1]),o.rotate(n),o.scale(1/r,-1/r),o.translate(-e[0],-e[1]),o}getViewReferenceId(){return`imageId:${this.getCurrentImageId()}`}getCurrentImageIdIndex(){return 0}static addMiniNavigationOverlayCss(){if(document.getElementById(this.overlayCssId))return;const e=document.createElement("style");e.innerText=_le,e.setAttribute("id",this.overlayCssId),document.getElementsByTagName("head")[0].append(e)}};R0.getDicomMicroscopyViewer=async()=>$A("dicom-microscopy-viewer"),R0.overlayCssId="overlayCss";let zy=R0;const Xk={[ir.ORTHOGRAPHIC]:Zn,[ir.PERSPECTIVE]:Zn,[ir.STACK]:Jn,[ir.VOLUME_3D]:oE,[ir.VIDEO]:_h,[ir.WHOLE_SLIDE]:zy};function Qd(t){return Xk[t].useCustomRenderingPipeline}const c9=2;class aE{constructor(e){if(this._needsRender=new Set,this._animationFrameSet=!1,this._animationFrameHandle=null,this.renderFrameOfReference=r=>{const i=this._getViewportsAsArray().map(o=>{if(o.getFrameOfReferenceUID()===r)return o.id});this.renderViewports(i)},this._renderFlaggedViewports=()=>{this._throwIfDestroyed(),this.useCPURendering||this.performVtkDrawCall();const r=this._getViewportsAsArray(),n=[];for(let i=0;i<r.length;i++){const o=r[i];if(this._needsRender.has(o.id)){const a=this.renderViewportUsingCustomOrVtkPipeline(o);if(n.push(a),o.setRendered(),this._needsRender.delete(o.id),this._needsRender.size===0)break}}this._animationFrameSet=!1,this._animationFrameHandle=null,n.forEach(i=>{i!=null&&i.element&&it(i.element,et.IMAGE_RENDERED,i)})},this.id=e||gn(),this.useCPURendering=X0(),o1.set(this),!zA())throw new Error("@cornerstonejs/core is not initialized, run init() first");this.useCPURendering||(this.offscreenMultiRenderWindow=Lre.newInstance(),this.offScreenCanvasContainer=document.createElement("div"),this.offscreenMultiRenderWindow.setContainer(this.offScreenCanvasContainer)),this._viewports=new Map,this.hasBeenDestroyed=!1}enableElement(e){const r=this._normalizeViewportInputEntry(e);this._throwIfDestroyed();const{element:n,viewportId:i}=r;if(!n)throw new Error("No element provided");this.getViewport(i)&&this.disableElement(i);const{type:a}=r,s=Qd(a);!this.useCPURendering&&!s?this.enableVTKjsDrivenViewport(r):this.addCustomViewport(r);const c=Bc(n),{background:l}=r.defaultOptions;this.fillCanvasWithBackgroundColor(c,l)}disableElement(e){this._throwIfDestroyed();const r=this.getViewport(e);if(!r){console.warn(`viewport ${e} does not exist`);return}this._resetViewport(r),!Qd(r.type)&&!this.useCPURendering&&this.offscreenMultiRenderWindow.removeRenderer(e),this._removeViewport(e),r.isDisabled=!0,this._needsRender.delete(e),this.getViewports().length||this._clearAnimationFrame()}setViewports(e){const r=this._normalizeViewportInputEntries(e);this._throwIfDestroyed(),this._reset();const n=[],i=[];r.forEach(o=>{!this.useCPURendering&&!Qd(o.type)?n.push(o):i.push(o)}),this.setVtkjsDrivenViewports(n),this.setCustomViewports(i),r.forEach(o=>{const a=Bc(o.element),{background:s}=o.defaultOptions;this.fillCanvasWithBackgroundColor(a,s)})}resize(e=!0,r=!0){this._throwIfDestroyed();const n=this._getViewportsAsArray(),i=[],o=[];n.forEach(a=>{Qd(a.type)?o.push(a):i.push(a)}),i.length&&this._resizeVTKViewports(i,r,e),o.length&&this._resizeUsingCustomResizeHandler(o,r,e)}getViewport(e){var r;return(r=this._viewports)==null?void 0:r.get(e)}getViewports(){return this._throwIfDestroyed(),this._getViewportsAsArray()}getStackViewport(e){this._throwIfDestroyed();const r=this.getViewport(e);if(!r)throw new Error(`Viewport with Id ${e} does not exist`);if(!(r instanceof Jn))throw new Error(`Viewport with Id ${e} is not a StackViewport.`);return r}getStackViewports(){return this._throwIfDestroyed(),this.getViewports().filter(r=>r instanceof Jn)}getVolumeViewports(){this._throwIfDestroyed();const e=this.getViewports(),r=n=>n instanceof fr;return e.filter(r)}render(){const r=this.getViewports().map(n=>n.id);this._setViewportsToBeRenderedNextFrame(r)}renderViewports(e){this._setViewportsToBeRenderedNextFrame(e)}renderViewport(e){this._setViewportsToBeRenderedNextFrame([e])}destroy(){this.hasBeenDestroyed||(this.useCPURendering||(this._getViewportsAsArray().forEach(r=>{this.offscreenMultiRenderWindow.removeRenderer(r.id)}),this.offscreenMultiRenderWindow.delete(),delete this.offscreenMultiRenderWindow),this._reset(),o1.delete(this.id),this.hasBeenDestroyed=!0)}fillCanvasWithBackgroundColor(e,r){const n=e.getContext("2d");let i;if(r){const o=r.map(a=>Math.floor(255*a));i=`rgb(${o[0]}, ${o[1]}, ${o[2]})`}else i="black";n.fillStyle=i,n.fillRect(0,0,e.width,e.height)}_normalizeViewportInputEntry(e){const{type:r,defaultOptions:n}=e;let i=n;return(!i||Object.keys(i).length===0)&&(i={background:[0,0,0],orientation:null,displayArea:null},r===ir.ORTHOGRAPHIC&&(i={...i,orientation:Cd.AXIAL})),{...e,defaultOptions:i}}_normalizeViewportInputEntries(e){const r=[];return e.forEach(n=>{r.push(this._normalizeViewportInputEntry(n))}),r}_resizeUsingCustomResizeHandler(e,r=!0,n=!0){e.forEach(i=>{typeof i.resize=="function"&&i.resize()}),e.forEach(i=>{const o=i.getCamera();i.resetCamera(),r&&i.setCamera(o)}),n&&this.render()}_resizeVTKViewports(e,r=!0,n=!0){const i=e.map(o=>Bc(o.element));if(i.forEach(o=>{const a=window.devicePixelRatio||1;o.width=o.clientWidth*a,o.height=o.clientHeight*a}),i.length){const{offScreenCanvasWidth:o,offScreenCanvasHeight:a}=this._resizeOffScreenCanvas(i);this._resize(e,o,a)}e.forEach(o=>{const a=o.getCamera(),s=o.getRotation(),{flipHorizontal:c}=a;o.resetCameraForResize();const l=o.getDisplayArea();r&&(l?(c&&o.setCamera({flipHorizontal:c}),s&&o.setViewPresentation({rotation:s})):o.setCamera(a))}),n&&this.render()}enableVTKjsDrivenViewport(e){const n=this._getViewportsAsArray().filter(f=>Qd(f.type)===!1),i=n.map(f=>f.canvas),o=Bc(e.element);i.push(o);const{offScreenCanvasWidth:a,offScreenCanvasHeight:s}=this._resizeOffScreenCanvas(i),c=this._resize(n,a,s),l={...e,canvas:o};this.addVtkjsDrivenViewport(l,{offScreenCanvasWidth:a,offScreenCanvasHeight:s,xOffset:c})}_removeViewport(e){if(!this.getViewport(e)){console.warn(`viewport ${e} does not exist`);return}this._viewports.delete(e)}addVtkjsDrivenViewport(e,r){const{element:n,canvas:i,viewportId:o,type:a,defaultOptions:s}=e;n.tabIndex=-1;const{offScreenCanvasWidth:c,offScreenCanvasHeight:l,xOffset:f}=r,{sxStartDisplayCoords:u,syStartDisplayCoords:d,sxEndDisplayCoords:h,syEndDisplayCoords:g,sx:p,sy:v,sWidth:y,sHeight:m}=this._getViewportCoordsOnOffScreenCanvas(e,c,l,f);this.offscreenMultiRenderWindow.addRenderer({viewport:[u,d,h,g],id:o,background:s.background?s.background:[0,0,0]});const w={id:o,element:n,renderingEngineId:this.id,type:a,canvas:i,sx:p,sy:v,sWidth:y,sHeight:m,defaultOptions:s||{}};let x;if(a===ir.STACK)x=new Jn(w);else if(a===ir.ORTHOGRAPHIC||a===ir.PERSPECTIVE)x=new Zn(w);else if(a===ir.VOLUME_3D)x=new oE(w);else throw new Error(`Viewport Type ${a} is not supported`);this._viewports.set(o,x);const C={element:n,viewportId:o,renderingEngineId:this.id};x.suppressEvents||it(Ze,et.ELEMENT_ENABLED,C)}addCustomViewport(e){const{element:r,viewportId:n,type:i,defaultOptions:o}=e;r.tabIndex=-1;const a=Bc(r),{clientWidth:s,clientHeight:c}=a;(a.width!==s||a.height!==c)&&(a.width=s,a.height=c);const l={id:n,renderingEngineId:this.id,element:r,type:i,canvas:a,sx:0,sy:0,sWidth:s,sHeight:c,defaultOptions:o||{}},f=Xk[i],u=new f(l);this._viewports.set(n,u);const d={element:r,viewportId:n,renderingEngineId:this.id};it(Ze,et.ELEMENT_ENABLED,d)}setCustomViewports(e){e.forEach(r=>{this.addCustomViewport(r)})}setVtkjsDrivenViewports(e){if(e.length){const r=e.map(a=>Bc(a.element));r.forEach(a=>{const s=window.devicePixelRatio||1,c=a.getBoundingClientRect();a.width=c.width*s,a.height=c.height*s});const{offScreenCanvasWidth:n,offScreenCanvasHeight:i}=this._resizeOffScreenCanvas(r);let o=0;for(let a=0;a<e.length;a++){const s=e[a],c=r[a],l={...s,canvas:c};this.addVtkjsDrivenViewport(l,{offScreenCanvasWidth:n,offScreenCanvasHeight:i,xOffset:o}),o+=c.width}}}_resizeOffScreenCanvas(e){const{offScreenCanvasContainer:r,offscreenMultiRenderWindow:n}=this,i=Math.max(...e.map(a=>a.height));let o=0;return e.forEach(a=>{o+=a.width}),r.width=o,r.height=i,n.resize(),{offScreenCanvasWidth:o,offScreenCanvasHeight:i}}_resize(e,r,n){let i=0;for(let o=0;o<e.length;o++){const a=e[o],{sxStartDisplayCoords:s,syStartDisplayCoords:c,sxEndDisplayCoords:l,syEndDisplayCoords:f,sx:u,sy:d,sWidth:h,sHeight:g}=this._getViewportCoordsOnOffScreenCanvas(a,r,n,i);i+=a.canvas.width,a.sx=u,a.sy=d,a.sWidth=h,a.sHeight=g,this.offscreenMultiRenderWindow.getRenderer(a.id).setViewport([s,c,l,f])}return i}_getViewportCoordsOnOffScreenCanvas(e,r,n,i){const{canvas:o}=e,{width:a,height:s}=o,c=i,l=0,f=c/r,u=l+(n-s)/n,d=a/r,h=s/n;return{sxStartDisplayCoords:f,syStartDisplayCoords:u,sxEndDisplayCoords:f+d,syEndDisplayCoords:u+h,sx:c,sy:l,sWidth:a,sHeight:s}}_getViewportsAsArray(){return Array.from(this._viewports.values())}_setViewportsToBeRenderedNextFrame(e){e.forEach(r=>{this._needsRender.add(r)}),this._render()}_render(){this._needsRender.size>0&&!this._animationFrameSet&&(this._animationFrameHandle=window.requestAnimationFrame(this._renderFlaggedViewports),this._animationFrameSet=!0)}performVtkDrawCall(){const{offscreenMultiRenderWindow:e}=this,r=e.getRenderWindow(),n=e.getRenderers();if(n.length){for(let i=0;i<n.length;i++){const{renderer:o,id:a}=n[i];this._needsRender.has(a)?o.setDraw(!0):o.setDraw(!1)}r.render();for(let i=0;i<n.length;i++)n[i].renderer.setDraw(!1)}}renderViewportUsingCustomOrVtkPipeline(e){let r;if(e.sWidth<c9||e.sHeight<c9){console.warn("Viewport is too small",e.sWidth,e.sHeight);return}if(Qd(e.type)===!0)r=e.customRenderViewportToCanvas();else{if(this.useCPURendering)throw new Error("GPU not available, and using a viewport with no custom render pipeline.");const{offscreenMultiRenderWindow:n}=this,a=n.getOpenGLRenderWindow().get3DContext().canvas;r=this._renderViewportFromVtkCanvasToOnscreenCanvas(e,a)}return r}_renderViewportFromVtkCanvasToOnscreenCanvas(e,r){const{element:n,canvas:i,sx:o,sy:a,sWidth:s,sHeight:c,id:l,renderingEngineId:f,suppressEvents:u}=e,{width:d,height:h}=i;return i.getContext("2d").drawImage(r,o,a,s,c,0,0,d,h),{element:n,suppressEvents:u,viewportId:l,renderingEngineId:f,viewportStatus:e.viewportStatus}}_resetViewport(e){const r=this.id,{element:n,canvas:i,id:o}=e,a={element:n,viewportId:o,renderingEngineId:r};e.removeWidgets(),it(Ze,et.ELEMENT_DISABLED,a),n.removeAttribute("data-viewport-uid"),n.removeAttribute("data-rendering-engine-uid"),i.getContext("2d").clearRect(0,0,i.width,i.height)}_clearAnimationFrame(){window.cancelAnimationFrame(this._animationFrameHandle),this._needsRender.clear(),this._animationFrameSet=!1,this._animationFrameHandle=null}_reset(){this._getViewportsAsArray().forEach(r=>{this._resetViewport(r)}),this._clearAnimationFrame(),this._viewports=new Map}_throwIfDestroyed(){if(this.hasBeenDestroyed)throw new Error("this.destroy() has been manually called to free up memory, can not longer use this instance. Instead make a new one.")}_downloadOffScreenCanvas(){const e=this._debugRender();ble(e)}_debugRender(){const{offscreenMultiRenderWindow:e}=this,r=e.getRenderWindow(),n=e.getRenderers();for(let c=0;c<n.length;c++)n[c].renderer.setDraw(!0);r.render();const a=e.getOpenGLRenderWindow().get3DContext().canvas,s=a.toDataURL();return this._getViewportsAsArray().forEach(c=>{const{sx:l,sy:f,sWidth:u,sHeight:d}=c,h=c.canvas,{width:g,height:p}=h;h.getContext("2d").drawImage(a,l,f,u,d,0,0,g,p)}),s}}function ble(t){const e=document.createElement("a");e.download="viewport.png",e.href=t,document.body.appendChild(e),e.click(),document.body.removeChild(e)}const Dle="3.20.0";class Yk{constructor(e){this._color=[200,0,0],this.id=e.id,this._points=e.points,this._polys=e.polys,this._color=e.color??this._color,this.frameOfReferenceUID=e.frameOfReferenceUID,this._segmentIndex=e.segmentIndex,this.sizeInBytes=this._getSizeInBytes(),this._updateCentroid(),this._visible=!0}_getSizeInBytes(){return this._points.length*4+this._polys.length*4}_updateCentroid(){const e=this._points.length/3;let r=0,n=0,i=0;for(let o=0;o<this._points.length;o+=3)r+=this._points[o],n+=this._points[o+1],i+=this._points[o+2];this._centroid=[r/e,n/e,i/e]}get color(){return this._color}set color(e){this._color=e}get points(){return this._points}set points(e){this._points=e,this._updateCentroid()}get polys(){return this._polys}set polys(e){this._polys=e}get segmentIndex(){return this._segmentIndex}get visible(){return this._visible}set visible(e){this._visible=e}get centroid(){return this._centroid}get flatPointsArray(){return this._points}get totalNumberOfPoints(){return this._points.length/3}}function Jk(t){return new TextDecoder("latin1").decode(t)}function Ile(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null;const n=Jk(t),i=e.exec(n);if(!i)return{text:n};const o=i.index+i[0].length,a=n.substring(0,o);let s=null;const c=r?r.exec(n):null;if(c){const l=n.substr(c.index);s={text:a+l,binaryBuffer:t.slice(o,c.index)}}else s={text:a,binaryBuffer:t.slice(o)};return s}var y1={arrayBufferToString:Jk,extractBinary:Ile};const sE={};function Zk(t){return!!sE[t]}function Ole(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"http",e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return sE[t](e)}function Qk(t,e){sE[t]=e}var hm={get:Ole,has:Zk,registerType:Qk};function eV(){const t=new ArrayBuffer(4),e=new Uint8Array(t),r=new Uint32Array(t);return e[0]=161,e[1]=178,e[2]=195,e[3]=212,r[0]===3569595041?"LittleEndian":r[0]===2712847316?"BigEndian":null}const Mle=eV();function Ple(t,e){if(e<2)return;const r=new Int8Array(t),n=r.length,i=[];for(let o=0;o<n;o+=e){for(let a=0;a<e;a++)i.push(r[o+a]);for(let a=0;a<e;a++)r[o+a]=i.pop()}}var nC={ENDIANNESS:Mle,getEndianness:eV,swapBytes:Ple};const{vtkErrorMacro:tV,vtkDebugMacro:Rle}=Z,cE=()=>(tV("LiteHttpDataAccessHelper does not support compression. Need to register HttpDataAccessHelper instead."),Promise.reject(new Error("LiteHttpDataAccessHelper does not support compression. Need to register HttpDataAccessHelper instead.")));let Eh=0;function xw(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const n=new XMLHttpRequest;return n.open(t,e,!0),r.headers&&Object.entries(r.headers).forEach(i=>{let[o,a]=i;return n.setRequestHeader(o,a)}),r.progressCallback&&n.addEventListener("progress",r.progressCallback),n}function Lle(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return new Promise((r,n)=>{const i=xw("GET",t,e);i.onreadystatechange=o=>{i.readyState===4&&(i.status===200||i.status===0?r(i.response):n({xhr:i,e:o}))},i.responseType="arraybuffer",i.send()})}function Ale(t,e,r){let n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return n&&n.compression?cE():r.ref&&!r.ref.pending?new Promise((i,o)=>{const a=[e,r.ref.basepath,r.ref.id].join("/"),s=xw("GET",a,n);s.onreadystatechange=c=>{s.readyState===1&&(r.ref.pending=!0,++Eh===1&&(t!=null&&t.invokeBusy)&&t.invokeBusy(!0)),s.readyState===4&&(r.ref.pending=!1,s.status===200||s.status===0?(r.buffer=s.response,r.ref.encode==="JSON"?r.values=JSON.parse(r.buffer):(nC.ENDIANNESS!==r.ref.encode&&nC.ENDIANNESS&&(Rle(`Swap bytes of ${r.name}`),nC.swapBytes(r.buffer,XP[r.dataType])),r.values=Z.newTypedArray(r.dataType,r.buffer)),r.values.length!==r.size&&tV(`Error in FetchArray: ${r.name}, does not have the proper array size. Got ${r.values.length}, instead of ${r.size}`),delete r.ref,--Eh===0&&(t!=null&&t.invokeBusy)&&t.invokeBusy(!1),t!=null&&t.modified&&t.modified(),i(r)):o({xhr:s,e:c}))},s.responseType=r.dataType!=="string"?"arraybuffer":"text",s.send()}):Promise.resolve(r)}function Nle(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return r&&r.compression?cE():new Promise((n,i)=>{const o=xw("GET",e,r);o.onreadystatechange=a=>{o.readyState===1&&++Eh===1&&t!=null&&t.invokeBusy&&t.invokeBusy(!0),o.readyState===4&&(--Eh===0&&(t!=null&&t.invokeBusy)&&t.invokeBusy(!1),o.status===200||o.status===0?n(JSON.parse(o.responseText)):i({xhr:o,e:a}))},o.responseType="text",o.send()})}function kle(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return r&&r.compression?cE():new Promise((n,i)=>{const o=xw("GET",e,r);o.onreadystatechange=a=>{o.readyState===1&&++Eh===1&&t!=null&&t.invokeBusy&&t.invokeBusy(!0),o.readyState===4&&(--Eh===0&&(t!=null&&t.invokeBusy)&&t.invokeBusy(!1),o.status===200||o.status===0?n(o.responseText):i({xhr:o,e:a}))},o.responseType="text",o.send()})}function Vle(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return new Promise((n,i)=>{const o=new Image;r.crossOrigin&&(o.crossOrigin=r.crossOrigin),o.onload=()=>n(o),o.onerror=i,o.src=e})}const Fle={fetchArray:Ale,fetchJSON:Nle,fetchText:kle,fetchBinary:Lle,fetchImage:Vle};Zk("http")||Qk("http",t=>Fle);const rC={ASCII:"ascii",BINARY_LITTLE_ENDIAN:"binary_little_endian"},l9={diffuse_red:"red",diffuse_green:"green",diffuse_blue:"blue"},nV={patternHeader:/ply([\s\S]*)end_header\r?\n/,patternBody:/end_header\s([\s\S]*)$/};function u9(t){let e="",r=0;const n=nV.patternHeader.exec(t);n!==null&&(e=n[1],r=n[0].length);const i={comments:[],elements:[],headerLength:r},o=e.split(`
|
||
`);let a,s,c;for(let l=0;l<o.length;l++){let f=o[l];if(f=f.trim(),f!==""){let u;switch(c=f.split(/\s+/),s=c.shift(),f=c.join(" "),s){case"format":i.format=c[0],i.version=c[1];break;case"comment":i.comments.push(f);break;case"element":a!==void 0&&i.elements.push(a),a={},a.name=c[0],a.count=parseInt(c[1],10),a.properties=[];break;case"property":u={type:c[0]},u.type==="list"?(u.name=c[3],u.countType=c[1],u.itemType=c[2]):u.name=c[1],u.name in l9&&(u.name=l9[u.name]),a.properties.push(u);break;case"obj_info":i.objInfo=f;break;default:console.warn("unhandled",s,c);break}}}return a!==void 0&&i.elements.push(a),i}function f9(t,e){const r=e.find(p=>p.name==="vertex"),n=e.find(p=>p.name==="face");let i=0,o=0;r&&(i=r.count),n&&(o=n.count);const a=new Float32Array(i*3),s=new Uint8Array(i*3),c=new Float32Array(i*2),l=new Float32Array(i*3),f=t.colors.length>0,u=t.uvs.length>0,d=t.normals.length>0,h=t.faceVertexUvs.length>0;for(let p=0;p<i;p++){let v=p*3+0,y=p*3+1;const m=p*3+2;a[v]=t.vertices[v],a[y]=t.vertices[y],a[m]=t.vertices[m],f&&(s[v]=t.colors[v],s[y]=t.colors[y],s[m]=t.colors[m]),u&&(v=p*2+0,y=p*2+1,c[v]=t.uvs[v],c[y]=t.uvs[y]),d&&(l[v]=t.normals[v],l[y]=t.normals[y],l[m]=t.normals[m])}if(!u&&h){let p=0,v=0;for(let y=0;y<o;++y){const m=t.indices[p++],w=t.faceVertexUvs[v++];if(w&&m*2===w.length)for(let x=0;x<m;++x){const C=t.indices[p++];c[C*2+0]=w[x*2+0],c[C*2+1]=w[x*2+1]}else p+=m}}const g=Er.newInstance();if(g.getPoints().setData(a,3),f&&g.getPointData().setScalars(bt.newInstance({numberOfComponents:3,values:s,name:"Scalars"})),u||h){const p=bt.newInstance({numberOfComponents:2,values:c,name:"TextureCoordinates"}),v=g.getPointData();v.addArray(p),v.setActiveTCoords(p.getName())}return d&&g.getPointData().setNormals(bt.newInstance({numberOfComponents:3,name:"Normals",values:l})),g.getPolys().setData(Uint32Array.from(t.indices)),g}function iC(t,e){let r;switch(e){case"char":case"uchar":case"short":case"ushort":case"int":case"uint":case"int8":case"uint8":case"int16":case"uint16":case"int32":case"uint32":r=parseInt(t,10);break;case"float":case"double":case"float32":case"float64":r=parseFloat(t);break;default:console.log("Unsupported type");break}return r}function Ule(t,e){const r=e.split(/\s+/),n={};for(let i=0;i<t.length;i++)if(t[i].type==="list"){const o=[],a=iC(r.shift(),t[i].countType);for(let s=0;s<a;s++)o.push(iC(r.shift(),t[i].itemType));n[t[i].name]=o}else n[t[i].name]=iC(r.shift(),t[i].type);return n}function d9(t,e,r){if(e==="vertex")t.vertices.push(r.x,r.y,r.z),"nx"in r&&"ny"in r&&"nz"in r&&t.normals.push(r.nx,r.ny,r.nz),"s"in r&&"t"in r?t.uvs.push(r.s,r.t):"u"in r&&"v"in r?t.uvs.push(r.u,r.v):"texture_u"in r&&"texture_v"in r&&t.uvs.push(r.texture_u,r.texture_v),"red"in r&&"green"in r&&"blue"in r&&t.colors.push(r.red,r.green,r.blue);else if(e==="face"){const n=r.vertex_indices||r.vertex_index,i=r.texcoord;n&&n.length>0&&(t.indices.push(n.length),n.forEach((o,a)=>{t.indices.push(o)})),t.faceVertexUvs.push(i)}}function oC(t,e,r,n){let i;switch(r){case"int8":case"char":i=[t.getInt8(e),1];break;case"uint8":case"uchar":i=[t.getUint8(e),1];break;case"int16":case"short":i=[t.getInt16(e,n),2];break;case"uint16":case"ushort":i=[t.getUint16(e,n),2];break;case"int32":case"int":i=[t.getInt32(e,n),4];break;case"uint32":case"uint":i=[t.getUint32(e,n),4];break;case"float32":case"float":i=[t.getFloat32(e,n),4];break;case"float64":case"double":i=[t.getFloat64(e,n),8];break;default:console.log("Unsupported type");break}return i}function Ble(t,e,r,n){const i={};let o,a=0;for(let s=0;s<r.length;s++)if(r[s].type==="list"){const c=[];o=oC(t,e+a,r[s].countType,n);const l=o[0];a+=o[1];for(let f=0;f<l;f++)o=oC(t,e+a,r[s].itemType,n),c.push(o[0]),a+=o[1];i[r[s].name]=c}else o=oC(t,e+a,r[s].type,n),i[r[s].name]=o[0],a+=o[1];return[i,a]}function Gle(t,e){e.classHierarchy.push("vtkPLYReader"),e.dataAccessHelper||(e.dataAccessHelper=hm.get("http"));function r(n){let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{compression:o,progressCallback:a}=e;return i.binary?e.dataAccessHelper.fetchBinary(n,{compression:o,progressCallback:a}):e.dataAccessHelper.fetchText(t,n,{compression:o,progressCallback:a})}t.setUrl=function(n){let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{binary:!0};e.url=n;const o=n.split("/");return o.pop(),e.baseURL=o.join("/"),e.compression=i.compression,t.loadData({progressCallback:i.progressCallback,binary:!!i.binary})},t.loadData=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const i=r(e.url,n);return i.then(t.parse),i},t.parse=n=>{typeof n=="string"?t.parseAsText(n):t.parseAsArrayBuffer(n)},t.parseAsArrayBuffer=n=>{if(!n)return;if(n!==e.parseData)t.modified();else return;const i=y1.arrayBufferToString(n),o=u9(i);if(!(o.format!==rC.ASCII)){t.parseAsText(n);return}e.parseData=n;const s={indices:[],vertices:[],normals:[],uvs:[],faceVertexUvs:[],colors:[]},c=o.format===rC.BINARY_LITTLE_ENDIAN,l=n instanceof ArrayBuffer?n:n.buffer,f=new DataView(l,o.headerLength);let u,d=0;for(let g=0;g<o.elements.length;g++)for(let p=0;p<o.elements[g].count;p++){u=Ble(f,d,o.elements[g].properties,c),d+=u[1];const v=u[0];d9(s,o.elements[g].name,v)}const h=f9(s,o.elements);e.output[0]=h},t.parseAsText=n=>{if(!n)return;if(n!==e.parseData)t.modified();else return;e.parseData=n;const i=y1.arrayBufferToString(n),o=u9(i);if(o.format!==rC.ASCII){t.parseAsArrayBuffer(n);return}const s={indices:[],vertices:[],normals:[],uvs:[],faceVertexUvs:[],colors:[]},c=nV.patternBody.exec(i);let l="";c!==null&&(l=c[1]);const f=l.split(`
|
||
`);let u=0,d=0;for(let g=0;g<f.length;g++){let p=f[g];if(p=p.trim(),p!==""){d>=o.elements[u].count&&(u++,d=0);const v=Ule(o.elements[u].properties,p);d9(s,o.elements[u].name,v),d++}}const h=f9(s,o.elements);e.output[0]=h},t.requestData=(n,i)=>{t.parse(e.parseData)}}const Wle={};function rV(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Wle,r),Z.obj(t,e),Z.get(t,e,["url","baseURL"]),Z.setGet(t,e,["dataAccessHelper"]),Z.algo(t,e,0,1),Gle(t,e),e.compression||(e.compression=null),e.progressCallback||(e.progressCallback=null)}const zle=Z.newInstance(rV,"vtkPLYReader");var $le={extend:rV,newInstance:zle};const{vtkErrorMacro:aC}=Z;function jle(t){const r=t.split(" ").filter(i=>i.indexOf("=")>-1),n={};for(let i=0;i<r.length;++i){const a=r[i].split("=");a.length===2&&(n[a[0]]=a[1])}return n}function h9(t,e){for(let r=0;r<t.length;r++)e.push(t[r])}function Hle(t,e,r,n,i){const o=t[e];if(o===void 0)return-1;if(o.indexOf("endfacet")!==-1||o.indexOf("facet")===-1)return e+1;let a=0,s=2;const c=r.length/3,l=o.split(/[ \t]+/).filter(f=>f).slice(-3).map(Number);for(h9(l,i);t[e+s].indexOf("vertex")!==-1;){const u=t[e+s].split(/[ \t]+/).filter(d=>d).slice(-3).map(Number);h9(u,r),a++,s++}n.push(a);for(let f=0;f<a;f++)n.push(c+f);for(;t[e+s]&&t[e+s].indexOf("endfacet")!==-1;)s++;return e+s+2}function Kle(t,e){e.classHierarchy.push("vtkSTLReader"),e.dataAccessHelper||(e.dataAccessHelper=hm.get("http"));function r(i){let o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const a=o.compression!==void 0?o.compression:e.compression,s=o.progressCallback!==void 0?o.progressCallback:e.progressCallback;return o.binary?e.dataAccessHelper.fetchBinary(i,{compression:a,progressCallback:s}):e.dataAccessHelper.fetchText(t,i,{compression:a,progressCallback:s})}function n(i){const o=e.output[0],a=o.getPoints().getData(),s=o.getPolys().getData();if(!a||!s){console.warn("No valid polydata.");return}const c=new Map,l=new Map;let f=0,u=!1;for(let p=0;p<a.length;p+=3){const v=(a[p]*10**i).toFixed(0),y=(a[p+1]*10**i).toFixed(0),m=(a[p+2]*10**i).toFixed(0),w=`${v},${y},${m}`;c.get(w)!==void 0?(l.set(p/3,c.get(w)),u=!0):(l.set(p/3,f),c.set(w,f),f++)}const d=new Float32Array(c.size*3),h=Array.from(c.keys());for(let p=0;p<h.length;p++){const v=h[p],y=c.get(v)*3,m=v.split(",").map(w=>+w*10**-i);d[y]=m[0],d[y+1]=m[1],d[y+2]=m[2]}const g=new Int32Array(s);for(let p=0;p<s.length;p+=4)g[p]=3,g[p+1]=l.get(s[p+1]),g[p+2]=l.get(s[p+2]),g[p+3]=l.get(s[p+3]);o.getPoints().setData(d),o.getPolys().setData(g),u&&t.modified()}t.setUrl=function(i){let o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{binary:!0};e.url=i;const a=i.split("/");return a.pop(),e.baseURL=a.join("/"),t.loadData(o)},t.loadData=function(){let i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const o=r(e.url,i);return o.then(t.parse),o},t.parse=i=>{typeof i=="string"?t.parseAsText(i):t.parseAsArrayBuffer(i)},t.parseAsArrayBuffer=i=>{if(!i)return;if(i!==e.parseData)t.modified();else return;e.parseData=i;let o=!1;if(o=84+new DataView(i,0,84).getUint32(80,!0)*50===i.byteLength,!o){t.parseAsText(y1.arrayBufferToString(i));return}const c=i.slice(0,80),l=y1.arrayBufferToString(c),f=jle(l),u=new DataView(i,84),d=(i.byteLength-84)/50,h=new Float32Array(d*9),g=new Float32Array(d*3),p=new Uint32Array(d*4),v=new Uint16Array(d);let y=0;for(let x=0;x<d;x++){const C=x*50;g[x*3+0]=u.getFloat32(C+0,!0),g[x*3+1]=u.getFloat32(C+4,!0),g[x*3+2]=u.getFloat32(C+8,!0),h[x*9+0]=u.getFloat32(C+12,!0),h[x*9+1]=u.getFloat32(C+16,!0),h[x*9+2]=u.getFloat32(C+20,!0),h[x*9+3]=u.getFloat32(C+24,!0),h[x*9+4]=u.getFloat32(C+28,!0),h[x*9+5]=u.getFloat32(C+32,!0),h[x*9+6]=u.getFloat32(C+36,!0),h[x*9+7]=u.getFloat32(C+40,!0),h[x*9+8]=u.getFloat32(C+44,!0),p[y++]=3,p[y++]=x*3+0,p[y++]=x*3+1,p[y++]=x*3+2,v[x]=u.getUint16(C+48,!0)}const m="SPACE";if(m in f&&f[m]!=="LPS"){const x=f[m],C=new Float32Array(16);switch(C[15]=1,x[0]){case"L":C[0]=1;break;case"R":C[0]=-1;break;default:aC(`Can not convert STL file from ${x} to LPS space: permutations not supported. Use itk.js STL reader instead.`);return}switch(x[1]){case"P":C[5]=1;break;case"A":C[5]=-1;break;default:aC(`Can not convert STL file from ${x} to LPS space: permutations not supported. Use itk.js STL reader instead.`);return}switch(x[2]){case"S":C[10]=1;break;case"I":C[10]=-1;break;default:aC(`Can not convert STL file from ${x} to LPS space: permutations not supported. Use itk.js STL reader instead.`);return}Ni.buildFromDegree().setMatrix(C).apply(h).apply(g)}const w=Er.newInstance();w.getPoints().setData(h,3),w.getPolys().setData(p),w.getCellData().setScalars(bt.newInstance({name:"Attribute",values:v})),w.getCellData().setNormals(bt.newInstance({name:"Normals",values:g,numberOfComponents:3})),e.output[0]=w,e.removeDuplicateVertices>=0&&n(e.removeDuplicateVertices)},t.parseAsText=i=>{if(!i)return;if(i!==e.parseData)t.modified();else return;e.parseData=i;const o=i.split(`
|
||
`);let a=1;const s=[],c=[],l=[];for(;a!==-1;)a=Hle(o,a,s,c,l);const f=Er.newInstance();f.getPoints().setData(Float32Array.from(s),3),f.getPolys().setData(Uint32Array.from(c)),f.getCellData().setNormals(bt.newInstance({name:"Normals",values:Float32Array.from(l),numberOfComponents:3})),e.output[0]=f,e.removeDuplicateVertices>=0&&n(e.removeDuplicateVertices)},t.requestData=(i,o)=>{t.parse(e.parseData)}}const qle={removeDuplicateVertices:-1};function iV(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,qle,r),Z.obj(t,e),Z.get(t,e,["url","baseURL"]),Z.setGet(t,e,["dataAccessHelper","removeDuplicateVertices"]),Z.algo(t,e,0,1),Kle(t,e),e.compression||(e.compression=null),e.progressCallback||(e.progressCallback=null)}const Xle=Z.newInstance(iV,"vtkSTLReader");var Yle={extend:iV,newInstance:Xle},oV={exports:{}};(function(t,e){(function(r,n){t.exports=n()})(Ai,function(){return function(r){var n={};function i(o){if(n[o])return n[o].exports;var a=n[o]={i:o,l:!1,exports:{}};return r[o].call(a.exports,a,a.exports,i),a.l=!0,a.exports}return i.m=r,i.c=n,i.d=function(o,a,s){i.o(o,a)||Object.defineProperty(o,a,{enumerable:!0,get:s})},i.r=function(o){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(o,"__esModule",{value:!0})},i.t=function(o,a){if(1&a&&(o=i(o)),8&a||4&a&&typeof o=="object"&&o&&o.__esModule)return o;var s=Object.create(null);if(i.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:o}),2&a&&typeof o!="string")for(var c in o)i.d(s,c,(function(l){return o[l]}).bind(null,c));return s},i.n=function(o){var a=o&&o.__esModule?function(){return o.default}:function(){return o};return i.d(a,"a",a),a},i.o=function(o,a){return Object.prototype.hasOwnProperty.call(o,a)},i.p="",i(i.s=184)}([function(r,n,i){function o(a){for(var s in a)n.hasOwnProperty(s)||(n[s]=a[s])}Object.defineProperty(n,"__esModule",{value:!0}),o(i(240)),o(i(251)),o(i(175)),o(i(107)),o(i(29)),o(i(73)),o(i(106)),o(i(30)),o(i(252)),o(i(52)),o(i(97)),o(i(253)),o(i(37)),o(i(51)),o(i(173)),o(i(176)),o(i(172)),o(i(108)),o(i(254)),o(i(255)),o(i(256)),o(i(72)),o(i(177)),o(i(105)),o(i(17)),o(i(257)),o(i(12)),o(i(174))},function(r,n,i){var o=this&&this.__values||function(w){var x=typeof Symbol=="function"&&Symbol.iterator,C=x&&w[x],S=0;if(C)return C.call(w);if(w&&typeof w.length=="number")return{next:function(){return w&&S>=w.length&&(w=void 0),{value:w&&w[S++],done:!w}}};throw new TypeError(x?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var a=i(212);n.FixedSizeSet=a.FixedSizeSet;var s=i(213);n.ObjectCache=s.ObjectCache;var c=i(214);n.CompareCache=c.CompareCache;var l=i(215);n.Lazy=l.Lazy;var f=i(216);function u(w,x,C){if(y(w))w.forEach(function(T,_){return x.call(C,_,T)});else for(var S in w)w.hasOwnProperty(S)&&x.call(C,S,w[S])}function d(w){var x,C;if(h(w))return w;if(p(w)){var S=[];try{for(var T=o(w),_=T.next();!_.done;_=T.next()){var E=_.value;S.push(d(E))}}catch(I){x={error:I}}finally{try{_&&!_.done&&(C=T.return)&&C.call(T)}finally{if(x)throw x.error}}return S}if(g(w)){S={};for(var b in w)if(w.hasOwnProperty(b)){var D=w[b];S[b]=d(D)}return S}return w}function h(w){return!!w&&Object.prototype.toString.call(w)==="[object Function]"}function g(w){var x=typeof w;return!!w&&(x==="function"||x==="object")}function p(w){return Array.isArray(w)}function v(w){return w instanceof Set}function y(w){return w instanceof Map}function m(w){if(g(w)){var x=Object.getPrototypeOf(w),C=x.constructor;return x&&C&&typeof C=="function"&&C instanceof C&&Function.prototype.toString.call(C)===Function.prototype.toString.call(Object)}return!1}n.StringWalker=f.StringWalker,n.applyMixin=function(w,x){for(var C=[],S=2;S<arguments.length;S++)C[S-2]=arguments[S];Object.getOwnPropertyNames(x.prototype).forEach(function(T){if(T!=="constructor"){if(C.indexOf(T)!==-1){var _=Object.getOwnPropertyDescriptor(w.prototype,T);_&&Object.defineProperty(w.prototype,"_"+T,_)}var E=Object.getOwnPropertyDescriptor(x.prototype,T);E&&Object.defineProperty(w.prototype,T,E)}})},n.applyDefaults=function w(x,C,S){S===void 0&&(S=!1);var T=d(x||{});return u(C,function(_,E){m(E)?T[_]=w(T[_],E,S):(S||T[_]===void 0)&&(T[_]=E)}),T},n.forEachArray=function(w,x,C){w.forEach(x,C)},n.forEachObject=u,n.arrayLength=function(w){return v(w)?w.size:w.length},n.objectLength=function(w){return y(w)?w.size:Object.keys(w).length},n.getObjectValue=function(w,x){return y(w)?w.get(x):w[x]},n.removeObjectValue=function(w,x){y(w)?w.delete(x):delete w[x]},n.clone=d,n.isBoolean=function(w){return typeof w=="boolean"},n.isNumber=function(w){return typeof w=="number"},n.isString=function(w){return typeof w=="string"},n.isFunction=h,n.isObject=g,n.isArray=p,n.isSet=v,n.isMap=y,n.isEmpty=function(w){if(p(w))return!w.length;if(v(w)||y(w))return!w.size;if(g(w)){for(var x in w)if(w.hasOwnProperty(x))return!1;return!0}return!1},n.isPlainObject=m,n.isIterable=function(w){return w&&typeof w[Symbol.iterator]=="function"},n.getValue=function(w){return h(w.valueOf)?w.valueOf():w},n.utf8Encode=function(w){for(var x=new Uint8Array(4*w.length),C=0,S=0;S<w.length;S++){var T=w.charCodeAt(S);if(T<128)x[C++]=T;else{if(T<2048)x[C++]=T>>6|192;else{if(T>55295&&T<56320){if(++S>=w.length)throw new Error("Incomplete surrogate pair.");var _=w.charCodeAt(S);if(_<56320||_>57343)throw new Error("Invalid surrogate character.");T=65536+((1023&T)<<10)+(1023&_),x[C++]=T>>18|240,x[C++]=T>>12&63|128}else x[C++]=T>>12|224;x[C++]=T>>6&63|128}x[C++]=63&T|128}}return x.subarray(0,C)},n.utf8Decode=function(w){for(var x="",C=0;C<w.length;){var S=w[C++];if(S>127)if(S>191&&S<224){if(C>=w.length)throw new Error("Incomplete 2-byte sequence.");S=(31&S)<<6|63&w[C++]}else if(S>223&&S<240){if(C+1>=w.length)throw new Error("Incomplete 3-byte sequence.");S=(15&S)<<12|(63&w[C++])<<6|63&w[C++]}else{if(!(S>239&&S<248))throw new Error("Unknown multi-byte start.");if(C+2>=w.length)throw new Error("Incomplete 4-byte sequence.");S=(7&S)<<18|(63&w[C++])<<12|(63&w[C++])<<6|63&w[C++]}if(S<=65535)x+=String.fromCharCode(S);else{if(!(S<=1114111))throw new Error("Code point exceeds UTF-16 limit.");S-=65536,x+=String.fromCharCode(S>>10|55296),x+=String.fromCharCode(1023&S|56320)}}return x}},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0}),function(o){o[o.Before=0]="Before",o[o.Equal=1]="Equal",o[o.After=2]="After"}(n.BoundaryPosition||(n.BoundaryPosition={})),function(o){o[o.None=0]="None",o[o.Capturing=1]="Capturing",o[o.AtTarget=2]="AtTarget",o[o.Bubbling=3]="Bubbling"}(n.EventPhase||(n.EventPhase={})),function(o){o[o.Element=1]="Element",o[o.Attribute=2]="Attribute",o[o.Text=3]="Text",o[o.CData=4]="CData",o[o.EntityReference=5]="EntityReference",o[o.Entity=6]="Entity",o[o.ProcessingInstruction=7]="ProcessingInstruction",o[o.Comment=8]="Comment",o[o.Document=9]="Document",o[o.DocumentType=10]="DocumentType",o[o.DocumentFragment=11]="DocumentFragment",o[o.Notation=12]="Notation"}(n.NodeType||(n.NodeType={})),function(o){o[o.Disconnected=1]="Disconnected",o[o.Preceding=2]="Preceding",o[o.Following=4]="Following",o[o.Contains=8]="Contains",o[o.ContainedBy=16]="ContainedBy",o[o.ImplementationSpecific=32]="ImplementationSpecific"}(n.Position||(n.Position={})),function(o){o[o.Accept=1]="Accept",o[o.Reject=2]="Reject",o[o.Skip=3]="Skip"}(n.FilterResult||(n.FilterResult={})),function(o){o[o.All=4294967295]="All",o[o.Element=1]="Element",o[o.Attribute=2]="Attribute",o[o.Text=4]="Text",o[o.CDataSection=8]="CDataSection",o[o.EntityReference=16]="EntityReference",o[o.Entity=32]="Entity",o[o.ProcessingInstruction=64]="ProcessingInstruction",o[o.Comment=128]="Comment",o[o.Document=256]="Document",o[o.DocumentType=512]="DocumentType",o[o.DocumentFragment=1024]="DocumentFragment",o[o.Notation=2048]="Notation"}(n.WhatToShow||(n.WhatToShow={})),function(o){o[o.StartToStart=0]="StartToStart",o[o.StartToEnd=1]="StartToEnd",o[o.EndToEnd=2]="EndToEnd",o[o.EndToStart=3]="EndToStart"}(n.HowToCompare||(n.HowToCompare={}))},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(241);n.Cast=o.Cast;var a=i(150);n.Guard=a.Guard;var s=i(242);n.EmptySet=s.EmptySet},function(r,n,i){var o=i(11),a=i(55).f,s=i(21),c=i(25),l=i(80),f=i(119),u=i(123);r.exports=function(d,h){var g,p,v,y,m,w=d.target,x=d.global,C=d.stat;if(g=x?o:C?o[w]||l(w,{}):(o[w]||{}).prototype)for(p in h){if(y=h[p],v=d.noTargetGet?(m=a(g,p))&&m.value:g[p],!u(x?p:w+(C?".":"#")+p,d.forced)&&v!==void 0){if(typeof y==typeof v)continue;f(y,v)}(d.sham||v&&v.sham)&&s(y,"sham",!0),c(g,p,y,d)}}},function(r,n,i){var o=i(11),a=i(81),s=i(14),c=i(58),l=i(86),f=i(124),u=a("wks"),d=o.Symbol,h=f?d:d&&d.withoutSetter||c;r.exports=function(g){return s(u,g)||(l&&s(d,g)?u[g]=d[g]:u[g]=h("Symbol."+g)),u[g]}},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(1),a=i(29),s=function(){function c(){this._features={mutationObservers:!0,customElements:!0,slots:!0,steps:!0},this._window=null,this._compareCache=new o.CompareCache,this._rangeList=new o.FixedSizeSet}return c.prototype.setFeatures=function(l){if(l===void 0&&(l=!0),o.isObject(l))for(var f in l)this._features[f]=l[f]||!1;else for(var f in this._features)this._features[f]=l},Object.defineProperty(c.prototype,"features",{get:function(){return this._features},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"window",{get:function(){return this._window===null&&(this._window=a.create_window()),this._window},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"compareCache",{get:function(){return this._compareCache},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"rangeList",{get:function(){return this._rangeList},enumerable:!0,configurable:!0}),Object.defineProperty(c,"instance",{get:function(){return c._instance||(c._instance=new c),c._instance},enumerable:!0,configurable:!0}),c}();n.dom=s.instance},function(r,n,i){var o=this&&this.__importStar||function(m){if(m&&m.__esModule)return m;var w={};if(m!=null)for(var x in m)Object.hasOwnProperty.call(m,x)&&(w[x]=m[x]);return w.default=m,w};Object.defineProperty(n,"__esModule",{value:!0});var a=o(i(228));n.base64=a;var s=o(i(146));n.byte=s;var c=o(i(147));n.byteSequence=c;var l=o(i(96));n.codePoint=l;var f=o(i(232));n.json=f;var u=o(i(233));n.list=u;var d=o(i(234));n.map=d;var h=o(i(235));n.namespace=h;var g=o(i(236));n.queue=g;var p=o(i(237));n.set=p;var v=o(i(238));n.stack=v;var y=o(i(239));n.string=y},function(r,n){r.exports=function(i){try{return!!i()}catch{return!0}}},function(r,n,i){var o,a=this&&this.__extends||(o=function(A,F){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(G,X){G.__proto__=X}||function(G,X){for(var ee in X)X.hasOwnProperty(ee)&&(G[ee]=X[ee])})(A,F)},function(A,F){function G(){this.constructor=A}o(A,F),A.prototype=F===null?Object.create(F):(G.prototype=F.prototype,new G)});Object.defineProperty(n,"__esModule",{value:!0});var s=function(A){function F(G,X){X===void 0&&(X="");var ee=A.call(this,X)||this;return ee.name=G,ee}return a(F,A),F}(Error);n.DOMException=s;var c=function(A){function F(G){return G===void 0&&(G=""),A.call(this,"DOMStringSizeError",G)||this}return a(F,A),F}(s);n.DOMStringSizeError=c;var l=function(A){function F(G){return G===void 0&&(G=""),A.call(this,"WrongDocumentError","The object is in the wrong document. "+G)||this}return a(F,A),F}(s);n.WrongDocumentError=l;var f=function(A){function F(G){return G===void 0&&(G=""),A.call(this,"NoDataAllowedError",G)||this}return a(F,A),F}(s);n.NoDataAllowedError=f;var u=function(A){function F(G){return G===void 0&&(G=""),A.call(this,"NoModificationAllowedError","The object can not be modified. "+G)||this}return a(F,A),F}(s);n.NoModificationAllowedError=u;var d=function(A){function F(G){return G===void 0&&(G=""),A.call(this,"NotSupportedError","The operation is not supported. "+G)||this}return a(F,A),F}(s);n.NotSupportedError=d;var h=function(A){function F(G){return G===void 0&&(G=""),A.call(this,"InUseAttributeError",G)||this}return a(F,A),F}(s);n.InUseAttributeError=h;var g=function(A){function F(G){return G===void 0&&(G=""),A.call(this,"InvalidStateError","The object is in an invalid state. "+G)||this}return a(F,A),F}(s);n.InvalidStateError=g;var p=function(A){function F(G){return G===void 0&&(G=""),A.call(this,"InvalidModificationError","The object can not be modified in this way. "+G)||this}return a(F,A),F}(s);n.InvalidModificationError=p;var v=function(A){function F(G){return G===void 0&&(G=""),A.call(this,"NamespaceError","The operation is not allowed by Namespaces in XML. [XMLNS] "+G)||this}return a(F,A),F}(s);n.NamespaceError=v;var y=function(A){function F(G){return G===void 0&&(G=""),A.call(this,"InvalidAccessError","The object does not support the operation or argument. "+G)||this}return a(F,A),F}(s);n.InvalidAccessError=y;var m=function(A){function F(G){return G===void 0&&(G=""),A.call(this,"ValidationError",G)||this}return a(F,A),F}(s);n.ValidationError=m;var w=function(A){function F(G){return G===void 0&&(G=""),A.call(this,"TypeMismatchError",G)||this}return a(F,A),F}(s);n.TypeMismatchError=w;var x=function(A){function F(G){return G===void 0&&(G=""),A.call(this,"SecurityError","The operation is insecure. "+G)||this}return a(F,A),F}(s);n.SecurityError=x;var C=function(A){function F(G){return G===void 0&&(G=""),A.call(this,"NetworkError","A network error occurred. "+G)||this}return a(F,A),F}(s);n.NetworkError=C;var S=function(A){function F(G){return G===void 0&&(G=""),A.call(this,"AbortError","The operation was aborted. "+G)||this}return a(F,A),F}(s);n.AbortError=S;var T=function(A){function F(G){return G===void 0&&(G=""),A.call(this,"URLMismatchError","The given URL does not match another URL. "+G)||this}return a(F,A),F}(s);n.URLMismatchError=T;var _=function(A){function F(G){return G===void 0&&(G=""),A.call(this,"QuotaExceededError","The quota has been exceeded. "+G)||this}return a(F,A),F}(s);n.QuotaExceededError=_;var E=function(A){function F(G){return G===void 0&&(G=""),A.call(this,"TimeoutError","The operation timed out. "+G)||this}return a(F,A),F}(s);n.TimeoutError=E;var b=function(A){function F(G){return G===void 0&&(G=""),A.call(this,"InvalidNodeTypeError","The supplied node is incorrect or has an incorrect ancestor for this operation. "+G)||this}return a(F,A),F}(s);n.InvalidNodeTypeError=b;var D=function(A){function F(G){return G===void 0&&(G=""),A.call(this,"DataCloneError","The object can not be cloned. "+G)||this}return a(F,A),F}(s);n.DataCloneError=D;var I=function(A){function F(G){return G===void 0&&(G=""),A.call(this,"NotImplementedError","The DOM method is not implemented by this module. "+G)||this}return a(F,A),F}(s);n.NotImplementedError=I;var P=function(A){function F(G){return G===void 0&&(G=""),A.call(this,"HierarchyRequestError","The operation would yield an incorrect node tree. "+G)||this}return a(F,A),F}(s);n.HierarchyRequestError=P;var O=function(A){function F(G){return G===void 0&&(G=""),A.call(this,"NotFoundError","The object can not be found here. "+G)||this}return a(F,A),F}(s);n.NotFoundError=O;var L=function(A){function F(G){return G===void 0&&(G=""),A.call(this,"IndexSizeError","The index is not in the allowed range. "+G)||this}return a(F,A),F}(s);n.IndexSizeError=L;var B=function(A){function F(G){return G===void 0&&(G=""),A.call(this,"SyntaxError","The string did not match the expected pattern. "+G)||this}return a(F,A),F}(s);n.SyntaxError=B;var H=function(A){function F(G){return G===void 0&&(G=""),A.call(this,"InvalidCharacterError","The string contains invalid characters. "+G)||this}return a(F,A),F}(s);n.InvalidCharacterError=H},function(r,n,i){var o=i(53),a=["kind","resolve","construct","instanceOf","predicate","represent","defaultStyle","styleAliases"],s=["scalar","sequence","mapping"];r.exports=function(c,l){var f,u;if(l=l||{},Object.keys(l).forEach(function(d){if(a.indexOf(d)===-1)throw new o('Unknown option "'+d+'" is met in definition of "'+c+'" YAML type.')}),this.tag=c,this.kind=l.kind||null,this.resolve=l.resolve||function(){return!0},this.construct=l.construct||function(d){return d},this.instanceOf=l.instanceOf||null,this.predicate=l.predicate||null,this.represent=l.represent||null,this.defaultStyle=l.defaultStyle||null,this.styleAliases=(f=l.styleAliases||null,u={},f!==null&&Object.keys(f).forEach(function(d){f[d].forEach(function(h){u[String(h)]=d})}),u),s.indexOf(this.kind)===-1)throw new o('Unknown kind "'+this.kind+'" is specified for "'+c+'" YAML type.')}},function(r,n,i){(function(o){var a=function(s){return s&&s.Math==Math&&s};r.exports=a(typeof globalThis=="object"&&globalThis)||a(typeof window=="object"&&window)||a(typeof self=="object"&&self)||a(typeof o=="object"&&o)||Function("return this")()}).call(this,i(78))},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0}),n.idl_defineConst=function(o,a,s){Object.defineProperty(o,a,{writable:!1,enumerable:!0,configurable:!1,value:s})}},function(r,n){r.exports=function(i){return typeof i=="object"?i!==null:typeof i=="function"}},function(r,n){var i={}.hasOwnProperty;r.exports=function(o,a){return i.call(o,a)}},function(r,n,i){var o=i(16),a=i(115),s=i(18),c=i(56),l=Object.defineProperty;n.f=o?l:function(f,u,d){if(s(f),u=c(u,!0),s(d),a)try{return l(f,u,d)}catch{}if("get"in d||"set"in d)throw TypeError("Accessors not supported");return"value"in d&&(f[u]=d.value),f}},function(r,n,i){var o=i(8);r.exports=!o(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!=7})},function(r,n,i){var o=this&&this.__values||function(w){var x=typeof Symbol=="function"&&Symbol.iterator,C=x&&w[x],S=0;if(C)return C.call(w);if(w&&typeof w.length=="number")return{next:function(){return w&&S>=w.length&&(w=void 0),{value:w&&w[S++],done:!w}}};throw new TypeError(x?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var a=i(3),s=i(2);function c(w,x,C){if(C===void 0&&(C=!1),C&&a.Guard.isElementNode(x)&&a.Guard.isShadowRoot(x.shadowRoot)&&x.shadowRoot._firstChild)return x.shadowRoot._firstChild;if(x._firstChild)return x._firstChild;if(x===w)return null;if(x._nextSibling)return x._nextSibling;for(var S=x._parent;S&&S!==w;){if(S._nextSibling)return S._nextSibling;S=S._parent}return null}function l(){var w;return(w={})[Symbol.iterator]=function(){return{next:function(){return{done:!0,value:null}}}},w}function f(w,x,C,S){x===void 0&&(x=!1),C===void 0&&(C=!1);for(var T=x?w:c(w,w,C);T&&S&&!S(T);)T=c(w,T,C);return T}function u(w,x,C,S,T){S===void 0&&(S=!1);for(var _=c(w,x,S);_&&T&&!T(_);)_=c(w,_,S);return _}function d(w,x,C,S){var T;return x===void 0&&(x=!1),C===void 0&&(C=!1),x||w._children.size!==0?((T={})[Symbol.iterator]=function(){var _=x?w:c(w,w,C);return{next:function(){for(;_&&S&&!S(_);)_=c(w,_,C);if(_===null)return{done:!0,value:null};var E={done:!1,value:_};return _=c(w,_,C),E}}},T):l()}function h(w,x,C){x===void 0&&(x=!1);for(var S=x?w:w._parent;S&&C&&!C(S);)S=S._parent;return S}function g(w,x,C,S){for(var T=x._parent;T&&S&&!S(T);)T=T._parent;return T}function p(w){return a.Guard.isDocumentTypeNode(w)?0:a.Guard.isCharacterDataNode(w)?w._data.length:w._children.size}function v(w,x){if(x===void 0&&(x=!1),x){var C=v(w,!1);return a.Guard.isShadowRoot(C)?v(C._host,!0):C}return w._parent?v(w._parent):w}function y(w,x,C,S){C===void 0&&(C=!1),S===void 0&&(S=!1);for(var T=C?w:S&&a.Guard.isShadowRoot(w)?w._host:w._parent;T!==null;){if(T===x)return!0;T=S&&a.Guard.isShadowRoot(T)?T._host:T._parent}return!1}function m(w){for(var x=v(w),C=0,S=f(x);S!==null;){if(C++,S===w)return C;S=u(x,S)}return-1}n.tree_getFirstDescendantNode=f,n.tree_getNextDescendantNode=u,n.tree_getDescendantNodes=d,n.tree_getDescendantElements=function(w,x,C,S){var T;return x===void 0&&(x=!1),C===void 0&&(C=!1),x||w._children.size!==0?((T={})[Symbol.iterator]=function(){var _=d(w,x,C,function(b){return a.Guard.isElementNode(b)})[Symbol.iterator](),E=_.next().value;return{next:function(){for(;E&&S&&!S(E);)E=_.next().value;if(E===null)return{done:!0,value:null};var b={done:!1,value:E};return E=_.next().value,b}}},T):l()},n.tree_getSiblingNodes=function(w,x,C){var S;return x===void 0&&(x=!1),w._parent&&w._parent._children.size!==0?((S={})[Symbol.iterator]=function(){var T=w._parent?w._parent._firstChild:null;return{next:function(){for(;T&&(C&&!C(T)||!x&&T===w);)T=T._nextSibling;if(T===null)return{done:!0,value:null};var _={done:!1,value:T};return T=T._nextSibling,_}}},S):l()},n.tree_getFirstAncestorNode=h,n.tree_getNextAncestorNode=g,n.tree_getAncestorNodes=function(w,x,C){var S;return x===void 0&&(x=!1),x||w._parent?((S={})[Symbol.iterator]=function(){var T=h(w,x,C);return{next:function(){if(T===null)return{done:!0,value:null};var _={done:!1,value:T};return T=g(0,T,x,C),_}}},S):l()},n.tree_getCommonAncestor=function(w,x){if(w===x)return w._parent;for(var C=[],S=[],T=h(w,!0);T!==null;)C.push(T),T=g(0,T);for(var _=h(x,!0);_!==null;)S.push(_),_=g(0,_);for(var E=C.length,b=S.length,D=null,I=Math.min(E,b);I>0;I--){var P=C[--E];if(P!==S[--b])break;D=P}return D},n.tree_getFollowingNode=function(w,x){if(x._firstChild)return x._firstChild;if(x._nextSibling)return x._nextSibling;for(;;){var C=x._parent;if(C===null||C===w)return null;if(C._nextSibling)return C._nextSibling;x=C}},n.tree_getPrecedingNode=function(w,x){return x===w?null:x._previousSibling?(x=x._previousSibling)._lastChild?x._lastChild:x:x._parent},n.tree_isConstrained=function w(x){var C,S,T,_,E,b;switch(x._nodeType){case s.NodeType.Document:var D=!1,I=!1;try{for(var P=o(x._children),O=P.next();!O.done;O=P.next())switch(O.value._nodeType){case s.NodeType.ProcessingInstruction:case s.NodeType.Comment:break;case s.NodeType.DocumentType:if(D||I)return!1;D=!0;break;case s.NodeType.Element:if(I)return!1;I=!0;break;default:return!1}}catch(F){C={error:F}}finally{try{O&&!O.done&&(S=P.return)&&S.call(P)}finally{if(C)throw C.error}}break;case s.NodeType.DocumentFragment:case s.NodeType.Element:try{for(var L=o(x._children),B=L.next();!B.done;B=L.next())switch(B.value._nodeType){case s.NodeType.Element:case s.NodeType.Text:case s.NodeType.ProcessingInstruction:case s.NodeType.CData:case s.NodeType.Comment:break;default:return!1}}catch(F){T={error:F}}finally{try{B&&!B.done&&(_=L.return)&&_.call(L)}finally{if(T)throw T.error}}break;case s.NodeType.DocumentType:case s.NodeType.Text:case s.NodeType.ProcessingInstruction:case s.NodeType.CData:case s.NodeType.Comment:return!x.hasChildNodes()}try{for(var H=o(x._children),A=H.next();!A.done;A=H.next())if(!w(A.value))return!1}catch(F){E={error:F}}finally{try{A&&!A.done&&(b=H.return)&&b.call(H)}finally{if(E)throw E.error}}return!0},n.tree_nodeLength=p,n.tree_isEmpty=function(w){return p(w)===0},n.tree_rootNode=v,n.tree_isDescendantOf=function(w,x,C,S){C===void 0&&(C=!1),S===void 0&&(S=!1);for(var T=f(w,C,S);T!==null;){if(T===x)return!0;T=u(w,T,C,S)}return!1},n.tree_isAncestorOf=y,n.tree_isHostIncludingAncestorOf=function w(x,C,S){if(S===void 0&&(S=!1),y(x,C,S))return!0;var T=v(x);return!(!a.Guard.isDocumentFragmentNode(T)||T._host===null||!w(T._host,C,S))},n.tree_isSiblingOf=function(w,x,C){return C===void 0&&(C=!1),w!==x?w._parent!==null&&w._parent===x._parent:!!C},n.tree_isPreceding=function(w,x){var C=m(w),S=m(x);return C!==-1&&S!==-1&&v(w)===v(x)&&S<C},n.tree_isFollowing=function(w,x){var C=m(w),S=m(x);return C!==-1&&S!==-1&&v(w)===v(x)&&S>C},n.tree_isParentOf=function(w,x){return w._parent===x},n.tree_isChildOf=function(w,x){return x._parent===w},n.tree_previousSibling=function(w){return w._previousSibling},n.tree_nextSibling=function(w){return w._nextSibling},n.tree_firstChild=function(w){return w._firstChild},n.tree_lastChild=function(w){return w._lastChild},n.tree_treePosition=m,n.tree_index=function(w){for(var x=0;w._previousSibling!==null;)x++,w=w._previousSibling;return x},n.tree_retarget=function(w,x){for(;;){if(!w||!a.Guard.isNode(w))return w;var C=v(w);if(!a.Guard.isShadowRoot(C)||x&&a.Guard.isNode(x)&&y(C,x,!0,!0))return w;w=C.host}}},function(r,n,i){var o=i(13);r.exports=function(a){if(!o(a))throw TypeError(String(a)+" is not an object");return a}},function(r,n,i){var o=i(24),a=i(130),s=i(49),c=i(43),l=i(88),f=c.set,u=c.getterFor("Array Iterator");r.exports=l(Array,"Array",function(d,h){f(this,{type:"Array Iterator",target:o(d),index:0,kind:h})},function(){var d=u(this),h=d.target,g=d.kind,p=d.index++;return!h||p>=h.length?(d.target=void 0,{value:void 0,done:!0}):g=="keys"?{value:p,done:!1}:g=="values"?{value:h[p],done:!1}:{value:[p,h[p]],done:!1}},"values"),s.Arguments=s.Array,a("keys"),a("values"),a("entries")},function(r,n,i){var o=i(90),a=i(25),s=i(202);o||a(Object.prototype,"toString",s,{unsafe:!0})},function(r,n,i){var o=i(16),a=i(15),s=i(40);r.exports=o?function(c,l,f){return a.f(c,l,s(1,f))}:function(c,l,f){return c[l]=f,c}},function(r,n,i){var o=i(137).charAt,a=i(43),s=i(88),c=a.set,l=a.getterFor("String Iterator");s(String,"String",function(f){c(this,{type:"String Iterator",string:String(f),index:0})},function(){var f,u=l(this),d=u.string,h=u.index;return h>=d.length?{value:void 0,done:!0}:(f=o(d,h),u.index+=f.length,{value:f,done:!1})})},function(r,n,i){var o=i(11),a=i(203),s=i(19),c=i(21),l=i(5),f=l("iterator"),u=l("toStringTag"),d=s.values;for(var h in a){var g=o[h],p=g&&g.prototype;if(p){if(p[f]!==d)try{c(p,f,d)}catch{p[f]=d}if(p[u]||c(p,u,h),a[h]){for(var v in s)if(p[v]!==s[v])try{c(p,v,s[v])}catch{p[v]=s[v]}}}}},function(r,n,i){var o=i(41),a=i(35);r.exports=function(s){return o(a(s))}},function(r,n,i){var o=i(11),a=i(21),s=i(14),c=i(80),l=i(117),f=i(43),u=f.get,d=f.enforce,h=String(String).split("String");(r.exports=function(g,p,v,y){var m=!!y&&!!y.unsafe,w=!!y&&!!y.enumerable,x=!!y&&!!y.noTargetGet;typeof v=="function"&&(typeof p!="string"||s(v,"name")||a(v,"name",p),d(v).source=h.join(typeof p=="string"?p:"")),g!==o?(m?!x&&g[p]&&(w=!0):delete g[p],w?g[p]=v:a(g,p,v)):w?g[p]=v:c(p,v)})(Function.prototype,"toString",function(){return typeof this=="function"&&u(this).source||l(this)})},function(r,n,i){var o=i(47),a=Math.min;r.exports=function(s){return s>0?a(o(s),9007199254740991):0}},function(r,n,i){var o=i(35);r.exports=function(a){return Object(o(a))}},function(r,n,i){var o=i(16),a=i(8),s=i(14),c=Object.defineProperty,l={},f=function(u){throw u};r.exports=function(u,d){if(s(l,u))return l[u];d||(d={});var h=[][u],g=!!s(d,"ACCESSORS")&&d.ACCESSORS,p=s(d,0)?d[0]:f,v=s(d,1)?d[1]:void 0;return l[u]=!!h&&!a(function(){if(g&&!o)return!0;var y={length:-1};g?c(y,1,{enumerable:!0,get:f}):y[1]=1,h.call(y,p,v)})}},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(148),a=i(149),s=i(151),c=i(98),l=i(153),f=i(154),u=i(155),d=i(99),h=i(100),g=i(156),p=i(157),v=i(101),y=i(158),m=i(159),w=i(160),x=i(161),C=i(162),S=i(163),T=i(164),_=i(165),E=i(166),b=i(167),D=i(168),I=i(169),P=i(170);n.create_domImplementation=function(O){return o.DOMImplementationImpl._create(O)},n.create_window=function(){return a.WindowImpl._create()},n.create_xmlDocument=function(){return new s.XMLDocumentImpl},n.create_document=function(){return new c.DocumentImpl},n.create_abortController=function(){return new l.AbortControllerImpl},n.create_abortSignal=function(){return f.AbortSignalImpl._create()},n.create_documentType=function(O,L,B,H){return u.DocumentTypeImpl._create(O,L,B,H)},n.create_element=function(O,L,B,H){return d.ElementImpl._create(O,L,B,H)},n.create_htmlElement=function(O,L,B,H){return d.ElementImpl._create(O,L,B,H)},n.create_htmlUnknownElement=function(O,L,B,H){return d.ElementImpl._create(O,L,B,H)},n.create_documentFragment=function(O){return h.DocumentFragmentImpl._create(O)},n.create_shadowRoot=function(O,L){return g.ShadowRootImpl._create(O,L)},n.create_attr=function(O,L){return p.AttrImpl._create(O,L)},n.create_text=function(O,L){return v.TextImpl._create(O,L)},n.create_cdataSection=function(O,L){return y.CDATASectionImpl._create(O,L)},n.create_comment=function(O,L){return m.CommentImpl._create(O,L)},n.create_processingInstruction=function(O,L,B){return w.ProcessingInstructionImpl._create(O,L,B)},n.create_htmlCollection=function(O,L){return L===void 0&&(L=function(){return!0}),x.HTMLCollectionImpl._create(O,L)},n.create_nodeList=function(O){return C.NodeListImpl._create(O)},n.create_nodeListStatic=function(O,L){return S.NodeListStaticImpl._create(O,L)},n.create_namedNodeMap=function(O){return T.NamedNodeMapImpl._create(O)},n.create_range=function(O,L){return _.RangeImpl._create(O,L)},n.create_nodeIterator=function(O,L,B){return E.NodeIteratorImpl._create(O,L,B)},n.create_treeWalker=function(O,L){return b.TreeWalkerImpl._create(O,L)},n.create_nodeFilter=function(){return D.NodeFilterImpl._create()},n.create_mutationRecord=function(O,L,B,H,A,F,G,X,ee){return I.MutationRecordImpl._create(O,L,B,H,A,F,G,X,ee)},n.create_domTokenList=function(O,L){return P.DOMTokenListImpl._create(O,L)}},function(r,n,i){var o=this&&this.__values||function(p){var v=typeof Symbol=="function"&&Symbol.iterator,y=v&&p[v],m=0;if(y)return y.call(p);if(p&&typeof p.length=="number")return{next:function(){return p&&m>=p.length&&(p=void 0),{value:p&&p[m++],done:!p}}};throw new TypeError(v?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var a=i(6),s=i(17),c=i(3),l=i(72),f=new Map;function u(p,v){if(v!==p._root&&s.tree_isAncestorOf(p._reference,v,!0)){if(p._pointerBeforeReference)for(;;){var y=s.tree_getFollowingNode(p._root,v);if(y!==null&&s.tree_isDescendantOf(p._root,y,!0)&&!s.tree_isDescendantOf(v,y,!0))return void(p._reference=y);if(y===null)return void(p._pointerBeforeReference=!1)}if(v._previousSibling===null)v._parent!==null&&(p._reference=v._parent);else{for(var m=v._previousSibling,w=s.tree_getFirstDescendantNode(v._previousSibling,!0,!1);w!==null;)w!==null&&(m=w),w=s.tree_getNextDescendantNode(v._previousSibling,w,!0,!1);p._reference=m}}}function d(p,v,y,m,w){if(c.Guard.isSlot(p)&&v==="name"&&w===null){if(m===y||m===null&&y===""||m===""&&y===null)return;p._name=m===null||m===""?"":m,l.shadowTree_assignSlotablesForATree(s.tree_rootNode(p))}}function h(p,v,y,m,w){if(c.Guard.isSlotable(p)&&v==="slot"&&w===null){if(m===y||m===null&&y===""||m===""&&y===null)return;p._name=m===null||m===""?"":m,l.shadowTree_isAssigned(p)&&l.shadowTree_assignSlotables(p._assignedSlot),l.shadowTree_assignASlot(p)}}function g(p,v,y,m){v==="id"&&m===null&&(p._uniqueIdentifier=y||void 0)}n.dom_runRemovingSteps=function(p,v){},n.dom_runCloningSteps=function(p,v,y,m){},n.dom_runAdoptingSteps=function(p,v){},n.dom_runAttributeChangeSteps=function(p,v,y,m,w){var x,C;a.dom.features.slots&&(h.call(p,p,v,y,m,w),d.call(p,p,v,y,m,w)),g.call(p,p,v,m,w);try{for(var S=o(p._attributeChangeSteps),T=S.next();!T.done;T=S.next())T.value.call(p,p,v,y,m,w)}catch(_){x={error:_}}finally{try{T&&!T.done&&(C=S.return)&&C.call(S)}finally{if(x)throw x.error}}},n.dom_runInsertionSteps=function(p){},n.dom_runNodeIteratorPreRemovingSteps=function(p,v){u.call(p,p,v)},n.dom_hasSupportedTokens=function(p){return f.has(p)},n.dom_getSupportedTokens=function(p){return f.get(p)||new Set},n.dom_runEventConstructingSteps=function(p){},n.dom_runChildTextContentChangeSteps=function(p){}},function(r,n,i){var o=i(4),a=i(11),s=i(46),c=i(44),l=i(16),f=i(86),u=i(124),d=i(8),h=i(14),g=i(59),p=i(13),v=i(18),y=i(27),m=i(24),w=i(56),x=i(40),C=i(60),S=i(61),T=i(82),_=i(190),E=i(85),b=i(55),D=i(15),I=i(79),P=i(21),O=i(25),L=i(81),B=i(57),H=i(45),A=i(58),F=i(5),G=i(125),X=i(126),ee=i(62),ce=i(43),Se=i(36).forEach,we=B("hidden"),_e=F("toPrimitive"),Ve=ce.set,Ge=ce.getterFor("Symbol"),Ne=Object.prototype,j=a.Symbol,M=s("JSON","stringify"),q=b.f,K=D.f,J=_.f,re=I.f,ie=L("symbols"),Re=L("op-symbols"),Fe=L("string-to-symbol-registry"),je=L("symbol-to-string-registry"),Xe=L("wks"),se=a.QObject,ue=!se||!se.prototype||!se.prototype.findChild,Pe=l&&d(function(){return C(K({},"a",{get:function(){return K(this,"a",{value:7}).a}})).a!=7})?function(nt,at,ot){var lt=q(Ne,at);lt&&delete Ne[at],K(nt,at,ot),lt&&nt!==Ne&&K(Ne,at,lt)}:K,pe=function(nt,at){var ot=ie[nt]=C(j.prototype);return Ve(ot,{type:"Symbol",tag:nt,description:at}),l||(ot.description=at),ot},Ee=u?function(nt){return typeof nt=="symbol"}:function(nt){return Object(nt)instanceof j},Qe=function(nt,at,ot){nt===Ne&&Qe(Re,at,ot),v(nt);var lt=w(at,!0);return v(ot),h(ie,lt)?(ot.enumerable?(h(nt,we)&&nt[we][lt]&&(nt[we][lt]=!1),ot=C(ot,{enumerable:x(0,!1)})):(h(nt,we)||K(nt,we,x(1,{})),nt[we][lt]=!0),Pe(nt,lt,ot)):K(nt,lt,ot)},fe=function(nt,at){v(nt);var ot=m(at),lt=S(ot).concat(Ue(ot));return Se(lt,function(_t){l&&!ft.call(ot,_t)||Qe(nt,_t,ot[_t])}),nt},ft=function(nt){var at=w(nt,!0),ot=re.call(this,at);return!(this===Ne&&h(ie,at)&&!h(Re,at))&&(!(ot||!h(this,at)||!h(ie,at)||h(this,we)&&this[we][at])||ot)},pt=function(nt,at){var ot=m(nt),lt=w(at,!0);if(ot!==Ne||!h(ie,lt)||h(Re,lt)){var _t=q(ot,lt);return!_t||!h(ie,lt)||h(ot,we)&&ot[we][lt]||(_t.enumerable=!0),_t}},dt=function(nt){var at=J(m(nt)),ot=[];return Se(at,function(lt){h(ie,lt)||h(H,lt)||ot.push(lt)}),ot},Ue=function(nt){var at=nt===Ne,ot=J(at?Re:m(nt)),lt=[];return Se(ot,function(_t){!h(ie,_t)||at&&!h(Ne,_t)||lt.push(ie[_t])}),lt};f||(O((j=function(){if(this instanceof j)throw TypeError("Symbol is not a constructor");var nt=arguments.length&&arguments[0]!==void 0?String(arguments[0]):void 0,at=A(nt),ot=function(lt){this===Ne&&ot.call(Re,lt),h(this,we)&&h(this[we],at)&&(this[we][at]=!1),Pe(this,at,x(1,lt))};return l&&ue&&Pe(Ne,at,{configurable:!0,set:ot}),pe(at,nt)}).prototype,"toString",function(){return Ge(this).tag}),O(j,"withoutSetter",function(nt){return pe(A(nt),nt)}),I.f=ft,D.f=Qe,b.f=pt,T.f=_.f=dt,E.f=Ue,G.f=function(nt){return pe(F(nt),nt)},l&&(K(j.prototype,"description",{configurable:!0,get:function(){return Ge(this).description}}),c||O(Ne,"propertyIsEnumerable",ft,{unsafe:!0}))),o({global:!0,wrap:!0,forced:!f,sham:!f},{Symbol:j}),Se(S(Xe),function(nt){X(nt)}),o({target:"Symbol",stat:!0,forced:!f},{for:function(nt){var at=String(nt);if(h(Fe,at))return Fe[at];var ot=j(at);return Fe[at]=ot,je[ot]=at,ot},keyFor:function(nt){if(!Ee(nt))throw TypeError(nt+" is not a symbol");if(h(je,nt))return je[nt]},useSetter:function(){ue=!0},useSimple:function(){ue=!1}}),o({target:"Object",stat:!0,forced:!f,sham:!l},{create:function(nt,at){return at===void 0?C(nt):fe(C(nt),at)},defineProperty:Qe,defineProperties:fe,getOwnPropertyDescriptor:pt}),o({target:"Object",stat:!0,forced:!f},{getOwnPropertyNames:dt,getOwnPropertySymbols:Ue}),o({target:"Object",stat:!0,forced:d(function(){E.f(1)})},{getOwnPropertySymbols:function(nt){return E.f(y(nt))}}),M&&o({target:"JSON",stat:!0,forced:!f||d(function(){var nt=j();return M([nt])!="[null]"||M({a:nt})!="{}"||M(Object(nt))!="{}"})},{stringify:function(nt,at,ot){for(var lt,_t=[nt],vt=1;arguments.length>vt;)_t.push(arguments[vt++]);if(lt=at,(p(at)||nt!==void 0)&&!Ee(nt))return g(at)||(at=function(Mt,Ft){if(typeof lt=="function"&&(Ft=lt.call(this,Mt,Ft)),!Ee(Ft))return Ft}),_t[1]=at,M.apply(null,_t)}}),j.prototype[_e]||P(j.prototype,_e,j.prototype.valueOf),ee(j,"Symbol"),H[we]=!0},function(r,n,i){var o=i(4),a=i(16),s=i(11),c=i(14),l=i(13),f=i(15).f,u=i(119),d=s.Symbol;if(a&&typeof d=="function"&&(!("description"in d.prototype)||d().description!==void 0)){var h={},g=function(){var w=arguments.length<1||arguments[0]===void 0?void 0:String(arguments[0]),x=this instanceof g?new d(w):w===void 0?d():d(w);return w===""&&(h[x]=!0),x};u(g,d);var p=g.prototype=d.prototype;p.constructor=g;var v=p.toString,y=String(d("test"))=="Symbol(test)",m=/^Symbol\((.*)\)[^)]+$/;f(p,"description",{configurable:!0,get:function(){var w=l(this)?this.valueOf():this,x=v.call(w);if(c(h,w))return"";var C=y?x.slice(7,-1):x.replace(m,"$1");return C===""?void 0:C}}),o({global:!0,forced:!0},{Symbol:g})}},function(r,n,i){i(126)("iterator")},function(r,n,i){var o,a=this&&this.__extends||(o=function(y,m){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(w,x){w.__proto__=x}||function(w,x){for(var C in x)x.hasOwnProperty(C)&&(w[C]=x[C])})(y,m)},function(y,m){function w(){this.constructor=y}o(y,m),y.prototype=m===null?Object.create(m):(w.prototype=m.prototype,new w)}),s=this&&this.__values||function(y){var m=typeof Symbol=="function"&&Symbol.iterator,w=m&&y[m],x=0;if(w)return w.call(y);if(y&&typeof y.length=="number")return{next:function(){return y&&x>=y.length&&(y=void 0),{value:y&&y[x++],done:!y}}};throw new TypeError(m?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var c=i(6),l=i(2),f=i(70),u=i(3),d=i(9),h=i(0),g=i(152),p=i(12),v=function(y){function m(){var w=y.call(this)||this;return w._parent=null,w._firstChild=null,w._lastChild=null,w._previousSibling=null,w._nextSibling=null,w}return a(m,y),Object.defineProperty(m.prototype,"_childNodes",{get:function(){return this.__childNodes||(this.__childNodes=h.create_nodeList(this))},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"_nodeDocument",{get:function(){return this._nodeDocumentOverride||c.dom.window._associatedDocument},set:function(w){this._nodeDocumentOverride=w},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"_registeredObserverList",{get:function(){return this.__registeredObserverList||(this.__registeredObserverList=[])},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"nodeType",{get:function(){return this._nodeType},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"nodeName",{get:function(){return u.Guard.isElementNode(this)?this._htmlUppercasedQualifiedName:u.Guard.isAttrNode(this)?this._qualifiedName:u.Guard.isExclusiveTextNode(this)?"#text":u.Guard.isCDATASectionNode(this)?"#cdata-section":u.Guard.isProcessingInstructionNode(this)?this._target:u.Guard.isCommentNode(this)?"#comment":u.Guard.isDocumentNode(this)?"#document":u.Guard.isDocumentTypeNode(this)?this._name:u.Guard.isDocumentFragmentNode(this)?"#document-fragment":""},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"baseURI",{get:function(){return g.urlSerializer(this._nodeDocument._URL)},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"isConnected",{get:function(){return u.Guard.isElementNode(this)&&h.shadowTree_isConnected(this)},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"ownerDocument",{get:function(){return this._nodeType===l.NodeType.Document?null:this._nodeDocument},enumerable:!0,configurable:!0}),m.prototype.getRootNode=function(w){return h.tree_rootNode(this,!!w&&w.composed)},Object.defineProperty(m.prototype,"parentNode",{get:function(){return this._nodeType===l.NodeType.Attribute?null:this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"parentElement",{get:function(){return this._parent&&u.Guard.isElementNode(this._parent)?this._parent:null},enumerable:!0,configurable:!0}),m.prototype.hasChildNodes=function(){return this._firstChild!==null},Object.defineProperty(m.prototype,"childNodes",{get:function(){return this._childNodes},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"firstChild",{get:function(){return this._firstChild},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"lastChild",{get:function(){return this._lastChild},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"previousSibling",{get:function(){return this._previousSibling},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"nextSibling",{get:function(){return this._nextSibling},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"nodeValue",{get:function(){return u.Guard.isAttrNode(this)?this._value:u.Guard.isCharacterDataNode(this)?this._data:null},set:function(w){w===null&&(w=""),u.Guard.isAttrNode(this)?h.attr_setAnExistingAttributeValue(this,w):u.Guard.isCharacterDataNode(this)&&h.characterData_replaceData(this,0,this._data.length,w)},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"textContent",{get:function(){return u.Guard.isDocumentFragmentNode(this)||u.Guard.isElementNode(this)?h.text_descendantTextContent(this):u.Guard.isAttrNode(this)?this._value:u.Guard.isCharacterDataNode(this)?this._data:null},set:function(w){w===null&&(w=""),u.Guard.isDocumentFragmentNode(this)||u.Guard.isElementNode(this)?h.node_stringReplaceAll(w,this):u.Guard.isAttrNode(this)?h.attr_setAnExistingAttributeValue(this,w):u.Guard.isCharacterDataNode(this)&&h.characterData_replaceData(this,0,h.tree_nodeLength(this),w)},enumerable:!0,configurable:!0}),m.prototype.normalize=function(){for(var w,x,C,S,T=[],_=h.tree_getFirstDescendantNode(this,!1,!1,function(Se){return u.Guard.isExclusiveTextNode(Se)});_!==null;)T.push(_),_=h.tree_getNextDescendantNode(this,_,!1,!1,function(Se){return u.Guard.isExclusiveTextNode(Se)});for(var E=0;E<T.length;E++){var b=T[E];if(b._parent!==null){var D=h.tree_nodeLength(b);if(D!==0){var I=[],P="";try{for(var O=(w=void 0,s(h.text_contiguousExclusiveTextNodes(b))),L=O.next();!L.done;L=O.next()){var B=L.value;I.push(B),P+=B._data}}catch(Se){w={error:Se}}finally{try{L&&!L.done&&(x=O.return)&&x.call(O)}finally{if(w)throw w.error}}if(h.characterData_replaceData(b,D,0,P),c.dom.rangeList.size!==0)for(var H=b._nextSibling;H!==null&&u.Guard.isExclusiveTextNode(H);){var A=H,F=h.tree_index(A);try{for(var G=(C=void 0,s(c.dom.rangeList)),X=G.next();!X.done;X=G.next()){var ee=X.value;ee._start[0]===A&&(ee._start[0]=b,ee._start[1]+=D),ee._end[0]===A&&(ee._end[0]=b,ee._end[1]+=D),ee._start[0]===A._parent&&ee._start[1]===F&&(ee._start[0]=b,ee._start[1]=D),ee._end[0]===A._parent&&ee._end[1]===F&&(ee._end[0]=b,ee._end[1]=D)}}catch(Se){C={error:Se}}finally{try{X&&!X.done&&(S=G.return)&&S.call(G)}finally{if(C)throw C.error}}D+=h.tree_nodeLength(H),H=H._nextSibling}for(var ce=0;ce<I.length;ce++)(B=I[ce])._parent!==null&&h.mutation_remove(B,B._parent)}else h.mutation_remove(b,b._parent)}}},m.prototype.cloneNode=function(w){if(w===void 0&&(w=!1),u.Guard.isShadowRoot(this))throw new d.NotSupportedError;return h.node_clone(this,null,w)},m.prototype.isEqualNode=function(w){return w===void 0&&(w=null),w!==null&&h.node_equals(this,w)},m.prototype.isSameNode=function(w){return w===void 0&&(w=null),this===w},m.prototype.compareDocumentPosition=function(w){if(w===this)return 0;var x=w,C=this,S=null,T=null;if(u.Guard.isAttrNode(x)&&(x=(S=x)._element),u.Guard.isAttrNode(C)&&(C=(T=C)._element,S&&x&&x===C))for(var _=0;_<C._attributeList.length;_++){var E=C._attributeList[_];if(h.node_equals(E,S))return l.Position.ImplementationSpecific|l.Position.Preceding;if(h.node_equals(E,T))return l.Position.ImplementationSpecific|l.Position.Following}return x===null||C===null||h.tree_rootNode(x)!==h.tree_rootNode(C)?l.Position.Disconnected|l.Position.ImplementationSpecific|(c.dom.compareCache.check(this,w)?l.Position.Preceding:l.Position.Following):!S&&h.tree_isAncestorOf(C,x)||T&&x===C?l.Position.Contains|l.Position.Preceding:!T&&h.tree_isDescendantOf(C,x)||S&&x===C?l.Position.ContainedBy|l.Position.Following:h.tree_isPreceding(C,x)?l.Position.Preceding:l.Position.Following},m.prototype.contains=function(w){return w!==null&&h.tree_isDescendantOf(this,w,!0)},m.prototype.lookupPrefix=function(w){return w?u.Guard.isElementNode(this)?h.node_locateANamespacePrefix(this,w):u.Guard.isDocumentNode(this)?this.documentElement===null?null:h.node_locateANamespacePrefix(this.documentElement,w):u.Guard.isDocumentTypeNode(this)||u.Guard.isDocumentFragmentNode(this)?null:u.Guard.isAttrNode(this)?this._element===null?null:h.node_locateANamespacePrefix(this._element,w):this._parent!==null&&u.Guard.isElementNode(this._parent)?h.node_locateANamespacePrefix(this._parent,w):null:null},m.prototype.lookupNamespaceURI=function(w){return h.node_locateANamespace(this,w||null)},m.prototype.isDefaultNamespace=function(w){return w||(w=null),h.node_locateANamespace(this,null)===w},m.prototype.insertBefore=function(w,x){return h.mutation_preInsert(w,this,x)},m.prototype.appendChild=function(w){return h.mutation_append(w,this)},m.prototype.replaceChild=function(w,x){return h.mutation_replace(x,w,this)},m.prototype.removeChild=function(w){return h.mutation_preRemove(w,this)},m.prototype._getTheParent=function(w){return u.Guard.isSlotable(this)&&h.shadowTree_isAssigned(this)?this._assignedSlot:this._parent},m.ELEMENT_NODE=1,m.ATTRIBUTE_NODE=2,m.TEXT_NODE=3,m.CDATA_SECTION_NODE=4,m.ENTITY_REFERENCE_NODE=5,m.ENTITY_NODE=6,m.PROCESSING_INSTRUCTION_NODE=7,m.COMMENT_NODE=8,m.DOCUMENT_NODE=9,m.DOCUMENT_TYPE_NODE=10,m.DOCUMENT_FRAGMENT_NODE=11,m.NOTATION_NODE=12,m.DOCUMENT_POSITION_DISCONNECTED=1,m.DOCUMENT_POSITION_PRECEDING=2,m.DOCUMENT_POSITION_FOLLOWING=4,m.DOCUMENT_POSITION_CONTAINS=8,m.DOCUMENT_POSITION_CONTAINED_BY=16,m.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC=32,m}(f.EventTargetImpl);n.NodeImpl=v,v.prototype._children=new u.EmptySet,p.idl_defineConst(v.prototype,"ELEMENT_NODE",1),p.idl_defineConst(v.prototype,"ATTRIBUTE_NODE",2),p.idl_defineConst(v.prototype,"TEXT_NODE",3),p.idl_defineConst(v.prototype,"CDATA_SECTION_NODE",4),p.idl_defineConst(v.prototype,"ENTITY_REFERENCE_NODE",5),p.idl_defineConst(v.prototype,"ENTITY_NODE",6),p.idl_defineConst(v.prototype,"PROCESSING_INSTRUCTION_NODE",7),p.idl_defineConst(v.prototype,"COMMENT_NODE",8),p.idl_defineConst(v.prototype,"DOCUMENT_NODE",9),p.idl_defineConst(v.prototype,"DOCUMENT_TYPE_NODE",10),p.idl_defineConst(v.prototype,"DOCUMENT_FRAGMENT_NODE",11),p.idl_defineConst(v.prototype,"NOTATION_NODE",12),p.idl_defineConst(v.prototype,"DOCUMENT_POSITION_DISCONNECTED",1),p.idl_defineConst(v.prototype,"DOCUMENT_POSITION_PRECEDING",2),p.idl_defineConst(v.prototype,"DOCUMENT_POSITION_FOLLOWING",4),p.idl_defineConst(v.prototype,"DOCUMENT_POSITION_CONTAINS",8),p.idl_defineConst(v.prototype,"DOCUMENT_POSITION_CONTAINED_BY",16),p.idl_defineConst(v.prototype,"DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC",32)},function(r,n){r.exports=function(i){if(i==null)throw TypeError("Can't call method on "+i);return i}},function(r,n,i){var o=i(87),a=i(41),s=i(27),c=i(26),l=i(128),f=[].push,u=function(d){var h=d==1,g=d==2,p=d==3,v=d==4,y=d==6,m=d==5||y;return function(w,x,C,S){for(var T,_,E=s(w),b=a(E),D=o(x,C,3),I=c(b.length),P=0,O=S||l,L=h?O(w,I):g?O(w,0):void 0;I>P;P++)if((m||P in b)&&(_=D(T=b[P],P,E),d)){if(h)L[P]=_;else if(_)switch(d){case 3:return!0;case 5:return T;case 6:return P;case 2:f.call(L,T)}else if(v)return!1}return y?-1:p||v?v:L}};r.exports={forEach:u(0),map:u(1),filter:u(2),some:u(3),every:u(4),find:u(5),findIndex:u(6)}},function(r,n,i){var o=this&&this.__values||function(E){var b=typeof Symbol=="function"&&Symbol.iterator,D=b&&E[b],I=0;if(D)return D.call(E);if(E&&typeof E.length=="number")return{next:function(){return E&&I>=E.length&&(E=void 0),{value:E&&E[I++],done:!E}}};throw new TypeError(b?"Object is not iterable.":"Symbol.iterator is not defined.")},a=this&&this.__read||function(E,b){var D=typeof Symbol=="function"&&E[Symbol.iterator];if(!D)return E;var I,P,O=D.call(E),L=[];try{for(;(b===void 0||b-- >0)&&!(I=O.next()).done;)L.push(I.value)}catch(B){P={error:B}}finally{try{I&&!I.done&&(D=O.return)&&D.call(O)}finally{if(P)throw P.error}}return L},s=this&&this.__spread||function(){for(var E=[],b=0;b<arguments.length;b++)E=E.concat(a(arguments[b]));return E};Object.defineProperty(n,"__esModule",{value:!0});var c=i(6),l=i(9),f=i(2),u=i(3),d=i(1),h=i(7),g=i(73),p=i(17),v=i(172),y=i(72),m=i(51),w=i(30),x=i(106);function C(E,b,D){var I,P,O,L,B,H,A,F,G=b._nodeType,X=E._nodeType,ee=D?D._nodeType:null;if(G!==f.NodeType.Document&&G!==f.NodeType.DocumentFragment&&G!==f.NodeType.Element)throw new l.HierarchyRequestError("Only document, document fragment and element nodes can contain child nodes. Parent node is "+b.nodeName+".");if(p.tree_isHostIncludingAncestorOf(b,E,!0))throw new l.HierarchyRequestError("The node to be inserted cannot be an inclusive ancestor of parent node. Node is "+E.nodeName+", parent node is "+b.nodeName+".");if(D!==null&&D._parent!==b)throw new l.NotFoundError("The reference child node cannot be found under parent node. Child node is "+D.nodeName+", parent node is "+b.nodeName+".");if(X!==f.NodeType.DocumentFragment&&X!==f.NodeType.DocumentType&&X!==f.NodeType.Element&&X!==f.NodeType.Text&&X!==f.NodeType.ProcessingInstruction&&X!==f.NodeType.CData&&X!==f.NodeType.Comment)throw new l.HierarchyRequestError("Only document fragment, document type, element, text, processing instruction, cdata section or comment nodes can be inserted. Node is "+E.nodeName+".");if(X===f.NodeType.Text&&G===f.NodeType.Document)throw new l.HierarchyRequestError("Cannot insert a text node as a child of a document node. Node is "+E.nodeName+".");if(X===f.NodeType.DocumentType&&G!==f.NodeType.Document)throw new l.HierarchyRequestError("A document type node can only be inserted under a document node. Parent node is "+b.nodeName+".");if(G===f.NodeType.Document){if(X===f.NodeType.DocumentFragment){var ce=0;try{for(var Se=o(E._children),we=Se.next();!we.done;we=Se.next()){var _e=we.value;if(_e._nodeType===f.NodeType.Element)ce++;else if(_e._nodeType===f.NodeType.Text)throw new l.HierarchyRequestError("Cannot insert text a node as a child of a document node. Node is "+_e.nodeName+".")}}catch(re){I={error:re}}finally{try{we&&!we.done&&(P=Se.return)&&P.call(Se)}finally{if(I)throw I.error}}if(ce>1)throw new l.HierarchyRequestError("A document node can only have one document element node. Document fragment to be inserted has "+ce+" element nodes.");if(ce===1){try{for(var Ve=o(b._children),Ge=Ve.next();!Ge.done;Ge=Ve.next())if(Ge.value._nodeType===f.NodeType.Element)throw new l.HierarchyRequestError("The document node already has a document element node.")}catch(re){O={error:re}}finally{try{Ge&&!Ge.done&&(L=Ve.return)&&L.call(Ve)}finally{if(O)throw O.error}}if(D){if(ee===f.NodeType.DocumentType)throw new l.HierarchyRequestError("Cannot insert an element node before a document type node.");for(var Ne=D._nextSibling;Ne;){if(Ne._nodeType===f.NodeType.DocumentType)throw new l.HierarchyRequestError("Cannot insert an element node before a document type node.");Ne=Ne._nextSibling}}}}else if(X===f.NodeType.Element){try{for(var j=o(b._children),M=j.next();!M.done;M=j.next())if(M.value._nodeType===f.NodeType.Element)throw new l.HierarchyRequestError("Document already has a document element node. Node is "+E.nodeName+".")}catch(re){B={error:re}}finally{try{M&&!M.done&&(H=j.return)&&H.call(j)}finally{if(B)throw B.error}}if(D){if(ee===f.NodeType.DocumentType)throw new l.HierarchyRequestError("Cannot insert an element node before a document type node. Node is "+E.nodeName+".");for(Ne=D._nextSibling;Ne;){if(Ne._nodeType===f.NodeType.DocumentType)throw new l.HierarchyRequestError("Cannot insert an element node before a document type node. Node is "+E.nodeName+".");Ne=Ne._nextSibling}}}else if(X===f.NodeType.DocumentType){try{for(var q=o(b._children),K=q.next();!K.done;K=q.next())if(K.value._nodeType===f.NodeType.DocumentType)throw new l.HierarchyRequestError("Document already has a document type node. Node is "+E.nodeName+".")}catch(re){A={error:re}}finally{try{K&&!K.done&&(F=q.return)&&F.call(q)}finally{if(A)throw A.error}}if(D)for(var J=D._previousSibling;J;){if(J._nodeType===f.NodeType.Element)throw new l.HierarchyRequestError("Cannot insert a document type node before an element node. Node is "+E.nodeName+".");J=J._previousSibling}else for(J=b._firstChild;J;){if(J._nodeType===f.NodeType.Element)throw new l.HierarchyRequestError("Cannot insert a document type node before an element node. Node is "+E.nodeName+".");J=J._nextSibling}}}}function S(E,b,D){C(E,b,D);var I=D;return I===E&&(I=E._nextSibling),x.document_adopt(E,b._nodeDocument),T(E,b,I),E}function T(E,b,D,I){var P,O;if(D!==null||E._nodeType===f.NodeType.DocumentFragment){var L=E._nodeType===f.NodeType.DocumentFragment?E._children.size:1;if(D!==null&&c.dom.rangeList.size!==0){var B=p.tree_index(D);try{for(var H=o(c.dom.rangeList),A=H.next();!A.done;A=H.next()){var F=A.value;F._start[0]===b&&F._start[1]>B&&(F._start[1]+=L),F._end[0]===b&&F._end[1]>B&&(F._end[1]+=L)}}catch(Ge){P={error:Ge}}finally{try{A&&!A.done&&(O=H.return)&&O.call(H)}finally{if(P)throw P.error}}}var G=E._nodeType===f.NodeType.DocumentFragment?new(Array.bind.apply(Array,s([void 0],E._children))):[E];if(E._nodeType===f.NodeType.DocumentFragment)for(;E._firstChild;)_(E._firstChild,E,!0);c.dom.features.mutationObservers&&E._nodeType===f.NodeType.DocumentFragment&&m.observer_queueTreeMutationRecord(E,[],G,null,null);for(var X=D?D._previousSibling:b._lastChild,ee=D===null?-1:p.tree_index(D),ce=0;ce<G.length;ce++){var Se=G[ce];if(u.Guard.isElementNode(Se)&&(u.Guard.isDocumentNode(b)&&(b._documentElement=Se),Se._nodeDocument._hasNamespaces||Se._namespace===null&&Se._namespacePrefix===null||(Se._nodeDocument._hasNamespaces=!0)),Se._parent=b,D===null?h.set.append(b._children,Se):(h.set.insert(b._children,Se,ee),ee++),b._firstChild===null)Se._previousSibling=null,Se._nextSibling=null,b._firstChild=Se,b._lastChild=Se;else{var we=D?D._previousSibling:b._lastChild,_e=D||null;Se._previousSibling=we,Se._nextSibling=_e,we&&(we._nextSibling=Se),_e&&(_e._previousSibling=Se),we||(b._firstChild=Se),_e||(b._lastChild=Se)}c.dom.features.slots&&b._shadowRoot!==null&&u.Guard.isSlotable(Se)&&y.shadowTree_assignASlot(Se),c.dom.features.steps&&u.Guard.isTextNode(Se)&&w.dom_runChildTextContentChangeSteps(b),c.dom.features.slots&&u.Guard.isShadowRoot(p.tree_rootNode(b))&&u.Guard.isSlot(b)&&d.isEmpty(b._assignedNodes)&&y.shadowTree_signalASlotChange(b),c.dom.features.slots&&y.shadowTree_assignSlotablesForATree(p.tree_rootNode(Se));for(var Ve=p.tree_getFirstDescendantNode(Se,!0,!0);Ve!==null;)c.dom.features.steps&&w.dom_runInsertionSteps(Ve),c.dom.features.customElements&&u.Guard.isElementNode(Ve)&&y.shadowTree_isConnected(Ve)&&(u.Guard.isCustomElementNode(Ve)?g.customElement_enqueueACustomElementCallbackReaction(Ve,"connectedCallback",[]):g.customElement_tryToUpgrade(Ve)),Ve=p.tree_getNextDescendantNode(Se,Ve,!0,!0)}c.dom.features.mutationObservers&&(I||m.observer_queueTreeMutationRecord(b,G,[],X,D))}else(function(Ge,Ne,j){var M=Ne._lastChild;if(u.Guard.isElementNode(Ge)&&(u.Guard.isDocumentNode(Ne)&&(Ne._documentElement=Ge),Ge._nodeDocument._hasNamespaces||Ge._namespace===null&&Ge._namespacePrefix===null||(Ge._nodeDocument._hasNamespaces=!0)),Ge._parent=Ne,Ne._children.add(Ge),Ne._firstChild===null)Ge._previousSibling=null,Ge._nextSibling=null,Ne._firstChild=Ge,Ne._lastChild=Ge;else{var q=Ne._lastChild;Ge._previousSibling=q,Ge._nextSibling=null,q&&(q._nextSibling=Ge),q||(Ne._firstChild=Ge),Ne._lastChild=Ge}c.dom.features.slots&&Ne._shadowRoot!==null&&u.Guard.isSlotable(Ge)&&y.shadowTree_assignASlot(Ge),c.dom.features.steps&&u.Guard.isTextNode(Ge)&&w.dom_runChildTextContentChangeSteps(Ne),c.dom.features.slots&&u.Guard.isShadowRoot(p.tree_rootNode(Ne))&&u.Guard.isSlot(Ne)&&d.isEmpty(Ne._assignedNodes)&&y.shadowTree_signalASlotChange(Ne),c.dom.features.slots&&y.shadowTree_assignSlotablesForATree(p.tree_rootNode(Ge)),c.dom.features.steps&&w.dom_runInsertionSteps(Ge),c.dom.features.customElements&&u.Guard.isElementNode(Ge)&&y.shadowTree_isConnected(Ge)&&(u.Guard.isCustomElementNode(Ge)?g.customElement_enqueueACustomElementCallbackReaction(Ge,"connectedCallback",[]):g.customElement_tryToUpgrade(Ge)),c.dom.features.mutationObservers&&(j||m.observer_queueTreeMutationRecord(Ne,[Ge],[],M,null))})(E,b,I)}function _(E,b,D){var I,P,O,L,B,H,A,F;if(c.dom.rangeList.size!==0){var G=p.tree_index(E);try{for(var X=o(c.dom.rangeList),ee=X.next();!ee.done;ee=X.next()){var ce=ee.value;p.tree_isDescendantOf(E,ce._start[0],!0)&&(ce._start=[b,G]),p.tree_isDescendantOf(E,ce._end[0],!0)&&(ce._end=[b,G]),ce._start[0]===b&&ce._start[1]>G&&ce._start[1]--,ce._end[0]===b&&ce._end[1]>G&&ce._end[1]--}}catch(Fe){I={error:Fe}}finally{try{ee&&!ee.done&&(P=X.return)&&P.call(X)}finally{if(I)throw I.error}}try{for(var Se=o(c.dom.rangeList),we=Se.next();!we.done;we=Se.next())(ce=we.value)._start[0]===b&&ce._start[1]>G&&(ce._start[1]-=1),ce._end[0]===b&&ce._end[1]>G&&(ce._end[1]-=1)}catch(Fe){O={error:Fe}}finally{try{we&&!we.done&&(L=Se.return)&&L.call(Se)}finally{if(O)throw O.error}}}if(c.dom.features.steps)try{for(var _e=o(v.nodeIterator_iteratorList()),Ve=_e.next();!Ve.done;Ve=_e.next()){var Ge=Ve.value;Ge._root._nodeDocument===E._nodeDocument&&w.dom_runNodeIteratorPreRemovingSteps(Ge,E)}}catch(Fe){B={error:Fe}}finally{try{Ve&&!Ve.done&&(H=_e.return)&&H.call(_e)}finally{if(B)throw B.error}}var Ne=E._previousSibling,j=E._nextSibling;u.Guard.isDocumentNode(b)&&u.Guard.isElementNode(E)&&(b._documentElement=null),E._parent=null,b._children.delete(E);var M=E._previousSibling,q=E._nextSibling;E._previousSibling=null,E._nextSibling=null,M&&(M._nextSibling=q),q&&(q._previousSibling=M),M||(b._firstChild=q),q||(b._lastChild=M),c.dom.features.slots&&u.Guard.isSlotable(E)&&E._assignedSlot!==null&&y.shadowTree_isAssigned(E)&&y.shadowTree_assignSlotables(E._assignedSlot),c.dom.features.slots&&u.Guard.isShadowRoot(p.tree_rootNode(b))&&u.Guard.isSlot(b)&&d.isEmpty(b._assignedNodes)&&y.shadowTree_signalASlotChange(b),c.dom.features.slots&&p.tree_getFirstDescendantNode(E,!0,!1,function(Fe){return u.Guard.isSlot(Fe)})!==null&&(y.shadowTree_assignSlotablesForATree(p.tree_rootNode(b)),y.shadowTree_assignSlotablesForATree(E)),c.dom.features.steps&&w.dom_runRemovingSteps(E,b),c.dom.features.customElements&&u.Guard.isCustomElementNode(E)&&g.customElement_enqueueACustomElementCallbackReaction(E,"disconnectedCallback",[]);for(var K=p.tree_getFirstDescendantNode(E,!1,!0);K!==null;)c.dom.features.steps&&w.dom_runRemovingSteps(K,E),c.dom.features.customElements&&u.Guard.isCustomElementNode(K)&&g.customElement_enqueueACustomElementCallbackReaction(K,"disconnectedCallback",[]),K=p.tree_getNextDescendantNode(E,K,!1,!0);if(c.dom.features.mutationObservers)for(var J=p.tree_getFirstAncestorNode(b,!0);J!==null;){try{for(var re=(A=void 0,o(J._registeredObserverList)),ie=re.next();!ie.done;ie=re.next()){var Re=ie.value;Re.options.subtree&&E._registeredObserverList.push({observer:Re.observer,options:Re.options,source:Re})}}catch(Fe){A={error:Fe}}finally{try{ie&&!ie.done&&(F=re.return)&&F.call(re)}finally{if(A)throw A.error}}J=p.tree_getNextAncestorNode(b,J,!0)}c.dom.features.mutationObservers&&(D||m.observer_queueTreeMutationRecord(b,[],[E],Ne,j)),c.dom.features.steps&&u.Guard.isTextNode(E)&&w.dom_runChildTextContentChangeSteps(b)}n.mutation_ensurePreInsertionValidity=C,n.mutation_preInsert=S,n.mutation_insert=T,n.mutation_append=function(E,b){return S(E,b,null)},n.mutation_replace=function(E,b,D){var I,P,O,L,B,H,A,F;if(D._nodeType!==f.NodeType.Document&&D._nodeType!==f.NodeType.DocumentFragment&&D._nodeType!==f.NodeType.Element)throw new l.HierarchyRequestError("Only document, document fragment and element nodes can contain child nodes. Parent node is "+D.nodeName+".");if(p.tree_isHostIncludingAncestorOf(D,b,!0))throw new l.HierarchyRequestError("The node to be inserted cannot be an ancestor of parent node. Node is "+b.nodeName+", parent node is "+D.nodeName+".");if(E._parent!==D)throw new l.NotFoundError("The reference child node cannot be found under parent node. Child node is "+E.nodeName+", parent node is "+D.nodeName+".");if(b._nodeType!==f.NodeType.DocumentFragment&&b._nodeType!==f.NodeType.DocumentType&&b._nodeType!==f.NodeType.Element&&b._nodeType!==f.NodeType.Text&&b._nodeType!==f.NodeType.ProcessingInstruction&&b._nodeType!==f.NodeType.CData&&b._nodeType!==f.NodeType.Comment)throw new l.HierarchyRequestError("Only document fragment, document type, element, text, processing instruction, cdata section or comment nodes can be inserted. Node is "+b.nodeName+".");if(b._nodeType===f.NodeType.Text&&D._nodeType===f.NodeType.Document)throw new l.HierarchyRequestError("Cannot insert a text node as a child of a document node. Node is "+b.nodeName+".");if(b._nodeType===f.NodeType.DocumentType&&D._nodeType!==f.NodeType.Document)throw new l.HierarchyRequestError("A document type node can only be inserted under a document node. Parent node is "+D.nodeName+".");if(D._nodeType===f.NodeType.Document){if(b._nodeType===f.NodeType.DocumentFragment){var G=0;try{for(var X=o(b._children),ee=X.next();!ee.done;ee=X.next()){var ce=ee.value;if(ce._nodeType===f.NodeType.Element)G++;else if(ce._nodeType===f.NodeType.Text)throw new l.HierarchyRequestError("Cannot insert text a node as a child of a document node. Node is "+ce.nodeName+".")}}catch(Re){I={error:Re}}finally{try{ee&&!ee.done&&(P=X.return)&&P.call(X)}finally{if(I)throw I.error}}if(G>1)throw new l.HierarchyRequestError("A document node can only have one document element node. Document fragment to be inserted has "+G+" element nodes.");if(G===1){try{for(var Se=o(D._children),we=Se.next();!we.done;we=Se.next())if((M=we.value)._nodeType===f.NodeType.Element&&M!==E)throw new l.HierarchyRequestError("The document node already has a document element node.")}catch(Re){O={error:Re}}finally{try{we&&!we.done&&(L=Se.return)&&L.call(Se)}finally{if(O)throw O.error}}for(var _e=E._nextSibling;_e;){if(_e._nodeType===f.NodeType.DocumentType)throw new l.HierarchyRequestError("Cannot insert an element node before a document type node.");_e=_e._nextSibling}}}else if(b._nodeType===f.NodeType.Element){try{for(var Ve=o(D._children),Ge=Ve.next();!Ge.done;Ge=Ve.next())if((M=Ge.value)._nodeType===f.NodeType.Element&&M!==E)throw new l.HierarchyRequestError("Document already has a document element node. Node is "+b.nodeName+".")}catch(Re){B={error:Re}}finally{try{Ge&&!Ge.done&&(H=Ve.return)&&H.call(Ve)}finally{if(B)throw B.error}}for(_e=E._nextSibling;_e;){if(_e._nodeType===f.NodeType.DocumentType)throw new l.HierarchyRequestError("Cannot insert an element node before a document type node. Node is "+b.nodeName+".");_e=_e._nextSibling}}else if(b._nodeType===f.NodeType.DocumentType){try{for(var Ne=o(D._children),j=Ne.next();!j.done;j=Ne.next()){var M;if((M=j.value)._nodeType===f.NodeType.DocumentType&&M!==E)throw new l.HierarchyRequestError("Document already has a document type node. Node is "+b.nodeName+".")}}catch(Re){A={error:Re}}finally{try{j&&!j.done&&(F=Ne.return)&&F.call(Ne)}finally{if(A)throw A.error}}for(var q=E._previousSibling;q;){if(q._nodeType===f.NodeType.Element)throw new l.HierarchyRequestError("Cannot insert a document type node before an element node. Node is "+b.nodeName+".");q=q._previousSibling}}}var K=E._nextSibling;K===b&&(K=b._nextSibling);var J=E._previousSibling;x.document_adopt(b,D._nodeDocument);var re=[];E._parent!==null&&(re.push(E),_(E,E._parent,!0));var ie=[];return b._nodeType===f.NodeType.DocumentFragment?ie=Array.from(b._children):ie.push(b),T(b,D,K,!0),c.dom.features.mutationObservers&&m.observer_queueTreeMutationRecord(D,ie,re,J,K),E},n.mutation_replaceAll=function(E,b){var D,I;E!==null&&x.document_adopt(E,b._nodeDocument);var P=Array.from(b._children),O=[];E&&E._nodeType===f.NodeType.DocumentFragment?O=Array.from(E._children):E!==null&&O.push(E);try{for(var L=o(P),B=L.next();!B.done;B=L.next())_(B.value,b,!0)}catch(H){D={error:H}}finally{try{B&&!B.done&&(I=L.return)&&I.call(L)}finally{if(D)throw D.error}}E!==null&&T(E,b,null,!0),c.dom.features.mutationObservers&&m.observer_queueTreeMutationRecord(b,O,P,null,null)},n.mutation_preRemove=function(E,b){if(E._parent!==b)throw new l.NotFoundError("The child node cannot be found under parent node. Child node is "+E.nodeName+", parent node is "+b.nodeName+".");return _(E,b),E},n.mutation_remove=_},function(r,n,i){function o(a){return a==null}r.exports.isNothing=o,r.exports.isObject=function(a){return typeof a=="object"&&a!==null},r.exports.toArray=function(a){return Array.isArray(a)?a:o(a)?[]:[a]},r.exports.repeat=function(a,s){var c,l="";for(c=0;c<s;c+=1)l+=a;return l},r.exports.isNegativeZero=function(a){return a===0&&Number.NEGATIVE_INFINITY===1/a},r.exports.extend=function(a,s){var c,l,f,u;if(s)for(c=0,l=(u=Object.keys(s)).length;c<l;c+=1)a[f=u[c]]=s[f];return a}},function(r,n,i){var o=i(38),a=i(53),s=i(10);function c(f,u,d){var h=[];return f.include.forEach(function(g){d=c(g,u,d)}),f[u].forEach(function(g){d.forEach(function(p,v){p.tag===g.tag&&p.kind===g.kind&&h.push(v)}),d.push(g)}),d.filter(function(g,p){return h.indexOf(p)===-1})}function l(f){this.include=f.include||[],this.implicit=f.implicit||[],this.explicit=f.explicit||[],this.implicit.forEach(function(u){if(u.loadKind&&u.loadKind!=="scalar")throw new a("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.")}),this.compiledImplicit=c(this,"implicit",[]),this.compiledExplicit=c(this,"explicit",[]),this.compiledTypeMap=function(){var u,d,h={scalar:{},sequence:{},mapping:{},fallback:{}};function g(p){h[p.kind][p.tag]=h.fallback[p.tag]=p}for(u=0,d=arguments.length;u<d;u+=1)arguments[u].forEach(g);return h}(this.compiledImplicit,this.compiledExplicit)}l.DEFAULT=null,l.create=function(){var f,u;switch(arguments.length){case 1:f=l.DEFAULT,u=arguments[0];break;case 2:f=arguments[0],u=arguments[1];break;default:throw new a("Wrong number of arguments for Schema.create function")}if(f=o.toArray(f),u=o.toArray(u),!f.every(function(d){return d instanceof l}))throw new a("Specified list of super schemas (or a single Schema object) contains a non-Schema object.");if(!u.every(function(d){return d instanceof s}))throw new a("Specified list of YAML types (or a single Type object) contains a non-Type object.");return new l({include:f,explicit:u})},r.exports=l},function(r,n){r.exports=function(i,o){return{enumerable:!(1&i),configurable:!(2&i),writable:!(4&i),value:o}}},function(r,n,i){var o=i(8),a=i(42),s="".split;r.exports=o(function(){return!Object("z").propertyIsEnumerable(0)})?function(c){return a(c)=="String"?s.call(c,""):Object(c)}:Object},function(r,n){var i={}.toString;r.exports=function(o){return i.call(o).slice(8,-1)}},function(r,n,i){var o,a,s,c=i(186),l=i(11),f=i(13),u=i(21),d=i(14),h=i(57),g=i(45),p=l.WeakMap;if(c){var v=new p,y=v.get,m=v.has,w=v.set;o=function(C,S){return w.call(v,C,S),S},a=function(C){return y.call(v,C)||{}},s=function(C){return m.call(v,C)}}else{var x=h("state");g[x]=!0,o=function(C,S){return u(C,x,S),S},a=function(C){return d(C,x)?C[x]:{}},s=function(C){return d(C,x)}}r.exports={set:o,get:a,has:s,enforce:function(C){return s(C)?a(C):o(C,{})},getterFor:function(C){return function(S){var T;if(!f(S)||(T=a(S)).type!==C)throw TypeError("Incompatible receiver, "+C+" required");return T}}}},function(r,n){r.exports=!1},function(r,n){r.exports={}},function(r,n,i){var o=i(120),a=i(11),s=function(c){return typeof c=="function"?c:void 0};r.exports=function(c,l){return arguments.length<2?s(o[c])||s(a[c]):o[c]&&o[c][l]||a[c]&&a[c][l]}},function(r,n){var i=Math.ceil,o=Math.floor;r.exports=function(a){return isNaN(a=+a)?0:(a>0?o:i)(a)}},function(r,n,i){var o=i(8);r.exports=function(a,s){var c=[][a];return!!c&&o(function(){c.call(null,s||function(){throw 1},1)})}},function(r,n){r.exports={}},function(r,n,i){i(31),i(32),i(33),i(220),i(64),i(19),i(65),i(20),i(68),i(66),i(92),i(144),i(22),i(94),i(23);var o=this&&this.__values||function(g){var p=typeof Symbol=="function"&&Symbol.iterator,v=p&&g[p],y=0;if(v)return v.call(g);if(g&&typeof g.length=="number")return{next:function(){return g&&y>=g.length&&(g=void 0),{value:g&&g[y++],done:!g}}};throw new TypeError(p?"Object is not iterable.":"Symbol.iterator is not defined.")},a=this&&this.__read||function(g,p){var v=typeof Symbol=="function"&&g[Symbol.iterator];if(!v)return g;var y,m,w=v.call(g),x=[];try{for(;(p===void 0||p-- >0)&&!(y=w.next()).done;)x.push(y.value)}catch(C){m={error:C}}finally{try{y&&!y.done&&(v=w.return)&&v.call(w)}finally{if(m)throw m.error}}return x},s=this&&this.__spread||function(){for(var g=[],p=0;p<arguments.length;p++)g=g.concat(a(arguments[p]));return g};Object.defineProperty(n,"__esModule",{value:!0});var c=i(2),l=i(69),f=i(95),u=i(7),d=i(0),h=function(){function g(p){this.level=0,this._builderOptions=p}return g.prototype.declaration=function(p,v,y){},g.prototype.docType=function(p,v,y){},g.prototype.comment=function(p){},g.prototype.text=function(p){},g.prototype.instruction=function(p,v){},g.prototype.cdata=function(p){},g.prototype.openTagBegin=function(p){},g.prototype.openTagEnd=function(p,v,y){},g.prototype.closeTag=function(p){},g.prototype.attributes=function(p){var v,y;try{for(var m=o(p),w=m.next();!w.done;w=m.next()){var x=w.value;this.attribute(x[1]===null?x[2]:x[1]+":"+x[2],x[3])}}catch(C){v={error:C}}finally{try{w&&!w.done&&(y=m.return)&&y.call(m)}finally{if(v)throw v.error}}},g.prototype.attribute=function(p,v){},g.prototype.beginElement=function(p){},g.prototype.endElement=function(p){},g.prototype.serializeNode=function(p,v){var y=p._nodeDocument!==void 0&&p._nodeDocument._hasNamespaces;if(this.level=0,this.currentNode=p,y){var m=new f.NamespacePrefixMap;m.set("xml",u.namespace.XML),this._serializeNodeNS(p,null,m,{value:1},v)}else this._serializeNode(p,v)},g.prototype._serializeNodeNS=function(p,v,y,m,w){switch(this.currentNode=p,p.nodeType){case c.NodeType.Element:this._serializeElementNS(p,v,y,m,w);break;case c.NodeType.Document:this._serializeDocumentNS(p,v,y,m,w);break;case c.NodeType.Comment:this._serializeComment(p,w);break;case c.NodeType.Text:this._serializeText(p,w);break;case c.NodeType.DocumentFragment:this._serializeDocumentFragmentNS(p,v,y,m,w);break;case c.NodeType.DocumentType:this._serializeDocumentType(p,w);break;case c.NodeType.ProcessingInstruction:this._serializeProcessingInstruction(p,w);break;case c.NodeType.CData:this._serializeCData(p,w);break;default:throw new Error("Unknown node type: "+p.nodeType)}},g.prototype._serializeNode=function(p,v){switch(this.currentNode=p,p.nodeType){case c.NodeType.Element:this._serializeElement(p,v);break;case c.NodeType.Document:this._serializeDocument(p,v);break;case c.NodeType.Comment:this._serializeComment(p,v);break;case c.NodeType.Text:this._serializeText(p,v);break;case c.NodeType.DocumentFragment:this._serializeDocumentFragment(p,v);break;case c.NodeType.DocumentType:this._serializeDocumentType(p,v);break;case c.NodeType.ProcessingInstruction:this._serializeProcessingInstruction(p,v);break;case c.NodeType.CData:this._serializeCData(p,v);break;default:throw new Error("Unknown node type: "+p.nodeType)}},g.prototype._serializeElementNS=function(p,v,y,m,w){var x,C,S=[];if(w&&(p.localName.indexOf(":")!==-1||!d.xml_isName(p.localName)))throw new Error("Node local name contains invalid characters (well-formed required).");var T="",_=!1,E=!1,b=y.copy(),D={},I=this._recordNamespaceInformation(p,b,D),P=v,O=p.namespaceURI;if(P===O)I!==null&&(E=!0),T=O===u.namespace.XML?"xml:"+p.localName:p.localName,this.beginElement(T),this.openTagBegin(T);else{var L=p.prefix,B=null;if(L===null&&O===I||(B=b.get(L,O)),L==="xmlns"){if(w)throw new Error("An element cannot have the 'xmlns' prefix (well-formed required).");B=L}B!==null?(T=B+":"+p.localName,I!==null&&I!==u.namespace.XML&&(P=I||null),this.beginElement(T),this.openTagBegin(T)):L!==null?(L in D&&(L=this._generatePrefix(O,b,m)),b.set(L,O),T+=L+":"+p.localName,this.beginElement(T),this.openTagBegin(T),S.push([null,"xmlns",L,this._serializeAttributeValue(O,w)]),I!==null&&(P=I||null)):I===null||I!==null&&I!==O?(E=!0,T+=p.localName,P=O,this.beginElement(T),this.openTagBegin(T),S.push([null,null,"xmlns",this._serializeAttributeValue(O,w)])):(T+=p.localName,P=O,this.beginElement(T),this.openTagBegin(T))}S.push.apply(S,s(this._serializeAttributesNS(p,b,m,D,E,w))),this.attributes(S);var H=O===u.namespace.HTML;if(H&&p.childNodes.length===0&&g._VoidElementNames.has(p.localName)?(this.openTagEnd(T,!0,!0),this.endElement(T),_=!0):H||p.childNodes.length!==0?this.openTagEnd(T,!1,!1):(this.openTagEnd(T,!0,!1),this.endElement(T),_=!0),!_){if(!(H&&p.localName==="template"))try{for(var A=o(p.childNodes),F=A.next();!F.done;F=A.next()){var G=F.value;this.level++,this._serializeNodeNS(G,P,b,m,w),this.level--}}catch(X){x={error:X}}finally{try{F&&!F.done&&(C=A.return)&&C.call(A)}finally{if(x)throw x.error}}this.closeTag(T),this.endElement(T)}},g.prototype._serializeElement=function(p,v){var y,m;if(v&&(p.localName.indexOf(":")!==-1||!d.xml_isName(p.localName)))throw new Error("Node local name contains invalid characters (well-formed required).");var w=!1,x=p.localName;this.beginElement(x),this.openTagBegin(x);var C=this._serializeAttributes(p,v);if(this.attributes(C),p.hasChildNodes()?this.openTagEnd(x,!1,!1):(this.openTagEnd(x,!0,!1),this.endElement(x),w=!0),!w){try{for(var S=o(p._children),T=S.next();!T.done;T=S.next()){var _=T.value;this.level++,this._serializeNode(_,v),this.level--}}catch(E){y={error:E}}finally{try{T&&!T.done&&(m=S.return)&&m.call(S)}finally{if(y)throw y.error}}this.closeTag(x),this.endElement(x)}},g.prototype._serializeDocumentNS=function(p,v,y,m,w){var x,C;if(w&&p.documentElement===null)throw new Error("Missing document element (well-formed required).");try{for(var S=o(p.childNodes),T=S.next();!T.done;T=S.next()){var _=T.value;this._serializeNodeNS(_,v,y,m,w)}}catch(E){x={error:E}}finally{try{T&&!T.done&&(C=S.return)&&C.call(S)}finally{if(x)throw x.error}}},g.prototype._serializeDocument=function(p,v){var y,m;if(v&&p.documentElement===null)throw new Error("Missing document element (well-formed required).");try{for(var w=o(p._children),x=w.next();!x.done;x=w.next()){var C=x.value;this._serializeNode(C,v)}}catch(S){y={error:S}}finally{try{x&&!x.done&&(m=w.return)&&m.call(w)}finally{if(y)throw y.error}}},g.prototype._serializeComment=function(p,v){if(v&&(!d.xml_isLegalChar(p.data)||p.data.indexOf("--")!==-1||p.data.endsWith("-")))throw new Error("Comment data contains invalid characters (well-formed required).");this.comment(p.data)},g.prototype._serializeText=function(p,v){if(v&&!d.xml_isLegalChar(p.data))throw new Error("Text data contains invalid characters (well-formed required).");var y=p.data.replace(/(?!&([^&;]*);)&/g,"&").replace(/</g,"<").replace(/>/g,">");this.text(y)},g.prototype._serializeDocumentFragmentNS=function(p,v,y,m,w){var x,C;try{for(var S=o(p.childNodes),T=S.next();!T.done;T=S.next()){var _=T.value;this._serializeNodeNS(_,v,y,m,w)}}catch(E){x={error:E}}finally{try{T&&!T.done&&(C=S.return)&&C.call(S)}finally{if(x)throw x.error}}},g.prototype._serializeDocumentFragment=function(p,v){var y,m;try{for(var w=o(p._children),x=w.next();!x.done;x=w.next()){var C=x.value;this._serializeNode(C,v)}}catch(S){y={error:S}}finally{try{x&&!x.done&&(m=w.return)&&m.call(w)}finally{if(y)throw y.error}}},g.prototype._serializeDocumentType=function(p,v){if(v&&!d.xml_isPubidChar(p.publicId))throw new Error("DocType public identifier does not match PubidChar construct (well-formed required).");if(v&&(!d.xml_isLegalChar(p.systemId)||p.systemId.indexOf('"')!==-1&&p.systemId.indexOf("'")!==-1))throw new Error("DocType system identifier contains invalid characters (well-formed required).");this.docType(p.name,p.publicId,p.systemId)},g.prototype._serializeProcessingInstruction=function(p,v){if(v&&(p.target.indexOf(":")!==-1||/^xml$/i.test(p.target)))throw new Error("Processing instruction target contains invalid characters (well-formed required).");if(v&&(!d.xml_isLegalChar(p.data)||p.data.indexOf("?>")!==-1))throw new Error("Processing instruction data contains invalid characters (well-formed required).");this.instruction(p.target,p.data)},g.prototype._serializeCData=function(p,v){if(v&&p.data.indexOf("]]>")!==-1)throw new Error("CDATA contains invalid characters (well-formed required).");this.cdata(p.data)},g.prototype._serializeAttributesNS=function(p,v,y,m,w,x){var C,S,T=[],_=x?new l.LocalNameSet:void 0;try{for(var E=o(p.attributes),b=E.next();!b.done;b=E.next()){var D=b.value;if(x||w||D.namespaceURI!==null){if(x&&_&&_.has(D.namespaceURI,D.localName))throw new Error("Element contains duplicate attributes (well-formed required).");x&&_&&_.set(D.namespaceURI,D.localName);var I=D.namespaceURI,P=null;if(I!==null)if(P=v.get(D.prefix,I),I===u.namespace.XMLNS){if(D.value===u.namespace.XML||D.prefix===null&&w||D.prefix!==null&&(!(D.localName in m)||m[D.localName]!==D.value)&&v.has(D.localName,D.value))continue;if(x&&D.value===u.namespace.XMLNS)throw new Error("XMLNS namespace is reserved (well-formed required).");if(x&&D.value==="")throw new Error("Namespace prefix declarations cannot be used to undeclare a namespace (well-formed required).");D.prefix==="xmlns"&&(P="xmlns")}else P===null&&(P=D.prefix===null||v.hasPrefix(D.prefix)&&!v.has(D.prefix,I)?this._generatePrefix(I,v,y):D.prefix,T.push([null,"xmlns",P,this._serializeAttributeValue(I,x)]));if(x&&(D.localName.indexOf(":")!==-1||!d.xml_isName(D.localName)||D.localName==="xmlns"&&I===null))throw new Error("Attribute local name contains invalid characters (well-formed required).");T.push([I,P,D.localName,this._serializeAttributeValue(D.value,x)])}else T.push([null,null,D.localName,this._serializeAttributeValue(D.value,x)])}}catch(O){C={error:O}}finally{try{b&&!b.done&&(S=E.return)&&S.call(E)}finally{if(C)throw C.error}}return T},g.prototype._serializeAttributes=function(p,v){var y,m,w=[],x=v?{}:void 0;try{for(var C=o(p.attributes),S=C.next();!S.done;S=C.next()){var T=S.value;if(v){if(v&&x&&T.localName in x)throw new Error("Element contains duplicate attributes (well-formed required).");if(v&&x&&(x[T.localName]=!0),v&&(T.localName.indexOf(":")!==-1||!d.xml_isName(T.localName)))throw new Error("Attribute local name contains invalid characters (well-formed required).");w.push([null,null,T.localName,this._serializeAttributeValue(T.value,v)])}else w.push([null,null,T.localName,this._serializeAttributeValue(T.value,v)])}}catch(_){y={error:_}}finally{try{S&&!S.done&&(m=C.return)&&m.call(C)}finally{if(y)throw y.error}}return w},g.prototype._recordNamespaceInformation=function(p,v,y){var m,w,x=null;try{for(var C=o(p.attributes),S=C.next();!S.done;S=C.next()){var T=S.value,_=T.namespaceURI,E=T.prefix;if(_===u.namespace.XMLNS){if(E===null){x=T.value;continue}var b=T.localName,D=T.value;if(D===u.namespace.XML||(D===""&&(D=null),v.has(b,D)))continue;v.set(b,D),y[b]=D||""}}}catch(I){m={error:I}}finally{try{S&&!S.done&&(w=C.return)&&w.call(C)}finally{if(m)throw m.error}}return x},g.prototype._generatePrefix=function(p,v,y){var m="ns"+y.value.toString();return y.value++,v.set(m,p),m},g.prototype._serializeAttributeValue=function(p,v){if(v&&p!==null&&!d.xml_isLegalChar(p))throw new Error("Invalid characters in attribute value.");return p===null?"":p.replace(/(?!&([^&;]*);)&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")},g._VoidElementNames=new Set(["area","base","basefont","bgsound","br","col","embed","frame","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"]),g}();n.BaseWriter=h},function(r,n,i){var o=this&&this.__values||function(v){var y=typeof Symbol=="function"&&Symbol.iterator,m=y&&v[y],w=0;if(m)return m.call(v);if(v&&typeof v.length=="number")return{next:function(){return v&&w>=v.length&&(v=void 0),{value:v&&v[w++],done:!v}}};throw new TypeError(y?"Object is not iterable.":"Symbol.iterator is not defined.")},a=this&&this.__read||function(v,y){var m=typeof Symbol=="function"&&v[Symbol.iterator];if(!m)return v;var w,x,C=m.call(v),S=[];try{for(;(y===void 0||y-- >0)&&!(w=C.next()).done;)S.push(w.value)}catch(T){x={error:T}}finally{try{w&&!w.done&&(m=C.return)&&m.call(C)}finally{if(x)throw x.error}}return S};Object.defineProperty(n,"__esModule",{value:!0});var s=i(6),c=i(3),l=i(7),f=i(29),u=i(17),d=i(97);function h(){var v=s.dom.window;v._mutationObserverMicrotaskQueued||(v._mutationObserverMicrotaskQueued=!0,Promise.resolve().then(function(){g()}))}function g(){var v,y,m,w,x=s.dom.window;x._mutationObserverMicrotaskQueued=!1;var C=l.set.clone(x._mutationObservers),S=l.set.clone(x._signalSlots);l.set.empty(x._signalSlots);var T=function(P){var O=l.list.clone(P._recordQueue);l.list.empty(P._recordQueue);for(var L=0;L<P._nodeList.length;L++){var B=P._nodeList[L];l.list.remove(B._registeredObserverList,function(H){return c.Guard.isTransientRegisteredObserver(H)&&H.observer===P})}if(!l.list.isEmpty(O))try{P._callback.call(P,O,P)}catch{}};try{for(var _=o(C),E=_.next();!E.done;E=_.next())T(E.value)}catch(P){v={error:P}}finally{try{E&&!E.done&&(y=_.return)&&y.call(_)}finally{if(v)throw v.error}}if(s.dom.features.slots)try{for(var b=o(S),D=b.next();!D.done;D=b.next()){var I=D.value;d.event_fireAnEvent("slotchange",I,void 0,{bubbles:!0})}}catch(P){m={error:P}}finally{try{D&&!D.done&&(w=b.return)&&w.call(b)}finally{if(m)throw m.error}}}function p(v,y,m,w,x,C,S,T,_){for(var E,b,D=new Map,I=u.tree_getFirstAncestorNode(y,!0);I!==null;){for(var P=0;P<I._registeredObserverList.length;P++){var O=I._registeredObserverList[P],L=O.options;if((I===y||L.subtree)&&(v!=="attributes"||L.attributes)&&(v!=="attributes"||!L.attributeFilter||L.attributeFilter.indexOf(m||"")&&w===null)&&(v!=="characterData"||L.characterData)&&(v!=="childList"||L.childList)){var B=O.observer;D.has(B)||D.set(B,null),(v==="attributes"&&L.attributeOldValue||v==="characterData"&&L.characterDataOldValue)&&D.set(B,x)}}I=u.tree_getNextAncestorNode(y,I,!0)}try{for(var H=o(D),A=H.next();!A.done;A=H.next()){var F=a(A.value,2),G=F[0],X=F[1],ee=f.create_mutationRecord(v,y,f.create_nodeListStatic(y,C),f.create_nodeListStatic(y,S),T,_,m,w,X);G._recordQueue.push(ee)}}catch(ce){E={error:ce}}finally{try{A&&!A.done&&(b=H.return)&&b.call(H)}finally{if(E)throw E.error}}h()}n.observer_queueAMutationObserverMicrotask=h,n.observer_notifyMutationObservers=g,n.observer_queueMutationRecord=p,n.observer_queueTreeMutationRecord=function(v,y,m,w,x){p("childList",v,null,null,null,y,m,w,x)},n.observer_queueAttributeMutationRecord=function(v,y,m,w){p("attributes",v,y,m,w,[],[],null,null)}},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(6),a=i(7),s=i(3),c=i(9),l=i(29),f=i(73),u=i(51),d=i(30),h=i(37),g=i(106);function p(C,S,T){o.dom.features.mutationObservers&&u.observer_queueAttributeMutationRecord(S,C._localName,C._namespace,C._value),o.dom.features.customElements&&s.Guard.isCustomElementNode(S)&&f.customElement_enqueueACustomElementCallbackReaction(S,"attributeChangedCallback",[C._localName,C._value,T,C._namespace]),o.dom.features.steps&&d.dom_runAttributeChangeSteps(S,C._localName,C._value,T,C._namespace),C._value=T}function v(C,S){o.dom.features.mutationObservers&&u.observer_queueAttributeMutationRecord(S,C._localName,C._namespace,null),o.dom.features.customElements&&s.Guard.isCustomElementNode(S)&&f.customElement_enqueueACustomElementCallbackReaction(S,"attributeChangedCallback",[C._localName,null,C._value,C._namespace]),o.dom.features.steps&&d.dom_runAttributeChangeSteps(S,C._localName,null,C._value,C._namespace),S._attributeList._asArray().push(C),C._element=S,S._nodeDocument._hasNamespaces||C._namespace===null&&C._namespacePrefix===null&&C._localName!=="xmlns"||(S._nodeDocument._hasNamespaces=!0)}function y(C,S){o.dom.features.mutationObservers&&u.observer_queueAttributeMutationRecord(S,C._localName,C._namespace,C._value),o.dom.features.customElements&&s.Guard.isCustomElementNode(S)&&f.customElement_enqueueACustomElementCallbackReaction(S,"attributeChangedCallback",[C._localName,C._value,null,C._namespace]),o.dom.features.steps&&d.dom_runAttributeChangeSteps(S,C._localName,C._value,null,C._namespace);var T=S._attributeList._asArray().indexOf(C);S._attributeList._asArray().splice(T,1),C._element=null}function m(C,S,T){o.dom.features.mutationObservers&&u.observer_queueAttributeMutationRecord(T,C._localName,C._namespace,C._value),o.dom.features.customElements&&s.Guard.isCustomElementNode(T)&&f.customElement_enqueueACustomElementCallbackReaction(T,"attributeChangedCallback",[C._localName,C._value,S._value,C._namespace]),o.dom.features.steps&&d.dom_runAttributeChangeSteps(T,C._localName,C._value,S._value,C._namespace);var _=T._attributeList._asArray().indexOf(C);_!==-1&&(T._attributeList._asArray()[_]=S),C._element=null,S._element=T,T._nodeDocument._hasNamespaces||S._namespace===null&&S._namespacePrefix===null&&S._localName!=="xmlns"||(T._nodeDocument._hasNamespaces=!0)}function w(C,S){return S._namespace===a.namespace.HTML&&S._nodeDocument._type==="html"&&(C=C.toLowerCase()),S._attributeList._asArray().find(function(T){return T._qualifiedName===C})||null}function x(C,S,T){var _=C||null;return T._attributeList._asArray().find(function(E){return E._namespace===_&&E._localName===S})||null}n.element_has=function(C,S){return S._attributeList._asArray().indexOf(C)!==-1},n.element_change=p,n.element_append=v,n.element_remove=y,n.element_replace=m,n.element_getAnAttributeByName=w,n.element_getAnAttributeByNamespaceAndLocalName=x,n.element_getAnAttributeValue=function(C,S,T){T===void 0&&(T="");var _=x(T,S,C);return _===null?"":_._value},n.element_setAnAttribute=function(C,S){if(C._element!==null&&C._element!==S)throw new c.InUseAttributeError("This attribute already exists in the document: "+C._qualifiedName+" as a child of "+C._element._qualifiedName+".");var T=x(C._namespace||"",C._localName,S);return T===C?C:(T!==null?m(T,C,S):v(C,S),T)},n.element_setAnAttributeValue=function(C,S,T,_,E){_===void 0&&(_=null),E===void 0&&(E=null);var b=x(E||"",S,C);if(b===null){var D=l.create_attr(C._nodeDocument,S);return D._namespace=E,D._namespacePrefix=_,D._value=T,void v(D,C)}p(b,C,T)},n.element_removeAnAttributeByName=function(C,S){var T=w(C,S);return T!==null&&y(T,S),T},n.element_removeAnAttributeByNamespaceAndLocalName=function(C,S,T){var _=x(C,S,T);return _!==null&&y(_,T),_},n.element_createAnElement=function(C,S,T,_,E,b){_===void 0&&(_=null),E===void 0&&(E=null),b===void 0&&(b=!1);var D=null;if(!o.dom.features.customElements)return(D=l.create_element(C,S,T,_))._customElementState="uncustomized",D._customElementDefinition=null,D._is=E,D;var I=f.customElement_lookUpACustomElementDefinition(C,T,S,E);if(I!==null&&I.name!==I.localName)(D=new(g.document_elementInterface(S,a.namespace.HTML)))._localName=S,D._namespace=a.namespace.HTML,D._namespacePrefix=_,D._customElementState="undefined",D._customElementDefinition=null,D._is=E,D._nodeDocument=C,b?f.customElement_upgrade(I,D):f.customElement_enqueueACustomElementUpgradeReaction(D,I);else if(I!==null)if(b)try{var P=new I.constructor;if(console.assert(P._customElementState!==void 0),console.assert(P._customElementDefinition!==void 0),console.assert(P._namespace===a.namespace.HTML),P._attributeList.length!==0)throw new c.NotSupportedError("Custom element already has attributes.");if(P._children.size!==0)throw new c.NotSupportedError("Custom element already has child nodes.");if(P._parent!==null)throw new c.NotSupportedError("Custom element already has a parent node.");if(P._nodeDocument!==C)throw new c.NotSupportedError("Custom element is already in a document.");if(P._localName!==S)throw new c.NotSupportedError("Custom element has a different local name.");P._namespacePrefix=_,P._is=null}catch{(D=l.create_htmlUnknownElement(C,S,a.namespace.HTML,_))._customElementState="failed",D._customElementDefinition=null,D._is=null}else(D=l.create_htmlElement(C,S,a.namespace.HTML,_))._customElementState="undefined",D._customElementDefinition=null,D._is=null,f.customElement_enqueueACustomElementUpgradeReaction(D,I);else(D=new(g.document_elementInterface(S,T)))._localName=S,D._namespace=T,D._namespacePrefix=_,D._customElementState="uncustomized",D._customElementDefinition=null,D._is=E,D._nodeDocument=C,T!==a.namespace.HTML||E===null&&!f.customElement_isValidCustomElementName(S)||(D._customElementState="undefined");if(D===null)throw new Error("Unable to create element.");return D},n.element_insertAdjacent=function(C,S,T){switch(S.toLowerCase()){case"beforebegin":return C._parent===null?null:h.mutation_preInsert(T,C._parent,C);case"afterbegin":return h.mutation_preInsert(T,C,C._firstChild);case"beforeend":return h.mutation_preInsert(T,C,null);case"afterend":return C._parent===null?null:h.mutation_preInsert(T,C._parent,C._nextSibling);default:throw new c.SyntaxError(`Invalid 'where' argument. "beforebegin", "afterbegin", "beforeend" or "afterend" expected`)}}},function(r,n,i){function o(a,s){Error.call(this),this.name="YAMLException",this.reason=a,this.mark=s,this.message=(this.reason||"(unknown reason)")+(this.mark?" "+this.mark.toString():""),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}o.prototype=Object.create(Error.prototype),o.prototype.constructor=o,o.prototype.toString=function(a){var s=this.name+": ";return s+=this.reason||"(unknown reason)",!a&&this.mark&&(s+=" "+this.mark.toString()),s},r.exports=o},function(r,n,i){var o=i(39);r.exports=new o({include:[i(181)],implicit:[i(293),i(294)],explicit:[i(295),i(296),i(297),i(298)]})},function(r,n,i){var o=i(16),a=i(79),s=i(40),c=i(24),l=i(56),f=i(14),u=i(115),d=Object.getOwnPropertyDescriptor;n.f=o?d:function(h,g){if(h=c(h),g=l(g,!0),u)try{return d(h,g)}catch{}if(f(h,g))return s(!a.f.call(h,g),h[g])}},function(r,n,i){var o=i(13);r.exports=function(a,s){if(!o(a))return a;var c,l;if(s&&typeof(c=a.toString)=="function"&&!o(l=c.call(a))||typeof(c=a.valueOf)=="function"&&!o(l=c.call(a))||!s&&typeof(c=a.toString)=="function"&&!o(l=c.call(a)))return l;throw TypeError("Can't convert object to primitive value")}},function(r,n,i){var o=i(81),a=i(58),s=o("keys");r.exports=function(c){return s[c]||(s[c]=a(c))}},function(r,n){var i=0,o=Math.random();r.exports=function(a){return"Symbol("+String(a===void 0?"":a)+")_"+(++i+o).toString(36)}},function(r,n,i){var o=i(42);r.exports=Array.isArray||function(a){return o(a)=="Array"}},function(r,n,i){var o,a=i(18),s=i(188),c=i(84),l=i(45),f=i(189),u=i(116),d=i(57),h=d("IE_PROTO"),g=function(){},p=function(y){return"<script>"+y+"<\/script>"},v=function(){try{o=document.domain&&new ActiveXObject("htmlfile")}catch{}var y,m;v=o?function(x){x.write(p("")),x.close();var C=x.parentWindow.Object;return x=null,C}(o):((m=u("iframe")).style.display="none",f.appendChild(m),m.src="javascript:",(y=m.contentWindow.document).open(),y.write(p("document.F=Object")),y.close(),y.F);for(var w=c.length;w--;)delete v.prototype[c[w]];return v()};l[h]=!0,r.exports=Object.create||function(y,m){var w;return y!==null?(g.prototype=a(y),w=new g,g.prototype=null,w[h]=y):w=v(),m===void 0?w:s(w,m)}},function(r,n,i){var o=i(121),a=i(84);r.exports=Object.keys||function(s){return o(s,a)}},function(r,n,i){var o=i(15).f,a=i(14),s=i(5)("toStringTag");r.exports=function(c,l,f){c&&!a(c=f?c:c.prototype,s)&&o(c,s,{configurable:!0,value:l})}},function(r,n,i){var o=i(8),a=i(5),s=i(129),c=a("species");r.exports=function(l){return s>=51||!o(function(){var f=[];return(f.constructor={})[c]=function(){return{foo:1}},f[l](Boolean).foo!==1})}},function(r,n,i){var o=i(4),a=i(122).indexOf,s=i(48),c=i(28),l=[].indexOf,f=!!l&&1/[1].indexOf(1,-0)<0,u=s("indexOf"),d=c("indexOf",{ACCESSORS:!0,1:0});o({target:"Array",proto:!0,forced:f||!u||!d},{indexOf:function(h){return f?l.apply(this,arguments)||0:a(this,h,arguments.length>1?arguments[1]:void 0)}})},function(r,n,i){var o=i(16),a=i(15).f,s=Function.prototype,c=s.toString,l=/^\s*function ([^ (]*)/;o&&!("name"in s)&&a(s,"name",{configurable:!0,get:function(){try{return c.call(this).match(l)[1]}catch{return""}}})},function(r,n,i){var o=i(25),a=i(18),s=i(8),c=i(136),l=RegExp.prototype,f=l.toString,u=s(function(){return f.call({source:"a",flags:"b"})!="/a/b"}),d=f.name!="toString";(u||d)&&o(RegExp.prototype,"toString",function(){var h=a(this),g=String(h.source),p=h.flags;return"/"+g+"/"+String(p===void 0&&h instanceof RegExp&&!("flags"in l)?c.call(h):p)},{unsafe:!0})},function(r,n,i){i(31),i(32),i(33),i(19),i(138),i(20),i(66),i(22),i(23);var o,a=this&&this.__extends||(o=function(u,d){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(h,g){h.__proto__=g}||function(h,g){for(var p in g)g.hasOwnProperty(p)&&(h[p]=g[p])})(u,d)},function(u,d){function h(){this.constructor=u}o(u,d),u.prototype=d===null?Object.create(d):(h.prototype=d.prototype,new h)}),s=this&&this.__values||function(u){var d=typeof Symbol=="function"&&Symbol.iterator,h=d&&u[d],g=0;if(h)return h.call(u);if(u&&typeof u.length=="number")return{next:function(){return u&&g>=u.length&&(u=void 0),{value:u&&u[g++],done:!u}}};throw new TypeError(d?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var c=i(1),l=i(2),f=function(u){function d(h,g){var p=u.call(this,h)||this;return p._writerOptions=c.applyDefaults(g,{format:"object",wellFormed:!1,group:!1,verbose:!1}),p}return a(d,u),d.prototype.serialize=function(h){return this._currentList=[],this._currentIndex=0,this._listRegister=[this._currentList],this.serializeNode(h,this._writerOptions.wellFormed),this._process(this._currentList,this._writerOptions)},d.prototype._process=function(h,g){var p,v,y,m,w,x,C;if(h.length===0)return{};for(var S={},T=!1,_=0,E=0,b=0,D=0,I=0;I<h.length;I++){var P=h[I];switch(Ne=Object.keys(P)[0]){case"@":continue;case"#":_++;break;case"!":E++;break;case"?":b++;break;case"$":D++;break;default:S[Ne]?T=!0:S[Ne]=!0}}var O=this._getAttrKey(),L=this._getNodeKey(l.NodeType.Text),B=this._getNodeKey(l.NodeType.Comment),H=this._getNodeKey(l.NodeType.ProcessingInstruction),A=this._getNodeKey(l.NodeType.CData);if(_===1&&h.length===1&&c.isString(h[0]["#"]))return h[0]["#"];if(T){var F={};for(I=0;I<h.length;I++)if(P=h[I],(Ne=Object.keys(P)[0])==="@"){var G=P["@"];(j=Object.keys(G)).length===1?F[O+j[0]]=G[j[0]]:F[O]=P["@"]}var X=[];for(I=0;I<h.length;I++)switch(P=h[I],Ne=Object.keys(P)[0]){case"@":break;case"#":X.push(((p={})[L]=P["#"],p));break;case"!":X.push(((v={})[B]=P["!"],v));break;case"?":X.push(((y={})[H]=P["?"],y));break;case"$":X.push(((m={})[A]=P.$,m));break;default:if((q=P)[Ne].length!==0&&c.isArray(q[Ne][0])){for(var ee=[],ce=q[Ne],Se=0;Se<ce.length;Se++)ee.push(this._process(ce[Se],g));X.push(((w={})[Ne]=ee,w))}else g.verbose?X.push(((x={})[Ne]=[this._process(q[Ne],g)],x)):X.push(((C={})[Ne]=this._process(q[Ne],g),C))}return F[L]=X,F}var we=1,_e=1,Ve=1,Ge=1;for(F={},I=0;I<h.length;I++){var Ne;switch(P=h[I],Ne=Object.keys(P)[0]){case"@":G=P["@"];var j=Object.keys(G);if(g.group&&j.length!==1)F[O]=G;else for(var M in G)F[O+M]=G[M];break;case"#":we=this._processSpecItem(P["#"],F,g.group,L,_,we);break;case"!":_e=this._processSpecItem(P["!"],F,g.group,B,E,_e);break;case"?":Ve=this._processSpecItem(P["?"],F,g.group,H,b,Ve);break;case"$":Ge=this._processSpecItem(P.$,F,g.group,A,D,Ge);break;default:var q;if((q=P)[Ne].length!==0&&c.isArray(q[Ne][0])){ee=[],ce=q[Ne];for(var K=0;K<ce.length;K++)ee.push(this._process(ce[K],g));F[Ne]=ee}else g.verbose?F[Ne]=[this._process(q[Ne],g)]:F[Ne]=this._process(q[Ne],g)}}return F},d.prototype._processSpecItem=function(h,g,p,v,y,m){var w,x;if(!p&&c.isArray(h)&&y+h.length>2)try{for(var C=s(h),S=C.next();!S.done;S=C.next()){var T=S.value;g[v+(m++).toString()]=T}}catch(_){w={error:_}}finally{try{S&&!S.done&&(x=C.return)&&x.call(C)}finally{if(w)throw w.error}}else g[y>1?v+(m++).toString():v]=h;return m},d.prototype.beginElement=function(h){var g,p,v=[];if(this._currentList.length===0)this._currentList.push(((g={})[h]=v,g));else{var y=this._currentList[this._currentList.length-1];this._isElementNode(y,h)?y[h].length!==0&&c.isArray(y[h][0])?y[h].push(v):y[h]=[y[h],v]:this._currentList.push(((p={})[h]=v,p))}this._currentIndex++,this._listRegister.length>this._currentIndex?this._listRegister[this._currentIndex]=v:this._listRegister.push(v),this._currentList=v},d.prototype.endElement=function(){this._currentList=this._listRegister[--this._currentIndex]},d.prototype.attribute=function(h,g){var p,v;if(this._currentList.length===0)this._currentList.push({"@":(p={},p[h]=g,p)});else{var y=this._currentList[this._currentList.length-1];this._isAttrNode(y)?y["@"][h]=g:this._currentList.push({"@":(v={},v[h]=g,v)})}},d.prototype.comment=function(h){if(this._currentList.length===0)this._currentList.push({"!":h});else{var g=this._currentList[this._currentList.length-1];this._isCommentNode(g)?c.isArray(g["!"])?g["!"].push(h):g["!"]=[g["!"],h]:this._currentList.push({"!":h})}},d.prototype.text=function(h){if(this._currentList.length===0)this._currentList.push({"#":h});else{var g=this._currentList[this._currentList.length-1];this._isTextNode(g)?c.isArray(g["#"])?g["#"].push(h):g["#"]=[g["#"],h]:this._currentList.push({"#":h})}},d.prototype.instruction=function(h,g){var p=g===""?h:h+" "+g;if(this._currentList.length===0)this._currentList.push({"?":p});else{var v=this._currentList[this._currentList.length-1];this._isInstructionNode(v)?c.isArray(v["?"])?v["?"].push(p):v["?"]=[v["?"],p]:this._currentList.push({"?":p})}},d.prototype.cdata=function(h){if(this._currentList.length===0)this._currentList.push({$:h});else{var g=this._currentList[this._currentList.length-1];this._isCDATANode(g)?c.isArray(g.$)?g.$.push(h):g.$=[g.$,h]:this._currentList.push({$:h})}},d.prototype._isAttrNode=function(h){return"@"in h},d.prototype._isTextNode=function(h){return"#"in h},d.prototype._isCommentNode=function(h){return"!"in h},d.prototype._isInstructionNode=function(h){return"?"in h},d.prototype._isCDATANode=function(h){return"$"in h},d.prototype._isElementNode=function(h,g){return g in h},d.prototype._getAttrKey=function(){return this._builderOptions.convert.att},d.prototype._getNodeKey=function(h){switch(h){case l.NodeType.Comment:return this._builderOptions.convert.comment;case l.NodeType.Text:return this._builderOptions.convert.text;case l.NodeType.ProcessingInstruction:return this._builderOptions.convert.ins;case l.NodeType.CData:return this._builderOptions.convert.cdata;default:throw new Error("Invalid node type.")}},d}(i(50).BaseWriter);n.ObjectWriter=f},function(r,n,i){var o=i(4),a=i(93);o({target:"RegExp",proto:!0,forced:/./.exec!==a},{exec:a})},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function a(){this._items={},this._nullItems={}}return a.prototype.set=function(s,c){s===null?this._nullItems[c]=!0:(this._items[s]||(this._items[s]={}),this._items[s][c]=!0)},a.prototype.has=function(s,c){return s===null?this._nullItems[c]===!0:!!this._items[s]&&this._items[s][c]===!0},a}();n.LocalNameSet=o},function(r,n,i){var o=this&&this.__read||function(f,u){var d=typeof Symbol=="function"&&f[Symbol.iterator];if(!d)return f;var h,g,p=d.call(f),v=[];try{for(;(u===void 0||u-- >0)&&!(h=p.next()).done;)v.push(h.value)}catch(y){g={error:y}}finally{try{h&&!h.done&&(d=p.return)&&d.call(p)}finally{if(g)throw g.error}}return v};Object.defineProperty(n,"__esModule",{value:!0});var a=i(9),s=i(3),c=i(0),l=function(){function f(){}return Object.defineProperty(f.prototype,"_eventListenerList",{get:function(){return this.__eventListenerList||(this.__eventListenerList=[])},enumerable:!0,configurable:!0}),Object.defineProperty(f.prototype,"_eventHandlerMap",{get:function(){return this.__eventHandlerMap||(this.__eventHandlerMap={})},enumerable:!0,configurable:!0}),f.prototype.addEventListener=function(u,d,h){h===void 0&&(h={passive:!1,once:!1,capture:!1});var g,p=o(c.eventTarget_flattenMore(h),3),v=p[0],y=p[1],m=p[2];d&&(g=s.Guard.isEventListener(d)?d:{handleEvent:d},c.eventTarget_addEventListener(this,{type:u,callback:g,capture:v,passive:y,once:m,removed:!1}))},f.prototype.removeEventListener=function(u,d,h){h===void 0&&(h={capture:!1});var g=c.eventTarget_flatten(h);if(d)for(var p=0;p<this._eventListenerList.length;p++){var v=this._eventListenerList[p];if(v.type===u&&v.capture===g){if(s.Guard.isEventListener(d)&&v.callback===d){c.eventTarget_removeEventListener(this,v,p);break}if(d&&v.callback.handleEvent===d){c.eventTarget_removeEventListener(this,v,p);break}}}},f.prototype.dispatchEvent=function(u){if(u._dispatchFlag||!u._initializedFlag)throw new a.InvalidStateError;return u._isTrusted=!1,c.event_dispatch(u,this)},f.prototype._getTheParent=function(u){return null},f}();n.EventTargetImpl=l},function(r,n,i){var o,a=this&&this.__extends||(o=function(f,u){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,h){d.__proto__=h}||function(d,h){for(var g in h)h.hasOwnProperty(g)&&(d[g]=h[g])})(f,u)},function(f,u){function d(){this.constructor=f}o(f,u),f.prototype=u===null?Object.create(u):(d.prototype=u.prototype,new d)});Object.defineProperty(n,"__esModule",{value:!0});var s=i(34),c=i(0),l=function(f){function u(d){var h=f.call(this)||this;return h._data=d,h}return a(u,f),Object.defineProperty(u.prototype,"data",{get:function(){return this._data},set:function(d){c.characterData_replaceData(this,0,this._data.length,d)},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"length",{get:function(){return this._data.length},enumerable:!0,configurable:!0}),u.prototype.substringData=function(d,h){return c.characterData_substringData(this,d,h)},u.prototype.appendData=function(d){return c.characterData_replaceData(this,this._data.length,0,d)},u.prototype.insertData=function(d,h){c.characterData_replaceData(this,d,0,h)},u.prototype.deleteData=function(d,h){c.characterData_replaceData(this,d,h,"")},u.prototype.replaceData=function(d,h,g){c.characterData_replaceData(this,d,h,g)},Object.defineProperty(u.prototype,"previousElementSibling",{get:function(){throw new Error("Mixin: NonDocumentTypeChildNode not implemented.")},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"nextElementSibling",{get:function(){throw new Error("Mixin: NonDocumentTypeChildNode not implemented.")},enumerable:!0,configurable:!0}),u.prototype.before=function(){for(var d=[],h=0;h<arguments.length;h++)d[h]=arguments[h];throw new Error("Mixin: ChildNode not implemented.")},u.prototype.after=function(){for(var d=[],h=0;h<arguments.length;h++)d[h]=arguments[h];throw new Error("Mixin: ChildNode not implemented.")},u.prototype.replaceWith=function(){for(var d=[],h=0;h<arguments.length;h++)d[h]=arguments[h];throw new Error("Mixin: ChildNode not implemented.")},u.prototype.remove=function(){throw new Error("Mixin: ChildNode not implemented.")},u}(s.NodeImpl);n.CharacterDataImpl=l},function(r,n,i){var o=this&&this.__values||function(y){var m=typeof Symbol=="function"&&Symbol.iterator,w=m&&y[m],x=0;if(w)return w.call(y);if(y&&typeof y.length=="number")return{next:function(){return y&&x>=y.length&&(y=void 0),{value:y&&y[x++],done:!y}}};throw new TypeError(m?"Object is not iterable.":"Symbol.iterator is not defined.")},a=this&&this.__read||function(y,m){var w=typeof Symbol=="function"&&y[Symbol.iterator];if(!w)return y;var x,C,S=w.call(y),T=[];try{for(;(m===void 0||m-- >0)&&!(x=S.next()).done;)T.push(x.value)}catch(_){C={error:_}}finally{try{x&&!x.done&&(w=S.return)&&w.call(S)}finally{if(C)throw C.error}}return T},s=this&&this.__spread||function(){for(var y=[],m=0;m<arguments.length;m++)y=y.concat(a(arguments[m]));return y};Object.defineProperty(n,"__esModule",{value:!0});var c=i(6),l=i(3),f=i(1),u=i(17),d=i(51);function h(y){c.dom.window._signalSlots.add(y),d.observer_queueAMutationObserverMicrotask()}function g(y,m){m===void 0&&(m=!1);var w=l.Cast.asNode(y)._parent;if(w===null)return null;var x=w._shadowRoot||null;if(x===null||m&&x._mode!=="open")return null;for(var C=u.tree_getFirstDescendantNode(x,!1,!0,function(S){return l.Guard.isSlot(S)});C!==null;){if(C._name===y._name)return C;C=u.tree_getNextDescendantNode(x,C,!1,!0,function(S){return l.Guard.isSlot(S)})}return null}function p(y){var m,w,x=[],C=u.tree_rootNode(y);if(!l.Guard.isShadowRoot(C))return x;var S=C._host;try{for(var T=o(S._children),_=T.next();!_.done;_=T.next()){var E=_.value;l.Guard.isSlotable(E)&&g(E)===y&&x.push(E)}}catch(b){m={error:b}}finally{try{_&&!_.done&&(w=T.return)&&w.call(T)}finally{if(m)throw m.error}}return x}function v(y){var m,w,x=p(y);if(x.length===y._assignedNodes.length){for(var C=!0,S=0;S<x.length;S++)if(x[S]!==y._assignedNodes[S]){C=!1;break}C||h(y)}y._assignedNodes=x;try{for(var T=o(x),_=T.next();!_.done;_=T.next())_.value._assignedSlot=y}catch(E){m={error:E}}finally{try{_&&!_.done&&(w=T.return)&&w.call(T)}finally{if(m)throw m.error}}}n.shadowTree_signalASlotChange=h,n.shadowTree_isConnected=function(y){return l.Guard.isDocumentNode(u.tree_rootNode(y,!0))},n.shadowTree_isAssigned=function(y){return y._assignedSlot!==null},n.shadowTree_findASlot=g,n.shadowTree_findSlotables=p,n.shadowTree_findFlattenedSlotables=function y(m){var w,x,C,S,T=[],_=u.tree_rootNode(m);if(!l.Guard.isShadowRoot(_))return T;var E=p(m);if(f.isEmpty(E))try{for(var b=o(m._children),D=b.next();!D.done;D=b.next()){var I=D.value;l.Guard.isSlotable(I)&&E.push(I)}}catch(H){w={error:H}}finally{try{D&&!D.done&&(x=b.return)&&x.call(b)}finally{if(w)throw w.error}}try{for(var P=o(E),O=P.next();!O.done;O=P.next()){var L=O.value;if(l.Guard.isSlot(L)&&l.Guard.isShadowRoot(u.tree_rootNode(L))){var B=y(L);T.push.apply(T,s(B))}else T.push(L)}}catch(H){C={error:H}}finally{try{O&&!O.done&&(S=P.return)&&S.call(P)}finally{if(C)throw C.error}}return T},n.shadowTree_assignSlotables=v,n.shadowTree_assignSlotablesForATree=function(y){for(var m=u.tree_getFirstDescendantNode(y,!0,!1,function(w){return l.Guard.isSlot(w)});m!==null;)v(m),m=u.tree_getNextDescendantNode(y,m,!0,!1,function(w){return l.Guard.isSlot(w)})},n.shadowTree_assignASlot=function(y){var m=g(y);m!==null&&v(m)}},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=/[a-z]([\0-\t\x2D\._a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*-([\0-\t\x2D\._a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*/,a=new Set(["annotation-xml","color-profile","font-face","font-face-src","font-face-uri","font-face-format","font-face-name","missing-glyph"]),s=new Set(["article","aside","blockquote","body","div","footer","h1","h2","h3","h4","h5","h6","header","main","nav","p","section","span"]),c=new Set(["area","base","basefont","bgsound","br","col","embed","frame","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"]),l=new Set(["article","aside","blockquote","body","div","footer","h1","h2","h3","h4","h5","h6","header","main","nav","p","section","span"]);n.customElement_isValidCustomElementName=function(f){return!!o.test(f)&&!a.has(f)},n.customElement_isValidElementName=function(f){return s.has(f)},n.customElement_isVoidElementName=function(f){return c.has(f)},n.customElement_isValidShadowHostName=function(f){return l.has(f)},n.customElement_enqueueACustomElementUpgradeReaction=function(f,u){},n.customElement_enqueueACustomElementCallbackReaction=function(f,u,d){},n.customElement_upgrade=function(f,u){},n.customElement_tryToUpgrade=function(f){},n.customElement_lookUpACustomElementDefinition=function(f,u,d,h){return null}},function(r,n,i){i(4)({target:"String",proto:!0},{repeat:i(259)})},function(r,n,i){i(278),i(68),i(179),i(94),Object.defineProperty(n,"__esModule",{value:!0});var o=i(109),a=function(){function s(c){this._builderOptions=c,c.parser&&Object.assign(this,c.parser)}return s.prototype._docType=function(c,l,f,u){return c.dtd({name:l,pubID:f,sysID:u})},s.prototype._comment=function(c,l){return c.com(l)},s.prototype._text=function(c,l){return c.txt(l)},s.prototype._instruction=function(c,l,f){return c.ins(l,f)},s.prototype._cdata=function(c,l){return c.dat(l)},s.prototype._element=function(c,l,f){return l===void 0?c.ele(f):c.ele(l,f)},s.prototype._attribute=function(c,l,f,u){return l===void 0?c.att(f,u):c.att(l,f,u)},s.prototype._sanitize=function(c){return o.sanitizeInput(c,this._builderOptions.invalidCharReplacement)},s.prototype._decodeText=function(c){return c==null?c:c.replace(/&(quot|amp|apos|lt|gt);/g,function(l,f){return s._entityTable[f]}).replace(/&#(?:x([a-fA-F0-9]+)|([0-9]+));/g,function(l,f,u){return String.fromCodePoint(parseInt(f||u,f?16:10))})},s.prototype._decodeAttributeValue=function(c){return this._decodeText(c)},s.prototype.parse=function(c,l){return this._parse(c,l)},s.prototype.docType=function(c,l,f,u){return this._docType(c,l,f,u)},s.prototype.comment=function(c,l){return this._comment(c,l)},s.prototype.text=function(c,l){return this._text(c,l)},s.prototype.instruction=function(c,l,f){return this._instruction(c,l,f)},s.prototype.cdata=function(c,l){return this._cdata(c,l)},s.prototype.element=function(c,l,f){return this._element(c,l,f)},s.prototype.attribute=function(c,l,f,u){return this._attribute(c,l,f,u)},s.prototype.sanitize=function(c){return this._sanitize(c)},s._entityTable={lt:"<",gt:">",amp:"&",quot:'"',apos:"'"},s}();n.BaseReader=a},function(r,n,i){var o=i(39);r.exports=o.DEFAULT=new o({include:[i(54)],explicit:[i(299),i(300),i(301)]})},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(185);n.XMLBuilderImpl=o.XMLBuilderImpl;var a=i(304);n.XMLBuilderCBImpl=a.XMLBuilderCBImpl;var s=i(183);n.builder=s.builder,n.create=s.create,n.fragment=s.fragment,n.convert=s.convert;var c=i(309);n.createCB=c.createCB,n.fragmentCB=c.fragmentCB},function(r,n){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch{typeof window=="object"&&(i=window)}r.exports=i},function(r,n,i){var o={}.propertyIsEnumerable,a=Object.getOwnPropertyDescriptor,s=a&&!o.call({1:2},1);n.f=s?function(c){var l=a(this,c);return!!l&&l.enumerable}:o},function(r,n,i){var o=i(11),a=i(21);r.exports=function(s,c){try{a(o,s,c)}catch{o[s]=c}return c}},function(r,n,i){var o=i(44),a=i(118);(r.exports=function(s,c){return a[s]||(a[s]=c!==void 0?c:{})})("versions",[]).push({version:"3.6.5",mode:o?"pure":"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"})},function(r,n,i){var o=i(121),a=i(84).concat("length","prototype");n.f=Object.getOwnPropertyNames||function(s){return o(s,a)}},function(r,n,i){var o=i(47),a=Math.max,s=Math.min;r.exports=function(c,l){var f=o(c);return f<0?a(f+l,0):s(f,l)}},function(r,n){r.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},function(r,n){n.f=Object.getOwnPropertySymbols},function(r,n,i){var o=i(8);r.exports=!!Object.getOwnPropertySymbols&&!o(function(){return!String(Symbol())})},function(r,n,i){var o=i(127);r.exports=function(a,s,c){if(o(a),s===void 0)return a;switch(c){case 0:return function(){return a.call(s)};case 1:return function(l){return a.call(s,l)};case 2:return function(l,f){return a.call(s,l,f)};case 3:return function(l,f,u){return a.call(s,l,f,u)}}return function(){return a.apply(s,arguments)}}},function(r,n,i){var o=i(4),a=i(195),s=i(132),c=i(133),l=i(62),f=i(21),u=i(25),d=i(5),h=i(44),g=i(49),p=i(131),v=p.IteratorPrototype,y=p.BUGGY_SAFARI_ITERATORS,m=d("iterator"),w=function(){return this};r.exports=function(x,C,S,T,_,E,b){a(S,C,T);var D,I,P,O=function(X){if(X===_&&F)return F;if(!y&&X in H)return H[X];switch(X){case"keys":case"values":case"entries":return function(){return new S(this,X)}}return function(){return new S(this)}},L=C+" Iterator",B=!1,H=x.prototype,A=H[m]||H["@@iterator"]||_&&H[_],F=!y&&A||O(_),G=C=="Array"&&H.entries||A;if(G&&(D=s(G.call(new x)),v!==Object.prototype&&D.next&&(h||s(D)===v||(c?c(D,v):typeof D[m]!="function"&&f(D,m,w)),l(D,L,!0,!0),h&&(g[L]=w))),_=="values"&&A&&A.name!=="values"&&(B=!0,F=function(){return A.call(this)}),h&&!b||H[m]===F||f(H,m,F),g[C]=F,_)if(I={values:O("values"),keys:E?F:O("keys"),entries:O("entries")},b)for(P in I)(y||B||!(P in H))&&u(H,P,I[P]);else o({target:C,proto:!0,forced:y||B},I);return I}},function(r,n,i){var o=i(4),a=i(13),s=i(59),c=i(83),l=i(26),f=i(24),u=i(134),d=i(5),h=i(63),g=i(28),p=h("slice"),v=g("slice",{ACCESSORS:!0,0:0,1:2}),y=d("species"),m=[].slice,w=Math.max;o({target:"Array",proto:!0,forced:!p||!v},{slice:function(x,C){var S,T,_,E=f(this),b=l(E.length),D=c(x,b),I=c(C===void 0?b:C,b);if(s(E)&&(typeof(S=E.constructor)!="function"||S!==Array&&!s(S.prototype)?a(S)&&(S=S[y])===null&&(S=void 0):S=void 0,S===Array||S===void 0))return m.call(E,D,I);for(T=new(S===void 0?Array:S)(w(I-D,0)),_=0;D<I;D++,_++)D in E&&u(T,_,E[D]);return T.length=_,T}})},function(r,n,i){var o={};o[i(5)("toStringTag")]="z",r.exports=String(o)==="[object z]"},function(r,n,i){i(19),i(138),i(20),i(92),i(22),i(23),Object.defineProperty(n,"__esModule",{value:!0}),n.DefaultBuilderOptions={version:"1.0",encoding:void 0,standalone:void 0,keepNullNodes:!1,keepNullAttributes:!1,ignoreConverters:!1,convert:{att:"@",ins:"?",text:"#",cdata:"$",comment:"!"},defaultNamespace:{ele:void 0,att:void 0},namespaceAlias:{html:"http://www.w3.org/1999/xhtml",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"},invalidCharReplacement:void 0,parser:void 0},n.XMLBuilderOptionKeys=new Set(Object.keys(n.DefaultBuilderOptions)),n.DefaultXMLBuilderCBOptions={format:"xml",wellFormed:!1,prettyPrint:!1,indent:" ",newline:`
|
||
`,offset:0,width:0,allowEmptyTags:!1,spaceBeforeSlash:!1,keepNullNodes:!1,keepNullAttributes:!1,ignoreConverters:!1,convert:{att:"@",ins:"?",text:"#",cdata:"$",comment:"!"},defaultNamespace:{ele:void 0,att:void 0},namespaceAlias:{html:"http://www.w3.org/1999/xhtml",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"}}},function(r,n,i){var o=i(139),a=i(143);r.exports=o("Set",function(s){return function(){return s(this,arguments.length?arguments[0]:void 0)}},a)},function(r,n,i){var o,a,s=i(136),c=i(221),l=RegExp.prototype.exec,f=String.prototype.replace,u=l,d=(o=/a/,a=/b*/g,l.call(o,"a"),l.call(a,"a"),o.lastIndex!==0||a.lastIndex!==0),h=c.UNSUPPORTED_Y||c.BROKEN_CARET,g=/()??/.exec("")[1]!==void 0;(d||g||h)&&(u=function(p){var v,y,m,w,x=this,C=h&&x.sticky,S=s.call(x),T=x.source,_=0,E=p;return C&&((S=S.replace("y","")).indexOf("g")===-1&&(S+="g"),E=String(p).slice(x.lastIndex),x.lastIndex>0&&(!x.multiline||x.multiline&&p[x.lastIndex-1]!==`
|
||
`)&&(T="(?: "+T+")",E=" "+E,_++),y=new RegExp("^(?:"+T+")",S)),g&&(y=new RegExp("^"+T+"$(?!\\s)",S)),d&&(v=x.lastIndex),m=l.call(C?y:x,E),C?m?(m.input=m.input.slice(_),m[0]=m[0].slice(_),m.index=x.lastIndex,x.lastIndex+=m[0].length):x.lastIndex=0:d&&m&&(x.lastIndex=x.global?m.index+m[0].length:v),g&&m&&m.length>1&&f.call(m[0],y,function(){for(w=1;w<arguments.length-2;w++)arguments[w]===void 0&&(m[w]=void 0)}),m}),r.exports=u},function(r,n,i){var o=i(225),a=i(18),s=i(27),c=i(26),l=i(47),f=i(35),u=i(226),d=i(227),h=Math.max,g=Math.min,p=Math.floor,v=/\$([$&'`]|\d\d?|<[^>]*>)/g,y=/\$([$&'`]|\d\d?)/g;o("replace",2,function(m,w,x,C){var S=C.REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE,T=C.REPLACE_KEEPS_$0,_=S?"$":"$0";return[function(b,D){var I=f(this),P=b==null?void 0:b[m];return P!==void 0?P.call(b,I,D):w.call(String(I),b,D)},function(b,D){if(!S&&T||typeof D=="string"&&D.indexOf(_)===-1){var I=x(w,b,this,D);if(I.done)return I.value}var P=a(b),O=String(this),L=typeof D=="function";L||(D=String(D));var B=P.global;if(B){var H=P.unicode;P.lastIndex=0}for(var A=[];;){var F=d(P,O);if(F===null||(A.push(F),!B))break;String(F[0])===""&&(P.lastIndex=u(O,c(P.lastIndex),H))}for(var G,X="",ee=0,ce=0;ce<A.length;ce++){F=A[ce];for(var Se=String(F[0]),we=h(g(l(F.index),O.length),0),_e=[],Ve=1;Ve<F.length;Ve++)_e.push((G=F[Ve])===void 0?G:String(G));var Ge=F.groups;if(L){var Ne=[Se].concat(_e,we,O);Ge!==void 0&&Ne.push(Ge);var j=String(D.apply(void 0,Ne))}else j=E(Se,O,we,_e,Ge,D);we>=ee&&(X+=O.slice(ee,we)+j,ee=we+Se.length)}return X+O.slice(ee)}];function E(b,D,I,P,O,L){var B=I+b.length,H=P.length,A=y;return O!==void 0&&(O=s(O),A=v),w.call(L,A,function(F,G){var X;switch(G.charAt(0)){case"$":return"$";case"&":return b;case"`":return D.slice(0,I);case"'":return D.slice(B);case"<":X=O[G.slice(1,-1)];break;default:var ee=+G;if(ee===0)return F;if(ee>H){var ce=p(ee/10);return ce===0?F:ce<=H?P[ce-1]===void 0?G.charAt(1):P[ce-1]+G.charAt(1):F}X=P[ee-1]}return X===void 0?"":X})}})},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function a(){this._items={},this._nullItems=[]}return a.prototype.copy=function(){var s=new a;for(var c in this._items)s._items[c]=this._items[c].slice(0);return s._nullItems=this._nullItems.slice(0),s},a.prototype.get=function(s,c){var l=c===null?this._nullItems:this._items[c]||null;if(l===null)return null;for(var f=null,u=0;u<l.length;u++)if((f=l[u])===s)return f;return f},a.prototype.has=function(s,c){var l=c===null?this._nullItems:this._items[c]||null;return l!==null&&l.indexOf(s)!==-1},a.prototype.hasPrefix=function(s){if(this._nullItems.indexOf(s)!==-1)return!0;for(var c in this._items)if(this._items[c].indexOf(s)!==-1)return!0;return!1},a.prototype.set=function(s,c){var l=c===null?this._nullItems:this._items[c]||null;c!==null&&l===null?this._items[c]=[s]:l.push(s)},a}();n.NamespacePrefixMap=o},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0}),n.Surrogate=/[\uD800-\uDFFF]/,n.ScalarValue=/[\uD800-\uDFFF]/,n.NonCharacter=/[\uFDD0-\uFDEF\uFFFE\uFFFF]|[\uD83F\uD87F\uD8BF\uD8FF\uD93F\uD97F\uD9BF\uD9FF\uDA3F\uDA7F\uDABF\uDAFF\uDB3F\uDB7F\uDBBF\uDBFF][\uDFFE\uDFFF]/,n.ASCIICodePoint=/[\u0000-\u007F]/,n.ASCIITabOrNewLine=/[\t\n\r]/,n.ASCIIWhiteSpace=/[\t\n\f\r ]/,n.C0Control=/[\u0000-\u001F]/,n.C0ControlOrSpace=/[\u0000-\u001F ]/,n.Control=/[\u0000-\u001F\u007F-\u009F]/,n.ASCIIDigit=/[0-9]/,n.ASCIIUpperHexDigit=/[0-9A-F]/,n.ASCIILowerHexDigit=/[0-9a-f]/,n.ASCIIHexDigit=/[0-9A-Fa-f]/,n.ASCIIUpperAlpha=/[A-Z]/,n.ASCIILowerAlpha=/[a-z]/,n.ASCIIAlpha=/[A-Za-z]/,n.ASCIIAlphanumeric=/[0-9A-Za-z]/},function(r,n,i){var o=this&&this.__values||function(D){var I=typeof Symbol=="function"&&Symbol.iterator,P=I&&D[I],O=0;if(P)return P.call(D);if(D&&typeof D.length=="number")return{next:function(){return D&&O>=D.length&&(D=void 0),{value:D&&D[O++],done:!D}}};throw new TypeError(I?"Object is not iterable.":"Symbol.iterator is not defined.")},a=this&&this.__read||function(D,I){var P=typeof Symbol=="function"&&D[Symbol.iterator];if(!P)return D;var O,L,B=P.call(D),H=[];try{for(;(I===void 0||I-- >0)&&!(O=B.next()).done;)H.push(O.value)}catch(A){L={error:A}}finally{try{O&&!O.done&&(P=B.return)&&P.call(B)}finally{if(L)throw L.error}}return H},s=this&&this.__spread||function(){for(var D=[],I=0;I<arguments.length;I++)D=D.concat(a(arguments[I]));return D};Object.defineProperty(n,"__esModule",{value:!0});var c=i(6),l=i(2),f=i(3),u=i(171),d=i(104),h=i(9),g=i(17),p=i(72),v=i(30);function y(D,I){I===void 0&&(I=void 0),I===void 0&&(I=null);var P=m(D,I,new Date,{});return P._isTrusted=!0,P}function m(D,I,P,O){var L=new D("");return L._initializedFlag=!0,L._timeStamp=P.getTime(),Object.assign(L,O),c.dom.features.steps&&v.dom_runEventConstructingSteps(L),L}function w(D,I,P,O){var L,B,H,A;P===void 0&&(P=!1),O===void 0&&(O={value:!1});var F=!1;D._dispatchFlag=!0;var G=I;if(P){var X=I._associatedDocument;f.Guard.isDocumentNode(X)&&(G=X)}var ee=null,ce=g.tree_retarget(D._relatedTarget,I);if(I!==ce||I===D._relatedTarget){var Se=[];try{for(var we=o(D._touchTargetList),_e=we.next();!_e.done;_e=we.next()){var Ve=_e.value;Se.push(g.tree_retarget(Ve,I))}}catch(Xe){L={error:Xe}}finally{try{_e&&!_e.done&&(B=we.return)&&B.call(we)}finally{if(L)throw L.error}}x(D,I,G,ce,Se,!1);var Ge=f.Guard.isMouseEvent(D)&&D._type==="click";Ge&&I._activationBehavior!==void 0&&(ee=I);for(var Ne=f.Guard.isSlotable(I)&&p.shadowTree_isAssigned(I)?I:null,j=!1,M=I._getTheParent(D);M!==null&&f.Guard.isNode(M);){if(Ne!==null){if(!f.Guard.isSlot(M))throw new Error("Parent node of a slotable should be a slot.");Ne=null;var q=g.tree_rootNode(M,!0);f.Guard.isShadowRoot(q)&&q._mode==="closed"&&(j=!0)}f.Guard.isSlotable(M)&&p.shadowTree_isAssigned(M)&&(Ne=M),ce=g.tree_retarget(D._relatedTarget,M),Se=[];try{for(var K=(H=void 0,o(D._touchTargetList)),J=K.next();!J.done;J=K.next())Ve=J.value,Se.push(g.tree_retarget(Ve,M))}catch(Xe){H={error:Xe}}finally{try{J&&!J.done&&(A=K.return)&&A.call(K)}finally{if(H)throw H.error}}f.Guard.isWindow(M)||f.Guard.isNode(M)&&f.Guard.isNode(I)&&g.tree_isAncestorOf(g.tree_rootNode(I,!0),M,!0,!0)?(Ge&&D._bubbles&&ee===null&&M._activationBehavior&&(ee=M),x(D,M,null,ce,Se,j)):M===ce?M=null:(I=M,Ge&&ee===null&&I._activationBehavior&&(ee=I),x(D,M,I,ce,Se,j)),M!==null&&(M=M._getTheParent(D)),j=!1}for(var re=null,ie=D._path,Re=ie.length-1;Re>=0;Re--)if((je=ie[Re]).shadowAdjustedTarget!==null){re=je;break}if(re!==null)if(f.Guard.isNode(re.shadowAdjustedTarget)&&f.Guard.isShadowRoot(g.tree_rootNode(re.shadowAdjustedTarget,!0)))F=!0;else if(f.Guard.isNode(re.relatedTarget)&&f.Guard.isShadowRoot(g.tree_rootNode(re.relatedTarget,!0)))F=!0;else for(var Fe=0;Fe<re.touchTargetList.length;Fe++){var je=re.touchTargetList[Fe];if(f.Guard.isNode(je)&&f.Guard.isShadowRoot(g.tree_rootNode(je,!0))){F=!0;break}}for(ee!==null&&ee._legacyPreActivationBehavior!==void 0&&ee._legacyPreActivationBehavior(D),Re=ie.length-1;Re>=0;Re--)(je=ie[Re]).shadowAdjustedTarget!==null?D._eventPhase=l.EventPhase.AtTarget:D._eventPhase=l.EventPhase.Capturing,C(je,D,"capturing",O);for(Re=0;Re<ie.length;Re++){if((je=ie[Re]).shadowAdjustedTarget!==null)D._eventPhase=l.EventPhase.AtTarget;else{if(!D._bubbles)continue;D._eventPhase=l.EventPhase.Bubbling}C(je,D,"bubbling",O)}}return D._eventPhase=l.EventPhase.None,D._currentTarget=null,D._path=[],D._dispatchFlag=!1,D._stopPropagationFlag=!1,D._stopImmediatePropagationFlag=!1,F&&(D._target=null,D._relatedTarget=null,D._touchTargetList=[]),ee!==null&&(D._canceledFlag||ee._activationBehavior===void 0?ee._legacyCanceledActivationBehavior!==void 0&&ee._legacyCanceledActivationBehavior(D):ee._activationBehavior(D)),!D._canceledFlag}function x(D,I,P,O,L,B){var H=!1;f.Guard.isNode(I)&&f.Guard.isShadowRoot(g.tree_rootNode(I))&&(H=!0);var A=!1;f.Guard.isShadowRoot(I)&&I._mode==="closed"&&(A=!0),D._path.push({invocationTarget:I,invocationTargetInShadowTree:H,shadowAdjustedTarget:P,relatedTarget:O,touchTargetList:L,rootOfClosedTree:A,slotInClosedTree:B})}function C(D,I,P,O){O===void 0&&(O={value:!1});for(var L=I._path,B=-1,H=0;H<L.length;H++)if(L[H]===D){B=H;break}if(B!==-1){var A=L[B];(A.shadowAdjustedTarget!==null||B>0&&(A=L[B-1]).shadowAdjustedTarget!==null)&&(I._target=A.shadowAdjustedTarget)}if(I._relatedTarget=D.relatedTarget,I._touchTargetList=D.touchTargetList,!I._stopPropagationFlag){I._currentTarget=D.invocationTarget;var F=I._currentTarget._eventListenerList,G=new(Array.bind.apply(Array,s([void 0],F)));if(!S(I,G,P,D,O)&&I._isTrusted){var X=I._type;X==="animationend"?I._type="webkitAnimationEnd":X==="animationiteration"?I._type="webkitAnimationIteration":X==="animationstart"?I._type="webkitAnimationStart":X==="transitionend"&&(I._type="webkitTransitionEnd"),S(I,G,P,D,O),I._type=X}}}function S(D,I,P,O,L){L===void 0&&(L={value:!1});for(var B=!1,H=0;H<I.length;H++){var A=I[H];if(!A.removed){if(D._type!==A.type||(B=!0,P==="capturing"&&!A.capture)||P==="bubbling"&&A.capture)continue;if(A.once&&D._currentTarget!==null){for(var F=D._currentTarget,G=-1,X=0;X<F._eventListenerList.length;X++)if(F._eventListenerList[X]===A){G=X;break}G!==-1&&F._eventListenerList.splice(G,1)}var ee=void 0,ce=void 0;f.Guard.isWindow(ee)&&(ce=ee._currentEvent,O.invocationTargetInShadowTree===!1&&(ee._currentEvent=D)),A.passive&&(D._inPassiveListenerFlag=!0);try{A.callback.handleEvent.call(D._currentTarget,D)}catch{L.value=!0}if(A.passive&&(D._inPassiveListenerFlag=!1),f.Guard.isWindow(ee)&&(ee._currentEvent=ce),D._stopImmediatePropagationFlag)return B}}return B}function T(D,I){return null}function _(D,I){return null}function E(D,I){}function b(D,I){}n.event_setTheCanceledFlag=function(D){D._cancelable&&!D._inPassiveListenerFlag&&(D._canceledFlag=!0)},n.event_initialize=function(D,I,P,O){D._initializedFlag=!0,D._stopPropagationFlag=!1,D._stopImmediatePropagationFlag=!1,D._canceledFlag=!1,D._isTrusted=!1,D._target=null,D._type=I,D._bubbles=P,D._cancelable=O},n.event_createAnEvent=y,n.event_innerEventCreationSteps=m,n.event_dispatch=w,n.event_appendToAnEventPath=x,n.event_invoke=C,n.event_innerInvoke=S,n.event_fireAnEvent=function(D,I,P,O,L){P===void 0&&(P=d.EventImpl);var B=y(P);if(B._type=D,O)for(var H in O)B[H]=O[H];return w(B,I,L)},n.event_createLegacyEvent=function(D){var I=null;switch(D.toLowerCase()){case"beforeunloadevent":case"compositionevent":break;case"customevent":I=u.CustomEventImpl;break;case"devicemotionevent":case"deviceorientationevent":case"dragevent":break;case"event":case"events":I=d.EventImpl}if(I===null)throw new h.NotSupportedError("Event constructor not found for interface "+D+".");var P=new I("");return P._type="",P._timeStamp=new Date().getTime(),P._isTrusted=!1,P._initializedFlag=!1,P},n.event_getterEventHandlerIDLAttribute=function(D,I){return null},n.event_setterEventHandlerIDLAttribute=function(D,I,P){},n.event_determineTheTargetOfAnEventHandler=T,n.event_getTheCurrentValueOfAnEventHandler=_,n.event_activateAnEventHandler=E,n.event_deactivateAnEventHandler=b},function(r,n,i){var o,a=this&&this.__extends||(o=function(x,C){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(S,T){S.__proto__=T}||function(S,T){for(var _ in T)T.hasOwnProperty(_)&&(S[_]=T[_])})(x,C)},function(x,C){function S(){this.constructor=x}o(x,C),x.prototype=C===null?Object.create(C):(S.prototype=C.prototype,new S)}),s=this&&this.__values||function(x){var C=typeof Symbol=="function"&&Symbol.iterator,S=C&&x[C],T=0;if(S)return S.call(x);if(x&&typeof x.length=="number")return{next:function(){return x&&T>=x.length&&(x=void 0),{value:x&&x[T++],done:!x}}};throw new TypeError(C?"Object is not iterable.":"Symbol.iterator is not defined.")},c=this&&this.__read||function(x,C){var S=typeof Symbol=="function"&&x[Symbol.iterator];if(!S)return x;var T,_,E=S.call(x),b=[];try{for(;(C===void 0||C-- >0)&&!(T=E.next()).done;)b.push(T.value)}catch(D){_={error:D}}finally{try{T&&!T.done&&(S=E.return)&&S.call(E)}finally{if(_)throw _.error}}return b};Object.defineProperty(n,"__esModule",{value:!0});var l=i(6),f=i(2),u=i(9),d=i(34),h=i(3),g=i(1),p=i(7),v=i(152),y=i(0),m=i(12),w=function(x){function C(){var S=x.call(this)||this;return S._children=new Set,S._encoding={name:"UTF-8",labels:["unicode-1-1-utf-8","utf-8","utf8"]},S._contentType="application/xml",S._URL={scheme:"about",username:"",password:"",host:null,port:null,path:["blank"],query:null,fragment:null,_cannotBeABaseURLFlag:!0,_blobURLEntry:null},S._origin=null,S._type="xml",S._mode="no-quirks",S._documentElement=null,S._hasNamespaces=!1,S._nodeDocumentOverwrite=null,S}return a(C,x),Object.defineProperty(C.prototype,"_nodeDocument",{get:function(){return this._nodeDocumentOverwrite||this},set:function(S){this._nodeDocumentOverwrite=S},enumerable:!0,configurable:!0}),Object.defineProperty(C.prototype,"implementation",{get:function(){return this._implementation||(this._implementation=y.create_domImplementation(this))},enumerable:!0,configurable:!0}),Object.defineProperty(C.prototype,"URL",{get:function(){return v.urlSerializer(this._URL)},enumerable:!0,configurable:!0}),Object.defineProperty(C.prototype,"documentURI",{get:function(){return this.URL},enumerable:!0,configurable:!0}),Object.defineProperty(C.prototype,"origin",{get:function(){return"null"},enumerable:!0,configurable:!0}),Object.defineProperty(C.prototype,"compatMode",{get:function(){return this._mode==="quirks"?"BackCompat":"CSS1Compat"},enumerable:!0,configurable:!0}),Object.defineProperty(C.prototype,"characterSet",{get:function(){return this._encoding.name},enumerable:!0,configurable:!0}),Object.defineProperty(C.prototype,"charset",{get:function(){return this._encoding.name},enumerable:!0,configurable:!0}),Object.defineProperty(C.prototype,"inputEncoding",{get:function(){return this._encoding.name},enumerable:!0,configurable:!0}),Object.defineProperty(C.prototype,"contentType",{get:function(){return this._contentType},enumerable:!0,configurable:!0}),Object.defineProperty(C.prototype,"doctype",{get:function(){var S,T;try{for(var _=s(this._children),E=_.next();!E.done;E=_.next()){var b=E.value;if(h.Guard.isDocumentTypeNode(b))return b}}catch(D){S={error:D}}finally{try{E&&!E.done&&(T=_.return)&&T.call(_)}finally{if(S)throw S.error}}return null},enumerable:!0,configurable:!0}),Object.defineProperty(C.prototype,"documentElement",{get:function(){return this._documentElement},enumerable:!0,configurable:!0}),C.prototype.getElementsByTagName=function(S){return y.node_listOfElementsWithQualifiedName(S,this)},C.prototype.getElementsByTagNameNS=function(S,T){return y.node_listOfElementsWithNamespace(S,T,this)},C.prototype.getElementsByClassName=function(S){return y.node_listOfElementsWithClassNames(S,this)},C.prototype.createElement=function(S,T){if(!y.xml_isName(S))throw new u.InvalidCharacterError;this._type==="html"&&(S=S.toLowerCase());var _=null;T!==void 0&&(_=g.isString(T)?T:T.is);var E=this._type==="html"||this._contentType==="application/xhtml+xml"?p.namespace.HTML:null;return y.element_createAnElement(this,S,E,null,_,!0)},C.prototype.createElementNS=function(S,T,_){return y.document_internalCreateElementNS(this,S,T,_)},C.prototype.createDocumentFragment=function(){return y.create_documentFragment(this)},C.prototype.createTextNode=function(S){return y.create_text(this,S)},C.prototype.createCDATASection=function(S){if(this._type==="html")throw new u.NotSupportedError;if(S.indexOf("]]>")!==-1)throw new u.InvalidCharacterError;return y.create_cdataSection(this,S)},C.prototype.createComment=function(S){return y.create_comment(this,S)},C.prototype.createProcessingInstruction=function(S,T){if(!y.xml_isName(S))throw new u.InvalidCharacterError;if(T.indexOf("?>")!==-1)throw new u.InvalidCharacterError;return y.create_processingInstruction(this,S,T)},C.prototype.importNode=function(S,T){if(T===void 0&&(T=!1),h.Guard.isDocumentNode(S)||h.Guard.isShadowRoot(S))throw new u.NotSupportedError;return y.node_clone(S,this,T)},C.prototype.adoptNode=function(S){if(h.Guard.isDocumentNode(S))throw new u.NotSupportedError;if(h.Guard.isShadowRoot(S))throw new u.HierarchyRequestError;return y.document_adopt(S,this),S},C.prototype.createAttribute=function(S){if(!y.xml_isName(S))throw new u.InvalidCharacterError;return this._type==="html"&&(S=S.toLowerCase()),y.create_attr(this,S)},C.prototype.createAttributeNS=function(S,T){var _=c(y.namespace_validateAndExtract(S,T),3),E=_[0],b=_[1],D=_[2],I=y.create_attr(this,D);return I._namespace=E,I._namespacePrefix=b,I},C.prototype.createEvent=function(S){return y.event_createLegacyEvent(S)},C.prototype.createRange=function(){var S=y.create_range();return S._start=[this,0],S._end=[this,0],S},C.prototype.createNodeIterator=function(S,T,_){T===void 0&&(T=f.WhatToShow.All),_===void 0&&(_=null);var E=y.create_nodeIterator(S,S,!0);return E._whatToShow=T,E._iteratorCollection=y.create_nodeList(S),g.isFunction(_)?(E._filter=y.create_nodeFilter(),E._filter.acceptNode=_):E._filter=_,E},C.prototype.createTreeWalker=function(S,T,_){T===void 0&&(T=f.WhatToShow.All),_===void 0&&(_=null);var E=y.create_treeWalker(S,S);return E._whatToShow=T,g.isFunction(_)?(E._filter=y.create_nodeFilter(),E._filter.acceptNode=_):E._filter=_,E},C.prototype._getTheParent=function(S){return S._type==="load"?null:l.dom.window},C.prototype.getElementById=function(S){throw new Error("Mixin: NonElementParentNode not implemented.")},Object.defineProperty(C.prototype,"children",{get:function(){throw new Error("Mixin: ParentNode not implemented.")},enumerable:!0,configurable:!0}),Object.defineProperty(C.prototype,"firstElementChild",{get:function(){throw new Error("Mixin: ParentNode not implemented.")},enumerable:!0,configurable:!0}),Object.defineProperty(C.prototype,"lastElementChild",{get:function(){throw new Error("Mixin: ParentNode not implemented.")},enumerable:!0,configurable:!0}),Object.defineProperty(C.prototype,"childElementCount",{get:function(){throw new Error("Mixin: ParentNode not implemented.")},enumerable:!0,configurable:!0}),C.prototype.prepend=function(){for(var S=[],T=0;T<arguments.length;T++)S[T]=arguments[T];throw new Error("Mixin: ParentNode not implemented.")},C.prototype.append=function(){for(var S=[],T=0;T<arguments.length;T++)S[T]=arguments[T];throw new Error("Mixin: ParentNode not implemented.")},C.prototype.querySelector=function(S){throw new Error("Mixin: ParentNode not implemented.")},C.prototype.querySelectorAll=function(S){throw new Error("Mixin: ParentNode not implemented.")},C}(d.NodeImpl);n.DocumentImpl=w,m.idl_defineConst(w.prototype,"_nodeType",f.NodeType.Document)},function(r,n,i){var o,a=this&&this.__extends||(o=function(v,y){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(m,w){m.__proto__=w}||function(m,w){for(var x in w)w.hasOwnProperty(x)&&(m[x]=w[x])})(v,y)},function(v,y){function m(){this.constructor=v}o(v,y),v.prototype=y===null?Object.create(y):(m.prototype=y.prototype,new m)}),s=this&&this.__values||function(v){var y=typeof Symbol=="function"&&Symbol.iterator,m=y&&v[y],w=0;if(m)return m.call(v);if(v&&typeof v.length=="number")return{next:function(){return v&&w>=v.length&&(v=void 0),{value:v&&v[w++],done:!v}}};throw new TypeError(y?"Object is not iterable.":"Symbol.iterator is not defined.")},c=this&&this.__read||function(v,y){var m=typeof Symbol=="function"&&v[Symbol.iterator];if(!m)return v;var w,x,C=m.call(v),S=[];try{for(;(y===void 0||y-- >0)&&!(w=C.next()).done;)S.push(w.value)}catch(T){x={error:T}}finally{try{w&&!w.done&&(m=C.return)&&m.call(C)}finally{if(x)throw x.error}}return S};Object.defineProperty(n,"__esModule",{value:!0});var l=i(2),f=i(34),u=i(9),d=i(7),h=i(0),g=i(12),p=function(v){function y(){var m=v.call(this)||this;return m._children=new Set,m._namespace=null,m._namespacePrefix=null,m._localName="",m._customElementState="undefined",m._customElementDefinition=null,m._is=null,m._shadowRoot=null,m._attributeList=h.create_namedNodeMap(m),m._attributeChangeSteps=[],m._name="",m._assignedSlot=null,m}return a(y,v),Object.defineProperty(y.prototype,"namespaceURI",{get:function(){return this._namespace},enumerable:!0,configurable:!0}),Object.defineProperty(y.prototype,"prefix",{get:function(){return this._namespacePrefix},enumerable:!0,configurable:!0}),Object.defineProperty(y.prototype,"localName",{get:function(){return this._localName},enumerable:!0,configurable:!0}),Object.defineProperty(y.prototype,"tagName",{get:function(){return this._htmlUppercasedQualifiedName},enumerable:!0,configurable:!0}),Object.defineProperty(y.prototype,"id",{get:function(){return h.element_getAnAttributeValue(this,"id")},set:function(m){h.element_setAnAttributeValue(this,"id",m)},enumerable:!0,configurable:!0}),Object.defineProperty(y.prototype,"className",{get:function(){return h.element_getAnAttributeValue(this,"class")},set:function(m){h.element_setAnAttributeValue(this,"class",m)},enumerable:!0,configurable:!0}),Object.defineProperty(y.prototype,"classList",{get:function(){var m=h.element_getAnAttributeByName("class",this);return m===null&&(m=h.create_attr(this._nodeDocument,"class")),h.create_domTokenList(this,m)},enumerable:!0,configurable:!0}),Object.defineProperty(y.prototype,"slot",{get:function(){return h.element_getAnAttributeValue(this,"slot")},set:function(m){h.element_setAnAttributeValue(this,"slot",m)},enumerable:!0,configurable:!0}),y.prototype.hasAttributes=function(){return this._attributeList.length!==0},Object.defineProperty(y.prototype,"attributes",{get:function(){return this._attributeList},enumerable:!0,configurable:!0}),y.prototype.getAttributeNames=function(){var m,w,x=[];try{for(var C=s(this._attributeList),S=C.next();!S.done;S=C.next()){var T=S.value;x.push(T._qualifiedName)}}catch(_){m={error:_}}finally{try{S&&!S.done&&(w=C.return)&&w.call(C)}finally{if(m)throw m.error}}return x},y.prototype.getAttribute=function(m){var w=h.element_getAnAttributeByName(m,this);return w?w._value:null},y.prototype.getAttributeNS=function(m,w){var x=h.element_getAnAttributeByNamespaceAndLocalName(m,w,this);return x?x._value:null},y.prototype.setAttribute=function(m,w){if(!h.xml_isName(m))throw new u.InvalidCharacterError;this._namespace===d.namespace.HTML&&this._nodeDocument._type==="html"&&(m=m.toLowerCase());for(var x=null,C=0;C<this._attributeList.length;C++){var S=this._attributeList[C];if(S._qualifiedName===m){x=S;break}}if(x===null)return(x=h.create_attr(this._nodeDocument,m))._value=w,void h.element_append(x,this);h.element_change(x,this,w)},y.prototype.setAttributeNS=function(m,w,x){var C=c(h.namespace_validateAndExtract(m,w),3),S=C[0],T=C[1],_=C[2];h.element_setAnAttributeValue(this,_,x,T,S)},y.prototype.removeAttribute=function(m){h.element_removeAnAttributeByName(m,this)},y.prototype.removeAttributeNS=function(m,w){h.element_removeAnAttributeByNamespaceAndLocalName(m,w,this)},y.prototype.hasAttribute=function(m){this._namespace===d.namespace.HTML&&this._nodeDocument._type==="html"&&(m=m.toLowerCase());for(var w=0;w<this._attributeList.length;w++)if(this._attributeList[w]._qualifiedName===m)return!0;return!1},y.prototype.toggleAttribute=function(m,w){if(!h.xml_isName(m))throw new u.InvalidCharacterError;this._namespace===d.namespace.HTML&&this._nodeDocument._type==="html"&&(m=m.toLowerCase());for(var x=null,C=0;C<this._attributeList.length;C++){var S=this._attributeList[C];if(S._qualifiedName===m){x=S;break}}return x===null?(w===void 0||w===!0)&&((x=h.create_attr(this._nodeDocument,m))._value="",h.element_append(x,this),!0):w!==void 0&&w!==!1||(h.element_removeAnAttributeByName(m,this),!1)},y.prototype.hasAttributeNS=function(m,w){for(var x=m||null,C=0;C<this._attributeList.length;C++){var S=this._attributeList[C];if(S._namespace===x&&S._localName===w)return!0}return!1},y.prototype.getAttributeNode=function(m){return h.element_getAnAttributeByName(m,this)},y.prototype.getAttributeNodeNS=function(m,w){return h.element_getAnAttributeByNamespaceAndLocalName(m,w,this)},y.prototype.setAttributeNode=function(m){return h.element_setAnAttribute(m,this)},y.prototype.setAttributeNodeNS=function(m){return h.element_setAnAttribute(m,this)},y.prototype.removeAttributeNode=function(m){for(var w=!1,x=0;x<this._attributeList.length;x++)if(this._attributeList[x]===m){w=!0;break}if(!w)throw new u.NotFoundError;return h.element_remove(m,this),m},y.prototype.attachShadow=function(m){if(this._namespace!==d.namespace.HTML)throw new u.NotSupportedError;if(!h.customElement_isValidCustomElementName(this._localName)&&!h.customElement_isValidShadowHostName(this._localName))throw new u.NotSupportedError;if(h.customElement_isValidCustomElementName(this._localName)||this._is!==null){var w=h.customElement_lookUpACustomElementDefinition(this._nodeDocument,this._namespace,this._localName,this._is);if(w!==null&&w.disableShadow===!0)throw new u.NotSupportedError}if(this._shadowRoot!==null)throw new u.NotSupportedError;var x=h.create_shadowRoot(this._nodeDocument,this);return x._mode=m.mode,this._shadowRoot=x,x},Object.defineProperty(y.prototype,"shadowRoot",{get:function(){var m=this._shadowRoot;return m===null||m.mode==="closed"?null:m},enumerable:!0,configurable:!0}),y.prototype.closest=function(m){throw new u.NotImplementedError},y.prototype.matches=function(m){throw new u.NotImplementedError},y.prototype.webkitMatchesSelector=function(m){return this.matches(m)},y.prototype.getElementsByTagName=function(m){return h.node_listOfElementsWithQualifiedName(m,this)},y.prototype.getElementsByTagNameNS=function(m,w){return h.node_listOfElementsWithNamespace(m,w,this)},y.prototype.getElementsByClassName=function(m){return h.node_listOfElementsWithClassNames(m,this)},y.prototype.insertAdjacentElement=function(m,w){return h.element_insertAdjacent(this,m,w)},y.prototype.insertAdjacentText=function(m,w){var x=h.create_text(this._nodeDocument,w);h.element_insertAdjacent(this,m,x)},Object.defineProperty(y.prototype,"_qualifiedName",{get:function(){return this._namespacePrefix?this._namespacePrefix+":"+this._localName:this._localName},enumerable:!0,configurable:!0}),Object.defineProperty(y.prototype,"_htmlUppercasedQualifiedName",{get:function(){var m=this._qualifiedName;return this._namespace===d.namespace.HTML&&this._nodeDocument._type==="html"&&(m=m.toUpperCase()),m},enumerable:!0,configurable:!0}),Object.defineProperty(y.prototype,"children",{get:function(){throw new Error("Mixin: ParentNode not implemented.")},enumerable:!0,configurable:!0}),Object.defineProperty(y.prototype,"firstElementChild",{get:function(){throw new Error("Mixin: ParentNode not implemented.")},enumerable:!0,configurable:!0}),Object.defineProperty(y.prototype,"lastElementChild",{get:function(){throw new Error("Mixin: ParentNode not implemented.")},enumerable:!0,configurable:!0}),Object.defineProperty(y.prototype,"childElementCount",{get:function(){throw new Error("Mixin: ParentNode not implemented.")},enumerable:!0,configurable:!0}),y.prototype.prepend=function(){for(var m=[],w=0;w<arguments.length;w++)m[w]=arguments[w];throw new Error("Mixin: ParentNode not implemented.")},y.prototype.append=function(){for(var m=[],w=0;w<arguments.length;w++)m[w]=arguments[w];throw new Error("Mixin: ParentNode not implemented.")},y.prototype.querySelector=function(m){throw new Error("Mixin: ParentNode not implemented.")},y.prototype.querySelectorAll=function(m){throw new Error("Mixin: ParentNode not implemented.")},Object.defineProperty(y.prototype,"previousElementSibling",{get:function(){throw new Error("Mixin: NonDocumentTypeChildNode not implemented.")},enumerable:!0,configurable:!0}),Object.defineProperty(y.prototype,"nextElementSibling",{get:function(){throw new Error("Mixin: NonDocumentTypeChildNode not implemented.")},enumerable:!0,configurable:!0}),y.prototype.before=function(){for(var m=[],w=0;w<arguments.length;w++)m[w]=arguments[w];throw new Error("Mixin: ChildNode not implemented.")},y.prototype.after=function(){for(var m=[],w=0;w<arguments.length;w++)m[w]=arguments[w];throw new Error("Mixin: ChildNode not implemented.")},y.prototype.replaceWith=function(){for(var m=[],w=0;w<arguments.length;w++)m[w]=arguments[w];throw new Error("Mixin: ChildNode not implemented.")},y.prototype.remove=function(){throw new Error("Mixin: ChildNode not implemented.")},Object.defineProperty(y.prototype,"assignedSlot",{get:function(){throw new Error("Mixin: Slotable not implemented.")},enumerable:!0,configurable:!0}),y._create=function(m,w,x,C){x===void 0&&(x=null),C===void 0&&(C=null);var S=new y;return S._localName=w,S._namespace=x,S._namespacePrefix=C,S._nodeDocument=m,S},y}(f.NodeImpl);n.ElementImpl=p,g.idl_defineConst(p.prototype,"_nodeType",l.NodeType.Element)},function(r,n,i){var o,a=this&&this.__extends||(o=function(u,d){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(h,g){h.__proto__=g}||function(h,g){for(var p in g)g.hasOwnProperty(p)&&(h[p]=g[p])})(u,d)},function(u,d){function h(){this.constructor=u}o(u,d),u.prototype=d===null?Object.create(d):(h.prototype=d.prototype,new h)});Object.defineProperty(n,"__esModule",{value:!0});var s=i(2),c=i(34),l=i(12),f=function(u){function d(h){h===void 0&&(h=null);var g=u.call(this)||this;return g._children=new Set,g._host=h,g}return a(d,u),d.prototype.getElementById=function(h){throw new Error("Mixin: NonElementParentNode not implemented.")},Object.defineProperty(d.prototype,"children",{get:function(){throw new Error("Mixin: ParentNode not implemented.")},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"firstElementChild",{get:function(){throw new Error("Mixin: ParentNode not implemented.")},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"lastElementChild",{get:function(){throw new Error("Mixin: ParentNode not implemented.")},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"childElementCount",{get:function(){throw new Error("Mixin: ParentNode not implemented.")},enumerable:!0,configurable:!0}),d.prototype.prepend=function(){for(var h=[],g=0;g<arguments.length;g++)h[g]=arguments[g];throw new Error("Mixin: ParentNode not implemented.")},d.prototype.append=function(){for(var h=[],g=0;g<arguments.length;g++)h[g]=arguments[g];throw new Error("Mixin: ParentNode not implemented.")},d.prototype.querySelector=function(h){throw new Error("Mixin: ParentNode not implemented.")},d.prototype.querySelectorAll=function(h){throw new Error("Mixin: ParentNode not implemented.")},d._create=function(h,g){g===void 0&&(g=null);var p=new d(g);return p._nodeDocument=h,p},d}(c.NodeImpl);n.DocumentFragmentImpl=f,l.idl_defineConst(f.prototype,"_nodeType",s.NodeType.DocumentFragment)},function(r,n,i){var o,a=this&&this.__extends||(o=function(h,g){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(p,v){p.__proto__=v}||function(p,v){for(var y in v)v.hasOwnProperty(y)&&(p[y]=v[y])})(h,g)},function(h,g){function p(){this.constructor=h}o(h,g),h.prototype=g===null?Object.create(g):(p.prototype=g.prototype,new p)}),s=this&&this.__values||function(h){var g=typeof Symbol=="function"&&Symbol.iterator,p=g&&h[g],v=0;if(p)return p.call(h);if(h&&typeof h.length=="number")return{next:function(){return h&&v>=h.length&&(h=void 0),{value:h&&h[v++],done:!h}}};throw new TypeError(g?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var c=i(2),l=i(71),f=i(0),u=i(12),d=function(h){function g(p){p===void 0&&(p="");var v=h.call(this,p)||this;return v._name="",v._assignedSlot=null,v}return a(g,h),Object.defineProperty(g.prototype,"wholeText",{get:function(){var p,v,y="";try{for(var m=s(f.text_contiguousTextNodes(this,!0)),w=m.next();!w.done;w=m.next())y+=w.value._data}catch(x){p={error:x}}finally{try{w&&!w.done&&(v=m.return)&&v.call(m)}finally{if(p)throw p.error}}return y},enumerable:!0,configurable:!0}),g.prototype.splitText=function(p){return f.text_split(this,p)},Object.defineProperty(g.prototype,"assignedSlot",{get:function(){throw new Error("Mixin: Slotable not implemented.")},enumerable:!0,configurable:!0}),g._create=function(p,v){v===void 0&&(v="");var y=new g(v);return y._nodeDocument=p,y},g}(l.CharacterDataImpl);n.TextImpl=d,u.idl_defineConst(d.prototype,"_nodeType",c.NodeType.Text)},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function a(){}return Object.defineProperty(a.prototype,"_startNode",{get:function(){return this._start[0]},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"_startOffset",{get:function(){return this._start[1]},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"_endNode",{get:function(){return this._end[0]},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"_endOffset",{get:function(){return this._end[1]},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"_collapsed",{get:function(){return this._start[0]===this._end[0]&&this._start[1]===this._end[1]},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"startContainer",{get:function(){return this._startNode},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"startOffset",{get:function(){return this._startOffset},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"endContainer",{get:function(){return this._endNode},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"endOffset",{get:function(){return this._endOffset},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"collapsed",{get:function(){return this._collapsed},enumerable:!0,configurable:!0}),a}();n.AbstractRangeImpl=o},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(2),a=function(){function s(c){this._activeFlag=!1,this._root=c,this._whatToShow=o.WhatToShow.All,this._filter=null}return Object.defineProperty(s.prototype,"root",{get:function(){return this._root},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"whatToShow",{get:function(){return this._whatToShow},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"filter",{get:function(){return this._filter},enumerable:!0,configurable:!0}),s}();n.TraverserImpl=a},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(2),a=i(0),s=i(12),c=function(){function l(f,u){this._target=null,this._relatedTarget=null,this._touchTargetList=[],this._path=[],this._currentTarget=null,this._eventPhase=o.EventPhase.None,this._stopPropagationFlag=!1,this._stopImmediatePropagationFlag=!1,this._canceledFlag=!1,this._inPassiveListenerFlag=!1,this._composedFlag=!1,this._initializedFlag=!1,this._dispatchFlag=!1,this._isTrusted=!1,this._bubbles=!1,this._cancelable=!1,this._type=f,u&&(this._bubbles=u.bubbles||!1,this._cancelable=u.cancelable||!1,this._composedFlag=u.composed||!1),this._initializedFlag=!0,this._timeStamp=new Date().getTime()}return Object.defineProperty(l.prototype,"type",{get:function(){return this._type},enumerable:!0,configurable:!0}),Object.defineProperty(l.prototype,"target",{get:function(){return this._target},enumerable:!0,configurable:!0}),Object.defineProperty(l.prototype,"srcElement",{get:function(){return this._target},enumerable:!0,configurable:!0}),Object.defineProperty(l.prototype,"currentTarget",{get:function(){return this._currentTarget},enumerable:!0,configurable:!0}),l.prototype.composedPath=function(){var f=[],u=this._path;if(u.length===0)return f;var d=this._currentTarget;if(d===null)throw new Error("Event currentTarget is null.");f.push(d);for(var h=0,g=0,p=u.length-1;p>=0;){if(u[p].rootOfClosedTree&&g++,u[p].invocationTarget===d){h=p;break}u[p].slotInClosedTree&&g--,p--}var v=g,y=g;for(p=h-1;p>=0;)u[p].rootOfClosedTree&&v++,v<=y&&f.unshift(u[p].invocationTarget),u[p].slotInClosedTree&&--v<y&&(y=v),p--;for(v=g,y=g,p=h+1;p<u.length;)u[p].slotInClosedTree&&v++,v<=y&&f.push(u[p].invocationTarget),u[p].rootOfClosedTree&&--v<y&&(y=v),p++;return f},Object.defineProperty(l.prototype,"eventPhase",{get:function(){return this._eventPhase},enumerable:!0,configurable:!0}),l.prototype.stopPropagation=function(){this._stopPropagationFlag=!0},Object.defineProperty(l.prototype,"cancelBubble",{get:function(){return this._stopPropagationFlag},set:function(f){f&&this.stopPropagation()},enumerable:!0,configurable:!0}),l.prototype.stopImmediatePropagation=function(){this._stopPropagationFlag=!0,this._stopImmediatePropagationFlag=!0},Object.defineProperty(l.prototype,"bubbles",{get:function(){return this._bubbles},enumerable:!0,configurable:!0}),Object.defineProperty(l.prototype,"cancelable",{get:function(){return this._cancelable},enumerable:!0,configurable:!0}),Object.defineProperty(l.prototype,"returnValue",{get:function(){return!this._canceledFlag},set:function(f){f||a.event_setTheCanceledFlag(this)},enumerable:!0,configurable:!0}),l.prototype.preventDefault=function(){a.event_setTheCanceledFlag(this)},Object.defineProperty(l.prototype,"defaultPrevented",{get:function(){return this._canceledFlag},enumerable:!0,configurable:!0}),Object.defineProperty(l.prototype,"composed",{get:function(){return this._composedFlag},enumerable:!0,configurable:!0}),Object.defineProperty(l.prototype,"isTrusted",{get:function(){return this._isTrusted},enumerable:!0,configurable:!0}),Object.defineProperty(l.prototype,"timeStamp",{get:function(){return this._timeStamp},enumerable:!0,configurable:!0}),l.prototype.initEvent=function(f,u,d){u===void 0&&(u=!1),d===void 0&&(d=!1),this._dispatchFlag||a.event_initialize(this,f,u,d)},l.NONE=0,l.CAPTURING_PHASE=1,l.AT_TARGET=2,l.BUBBLING_PHASE=3,l}();n.EventImpl=c,s.idl_defineConst(c.prototype,"NONE",0),s.idl_defineConst(c.prototype,"CAPTURING_PHASE",1),s.idl_defineConst(c.prototype,"AT_TARGET",2),s.idl_defineConst(c.prototype,"BUBBLING_PHASE",3)},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(2),a=i(9);n.traversal_filter=function(s,c){if(s._activeFlag)throw new a.InvalidStateError;var l=1<<c._nodeType-1;if(!(s.whatToShow&l))return o.FilterResult.Skip;if(!s.filter)return o.FilterResult.Accept;s._activeFlag=!0;var f=o.FilterResult.Reject;try{f=s.filter.acceptNode(c)}catch(u){throw s._activeFlag=!1,u}return s._activeFlag=!1,f}},function(r,n,i){var o=this&&this.__read||function(y,m){var w=typeof Symbol=="function"&&y[Symbol.iterator];if(!w)return y;var x,C,S=w.call(y),T=[];try{for(;(m===void 0||m-- >0)&&!(x=S.next()).done;)T.push(x.value)}catch(_){C={error:_}}finally{try{x&&!x.done&&(w=S.return)&&w.call(S)}finally{if(C)throw C.error}}return T},a=this&&this.__values||function(y){var m=typeof Symbol=="function"&&Symbol.iterator,w=m&&y[m],x=0;if(w)return w.call(y);if(y&&typeof y.length=="number")return{next:function(){return y&&x>=y.length&&(y=void 0),{value:y&&y[x++],done:!y}}};throw new TypeError(m?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var s=i(6),c=i(3),l=i(1),f=i(99),u=i(73),d=i(17),h=i(173),g=i(30),p=i(52),v=i(37);n.document_elementInterface=function(y,m){return f.ElementImpl},n.document_internalCreateElementNS=function(y,m,w,x){var C=o(h.namespace_validateAndExtract(m,w),3),S=C[0],T=C[1],_=C[2],E=null;return x!==void 0&&(E=l.isString(x)?x:x.is),p.element_createAnElement(y,_,S,T,E,!0)},n.document_adopt=function(y,m){var w,x;if(y._nodeDocument!==m||y._parent!==null){var C=y._nodeDocument;if(y._parent&&v.mutation_remove(y,y._parent),m!==C)for(var S=d.tree_getFirstDescendantNode(y,!0,!0);S!==null;){if(S._nodeDocument=m,c.Guard.isElementNode(S))try{for(var T=(w=void 0,a(S._attributeList._asArray())),_=T.next();!_.done;_=T.next())_.value._nodeDocument=m}catch(E){w={error:E}}finally{try{_&&!_.done&&(x=T.return)&&x.call(T)}finally{if(w)throw w.error}}s.dom.features.customElements&&c.Guard.isElementNode(S)&&S._customElementState==="custom"&&u.customElement_enqueueACustomElementCallbackReaction(S,"adoptedCallback",[C,m]),s.dom.features.steps&&g.dom_runAdoptingSteps(S,C),S=d.tree_getNextDescendantNode(y,S,!0,!0)}}}},function(r,n,i){var o=this&&this.__values||function(d){var h=typeof Symbol=="function"&&Symbol.iterator,g=h&&d[h],p=0;if(g)return g.call(d);if(d&&typeof d.length=="number")return{next:function(){return d&&p>=d.length&&(d=void 0),{value:d&&d[p++],done:!d}}};throw new TypeError(h?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var a=i(6),s=i(3),c=i(9),l=i(17),f=i(51),u=i(30);n.characterData_replaceData=function(d,h,g,p){var v,y,m=l.tree_nodeLength(d);if(h>m)throw new c.IndexSizeError("Offset exceeds character data length. Offset: "+h+", Length: "+m+", Node is "+d.nodeName+".");h+g>m&&(g=m-h),a.dom.features.mutationObservers&&f.observer_queueMutationRecord("characterData",d,null,null,d._data,[],[],null,null);var w=d._data.substring(0,h)+p+d._data.substring(h+g);d._data=w;try{for(var x=o(a.dom.rangeList),C=x.next();!C.done;C=x.next()){var S=C.value;S._start[0]===d&&S._start[1]>h&&S._start[1]<=h+g&&(S._start[1]=h),S._end[0]===d&&S._end[1]>h&&S._end[1]<=h+g&&(S._end[1]=h),S._start[0]===d&&S._start[1]>h+g&&(S._start[1]+=p.length-g),S._end[0]===d&&S._end[1]>h+g&&(S._end[1]+=p.length-g)}}catch(T){v={error:T}}finally{try{C&&!C.done&&(y=x.return)&&y.call(x)}finally{if(v)throw v.error}}a.dom.features.steps&&s.Guard.isTextNode(d)&&d._parent!==null&&u.dom_runChildTextContentChangeSteps(d._parent)},n.characterData_substringData=function(d,h,g){var p=l.tree_nodeLength(d);if(h>p)throw new c.IndexSizeError("Offset exceeds character data length. Offset: "+h+", Length: "+p+", Node is "+d.nodeName+".");return h+g>p?d._data.substr(h):d._data.substr(h,g)}},function(r,n,i){var o=this&&this.__read||function(u,d){var h=typeof Symbol=="function"&&u[Symbol.iterator];if(!h)return u;var g,p,v=h.call(u),y=[];try{for(;(d===void 0||d-- >0)&&!(g=v.next()).done;)y.push(g.value)}catch(m){p={error:m}}finally{try{g&&!g.done&&(h=v.return)&&h.call(v)}finally{if(p)throw p.error}}return y},a=this&&this.__spread||function(){for(var u=[],d=0;d<arguments.length;d++)u=u.concat(o(arguments[d]));return u},s=this&&this.__values||function(u){var d=typeof Symbol=="function"&&Symbol.iterator,h=d&&u[d],g=0;if(h)return h.call(u);if(u&&typeof u.length=="number")return{next:function(){return u&&g>=u.length&&(u=void 0),{value:u&&u[g++],done:!u}}};throw new TypeError(d?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var c=i(7);function l(u){var d=c.string.splitAStringOnASCIIWhitespace(u);return new Set(d)}function f(u){return a(u).join(" ")}n.orderedSet_parse=l,n.orderedSet_serialize=f,n.orderedSet_sanitize=function(u){return f(l(u))},n.orderedSet_contains=function(u,d,h){var g,p,v,y;try{for(var m=s(d),w=m.next();!w.done;w=m.next()){var x=w.value,C=!1;try{for(var S=(v=void 0,s(u)),T=S.next();!T.done;T=S.next()){var _=T.value;if(h){if(_===x){C=!0;break}}else if(_.toUpperCase()===x.toUpperCase()){C=!0;break}}}catch(E){v={error:E}}finally{try{T&&!T.done&&(y=S.return)&&y.call(S)}finally{if(v)throw v.error}}if(!C)return!1}}catch(E){g={error:E}}finally{try{w&&!w.done&&(p=m.return)&&p.call(m)}finally{if(g)throw g.error}}return!0}},function(r,n,i){i(179),Object.defineProperty(n,"__esModule",{value:!0});var o=i(262),a=i(110),s=i(1);a.dom.setFeatures(!1),n.createDocument=function(){var c=new o.DOMImplementation().createDocument(null,"root",null);return c.documentElement&&c.removeChild(c.documentElement),c},n.sanitizeInput=function(c,l){if(c==null)return c;if(l===void 0)return c+"";var f="";c+="";for(var u=0;u<c.length;u++){var d=c.charCodeAt(u);if(d===9||d===10||d===13||d>=32&&d<=55295||d>=57344&&d<=65533)f+=c.charAt(u);else if(d>=55296&&d<=56319&&u<c.length-1){var h=c.charCodeAt(u+1);h>=56320&&h<=57343?(d=1024*(d-55296)+h-56320+65536,f+=String.fromCodePoint(d),u++):f+=s.isString(l)?l:l(c.charAt(u),u,c)}else f+=s.isString(l)?l:l(c.charAt(u),u,c)}return f}},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(1),a=i(153);n.AbortController=a.AbortControllerImpl;var s=i(154);n.AbortSignal=s.AbortSignalImpl;var c=i(102);n.AbstractRange=c.AbstractRangeImpl;var l=i(157);n.Attr=l.AttrImpl;var f=i(158);n.CDATASection=f.CDATASectionImpl;var u=i(71);n.CharacterData=u.CharacterDataImpl;var d=i(263),h=i(159);n.Comment=h.CommentImpl;var g=i(171);n.CustomEvent=g.CustomEventImpl;var p=i(100);n.DocumentFragment=p.DocumentFragmentImpl;var v=i(98);n.Document=v.DocumentImpl;var y=i(264),m=i(155);n.DocumentType=m.DocumentTypeImpl;var w=i(6);n.dom=w.dom;var x=i(148);n.DOMImplementation=x.DOMImplementationImpl;var C=i(170);n.DOMTokenList=C.DOMTokenListImpl;var S=i(99);n.Element=S.ElementImpl;var T=i(104);n.Event=T.EventImpl;var _=i(70);n.EventTarget=_.EventTargetImpl;var E=i(161);n.HTMLCollection=E.HTMLCollectionImpl;var b=i(265);n.MutationObserver=b.MutationObserverImpl;var D=i(169);n.MutationRecord=D.MutationRecordImpl;var I=i(164);n.NamedNodeMap=I.NamedNodeMapImpl;var P=i(168);n.NodeFilter=P.NodeFilterImpl;var O=i(34);n.Node=O.NodeImpl;var L=i(166);n.NodeIterator=L.NodeIteratorImpl;var B=i(162);n.NodeList=B.NodeListImpl;var H=i(163);n.NodeListStatic=H.NodeListStaticImpl;var A=i(266),F=i(267),G=i(268),X=i(160);n.ProcessingInstruction=X.ProcessingInstructionImpl;var ee=i(165);n.Range=ee.RangeImpl;var ce=i(156);n.ShadowRoot=ce.ShadowRootImpl;var Se=i(269),we=i(270);n.StaticRange=we.StaticRangeImpl;var _e=i(101);n.Text=_e.TextImpl;var Ve=i(103);n.Traverser=Ve.TraverserImpl;var Ge=i(167);n.TreeWalker=Ge.TreeWalkerImpl;var Ne=i(149);n.Window=Ne.WindowImpl;var j=i(151);n.XMLDocument=j.XMLDocumentImpl,o.applyMixin(S.ElementImpl,d.ChildNodeImpl),o.applyMixin(u.CharacterDataImpl,d.ChildNodeImpl),o.applyMixin(m.DocumentTypeImpl,d.ChildNodeImpl),o.applyMixin(v.DocumentImpl,y.DocumentOrShadowRootImpl),o.applyMixin(ce.ShadowRootImpl,y.DocumentOrShadowRootImpl),o.applyMixin(S.ElementImpl,A.NonDocumentTypeChildNodeImpl),o.applyMixin(u.CharacterDataImpl,A.NonDocumentTypeChildNodeImpl),o.applyMixin(v.DocumentImpl,F.NonElementParentNodeImpl),o.applyMixin(p.DocumentFragmentImpl,F.NonElementParentNodeImpl),o.applyMixin(v.DocumentImpl,G.ParentNodeImpl),o.applyMixin(p.DocumentFragmentImpl,G.ParentNodeImpl),o.applyMixin(S.ElementImpl,G.ParentNodeImpl),o.applyMixin(_e.TextImpl,Se.SlotableImpl),o.applyMixin(S.ElementImpl,Se.SlotableImpl)},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0}),function(o){o[o.EOF=0]="EOF",o[o.Declaration=1]="Declaration",o[o.DocType=2]="DocType",o[o.Element=3]="Element",o[o.Text=4]="Text",o[o.CDATA=5]="CDATA",o[o.PI=6]="PI",o[o.Comment=7]="Comment",o[o.ClosingTag=8]="ClosingTag"}(n.TokenType||(n.TokenType={}))},function(r,n,i){i(64),i(20),i(66);var o,a=this&&this.__extends||(o=function(l,f){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(u,d){u.__proto__=d}||function(u,d){for(var h in d)d.hasOwnProperty(h)&&(u[h]=d[h])})(l,f)},function(l,f){function u(){this.constructor=l}o(l,f),l.prototype=f===null?Object.create(f):(u.prototype=f.prototype,new u)});Object.defineProperty(n,"__esModule",{value:!0});var s=i(1),c=function(l){function f(){return l!==null&&l.apply(this,arguments)||this}return a(f,l),f.prototype._parse=function(u,d){var h=this,g=this._builderOptions,p=null;return s.isFunction(d)?p=this.parse(u,d.apply(this)):s.isArray(d)||s.isSet(d)?s.forEachArray(d,function(v){return p=h.parse(u,v)},this):s.isMap(d)||s.isObject(d)?s.forEachObject(d,function(v,y){if(s.isFunction(y)&&(y=y.apply(h)),g.ignoreConverters||v.indexOf(g.convert.att)!==0)if(g.ignoreConverters||v.indexOf(g.convert.text)!==0)if(g.ignoreConverters||v.indexOf(g.convert.cdata)!==0)if(g.ignoreConverters||v.indexOf(g.convert.comment)!==0)if(g.ignoreConverters||v.indexOf(g.convert.ins)!==0){if(!((s.isArray(y)||s.isSet(y))&&s.isEmpty(y))){if((s.isMap(y)||s.isObject(y))&&s.isEmpty(y))p=h.element(u,void 0,h.sanitize(v))||p;else if(g.keepNullNodes||y!=null)if(s.isArray(y)||s.isSet(y))s.forEachArray(y,function(S){var T={};T[v]=S,p=h.parse(u,T)},h);else if(s.isMap(y)||s.isObject(y))(m=h.element(u,void 0,h.sanitize(v)))&&(p=m,h.parse(m,y));else if(y!=null&&y!==""){var m;(m=h.element(u,void 0,h.sanitize(v)))&&(p=m,h.text(m,h._decodeText(h.sanitize(y))))}else p=h.element(u,void 0,h.sanitize(v))||p}}else if(s.isString(y)){var w=y.indexOf(" "),x=w===-1?y:y.substr(0,w),C=w===-1?"":y.substr(w+1);p=h.instruction(u,h.sanitize(x),h.sanitize(C))||p}else s.isArray(y)||s.isSet(y)?s.forEachArray(y,function(S){var T=S.indexOf(" "),_=T===-1?S:S.substr(0,T),E=T===-1?"":S.substr(T+1);p=h.instruction(u,h.sanitize(_),h.sanitize(E))||p},h):s.forEachObject(y,function(S,T){return p=h.instruction(u,h.sanitize(S),h.sanitize(T))||p},h);else s.isArray(y)||s.isSet(y)?s.forEachArray(y,function(S){return p=h.comment(u,h.sanitize(S))||p},h):p=h.comment(u,h.sanitize(y))||p;else s.isArray(y)||s.isSet(y)?s.forEachArray(y,function(S){return p=h.cdata(u,h.sanitize(S))||p},h):p=h.cdata(u,h.sanitize(y))||p;else p=s.isMap(y)||s.isObject(y)?h.parse(u,y):h.text(u,h._decodeText(h.sanitize(y)))||p;else if(v===g.convert.att){if(s.isArray(y)||s.isSet(y))throw new Error("Invalid attribute: "+y.toString()+". "+u._debugInfo());s.forEachObject(y,function(S,T){p=h.attribute(u,void 0,h.sanitize(S),h._decodeAttributeValue(h.sanitize(T)))||p})}else p=h.attribute(u,void 0,h.sanitize(v.substr(g.convert.att.length)),h._decodeAttributeValue(h.sanitize(y)))||p},this):(g.keepNullNodes||d!=null)&&(p=this.text(u,this._decodeText(this.sanitize(d)))||p),p||u},f}(i(75).BaseReader);n.ObjectReader=c},function(r,n,i){var o=i(39);r.exports=new o({explicit:[i(286),i(287),i(288)]})},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=function(a){this.level=0,this._builderOptions=a,this._writerOptions=a};n.BaseCBWriter=o},function(r,n,i){var o=i(16),a=i(8),s=i(116);r.exports=!o&&!a(function(){return Object.defineProperty(s("div"),"a",{get:function(){return 7}}).a!=7})},function(r,n,i){var o=i(11),a=i(13),s=o.document,c=a(s)&&a(s.createElement);r.exports=function(l){return c?s.createElement(l):{}}},function(r,n,i){var o=i(118),a=Function.toString;typeof o.inspectSource!="function"&&(o.inspectSource=function(s){return a.call(s)}),r.exports=o.inspectSource},function(r,n,i){var o=i(11),a=i(80),s=o["__core-js_shared__"]||a("__core-js_shared__",{});r.exports=s},function(r,n,i){var o=i(14),a=i(187),s=i(55),c=i(15);r.exports=function(l,f){for(var u=a(f),d=c.f,h=s.f,g=0;g<u.length;g++){var p=u[g];o(l,p)||d(l,p,h(f,p))}}},function(r,n,i){var o=i(11);r.exports=o},function(r,n,i){var o=i(14),a=i(24),s=i(122).indexOf,c=i(45);r.exports=function(l,f){var u,d=a(l),h=0,g=[];for(u in d)!o(c,u)&&o(d,u)&&g.push(u);for(;f.length>h;)o(d,u=f[h++])&&(~s(g,u)||g.push(u));return g}},function(r,n,i){var o=i(24),a=i(26),s=i(83),c=function(l){return function(f,u,d){var h,g=o(f),p=a(g.length),v=s(d,p);if(l&&u!=u){for(;p>v;)if((h=g[v++])!=h)return!0}else for(;p>v;v++)if((l||v in g)&&g[v]===u)return l||v||0;return!l&&-1}};r.exports={includes:c(!0),indexOf:c(!1)}},function(r,n,i){var o=i(8),a=/#|\.prototype\./,s=function(d,h){var g=l[c(d)];return g==u||g!=f&&(typeof h=="function"?o(h):!!h)},c=s.normalize=function(d){return String(d).replace(a,".").toLowerCase()},l=s.data={},f=s.NATIVE="N",u=s.POLYFILL="P";r.exports=s},function(r,n,i){var o=i(86);r.exports=o&&!Symbol.sham&&typeof Symbol.iterator=="symbol"},function(r,n,i){var o=i(5);n.f=o},function(r,n,i){var o=i(120),a=i(14),s=i(125),c=i(15).f;r.exports=function(l){var f=o.Symbol||(o.Symbol={});a(f,l)||c(f,l,{value:s.f(l)})}},function(r,n){r.exports=function(i){if(typeof i!="function")throw TypeError(String(i)+" is not a function");return i}},function(r,n,i){var o=i(13),a=i(59),s=i(5)("species");r.exports=function(c,l){var f;return a(c)&&(typeof(f=c.constructor)!="function"||f!==Array&&!a(f.prototype)?o(f)&&(f=f[s])===null&&(f=void 0):f=void 0),new(f===void 0?Array:f)(l===0?0:l)}},function(r,n,i){var o,a,s=i(11),c=i(193),l=s.process,f=l&&l.versions,u=f&&f.v8;u?a=(o=u.split("."))[0]+o[1]:c&&(!(o=c.match(/Edge\/(\d+)/))||o[1]>=74)&&(o=c.match(/Chrome\/(\d+)/))&&(a=o[1]),r.exports=a&&+a},function(r,n,i){var o=i(5),a=i(60),s=i(15),c=o("unscopables"),l=Array.prototype;l[c]==null&&s.f(l,c,{configurable:!0,value:a(null)}),r.exports=function(f){l[c][f]=!0}},function(r,n,i){var o,a,s,c=i(132),l=i(21),f=i(14),u=i(5),d=i(44),h=u("iterator"),g=!1;[].keys&&("next"in(s=[].keys())?(a=c(c(s)))!==Object.prototype&&(o=a):g=!0),o==null&&(o={}),d||f(o,h)||l(o,h,function(){return this}),r.exports={IteratorPrototype:o,BUGGY_SAFARI_ITERATORS:g}},function(r,n,i){var o=i(14),a=i(27),s=i(57),c=i(196),l=s("IE_PROTO"),f=Object.prototype;r.exports=c?Object.getPrototypeOf:function(u){return u=a(u),o(u,l)?u[l]:typeof u.constructor=="function"&&u instanceof u.constructor?u.constructor.prototype:u instanceof Object?f:null}},function(r,n,i){var o=i(18),a=i(197);r.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var s,c=!1,l={};try{(s=Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set).call(l,[]),c=l instanceof Array}catch{}return function(f,u){return o(f),a(u),c?s.call(f,u):f.__proto__=u,f}}():void 0)},function(r,n,i){var o=i(56),a=i(15),s=i(40);r.exports=function(c,l,f){var u=o(l);u in c?a.f(c,u,s(0,f)):c[u]=f}},function(r,n,i){var o=i(90),a=i(42),s=i(5)("toStringTag"),c=a(function(){return arguments}())=="Arguments";r.exports=o?a:function(l){var f,u,d;return l===void 0?"Undefined":l===null?"Null":typeof(u=function(h,g){try{return h[g]}catch{}}(f=Object(l),s))=="string"?u:c?a(f):(d=a(f))=="Object"&&typeof f.callee=="function"?"Arguments":d}},function(r,n,i){var o=i(18);r.exports=function(){var a=o(this),s="";return a.global&&(s+="g"),a.ignoreCase&&(s+="i"),a.multiline&&(s+="m"),a.dotAll&&(s+="s"),a.unicode&&(s+="u"),a.sticky&&(s+="y"),s}},function(r,n,i){var o=i(47),a=i(35),s=function(c){return function(l,f){var u,d,h=String(a(l)),g=o(f),p=h.length;return g<0||g>=p?c?"":void 0:(u=h.charCodeAt(g))<55296||u>56319||g+1===p||(d=h.charCodeAt(g+1))<56320||d>57343?c?h.charAt(g):u:c?h.slice(g,g+2):d-56320+(u-55296<<10)+65536}};r.exports={codeAt:s(!1),charAt:s(!0)}},function(r,n,i){var o=i(4),a=i(27),s=i(61);o({target:"Object",stat:!0,forced:i(8)(function(){s(1)})},{keys:function(c){return s(a(c))}})},function(r,n,i){var o=i(4),a=i(11),s=i(123),c=i(25),l=i(140),f=i(141),u=i(142),d=i(13),h=i(8),g=i(208),p=i(62),v=i(209);r.exports=function(y,m,w){var x=y.indexOf("Map")!==-1,C=y.indexOf("Weak")!==-1,S=x?"set":"add",T=a[y],_=T&&T.prototype,E=T,b={},D=function(H){var A=_[H];c(_,H,H=="add"?function(F){return A.call(this,F===0?0:F),this}:H=="delete"?function(F){return!(C&&!d(F))&&A.call(this,F===0?0:F)}:H=="get"?function(F){return C&&!d(F)?void 0:A.call(this,F===0?0:F)}:H=="has"?function(F){return!(C&&!d(F))&&A.call(this,F===0?0:F)}:function(F,G){return A.call(this,F===0?0:F,G),this})};if(s(y,typeof T!="function"||!(C||_.forEach&&!h(function(){new T().entries().next()}))))E=w.getConstructor(m,y,x,S),l.REQUIRED=!0;else if(s(y,!0)){var I=new E,P=I[S](C?{}:-0,1)!=I,O=h(function(){I.has(1)}),L=g(function(H){new T(H)}),B=!C&&h(function(){for(var H=new T,A=5;A--;)H[S](A,A);return!H.has(-0)});L||((E=m(function(H,A){u(H,E,y);var F=v(new T,H,E);return A!=null&&f(A,F[S],F,x),F})).prototype=_,_.constructor=E),(O||B)&&(D("delete"),D("has"),x&&D("get")),(B||P)&&D(S),C&&_.clear&&delete _.clear}return b[y]=E,o({global:!0,forced:E!=T},b),p(E,y),C||w.setStrong(E,y,x),E}},function(r,n,i){var o=i(45),a=i(13),s=i(14),c=i(15).f,l=i(58),f=i(204),u=l("meta"),d=0,h=Object.isExtensible||function(){return!0},g=function(v){c(v,u,{value:{objectID:"O"+ ++d,weakData:{}}})},p=r.exports={REQUIRED:!1,fastKey:function(v,y){if(!a(v))return typeof v=="symbol"?v:(typeof v=="string"?"S":"P")+v;if(!s(v,u)){if(!h(v))return"F";if(!y)return"E";g(v)}return v[u].objectID},getWeakData:function(v,y){if(!s(v,u)){if(!h(v))return!0;if(!y)return!1;g(v)}return v[u].weakData},onFreeze:function(v){return f&&p.REQUIRED&&h(v)&&!s(v,u)&&g(v),v}};o[u]=!0},function(r,n,i){var o=i(18),a=i(205),s=i(26),c=i(87),l=i(206),f=i(207),u=function(d,h){this.stopped=d,this.result=h};(r.exports=function(d,h,g,p,v){var y,m,w,x,C,S,T,_=c(h,g,p?2:1);if(v)y=d;else{if(typeof(m=l(d))!="function")throw TypeError("Target is not iterable");if(a(m)){for(w=0,x=s(d.length);x>w;w++)if((C=p?_(o(T=d[w])[0],T[1]):_(d[w]))&&C instanceof u)return C;return new u(!1)}y=m.call(d)}for(S=y.next;!(T=S.call(y)).done;)if(typeof(C=f(y,_,T.value,p))=="object"&&C&&C instanceof u)return C;return new u(!1)}).stop=function(d){return new u(!0,d)}},function(r,n){r.exports=function(i,o,a){if(!(i instanceof o))throw TypeError("Incorrect "+(a?a+" ":"")+"invocation");return i}},function(r,n,i){var o=i(15).f,a=i(60),s=i(210),c=i(87),l=i(142),f=i(141),u=i(88),d=i(211),h=i(16),g=i(140).fastKey,p=i(43),v=p.set,y=p.getterFor;r.exports={getConstructor:function(m,w,x,C){var S=m(function(b,D){l(b,S,w),v(b,{type:w,index:a(null),first:void 0,last:void 0,size:0}),h||(b.size=0),D!=null&&f(D,b[C],b,x)}),T=y(w),_=function(b,D,I){var P,O,L=T(b),B=E(b,D);return B?B.value=I:(L.last=B={index:O=g(D,!0),key:D,value:I,previous:P=L.last,next:void 0,removed:!1},L.first||(L.first=B),P&&(P.next=B),h?L.size++:b.size++,O!=="F"&&(L.index[O]=B)),b},E=function(b,D){var I,P=T(b),O=g(D);if(O!=="F")return P.index[O];for(I=P.first;I;I=I.next)if(I.key==D)return I};return s(S.prototype,{clear:function(){for(var b=T(this),D=b.index,I=b.first;I;)I.removed=!0,I.previous&&(I.previous=I.previous.next=void 0),delete D[I.index],I=I.next;b.first=b.last=void 0,h?b.size=0:this.size=0},delete:function(b){var D=T(this),I=E(this,b);if(I){var P=I.next,O=I.previous;delete D.index[I.index],I.removed=!0,O&&(O.next=P),P&&(P.previous=O),D.first==I&&(D.first=P),D.last==I&&(D.last=O),h?D.size--:this.size--}return!!I},forEach:function(b){for(var D,I=T(this),P=c(b,arguments.length>1?arguments[1]:void 0,3);D=D?D.next:I.first;)for(P(D.value,D.key,this);D&&D.removed;)D=D.previous},has:function(b){return!!E(this,b)}}),s(S.prototype,x?{get:function(b){var D=E(this,b);return D&&D.value},set:function(b,D){return _(this,b===0?0:b,D)}}:{add:function(b){return _(this,b=b===0?0:b,b)}}),h&&o(S.prototype,"size",{get:function(){return T(this).size}}),S},setStrong:function(m,w,x){var C=w+" Iterator",S=y(w),T=y(C);u(m,w,function(_,E){v(this,{type:C,target:_,state:S(_),kind:E,last:void 0})},function(){for(var _=T(this),E=_.kind,b=_.last;b&&b.removed;)b=b.previous;return _.target&&(_.last=b=b?b.next:_.state.first)?E=="keys"?{value:b.key,done:!1}:E=="values"?{value:b.value,done:!1}:{value:[b.key,b.value],done:!1}:(_.target=void 0,{value:void 0,done:!0})},x?"entries":"values",!x,!0),d(w)}}},function(r,n,i){var o,a=i(4),s=i(55).f,c=i(26),l=i(222),f=i(35),u=i(224),d=i(44),h="".endsWith,g=Math.min,p=u("endsWith");a({target:"String",proto:!0,forced:!!(d||p||(o=s(String.prototype,"endsWith"),!o||o.writable))&&!p},{endsWith:function(v){var y=String(f(this));l(v);var m=arguments.length>1?arguments[1]:void 0,w=c(y.length),x=m===void 0?w:g(c(m),w),C=String(v);return h?h.call(y,C,x):y.slice(x-C.length,x)===C}})},function(r,n,i){(function(o){/*!
|
||
* The buffer module from node.js, for the browser.
|
||
*
|
||
* @author Feross Aboukhadijeh <http://feross.org>
|
||
* @license MIT
|
||
*/var a=i(229),s=i(230),c=i(231);function l(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function f(j,M){if(l()<M)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(j=new Uint8Array(M)).__proto__=u.prototype:(j===null&&(j=new u(M)),j.length=M),j}function u(j,M,q){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(j,M,q);if(typeof j=="number"){if(typeof M=="string")throw new Error("If encoding is specified then the first argument must be a string");return g(this,j)}return d(this,j,M,q)}function d(j,M,q,K){if(typeof M=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer<"u"&&M instanceof ArrayBuffer?function(J,re,ie,Re){if(re.byteLength,ie<0||re.byteLength<ie)throw new RangeError("'offset' is out of bounds");if(re.byteLength<ie+(Re||0))throw new RangeError("'length' is out of bounds");return re=ie===void 0&&Re===void 0?new Uint8Array(re):Re===void 0?new Uint8Array(re,ie):new Uint8Array(re,ie,Re),u.TYPED_ARRAY_SUPPORT?(J=re).__proto__=u.prototype:J=p(J,re),J}(j,M,q,K):typeof M=="string"?function(J,re,ie){if(typeof ie=="string"&&ie!==""||(ie="utf8"),!u.isEncoding(ie))throw new TypeError('"encoding" must be a valid string encoding');var Re=0|y(re,ie),Fe=(J=f(J,Re)).write(re,ie);return Fe!==Re&&(J=J.slice(0,Fe)),J}(j,M,q):function(J,re){if(u.isBuffer(re)){var ie=0|v(re.length);return(J=f(J,ie)).length===0||re.copy(J,0,0,ie),J}if(re){if(typeof ArrayBuffer<"u"&&re.buffer instanceof ArrayBuffer||"length"in re)return typeof re.length!="number"||(Re=re.length)!=Re?f(J,0):p(J,re);if(re.type==="Buffer"&&c(re.data))return p(J,re.data)}var Re;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(j,M)}function h(j){if(typeof j!="number")throw new TypeError('"size" argument must be a number');if(j<0)throw new RangeError('"size" argument must not be negative')}function g(j,M){if(h(M),j=f(j,M<0?0:0|v(M)),!u.TYPED_ARRAY_SUPPORT)for(var q=0;q<M;++q)j[q]=0;return j}function p(j,M){var q=M.length<0?0:0|v(M.length);j=f(j,q);for(var K=0;K<q;K+=1)j[K]=255&M[K];return j}function v(j){if(j>=l())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+l().toString(16)+" bytes");return 0|j}function y(j,M){if(u.isBuffer(j))return j.length;if(typeof ArrayBuffer<"u"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(j)||j instanceof ArrayBuffer))return j.byteLength;typeof j!="string"&&(j=""+j);var q=j.length;if(q===0)return 0;for(var K=!1;;)switch(M){case"ascii":case"latin1":case"binary":return q;case"utf8":case"utf-8":case void 0:return Ve(j).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*q;case"hex":return q>>>1;case"base64":return Ge(j).length;default:if(K)return Ve(j).length;M=(""+M).toLowerCase(),K=!0}}function m(j,M,q){var K=!1;if((M===void 0||M<0)&&(M=0),M>this.length||((q===void 0||q>this.length)&&(q=this.length),q<=0)||(q>>>=0)<=(M>>>=0))return"";for(j||(j="utf8");;)switch(j){case"hex":return B(this,M,q);case"utf8":case"utf-8":return P(this,M,q);case"ascii":return O(this,M,q);case"latin1":case"binary":return L(this,M,q);case"base64":return I(this,M,q);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return H(this,M,q);default:if(K)throw new TypeError("Unknown encoding: "+j);j=(j+"").toLowerCase(),K=!0}}function w(j,M,q){var K=j[M];j[M]=j[q],j[q]=K}function x(j,M,q,K,J){if(j.length===0)return-1;if(typeof q=="string"?(K=q,q=0):q>2147483647?q=2147483647:q<-2147483648&&(q=-2147483648),q=+q,isNaN(q)&&(q=J?0:j.length-1),q<0&&(q=j.length+q),q>=j.length){if(J)return-1;q=j.length-1}else if(q<0){if(!J)return-1;q=0}if(typeof M=="string"&&(M=u.from(M,K)),u.isBuffer(M))return M.length===0?-1:C(j,M,q,K,J);if(typeof M=="number")return M&=255,u.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?J?Uint8Array.prototype.indexOf.call(j,M,q):Uint8Array.prototype.lastIndexOf.call(j,M,q):C(j,[M],q,K,J);throw new TypeError("val must be string, number or Buffer")}function C(j,M,q,K,J){var re,ie=1,Re=j.length,Fe=M.length;if(K!==void 0&&((K=String(K).toLowerCase())==="ucs2"||K==="ucs-2"||K==="utf16le"||K==="utf-16le")){if(j.length<2||M.length<2)return-1;ie=2,Re/=2,Fe/=2,q/=2}function je(Pe,pe){return ie===1?Pe[pe]:Pe.readUInt16BE(pe*ie)}if(J){var Xe=-1;for(re=q;re<Re;re++)if(je(j,re)===je(M,Xe===-1?0:re-Xe)){if(Xe===-1&&(Xe=re),re-Xe+1===Fe)return Xe*ie}else Xe!==-1&&(re-=re-Xe),Xe=-1}else for(q+Fe>Re&&(q=Re-Fe),re=q;re>=0;re--){for(var se=!0,ue=0;ue<Fe;ue++)if(je(j,re+ue)!==je(M,ue)){se=!1;break}if(se)return re}return-1}function S(j,M,q,K){q=Number(q)||0;var J=j.length-q;K?(K=Number(K))>J&&(K=J):K=J;var re=M.length;if(re%2!=0)throw new TypeError("Invalid hex string");K>re/2&&(K=re/2);for(var ie=0;ie<K;++ie){var Re=parseInt(M.substr(2*ie,2),16);if(isNaN(Re))return ie;j[q+ie]=Re}return ie}function T(j,M,q,K){return Ne(Ve(M,j.length-q),j,q,K)}function _(j,M,q,K){return Ne(function(J){for(var re=[],ie=0;ie<J.length;++ie)re.push(255&J.charCodeAt(ie));return re}(M),j,q,K)}function E(j,M,q,K){return _(j,M,q,K)}function b(j,M,q,K){return Ne(Ge(M),j,q,K)}function D(j,M,q,K){return Ne(function(J,re){for(var ie,Re,Fe,je=[],Xe=0;Xe<J.length&&!((re-=2)<0);++Xe)ie=J.charCodeAt(Xe),Re=ie>>8,Fe=ie%256,je.push(Fe),je.push(Re);return je}(M,j.length-q),j,q,K)}function I(j,M,q){return M===0&&q===j.length?a.fromByteArray(j):a.fromByteArray(j.slice(M,q))}function P(j,M,q){q=Math.min(j.length,q);for(var K=[],J=M;J<q;){var re,ie,Re,Fe,je=j[J],Xe=null,se=je>239?4:je>223?3:je>191?2:1;if(J+se<=q)switch(se){case 1:je<128&&(Xe=je);break;case 2:(192&(re=j[J+1]))==128&&(Fe=(31&je)<<6|63&re)>127&&(Xe=Fe);break;case 3:re=j[J+1],ie=j[J+2],(192&re)==128&&(192&ie)==128&&(Fe=(15&je)<<12|(63&re)<<6|63&ie)>2047&&(Fe<55296||Fe>57343)&&(Xe=Fe);break;case 4:re=j[J+1],ie=j[J+2],Re=j[J+3],(192&re)==128&&(192&ie)==128&&(192&Re)==128&&(Fe=(15&je)<<18|(63&re)<<12|(63&ie)<<6|63&Re)>65535&&Fe<1114112&&(Xe=Fe)}Xe===null?(Xe=65533,se=1):Xe>65535&&(Xe-=65536,K.push(Xe>>>10&1023|55296),Xe=56320|1023&Xe),K.push(Xe),J+=se}return function(ue){var Pe=ue.length;if(Pe<=4096)return String.fromCharCode.apply(String,ue);for(var pe="",Ee=0;Ee<Pe;)pe+=String.fromCharCode.apply(String,ue.slice(Ee,Ee+=4096));return pe}(K)}n.Buffer=u,n.SlowBuffer=function(j){return+j!=j&&(j=0),u.alloc(+j)},n.INSPECT_MAX_BYTES=50,u.TYPED_ARRAY_SUPPORT=o.TYPED_ARRAY_SUPPORT!==void 0?o.TYPED_ARRAY_SUPPORT:function(){try{var j=new Uint8Array(1);return j.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},j.foo()===42&&typeof j.subarray=="function"&&j.subarray(1,1).byteLength===0}catch{return!1}}(),n.kMaxLength=l(),u.poolSize=8192,u._augment=function(j){return j.__proto__=u.prototype,j},u.from=function(j,M,q){return d(null,j,M,q)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,typeof Symbol<"u"&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(j,M,q){return function(K,J,re,ie){return h(J),J<=0?f(K,J):re!==void 0?typeof ie=="string"?f(K,J).fill(re,ie):f(K,J).fill(re):f(K,J)}(null,j,M,q)},u.allocUnsafe=function(j){return g(null,j)},u.allocUnsafeSlow=function(j){return g(null,j)},u.isBuffer=function(j){return!(j==null||!j._isBuffer)},u.compare=function(j,M){if(!u.isBuffer(j)||!u.isBuffer(M))throw new TypeError("Arguments must be Buffers");if(j===M)return 0;for(var q=j.length,K=M.length,J=0,re=Math.min(q,K);J<re;++J)if(j[J]!==M[J]){q=j[J],K=M[J];break}return q<K?-1:K<q?1:0},u.isEncoding=function(j){switch(String(j).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(j,M){if(!c(j))throw new TypeError('"list" argument must be an Array of Buffers');if(j.length===0)return u.alloc(0);var q;if(M===void 0)for(M=0,q=0;q<j.length;++q)M+=j[q].length;var K=u.allocUnsafe(M),J=0;for(q=0;q<j.length;++q){var re=j[q];if(!u.isBuffer(re))throw new TypeError('"list" argument must be an Array of Buffers');re.copy(K,J),J+=re.length}return K},u.byteLength=y,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var j=this.length;if(j%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var M=0;M<j;M+=2)w(this,M,M+1);return this},u.prototype.swap32=function(){var j=this.length;if(j%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var M=0;M<j;M+=4)w(this,M,M+3),w(this,M+1,M+2);return this},u.prototype.swap64=function(){var j=this.length;if(j%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var M=0;M<j;M+=8)w(this,M,M+7),w(this,M+1,M+6),w(this,M+2,M+5),w(this,M+3,M+4);return this},u.prototype.toString=function(){var j=0|this.length;return j===0?"":arguments.length===0?P(this,0,j):m.apply(this,arguments)},u.prototype.equals=function(j){if(!u.isBuffer(j))throw new TypeError("Argument must be a Buffer");return this===j||u.compare(this,j)===0},u.prototype.inspect=function(){var j="",M=n.INSPECT_MAX_BYTES;return this.length>0&&(j=this.toString("hex",0,M).match(/.{2}/g).join(" "),this.length>M&&(j+=" ... ")),"<Buffer "+j+">"},u.prototype.compare=function(j,M,q,K,J){if(!u.isBuffer(j))throw new TypeError("Argument must be a Buffer");if(M===void 0&&(M=0),q===void 0&&(q=j?j.length:0),K===void 0&&(K=0),J===void 0&&(J=this.length),M<0||q>j.length||K<0||J>this.length)throw new RangeError("out of range index");if(K>=J&&M>=q)return 0;if(K>=J)return-1;if(M>=q)return 1;if(this===j)return 0;for(var re=(J>>>=0)-(K>>>=0),ie=(q>>>=0)-(M>>>=0),Re=Math.min(re,ie),Fe=this.slice(K,J),je=j.slice(M,q),Xe=0;Xe<Re;++Xe)if(Fe[Xe]!==je[Xe]){re=Fe[Xe],ie=je[Xe];break}return re<ie?-1:ie<re?1:0},u.prototype.includes=function(j,M,q){return this.indexOf(j,M,q)!==-1},u.prototype.indexOf=function(j,M,q){return x(this,j,M,q,!0)},u.prototype.lastIndexOf=function(j,M,q){return x(this,j,M,q,!1)},u.prototype.write=function(j,M,q,K){if(M===void 0)K="utf8",q=this.length,M=0;else if(q===void 0&&typeof M=="string")K=M,q=this.length,M=0;else{if(!isFinite(M))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");M|=0,isFinite(q)?(q|=0,K===void 0&&(K="utf8")):(K=q,q=void 0)}var J=this.length-M;if((q===void 0||q>J)&&(q=J),j.length>0&&(q<0||M<0)||M>this.length)throw new RangeError("Attempt to write outside buffer bounds");K||(K="utf8");for(var re=!1;;)switch(K){case"hex":return S(this,j,M,q);case"utf8":case"utf-8":return T(this,j,M,q);case"ascii":return _(this,j,M,q);case"latin1":case"binary":return E(this,j,M,q);case"base64":return b(this,j,M,q);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return D(this,j,M,q);default:if(re)throw new TypeError("Unknown encoding: "+K);K=(""+K).toLowerCase(),re=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function O(j,M,q){var K="";q=Math.min(j.length,q);for(var J=M;J<q;++J)K+=String.fromCharCode(127&j[J]);return K}function L(j,M,q){var K="";q=Math.min(j.length,q);for(var J=M;J<q;++J)K+=String.fromCharCode(j[J]);return K}function B(j,M,q){var K=j.length;(!M||M<0)&&(M=0),(!q||q<0||q>K)&&(q=K);for(var J="",re=M;re<q;++re)J+=_e(j[re]);return J}function H(j,M,q){for(var K=j.slice(M,q),J="",re=0;re<K.length;re+=2)J+=String.fromCharCode(K[re]+256*K[re+1]);return J}function A(j,M,q){if(j%1!=0||j<0)throw new RangeError("offset is not uint");if(j+M>q)throw new RangeError("Trying to access beyond buffer length")}function F(j,M,q,K,J,re){if(!u.isBuffer(j))throw new TypeError('"buffer" argument must be a Buffer instance');if(M>J||M<re)throw new RangeError('"value" argument is out of bounds');if(q+K>j.length)throw new RangeError("Index out of range")}function G(j,M,q,K){M<0&&(M=65535+M+1);for(var J=0,re=Math.min(j.length-q,2);J<re;++J)j[q+J]=(M&255<<8*(K?J:1-J))>>>8*(K?J:1-J)}function X(j,M,q,K){M<0&&(M=4294967295+M+1);for(var J=0,re=Math.min(j.length-q,4);J<re;++J)j[q+J]=M>>>8*(K?J:3-J)&255}function ee(j,M,q,K,J,re){if(q+K>j.length)throw new RangeError("Index out of range");if(q<0)throw new RangeError("Index out of range")}function ce(j,M,q,K,J){return J||ee(j,0,q,4),s.write(j,M,q,K,23,4),q+4}function Se(j,M,q,K,J){return J||ee(j,0,q,8),s.write(j,M,q,K,52,8),q+8}u.prototype.slice=function(j,M){var q,K=this.length;if((j=~~j)<0?(j+=K)<0&&(j=0):j>K&&(j=K),(M=M===void 0?K:~~M)<0?(M+=K)<0&&(M=0):M>K&&(M=K),M<j&&(M=j),u.TYPED_ARRAY_SUPPORT)(q=this.subarray(j,M)).__proto__=u.prototype;else{var J=M-j;q=new u(J,void 0);for(var re=0;re<J;++re)q[re]=this[re+j]}return q},u.prototype.readUIntLE=function(j,M,q){j|=0,M|=0,q||A(j,M,this.length);for(var K=this[j],J=1,re=0;++re<M&&(J*=256);)K+=this[j+re]*J;return K},u.prototype.readUIntBE=function(j,M,q){j|=0,M|=0,q||A(j,M,this.length);for(var K=this[j+--M],J=1;M>0&&(J*=256);)K+=this[j+--M]*J;return K},u.prototype.readUInt8=function(j,M){return M||A(j,1,this.length),this[j]},u.prototype.readUInt16LE=function(j,M){return M||A(j,2,this.length),this[j]|this[j+1]<<8},u.prototype.readUInt16BE=function(j,M){return M||A(j,2,this.length),this[j]<<8|this[j+1]},u.prototype.readUInt32LE=function(j,M){return M||A(j,4,this.length),(this[j]|this[j+1]<<8|this[j+2]<<16)+16777216*this[j+3]},u.prototype.readUInt32BE=function(j,M){return M||A(j,4,this.length),16777216*this[j]+(this[j+1]<<16|this[j+2]<<8|this[j+3])},u.prototype.readIntLE=function(j,M,q){j|=0,M|=0,q||A(j,M,this.length);for(var K=this[j],J=1,re=0;++re<M&&(J*=256);)K+=this[j+re]*J;return K>=(J*=128)&&(K-=Math.pow(2,8*M)),K},u.prototype.readIntBE=function(j,M,q){j|=0,M|=0,q||A(j,M,this.length);for(var K=M,J=1,re=this[j+--K];K>0&&(J*=256);)re+=this[j+--K]*J;return re>=(J*=128)&&(re-=Math.pow(2,8*M)),re},u.prototype.readInt8=function(j,M){return M||A(j,1,this.length),128&this[j]?-1*(255-this[j]+1):this[j]},u.prototype.readInt16LE=function(j,M){M||A(j,2,this.length);var q=this[j]|this[j+1]<<8;return 32768&q?4294901760|q:q},u.prototype.readInt16BE=function(j,M){M||A(j,2,this.length);var q=this[j+1]|this[j]<<8;return 32768&q?4294901760|q:q},u.prototype.readInt32LE=function(j,M){return M||A(j,4,this.length),this[j]|this[j+1]<<8|this[j+2]<<16|this[j+3]<<24},u.prototype.readInt32BE=function(j,M){return M||A(j,4,this.length),this[j]<<24|this[j+1]<<16|this[j+2]<<8|this[j+3]},u.prototype.readFloatLE=function(j,M){return M||A(j,4,this.length),s.read(this,j,!0,23,4)},u.prototype.readFloatBE=function(j,M){return M||A(j,4,this.length),s.read(this,j,!1,23,4)},u.prototype.readDoubleLE=function(j,M){return M||A(j,8,this.length),s.read(this,j,!0,52,8)},u.prototype.readDoubleBE=function(j,M){return M||A(j,8,this.length),s.read(this,j,!1,52,8)},u.prototype.writeUIntLE=function(j,M,q,K){j=+j,M|=0,q|=0,K||F(this,j,M,q,Math.pow(2,8*q)-1,0);var J=1,re=0;for(this[M]=255&j;++re<q&&(J*=256);)this[M+re]=j/J&255;return M+q},u.prototype.writeUIntBE=function(j,M,q,K){j=+j,M|=0,q|=0,K||F(this,j,M,q,Math.pow(2,8*q)-1,0);var J=q-1,re=1;for(this[M+J]=255&j;--J>=0&&(re*=256);)this[M+J]=j/re&255;return M+q},u.prototype.writeUInt8=function(j,M,q){return j=+j,M|=0,q||F(this,j,M,1,255,0),u.TYPED_ARRAY_SUPPORT||(j=Math.floor(j)),this[M]=255&j,M+1},u.prototype.writeUInt16LE=function(j,M,q){return j=+j,M|=0,q||F(this,j,M,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[M]=255&j,this[M+1]=j>>>8):G(this,j,M,!0),M+2},u.prototype.writeUInt16BE=function(j,M,q){return j=+j,M|=0,q||F(this,j,M,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[M]=j>>>8,this[M+1]=255&j):G(this,j,M,!1),M+2},u.prototype.writeUInt32LE=function(j,M,q){return j=+j,M|=0,q||F(this,j,M,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[M+3]=j>>>24,this[M+2]=j>>>16,this[M+1]=j>>>8,this[M]=255&j):X(this,j,M,!0),M+4},u.prototype.writeUInt32BE=function(j,M,q){return j=+j,M|=0,q||F(this,j,M,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[M]=j>>>24,this[M+1]=j>>>16,this[M+2]=j>>>8,this[M+3]=255&j):X(this,j,M,!1),M+4},u.prototype.writeIntLE=function(j,M,q,K){if(j=+j,M|=0,!K){var J=Math.pow(2,8*q-1);F(this,j,M,q,J-1,-J)}var re=0,ie=1,Re=0;for(this[M]=255&j;++re<q&&(ie*=256);)j<0&&Re===0&&this[M+re-1]!==0&&(Re=1),this[M+re]=(j/ie>>0)-Re&255;return M+q},u.prototype.writeIntBE=function(j,M,q,K){if(j=+j,M|=0,!K){var J=Math.pow(2,8*q-1);F(this,j,M,q,J-1,-J)}var re=q-1,ie=1,Re=0;for(this[M+re]=255&j;--re>=0&&(ie*=256);)j<0&&Re===0&&this[M+re+1]!==0&&(Re=1),this[M+re]=(j/ie>>0)-Re&255;return M+q},u.prototype.writeInt8=function(j,M,q){return j=+j,M|=0,q||F(this,j,M,1,127,-128),u.TYPED_ARRAY_SUPPORT||(j=Math.floor(j)),j<0&&(j=255+j+1),this[M]=255&j,M+1},u.prototype.writeInt16LE=function(j,M,q){return j=+j,M|=0,q||F(this,j,M,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[M]=255&j,this[M+1]=j>>>8):G(this,j,M,!0),M+2},u.prototype.writeInt16BE=function(j,M,q){return j=+j,M|=0,q||F(this,j,M,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[M]=j>>>8,this[M+1]=255&j):G(this,j,M,!1),M+2},u.prototype.writeInt32LE=function(j,M,q){return j=+j,M|=0,q||F(this,j,M,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[M]=255&j,this[M+1]=j>>>8,this[M+2]=j>>>16,this[M+3]=j>>>24):X(this,j,M,!0),M+4},u.prototype.writeInt32BE=function(j,M,q){return j=+j,M|=0,q||F(this,j,M,4,2147483647,-2147483648),j<0&&(j=4294967295+j+1),u.TYPED_ARRAY_SUPPORT?(this[M]=j>>>24,this[M+1]=j>>>16,this[M+2]=j>>>8,this[M+3]=255&j):X(this,j,M,!1),M+4},u.prototype.writeFloatLE=function(j,M,q){return ce(this,j,M,!0,q)},u.prototype.writeFloatBE=function(j,M,q){return ce(this,j,M,!1,q)},u.prototype.writeDoubleLE=function(j,M,q){return Se(this,j,M,!0,q)},u.prototype.writeDoubleBE=function(j,M,q){return Se(this,j,M,!1,q)},u.prototype.copy=function(j,M,q,K){if(q||(q=0),K||K===0||(K=this.length),M>=j.length&&(M=j.length),M||(M=0),K>0&&K<q&&(K=q),K===q||j.length===0||this.length===0)return 0;if(M<0)throw new RangeError("targetStart out of bounds");if(q<0||q>=this.length)throw new RangeError("sourceStart out of bounds");if(K<0)throw new RangeError("sourceEnd out of bounds");K>this.length&&(K=this.length),j.length-M<K-q&&(K=j.length-M+q);var J,re=K-q;if(this===j&&q<M&&M<K)for(J=re-1;J>=0;--J)j[J+M]=this[J+q];else if(re<1e3||!u.TYPED_ARRAY_SUPPORT)for(J=0;J<re;++J)j[J+M]=this[J+q];else Uint8Array.prototype.set.call(j,this.subarray(q,q+re),M);return re},u.prototype.fill=function(j,M,q,K){if(typeof j=="string"){if(typeof M=="string"?(K=M,M=0,q=this.length):typeof q=="string"&&(K=q,q=this.length),j.length===1){var J=j.charCodeAt(0);J<256&&(j=J)}if(K!==void 0&&typeof K!="string")throw new TypeError("encoding must be a string");if(typeof K=="string"&&!u.isEncoding(K))throw new TypeError("Unknown encoding: "+K)}else typeof j=="number"&&(j&=255);if(M<0||this.length<M||this.length<q)throw new RangeError("Out of range index");if(q<=M)return this;var re;if(M>>>=0,q=q===void 0?this.length:q>>>0,j||(j=0),typeof j=="number")for(re=M;re<q;++re)this[re]=j;else{var ie=u.isBuffer(j)?j:Ve(new u(j,K).toString()),Re=ie.length;for(re=0;re<q-M;++re)this[re+M]=ie[re%Re]}return this};var we=/[^+\/0-9A-Za-z-_]/g;function _e(j){return j<16?"0"+j.toString(16):j.toString(16)}function Ve(j,M){var q;M=M||1/0;for(var K=j.length,J=null,re=[],ie=0;ie<K;++ie){if((q=j.charCodeAt(ie))>55295&&q<57344){if(!J){if(q>56319){(M-=3)>-1&&re.push(239,191,189);continue}if(ie+1===K){(M-=3)>-1&&re.push(239,191,189);continue}J=q;continue}if(q<56320){(M-=3)>-1&&re.push(239,191,189),J=q;continue}q=65536+(J-55296<<10|q-56320)}else J&&(M-=3)>-1&&re.push(239,191,189);if(J=null,q<128){if((M-=1)<0)break;re.push(q)}else if(q<2048){if((M-=2)<0)break;re.push(q>>6|192,63&q|128)}else if(q<65536){if((M-=3)<0)break;re.push(q>>12|224,q>>6&63|128,63&q|128)}else{if(!(q<1114112))throw new Error("Invalid code point");if((M-=4)<0)break;re.push(q>>18|240,q>>12&63|128,q>>6&63|128,63&q|128)}}return re}function Ge(j){return a.toByteArray(function(M){if((M=function(q){return q.trim?q.trim():q.replace(/^\s+|\s+$/g,"")}(M).replace(we,"")).length<2)return"";for(;M.length%4!=0;)M+="=";return M}(j))}function Ne(j,M,q,K){for(var J=0;J<K&&!(J+q>=M.length||J>=j.length);++J)M[J+q]=j[J];return J}}).call(this,i(78))},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0}),n.isASCIIByte=function(o){return o>=0&&o<=127}},function(r,n,i){var o=this&&this.__read||function(s,c){var l=typeof Symbol=="function"&&s[Symbol.iterator];if(!l)return s;var f,u,d=l.call(s),h=[];try{for(;(c===void 0||c-- >0)&&!(f=d.next()).done;)h.push(f.value)}catch(g){u={error:g}}finally{try{f&&!f.done&&(l=d.return)&&l.call(d)}finally{if(u)throw u.error}}return h},a=this&&this.__spread||function(){for(var s=[],c=0;c<arguments.length;c++)s=s.concat(o(arguments[c]));return s};Object.defineProperty(n,"__esModule",{value:!0}),n.length=function(s){return s.length},n.byteLowercase=function(s){for(var c=0;c<s.length;c++){var l=s[c];l>=65&&l<=90&&(s[c]=l+32)}},n.byteUppercase=function(s){for(var c=0;c<s.length;c++){var l=s[c];l>=97&&l<=122&&(s[c]=l-32)}},n.byteCaseInsensitiveMatch=function(s,c){if(s.length!==c.length)return!1;for(var l=0;l<s.length;l++){var f=s[l],u=c[l];if(f>=65&&f<=90&&(f+=32),u>=65&&u<=90&&(u+=32),f!==u)return!1}return!0},n.startsWith=function(s,c){for(var l=0;;){if(l>=s.length)return!1;if(l>=c.length)return!0;if(s[l]!==c[l])return!1;l++}},n.byteLessThan=function(s,c){for(var l=0;;){if(l>=s.length)return!1;if(l>=c.length)return!0;var f=s[l],u=c[l];if(f<u)return!0;if(f>u)return!1;l++}},n.isomorphicDecode=function(s){return String.fromCodePoint.apply(String,a(s))}},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(6),a=i(7),s=i(0),c=i(12),l=function(){function f(u){this._associatedDocument=u||o.dom.window.document}return f.prototype.createDocumentType=function(u,d,h){return s.namespace_validate(u),s.create_documentType(this._associatedDocument,u,d,h)},f.prototype.createDocument=function(u,d,h){h===void 0&&(h=null);var g=s.create_xmlDocument(),p=null;return d&&(p=s.document_internalCreateElementNS(g,u,d)),h&&g.appendChild(h),p&&g.appendChild(p),g._origin=this._associatedDocument._origin,u===a.namespace.HTML?g._contentType="application/xhtml+xml":u===a.namespace.SVG?g._contentType="image/svg+xml":g._contentType="application/xml",g},f.prototype.createHTMLDocument=function(u){var d=s.create_document();d._type="html",d._contentType="text/html",d.appendChild(s.create_documentType(d,"html","",""));var h=s.element_createAnElement(d,"html",a.namespace.HTML);d.appendChild(h);var g=s.element_createAnElement(d,"head",a.namespace.HTML);if(h.appendChild(g),u!==void 0){var p=s.element_createAnElement(d,"title",a.namespace.HTML);g.appendChild(p);var v=s.create_text(d,u);p.appendChild(v)}var y=s.element_createAnElement(d,"body",a.namespace.HTML);return h.appendChild(y),d._origin=this._associatedDocument._origin,d},f.prototype.hasFeature=function(){return!0},f._create=function(u){return new f(u)},f}();n.DOMImplementationImpl=l,c.idl_defineConst(l.prototype,"_ID","@oozcitak/dom")},function(r,n,i){var o,a=this&&this.__extends||(o=function(u,d){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(h,g){h.__proto__=g}||function(h,g){for(var p in g)g.hasOwnProperty(p)&&(h[p]=g[p])})(u,d)},function(u,d){function h(){this.constructor=u}o(u,d),u.prototype=d===null?Object.create(d):(h.prototype=d.prototype,new h)});Object.defineProperty(n,"__esModule",{value:!0});var s=i(70),c=i(1),l=i(0),f=function(u){function d(){var h=u.call(this)||this;return h._signalSlots=new Set,h._mutationObserverMicrotaskQueued=!1,h._mutationObservers=new Set,h._iteratorList=new c.FixedSizeSet,h._associatedDocument=l.create_document(),h}return a(d,u),Object.defineProperty(d.prototype,"document",{get:function(){return this._associatedDocument},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"event",{get:function(){return this._currentEvent},enumerable:!0,configurable:!0}),d._create=function(){return new d},d}(s.EventTargetImpl);n.WindowImpl=f},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(2),a=function(){function s(){}return s.isNode=function(c){return!!c&&c._nodeType!==void 0},s.isDocumentNode=function(c){return s.isNode(c)&&c._nodeType===o.NodeType.Document},s.isDocumentTypeNode=function(c){return s.isNode(c)&&c._nodeType===o.NodeType.DocumentType},s.isDocumentFragmentNode=function(c){return s.isNode(c)&&c._nodeType===o.NodeType.DocumentFragment},s.isAttrNode=function(c){return s.isNode(c)&&c._nodeType===o.NodeType.Attribute},s.isCharacterDataNode=function(c){if(!s.isNode(c))return!1;var l=c._nodeType;return l===o.NodeType.Text||l===o.NodeType.ProcessingInstruction||l===o.NodeType.Comment||l===o.NodeType.CData},s.isTextNode=function(c){return s.isNode(c)&&(c._nodeType===o.NodeType.Text||c._nodeType===o.NodeType.CData)},s.isExclusiveTextNode=function(c){return s.isNode(c)&&c._nodeType===o.NodeType.Text},s.isCDATASectionNode=function(c){return s.isNode(c)&&c._nodeType===o.NodeType.CData},s.isCommentNode=function(c){return s.isNode(c)&&c._nodeType===o.NodeType.Comment},s.isProcessingInstructionNode=function(c){return s.isNode(c)&&c._nodeType===o.NodeType.ProcessingInstruction},s.isElementNode=function(c){return s.isNode(c)&&c._nodeType===o.NodeType.Element},s.isCustomElementNode=function(c){return s.isElementNode(c)&&c._customElementState==="custom"},s.isShadowRoot=function(c){return!!c&&c.host!==void 0},s.isMouseEvent=function(c){return!!c&&c.screenX!==void 0&&c.screenY!=null},s.isSlotable=function(c){return!!c&&c._name!==void 0&&c._assignedSlot!==void 0&&(s.isTextNode(c)||s.isElementNode(c))},s.isSlot=function(c){return!!c&&c._name!==void 0&&c._assignedNodes!==void 0&&s.isElementNode(c)},s.isWindow=function(c){return!!c&&c.navigator!==void 0},s.isEventListener=function(c){return!!c&&c.handleEvent!==void 0},s.isRegisteredObserver=function(c){return!!c&&c.observer!==void 0&&c.options!==void 0},s.isTransientRegisteredObserver=function(c){return!!c&&c.source!==void 0&&s.isRegisteredObserver(c)},s}();n.Guard=a},function(r,n,i){var o,a=this&&this.__extends||(o=function(c,l){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(f,u){f.__proto__=u}||function(f,u){for(var d in u)u.hasOwnProperty(d)&&(f[d]=u[d])})(c,l)},function(c,l){function f(){this.constructor=c}o(c,l),c.prototype=l===null?Object.create(l):(f.prototype=l.prototype,new f)});Object.defineProperty(n,"__esModule",{value:!0});var s=function(c){function l(){return c.call(this)||this}return a(l,c),l}(i(98).DocumentImpl);n.XMLDocumentImpl=s},function(r,n,i){var o=this&&this.__values||function(K){var J=typeof Symbol=="function"&&Symbol.iterator,re=J&&K[J],ie=0;if(re)return re.call(K);if(K&&typeof K.length=="number")return{next:function(){return K&&ie>=K.length&&(K=void 0),{value:K&&K[ie++],done:!K}}};throw new TypeError(J?"Object is not iterable.":"Symbol.iterator is not defined.")},a=this&&this.__read||function(K,J){var re=typeof Symbol=="function"&&K[Symbol.iterator];if(!re)return K;var ie,Re,Fe=re.call(K),je=[];try{for(;(J===void 0||J-- >0)&&!(ie=Fe.next()).done;)je.push(ie.value)}catch(Xe){Re={error:Xe}}finally{try{ie&&!ie.done&&(re=Fe.return)&&re.call(Fe)}finally{if(Re)throw Re.error}}return je};Object.defineProperty(n,"__esModule",{value:!0});var s,c=i(1),l=i(243),f=i(7),u=i(244),d={ftp:21,file:null,http:80,https:443,ws:80,wss:443},h=/[\0-\x1F\x7F-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,g=/[ "<>`]|[\0-\x1F\x7F-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,p=/[ "<>`#?{}]|[\0-\x1F\x7F-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,v=/[ "<>`#?{}/:;=@\[\]\\\^\|]|[\0-\x1F\x7F-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,y=/[0-9A-Za-z!\$&-\/:;=\?@_~\xA0-\uD7FF\uE000-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uD83E\uD840-\uD87E\uD880-\uD8BE\uD8C0-\uD8FE\uD900-\uD93E\uD940-\uD97E\uD980-\uD9BE\uD9C0-\uD9FE\uDA00-\uDA3E\uDA40-\uDA7E\uDA80-\uDABE\uDAC0-\uDAFE\uDB00-\uDB3E\uDB40-\uDB7E\uDB80-\uDBBE\uDBC0-\uDBFE][\uDC00-\uDFFF]|[\uD83F\uD87F\uD8BF\uD8FF\uD93F\uD97F\uD9BF\uD9FF\uDA3F\uDA7F\uDABF\uDAFF\uDB3F\uDB7F\uDBBF\uDBFF][\uDC00-\uDFFD]/,m=/[\0\t\f\r #%/:?@\[\\\]]/;function w(K){s!==void 0&&s.call(null,"Validation Error: "+K)}function x(){return{scheme:"",username:"",password:"",host:null,port:null,path:[],query:null,fragment:null,_cannotBeABaseURLFlag:!1,_blobURLEntry:null}}function C(K){return K in d}function S(K){return C(K.scheme)}function T(K){return d[K]||null}function _(K){return K.username!==""||K.password!==""}function E(K,J){var re,ie;J===void 0&&(J=!1);var Re=K.scheme+":";if(K.host!==null?(Re+="//",_(K)&&(Re+=K.username,K.password!==""&&(Re+=":"+K.password),Re+="@"),Re+=b(K.host),K.port!==null&&(Re+=":"+K.port)):K.host===null&&K.scheme==="file"&&(Re+="//"),K._cannotBeABaseURLFlag)Re+=K.path[0];else try{for(var Fe=o(K.path),je=Fe.next();!je.done;je=Fe.next())Re+="/"+je.value}catch(Xe){re={error:Xe}}finally{try{je&&!je.done&&(ie=Fe.return)&&ie.call(Fe)}finally{if(re)throw re.error}}return K.query!==null&&(Re+="?"+K.query),J||K.fragment===null||(Re+="#"+K.fragment),Re}function b(K){return c.isNumber(K)?D(K):c.isArray(K)?"["+I(K)+"]":K}function D(K){for(var J="",re=K,ie=1;ie<=4;ie++)J=(re%256).toString()+J,ie!==4&&(J="."+J),re=Math.floor(re/256);return J}function I(K){for(var J="",re=null,ie=-1,Re=0,Fe=0,je=0;je<8;je++)if(K[je]===0){Re=1;for(var Xe=je+1;Xe<8&&K[Xe]===0;Xe++)Re++;Re>Fe&&(Fe=Re,ie=je)}Fe>1&&(re=ie);for(var se=!1,ue=0;ue<8;ue++)se&&K[ue]===0||(se&&(se=!1),re!==ue?(J+=K[ue].toString(16),ue!==7&&(J+=":")):(J+=ue===0?"::":":",se=!0));return J}function P(K,J,re,ie,Re){var Fe,je,Xe,se;if(ie===void 0){ie={scheme:"",username:"",password:"",host:null,port:null,path:[],query:null,fragment:null,_cannotBeABaseURLFlag:!1,_blobURLEntry:null};var ue=/^[\u0000-\u001F\u0020]+/,Pe=/[\u0000-\u001F\u0020]+$/;(ue.test(K)||Pe.test(K))&&w("Input string contains leading or trailing control characters or space."),K=(K=K.replace(ue,"")).replace(Pe,"")}var pe=/[\u0009\u000A\u000D]/g;pe.test(K)&&w("Input string contains tab or newline characters."),K=K.replace(pe,"");var Ee=Re===void 0?l.ParserState.SchemeStart:Re;J===void 0&&(J=null);for(var Qe=re===void 0||re==="replacement"||re==="UTF-16BE"||re==="UTF-16LE"?"UTF-8":re,fe="",ft=!1,pt=!1,dt=!1,Ue=new c.StringWalker(K);;){switch(Ee){case l.ParserState.SchemeStart:if(f.codePoint.ASCIIAlpha.test(Ue.c()))fe+=Ue.c().toLowerCase(),Ee=l.ParserState.Scheme;else{if(Re!==void 0)return w("Invalid scheme start character."),null;Ee=l.ParserState.NoScheme,Ue.pointer--}break;case l.ParserState.Scheme:if(f.codePoint.ASCIIAlphanumeric.test(Ue.c())||Ue.c()==="+"||Ue.c()==="-"||Ue.c()===".")fe+=Ue.c().toLowerCase();else{if(Ue.c()!==":"){if(Re===void 0){fe="",Ee=l.ParserState.NoScheme,Ue.pointer=0;continue}return w("Invalid input string."),null}if(Re!==void 0&&(C(ie.scheme)&&!C(fe)||!C(ie.scheme)&&C(fe)||(_(ie)||ie.port!==null)&&fe==="file"||ie.scheme==="file"&&(ie.host===""||ie.host===null)))return ie;if(ie.scheme=fe,Re!==void 0)return ie.port===T(ie.scheme)&&(ie.port=null),ie;fe="",ie.scheme==="file"?(Ue.remaining().startsWith("//")||w("Invalid file URL scheme, '//' expected."),Ee=l.ParserState.File):S(ie)&&J!==null&&J.scheme===ie.scheme?Ee=l.ParserState.SpecialRelativeOrAuthority:S(ie)?Ee=l.ParserState.SpecialAuthoritySlashes:Ue.remaining().startsWith("/")?(Ee=l.ParserState.PathOrAuthority,Ue.pointer++):(ie._cannotBeABaseURLFlag=!0,ie.path.push(""),Ee=l.ParserState.CannotBeABaseURLPath)}break;case l.ParserState.NoScheme:if(J===null||J._cannotBeABaseURLFlag&&Ue.c()!=="#")return w("Invalid input string."),null;J._cannotBeABaseURLFlag&&Ue.c()==="#"?(ie.scheme=J.scheme,ie.path=f.list.clone(J.path),ie.query=J.query,ie.fragment="",ie._cannotBeABaseURLFlag=!0,Ee=l.ParserState.Fragment):J.scheme!=="file"?(Ee=l.ParserState.Relative,Ue.pointer--):(Ee=l.ParserState.File,Ue.pointer--);break;case l.ParserState.SpecialRelativeOrAuthority:Ue.c()==="/"&&Ue.remaining().startsWith("/")?(Ee=l.ParserState.SpecialAuthorityIgnoreSlashes,Ue.pointer++):(w("Invalid input string."),Ee=l.ParserState.Relative,Ue.pointer--);break;case l.ParserState.PathOrAuthority:Ue.c()==="/"?Ee=l.ParserState.Authority:(Ee=l.ParserState.Path,Ue.pointer--);break;case l.ParserState.Relative:if(J===null)throw new Error("Invalid parser state. Base URL is null.");switch(ie.scheme=J.scheme,Ue.c()){case"":ie.username=J.username,ie.password=J.password,ie.host=J.host,ie.port=J.port,ie.path=f.list.clone(J.path),ie.query=J.query;break;case"/":Ee=l.ParserState.RelativeSlash;break;case"?":ie.username=J.username,ie.password=J.password,ie.host=J.host,ie.port=J.port,ie.path=f.list.clone(J.path),ie.query="",Ee=l.ParserState.Query;break;case"#":ie.username=J.username,ie.password=J.password,ie.host=J.host,ie.port=J.port,ie.path=f.list.clone(J.path),ie.query=J.query,ie.fragment="",Ee=l.ParserState.Fragment;break;default:S(ie)&&Ue.c()==="\\"?(w("Invalid input string."),Ee=l.ParserState.RelativeSlash):(ie.username=J.username,ie.password=J.password,ie.host=J.host,ie.port=J.port,ie.path=f.list.clone(J.path),ie.path.length!==0&&ie.path.splice(ie.path.length-1,1),Ee=l.ParserState.Path,Ue.pointer--)}break;case l.ParserState.RelativeSlash:if(!S(ie)||Ue.c()!=="/"&&Ue.c()!=="\\")if(Ue.c()==="/")Ee=l.ParserState.Authority;else{if(J===null)throw new Error("Invalid parser state. Base URL is null.");ie.username=J.username,ie.password=J.password,ie.host=J.host,ie.port=J.port,Ee=l.ParserState.Path,Ue.pointer--}else Ue.c()==="\\"&&w("Invalid input string."),Ee=l.ParserState.SpecialAuthorityIgnoreSlashes;break;case l.ParserState.SpecialAuthoritySlashes:Ue.c()==="/"&&Ue.remaining().startsWith("/")?(Ee=l.ParserState.SpecialAuthorityIgnoreSlashes,Ue.pointer++):(w("Expected '//'."),Ee=l.ParserState.SpecialAuthorityIgnoreSlashes,Ue.pointer--);break;case l.ParserState.SpecialAuthorityIgnoreSlashes:Ue.c()!=="/"&&Ue.c()!=="\\"?(Ee=l.ParserState.Authority,Ue.pointer--):w("Unexpected '/' or '\\'.");break;case l.ParserState.Authority:if(Ue.c()==="@"){w("Unexpected '@'."),ft&&(fe="%40"+fe),ft=!0;try{for(var nt=(Fe=void 0,o(fe)),at=nt.next();!at.done;at=nt.next()){var ot=at.value;if(ot!==":"||dt){var lt=Ne(ot,v);dt?ie.password+=lt:ie.username+=lt}else dt=!0}}catch(xn){Fe={error:xn}}finally{try{at&&!at.done&&(je=nt.return)&&je.call(nt)}finally{if(Fe)throw Fe.error}}fe=""}else if(Ue.c()===""||Ue.c()==="/"||Ue.c()==="?"||Ue.c()==="#"||S(ie)&&Ue.c()==="\\"){if(ft&&fe==="")return w("Invalid input string."),null;Ue.pointer-=fe.length+1,fe="",Ee=l.ParserState.Host}else fe+=Ue.c();break;case l.ParserState.Host:case l.ParserState.Hostname:if(Re!==void 0&&ie.scheme==="file")Ue.pointer--,Ee=l.ParserState.FileHost;else if(Ue.c()!==":"||pt)if(Ue.c()===""||Ue.c()==="/"||Ue.c()==="?"||Ue.c()==="#"||S(ie)&&Ue.c()==="\\"){if(Ue.pointer--,S(ie)&&fe==="")return w("Invalid input string."),null;if(Re!==void 0&&fe===""&&(_(ie)||ie.port!==null))return w("Invalid input string."),ie;if((vt=G(fe,!S(ie)))===null)return null;if(ie.host=vt,fe="",Ee=l.ParserState.PathStart,Re!==void 0)return ie}else Ue.c()==="["&&(pt=!0),Ue.c()==="]"&&(pt=!1),fe+=Ue.c();else{if(fe==="")return w("Invalid input string."),null;if((vt=G(fe,!S(ie)))===null)return null;if(ie.host=vt,fe="",Ee=l.ParserState.Port,Re===l.ParserState.Hostname)return ie}break;case l.ParserState.Port:if(f.codePoint.ASCIIDigit.test(Ue.c()))fe+=Ue.c();else{if(!(Ue.c()===""||Ue.c()==="/"||Ue.c()==="?"||Ue.c()==="#"||S(ie)&&Ue.c()==="\\"||Re))return w("Invalid input string."),null;if(fe!==""&&fe!==""){var _t=parseInt(fe,10);if(_t>Math.pow(2,16)-1)return w("Invalid port number."),null;ie.port=_t===T(ie.scheme)?null:_t,fe=""}if(Re!==void 0)return ie;Ee=l.ParserState.PathStart,Ue.pointer--}break;case l.ParserState.File:if(ie.scheme="file",Ue.c()==="/"||Ue.c()==="\\")Ue.c()==="\\"&&w("Invalid input string."),Ee=l.ParserState.FileSlash;else if(J!==null&&J.scheme==="file")switch(Ue.c()){case"":ie.host=J.host,ie.path=f.list.clone(J.path),ie.query=J.query;break;case"?":ie.host=J.host,ie.path=f.list.clone(J.path),ie.query="",Ee=l.ParserState.Query;break;case"#":ie.host=J.host,ie.path=f.list.clone(J.path),ie.query=J.query,ie.fragment="",Ee=l.ParserState.Fragment;break;default:F(Ue.substring())?w("Unexpected windows drive letter in input string."):(ie.host=J.host,ie.path=f.list.clone(J.path),B(ie)),Ee=l.ParserState.Path,Ue.pointer--}else Ee=l.ParserState.Path,Ue.pointer--;break;case l.ParserState.FileSlash:Ue.c()==="/"||Ue.c()==="\\"?(Ue.c()==="\\"&&w("Invalid input string."),Ee=l.ParserState.FileHost):(J===null||J.scheme!=="file"||F(Ue.substring())||(H(J.path[0])?ie.path.push(J.path[0]):ie.host=J.host),Ee=l.ParserState.Path,Ue.pointer--);break;case l.ParserState.FileHost:if(Ue.c()===""||Ue.c()==="/"||Ue.c()==="\\"||Ue.c()==="?"||Ue.c()==="#")if(Ue.pointer--,Re===void 0&&A(fe))w("Unexpected windows drive letter in input string."),Ee=l.ParserState.Path;else if(fe===""){if(ie.host="",Re!==void 0)return ie;Ee=l.ParserState.PathStart}else{var vt;if((vt=G(fe,!S(ie)))===null)return null;if(vt==="localhost"&&(vt=""),ie.host=vt,Re!==void 0)return ie;fe="",Ee=l.ParserState.PathStart}else fe+=Ue.c();break;case l.ParserState.PathStart:S(ie)?(Ue.c()==="\\"&&w("Invalid input string."),Ee=l.ParserState.Path,Ue.c()!=="/"&&Ue.c()!=="\\"&&Ue.pointer--):Re===void 0&&Ue.c()==="?"?(ie.query="",Ee=l.ParserState.Query):Re===void 0&&Ue.c()==="#"?(ie.fragment="",Ee=l.ParserState.Fragment):Ue.c()!==""&&(Ee=l.ParserState.Path,Ue.c()!=="/"&&Ue.pointer--);break;case l.ParserState.Path:if(Ue.c()===""||Ue.c()==="/"||S(ie)&&Ue.c()==="\\"||Re===void 0&&(Ue.c()==="?"||Ue.c()==="#")){if(S(ie)&&Ue.c()==="\\"&&w("Invalid input string."),L(fe))B(ie),Ue.c()==="/"||S(ie)&&Ue.c()==="\\"||ie.path.push("");else if(!O(fe)||Ue.c()==="/"||S(ie)&&Ue.c()==="\\"){if(!O(fe)){if(ie.scheme==="file"&&ie.path.length===0&&A(fe)){ie.host!==null&&ie.host!==""&&(w("Invalid input string."),ie.host="");var Mt=Array.from(fe);fe=Mt.slice(0,1)+":"+Mt.slice(2)}ie.path.push(fe)}}else ie.path.push("");if(fe="",ie.scheme==="file"&&(Ue.c()===""||Ue.c()==="?"||Ue.c()==="#"))for(;ie.path.length>1&&ie.path[0]==="";)w("Invalid input string."),ie.path.splice(0,1);Ue.c()==="?"&&(ie.query="",Ee=l.ParserState.Query),Ue.c()==="#"&&(ie.fragment="",Ee=l.ParserState.Fragment)}else y.test(Ue.c())||Ue.c()==="%"||w("Character is not a URL code point or a percent encoded character."),Ue.c()!=="%"||/^[0-9a-fA-F][0-9a-fA-F]/.test(Ue.remaining())||w("Percent encoded character must be followed by two hex digits."),fe+=Ne(Ue.c(),p);break;case l.ParserState.CannotBeABaseURLPath:Ue.c()==="?"?(ie.query="",Ee=l.ParserState.Query):Ue.c()==="#"?(ie.fragment="",Ee=l.ParserState.Fragment):(Ue.c()===""||y.test(Ue.c())||Ue.c()==="%"||w("Character is not a URL code point or a percent encoded character."),Ue.c()!=="%"||/^[0-9a-fA-F][0-9a-fA-F]/.test(Ue.remaining())||w("Percent encoded character must be followed by two hex digits."),Ue.c()!==""&&(ie.path[0]+=Ne(Ue.c(),h)));break;case l.ParserState.Query:if(Qe==="UTF-8"||S(ie)&&ie.scheme!=="ws"&&ie.scheme!=="wss"||(Qe="UTF-8"),Re===void 0&&Ue.c()==="#")ie.fragment="",Ee=l.ParserState.Fragment;else if(Ue.c()!==""){if(y.test(Ue.c())||Ue.c()==="%"||w("Character is not a URL code point or a percent encoded character."),Ue.c()!=="%"||/^[0-9a-fA-F][0-9a-fA-F]/.test(Ue.remaining())||w("Percent encoded character must be followed by two hex digits."),Qe.toUpperCase()!=="UTF-8")throw new Error("Only UTF-8 encoding is supported.");var Ft=c.utf8Encode(Ue.c());if(Ft.length>=3&&Ft[0]===38&&Ft[1]===35&&Ft[Ft.length-1]===59)Ft=Ft.subarray(2,Ft.length-1),ie.query+="%26%23"+f.byteSequence.isomorphicDecode(Ft)+"%3B";else try{for(var wn=(Xe=void 0,o(Ft)),Dn=wn.next();!Dn.done;Dn=wn.next()){var Nt=Dn.value;Nt<33||Nt>126||Nt===34||Nt===35||Nt===60||Nt===62||Nt===39&&S(ie)?ie.query+=_e(Nt):ie.query+=String.fromCharCode(Nt)}}catch(xn){Xe={error:xn}}finally{try{Dn&&!Dn.done&&(se=wn.return)&&se.call(wn)}finally{if(Xe)throw Xe.error}}}break;case l.ParserState.Fragment:Ue.c()===""||(Ue.c()==="\0"?w("NULL character in input string."):(y.test(Ue.c())||Ue.c()==="%"||w("Unexpected character in fragment string."),Ue.c()!=="%"||/^[A-Za-z0-9][A-Za-z0-9]/.test(Ue.remaining())||w("Unexpected character in fragment string."),ie.fragment+=Ne(Ue.c(),g)))}if(Ue.eof)break;Ue.pointer++}return ie}function O(K){return K==="."||K.toLowerCase()==="%2e"}function L(K){var J=K.toLowerCase();return J===".."||J===".%2e"||J==="%2e."||J==="%2e%2e"}function B(K){var J=K.path;J.length!==0&&(K.scheme==="file"&&J.length===1&&H(J[0])||K.path.splice(K.path.length-1,1))}function H(K){return K.length>=2&&f.codePoint.ASCIIAlpha.test(K[0])&&K[1]===":"}function A(K){return K.length>=2&&f.codePoint.ASCIIAlpha.test(K[0])&&(K[1]===":"||K[1]==="|")}function F(K){return K.length>=2&&A(K)&&(K.length===2||K[2]==="/"||K[2]==="\\"||K[2]==="?"||K[2]==="#")}function G(K,J){if(J===void 0&&(J=!1),K.startsWith("["))return K.endsWith("]")?ce(K.substring(1,K.length-1)):(w("Expected ']' after '['."),null);if(J)return Se(K);var re=q(c.utf8Decode(Ge(K)));if(re===null||m.test(re))return w("Invalid domain."),null;var ie=ee(re);return ie===null||c.isNumber(ie)?ie:re}function X(K,J){J===void 0&&(J={value:!1});var re=10;return K.startsWith("0x")||K.startsWith("0X")?(J.value=!0,K=K.substr(2),re=16):K.length>=2&&K[0]==="0"&&(J.value=!0,K=K.substr(1),re=8),K===""?0:(re===10?/^[0-9]+$/:re===16?/^[0-9A-Fa-f]+$/:/^[0-7]+$/).test(K)?parseInt(K,re):null}function ee(K){var J,re,ie,Re,Fe={value:!1},je=K.split(".");if(je[je.length-1]===""&&(Fe.value=!0,je.length>1&&je.pop()),je.length>4)return K;var Xe=[];try{for(var se=o(je),ue=se.next();!ue.done;ue=se.next()){var Pe=ue.value;if(Pe===""||(pt=X(Pe,Fe))===null)return K;Xe.push(pt)}}catch(dt){J={error:dt}}finally{try{ue&&!ue.done&&(re=se.return)&&re.call(se)}finally{if(J)throw J.error}}Fe.value&&w("Invalid IP v4 address.");for(var pe=0;pe<Xe.length;pe++)if(Xe[pe]>255&&(w("Invalid IP v4 address."),pe<Xe.length-1))return null;if(Xe[Xe.length-1]>=Math.pow(256,5-Xe.length))return w("Invalid IP v4 address."),null;var Ee=Xe[Xe.length-1];Xe.pop();var Qe=0;try{for(var fe=o(Xe),ft=fe.next();!ft.done;ft=fe.next()){var pt;Ee+=(pt=ft.value)*Math.pow(256,3-Qe),Qe++}}catch(dt){ie={error:dt}}finally{try{ft&&!ft.done&&(Re=fe.return)&&Re.call(fe)}finally{if(ie)throw ie.error}}return Ee}function ce(K){var J,re=[0,0,0,0,0,0,0,0],ie=0,Re=null,Fe=new c.StringWalker(K);if(Fe.c()===":"){if(!Fe.remaining().startsWith(":"))return w("Invalid IP v6 address."),null;Fe.pointer+=2,Re=ie+=1}for(;Fe.c()!=="";){if(ie===8)return w("Invalid IP v6 address."),null;if(Fe.c()!==":"){for(var je=0,Xe=0;Xe<4&&f.codePoint.ASCIIHexDigit.test(Fe.c());)je=16*je+parseInt(Fe.c(),16),Fe.pointer++,Xe++;if(Fe.c()==="."){if(Xe===0||(Fe.pointer-=Xe,ie>6))return w("Invalid IP v6 address."),null;for(var se=0;Fe.c()!=="";){var ue=null;if(se>0){if(!(Fe.c()==="."&&se<4))return w("Invalid IP v6 address."),null;Fe.pointer++}if(!f.codePoint.ASCIIDigit.test(Fe.c()))return w("Invalid IP v6 address."),null;for(;f.codePoint.ASCIIDigit.test(Fe.c());){var Pe=parseInt(Fe.c(),10);if(ue===null)ue=Pe;else{if(ue===0)return w("Invalid IP v6 address."),null;ue=10*ue+Pe}if(ue>255)return w("Invalid IP v6 address."),null;Fe.pointer++}if(ue===null)return w("Invalid IP v6 address."),null;re[ie]=256*re[ie]+ue,++se!==2&&se!==4||ie++}if(se!==4)return w("Invalid IP v6 address."),null;break}if(Fe.c()===":"){if(Fe.pointer++,Fe.c()==="")return w("Invalid IP v6 address."),null}else if(Fe.c()!=="")return w("Invalid IP v6 address."),null;re[ie]=je,ie++}else{if(Re!==null)return w("Invalid IP v6 address."),null;Fe.pointer++,Re=++ie}}if(Re!==null){var pe=ie-Re;for(ie=7;ie!==0&&pe>0;)J=a([re[Re+pe-1],re[ie]],2),re[ie]=J[0],re[Re+pe-1]=J[1],ie--,pe--}else if(Re===null&&ie!==8)return w("Invalid IP v6 address."),null;return re}function Se(K){var J,re;if(/[\x00\t\f\r #/:?@\[\\\]]/.test(K))return w("Invalid host string."),null;var ie="";try{for(var Re=o(K),Fe=Re.next();!Fe.done;Fe=Re.next())ie+=Ne(Fe.value,h)}catch(je){J={error:je}}finally{try{Fe&&!Fe.done&&(re=Re.return)&&re.call(Re)}finally{if(J)throw J.error}}return ie}function we(K){return null}function _e(K){return"%"+("00"+K.toString(16).toUpperCase()).slice(-2)}function Ve(K){for(var J=function(Xe){return Xe>=48&&Xe<=57||Xe>=65&&Xe<=70||Xe>=97&&Xe<=102},re=new Uint8Array(K.length),ie=0,Re=0;Re<K.length;Re++){var Fe=K[Re];if(Fe!==37)re[ie]=Fe,ie++;else if(Fe===37&&Re>=K.length-2)re[ie]=Fe,ie++;else if(Fe!==37||J(K[Re+1])&&J(K[Re+2])){var je=parseInt(c.utf8Decode(Uint8Array.of(K[Re+1],K[Re+2])),16);re[ie]=je,ie++,Re+=2}else re[ie]=Fe,ie++}return re.subarray(0,ie)}function Ge(K){return Ve(c.utf8Encode(K))}function Ne(K,J){var re,ie;if(!J.test(K))return K;var Re=c.utf8Encode(K),Fe="";try{for(var je=o(Re),Xe=je.next();!Xe.done;Xe=je.next())Fe+=_e(Xe.value)}catch(se){re={error:se}}finally{try{Xe&&!Xe.done&&(ie=je.return)&&ie.call(je)}finally{if(re)throw re.error}}return Fe}function j(K){var J,re,ie,Re,Fe=[],je=[];try{for(var Xe=o(K),se=Xe.next();!se.done;se=Xe.next()){var ue=se.value;ue===38?(Fe.push(Uint8Array.from(je)),je=[]):je.push(ue)}}catch(at){J={error:at}}finally{try{se&&!se.done&&(re=Xe.return)&&re.call(Xe)}finally{if(J)throw J.error}}je.length!==0&&Fe.push(Uint8Array.from(je));var Pe=[];try{for(var pe=o(Fe),Ee=pe.next();!Ee.done;Ee=pe.next()){var Qe=Ee.value;if(Qe.length!==0){for(var fe=Qe.indexOf(61),ft=fe!==-1?Qe.slice(0,fe):Qe,pt=fe!==-1?Qe.slice(fe+1):new Uint8Array,dt=0;dt<ft.length;dt++)ft[dt]===43&&(ft[dt]=32);for(dt=0;dt<pt.length;dt++)pt[dt]===43&&(pt[dt]=32);var Ue=c.utf8Decode(ft),nt=c.utf8Decode(pt);Pe.push([Ue,nt])}}}catch(at){ie={error:at}}finally{try{Ee&&!Ee.done&&(Re=pe.return)&&Re.call(pe)}finally{if(ie)throw ie.error}}return Pe}function M(K){var J,re,ie="";try{for(var Re=o(K),Fe=Re.next();!Fe.done;Fe=Re.next()){var je=Fe.value;ie+=je===32?"+":je===42||je===45||je===46||je>=48&&je<=57||je>=65&&je<=90||je===95||je>=97&&je<=122?String.fromCodePoint(je):_e(je)}}catch(Xe){J={error:Xe}}finally{try{Fe&&!Fe.done&&(re=Re.return)&&re.call(Re)}finally{if(J)throw J.error}}return ie}function q(K,J){var re=u.domainToASCII(K);return re===""?(w("Invalid domain name."),null):re}n.setValidationErrorCallback=function(K){s=K},n.newURL=x,n.isSpecialScheme=C,n.isSpecial=S,n.defaultPort=T,n.includesCredentials=_,n.cannotHaveAUsernamePasswordPort=function(K){return K.host===null||K.host===""||K._cannotBeABaseURLFlag||K.scheme==="file"},n.urlSerializer=E,n.hostSerializer=b,n.iPv4Serializer=D,n.iPv6Serializer=I,n.urlParser=function(K,J,re){var ie=P(K,J,re);return ie===null?null:(ie.scheme!=="blob"||(ie._blobURLEntry=null),ie)},n.basicURLParser=P,n.setTheUsername=function(K,J){var re,ie,Re="";try{for(var Fe=o(J),je=Fe.next();!je.done;je=Fe.next())Re+=Ne(je.value,v)}catch(Xe){re={error:Xe}}finally{try{je&&!je.done&&(ie=Fe.return)&&ie.call(Fe)}finally{if(re)throw re.error}}K.username=Re},n.setThePassword=function(K,J){var re,ie,Re="";try{for(var Fe=o(J),je=Fe.next();!je.done;je=Fe.next())Re+=Ne(je.value,v)}catch(Xe){re={error:Xe}}finally{try{je&&!je.done&&(ie=Fe.return)&&ie.call(Fe)}finally{if(re)throw re.error}}K.password=Re},n.isSingleDotPathSegment=O,n.isDoubleDotPathSegment=L,n.shorten=B,n.isNormalizedWindowsDriveLetter=H,n.isWindowsDriveLetter=A,n.startsWithAWindowsDriveLetter=F,n.hostParser=G,n.iPv4NumberParser=X,n.iPv4Parser=ee,n.iPv6Parser=ce,n.opaqueHostParser=Se,n.resolveABlobURL=we,n.percentEncode=_e,n.percentDecode=Ve,n.stringPercentDecode=Ge,n.utf8PercentEncode=Ne,n.hostEquals=function(K,J){return K===J},n.urlEquals=function(K,J,re){return re===void 0&&(re=!1),E(K,re)===E(J,re)},n.urlEncodedStringParser=function(K){return j(c.utf8Encode(K))},n.urlEncodedParser=j,n.urlEncodedByteSerializer=M,n.urlEncodedSerializer=function(K,J){var re,ie;if((J===void 0||J==="replacement"||J==="UTF-16BE"||J==="UTF-16LE"?"UTF-8":J).toUpperCase()!=="UTF-8")throw new Error("Only UTF-8 encoding is supported.");var Re="";try{for(var Fe=o(K),je=Fe.next();!je.done;je=Fe.next()){var Xe=je.value,se=M(c.utf8Encode(Xe[0])),ue=Xe[1];ue=M(c.utf8Encode(ue)),Re!==""&&(Re+="&"),Re+=se+"="+ue}}catch(Pe){re={error:Pe}}finally{try{je&&!je.done&&(ie=Fe.return)&&ie.call(Fe)}finally{if(re)throw re.error}}return Re},n.origin=function K(J){switch(J.scheme){case"blob":J._blobURLEntry;var re=P(J.path[0]);return re===null?l.OpaqueOrigin:K(re);case"ftp":case"http":case"https":case"ws":case"wss":return[J.scheme,J.host===null?"":J.host,J.port,null];case"file":default:return l.OpaqueOrigin}},n.domainToASCII=q,n.domainToUnicode=function(K,J){var re=u.domainToUnicode(K);return re===""&&w("Invalid domain name."),re},n.asciiSerializationOfAnOrigin=function(K){if(K[0]===""&&K[1]===""&&K[2]===null&&K[3]===null)return"null";var J=K[0]+"://"+b(K[1]);return K[2]!==null&&(J+=":"+K[2].toString()),J}},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(0),a=function(){function s(){this._signal=o.create_abortSignal()}return Object.defineProperty(s.prototype,"signal",{get:function(){return this._signal},enumerable:!0,configurable:!0}),s.prototype.abort=function(){o.abort_signalAbort(this._signal)},s}();n.AbortControllerImpl=a},function(r,n,i){var o,a=this&&this.__extends||(o=function(f,u){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,h){d.__proto__=h}||function(d,h){for(var g in h)h.hasOwnProperty(g)&&(d[g]=h[g])})(f,u)},function(f,u){function d(){this.constructor=f}o(f,u),f.prototype=u===null?Object.create(u):(d.prototype=u.prototype,new d)});Object.defineProperty(n,"__esModule",{value:!0});var s=i(70),c=i(0),l=function(f){function u(){var d=f.call(this)||this;return d._abortedFlag=!1,d._abortAlgorithms=new Set,d}return a(u,f),Object.defineProperty(u.prototype,"aborted",{get:function(){return this._abortedFlag},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"onabort",{get:function(){return c.event_getterEventHandlerIDLAttribute(this,"onabort")},set:function(d){c.event_setterEventHandlerIDLAttribute(this,"onabort",d)},enumerable:!0,configurable:!0}),u._create=function(){return new u},u}(s.EventTargetImpl);n.AbortSignalImpl=l},function(r,n,i){var o,a=this&&this.__extends||(o=function(u,d){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(h,g){h.__proto__=g}||function(h,g){for(var p in g)g.hasOwnProperty(p)&&(h[p]=g[p])})(u,d)},function(u,d){function h(){this.constructor=u}o(u,d),u.prototype=d===null?Object.create(d):(h.prototype=d.prototype,new h)});Object.defineProperty(n,"__esModule",{value:!0});var s=i(2),c=i(34),l=i(12),f=function(u){function d(h,g,p){var v=u.call(this)||this;return v._name="",v._publicId="",v._systemId="",v._name=h,v._publicId=g,v._systemId=p,v}return a(d,u),Object.defineProperty(d.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"publicId",{get:function(){return this._publicId},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"systemId",{get:function(){return this._systemId},enumerable:!0,configurable:!0}),d.prototype.before=function(){for(var h=[],g=0;g<arguments.length;g++)h[g]=arguments[g];throw new Error("Mixin: ChildNode not implemented.")},d.prototype.after=function(){for(var h=[],g=0;g<arguments.length;g++)h[g]=arguments[g];throw new Error("Mixin: ChildNode not implemented.")},d.prototype.replaceWith=function(){for(var h=[],g=0;g<arguments.length;g++)h[g]=arguments[g];throw new Error("Mixin: ChildNode not implemented.")},d.prototype.remove=function(){throw new Error("Mixin: ChildNode not implemented.")},d._create=function(h,g,p,v){p===void 0&&(p=""),v===void 0&&(v="");var y=new d(g,p,v);return y._nodeDocument=h,y},d}(c.NodeImpl);n.DocumentTypeImpl=f,l.idl_defineConst(f.prototype,"_nodeType",s.NodeType.DocumentType)},function(r,n,i){var o,a=this&&this.__extends||(o=function(u,d){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(h,g){h.__proto__=g}||function(h,g){for(var p in g)g.hasOwnProperty(p)&&(h[p]=g[p])})(u,d)},function(u,d){function h(){this.constructor=u}o(u,d),u.prototype=d===null?Object.create(d):(h.prototype=d.prototype,new h)});Object.defineProperty(n,"__esModule",{value:!0});var s=i(100),c=i(1),l=i(0),f=function(u){function d(h,g){var p=u.call(this)||this;return p._host=h,p._mode=g,p}return a(d,u),Object.defineProperty(d.prototype,"mode",{get:function(){return this._mode},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"host",{get:function(){return this._host},enumerable:!0,configurable:!0}),d.prototype._getTheParent=function(h){return h._composedFlag||c.isEmpty(h._path)||l.tree_rootNode(h._path[0].invocationTarget)!==this?this._host:null},d._create=function(h,g){return new d(g,"closed")},d}(s.DocumentFragmentImpl);n.ShadowRootImpl=f},function(r,n,i){var o,a=this&&this.__extends||(o=function(d,h){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(g,p){g.__proto__=p}||function(g,p){for(var v in p)p.hasOwnProperty(v)&&(g[v]=p[v])})(d,h)},function(d,h){function g(){this.constructor=d}o(d,h),d.prototype=h===null?Object.create(h):(g.prototype=h.prototype,new g)});Object.defineProperty(n,"__esModule",{value:!0});var s=i(2),c=i(34),l=i(0),f=i(12),u=function(d){function h(g){var p=d.call(this)||this;return p._namespace=null,p._namespacePrefix=null,p._element=null,p._value="",p._localName=g,p}return a(h,d),Object.defineProperty(h.prototype,"ownerElement",{get:function(){return this._element},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"namespaceURI",{get:function(){return this._namespace},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"prefix",{get:function(){return this._namespacePrefix},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"localName",{get:function(){return this._localName},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"name",{get:function(){return this._qualifiedName},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"value",{get:function(){return this._value},set:function(g){l.attr_setAnExistingAttributeValue(this,g)},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"_qualifiedName",{get:function(){return this._namespacePrefix!==null?this._namespacePrefix+":"+this._localName:this._localName},enumerable:!0,configurable:!0}),h._create=function(g,p){var v=new h(p);return v._nodeDocument=g,v},h}(c.NodeImpl);n.AttrImpl=u,f.idl_defineConst(u.prototype,"_nodeType",s.NodeType.Attribute),f.idl_defineConst(u.prototype,"specified",!0)},function(r,n,i){var o,a=this&&this.__extends||(o=function(u,d){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(h,g){h.__proto__=g}||function(h,g){for(var p in g)g.hasOwnProperty(p)&&(h[p]=g[p])})(u,d)},function(u,d){function h(){this.constructor=u}o(u,d),u.prototype=d===null?Object.create(d):(h.prototype=d.prototype,new h)});Object.defineProperty(n,"__esModule",{value:!0});var s=i(101),c=i(2),l=i(12),f=function(u){function d(h){return u.call(this,h)||this}return a(d,u),d._create=function(h,g){g===void 0&&(g="");var p=new d(g);return p._nodeDocument=h,p},d}(s.TextImpl);n.CDATASectionImpl=f,l.idl_defineConst(f.prototype,"_nodeType",c.NodeType.CData)},function(r,n,i){var o,a=this&&this.__extends||(o=function(u,d){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(h,g){h.__proto__=g}||function(h,g){for(var p in g)g.hasOwnProperty(p)&&(h[p]=g[p])})(u,d)},function(u,d){function h(){this.constructor=u}o(u,d),u.prototype=d===null?Object.create(d):(h.prototype=d.prototype,new h)});Object.defineProperty(n,"__esModule",{value:!0});var s=i(2),c=i(71),l=i(12),f=function(u){function d(h){return h===void 0&&(h=""),u.call(this,h)||this}return a(d,u),d._create=function(h,g){g===void 0&&(g="");var p=new d(g);return p._nodeDocument=h,p},d}(c.CharacterDataImpl);n.CommentImpl=f,l.idl_defineConst(f.prototype,"_nodeType",s.NodeType.Comment)},function(r,n,i){var o,a=this&&this.__extends||(o=function(u,d){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(h,g){h.__proto__=g}||function(h,g){for(var p in g)g.hasOwnProperty(p)&&(h[p]=g[p])})(u,d)},function(u,d){function h(){this.constructor=u}o(u,d),u.prototype=d===null?Object.create(d):(h.prototype=d.prototype,new h)});Object.defineProperty(n,"__esModule",{value:!0});var s=i(2),c=i(71),l=i(12),f=function(u){function d(h,g){var p=u.call(this,g)||this;return p._target=h,p}return a(d,u),Object.defineProperty(d.prototype,"target",{get:function(){return this._target},enumerable:!0,configurable:!0}),d._create=function(h,g,p){var v=new d(g,p);return v._nodeDocument=h,v},d}(c.CharacterDataImpl);n.ProcessingInstructionImpl=f,l.idl_defineConst(f.prototype,"_nodeType",s.NodeType.ProcessingInstruction)},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(7),a=i(0),s=i(3),c=i(1),l=function(){function f(u,d){return this._live=!0,this._root=u,this._filter=d,new Proxy(this,this)}return Object.defineProperty(f.prototype,"length",{get:function(){for(var u=this,d=0,h=a.tree_getFirstDescendantNode(this._root,!1,!1,function(g){return s.Guard.isElementNode(g)&&u._filter(g)});h!==null;)d++,h=a.tree_getNextDescendantNode(this._root,h,!1,!1,function(g){return s.Guard.isElementNode(g)&&u._filter(g)});return d},enumerable:!0,configurable:!0}),f.prototype.item=function(u){for(var d=this,h=0,g=a.tree_getFirstDescendantNode(this._root,!1,!1,function(p){return s.Guard.isElementNode(p)&&d._filter(p)});g!==null;){if(h===u)return g;h++,g=a.tree_getNextDescendantNode(this._root,g,!1,!1,function(p){return s.Guard.isElementNode(p)&&d._filter(p)})}return null},f.prototype.namedItem=function(u){var d=this;if(u==="")return null;for(var h=a.tree_getFirstDescendantNode(this._root,!1,!1,function(v){return s.Guard.isElementNode(v)&&d._filter(v)});h!=null;){if(h._uniqueIdentifier===u)return h;if(h._namespace===o.namespace.HTML)for(var g=0;g<h._attributeList.length;g++){var p=h._attributeList[g];if(p._localName==="name"&&p._namespace===null&&p._namespacePrefix===null&&p._value===u)return h}h=a.tree_getNextDescendantNode(this._root,h,!1,!1,function(v){return s.Guard.isElementNode(v)&&d._filter(v)})}return null},f.prototype[Symbol.iterator]=function(){var u=this._root,d=this._filter,h=a.tree_getFirstDescendantNode(u,!1,!1,function(g){return s.Guard.isElementNode(g)&&d(g)});return{next:function(){if(h===null)return{done:!0,value:null};var g={done:!1,value:h};return h=a.tree_getNextDescendantNode(u,h,!1,!1,function(p){return s.Guard.isElementNode(p)&&d(p)}),g}}},f.prototype.get=function(u,d,h){if(!c.isString(d)||f.reservedNames.indexOf(d)!==-1)return Reflect.get(u,d,h);var g=Number(d);return isNaN(g)?u.namedItem(d)||void 0:u.item(g)||void 0},f.prototype.set=function(u,d,h,g){if(!c.isString(d)||f.reservedNames.indexOf(d)!==-1)return Reflect.set(u,d,h,g);var p=Number(d),v=isNaN(p)?u.namedItem(d)||void 0:u.item(p)||void 0;return!(!v||!v._parent)&&(a.mutation_replace(v,h,v._parent),!0)},f._create=function(u,d){return d===void 0&&(d=function(){return!0}),new f(u,d)},f.reservedNames=["_root","_live","_filter","length","item","namedItem","get","set"],f}();n.HTMLCollectionImpl=l},function(r,n,i){var o=this&&this.__values||function(f){var u=typeof Symbol=="function"&&Symbol.iterator,d=u&&f[u],h=0;if(d)return d.call(f);if(f&&typeof f.length=="number")return{next:function(){return f&&h>=f.length&&(f=void 0),{value:f&&f[h++],done:!f}}};throw new TypeError(u?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var a=i(6),s=i(1),c=i(0),l=function(){function f(u){return this._live=!0,this._filter=null,this._length=0,this._root=u,new Proxy(this,this)}return Object.defineProperty(f.prototype,"length",{get:function(){return this._root._children.size},enumerable:!0,configurable:!0}),f.prototype.item=function(u){if(u<0||u>this.length-1)return null;if(u<this.length/2){for(var d=0,h=this._root._firstChild;h!==null&&d!==u;)h=h._nextSibling,d++;return h}for(d=this.length-1,h=this._root._lastChild;h!==null&&d!==u;)h=h._previousSibling,d--;return h},f.prototype.keys=function(){var u;return(u={})[Symbol.iterator]=(function(){var d=0;return{next:(function(){return d===this.length?{done:!0,value:null}:{done:!1,value:d++}}).bind(this)}}).bind(this),u},f.prototype.values=function(){var u;return(u={})[Symbol.iterator]=(function(){var d=this[Symbol.iterator]();return{next:function(){return d.next()}}}).bind(this),u},f.prototype.entries=function(){var u;return(u={})[Symbol.iterator]=(function(){var d=this[Symbol.iterator](),h=0;return{next:function(){var g=d.next();return g.done?{done:!0,value:null}:{done:!1,value:[h++,g.value]}}}}).bind(this),u},f.prototype[Symbol.iterator]=function(){return this._root._children[Symbol.iterator]()},f.prototype.forEach=function(u,d){var h,g;d===void 0&&(d=a.dom.window);var p=0;try{for(var v=o(this._root._children),y=v.next();!y.done;y=v.next()){var m=y.value;u.call(d,m,p++,this)}}catch(w){h={error:w}}finally{try{y&&!y.done&&(g=v.return)&&g.call(v)}finally{if(h)throw h.error}}},f.prototype.get=function(u,d,h){if(!s.isString(d))return Reflect.get(u,d,h);var g=Number(d);return isNaN(g)?Reflect.get(u,d,h):u.item(g)||void 0},f.prototype.set=function(u,d,h,g){if(!s.isString(d))return Reflect.set(u,d,h,g);var p=Number(d);if(isNaN(p))return Reflect.set(u,d,h,g);var v=u.item(p)||void 0;return!!v&&!!v._parent&&(c.mutation_replace(v,h,v._parent),!0)},f._create=function(u){return new f(u)},f}();n.NodeListImpl=l},function(r,n,i){var o=this&&this.__values||function(l){var f=typeof Symbol=="function"&&Symbol.iterator,u=f&&l[f],d=0;if(u)return u.call(l);if(l&&typeof l.length=="number")return{next:function(){return l&&d>=l.length&&(l=void 0),{value:l&&l[d++],done:!l}}};throw new TypeError(f?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var a=i(6),s=i(1),c=function(){function l(f){return this._live=!1,this._items=[],this._length=0,this._root=f,this._items=[],this._filter=function(u){return!0},new Proxy(this,this)}return Object.defineProperty(l.prototype,"length",{get:function(){return this._items.length},enumerable:!0,configurable:!0}),l.prototype.item=function(f){return f<0||f>this.length-1?null:this._items[f]},l.prototype.keys=function(){var f;return(f={})[Symbol.iterator]=(function(){var u=0;return{next:(function(){return u===this.length?{done:!0,value:null}:{done:!1,value:u++}}).bind(this)}}).bind(this),f},l.prototype.values=function(){var f;return(f={})[Symbol.iterator]=(function(){var u=this[Symbol.iterator]();return{next:function(){return u.next()}}}).bind(this),f},l.prototype.entries=function(){var f;return(f={})[Symbol.iterator]=(function(){var u=this[Symbol.iterator](),d=0;return{next:function(){var h=u.next();return h.done?{done:!0,value:null}:{done:!1,value:[d++,h.value]}}}}).bind(this),f},l.prototype[Symbol.iterator]=function(){var f=this._items[Symbol.iterator]();return{next:function(){return f.next()}}},l.prototype.forEach=function(f,u){var d,h;u===void 0&&(u=a.dom.window);var g=0;try{for(var p=o(this._items),v=p.next();!v.done;v=p.next()){var y=v.value;f.call(u,y,g++,this)}}catch(m){d={error:m}}finally{try{v&&!v.done&&(h=p.return)&&h.call(p)}finally{if(d)throw d.error}}},l.prototype.get=function(f,u,d){if(!s.isString(u))return Reflect.get(f,u,d);var h=Number(u);return isNaN(h)?Reflect.get(f,u,d):f._items[h]||void 0},l.prototype.set=function(f,u,d,h){if(!s.isString(u))return Reflect.set(f,u,d,h);var g=Number(u);return isNaN(g)?Reflect.set(f,u,d,h):g>=0&&g<f._items.length&&(f._items[g]=d,!0)},l._create=function(f,u){var d=new l(f);return d._items=u,d},l}();n.NodeListStaticImpl=c},function(r,n,i){var o,a=this&&this.__extends||(o=function(f,u){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,h){d.__proto__=h}||function(d,h){for(var g in h)h.hasOwnProperty(g)&&(d[g]=h[g])})(f,u)},function(f,u){function d(){this.constructor=f}o(f,u),f.prototype=u===null?Object.create(u):(d.prototype=u.prototype,new d)});Object.defineProperty(n,"__esModule",{value:!0});var s=i(9),c=i(0),l=function(f){function u(d){var h=f.call(this)||this;return h._element=d,Object.setPrototypeOf(h,u.prototype),h}return a(u,f),u.prototype._asArray=function(){return this},u.prototype.item=function(d){return this[d]||null},u.prototype.getNamedItem=function(d){return c.element_getAnAttributeByName(d,this._element)},u.prototype.getNamedItemNS=function(d,h){return c.element_getAnAttributeByNamespaceAndLocalName(d||"",h,this._element)},u.prototype.setNamedItem=function(d){return c.element_setAnAttribute(d,this._element)},u.prototype.setNamedItemNS=function(d){return c.element_setAnAttribute(d,this._element)},u.prototype.removeNamedItem=function(d){var h=c.element_removeAnAttributeByName(d,this._element);if(h===null)throw new s.NotFoundError;return h},u.prototype.removeNamedItemNS=function(d,h){var g=c.element_removeAnAttributeByNamespaceAndLocalName(d||"",h,this._element);if(g===null)throw new s.NotFoundError;return g},u._create=function(d){return new u(d)},u}(Array);n.NamedNodeMapImpl=l},function(r,n,i){var o,a=this&&this.__extends||(o=function(v,y){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(m,w){m.__proto__=w}||function(m,w){for(var x in w)w.hasOwnProperty(x)&&(m[x]=w[x])})(v,y)},function(v,y){function m(){this.constructor=v}o(v,y),v.prototype=y===null?Object.create(y):(m.prototype=y.prototype,new m)}),s=this&&this.__values||function(v){var y=typeof Symbol=="function"&&Symbol.iterator,m=y&&v[y],w=0;if(m)return m.call(v);if(v&&typeof v.length=="number")return{next:function(){return v&&w>=v.length&&(v=void 0),{value:v&&v[w++],done:!v}}};throw new TypeError(y?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var c=i(6),l=i(2),f=i(102),u=i(9),d=i(0),h=i(12),g=i(3),p=function(v){function y(){var m=v.call(this)||this,w=c.dom.window._associatedDocument;return m._start=[w,0],m._end=[w,0],c.dom.rangeList.add(m),m}return a(y,v),Object.defineProperty(y.prototype,"commonAncestorContainer",{get:function(){for(var m=this._start[0];!d.tree_isAncestorOf(this._end[0],m,!0);){if(m._parent===null)throw new Error("Parent node is null.");m=m._parent}return m},enumerable:!0,configurable:!0}),y.prototype.setStart=function(m,w){d.range_setTheStart(this,m,w)},y.prototype.setEnd=function(m,w){d.range_setTheEnd(this,m,w)},y.prototype.setStartBefore=function(m){var w=m._parent;if(w===null)throw new u.InvalidNodeTypeError;d.range_setTheStart(this,w,d.tree_index(m))},y.prototype.setStartAfter=function(m){var w=m._parent;if(w===null)throw new u.InvalidNodeTypeError;d.range_setTheStart(this,w,d.tree_index(m)+1)},y.prototype.setEndBefore=function(m){var w=m._parent;if(w===null)throw new u.InvalidNodeTypeError;d.range_setTheEnd(this,w,d.tree_index(m))},y.prototype.setEndAfter=function(m){var w=m._parent;if(w===null)throw new u.InvalidNodeTypeError;d.range_setTheEnd(this,w,d.tree_index(m)+1)},y.prototype.collapse=function(m){m?this._end=this._start:this._start=this._end},y.prototype.selectNode=function(m){d.range_select(m,this)},y.prototype.selectNodeContents=function(m){if(g.Guard.isDocumentTypeNode(m))throw new u.InvalidNodeTypeError;var w=d.tree_nodeLength(m);this._start=[m,0],this._end=[m,w]},y.prototype.compareBoundaryPoints=function(m,w){if(m!==l.HowToCompare.StartToStart&&m!==l.HowToCompare.StartToEnd&&m!==l.HowToCompare.EndToEnd&&m!==l.HowToCompare.EndToStart)throw new u.NotSupportedError;if(d.range_root(this)!==d.range_root(w))throw new u.WrongDocumentError;var x,C;switch(m){case l.HowToCompare.StartToStart:x=this._start,C=w._start;break;case l.HowToCompare.StartToEnd:x=this._end,C=w._start;break;case l.HowToCompare.EndToEnd:x=this._end,C=w._end;break;case l.HowToCompare.EndToStart:x=this._start,C=w._end;break;default:throw new u.NotSupportedError}var S=d.boundaryPoint_position(x,C);return S===l.BoundaryPosition.Before?-1:S===l.BoundaryPosition.After?1:0},y.prototype.deleteContents=function(){var m,w,x,C;if(!d.range_collapsed(this)){var S=this._startNode,T=this._startOffset,_=this._endNode,E=this._endOffset;if(S===_&&g.Guard.isCharacterDataNode(S))d.characterData_replaceData(S,T,E-T,"");else{var b,D,I=[];try{for(var P=s(d.range_getContainedNodes(this)),O=P.next();!O.done;O=P.next()){var L=(F=O.value)._parent;L!==null&&d.range_isContained(L,this)||I.push(F)}}catch(G){m={error:G}}finally{try{O&&!O.done&&(w=P.return)&&w.call(P)}finally{if(m)throw m.error}}if(d.tree_isAncestorOf(_,S,!0))b=S,D=T;else{for(var B=S;B._parent!==null&&!d.tree_isAncestorOf(_,B._parent,!0);)B=B._parent;if(B._parent===null)throw new Error("Parent node is null.");b=B._parent,D=d.tree_index(B)+1}g.Guard.isCharacterDataNode(S)&&d.characterData_replaceData(S,T,d.tree_nodeLength(S)-T,"");try{for(var H=s(I),A=H.next();!A.done;A=H.next()){var F;(F=A.value)._parent&&d.mutation_remove(F,F._parent)}}catch(G){x={error:G}}finally{try{A&&!A.done&&(C=H.return)&&C.call(H)}finally{if(x)throw x.error}}g.Guard.isCharacterDataNode(_)&&d.characterData_replaceData(_,0,E,""),this._start=[b,D],this._end=[b,D]}}},y.prototype.extractContents=function(){return d.range_extract(this)},y.prototype.cloneContents=function(){return d.range_cloneTheContents(this)},y.prototype.insertNode=function(m){return d.range_insert(m,this)},y.prototype.surroundContents=function(m){var w,x;try{for(var C=s(d.range_getPartiallyContainedNodes(this)),S=C.next();!S.done;S=C.next()){var T=S.value;if(!g.Guard.isTextNode(T))throw new u.InvalidStateError}}catch(E){w={error:E}}finally{try{S&&!S.done&&(x=C.return)&&x.call(C)}finally{if(w)throw w.error}}if(g.Guard.isDocumentNode(m)||g.Guard.isDocumentTypeNode(m)||g.Guard.isDocumentFragmentNode(m))throw new u.InvalidNodeTypeError;var _=d.range_extract(this);m._children.size!==0&&d.mutation_replaceAll(null,m),d.range_insert(m,this),d.mutation_append(_,m),d.range_select(m,this)},y.prototype.cloneRange=function(){return d.create_range(this._start,this._end)},y.prototype.detach=function(){c.dom.rangeList.delete(this)},y.prototype.isPointInRange=function(m,w){if(d.tree_rootNode(m)!==d.range_root(this))return!1;if(g.Guard.isDocumentTypeNode(m))throw new u.InvalidNodeTypeError;if(w>d.tree_nodeLength(m))throw new u.IndexSizeError;var x=[m,w];return d.boundaryPoint_position(x,this._start)!==l.BoundaryPosition.Before&&d.boundaryPoint_position(x,this._end)!==l.BoundaryPosition.After},y.prototype.comparePoint=function(m,w){if(d.tree_rootNode(m)!==d.range_root(this))throw new u.WrongDocumentError;if(g.Guard.isDocumentTypeNode(m))throw new u.InvalidNodeTypeError;if(w>d.tree_nodeLength(m))throw new u.IndexSizeError;var x=[m,w];return d.boundaryPoint_position(x,this._start)===l.BoundaryPosition.Before?-1:d.boundaryPoint_position(x,this._end)===l.BoundaryPosition.After?1:0},y.prototype.intersectsNode=function(m){if(d.tree_rootNode(m)!==d.range_root(this))return!1;var w=m._parent;if(w===null)return!0;var x=d.tree_index(m);return d.boundaryPoint_position([w,x],this._end)===l.BoundaryPosition.Before&&d.boundaryPoint_position([w,x+1],this._start)===l.BoundaryPosition.After},y.prototype.toString=function(){var m,w,x="";if(this._startNode===this._endNode&&g.Guard.isTextNode(this._startNode))return this._startNode._data.substring(this._startOffset,this._endOffset);g.Guard.isTextNode(this._startNode)&&(x+=this._startNode._data.substring(this._startOffset));try{for(var C=s(d.range_getContainedNodes(this)),S=C.next();!S.done;S=C.next()){var T=S.value;g.Guard.isTextNode(T)&&(x+=T._data)}}catch(_){m={error:_}}finally{try{S&&!S.done&&(w=C.return)&&w.call(C)}finally{if(m)throw m.error}}return g.Guard.isTextNode(this._endNode)&&(x+=this._endNode._data.substring(0,this._endOffset)),x},y._create=function(m,w){var x=new y;return m&&(x._start=m),w&&(x._end=w),x},y.START_TO_START=0,y.START_TO_END=1,y.END_TO_END=2,y.END_TO_START=3,y}(f.AbstractRangeImpl);n.RangeImpl=p,h.idl_defineConst(p.prototype,"START_TO_START",0),h.idl_defineConst(p.prototype,"START_TO_END",1),h.idl_defineConst(p.prototype,"END_TO_END",2),h.idl_defineConst(p.prototype,"END_TO_START",3)},function(r,n,i){var o,a=this&&this.__extends||(o=function(f,u){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,h){d.__proto__=h}||function(d,h){for(var g in h)h.hasOwnProperty(g)&&(d[g]=h[g])})(f,u)},function(f,u){function d(){this.constructor=f}o(f,u),f.prototype=u===null?Object.create(u):(d.prototype=u.prototype,new d)});Object.defineProperty(n,"__esModule",{value:!0});var s=i(103),c=i(0),l=function(f){function u(d,h,g){var p=f.call(this,d)||this;return p._iteratorCollection=void 0,p._reference=h,p._pointerBeforeReference=g,c.nodeIterator_iteratorList().add(p),p}return a(u,f),Object.defineProperty(u.prototype,"referenceNode",{get:function(){return this._reference},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"pointerBeforeReferenceNode",{get:function(){return this._pointerBeforeReference},enumerable:!0,configurable:!0}),u.prototype.nextNode=function(){return c.nodeIterator_traverse(this,!0)},u.prototype.previousNode=function(){return c.nodeIterator_traverse(this,!1)},u.prototype.detach=function(){c.nodeIterator_iteratorList().delete(this)},u._create=function(d,h,g){return new u(d,h,g)},u}(s.TraverserImpl);n.NodeIteratorImpl=l},function(r,n,i){var o,a=this&&this.__extends||(o=function(u,d){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(h,g){h.__proto__=g}||function(h,g){for(var p in g)g.hasOwnProperty(p)&&(h[p]=g[p])})(u,d)},function(u,d){function h(){this.constructor=u}o(u,d),u.prototype=d===null?Object.create(d):(h.prototype=d.prototype,new h)});Object.defineProperty(n,"__esModule",{value:!0});var s=i(2),c=i(103),l=i(0),f=function(u){function d(h,g){var p=u.call(this,h)||this;return p._current=g,p}return a(d,u),Object.defineProperty(d.prototype,"currentNode",{get:function(){return this._current},set:function(h){this._current=h},enumerable:!0,configurable:!0}),d.prototype.parentNode=function(){for(var h=this._current;h!==null&&h!==this._root;)if((h=h._parent)!==null&&l.traversal_filter(this,h)===s.FilterResult.Accept)return this._current=h,h;return null},d.prototype.firstChild=function(){return l.treeWalker_traverseChildren(this,!0)},d.prototype.lastChild=function(){return l.treeWalker_traverseChildren(this,!1)},d.prototype.nextSibling=function(){return l.treeWalker_traverseSiblings(this,!0)},d.prototype.previousNode=function(){for(var h=this._current;h!==this._root;){for(var g=h._previousSibling;g;){h=g;for(var p=l.traversal_filter(this,h);p!==s.FilterResult.Reject&&h._lastChild;)h=h._lastChild,p=l.traversal_filter(this,h);if(p===s.FilterResult.Accept)return this._current=h,h;g=h._previousSibling}if(h===this._root||h._parent===null)return null;if(h=h._parent,l.traversal_filter(this,h)===s.FilterResult.Accept)return this._current=h,h}return null},d.prototype.previousSibling=function(){return l.treeWalker_traverseSiblings(this,!1)},d.prototype.nextNode=function(){for(var h=this._current,g=s.FilterResult.Accept;;){for(;g!==s.FilterResult.Reject&&h._firstChild;)if(h=h._firstChild,(g=l.traversal_filter(this,h))===s.FilterResult.Accept)return this._current=h,h;for(var p=null,v=h;v!==null;){if(v===this._root)return null;if((p=v._nextSibling)!==null){h=p;break}v=v._parent}if((g=l.traversal_filter(this,h))===s.FilterResult.Accept)return this._current=h,h}},d._create=function(h,g){return new d(h,g)},d}(c.TraverserImpl);n.TreeWalkerImpl=f},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(2),a=i(12),s=function(){function c(){}return c.prototype.acceptNode=function(l){return o.FilterResult.Accept},c._create=function(){return new c},c.FILTER_ACCEPT=1,c.FILTER_REJECT=2,c.FILTER_SKIP=3,c.SHOW_ALL=4294967295,c.SHOW_ELEMENT=1,c.SHOW_ATTRIBUTE=2,c.SHOW_TEXT=4,c.SHOW_CDATA_SECTION=8,c.SHOW_ENTITY_REFERENCE=16,c.SHOW_ENTITY=32,c.SHOW_PROCESSING_INSTRUCTION=64,c.SHOW_COMMENT=128,c.SHOW_DOCUMENT=256,c.SHOW_DOCUMENT_TYPE=512,c.SHOW_DOCUMENT_FRAGMENT=1024,c.SHOW_NOTATION=2048,c}();n.NodeFilterImpl=s,a.idl_defineConst(s.prototype,"FILTER_ACCEPT",1),a.idl_defineConst(s.prototype,"FILTER_REJECT",2),a.idl_defineConst(s.prototype,"FILTER_SKIP",3),a.idl_defineConst(s.prototype,"SHOW_ALL",4294967295),a.idl_defineConst(s.prototype,"SHOW_ELEMENT",1),a.idl_defineConst(s.prototype,"SHOW_ATTRIBUTE",2),a.idl_defineConst(s.prototype,"SHOW_TEXT",4),a.idl_defineConst(s.prototype,"SHOW_CDATA_SECTION",8),a.idl_defineConst(s.prototype,"SHOW_ENTITY_REFERENCE",16),a.idl_defineConst(s.prototype,"SHOW_ENTITY",32),a.idl_defineConst(s.prototype,"SHOW_PROCESSING_INSTRUCTION",64),a.idl_defineConst(s.prototype,"SHOW_COMMENT",128),a.idl_defineConst(s.prototype,"SHOW_DOCUMENT",256),a.idl_defineConst(s.prototype,"SHOW_DOCUMENT_TYPE",512),a.idl_defineConst(s.prototype,"SHOW_DOCUMENT_FRAGMENT",1024),a.idl_defineConst(s.prototype,"SHOW_NOTATION",2048)},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function a(s,c,l,f,u,d,h,g,p){this._type=s,this._target=c,this._addedNodes=l,this._removedNodes=f,this._previousSibling=u,this._nextSibling=d,this._attributeName=h,this._attributeNamespace=g,this._oldValue=p}return Object.defineProperty(a.prototype,"type",{get:function(){return this._type},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"target",{get:function(){return this._target},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"addedNodes",{get:function(){return this._addedNodes},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"removedNodes",{get:function(){return this._removedNodes},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"previousSibling",{get:function(){return this._previousSibling},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"nextSibling",{get:function(){return this._nextSibling},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"attributeName",{get:function(){return this._attributeName},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"attributeNamespace",{get:function(){return this._attributeNamespace},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"oldValue",{get:function(){return this._oldValue},enumerable:!0,configurable:!0}),a._create=function(s,c,l,f,u,d,h,g,p){return new a(s,c,l,f,u,d,h,g,p)},a}();n.MutationRecordImpl=o},function(r,n,i){var o=this&&this.__values||function(u){var d=typeof Symbol=="function"&&Symbol.iterator,h=d&&u[d],g=0;if(h)return h.call(u);if(u&&typeof u.length=="number")return{next:function(){return u&&g>=u.length&&(u=void 0),{value:u&&u[g++],done:!u}}};throw new TypeError(d?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var a=i(6),s=i(9),c=i(7),l=i(0),f=function(){function u(d,h){this._element=d,this._attribute=h,this._tokenSet=new Set;var g=h._localName,p=l.element_getAnAttributeValue(d,g),v=this;this._element._attributeChangeSteps.push(function(y,m,w,x,C){m===v._attribute._localName&&C===null&&(x?v._tokenSet=l.orderedSet_parse(x):v._tokenSet.clear())}),a.dom.features.steps&&l.dom_runAttributeChangeSteps(d,g,p,p,null)}return Object.defineProperty(u.prototype,"length",{get:function(){return this._tokenSet.size},enumerable:!0,configurable:!0}),u.prototype.item=function(d){var h,g,p=0;try{for(var v=o(this._tokenSet),y=v.next();!y.done;y=v.next()){var m=y.value;if(p===d)return m;p++}}catch(w){h={error:w}}finally{try{y&&!y.done&&(g=v.return)&&g.call(v)}finally{if(h)throw h.error}}return null},u.prototype.contains=function(d){return this._tokenSet.has(d)},u.prototype.add=function(){for(var d,h,g=[],p=0;p<arguments.length;p++)g[p]=arguments[p];try{for(var v=o(g),y=v.next();!y.done;y=v.next()){var m=y.value;if(m==="")throw new s.SyntaxError("Cannot add an empty token.");if(c.codePoint.ASCIIWhiteSpace.test(m))throw new s.InvalidCharacterError("Token cannot contain whitespace.");this._tokenSet.add(m)}}catch(w){d={error:w}}finally{try{y&&!y.done&&(h=v.return)&&h.call(v)}finally{if(d)throw d.error}}l.tokenList_updateSteps(this)},u.prototype.remove=function(){for(var d,h,g=[],p=0;p<arguments.length;p++)g[p]=arguments[p];try{for(var v=o(g),y=v.next();!y.done;y=v.next()){var m=y.value;if(m==="")throw new s.SyntaxError("Cannot remove an empty token.");if(c.codePoint.ASCIIWhiteSpace.test(m))throw new s.InvalidCharacterError("Token cannot contain whitespace.");this._tokenSet.delete(m)}}catch(w){d={error:w}}finally{try{y&&!y.done&&(h=v.return)&&h.call(v)}finally{if(d)throw d.error}}l.tokenList_updateSteps(this)},u.prototype.toggle=function(d,h){if(h===void 0&&(h=void 0),d==="")throw new s.SyntaxError("Cannot toggle an empty token.");if(c.codePoint.ASCIIWhiteSpace.test(d))throw new s.InvalidCharacterError("Token cannot contain whitespace.");return this._tokenSet.has(d)?h!==void 0&&h!==!1||(this._tokenSet.delete(d),l.tokenList_updateSteps(this),!1):(h===void 0||h===!0)&&(this._tokenSet.add(d),l.tokenList_updateSteps(this),!0)},u.prototype.replace=function(d,h){if(d===""||h==="")throw new s.SyntaxError("Cannot replace an empty token.");if(c.codePoint.ASCIIWhiteSpace.test(d)||c.codePoint.ASCIIWhiteSpace.test(h))throw new s.InvalidCharacterError("Token cannot contain whitespace.");return!!this._tokenSet.has(d)&&(c.set.replace(this._tokenSet,d,h),l.tokenList_updateSteps(this),!0)},u.prototype.supports=function(d){return l.tokenList_validationSteps(this,d)},Object.defineProperty(u.prototype,"value",{get:function(){return l.tokenList_serializeSteps(this)},set:function(d){l.element_setAnAttributeValue(this._element,this._attribute._localName,d)},enumerable:!0,configurable:!0}),u.prototype[Symbol.iterator]=function(){var d=this._tokenSet[Symbol.iterator]();return{next:function(){return d.next()}}},u._create=function(d,h){return new u(d,h)},u}();n.DOMTokenListImpl=f},function(r,n,i){var o,a=this&&this.__extends||(o=function(f,u){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,h){d.__proto__=h}||function(d,h){for(var g in h)h.hasOwnProperty(g)&&(d[g]=h[g])})(f,u)},function(f,u){function d(){this.constructor=f}o(f,u),f.prototype=u===null?Object.create(u):(d.prototype=u.prototype,new d)});Object.defineProperty(n,"__esModule",{value:!0});var s=i(104),c=i(0),l=function(f){function u(d,h){var g=f.call(this,d,h)||this;return g._detail=null,g._detail=h&&h.detail||null,g}return a(u,f),Object.defineProperty(u.prototype,"detail",{get:function(){return this._detail},enumerable:!0,configurable:!0}),u.prototype.initCustomEvent=function(d,h,g,p){h===void 0&&(h=!1),g===void 0&&(g=!1),p===void 0&&(p=null),this._dispatchFlag||(c.event_initialize(this,d,h,g),this._detail=p)},u}(s.EventImpl);n.CustomEventImpl=l},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(6),a=i(2),s=i(105),c=i(17);n.nodeIterator_traverse=function(l,f){for(var u=l._reference,d=l._pointerBeforeReference;;){if(f)if(d)d=!1;else{var h=c.tree_getFollowingNode(l._root,u);if(!h)return null;u=h}else if(d){var g=c.tree_getPrecedingNode(l.root,u);if(!g)return null;u=g}else d=!0;if(s.traversal_filter(l,u)===a.FilterResult.Accept)break}return l._reference=u,l._pointerBeforeReference=d,u},n.nodeIterator_iteratorList=function(){return o.dom.window._iteratorList}},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(9),a=i(7),s=i(174);function c(l){if(!s.xml_isName(l))throw new o.InvalidCharacterError("Invalid XML name: "+l);if(!s.xml_isQName(l))throw new o.InvalidCharacterError("Invalid XML qualified name: "+l+".")}n.namespace_validate=c,n.namespace_validateAndExtract=function(l,f){l||(l=null),c(f);var u=f.split(":"),d=u.length===2?u[0]:null,h=u.length===2?u[1]:f;if(d&&l===null)throw new o.NamespaceError("Qualified name includes a prefix but the namespace is null.");if(d==="xml"&&l!==a.namespace.XML)throw new o.NamespaceError('Qualified name includes the "xml" prefix but the namespace is not the XML namespace.');if(l!==a.namespace.XMLNS&&(d==="xmlns"||f==="xmlns"))throw new o.NamespaceError('Qualified name includes the "xmlns" prefix but the namespace is not the XMLNS namespace.');if(l===a.namespace.XMLNS&&d!=="xmlns"&&f!=="xmlns")throw new o.NamespaceError('Qualified name does not include the "xmlns" prefix but the namespace is the XMLNS namespace.');return[l,d,h]},n.namespace_extractQName=function(l){c(l);var f=l.split(":");return[f.length===2?f[0]:null,f.length===2?f[1]:l]}},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0}),n.xml_isName=function(o){for(var a=0;a<o.length;a++){var s=o.charCodeAt(a);if(!(s>=97&&s<=122||s>=65&&s<=90||s===58||s===95||s>=192&&s<=214||s>=216&&s<=246||s>=248&&s<=767||s>=880&&s<=893||s>=895&&s<=8191||s>=8204&&s<=8205||s>=8304&&s<=8591||s>=11264&&s<=12271||s>=12289&&s<=55295||s>=63744&&s<=64975||s>=65008&&s<=65533)&&(a===0||!(s===45||s===46||s>=48&&s<=57||s===183||s>=768&&s<=879||s>=8255&&s<=8256))){if(s>=55296&&s<=56319&&a<o.length-1){var c=o.charCodeAt(a+1);if(c>=56320&&c<=57343&&(a++,(s=1024*(s-55296)+c-56320+65536)>=65536&&s<=983039))continue}return!1}}return!0},n.xml_isQName=function(o){for(var a=!1,s=0;s<o.length;s++){var c=o.charCodeAt(s);if(!(c>=97&&c<=122||c>=65&&c<=90||c===95||c>=192&&c<=214||c>=216&&c<=246||c>=248&&c<=767||c>=880&&c<=893||c>=895&&c<=8191||c>=8204&&c<=8205||c>=8304&&c<=8591||c>=11264&&c<=12271||c>=12289&&c<=55295||c>=63744&&c<=64975||c>=65008&&c<=65533)&&(s===0||!(c===45||c===46||c>=48&&c<=57||c===183||c>=768&&c<=879||c>=8255&&c<=8256))){if(s===0||c!==58){if(c>=55296&&c<=56319&&s<o.length-1){var l=o.charCodeAt(s+1);if(l>=56320&&l<=57343&&(s++,(c=1024*(c-55296)+l-56320+65536)>=65536&&c<=983039))continue}return!1}if(a||s===o.length-1)return!1;a=!0}}return!0},n.xml_isLegalChar=function(o){for(var a=0;a<o.length;a++){var s=o.charCodeAt(a);if(!(s===9||s===10||s===13||s>=32&&s<=55295||s>=57344&&s<=65533)){if(s>=55296&&s<=56319&&a<o.length-1){var c=o.charCodeAt(a+1);if(c>=56320&&c<=57343&&(a++,(s=1024*(s-55296)+c-56320+65536)>=65536&&s<=1114111))continue}return!1}}return!0},n.xml_isPubidChar=function(o){for(var a=0;a<o.length;a++){var s=o.charCodeAt(a);if(!(s>=97&&s<=122||s>=65&&s<=90||s>=39&&s<=59||s===32||s===13||s===10||s>=35&&s<=37||s===33||s===61||s===63||s===64||s===95))return!1}return!0}},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(2),a=i(17);n.boundaryPoint_position=function s(c,l){var f=c[0],u=c[1],d=l[0],h=l[1];if(console.assert(a.tree_rootNode(f)===a.tree_rootNode(d),"Boundary points must share the same root node."),f===d)return u===h?o.BoundaryPosition.Equal:u<h?o.BoundaryPosition.Before:o.BoundaryPosition.After;if(a.tree_isFollowing(d,f)){var g=s([d,h],[f,u]);if(g===o.BoundaryPosition.Before)return o.BoundaryPosition.After;if(g===o.BoundaryPosition.After)return o.BoundaryPosition.Before}if(a.tree_isAncestorOf(d,f)){for(var p=d;!a.tree_isChildOf(f,p);)p._parent!==null&&(p=p._parent);if(a.tree_index(p)<u)return o.BoundaryPosition.After}return o.BoundaryPosition.Before}},function(r,n,i){var o=this&&this.__values||function(g){var p=typeof Symbol=="function"&&Symbol.iterator,v=p&&g[p],y=0;if(v)return v.call(g);if(g&&typeof g.length=="number")return{next:function(){return g&&y>=g.length&&(g=void 0),{value:g&&g[y++],done:!g}}};throw new TypeError(p?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var a=i(6),s=i(3),c=i(7),l=i(29),f=i(108),u=i(30),d=i(37),h=i(52);n.node_stringReplaceAll=function(g,p){var v=null;g!==""&&(v=l.create_text(p._nodeDocument,g)),d.mutation_replaceAll(v,p)},n.node_clone=function g(p,v,y){var m,w,x,C,S;if(v===void 0&&(v=null),y===void 0&&(y=!1),v===null&&(v=p._nodeDocument),s.Guard.isElementNode(p)){S=h.element_createAnElement(v,p._localName,p._namespace,p._namespacePrefix,p._is,!1);try{for(var T=o(p._attributeList),_=T.next();!_.done;_=T.next()){var E=g(_.value,v);h.element_append(E,S)}}catch(L){m={error:L}}finally{try{_&&!_.done&&(w=T.return)&&w.call(T)}finally{if(m)throw m.error}}}else if(s.Guard.isDocumentNode(p)){var b=l.create_document();b._encoding=p._encoding,b._contentType=p._contentType,b._URL=p._URL,b._origin=p._origin,b._type=p._type,b._mode=p._mode,S=b}else if(s.Guard.isDocumentTypeNode(p))S=l.create_documentType(v,p._name,p._publicId,p._systemId);else if(s.Guard.isAttrNode(p)){var D=l.create_attr(v,p.localName);D._namespace=p._namespace,D._namespacePrefix=p._namespacePrefix,D._value=p._value,S=D}else S=s.Guard.isExclusiveTextNode(p)?l.create_text(v,p._data):s.Guard.isCDATASectionNode(p)?l.create_cdataSection(v,p._data):s.Guard.isCommentNode(p)?l.create_comment(v,p._data):s.Guard.isProcessingInstructionNode(p)?l.create_processingInstruction(v,p._target,p._data):s.Guard.isDocumentFragmentNode(p)?l.create_documentFragment(v):Object.create(p);if(s.Guard.isDocumentNode(S)?(S._nodeDocument=S,v=S):S._nodeDocument=v,a.dom.features.steps&&u.dom_runCloningSteps(S,p,v,y),y)try{for(var I=o(p._children),P=I.next();!P.done;P=I.next()){var O=g(P.value,v,!0);d.mutation_append(O,S)}}catch(L){x={error:L}}finally{try{P&&!P.done&&(C=I.return)&&C.call(I)}finally{if(x)throw x.error}}return S},n.node_equals=function g(p,v){var y,m,w,x;if(p._nodeType!==v._nodeType)return!1;if(s.Guard.isDocumentTypeNode(p)&&s.Guard.isDocumentTypeNode(v)){if(p._name!==v._name||p._publicId!==v._publicId||p._systemId!==v._systemId)return!1}else if(s.Guard.isElementNode(p)&&s.Guard.isElementNode(v)){if(p._namespace!==v._namespace||p._namespacePrefix!==v._namespacePrefix||p._localName!==v._localName||p._attributeList.length!==v._attributeList.length)return!1}else if(s.Guard.isAttrNode(p)&&s.Guard.isAttrNode(v)){if(p._namespace!==v._namespace||p._localName!==v._localName||p._value!==v._value)return!1}else if(s.Guard.isProcessingInstructionNode(p)&&s.Guard.isProcessingInstructionNode(v)){if(p._target!==v._target||p._data!==v._data)return!1}else if(s.Guard.isCharacterDataNode(p)&&s.Guard.isCharacterDataNode(v)&&p._data!==v._data)return!1;if(s.Guard.isElementNode(p)&&s.Guard.isElementNode(v)){var C={};try{for(var S=o(p._attributeList),T=S.next();!T.done;T=S.next())C[(b=T.value)._localName]=b}catch(B){y={error:B}}finally{try{T&&!T.done&&(m=S.return)&&m.call(S)}finally{if(y)throw y.error}}try{for(var _=o(v._attributeList),E=_.next();!E.done;E=_.next()){var b,D=E.value;if(!(b=C[D._localName])||!g(b,D))return!1}}catch(B){w={error:B}}finally{try{E&&!E.done&&(x=_.return)&&x.call(_)}finally{if(w)throw w.error}}}if(p._children.size!==v._children.size)return!1;for(var I=p._children[Symbol.iterator](),P=v._children[Symbol.iterator](),O=I.next(),L=P.next();!O.done&&!L.done;){if(!g(O.value,L.value))return!1;O=I.next(),L=P.next()}return!0},n.node_listOfElementsWithQualifiedName=function(g,p){return g==="*"?l.create_htmlCollection(p):p._nodeDocument._type==="html"?l.create_htmlCollection(p,function(v){return v._namespace===c.namespace.HTML&&v._qualifiedName===g.toLowerCase()||v._namespace!==c.namespace.HTML&&v._qualifiedName===g}):l.create_htmlCollection(p,function(v){return v._qualifiedName===g})},n.node_listOfElementsWithNamespace=function(g,p,v){return g===""&&(g=null),g==="*"&&p==="*"?l.create_htmlCollection(v):g==="*"?l.create_htmlCollection(v,function(y){return y._localName===p}):p==="*"?l.create_htmlCollection(v,function(y){return y._namespace===g}):l.create_htmlCollection(v,function(y){return y._localName===p&&y._namespace===g})},n.node_listOfElementsWithClassNames=function(g,p){var v=f.orderedSet_parse(g);if(v.size===0)return l.create_htmlCollection(p,function(){return!1});var y=p._nodeDocument._mode!=="quirks";return l.create_htmlCollection(p,function(m){var w=m.classList;return f.orderedSet_contains(w._tokenSet,v,y)})},n.node_locateANamespacePrefix=function g(p,v){if(p._namespace===v&&p._namespacePrefix!==null)return p._namespacePrefix;for(var y=0;y<p._attributeList.length;y++){var m=p._attributeList[y];if(m._namespacePrefix==="xmlns"&&m._value===v)return m._localName}return p._parent&&s.Guard.isElementNode(p._parent)?g(p._parent,v):null},n.node_locateANamespace=function g(p,v){if(s.Guard.isElementNode(p)){if(p._namespace!==null&&p._namespacePrefix===v)return p._namespace;for(var y=0;y<p._attributeList.length;y++){var m=p._attributeList[y];if(m._namespace===c.namespace.XMLNS&&m._namespacePrefix==="xmlns"&&m._localName===v||v===null&&m._namespace===c.namespace.XMLNS&&m._namespacePrefix===null&&m._localName==="xmlns")return m._value||null}return p.parentElement===null?null:g(p.parentElement,v)}return s.Guard.isDocumentNode(p)?p.documentElement===null?null:g(p.documentElement,v):s.Guard.isDocumentTypeNode(p)||s.Guard.isDocumentFragmentNode(p)?null:s.Guard.isAttrNode(p)?p._element===null?null:g(p._element,v):p._parent&&s.Guard.isElementNode(p._parent)?g(p._parent,v):null}},function(r,n,i){var o=this&&this.__values||function(h){var g=typeof Symbol=="function"&&Symbol.iterator,p=g&&h[g],v=0;if(p)return p.call(h);if(h&&typeof h.length=="number")return{next:function(){return h&&v>=h.length&&(h=void 0),{value:h&&h[v++],done:!h}}};throw new TypeError(g?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var a=i(6),s=i(3),c=i(9),l=i(29),f=i(17),u=i(107),d=i(37);n.text_contiguousTextNodes=function(h,g){var p;return g===void 0&&(g=!1),(p={})[Symbol.iterator]=function(){for(var v=h;v&&s.Guard.isTextNode(v._previousSibling);)v=v._previousSibling;return{next:function(){if(v&&!g&&v===h&&(v=s.Guard.isTextNode(v._nextSibling)?v._nextSibling:null),v===null)return{done:!0,value:null};var y={done:!1,value:v};return v=s.Guard.isTextNode(v._nextSibling)?v._nextSibling:null,y}}},p},n.text_contiguousExclusiveTextNodes=function(h,g){var p;return g===void 0&&(g=!1),(p={})[Symbol.iterator]=function(){for(var v=h;v&&s.Guard.isExclusiveTextNode(v._previousSibling);)v=v._previousSibling;return{next:function(){if(v&&!g&&v===h&&(v=s.Guard.isExclusiveTextNode(v._nextSibling)?v._nextSibling:null),v===null)return{done:!0,value:null};var y={done:!1,value:v};return v=s.Guard.isExclusiveTextNode(v._nextSibling)?v._nextSibling:null,y}}},p},n.text_descendantTextContent=function(h){for(var g="",p=f.tree_getFirstDescendantNode(h,!1,!1,function(v){return s.Guard.isTextNode(v)});p!==null;)g+=p._data,p=f.tree_getNextDescendantNode(h,p,!1,!1,function(v){return s.Guard.isTextNode(v)});return g},n.text_split=function(h,g){var p,v,y=h._data.length;if(g>y)throw new c.IndexSizeError;var m=y-g,w=u.characterData_substringData(h,g,m),x=l.create_text(h._nodeDocument,w),C=h._parent;if(C!==null){d.mutation_insert(x,C,h._nextSibling);try{for(var S=o(a.dom.rangeList),T=S.next();!T.done;T=S.next()){var _=T.value;_._start[0]===h&&_._start[1]>g&&(_._start[0]=x,_._start[1]-=g),_._end[0]===h&&_._end[1]>g&&(_._end[0]=x,_._end[1]-=g);var E=f.tree_index(h);_._start[0]===C&&_._start[1]===E+1&&_._start[1]++,_._end[0]===C&&_._end[1]===E+1&&_._end[1]++}}catch(b){p={error:b}}finally{try{T&&!T.done&&(v=S.return)&&v.call(S)}finally{if(p)throw p.error}}}return u.characterData_replaceData(h,g,m,""),x}},function(r,n,i){var o=i(4),a=i(41),s=i(24),c=i(48),l=[].join,f=a!=Object,u=c("join",",");o({target:"Array",proto:!0,forced:f||!u},{join:function(d){return l.call(s(this),d===void 0?",":d)}})},function(r,n,i){var o=i(4),a=i(83),s=String.fromCharCode,c=String.fromCodePoint;o({target:"String",stat:!0,forced:!!c&&c.length!=1},{fromCodePoint:function(l){for(var f,u=[],d=arguments.length,h=0;d>h;){if(f=+arguments[h++],a(f,1114111)!==f)throw RangeError(f+" is not a valid code point");u.push(f<65536?s(f):s(55296+((f-=65536)>>10),f%1024+56320))}return u.join("")}})},function(r,n,i){var o=this&&this.__read||function(c,l){var f=typeof Symbol=="function"&&c[Symbol.iterator];if(!f)return c;var u,d,h=f.call(c),g=[];try{for(;(l===void 0||l-- >0)&&!(u=h.next()).done;)g.push(u.value)}catch(p){d={error:p}}finally{try{u&&!u.done&&(f=h.return)&&f.call(h)}finally{if(d)throw d.error}}return g};Object.defineProperty(n,"__esModule",{value:!0});var a=i(111),s=function(){function c(l,f){this._options={skipWhitespaceOnlyText:!1},this.err={line:-1,col:-1,index:-1,str:""},this._str=l,this._index=0,this._length=l.length,f&&(this._options.skipWhitespaceOnlyText=f.skipWhitespaceOnlyText||!1)}return c.prototype.nextToken=function(){if(this.eof())return{type:a.TokenType.EOF};var l=this.skipIfStartsWith("<")?this.openBracket():this.text();return this._options.skipWhitespaceOnlyText&&l.type===a.TokenType.Text&&c.isWhiteSpaceToken(l)&&(l=this.nextToken()),l},c.prototype.openBracket=function(){return this.skipIfStartsWith("?")?this.skipIfStartsWith("xml")?c.isSpace(this._str[this._index])?this.declaration():(this.seek(-3),this.pi()):this.pi():this.skipIfStartsWith("!")?this.skipIfStartsWith("--")?this.comment():this.skipIfStartsWith("[CDATA[")?this.cdata():this.skipIfStartsWith("DOCTYPE")?this.doctype():void this.throwError("Invalid '!' in opening tag."):this.skipIfStartsWith("/")?this.closeTag():this.openTag()},c.prototype.declaration=function(){for(var l="",f="",u="";!this.eof();){if(this.skipSpace(),this.skipIfStartsWith("?>"))return{type:a.TokenType.Declaration,version:l,encoding:f,standalone:u};var d=o(this.attribute(),2),h=d[0],g=d[1];h==="version"?l=g:h==="encoding"?f=g:h==="standalone"?u=g:this.throwError("Invalid attribute name: "+h)}this.throwError("Missing declaration end symbol `?>`")},c.prototype.doctype=function(){var l="",f="";this.skipSpace();var u=this.takeUntil2("[",">",!0);return this.skipSpace(),this.skipIfStartsWith("PUBLIC")?(l=this.quotedString(),f=this.quotedString()):this.skipIfStartsWith("SYSTEM")&&(f=this.quotedString()),this.skipSpace(),this.skipIfStartsWith("[")&&(this.skipUntil("]"),this.skipIfStartsWith("]")||this.throwError("Missing end bracket of DTD internal subset")),this.skipSpace(),this.skipIfStartsWith(">")||this.throwError("Missing doctype end symbol `>`"),{type:a.TokenType.DocType,name:u,pubId:l,sysId:f}},c.prototype.pi=function(){var l=this.takeUntilStartsWith("?>",!0);if(this.eof()&&this.throwError("Missing processing instruction end symbol `?>`"),this.skipSpace(),this.skipIfStartsWith("?>"))return{type:a.TokenType.PI,target:l,data:""};var f=this.takeUntilStartsWith("?>");return this.eof()&&this.throwError("Missing processing instruction end symbol `?>`"),this.seek(2),{type:a.TokenType.PI,target:l,data:f}},c.prototype.text=function(){var l=this.takeUntil("<");return{type:a.TokenType.Text,data:l}},c.prototype.comment=function(){var l=this.takeUntilStartsWith("-->");return this.eof()&&this.throwError("Missing comment end symbol `-->`"),this.seek(3),{type:a.TokenType.Comment,data:l}},c.prototype.cdata=function(){var l=this.takeUntilStartsWith("]]>");return this.eof()&&this.throwError("Missing CDATA end symbol `]>`"),this.seek(3),{type:a.TokenType.CDATA,data:l}},c.prototype.openTag=function(){this.skipSpace();var l=this.takeUntil2(">","/",!0);if(this.skipSpace(),this.skipIfStartsWith(">"))return{type:a.TokenType.Element,name:l,attributes:[],selfClosing:!1};if(this.skipIfStartsWith("/>"))return{type:a.TokenType.Element,name:l,attributes:[],selfClosing:!0};for(var f=[];!this.eof();){if(this.skipSpace(),this.skipIfStartsWith(">"))return{type:a.TokenType.Element,name:l,attributes:f,selfClosing:!1};if(this.skipIfStartsWith("/>"))return{type:a.TokenType.Element,name:l,attributes:f,selfClosing:!0};var u=this.attribute();f.push(u)}this.throwError("Missing opening element tag end symbol `>`")},c.prototype.closeTag=function(){this.skipSpace();var l=this.takeUntil(">",!0);return this.skipSpace(),this.skipIfStartsWith(">")||this.throwError("Missing closing element tag end symbol `>`"),{type:a.TokenType.ClosingTag,name:l}},c.prototype.attribute=function(){this.skipSpace();var l=this.takeUntil("=",!0);return this.skipSpace(),this.skipIfStartsWith("=")||this.throwError("Missing equals sign before attribute value"),[l,this.quotedString()]},c.prototype.quotedString=function(){this.skipSpace();var l=this.take(1);c.isQuote(l)||this.throwError("Missing start quote character before quoted value");var f=this.takeUntil(l);return this.skipIfStartsWith(l)||this.throwError("Missing end quote character after quoted value"),f},c.prototype.eof=function(){return this._index>=this._length},c.prototype.skipIfStartsWith=function(l){var f=l.length;if(f===1)return this._str[this._index]===l&&(this._index++,!0);for(var u=0;u<f;u++)if(this._str[this._index+u]!==l[u])return!1;return this._index+=f,!0},c.prototype.seek=function(l){this._index+=l,this._index<0&&(this._index=0),this._index>this._length&&(this._index=this._length)},c.prototype.skipSpace=function(){for(;!this.eof()&&c.isSpace(this._str[this._index]);)this._index++},c.prototype.take=function(l){if(l===1)return this._str[this._index++];var f=this._index;return this.seek(l),this._str.slice(f,this._index)},c.prototype.takeUntil=function(l,f){f===void 0&&(f=!1);for(var u=this._index;this._index<this._length;){var d=this._str[this._index];if(d===l||f&&c.isSpace(d))break;this._index++}return this._str.slice(u,this._index)},c.prototype.takeUntil2=function(l,f,u){u===void 0&&(u=!1);for(var d=this._index;this._index<this._length;){var h=this._str[this._index];if(h===l||h===f||u&&c.isSpace(h))break;this._index++}return this._str.slice(d,this._index)},c.prototype.takeUntilStartsWith=function(l,f){f===void 0&&(f=!1);for(var u=this._index,d=l.length;this._index<this._length;){for(var h=!0,g=0;g<d;g++){var p=this._str[this._index+g],v=l[g];if(f&&c.isSpace(p))return this._str.slice(u,this._index);if(p!==v){this._index++,h=!1;break}}if(h)return this._str.slice(u,this._index)}return this._index=this._length,this._str.slice(u)},c.prototype.skipUntil=function(l){for(;this._index<this._length&&this._str[this._index]!==l;)this._index++},c.isWhiteSpaceToken=function(l){for(var f=l.data,u=0;u<f.length;u++){var d=f[u];if(d!==" "&&d!==`
|
||
`&&d!=="\r"&&d!==" "&&d!=="\f")return!1}return!0},c.isSpace=function(l){return l===" "||l===`
|
||
`||l==="\r"||l===" "},c.isQuote=function(l){return l==='"'||l==="'"},c.prototype.throwError=function(l){for(var f=/\r\n|\r|\n/g,u=null,d=0,h=0,g=this._str.length;(u=f.exec(this._str))!==null&&u!==null;)if(d++,u.index<this._index&&(h=f.lastIndex),u.index>this._index){g=u.index;break}throw this.err={line:d,col:this._index-h,index:this._index,str:this._str.substring(h,g)},new Error(l+`
|
||
Index: `+this.err.index+`
|
||
Ln: `+this.err.line+", Col: "+this.err.col+`
|
||
Input: `+this.err.str)},c.prototype[Symbol.iterator]=function(){return this._index=0,{next:(function(){var l=this.nextToken();return l.type===a.TokenType.EOF?{done:!0,value:null}:{done:!1,value:l}}).bind(this)}},c}();n.XMLStringLexer=s},function(r,n,i){var o=i(39);r.exports=new o({include:[i(182)]})},function(r,n,i){var o=i(39);r.exports=new o({include:[i(113)],implicit:[i(289),i(290),i(291),i(292)]})},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(91),a=i(1),s=i(3),c=i(77),l=i(109);function f(g,p){var v=d(g===void 0||u(g)?g:o.DefaultBuilderOptions),y=u(g)?p:g,m=l.createDocument();h(m,v);var w=new c.XMLBuilderImpl(m);return y!==void 0&&w.ele(y),w}function u(g){if(!a.isPlainObject(g))return!1;for(var p in g)if(g.hasOwnProperty(p)&&!o.XMLBuilderOptionKeys.has(p))return!1;return!0}function d(g){g===void 0&&(g={});var p=a.applyDefaults(g,o.DefaultBuilderOptions);if(p.convert.att.length===0||p.convert.ins.length===0||p.convert.text.length===0||p.convert.cdata.length===0||p.convert.comment.length===0)throw new Error("JS object converter strings cannot be zero length.");return p}function h(g,p,v){var y=g;y._xmlBuilderOptions=p,y._isFragment=v}n.builder=function(g,p){var v=d(u(g)?g:o.DefaultBuilderOptions),y=s.Guard.isNode(g)||a.isArray(g)?g:p;if(y===void 0)throw new Error("Invalid arguments.");if(a.isArray(y)){for(var m=[],w=0;w<y.length;w++){var x=new c.XMLBuilderImpl(y[w]);x.set(v),m.push(x)}return m}var C=new c.XMLBuilderImpl(y);return C.set(v),C},n.create=f,n.fragment=function(g,p){var v=d(g===void 0||u(g)?g:o.DefaultBuilderOptions),y=u(g)?p:g,m=l.createDocument();h(m,v,!0);var w=new c.XMLBuilderImpl(m.createDocumentFragment());return y!==void 0&&w.ele(y),w},n.convert=function(g,p,v){var y,m,w;return u(g)&&p!==void 0?(y=g,m=p,w=v):(y=o.DefaultBuilderOptions,m=g,w=p||void 0),f(y,m).end(w)}},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(77);n.builder=o.builder,n.create=o.create,n.fragment=o.fragment,n.convert=o.convert,n.createCB=o.createCB,n.fragmentCB=o.fragmentCB},function(r,n,i){i(31),i(32),i(33),i(191),i(192),i(194),i(64),i(19),i(198),i(199),i(89),i(201),i(65),i(20),i(66),i(22),i(23);var o=this&&this.__read||function(y,m){var w=typeof Symbol=="function"&&y[Symbol.iterator];if(!w)return y;var x,C,S=w.call(y),T=[];try{for(;(m===void 0||m-- >0)&&!(x=S.next()).done;)T.push(x.value)}catch(_){C={error:_}}finally{try{x&&!x.done&&(w=S.return)&&w.call(S)}finally{if(C)throw C.error}}return T},a=this&&this.__values||function(y){var m=typeof Symbol=="function"&&Symbol.iterator,w=m&&y[m],x=0;if(w)return w.call(y);if(y&&typeof y.length=="number")return{next:function(){return y&&x>=y.length&&(y=void 0),{value:y&&y[x++],done:!y}}};throw new TypeError(m?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var s=i(91),c=i(1),l=i(217),f=i(2),u=i(3),d=i(0),h=i(109),g=i(7),p=i(276),v=function(){function y(m){this._domNode=m}return Object.defineProperty(y.prototype,"node",{get:function(){return this._domNode},enumerable:!0,configurable:!0}),Object.defineProperty(y.prototype,"options",{get:function(){return this._options},enumerable:!0,configurable:!0}),y.prototype.set=function(m){return this._options=c.applyDefaults(c.applyDefaults(this._options,m,!0),s.DefaultBuilderOptions),this},y.prototype.ele=function(m,w,x){var C,S,T,_,E,b;if(c.isObject(m))return new p.ObjectReader(this._options).parse(this,m);if(m!==null&&/^\s*</.test(m))return new p.XMLReader(this._options).parse(this,m);if(m!==null&&/^\s*[\{\[]/.test(m))return new p.JSONReader(this._options).parse(this,m);if(m!==null&&/^(\s*|(#.*)|(%.*))*---/.test(m))return new p.YAMLReader(this._options).parse(this,m);if((m===null||c.isString(m))&&c.isString(w))_=(C=o([m,w,x],3))[0],E=C[1],b=C[2];else{if(m===null)throw new Error("Element name cannot be null. "+this._debugInfo());_=(S=o([void 0,m,c.isObject(w)?w:void 0],3))[0],E=S[1],b=S[2]}if(b&&(b=c.getValue(b)),_=(T=o(this._extractNamespace(h.sanitizeInput(_,this._options.invalidCharReplacement),h.sanitizeInput(E,this._options.invalidCharReplacement),!0),2))[0],E=T[1],_===void 0){var D=o(d.namespace_extractQName(E),1)[0];_=this.node.lookupNamespaceURI(D)}var I=_!=null?this._doc.createElementNS(_,E):this._doc.createElement(E);this.node.appendChild(I);var P=new y(I),O=this._doc.doctype;if(I===this._doc.documentElement&&O!==null){var L=this._doc.implementation.createDocumentType(this._doc.documentElement.tagName,O.publicId,O.systemId);this._doc.replaceChild(L,O)}return b&&!c.isEmpty(b)&&P.att(b),P},y.prototype.remove=function(){var m=this.up();return m.node.removeChild(this.node),m},y.prototype.att=function(m,w,x){var C,S,T,_,E,b,D=this;if(c.isMap(m)||c.isObject(m))return c.forEachObject(m,function(A,F){return D.att(A,F)},this),this;if(m!=null&&(m=c.getValue(m+"")),w!=null&&(w=c.getValue(w+"")),x!=null&&(x=c.getValue(x+"")),m!==null&&!c.isString(m)||!c.isString(w)||x!==null&&!c.isString(x)){if(!c.isString(m)||w!=null&&!c.isString(w))throw new Error("Attribute name and value not specified. "+this._debugInfo());_=(S=o([void 0,m,w],3))[0],E=S[1],b=S[2]}else _=(C=o([m,w,x],3))[0],E=C[1],b=C[2];if(this._options.keepNullAttributes&&b==null)b="";else if(b==null)return this;if(!u.Guard.isElementNode(this.node))throw new Error("An attribute can only be assigned to an element node.");var I=this.node;_=(T=o(this._extractNamespace(_,E,!1),2))[0],E=T[1],E=h.sanitizeInput(E,this._options.invalidCharReplacement),_=h.sanitizeInput(_,this._options.invalidCharReplacement),b=h.sanitizeInput(b,this._options.invalidCharReplacement);var P=o(d.namespace_extractQName(E),2),O=P[0],L=P[1],B=o(d.namespace_extractQName(I.prefix?I.prefix+":"+I.localName:I.localName),1)[0],H=null;return O==="xmlns"?(_=g.namespace.XMLNS,I.namespaceURI===null&&B===L&&(H=b)):O===null&&L==="xmlns"&&B===null&&(_=g.namespace.XMLNS,H=b),H!==null&&(this._updateNamespace(H),I=this.node),_!==void 0?I.setAttributeNS(_,E,b):I.setAttribute(E,b),this},y.prototype.removeAtt=function(m,w){var x,C,S=this;if(!u.Guard.isElementNode(this.node))throw new Error("An attribute can only be removed from an element node.");if(m=c.getValue(m),w!==void 0&&(w=c.getValue(w)),m!==null&&w===void 0)C=m;else{if(m!==null&&!c.isString(m)||w===void 0)throw new Error("Attribute namespace must be a string. "+this._debugInfo());x=m,C=w}return c.isArray(C)||c.isSet(C)?c.forEachArray(C,function(T){return x===void 0?S.removeAtt(T):S.removeAtt(x,T)},this):x!==void 0?(C=h.sanitizeInput(C,this._options.invalidCharReplacement),x=h.sanitizeInput(x,this._options.invalidCharReplacement),this.node.removeAttributeNS(x,C)):(C=h.sanitizeInput(C,this._options.invalidCharReplacement),this.node.removeAttribute(C)),this},y.prototype.txt=function(m){if(m==null){if(!this._options.keepNullNodes)return this;m=""}var w=this._doc.createTextNode(h.sanitizeInput(m,this._options.invalidCharReplacement));return this.node.appendChild(w),this},y.prototype.com=function(m){if(m==null){if(!this._options.keepNullNodes)return this;m=""}var w=this._doc.createComment(h.sanitizeInput(m,this._options.invalidCharReplacement));return this.node.appendChild(w),this},y.prototype.dat=function(m){if(m==null){if(!this._options.keepNullNodes)return this;m=""}var w=this._doc.createCDATASection(h.sanitizeInput(m,this._options.invalidCharReplacement));return this.node.appendChild(w),this},y.prototype.ins=function(m,w){var x=this;if(w===void 0&&(w=""),w==null){if(!this._options.keepNullNodes)return this;w=""}if(c.isArray(m)||c.isSet(m))c.forEachArray(m,function(S){var T=(S+="").indexOf(" "),_=T===-1?S:S.substr(0,T),E=T===-1?"":S.substr(T+1);x.ins(_,E)},this);else if(c.isMap(m)||c.isObject(m))c.forEachObject(m,function(S,T){return x.ins(S,T)},this);else{var C=this._doc.createProcessingInstruction(h.sanitizeInput(m,this._options.invalidCharReplacement),h.sanitizeInput(w,this._options.invalidCharReplacement));this.node.appendChild(C)}return this},y.prototype.dec=function(m){return this._options.version=m.version||"1.0",this._options.encoding=m.encoding,this._options.standalone=m.standalone,this},y.prototype.dtd=function(m){var w=h.sanitizeInput(m&&m.name||(this._doc.documentElement?this._doc.documentElement.tagName:"ROOT"),this._options.invalidCharReplacement),x=h.sanitizeInput(m&&m.pubID||"",this._options.invalidCharReplacement),C=h.sanitizeInput(m&&m.sysID||"",this._options.invalidCharReplacement);if(this._doc.documentElement!==null&&w!==this._doc.documentElement.tagName)throw new Error("DocType name does not match document element name.");var S=this._doc.implementation.createDocumentType(w,x,C);return this._doc.doctype!==null?this._doc.replaceChild(S,this._doc.doctype):this._doc.insertBefore(S,this._doc.documentElement),this},y.prototype.import=function(m){var w,x,C=this._domNode,S=this._doc,T=m.node;if(u.Guard.isDocumentNode(T)){var _=T.documentElement;if(_===null)throw new Error("Imported document has no document element node. "+this._debugInfo());var E=S.importNode(_,!0);C.appendChild(E);var b=o(d.namespace_extractQName(E.prefix?E.prefix+":"+E.localName:E.localName),1)[0],D=C.lookupNamespaceURI(b);new y(E)._updateNamespace(D)}else if(u.Guard.isDocumentFragmentNode(T))try{for(var I=a(T.childNodes),P=I.next();!P.done;P=I.next()){var O=P.value;E=S.importNode(O,!0),C.appendChild(E),u.Guard.isElementNode(E)&&(b=o(d.namespace_extractQName(E.prefix?E.prefix+":"+E.localName:E.localName),1)[0],D=C.lookupNamespaceURI(b),new y(E)._updateNamespace(D))}}catch(L){w={error:L}}finally{try{P&&!P.done&&(x=I.return)&&x.call(I)}finally{if(w)throw w.error}}else E=S.importNode(T,!0),C.appendChild(E),u.Guard.isElementNode(E)&&(b=o(d.namespace_extractQName(E.prefix?E.prefix+":"+E.localName:E.localName),1)[0],D=C.lookupNamespaceURI(b),new y(E)._updateNamespace(D));return this},y.prototype.doc=function(){if(this._doc._isFragment){for(var m=this.node;m&&m.nodeType!==f.NodeType.DocumentFragment;)m=m.parentNode;if(m===null)throw new Error("Node has no parent node while searching for document fragment ancestor. "+this._debugInfo());return new y(m)}return new y(this._doc)},y.prototype.root=function(){var m=this._doc.documentElement;if(!m)throw new Error("Document root element is null. "+this._debugInfo());return new y(m)},y.prototype.up=function(){var m=this._domNode.parentNode;if(!m)throw new Error("Parent node is null. "+this._debugInfo());return new y(m)},y.prototype.prev=function(){var m=this._domNode.previousSibling;if(!m)throw new Error("Previous sibling node is null. "+this._debugInfo());return new y(m)},y.prototype.next=function(){var m=this._domNode.nextSibling;if(!m)throw new Error("Next sibling node is null. "+this._debugInfo());return new y(m)},y.prototype.first=function(){var m=this._domNode.firstChild;if(!m)throw new Error("First child node is null. "+this._debugInfo());return new y(m)},y.prototype.last=function(){var m=this._domNode.lastChild;if(!m)throw new Error("Last child node is null. "+this._debugInfo());return new y(m)},y.prototype.each=function(m,w,x,C){w===void 0&&(w=!1),x===void 0&&(x=!1);for(var S=this._getFirstDescendantNode(this._domNode,w,x);S[0];){var T=this._getNextDescendantNode(this._domNode,S[0],x,S[1],S[2]);m.call(C,new y(S[0]),S[1],S[2]),S=T}return this},y.prototype.map=function(m,w,x,C){w===void 0&&(w=!1),x===void 0&&(x=!1);var S=[];return this.each(function(T,_,E){return S.push(m.call(C,T,_,E))},w,x),S},y.prototype.reduce=function(m,w,x,C,S){x===void 0&&(x=!1),C===void 0&&(C=!1);var T=w;return this.each(function(_,E,b){return T=m.call(S,T,_,E,b)},x,C),T},y.prototype.find=function(m,w,x,C){w===void 0&&(w=!1),x===void 0&&(x=!1);for(var S=this._getFirstDescendantNode(this._domNode,w,x);S[0];){var T=new y(S[0]);if(m.call(C,T,S[1],S[2]))return T;S=this._getNextDescendantNode(this._domNode,S[0],x,S[1],S[2])}},y.prototype.filter=function(m,w,x,C){w===void 0&&(w=!1),x===void 0&&(x=!1);var S=[];return this.each(function(T,_,E){m.call(C,T,_,E)&&S.push(T)},w,x),S},y.prototype.every=function(m,w,x,C){w===void 0&&(w=!1),x===void 0&&(x=!1);for(var S=this._getFirstDescendantNode(this._domNode,w,x);S[0];){var T=new y(S[0]);if(!m.call(C,T,S[1],S[2]))return!1;S=this._getNextDescendantNode(this._domNode,S[0],x,S[1],S[2])}return!0},y.prototype.some=function(m,w,x,C){w===void 0&&(w=!1),x===void 0&&(x=!1);for(var S=this._getFirstDescendantNode(this._domNode,w,x);S[0];){var T=new y(S[0]);if(m.call(C,T,S[1],S[2]))return!0;S=this._getNextDescendantNode(this._domNode,S[0],x,S[1],S[2])}return!1},y.prototype.toArray=function(m,w){m===void 0&&(m=!1),w===void 0&&(w=!1);var x=[];return this.each(function(C){return x.push(C)},m,w),x},y.prototype.toString=function(m){return(m=m||{}).format===void 0&&(m.format="xml"),this._serialize(m)},y.prototype.toObject=function(m){return(m=m||{}).format===void 0&&(m.format="object"),this._serialize(m)},y.prototype.end=function(m){return(m=m||{}).format===void 0&&(m.format="xml"),this.doc()._serialize(m)},y.prototype._getFirstDescendantNode=function(m,w,x){return w?[this._domNode,0,0]:x?this._getNextDescendantNode(m,m,x,0,0):[this._domNode.firstChild,0,1]},y.prototype._getNextDescendantNode=function(m,w,x,C,S){if(!x)return m===w?[w.firstChild,0,S+1]:[w.nextSibling,C+1,S];if(w.firstChild)return[w.firstChild,0,S+1];if(w===m)return[null,-1,-1];if(w.nextSibling)return[w.nextSibling,C+1,S];for(var T=w.parentNode;T&&T!==m;){if(T.nextSibling)return[T.nextSibling,d.tree_index(T.nextSibling),S-1];T=T.parentNode,S--}return[null,-1,-1]},y.prototype._serialize=function(m){if(m.format==="xml")return new l.XMLWriter(this._options,m).serialize(this.node);if(m.format==="map")return new l.MapWriter(this._options,m).serialize(this.node);if(m.format==="object")return new l.ObjectWriter(this._options,m).serialize(this.node);if(m.format==="json")return new l.JSONWriter(this._options,m).serialize(this.node);if(m.format==="yaml")return new l.YAMLWriter(this._options,m).serialize(this.node);throw new Error("Invalid writer format: "+m.format+". "+this._debugInfo())},y.prototype._extractNamespace=function(m,w,x){var C=w.indexOf("@");if(C>0&&(m===void 0&&(m=w.slice(C+1)),w=w.slice(0,C)),m===void 0)m=x?this._options.defaultNamespace.ele:this._options.defaultNamespace.att;else if(m!==null&&m[0]==="@"){var S=m.slice(1);if((m=this._options.namespaceAlias[S])===void 0)throw new Error("Namespace alias `"+S+"` is not defined. "+this._debugInfo())}return[m,w]},y.prototype._updateNamespace=function(m){var w,x,C,S,T=this._domNode;if(u.Guard.isElementNode(T)&&m!==null&&T.namespaceURI!==m){var _=o(d.namespace_extractQName(T.prefix?T.prefix+":"+T.localName:T.localName),2),E=_[0],b=_[1],D=d.create_element(this._doc,b,m,E);try{for(var I=a(T.attributes),P=I.next();!P.done;P=I.next()){var O=P.value,L=O.prefix?O.prefix+":"+O.localName:O.localName,B=o(d.namespace_extractQName(L),1)[0],H=O.namespaceURI;H===null&&B!==null&&(H=T.lookupNamespaceURI(B)),H===null?D.setAttribute(L,O.value):D.setAttributeNS(H,L,O.value)}}catch(Se){w={error:Se}}finally{try{P&&!P.done&&(x=I.return)&&x.call(I)}finally{if(w)throw w.error}}var A=T.parentNode;if(A===null)throw new Error("Parent node is null."+this._debugInfo());A.replaceChild(D,T),this._domNode=D;try{for(var F=a(T.childNodes),G=F.next();!G.done;G=F.next()){var X=G.value.cloneNode(!0);if(D.appendChild(X),u.Guard.isElementNode(X)){var ee=o(d.namespace_extractQName(X.prefix?X.prefix+":"+X.localName:X.localName),1)[0],ce=D.lookupNamespaceURI(ee);new y(X)._updateNamespace(ce)}}}catch(Se){C={error:Se}}finally{try{G&&!G.done&&(S=F.return)&&S.call(F)}finally{if(C)throw C.error}}}},Object.defineProperty(y.prototype,"_doc",{get:function(){var m=this.node;if(u.Guard.isDocumentNode(m))return m;var w=m.ownerDocument;if(!w)throw new Error("Owner document is null. "+this._debugInfo());return w},enumerable:!0,configurable:!0}),y.prototype._debugInfo=function(m){var w=this.node,x=w.parentNode;m=m||w.nodeName;var C=x?x.nodeName:"";return C?"node: <"+m+">, parent: <"+C+">":"node: <"+m+">"},Object.defineProperty(y.prototype,"_options",{get:function(){var m=this._doc;if(m._xmlBuilderOptions===void 0)throw new Error("Builder options is not set.");return m._xmlBuilderOptions},set:function(m){this._doc._xmlBuilderOptions=m},enumerable:!0,configurable:!0}),y}();n.XMLBuilderImpl=v},function(r,n,i){var o=i(11),a=i(117),s=o.WeakMap;r.exports=typeof s=="function"&&/native code/.test(a(s))},function(r,n,i){var o=i(46),a=i(82),s=i(85),c=i(18);r.exports=o("Reflect","ownKeys")||function(l){var f=a.f(c(l)),u=s.f;return u?f.concat(u(l)):f}},function(r,n,i){var o=i(16),a=i(15),s=i(18),c=i(61);r.exports=o?Object.defineProperties:function(l,f){s(l);for(var u,d=c(f),h=d.length,g=0;h>g;)a.f(l,u=d[g++],f[u]);return l}},function(r,n,i){var o=i(46);r.exports=o("document","documentElement")},function(r,n,i){var o=i(24),a=i(82).f,s={}.toString,c=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];r.exports.f=function(l){return c&&s.call(l)=="[object Window]"?function(f){try{return a(f)}catch{return c.slice()}}(l):a(o(l))}},function(r,n,i){var o=i(4),a=i(36).every,s=i(48),c=i(28),l=s("every"),f=c("every");o({target:"Array",proto:!0,forced:!l||!f},{every:function(u){return a(this,u,arguments.length>1?arguments[1]:void 0)}})},function(r,n,i){var o=i(4),a=i(36).filter,s=i(63),c=i(28),l=s("filter"),f=c("filter");o({target:"Array",proto:!0,forced:!l||!f},{filter:function(u){return a(this,u,arguments.length>1?arguments[1]:void 0)}})},function(r,n,i){var o=i(46);r.exports=o("navigator","userAgent")||""},function(r,n,i){var o=i(4),a=i(36).find,s=i(130),c=i(28),l=!0,f=c("find");"find"in[]&&Array(1).find(function(){l=!1}),o({target:"Array",proto:!0,forced:l||!f},{find:function(u){return a(this,u,arguments.length>1?arguments[1]:void 0)}}),s("find")},function(r,n,i){var o=i(131).IteratorPrototype,a=i(60),s=i(40),c=i(62),l=i(49),f=function(){return this};r.exports=function(u,d,h){var g=d+" Iterator";return u.prototype=a(o,{next:s(1,h)}),c(u,g,!1,!0),l[g]=f,u}},function(r,n,i){var o=i(8);r.exports=!o(function(){function a(){}return a.prototype.constructor=null,Object.getPrototypeOf(new a)!==a.prototype})},function(r,n,i){var o=i(13);r.exports=function(a){if(!o(a)&&a!==null)throw TypeError("Can't set "+String(a)+" as a prototype");return a}},function(r,n,i){var o=i(4),a=i(36).map,s=i(63),c=i(28),l=s("map"),f=c("map");o({target:"Array",proto:!0,forced:!l||!f},{map:function(u){return a(this,u,arguments.length>1?arguments[1]:void 0)}})},function(r,n,i){var o=i(4),a=i(200).left,s=i(48),c=i(28),l=s("reduce"),f=c("reduce",{1:0});o({target:"Array",proto:!0,forced:!l||!f},{reduce:function(u){return a(this,u,arguments.length,arguments.length>1?arguments[1]:void 0)}})},function(r,n,i){var o=i(127),a=i(27),s=i(41),c=i(26),l=function(f){return function(u,d,h,g){o(d);var p=a(u),v=s(p),y=c(p.length),m=f?y-1:0,w=f?-1:1;if(h<2)for(;;){if(m in v){g=v[m],m+=w;break}if(m+=w,f?m<0:y<=m)throw TypeError("Reduce of empty array with no initial value")}for(;f?m>=0:y>m;m+=w)m in v&&(g=d(g,v[m],m,p));return g}};r.exports={left:l(!1),right:l(!0)}},function(r,n,i){var o=i(4),a=i(36).some,s=i(48),c=i(28),l=s("some"),f=c("some");o({target:"Array",proto:!0,forced:!l||!f},{some:function(u){return a(this,u,arguments.length>1?arguments[1]:void 0)}})},function(r,n,i){var o=i(90),a=i(135);r.exports=o?{}.toString:function(){return"[object "+a(this)+"]"}},function(r,n){r.exports={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}},function(r,n,i){var o=i(8);r.exports=!o(function(){return Object.isExtensible(Object.preventExtensions({}))})},function(r,n,i){var o=i(5),a=i(49),s=o("iterator"),c=Array.prototype;r.exports=function(l){return l!==void 0&&(a.Array===l||c[s]===l)}},function(r,n,i){var o=i(135),a=i(49),s=i(5)("iterator");r.exports=function(c){if(c!=null)return c[s]||c["@@iterator"]||a[o(c)]}},function(r,n,i){var o=i(18);r.exports=function(a,s,c,l){try{return l?s(o(c)[0],c[1]):s(c)}catch(u){var f=a.return;throw f!==void 0&&o(f.call(a)),u}}},function(r,n,i){var o=i(5)("iterator"),a=!1;try{var s=0,c={next:function(){return{done:!!s++}},return:function(){a=!0}};c[o]=function(){return this},Array.from(c,function(){throw 2})}catch{}r.exports=function(l,f){if(!f&&!a)return!1;var u=!1;try{var d={};d[o]=function(){return{next:function(){return{done:u=!0}}}},l(d)}catch{}return u}},function(r,n,i){var o=i(13),a=i(133);r.exports=function(s,c,l){var f,u;return a&&typeof(f=c.constructor)=="function"&&f!==l&&o(u=f.prototype)&&u!==l.prototype&&a(s,u),s}},function(r,n,i){var o=i(25);r.exports=function(a,s,c){for(var l in s)o(a,l,s[l],c);return a}},function(r,n,i){var o=i(46),a=i(15),s=i(5),c=i(16),l=s("species");r.exports=function(f){var u=o(f),d=a.f;c&&u&&!u[l]&&d(u,l,{configurable:!0,get:function(){return this}})}},function(r,n,i){var o=this&&this.__generator||function(c,l){var f,u,d,h,g={label:0,sent:function(){if(1&d[0])throw d[1];return d[1]},trys:[],ops:[]};return h={next:p(0),throw:p(1),return:p(2)},typeof Symbol=="function"&&(h[Symbol.iterator]=function(){return this}),h;function p(v){return function(y){return function(m){if(f)throw new TypeError("Generator is already executing.");for(;g;)try{if(f=1,u&&(d=2&m[0]?u.return:m[0]?u.throw||((d=u.return)&&d.call(u),0):u.next)&&!(d=d.call(u,m[1])).done)return d;switch(u=0,d&&(m=[2&m[0],d.value]),m[0]){case 0:case 1:d=m;break;case 4:return g.label++,{value:m[1],done:!1};case 5:g.label++,u=m[1],m=[0];continue;case 7:m=g.ops.pop(),g.trys.pop();continue;default:if(d=g.trys,!((d=d.length>0&&d[d.length-1])||m[0]!==6&&m[0]!==2)){g=0;continue}if(m[0]===3&&(!d||m[1]>d[0]&&m[1]<d[3])){g.label=m[1];break}if(m[0]===6&&g.label<d[1]){g.label=d[1],d=m;break}if(d&&g.label<d[2]){g.label=d[2],g.ops.push(m);break}d[2]&&g.ops.pop(),g.trys.pop();continue}m=l.call(c,g)}catch(w){m=[6,w],u=0}finally{f=d=0}if(5&m[0])throw m[1];return{value:m[0]?m[1]:void 0,done:!0}}([v,y])}}},a=this&&this.__values||function(c){var l=typeof Symbol=="function"&&Symbol.iterator,f=l&&c[l],u=0;if(f)return f.call(c);if(c&&typeof c.length=="number")return{next:function(){return c&&u>=c.length&&(c=void 0),{value:c&&c[u++],done:!c}}};throw new TypeError(l?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var s=function(){function c(l){l===void 0&&(l=1e3),this._items=new Set,this._limit=l}return c.prototype.add=function(l){if(this._items.add(l),this._items.size>this._limit){var f=this._items.values().next();f.done||this._items.delete(f.value)}return this},c.prototype.delete=function(l){return this._items.delete(l)},c.prototype.has=function(l){return this._items.has(l)},c.prototype.clear=function(){this._items.clear()},Object.defineProperty(c.prototype,"size",{get:function(){return this._items.size},enumerable:!0,configurable:!0}),c.prototype.forEach=function(l,f){var u=this;this._items.forEach(function(d){return l.call(f,d,d,u)})},c.prototype.keys=function(){return o(this,function(l){switch(l.label){case 0:return[5,a(this._items.keys())];case 1:return l.sent(),[2]}})},c.prototype.values=function(){return o(this,function(l){switch(l.label){case 0:return[5,a(this._items.values())];case 1:return l.sent(),[2]}})},c.prototype.entries=function(){return o(this,function(l){switch(l.label){case 0:return[5,a(this._items.entries())];case 1:return l.sent(),[2]}})},c.prototype[Symbol.iterator]=function(){return o(this,function(l){switch(l.label){case 0:return[5,a(this._items)];case 1:return l.sent(),[2]}})},Object.defineProperty(c.prototype,Symbol.toStringTag,{get:function(){return"FixedSizeSet"},enumerable:!0,configurable:!0}),c}();n.FixedSizeSet=s},function(r,n,i){var o=this&&this.__generator||function(c,l){var f,u,d,h,g={label:0,sent:function(){if(1&d[0])throw d[1];return d[1]},trys:[],ops:[]};return h={next:p(0),throw:p(1),return:p(2)},typeof Symbol=="function"&&(h[Symbol.iterator]=function(){return this}),h;function p(v){return function(y){return function(m){if(f)throw new TypeError("Generator is already executing.");for(;g;)try{if(f=1,u&&(d=2&m[0]?u.return:m[0]?u.throw||((d=u.return)&&d.call(u),0):u.next)&&!(d=d.call(u,m[1])).done)return d;switch(u=0,d&&(m=[2&m[0],d.value]),m[0]){case 0:case 1:d=m;break;case 4:return g.label++,{value:m[1],done:!1};case 5:g.label++,u=m[1],m=[0];continue;case 7:m=g.ops.pop(),g.trys.pop();continue;default:if(d=g.trys,!((d=d.length>0&&d[d.length-1])||m[0]!==6&&m[0]!==2)){g=0;continue}if(m[0]===3&&(!d||m[1]>d[0]&&m[1]<d[3])){g.label=m[1];break}if(m[0]===6&&g.label<d[1]){g.label=d[1],d=m;break}if(d&&g.label<d[2]){g.label=d[2],g.ops.push(m);break}d[2]&&g.ops.pop(),g.trys.pop();continue}m=l.call(c,g)}catch(w){m=[6,w],u=0}finally{f=d=0}if(5&m[0])throw m[1];return{value:m[0]?m[1]:void 0,done:!0}}([v,y])}}},a=this&&this.__values||function(c){var l=typeof Symbol=="function"&&Symbol.iterator,f=l&&c[l],u=0;if(f)return f.call(c);if(c&&typeof c.length=="number")return{next:function(){return c&&u>=c.length&&(c=void 0),{value:c&&c[u++],done:!c}}};throw new TypeError(l?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var s=function(){function c(l){l===void 0&&(l=1e3),this._items=new Map,this._limit=l}return c.prototype.get=function(l){return this._items.get(l)},c.prototype.set=function(l,f){if(this._items.set(l,f),this._items.size>this._limit){var u=this._items.keys().next();u.done||this._items.delete(u.value)}},c.prototype.delete=function(l){return this._items.delete(l)},c.prototype.has=function(l){return this._items.has(l)},c.prototype.clear=function(){this._items.clear()},Object.defineProperty(c.prototype,"size",{get:function(){return this._items.size},enumerable:!0,configurable:!0}),c.prototype.forEach=function(l,f){this._items.forEach(function(u,d){return l.call(f,d,u)})},c.prototype.keys=function(){return o(this,function(l){switch(l.label){case 0:return[5,a(this._items.keys())];case 1:return l.sent(),[2]}})},c.prototype.values=function(){return o(this,function(l){switch(l.label){case 0:return[5,a(this._items.values())];case 1:return l.sent(),[2]}})},c.prototype.entries=function(){return o(this,function(l){switch(l.label){case 0:return[5,a(this._items.entries())];case 1:return l.sent(),[2]}})},c.prototype[Symbol.iterator]=function(){return o(this,function(l){switch(l.label){case 0:return[5,a(this._items)];case 1:return l.sent(),[2]}})},Object.defineProperty(c.prototype,Symbol.toStringTag,{get:function(){return"ObjectCache"},enumerable:!0,configurable:!0}),c}();n.ObjectCache=s},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function a(s){s===void 0&&(s=1e3),this._items=new Map,this._limit=s}return a.prototype.check=function(s,c){if(this._items.get(s)===c)return!0;if(this._items.get(c)===s)return!1;var l=Math.random()<.5;if(l?this._items.set(s,c):this._items.set(c,s),this._items.size>this._limit){var f=this._items.keys().next();f.done||this._items.delete(f.value)}return l},a}();n.CompareCache=o},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function a(s){this._initialized=!1,this._value=void 0,this._initFunc=s}return Object.defineProperty(a.prototype,"value",{get:function(){return this._initialized||(this._value=this._initFunc(),this._initialized=!0),this._value},enumerable:!0,configurable:!0}),a}();n.Lazy=o},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function a(s){this._pointer=0,this._chars=Array.from(s),this._length=this._chars.length}return Object.defineProperty(a.prototype,"eof",{get:function(){return this._pointer>=this._length},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"length",{get:function(){return this._length},enumerable:!0,configurable:!0}),a.prototype.codePoint=function(){if(this._codePoint===void 0)if(this.eof)this._codePoint=-1;else{var s=this._chars[this._pointer].codePointAt(0);this._codePoint=s!==void 0?s:-1}return this._codePoint},a.prototype.c=function(){return this._c===void 0&&(this._c=this.eof?"":this._chars[this._pointer]),this._c},a.prototype.remaining=function(){return this._remaining===void 0&&(this._remaining=this.eof?"":this._chars.slice(this._pointer+1).join("")),this._remaining},a.prototype.substring=function(){return this._substring===void 0&&(this._substring=this.eof?"":this._chars.slice(this._pointer).join("")),this._substring},Object.defineProperty(a.prototype,"pointer",{get:function(){return this._pointer},set:function(s){s!==this._pointer&&(this._pointer=s,this._codePoint=void 0,this._c=void 0,this._remaining=void 0,this._substring=void 0)},enumerable:!0,configurable:!0}),a}();n.StringWalker=o},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(218);n.MapWriter=o.MapWriter;var a=i(258);n.XMLWriter=a.XMLWriter;var s=i(67);n.ObjectWriter=s.ObjectWriter;var c=i(260);n.JSONWriter=c.JSONWriter;var l=i(261);n.YAMLWriter=l.YAMLWriter},function(r,n,i){i(19),i(219),i(20),i(22),i(23);var o,a=this&&this.__extends||(o=function(f,u){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,h){d.__proto__=h}||function(d,h){for(var g in h)h.hasOwnProperty(g)&&(d[g]=h[g])})(f,u)},function(f,u){function d(){this.constructor=f}o(f,u),f.prototype=u===null?Object.create(u):(d.prototype=u.prototype,new d)});Object.defineProperty(n,"__esModule",{value:!0});var s=i(1),c=i(67),l=function(f){function u(d,h){var g=f.call(this,d)||this;return g._writerOptions=s.applyDefaults(h,{format:"map",wellFormed:!1,group:!1,verbose:!1}),g}return a(u,f),u.prototype.serialize=function(d){var h=s.applyDefaults(this._writerOptions,{format:"object",wellFormed:!1,verbose:!1}),g=new c.ObjectWriter(this._builderOptions,h).serialize(d);return this._convertObject(g)},u.prototype._convertObject=function(d){if(s.isArray(d)){for(var h=0;h<d.length;h++)d[h]=this._convertObject(d[h]);return d}if(s.isObject(d)){var g=new Map;for(var p in d)g.set(p,this._convertObject(d[p]));return g}return d},u}(i(50).BaseWriter);n.MapWriter=l},function(r,n,i){var o=i(139),a=i(143);r.exports=o("Map",function(s){return function(){return s(this,arguments.length?arguments[0]:void 0)}},a)},function(r,n,i){var o=i(4),a=i(8),s=i(59),c=i(13),l=i(27),f=i(26),u=i(134),d=i(128),h=i(63),g=i(5),p=i(129),v=g("isConcatSpreadable"),y=p>=51||!a(function(){var x=[];return x[v]=!1,x.concat()[0]!==x}),m=h("concat"),w=function(x){if(!c(x))return!1;var C=x[v];return C!==void 0?!!C:s(x)};o({target:"Array",proto:!0,forced:!y||!m},{concat:function(x){var C,S,T,_,E,b=l(this),D=d(b,0),I=0;for(C=-1,T=arguments.length;C<T;C++)if(w(E=C===-1?b:arguments[C])){if(I+(_=f(E.length))>9007199254740991)throw TypeError("Maximum allowed index exceeded");for(S=0;S<_;S++,I++)S in E&&u(D,I,E[S])}else{if(I>=9007199254740991)throw TypeError("Maximum allowed index exceeded");u(D,I++,E)}return D.length=I,D}})},function(r,n,i){var o=i(8);function a(s,c){return RegExp(s,c)}n.UNSUPPORTED_Y=o(function(){var s=a("a","y");return s.lastIndex=2,s.exec("abcd")!=null}),n.BROKEN_CARET=o(function(){var s=a("^r","gy");return s.lastIndex=2,s.exec("str")!=null})},function(r,n,i){var o=i(223);r.exports=function(a){if(o(a))throw TypeError("The method doesn't accept regular expressions");return a}},function(r,n,i){var o=i(13),a=i(42),s=i(5)("match");r.exports=function(c){var l;return o(c)&&((l=c[s])!==void 0?!!l:a(c)=="RegExp")}},function(r,n,i){var o=i(5)("match");r.exports=function(a){var s=/./;try{"/./"[a](s)}catch{try{return s[o]=!1,"/./"[a](s)}catch{}}return!1}},function(r,n,i){i(68);var o=i(25),a=i(8),s=i(5),c=i(93),l=i(21),f=s("species"),u=!a(function(){var v=/./;return v.exec=function(){var y=[];return y.groups={a:"7"},y},"".replace(v,"$<a>")!=="7"}),d="a".replace(/./,"$0")==="$0",h=s("replace"),g=!!/./[h]&&/./[h]("a","$0")==="",p=!a(function(){var v=/(?:)/,y=v.exec;v.exec=function(){return y.apply(this,arguments)};var m="ab".split(v);return m.length!==2||m[0]!=="a"||m[1]!=="b"});r.exports=function(v,y,m,w){var x=s(v),C=!a(function(){var D={};return D[x]=function(){return 7},""[v](D)!=7}),S=C&&!a(function(){var D=!1,I=/a/;return v==="split"&&((I={}).constructor={},I.constructor[f]=function(){return I},I.flags="",I[x]=/./[x]),I.exec=function(){return D=!0,null},I[x](""),!D});if(!C||!S||v==="replace"&&(!u||!d||g)||v==="split"&&!p){var T=/./[x],_=m(x,""[v],function(D,I,P,O,L){return I.exec===c?C&&!L?{done:!0,value:T.call(I,P,O)}:{done:!0,value:D.call(P,I,O)}:{done:!1}},{REPLACE_KEEPS_$0:d,REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE:g}),E=_[0],b=_[1];o(String.prototype,v,E),o(RegExp.prototype,x,y==2?function(D,I){return b.call(D,this,I)}:function(D){return b.call(D,this)})}w&&l(RegExp.prototype[x],"sham",!0)}},function(r,n,i){var o=i(137).charAt;r.exports=function(a,s,c){return s+(c?o(a,s).length:1)}},function(r,n,i){var o=i(42),a=i(93);r.exports=function(s,c){var l=s.exec;if(typeof l=="function"){var f=l.call(s,c);if(typeof f!="object")throw TypeError("RegExp exec method returned something other than an Object or null");return f}if(o(s)!=="RegExp")throw TypeError("RegExp#exec called on incompatible receiver");return a.call(s,c)}},function(r,n,i){(function(o){Object.defineProperty(n,"__esModule",{value:!0});var a=i(96);n.forgivingBase64Encode=function(s){return o.from(s).toString("base64")},n.forgivingBase64Decode=function(s){return s===""?"":((s=s.replace(a.ASCIIWhiteSpace,"")).length%4==0&&(s.endsWith("==")?s=s.substr(0,s.length-2):s.endsWith("=")&&(s=s.substr(0,s.length-1))),s.length%4==1?null:/[0-9A-Za-z+/]/.test(s)?o.from(s,"base64").toString("utf8"):null)}}).call(this,i(145).Buffer)},function(r,n,i){n.byteLength=function(h){var g=u(h),p=g[0],v=g[1];return 3*(p+v)/4-v},n.toByteArray=function(h){var g,p,v=u(h),y=v[0],m=v[1],w=new s(function(S,T,_){return 3*(T+_)/4-_}(0,y,m)),x=0,C=m>0?y-4:y;for(p=0;p<C;p+=4)g=a[h.charCodeAt(p)]<<18|a[h.charCodeAt(p+1)]<<12|a[h.charCodeAt(p+2)]<<6|a[h.charCodeAt(p+3)],w[x++]=g>>16&255,w[x++]=g>>8&255,w[x++]=255&g;return m===2&&(g=a[h.charCodeAt(p)]<<2|a[h.charCodeAt(p+1)]>>4,w[x++]=255&g),m===1&&(g=a[h.charCodeAt(p)]<<10|a[h.charCodeAt(p+1)]<<4|a[h.charCodeAt(p+2)]>>2,w[x++]=g>>8&255,w[x++]=255&g),w},n.fromByteArray=function(h){for(var g,p=h.length,v=p%3,y=[],m=0,w=p-v;m<w;m+=16383)y.push(d(h,m,m+16383>w?w:m+16383));return v===1?(g=h[p-1],y.push(o[g>>2]+o[g<<4&63]+"==")):v===2&&(g=(h[p-2]<<8)+h[p-1],y.push(o[g>>10]+o[g>>4&63]+o[g<<2&63]+"=")),y.join("")};for(var o=[],a=[],s=typeof Uint8Array<"u"?Uint8Array:Array,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",l=0,f=c.length;l<f;++l)o[l]=c[l],a[c.charCodeAt(l)]=l;function u(h){var g=h.length;if(g%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var p=h.indexOf("=");return p===-1&&(p=g),[p,p===g?0:4-p%4]}function d(h,g,p){for(var v,y,m=[],w=g;w<p;w+=3)v=(h[w]<<16&16711680)+(h[w+1]<<8&65280)+(255&h[w+2]),m.push(o[(y=v)>>18&63]+o[y>>12&63]+o[y>>6&63]+o[63&y]);return m.join("")}a[45]=62,a[95]=63},function(r,n){n.read=function(i,o,a,s,c){var l,f,u=8*c-s-1,d=(1<<u)-1,h=d>>1,g=-7,p=a?c-1:0,v=a?-1:1,y=i[o+p];for(p+=v,l=y&(1<<-g)-1,y>>=-g,g+=u;g>0;l=256*l+i[o+p],p+=v,g-=8);for(f=l&(1<<-g)-1,l>>=-g,g+=s;g>0;f=256*f+i[o+p],p+=v,g-=8);if(l===0)l=1-h;else{if(l===d)return f?NaN:1/0*(y?-1:1);f+=Math.pow(2,s),l-=h}return(y?-1:1)*f*Math.pow(2,l-s)},n.write=function(i,o,a,s,c,l){var f,u,d,h=8*l-c-1,g=(1<<h)-1,p=g>>1,v=c===23?Math.pow(2,-24)-Math.pow(2,-77):0,y=s?0:l-1,m=s?1:-1,w=o<0||o===0&&1/o<0?1:0;for(o=Math.abs(o),isNaN(o)||o===1/0?(u=isNaN(o)?1:0,f=g):(f=Math.floor(Math.log(o)/Math.LN2),o*(d=Math.pow(2,-f))<1&&(f--,d*=2),(o+=f+p>=1?v/d:v*Math.pow(2,1-p))*d>=2&&(f++,d/=2),f+p>=g?(u=0,f=g):f+p>=1?(u=(o*d-1)*Math.pow(2,c),f+=p):(u=o*Math.pow(2,p-1)*Math.pow(2,c),f=0));c>=8;i[a+y]=255&u,y+=m,u/=256,c-=8);for(f=f<<c|u,h+=c;h>0;i[a+y]=255&f,y+=m,f/=256,h-=8);i[a+y-m]|=128*w}},function(r,n){var i={}.toString;r.exports=Array.isArray||function(o){return i.call(o)=="[object Array]"}},function(r,n,i){var o=this&&this.__values||function(c){var l=typeof Symbol=="function"&&Symbol.iterator,f=l&&c[l],u=0;if(f)return f.call(c);if(c&&typeof c.length=="number")return{next:function(){return c&&u>=c.length&&(c=void 0),{value:c&&c[u++],done:!c}}};throw new TypeError(l?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var a=i(1);function s(c){var l,f;if(c===null||a.isString(c)||a.isNumber(c))return c;if(a.isArray(c)){var u=new Array;try{for(var d=o(c),h=d.next();!h.done;h=d.next()){var g=h.value;u.push(s(g))}}catch(y){l={error:y}}finally{try{h&&!h.done&&(f=d.return)&&f.call(d)}finally{if(l)throw l.error}}return u}if(a.isObject(c)){u=new Map;for(var p in c)if(c.hasOwnProperty(p)){var v=c[p];u.set(p,s(v))}return u}return c}n.parseJSONFromBytes=function(c){var l=a.utf8Decode(c);return JSON.parse.call(void 0,l)},n.serializeJSONToBytes=function(c){var l=JSON.stringify.call(void 0,c);return a.utf8Encode(l)},n.parseJSONIntoInfraValues=function(c){return s(JSON.parse.call(void 0,c))},n.convertAJSONDerivedJavaScriptValueToAnInfraValue=s},function(r,n,i){var o=this&&this.__generator||function(f,u){var d,h,g,p,v={label:0,sent:function(){if(1&g[0])throw g[1];return g[1]},trys:[],ops:[]};return p={next:y(0),throw:y(1),return:y(2)},typeof Symbol=="function"&&(p[Symbol.iterator]=function(){return this}),p;function y(m){return function(w){return function(x){if(d)throw new TypeError("Generator is already executing.");for(;v;)try{if(d=1,h&&(g=2&x[0]?h.return:x[0]?h.throw||((g=h.return)&&g.call(h),0):h.next)&&!(g=g.call(h,x[1])).done)return g;switch(h=0,g&&(x=[2&x[0],g.value]),x[0]){case 0:case 1:g=x;break;case 4:return v.label++,{value:x[1],done:!1};case 5:v.label++,h=x[1],x=[0];continue;case 7:x=v.ops.pop(),v.trys.pop();continue;default:if(g=v.trys,!((g=g.length>0&&g[g.length-1])||x[0]!==6&&x[0]!==2)){v=0;continue}if(x[0]===3&&(!g||x[1]>g[0]&&x[1]<g[3])){v.label=x[1];break}if(x[0]===6&&v.label<g[1]){v.label=g[1],g=x;break}if(g&&v.label<g[2]){v.label=g[2],v.ops.push(x);break}g[2]&&v.ops.pop(),v.trys.pop();continue}x=u.call(f,v)}catch(C){x=[6,C],h=0}finally{d=g=0}if(5&x[0])throw x[1];return{value:x[0]?x[1]:void 0,done:!0}}([m,w])}}},a=this&&this.__read||function(f,u){var d=typeof Symbol=="function"&&f[Symbol.iterator];if(!d)return f;var h,g,p=d.call(f),v=[];try{for(;(u===void 0||u-- >0)&&!(h=p.next()).done;)v.push(h.value)}catch(y){g={error:y}}finally{try{h&&!h.done&&(d=p.return)&&d.call(p)}finally{if(g)throw g.error}}return v},s=this&&this.__spread||function(){for(var f=[],u=0;u<arguments.length;u++)f=f.concat(a(arguments[u]));return f},c=this&&this.__values||function(f){var u=typeof Symbol=="function"&&Symbol.iterator,d=u&&f[u],h=0;if(d)return d.call(f);if(f&&typeof f.length=="number")return{next:function(){return f&&h>=f.length&&(f=void 0),{value:f&&f[h++],done:!f}}};throw new TypeError(u?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var l=i(1);n.append=function(f,u){f.push(u)},n.extend=function(f,u){f.push.apply(f,s(u))},n.prepend=function(f,u){f.unshift(u)},n.replace=function(f,u,d){var h,g,p=0;try{for(var v=c(f),y=v.next();!y.done;y=v.next()){var m=y.value;if(l.isFunction(u))u.call(null,m)&&(f[p]=d);else if(m===u)return void(f[p]=d);p++}}catch(w){h={error:w}}finally{try{y&&!y.done&&(g=v.return)&&g.call(v)}finally{if(h)throw h.error}}},n.insert=function(f,u,d){f.splice(d,0,u)},n.remove=function(f,u){for(var d=f.length;d--;){var h=f[d];if(l.isFunction(u))u.call(null,h)&&f.splice(d,1);else if(h===u)return void f.splice(d,1)}},n.empty=function(f){f.length=0},n.contains=function(f,u){var d,h;try{for(var g=c(f),p=g.next();!p.done;p=g.next()){var v=p.value;if(l.isFunction(u)){if(u.call(null,v))return!0}else if(v===u)return!0}}catch(y){d={error:y}}finally{try{p&&!p.done&&(h=g.return)&&h.call(g)}finally{if(d)throw d.error}}return!1},n.size=function(f,u){var d,h;if(u===void 0)return f.length;var g=0;try{for(var p=c(f),v=p.next();!v.done;v=p.next()){var y=v.value;u.call(null,y)&&g++}}catch(m){d={error:m}}finally{try{v&&!v.done&&(h=p.return)&&h.call(p)}finally{if(d)throw d.error}}return g},n.isEmpty=function(f){return f.length===0},n.forEach=function(f,u){var d,h,g,p,v,y;return o(this,function(m){switch(m.label){case 0:return u!==void 0?[3,2]:[5,c(f)];case 1:return m.sent(),[3,9];case 2:m.trys.push([2,7,8,9]),d=c(f),h=d.next(),m.label=3;case 3:return h.done?[3,6]:(g=h.value,u.call(null,g)?[4,g]:[3,5]);case 4:m.sent(),m.label=5;case 5:return h=d.next(),[3,3];case 6:return[3,9];case 7:return p=m.sent(),v={error:p},[3,9];case 8:try{h&&!h.done&&(y=d.return)&&y.call(d)}finally{if(v)throw v.error}return[7];case 9:return[2]}})},n.clone=function(f){return new(Array.bind.apply(Array,s([void 0],f)))},n.sortInAscendingOrder=function(f,u){return f.sort(function(d,h){return u.call(null,d,h)?-1:1})},n.sortInDescendingOrder=function(f,u){return f.sort(function(d,h){return u.call(null,d,h)?1:-1})}},function(r,n,i){var o=this&&this.__generator||function(f,u){var d,h,g,p,v={label:0,sent:function(){if(1&g[0])throw g[1];return g[1]},trys:[],ops:[]};return p={next:y(0),throw:y(1),return:y(2)},typeof Symbol=="function"&&(p[Symbol.iterator]=function(){return this}),p;function y(m){return function(w){return function(x){if(d)throw new TypeError("Generator is already executing.");for(;v;)try{if(d=1,h&&(g=2&x[0]?h.return:x[0]?h.throw||((g=h.return)&&g.call(h),0):h.next)&&!(g=g.call(h,x[1])).done)return g;switch(h=0,g&&(x=[2&x[0],g.value]),x[0]){case 0:case 1:g=x;break;case 4:return v.label++,{value:x[1],done:!1};case 5:v.label++,h=x[1],x=[0];continue;case 7:x=v.ops.pop(),v.trys.pop();continue;default:if(g=v.trys,!((g=g.length>0&&g[g.length-1])||x[0]!==6&&x[0]!==2)){v=0;continue}if(x[0]===3&&(!g||x[1]>g[0]&&x[1]<g[3])){v.label=x[1];break}if(x[0]===6&&v.label<g[1]){v.label=g[1],g=x;break}if(g&&v.label<g[2]){v.label=g[2],v.ops.push(x);break}g[2]&&v.ops.pop(),v.trys.pop();continue}x=u.call(f,v)}catch(C){x=[6,C],h=0}finally{d=g=0}if(5&x[0])throw x[1];return{value:x[0]?x[1]:void 0,done:!0}}([m,w])}}},a=this&&this.__values||function(f){var u=typeof Symbol=="function"&&Symbol.iterator,d=u&&f[u],h=0;if(d)return d.call(f);if(f&&typeof f.length=="number")return{next:function(){return f&&h>=f.length&&(f=void 0),{value:f&&f[h++],done:!f}}};throw new TypeError(u?"Object is not iterable.":"Symbol.iterator is not defined.")},s=this&&this.__read||function(f,u){var d=typeof Symbol=="function"&&f[Symbol.iterator];if(!d)return f;var h,g,p=d.call(f),v=[];try{for(;(u===void 0||u-- >0)&&!(h=p.next()).done;)v.push(h.value)}catch(y){g={error:y}}finally{try{h&&!h.done&&(d=p.return)&&d.call(p)}finally{if(g)throw g.error}}return v},c=this&&this.__spread||function(){for(var f=[],u=0;u<arguments.length;u++)f=f.concat(s(arguments[u]));return f};Object.defineProperty(n,"__esModule",{value:!0});var l=i(1);n.get=function(f,u){return f.get(u)},n.set=function(f,u,d){f.set(u,d)},n.remove=function(f,u){var d,h,g,p;if(l.isFunction(u)){var v=[];try{for(var y=a(f),m=y.next();!m.done;m=y.next()){var w=m.value;u.call(null,w)&&v.push(w[0])}}catch(T){d={error:T}}finally{try{m&&!m.done&&(h=y.return)&&h.call(y)}finally{if(d)throw d.error}}try{for(var x=a(v),C=x.next();!C.done;C=x.next()){var S=C.value;f.delete(S)}}catch(T){g={error:T}}finally{try{C&&!C.done&&(p=x.return)&&p.call(x)}finally{if(g)throw g.error}}}else f.delete(u)},n.contains=function(f,u){var d,h;if(l.isFunction(u)){try{for(var g=a(f),p=g.next();!p.done;p=g.next()){var v=p.value;if(u.call(null,v))return!0}}catch(y){d={error:y}}finally{try{p&&!p.done&&(h=g.return)&&h.call(g)}finally{if(d)throw d.error}}return!1}return f.has(u)},n.keys=function(f){return new Set(f.keys())},n.values=function(f){return c(f.values())},n.size=function(f,u){var d,h;if(u===void 0)return f.size;var g=0;try{for(var p=a(f),v=p.next();!v.done;v=p.next()){var y=v.value;u.call(null,y)&&g++}}catch(m){d={error:m}}finally{try{v&&!v.done&&(h=p.return)&&h.call(p)}finally{if(d)throw d.error}}return g},n.isEmpty=function(f){return f.size===0},n.forEach=function(f,u){var d,h,g,p,v,y;return o(this,function(m){switch(m.label){case 0:return u!==void 0?[3,2]:[5,a(f)];case 1:return m.sent(),[3,9];case 2:m.trys.push([2,7,8,9]),d=a(f),h=d.next(),m.label=3;case 3:return h.done?[3,6]:(g=h.value,u.call(null,g)?[4,g]:[3,5]);case 4:m.sent(),m.label=5;case 5:return h=d.next(),[3,3];case 6:return[3,9];case 7:return p=m.sent(),v={error:p},[3,9];case 8:try{h&&!h.done&&(y=d.return)&&y.call(d)}finally{if(v)throw v.error}return[7];case 9:return[2]}})},n.clone=function(f){return new Map(f)},n.sortInAscendingOrder=function(f,u){var d=new(Array.bind.apply(Array,c([void 0],f)));return d.sort(function(h,g){return u.call(null,h,g)?-1:1}),new Map(d)},n.sortInDescendingOrder=function(f,u){var d=new(Array.bind.apply(Array,c([void 0],f)));return d.sort(function(h,g){return u.call(null,h,g)?1:-1}),new Map(d)}},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0}),n.HTML="http://www.w3.org/1999/xhtml",n.XML="http://www.w3.org/XML/1998/namespace",n.XMLNS="http://www.w3.org/2000/xmlns/",n.MathML="http://www.w3.org/1998/Math/MathML",n.SVG="http://www.w3.org/2000/svg",n.XLink="http://www.w3.org/1999/xlink"},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0}),n.enqueue=function(o,a){o.push(a)},n.dequeue=function(o){return o.shift()||null}},function(r,n,i){var o=this&&this.__generator||function(u,d){var h,g,p,v,y={label:0,sent:function(){if(1&p[0])throw p[1];return p[1]},trys:[],ops:[]};return v={next:m(0),throw:m(1),return:m(2)},typeof Symbol=="function"&&(v[Symbol.iterator]=function(){return this}),v;function m(w){return function(x){return function(C){if(h)throw new TypeError("Generator is already executing.");for(;y;)try{if(h=1,g&&(p=2&C[0]?g.return:C[0]?g.throw||((p=g.return)&&p.call(g),0):g.next)&&!(p=p.call(g,C[1])).done)return p;switch(g=0,p&&(C=[2&C[0],p.value]),C[0]){case 0:case 1:p=C;break;case 4:return y.label++,{value:C[1],done:!1};case 5:y.label++,g=C[1],C=[0];continue;case 7:C=y.ops.pop(),y.trys.pop();continue;default:if(p=y.trys,!((p=p.length>0&&p[p.length-1])||C[0]!==6&&C[0]!==2)){y=0;continue}if(C[0]===3&&(!p||C[1]>p[0]&&C[1]<p[3])){y.label=C[1];break}if(C[0]===6&&y.label<p[1]){y.label=p[1],p=C;break}if(p&&y.label<p[2]){y.label=p[2],y.ops.push(C);break}p[2]&&y.ops.pop(),y.trys.pop();continue}C=d.call(u,y)}catch(S){C=[6,S],g=0}finally{h=p=0}if(5&C[0])throw C[1];return{value:C[0]?C[1]:void 0,done:!0}}([w,x])}}},a=this&&this.__values||function(u){var d=typeof Symbol=="function"&&Symbol.iterator,h=d&&u[d],g=0;if(h)return h.call(u);if(u&&typeof u.length=="number")return{next:function(){return u&&g>=u.length&&(u=void 0),{value:u&&u[g++],done:!u}}};throw new TypeError(d?"Object is not iterable.":"Symbol.iterator is not defined.")},s=this&&this.__read||function(u,d){var h=typeof Symbol=="function"&&u[Symbol.iterator];if(!h)return u;var g,p,v=h.call(u),y=[];try{for(;(d===void 0||d-- >0)&&!(g=v.next()).done;)y.push(g.value)}catch(m){p={error:m}}finally{try{g&&!g.done&&(h=v.return)&&h.call(v)}finally{if(p)throw p.error}}return y},c=this&&this.__spread||function(){for(var u=[],d=0;d<arguments.length;d++)u=u.concat(s(arguments[d]));return u};Object.defineProperty(n,"__esModule",{value:!0});var l=i(1);function f(u,d){var h,g;try{for(var p=a(u),v=p.next();!v.done;v=p.next()){var y=v.value;if(!d.has(y))return!1}}catch(m){h={error:m}}finally{try{v&&!v.done&&(g=p.return)&&g.call(p)}finally{if(h)throw h.error}}return!0}n.append=function(u,d){u.add(d)},n.extend=function(u,d){d.forEach(u.add,u)},n.prepend=function(u,d){var h=new Set(u);u.clear(),u.add(d),h.forEach(u.add,u)},n.replace=function(u,d,h){var g,p,v=new Set;try{for(var y=a(u),m=y.next();!m.done;m=y.next()){var w=m.value;l.isFunction(d)?d.call(null,w)?v.add(h):v.add(w):w===d?v.add(h):v.add(w)}}catch(x){g={error:x}}finally{try{m&&!m.done&&(p=y.return)&&p.call(y)}finally{if(g)throw g.error}}u.clear(),v.forEach(u.add,u)},n.insert=function(u,d,h){var g,p,v=new Set,y=0;try{for(var m=a(u),w=m.next();!w.done;w=m.next()){var x=w.value;y===h&&v.add(d),v.add(x),y++}}catch(C){g={error:C}}finally{try{w&&!w.done&&(p=m.return)&&p.call(m)}finally{if(g)throw g.error}}u.clear(),v.forEach(u.add,u)},n.remove=function(u,d){var h,g,p,v;if(l.isFunction(d)){var y=[];try{for(var m=a(u),w=m.next();!w.done;w=m.next()){var x=w.value;d.call(null,x)&&y.push(x)}}catch(_){h={error:_}}finally{try{w&&!w.done&&(g=m.return)&&g.call(m)}finally{if(h)throw h.error}}try{for(var C=a(y),S=C.next();!S.done;S=C.next()){var T=S.value;u.delete(T)}}catch(_){p={error:_}}finally{try{S&&!S.done&&(v=C.return)&&v.call(C)}finally{if(p)throw p.error}}}else u.delete(d)},n.empty=function(u){u.clear()},n.contains=function(u,d){var h,g;if(!l.isFunction(d))return u.has(d);try{for(var p=a(u),v=p.next();!v.done;v=p.next()){var y=v.value;if(d.call(null,y))return!0}}catch(m){h={error:m}}finally{try{v&&!v.done&&(g=p.return)&&g.call(p)}finally{if(h)throw h.error}}return!1},n.size=function(u,d){var h,g;if(d===void 0)return u.size;var p=0;try{for(var v=a(u),y=v.next();!y.done;y=v.next()){var m=y.value;d.call(null,m)&&p++}}catch(w){h={error:w}}finally{try{y&&!y.done&&(g=v.return)&&g.call(v)}finally{if(h)throw h.error}}return p},n.isEmpty=function(u){return u.size===0},n.forEach=function(u,d){var h,g,p,v,y,m;return o(this,function(w){switch(w.label){case 0:return d!==void 0?[3,2]:[5,a(u)];case 1:return w.sent(),[3,9];case 2:w.trys.push([2,7,8,9]),h=a(u),g=h.next(),w.label=3;case 3:return g.done?[3,6]:(p=g.value,d.call(null,p)?[4,p]:[3,5]);case 4:w.sent(),w.label=5;case 5:return g=h.next(),[3,3];case 6:return[3,9];case 7:return v=w.sent(),y={error:v},[3,9];case 8:try{g&&!g.done&&(m=h.return)&&m.call(h)}finally{if(y)throw y.error}return[7];case 9:return[2]}})},n.clone=function(u){return new Set(u)},n.sortInAscendingOrder=function(u,d){var h=new(Array.bind.apply(Array,c([void 0],u)));return h.sort(function(g,p){return d.call(null,g,p)?-1:1}),new Set(h)},n.sortInDescendingOrder=function(u,d){var h=new(Array.bind.apply(Array,c([void 0],u)));return h.sort(function(g,p){return d.call(null,g,p)?1:-1}),new Set(h)},n.isSubsetOf=f,n.isSupersetOf=function(u,d){return f(d,u)},n.intersection=function(u,d){var h,g,p=new Set;try{for(var v=a(u),y=v.next();!y.done;y=v.next()){var m=y.value;d.has(m)&&p.add(m)}}catch(w){h={error:w}}finally{try{y&&!y.done&&(g=v.return)&&g.call(v)}finally{if(h)throw h.error}}return p},n.union=function(u,d){var h=new Set(u);return d.forEach(h.add,h),h},n.range=function(u,d){for(var h=new Set,g=u;g<=d;g++)h.add(g);return h}},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0}),n.push=function(o,a){o.push(a)},n.pop=function(o){return o.pop()||null}},function(r,n,i){var o=this&&this.__values||function(y){var m=typeof Symbol=="function"&&Symbol.iterator,w=m&&y[m],x=0;if(w)return w.call(y);if(y&&typeof y.length=="number")return{next:function(){return y&&x>=y.length&&(y=void 0),{value:y&&y[x++],done:!y}}};throw new TypeError(m?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var a=i(96),s=i(147),c=i(146),l=i(1);function f(y,m){for(var w=0;;){var x=w<y.length?y.charCodeAt(w):null,C=w<m.length?m.charCodeAt(w):null;if(x===null)return!0;if(x!==C)return!1;w++}}function u(y){var m,w,x=Array.from(y),C=new Uint8Array(x.length),S=0;try{for(var T=o(y),_=T.next();!_.done;_=T.next()){var E=_.value.codePointAt(0);console.assert(E!==void 0&&E<=255,"isomorphicEncode requires string bytes to be less than or equal to 0x00FF."),E!==void 0&&E<=255&&(C[S++]=E)}}catch(b){m={error:b}}finally{try{_&&!_.done&&(w=T.return)&&w.call(T)}finally{if(m)throw m.error}}return C}function d(y){return/^[\u0000-\u007F]*$/.test(y)}function h(y){var m,w,x="";try{for(var C=o(y),S=C.next();!S.done;S=C.next()){var T=S.value,_=T.codePointAt(0);x+=_!==void 0&&_>=65&&_<=90?String.fromCodePoint(_+32):T}}catch(E){m={error:E}}finally{try{S&&!S.done&&(w=C.return)&&w.call(C)}finally{if(m)throw m.error}}return x}function g(y){return y.replace(/^[\t\n\f\r ]+/,"").replace(/[\t\n\f\r ]+$/,"")}function p(y,m,w){if(!l.isArray(m))return p(y,Array.from(m),w);for(var x="";w.position<m.length&&y.call(null,m[w.position]);)x+=m[w.position],w.position++;return x}function v(y,m){p(function(w){return a.ASCIIWhiteSpace.test(w)},y,m)}n.isCodeUnitPrefix=f,n.isCodeUnitLessThan=function(y,m){if(f(m,y))return!1;if(f(y,m))return!0;for(var w=0;w<Math.min(y.length,m.length);w++){var x=y.charCodeAt(w),C=m.charCodeAt(w);if(x!==C)return x<C}return!1},n.isomorphicEncode=u,n.isASCIIString=d,n.asciiLowercase=h,n.asciiUppercase=function(y){var m,w,x="";try{for(var C=o(y),S=C.next();!S.done;S=C.next()){var T=S.value,_=T.codePointAt(0);x+=_!==void 0&&_>=97&&_<=122?String.fromCodePoint(_-32):T}}catch(E){m={error:E}}finally{try{S&&!S.done&&(w=C.return)&&w.call(C)}finally{if(m)throw m.error}}return x},n.asciiCaseInsensitiveMatch=function(y,m){return h(y)===h(m)},n.asciiEncode=function(y){return console.assert(d(y),"asciiEncode requires an ASCII string."),u(y)},n.asciiDecode=function(y){var m,w;try{for(var x=o(y),C=x.next();!C.done;C=x.next()){var S=C.value;console.assert(c.isASCIIByte(S),"asciiDecode requires an ASCII byte sequence.")}}catch(T){m={error:T}}finally{try{C&&!C.done&&(w=x.return)&&w.call(x)}finally{if(m)throw m.error}}return s.isomorphicDecode(y)},n.stripNewlines=function(y){return y.replace(/[\n\r]/g,"")},n.normalizeNewlines=function(y){return y.replace(/\r\n/g,`
|
||
`).replace(/\r/g,`
|
||
`)},n.stripLeadingAndTrailingASCIIWhitespace=g,n.stripAndCollapseASCIIWhitespace=function(y){return g(y.replace(/[\t\n\f\r ]{2,}/g," "))},n.collectASequenceOfCodePoints=p,n.skipASCIIWhitespace=v,n.strictlySplit=function y(m,w){if(!l.isArray(m))return y(Array.from(m),w);var x={position:0},C=[],S=p(function(T){return w!==T},m,x);for(C.push(S);x.position<m.length;)console.assert(m[x.position]===w,"strictlySplit found no delimiter in input string."),x.position++,S=p(function(T){return w!==T},m,x),C.push(S);return C},n.splitAStringOnASCIIWhitespace=function y(m){if(!l.isArray(m))return y(Array.from(m));var w={position:0},x=[];for(v(m,w);w.position<m.length;){var C=p(function(S){return!a.ASCIIWhiteSpace.test(S)},m,w);x.push(C),v(m,w)}return x},n.splitAStringOnCommas=function y(m){if(!l.isArray(m))return y(Array.from(m));for(var w={position:0},x=[];w.position<m.length;){var C=p(function(S){return S!==","},m,w);x.push(g(C)),w.position<m.length&&(console.assert(m[w.position]===",","splitAStringOnCommas found no delimiter in input string."),w.position++)}return x},n.concatenate=function(y,m){return m===void 0&&(m=""),y.length===0?"":y.join(m)}},function(r,n,i){var o=this&&this.__values||function(s){var c=typeof Symbol=="function"&&Symbol.iterator,l=c&&s[c],f=0;if(l)return l.call(s);if(s&&typeof s.length=="number")return{next:function(){return s&&f>=s.length&&(s=void 0),{value:s&&s[f++],done:!s}}};throw new TypeError(c?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var a=i(97);n.abort_add=function(s,c){c._abortedFlag||c._abortAlgorithms.add(s)},n.abort_remove=function(s,c){c._abortAlgorithms.delete(s)},n.abort_signalAbort=function(s){var c,l;if(!s._abortedFlag){s._abortedFlag=!0;try{for(var f=o(s._abortAlgorithms),u=f.next();!u.done;u=f.next())u.value.call(s)}catch(d){c={error:d}}finally{try{u&&!u.done&&(l=f.return)&&l.call(f)}finally{if(c)throw c.error}}s._abortAlgorithms.clear(),a.event_fireAnEvent("abort",s)}}},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(150),a=function(){function s(){}return s.asNode=function(c){if(o.Guard.isNode(c))return c;throw new Error("Invalid object. Node expected.")},s}();n.Cast=a},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=function(){function s(){}return Object.defineProperty(s.prototype,"size",{get:function(){return 0},enumerable:!0,configurable:!0}),s.prototype.add=function(c){throw new Error("Cannot add to an empty set.")},s.prototype.clear=function(){},s.prototype.delete=function(c){return!1},s.prototype.forEach=function(c,l){},s.prototype.has=function(c){return!1},s.prototype[Symbol.iterator]=function(){return new a},s.prototype.entries=function(){return new a},s.prototype.keys=function(){return new a},s.prototype.values=function(){return new a},Object.defineProperty(s.prototype,Symbol.toStringTag,{get:function(){return"EmptySet"},enumerable:!0,configurable:!0}),s}();n.EmptySet=o;var a=function(){function s(){}return s.prototype[Symbol.iterator]=function(){return this},s.prototype.next=function(){return{done:!0,value:null}},s}()},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0}),function(o){o[o.SchemeStart=0]="SchemeStart",o[o.Scheme=1]="Scheme",o[o.NoScheme=2]="NoScheme",o[o.SpecialRelativeOrAuthority=3]="SpecialRelativeOrAuthority",o[o.PathOrAuthority=4]="PathOrAuthority",o[o.Relative=5]="Relative",o[o.RelativeSlash=6]="RelativeSlash",o[o.SpecialAuthoritySlashes=7]="SpecialAuthoritySlashes",o[o.SpecialAuthorityIgnoreSlashes=8]="SpecialAuthorityIgnoreSlashes",o[o.Authority=9]="Authority",o[o.Host=10]="Host",o[o.Hostname=11]="Hostname",o[o.Port=12]="Port",o[o.File=13]="File",o[o.FileSlash=14]="FileSlash",o[o.FileHost=15]="FileHost",o[o.PathStart=16]="PathStart",o[o.Path=17]="Path",o[o.CannotBeABaseURLPath=18]="CannotBeABaseURLPath",o[o.Query=19]="Query",o[o.Fragment=20]="Fragment"}(n.ParserState||(n.ParserState={})),n.OpaqueOrigin=["","",null,null]},function(r,n,i){var o=i(245),a=i(247);function s(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}n.parse=C,n.resolve=function(S,T){return C(S,!1,!0).resolve(T)},n.resolveObject=function(S,T){return S?C(S,!1,!0).resolveObject(T):T},n.format=function(S){return a.isString(S)&&(S=C(S)),S instanceof s?S.format():s.prototype.format.call(S)},n.Url=s;var c=/^([a-z0-9.+-]+:)/i,l=/:[0-9]*$/,f=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,u=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r",`
|
||
`," "]),d=["'"].concat(u),h=["%","/","?",";","#"].concat(d),g=["/","?","#"],p=/^[+a-z0-9A-Z_-]{0,63}$/,v=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,y={javascript:!0,"javascript:":!0},m={javascript:!0,"javascript:":!0},w={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},x=i(248);function C(S,T,_){if(S&&a.isObject(S)&&S instanceof s)return S;var E=new s;return E.parse(S,T,_),E}s.prototype.parse=function(S,T,_){if(!a.isString(S))throw new TypeError("Parameter 'url' must be a string, not "+typeof S);var E=S.indexOf("?"),b=E!==-1&&E<S.indexOf("#")?"?":"#",D=S.split(b);D[0]=D[0].replace(/\\/g,"/");var I=S=D.join(b);if(I=I.trim(),!_&&S.split("#").length===1){var P=f.exec(I);if(P)return this.path=I,this.href=I,this.pathname=P[1],P[2]?(this.search=P[2],this.query=T?x.parse(this.search.substr(1)):this.search.substr(1)):T&&(this.search="",this.query={}),this}var O=c.exec(I);if(O){var L=(O=O[0]).toLowerCase();this.protocol=L,I=I.substr(O.length)}if(_||O||I.match(/^\/\/[^@\/]+@[^@\/]+/)){var B=I.substr(0,2)==="//";!B||O&&m[O]||(I=I.substr(2),this.slashes=!0)}if(!m[O]&&(B||O&&!w[O])){for(var H,A,F=-1,G=0;G<g.length;G++)(X=I.indexOf(g[G]))!==-1&&(F===-1||X<F)&&(F=X);for((A=F===-1?I.lastIndexOf("@"):I.lastIndexOf("@",F))!==-1&&(H=I.slice(0,A),I=I.slice(A+1),this.auth=decodeURIComponent(H)),F=-1,G=0;G<h.length;G++){var X;(X=I.indexOf(h[G]))!==-1&&(F===-1||X<F)&&(F=X)}F===-1&&(F=I.length),this.host=I.slice(0,F),I=I.slice(F),this.parseHost(),this.hostname=this.hostname||"";var ee=this.hostname[0]==="["&&this.hostname[this.hostname.length-1]==="]";if(!ee)for(var ce=this.hostname.split(/\./),Se=(G=0,ce.length);G<Se;G++){var we=ce[G];if(we&&!we.match(p)){for(var _e="",Ve=0,Ge=we.length;Ve<Ge;Ve++)we.charCodeAt(Ve)>127?_e+="x":_e+=we[Ve];if(!_e.match(p)){var Ne=ce.slice(0,G),j=ce.slice(G+1),M=we.match(v);M&&(Ne.push(M[1]),j.unshift(M[2])),j.length&&(I="/"+j.join(".")+I),this.hostname=Ne.join(".");break}}}this.hostname.length>255?this.hostname="":this.hostname=this.hostname.toLowerCase(),ee||(this.hostname=o.toASCII(this.hostname));var q=this.port?":"+this.port:"",K=this.hostname||"";this.host=K+q,this.href+=this.host,ee&&(this.hostname=this.hostname.substr(1,this.hostname.length-2),I[0]!=="/"&&(I="/"+I))}if(!y[L])for(G=0,Se=d.length;G<Se;G++){var J=d[G];if(I.indexOf(J)!==-1){var re=encodeURIComponent(J);re===J&&(re=escape(J)),I=I.split(J).join(re)}}var ie=I.indexOf("#");ie!==-1&&(this.hash=I.substr(ie),I=I.slice(0,ie));var Re=I.indexOf("?");if(Re!==-1?(this.search=I.substr(Re),this.query=I.substr(Re+1),T&&(this.query=x.parse(this.query)),I=I.slice(0,Re)):T&&(this.search="",this.query={}),I&&(this.pathname=I),w[L]&&this.hostname&&!this.pathname&&(this.pathname="/"),this.pathname||this.search){q=this.pathname||"";var Fe=this.search||"";this.path=q+Fe}return this.href=this.format(),this},s.prototype.format=function(){var S=this.auth||"";S&&(S=(S=encodeURIComponent(S)).replace(/%3A/i,":"),S+="@");var T=this.protocol||"",_=this.pathname||"",E=this.hash||"",b=!1,D="";this.host?b=S+this.host:this.hostname&&(b=S+(this.hostname.indexOf(":")===-1?this.hostname:"["+this.hostname+"]"),this.port&&(b+=":"+this.port)),this.query&&a.isObject(this.query)&&Object.keys(this.query).length&&(D=x.stringify(this.query));var I=this.search||D&&"?"+D||"";return T&&T.substr(-1)!==":"&&(T+=":"),this.slashes||(!T||w[T])&&b!==!1?(b="//"+(b||""),_&&_.charAt(0)!=="/"&&(_="/"+_)):b||(b=""),E&&E.charAt(0)!=="#"&&(E="#"+E),I&&I.charAt(0)!=="?"&&(I="?"+I),T+b+(_=_.replace(/[?#]/g,function(P){return encodeURIComponent(P)}))+(I=I.replace("#","%23"))+E},s.prototype.resolve=function(S){return this.resolveObject(C(S,!1,!0)).format()},s.prototype.resolveObject=function(S){if(a.isString(S)){var T=new s;T.parse(S,!1,!0),S=T}for(var _=new s,E=Object.keys(this),b=0;b<E.length;b++){var D=E[b];_[D]=this[D]}if(_.hash=S.hash,S.href==="")return _.href=_.format(),_;if(S.slashes&&!S.protocol){for(var I=Object.keys(S),P=0;P<I.length;P++){var O=I[P];O!=="protocol"&&(_[O]=S[O])}return w[_.protocol]&&_.hostname&&!_.pathname&&(_.path=_.pathname="/"),_.href=_.format(),_}if(S.protocol&&S.protocol!==_.protocol){if(!w[S.protocol]){for(var L=Object.keys(S),B=0;B<L.length;B++){var H=L[B];_[H]=S[H]}return _.href=_.format(),_}if(_.protocol=S.protocol,S.host||m[S.protocol])_.pathname=S.pathname;else{for(var A=(S.pathname||"").split("/");A.length&&!(S.host=A.shift()););S.host||(S.host=""),S.hostname||(S.hostname=""),A[0]!==""&&A.unshift(""),A.length<2&&A.unshift(""),_.pathname=A.join("/")}if(_.search=S.search,_.query=S.query,_.host=S.host||"",_.auth=S.auth,_.hostname=S.hostname||S.host,_.port=S.port,_.pathname||_.search){var F=_.pathname||"",G=_.search||"";_.path=F+G}return _.slashes=_.slashes||S.slashes,_.href=_.format(),_}var X=_.pathname&&_.pathname.charAt(0)==="/",ee=S.host||S.pathname&&S.pathname.charAt(0)==="/",ce=ee||X||_.host&&S.pathname,Se=ce,we=_.pathname&&_.pathname.split("/")||[],_e=(A=S.pathname&&S.pathname.split("/")||[],_.protocol&&!w[_.protocol]);if(_e&&(_.hostname="",_.port=null,_.host&&(we[0]===""?we[0]=_.host:we.unshift(_.host)),_.host="",S.protocol&&(S.hostname=null,S.port=null,S.host&&(A[0]===""?A[0]=S.host:A.unshift(S.host)),S.host=null),ce=ce&&(A[0]===""||we[0]==="")),ee)_.host=S.host||S.host===""?S.host:_.host,_.hostname=S.hostname||S.hostname===""?S.hostname:_.hostname,_.search=S.search,_.query=S.query,we=A;else if(A.length)we||(we=[]),we.pop(),we=we.concat(A),_.search=S.search,_.query=S.query;else if(!a.isNullOrUndefined(S.search))return _e&&(_.hostname=_.host=we.shift(),(M=!!(_.host&&_.host.indexOf("@")>0)&&_.host.split("@"))&&(_.auth=M.shift(),_.host=_.hostname=M.shift())),_.search=S.search,_.query=S.query,a.isNull(_.pathname)&&a.isNull(_.search)||(_.path=(_.pathname?_.pathname:"")+(_.search?_.search:"")),_.href=_.format(),_;if(!we.length)return _.pathname=null,_.search?_.path="/"+_.search:_.path=null,_.href=_.format(),_;for(var Ve=we.slice(-1)[0],Ge=(_.host||S.host||we.length>1)&&(Ve==="."||Ve==="..")||Ve==="",Ne=0,j=we.length;j>=0;j--)(Ve=we[j])==="."?we.splice(j,1):Ve===".."?(we.splice(j,1),Ne++):Ne&&(we.splice(j,1),Ne--);if(!ce&&!Se)for(;Ne--;Ne)we.unshift("..");!ce||we[0]===""||we[0]&&we[0].charAt(0)==="/"||we.unshift(""),Ge&&we.join("/").substr(-1)!=="/"&&we.push("");var M,q=we[0]===""||we[0]&&we[0].charAt(0)==="/";return _e&&(_.hostname=_.host=q?"":we.length?we.shift():"",(M=!!(_.host&&_.host.indexOf("@")>0)&&_.host.split("@"))&&(_.auth=M.shift(),_.host=_.hostname=M.shift())),(ce=ce||_.host&&we.length)&&!q&&we.unshift(""),we.length?_.pathname=we.join("/"):(_.pathname=null,_.path=null),a.isNull(_.pathname)&&a.isNull(_.search)||(_.path=(_.pathname?_.pathname:"")+(_.search?_.search:"")),_.auth=S.auth||_.auth,_.slashes=_.slashes||S.slashes,_.href=_.format(),_},s.prototype.parseHost=function(){var S=this.host,T=l.exec(S);T&&((T=T[0])!==":"&&(this.port=T.substr(1)),S=S.substr(0,S.length-T.length)),S&&(this.hostname=S)}},function(r,n,i){(function(o,a){var s;/*! https://mths.be/punycode v1.4.1 by @mathias */(function(c){n&&n.nodeType,o&&o.nodeType;var l=typeof a=="object"&&a;l.global!==l&&l.window!==l&&l.self;var f,u=2147483647,d=/^xn--/,h=/[^\x20-\x7E]/,g=/[\x2E\u3002\uFF0E\uFF61]/g,p={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},v=Math.floor,y=String.fromCharCode;function m(D){throw new RangeError(p[D])}function w(D,I){for(var P=D.length,O=[];P--;)O[P]=I(D[P]);return O}function x(D,I){var P=D.split("@"),O="";return P.length>1&&(O=P[0]+"@",D=P[1]),O+w((D=D.replace(g,".")).split("."),I).join(".")}function C(D){for(var I,P,O=[],L=0,B=D.length;L<B;)(I=D.charCodeAt(L++))>=55296&&I<=56319&&L<B?(64512&(P=D.charCodeAt(L++)))==56320?O.push(((1023&I)<<10)+(1023&P)+65536):(O.push(I),L--):O.push(I);return O}function S(D){return w(D,function(I){var P="";return I>65535&&(P+=y((I-=65536)>>>10&1023|55296),I=56320|1023&I),P+=y(I)}).join("")}function T(D,I){return D+22+75*(D<26)-((I!=0)<<5)}function _(D,I,P){var O=0;for(D=P?v(D/700):D>>1,D+=v(D/I);D>455;O+=36)D=v(D/35);return v(O+36*D/(D+38))}function E(D){var I,P,O,L,B,H,A,F,G,X,ee,ce=[],Se=D.length,we=0,_e=128,Ve=72;for((P=D.lastIndexOf("-"))<0&&(P=0),O=0;O<P;++O)D.charCodeAt(O)>=128&&m("not-basic"),ce.push(D.charCodeAt(O));for(L=P>0?P+1:0;L<Se;){for(B=we,H=1,A=36;L>=Se&&m("invalid-input"),((F=(ee=D.charCodeAt(L++))-48<10?ee-22:ee-65<26?ee-65:ee-97<26?ee-97:36)>=36||F>v((u-we)/H))&&m("overflow"),we+=F*H,!(F<(G=A<=Ve?1:A>=Ve+26?26:A-Ve));A+=36)H>v(u/(X=36-G))&&m("overflow"),H*=X;Ve=_(we-B,I=ce.length+1,B==0),v(we/I)>u-_e&&m("overflow"),_e+=v(we/I),we%=I,ce.splice(we++,0,_e)}return S(ce)}function b(D){var I,P,O,L,B,H,A,F,G,X,ee,ce,Se,we,_e,Ve=[];for(ce=(D=C(D)).length,I=128,P=0,B=72,H=0;H<ce;++H)(ee=D[H])<128&&Ve.push(y(ee));for(O=L=Ve.length,L&&Ve.push("-");O<ce;){for(A=u,H=0;H<ce;++H)(ee=D[H])>=I&&ee<A&&(A=ee);for(A-I>v((u-P)/(Se=O+1))&&m("overflow"),P+=(A-I)*Se,I=A,H=0;H<ce;++H)if((ee=D[H])<I&&++P>u&&m("overflow"),ee==I){for(F=P,G=36;!(F<(X=G<=B?1:G>=B+26?26:G-B));G+=36)_e=F-X,we=36-X,Ve.push(y(T(X+_e%we,0))),F=v(_e/we);Ve.push(y(T(F,0))),B=_(P,Se,O==L),P=0,++O}++P,++I}return Ve.join("")}f={version:"1.4.1",ucs2:{decode:C,encode:S},decode:E,encode:b,toASCII:function(D){return x(D,function(I){return h.test(I)?"xn--"+b(I):I})},toUnicode:function(D){return x(D,function(I){return d.test(I)?E(I.slice(4).toLowerCase()):I})}},(s=(function(){return f}).call(n,i,n,o))===void 0||(o.exports=s)})()}).call(this,i(246)(r),i(78))},function(r,n){r.exports=function(i){return i.webpackPolyfill||(i.deprecate=function(){},i.paths=[],i.children||(i.children=[]),Object.defineProperty(i,"loaded",{enumerable:!0,get:function(){return i.l}}),Object.defineProperty(i,"id",{enumerable:!0,get:function(){return i.i}}),i.webpackPolyfill=1),i}},function(r,n,i){r.exports={isString:function(o){return typeof o=="string"},isObject:function(o){return typeof o=="object"&&o!==null},isNull:function(o){return o===null},isNullOrUndefined:function(o){return o==null}}},function(r,n,i){n.decode=n.parse=i(249),n.encode=n.stringify=i(250)},function(r,n,i){function o(s,c){return Object.prototype.hasOwnProperty.call(s,c)}r.exports=function(s,c,l,f){c=c||"&",l=l||"=";var u={};if(typeof s!="string"||s.length===0)return u;var d=/\+/g;s=s.split(c);var h=1e3;f&&typeof f.maxKeys=="number"&&(h=f.maxKeys);var g=s.length;h>0&&g>h&&(g=h);for(var p=0;p<g;++p){var v,y,m,w,x=s[p].replace(d,"%20"),C=x.indexOf(l);C>=0?(v=x.substr(0,C),y=x.substr(C+1)):(v=x,y=""),m=decodeURIComponent(v),w=decodeURIComponent(y),o(u,m)?a(u[m])?u[m].push(w):u[m]=[u[m],w]:u[m]=w}return u};var a=Array.isArray||function(s){return Object.prototype.toString.call(s)==="[object Array]"}},function(r,n,i){var o=function(l){switch(typeof l){case"string":return l;case"boolean":return l?"true":"false";case"number":return isFinite(l)?l:"";default:return""}};r.exports=function(l,f,u,d){return f=f||"&",u=u||"=",l===null&&(l=void 0),typeof l=="object"?s(c(l),function(h){var g=encodeURIComponent(o(h))+u;return a(l[h])?s(l[h],function(p){return g+encodeURIComponent(o(p))}).join(f):g+encodeURIComponent(o(l[h]))}).join(f):d?encodeURIComponent(o(d))+u+encodeURIComponent(o(l)):""};var a=Array.isArray||function(l){return Object.prototype.toString.call(l)==="[object Array]"};function s(l,f){if(l.map)return l.map(f);for(var u=[],d=0;d<l.length;d++)u.push(f(l[d],d));return u}var c=Object.keys||function(l){var f=[];for(var u in l)Object.prototype.hasOwnProperty.call(l,u)&&f.push(u);return f}},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(52);n.attr_setAnExistingAttributeValue=function(a,s){a._element===null?a._value=s:o.element_change(a,a._element,s)}},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(108),a=i(30),s=i(52);n.tokenList_validationSteps=function(c,l){if(!a.dom_hasSupportedTokens(c._attribute._localName))throw new TypeError("There are no supported tokens defined for attribute name: '"+c._attribute._localName+"'.");return a.dom_getSupportedTokens(c._attribute._localName).has(l.toLowerCase())},n.tokenList_updateSteps=function(c){(c._element.hasAttribute(c._attribute._localName)||c._tokenSet.size!==0)&&s.element_setAnAttributeValue(c._element,c._attribute._localName,o.orderedSet_serialize(c._tokenSet))},n.tokenList_serializeSteps=function(c){return s.element_getAnAttributeValue(c._element,c._attribute._localName)}},function(r,n,i){var o=this&&this.__values||function(c){var l=typeof Symbol=="function"&&Symbol.iterator,f=l&&c[l],u=0;if(f)return f.call(c);if(c&&typeof c.length=="number")return{next:function(){return c&&u>=c.length&&(c=void 0),{value:c&&c[u++],done:!c}}};throw new TypeError(l?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var a=i(1);function s(c){return a.isBoolean(c)?c:c.capture||!1}n.eventTarget_flatten=s,n.eventTarget_flattenMore=function(c){var l=s(c),f=!1,u=!1;return a.isBoolean(c)||(f=c.once||!1,u=c.passive||!1),[l,u,f]},n.eventTarget_addEventListener=function(c,l){if(l.callback!==null){for(var f=0;f<c._eventListenerList.length;f++){var u=c._eventListenerList[f];if(u.type===l.type&&u.callback.handleEvent===l.callback.handleEvent&&u.capture===l.capture)return}c._eventListenerList.push(l)}},n.eventTarget_removeEventListener=function(c,l,f){l.removed=!0,c._eventListenerList.splice(f,1)},n.eventTarget_removeAllEventListeners=function(c){var l,f;try{for(var u=o(c._eventListenerList),d=u.next();!d.done;d=u.next())d.value.removed=!0}catch(h){l={error:h}}finally{try{d&&!d.done&&(f=u.return)&&f.call(u)}finally{if(l)throw l.error}}c._eventListenerList.length=0}},function(r,n,i){var o=this&&this.__values||function(c){var l=typeof Symbol=="function"&&Symbol.iterator,f=l&&c[l],u=0;if(f)return f.call(c);if(c&&typeof c.length=="number")return{next:function(){return c&&u>=c.length&&(c=void 0),{value:c&&c[u++],done:!c}}};throw new TypeError(l?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var a=i(1),s=i(29);n.parentNode_convertNodesIntoANode=function(c,l){for(var f,u,d=null,h=0;h<c.length;h++){var g=c[h];if(a.isString(g)){var p=s.create_text(l,g);c[h]=p}}if(c.length===1)d=c[0];else{var v=d=s.create_documentFragment(l);try{for(var y=o(c),m=y.next();!m.done;m=y.next())g=m.value,v.appendChild(g)}catch(w){f={error:w}}finally{try{m&&!m.done&&(u=y.return)&&u.call(y)}finally{if(f)throw f.error}}}return d}},function(r,n,i){var o=this&&this.__values||function(T){var _=typeof Symbol=="function"&&Symbol.iterator,E=_&&T[_],b=0;if(E)return E.call(T);if(T&&typeof T.length=="number")return{next:function(){return T&&b>=T.length&&(T=void 0),{value:T&&T[b++],done:!T}}};throw new TypeError(_?"Object is not iterable.":"Symbol.iterator is not defined.")},a=this&&this.__read||function(T,_){var E=typeof Symbol=="function"&&T[Symbol.iterator];if(!E)return T;var b,D,I=E.call(T),P=[];try{for(;(_===void 0||_-- >0)&&!(b=I.next()).done;)P.push(b.value)}catch(O){D={error:O}}finally{try{b&&!b.done&&(E=I.return)&&E.call(I)}finally{if(D)throw D.error}}return P},s=this&&this.__spread||function(){for(var T=[],_=0;_<arguments.length;_++)T=T.concat(a(arguments[_]));return T};Object.defineProperty(n,"__esModule",{value:!0});var c=i(2),l=i(9),f=i(3),u=i(29),d=i(17),h=i(175),g=i(107),p=i(176),v=i(37),y=i(177);function m(T){return T._startNode===T._endNode&&T._startOffset===T._endOffset}function w(T){return d.tree_rootNode(T._startNode)}function x(T,_){return d.tree_rootNode(T)===w(_)&&h.boundaryPoint_position([T,0],_._start)===c.BoundaryPosition.After&&h.boundaryPoint_position([T,d.tree_nodeLength(T)],_._end)===c.BoundaryPosition.Before}function C(T,_){var E=d.tree_isAncestorOf(_._startNode,T,!0),b=d.tree_isAncestorOf(_._endNode,T,!0);return E&&!b||!E&&b}function S(T){var _,E,b,D,I,P,O=u.create_documentFragment(T._startNode._nodeDocument);if(m(T))return O;var L=T._startNode,B=T._startOffset,H=T._endNode,A=T._endOffset;if(L===H&&f.Guard.isCharacterDataNode(L))return(K=p.node_clone(L))._data=g.characterData_substringData(L,B,A-B),v.mutation_append(K,O),g.characterData_replaceData(L,B,A-B,""),O;for(var F=L;!d.tree_isAncestorOf(H,F,!0);){if(F._parent===null)throw new Error("Parent node is null.");F=F._parent}var G=null;if(!d.tree_isAncestorOf(H,L,!0))try{for(var X=o(F._children),ee=X.next();!ee.done;ee=X.next())if(C(_e=ee.value,T)){G=_e;break}}catch(Fe){_={error:Fe}}finally{try{ee&&!ee.done&&(E=X.return)&&E.call(X)}finally{if(_)throw _.error}}var ce=null;if(!d.tree_isAncestorOf(L,H,!0))for(var Se=s(F._children),we=Se.length-1;we>0;we--){var _e;if(C(_e=Se[we],T)){ce=_e;break}}var Ve,Ge,Ne=[];try{for(var j=o(F._children),M=j.next();!M.done;M=j.next())if(x(Re=M.value,T)){if(f.Guard.isDocumentTypeNode(Re))throw new l.HierarchyRequestError;Ne.push(Re)}}catch(Fe){b={error:Fe}}finally{try{M&&!M.done&&(D=j.return)&&D.call(j)}finally{if(b)throw b.error}}if(d.tree_isAncestorOf(H,L,!0))Ve=L,Ge=B;else{for(var q=L;q._parent!==null&&!d.tree_isAncestorOf(H,q._parent);)q=q._parent;if(q._parent===null)throw new Error("Parent node is null.");Ve=q._parent,Ge=1+d.tree_index(q)}if(f.Guard.isCharacterDataNode(G))(K=p.node_clone(L))._data=g.characterData_substringData(L,B,d.tree_nodeLength(L)-B),v.mutation_append(K,O),g.characterData_replaceData(L,B,d.tree_nodeLength(L)-B,"");else if(G!==null){var K=p.node_clone(G);v.mutation_append(K,O);var J=S(u.create_range([L,B],[G,d.tree_nodeLength(G)]));v.mutation_append(J,K)}try{for(var re=o(Ne),ie=re.next();!ie.done;ie=re.next()){var Re=ie.value;v.mutation_append(Re,O)}}catch(Fe){I={error:Fe}}finally{try{ie&&!ie.done&&(P=re.return)&&P.call(re)}finally{if(I)throw I.error}}return f.Guard.isCharacterDataNode(ce)?((K=p.node_clone(H))._data=g.characterData_substringData(H,0,A),v.mutation_append(K,O),g.characterData_replaceData(H,0,A,"")):ce!==null&&(K=p.node_clone(ce),v.mutation_append(K,O),J=S(u.create_range([ce,0],[H,A])),v.mutation_append(J,K)),T._start=[Ve,Ge],T._end=[Ve,Ge],O}n.range_collapsed=m,n.range_root=w,n.range_isContained=x,n.range_isPartiallyContained=C,n.range_setTheStart=function(T,_,E){if(f.Guard.isDocumentTypeNode(_))throw new l.InvalidNodeTypeError;if(E>d.tree_nodeLength(_))throw new l.IndexSizeError;var b=[_,E];w(T)===d.tree_rootNode(_)&&h.boundaryPoint_position(b,T._end)!==c.BoundaryPosition.After||(T._end=b),T._start=b},n.range_setTheEnd=function(T,_,E){if(f.Guard.isDocumentTypeNode(_))throw new l.InvalidNodeTypeError;if(E>d.tree_nodeLength(_))throw new l.IndexSizeError;var b=[_,E];w(T)===d.tree_rootNode(_)&&h.boundaryPoint_position(b,T._start)!==c.BoundaryPosition.Before||(T._start=b),T._end=b},n.range_select=function(T,_){var E=T._parent;if(E===null)throw new l.InvalidNodeTypeError;var b=d.tree_index(T);_._start=[E,b],_._end=[E,b+1]},n.range_extract=S,n.range_cloneTheContents=function T(_){var E,b,D,I,P,O,L=u.create_documentFragment(_._startNode._nodeDocument);if(m(_))return L;var B=_._startNode,H=_._startOffset,A=_._endNode,F=_._endOffset;B===A&&f.Guard.isCharacterDataNode(B)&&((M=p.node_clone(B))._data=g.characterData_substringData(B,H,F-H),v.mutation_append(M,L));for(var G=B;!d.tree_isAncestorOf(A,G,!0);){if(G._parent===null)throw new Error("Parent node is null.");G=G._parent}var X=null;if(!d.tree_isAncestorOf(A,B,!0))try{for(var ee=o(G._children),ce=ee.next();!ce.done;ce=ee.next())if(C(Ve=ce.value,_)){X=Ve;break}}catch(ie){E={error:ie}}finally{try{ce&&!ce.done&&(b=ee.return)&&b.call(ee)}finally{if(E)throw E.error}}var Se=null;if(!d.tree_isAncestorOf(B,A,!0))for(var we=s(G._children),_e=we.length-1;_e>0;_e--){var Ve;if(C(Ve=we[_e],_)){Se=Ve;break}}var Ge=[];try{for(var Ne=o(G._children),j=Ne.next();!j.done;j=Ne.next())if(x(re=j.value,_)){if(f.Guard.isDocumentTypeNode(re))throw new l.HierarchyRequestError;Ge.push(re)}}catch(ie){D={error:ie}}finally{try{j&&!j.done&&(I=Ne.return)&&I.call(Ne)}finally{if(D)throw D.error}}if(f.Guard.isCharacterDataNode(X))(M=p.node_clone(B))._data=g.characterData_substringData(B,H,d.tree_nodeLength(B)-H),v.mutation_append(M,L);else if(X!==null){var M=p.node_clone(X);v.mutation_append(M,L);var q=T(u.create_range([B,H],[X,d.tree_nodeLength(X)]));v.mutation_append(q,M)}try{for(var K=o(Ge),J=K.next();!J.done;J=K.next()){var re=J.value,M=p.node_clone(re);v.mutation_append(M,L)}}catch(ie){P={error:ie}}finally{try{J&&!J.done&&(O=K.return)&&O.call(K)}finally{if(P)throw P.error}}return f.Guard.isCharacterDataNode(Se)?((M=p.node_clone(A))._data=g.characterData_substringData(A,0,F),v.mutation_append(M,L)):Se!==null&&(M=p.node_clone(Se),L.append(M),q=S(u.create_range([Se,0],[A,F])),v.mutation_append(q,M)),L},n.range_insert=function(T,_){var E,b;if(f.Guard.isProcessingInstructionNode(_._startNode)||f.Guard.isCommentNode(_._startNode)||f.Guard.isTextNode(_._startNode)&&_._startNode._parent===null||_._startNode===T)throw new l.HierarchyRequestError;var D,I=null;if(f.Guard.isTextNode(_._startNode))I=_._startNode;else{var P=0;try{for(var O=o(_._startNode._children),L=O.next();!L.done;L=O.next()){var B=L.value;if(P===_._startOffset){I=B;break}P++}}catch(A){E={error:A}}finally{try{L&&!L.done&&(b=O.return)&&b.call(O)}finally{if(E)throw E.error}}}if(I===null)D=_._startNode;else{if(I._parent===null)throw new Error("Parent node is null.");D=I._parent}v.mutation_ensurePreInsertionValidity(T,D,I),f.Guard.isTextNode(_._startNode)&&(I=y.text_split(_._startNode,_._startOffset)),T===I&&(I=T._nextSibling),T._parent!==null&&v.mutation_remove(T,T._parent);var H=I===null?d.tree_nodeLength(D):d.tree_index(I);f.Guard.isDocumentFragmentNode(T)?H+=d.tree_nodeLength(T):H++,v.mutation_preInsert(T,D,I),m(_)&&(_._end=[D,H])},n.range_getContainedNodes=function(T){var _;return(_={})[Symbol.iterator]=function(){var E=T.commonAncestorContainer,b=d.tree_getFirstDescendantNode(E);return{next:function(){for(;b&&!x(b,T);)b=d.tree_getNextDescendantNode(E,b);if(b===null)return{done:!0,value:null};var D={done:!1,value:b};return b=d.tree_getNextDescendantNode(E,b),D}}},_},n.range_getPartiallyContainedNodes=function(T){var _;return(_={})[Symbol.iterator]=function(){var E=T.commonAncestorContainer,b=d.tree_getFirstDescendantNode(E);return{next:function(){for(;b&&!C(b,T);)b=d.tree_getNextDescendantNode(E,b);if(b===null)return{done:!0,value:null};var D={done:!1,value:b};return b=d.tree_getNextDescendantNode(E,b),D}}},_}},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(9);n.selectors_scopeMatchASelectorsString=function(a,s){throw new o.NotSupportedError}},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(2),a=i(105);n.treeWalker_traverseChildren=function(s,c){for(var l=c?s._current._firstChild:s._current._lastChild;l!==null;){var f=a.traversal_filter(s,l);if(f===o.FilterResult.Accept)return s._current=l,l;if(f===o.FilterResult.Skip){var u=c?l._firstChild:l._lastChild;if(u!==null){l=u;continue}}for(;l!==null;){var d=c?l._nextSibling:l._previousSibling;if(d!==null){l=d;break}var h=l._parent;if(h===null||h===s._root||h===s._current)return null;l=h}}return null},n.treeWalker_traverseSiblings=function(s,c){var l=s._current;if(l===s._root)return null;for(;;){for(var f=c?l._nextSibling:l._previousSibling;f!==null;){l=f;var u=a.traversal_filter(s,l);if(u===o.FilterResult.Accept)return s._current=l,l;f=c?l._firstChild:l._lastChild,u!==o.FilterResult.Reject&&f!==null||(f=c?l._nextSibling:l._previousSibling)}if((l=l._parent)===null||l===s._root||a.traversal_filter(s,l)===o.FilterResult.Accept)return null}}},function(r,n,i){i(89),i(74);var o,a=this&&this.__extends||(o=function(d,h){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(g,p){g.__proto__=p}||function(g,p){for(var v in p)p.hasOwnProperty(v)&&(g[v]=p[v])})(d,h)},function(d,h){function g(){this.constructor=d}o(d,h),d.prototype=h===null?Object.create(h):(g.prototype=h.prototype,new g)});Object.defineProperty(n,"__esModule",{value:!0});var s=i(1),c=i(2),l=i(50),f=i(3),u=function(d){function h(g,p){var v=d.call(this,g)||this;return v._indentation={},v._lengthToLastNewline=0,v._writerOptions=s.applyDefaults(p,{wellFormed:!1,headless:!1,prettyPrint:!1,indent:" ",newline:`
|
||
`,offset:0,width:0,allowEmptyTags:!1,indentTextOnlyNodes:!1,spaceBeforeSlash:!1}),v}return a(h,d),h.prototype.serialize=function(g){return this._refs={suppressPretty:!1,emptyNode:!1,markup:""},g.nodeType!==c.NodeType.Document||this._writerOptions.headless||this.declaration(this._builderOptions.version,this._builderOptions.encoding,this._builderOptions.standalone),this.serializeNode(g,this._writerOptions.wellFormed),this._writerOptions.prettyPrint&&this._refs.markup.slice(-this._writerOptions.newline.length)===this._writerOptions.newline&&(this._refs.markup=this._refs.markup.slice(0,-this._writerOptions.newline.length)),this._refs.markup},h.prototype.declaration=function(g,p,v){this._beginLine(),this._refs.markup+='<?xml version="'+g+'"',p!==void 0&&(this._refs.markup+=' encoding="'+p+'"'),v!==void 0&&(this._refs.markup+=' standalone="'+(v?"yes":"no")+'"'),this._refs.markup+="?>",this._endLine()},h.prototype.docType=function(g,p,v){this._beginLine(),this._refs.markup+=p&&v?"<!DOCTYPE "+g+' PUBLIC "'+p+'" "'+v+'">':p?"<!DOCTYPE "+g+' PUBLIC "'+p+'">':v?"<!DOCTYPE "+g+' SYSTEM "'+v+'">':"<!DOCTYPE "+g+">",this._endLine()},h.prototype.openTagBegin=function(g){this._beginLine(),this._refs.markup+="<"+g},h.prototype.openTagEnd=function(g,p,v){if(this._refs.suppressPretty=!1,this._refs.emptyNode=!1,this._writerOptions.prettyPrint&&!p&&!v){for(var y=!0,m=!0,w=this.currentNode.firstChild,x=0,C=0;w;){if(f.Guard.isExclusiveTextNode(w))C++;else{if(!f.Guard.isCDATASectionNode(w)){y=!1,m=!1;break}x++}w.data!==""&&(m=!1),w=w.nextSibling}this._refs.suppressPretty=!this._writerOptions.indentTextOnlyNodes&&y&&(x<=1&&C===0||x===0),this._refs.emptyNode=m}(v||p||this._refs.emptyNode)&&this._writerOptions.allowEmptyTags?this._refs.markup+="></"+g+">":this._refs.markup+=v?" />":p||this._refs.emptyNode?this._writerOptions.spaceBeforeSlash?" />":"/>":">",this._endLine()},h.prototype.closeTag=function(g){this._refs.emptyNode||(this._beginLine(),this._refs.markup+="</"+g+">"),this._refs.suppressPretty=!1,this._refs.emptyNode=!1,this._endLine()},h.prototype.attribute=function(g,p){var v=g+'="'+p+'"';this._writerOptions.prettyPrint&&this._writerOptions.width>0&&this._refs.markup.length-this._lengthToLastNewline+1+v.length>this._writerOptions.width?(this._endLine(),this._beginLine(),this._refs.markup+=this._indent(1)+v):this._refs.markup+=" "+v},h.prototype.text=function(g){g!==""&&(this._beginLine(),this._refs.markup+=g,this._endLine())},h.prototype.cdata=function(g){g!==""&&(this._beginLine(),this._refs.markup+="<![CDATA["+g+"]]>",this._endLine())},h.prototype.comment=function(g){this._beginLine(),this._refs.markup+="<!--"+g+"-->",this._endLine()},h.prototype.instruction=function(g,p){this._beginLine(),this._refs.markup+="<?"+(p===""?g:g+" "+p)+"?>",this._endLine()},h.prototype._beginLine=function(){this._writerOptions.prettyPrint&&!this._refs.suppressPretty&&(this._refs.markup+=this._indent(this._writerOptions.offset+this.level))},h.prototype._endLine=function(){this._writerOptions.prettyPrint&&!this._refs.suppressPretty&&(this._refs.markup+=this._writerOptions.newline,this._lengthToLastNewline=this._refs.markup.length)},h.prototype._indent=function(g){if(g<=0)return"";if(this._indentation[g]!==void 0)return this._indentation[g];var p=this._writerOptions.indent.repeat(g);return this._indentation[g]=p,p},h}(l.BaseWriter);n.XMLWriter=u},function(r,n,i){var o=i(47),a=i(35);r.exports="".repeat||function(s){var c=String(a(this)),l="",f=o(s);if(f<0||f==1/0)throw RangeError("Wrong number of repetitions");for(;f>0;(f>>>=1)&&(c+=c))1&f&&(l+=c);return l}},function(r,n,i){i(31),i(32),i(33),i(19),i(178),i(20),i(22),i(23);var o,a=this&&this.__extends||(o=function(u,d){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(h,g){h.__proto__=g}||function(h,g){for(var p in g)g.hasOwnProperty(p)&&(h[p]=g[p])})(u,d)},function(u,d){function h(){this.constructor=u}o(u,d),u.prototype=d===null?Object.create(d):(h.prototype=d.prototype,new h)}),s=this&&this.__values||function(u){var d=typeof Symbol=="function"&&Symbol.iterator,h=d&&u[d],g=0;if(h)return h.call(u);if(u&&typeof u.length=="number")return{next:function(){return u&&g>=u.length&&(u=void 0),{value:u&&u[g++],done:!u}}};throw new TypeError(d?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var c=i(67),l=i(1),f=function(u){function d(h,g){var p=u.call(this,h)||this;return p._writerOptions=l.applyDefaults(g,{wellFormed:!1,prettyPrint:!1,indent:" ",newline:`
|
||
`,offset:0,group:!1,verbose:!1}),p}return a(d,u),d.prototype.serialize=function(h){var g=l.applyDefaults(this._writerOptions,{format:"object",wellFormed:!1}),p=new c.ObjectWriter(this._builderOptions,g).serialize(h);return this._beginLine(this._writerOptions,0)+this._convertObject(p,this._writerOptions)},d.prototype._convertObject=function(h,g,p){var v,y,m=this;p===void 0&&(p=0);var w="",x=this._isLeafNode(h);if(l.isArray(h)){w+="[";var C=h.length,S=0;try{for(var T=s(h),_=T.next();!_.done;_=T.next()){var E=_.value;w+=this._endLine(g,p+1)+this._beginLine(g,p+1)+this._convertObject(E,g,p+1),S<C-1&&(w+=","),S++}}catch(I){v={error:I}}finally{try{_&&!_.done&&(y=T.return)&&y.call(T)}finally{if(v)throw v.error}}w+=this._endLine(g,p)+this._beginLine(g,p),w+="]"}else if(l.isObject(h)){w+="{";var b=l.objectLength(h),D=0;l.forEachObject(h,function(I,P){x&&g.prettyPrint?w+=" ":w+=m._endLine(g,p+1)+m._beginLine(g,p+1),w+=m._key(I),g.prettyPrint&&(w+=" "),w+=m._convertObject(P,g,p+1),D<b-1&&(w+=","),D++},this),x&&g.prettyPrint?w+=" ":w+=this._endLine(g,p)+this._beginLine(g,p),w+="}"}else w+=this._val(h);return w},d.prototype._beginLine=function(h,g){if(!h.prettyPrint)return"";var p=h.offset+g+1;return p>0?new Array(p).join(h.indent):""},d.prototype._endLine=function(h,g){return h.prettyPrint?h.newline:""},d.prototype._key=function(h){return'"'+h+'":'},d.prototype._val=function(h){return JSON.stringify(h)},d.prototype._isLeafNode=function(h){return this._descendantCount(h)<=1},d.prototype._descendantCount=function(h,g){var p=this;return g===void 0&&(g=0),l.isArray(h)?l.forEachArray(h,function(v){return g+=p._descendantCount(v,g)},this):l.isObject(h)?l.forEachObject(h,function(v,y){return g+=p._descendantCount(y,g)},this):g++,g},d}(i(50).BaseWriter);n.JSONWriter=f},function(r,n,i){i(31),i(32),i(33),i(19),i(178),i(89),i(20),i(22),i(23);var o,a=this&&this.__extends||(o=function(u,d){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(h,g){h.__proto__=g}||function(h,g){for(var p in g)g.hasOwnProperty(p)&&(h[p]=g[p])})(u,d)},function(u,d){function h(){this.constructor=u}o(u,d),u.prototype=d===null?Object.create(d):(h.prototype=d.prototype,new h)}),s=this&&this.__values||function(u){var d=typeof Symbol=="function"&&Symbol.iterator,h=d&&u[d],g=0;if(h)return h.call(u);if(u&&typeof u.length=="number")return{next:function(){return u&&g>=u.length&&(u=void 0),{value:u&&u[g++],done:!u}}};throw new TypeError(d?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var c=i(67),l=i(1),f=function(u){function d(h,g){var p=u.call(this,h)||this;if(p._writerOptions=l.applyDefaults(g,{wellFormed:!1,indent:" ",newline:`
|
||
`,offset:0,group:!1,verbose:!1}),p._writerOptions.indent.length<2)throw new Error("YAML indententation string must be at least two characters long.");if(p._writerOptions.offset<0)throw new Error("YAML offset should be zero or a positive number.");return p}return a(d,u),d.prototype.serialize=function(h){var g=l.applyDefaults(this._writerOptions,{format:"object",wellFormed:!1}),p=new c.ObjectWriter(this._builderOptions,g).serialize(h),v=this._beginLine(this._writerOptions,0)+"---"+this._endLine(this._writerOptions)+this._convertObject(p,this._writerOptions,0);return v.slice(-this._writerOptions.newline.length)===this._writerOptions.newline&&(v=v.slice(0,-this._writerOptions.newline.length)),v},d.prototype._convertObject=function(h,g,p,v){var y,m,w=this;v===void 0&&(v=!1);var x="";if(l.isArray(h))try{for(var C=s(h),S=C.next();!S.done;S=C.next()){var T=S.value;x+=this._beginLine(g,p,!0),l.isObject(T)?l.isEmpty(T)?x+='""'+this._endLine(g):x+=this._convertObject(T,g,p,!0):x+=this._val(T)+this._endLine(g)}}catch(_){y={error:_}}finally{try{S&&!S.done&&(m=C.return)&&m.call(C)}finally{if(y)throw y.error}}else l.forEachObject(h,function(_,E){v?(x+=w._key(_),v=!1):x+=w._beginLine(g,p)+w._key(_),l.isObject(E)?l.isEmpty(E)?x+=' ""'+w._endLine(g):x+=w._endLine(g)+w._convertObject(E,g,p+1):x+=" "+w._val(E)+w._endLine(g)},this);return x},d.prototype._beginLine=function(h,g,p){p===void 0&&(p=!1);var v=h.offset+g+1,y=new Array(v).join(h.indent);return p?y.substr(0,y.length-2)+"-"+y.substr(-1,1):y},d.prototype._endLine=function(h){return h.newline},d.prototype._key=function(h){return'"'+h+'":'},d.prototype._val=function(h){return JSON.stringify(h)},d}(i(50).BaseWriter);n.YAMLWriter=f},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0}),i(110).dom.setFeatures(!0);var o=i(110);n.DOMImplementation=o.DOMImplementation;var a=i(271);n.DOMParser=a.DOMParser;var s=i(274);n.XMLSerializer=s.XMLSerializer},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(3),a=i(0),s=function(){function c(){}return c.prototype.before=function(){for(var l=[],f=0;f<arguments.length;f++)l[f]=arguments[f];var u=o.Cast.asNode(this),d=u._parent;if(d!==null){for(var h=u._previousSibling,g=!0;g&&h;){g=!1;for(var p=0;p<l.length;p++){var v=l[p];if(v===h){h=h._previousSibling,g=!0;break}}}var y=a.parentNode_convertNodesIntoANode(l,u._nodeDocument);h=h===null?d._firstChild:h._nextSibling,a.mutation_preInsert(y,d,h)}},c.prototype.after=function(){for(var l=[],f=0;f<arguments.length;f++)l[f]=arguments[f];var u=o.Cast.asNode(this),d=u._parent;if(d){for(var h=u._nextSibling,g=!0;g&&h;){g=!1;for(var p=0;p<l.length;p++){var v=l[p];if(v===h){h=h._nextSibling,g=!0;break}}}var y=a.parentNode_convertNodesIntoANode(l,u._nodeDocument);a.mutation_preInsert(y,d,h)}},c.prototype.replaceWith=function(){for(var l=[],f=0;f<arguments.length;f++)l[f]=arguments[f];var u=o.Cast.asNode(this),d=u._parent;if(d){for(var h=u._nextSibling,g=!0;g&&h;){g=!1;for(var p=0;p<l.length;p++){var v=l[p];if(v===h){h=h._nextSibling,g=!0;break}}}var y=a.parentNode_convertNodesIntoANode(l,u._nodeDocument);u._parent===d?a.mutation_replace(u,y,d):a.mutation_preInsert(y,d,h)}},c.prototype.remove=function(){var l=o.Cast.asNode(this),f=l._parent;f&&a.mutation_remove(l,f)},c}();n.ChildNodeImpl=s},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=function(){};n.DocumentOrShadowRootImpl=o},function(r,n,i){var o=this&&this.__values||function(f){var u=typeof Symbol=="function"&&Symbol.iterator,d=u&&f[u],h=0;if(d)return d.call(f);if(f&&typeof f.length=="number")return{next:function(){return f&&h>=f.length&&(f=void 0),{value:f&&f[h++],done:!f}}};throw new TypeError(u?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var a=i(6),s=i(3),c=i(7),l=function(){function f(u){this._nodeList=[],this._recordQueue=[],this._callback=u;var d=a.dom.window;c.set.append(d._mutationObservers,this)}return f.prototype.observe=function(u,d){var h,g;if((d=d||{childList:!1,subtree:!1}).attributeOldValue===void 0&&d.attributeFilter===void 0||d.attributes!==void 0||(d.attributes=!0),d.characterDataOldValue!==void 0&&d.characterData===void 0&&(d.characterData=!0),!d.childList&&!d.attributes&&!d.characterData)throw new TypeError;if(d.attributeOldValue&&!d.attributes)throw new TypeError;if(d.attributeFilter!==void 0&&!d.attributes)throw new TypeError;if(d.characterDataOldValue&&!d.characterData)throw new TypeError;var p=!1,v=d,y=function(C){var S,T;if(C.observer===m){p=!0;try{for(var _=(S=void 0,o(m._nodeList)),E=_.next();!E.done;E=_.next()){var b=E.value;c.list.remove(b._registeredObserverList,function(D){return s.Guard.isTransientRegisteredObserver(D)&&D.source===C})}}catch(D){S={error:D}}finally{try{E&&!E.done&&(T=_.return)&&T.call(_)}finally{if(S)throw S.error}}C.options=v}},m=this;try{for(var w=o(u._registeredObserverList),x=w.next();!x.done;x=w.next())y(x.value)}catch(C){h={error:C}}finally{try{x&&!x.done&&(g=w.return)&&g.call(w)}finally{if(h)throw h.error}}p||(u._registeredObserverList.push({observer:this,options:d}),this._nodeList.push(u))},f.prototype.disconnect=function(){var u,d,h=this;try{for(var g=o(this._nodeList),p=g.next();!p.done;p=g.next()){var v=p.value;c.list.remove(v._registeredObserverList,function(y){return y.observer===h})}}catch(y){u={error:y}}finally{try{p&&!p.done&&(d=g.return)&&d.call(g)}finally{if(u)throw u.error}}this._recordQueue=[]},f.prototype.takeRecords=function(){var u=this._recordQueue;return this._recordQueue=[],u},f}();n.MutationObserverImpl=l},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(3),a=function(){function s(){}return Object.defineProperty(s.prototype,"previousElementSibling",{get:function(){for(var c=o.Cast.asNode(this)._previousSibling;c;){if(o.Guard.isElementNode(c))return c;c=c._previousSibling}return null},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"nextElementSibling",{get:function(){for(var c=o.Cast.asNode(this)._nextSibling;c;){if(o.Guard.isElementNode(c))return c;c=c._nextSibling}return null},enumerable:!0,configurable:!0}),s}();n.NonDocumentTypeChildNodeImpl=a},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(3),a=i(0),s=function(){function c(){}return c.prototype.getElementById=function(l){for(var f=a.tree_getFirstDescendantNode(o.Cast.asNode(this),!1,!1,function(u){return o.Guard.isElementNode(u)});f!==null;){if(f._uniqueIdentifier===l)return f;f=a.tree_getNextDescendantNode(o.Cast.asNode(this),f,!1,!1,function(u){return o.Guard.isElementNode(u)})}return null},c}();n.NonElementParentNodeImpl=s},function(r,n,i){var o=this&&this.__values||function(l){var f=typeof Symbol=="function"&&Symbol.iterator,u=f&&l[f],d=0;if(u)return u.call(l);if(l&&typeof l.length=="number")return{next:function(){return l&&d>=l.length&&(l=void 0),{value:l&&l[d++],done:!l}}};throw new TypeError(f?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var a=i(3),s=i(0),c=function(){function l(){}return Object.defineProperty(l.prototype,"children",{get:function(){return s.create_htmlCollection(a.Cast.asNode(this))},enumerable:!0,configurable:!0}),Object.defineProperty(l.prototype,"firstElementChild",{get:function(){for(var f=a.Cast.asNode(this)._firstChild;f;){if(a.Guard.isElementNode(f))return f;f=f._nextSibling}return null},enumerable:!0,configurable:!0}),Object.defineProperty(l.prototype,"lastElementChild",{get:function(){for(var f=a.Cast.asNode(this)._lastChild;f;){if(a.Guard.isElementNode(f))return f;f=f._previousSibling}return null},enumerable:!0,configurable:!0}),Object.defineProperty(l.prototype,"childElementCount",{get:function(){var f,u,d=0;try{for(var h=o(a.Cast.asNode(this)._children),g=h.next();!g.done;g=h.next()){var p=g.value;a.Guard.isElementNode(p)&&d++}}catch(v){f={error:v}}finally{try{g&&!g.done&&(u=h.return)&&u.call(h)}finally{if(f)throw f.error}}return d},enumerable:!0,configurable:!0}),l.prototype.prepend=function(){for(var f=[],u=0;u<arguments.length;u++)f[u]=arguments[u];var d=a.Cast.asNode(this),h=s.parentNode_convertNodesIntoANode(f,d._nodeDocument);s.mutation_preInsert(h,d,d._firstChild)},l.prototype.append=function(){for(var f=[],u=0;u<arguments.length;u++)f[u]=arguments[u];var d=a.Cast.asNode(this),h=s.parentNode_convertNodesIntoANode(f,d._nodeDocument);s.mutation_append(h,d)},l.prototype.querySelector=function(f){var u=a.Cast.asNode(this),d=s.selectors_scopeMatchASelectorsString(f,u);return d.length===0?null:d[0]},l.prototype.querySelectorAll=function(f){var u=a.Cast.asNode(this),d=s.selectors_scopeMatchASelectorsString(f,u);return s.create_nodeListStatic(u,d)},l}();n.ParentNodeImpl=c},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(0),a=function(){function s(){}return Object.defineProperty(s.prototype,"_name",{get:function(){return this.__name||""},set:function(c){this.__name=c},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"_assignedSlot",{get:function(){return this.__assignedSlot||null},set:function(c){this.__assignedSlot=c},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"assignedSlot",{get:function(){return o.shadowTree_findASlot(this,!0)},enumerable:!0,configurable:!0}),s}();n.SlotableImpl=a},function(r,n,i){var o,a=this&&this.__extends||(o=function(u,d){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(h,g){h.__proto__=g}||function(h,g){for(var p in g)g.hasOwnProperty(p)&&(h[p]=g[p])})(u,d)},function(u,d){function h(){this.constructor=u}o(u,d),u.prototype=d===null?Object.create(d):(h.prototype=d.prototype,new h)});Object.defineProperty(n,"__esModule",{value:!0});var s=i(102),c=i(9),l=i(3),f=function(u){function d(h){var g=u.call(this)||this;if(l.Guard.isDocumentTypeNode(h.startContainer)||l.Guard.isAttrNode(h.startContainer)||l.Guard.isDocumentTypeNode(h.endContainer)||l.Guard.isAttrNode(h.endContainer))throw new c.InvalidNodeTypeError;return g._start=[h.startContainer,h.startOffset],g._end=[h.endContainer,h.endOffset],g}return a(d,u),d}(s.AbstractRangeImpl);n.StaticRangeImpl=f},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(272);n.DOMParser=o.DOMParserImpl},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(0),a=i(273),s=function(){function c(){}return c.prototype.parseFromString=function(l,f){if(f==="text/html")throw new Error("HTML parser not implemented.");try{return(u=new a.XMLParserImpl().parse(l))._contentType=f,u}catch(p){var u,d="http://www.mozilla.org/newlayout/xml/parsererror.xml",h=(u=o.create_xmlDocument()).createElementNS(d,"parsererror"),g=u.createElementNS(d,"error");return g.setAttribute("message",p.message),h.appendChild(g),u.appendChild(h),u}},c}();n.DOMParserImpl=s},function(r,n,i){var o=this&&this.__read||function(h,g){var p=typeof Symbol=="function"&&h[Symbol.iterator];if(!p)return h;var v,y,m=p.call(h),w=[];try{for(;(g===void 0||g-- >0)&&!(v=m.next()).done;)w.push(v.value)}catch(x){y={error:x}}finally{try{v&&!v.done&&(p=m.return)&&p.call(m)}finally{if(y)throw y.error}}return w},a=this&&this.__values||function(h){var g=typeof Symbol=="function"&&Symbol.iterator,p=g&&h[g],v=0;if(p)return p.call(h);if(h&&typeof h.length=="number")return{next:function(){return h&&v>=h.length&&(h=void 0),{value:h&&h[v++],done:!h}}};throw new TypeError(g?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var s=i(180),c=i(111),l=i(7),f=i(0),u=i(69),d=function(){function h(){}return h.prototype.parse=function(g){for(var p,v,y,m,w=new s.XMLStringLexer(g,{skipWhitespaceOnlyText:!0}),x=f.create_document(),C=x,S=w.nextToken();S.type!==c.TokenType.EOF;){switch(S.type){case c.TokenType.Declaration:var T=S;if(T.version!=="1.0")throw new Error("Invalid xml version: "+T.version);break;case c.TokenType.DocType:var _=S;if(!f.xml_isPubidChar(_.pubId))throw new Error("DocType public identifier does not match PubidChar construct.");if(!f.xml_isLegalChar(_.sysId)||_.sysId.indexOf('"')!==-1&&_.sysId.indexOf("'")!==-1)throw new Error("DocType system identifier contains invalid characters.");C.appendChild(x.implementation.createDocumentType(_.name,_.pubId,_.sysId));break;case c.TokenType.CDATA:var E=S;if(!f.xml_isLegalChar(E.data)||E.data.indexOf("]]>")!==-1)throw new Error("CDATA contains invalid characters.");C.appendChild(x.createCDATASection(E.data));break;case c.TokenType.Comment:var b=S;if(!f.xml_isLegalChar(b.data)||b.data.indexOf("--")!==-1||b.data.endsWith("-"))throw new Error("Comment data contains invalid characters.");C.appendChild(x.createComment(b.data));break;case c.TokenType.PI:var D=S;if(D.target.indexOf(":")!==-1||/^xml$/i.test(D.target))throw new Error("Processing instruction target contains invalid characters.");if(!f.xml_isLegalChar(D.data)||D.data.indexOf("?>")!==-1)throw new Error("Processing instruction data contains invalid characters.");C.appendChild(x.createProcessingInstruction(D.target,D.data));break;case c.TokenType.Text:var I=S;if(!f.xml_isLegalChar(I.data))throw new Error("Text data contains invalid characters.");C.appendChild(x.createTextNode(this._decodeText(I.data)));break;case c.TokenType.Element:var P=S,O=o(f.namespace_extractQName(P.name),2),L=O[0],B=O[1];if(B.indexOf(":")!==-1||!f.xml_isName(B))throw new Error("Node local name contains invalid characters.");if(L==="xmlns")throw new Error("An element cannot have the 'xmlns' prefix.");var H=C.lookupNamespaceURI(L),A={};try{for(var F=(p=void 0,a(P.attributes)),G=F.next();!G.done;G=F.next()){var X=o(G.value,2),ee=X[0],ce=X[1];if(ee==="xmlns")H=ce;else{var Se=o(f.namespace_extractQName(ee),2),we=Se[0],_e=Se[1];we==="xmlns"&&(_e===L&&(H=ce),A[_e]=ce)}}}catch(J){p={error:J}}finally{try{G&&!G.done&&(v=F.return)&&v.call(F)}finally{if(p)throw p.error}}var Ve=H!==null?x.createElementNS(H,P.name):x.createElement(P.name);C.appendChild(Ve);var Ge=new u.LocalNameSet;try{for(var Ne=(y=void 0,a(P.attributes)),j=Ne.next();!j.done;j=Ne.next()){var M=o(j.value,2),q=(ee=M[0],ce=M[1],o(f.namespace_extractQName(ee),2)),K=(we=q[0],_e=q[1],null);if(we==="xmlns"||we===null&&_e==="xmlns"?K=l.namespace.XMLNS:(K=Ve.lookupNamespaceURI(we))!==null&&Ve.isDefaultNamespace(K)?K=null:K===null&&we!==null&&(K=A[we]||null),Ge.has(K,_e))throw new Error("Element contains duplicate attributes.");if(Ge.set(K,_e),K===l.namespace.XMLNS&&ce===l.namespace.XMLNS)throw new Error("XMLNS namespace is reserved.");if(_e.indexOf(":")!==-1||!f.xml_isName(_e))throw new Error("Attribute local name contains invalid characters.");if(we==="xmlns"&&ce==="")throw new Error("Empty XML namespace is not allowed.");K!==null?Ve.setAttributeNS(K,ee,this._decodeAttributeValue(ce)):Ve.setAttribute(ee,this._decodeAttributeValue(ce))}}catch(J){y={error:J}}finally{try{j&&!j.done&&(m=Ne.return)&&m.call(Ne)}finally{if(y)throw y.error}}P.selfClosing||(C=Ve);break;case c.TokenType.ClosingTag:if(S.name!==C.nodeName)throw new Error("Closing tag name does not match opening tag name.");C._parent&&(C=C._parent)}S=w.nextToken()}return x},h.prototype._decodeText=function(g){return g==null?g:g.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")},h.prototype._decodeAttributeValue=function(g){return g==null?g:g.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")},h}();n.XMLParserImpl=d},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(275);n.XMLSerializer=o.XMLSerializerImpl},function(r,n,i){var o=this&&this.__values||function(h){var g=typeof Symbol=="function"&&Symbol.iterator,p=g&&h[g],v=0;if(p)return p.call(h);if(h&&typeof h.length=="number")return{next:function(){return h&&v>=h.length&&(h=void 0),{value:h&&h[v++],done:!h}}};throw new TypeError(g?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var a=i(2),s=i(69),c=i(95),l=i(9),f=i(7),u=i(0),d=function(){function h(){}return h.prototype.serializeToString=function(g){return this._xmlSerialization(g,!1)},h.prototype._xmlSerialization=function(g,p){if(g._nodeDocument===void 0||g._nodeDocument._hasNamespaces){var v=new c.NamespacePrefixMap;v.set("xml",f.namespace.XML);try{return this._serializeNodeNS(g,null,v,{value:1},p)}catch{throw new l.InvalidStateError}}else try{return this._serializeNode(g,p)}catch{throw new l.InvalidStateError}},h.prototype._serializeNodeNS=function(g,p,v,y,m){switch(g.nodeType){case a.NodeType.Element:return this._serializeElementNS(g,p,v,y,m);case a.NodeType.Document:return this._serializeDocumentNS(g,p,v,y,m);case a.NodeType.Comment:return this._serializeComment(g,m);case a.NodeType.Text:return this._serializeText(g,m);case a.NodeType.DocumentFragment:return this._serializeDocumentFragmentNS(g,p,v,y,m);case a.NodeType.DocumentType:return this._serializeDocumentType(g,m);case a.NodeType.ProcessingInstruction:return this._serializeProcessingInstruction(g,m);case a.NodeType.CData:return this._serializeCData(g,m);default:throw new Error("Unknown node type: "+g.nodeType)}},h.prototype._serializeNode=function(g,p){switch(g.nodeType){case a.NodeType.Element:return this._serializeElement(g,p);case a.NodeType.Document:return this._serializeDocument(g,p);case a.NodeType.Comment:return this._serializeComment(g,p);case a.NodeType.Text:return this._serializeText(g,p);case a.NodeType.DocumentFragment:return this._serializeDocumentFragment(g,p);case a.NodeType.DocumentType:return this._serializeDocumentType(g,p);case a.NodeType.ProcessingInstruction:return this._serializeProcessingInstruction(g,p);case a.NodeType.CData:return this._serializeCData(g,p);default:throw new Error("Unknown node type: "+g.nodeType)}},h.prototype._serializeElementNS=function(g,p,v,y,m){var w,x;if(m&&(g.localName.indexOf(":")!==-1||!u.xml_isName(g.localName)))throw new Error("Node local name contains invalid characters (well-formed required).");var C="<",S="",T=!1,_=!1,E=v.copy(),b={},D=this._recordNamespaceInformation(g,E,b),I=p,P=g.namespaceURI;if(I===P)D!==null&&(_=!0),C+=S=P===f.namespace.XML?"xml:"+g.localName:g.localName;else{var O=g.prefix,L=null;if(O===null&&P===D||(L=E.get(O,P)),O==="xmlns"){if(m)throw new Error("An element cannot have the 'xmlns' prefix (well-formed required).");L=O}L!==null?(S=L+":"+g.localName,D!==null&&D!==f.namespace.XML&&(I=D||null),C+=S):O!==null?(O in b&&(O=this._generatePrefix(P,E,y)),E.set(O,P),C+=S+=O+":"+g.localName,C+=" xmlns:"+O+'="'+this._serializeAttributeValue(P,m)+'"',D!==null&&(I=D||null)):D===null||D!==null&&D!==P?(_=!0,I=P,C+=S+=g.localName,C+=' xmlns="'+this._serializeAttributeValue(P,m)+'"'):(I=P,C+=S+=g.localName)}C+=this._serializeAttributesNS(g,E,y,b,_,m);var B=P===f.namespace.HTML;if(B&&g.childNodes.length===0&&h._VoidElementNames.has(g.localName)?(C+=" /",T=!0):B||g.childNodes.length!==0||(C+="/",T=!0),C+=">",T)return C;if(!(B&&g.localName==="template"))try{for(var H=o(g._children||g.childNodes),A=H.next();!A.done;A=H.next()){var F=A.value;C+=this._serializeNodeNS(F,I,E,y,m)}}catch(G){w={error:G}}finally{try{A&&!A.done&&(x=H.return)&&x.call(H)}finally{if(w)throw w.error}}return C+="</"+S+">"},h.prototype._serializeDocumentNS=function(g,p,v,y,m){var w,x;if(m&&g.documentElement===null)throw new Error("Missing document element (well-formed required).");var C="";try{for(var S=o(g._children||g.childNodes),T=S.next();!T.done;T=S.next()){var _=T.value;C+=this._serializeNodeNS(_,p,v,y,m)}}catch(E){w={error:E}}finally{try{T&&!T.done&&(x=S.return)&&x.call(S)}finally{if(w)throw w.error}}return C},h.prototype._serializeComment=function(g,p){if(p&&(!u.xml_isLegalChar(g.data)||g.data.indexOf("--")!==-1||g.data.endsWith("-")))throw new Error("Comment data contains invalid characters (well-formed required).");return"<!--"+g.data+"-->"},h.prototype._serializeText=function(g,p){if(p&&!u.xml_isLegalChar(g.data))throw new Error("Text data contains invalid characters (well-formed required).");for(var v="",y=0;y<g.data.length;y++){var m=g.data[y];v+=m==="&"?"&":m==="<"?"<":m===">"?">":m}return v},h.prototype._serializeDocumentFragmentNS=function(g,p,v,y,m){var w,x,C="";try{for(var S=o(g._children||g.childNodes),T=S.next();!T.done;T=S.next()){var _=T.value;C+=this._serializeNodeNS(_,p,v,y,m)}}catch(E){w={error:E}}finally{try{T&&!T.done&&(x=S.return)&&x.call(S)}finally{if(w)throw w.error}}return C},h.prototype._serializeDocumentType=function(g,p){if(p&&!u.xml_isPubidChar(g.publicId))throw new Error("DocType public identifier does not match PubidChar construct (well-formed required).");if(p&&(!u.xml_isLegalChar(g.systemId)||g.systemId.indexOf('"')!==-1&&g.systemId.indexOf("'")!==-1))throw new Error("DocType system identifier contains invalid characters (well-formed required).");return g.publicId&&g.systemId?"<!DOCTYPE "+g.name+' PUBLIC "'+g.publicId+'" "'+g.systemId+'">':g.publicId?"<!DOCTYPE "+g.name+' PUBLIC "'+g.publicId+'">':g.systemId?"<!DOCTYPE "+g.name+' SYSTEM "'+g.systemId+'">':"<!DOCTYPE "+g.name+">"},h.prototype._serializeProcessingInstruction=function(g,p){if(p&&(g.target.indexOf(":")!==-1||/^xml$/i.test(g.target)))throw new Error("Processing instruction target contains invalid characters (well-formed required).");if(p&&(!u.xml_isLegalChar(g.data)||g.data.indexOf("?>")!==-1))throw new Error("Processing instruction data contains invalid characters (well-formed required).");return"<?"+(g.data===""?g.target:g.target+" "+g.data)+"?>"},h.prototype._serializeCData=function(g,p){if(p&&g.data.indexOf("]]>")!==-1)throw new Error("CDATA contains invalid characters (well-formed required).");return"<![CDATA["+g.data+"]]>"},h.prototype._serializeAttributesNS=function(g,p,v,y,m,w){var x,C,S="",T=w?new s.LocalNameSet:void 0;try{for(var _=o(g.attributes),E=_.next();!E.done;E=_.next()){var b=E.value;if(m||w||b.namespaceURI!==null){if(w&&T&&T.has(b.namespaceURI,b.localName))throw new Error("Element contains duplicate attributes (well-formed required).");w&&T&&T.set(b.namespaceURI,b.localName);var D=b.namespaceURI,I=null;if(D!==null)if(I=p.get(b.prefix,D),D===f.namespace.XMLNS){if(b.value===f.namespace.XML||b.prefix===null&&m||b.prefix!==null&&(!(b.localName in y)||y[b.localName]!==b.value)&&p.has(b.localName,b.value))continue;if(w&&b.value===f.namespace.XMLNS)throw new Error("XMLNS namespace is reserved (well-formed required).");if(w&&b.value==="")throw new Error("Namespace prefix declarations cannot be used to undeclare a namespace (well-formed required).");b.prefix==="xmlns"&&(I="xmlns")}else I===null&&(S+=" xmlns:"+(I=b.prefix===null||p.hasPrefix(b.prefix)&&!p.has(b.prefix,D)?this._generatePrefix(D,p,v):b.prefix)+'="'+this._serializeAttributeValue(D,w)+'"');if(S+=" ",I!==null&&(S+=I+":"),w&&(b.localName.indexOf(":")!==-1||!u.xml_isName(b.localName)||b.localName==="xmlns"&&D===null))throw new Error("Attribute local name contains invalid characters (well-formed required).");S+=b.localName+'="'+this._serializeAttributeValue(b.value,w)+'"'}else S+=" "+b.localName+'="'+this._serializeAttributeValue(b.value,w)+'"'}}catch(P){x={error:P}}finally{try{E&&!E.done&&(C=_.return)&&C.call(_)}finally{if(x)throw x.error}}return S},h.prototype._recordNamespaceInformation=function(g,p,v){var y,m,w=null;try{for(var x=o(g.attributes),C=x.next();!C.done;C=x.next()){var S=C.value,T=S.namespaceURI,_=S.prefix;if(T===f.namespace.XMLNS){if(_===null){w=S.value;continue}var E=S.localName,b=S.value;if(b===f.namespace.XML||(b===""&&(b=null),p.has(E,b)))continue;p.set(E,b),v[E]=b||""}}}catch(D){y={error:D}}finally{try{C&&!C.done&&(m=x.return)&&m.call(x)}finally{if(y)throw y.error}}return w},h.prototype._generatePrefix=function(g,p,v){var y="ns"+v.value;return v.value++,p.set(y,g),y},h.prototype._serializeAttributeValue=function(g,p){if(p&&g!==null&&!u.xml_isLegalChar(g))throw new Error("Invalid characters in attribute value.");if(g===null)return"";for(var v="",y=0;y<g.length;y++){var m=g[y];v+=m==='"'?""":m==="&"?"&":m==="<"?"<":m===">"?">":m}return v},h.prototype._serializeElement=function(g,p){var v,y;if(p&&(g.localName.indexOf(":")!==-1||!u.xml_isName(g.localName)))throw new Error("Node local name contains invalid characters (well-formed required).");var m=!1,w=g.localName,x="<"+w;if(x+=this._serializeAttributes(g,p),g._children.size===0&&(x+="/",m=!0),x+=">",m)return x;try{for(var C=o(g._children),S=C.next();!S.done;S=C.next()){var T=S.value;x+=this._serializeNode(T,p)}}catch(_){v={error:_}}finally{try{S&&!S.done&&(y=C.return)&&y.call(C)}finally{if(v)throw v.error}}return x+="</"+w+">"},h.prototype._serializeDocument=function(g,p){var v,y;if(p&&g.documentElement===null)throw new Error("Missing document element (well-formed required).");var m="";try{for(var w=o(g._children),x=w.next();!x.done;x=w.next()){var C=x.value;m+=this._serializeNode(C,p)}}catch(S){v={error:S}}finally{try{x&&!x.done&&(y=w.return)&&y.call(w)}finally{if(v)throw v.error}}return m},h.prototype._serializeDocumentFragment=function(g,p){var v,y,m="";try{for(var w=o(g._children),x=w.next();!x.done;x=w.next()){var C=x.value;m+=this._serializeNode(C,p)}}catch(S){v={error:S}}finally{try{x&&!x.done&&(y=w.return)&&y.call(w)}finally{if(v)throw v.error}}return m},h.prototype._serializeAttributes=function(g,p){var v,y,m="",w=p?{}:void 0;try{for(var x=o(g.attributes),C=x.next();!C.done;C=x.next()){var S=C.value;if(p&&w&&S.localName in w)throw new Error("Element contains duplicate attributes (well-formed required).");if(p&&w&&(w[S.localName]=!0),p&&(S.localName.indexOf(":")!==-1||!u.xml_isName(S.localName)))throw new Error("Attribute local name contains invalid characters (well-formed required).");m+=" "+S.localName+'="'+this._serializeAttributeValue(S.value,p)+'"'}}catch(T){v={error:T}}finally{try{C&&!C.done&&(y=x.return)&&y.call(x)}finally{if(v)throw v.error}}return m},h._VoidElementNames=new Set(["area","base","basefont","bgsound","br","col","embed","frame","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"]),h}();n.XMLSerializerImpl=d},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(277);n.XMLReader=o.XMLReader;var a=i(112);n.ObjectReader=a.ObjectReader;var s=i(280);n.JSONReader=s.JSONReader;var c=i(281);n.YAMLReader=c.YAMLReader},function(r,n,i){i(31),i(32),i(33),i(19),i(65),i(20),i(22),i(23);var o,a=this&&this.__extends||(o=function(g,p){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(v,y){v.__proto__=y}||function(v,y){for(var m in y)y.hasOwnProperty(m)&&(v[m]=y[m])})(g,p)},function(g,p){function v(){this.constructor=g}o(g,p),g.prototype=p===null?Object.create(p):(v.prototype=p.prototype,new v)}),s=this&&this.__read||function(g,p){var v=typeof Symbol=="function"&&g[Symbol.iterator];if(!v)return g;var y,m,w=v.call(g),x=[];try{for(;(p===void 0||p-- >0)&&!(y=w.next()).done;)x.push(y.value)}catch(C){m={error:C}}finally{try{y&&!y.done&&(v=w.return)&&v.call(w)}finally{if(m)throw m.error}}return x},c=this&&this.__values||function(g){var p=typeof Symbol=="function"&&Symbol.iterator,v=p&&g[p],y=0;if(v)return v.call(g);if(g&&typeof g.length=="number")return{next:function(){return g&&y>=g.length&&(g=void 0),{value:g&&g[y++],done:!g}}};throw new TypeError(p?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(n,"__esModule",{value:!0});var l=i(180),f=i(111),u=i(7),d=i(0),h=function(g){function p(){return g!==null&&g.apply(this,arguments)||this}return a(p,g),p.prototype._parse=function(v,y){for(var m,w,x,C,S=new l.XMLStringLexer(y,{skipWhitespaceOnlyText:!0}),T=v,_=v,E=S.nextToken();E.type!==f.TokenType.EOF;){switch(E.type){case f.TokenType.Declaration:var b=E,D=this.sanitize(b.version);if(D!=="1.0")throw new Error("Invalid xml version: "+D);var I={version:D};b.encoding&&(I.encoding=this.sanitize(b.encoding)),b.standalone&&(I.standalone=this.sanitize(b.standalone)==="yes"),_.set(I);break;case f.TokenType.DocType:var P=E;_=this.docType(_,this.sanitize(P.name),this.sanitize(P.pubId),this.sanitize(P.sysId))||_;break;case f.TokenType.CDATA:var O=E;_=this.cdata(_,this.sanitize(O.data))||_;break;case f.TokenType.Comment:var L=E;_=this.comment(_,this.sanitize(L.data))||_;break;case f.TokenType.PI:var B=E;_=this.instruction(_,this.sanitize(B.target),this.sanitize(B.data))||_;break;case f.TokenType.Text:var H=E;_=this.text(_,this._decodeText(this.sanitize(H.data)))||_;break;case f.TokenType.Element:var A=E,F=this.sanitize(A.name),G=s(d.namespace_extractQName(F),1)[0],X=_.node.lookupNamespaceURI(G),ee={};try{for(var ce=(m=void 0,c(A.attributes)),Se=ce.next();!Se.done;Se=ce.next()){var we=s(Se.value,2),_e=we[0],Ve=we[1];if(_e=this.sanitize(_e),Ve=this.sanitize(Ve),_e==="xmlns")X=Ve;else{var Ge=s(d.namespace_extractQName(_e),2),Ne=Ge[0],j=Ge[1];Ne==="xmlns"&&(j===G&&(X=Ve),ee[j]=Ve)}}}catch(Re){m={error:Re}}finally{try{Se&&!Se.done&&(w=ce.return)&&w.call(ce)}finally{if(m)throw m.error}}var M=X!==null?this.element(_,X,F):this.element(_,void 0,F);if(M===void 0)break;_.node===v.node&&(T=M);try{for(var q=(x=void 0,c(A.attributes)),K=q.next();!K.done;K=q.next()){var J=s(K.value,2);_e=J[0],Ve=J[1],_e=this.sanitize(_e),Ve=this.sanitize(Ve);var re=s(d.namespace_extractQName(_e),2),ie=(Ne=re[0],j=re[1],null);Ne==="xmlns"||Ne===null&&j==="xmlns"?ie=u.namespace.XMLNS:(ie=M.node.lookupNamespaceURI(Ne))!==null&&M.node.isDefaultNamespace(ie)?ie=null:ie===null&&Ne!==null&&(ie=ee[Ne]||null),ie!==null?this.attribute(M,ie,_e,this._decodeAttributeValue(Ve)):this.attribute(M,void 0,_e,this._decodeAttributeValue(Ve))}}catch(Re){x={error:Re}}finally{try{K&&!K.done&&(C=q.return)&&C.call(q)}finally{if(x)throw x.error}}A.selfClosing||(_=M);break;case f.TokenType.ClosingTag:_.node.parentNode&&(_=_.up())}E=S.nextToken()}return T},p}(i(75).BaseReader);n.XMLReader=h},function(r,n,i){var o=i(4),a=i(279);o({target:"Object",stat:!0,forced:Object.assign!==a},{assign:a})},function(r,n,i){var o=i(16),a=i(8),s=i(61),c=i(85),l=i(79),f=i(27),u=i(41),d=Object.assign,h=Object.defineProperty;r.exports=!d||a(function(){if(o&&d({b:1},d(h({},"a",{enumerable:!0,get:function(){h(this,"b",{value:3,enumerable:!1})}}),{b:2})).b!==1)return!0;var g={},p={},v=Symbol();return g[v]=7,"abcdefghijklmnopqrst".split("").forEach(function(y){p[y]=y}),d({},g)[v]!=7||s(d({},p)).join("")!="abcdefghijklmnopqrst"})?function(g,p){for(var v=f(g),y=arguments.length,m=1,w=c.f,x=l.f;y>m;)for(var C,S=u(arguments[m++]),T=w?s(S).concat(w(S)):s(S),_=T.length,E=0;_>E;)C=T[E++],o&&!x.call(S,C)||(v[C]=S[C]);return v}:d},function(r,n,i){var o,a=this&&this.__extends||(o=function(l,f){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(u,d){u.__proto__=d}||function(u,d){for(var h in d)d.hasOwnProperty(h)&&(u[h]=d[h])})(l,f)},function(l,f){function u(){this.constructor=l}o(l,f),l.prototype=f===null?Object.create(f):(u.prototype=f.prototype,new u)});Object.defineProperty(n,"__esModule",{value:!0});var s=i(112),c=function(l){function f(){return l!==null&&l.apply(this,arguments)||this}return a(f,l),f.prototype._parse=function(u,d){return new s.ObjectReader(this._builderOptions).parse(u,JSON.parse(d))},f}(i(75).BaseReader);n.JSONReader=c},function(r,n,i){var o,a=this&&this.__extends||(o=function(u,d){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(h,g){h.__proto__=g}||function(h,g){for(var p in g)g.hasOwnProperty(p)&&(h[p]=g[p])})(u,d)},function(u,d){function h(){this.constructor=u}o(u,d),u.prototype=d===null?Object.create(d):(h.prototype=d.prototype,new h)});Object.defineProperty(n,"__esModule",{value:!0});var s=i(112),c=i(75),l=i(282),f=function(u){function d(){return u!==null&&u.apply(this,arguments)||this}return a(d,u),d.prototype._parse=function(h,g){var p=l.safeLoad(g);if(p===void 0)throw new Error("Unable to parse YAML document.");return new s.ObjectReader(this._builderOptions).parse(h,p)},d}(c.BaseReader);n.YAMLReader=f},function(r,n,i){var o=i(283);r.exports=o},function(r,n,i){var o=i(284),a=i(303);function s(c){return function(){throw new Error("Function "+c+" is deprecated and cannot be used.")}}r.exports.Type=i(10),r.exports.Schema=i(39),r.exports.FAILSAFE_SCHEMA=i(113),r.exports.JSON_SCHEMA=i(182),r.exports.CORE_SCHEMA=i(181),r.exports.DEFAULT_SAFE_SCHEMA=i(54),r.exports.DEFAULT_FULL_SCHEMA=i(76),r.exports.load=o.load,r.exports.loadAll=o.loadAll,r.exports.safeLoad=o.safeLoad,r.exports.safeLoadAll=o.safeLoadAll,r.exports.dump=a.dump,r.exports.safeDump=a.safeDump,r.exports.YAMLException=i(53),r.exports.MINIMAL_SCHEMA=i(113),r.exports.SAFE_SCHEMA=i(54),r.exports.DEFAULT_SCHEMA=i(76),r.exports.scan=s("scan"),r.exports.parse=s("parse"),r.exports.compose=s("compose"),r.exports.addConstructor=s("addConstructor")},function(r,n,i){var o=i(38),a=i(53),s=i(285),c=i(54),l=i(76),f=Object.prototype.hasOwnProperty,u=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,d=/[\x85\u2028\u2029]/,h=/[,\[\]\{\}]/,g=/^(?:!|!!|![a-z\-]+!)$/i,p=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function v(M){return Object.prototype.toString.call(M)}function y(M){return M===10||M===13}function m(M){return M===9||M===32}function w(M){return M===9||M===32||M===10||M===13}function x(M){return M===44||M===91||M===93||M===123||M===125}function C(M){var q;return 48<=M&&M<=57?M-48:97<=(q=32|M)&&q<=102?q-97+10:-1}function S(M){return M===48?"\0":M===97?"\x07":M===98?"\b":M===116||M===9?" ":M===110?`
|
||
`:M===118?"\v":M===102?"\f":M===114?"\r":M===101?"\x1B":M===32?" ":M===34?'"':M===47?"/":M===92?"\\":M===78?"
":M===95?" ":M===76?"\u2028":M===80?"\u2029":""}function T(M){return M<=65535?String.fromCharCode(M):String.fromCharCode(55296+(M-65536>>10),56320+(M-65536&1023))}for(var _=new Array(256),E=new Array(256),b=0;b<256;b++)_[b]=S(b)?1:0,E[b]=S(b);function D(M,q){this.input=M,this.filename=q.filename||null,this.schema=q.schema||l,this.onWarning=q.onWarning||null,this.legacy=q.legacy||!1,this.json=q.json||!1,this.listener=q.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=M.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.documents=[]}function I(M,q){return new a(q,new s(M.filename,M.input,M.position,M.line,M.position-M.lineStart))}function P(M,q){throw I(M,q)}function O(M,q){M.onWarning&&M.onWarning.call(null,I(M,q))}var L={YAML:function(M,q,K){var J,re,ie;M.version!==null&&P(M,"duplication of %YAML directive"),K.length!==1&&P(M,"YAML directive accepts exactly one argument"),(J=/^([0-9]+)\.([0-9]+)$/.exec(K[0]))===null&&P(M,"ill-formed argument of the YAML directive"),re=parseInt(J[1],10),ie=parseInt(J[2],10),re!==1&&P(M,"unacceptable YAML version of the document"),M.version=K[0],M.checkLineBreaks=ie<2,ie!==1&&ie!==2&&O(M,"unsupported YAML version of the document")},TAG:function(M,q,K){var J,re;K.length!==2&&P(M,"TAG directive accepts exactly two arguments"),J=K[0],re=K[1],g.test(J)||P(M,"ill-formed tag handle (first argument) of the TAG directive"),f.call(M.tagMap,J)&&P(M,'there is a previously declared suffix for "'+J+'" tag handle'),p.test(re)||P(M,"ill-formed tag prefix (second argument) of the TAG directive"),M.tagMap[J]=re}};function B(M,q,K,J){var re,ie,Re,Fe;if(q<K){if(Fe=M.input.slice(q,K),J)for(re=0,ie=Fe.length;re<ie;re+=1)(Re=Fe.charCodeAt(re))===9||32<=Re&&Re<=1114111||P(M,"expected valid JSON character");else u.test(Fe)&&P(M,"the stream contains non-printable characters");M.result+=Fe}}function H(M,q,K,J){var re,ie,Re,Fe;for(o.isObject(K)||P(M,"cannot merge mappings; the provided source object is unacceptable"),Re=0,Fe=(re=Object.keys(K)).length;Re<Fe;Re+=1)ie=re[Re],f.call(q,ie)||(q[ie]=K[ie],J[ie]=!0)}function A(M,q,K,J,re,ie,Re,Fe){var je,Xe;if(Array.isArray(re))for(je=0,Xe=(re=Array.prototype.slice.call(re)).length;je<Xe;je+=1)Array.isArray(re[je])&&P(M,"nested arrays are not supported inside keys"),typeof re=="object"&&v(re[je])==="[object Object]"&&(re[je]="[object Object]");if(typeof re=="object"&&v(re)==="[object Object]"&&(re="[object Object]"),re=String(re),q===null&&(q={}),J==="tag:yaml.org,2002:merge")if(Array.isArray(ie))for(je=0,Xe=ie.length;je<Xe;je+=1)H(M,q,ie[je],K);else H(M,q,ie,K);else M.json||f.call(K,re)||!f.call(q,re)||(M.line=Re||M.line,M.position=Fe||M.position,P(M,"duplicated mapping key")),q[re]=ie,delete K[re];return q}function F(M){var q;(q=M.input.charCodeAt(M.position))===10?M.position++:q===13?(M.position++,M.input.charCodeAt(M.position)===10&&M.position++):P(M,"a line break is expected"),M.line+=1,M.lineStart=M.position}function G(M,q,K){for(var J=0,re=M.input.charCodeAt(M.position);re!==0;){for(;m(re);)re=M.input.charCodeAt(++M.position);if(q&&re===35)do re=M.input.charCodeAt(++M.position);while(re!==10&&re!==13&&re!==0);if(!y(re))break;for(F(M),re=M.input.charCodeAt(M.position),J++,M.lineIndent=0;re===32;)M.lineIndent++,re=M.input.charCodeAt(++M.position)}return K!==-1&&J!==0&&M.lineIndent<K&&O(M,"deficient indentation"),J}function X(M){var q,K=M.position;return!((q=M.input.charCodeAt(K))!==45&&q!==46||q!==M.input.charCodeAt(K+1)||q!==M.input.charCodeAt(K+2)||(K+=3,(q=M.input.charCodeAt(K))!==0&&!w(q)))}function ee(M,q){q===1?M.result+=" ":q>1&&(M.result+=o.repeat(`
|
||
`,q-1))}function ce(M,q){var K,J,re=M.tag,ie=M.anchor,Re=[],Fe=!1;for(M.anchor!==null&&(M.anchorMap[M.anchor]=Re),J=M.input.charCodeAt(M.position);J!==0&&J===45&&w(M.input.charCodeAt(M.position+1));)if(Fe=!0,M.position++,G(M,!0,-1)&&M.lineIndent<=q)Re.push(null),J=M.input.charCodeAt(M.position);else if(K=M.line,_e(M,q,3,!1,!0),Re.push(M.result),G(M,!0,-1),J=M.input.charCodeAt(M.position),(M.line===K||M.lineIndent>q)&&J!==0)P(M,"bad indentation of a sequence entry");else if(M.lineIndent<q)break;return!!Fe&&(M.tag=re,M.anchor=ie,M.kind="sequence",M.result=Re,!0)}function Se(M){var q,K,J,re,ie=!1,Re=!1;if((re=M.input.charCodeAt(M.position))!==33)return!1;if(M.tag!==null&&P(M,"duplication of a tag property"),(re=M.input.charCodeAt(++M.position))===60?(ie=!0,re=M.input.charCodeAt(++M.position)):re===33?(Re=!0,K="!!",re=M.input.charCodeAt(++M.position)):K="!",q=M.position,ie){do re=M.input.charCodeAt(++M.position);while(re!==0&&re!==62);M.position<M.length?(J=M.input.slice(q,M.position),re=M.input.charCodeAt(++M.position)):P(M,"unexpected end of the stream within a verbatim tag")}else{for(;re!==0&&!w(re);)re===33&&(Re?P(M,"tag suffix cannot contain exclamation marks"):(K=M.input.slice(q-1,M.position+1),g.test(K)||P(M,"named tag handle cannot contain such characters"),Re=!0,q=M.position+1)),re=M.input.charCodeAt(++M.position);J=M.input.slice(q,M.position),h.test(J)&&P(M,"tag suffix cannot contain flow indicator characters")}return J&&!p.test(J)&&P(M,"tag name cannot contain such characters: "+J),ie?M.tag=J:f.call(M.tagMap,K)?M.tag=M.tagMap[K]+J:K==="!"?M.tag="!"+J:K==="!!"?M.tag="tag:yaml.org,2002:"+J:P(M,'undeclared tag handle "'+K+'"'),!0}function we(M){var q,K;if((K=M.input.charCodeAt(M.position))!==38)return!1;for(M.anchor!==null&&P(M,"duplication of an anchor property"),K=M.input.charCodeAt(++M.position),q=M.position;K!==0&&!w(K)&&!x(K);)K=M.input.charCodeAt(++M.position);return M.position===q&&P(M,"name of an anchor node must contain at least one character"),M.anchor=M.input.slice(q,M.position),!0}function _e(M,q,K,J,re){var ie,Re,Fe,je,Xe,se,ue,Pe,pe=1,Ee=!1,Qe=!1;if(M.listener!==null&&M.listener("open",M),M.tag=null,M.anchor=null,M.kind=null,M.result=null,ie=Re=Fe=K===4||K===3,J&&G(M,!0,-1)&&(Ee=!0,M.lineIndent>q?pe=1:M.lineIndent===q?pe=0:M.lineIndent<q&&(pe=-1)),pe===1)for(;Se(M)||we(M);)G(M,!0,-1)?(Ee=!0,Fe=ie,M.lineIndent>q?pe=1:M.lineIndent===q?pe=0:M.lineIndent<q&&(pe=-1)):Fe=!1;if(Fe&&(Fe=Ee||re),pe!==1&&K!==4||(ue=K===1||K===2?q:q+1,Pe=M.position-M.lineStart,pe===1?Fe&&(ce(M,Pe)||function(fe,ft,pt){var dt,Ue,nt,at,ot,lt=fe.tag,_t=fe.anchor,vt={},Mt={},Ft=null,wn=null,Dn=null,Nt=!1,xn=!1;for(fe.anchor!==null&&(fe.anchorMap[fe.anchor]=vt),ot=fe.input.charCodeAt(fe.position);ot!==0;){if(dt=fe.input.charCodeAt(fe.position+1),nt=fe.line,at=fe.position,ot!==63&&ot!==58||!w(dt)){if(!_e(fe,pt,2,!1,!0))break;if(fe.line===nt){for(ot=fe.input.charCodeAt(fe.position);m(ot);)ot=fe.input.charCodeAt(++fe.position);if(ot===58)w(ot=fe.input.charCodeAt(++fe.position))||P(fe,"a whitespace character is expected after the key-value separator within a block mapping"),Nt&&(A(fe,vt,Mt,Ft,wn,null),Ft=wn=Dn=null),xn=!0,Nt=!1,Ue=!1,Ft=fe.tag,wn=fe.result;else{if(!xn)return fe.tag=lt,fe.anchor=_t,!0;P(fe,"can not read an implicit mapping pair; a colon is missed")}}else{if(!xn)return fe.tag=lt,fe.anchor=_t,!0;P(fe,"can not read a block mapping entry; a multiline key may not be an implicit key")}}else ot===63?(Nt&&(A(fe,vt,Mt,Ft,wn,null),Ft=wn=Dn=null),xn=!0,Nt=!0,Ue=!0):Nt?(Nt=!1,Ue=!0):P(fe,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),fe.position+=1,ot=dt;if((fe.line===nt||fe.lineIndent>ft)&&(_e(fe,ft,4,!0,Ue)&&(Nt?wn=fe.result:Dn=fe.result),Nt||(A(fe,vt,Mt,Ft,wn,Dn,nt,at),Ft=wn=Dn=null),G(fe,!0,-1),ot=fe.input.charCodeAt(fe.position)),fe.lineIndent>ft&&ot!==0)P(fe,"bad indentation of a mapping entry");else if(fe.lineIndent<ft)break}return Nt&&A(fe,vt,Mt,Ft,wn,null),xn&&(fe.tag=lt,fe.anchor=_t,fe.kind="mapping",fe.result=vt),xn}(M,Pe,ue))||function(fe,ft){var pt,dt,Ue,nt,at,ot,lt,_t,vt,Mt,Ft=!0,wn=fe.tag,Dn=fe.anchor,Nt={};if((Mt=fe.input.charCodeAt(fe.position))===91)Ue=93,ot=!1,dt=[];else{if(Mt!==123)return!1;Ue=125,ot=!0,dt={}}for(fe.anchor!==null&&(fe.anchorMap[fe.anchor]=dt),Mt=fe.input.charCodeAt(++fe.position);Mt!==0;){if(G(fe,!0,ft),(Mt=fe.input.charCodeAt(fe.position))===Ue)return fe.position++,fe.tag=wn,fe.anchor=Dn,fe.kind=ot?"mapping":"sequence",fe.result=dt,!0;Ft||P(fe,"missed comma between flow collection entries"),vt=null,nt=at=!1,Mt===63&&w(fe.input.charCodeAt(fe.position+1))&&(nt=at=!0,fe.position++,G(fe,!0,ft)),pt=fe.line,_e(fe,ft,1,!1,!0),_t=fe.tag,lt=fe.result,G(fe,!0,ft),Mt=fe.input.charCodeAt(fe.position),!at&&fe.line!==pt||Mt!==58||(nt=!0,Mt=fe.input.charCodeAt(++fe.position),G(fe,!0,ft),_e(fe,ft,1,!1,!0),vt=fe.result),ot?A(fe,dt,Nt,_t,lt,vt):nt?dt.push(A(fe,null,Nt,_t,lt,vt)):dt.push(lt),G(fe,!0,ft),(Mt=fe.input.charCodeAt(fe.position))===44?(Ft=!0,Mt=fe.input.charCodeAt(++fe.position)):Ft=!1}P(fe,"unexpected end of the stream within a flow collection")}(M,ue)?Qe=!0:(Re&&function(fe,ft){var pt,dt,Ue,nt,at,ot=1,lt=!1,_t=!1,vt=ft,Mt=0,Ft=!1;if((nt=fe.input.charCodeAt(fe.position))===124)dt=!1;else{if(nt!==62)return!1;dt=!0}for(fe.kind="scalar",fe.result="";nt!==0;)if((nt=fe.input.charCodeAt(++fe.position))===43||nt===45)ot===1?ot=nt===43?3:2:P(fe,"repeat of a chomping mode identifier");else{if(!((Ue=48<=(at=nt)&&at<=57?at-48:-1)>=0))break;Ue===0?P(fe,"bad explicit indentation width of a block scalar; it cannot be less than one"):_t?P(fe,"repeat of an indentation width identifier"):(vt=ft+Ue-1,_t=!0)}if(m(nt)){do nt=fe.input.charCodeAt(++fe.position);while(m(nt));if(nt===35)do nt=fe.input.charCodeAt(++fe.position);while(!y(nt)&&nt!==0)}for(;nt!==0;){for(F(fe),fe.lineIndent=0,nt=fe.input.charCodeAt(fe.position);(!_t||fe.lineIndent<vt)&&nt===32;)fe.lineIndent++,nt=fe.input.charCodeAt(++fe.position);if(!_t&&fe.lineIndent>vt&&(vt=fe.lineIndent),y(nt))Mt++;else{if(fe.lineIndent<vt){ot===3?fe.result+=o.repeat(`
|
||
`,lt?1+Mt:Mt):ot===1&<&&(fe.result+=`
|
||
`);break}for(dt?m(nt)?(Ft=!0,fe.result+=o.repeat(`
|
||
`,lt?1+Mt:Mt)):Ft?(Ft=!1,fe.result+=o.repeat(`
|
||
`,Mt+1)):Mt===0?lt&&(fe.result+=" "):fe.result+=o.repeat(`
|
||
`,Mt):fe.result+=o.repeat(`
|
||
`,lt?1+Mt:Mt),lt=!0,_t=!0,Mt=0,pt=fe.position;!y(nt)&&nt!==0;)nt=fe.input.charCodeAt(++fe.position);B(fe,pt,fe.position,!1)}}return!0}(M,ue)||function(fe,ft){var pt,dt,Ue;if((pt=fe.input.charCodeAt(fe.position))!==39)return!1;for(fe.kind="scalar",fe.result="",fe.position++,dt=Ue=fe.position;(pt=fe.input.charCodeAt(fe.position))!==0;)if(pt===39){if(B(fe,dt,fe.position,!0),(pt=fe.input.charCodeAt(++fe.position))!==39)return!0;dt=fe.position,fe.position++,Ue=fe.position}else y(pt)?(B(fe,dt,Ue,!0),ee(fe,G(fe,!1,ft)),dt=Ue=fe.position):fe.position===fe.lineStart&&X(fe)?P(fe,"unexpected end of the document within a single quoted scalar"):(fe.position++,Ue=fe.position);P(fe,"unexpected end of the stream within a single quoted scalar")}(M,ue)||function(fe,ft){var pt,dt,Ue,nt,at,ot,lt;if((ot=fe.input.charCodeAt(fe.position))!==34)return!1;for(fe.kind="scalar",fe.result="",fe.position++,pt=dt=fe.position;(ot=fe.input.charCodeAt(fe.position))!==0;){if(ot===34)return B(fe,pt,fe.position,!0),fe.position++,!0;if(ot===92){if(B(fe,pt,fe.position,!0),y(ot=fe.input.charCodeAt(++fe.position)))G(fe,!1,ft);else if(ot<256&&_[ot])fe.result+=E[ot],fe.position++;else if((at=(lt=ot)===120?2:lt===117?4:lt===85?8:0)>0){for(Ue=at,nt=0;Ue>0;Ue--)(at=C(ot=fe.input.charCodeAt(++fe.position)))>=0?nt=(nt<<4)+at:P(fe,"expected hexadecimal character");fe.result+=T(nt),fe.position++}else P(fe,"unknown escape sequence");pt=dt=fe.position}else y(ot)?(B(fe,pt,dt,!0),ee(fe,G(fe,!1,ft)),pt=dt=fe.position):fe.position===fe.lineStart&&X(fe)?P(fe,"unexpected end of the document within a double quoted scalar"):(fe.position++,dt=fe.position)}P(fe,"unexpected end of the stream within a double quoted scalar")}(M,ue)?Qe=!0:function(fe){var ft,pt,dt;if((dt=fe.input.charCodeAt(fe.position))!==42)return!1;for(dt=fe.input.charCodeAt(++fe.position),ft=fe.position;dt!==0&&!w(dt)&&!x(dt);)dt=fe.input.charCodeAt(++fe.position);return fe.position===ft&&P(fe,"name of an alias node must contain at least one character"),pt=fe.input.slice(ft,fe.position),fe.anchorMap.hasOwnProperty(pt)||P(fe,'unidentified alias "'+pt+'"'),fe.result=fe.anchorMap[pt],G(fe,!0,-1),!0}(M)?(Qe=!0,M.tag===null&&M.anchor===null||P(M,"alias node should not have any properties")):function(fe,ft,pt){var dt,Ue,nt,at,ot,lt,_t,vt,Mt=fe.kind,Ft=fe.result;if(w(vt=fe.input.charCodeAt(fe.position))||x(vt)||vt===35||vt===38||vt===42||vt===33||vt===124||vt===62||vt===39||vt===34||vt===37||vt===64||vt===96||(vt===63||vt===45)&&(w(dt=fe.input.charCodeAt(fe.position+1))||pt&&x(dt)))return!1;for(fe.kind="scalar",fe.result="",Ue=nt=fe.position,at=!1;vt!==0;){if(vt===58){if(w(dt=fe.input.charCodeAt(fe.position+1))||pt&&x(dt))break}else if(vt===35){if(w(fe.input.charCodeAt(fe.position-1)))break}else{if(fe.position===fe.lineStart&&X(fe)||pt&&x(vt))break;if(y(vt)){if(ot=fe.line,lt=fe.lineStart,_t=fe.lineIndent,G(fe,!1,-1),fe.lineIndent>=ft){at=!0,vt=fe.input.charCodeAt(fe.position);continue}fe.position=nt,fe.line=ot,fe.lineStart=lt,fe.lineIndent=_t;break}}at&&(B(fe,Ue,nt,!1),ee(fe,fe.line-ot),Ue=nt=fe.position,at=!1),m(vt)||(nt=fe.position+1),vt=fe.input.charCodeAt(++fe.position)}return B(fe,Ue,nt,!1),!!fe.result||(fe.kind=Mt,fe.result=Ft,!1)}(M,ue,K===1)&&(Qe=!0,M.tag===null&&(M.tag="?")),M.anchor!==null&&(M.anchorMap[M.anchor]=M.result)):pe===0&&(Qe=Fe&&ce(M,Pe))),M.tag!==null&&M.tag!=="!")if(M.tag==="?"){for(M.result!==null&&M.kind!=="scalar"&&P(M,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+M.kind+'"'),je=0,Xe=M.implicitTypes.length;je<Xe;je+=1)if((se=M.implicitTypes[je]).resolve(M.result)){M.result=se.construct(M.result),M.tag=se.tag,M.anchor!==null&&(M.anchorMap[M.anchor]=M.result);break}}else f.call(M.typeMap[M.kind||"fallback"],M.tag)?(se=M.typeMap[M.kind||"fallback"][M.tag],M.result!==null&&se.kind!==M.kind&&P(M,"unacceptable node kind for !<"+M.tag+'> tag; it should be "'+se.kind+'", not "'+M.kind+'"'),se.resolve(M.result)?(M.result=se.construct(M.result),M.anchor!==null&&(M.anchorMap[M.anchor]=M.result)):P(M,"cannot resolve a node with !<"+M.tag+"> explicit tag")):P(M,"unknown tag !<"+M.tag+">");return M.listener!==null&&M.listener("close",M),M.tag!==null||M.anchor!==null||Qe}function Ve(M){var q,K,J,re,ie=M.position,Re=!1;for(M.version=null,M.checkLineBreaks=M.legacy,M.tagMap={},M.anchorMap={};(re=M.input.charCodeAt(M.position))!==0&&(G(M,!0,-1),re=M.input.charCodeAt(M.position),!(M.lineIndent>0||re!==37));){for(Re=!0,re=M.input.charCodeAt(++M.position),q=M.position;re!==0&&!w(re);)re=M.input.charCodeAt(++M.position);for(J=[],(K=M.input.slice(q,M.position)).length<1&&P(M,"directive name must not be less than one character in length");re!==0;){for(;m(re);)re=M.input.charCodeAt(++M.position);if(re===35){do re=M.input.charCodeAt(++M.position);while(re!==0&&!y(re));break}if(y(re))break;for(q=M.position;re!==0&&!w(re);)re=M.input.charCodeAt(++M.position);J.push(M.input.slice(q,M.position))}re!==0&&F(M),f.call(L,K)?L[K](M,K,J):O(M,'unknown document directive "'+K+'"')}G(M,!0,-1),M.lineIndent===0&&M.input.charCodeAt(M.position)===45&&M.input.charCodeAt(M.position+1)===45&&M.input.charCodeAt(M.position+2)===45?(M.position+=3,G(M,!0,-1)):Re&&P(M,"directives end mark is expected"),_e(M,M.lineIndent-1,4,!1,!0),G(M,!0,-1),M.checkLineBreaks&&d.test(M.input.slice(ie,M.position))&&O(M,"non-ASCII line breaks are interpreted as content"),M.documents.push(M.result),M.position===M.lineStart&&X(M)?M.input.charCodeAt(M.position)===46&&(M.position+=3,G(M,!0,-1)):M.position<M.length-1&&P(M,"end of the stream or a document separator is expected")}function Ge(M,q){q=q||{},(M=String(M)).length!==0&&(M.charCodeAt(M.length-1)!==10&&M.charCodeAt(M.length-1)!==13&&(M+=`
|
||
`),M.charCodeAt(0)===65279&&(M=M.slice(1)));var K=new D(M,q),J=M.indexOf("\0");for(J!==-1&&(K.position=J,P(K,"null byte is not allowed in input")),K.input+="\0";K.input.charCodeAt(K.position)===32;)K.lineIndent+=1,K.position+=1;for(;K.position<K.length-1;)Ve(K);return K.documents}function Ne(M,q,K){q!==null&&typeof q=="object"&&K===void 0&&(K=q,q=null);var J=Ge(M,K);if(typeof q!="function")return J;for(var re=0,ie=J.length;re<ie;re+=1)q(J[re])}function j(M,q){var K=Ge(M,q);if(K.length!==0){if(K.length===1)return K[0];throw new a("expected a single document in the stream, but found more")}}r.exports.loadAll=Ne,r.exports.load=j,r.exports.safeLoadAll=function(M,q,K){return typeof q=="object"&&q!==null&&K===void 0&&(K=q,q=null),Ne(M,q,o.extend({schema:c},K))},r.exports.safeLoad=function(M,q){return j(M,o.extend({schema:c},q))}},function(r,n,i){var o=i(38);function a(s,c,l,f,u){this.name=s,this.buffer=c,this.position=l,this.line=f,this.column=u}a.prototype.getSnippet=function(s,c){var l,f,u,d,h;if(!this.buffer)return null;for(s=s||4,c=c||75,l="",f=this.position;f>0&&`\0\r
|
||
\u2028\u2029`.indexOf(this.buffer.charAt(f-1))===-1;)if(f-=1,this.position-f>c/2-1){l=" ... ",f+=5;break}for(u="",d=this.position;d<this.buffer.length&&`\0\r
|
||
\u2028\u2029`.indexOf(this.buffer.charAt(d))===-1;)if((d+=1)-this.position>c/2-1){u=" ... ",d-=5;break}return h=this.buffer.slice(f,d),o.repeat(" ",s)+l+h+u+`
|
||
`+o.repeat(" ",s+this.position-f+l.length)+"^"},a.prototype.toString=function(s){var c,l="";return this.name&&(l+='in "'+this.name+'" '),l+="at line "+(this.line+1)+", column "+(this.column+1),s||(c=this.getSnippet())&&(l+=`:
|
||
`+c),l},r.exports=a},function(r,n,i){var o=i(10);r.exports=new o("tag:yaml.org,2002:str",{kind:"scalar",construct:function(a){return a!==null?a:""}})},function(r,n,i){var o=i(10);r.exports=new o("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(a){return a!==null?a:[]}})},function(r,n,i){var o=i(10);r.exports=new o("tag:yaml.org,2002:map",{kind:"mapping",construct:function(a){return a!==null?a:{}}})},function(r,n,i){var o=i(10);r.exports=new o("tag:yaml.org,2002:null",{kind:"scalar",resolve:function(a){if(a===null)return!0;var s=a.length;return s===1&&a==="~"||s===4&&(a==="null"||a==="Null"||a==="NULL")},construct:function(){return null},predicate:function(a){return a===null},represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"}},defaultStyle:"lowercase"})},function(r,n,i){var o=i(10);r.exports=new o("tag:yaml.org,2002:bool",{kind:"scalar",resolve:function(a){if(a===null)return!1;var s=a.length;return s===4&&(a==="true"||a==="True"||a==="TRUE")||s===5&&(a==="false"||a==="False"||a==="FALSE")},construct:function(a){return a==="true"||a==="True"||a==="TRUE"},predicate:function(a){return Object.prototype.toString.call(a)==="[object Boolean]"},represent:{lowercase:function(a){return a?"true":"false"},uppercase:function(a){return a?"TRUE":"FALSE"},camelcase:function(a){return a?"True":"False"}},defaultStyle:"lowercase"})},function(r,n,i){var o=i(38),a=i(10);function s(l){return 48<=l&&l<=55}function c(l){return 48<=l&&l<=57}r.exports=new a("tag:yaml.org,2002:int",{kind:"scalar",resolve:function(l){if(l===null)return!1;var f,u,d=l.length,h=0,g=!1;if(!d)return!1;if((f=l[h])!=="-"&&f!=="+"||(f=l[++h]),f==="0"){if(h+1===d)return!0;if((f=l[++h])==="b"){for(h++;h<d;h++)if((f=l[h])!=="_"){if(f!=="0"&&f!=="1")return!1;g=!0}return g&&f!=="_"}if(f==="x"){for(h++;h<d;h++)if((f=l[h])!=="_"){if(!(48<=(u=l.charCodeAt(h))&&u<=57||65<=u&&u<=70||97<=u&&u<=102))return!1;g=!0}return g&&f!=="_"}for(;h<d;h++)if((f=l[h])!=="_"){if(!s(l.charCodeAt(h)))return!1;g=!0}return g&&f!=="_"}if(f==="_")return!1;for(;h<d;h++)if((f=l[h])!=="_"){if(f===":")break;if(!c(l.charCodeAt(h)))return!1;g=!0}return!(!g||f==="_")&&(f!==":"||/^(:[0-5]?[0-9])+$/.test(l.slice(h)))},construct:function(l){var f,u,d=l,h=1,g=[];return d.indexOf("_")!==-1&&(d=d.replace(/_/g,"")),(f=d[0])!=="-"&&f!=="+"||(f==="-"&&(h=-1),f=(d=d.slice(1))[0]),d==="0"?0:f==="0"?d[1]==="b"?h*parseInt(d.slice(2),2):d[1]==="x"?h*parseInt(d,16):h*parseInt(d,8):d.indexOf(":")!==-1?(d.split(":").forEach(function(p){g.unshift(parseInt(p,10))}),d=0,u=1,g.forEach(function(p){d+=p*u,u*=60}),h*d):h*parseInt(d,10)},predicate:function(l){return Object.prototype.toString.call(l)==="[object Number]"&&l%1==0&&!o.isNegativeZero(l)},represent:{binary:function(l){return l>=0?"0b"+l.toString(2):"-0b"+l.toString(2).slice(1)},octal:function(l){return l>=0?"0"+l.toString(8):"-0"+l.toString(8).slice(1)},decimal:function(l){return l.toString(10)},hexadecimal:function(l){return l>=0?"0x"+l.toString(16).toUpperCase():"-0x"+l.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}})},function(r,n,i){var o=i(38),a=i(10),s=new RegExp("^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),c=/^[-+]?[0-9]+e/;r.exports=new a("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(l){return l!==null&&!(!s.test(l)||l[l.length-1]==="_")},construct:function(l){var f,u,d,h;return u=(f=l.replace(/_/g,"").toLowerCase())[0]==="-"?-1:1,h=[],"+-".indexOf(f[0])>=0&&(f=f.slice(1)),f===".inf"?u===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:f===".nan"?NaN:f.indexOf(":")>=0?(f.split(":").forEach(function(g){h.unshift(parseFloat(g,10))}),f=0,d=1,h.forEach(function(g){f+=g*d,d*=60}),u*f):u*parseFloat(f,10)},predicate:function(l){return Object.prototype.toString.call(l)==="[object Number]"&&(l%1!=0||o.isNegativeZero(l))},represent:function(l,f){var u;if(isNaN(l))switch(f){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===l)switch(f){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===l)switch(f){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(o.isNegativeZero(l))return"-0.0";return u=l.toString(10),c.test(u)?u.replace("e",".e"):u},defaultStyle:"lowercase"})},function(r,n,i){var o=i(10),a=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),s=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");r.exports=new o("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(c){return c!==null&&(a.exec(c)!==null||s.exec(c)!==null)},construct:function(c){var l,f,u,d,h,g,p,v,y=0,m=null;if((l=a.exec(c))===null&&(l=s.exec(c)),l===null)throw new Error("Date resolve error");if(f=+l[1],u=+l[2]-1,d=+l[3],!l[4])return new Date(Date.UTC(f,u,d));if(h=+l[4],g=+l[5],p=+l[6],l[7]){for(y=l[7].slice(0,3);y.length<3;)y+="0";y=+y}return l[9]&&(m=6e4*(60*+l[10]+ +(l[11]||0)),l[9]==="-"&&(m=-m)),v=new Date(Date.UTC(f,u,d,h,g,p,y)),m&&v.setTime(v.getTime()-m),v},instanceOf:Date,represent:function(c){return c.toISOString()}})},function(r,n,i){var o=i(10);r.exports=new o("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(a){return a==="<<"||a===null}})},function(r,n,i){var o;try{o=i(145).Buffer}catch{}var a=i(10),s=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
||
\r`;r.exports=new a("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(c){if(c===null)return!1;var l,f,u=0,d=c.length,h=s;for(f=0;f<d;f++)if(!((l=h.indexOf(c.charAt(f)))>64)){if(l<0)return!1;u+=6}return u%8==0},construct:function(c){var l,f,u=c.replace(/[\r\n=]/g,""),d=u.length,h=s,g=0,p=[];for(l=0;l<d;l++)l%4==0&&l&&(p.push(g>>16&255),p.push(g>>8&255),p.push(255&g)),g=g<<6|h.indexOf(u.charAt(l));return(f=d%4*6)===0?(p.push(g>>16&255),p.push(g>>8&255),p.push(255&g)):f===18?(p.push(g>>10&255),p.push(g>>2&255)):f===12&&p.push(g>>4&255),o?o.from?o.from(p):new o(p):p},predicate:function(c){return o&&o.isBuffer(c)},represent:function(c){var l,f,u="",d=0,h=c.length,g=s;for(l=0;l<h;l++)l%3==0&&l&&(u+=g[d>>18&63],u+=g[d>>12&63],u+=g[d>>6&63],u+=g[63&d]),d=(d<<8)+c[l];return(f=h%3)===0?(u+=g[d>>18&63],u+=g[d>>12&63],u+=g[d>>6&63],u+=g[63&d]):f===2?(u+=g[d>>10&63],u+=g[d>>4&63],u+=g[d<<2&63],u+=g[64]):f===1&&(u+=g[d>>2&63],u+=g[d<<4&63],u+=g[64],u+=g[64]),u}})},function(r,n,i){var o=i(10),a=Object.prototype.hasOwnProperty,s=Object.prototype.toString;r.exports=new o("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(c){if(c===null)return!0;var l,f,u,d,h,g=[],p=c;for(l=0,f=p.length;l<f;l+=1){if(u=p[l],h=!1,s.call(u)!=="[object Object]")return!1;for(d in u)if(a.call(u,d)){if(h)return!1;h=!0}if(!h||g.indexOf(d)!==-1)return!1;g.push(d)}return!0},construct:function(c){return c!==null?c:[]}})},function(r,n,i){var o=i(10),a=Object.prototype.toString;r.exports=new o("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:function(s){if(s===null)return!0;var c,l,f,u,d,h=s;for(d=new Array(h.length),c=0,l=h.length;c<l;c+=1){if(f=h[c],a.call(f)!=="[object Object]"||(u=Object.keys(f)).length!==1)return!1;d[c]=[u[0],f[u[0]]]}return!0},construct:function(s){if(s===null)return[];var c,l,f,u,d,h=s;for(d=new Array(h.length),c=0,l=h.length;c<l;c+=1)f=h[c],u=Object.keys(f),d[c]=[u[0],f[u[0]]];return d}})},function(r,n,i){var o=i(10),a=Object.prototype.hasOwnProperty;r.exports=new o("tag:yaml.org,2002:set",{kind:"mapping",resolve:function(s){if(s===null)return!0;var c,l=s;for(c in l)if(a.call(l,c)&&l[c]!==null)return!1;return!0},construct:function(s){return s!==null?s:{}}})},function(r,n,i){var o=i(10);r.exports=new o("tag:yaml.org,2002:js/undefined",{kind:"scalar",resolve:function(){return!0},construct:function(){},predicate:function(a){return a===void 0},represent:function(){return""}})},function(r,n,i){var o=i(10);r.exports=new o("tag:yaml.org,2002:js/regexp",{kind:"scalar",resolve:function(a){if(a===null||a.length===0)return!1;var s=a,c=/\/([gim]*)$/.exec(a),l="";return!(s[0]==="/"&&(c&&(l=c[1]),l.length>3||s[s.length-l.length-1]!=="/"))},construct:function(a){var s=a,c=/\/([gim]*)$/.exec(a),l="";return s[0]==="/"&&(c&&(l=c[1]),s=s.slice(1,s.length-l.length-1)),new RegExp(s,l)},predicate:function(a){return Object.prototype.toString.call(a)==="[object RegExp]"},represent:function(a){var s="/"+a.source+"/";return a.global&&(s+="g"),a.multiline&&(s+="m"),a.ignoreCase&&(s+="i"),s}})},function(r,n,i){var o;try{o=i(302)}catch{typeof window<"u"&&(o=window.esprima)}var a=i(10);r.exports=new a("tag:yaml.org,2002:js/function",{kind:"scalar",resolve:function(s){if(s===null)return!1;try{var c="("+s+")",l=o.parse(c,{range:!0});return l.type==="Program"&&l.body.length===1&&l.body[0].type==="ExpressionStatement"&&(l.body[0].expression.type==="ArrowFunctionExpression"||l.body[0].expression.type==="FunctionExpression")}catch{return!1}},construct:function(s){var c,l="("+s+")",f=o.parse(l,{range:!0}),u=[];if(f.type!=="Program"||f.body.length!==1||f.body[0].type!=="ExpressionStatement"||f.body[0].expression.type!=="ArrowFunctionExpression"&&f.body[0].expression.type!=="FunctionExpression")throw new Error("Failed to resolve function");return f.body[0].expression.params.forEach(function(d){u.push(d.name)}),c=f.body[0].expression.body.range,f.body[0].expression.body.type==="BlockStatement"?new Function(u,l.slice(c[0]+1,c[1]-1)):new Function(u,"return "+l.slice(c[0],c[1]))},predicate:function(s){return Object.prototype.toString.call(s)==="[object Function]"},represent:function(s){return s.toString()}})},function(r,n,i){var o;o=function(){return function(a){var s={};function c(l){if(s[l])return s[l].exports;var f=s[l]={exports:{},id:l,loaded:!1};return a[l].call(f.exports,f,f.exports,c),f.loaded=!0,f.exports}return c.m=a,c.c=s,c.p="",c(0)}([function(a,s,c){Object.defineProperty(s,"__esModule",{value:!0});var l=c(1),f=c(3),u=c(8),d=c(15);function h(p,v,y){var m=null,w=function(b,D){y&&y(b,D),m&&m.visit(b,D)},x=typeof y=="function"?w:null,C=!1;if(v){C=typeof v.comment=="boolean"&&v.comment;var S=typeof v.attachComment=="boolean"&&v.attachComment;(C||S)&&((m=new l.CommentHandler).attach=S,v.comment=!0,x=w)}var T,_=!1;v&&typeof v.sourceType=="string"&&(_=v.sourceType==="module"),T=v&&typeof v.jsx=="boolean"&&v.jsx?new f.JSXParser(p,v,x):new u.Parser(p,v,x);var E=_?T.parseModule():T.parseScript();return C&&m&&(E.comments=m.comments),T.config.tokens&&(E.tokens=T.tokens),T.config.tolerant&&(E.errors=T.errorHandler.errors),E}s.parse=h,s.parseModule=function(p,v,y){var m=v||{};return m.sourceType="module",h(p,m,y)},s.parseScript=function(p,v,y){var m=v||{};return m.sourceType="script",h(p,m,y)},s.tokenize=function(p,v,y){var m,w=new d.Tokenizer(p,v);m=[];try{for(;;){var x=w.getNextToken();if(!x)break;y&&(x=y(x)),m.push(x)}}catch(C){w.errorHandler.tolerate(C)}return w.errorHandler.tolerant&&(m.errors=w.errors()),m};var g=c(2);s.Syntax=g.Syntax,s.version="4.0.1"},function(a,s,c){Object.defineProperty(s,"__esModule",{value:!0});var l=c(2),f=function(){function u(){this.attach=!1,this.comments=[],this.stack=[],this.leading=[],this.trailing=[]}return u.prototype.insertInnerComments=function(d,h){if(d.type===l.Syntax.BlockStatement&&d.body.length===0){for(var g=[],p=this.leading.length-1;p>=0;--p){var v=this.leading[p];h.end.offset>=v.start&&(g.unshift(v.comment),this.leading.splice(p,1),this.trailing.splice(p,1))}g.length&&(d.innerComments=g)}},u.prototype.findTrailingComments=function(d){var h=[];if(this.trailing.length>0){for(var g=this.trailing.length-1;g>=0;--g){var p=this.trailing[g];p.start>=d.end.offset&&h.unshift(p.comment)}return this.trailing.length=0,h}var v=this.stack[this.stack.length-1];if(v&&v.node.trailingComments){var y=v.node.trailingComments[0];y&&y.range[0]>=d.end.offset&&(h=v.node.trailingComments,delete v.node.trailingComments)}return h},u.prototype.findLeadingComments=function(d){for(var h,g=[];this.stack.length>0&&(y=this.stack[this.stack.length-1])&&y.start>=d.start.offset;)h=y.node,this.stack.pop();if(h){for(var p=(h.leadingComments?h.leadingComments.length:0)-1;p>=0;--p){var v=h.leadingComments[p];v.range[1]<=d.start.offset&&(g.unshift(v),h.leadingComments.splice(p,1))}return h.leadingComments&&h.leadingComments.length===0&&delete h.leadingComments,g}for(p=this.leading.length-1;p>=0;--p){var y;(y=this.leading[p]).start<=d.start.offset&&(g.unshift(y.comment),this.leading.splice(p,1))}return g},u.prototype.visitNode=function(d,h){if(!(d.type===l.Syntax.Program&&d.body.length>0)){this.insertInnerComments(d,h);var g=this.findTrailingComments(h),p=this.findLeadingComments(h);p.length>0&&(d.leadingComments=p),g.length>0&&(d.trailingComments=g),this.stack.push({node:d,start:h.start.offset})}},u.prototype.visitComment=function(d,h){var g=d.type[0]==="L"?"Line":"Block",p={type:g,value:d.value};if(d.range&&(p.range=d.range),d.loc&&(p.loc=d.loc),this.comments.push(p),this.attach){var v={comment:{type:g,value:d.value,range:[h.start.offset,h.end.offset]},start:h.start.offset};d.loc&&(v.comment.loc=d.loc),d.type=g,this.leading.push(v),this.trailing.push(v)}},u.prototype.visit=function(d,h){d.type==="LineComment"||d.type==="BlockComment"?this.visitComment(d,h):this.attach&&this.visitNode(d,h)},u}();s.CommentHandler=f},function(a,s){Object.defineProperty(s,"__esModule",{value:!0}),s.Syntax={AssignmentExpression:"AssignmentExpression",AssignmentPattern:"AssignmentPattern",ArrayExpression:"ArrayExpression",ArrayPattern:"ArrayPattern",ArrowFunctionExpression:"ArrowFunctionExpression",AwaitExpression:"AwaitExpression",BlockStatement:"BlockStatement",BinaryExpression:"BinaryExpression",BreakStatement:"BreakStatement",CallExpression:"CallExpression",CatchClause:"CatchClause",ClassBody:"ClassBody",ClassDeclaration:"ClassDeclaration",ClassExpression:"ClassExpression",ConditionalExpression:"ConditionalExpression",ContinueStatement:"ContinueStatement",DoWhileStatement:"DoWhileStatement",DebuggerStatement:"DebuggerStatement",EmptyStatement:"EmptyStatement",ExportAllDeclaration:"ExportAllDeclaration",ExportDefaultDeclaration:"ExportDefaultDeclaration",ExportNamedDeclaration:"ExportNamedDeclaration",ExportSpecifier:"ExportSpecifier",ExpressionStatement:"ExpressionStatement",ForStatement:"ForStatement",ForOfStatement:"ForOfStatement",ForInStatement:"ForInStatement",FunctionDeclaration:"FunctionDeclaration",FunctionExpression:"FunctionExpression",Identifier:"Identifier",IfStatement:"IfStatement",ImportDeclaration:"ImportDeclaration",ImportDefaultSpecifier:"ImportDefaultSpecifier",ImportNamespaceSpecifier:"ImportNamespaceSpecifier",ImportSpecifier:"ImportSpecifier",Literal:"Literal",LabeledStatement:"LabeledStatement",LogicalExpression:"LogicalExpression",MemberExpression:"MemberExpression",MetaProperty:"MetaProperty",MethodDefinition:"MethodDefinition",NewExpression:"NewExpression",ObjectExpression:"ObjectExpression",ObjectPattern:"ObjectPattern",Program:"Program",Property:"Property",RestElement:"RestElement",ReturnStatement:"ReturnStatement",SequenceExpression:"SequenceExpression",SpreadElement:"SpreadElement",Super:"Super",SwitchCase:"SwitchCase",SwitchStatement:"SwitchStatement",TaggedTemplateExpression:"TaggedTemplateExpression",TemplateElement:"TemplateElement",TemplateLiteral:"TemplateLiteral",ThisExpression:"ThisExpression",ThrowStatement:"ThrowStatement",TryStatement:"TryStatement",UnaryExpression:"UnaryExpression",UpdateExpression:"UpdateExpression",VariableDeclaration:"VariableDeclaration",VariableDeclarator:"VariableDeclarator",WhileStatement:"WhileStatement",WithStatement:"WithStatement",YieldExpression:"YieldExpression"}},function(a,s,c){var l,f=this&&this.__extends||(l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(x,C){x.__proto__=C}||function(x,C){for(var S in C)C.hasOwnProperty(S)&&(x[S]=C[S])},function(x,C){function S(){this.constructor=x}l(x,C),x.prototype=C===null?Object.create(C):(S.prototype=C.prototype,new S)});Object.defineProperty(s,"__esModule",{value:!0});var u=c(4),d=c(5),h=c(6),g=c(7),p=c(8),v=c(13),y=c(14);function m(x){var C;switch(x.type){case h.JSXSyntax.JSXIdentifier:C=x.name;break;case h.JSXSyntax.JSXNamespacedName:var S=x;C=m(S.namespace)+":"+m(S.name);break;case h.JSXSyntax.JSXMemberExpression:var T=x;C=m(T.object)+"."+m(T.property)}return C}v.TokenName[100]="JSXIdentifier",v.TokenName[101]="JSXText";var w=function(x){function C(S,T,_){return x.call(this,S,T,_)||this}return f(C,x),C.prototype.parsePrimaryExpression=function(){return this.match("<")?this.parseJSXRoot():x.prototype.parsePrimaryExpression.call(this)},C.prototype.startJSX=function(){this.scanner.index=this.startMarker.index,this.scanner.lineNumber=this.startMarker.line,this.scanner.lineStart=this.startMarker.index-this.startMarker.column},C.prototype.finishJSX=function(){this.nextToken()},C.prototype.reenterJSX=function(){this.startJSX(),this.expectJSX("}"),this.config.tokens&&this.tokens.pop()},C.prototype.createJSXNode=function(){return this.collectComments(),{index:this.scanner.index,line:this.scanner.lineNumber,column:this.scanner.index-this.scanner.lineStart}},C.prototype.createJSXChildNode=function(){return{index:this.scanner.index,line:this.scanner.lineNumber,column:this.scanner.index-this.scanner.lineStart}},C.prototype.scanXHTMLEntity=function(S){for(var T="&",_=!0,E=!1,b=!1,D=!1;!this.scanner.eof()&&_&&!E;){var I=this.scanner.source[this.scanner.index];if(I===S)break;if(E=I===";",T+=I,++this.scanner.index,!E)switch(T.length){case 2:b=I==="#";break;case 3:b&&(_=(D=I==="x")||u.Character.isDecimalDigit(I.charCodeAt(0)),b=b&&!D);break;default:_=(_=_&&!(b&&!u.Character.isDecimalDigit(I.charCodeAt(0))))&&!(D&&!u.Character.isHexDigit(I.charCodeAt(0)))}}if(_&&E&&T.length>2){var P=T.substr(1,T.length-2);b&&P.length>1?T=String.fromCharCode(parseInt(P.substr(1),10)):D&&P.length>2?T=String.fromCharCode(parseInt("0"+P.substr(1),16)):b||D||!y.XHTMLEntities[P]||(T=y.XHTMLEntities[P])}return T},C.prototype.lexJSX=function(){var S=this.scanner.source.charCodeAt(this.scanner.index);if(S===60||S===62||S===47||S===58||S===61||S===123||S===125)return{type:7,value:I=this.scanner.source[this.scanner.index++],lineNumber:this.scanner.lineNumber,lineStart:this.scanner.lineStart,start:this.scanner.index-1,end:this.scanner.index};if(S===34||S===39){for(var T=this.scanner.index,_=this.scanner.source[this.scanner.index++],E="";!this.scanner.eof()&&(P=this.scanner.source[this.scanner.index++])!==_;)E+=P==="&"?this.scanXHTMLEntity(_):P;return{type:8,value:E,lineNumber:this.scanner.lineNumber,lineStart:this.scanner.lineStart,start:T,end:this.scanner.index}}if(S===46){var b=this.scanner.source.charCodeAt(this.scanner.index+1),D=this.scanner.source.charCodeAt(this.scanner.index+2),I=b===46&&D===46?"...":".";return T=this.scanner.index,this.scanner.index+=I.length,{type:7,value:I,lineNumber:this.scanner.lineNumber,lineStart:this.scanner.lineStart,start:T,end:this.scanner.index}}if(S===96)return{type:10,value:"",lineNumber:this.scanner.lineNumber,lineStart:this.scanner.lineStart,start:this.scanner.index,end:this.scanner.index};if(u.Character.isIdentifierStart(S)&&S!==92){for(T=this.scanner.index,++this.scanner.index;!this.scanner.eof();){var P=this.scanner.source.charCodeAt(this.scanner.index);if(u.Character.isIdentifierPart(P)&&P!==92)++this.scanner.index;else{if(P!==45)break;++this.scanner.index}}return{type:100,value:this.scanner.source.slice(T,this.scanner.index),lineNumber:this.scanner.lineNumber,lineStart:this.scanner.lineStart,start:T,end:this.scanner.index}}return this.scanner.lex()},C.prototype.nextJSXToken=function(){this.collectComments(),this.startMarker.index=this.scanner.index,this.startMarker.line=this.scanner.lineNumber,this.startMarker.column=this.scanner.index-this.scanner.lineStart;var S=this.lexJSX();return this.lastMarker.index=this.scanner.index,this.lastMarker.line=this.scanner.lineNumber,this.lastMarker.column=this.scanner.index-this.scanner.lineStart,this.config.tokens&&this.tokens.push(this.convertToken(S)),S},C.prototype.nextJSXText=function(){this.startMarker.index=this.scanner.index,this.startMarker.line=this.scanner.lineNumber,this.startMarker.column=this.scanner.index-this.scanner.lineStart;for(var S=this.scanner.index,T="";!this.scanner.eof();){var _=this.scanner.source[this.scanner.index];if(_==="{"||_==="<")break;++this.scanner.index,T+=_,u.Character.isLineTerminator(_.charCodeAt(0))&&(++this.scanner.lineNumber,_==="\r"&&this.scanner.source[this.scanner.index]===`
|
||
`&&++this.scanner.index,this.scanner.lineStart=this.scanner.index)}this.lastMarker.index=this.scanner.index,this.lastMarker.line=this.scanner.lineNumber,this.lastMarker.column=this.scanner.index-this.scanner.lineStart;var E={type:101,value:T,lineNumber:this.scanner.lineNumber,lineStart:this.scanner.lineStart,start:S,end:this.scanner.index};return T.length>0&&this.config.tokens&&this.tokens.push(this.convertToken(E)),E},C.prototype.peekJSXToken=function(){var S=this.scanner.saveState();this.scanner.scanComments();var T=this.lexJSX();return this.scanner.restoreState(S),T},C.prototype.expectJSX=function(S){var T=this.nextJSXToken();T.type===7&&T.value===S||this.throwUnexpectedToken(T)},C.prototype.matchJSX=function(S){var T=this.peekJSXToken();return T.type===7&&T.value===S},C.prototype.parseJSXIdentifier=function(){var S=this.createJSXNode(),T=this.nextJSXToken();return T.type!==100&&this.throwUnexpectedToken(T),this.finalize(S,new d.JSXIdentifier(T.value))},C.prototype.parseJSXElementName=function(){var S=this.createJSXNode(),T=this.parseJSXIdentifier();if(this.matchJSX(":")){var _=T;this.expectJSX(":");var E=this.parseJSXIdentifier();T=this.finalize(S,new d.JSXNamespacedName(_,E))}else if(this.matchJSX("."))for(;this.matchJSX(".");){var b=T;this.expectJSX(".");var D=this.parseJSXIdentifier();T=this.finalize(S,new d.JSXMemberExpression(b,D))}return T},C.prototype.parseJSXAttributeName=function(){var S,T=this.createJSXNode(),_=this.parseJSXIdentifier();if(this.matchJSX(":")){var E=_;this.expectJSX(":");var b=this.parseJSXIdentifier();S=this.finalize(T,new d.JSXNamespacedName(E,b))}else S=_;return S},C.prototype.parseJSXStringLiteralAttribute=function(){var S=this.createJSXNode(),T=this.nextJSXToken();T.type!==8&&this.throwUnexpectedToken(T);var _=this.getTokenRaw(T);return this.finalize(S,new g.Literal(T.value,_))},C.prototype.parseJSXExpressionAttribute=function(){var S=this.createJSXNode();this.expectJSX("{"),this.finishJSX(),this.match("}")&&this.tolerateError("JSX attributes must only be assigned a non-empty expression");var T=this.parseAssignmentExpression();return this.reenterJSX(),this.finalize(S,new d.JSXExpressionContainer(T))},C.prototype.parseJSXAttributeValue=function(){return this.matchJSX("{")?this.parseJSXExpressionAttribute():this.matchJSX("<")?this.parseJSXElement():this.parseJSXStringLiteralAttribute()},C.prototype.parseJSXNameValueAttribute=function(){var S=this.createJSXNode(),T=this.parseJSXAttributeName(),_=null;return this.matchJSX("=")&&(this.expectJSX("="),_=this.parseJSXAttributeValue()),this.finalize(S,new d.JSXAttribute(T,_))},C.prototype.parseJSXSpreadAttribute=function(){var S=this.createJSXNode();this.expectJSX("{"),this.expectJSX("..."),this.finishJSX();var T=this.parseAssignmentExpression();return this.reenterJSX(),this.finalize(S,new d.JSXSpreadAttribute(T))},C.prototype.parseJSXAttributes=function(){for(var S=[];!this.matchJSX("/")&&!this.matchJSX(">");){var T=this.matchJSX("{")?this.parseJSXSpreadAttribute():this.parseJSXNameValueAttribute();S.push(T)}return S},C.prototype.parseJSXOpeningElement=function(){var S=this.createJSXNode();this.expectJSX("<");var T=this.parseJSXElementName(),_=this.parseJSXAttributes(),E=this.matchJSX("/");return E&&this.expectJSX("/"),this.expectJSX(">"),this.finalize(S,new d.JSXOpeningElement(T,E,_))},C.prototype.parseJSXBoundaryElement=function(){var S=this.createJSXNode();if(this.expectJSX("<"),this.matchJSX("/")){this.expectJSX("/");var T=this.parseJSXElementName();return this.expectJSX(">"),this.finalize(S,new d.JSXClosingElement(T))}var _=this.parseJSXElementName(),E=this.parseJSXAttributes(),b=this.matchJSX("/");return b&&this.expectJSX("/"),this.expectJSX(">"),this.finalize(S,new d.JSXOpeningElement(_,b,E))},C.prototype.parseJSXEmptyExpression=function(){var S=this.createJSXChildNode();return this.collectComments(),this.lastMarker.index=this.scanner.index,this.lastMarker.line=this.scanner.lineNumber,this.lastMarker.column=this.scanner.index-this.scanner.lineStart,this.finalize(S,new d.JSXEmptyExpression)},C.prototype.parseJSXExpressionContainer=function(){var S,T=this.createJSXNode();return this.expectJSX("{"),this.matchJSX("}")?(S=this.parseJSXEmptyExpression(),this.expectJSX("}")):(this.finishJSX(),S=this.parseAssignmentExpression(),this.reenterJSX()),this.finalize(T,new d.JSXExpressionContainer(S))},C.prototype.parseJSXChildren=function(){for(var S=[];!this.scanner.eof();){var T=this.createJSXChildNode(),_=this.nextJSXText();if(_.start<_.end){var E=this.getTokenRaw(_),b=this.finalize(T,new d.JSXText(_.value,E));S.push(b)}if(this.scanner.source[this.scanner.index]!=="{")break;var D=this.parseJSXExpressionContainer();S.push(D)}return S},C.prototype.parseComplexJSXElement=function(S){for(var T=[];!this.scanner.eof();){S.children=S.children.concat(this.parseJSXChildren());var _=this.createJSXChildNode(),E=this.parseJSXBoundaryElement();if(E.type===h.JSXSyntax.JSXOpeningElement){var b=E;if(b.selfClosing){var D=this.finalize(_,new d.JSXElement(b,[],null));S.children.push(D)}else T.push(S),S={node:_,opening:b,closing:null,children:[]}}if(E.type===h.JSXSyntax.JSXClosingElement){S.closing=E;var I=m(S.opening.name);if(I!==m(S.closing.name)&&this.tolerateError("Expected corresponding JSX closing tag for %0",I),!(T.length>0))break;D=this.finalize(S.node,new d.JSXElement(S.opening,S.children,S.closing)),(S=T[T.length-1]).children.push(D),T.pop()}}return S},C.prototype.parseJSXElement=function(){var S=this.createJSXNode(),T=this.parseJSXOpeningElement(),_=[],E=null;if(!T.selfClosing){var b=this.parseComplexJSXElement({node:S,opening:T,closing:E,children:_});_=b.children,E=b.closing}return this.finalize(S,new d.JSXElement(T,_,E))},C.prototype.parseJSXRoot=function(){this.config.tokens&&this.tokens.pop(),this.startJSX();var S=this.parseJSXElement();return this.finishJSX(),S},C.prototype.isStartOfExpression=function(){return x.prototype.isStartOfExpression.call(this)||this.match("<")},C}(p.Parser);s.JSXParser=w},function(a,s){Object.defineProperty(s,"__esModule",{value:!0});var c={NonAsciiIdentifierStart:/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]/,NonAsciiIdentifierPart:/[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/};s.Character={fromCodePoint:function(l){return l<65536?String.fromCharCode(l):String.fromCharCode(55296+(l-65536>>10))+String.fromCharCode(56320+(l-65536&1023))},isWhiteSpace:function(l){return l===32||l===9||l===11||l===12||l===160||l>=5760&&[5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].indexOf(l)>=0},isLineTerminator:function(l){return l===10||l===13||l===8232||l===8233},isIdentifierStart:function(l){return l===36||l===95||l>=65&&l<=90||l>=97&&l<=122||l===92||l>=128&&c.NonAsciiIdentifierStart.test(s.Character.fromCodePoint(l))},isIdentifierPart:function(l){return l===36||l===95||l>=65&&l<=90||l>=97&&l<=122||l>=48&&l<=57||l===92||l>=128&&c.NonAsciiIdentifierPart.test(s.Character.fromCodePoint(l))},isDecimalDigit:function(l){return l>=48&&l<=57},isHexDigit:function(l){return l>=48&&l<=57||l>=65&&l<=70||l>=97&&l<=102},isOctalDigit:function(l){return l>=48&&l<=55}}},function(a,s,c){Object.defineProperty(s,"__esModule",{value:!0});var l=c(6),f=function(C){this.type=l.JSXSyntax.JSXClosingElement,this.name=C};s.JSXClosingElement=f;var u=function(C,S,T){this.type=l.JSXSyntax.JSXElement,this.openingElement=C,this.children=S,this.closingElement=T};s.JSXElement=u;var d=function(){this.type=l.JSXSyntax.JSXEmptyExpression};s.JSXEmptyExpression=d;var h=function(C){this.type=l.JSXSyntax.JSXExpressionContainer,this.expression=C};s.JSXExpressionContainer=h;var g=function(C){this.type=l.JSXSyntax.JSXIdentifier,this.name=C};s.JSXIdentifier=g;var p=function(C,S){this.type=l.JSXSyntax.JSXMemberExpression,this.object=C,this.property=S};s.JSXMemberExpression=p;var v=function(C,S){this.type=l.JSXSyntax.JSXAttribute,this.name=C,this.value=S};s.JSXAttribute=v;var y=function(C,S){this.type=l.JSXSyntax.JSXNamespacedName,this.namespace=C,this.name=S};s.JSXNamespacedName=y;var m=function(C,S,T){this.type=l.JSXSyntax.JSXOpeningElement,this.name=C,this.selfClosing=S,this.attributes=T};s.JSXOpeningElement=m;var w=function(C){this.type=l.JSXSyntax.JSXSpreadAttribute,this.argument=C};s.JSXSpreadAttribute=w;var x=function(C,S){this.type=l.JSXSyntax.JSXText,this.value=C,this.raw=S};s.JSXText=x},function(a,s){Object.defineProperty(s,"__esModule",{value:!0}),s.JSXSyntax={JSXAttribute:"JSXAttribute",JSXClosingElement:"JSXClosingElement",JSXElement:"JSXElement",JSXEmptyExpression:"JSXEmptyExpression",JSXExpressionContainer:"JSXExpressionContainer",JSXIdentifier:"JSXIdentifier",JSXMemberExpression:"JSXMemberExpression",JSXNamespacedName:"JSXNamespacedName",JSXOpeningElement:"JSXOpeningElement",JSXSpreadAttribute:"JSXSpreadAttribute",JSXText:"JSXText"}},function(a,s,c){Object.defineProperty(s,"__esModule",{value:!0});var l=c(2),f=function(Ye){this.type=l.Syntax.ArrayExpression,this.elements=Ye};s.ArrayExpression=f;var u=function(Ye){this.type=l.Syntax.ArrayPattern,this.elements=Ye};s.ArrayPattern=u;var d=function(Ye,ut,Rt){this.type=l.Syntax.ArrowFunctionExpression,this.id=null,this.params=Ye,this.body=ut,this.generator=!1,this.expression=Rt,this.async=!1};s.ArrowFunctionExpression=d;var h=function(Ye,ut,Rt){this.type=l.Syntax.AssignmentExpression,this.operator=Ye,this.left=ut,this.right=Rt};s.AssignmentExpression=h;var g=function(Ye,ut){this.type=l.Syntax.AssignmentPattern,this.left=Ye,this.right=ut};s.AssignmentPattern=g;var p=function(Ye,ut,Rt){this.type=l.Syntax.ArrowFunctionExpression,this.id=null,this.params=Ye,this.body=ut,this.generator=!1,this.expression=Rt,this.async=!0};s.AsyncArrowFunctionExpression=p;var v=function(Ye,ut,Rt){this.type=l.Syntax.FunctionDeclaration,this.id=Ye,this.params=ut,this.body=Rt,this.generator=!1,this.expression=!1,this.async=!0};s.AsyncFunctionDeclaration=v;var y=function(Ye,ut,Rt){this.type=l.Syntax.FunctionExpression,this.id=Ye,this.params=ut,this.body=Rt,this.generator=!1,this.expression=!1,this.async=!0};s.AsyncFunctionExpression=y;var m=function(Ye){this.type=l.Syntax.AwaitExpression,this.argument=Ye};s.AwaitExpression=m;var w=function(Ye,ut,Rt){var mn=Ye==="||"||Ye==="&&";this.type=mn?l.Syntax.LogicalExpression:l.Syntax.BinaryExpression,this.operator=Ye,this.left=ut,this.right=Rt};s.BinaryExpression=w;var x=function(Ye){this.type=l.Syntax.BlockStatement,this.body=Ye};s.BlockStatement=x;var C=function(Ye){this.type=l.Syntax.BreakStatement,this.label=Ye};s.BreakStatement=C;var S=function(Ye,ut){this.type=l.Syntax.CallExpression,this.callee=Ye,this.arguments=ut};s.CallExpression=S;var T=function(Ye,ut){this.type=l.Syntax.CatchClause,this.param=Ye,this.body=ut};s.CatchClause=T;var _=function(Ye){this.type=l.Syntax.ClassBody,this.body=Ye};s.ClassBody=_;var E=function(Ye,ut,Rt){this.type=l.Syntax.ClassDeclaration,this.id=Ye,this.superClass=ut,this.body=Rt};s.ClassDeclaration=E;var b=function(Ye,ut,Rt){this.type=l.Syntax.ClassExpression,this.id=Ye,this.superClass=ut,this.body=Rt};s.ClassExpression=b;var D=function(Ye,ut){this.type=l.Syntax.MemberExpression,this.computed=!0,this.object=Ye,this.property=ut};s.ComputedMemberExpression=D;var I=function(Ye,ut,Rt){this.type=l.Syntax.ConditionalExpression,this.test=Ye,this.consequent=ut,this.alternate=Rt};s.ConditionalExpression=I;var P=function(Ye){this.type=l.Syntax.ContinueStatement,this.label=Ye};s.ContinueStatement=P;var O=function(){this.type=l.Syntax.DebuggerStatement};s.DebuggerStatement=O;var L=function(Ye,ut){this.type=l.Syntax.ExpressionStatement,this.expression=Ye,this.directive=ut};s.Directive=L;var B=function(Ye,ut){this.type=l.Syntax.DoWhileStatement,this.body=Ye,this.test=ut};s.DoWhileStatement=B;var H=function(){this.type=l.Syntax.EmptyStatement};s.EmptyStatement=H;var A=function(Ye){this.type=l.Syntax.ExportAllDeclaration,this.source=Ye};s.ExportAllDeclaration=A;var F=function(Ye){this.type=l.Syntax.ExportDefaultDeclaration,this.declaration=Ye};s.ExportDefaultDeclaration=F;var G=function(Ye,ut,Rt){this.type=l.Syntax.ExportNamedDeclaration,this.declaration=Ye,this.specifiers=ut,this.source=Rt};s.ExportNamedDeclaration=G;var X=function(Ye,ut){this.type=l.Syntax.ExportSpecifier,this.exported=ut,this.local=Ye};s.ExportSpecifier=X;var ee=function(Ye){this.type=l.Syntax.ExpressionStatement,this.expression=Ye};s.ExpressionStatement=ee;var ce=function(Ye,ut,Rt){this.type=l.Syntax.ForInStatement,this.left=Ye,this.right=ut,this.body=Rt,this.each=!1};s.ForInStatement=ce;var Se=function(Ye,ut,Rt){this.type=l.Syntax.ForOfStatement,this.left=Ye,this.right=ut,this.body=Rt};s.ForOfStatement=Se;var we=function(Ye,ut,Rt,mn){this.type=l.Syntax.ForStatement,this.init=Ye,this.test=ut,this.update=Rt,this.body=mn};s.ForStatement=we;var _e=function(Ye,ut,Rt,mn){this.type=l.Syntax.FunctionDeclaration,this.id=Ye,this.params=ut,this.body=Rt,this.generator=mn,this.expression=!1,this.async=!1};s.FunctionDeclaration=_e;var Ve=function(Ye,ut,Rt,mn){this.type=l.Syntax.FunctionExpression,this.id=Ye,this.params=ut,this.body=Rt,this.generator=mn,this.expression=!1,this.async=!1};s.FunctionExpression=Ve;var Ge=function(Ye){this.type=l.Syntax.Identifier,this.name=Ye};s.Identifier=Ge;var Ne=function(Ye,ut,Rt){this.type=l.Syntax.IfStatement,this.test=Ye,this.consequent=ut,this.alternate=Rt};s.IfStatement=Ne;var j=function(Ye,ut){this.type=l.Syntax.ImportDeclaration,this.specifiers=Ye,this.source=ut};s.ImportDeclaration=j;var M=function(Ye){this.type=l.Syntax.ImportDefaultSpecifier,this.local=Ye};s.ImportDefaultSpecifier=M;var q=function(Ye){this.type=l.Syntax.ImportNamespaceSpecifier,this.local=Ye};s.ImportNamespaceSpecifier=q;var K=function(Ye,ut){this.type=l.Syntax.ImportSpecifier,this.local=Ye,this.imported=ut};s.ImportSpecifier=K;var J=function(Ye,ut){this.type=l.Syntax.LabeledStatement,this.label=Ye,this.body=ut};s.LabeledStatement=J;var re=function(Ye,ut){this.type=l.Syntax.Literal,this.value=Ye,this.raw=ut};s.Literal=re;var ie=function(Ye,ut){this.type=l.Syntax.MetaProperty,this.meta=Ye,this.property=ut};s.MetaProperty=ie;var Re=function(Ye,ut,Rt,mn,Fr){this.type=l.Syntax.MethodDefinition,this.key=Ye,this.computed=ut,this.value=Rt,this.kind=mn,this.static=Fr};s.MethodDefinition=Re;var Fe=function(Ye){this.type=l.Syntax.Program,this.body=Ye,this.sourceType="module"};s.Module=Fe;var je=function(Ye,ut){this.type=l.Syntax.NewExpression,this.callee=Ye,this.arguments=ut};s.NewExpression=je;var Xe=function(Ye){this.type=l.Syntax.ObjectExpression,this.properties=Ye};s.ObjectExpression=Xe;var se=function(Ye){this.type=l.Syntax.ObjectPattern,this.properties=Ye};s.ObjectPattern=se;var ue=function(Ye,ut,Rt,mn,Fr,Lt){this.type=l.Syntax.Property,this.key=ut,this.computed=Rt,this.value=mn,this.kind=Ye,this.method=Fr,this.shorthand=Lt};s.Property=ue;var Pe=function(Ye,ut,Rt,mn){this.type=l.Syntax.Literal,this.value=Ye,this.raw=ut,this.regex={pattern:Rt,flags:mn}};s.RegexLiteral=Pe;var pe=function(Ye){this.type=l.Syntax.RestElement,this.argument=Ye};s.RestElement=pe;var Ee=function(Ye){this.type=l.Syntax.ReturnStatement,this.argument=Ye};s.ReturnStatement=Ee;var Qe=function(Ye){this.type=l.Syntax.Program,this.body=Ye,this.sourceType="script"};s.Script=Qe;var fe=function(Ye){this.type=l.Syntax.SequenceExpression,this.expressions=Ye};s.SequenceExpression=fe;var ft=function(Ye){this.type=l.Syntax.SpreadElement,this.argument=Ye};s.SpreadElement=ft;var pt=function(Ye,ut){this.type=l.Syntax.MemberExpression,this.computed=!1,this.object=Ye,this.property=ut};s.StaticMemberExpression=pt;var dt=function(){this.type=l.Syntax.Super};s.Super=dt;var Ue=function(Ye,ut){this.type=l.Syntax.SwitchCase,this.test=Ye,this.consequent=ut};s.SwitchCase=Ue;var nt=function(Ye,ut){this.type=l.Syntax.SwitchStatement,this.discriminant=Ye,this.cases=ut};s.SwitchStatement=nt;var at=function(Ye,ut){this.type=l.Syntax.TaggedTemplateExpression,this.tag=Ye,this.quasi=ut};s.TaggedTemplateExpression=at;var ot=function(Ye,ut){this.type=l.Syntax.TemplateElement,this.value=Ye,this.tail=ut};s.TemplateElement=ot;var lt=function(Ye,ut){this.type=l.Syntax.TemplateLiteral,this.quasis=Ye,this.expressions=ut};s.TemplateLiteral=lt;var _t=function(){this.type=l.Syntax.ThisExpression};s.ThisExpression=_t;var vt=function(Ye){this.type=l.Syntax.ThrowStatement,this.argument=Ye};s.ThrowStatement=vt;var Mt=function(Ye,ut,Rt){this.type=l.Syntax.TryStatement,this.block=Ye,this.handler=ut,this.finalizer=Rt};s.TryStatement=Mt;var Ft=function(Ye,ut){this.type=l.Syntax.UnaryExpression,this.operator=Ye,this.argument=ut,this.prefix=!0};s.UnaryExpression=Ft;var wn=function(Ye,ut,Rt){this.type=l.Syntax.UpdateExpression,this.operator=Ye,this.argument=ut,this.prefix=Rt};s.UpdateExpression=wn;var Dn=function(Ye,ut){this.type=l.Syntax.VariableDeclaration,this.declarations=Ye,this.kind=ut};s.VariableDeclaration=Dn;var Nt=function(Ye,ut){this.type=l.Syntax.VariableDeclarator,this.id=Ye,this.init=ut};s.VariableDeclarator=Nt;var xn=function(Ye,ut){this.type=l.Syntax.WhileStatement,this.test=Ye,this.body=ut};s.WhileStatement=xn;var Ui=function(Ye,ut){this.type=l.Syntax.WithStatement,this.object=Ye,this.body=ut};s.WithStatement=Ui;var br=function(Ye,ut){this.type=l.Syntax.YieldExpression,this.argument=Ye,this.delegate=ut};s.YieldExpression=br},function(a,s,c){Object.defineProperty(s,"__esModule",{value:!0});var l=c(9),f=c(10),u=c(11),d=c(7),h=c(12),g=c(2),p=c(13),v=function(){function y(m,w,x){w===void 0&&(w={}),this.config={range:typeof w.range=="boolean"&&w.range,loc:typeof w.loc=="boolean"&&w.loc,source:null,tokens:typeof w.tokens=="boolean"&&w.tokens,comment:typeof w.comment=="boolean"&&w.comment,tolerant:typeof w.tolerant=="boolean"&&w.tolerant},this.config.loc&&w.source&&w.source!==null&&(this.config.source=String(w.source)),this.delegate=x,this.errorHandler=new f.ErrorHandler,this.errorHandler.tolerant=this.config.tolerant,this.scanner=new h.Scanner(m,this.errorHandler),this.scanner.trackComment=this.config.comment,this.operatorPrecedence={")":0,";":0,",":0,"=":0,"]":0,"||":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":11,"/":11,"%":11},this.lookahead={type:2,value:"",lineNumber:this.scanner.lineNumber,lineStart:0,start:0,end:0},this.hasLineTerminator=!1,this.context={isModule:!1,await:!1,allowIn:!0,allowStrictDirective:!0,allowYield:!0,firstCoverInitializedNameError:null,isAssignmentTarget:!1,isBindingElement:!1,inFunctionBody:!1,inIteration:!1,inSwitch:!1,labelSet:{},strict:!1},this.tokens=[],this.startMarker={index:0,line:this.scanner.lineNumber,column:0},this.lastMarker={index:0,line:this.scanner.lineNumber,column:0},this.nextToken(),this.lastMarker={index:this.scanner.index,line:this.scanner.lineNumber,column:this.scanner.index-this.scanner.lineStart}}return y.prototype.throwError=function(m){for(var w=[],x=1;x<arguments.length;x++)w[x-1]=arguments[x];var C=Array.prototype.slice.call(arguments,1),S=m.replace(/%(\d)/g,function(b,D){return l.assert(D<C.length,"Message reference must be in range"),C[D]}),T=this.lastMarker.index,_=this.lastMarker.line,E=this.lastMarker.column+1;throw this.errorHandler.createError(T,_,E,S)},y.prototype.tolerateError=function(m){for(var w=[],x=1;x<arguments.length;x++)w[x-1]=arguments[x];var C=Array.prototype.slice.call(arguments,1),S=m.replace(/%(\d)/g,function(b,D){return l.assert(D<C.length,"Message reference must be in range"),C[D]}),T=this.lastMarker.index,_=this.scanner.lineNumber,E=this.lastMarker.column+1;this.errorHandler.tolerateError(T,_,E,S)},y.prototype.unexpectedTokenError=function(m,w){var x,C=w||u.Messages.UnexpectedToken;if(m?(w||(C=m.type===2?u.Messages.UnexpectedEOS:m.type===3?u.Messages.UnexpectedIdentifier:m.type===6?u.Messages.UnexpectedNumber:m.type===8?u.Messages.UnexpectedString:m.type===10?u.Messages.UnexpectedTemplate:u.Messages.UnexpectedToken,m.type===4&&(this.scanner.isFutureReservedWord(m.value)?C=u.Messages.UnexpectedReserved:this.context.strict&&this.scanner.isStrictModeReservedWord(m.value)&&(C=u.Messages.StrictReservedWord))),x=m.value):x="ILLEGAL",C=C.replace("%0",x),m&&typeof m.lineNumber=="number"){var S=m.start,T=m.lineNumber,_=this.lastMarker.index-this.lastMarker.column,E=m.start-_+1;return this.errorHandler.createError(S,T,E,C)}return S=this.lastMarker.index,T=this.lastMarker.line,E=this.lastMarker.column+1,this.errorHandler.createError(S,T,E,C)},y.prototype.throwUnexpectedToken=function(m,w){throw this.unexpectedTokenError(m,w)},y.prototype.tolerateUnexpectedToken=function(m,w){this.errorHandler.tolerate(this.unexpectedTokenError(m,w))},y.prototype.collectComments=function(){if(this.config.comment){var m=this.scanner.scanComments();if(m.length>0&&this.delegate)for(var w=0;w<m.length;++w){var x=m[w],C=void 0;C={type:x.multiLine?"BlockComment":"LineComment",value:this.scanner.source.slice(x.slice[0],x.slice[1])},this.config.range&&(C.range=x.range),this.config.loc&&(C.loc=x.loc);var S={start:{line:x.loc.start.line,column:x.loc.start.column,offset:x.range[0]},end:{line:x.loc.end.line,column:x.loc.end.column,offset:x.range[1]}};this.delegate(C,S)}}else this.scanner.scanComments()},y.prototype.getTokenRaw=function(m){return this.scanner.source.slice(m.start,m.end)},y.prototype.convertToken=function(m){var w={type:p.TokenName[m.type],value:this.getTokenRaw(m)};if(this.config.range&&(w.range=[m.start,m.end]),this.config.loc&&(w.loc={start:{line:this.startMarker.line,column:this.startMarker.column},end:{line:this.scanner.lineNumber,column:this.scanner.index-this.scanner.lineStart}}),m.type===9){var x=m.pattern,C=m.flags;w.regex={pattern:x,flags:C}}return w},y.prototype.nextToken=function(){var m=this.lookahead;this.lastMarker.index=this.scanner.index,this.lastMarker.line=this.scanner.lineNumber,this.lastMarker.column=this.scanner.index-this.scanner.lineStart,this.collectComments(),this.scanner.index!==this.startMarker.index&&(this.startMarker.index=this.scanner.index,this.startMarker.line=this.scanner.lineNumber,this.startMarker.column=this.scanner.index-this.scanner.lineStart);var w=this.scanner.lex();return this.hasLineTerminator=m.lineNumber!==w.lineNumber,w&&this.context.strict&&w.type===3&&this.scanner.isStrictModeReservedWord(w.value)&&(w.type=4),this.lookahead=w,this.config.tokens&&w.type!==2&&this.tokens.push(this.convertToken(w)),m},y.prototype.nextRegexToken=function(){this.collectComments();var m=this.scanner.scanRegExp();return this.config.tokens&&(this.tokens.pop(),this.tokens.push(this.convertToken(m))),this.lookahead=m,this.nextToken(),m},y.prototype.createNode=function(){return{index:this.startMarker.index,line:this.startMarker.line,column:this.startMarker.column}},y.prototype.startNode=function(m,w){w===void 0&&(w=0);var x=m.start-m.lineStart,C=m.lineNumber;return x<0&&(x+=w,C--),{index:m.start,line:C,column:x}},y.prototype.finalize=function(m,w){if(this.config.range&&(w.range=[m.index,this.lastMarker.index]),this.config.loc&&(w.loc={start:{line:m.line,column:m.column},end:{line:this.lastMarker.line,column:this.lastMarker.column}},this.config.source&&(w.loc.source=this.config.source)),this.delegate){var x={start:{line:m.line,column:m.column,offset:m.index},end:{line:this.lastMarker.line,column:this.lastMarker.column,offset:this.lastMarker.index}};this.delegate(w,x)}return w},y.prototype.expect=function(m){var w=this.nextToken();w.type===7&&w.value===m||this.throwUnexpectedToken(w)},y.prototype.expectCommaSeparator=function(){if(this.config.tolerant){var m=this.lookahead;m.type===7&&m.value===","?this.nextToken():m.type===7&&m.value===";"?(this.nextToken(),this.tolerateUnexpectedToken(m)):this.tolerateUnexpectedToken(m,u.Messages.UnexpectedToken)}else this.expect(",")},y.prototype.expectKeyword=function(m){var w=this.nextToken();w.type===4&&w.value===m||this.throwUnexpectedToken(w)},y.prototype.match=function(m){return this.lookahead.type===7&&this.lookahead.value===m},y.prototype.matchKeyword=function(m){return this.lookahead.type===4&&this.lookahead.value===m},y.prototype.matchContextualKeyword=function(m){return this.lookahead.type===3&&this.lookahead.value===m},y.prototype.matchAssign=function(){if(this.lookahead.type!==7)return!1;var m=this.lookahead.value;return m==="="||m==="*="||m==="**="||m==="/="||m==="%="||m==="+="||m==="-="||m==="<<="||m===">>="||m===">>>="||m==="&="||m==="^="||m==="|="},y.prototype.isolateCoverGrammar=function(m){var w=this.context.isBindingElement,x=this.context.isAssignmentTarget,C=this.context.firstCoverInitializedNameError;this.context.isBindingElement=!0,this.context.isAssignmentTarget=!0,this.context.firstCoverInitializedNameError=null;var S=m.call(this);return this.context.firstCoverInitializedNameError!==null&&this.throwUnexpectedToken(this.context.firstCoverInitializedNameError),this.context.isBindingElement=w,this.context.isAssignmentTarget=x,this.context.firstCoverInitializedNameError=C,S},y.prototype.inheritCoverGrammar=function(m){var w=this.context.isBindingElement,x=this.context.isAssignmentTarget,C=this.context.firstCoverInitializedNameError;this.context.isBindingElement=!0,this.context.isAssignmentTarget=!0,this.context.firstCoverInitializedNameError=null;var S=m.call(this);return this.context.isBindingElement=this.context.isBindingElement&&w,this.context.isAssignmentTarget=this.context.isAssignmentTarget&&x,this.context.firstCoverInitializedNameError=C||this.context.firstCoverInitializedNameError,S},y.prototype.consumeSemicolon=function(){this.match(";")?this.nextToken():this.hasLineTerminator||(this.lookahead.type===2||this.match("}")||this.throwUnexpectedToken(this.lookahead),this.lastMarker.index=this.startMarker.index,this.lastMarker.line=this.startMarker.line,this.lastMarker.column=this.startMarker.column)},y.prototype.parsePrimaryExpression=function(){var m,w,x,C=this.createNode();switch(this.lookahead.type){case 3:(this.context.isModule||this.context.await)&&this.lookahead.value==="await"&&this.tolerateUnexpectedToken(this.lookahead),m=this.matchAsyncFunction()?this.parseFunctionExpression():this.finalize(C,new d.Identifier(this.nextToken().value));break;case 6:case 8:this.context.strict&&this.lookahead.octal&&this.tolerateUnexpectedToken(this.lookahead,u.Messages.StrictOctalLiteral),this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1,w=this.nextToken(),x=this.getTokenRaw(w),m=this.finalize(C,new d.Literal(w.value,x));break;case 1:this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1,w=this.nextToken(),x=this.getTokenRaw(w),m=this.finalize(C,new d.Literal(w.value==="true",x));break;case 5:this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1,w=this.nextToken(),x=this.getTokenRaw(w),m=this.finalize(C,new d.Literal(null,x));break;case 10:m=this.parseTemplateLiteral();break;case 7:switch(this.lookahead.value){case"(":this.context.isBindingElement=!1,m=this.inheritCoverGrammar(this.parseGroupExpression);break;case"[":m=this.inheritCoverGrammar(this.parseArrayInitializer);break;case"{":m=this.inheritCoverGrammar(this.parseObjectInitializer);break;case"/":case"/=":this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1,this.scanner.index=this.startMarker.index,w=this.nextRegexToken(),x=this.getTokenRaw(w),m=this.finalize(C,new d.RegexLiteral(w.regex,x,w.pattern,w.flags));break;default:m=this.throwUnexpectedToken(this.nextToken())}break;case 4:!this.context.strict&&this.context.allowYield&&this.matchKeyword("yield")?m=this.parseIdentifierName():!this.context.strict&&this.matchKeyword("let")?m=this.finalize(C,new d.Identifier(this.nextToken().value)):(this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1,this.matchKeyword("function")?m=this.parseFunctionExpression():this.matchKeyword("this")?(this.nextToken(),m=this.finalize(C,new d.ThisExpression)):m=this.matchKeyword("class")?this.parseClassExpression():this.throwUnexpectedToken(this.nextToken()));break;default:m=this.throwUnexpectedToken(this.nextToken())}return m},y.prototype.parseSpreadElement=function(){var m=this.createNode();this.expect("...");var w=this.inheritCoverGrammar(this.parseAssignmentExpression);return this.finalize(m,new d.SpreadElement(w))},y.prototype.parseArrayInitializer=function(){var m=this.createNode(),w=[];for(this.expect("[");!this.match("]");)if(this.match(","))this.nextToken(),w.push(null);else if(this.match("...")){var x=this.parseSpreadElement();this.match("]")||(this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1,this.expect(",")),w.push(x)}else w.push(this.inheritCoverGrammar(this.parseAssignmentExpression)),this.match("]")||this.expect(",");return this.expect("]"),this.finalize(m,new d.ArrayExpression(w))},y.prototype.parsePropertyMethod=function(m){this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1;var w=this.context.strict,x=this.context.allowStrictDirective;this.context.allowStrictDirective=m.simple;var C=this.isolateCoverGrammar(this.parseFunctionSourceElements);return this.context.strict&&m.firstRestricted&&this.tolerateUnexpectedToken(m.firstRestricted,m.message),this.context.strict&&m.stricted&&this.tolerateUnexpectedToken(m.stricted,m.message),this.context.strict=w,this.context.allowStrictDirective=x,C},y.prototype.parsePropertyMethodFunction=function(){var m=this.createNode(),w=this.context.allowYield;this.context.allowYield=!0;var x=this.parseFormalParameters(),C=this.parsePropertyMethod(x);return this.context.allowYield=w,this.finalize(m,new d.FunctionExpression(null,x.params,C,!1))},y.prototype.parsePropertyMethodAsyncFunction=function(){var m=this.createNode(),w=this.context.allowYield,x=this.context.await;this.context.allowYield=!1,this.context.await=!0;var C=this.parseFormalParameters(),S=this.parsePropertyMethod(C);return this.context.allowYield=w,this.context.await=x,this.finalize(m,new d.AsyncFunctionExpression(null,C.params,S))},y.prototype.parseObjectPropertyKey=function(){var m,w=this.createNode(),x=this.nextToken();switch(x.type){case 8:case 6:this.context.strict&&x.octal&&this.tolerateUnexpectedToken(x,u.Messages.StrictOctalLiteral);var C=this.getTokenRaw(x);m=this.finalize(w,new d.Literal(x.value,C));break;case 3:case 1:case 5:case 4:m=this.finalize(w,new d.Identifier(x.value));break;case 7:x.value==="["?(m=this.isolateCoverGrammar(this.parseAssignmentExpression),this.expect("]")):m=this.throwUnexpectedToken(x);break;default:m=this.throwUnexpectedToken(x)}return m},y.prototype.isPropertyKey=function(m,w){return m.type===g.Syntax.Identifier&&m.name===w||m.type===g.Syntax.Literal&&m.value===w},y.prototype.parseObjectProperty=function(m){var w,x=this.createNode(),C=this.lookahead,S=null,T=null,_=!1,E=!1,b=!1,D=!1;if(C.type===3){var I=C.value;this.nextToken(),_=this.match("["),S=(D=!(this.hasLineTerminator||I!=="async"||this.match(":")||this.match("(")||this.match("*")||this.match(",")))?this.parseObjectPropertyKey():this.finalize(x,new d.Identifier(I))}else this.match("*")?this.nextToken():(_=this.match("["),S=this.parseObjectPropertyKey());var P=this.qualifiedPropertyName(this.lookahead);if(C.type===3&&!D&&C.value==="get"&&P)w="get",_=this.match("["),S=this.parseObjectPropertyKey(),this.context.allowYield=!1,T=this.parseGetterMethod();else if(C.type===3&&!D&&C.value==="set"&&P)w="set",_=this.match("["),S=this.parseObjectPropertyKey(),T=this.parseSetterMethod();else if(C.type===7&&C.value==="*"&&P)w="init",_=this.match("["),S=this.parseObjectPropertyKey(),T=this.parseGeneratorMethod(),E=!0;else if(S||this.throwUnexpectedToken(this.lookahead),w="init",this.match(":")&&!D)!_&&this.isPropertyKey(S,"__proto__")&&(m.value&&this.tolerateError(u.Messages.DuplicateProtoProperty),m.value=!0),this.nextToken(),T=this.inheritCoverGrammar(this.parseAssignmentExpression);else if(this.match("("))T=D?this.parsePropertyMethodAsyncFunction():this.parsePropertyMethodFunction(),E=!0;else if(C.type===3)if(I=this.finalize(x,new d.Identifier(C.value)),this.match("=")){this.context.firstCoverInitializedNameError=this.lookahead,this.nextToken(),b=!0;var O=this.isolateCoverGrammar(this.parseAssignmentExpression);T=this.finalize(x,new d.AssignmentPattern(I,O))}else b=!0,T=I;else this.throwUnexpectedToken(this.nextToken());return this.finalize(x,new d.Property(w,S,_,T,E,b))},y.prototype.parseObjectInitializer=function(){var m=this.createNode();this.expect("{");for(var w=[],x={value:!1};!this.match("}");)w.push(this.parseObjectProperty(x)),this.match("}")||this.expectCommaSeparator();return this.expect("}"),this.finalize(m,new d.ObjectExpression(w))},y.prototype.parseTemplateHead=function(){l.assert(this.lookahead.head,"Template literal must start with a template head");var m=this.createNode(),w=this.nextToken(),x=w.value,C=w.cooked;return this.finalize(m,new d.TemplateElement({raw:x,cooked:C},w.tail))},y.prototype.parseTemplateElement=function(){this.lookahead.type!==10&&this.throwUnexpectedToken();var m=this.createNode(),w=this.nextToken(),x=w.value,C=w.cooked;return this.finalize(m,new d.TemplateElement({raw:x,cooked:C},w.tail))},y.prototype.parseTemplateLiteral=function(){var m=this.createNode(),w=[],x=[],C=this.parseTemplateHead();for(x.push(C);!C.tail;)w.push(this.parseExpression()),C=this.parseTemplateElement(),x.push(C);return this.finalize(m,new d.TemplateLiteral(x,w))},y.prototype.reinterpretExpressionAsPattern=function(m){switch(m.type){case g.Syntax.Identifier:case g.Syntax.MemberExpression:case g.Syntax.RestElement:case g.Syntax.AssignmentPattern:break;case g.Syntax.SpreadElement:m.type=g.Syntax.RestElement,this.reinterpretExpressionAsPattern(m.argument);break;case g.Syntax.ArrayExpression:m.type=g.Syntax.ArrayPattern;for(var w=0;w<m.elements.length;w++)m.elements[w]!==null&&this.reinterpretExpressionAsPattern(m.elements[w]);break;case g.Syntax.ObjectExpression:for(m.type=g.Syntax.ObjectPattern,w=0;w<m.properties.length;w++)this.reinterpretExpressionAsPattern(m.properties[w].value);break;case g.Syntax.AssignmentExpression:m.type=g.Syntax.AssignmentPattern,delete m.operator,this.reinterpretExpressionAsPattern(m.left)}},y.prototype.parseGroupExpression=function(){var m;if(this.expect("("),this.match(")"))this.nextToken(),this.match("=>")||this.expect("=>"),m={type:"ArrowParameterPlaceHolder",params:[],async:!1};else{var w=this.lookahead,x=[];if(this.match("..."))m=this.parseRestElement(x),this.expect(")"),this.match("=>")||this.expect("=>"),m={type:"ArrowParameterPlaceHolder",params:[m],async:!1};else{var C=!1;if(this.context.isBindingElement=!0,m=this.inheritCoverGrammar(this.parseAssignmentExpression),this.match(",")){var S=[];for(this.context.isAssignmentTarget=!1,S.push(m);this.lookahead.type!==2&&this.match(",");){if(this.nextToken(),this.match(")")){this.nextToken();for(var T=0;T<S.length;T++)this.reinterpretExpressionAsPattern(S[T]);C=!0,m={type:"ArrowParameterPlaceHolder",params:S,async:!1}}else if(this.match("...")){for(this.context.isBindingElement||this.throwUnexpectedToken(this.lookahead),S.push(this.parseRestElement(x)),this.expect(")"),this.match("=>")||this.expect("=>"),this.context.isBindingElement=!1,T=0;T<S.length;T++)this.reinterpretExpressionAsPattern(S[T]);C=!0,m={type:"ArrowParameterPlaceHolder",params:S,async:!1}}else S.push(this.inheritCoverGrammar(this.parseAssignmentExpression));if(C)break}C||(m=this.finalize(this.startNode(w),new d.SequenceExpression(S)))}if(!C){if(this.expect(")"),this.match("=>")&&(m.type===g.Syntax.Identifier&&m.name==="yield"&&(C=!0,m={type:"ArrowParameterPlaceHolder",params:[m],async:!1}),!C)){if(this.context.isBindingElement||this.throwUnexpectedToken(this.lookahead),m.type===g.Syntax.SequenceExpression)for(T=0;T<m.expressions.length;T++)this.reinterpretExpressionAsPattern(m.expressions[T]);else this.reinterpretExpressionAsPattern(m);m={type:"ArrowParameterPlaceHolder",params:m.type===g.Syntax.SequenceExpression?m.expressions:[m],async:!1}}this.context.isBindingElement=!1}}}return m},y.prototype.parseArguments=function(){this.expect("(");var m=[];if(!this.match(")"))for(;;){var w=this.match("...")?this.parseSpreadElement():this.isolateCoverGrammar(this.parseAssignmentExpression);if(m.push(w),this.match(")")||(this.expectCommaSeparator(),this.match(")")))break}return this.expect(")"),m},y.prototype.isIdentifierName=function(m){return m.type===3||m.type===4||m.type===1||m.type===5},y.prototype.parseIdentifierName=function(){var m=this.createNode(),w=this.nextToken();return this.isIdentifierName(w)||this.throwUnexpectedToken(w),this.finalize(m,new d.Identifier(w.value))},y.prototype.parseNewExpression=function(){var m,w=this.createNode(),x=this.parseIdentifierName();if(l.assert(x.name==="new","New expression must start with `new`"),this.match("."))if(this.nextToken(),this.lookahead.type===3&&this.context.inFunctionBody&&this.lookahead.value==="target"){var C=this.parseIdentifierName();m=new d.MetaProperty(x,C)}else this.throwUnexpectedToken(this.lookahead);else{var S=this.isolateCoverGrammar(this.parseLeftHandSideExpression),T=this.match("(")?this.parseArguments():[];m=new d.NewExpression(S,T),this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1}return this.finalize(w,m)},y.prototype.parseAsyncArgument=function(){var m=this.parseAssignmentExpression();return this.context.firstCoverInitializedNameError=null,m},y.prototype.parseAsyncArguments=function(){this.expect("(");var m=[];if(!this.match(")"))for(;;){var w=this.match("...")?this.parseSpreadElement():this.isolateCoverGrammar(this.parseAsyncArgument);if(m.push(w),this.match(")")||(this.expectCommaSeparator(),this.match(")")))break}return this.expect(")"),m},y.prototype.parseLeftHandSideExpressionAllowCall=function(){var m,w=this.lookahead,x=this.matchContextualKeyword("async"),C=this.context.allowIn;for(this.context.allowIn=!0,this.matchKeyword("super")&&this.context.inFunctionBody?(m=this.createNode(),this.nextToken(),m=this.finalize(m,new d.Super),this.match("(")||this.match(".")||this.match("[")||this.throwUnexpectedToken(this.lookahead)):m=this.inheritCoverGrammar(this.matchKeyword("new")?this.parseNewExpression:this.parsePrimaryExpression);;)if(this.match(".")){this.context.isBindingElement=!1,this.context.isAssignmentTarget=!0,this.expect(".");var S=this.parseIdentifierName();m=this.finalize(this.startNode(w),new d.StaticMemberExpression(m,S))}else if(this.match("(")){var T=x&&w.lineNumber===this.lookahead.lineNumber;this.context.isBindingElement=!1,this.context.isAssignmentTarget=!1;var _=T?this.parseAsyncArguments():this.parseArguments();if(m=this.finalize(this.startNode(w),new d.CallExpression(m,_)),T&&this.match("=>")){for(var E=0;E<_.length;++E)this.reinterpretExpressionAsPattern(_[E]);m={type:"ArrowParameterPlaceHolder",params:_,async:!0}}}else if(this.match("["))this.context.isBindingElement=!1,this.context.isAssignmentTarget=!0,this.expect("["),S=this.isolateCoverGrammar(this.parseExpression),this.expect("]"),m=this.finalize(this.startNode(w),new d.ComputedMemberExpression(m,S));else{if(this.lookahead.type!==10||!this.lookahead.head)break;var b=this.parseTemplateLiteral();m=this.finalize(this.startNode(w),new d.TaggedTemplateExpression(m,b))}return this.context.allowIn=C,m},y.prototype.parseSuper=function(){var m=this.createNode();return this.expectKeyword("super"),this.match("[")||this.match(".")||this.throwUnexpectedToken(this.lookahead),this.finalize(m,new d.Super)},y.prototype.parseLeftHandSideExpression=function(){l.assert(this.context.allowIn,"callee of new expression always allow in keyword.");for(var m=this.startNode(this.lookahead),w=this.matchKeyword("super")&&this.context.inFunctionBody?this.parseSuper():this.inheritCoverGrammar(this.matchKeyword("new")?this.parseNewExpression:this.parsePrimaryExpression);;)if(this.match("[")){this.context.isBindingElement=!1,this.context.isAssignmentTarget=!0,this.expect("[");var x=this.isolateCoverGrammar(this.parseExpression);this.expect("]"),w=this.finalize(m,new d.ComputedMemberExpression(w,x))}else if(this.match("."))this.context.isBindingElement=!1,this.context.isAssignmentTarget=!0,this.expect("."),x=this.parseIdentifierName(),w=this.finalize(m,new d.StaticMemberExpression(w,x));else{if(this.lookahead.type!==10||!this.lookahead.head)break;var C=this.parseTemplateLiteral();w=this.finalize(m,new d.TaggedTemplateExpression(w,C))}return w},y.prototype.parseUpdateExpression=function(){var m,w=this.lookahead;if(this.match("++")||this.match("--")){var x=this.startNode(w),C=this.nextToken();m=this.inheritCoverGrammar(this.parseUnaryExpression),this.context.strict&&m.type===g.Syntax.Identifier&&this.scanner.isRestrictedWord(m.name)&&this.tolerateError(u.Messages.StrictLHSPrefix),this.context.isAssignmentTarget||this.tolerateError(u.Messages.InvalidLHSInAssignment);var S=!0;m=this.finalize(x,new d.UpdateExpression(C.value,m,S)),this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1}else if(m=this.inheritCoverGrammar(this.parseLeftHandSideExpressionAllowCall),!this.hasLineTerminator&&this.lookahead.type===7&&(this.match("++")||this.match("--"))){this.context.strict&&m.type===g.Syntax.Identifier&&this.scanner.isRestrictedWord(m.name)&&this.tolerateError(u.Messages.StrictLHSPostfix),this.context.isAssignmentTarget||this.tolerateError(u.Messages.InvalidLHSInAssignment),this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1;var T=this.nextToken().value;S=!1,m=this.finalize(this.startNode(w),new d.UpdateExpression(T,m,S))}return m},y.prototype.parseAwaitExpression=function(){var m=this.createNode();this.nextToken();var w=this.parseUnaryExpression();return this.finalize(m,new d.AwaitExpression(w))},y.prototype.parseUnaryExpression=function(){var m;if(this.match("+")||this.match("-")||this.match("~")||this.match("!")||this.matchKeyword("delete")||this.matchKeyword("void")||this.matchKeyword("typeof")){var w=this.startNode(this.lookahead),x=this.nextToken();m=this.inheritCoverGrammar(this.parseUnaryExpression),m=this.finalize(w,new d.UnaryExpression(x.value,m)),this.context.strict&&m.operator==="delete"&&m.argument.type===g.Syntax.Identifier&&this.tolerateError(u.Messages.StrictDelete),this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1}else m=this.context.await&&this.matchContextualKeyword("await")?this.parseAwaitExpression():this.parseUpdateExpression();return m},y.prototype.parseExponentiationExpression=function(){var m=this.lookahead,w=this.inheritCoverGrammar(this.parseUnaryExpression);if(w.type!==g.Syntax.UnaryExpression&&this.match("**")){this.nextToken(),this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1;var x=w,C=this.isolateCoverGrammar(this.parseExponentiationExpression);w=this.finalize(this.startNode(m),new d.BinaryExpression("**",x,C))}return w},y.prototype.binaryPrecedence=function(m){var w=m.value;return m.type===7?this.operatorPrecedence[w]||0:m.type===4&&(w==="instanceof"||this.context.allowIn&&w==="in")?7:0},y.prototype.parseBinaryExpression=function(){var m=this.lookahead,w=this.inheritCoverGrammar(this.parseExponentiationExpression),x=this.lookahead,C=this.binaryPrecedence(x);if(C>0){this.nextToken(),this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1;for(var S=[m,this.lookahead],T=w,_=this.isolateCoverGrammar(this.parseExponentiationExpression),E=[T,x.value,_],b=[C];!((C=this.binaryPrecedence(this.lookahead))<=0);){for(;E.length>2&&C<=b[b.length-1];){_=E.pop();var D=E.pop();b.pop(),T=E.pop(),S.pop();var I=this.startNode(S[S.length-1]);E.push(this.finalize(I,new d.BinaryExpression(D,T,_)))}E.push(this.nextToken().value),b.push(C),S.push(this.lookahead),E.push(this.isolateCoverGrammar(this.parseExponentiationExpression))}var P=E.length-1;w=E[P];for(var O=S.pop();P>1;){var L=S.pop(),B=O&&O.lineStart;I=this.startNode(L,B),D=E[P-1],w=this.finalize(I,new d.BinaryExpression(D,E[P-2],w)),P-=2,O=L}}return w},y.prototype.parseConditionalExpression=function(){var m=this.lookahead,w=this.inheritCoverGrammar(this.parseBinaryExpression);if(this.match("?")){this.nextToken();var x=this.context.allowIn;this.context.allowIn=!0;var C=this.isolateCoverGrammar(this.parseAssignmentExpression);this.context.allowIn=x,this.expect(":");var S=this.isolateCoverGrammar(this.parseAssignmentExpression);w=this.finalize(this.startNode(m),new d.ConditionalExpression(w,C,S)),this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1}return w},y.prototype.checkPatternParam=function(m,w){switch(w.type){case g.Syntax.Identifier:this.validateParam(m,w,w.name);break;case g.Syntax.RestElement:this.checkPatternParam(m,w.argument);break;case g.Syntax.AssignmentPattern:this.checkPatternParam(m,w.left);break;case g.Syntax.ArrayPattern:for(var x=0;x<w.elements.length;x++)w.elements[x]!==null&&this.checkPatternParam(m,w.elements[x]);break;case g.Syntax.ObjectPattern:for(x=0;x<w.properties.length;x++)this.checkPatternParam(m,w.properties[x].value)}m.simple=m.simple&&w instanceof d.Identifier},y.prototype.reinterpretAsCoverFormalsList=function(m){var w,x=[m],C=!1;switch(m.type){case g.Syntax.Identifier:break;case"ArrowParameterPlaceHolder":x=m.params,C=m.async;break;default:return null}w={simple:!0,paramSet:{}};for(var S=0;S<x.length;++S)(T=x[S]).type===g.Syntax.AssignmentPattern?T.right.type===g.Syntax.YieldExpression&&(T.right.argument&&this.throwUnexpectedToken(this.lookahead),T.right.type=g.Syntax.Identifier,T.right.name="yield",delete T.right.argument,delete T.right.delegate):C&&T.type===g.Syntax.Identifier&&T.name==="await"&&this.throwUnexpectedToken(this.lookahead),this.checkPatternParam(w,T),x[S]=T;if(this.context.strict||!this.context.allowYield)for(S=0;S<x.length;++S){var T;(T=x[S]).type===g.Syntax.YieldExpression&&this.throwUnexpectedToken(this.lookahead)}if(w.message===u.Messages.StrictParamDupe){var _=this.context.strict?w.stricted:w.firstRestricted;this.throwUnexpectedToken(_,w.message)}return{simple:w.simple,params:x,stricted:w.stricted,firstRestricted:w.firstRestricted,message:w.message}},y.prototype.parseAssignmentExpression=function(){var m;if(!this.context.allowYield&&this.matchKeyword("yield"))m=this.parseYieldExpression();else{var w=this.lookahead,x=w;if(m=this.parseConditionalExpression(),x.type===3&&x.lineNumber===this.lookahead.lineNumber&&x.value==="async"&&(this.lookahead.type===3||this.matchKeyword("yield"))){var C=this.parsePrimaryExpression();this.reinterpretExpressionAsPattern(C),m={type:"ArrowParameterPlaceHolder",params:[C],async:!0}}if(m.type==="ArrowParameterPlaceHolder"||this.match("=>")){this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1;var S=m.async,T=this.reinterpretAsCoverFormalsList(m);if(T){this.hasLineTerminator&&this.tolerateUnexpectedToken(this.lookahead),this.context.firstCoverInitializedNameError=null;var _=this.context.strict,E=this.context.allowStrictDirective;this.context.allowStrictDirective=T.simple;var b=this.context.allowYield,D=this.context.await;this.context.allowYield=!0,this.context.await=S;var I=this.startNode(w);this.expect("=>");var P=void 0;if(this.match("{")){var O=this.context.allowIn;this.context.allowIn=!0,P=this.parseFunctionSourceElements(),this.context.allowIn=O}else P=this.isolateCoverGrammar(this.parseAssignmentExpression);var L=P.type!==g.Syntax.BlockStatement;this.context.strict&&T.firstRestricted&&this.throwUnexpectedToken(T.firstRestricted,T.message),this.context.strict&&T.stricted&&this.tolerateUnexpectedToken(T.stricted,T.message),m=S?this.finalize(I,new d.AsyncArrowFunctionExpression(T.params,P,L)):this.finalize(I,new d.ArrowFunctionExpression(T.params,P,L)),this.context.strict=_,this.context.allowStrictDirective=E,this.context.allowYield=b,this.context.await=D}}else if(this.matchAssign()){if(this.context.isAssignmentTarget||this.tolerateError(u.Messages.InvalidLHSInAssignment),this.context.strict&&m.type===g.Syntax.Identifier){var B=m;this.scanner.isRestrictedWord(B.name)&&this.tolerateUnexpectedToken(x,u.Messages.StrictLHSAssignment),this.scanner.isStrictModeReservedWord(B.name)&&this.tolerateUnexpectedToken(x,u.Messages.StrictReservedWord)}this.match("=")?this.reinterpretExpressionAsPattern(m):(this.context.isAssignmentTarget=!1,this.context.isBindingElement=!1);var H=(x=this.nextToken()).value,A=this.isolateCoverGrammar(this.parseAssignmentExpression);m=this.finalize(this.startNode(w),new d.AssignmentExpression(H,m,A)),this.context.firstCoverInitializedNameError=null}}return m},y.prototype.parseExpression=function(){var m=this.lookahead,w=this.isolateCoverGrammar(this.parseAssignmentExpression);if(this.match(",")){var x=[];for(x.push(w);this.lookahead.type!==2&&this.match(",");)this.nextToken(),x.push(this.isolateCoverGrammar(this.parseAssignmentExpression));w=this.finalize(this.startNode(m),new d.SequenceExpression(x))}return w},y.prototype.parseStatementListItem=function(){var m;if(this.context.isAssignmentTarget=!0,this.context.isBindingElement=!0,this.lookahead.type===4)switch(this.lookahead.value){case"export":this.context.isModule||this.tolerateUnexpectedToken(this.lookahead,u.Messages.IllegalExportDeclaration),m=this.parseExportDeclaration();break;case"import":this.context.isModule||this.tolerateUnexpectedToken(this.lookahead,u.Messages.IllegalImportDeclaration),m=this.parseImportDeclaration();break;case"const":m=this.parseLexicalDeclaration({inFor:!1});break;case"function":m=this.parseFunctionDeclaration();break;case"class":m=this.parseClassDeclaration();break;case"let":m=this.isLexicalDeclaration()?this.parseLexicalDeclaration({inFor:!1}):this.parseStatement();break;default:m=this.parseStatement()}else m=this.parseStatement();return m},y.prototype.parseBlock=function(){var m=this.createNode();this.expect("{");for(var w=[];!this.match("}");)w.push(this.parseStatementListItem());return this.expect("}"),this.finalize(m,new d.BlockStatement(w))},y.prototype.parseLexicalBinding=function(m,w){var x=this.createNode(),C=this.parsePattern([],m);this.context.strict&&C.type===g.Syntax.Identifier&&this.scanner.isRestrictedWord(C.name)&&this.tolerateError(u.Messages.StrictVarName);var S=null;return m==="const"?this.matchKeyword("in")||this.matchContextualKeyword("of")||(this.match("=")?(this.nextToken(),S=this.isolateCoverGrammar(this.parseAssignmentExpression)):this.throwError(u.Messages.DeclarationMissingInitializer,"const")):(!w.inFor&&C.type!==g.Syntax.Identifier||this.match("="))&&(this.expect("="),S=this.isolateCoverGrammar(this.parseAssignmentExpression)),this.finalize(x,new d.VariableDeclarator(C,S))},y.prototype.parseBindingList=function(m,w){for(var x=[this.parseLexicalBinding(m,w)];this.match(",");)this.nextToken(),x.push(this.parseLexicalBinding(m,w));return x},y.prototype.isLexicalDeclaration=function(){var m=this.scanner.saveState();this.scanner.scanComments();var w=this.scanner.lex();return this.scanner.restoreState(m),w.type===3||w.type===7&&w.value==="["||w.type===7&&w.value==="{"||w.type===4&&w.value==="let"||w.type===4&&w.value==="yield"},y.prototype.parseLexicalDeclaration=function(m){var w=this.createNode(),x=this.nextToken().value;l.assert(x==="let"||x==="const","Lexical declaration must be either let or const");var C=this.parseBindingList(x,m);return this.consumeSemicolon(),this.finalize(w,new d.VariableDeclaration(C,x))},y.prototype.parseBindingRestElement=function(m,w){var x=this.createNode();this.expect("...");var C=this.parsePattern(m,w);return this.finalize(x,new d.RestElement(C))},y.prototype.parseArrayPattern=function(m,w){var x=this.createNode();this.expect("[");for(var C=[];!this.match("]");)if(this.match(","))this.nextToken(),C.push(null);else{if(this.match("...")){C.push(this.parseBindingRestElement(m,w));break}C.push(this.parsePatternWithDefault(m,w)),this.match("]")||this.expect(",")}return this.expect("]"),this.finalize(x,new d.ArrayPattern(C))},y.prototype.parsePropertyPattern=function(m,w){var x,C,S=this.createNode(),T=!1,_=!1;if(this.lookahead.type===3){var E=this.lookahead;x=this.parseVariableIdentifier();var b=this.finalize(S,new d.Identifier(E.value));if(this.match("=")){m.push(E),_=!0,this.nextToken();var D=this.parseAssignmentExpression();C=this.finalize(this.startNode(E),new d.AssignmentPattern(b,D))}else this.match(":")?(this.expect(":"),C=this.parsePatternWithDefault(m,w)):(m.push(E),_=!0,C=b)}else T=this.match("["),x=this.parseObjectPropertyKey(),this.expect(":"),C=this.parsePatternWithDefault(m,w);return this.finalize(S,new d.Property("init",x,T,C,!1,_))},y.prototype.parseObjectPattern=function(m,w){var x=this.createNode(),C=[];for(this.expect("{");!this.match("}");)C.push(this.parsePropertyPattern(m,w)),this.match("}")||this.expect(",");return this.expect("}"),this.finalize(x,new d.ObjectPattern(C))},y.prototype.parsePattern=function(m,w){var x;return this.match("[")?x=this.parseArrayPattern(m,w):this.match("{")?x=this.parseObjectPattern(m,w):(!this.matchKeyword("let")||w!=="const"&&w!=="let"||this.tolerateUnexpectedToken(this.lookahead,u.Messages.LetInLexicalBinding),m.push(this.lookahead),x=this.parseVariableIdentifier(w)),x},y.prototype.parsePatternWithDefault=function(m,w){var x=this.lookahead,C=this.parsePattern(m,w);if(this.match("=")){this.nextToken();var S=this.context.allowYield;this.context.allowYield=!0;var T=this.isolateCoverGrammar(this.parseAssignmentExpression);this.context.allowYield=S,C=this.finalize(this.startNode(x),new d.AssignmentPattern(C,T))}return C},y.prototype.parseVariableIdentifier=function(m){var w=this.createNode(),x=this.nextToken();return x.type===4&&x.value==="yield"?this.context.strict?this.tolerateUnexpectedToken(x,u.Messages.StrictReservedWord):this.context.allowYield||this.throwUnexpectedToken(x):x.type!==3?this.context.strict&&x.type===4&&this.scanner.isStrictModeReservedWord(x.value)?this.tolerateUnexpectedToken(x,u.Messages.StrictReservedWord):(this.context.strict||x.value!=="let"||m!=="var")&&this.throwUnexpectedToken(x):(this.context.isModule||this.context.await)&&x.type===3&&x.value==="await"&&this.tolerateUnexpectedToken(x),this.finalize(w,new d.Identifier(x.value))},y.prototype.parseVariableDeclaration=function(m){var w=this.createNode(),x=this.parsePattern([],"var");this.context.strict&&x.type===g.Syntax.Identifier&&this.scanner.isRestrictedWord(x.name)&&this.tolerateError(u.Messages.StrictVarName);var C=null;return this.match("=")?(this.nextToken(),C=this.isolateCoverGrammar(this.parseAssignmentExpression)):x.type===g.Syntax.Identifier||m.inFor||this.expect("="),this.finalize(w,new d.VariableDeclarator(x,C))},y.prototype.parseVariableDeclarationList=function(m){var w={inFor:m.inFor},x=[];for(x.push(this.parseVariableDeclaration(w));this.match(",");)this.nextToken(),x.push(this.parseVariableDeclaration(w));return x},y.prototype.parseVariableStatement=function(){var m=this.createNode();this.expectKeyword("var");var w=this.parseVariableDeclarationList({inFor:!1});return this.consumeSemicolon(),this.finalize(m,new d.VariableDeclaration(w,"var"))},y.prototype.parseEmptyStatement=function(){var m=this.createNode();return this.expect(";"),this.finalize(m,new d.EmptyStatement)},y.prototype.parseExpressionStatement=function(){var m=this.createNode(),w=this.parseExpression();return this.consumeSemicolon(),this.finalize(m,new d.ExpressionStatement(w))},y.prototype.parseIfClause=function(){return this.context.strict&&this.matchKeyword("function")&&this.tolerateError(u.Messages.StrictFunction),this.parseStatement()},y.prototype.parseIfStatement=function(){var m,w=this.createNode(),x=null;this.expectKeyword("if"),this.expect("(");var C=this.parseExpression();return!this.match(")")&&this.config.tolerant?(this.tolerateUnexpectedToken(this.nextToken()),m=this.finalize(this.createNode(),new d.EmptyStatement)):(this.expect(")"),m=this.parseIfClause(),this.matchKeyword("else")&&(this.nextToken(),x=this.parseIfClause())),this.finalize(w,new d.IfStatement(C,m,x))},y.prototype.parseDoWhileStatement=function(){var m=this.createNode();this.expectKeyword("do");var w=this.context.inIteration;this.context.inIteration=!0;var x=this.parseStatement();this.context.inIteration=w,this.expectKeyword("while"),this.expect("(");var C=this.parseExpression();return!this.match(")")&&this.config.tolerant?this.tolerateUnexpectedToken(this.nextToken()):(this.expect(")"),this.match(";")&&this.nextToken()),this.finalize(m,new d.DoWhileStatement(x,C))},y.prototype.parseWhileStatement=function(){var m,w=this.createNode();this.expectKeyword("while"),this.expect("(");var x=this.parseExpression();if(!this.match(")")&&this.config.tolerant)this.tolerateUnexpectedToken(this.nextToken()),m=this.finalize(this.createNode(),new d.EmptyStatement);else{this.expect(")");var C=this.context.inIteration;this.context.inIteration=!0,m=this.parseStatement(),this.context.inIteration=C}return this.finalize(w,new d.WhileStatement(x,m))},y.prototype.parseForStatement=function(){var m,w,x,C=null,S=null,T=null,_=!0,E=this.createNode();if(this.expectKeyword("for"),this.expect("("),this.match(";"))this.nextToken();else if(this.matchKeyword("var")){C=this.createNode(),this.nextToken();var b=this.context.allowIn;this.context.allowIn=!1;var D=this.parseVariableDeclarationList({inFor:!0});if(this.context.allowIn=b,D.length===1&&this.matchKeyword("in")){var I=D[0];I.init&&(I.id.type===g.Syntax.ArrayPattern||I.id.type===g.Syntax.ObjectPattern||this.context.strict)&&this.tolerateError(u.Messages.ForInOfLoopInitializer,"for-in"),C=this.finalize(C,new d.VariableDeclaration(D,"var")),this.nextToken(),m=C,w=this.parseExpression(),C=null}else D.length===1&&D[0].init===null&&this.matchContextualKeyword("of")?(C=this.finalize(C,new d.VariableDeclaration(D,"var")),this.nextToken(),m=C,w=this.parseAssignmentExpression(),C=null,_=!1):(C=this.finalize(C,new d.VariableDeclaration(D,"var")),this.expect(";"))}else if(this.matchKeyword("const")||this.matchKeyword("let")){C=this.createNode();var P=this.nextToken().value;this.context.strict||this.lookahead.value!=="in"?(b=this.context.allowIn,this.context.allowIn=!1,D=this.parseBindingList(P,{inFor:!0}),this.context.allowIn=b,D.length===1&&D[0].init===null&&this.matchKeyword("in")?(C=this.finalize(C,new d.VariableDeclaration(D,P)),this.nextToken(),m=C,w=this.parseExpression(),C=null):D.length===1&&D[0].init===null&&this.matchContextualKeyword("of")?(C=this.finalize(C,new d.VariableDeclaration(D,P)),this.nextToken(),m=C,w=this.parseAssignmentExpression(),C=null,_=!1):(this.consumeSemicolon(),C=this.finalize(C,new d.VariableDeclaration(D,P)))):(C=this.finalize(C,new d.Identifier(P)),this.nextToken(),m=C,w=this.parseExpression(),C=null)}else{var O=this.lookahead;if(b=this.context.allowIn,this.context.allowIn=!1,C=this.inheritCoverGrammar(this.parseAssignmentExpression),this.context.allowIn=b,this.matchKeyword("in"))this.context.isAssignmentTarget&&C.type!==g.Syntax.AssignmentExpression||this.tolerateError(u.Messages.InvalidLHSInForIn),this.nextToken(),this.reinterpretExpressionAsPattern(C),m=C,w=this.parseExpression(),C=null;else if(this.matchContextualKeyword("of"))this.context.isAssignmentTarget&&C.type!==g.Syntax.AssignmentExpression||this.tolerateError(u.Messages.InvalidLHSInForLoop),this.nextToken(),this.reinterpretExpressionAsPattern(C),m=C,w=this.parseAssignmentExpression(),C=null,_=!1;else{if(this.match(",")){for(var L=[C];this.match(",");)this.nextToken(),L.push(this.isolateCoverGrammar(this.parseAssignmentExpression));C=this.finalize(this.startNode(O),new d.SequenceExpression(L))}this.expect(";")}}if(m===void 0&&(this.match(";")||(S=this.parseExpression()),this.expect(";"),this.match(")")||(T=this.parseExpression())),!this.match(")")&&this.config.tolerant)this.tolerateUnexpectedToken(this.nextToken()),x=this.finalize(this.createNode(),new d.EmptyStatement);else{this.expect(")");var B=this.context.inIteration;this.context.inIteration=!0,x=this.isolateCoverGrammar(this.parseStatement),this.context.inIteration=B}return m===void 0?this.finalize(E,new d.ForStatement(C,S,T,x)):_?this.finalize(E,new d.ForInStatement(m,w,x)):this.finalize(E,new d.ForOfStatement(m,w,x))},y.prototype.parseContinueStatement=function(){var m=this.createNode();this.expectKeyword("continue");var w=null;if(this.lookahead.type===3&&!this.hasLineTerminator){var x=this.parseVariableIdentifier();w=x;var C="$"+x.name;Object.prototype.hasOwnProperty.call(this.context.labelSet,C)||this.throwError(u.Messages.UnknownLabel,x.name)}return this.consumeSemicolon(),w!==null||this.context.inIteration||this.throwError(u.Messages.IllegalContinue),this.finalize(m,new d.ContinueStatement(w))},y.prototype.parseBreakStatement=function(){var m=this.createNode();this.expectKeyword("break");var w=null;if(this.lookahead.type===3&&!this.hasLineTerminator){var x=this.parseVariableIdentifier(),C="$"+x.name;Object.prototype.hasOwnProperty.call(this.context.labelSet,C)||this.throwError(u.Messages.UnknownLabel,x.name),w=x}return this.consumeSemicolon(),w!==null||this.context.inIteration||this.context.inSwitch||this.throwError(u.Messages.IllegalBreak),this.finalize(m,new d.BreakStatement(w))},y.prototype.parseReturnStatement=function(){this.context.inFunctionBody||this.tolerateError(u.Messages.IllegalReturn);var m=this.createNode();this.expectKeyword("return");var w=(this.match(";")||this.match("}")||this.hasLineTerminator||this.lookahead.type===2)&&this.lookahead.type!==8&&this.lookahead.type!==10?null:this.parseExpression();return this.consumeSemicolon(),this.finalize(m,new d.ReturnStatement(w))},y.prototype.parseWithStatement=function(){this.context.strict&&this.tolerateError(u.Messages.StrictModeWith);var m,w=this.createNode();this.expectKeyword("with"),this.expect("(");var x=this.parseExpression();return!this.match(")")&&this.config.tolerant?(this.tolerateUnexpectedToken(this.nextToken()),m=this.finalize(this.createNode(),new d.EmptyStatement)):(this.expect(")"),m=this.parseStatement()),this.finalize(w,new d.WithStatement(x,m))},y.prototype.parseSwitchCase=function(){var m,w=this.createNode();this.matchKeyword("default")?(this.nextToken(),m=null):(this.expectKeyword("case"),m=this.parseExpression()),this.expect(":");for(var x=[];!(this.match("}")||this.matchKeyword("default")||this.matchKeyword("case"));)x.push(this.parseStatementListItem());return this.finalize(w,new d.SwitchCase(m,x))},y.prototype.parseSwitchStatement=function(){var m=this.createNode();this.expectKeyword("switch"),this.expect("(");var w=this.parseExpression();this.expect(")");var x=this.context.inSwitch;this.context.inSwitch=!0;var C=[],S=!1;for(this.expect("{");!this.match("}");){var T=this.parseSwitchCase();T.test===null&&(S&&this.throwError(u.Messages.MultipleDefaultsInSwitch),S=!0),C.push(T)}return this.expect("}"),this.context.inSwitch=x,this.finalize(m,new d.SwitchStatement(w,C))},y.prototype.parseLabelledStatement=function(){var m,w=this.createNode(),x=this.parseExpression();if(x.type===g.Syntax.Identifier&&this.match(":")){this.nextToken();var C=x,S="$"+C.name;Object.prototype.hasOwnProperty.call(this.context.labelSet,S)&&this.throwError(u.Messages.Redeclaration,"Label",C.name),this.context.labelSet[S]=!0;var T=void 0;if(this.matchKeyword("class"))this.tolerateUnexpectedToken(this.lookahead),T=this.parseClassDeclaration();else if(this.matchKeyword("function")){var _=this.lookahead,E=this.parseFunctionDeclaration();this.context.strict?this.tolerateUnexpectedToken(_,u.Messages.StrictFunction):E.generator&&this.tolerateUnexpectedToken(_,u.Messages.GeneratorInLegacyContext),T=E}else T=this.parseStatement();delete this.context.labelSet[S],m=new d.LabeledStatement(C,T)}else this.consumeSemicolon(),m=new d.ExpressionStatement(x);return this.finalize(w,m)},y.prototype.parseThrowStatement=function(){var m=this.createNode();this.expectKeyword("throw"),this.hasLineTerminator&&this.throwError(u.Messages.NewlineAfterThrow);var w=this.parseExpression();return this.consumeSemicolon(),this.finalize(m,new d.ThrowStatement(w))},y.prototype.parseCatchClause=function(){var m=this.createNode();this.expectKeyword("catch"),this.expect("("),this.match(")")&&this.throwUnexpectedToken(this.lookahead);for(var w=[],x=this.parsePattern(w),C={},S=0;S<w.length;S++){var T="$"+w[S].value;Object.prototype.hasOwnProperty.call(C,T)&&this.tolerateError(u.Messages.DuplicateBinding,w[S].value),C[T]=!0}this.context.strict&&x.type===g.Syntax.Identifier&&this.scanner.isRestrictedWord(x.name)&&this.tolerateError(u.Messages.StrictCatchVariable),this.expect(")");var _=this.parseBlock();return this.finalize(m,new d.CatchClause(x,_))},y.prototype.parseFinallyClause=function(){return this.expectKeyword("finally"),this.parseBlock()},y.prototype.parseTryStatement=function(){var m=this.createNode();this.expectKeyword("try");var w=this.parseBlock(),x=this.matchKeyword("catch")?this.parseCatchClause():null,C=this.matchKeyword("finally")?this.parseFinallyClause():null;return x||C||this.throwError(u.Messages.NoCatchOrFinally),this.finalize(m,new d.TryStatement(w,x,C))},y.prototype.parseDebuggerStatement=function(){var m=this.createNode();return this.expectKeyword("debugger"),this.consumeSemicolon(),this.finalize(m,new d.DebuggerStatement)},y.prototype.parseStatement=function(){var m;switch(this.lookahead.type){case 1:case 5:case 6:case 8:case 10:case 9:m=this.parseExpressionStatement();break;case 7:var w=this.lookahead.value;m=w==="{"?this.parseBlock():w==="("?this.parseExpressionStatement():w===";"?this.parseEmptyStatement():this.parseExpressionStatement();break;case 3:m=this.matchAsyncFunction()?this.parseFunctionDeclaration():this.parseLabelledStatement();break;case 4:switch(this.lookahead.value){case"break":m=this.parseBreakStatement();break;case"continue":m=this.parseContinueStatement();break;case"debugger":m=this.parseDebuggerStatement();break;case"do":m=this.parseDoWhileStatement();break;case"for":m=this.parseForStatement();break;case"function":m=this.parseFunctionDeclaration();break;case"if":m=this.parseIfStatement();break;case"return":m=this.parseReturnStatement();break;case"switch":m=this.parseSwitchStatement();break;case"throw":m=this.parseThrowStatement();break;case"try":m=this.parseTryStatement();break;case"var":m=this.parseVariableStatement();break;case"while":m=this.parseWhileStatement();break;case"with":m=this.parseWithStatement();break;default:m=this.parseExpressionStatement()}break;default:m=this.throwUnexpectedToken(this.lookahead)}return m},y.prototype.parseFunctionSourceElements=function(){var m=this.createNode();this.expect("{");var w=this.parseDirectivePrologues(),x=this.context.labelSet,C=this.context.inIteration,S=this.context.inSwitch,T=this.context.inFunctionBody;for(this.context.labelSet={},this.context.inIteration=!1,this.context.inSwitch=!1,this.context.inFunctionBody=!0;this.lookahead.type!==2&&!this.match("}");)w.push(this.parseStatementListItem());return this.expect("}"),this.context.labelSet=x,this.context.inIteration=C,this.context.inSwitch=S,this.context.inFunctionBody=T,this.finalize(m,new d.BlockStatement(w))},y.prototype.validateParam=function(m,w,x){var C="$"+x;this.context.strict?(this.scanner.isRestrictedWord(x)&&(m.stricted=w,m.message=u.Messages.StrictParamName),Object.prototype.hasOwnProperty.call(m.paramSet,C)&&(m.stricted=w,m.message=u.Messages.StrictParamDupe)):m.firstRestricted||(this.scanner.isRestrictedWord(x)?(m.firstRestricted=w,m.message=u.Messages.StrictParamName):this.scanner.isStrictModeReservedWord(x)?(m.firstRestricted=w,m.message=u.Messages.StrictReservedWord):Object.prototype.hasOwnProperty.call(m.paramSet,C)&&(m.stricted=w,m.message=u.Messages.StrictParamDupe)),typeof Object.defineProperty=="function"?Object.defineProperty(m.paramSet,C,{value:!0,enumerable:!0,writable:!0,configurable:!0}):m.paramSet[C]=!0},y.prototype.parseRestElement=function(m){var w=this.createNode();this.expect("...");var x=this.parsePattern(m);return this.match("=")&&this.throwError(u.Messages.DefaultRestParameter),this.match(")")||this.throwError(u.Messages.ParameterAfterRestParameter),this.finalize(w,new d.RestElement(x))},y.prototype.parseFormalParameter=function(m){for(var w=[],x=this.match("...")?this.parseRestElement(w):this.parsePatternWithDefault(w),C=0;C<w.length;C++)this.validateParam(m,w[C],w[C].value);m.simple=m.simple&&x instanceof d.Identifier,m.params.push(x)},y.prototype.parseFormalParameters=function(m){var w;if(w={simple:!0,params:[],firstRestricted:m},this.expect("("),!this.match(")"))for(w.paramSet={};this.lookahead.type!==2&&(this.parseFormalParameter(w),!this.match(")"))&&(this.expect(","),!this.match(")")););return this.expect(")"),{simple:w.simple,params:w.params,stricted:w.stricted,firstRestricted:w.firstRestricted,message:w.message}},y.prototype.matchAsyncFunction=function(){var m=this.matchContextualKeyword("async");if(m){var w=this.scanner.saveState();this.scanner.scanComments();var x=this.scanner.lex();this.scanner.restoreState(w),m=w.lineNumber===x.lineNumber&&x.type===4&&x.value==="function"}return m},y.prototype.parseFunctionDeclaration=function(m){var w=this.createNode(),x=this.matchContextualKeyword("async");x&&this.nextToken(),this.expectKeyword("function");var C,S=!x&&this.match("*");S&&this.nextToken();var T=null,_=null;if(!m||!this.match("(")){var E=this.lookahead;T=this.parseVariableIdentifier(),this.context.strict?this.scanner.isRestrictedWord(E.value)&&this.tolerateUnexpectedToken(E,u.Messages.StrictFunctionName):this.scanner.isRestrictedWord(E.value)?(_=E,C=u.Messages.StrictFunctionName):this.scanner.isStrictModeReservedWord(E.value)&&(_=E,C=u.Messages.StrictReservedWord)}var b=this.context.await,D=this.context.allowYield;this.context.await=x,this.context.allowYield=!S;var I=this.parseFormalParameters(_),P=I.params,O=I.stricted;_=I.firstRestricted,I.message&&(C=I.message);var L=this.context.strict,B=this.context.allowStrictDirective;this.context.allowStrictDirective=I.simple;var H=this.parseFunctionSourceElements();return this.context.strict&&_&&this.throwUnexpectedToken(_,C),this.context.strict&&O&&this.tolerateUnexpectedToken(O,C),this.context.strict=L,this.context.allowStrictDirective=B,this.context.await=b,this.context.allowYield=D,x?this.finalize(w,new d.AsyncFunctionDeclaration(T,P,H)):this.finalize(w,new d.FunctionDeclaration(T,P,H,S))},y.prototype.parseFunctionExpression=function(){var m=this.createNode(),w=this.matchContextualKeyword("async");w&&this.nextToken(),this.expectKeyword("function");var x,C=!w&&this.match("*");C&&this.nextToken();var S,T=null,_=this.context.await,E=this.context.allowYield;if(this.context.await=w,this.context.allowYield=!C,!this.match("(")){var b=this.lookahead;T=this.context.strict||C||!this.matchKeyword("yield")?this.parseVariableIdentifier():this.parseIdentifierName(),this.context.strict?this.scanner.isRestrictedWord(b.value)&&this.tolerateUnexpectedToken(b,u.Messages.StrictFunctionName):this.scanner.isRestrictedWord(b.value)?(S=b,x=u.Messages.StrictFunctionName):this.scanner.isStrictModeReservedWord(b.value)&&(S=b,x=u.Messages.StrictReservedWord)}var D=this.parseFormalParameters(S),I=D.params,P=D.stricted;S=D.firstRestricted,D.message&&(x=D.message);var O=this.context.strict,L=this.context.allowStrictDirective;this.context.allowStrictDirective=D.simple;var B=this.parseFunctionSourceElements();return this.context.strict&&S&&this.throwUnexpectedToken(S,x),this.context.strict&&P&&this.tolerateUnexpectedToken(P,x),this.context.strict=O,this.context.allowStrictDirective=L,this.context.await=_,this.context.allowYield=E,w?this.finalize(m,new d.AsyncFunctionExpression(T,I,B)):this.finalize(m,new d.FunctionExpression(T,I,B,C))},y.prototype.parseDirective=function(){var m=this.lookahead,w=this.createNode(),x=this.parseExpression(),C=x.type===g.Syntax.Literal?this.getTokenRaw(m).slice(1,-1):null;return this.consumeSemicolon(),this.finalize(w,C?new d.Directive(x,C):new d.ExpressionStatement(x))},y.prototype.parseDirectivePrologues=function(){for(var m=null,w=[];;){var x=this.lookahead;if(x.type!==8)break;var C=this.parseDirective();w.push(C);var S=C.directive;if(typeof S!="string")break;S==="use strict"?(this.context.strict=!0,m&&this.tolerateUnexpectedToken(m,u.Messages.StrictOctalLiteral),this.context.allowStrictDirective||this.tolerateUnexpectedToken(x,u.Messages.IllegalLanguageModeDirective)):!m&&x.octal&&(m=x)}return w},y.prototype.qualifiedPropertyName=function(m){switch(m.type){case 3:case 8:case 1:case 5:case 6:case 4:return!0;case 7:return m.value==="["}return!1},y.prototype.parseGetterMethod=function(){var m=this.createNode(),w=this.context.allowYield;this.context.allowYield=!0;var x=this.parseFormalParameters();x.params.length>0&&this.tolerateError(u.Messages.BadGetterArity);var C=this.parsePropertyMethod(x);return this.context.allowYield=w,this.finalize(m,new d.FunctionExpression(null,x.params,C,!1))},y.prototype.parseSetterMethod=function(){var m=this.createNode(),w=this.context.allowYield;this.context.allowYield=!0;var x=this.parseFormalParameters();x.params.length!==1?this.tolerateError(u.Messages.BadSetterArity):x.params[0]instanceof d.RestElement&&this.tolerateError(u.Messages.BadSetterRestParameter);var C=this.parsePropertyMethod(x);return this.context.allowYield=w,this.finalize(m,new d.FunctionExpression(null,x.params,C,!1))},y.prototype.parseGeneratorMethod=function(){var m=this.createNode(),w=this.context.allowYield;this.context.allowYield=!0;var x=this.parseFormalParameters();this.context.allowYield=!1;var C=this.parsePropertyMethod(x);return this.context.allowYield=w,this.finalize(m,new d.FunctionExpression(null,x.params,C,!0))},y.prototype.isStartOfExpression=function(){var m=!0,w=this.lookahead.value;switch(this.lookahead.type){case 7:m=w==="["||w==="("||w==="{"||w==="+"||w==="-"||w==="!"||w==="~"||w==="++"||w==="--"||w==="/"||w==="/=";break;case 4:m=w==="class"||w==="delete"||w==="function"||w==="let"||w==="new"||w==="super"||w==="this"||w==="typeof"||w==="void"||w==="yield"}return m},y.prototype.parseYieldExpression=function(){var m=this.createNode();this.expectKeyword("yield");var w=null,x=!1;if(!this.hasLineTerminator){var C=this.context.allowYield;this.context.allowYield=!1,(x=this.match("*"))?(this.nextToken(),w=this.parseAssignmentExpression()):this.isStartOfExpression()&&(w=this.parseAssignmentExpression()),this.context.allowYield=C}return this.finalize(m,new d.YieldExpression(w,x))},y.prototype.parseClassElement=function(m){var w=this.lookahead,x=this.createNode(),C="",S=null,T=null,_=!1,E=!1,b=!1,D=!1;if(this.match("*"))this.nextToken();else if(_=this.match("["),(S=this.parseObjectPropertyKey()).name==="static"&&(this.qualifiedPropertyName(this.lookahead)||this.match("*"))&&(w=this.lookahead,b=!0,_=this.match("["),this.match("*")?this.nextToken():S=this.parseObjectPropertyKey()),w.type===3&&!this.hasLineTerminator&&w.value==="async"){var I=this.lookahead.value;I!==":"&&I!=="("&&I!=="*"&&(D=!0,w=this.lookahead,S=this.parseObjectPropertyKey(),w.type===3&&w.value==="constructor"&&this.tolerateUnexpectedToken(w,u.Messages.ConstructorIsAsync))}var P=this.qualifiedPropertyName(this.lookahead);return w.type===3?w.value==="get"&&P?(C="get",_=this.match("["),S=this.parseObjectPropertyKey(),this.context.allowYield=!1,T=this.parseGetterMethod()):w.value==="set"&&P&&(C="set",_=this.match("["),S=this.parseObjectPropertyKey(),T=this.parseSetterMethod()):w.type===7&&w.value==="*"&&P&&(C="init",_=this.match("["),S=this.parseObjectPropertyKey(),T=this.parseGeneratorMethod(),E=!0),!C&&S&&this.match("(")&&(C="init",T=D?this.parsePropertyMethodAsyncFunction():this.parsePropertyMethodFunction(),E=!0),C||this.throwUnexpectedToken(this.lookahead),C==="init"&&(C="method"),_||(b&&this.isPropertyKey(S,"prototype")&&this.throwUnexpectedToken(w,u.Messages.StaticPrototype),!b&&this.isPropertyKey(S,"constructor")&&((C!=="method"||!E||T&&T.generator)&&this.throwUnexpectedToken(w,u.Messages.ConstructorSpecialMethod),m.value?this.throwUnexpectedToken(w,u.Messages.DuplicateConstructor):m.value=!0,C="constructor")),this.finalize(x,new d.MethodDefinition(S,_,T,C,b))},y.prototype.parseClassElementList=function(){var m=[],w={value:!1};for(this.expect("{");!this.match("}");)this.match(";")?this.nextToken():m.push(this.parseClassElement(w));return this.expect("}"),m},y.prototype.parseClassBody=function(){var m=this.createNode(),w=this.parseClassElementList();return this.finalize(m,new d.ClassBody(w))},y.prototype.parseClassDeclaration=function(m){var w=this.createNode(),x=this.context.strict;this.context.strict=!0,this.expectKeyword("class");var C=m&&this.lookahead.type!==3?null:this.parseVariableIdentifier(),S=null;this.matchKeyword("extends")&&(this.nextToken(),S=this.isolateCoverGrammar(this.parseLeftHandSideExpressionAllowCall));var T=this.parseClassBody();return this.context.strict=x,this.finalize(w,new d.ClassDeclaration(C,S,T))},y.prototype.parseClassExpression=function(){var m=this.createNode(),w=this.context.strict;this.context.strict=!0,this.expectKeyword("class");var x=this.lookahead.type===3?this.parseVariableIdentifier():null,C=null;this.matchKeyword("extends")&&(this.nextToken(),C=this.isolateCoverGrammar(this.parseLeftHandSideExpressionAllowCall));var S=this.parseClassBody();return this.context.strict=w,this.finalize(m,new d.ClassExpression(x,C,S))},y.prototype.parseModule=function(){this.context.strict=!0,this.context.isModule=!0,this.scanner.isModule=!0;for(var m=this.createNode(),w=this.parseDirectivePrologues();this.lookahead.type!==2;)w.push(this.parseStatementListItem());return this.finalize(m,new d.Module(w))},y.prototype.parseScript=function(){for(var m=this.createNode(),w=this.parseDirectivePrologues();this.lookahead.type!==2;)w.push(this.parseStatementListItem());return this.finalize(m,new d.Script(w))},y.prototype.parseModuleSpecifier=function(){var m=this.createNode();this.lookahead.type!==8&&this.throwError(u.Messages.InvalidModuleSpecifier);var w=this.nextToken(),x=this.getTokenRaw(w);return this.finalize(m,new d.Literal(w.value,x))},y.prototype.parseImportSpecifier=function(){var m,w,x=this.createNode();return this.lookahead.type===3?(w=m=this.parseVariableIdentifier(),this.matchContextualKeyword("as")&&(this.nextToken(),w=this.parseVariableIdentifier())):(w=m=this.parseIdentifierName(),this.matchContextualKeyword("as")?(this.nextToken(),w=this.parseVariableIdentifier()):this.throwUnexpectedToken(this.nextToken())),this.finalize(x,new d.ImportSpecifier(w,m))},y.prototype.parseNamedImports=function(){this.expect("{");for(var m=[];!this.match("}");)m.push(this.parseImportSpecifier()),this.match("}")||this.expect(",");return this.expect("}"),m},y.prototype.parseImportDefaultSpecifier=function(){var m=this.createNode(),w=this.parseIdentifierName();return this.finalize(m,new d.ImportDefaultSpecifier(w))},y.prototype.parseImportNamespaceSpecifier=function(){var m=this.createNode();this.expect("*"),this.matchContextualKeyword("as")||this.throwError(u.Messages.NoAsAfterImportNamespace),this.nextToken();var w=this.parseIdentifierName();return this.finalize(m,new d.ImportNamespaceSpecifier(w))},y.prototype.parseImportDeclaration=function(){this.context.inFunctionBody&&this.throwError(u.Messages.IllegalImportDeclaration);var m,w=this.createNode();this.expectKeyword("import");var x=[];if(this.lookahead.type===8)m=this.parseModuleSpecifier();else{if(this.match("{")?x=x.concat(this.parseNamedImports()):this.match("*")?x.push(this.parseImportNamespaceSpecifier()):this.isIdentifierName(this.lookahead)&&!this.matchKeyword("default")?(x.push(this.parseImportDefaultSpecifier()),this.match(",")&&(this.nextToken(),this.match("*")?x.push(this.parseImportNamespaceSpecifier()):this.match("{")?x=x.concat(this.parseNamedImports()):this.throwUnexpectedToken(this.lookahead))):this.throwUnexpectedToken(this.nextToken()),!this.matchContextualKeyword("from")){var C=this.lookahead.value?u.Messages.UnexpectedToken:u.Messages.MissingFromClause;this.throwError(C,this.lookahead.value)}this.nextToken(),m=this.parseModuleSpecifier()}return this.consumeSemicolon(),this.finalize(w,new d.ImportDeclaration(x,m))},y.prototype.parseExportSpecifier=function(){var m=this.createNode(),w=this.parseIdentifierName(),x=w;return this.matchContextualKeyword("as")&&(this.nextToken(),x=this.parseIdentifierName()),this.finalize(m,new d.ExportSpecifier(w,x))},y.prototype.parseExportDeclaration=function(){this.context.inFunctionBody&&this.throwError(u.Messages.IllegalExportDeclaration);var m,w=this.createNode();if(this.expectKeyword("export"),this.matchKeyword("default"))if(this.nextToken(),this.matchKeyword("function")){var x=this.parseFunctionDeclaration(!0);m=this.finalize(w,new d.ExportDefaultDeclaration(x))}else this.matchKeyword("class")?(x=this.parseClassDeclaration(!0),m=this.finalize(w,new d.ExportDefaultDeclaration(x))):this.matchContextualKeyword("async")?(x=this.matchAsyncFunction()?this.parseFunctionDeclaration(!0):this.parseAssignmentExpression(),m=this.finalize(w,new d.ExportDefaultDeclaration(x))):(this.matchContextualKeyword("from")&&this.throwError(u.Messages.UnexpectedToken,this.lookahead.value),x=this.match("{")?this.parseObjectInitializer():this.match("[")?this.parseArrayInitializer():this.parseAssignmentExpression(),this.consumeSemicolon(),m=this.finalize(w,new d.ExportDefaultDeclaration(x)));else if(this.match("*")){if(this.nextToken(),!this.matchContextualKeyword("from")){var C=this.lookahead.value?u.Messages.UnexpectedToken:u.Messages.MissingFromClause;this.throwError(C,this.lookahead.value)}this.nextToken();var S=this.parseModuleSpecifier();this.consumeSemicolon(),m=this.finalize(w,new d.ExportAllDeclaration(S))}else if(this.lookahead.type===4){switch(x=void 0,this.lookahead.value){case"let":case"const":x=this.parseLexicalDeclaration({inFor:!1});break;case"var":case"class":case"function":x=this.parseStatementListItem();break;default:this.throwUnexpectedToken(this.lookahead)}m=this.finalize(w,new d.ExportNamedDeclaration(x,[],null))}else if(this.matchAsyncFunction())x=this.parseFunctionDeclaration(),m=this.finalize(w,new d.ExportNamedDeclaration(x,[],null));else{var T=[],_=null,E=!1;for(this.expect("{");!this.match("}");)E=E||this.matchKeyword("default"),T.push(this.parseExportSpecifier()),this.match("}")||this.expect(",");this.expect("}"),this.matchContextualKeyword("from")?(this.nextToken(),_=this.parseModuleSpecifier(),this.consumeSemicolon()):E?(C=this.lookahead.value?u.Messages.UnexpectedToken:u.Messages.MissingFromClause,this.throwError(C,this.lookahead.value)):this.consumeSemicolon(),m=this.finalize(w,new d.ExportNamedDeclaration(null,T,_))}return m},y}();s.Parser=v},function(a,s){Object.defineProperty(s,"__esModule",{value:!0}),s.assert=function(c,l){if(!c)throw new Error("ASSERT: "+l)}},function(a,s){Object.defineProperty(s,"__esModule",{value:!0});var c=function(){function l(){this.errors=[],this.tolerant=!1}return l.prototype.recordError=function(f){this.errors.push(f)},l.prototype.tolerate=function(f){if(!this.tolerant)throw f;this.recordError(f)},l.prototype.constructError=function(f,u){var d=new Error(f);try{throw d}catch(h){Object.create&&Object.defineProperty&&(d=Object.create(h),Object.defineProperty(d,"column",{value:u}))}return d},l.prototype.createError=function(f,u,d,h){var g="Line "+u+": "+h,p=this.constructError(g,d);return p.index=f,p.lineNumber=u,p.description=h,p},l.prototype.throwError=function(f,u,d,h){throw this.createError(f,u,d,h)},l.prototype.tolerateError=function(f,u,d,h){var g=this.createError(f,u,d,h);if(!this.tolerant)throw g;this.recordError(g)},l}();s.ErrorHandler=c},function(a,s){Object.defineProperty(s,"__esModule",{value:!0}),s.Messages={BadGetterArity:"Getter must not have any formal parameters",BadSetterArity:"Setter must have exactly one formal parameter",BadSetterRestParameter:"Setter function argument must not be a rest parameter",ConstructorIsAsync:"Class constructor may not be an async method",ConstructorSpecialMethod:"Class constructor may not be an accessor",DeclarationMissingInitializer:"Missing initializer in %0 declaration",DefaultRestParameter:"Unexpected token =",DuplicateBinding:"Duplicate binding %0",DuplicateConstructor:"A class may only have one constructor",DuplicateProtoProperty:"Duplicate __proto__ fields are not allowed in object literals",ForInOfLoopInitializer:"%0 loop variable declaration may not have an initializer",GeneratorInLegacyContext:"Generator declarations are not allowed in legacy contexts",IllegalBreak:"Illegal break statement",IllegalContinue:"Illegal continue statement",IllegalExportDeclaration:"Unexpected token",IllegalImportDeclaration:"Unexpected token",IllegalLanguageModeDirective:"Illegal 'use strict' directive in function with non-simple parameter list",IllegalReturn:"Illegal return statement",InvalidEscapedReservedWord:"Keyword must not contain escaped characters",InvalidHexEscapeSequence:"Invalid hexadecimal escape sequence",InvalidLHSInAssignment:"Invalid left-hand side in assignment",InvalidLHSInForIn:"Invalid left-hand side in for-in",InvalidLHSInForLoop:"Invalid left-hand side in for-loop",InvalidModuleSpecifier:"Unexpected token",InvalidRegExp:"Invalid regular expression",LetInLexicalBinding:"let is disallowed as a lexically bound name",MissingFromClause:"Unexpected token",MultipleDefaultsInSwitch:"More than one default clause in switch statement",NewlineAfterThrow:"Illegal newline after throw",NoAsAfterImportNamespace:"Unexpected token",NoCatchOrFinally:"Missing catch or finally after try",ParameterAfterRestParameter:"Rest parameter must be last formal parameter",Redeclaration:"%0 '%1' has already been declared",StaticPrototype:"Classes may not have static property named prototype",StrictCatchVariable:"Catch variable may not be eval or arguments in strict mode",StrictDelete:"Delete of an unqualified identifier in strict mode.",StrictFunction:"In strict mode code, functions can only be declared at top level or inside a block",StrictFunctionName:"Function name may not be eval or arguments in strict mode",StrictLHSAssignment:"Assignment to eval or arguments is not allowed in strict mode",StrictLHSPostfix:"Postfix increment/decrement may not have eval or arguments operand in strict mode",StrictLHSPrefix:"Prefix increment/decrement may not have eval or arguments operand in strict mode",StrictModeWith:"Strict mode code may not include a with statement",StrictOctalLiteral:"Octal literals are not allowed in strict mode.",StrictParamDupe:"Strict mode function may not have duplicate parameter names",StrictParamName:"Parameter name eval or arguments is not allowed in strict mode",StrictReservedWord:"Use of future reserved word in strict mode",StrictVarName:"Variable name may not be eval or arguments in strict mode",TemplateOctalLiteral:"Octal literals are not allowed in template strings.",UnexpectedEOS:"Unexpected end of input",UnexpectedIdentifier:"Unexpected identifier",UnexpectedNumber:"Unexpected number",UnexpectedReserved:"Unexpected reserved word",UnexpectedString:"Unexpected string",UnexpectedTemplate:"Unexpected quasi %0",UnexpectedToken:"Unexpected token %0",UnexpectedTokenIllegal:"Unexpected token ILLEGAL",UnknownLabel:"Undefined label '%0'",UnterminatedRegExp:"Invalid regular expression: missing /"}},function(a,s,c){Object.defineProperty(s,"__esModule",{value:!0});var l=c(9),f=c(4),u=c(11);function d(p){return"0123456789abcdef".indexOf(p.toLowerCase())}function h(p){return"01234567".indexOf(p)}var g=function(){function p(v,y){this.source=v,this.errorHandler=y,this.trackComment=!1,this.isModule=!1,this.length=v.length,this.index=0,this.lineNumber=v.length>0?1:0,this.lineStart=0,this.curlyStack=[]}return p.prototype.saveState=function(){return{index:this.index,lineNumber:this.lineNumber,lineStart:this.lineStart}},p.prototype.restoreState=function(v){this.index=v.index,this.lineNumber=v.lineNumber,this.lineStart=v.lineStart},p.prototype.eof=function(){return this.index>=this.length},p.prototype.throwUnexpectedToken=function(v){return v===void 0&&(v=u.Messages.UnexpectedTokenIllegal),this.errorHandler.throwError(this.index,this.lineNumber,this.index-this.lineStart+1,v)},p.prototype.tolerateUnexpectedToken=function(v){v===void 0&&(v=u.Messages.UnexpectedTokenIllegal),this.errorHandler.tolerateError(this.index,this.lineNumber,this.index-this.lineStart+1,v)},p.prototype.skipSingleLineComment=function(v){var y,m,w=[];for(this.trackComment&&(w=[],y=this.index-v,m={start:{line:this.lineNumber,column:this.index-this.lineStart-v},end:{}});!this.eof();){var x=this.source.charCodeAt(this.index);if(++this.index,f.Character.isLineTerminator(x)){if(this.trackComment){m.end={line:this.lineNumber,column:this.index-this.lineStart-1};var C={multiLine:!1,slice:[y+v,this.index-1],range:[y,this.index-1],loc:m};w.push(C)}return x===13&&this.source.charCodeAt(this.index)===10&&++this.index,++this.lineNumber,this.lineStart=this.index,w}}return this.trackComment&&(m.end={line:this.lineNumber,column:this.index-this.lineStart},C={multiLine:!1,slice:[y+v,this.index],range:[y,this.index],loc:m},w.push(C)),w},p.prototype.skipMultiLineComment=function(){var v,y,m=[];for(this.trackComment&&(m=[],v=this.index-2,y={start:{line:this.lineNumber,column:this.index-this.lineStart-2},end:{}});!this.eof();){var w=this.source.charCodeAt(this.index);if(f.Character.isLineTerminator(w))w===13&&this.source.charCodeAt(this.index+1)===10&&++this.index,++this.lineNumber,++this.index,this.lineStart=this.index;else if(w===42){if(this.source.charCodeAt(this.index+1)===47){if(this.index+=2,this.trackComment){y.end={line:this.lineNumber,column:this.index-this.lineStart};var x={multiLine:!0,slice:[v+2,this.index-2],range:[v,this.index],loc:y};m.push(x)}return m}++this.index}else++this.index}return this.trackComment&&(y.end={line:this.lineNumber,column:this.index-this.lineStart},x={multiLine:!0,slice:[v+2,this.index],range:[v,this.index],loc:y},m.push(x)),this.tolerateUnexpectedToken(),m},p.prototype.scanComments=function(){var v;this.trackComment&&(v=[]);for(var y=this.index===0;!this.eof();){var m=this.source.charCodeAt(this.index);if(f.Character.isWhiteSpace(m))++this.index;else if(f.Character.isLineTerminator(m))++this.index,m===13&&this.source.charCodeAt(this.index)===10&&++this.index,++this.lineNumber,this.lineStart=this.index,y=!0;else if(m===47)if((m=this.source.charCodeAt(this.index+1))===47){this.index+=2;var w=this.skipSingleLineComment(2);this.trackComment&&(v=v.concat(w)),y=!0}else{if(m!==42)break;this.index+=2,w=this.skipMultiLineComment(),this.trackComment&&(v=v.concat(w))}else if(y&&m===45){if(this.source.charCodeAt(this.index+1)!==45||this.source.charCodeAt(this.index+2)!==62)break;this.index+=3,w=this.skipSingleLineComment(3),this.trackComment&&(v=v.concat(w))}else{if(m!==60||this.isModule||this.source.slice(this.index+1,this.index+4)!=="!--")break;this.index+=4,w=this.skipSingleLineComment(4),this.trackComment&&(v=v.concat(w))}}return v},p.prototype.isFutureReservedWord=function(v){switch(v){case"enum":case"export":case"import":case"super":return!0;default:return!1}},p.prototype.isStrictModeReservedWord=function(v){switch(v){case"implements":case"interface":case"package":case"private":case"protected":case"public":case"static":case"yield":case"let":return!0;default:return!1}},p.prototype.isRestrictedWord=function(v){return v==="eval"||v==="arguments"},p.prototype.isKeyword=function(v){switch(v.length){case 2:return v==="if"||v==="in"||v==="do";case 3:return v==="var"||v==="for"||v==="new"||v==="try"||v==="let";case 4:return v==="this"||v==="else"||v==="case"||v==="void"||v==="with"||v==="enum";case 5:return v==="while"||v==="break"||v==="catch"||v==="throw"||v==="const"||v==="yield"||v==="class"||v==="super";case 6:return v==="return"||v==="typeof"||v==="delete"||v==="switch"||v==="export"||v==="import";case 7:return v==="default"||v==="finally"||v==="extends";case 8:return v==="function"||v==="continue"||v==="debugger";case 10:return v==="instanceof";default:return!1}},p.prototype.codePointAt=function(v){var y=this.source.charCodeAt(v);if(y>=55296&&y<=56319){var m=this.source.charCodeAt(v+1);m>=56320&&m<=57343&&(y=1024*(y-55296)+m-56320+65536)}return y},p.prototype.scanHexEscape=function(v){for(var y=v==="u"?4:2,m=0,w=0;w<y;++w){if(this.eof()||!f.Character.isHexDigit(this.source.charCodeAt(this.index)))return null;m=16*m+d(this.source[this.index++])}return String.fromCharCode(m)},p.prototype.scanUnicodeCodePointEscape=function(){var v=this.source[this.index],y=0;for(v==="}"&&this.throwUnexpectedToken();!this.eof()&&(v=this.source[this.index++],f.Character.isHexDigit(v.charCodeAt(0)));)y=16*y+d(v);return(y>1114111||v!=="}")&&this.throwUnexpectedToken(),f.Character.fromCodePoint(y)},p.prototype.getIdentifier=function(){for(var v=this.index++;!this.eof();){var y=this.source.charCodeAt(this.index);if(y===92)return this.index=v,this.getComplexIdentifier();if(y>=55296&&y<57343)return this.index=v,this.getComplexIdentifier();if(!f.Character.isIdentifierPart(y))break;++this.index}return this.source.slice(v,this.index)},p.prototype.getComplexIdentifier=function(){var v,y=this.codePointAt(this.index),m=f.Character.fromCodePoint(y);for(this.index+=m.length,y===92&&(this.source.charCodeAt(this.index)!==117&&this.throwUnexpectedToken(),++this.index,this.source[this.index]==="{"?(++this.index,v=this.scanUnicodeCodePointEscape()):(v=this.scanHexEscape("u"))!==null&&v!=="\\"&&f.Character.isIdentifierStart(v.charCodeAt(0))||this.throwUnexpectedToken(),m=v);!this.eof()&&(y=this.codePointAt(this.index),f.Character.isIdentifierPart(y));)m+=v=f.Character.fromCodePoint(y),this.index+=v.length,y===92&&(m=m.substr(0,m.length-1),this.source.charCodeAt(this.index)!==117&&this.throwUnexpectedToken(),++this.index,this.source[this.index]==="{"?(++this.index,v=this.scanUnicodeCodePointEscape()):(v=this.scanHexEscape("u"))!==null&&v!=="\\"&&f.Character.isIdentifierPart(v.charCodeAt(0))||this.throwUnexpectedToken(),m+=v);return m},p.prototype.octalToDecimal=function(v){var y=v!=="0",m=h(v);return!this.eof()&&f.Character.isOctalDigit(this.source.charCodeAt(this.index))&&(y=!0,m=8*m+h(this.source[this.index++]),"0123".indexOf(v)>=0&&!this.eof()&&f.Character.isOctalDigit(this.source.charCodeAt(this.index))&&(m=8*m+h(this.source[this.index++]))),{code:m,octal:y}},p.prototype.scanIdentifier=function(){var v,y=this.index,m=this.source.charCodeAt(y)===92?this.getComplexIdentifier():this.getIdentifier();if((v=m.length===1?3:this.isKeyword(m)?4:m==="null"?5:m==="true"||m==="false"?1:3)!=3&&y+m.length!==this.index){var w=this.index;this.index=y,this.tolerateUnexpectedToken(u.Messages.InvalidEscapedReservedWord),this.index=w}return{type:v,value:m,lineNumber:this.lineNumber,lineStart:this.lineStart,start:y,end:this.index}},p.prototype.scanPunctuator=function(){var v=this.index,y=this.source[this.index];switch(y){case"(":case"{":y==="{"&&this.curlyStack.push("{"),++this.index;break;case".":++this.index,this.source[this.index]==="."&&this.source[this.index+1]==="."&&(this.index+=2,y="...");break;case"}":++this.index,this.curlyStack.pop();break;case")":case";":case",":case"[":case"]":case":":case"?":case"~":++this.index;break;default:(y=this.source.substr(this.index,4))===">>>="?this.index+=4:(y=y.substr(0,3))==="==="||y==="!=="||y===">>>"||y==="<<="||y===">>="||y==="**="?this.index+=3:(y=y.substr(0,2))==="&&"||y==="||"||y==="=="||y==="!="||y==="+="||y==="-="||y==="*="||y==="/="||y==="++"||y==="--"||y==="<<"||y===">>"||y==="&="||y==="|="||y==="^="||y==="%="||y==="<="||y===">="||y==="=>"||y==="**"?this.index+=2:(y=this.source[this.index],"<>=!+-*%&|^/".indexOf(y)>=0&&++this.index)}return this.index===v&&this.throwUnexpectedToken(),{type:7,value:y,lineNumber:this.lineNumber,lineStart:this.lineStart,start:v,end:this.index}},p.prototype.scanHexLiteral=function(v){for(var y="";!this.eof()&&f.Character.isHexDigit(this.source.charCodeAt(this.index));)y+=this.source[this.index++];return y.length===0&&this.throwUnexpectedToken(),f.Character.isIdentifierStart(this.source.charCodeAt(this.index))&&this.throwUnexpectedToken(),{type:6,value:parseInt("0x"+y,16),lineNumber:this.lineNumber,lineStart:this.lineStart,start:v,end:this.index}},p.prototype.scanBinaryLiteral=function(v){for(var y,m="";!this.eof()&&((y=this.source[this.index])==="0"||y==="1");)m+=this.source[this.index++];return m.length===0&&this.throwUnexpectedToken(),this.eof()||(y=this.source.charCodeAt(this.index),(f.Character.isIdentifierStart(y)||f.Character.isDecimalDigit(y))&&this.throwUnexpectedToken()),{type:6,value:parseInt(m,2),lineNumber:this.lineNumber,lineStart:this.lineStart,start:v,end:this.index}},p.prototype.scanOctalLiteral=function(v,y){var m="",w=!1;for(f.Character.isOctalDigit(v.charCodeAt(0))?(w=!0,m="0"+this.source[this.index++]):++this.index;!this.eof()&&f.Character.isOctalDigit(this.source.charCodeAt(this.index));)m+=this.source[this.index++];return w||m.length!==0||this.throwUnexpectedToken(),(f.Character.isIdentifierStart(this.source.charCodeAt(this.index))||f.Character.isDecimalDigit(this.source.charCodeAt(this.index)))&&this.throwUnexpectedToken(),{type:6,value:parseInt(m,8),octal:w,lineNumber:this.lineNumber,lineStart:this.lineStart,start:y,end:this.index}},p.prototype.isImplicitOctalLiteral=function(){for(var v=this.index+1;v<this.length;++v){var y=this.source[v];if(y==="8"||y==="9")return!1;if(!f.Character.isOctalDigit(y.charCodeAt(0)))return!0}return!0},p.prototype.scanNumericLiteral=function(){var v=this.index,y=this.source[v];l.assert(f.Character.isDecimalDigit(y.charCodeAt(0))||y===".","Numeric literal must start with a decimal digit or a decimal point");var m="";if(y!=="."){if(m=this.source[this.index++],y=this.source[this.index],m==="0"){if(y==="x"||y==="X")return++this.index,this.scanHexLiteral(v);if(y==="b"||y==="B")return++this.index,this.scanBinaryLiteral(v);if(y==="o"||y==="O")return this.scanOctalLiteral(y,v);if(y&&f.Character.isOctalDigit(y.charCodeAt(0))&&this.isImplicitOctalLiteral())return this.scanOctalLiteral(y,v)}for(;f.Character.isDecimalDigit(this.source.charCodeAt(this.index));)m+=this.source[this.index++];y=this.source[this.index]}if(y==="."){for(m+=this.source[this.index++];f.Character.isDecimalDigit(this.source.charCodeAt(this.index));)m+=this.source[this.index++];y=this.source[this.index]}if(y==="e"||y==="E")if(m+=this.source[this.index++],(y=this.source[this.index])!=="+"&&y!=="-"||(m+=this.source[this.index++]),f.Character.isDecimalDigit(this.source.charCodeAt(this.index)))for(;f.Character.isDecimalDigit(this.source.charCodeAt(this.index));)m+=this.source[this.index++];else this.throwUnexpectedToken();return f.Character.isIdentifierStart(this.source.charCodeAt(this.index))&&this.throwUnexpectedToken(),{type:6,value:parseFloat(m),lineNumber:this.lineNumber,lineStart:this.lineStart,start:v,end:this.index}},p.prototype.scanStringLiteral=function(){var v=this.index,y=this.source[v];l.assert(y==="'"||y==='"',"String literal must starts with a quote"),++this.index;for(var m=!1,w="";!this.eof();){var x=this.source[this.index++];if(x===y){y="";break}if(x==="\\")if((x=this.source[this.index++])&&f.Character.isLineTerminator(x.charCodeAt(0)))++this.lineNumber,x==="\r"&&this.source[this.index]===`
|
||
`&&++this.index,this.lineStart=this.index;else switch(x){case"u":if(this.source[this.index]==="{")++this.index,w+=this.scanUnicodeCodePointEscape();else{var C=this.scanHexEscape(x);C===null&&this.throwUnexpectedToken(),w+=C}break;case"x":var S=this.scanHexEscape(x);S===null&&this.throwUnexpectedToken(u.Messages.InvalidHexEscapeSequence),w+=S;break;case"n":w+=`
|
||
`;break;case"r":w+="\r";break;case"t":w+=" ";break;case"b":w+="\b";break;case"f":w+="\f";break;case"v":w+="\v";break;case"8":case"9":w+=x,this.tolerateUnexpectedToken();break;default:if(x&&f.Character.isOctalDigit(x.charCodeAt(0))){var T=this.octalToDecimal(x);m=T.octal||m,w+=String.fromCharCode(T.code)}else w+=x}else{if(f.Character.isLineTerminator(x.charCodeAt(0)))break;w+=x}}return y!==""&&(this.index=v,this.throwUnexpectedToken()),{type:8,value:w,octal:m,lineNumber:this.lineNumber,lineStart:this.lineStart,start:v,end:this.index}},p.prototype.scanTemplate=function(){var v="",y=!1,m=this.index,w=this.source[m]==="`",x=!1,C=2;for(++this.index;!this.eof();){var S=this.source[this.index++];if(S==="`"){C=1,x=!0,y=!0;break}if(S==="$"){if(this.source[this.index]==="{"){this.curlyStack.push("${"),++this.index,y=!0;break}v+=S}else if(S==="\\")if(S=this.source[this.index++],f.Character.isLineTerminator(S.charCodeAt(0)))++this.lineNumber,S==="\r"&&this.source[this.index]===`
|
||
`&&++this.index,this.lineStart=this.index;else switch(S){case"n":v+=`
|
||
`;break;case"r":v+="\r";break;case"t":v+=" ";break;case"u":if(this.source[this.index]==="{")++this.index,v+=this.scanUnicodeCodePointEscape();else{var T=this.index,_=this.scanHexEscape(S);_!==null?v+=_:(this.index=T,v+=S)}break;case"x":var E=this.scanHexEscape(S);E===null&&this.throwUnexpectedToken(u.Messages.InvalidHexEscapeSequence),v+=E;break;case"b":v+="\b";break;case"f":v+="\f";break;case"v":v+="\v";break;default:S==="0"?(f.Character.isDecimalDigit(this.source.charCodeAt(this.index))&&this.throwUnexpectedToken(u.Messages.TemplateOctalLiteral),v+="\0"):f.Character.isOctalDigit(S.charCodeAt(0))?this.throwUnexpectedToken(u.Messages.TemplateOctalLiteral):v+=S}else f.Character.isLineTerminator(S.charCodeAt(0))?(++this.lineNumber,S==="\r"&&this.source[this.index]===`
|
||
`&&++this.index,this.lineStart=this.index,v+=`
|
||
`):v+=S}return y||this.throwUnexpectedToken(),w||this.curlyStack.pop(),{type:10,value:this.source.slice(m+1,this.index-C),cooked:v,head:w,tail:x,lineNumber:this.lineNumber,lineStart:this.lineStart,start:m,end:this.index}},p.prototype.testRegExp=function(v,y){var m=v,w=this;y.indexOf("u")>=0&&(m=m.replace(/\\u\{([0-9a-fA-F]+)\}|\\u([a-fA-F0-9]{4})/g,function(x,C,S){var T=parseInt(C||S,16);return T>1114111&&w.throwUnexpectedToken(u.Messages.InvalidRegExp),T<=65535?String.fromCharCode(T):""}).replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,""));try{RegExp(m)}catch{this.throwUnexpectedToken(u.Messages.InvalidRegExp)}try{return new RegExp(v,y)}catch{return null}},p.prototype.scanRegExpBody=function(){var v=this.source[this.index];l.assert(v==="/","Regular expression literal must start with a slash");for(var y=this.source[this.index++],m=!1,w=!1;!this.eof();)if(y+=v=this.source[this.index++],v==="\\")v=this.source[this.index++],f.Character.isLineTerminator(v.charCodeAt(0))&&this.throwUnexpectedToken(u.Messages.UnterminatedRegExp),y+=v;else if(f.Character.isLineTerminator(v.charCodeAt(0)))this.throwUnexpectedToken(u.Messages.UnterminatedRegExp);else if(m)v==="]"&&(m=!1);else{if(v==="/"){w=!0;break}v==="["&&(m=!0)}return w||this.throwUnexpectedToken(u.Messages.UnterminatedRegExp),y.substr(1,y.length-2)},p.prototype.scanRegExpFlags=function(){for(var v="";!this.eof();){var y=this.source[this.index];if(!f.Character.isIdentifierPart(y.charCodeAt(0)))break;if(++this.index,y!=="\\"||this.eof())v+=y;else if((y=this.source[this.index])==="u"){++this.index;var m=this.index,w=this.scanHexEscape("u");if(w!==null)for(v+=w;m<this.index;++m)this.source[m];else this.index=m,v+="u";this.tolerateUnexpectedToken()}else this.tolerateUnexpectedToken()}return v},p.prototype.scanRegExp=function(){var v=this.index,y=this.scanRegExpBody(),m=this.scanRegExpFlags();return{type:9,value:"",pattern:y,flags:m,regex:this.testRegExp(y,m),lineNumber:this.lineNumber,lineStart:this.lineStart,start:v,end:this.index}},p.prototype.lex=function(){if(this.eof())return{type:2,value:"",lineNumber:this.lineNumber,lineStart:this.lineStart,start:this.index,end:this.index};var v=this.source.charCodeAt(this.index);return f.Character.isIdentifierStart(v)?this.scanIdentifier():v===40||v===41||v===59?this.scanPunctuator():v===39||v===34?this.scanStringLiteral():v===46?f.Character.isDecimalDigit(this.source.charCodeAt(this.index+1))?this.scanNumericLiteral():this.scanPunctuator():f.Character.isDecimalDigit(v)?this.scanNumericLiteral():v===96||v===125&&this.curlyStack[this.curlyStack.length-1]==="${"?this.scanTemplate():v>=55296&&v<57343&&f.Character.isIdentifierStart(this.codePointAt(this.index))?this.scanIdentifier():this.scanPunctuator()},p}();s.Scanner=g},function(a,s){Object.defineProperty(s,"__esModule",{value:!0}),s.TokenName={},s.TokenName[1]="Boolean",s.TokenName[2]="<end>",s.TokenName[3]="Identifier",s.TokenName[4]="Keyword",s.TokenName[5]="Null",s.TokenName[6]="Numeric",s.TokenName[7]="Punctuator",s.TokenName[8]="String",s.TokenName[9]="RegularExpression",s.TokenName[10]="Template"},function(a,s){Object.defineProperty(s,"__esModule",{value:!0}),s.XHTMLEntities={quot:'"',amp:"&",apos:"'",gt:">",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",ensp:" ",emsp:" ",thinsp:" ",zwnj:"",zwj:"",lrm:"",rlm:"",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",frasl:"⁄",euro:"€",image:"ℑ",weierp:"℘",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",lang:"⟨",rang:"⟩"}},function(a,s,c){Object.defineProperty(s,"__esModule",{value:!0});var l=c(10),f=c(12),u=c(13),d=function(){function g(){this.values=[],this.curly=this.paren=-1}return g.prototype.beforeFunctionExpression=function(p){return["(","{","[","in","typeof","instanceof","new","return","case","delete","throw","void","=","+=","-=","*=","**=","/=","%=","<<=",">>=",">>>=","&=","|=","^=",",","+","-","*","**","/","%","++","--","<<",">>",">>>","&","|","^","!","~","&&","||","?",":","===","==",">=","<=","<",">","!=","!=="].indexOf(p)>=0},g.prototype.isRegexStart=function(){var p=this.values[this.values.length-1],v=p!==null;switch(p){case"this":case"]":v=!1;break;case")":var y=this.values[this.paren-1];v=y==="if"||y==="while"||y==="for"||y==="with";break;case"}":if(v=!1,this.values[this.curly-3]==="function")v=!!(m=this.values[this.curly-4])&&!this.beforeFunctionExpression(m);else if(this.values[this.curly-4]==="function"){var m;v=!(m=this.values[this.curly-5])||!this.beforeFunctionExpression(m)}}return v},g.prototype.push=function(p){p.type===7||p.type===4?(p.value==="{"?this.curly=this.values.length:p.value==="("&&(this.paren=this.values.length),this.values.push(p.value)):this.values.push(null)},g}(),h=function(){function g(p,v){this.errorHandler=new l.ErrorHandler,this.errorHandler.tolerant=!!v&&typeof v.tolerant=="boolean"&&v.tolerant,this.scanner=new f.Scanner(p,this.errorHandler),this.scanner.trackComment=!!v&&typeof v.comment=="boolean"&&v.comment,this.trackRange=!!v&&typeof v.range=="boolean"&&v.range,this.trackLoc=!!v&&typeof v.loc=="boolean"&&v.loc,this.buffer=[],this.reader=new d}return g.prototype.errors=function(){return this.errorHandler.errors},g.prototype.getNextToken=function(){if(this.buffer.length===0){var p=this.scanner.scanComments();if(this.scanner.trackComment)for(var v=0;v<p.length;++v){var y=p[v],m=this.scanner.source.slice(y.slice[0],y.slice[1]),w={type:y.multiLine?"BlockComment":"LineComment",value:m};this.trackRange&&(w.range=y.range),this.trackLoc&&(w.loc=y.loc),this.buffer.push(w)}if(!this.scanner.eof()){var x=void 0;this.trackLoc&&(x={start:{line:this.scanner.lineNumber,column:this.scanner.index-this.scanner.lineStart},end:{}});var C=this.scanner.source[this.scanner.index]==="/"&&this.reader.isRegexStart()?this.scanner.scanRegExp():this.scanner.lex();this.reader.push(C);var S={type:u.TokenName[C.type],value:this.scanner.source.slice(C.start,C.end)};if(this.trackRange&&(S.range=[C.start,C.end]),this.trackLoc&&(x.end={line:this.scanner.lineNumber,column:this.scanner.index-this.scanner.lineStart},S.loc=x),C.type===9){var T=C.pattern,_=C.flags;S.regex={pattern:T,flags:_}}this.buffer.push(S)}}return this.buffer.shift()},g}();s.Tokenizer=h}])},r.exports=o()},function(r,n,i){var o=i(38),a=i(53),s=i(76),c=i(54),l=Object.prototype.toString,f=Object.prototype.hasOwnProperty,u={0:"\\0",7:"\\a",8:"\\b",9:"\\t",10:"\\n",11:"\\v",12:"\\f",13:"\\r",27:"\\e",34:'\\"',92:"\\\\",133:"\\N",160:"\\_",8232:"\\L",8233:"\\P"},d=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"];function h(O){var L,B,H;if(L=O.toString(16).toUpperCase(),O<=255)B="x",H=2;else if(O<=65535)B="u",H=4;else{if(!(O<=4294967295))throw new a("code point within a string may not be greater than 0xFFFFFFFF");B="U",H=8}return"\\"+B+o.repeat("0",H-L.length)+L}function g(O){this.schema=O.schema||s,this.indent=Math.max(1,O.indent||2),this.noArrayIndent=O.noArrayIndent||!1,this.skipInvalid=O.skipInvalid||!1,this.flowLevel=o.isNothing(O.flowLevel)?-1:O.flowLevel,this.styleMap=function(L,B){var H,A,F,G,X,ee,ce;if(B===null)return{};for(H={},F=0,G=(A=Object.keys(B)).length;F<G;F+=1)X=A[F],ee=String(B[X]),X.slice(0,2)==="!!"&&(X="tag:yaml.org,2002:"+X.slice(2)),(ce=L.compiledTypeMap.fallback[X])&&f.call(ce.styleAliases,ee)&&(ee=ce.styleAliases[ee]),H[X]=ee;return H}(this.schema,O.styles||null),this.sortKeys=O.sortKeys||!1,this.lineWidth=O.lineWidth||80,this.noRefs=O.noRefs||!1,this.noCompatMode=O.noCompatMode||!1,this.condenseFlow=O.condenseFlow||!1,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function p(O,L){for(var B,H=o.repeat(" ",L),A=0,F=-1,G="",X=O.length;A<X;)(F=O.indexOf(`
|
||
`,A))===-1?(B=O.slice(A),A=X):(B=O.slice(A,F+1),A=F+1),B.length&&B!==`
|
||
`&&(G+=H),G+=B;return G}function v(O,L){return`
|
||
`+o.repeat(" ",O.indent*L)}function y(O){return O===32||O===9}function m(O){return 32<=O&&O<=126||161<=O&&O<=55295&&O!==8232&&O!==8233||57344<=O&&O<=65533&&O!==65279||65536<=O&&O<=1114111}function w(O,L){return m(O)&&O!==65279&&O!==44&&O!==91&&O!==93&&O!==123&&O!==125&&O!==58&&(O!==35||L&&function(B){return m(B)&&!y(B)&&B!==65279&&B!==13&&B!==10}(L))}function x(O){return/^\n* /.test(O)}function C(O,L,B,H,A){var F,G,X,ee,ce=!1,Se=!1,we=H!==-1,_e=-1,Ve=m(ee=O.charCodeAt(0))&&ee!==65279&&!y(ee)&&ee!==45&&ee!==63&&ee!==58&&ee!==44&&ee!==91&&ee!==93&&ee!==123&&ee!==125&&ee!==35&&ee!==38&&ee!==42&&ee!==33&&ee!==124&&ee!==61&&ee!==62&&ee!==39&&ee!==34&&ee!==37&&ee!==64&&ee!==96&&!y(O.charCodeAt(O.length-1));if(L)for(F=0;F<O.length;F++){if(!m(G=O.charCodeAt(F)))return 5;X=F>0?O.charCodeAt(F-1):null,Ve=Ve&&w(G,X)}else{for(F=0;F<O.length;F++){if((G=O.charCodeAt(F))===10)ce=!0,we&&(Se=Se||F-_e-1>H&&O[_e+1]!==" ",_e=F);else if(!m(G))return 5;X=F>0?O.charCodeAt(F-1):null,Ve=Ve&&w(G,X)}Se=Se||we&&F-_e-1>H&&O[_e+1]!==" "}return ce||Se?B>9&&x(O)?5:Se?4:3:Ve&&!A(O)?1:2}function S(O,L,B,H){O.dump=function(){if(L.length===0)return"''";if(!O.noCompatMode&&d.indexOf(L)!==-1)return"'"+L+"'";var A=O.indent*Math.max(1,B),F=O.lineWidth===-1?-1:Math.max(Math.min(O.lineWidth,40),O.lineWidth-A),G=H||O.flowLevel>-1&&B>=O.flowLevel;switch(C(L,G,O.indent,F,function(X){return function(ee,ce){var Se,we;for(Se=0,we=ee.implicitTypes.length;Se<we;Se+=1)if(ee.implicitTypes[Se].resolve(ce))return!0;return!1}(O,X)})){case 1:return L;case 2:return"'"+L.replace(/'/g,"''")+"'";case 3:return"|"+T(L,O.indent)+_(p(L,A));case 4:return">"+T(L,O.indent)+_(p(function(X,ee){for(var ce,Se,we=/(\n+)([^\n]*)/g,_e=(Ge=X.indexOf(`
|
||
`),Ge=Ge!==-1?Ge:X.length,we.lastIndex=Ge,E(X.slice(0,Ge),ee)),Ve=X[0]===`
|
||
`||X[0]===" ",Ge;Se=we.exec(X);){var Ne=Se[1],j=Se[2];ce=j[0]===" ",_e+=Ne+(Ve||ce||j===""?"":`
|
||
`)+E(j,ee),Ve=ce}return _e}(L,F),A));case 5:return'"'+function(X){for(var ee,ce,Se,we="",_e=0;_e<X.length;_e++)(ee=X.charCodeAt(_e))>=55296&&ee<=56319&&(ce=X.charCodeAt(_e+1))>=56320&&ce<=57343?(we+=h(1024*(ee-55296)+ce-56320+65536),_e++):(Se=u[ee],we+=!Se&&m(ee)?X[_e]:Se||h(ee));return we}(L)+'"';default:throw new a("impossible error: invalid scalar style")}}()}function T(O,L){var B=x(O)?String(L):"",H=O[O.length-1]===`
|
||
`;return B+(H&&(O[O.length-2]===`
|
||
`||O===`
|
||
`)?"+":H?"":"-")+`
|
||
`}function _(O){return O[O.length-1]===`
|
||
`?O.slice(0,-1):O}function E(O,L){if(O===""||O[0]===" ")return O;for(var B,H,A=/ [^ ]/g,F=0,G=0,X=0,ee="";B=A.exec(O);)(X=B.index)-F>L&&(H=G>F?G:X,ee+=`
|
||
`+O.slice(F,H),F=H+1),G=X;return ee+=`
|
||
`,O.length-F>L&&G>F?ee+=O.slice(F,G)+`
|
||
`+O.slice(G+1):ee+=O.slice(F),ee.slice(1)}function b(O,L,B){var H,A,F,G,X,ee;for(F=0,G=(A=B?O.explicitTypes:O.implicitTypes).length;F<G;F+=1)if(((X=A[F]).instanceOf||X.predicate)&&(!X.instanceOf||typeof L=="object"&&L instanceof X.instanceOf)&&(!X.predicate||X.predicate(L))){if(O.tag=B?X.tag:"?",X.represent){if(ee=O.styleMap[X.tag]||X.defaultStyle,l.call(X.represent)==="[object Function]")H=X.represent(L,ee);else{if(!f.call(X.represent,ee))throw new a("!<"+X.tag+'> tag resolver accepts not "'+ee+'" style');H=X.represent[ee](L,ee)}O.dump=H}return!0}return!1}function D(O,L,B,H,A,F){O.tag=null,O.dump=B,b(O,B,!1)||b(O,B,!0);var G=l.call(O.dump);H&&(H=O.flowLevel<0||O.flowLevel>L);var X,ee,ce=G==="[object Object]"||G==="[object Array]";if(ce&&(ee=(X=O.duplicates.indexOf(B))!==-1),(O.tag!==null&&O.tag!=="?"||ee||O.indent!==2&&L>0)&&(A=!1),ee&&O.usedDuplicates[X])O.dump="*ref_"+X;else{if(ce&&ee&&!O.usedDuplicates[X]&&(O.usedDuplicates[X]=!0),G==="[object Object]")H&&Object.keys(O.dump).length!==0?(function(we,_e,Ve,Ge){var Ne,j,M,q,K,J,re="",ie=we.tag,Re=Object.keys(Ve);if(we.sortKeys===!0)Re.sort();else if(typeof we.sortKeys=="function")Re.sort(we.sortKeys);else if(we.sortKeys)throw new a("sortKeys must be a boolean or a function");for(Ne=0,j=Re.length;Ne<j;Ne+=1)J="",Ge&&Ne===0||(J+=v(we,_e)),q=Ve[M=Re[Ne]],D(we,_e+1,M,!0,!0,!0)&&((K=we.tag!==null&&we.tag!=="?"||we.dump&&we.dump.length>1024)&&(we.dump&&we.dump.charCodeAt(0)===10?J+="?":J+="? "),J+=we.dump,K&&(J+=v(we,_e)),D(we,_e+1,q,!0,K)&&(we.dump&&we.dump.charCodeAt(0)===10?J+=":":J+=": ",re+=J+=we.dump));we.tag=ie,we.dump=re||"{}"}(O,L,O.dump,A),ee&&(O.dump="&ref_"+X+O.dump)):(function(we,_e,Ve){var Ge,Ne,j,M,q,K="",J=we.tag,re=Object.keys(Ve);for(Ge=0,Ne=re.length;Ge<Ne;Ge+=1)q="",Ge!==0&&(q+=", "),we.condenseFlow&&(q+='"'),M=Ve[j=re[Ge]],D(we,_e,j,!1,!1)&&(we.dump.length>1024&&(q+="? "),q+=we.dump+(we.condenseFlow?'"':"")+":"+(we.condenseFlow?"":" "),D(we,_e,M,!1,!1)&&(K+=q+=we.dump));we.tag=J,we.dump="{"+K+"}"}(O,L,O.dump),ee&&(O.dump="&ref_"+X+" "+O.dump));else if(G==="[object Array]"){var Se=O.noArrayIndent&&L>0?L-1:L;H&&O.dump.length!==0?(function(we,_e,Ve,Ge){var Ne,j,M="",q=we.tag;for(Ne=0,j=Ve.length;Ne<j;Ne+=1)D(we,_e+1,Ve[Ne],!0,!0)&&(Ge&&Ne===0||(M+=v(we,_e)),we.dump&&we.dump.charCodeAt(0)===10?M+="-":M+="- ",M+=we.dump);we.tag=q,we.dump=M||"[]"}(O,Se,O.dump,A),ee&&(O.dump="&ref_"+X+O.dump)):(function(we,_e,Ve){var Ge,Ne,j="",M=we.tag;for(Ge=0,Ne=Ve.length;Ge<Ne;Ge+=1)D(we,_e,Ve[Ge],!1,!1)&&(Ge!==0&&(j+=","+(we.condenseFlow?"":" ")),j+=we.dump);we.tag=M,we.dump="["+j+"]"}(O,Se,O.dump),ee&&(O.dump="&ref_"+X+" "+O.dump))}else{if(G!=="[object String]"){if(O.skipInvalid)return!1;throw new a("unacceptable kind of an object to dump "+G)}O.tag!=="?"&&S(O,O.dump,L,F)}O.tag!==null&&O.tag!=="?"&&(O.dump="!<"+O.tag+"> "+O.dump)}return!0}function I(O,L){var B,H,A=[],F=[];for(function G(X,ee,ce){var Se,we,_e;if(X!==null&&typeof X=="object")if((we=ee.indexOf(X))!==-1)ce.indexOf(we)===-1&&ce.push(we);else if(ee.push(X),Array.isArray(X))for(we=0,_e=X.length;we<_e;we+=1)G(X[we],ee,ce);else for(Se=Object.keys(X),we=0,_e=Se.length;we<_e;we+=1)G(X[Se[we]],ee,ce)}(O,A,F),B=0,H=F.length;B<H;B+=1)L.duplicates.push(A[F[B]]);L.usedDuplicates=new Array(H)}function P(O,L){var B=new g(L=L||{});return B.noRefs||I(O,B),D(B,0,O,!0,!0)?B.dump+`
|
||
`:""}r.exports.dump=P,r.exports.safeDump=function(O,L){return P(O,o.extend({schema:c},L))}},function(r,n,i){i(31),i(32),i(33),i(64),i(19),i(65),i(20),i(68),i(92),i(144),i(22),i(94),i(23);var o,a=this&&this.__extends||(o=function(C,S){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(T,_){T.__proto__=_}||function(T,_){for(var E in _)_.hasOwnProperty(E)&&(T[E]=_[E])})(C,S)},function(C,S){function T(){this.constructor=C}o(C,S),C.prototype=S===null?Object.create(S):(T.prototype=S.prototype,new T)}),s=this&&this.__values||function(C){var S=typeof Symbol=="function"&&Symbol.iterator,T=S&&C[S],_=0;if(T)return T.call(C);if(C&&typeof C.length=="number")return{next:function(){return C&&_>=C.length&&(C=void 0),{value:C&&C[_++],done:!C}}};throw new TypeError(S?"Object is not iterable.":"Symbol.iterator is not defined.")},c=this&&this.__read||function(C,S){var T=typeof Symbol=="function"&&C[Symbol.iterator];if(!T)return C;var _,E,b=T.call(C),D=[];try{for(;(S===void 0||S-- >0)&&!(_=b.next()).done;)D.push(_.value)}catch(I){E={error:I}}finally{try{_&&!_.done&&(T=b.return)&&T.call(b)}finally{if(E)throw E.error}}return D};Object.defineProperty(n,"__esModule",{value:!0});var l=i(91),f=i(1),u=i(183),d=i(0),h=i(7),g=i(95),p=i(69),v=i(3),y=i(305),m=i(306),w=i(307),x=function(C){function S(T,_){_===void 0&&(_=!1);var E=C.call(this)||this;return E._hasDeclaration=!1,E._docTypeName="",E._hasDocumentElement=!1,E._currentElementSerialized=!1,E._openTags=[],E._ended=!1,E._fragment=_,E._options=f.applyDefaults(T||{},l.DefaultXMLBuilderCBOptions),E._builderOptions={defaultNamespace:E._options.defaultNamespace,namespaceAlias:E._options.namespaceAlias},E._options.format==="json"?E._writer=new m.JSONCBWriter(E._options):E._options.format==="yaml"?E._writer=new w.YAMLCBWriter(E._options):E._writer=new y.XMLCBWriter(E._options),E._options.data!==void 0&&E.on("data",E._options.data),E._options.end!==void 0&&E.on("end",E._options.end),E._options.error!==void 0&&E.on("error",E._options.error),E._prefixMap=new g.NamespacePrefixMap,E._prefixMap.set("xml",h.namespace.XML),E._prefixIndex={value:1},E._push(E._writer.frontMatter()),E}return a(S,C),S.prototype.ele=function(T,_,E){var b,D;if(f.isObject(T)||f.isString(T)&&(/^\s*</.test(T)||/^\s*[\{\[]/.test(T)||/^(\s*|(#.*)|(%.*))*---/.test(T))){var I=u.fragment().set(this._options);try{I.ele(T)}catch(B){return this.emit("error",B),this}try{for(var P=s(I.node.childNodes),O=P.next();!O.done;O=P.next()){var L=O.value;this._fromNode(L)}}catch(B){b={error:B}}finally{try{O&&!O.done&&(D=P.return)&&D.call(P)}finally{if(b)throw b.error}}return this}if(this._serializeOpenTag(!0),!this._fragment&&this._hasDocumentElement&&this._writer.level===0)return this.emit("error",new Error("Document cannot have multiple document element nodes.")),this;try{this._currentElement=u.fragment(this._builderOptions).ele(T,_,E)}catch(B){return this.emit("error",B),this}return this._fragment||this._hasDocumentElement||this._docTypeName===""||this._currentElement.node._qualifiedName===this._docTypeName?(this._currentElementSerialized=!1,this._fragment||(this._hasDocumentElement=!0),this):(this.emit("error",new Error("Document element name does not match DocType declaration name.")),this)},S.prototype.att=function(T,_,E){if(this._currentElement===void 0)return this.emit("error",new Error("Cannot insert an attribute node as child of a document node.")),this;try{this._currentElement.att(T,_,E)}catch(b){return this.emit("error",b),this}return this},S.prototype.com=function(T){var _;this._serializeOpenTag(!0);try{_=u.fragment(this._builderOptions).com(T).first().node}catch(E){return this.emit("error",E),this}return!this._options.wellFormed||d.xml_isLegalChar(_.data)&&_.data.indexOf("--")===-1&&!_.data.endsWith("-")?(this._push(this._writer.comment(_.data)),this):(this.emit("error",new Error("Comment data contains invalid characters (well-formed required).")),this)},S.prototype.txt=function(T){if(!this._fragment&&this._currentElement===void 0)return this.emit("error",new Error("Cannot insert a text node as child of a document node.")),this;var _;this._serializeOpenTag(!0);try{_=u.fragment(this._builderOptions).txt(T).first().node}catch(b){return this.emit("error",b),this}if(this._options.wellFormed&&!d.xml_isLegalChar(_.data))return this.emit("error",new Error("Text data contains invalid characters (well-formed required).")),this;var E=_.data.replace(/(?!&(lt|gt|amp|apos|quot);)&/g,"&").replace(/</g,"<").replace(/>/g,">");return this._push(this._writer.text(E)),this},S.prototype.ins=function(T,_){var E;_===void 0&&(_=""),this._serializeOpenTag(!0);try{E=u.fragment(this._builderOptions).ins(T,_).first().node}catch(b){return this.emit("error",b),this}return this._options.wellFormed&&(E.target.indexOf(":")!==-1||/^xml$/i.test(E.target))?(this.emit("error",new Error("Processing instruction target contains invalid characters (well-formed required).")),this):this._options.wellFormed&&!d.xml_isLegalChar(E.data)?(this.emit("error",Error("Processing instruction data contains invalid characters (well-formed required).")),this):(this._push(this._writer.instruction(E.target,E.data)),this)},S.prototype.dat=function(T){var _;this._serializeOpenTag(!0);try{_=u.fragment(this._builderOptions).dat(T).first().node}catch(E){return this.emit("error",E),this}return this._push(this._writer.cdata(_.data)),this},S.prototype.dec=function(T){return T===void 0&&(T={version:"1.0"}),this._fragment?(this.emit("error",Error("Cannot insert an XML declaration into a document fragment.")),this):this._hasDeclaration?(this.emit("error",Error("XML declaration is already inserted.")),this):(this._push(this._writer.declaration(T.version||"1.0",T.encoding,T.standalone)),this._hasDeclaration=!0,this)},S.prototype.dtd=function(T){if(this._fragment)return this.emit("error",Error("Cannot insert a DocType declaration into a document fragment.")),this;if(this._docTypeName!=="")return this.emit("error",new Error("DocType declaration is already inserted.")),this;if(this._hasDocumentElement)return this.emit("error",new Error("Cannot insert DocType declaration after document element.")),this;var _;try{_=u.create().dtd(T).first().node}catch(E){return this.emit("error",E),this}return this._options.wellFormed&&!d.xml_isPubidChar(_.publicId)?(this.emit("error",new Error("DocType public identifier does not match PubidChar construct (well-formed required).")),this):this._options.wellFormed&&(!d.xml_isLegalChar(_.systemId)||_.systemId.indexOf('"')!==-1&&_.systemId.indexOf("'")!==-1)?(this.emit("error",new Error("DocType system identifier contains invalid characters (well-formed required).")),this):(this._docTypeName=T.name,this._push(this._writer.docType(T.name,_.publicId,_.systemId)),this)},S.prototype.import=function(T){var _,E,b=u.fragment().set(this._options);try{b.import(T)}catch(O){return this.emit("error",O),this}try{for(var D=s(b.node.childNodes),I=D.next();!I.done;I=D.next()){var P=I.value;this._fromNode(P)}}catch(O){_={error:O}}finally{try{I&&!I.done&&(E=D.return)&&E.call(D)}finally{if(_)throw _.error}}return this},S.prototype.up=function(){return this._serializeOpenTag(!1),this._serializeCloseTag(),this},S.prototype.end=function(){for(this._serializeOpenTag(!1);this._openTags.length>0;)this._serializeCloseTag();return this._push(null),this},S.prototype._serializeOpenTag=function(T){if(!this._currentElementSerialized&&this._currentElement!==void 0){var _=this._currentElement.node;if(!this._options.wellFormed||_.localName.indexOf(":")===-1&&d.xml_isName(_.localName)){var E="",b=!1,D=this._prefixMap.copy(),I={},P=this._recordNamespaceInformation(_,D,I),O=this._openTags.length===0?null:this._openTags[this._openTags.length-1][1],L=_.namespaceURI;if(L===null&&(L=O),O===L)P!==null&&(b=!0),E=L===h.namespace.XML?"xml:"+_.localName:_.localName,this._writer.beginElement(E),this._push(this._writer.openTagBegin(E));else{var B=_.prefix,H=null;if(B===null&&L===P||(H=D.get(B,L)),B==="xmlns"){if(this._options.wellFormed)return void this.emit("error",new Error("An element cannot have the 'xmlns' prefix (well-formed required)."));H=B}H!==null?(E=H+":"+_.localName,P!==null&&P!==h.namespace.XML&&(O=P||null),this._writer.beginElement(E),this._push(this._writer.openTagBegin(E))):B!==null?(B in I&&(B=this._generatePrefix(L,D,this._prefixIndex)),D.set(B,L),E+=B+":"+_.localName,this._writer.beginElement(E),this._push(this._writer.openTagBegin(E)),this._push(this._writer.attribute("xmlns:"+B,this._serializeAttributeValue(L,this._options.wellFormed))),P!==null&&(O=P||null)):P===null||P!==null&&P!==L?(b=!0,E+=_.localName,O=L,this._writer.beginElement(E),this._push(this._writer.openTagBegin(E)),this._push(this._writer.attribute("xmlns",this._serializeAttributeValue(L,this._options.wellFormed)))):(E+=_.localName,O=L,this._writer.beginElement(E),this._push(this._writer.openTagBegin(E)))}this._serializeAttributes(_,D,this._prefixIndex,I,b,this._options.wellFormed);var A=L===h.namespace.HTML;A&&!T&&S._VoidElementNames.has(_.localName)?(this._push(this._writer.openTagEnd(E,!0,!0)),this._writer.endElement(E)):A||T?this._push(this._writer.openTagEnd(E,!1,!1)):(this._push(this._writer.openTagEnd(E,!0,!1)),this._writer.endElement(E)),this._currentElementSerialized=!0,this._openTags.push([E,O,this._prefixMap,T]),this._isPrefixMapModified(this._prefixMap,D)&&(this._prefixMap=D),this._writer.level++}else this.emit("error",new Error("Node local name contains invalid characters (well-formed required)."))}},S.prototype._serializeCloseTag=function(){this._writer.level--;var T=this._openTags.pop();if(T!==void 0){var _=c(T,4),E=_[0],b=(_[1],_[2]),D=_[3];this._prefixMap=b,D&&(this._push(this._writer.closeTag(E)),this._writer.endElement(E))}else this.emit("error",new Error("Last element is undefined."))},S.prototype._push=function(T){T===null?(this._ended=!0,this.emit("end")):this._ended?this.emit("error",new Error("Cannot push to ended stream.")):T.length!==0&&(this._writer.hasData=!0,this.emit("data",T,this._writer.level))},S.prototype._fromNode=function(T){var _,E,b,D;if(v.Guard.isElementNode(T)){var I=T.prefix?T.prefix+":"+T.localName:T.localName;T.namespaceURI!==null?this.ele(T.namespaceURI,I):this.ele(I);try{for(var P=s(T.attributes),O=P.next();!O.done;O=P.next()){var L=O.value,B=L.prefix?L.prefix+":"+L.localName:L.localName;L.namespaceURI!==null?this.att(L.namespaceURI,B,L.value):this.att(B,L.value)}}catch(G){_={error:G}}finally{try{O&&!O.done&&(E=P.return)&&E.call(P)}finally{if(_)throw _.error}}try{for(var H=s(T.childNodes),A=H.next();!A.done;A=H.next()){var F=A.value;this._fromNode(F)}}catch(G){b={error:G}}finally{try{A&&!A.done&&(D=H.return)&&D.call(H)}finally{if(b)throw b.error}}this.up()}else v.Guard.isExclusiveTextNode(T)&&T.data?this.txt(T.data):v.Guard.isCommentNode(T)?this.com(T.data):v.Guard.isCDATASectionNode(T)?this.dat(T.data):v.Guard.isProcessingInstructionNode(T)&&this.ins(T.target,T.data)},S.prototype._serializeAttributes=function(T,_,E,b,D,I){var P,O,L=I?new p.LocalNameSet:void 0;try{for(var B=s(T.attributes),H=B.next();!H.done;H=B.next()){var A=H.value;if(I||D||A.namespaceURI!==null){if(I&&L&&L.has(A.namespaceURI,A.localName))return void this.emit("error",new Error("Element contains duplicate attributes (well-formed required)."));I&&L&&L.set(A.namespaceURI,A.localName);var F=A.namespaceURI,G=null;if(F!==null)if(G=_.get(A.prefix,F),F===h.namespace.XMLNS){if(A.value===h.namespace.XML||A.prefix===null&&D||A.prefix!==null&&(!(A.localName in b)||b[A.localName]!==A.value)&&_.has(A.localName,A.value))continue;if(I&&A.value===h.namespace.XMLNS)return void this.emit("error",new Error("XMLNS namespace is reserved (well-formed required)."));if(I&&A.value==="")return void this.emit("error",new Error("Namespace prefix declarations cannot be used to undeclare a namespace (well-formed required)."));A.prefix==="xmlns"&&(G="xmlns")}else G===null&&(G=A.prefix===null||_.hasPrefix(A.prefix)&&!_.has(A.prefix,F)?this._generatePrefix(F,_,E):A.prefix,this._push(this._writer.attribute("xmlns:"+G,this._serializeAttributeValue(F,this._options.wellFormed))));if(I&&(A.localName.indexOf(":")!==-1||!d.xml_isName(A.localName)||A.localName==="xmlns"&&F===null))return void this.emit("error",new Error("Attribute local name contains invalid characters (well-formed required)."));this._push(this._writer.attribute((G!==null?G+":":"")+A.localName,this._serializeAttributeValue(A.value,this._options.wellFormed)))}else this._push(this._writer.attribute(A.localName,this._serializeAttributeValue(A.value,this._options.wellFormed)))}}catch(X){P={error:X}}finally{try{H&&!H.done&&(O=B.return)&&O.call(B)}finally{if(P)throw P.error}}},S.prototype._serializeAttributeValue=function(T,_){return _&&T!==null&&!d.xml_isLegalChar(T)?(this.emit("error",new Error("Invalid characters in attribute value.")),""):T===null?"":T.replace(/(?!&(lt|gt|amp|apos|quot);)&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")},S.prototype._recordNamespaceInformation=function(T,_,E){var b,D,I=null;try{for(var P=s(T.attributes),O=P.next();!O.done;O=P.next()){var L=O.value,B=L.namespaceURI,H=L.prefix;if(B===h.namespace.XMLNS){if(H===null){I=L.value;continue}var A=L.localName,F=L.value;if(F===h.namespace.XML||(F===""&&(F=null),_.has(A,F)))continue;_.set(A,F),E[A]=F||""}}}catch(G){b={error:G}}finally{try{O&&!O.done&&(D=P.return)&&D.call(P)}finally{if(b)throw b.error}}return I},S.prototype._generatePrefix=function(T,_,E){var b="ns"+E.value;return E.value++,_.set(b,T),b},S.prototype._isPrefixMapModified=function(T,_){var E=T._items,b=_._items,D=T._nullItems,I=_._nullItems;for(var P in b){var O=E[P];if(O===void 0)return!0;var L=b[P];if(O.length!==L.length)return!0;for(var B=0;B<O.length;B++)if(O[B]!==L[B])return!0}if(D.length!==I.length)return!0;for(B=0;B<D.length;B++)if(D[B]!==I[B])return!0;return!1},S._VoidElementNames=new Set(["area","base","basefont","bgsound","br","col","embed","frame","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"]),S}(i(308).EventEmitter);n.XMLBuilderCBImpl=x},function(r,n,i){i(74);var o,a=this&&this.__extends||(o=function(c,l){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(f,u){f.__proto__=u}||function(f,u){for(var d in u)u.hasOwnProperty(d)&&(f[d]=u[d])})(c,l)},function(c,l){function f(){this.constructor=c}o(c,l),c.prototype=l===null?Object.create(l):(f.prototype=l.prototype,new f)});Object.defineProperty(n,"__esModule",{value:!0});var s=function(c){function l(f){var u=c.call(this,f)||this;return u._lineLength=0,u}return a(l,c),l.prototype.frontMatter=function(){return""},l.prototype.declaration=function(f,u,d){var h=this._beginLine()+"<?xml";return h+=' version="'+f+'"',u!==void 0&&(h+=' encoding="'+u+'"'),d!==void 0&&(h+=' standalone="'+(d?"yes":"no")+'"'),h+="?>"},l.prototype.docType=function(f,u,d){var h=this._beginLine();return h+=u&&d?"<!DOCTYPE "+f+' PUBLIC "'+u+'" "'+d+'">':u?"<!DOCTYPE "+f+' PUBLIC "'+u+'">':d?"<!DOCTYPE "+f+' SYSTEM "'+d+'">':"<!DOCTYPE "+f+">"},l.prototype.comment=function(f){return this._beginLine()+"<!--"+f+"-->"},l.prototype.text=function(f){return this._beginLine()+f},l.prototype.instruction=function(f,u){return u?this._beginLine()+"<?"+f+" "+u+"?>":this._beginLine()+"<?"+f+"?>"},l.prototype.cdata=function(f){return this._beginLine()+"<![CDATA["+f+"]]>"},l.prototype.openTagBegin=function(f){return this._lineLength+=1+f.length,this._beginLine()+"<"+f},l.prototype.openTagEnd=function(f,u,d){return d?" />":u?this._writerOptions.allowEmptyTags?"></"+f+">":this._writerOptions.spaceBeforeSlash?" />":"/>":">"},l.prototype.closeTag=function(f){return this._beginLine()+"</"+f+">"},l.prototype.attribute=function(f,u){var d=f+'="'+u+'"';return this._writerOptions.prettyPrint&&this._writerOptions.width>0&&this._lineLength+1+d.length>this._writerOptions.width?(d=this._beginLine()+this._indent(1)+d,this._lineLength=d.length,d):(this._lineLength+=1+d.length," "+d)},l.prototype.beginElement=function(f){},l.prototype.endElement=function(f){},l.prototype._beginLine=function(){if(this._writerOptions.prettyPrint){var f=(this.hasData?this._writerOptions.newline:"")+this._indent(this._writerOptions.offset+this.level);return this._lineLength=f.length,f}return""},l.prototype._indent=function(f){return f<=0?"":this._writerOptions.indent.repeat(f)},l}(i(114).BaseCBWriter);n.XMLCBWriter=s},function(r,n,i){i(74);var o,a=this&&this.__extends||(o=function(c,l){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(f,u){f.__proto__=u}||function(f,u){for(var d in u)u.hasOwnProperty(d)&&(f[d]=u[d])})(c,l)},function(c,l){function f(){this.constructor=c}o(c,l),c.prototype=l===null?Object.create(l):(f.prototype=l.prototype,new f)});Object.defineProperty(n,"__esModule",{value:!0});var s=function(c){function l(f){var u=c.call(this,f)||this;return u._hasChildren=[],u._additionalLevel=0,u}return a(l,c),l.prototype.frontMatter=function(){return""},l.prototype.declaration=function(f,u,d){return""},l.prototype.docType=function(f,u,d){return""},l.prototype.comment=function(f){return this._comma()+this._beginLine()+"{"+this._sep()+this._key(this._builderOptions.convert.comment)+this._sep()+this._val(f)+this._sep()+"}"},l.prototype.text=function(f){return this._comma()+this._beginLine()+"{"+this._sep()+this._key(this._builderOptions.convert.text)+this._sep()+this._val(f)+this._sep()+"}"},l.prototype.instruction=function(f,u){return this._comma()+this._beginLine()+"{"+this._sep()+this._key(this._builderOptions.convert.ins)+this._sep()+this._val(u?f+" "+u:f)+this._sep()+"}"},l.prototype.cdata=function(f){return this._comma()+this._beginLine()+"{"+this._sep()+this._key(this._builderOptions.convert.cdata)+this._sep()+this._val(f)+this._sep()+"}"},l.prototype.attribute=function(f,u){return this._comma()+this._beginLine(1)+"{"+this._sep()+this._key(this._builderOptions.convert.att+f)+this._sep()+this._val(u)+this._sep()+"}"},l.prototype.openTagBegin=function(f){var u=this._comma()+this._beginLine()+"{"+this._sep()+this._key(f)+this._sep()+"{";return this._additionalLevel++,this.hasData=!0,u+=this._beginLine()+this._key(this._builderOptions.convert.text)+this._sep()+"[",this._hasChildren.push(!1),u},l.prototype.openTagEnd=function(f,u,d){if(u){var h=this._sep()+"]";return this._additionalLevel--,h+=this._beginLine()+"}"+this._sep()+"}"}return""},l.prototype.closeTag=function(f){var u=this._beginLine()+"]";return this._additionalLevel--,u+=this._beginLine()+"}"+this._sep()+"}"},l.prototype.beginElement=function(f){},l.prototype.endElement=function(f){this._hasChildren.pop()},l.prototype._beginLine=function(f){return f===void 0&&(f=0),this._writerOptions.prettyPrint?(this.hasData?this._writerOptions.newline:"")+this._indent(this._writerOptions.offset+this.level+f):""},l.prototype._indent=function(f){return f+this._additionalLevel<=0?"":this._writerOptions.indent.repeat(f+this._additionalLevel)},l.prototype._comma=function(){var f=this._hasChildren[this._hasChildren.length-1]?",":"";return this._hasChildren.length>0&&(this._hasChildren[this._hasChildren.length-1]=!0),f},l.prototype._sep=function(){return this._writerOptions.prettyPrint?" ":""},l.prototype._key=function(f){return'"'+f+'":'},l.prototype._val=function(f){return JSON.stringify(f)},l}(i(114).BaseCBWriter);n.JSONCBWriter=s},function(r,n,i){i(74);var o,a=this&&this.__extends||(o=function(c,l){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(f,u){f.__proto__=u}||function(f,u){for(var d in u)u.hasOwnProperty(d)&&(f[d]=u[d])})(c,l)},function(c,l){function f(){this.constructor=c}o(c,l),c.prototype=l===null?Object.create(l):(f.prototype=l.prototype,new f)});Object.defineProperty(n,"__esModule",{value:!0});var s=function(c){function l(f){var u=c.call(this,f)||this;if(u._rootWritten=!1,u._additionalLevel=0,f.indent.length<2)throw new Error("YAML indententation string must be at least two characters long.");if(f.offset<0)throw new Error("YAML offset should be zero or a positive number.");return u}return a(l,c),l.prototype.frontMatter=function(){return this._beginLine()+"---"},l.prototype.declaration=function(f,u,d){return""},l.prototype.docType=function(f,u,d){return""},l.prototype.comment=function(f){return this._beginLine()+this._key(this._builderOptions.convert.comment)+" "+this._val(f)},l.prototype.text=function(f){return this._beginLine()+this._key(this._builderOptions.convert.text)+" "+this._val(f)},l.prototype.instruction=function(f,u){return this._beginLine()+this._key(this._builderOptions.convert.ins)+" "+this._val(u?f+" "+u:f)},l.prototype.cdata=function(f){return this._beginLine()+this._key(this._builderOptions.convert.cdata)+" "+this._val(f)},l.prototype.attribute=function(f,u){this._additionalLevel++;var d=this._beginLine()+this._key(this._builderOptions.convert.att+f)+" "+this._val(u);return this._additionalLevel--,d},l.prototype.openTagBegin=function(f){var u=this._beginLine()+this._key(f);return this._rootWritten||(this._rootWritten=!0),this.hasData=!0,this._additionalLevel++,u+=this._beginLine(!0)+this._key(this._builderOptions.convert.text)},l.prototype.openTagEnd=function(f,u,d){return u?" "+this._val(""):""},l.prototype.closeTag=function(f){return this._additionalLevel--,""},l.prototype.beginElement=function(f){},l.prototype.endElement=function(f){},l.prototype._beginLine=function(f){return f===void 0&&(f=!1),(this.hasData?this._writerOptions.newline:"")+this._indent(this._writerOptions.offset+this.level,f)},l.prototype._indent=function(f,u){if(f+this._additionalLevel<=0)return"";var d=this._writerOptions.indent.repeat(f+this._additionalLevel);return!u&&this._rootWritten?d.substr(0,d.length-2)+"-"+d.substr(-1,1):d},l.prototype._key=function(f){return'"'+f+'":'},l.prototype._val=function(f){return JSON.stringify(f)},l}(i(114).BaseCBWriter);n.YAMLCBWriter=s},function(r,n,i){var o,a=typeof Reflect=="object"?Reflect:null,s=a&&typeof a.apply=="function"?a.apply:function(w,x,C){return Function.prototype.apply.call(w,x,C)};o=a&&typeof a.ownKeys=="function"?a.ownKeys:Object.getOwnPropertySymbols?function(w){return Object.getOwnPropertyNames(w).concat(Object.getOwnPropertySymbols(w))}:function(w){return Object.getOwnPropertyNames(w)};var c=Number.isNaN||function(w){return w!=w};function l(){l.init.call(this)}r.exports=l,l.EventEmitter=l,l.prototype._events=void 0,l.prototype._eventsCount=0,l.prototype._maxListeners=void 0;var f=10;function u(w){if(typeof w!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof w)}function d(w){return w._maxListeners===void 0?l.defaultMaxListeners:w._maxListeners}function h(w,x,C,S){var T,_,E,b;if(u(C),(_=w._events)===void 0?(_=w._events=Object.create(null),w._eventsCount=0):(_.newListener!==void 0&&(w.emit("newListener",x,C.listener?C.listener:C),_=w._events),E=_[x]),E===void 0)E=_[x]=C,++w._eventsCount;else if(typeof E=="function"?E=_[x]=S?[C,E]:[E,C]:S?E.unshift(C):E.push(C),(T=d(w))>0&&E.length>T&&!E.warned){E.warned=!0;var D=new Error("Possible EventEmitter memory leak detected. "+E.length+" "+String(x)+" listeners added. Use emitter.setMaxListeners() to increase limit");D.name="MaxListenersExceededWarning",D.emitter=w,D.type=x,D.count=E.length,b=D,console&&console.warn&&console.warn(b)}return w}function g(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(w,x,C){var S={fired:!1,wrapFn:void 0,target:w,type:x,listener:C},T=g.bind(S);return T.listener=C,S.wrapFn=T,T}function v(w,x,C){var S=w._events;if(S===void 0)return[];var T=S[x];return T===void 0?[]:typeof T=="function"?C?[T.listener||T]:[T]:C?function(_){for(var E=new Array(_.length),b=0;b<E.length;++b)E[b]=_[b].listener||_[b];return E}(T):m(T,T.length)}function y(w){var x=this._events;if(x!==void 0){var C=x[w];if(typeof C=="function")return 1;if(C!==void 0)return C.length}return 0}function m(w,x){for(var C=new Array(x),S=0;S<x;++S)C[S]=w[S];return C}Object.defineProperty(l,"defaultMaxListeners",{enumerable:!0,get:function(){return f},set:function(w){if(typeof w!="number"||w<0||c(w))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+w+".");f=w}}),l.init=function(){this._events!==void 0&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},l.prototype.setMaxListeners=function(w){if(typeof w!="number"||w<0||c(w))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+w+".");return this._maxListeners=w,this},l.prototype.getMaxListeners=function(){return d(this)},l.prototype.emit=function(w){for(var x=[],C=1;C<arguments.length;C++)x.push(arguments[C]);var S=w==="error",T=this._events;if(T!==void 0)S=S&&T.error===void 0;else if(!S)return!1;if(S){var _;if(x.length>0&&(_=x[0]),_ instanceof Error)throw _;var E=new Error("Unhandled error."+(_?" ("+_.message+")":""));throw E.context=_,E}var b=T[w];if(b===void 0)return!1;if(typeof b=="function")s(b,this,x);else{var D=b.length,I=m(b,D);for(C=0;C<D;++C)s(I[C],this,x)}return!0},l.prototype.addListener=function(w,x){return h(this,w,x,!1)},l.prototype.on=l.prototype.addListener,l.prototype.prependListener=function(w,x){return h(this,w,x,!0)},l.prototype.once=function(w,x){return u(x),this.on(w,p(this,w,x)),this},l.prototype.prependOnceListener=function(w,x){return u(x),this.prependListener(w,p(this,w,x)),this},l.prototype.removeListener=function(w,x){var C,S,T,_,E;if(u(x),(S=this._events)===void 0)return this;if((C=S[w])===void 0)return this;if(C===x||C.listener===x)--this._eventsCount==0?this._events=Object.create(null):(delete S[w],S.removeListener&&this.emit("removeListener",w,C.listener||x));else if(typeof C!="function"){for(T=-1,_=C.length-1;_>=0;_--)if(C[_]===x||C[_].listener===x){E=C[_].listener,T=_;break}if(T<0)return this;T===0?C.shift():function(b,D){for(;D+1<b.length;D++)b[D]=b[D+1];b.pop()}(C,T),C.length===1&&(S[w]=C[0]),S.removeListener!==void 0&&this.emit("removeListener",w,E||x)}return this},l.prototype.off=l.prototype.removeListener,l.prototype.removeAllListeners=function(w){var x,C,S;if((C=this._events)===void 0)return this;if(C.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):C[w]!==void 0&&(--this._eventsCount==0?this._events=Object.create(null):delete C[w]),this;if(arguments.length===0){var T,_=Object.keys(C);for(S=0;S<_.length;++S)(T=_[S])!=="removeListener"&&this.removeAllListeners(T);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(typeof(x=C[w])=="function")this.removeListener(w,x);else if(x!==void 0)for(S=x.length-1;S>=0;S--)this.removeListener(w,x[S]);return this},l.prototype.listeners=function(w){return v(this,w,!0)},l.prototype.rawListeners=function(w){return v(this,w,!1)},l.listenerCount=function(w,x){return typeof w.listenerCount=="function"?w.listenerCount(x):y.call(w,x)},l.prototype.listenerCount=y,l.prototype.eventNames=function(){return this._eventsCount>0?o(this._events):[]}},function(r,n,i){Object.defineProperty(n,"__esModule",{value:!0});var o=i(77);n.createCB=function(a){return new o.XMLBuilderCBImpl(a)},n.fragmentCB=function(a){return new o.XMLBuilderCBImpl(a,!0)}}])})})(oV);var Jle=oV.exports,Aa=Uint8Array,rd=Uint16Array,aV=Uint32Array,sV=new Aa([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]),cV=new Aa([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]),Zle=new Aa([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),lV=function(t,e){for(var r=new rd(31),n=0;n<31;++n)r[n]=e+=1<<t[n-1];for(var i=new aV(r[30]),n=1;n<30;++n)for(var o=r[n];o<r[n+1];++o)i[o]=o-r[n]<<5|n;return[r,i]},uV=lV(sV,2),fV=uV[0],Qle=uV[1];fV[28]=258,Qle[258]=28;var eue=lV(cV,0),tue=eue[0],PS=new rd(32768);for(var Sr=0;Sr<32768;++Sr){var vu=(Sr&43690)>>>1|(Sr&21845)<<1;vu=(vu&52428)>>>2|(vu&13107)<<2,vu=(vu&61680)>>>4|(vu&3855)<<4,PS[Sr]=((vu&65280)>>>8|(vu&255)<<8)>>>1}var Cp=function(t,e,r){for(var n=t.length,i=0,o=new rd(e);i<n;++i)t[i]&&++o[t[i]-1];var a=new rd(e);for(i=0;i<e;++i)a[i]=a[i-1]+o[i-1]<<1;var s;if(r){s=new rd(1<<e);var c=15-e;for(i=0;i<n;++i)if(t[i])for(var l=i<<4|t[i],f=e-t[i],u=a[t[i]-1]++<<f,d=u|(1<<f)-1;u<=d;++u)s[PS[u]>>>c]=l}else for(s=new rd(n),i=0;i<n;++i)t[i]&&(s[i]=PS[a[t[i]-1]++]>>>15-t[i]);return s},gm=new Aa(288);for(var Sr=0;Sr<144;++Sr)gm[Sr]=8;for(var Sr=144;Sr<256;++Sr)gm[Sr]=9;for(var Sr=256;Sr<280;++Sr)gm[Sr]=7;for(var Sr=280;Sr<288;++Sr)gm[Sr]=8;var dV=new Aa(32);for(var Sr=0;Sr<32;++Sr)dV[Sr]=5;var nue=Cp(gm,9,1),rue=Cp(dV,5,1),sC=function(t){for(var e=t[0],r=1;r<t.length;++r)t[r]>e&&(e=t[r]);return e},Bs=function(t,e,r){var n=e/8|0;return(t[n]|t[n+1]<<8)>>(e&7)&r},cC=function(t,e){var r=e/8|0;return(t[r]|t[r+1]<<8|t[r+2]<<16)>>(e&7)},iue=function(t){return(t+7)/8|0},oue=function(t,e,r){(r==null||r>t.length)&&(r=t.length);var n=new(t.BYTES_PER_ELEMENT==2?rd:t.BYTES_PER_ELEMENT==4?aV:Aa)(r-e);return n.set(t.subarray(e,r)),n},aue=["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"],Xs=function(t,e,r){var n=new Error(e||aue[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,Xs),!r)throw n;return n},lE=function(t,e,r){var n=t.length;if(!n||r&&r.f&&!r.l)return e||new Aa(0);var i=!e||r,o=!r||r.i;r||(r={}),e||(e=new Aa(n*3));var a=function(_e){var Ve=e.length;if(_e>Ve){var Ge=new Aa(Math.max(Ve*2,_e));Ge.set(e),e=Ge}},s=r.f||0,c=r.p||0,l=r.b||0,f=r.l,u=r.d,d=r.m,h=r.n,g=n*8;do{if(!f){s=Bs(t,c,1);var p=Bs(t,c+1,3);if(c+=3,p)if(p==1)f=nue,u=rue,d=9,h=5;else if(p==2){var w=Bs(t,c,31)+257,x=Bs(t,c+10,15)+4,C=w+Bs(t,c+5,31)+1;c+=14;for(var S=new Aa(C),T=new Aa(19),_=0;_<x;++_)T[Zle[_]]=Bs(t,c+_*3,7);c+=x*3;for(var E=sC(T),b=(1<<E)-1,D=Cp(T,E,1),_=0;_<C;){var I=D[Bs(t,c,b)];c+=I&15;var v=I>>>4;if(v<16)S[_++]=v;else{var P=0,O=0;for(v==16?(O=3+Bs(t,c,3),c+=2,P=S[_-1]):v==17?(O=3+Bs(t,c,7),c+=3):v==18&&(O=11+Bs(t,c,127),c+=7);O--;)S[_++]=P}}var L=S.subarray(0,w),B=S.subarray(w);d=sC(L),h=sC(B),f=Cp(L,d,1),u=Cp(B,h,1)}else Xs(1);else{var v=iue(c)+4,y=t[v-4]|t[v-3]<<8,m=v+y;if(m>n){o&&Xs(0);break}i&&a(l+y),e.set(t.subarray(v,m),l),r.b=l+=y,r.p=c=m*8,r.f=s;continue}if(c>g){o&&Xs(0);break}}i&&a(l+131072);for(var H=(1<<d)-1,A=(1<<h)-1,F=c;;F=c){var P=f[cC(t,c)&H],G=P>>>4;if(c+=P&15,c>g){o&&Xs(0);break}if(P||Xs(2),G<256)e[l++]=G;else if(G==256){F=c,f=null;break}else{var X=G-254;if(G>264){var _=G-257,ee=sV[_];X=Bs(t,c,(1<<ee)-1)+fV[_],c+=ee}var ce=u[cC(t,c)&A],Se=ce>>>4;ce||Xs(3),c+=ce&15;var B=tue[Se];if(Se>3){var ee=cV[Se];B+=cC(t,c)&(1<<ee)-1,c+=ee}if(c>g){o&&Xs(0);break}i&&a(l+131072);for(var we=l+X;l<we;l+=4)e[l]=e[l-B],e[l+1]=e[l+1-B],e[l+2]=e[l+2-B],e[l+3]=e[l+3-B];l=we}}r.l=f,r.p=F,r.b=l,r.f=s,f&&(s=1,r.m=d,r.d=u,r.n=h)}while(!s);return l==e.length?e:oue(e,0,l)},sue=new Aa(0),cue=function(t){(t[0]!=31||t[1]!=139||t[2]!=8)&&Xs(6,"invalid gzip data");var e=t[3],r=10;e&4&&(r+=t[10]|(t[11]<<8)+2);for(var n=(e>>3&1)+(e>>4&1);n>0;n-=!t[r++]);return r+(e&2)},lue=function(t){var e=t.length;return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0},uue=function(t){((t[0]&15)!=8||t[0]>>>4>7||(t[0]<<8|t[1])%31)&&Xs(6,"invalid zlib data"),t[1]&32&&Xs(6,"invalid zlib data: preset dictionaries not supported")};function fue(t,e){return lE(t,e)}function due(t,e){return lE(t.subarray(cue(t),-8),new Aa(lue(t)))}function hue(t,e){return lE((uue(t),t.subarray(2,-4)),e)}function gue(t,e){return t[0]==31&&t[1]==139&&t[2]==8?due(t):(t[0]&15)!=8||t[0]>>4>7||(t[0]<<8|t[1])%31?fue(t,e):hue(t,e)}var pue=typeof TextDecoder<"u"&&new TextDecoder,mue=0;try{pue.decode(sue,{stream:!0}),mue=1}catch{}const Pa=[];Pa[45]=62;Pa[95]=63;const _0="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let t=0;t<_0.length;t++)Pa[_0.charCodeAt(t)]=t;function Ac(t){return Pa[t.charCodeAt(0)]!==void 0}function vue(t){const e=t.length,r=[];let n=null;for(let i=0;i<e;i++)Ac(t[i])?(n||(n={start:i,count:0}),n.count++,n.end=i):t[i]==="="&&n&&(r.push(n),n=null);return n&&r.push(n),r}function yue(t,e,r,n){const{start:i,count:o}=e,a=o%4,s=Math.floor(o/4);let c=i,l=null,f=r;for(let u=0;u<s;u++){for(;!Ac(t[c]);)c++;for(l=Pa[t.charCodeAt(c++)]<<18;!Ac(t[c]);)c++;for(l|=Pa[t.charCodeAt(c++)]<<12;!Ac(t[c]);)c++;for(l|=Pa[t.charCodeAt(c++)]<<6;!Ac(t[c]);)c++;l|=Pa[t.charCodeAt(c++)],n[f++]=l>>16&255,n[f++]=l>>8&255,n[f++]=l&255}switch(a){case 3:for(;!Ac(t[c]);)c++;for(l=Pa[t.charCodeAt(c++)]<<10;!Ac(t[c]);)c++;for(l|=Pa[t.charCodeAt(c++)]<<4;!Ac(t[c]);)c++;l|=Pa[t.charCodeAt(c++)]>>2,n[f++]=l>>8&255,n[f++]=l&255;break;case 2:for(;!Ac(t[c]);)c++;for(l=Pa[t.charCodeAt(c++)]<<2;!Ac(t[c]);)c++;l|=Pa[t.charCodeAt(c++)]>>4,n[f++]=l&255;break;case 1:throw new Error("BASE64: remain 1 should not happen")}return f}function wue(t){const e=vue(t),r=e[e.length-1].end+1,n=(4-r%4)%4,i=(r+n)*3/4-n,o=new ArrayBuffer(i),a=new Uint8Array(o);let s=0;for(let c=0;c<e.length;c++)s+=yue(t,e[c],s,a),s+=(4-e[c].count%4)%4;return o}function g9(t,e,r){const n=(t<<16)+(e<<8)+r;return _0[n>>18]+_0[n>>12&63]+_0[n>>6&63]+_0[n&63]}function xue(t){const e=new Uint8Array(t),r=t.byteLength%3,n=t.byteLength-r,i=Array(n/3);for(let o=0;o<i.length;o++){const a=o*3;i[o]=g9(e[a],e[a+1],e[a+2])}if(r>0){const o=g9(e[n],e[n+1]||0,e[n+2]||0);r===1?i.push(`${o.substr(0,2)}==`):r===2&&i.push(`${o.substr(0,3)}=`)}return i.join("")}var uE={toArrayBuffer:wue,fromArrayBuffer:xue};function Cue(t,e){e.classHierarchy.push("vtkStringArray"),t.getComponent=function(r){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return e.values[r*e.numberOfComponents+n]},t.setComponent=(r,n,i)=>{i!==e.values[r*e.numberOfComponents+n]&&(e.values[r*e.numberOfComponents+n]=i,t.modified())},t.getData=()=>e.values,t.getTuple=function(r){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];const i=e.numberOfComponents||1;n.length&&(n.length=i);const o=r*i;for(let a=0;a<i;a++)n[a]=e.values[o+a];return n},t.getTupleLocation=function(){return(arguments.length>0&&arguments[0]!==void 0?arguments[0]:1)*e.numberOfComponents},t.getNumberOfComponents=()=>e.numberOfComponents,t.getNumberOfValues=()=>e.values.length,t.getNumberOfTuples=()=>e.values.length/e.numberOfComponents,t.getDataType=()=>e.dataType,t.newClone=()=>gV({name:e.name,numberOfComponents:e.numberOfComponents,empty:!0}),t.getName=()=>(e.name||t.setName(`vtkStringArray${t.getMTime()}`),e.name),t.setData=(r,n)=>{e.values=r,e.size=r.length,n&&(e.numberOfComponents=n),e.size%e.numberOfComponents!==0&&(e.numberOfComponents=1),t.modified()}}const Sue={name:"",numberOfComponents:1,size:0,dataType:"string"};function hV(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(Object.assign(e,Sue,r),!e.empty&&!e.values&&!e.size)throw new TypeError("Cannot create vtkStringArray object without: size > 0, values");e.values?Array.isArray(e.values)&&(e.values=[...e.values]):e.values=[],e.values&&(e.size=e.values.length),Z.obj(t,e),Z.set(t,e,["name"]),Cue(t,e)}const gV=Z.newInstance(hV,"vtkStringArray");var Tue={newInstance:gV,extend:hV};function _ue(t,e){return[...t.getElementsByTagName(e)]}function p9(t,e){return _ue(t,e)[0]}function Eue(t){return Jle.create(t)}function bue(t){const e=/^\s*<AppendedData\s+encoding="raw">\s*_/m,r=/\n\s*<\/AppendedData>/m;return y1.extractBinary(t,e,r)}const Bu={Int8:Int8Array,UInt8:Uint8Array,Int16:Int16Array,UInt16:Uint16Array,Int32:Int32Array,UInt32:Uint32Array,Int64:Int32Array,UInt64:Uint32Array,Float32:Float32Array,Float64:Float64Array},w1={Int8:1,UInt8:1,Int16:2,UInt16:2,Int32:4,UInt32:4,Int64:8,UInt64:8,Float32:4,Float64:8};function RS(t){const e=t.length-1;return t.filter((r,n)=>n<e&&n%2===0)}function LS(t,e,r){if(!["UInt64","UInt32"].includes(r))throw new Error(`Cannot handle a header type of ${r}`);let n=Bu[r],i=Bu[e],o=!1;r==="UInt64"&&(n=Bu.UInt32),/^U?Int64$/.test(e)&&(o=!0,i=Bu[e.replace("64","32")]);const{byteOffset:a}=t,s=w1[e],c=w1[r];let l;a%c===0?l=new n(t.buffer,a,1):l=new n(t.buffer.slice(a,a+c));const f=Number(l[0]);let u,d=f/s;o&&(d*=2);const h=a+c;return h%s===0?u=new i(t.buffer,h,d):u=new i(t.buffer.slice(h,h+f)),o&&(u=RS(u)),u}function Due(t,e){if(e==="UInt64"){let l=new Uint32Array(t.buffer,0,6);const f=l[0],u=l[2],d=l[4],h=[8,f,u,d];l=new Uint32Array(t.buffer,3*8,f*2);for(let g=0;g<f;g++)h.push(l[g*2]);return h}let r=new Uint32Array(t.buffer,0,3);const n=4,i=r[0],o=r[1],a=r[2],s=[n,i,o,a];r=new Uint32Array(t.buffer,3*4,i);for(let c=0;c<i;c++)s.push(r[c]);return s}function Iue(t,e){const[r]=t;return(t.length-1)*r}function Oue(t,e){const r=gue(t);e.uint8.set(r,e.offset),e.offset+=r.length}function fE(t,e){const r=Due(t,e),n=r[1],i=r[2],o=r[3];let a=0;n>0&&(o===0?a=n*i:a=(n-1)*i+o);const s=new ArrayBuffer(a),c={offset:0,uint8:new Uint8Array(s)};let l=Iue(r);for(;l<t.length&&t[l]!==120;)l++;for(let f=0;f<n;f++){const u=r[4+f],d=new Uint8Array(t.buffer,l,u);Oue(d,c),l+=u}return c.uint8}function x1(t,e,r,n,i,o){const a=e.getAttribute("type"),s=e.getAttribute("Name"),c=e.getAttribute("format"),l=Number(e.getAttribute("NumberOfComponents")||"1");let f=null;if(c==="ascii"){f=new Bu[a](t*l);let u=0;e.firstChild.nodeValue.split(/[\\t \\n]+/).forEach(d=>{d.trim().length&&(f[u++]=Number(d))})}else if(c==="binary"){const u=new Uint8Array(uE.toArrayBuffer(e.firstChild.nodeValue.trim()));if(r==="vtkZLibDataCompressor"){const d=fE(u,i);f=new Bu[a](d.buffer),/^U?Int64$/.test(a)&&(f=RS(f))}else f=new Bu[a](u.buffer,w1[i]),a.indexOf("Int64")!==-1&&(f=RS(f))}else if(c==="appended"){const u=Number(e.getAttribute("offset"));f=LS(new Uint8Array(o,u),a,i)}else console.error("Format not supported",c);return{name:s,values:f,numberOfComponents:l}}function lC(t){return new TextDecoder().decode(t).split("\0").slice(0,-1)}function Mue(t,e,r,n,i){const o=t.getAttribute("Name"),a=t.getAttribute("format"),s=Number(t.getAttribute("NumberOfComponents")||"1"),l=Number(t.getAttribute("NumberOfTuples")||"1")*s,f=[];if(a==="ascii"){const u=t.firstChild.nodeValue.trim().split(/\s+/);let d=0;const h=[];for(;f.length<l;){const g=Number(u[d++]);g===0?(f.push(h.join("")),h.length=0):h.push(String.fromCharCode(g))}}else if(a==="binary"){const u=new Uint8Array(uE.toArrayBuffer(t.firstChild.nodeValue.trim()));if(e==="vtkZLibDataCompressor"){const d=fE(u,n);f.push(...lC(d))}else{const d=LS(u,"UInt8",n);f.push(...lC(d))}}else if(a==="appended"){const u=Number(t.getAttribute("offset")),d=LS(new Uint8Array(i,u),"UInt8",n);f.push(...lC(d))}else Z.vtkErrorMacro(`Format not supported: ${a}`);return{name:o,values:f,numberOfComponents:s}}function Pue(t,e,r,n,i,o){const a={},s=e.getElementsByTagName("DataArray");for(let g=0;g<s.length;g++){const p=s[g];a[p.getAttribute("Name")]=p}const c=x1(t,a.offsets,r,n,i,o).values,l=c[c.length-1],f=x1(l,a.connectivity,r,n,i,o).values,u=new Uint32Array(t+l);let d=0,h=0;return c.forEach(g=>{const p=g-h;u[d++]=p;for(let v=0;v<p;v++)u[d++]=f[h+v];h=g}),u}function Rue(t,e,r,n,i,o,a){if(e){const s=["Scalars","Vectors","Normals","Tensors","TCoords"],c={};s.forEach(u=>{const d=e.getAttribute(u);d&&(c[d]=r[`set${u}`])});const l=e.getElementsByTagName("DataArray"),f=l.length;for(let u=0;u<f;u++){const d=l[u],h=bt.newInstance(x1(t,d,n,i,o,a)),g=h.getName();(c[g]||r.addArray)(h)}}}function Lue(t,e,r,n,i){const o=[...t.getElementsByTagName("DataArray")].map(s=>bt.newInstance(x1(Number(s.getAttribute("NumberOfTuples")),s,e,r,n,i))),a=[...t.getElementsByTagName("Array")].filter(s=>s.getAttribute("type")==="String").map(s=>Tue.newInstance(Mue(s,e,r,n,i)));return[...o,...a]}function Aue(t,e){e.classHierarchy.push("vtkXMLReader"),e.dataAccessHelper||(e.dataAccessHelper=hm.get("http"));function r(n){let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return e.dataAccessHelper.fetchBinary(n,i)}t.setUrl=function(n){let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};e.url=n;const o=n.split("/");return o.pop(),e.baseURL=o.join("/"),t.loadData(i)},t.loadData=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return r(e.url,n).then(t.parseAsArrayBuffer)},t.parseAsArrayBuffer=n=>{if(!n)return!1;if(n!==e.rawDataBuffer)t.modified();else return!0;const{text:i,binaryBuffer:o}=bue(n);e.rawDataBuffer=n,e.binaryBuffer=o;const s=Eue(i).root(),c=s.node,l=c.getAttribute("type"),f=c.getAttribute("compressor"),u=c.getAttribute("byte_order"),d=c.getAttribute("header_type")||"UInt32";if(f&&f!=="vtkZLibDataCompressor")return console.error("Invalid compressor",f),!1;if(u&&u!=="LittleEndian")return console.error("Only LittleEndian encoding is supported"),!1;if(l!==e.dataType)return console.error("Invalid data type",l,"expecting",e.dataType),!1;if(p9(c,"AppendedData")){const p=p9(c,"AppendedData"),v=p.getAttribute("encoding"),y=s.filter(T=>{const{node:_}=T;return _.nodeType===Node.ELEMENT_NODE&&_.getAttribute("format")==="appended"&&_.hasAttribute("offset")},!1,!0).map(T=>({node:T.node,offset:Number(T.node.getAttribute("offset"))}));y.sort((T,_)=>T.offset-_.offset);let m=e.binaryBuffer;v==="base64"&&(m=p.textContent.trim().substr(1));const w=[];for(let T=0;T<y.length;++T){const _=y[T].offset;let E=0;T===y.length-1?E=m.length||m.byteLength:E=y[T+1].offset,v==="base64"?w.push(new Uint8Array(uE.toArrayBuffer(m.substring(_,E)))):w.push(new Uint8Array(m.slice(_,E)))}if(f==="vtkZLibDataCompressor")for(let T=0;T<w.length;++T){const _=w[T],E=fE(_,d),b=new Uint8Array(E.length+w1[d]);new Bu[d](b.buffer,0,1)[0]=E.length,b.set(E,w1[d]),w[T]=b}const x=w.reduce((T,_)=>T+_.length,0),C=new ArrayBuffer(x),S=new Uint8Array(C);for(let T=0,_=0;T<w.length;++T)y[T].node.setAttribute("offset",_),S.set(w[T],_),_+=w[T].length;if(e.binaryBuffer=C,!e.binaryBuffer)return console.error("Processing appended data format: requires binaryBuffer to parse"),!1}t.parseXML(c,l,f,u,d);const g=c.getElementsByTagName(l)[0].getElementsByTagName("FieldData")[0];if(g){const p=Lue(g,f,u,d,e.binaryBuffer);for(let v=0;v<e.output.length;v++){const y=e.output[v].getFieldData();for(let m=0;m<p.length;m++)y.addArray(p[m])}}return!0},t.requestData=(n,i)=>{t.parseAsArrayBuffer(e.rawDataBuffer)}}const Nue={};function kue(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Nue,r),Z.obj(t,e),Z.get(t,e,["url","baseURL"]),Z.setGet(t,e,["dataAccessHelper"]),Z.algo(t,e,0,1),Aue(t,e)}var C1={extend:kue,processDataArray:x1,processFieldData:Rue,processCells:Pue};function Vue(t,e,r,n,i,o,a){const s=Number(r.getAttribute(`NumberOf${e}`));if(s>0){const c=r.getElementsByTagName(e)[0].getElementsByTagName("DataArray")[0],{values:l,numberOfComponents:f}=C1.processDataArray(s,c,n,i,o,a);t[`get${e}`]().setData(l,f)}return s}function Fue(t,e,r,n,i,o,a){const s=Number(r.getAttribute(`NumberOf${e}`));if(s>0){const c=C1.processCells(s,r.getElementsByTagName(e)[0],n,i,o,a);t[`get${e}`]().setData(c)}return s}function Uue(t,e){e.classHierarchy.push("vtkXMLPolyDataReader"),t.parseXML=(r,n,i,o,a)=>{const c=r.getElementsByTagName(e.dataType)[0].getElementsByTagName("Piece"),l=c.length;for(let f=0;f<l;f++){const u=Er.newInstance(),d=c[f],h=Vue(u,"Points",d,i,o,a,e.binaryBuffer);let g=0;["Verts","Lines","Strips","Polys"].forEach(p=>{g+=Fue(u,p,d,i,o,a,e.binaryBuffer)}),C1.processFieldData(h,d.getElementsByTagName("PointData")[0],u.getPointData(),i,o,a,e.binaryBuffer),C1.processFieldData(g,d.getElementsByTagName("CellData")[0],u.getCellData(),i,o,a,e.binaryBuffer),e.output[f]=u}}}const Bue={dataType:"PolyData"};function pV(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Bue,r),C1.extend(t,e,r),Uue(t,e)}const Gue=Z.newInstance(pV,"vtkXMLPolyDataReader");var mV={newInstance:Gue,extend:pV};const nn={};function uC(t,e,r,n,i){for(let o=0;o<i;o++)r[n+o]=t[e+o]}function Wue(t){nn.splitOn=t,nn.pieces=[],nn.v=[],nn.vt=[],nn.vn=[],nn.f=[[]],nn.size=0}function zue(t){const e=t.split("/").map(o=>Number(o));let r=e[0]-1;r=r<0?r+1+nn.v.length/3:r;let n=e[1]?e[1]-1:r;n=n<0?n+1+nn.vt.length/2:n;let i=e[2]?e[2]-1:r;return i=i<0?i+1+nn.vn.length/3:i,[r,n,i]}function $ue(t){if(t[0]==="#")return;const e=t.split(/[ \t]+/);if(e[0]===nn.splitOn)e.shift(),nn.pieces.push(e.join(" ").trim()),nn.f.push([]),nn.size++;else if(e[0]==="v")nn.v.push(Number(e[1])),nn.v.push(Number(e[2])),nn.v.push(Number(e[3]));else if(e[0]==="vt")nn.vt.push(Number(e[1])),nn.vt.push(Number(e[2]));else if(e[0]==="vn")nn.vn.push(Number(e[1])),nn.vn.push(Number(e[2])),nn.vn.push(Number(e[3]));else if(e[0]==="f"){nn.size===0&&nn.size++;const r=nn.f[nn.size-1];e.shift();const n=e.filter(o=>o.length>0&&o!=="\r"),i=n.length;r.push(i);for(let o=0;o<i;o++)r.push(zue(n[o]))}}function jue(t){const e=!!nn.vt.length,r=!!nn.vn.length;if(t.splitMode){t.numberOfOutputs=nn.size;for(let n=0;n<nn.size;n++){const i=nn.f[n],o=i.length,a=nn.v.length/3,s={};let c;if(t.trackDuplicates){const v=[];let y=0;for(let w=0;w<o;){const x=i[w++];for(let C=0;C<x;C++){const[S,T,_]=i[w++],E=`${S}/${T}/${_}`;s[E]===void 0&&(v[S]===void 0?v[S]=[E]:(v[S].push(E),++y),s[E]=S)}}c=new Uint16Array(a+y);let m=0;for(let w=0;w<v.length;++w){const x=v[w]?v[w].length:0;c[w]=x>1?a+m:w;for(let C=1;C<x;++C){const S=a+m++;c[S]=w,s[v[w][C]]=S}}}const l={},f=Er.newInstance({name:nn.pieces[n]}),u=[],d=[],h=[],g=[];let p=0;for(;p<o;){const v=i[p];g.push(v);for(let y=0;y<v;y++){const[m,w,x]=i[p+y+1],C=`${m}/${w}/${x}`;if(l[C]===void 0){const S=t.trackDuplicates?s[C]:u.length/3;l[C]=S,uC(nn.v,m*3,u,S*3,3),e&&uC(nn.vt,w*2,d,S*2,2),r&&uC(nn.vn,x*3,h,S*3,3)}g.push(l[C])}p+=v+1}if(f.getPoints().setData(Float32Array.from(u),3),t.trackDuplicates){const v=bt.newInstance({name:"Duplicates",values:c});f.getPointData().addArray(v)}if(f.getPolys().setData(Uint32Array.from(g)),e){const v=bt.newInstance({numberOfComponents:2,values:Float32Array.from(d),name:"TextureCoordinates"});f.getPointData().setTCoords(v)}if(r){const v=bt.newInstance({numberOfComponents:3,values:Float32Array.from(h),name:"Normals"});f.getPointData().setNormals(v)}t.output[n]=f}}else{t.numberOfOutputs=1;const n=Er.newInstance();if(n.getPoints().setData(Float32Array.from(nn.v),3),e&&nn.v.length/3===nn.vt.length/2){const c=bt.newInstance({numberOfComponents:2,values:Float32Array.from(nn.vt),name:"TextureCoordinates"});n.getPointData().setTCoords(c)}if(r&&nn.v.length===nn.vn.length){const c=bt.newInstance({numberOfComponents:3,values:Float32Array.from(nn.vn),name:"Normals"});n.getPointData().setNormals(c)}const i=[],o=nn.f[0],a=o.length;let s=0;for(;s<a;){const c=o[s];i.push(c);for(let l=0;l<c;l++){const[f]=o[s+l+1];i.push(f)}s+=c+1}n.getPolys().setData(Uint32Array.from(i)),t.output[0]=n}}function Hue(t,e){const r=[],n=t.getPointData().getArrayByName("Duplicates");if(n==null)return r;const i=n.getData(),o=Math.min(e,i[e]);r.push(o);let a=i[o];if(a!==o)for(;a<i.length&&i[a]===o;)r.push(a++);return r}const Kue={getPointDuplicateIds:Hue};function que(t,e){e.classHierarchy.push("vtkOBJReader"),e.dataAccessHelper||(e.dataAccessHelper=hm.get("http"));function r(n){let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return e.dataAccessHelper.fetchText(t,n,i)}t.setUrl=function(n){let i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(n.indexOf(".obj")===-1&&!i.fullpath)e.baseURL=n,e.url=`${n}/index.obj`;else{e.url=n;const o=n.split("/");o.pop(),e.baseURL=o.join("/")}return t.loadData(i)},t.loadData=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};return r(e.url,n).then(i=>t.isDeleted()?!1:t.parseAsText(i))},t.parseAsText=n=>(n&&(n!==e.parseData&&t.modified(),e.parseData=n,e.numberOfOutputs=0,Wue(e.splitMode),n.split(`
|
||
`).forEach($ue),jue(e)),!0),t.requestData=(n,i)=>{t.parseAsText(e.parseData)},t.isBusy=()=>!!e.requestCount,t.getNumberOfOutputPorts=()=>e.numberOfOutputs}const Xue={numberOfOutputs:1,requestCount:0,splitMode:null,trackDuplicates:!1};function vV(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Xue,r),Z.obj(t,e),Z.get(t,e,["url","baseURL"]),Z.setGet(t,e,["dataAccessHelper","splitMode","trackDuplicates"]),Z.algo(t,e,0,1),Z.event(t,e,"busy"),que(t,e)}const Yue=Z.newInstance(vV,"vtkOBJReader");var Jue={newInstance:Yue,extend:vV,...Kue};function Zue(t,e){e.classHierarchy.push("vtkPolyDataNormals"),t.vtkPolyDataNormalsExecute=(r,n,i)=>{if(!i)return null;const o=new Float32Array(i.length),a=new Float32Array(3*r);let s=0,c=0;const l=n.length,f=[0,0,0],u=[0,0,0];for(let d=0;d<l;d+=c+1)if(c=n[d],!(c<3)){for(let h=1;h<=3;++h)f[h-1]=3*n[d+h];if(hN.computeNormal(i.slice(f[0],f[0]+3),i.slice(f[1],f[1]+3),i.slice(f[2],f[2]+3),u),a[s++]=u[0],a[s++]=u[1],a[s++]=u[2],e.computePointNormals)for(let h=1;h<=c;++h){let g=3*n[d+h];o[g]+=u[0],o[++g]+=u[1],o[++g]+=u[2]}}if(e.computePointNormals){const d=[0,0,0];for(let h=0;h<i.length;)d[0]=o[h],d[1]=o[h+1],d[2]=o[h+2],Gt.normalize(d),o[h++]=d[0],o[h++]=d[1],o[h++]=d[2]}return[a,o]},t.requestData=(r,n)=>{if(!t.getNumberOfInputPorts())return;const o=r[0];if(!o)return;const a=Er.newInstance();a.setPoints(o.getPoints()),a.setVerts(o.getVerts()),a.setLines(o.getLines()),a.setPolys(o.getPolys()),a.setStrips(o.getStrips()),a.getPointData().passData(o.getPointData()),a.getCellData().passData(o.getCellData()),a.getFieldData().passData(o.getFieldData());const[s,c]=t.vtkPolyDataNormalsExecute(o.getNumberOfPolys(),o.getPolys().getData(),o.getPoints().getData());if(e.computePointNormals){const l=bt.newInstance({numberOfComponents:3,name:"Normals",values:c});a.getPointData().setNormals(l)}if(e.computeCellNormals){const l=bt.newInstance({numberOfComponents:3,name:"Normals",values:s});a.getCellData().setNormals(l)}n[0]=a}}function Que(t){return{computeCellNormals:!1,computePointNormals:!0,...t}}function yV(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Que(r)),Z.obj(t,e),Z.algo(t,e,1,1),Z.setGet(t,e,["computeCellNormals","computePointNormals"]),Zue(t,e)}const efe=Z.newInstance(yV,"vtkPolyDataNormals");var tfe={newInstance:efe,extend:yV};class nfe{constructor(e){this._color=[255,255,255],this._actors=[],this.id=e.id,this._color=e.color??this._color,this._format=e.format;const r=new TextDecoder,n=tfe.newInstance(),i=o=>{const a=uc.newInstance();a.setMapper(o);const s=Fd.newInstance();return s.setColor(this._color[0]/255,this._color[1]/255,this._color[2]/255),a.setProperty(s),a};if(this._format===ka.PLY){const o=la.newInstance(),a=$le.newInstance();a.parseAsArrayBuffer(e.arrayBuffer),o.setInputConnection(a.getOutputPort()),this._actors.push(i(o))}else if(this._format===ka.STL){const o=la.newInstance(),a=Yle.newInstance();a.parseAsArrayBuffer(e.arrayBuffer),n.setInputConnection(a.getOutputPort()),o.setInputConnection(n.getOutputPort()),this._actors.push(i(o))}else if(this._format===ka.OBJ){const o=Jue.newInstance({splitMode:e.materialUrl?"usemtl":null});o.parseAsText(r.decode(e.arrayBuffer));const a=o.getNumberOfOutputPorts();for(let s=0;s<a;s++){const c=o.getOutputData(s),l=la.newInstance();l.setInputData(c),this._actors.push(i(l))}}else if(this._format===ka.VTP){const o=la.newInstance(),a=mV.newInstance();a.parseAsArrayBuffer(e.arrayBuffer),o.setInputConnection(a.getOutputPort()),this._actors.push(i(o))}this.sizeInBytes=this._getSizeInBytes()}_getSizeInBytes(){let e=0;for(let r=0;r<this._actors.length;r++){const o=this._actors[r].getMapper().getInputData(),a=o.getPoints(),s=o.getPolys(),c=a.getData().length,l=s.getData().length;e+=c*4+l*4}return e}get defaultActor(){return this._actors[0]}get actors(){return this._actors}get color(){return this._color}get format(){return this._format}}var js;(function(t){t[t.None=0]="None",t[t.Capture=1]="Capture",t[t.Bubble=2]="Bubble"})(js||(js={}));class Cw{constructor(e){this._eventListeners=new Map,this._children=new Map,this._target=e}get isEmpty(){return this._eventListeners.size===0&&this._children.size===0}addEventListener(e,r,n){const i=e.indexOf(".");if(i!==-1){const a=e.substring(0,i);let s=this._children.get(a);s||(s=new Cw(this._target),this._children.set(a,s)),e=e.substring(i+1),s.addEventListener(e,r,n)}else this._addEventListener(e,r,n)}removeEventListener(e,r,n){const i=e.indexOf(".");if(i!==-1){const a=e.substring(0,i),s=this._children.get(a);if(!s)return;e=e.substring(i+1),s.removeEventListener(e,r,n),s.isEmpty&&this._children.delete(a)}else this._removeEventListener(e,r,n)}reset(){Array.from(this._children.entries()).forEach(([e,r])=>{if(r.reset(),r.isEmpty)this._children.delete(e);else throw new Error("Child is not empty and cannot be removed")}),this._unregisterAllEvents()}_addEventListener(e,r,n){let i=this._eventListeners.get(e);i||(i=new Map,this._eventListeners.set(e,i));const a=(n==null?void 0:n.capture)??!1?js.Capture:js.Bubble,s=i.get(r)??js.None;if(s&a){console.warn("A listener is already registered for this phase");return}i.set(r,s|a),this._target.addEventListener(e,r,n)}_removeEventListener(e,r,n){const o=(n==null?void 0:n.capture)??!1?js.Capture:js.Bubble,a=this._eventListeners.get(e);if(!a)return;(r?[r]:Array.from(a.keys())).forEach(c=>{const l=a.get(c)??js.None;if(!!!(l&o))return;this._target.removeEventListener(e,c,n);const u=l^o;u===js.None?a.delete(c):a.set(c,u)}),a.size||this._eventListeners.delete(e)}_unregisterAllListeners(e,r){Array.from(r.entries()).forEach(([n,i])=>{const o=js.Capture;for(let a=o;i;a<<=1){if(!(i&a))continue;const s=a===js.Capture;this.removeEventListener(e,n,{capture:s}),i^=a}})}_unregisterAllEvents(){Array.from(this._eventListeners.entries()).forEach(([e,r])=>{this._unregisterAllListeners(e,r)})}}class wV{constructor(){this._targetsEventListeners=new Map}addEventListener(e,r,n,i){let o=this._targetsEventListeners.get(e);o||(o=new Cw(e),this._targetsEventListeners.set(e,o)),o.addEventListener(r,n,i)}removeEventListener(e,r,n,i){const o=this._targetsEventListeners.get(e);o&&(o.removeEventListener(r,n,i),o.isEmpty&&this._targetsEventListeners.delete(e))}reset(){Array.from(this._targetsEventListeners.entries()).forEach(([e,r])=>{r.reset(),this._targetsEventListeners.delete(e)})}}const rfe=Object.freeze(Object.defineProperty({__proto__:null,MultiTargetEventListenerManager:wV,TargetEventListeners:Cw},Symbol.toStringTag,{value:"Module"}));function ife(t,e){const r=t.getSize();for(let n=0;n<r;n++){const i=[];t.getNodeValue(n,i),i[1]=i[1]*e,i[2]=i[2]*e,i[3]=i[3]*e,t.setNodeValue(n,i)}}function dE(t){let e=t[0],r=t[0],n;const i=t.length;for(let o=1;o<i;o++)n=t[o],e=Math.min(e,n),r=Math.max(r,n);return{min:e,max:r}}const ofe=Symbol("LastRuntimeId"),afe={},sfe=4294967295,cfe="-";function xV(t,e,r){return lfe(t!==null&&typeof t=="object"?t:afe,ofe,(typeof r=="number"&&r>0?r:sfe)>>>0).join(typeof e=="string"?e:cfe)}function lfe(t,e,r){let n=t[e];n instanceof Array||(n=[0],Object.defineProperty(t,e,{value:n}));for(let i=!0,o=0;i&&o<n.length;++o){let a=n[o]|0;a<r?(i=!1,a=a+1):(a=0,o+1===n.length&&n.push(0)),n[o]=a}return n}const m9={},ufe={add:(t,e)=>{const r=_r(t);m9[r]=e},get:(t,e)=>{if(t==="calibratedPixelSpacing"){const r=_r(e);return m9[r]}}};function ep(t,e,r=1e-5){return Math.abs(t[0]+e[0])<r&&Math.abs(t[1]+e[1])<r&&Math.abs(t[2]+e[2])<r}function tr(t,e){return!(t[0]<0||t[0]>=e[0]||t[1]<0||t[1]>=e[1]||t[2]<0||t[2]>=e[2])}function ffe(t,e){let r;e?r=[Nr(e)]:r=Po();const n=[];return r.forEach(i=>{const o=t.getActors(),a=i.getVolumeViewports();for(const s of a){const c=s.getActors();if(c.length!==o.length)continue;o.every(({uid:f})=>c.find(u=>f===u.uid))&&n.push(s)}}),n}const CV=t=>t.preScale.scaled&&t.preScale.scalingParameters.suvbw;function SV(t,e,r=void 0,n="_thumbnails",i={displayArea:{imageArea:[1,1]}}){if(!t||!(t instanceof HTMLCanvasElement))throw new Error("canvas element is required");const o=!e.imageId,a=!o&&e,s=o&&e,l=`renderGPUViewport-${a.imageId||s.volumeId}`,f=document.createElement("div"),u=window.devicePixelRatio||1;i.displayArea||(i.displayArea={imageArea:[1,1]});const d=t.width,h=t.height;f.style.width=`${d/u+Q0}px`,f.style.height=`${h/u+Q0}px`,f.style.visibility="hidden",f.style.position="absolute",document.body.appendChild(f);const g=l.split(":").join("-");f.setAttribute("viewport-id-for-remove",g);const p=Bc(f),v=Nr(n)||new aE(n);let y=v.getViewport(l);if(!y){const m={viewportId:l,type:o?ir.ORTHOGRAPHIC:ir.STACK,element:f,defaultOptions:{...i,suppressEvents:!0}};v.enableElement(m),y=v.getViewport(l)}return new Promise(m=>{let w=!1,{viewReference:x}=i;const C=S=>{if(w)return;if(x){const O=x;x=null,y.setViewReference(O),y.render();return}t.getContext("2d").drawImage(p,0,0,p.width,p.height,0,0,t.width,t.height);const _=y.canvasToWorld([0,0]),E=y.canvasToWorld([p.width/u,0]),b=y.canvasToWorld([0,p.height/u]),D=hn([0,0,0],y.canvasToWorld([1/u,0]),_),I=hn([0,0,0],y.canvasToWorld([0,1/u]),_),P=1;w=!0,f.removeEventListener(et.IMAGE_RENDERED,C),setTimeout(()=>{v.disableElement(l),document.querySelectorAll(`[viewport-id-for-remove="${g}"]`).forEach(L=>{L.remove()})},0),m({origin:_,bottomLeft:b,topRight:E,thicknessMm:P,rightVector:D,downVector:I})};f.addEventListener(et.IMAGE_RENDERED,C),o?y.setVolumes([s],!1,!0):y.renderImageObject(e),y.resetCamera(),r==="PT"&&!CV(a)&&y.setProperties({voiRange:{lower:a.minPixelValue,upper:a.maxPixelValue}}),y.render()})}function TV(t,e,r,n,i){if(e.volumeId)throw new Error("Unsupported volume rendering for CPU");const a=e,s=jk(t,a,r),c={canvas:t,viewport:s,image:a,renderingTools:{}};c.transform=v1(c);const l=!0;return new Promise((f,u)=>{Wk(c,l),f(null)})}function dfe(t){const{canvas:e,imageId:r,viewReference:n,requestType:i=Qt.Thumbnail,priority:o=-5,renderingEngineId:a="_thumbnails",useCPURendering:s=!1,thumbnail:c=!1,imageAspect:l=!1,viewportOptions:f}=t,u=n==null?void 0:n.volumeId,d=u&&!r,h=n&&f?{...f,viewReference:n}:f,g=s?TV:SV;return new Promise((p,v)=>{function y(C,S){var b;const{modality:T}=ct("generalSeriesModule",S)||{},_=!d&&C,E=d&&C;_&&(_.isPreScaled=_.isPreScaled||((b=_.preScale)==null?void 0:b.scaled)),c&&(e.height=256,e.width=256),l&&_&&(e.width=_&&e.height*_.width/_.height),e.style.width=`${e.width/devicePixelRatio}px`,e.style.height=`${e.height/devicePixelRatio}px`,E&&s&&v(new Error("CPU rendering of volume not supported")),g(e,C,T,a,h).then(p)}function m(C,S){console.error(C,S),v(C)}function w(C,S,T){return ws(C,T).then(_=>{y.call(this,_,C)},_=>{m.call(this,_,C)})}const x={useRGBA:!!s,requestType:i};if(u){const C=$e.getVolume(u);C||v(new Error(`Volume id ${u} not found in cache`));const S=C.imageIds[0];y(C,S)}else _i.addRequest(w.bind(null,r,null,x),i,{imageId:r},o)})}const v9={HISTORY_UNDO:"CORNERSTONE_TOOLS_HISTORY_UNDO",HISTORY_REDO:"CORNERSTONE_TOOLS_HISTORY_REDO"};class _V{constructor(e="Tools",r=50){this.position=-1,this.redoAvailable=0,this.undoAvailable=0,this.ring=new Array,this.label=e,this._size=r}get size(){return this._size}set size(e){this.ring=new Array(e),this._size=e,this.position=-1,this.redoAvailable=0,this.undoAvailable=0}undo(e=1){for(;e>0&&this.undoAvailable>0;){const r=this.ring[this.position];r.restoreMemo(!0),r.id&&Ze.dispatchEvent(new CustomEvent(v9.HISTORY_UNDO,{detail:{isUndo:!0,id:r.id,operationType:r.operationType||"annotation",memo:r}})),e--,this.redoAvailable++,this.undoAvailable--,this.position=(this.position-1+this.size)%this.size}}undoIf(e){return this.undoAvailable>0&&e(this.ring[this.position])?(this.undo(),!0):!1}redo(e=1){for(;e>0&&this.redoAvailable>0;){const r=(this.position+1)%this.size,n=this.ring[r];n.restoreMemo(!1),n.id&&Ze.dispatchEvent(new CustomEvent(v9.HISTORY_REDO,{detail:{isUndo:!1,id:n.id,operationType:n.operationType||"annotation",memo:n}})),e--,this.position=r,this.undoAvailable++,this.redoAvailable--}}push(e){var n;if(!e)return;const r=e.restoreMemo?e:(n=e.createMemo)==null?void 0:n.call(e);if(r)return this.redoAvailable=0,this.undoAvailable<this._size&&this.undoAvailable++,this.position=(this.position+1)%this._size,this.ring[this.position]=r,r}}const EV=new _V,hE=Object.freeze(Object.defineProperty({__proto__:null,DefaultHistoryMemo:EV,HistoryMemo:_V},Symbol.toStringTag,{value:"Module"}));function AS(t,e){const r=ct("imagePlaneModule",t);if(!r)throw new Error(`No imagePlaneModule found for imageId: ${t}`);const{columnCosines:n,rowCosines:i,imagePositionPatient:o}=r;let{columnPixelSpacing:a,rowPixelSpacing:s}=r;a||(a=1),s||(s=1);const c=Ke();dn(c,o,n,-a/2),dn(c,c,i,-s/2);const l=Ke();hn(l,e,c);const f=xt(l,i),u=xt(l,n);return[f/s,u/a]}function bV(t,e){const r=ct("imagePlaneModule",t);if(!r)throw new Error(`No imagePlaneModule found for imageId: ${t}`);const{columnCosines:n,rowCosines:i,imagePositionPatient:o}=r;let{columnPixelSpacing:a,rowPixelSpacing:s}=r;a||(a=1),s||(s=1);const c=Ke();return dn(c,o,i,s*(e[0]-.5)),dn(c,c,n,a*(e[1]-.5)),Array.from(c)}function $y(t){const e=Po(),r=[];return e.forEach(n=>{n.getViewports().forEach(o=>{o.hasImageURI(t)&&r.push(o)})}),r}function gE(t,e){const r=hfe(t,e);return r?r.index:null}function hfe(t,e){const r=e.getImageIds(),n=e.getCurrentImageIdIndex();if(r.length===0)return null;const i=c=>{const l=gfe(c);if(!l)return null;const f=Yc(l.planeNormal,l.imagePositionPatient);return m1(f,t)},o={distance:i(r[n])??1/0,index:n},a=r.slice(n+1);for(let c=0;c<a.length;c++){const l=a[c],f=i(l);if(f!==null)if(f<=o.distance)o.distance=f,o.index=c+n+1;else break}const s=r.slice(0,n);for(let c=s.length-1;c>=0;c--){const l=s[c],f=i(l);if(!(f===null||f===o.distance))if(f<o.distance)o.distance=f,o.index=c;else break}return o.distance===1/0?null:o}function gfe(t){const e=ct("imagePlaneModule",t);if(!e||!(e.rowCosines instanceof Array&&e.rowCosines.length===3)||!(e.columnCosines instanceof Array&&e.columnCosines.length===3)||!(e.imagePositionPatient instanceof Array&&e.imagePositionPatient.length===3))return null;const{rowCosines:r,columnCosines:n,imagePositionPatient:i}=e,o=Wn(Ke(),...r),a=Wn(Ke(),...n),s=Tn(Ke(),o,a);return{rowCosines:r,columnCosines:n,imagePositionPatient:i,planeNormal:s}}function pE(t){const{width:e,height:r}=t.getCanvas(),{sliceToIndexMatrix:n,indexToSliceMatrix:i}=t.getSliceViewInfo(),o=Ru(t,[0,0]),a=Ru(t,[e-1,0]),s=Ru(t,[0,r-1]),c=hn(Ke(),a,o),l=hn(Ke(),s,o),f=Tn(Ke(),c,l);Un(c,c),Un(l,l),Un(f,f);const u=Math.max(Math.abs(c[0]),Math.abs(c[1]),Math.abs(c[2])),d=Math.max(Math.abs(l[0]),Math.abs(l[1]),Math.abs(l[2]));if(!af(1,u)||!af(1,d))throw new Error("Livewire is not available for rotate/oblique viewports");const{voxelManager:h}=t.getImageData(),g=t.getSliceViewInfo(),p=h.getSliceData(g);return{width:g.width,height:g.height,scalarData:p,sliceToIndexMatrix:n,indexToSliceMatrix:i}}const Af={},S1={add:(t,e)=>{const[r,n]=t,i=`${r}_${n}`;Af[i]||(Af[i]={}),Af[i]=e},get:(t,e,r)=>{if(t!=="spatialRegistrationModule")return;const n=`${e}_${r}`;if(Af[n])return Af[n];const i=`${r}_${e}`;if(Af[i])return Ar(ma(),Af[i])}};zh(S1.get.bind(S1));const pfe=.05;function DV(t,e){const r=t.getSliceIndex(),n=e.getSliceIndex(),i=ct("imagePlaneModule",r.toString()),o=ct("imagePlaneModule",n.toString());if(!i||!o){console.log("Viewport spatial registration requires image plane module");return}const{imageOrientationPatient:a}=o;if(!i.imageOrientationPatient.every((d,h)=>Math.abs(d-a[h])<pfe)){console.log("Viewport spatial registration only supported for same orientation (hence translation only) for now",i==null?void 0:i.imageOrientationPatient,o==null?void 0:o.imageOrientationPatient);return}const c=i.imagePositionPatient,l=o.imagePositionPatient,f=Nn(Ke(),c,l),u=tm(ma(),f);S1.add([t.id,e.id],u)}function jy(t){const{imageData:e,dimensions:r}=t.getImageData()||{};if(!e||!r)return[];const{canvas:n}=t,i=window.devicePixelRatio,o=[0,0],a=[n.width/i,0],s=[n.width/i,n.height/i],c=[0,n.height/i],l=t.canvasToWorld(o),f=t.canvasToWorld(a),u=t.canvasToWorld(s),d=t.canvasToWorld(c),h=e.worldToIndex(l),g=e.worldToIndex(f),p=e.worldToIndex(u),v=e.worldToIndex(d);return mfe({dimensions:r,imageData:e,topLeftImage:h,topRightImage:g,bottomRightImage:p,bottomLeftImage:v,topLeftWorld:l,topRightWorld:f,bottomRightWorld:u,bottomLeftWorld:d})}function mfe({dimensions:t,imageData:e,topLeftImage:r,topRightImage:n,bottomRightImage:i,bottomLeftImage:o,topLeftWorld:a,topRightWorld:s,bottomRightWorld:c,bottomLeftWorld:l}){const f=C2(r,t)?a:e.indexToWorld([0,0,0]),u=C2(n,t)?s:e.indexToWorld([t[0]-1,0,0]),d=C2(i,t)?c:e.indexToWorld([t[0]-1,t[1]-1,0]),h=C2(o,t)?l:e.indexToWorld([0,t[1]-1,0]);return[f,u,h,d]}function C2(t,e){return t[0]>0||t[0]<e[0]-1||t[1]>0||t[1]<e[1]-1||t[2]>0||t[2]<e[2]-1}function Le(t){if(!t)return;const{viewportUid:e,renderingEngineUid:r}=t.dataset;return fi(e,r)}function fi(t,e){if(!e||!t)return;const r=Nr(e);if(!r||r.hasBeenDestroyed)return;const n=r.getViewport(t);if(!n)return;const i=n.getFrameOfReferenceUID();return{viewport:n,renderingEngine:r,viewportId:t,renderingEngineId:e,FrameOfReferenceUID:i}}function Mn(t){const e=Po();for(let r=0;r<e.length;r++){const n=e[r];if(n.getViewport(t))return fi(t,n.id)}}function IV(){const t=[];return Po().forEach(r=>{r.getViewports().forEach(({element:i})=>{t.push(Le(i))})}),t}function vfe(t){const e=Le(t);if(!e)return;const{viewport:r}=e;if(!(r instanceof Jn))throw new Error(`An image can only be fetched for a stack viewport and not for a viewport of type: ${r.type}`);return r.getCornerstoneImage()}function Sf(t){if(t.length<=1)return!1;const e=t[0],{modality:r,seriesInstanceUID:n}=ct("generalSeriesModule",e),{imageOrientationPatient:i,pixelSpacing:o,frameOfReferenceUID:a,columns:s,rows:c,usingDefaultValues:l}=ct("imagePlaneModule",e);if(l)return!1;const f={modality:r,imageOrientationPatient:i,pixelSpacing:o,columns:s,rows:c,seriesInstanceUID:n};let u=!0;for(let d=0;d<t.length;d++){const h=t[d],{modality:g,seriesInstanceUID:p}=ct("generalSeriesModule",h),{imageOrientationPatient:v,pixelSpacing:y,columns:m,rows:w}=ct("imagePlaneModule",h);if(p!==f.seriesInstanceUID){u=!1;break}if(g!==f.modality){u=!1;break}if(m!==f.columns){u=!1;break}if(w!==f.rows){u=!1;break}if(!Vt(v,f.imageOrientationPatient)){u=!1;break}if(!Vt(y,f.pixelSpacing)){u=!1;break}}return u}const yfe=new Set(["1.2.840.10008.1.2.4.100","1.2.840.10008.1.2.4.100.1","1.2.840.10008.1.2.4.101","1.2.840.10008.1.2.4.101.1","1.2.840.10008.1.2.4.102","1.2.840.10008.1.2.4.102.1","1.2.840.10008.1.2.4.103","1.2.840.10008.1.2.4.103.1","1.2.840.10008.1.2.4.104","1.2.840.10008.1.2.4.104.1","1.2.840.10008.1.2.4.105","1.2.840.10008.1.2.4.105.1","1.2.840.10008.1.2.4.106","1.2.840.10008.1.2.4.106.1","1.2.840.10008.1.2.4.107","1.2.840.10008.1.2.4.108"]);function OV(t){return t?(Array.isArray(t)?t:[t]).find(r=>yfe.has(r)):!1}async function wfe({viewport:t,options:e={}}){const r=t.getRenderingEngine();let n=e.volumeId||`${gn()}`;n.split(":").length===0&&(n=`${Tk()}:${n}`);const{id:i,element:o}=t,a=e.viewportId||i,s=t.getImageIds(),c=t.getViewPresentation(),l=t.getViewReference();r.enableElement({viewportId:a,type:ir.ORTHOGRAPHIC,element:o,defaultOptions:{background:e.background,orientation:e.orientation}}),(await p1(n,{imageIds:s})).load();const u=r.getViewport(a);await Hk(r,[{volumeId:n}],[a]);const d=()=>{u.render(),o.removeEventListener(et.VOLUME_VIEWPORT_NEW_VOLUME,d)};return(()=>{o.addEventListener(et.VOLUME_VIEWPORT_NEW_VOLUME,d)})(),u.setViewPresentation(c),u.setViewReference(l),u.render(),u}async function xfe({viewport:t,options:e}){const r=t,{id:n,element:i}=r,o=t.getRenderingEngine(),{background:a}=e,s=e.viewportId||n,c=$e.getVolume(r.getVolumeId());if(!(c instanceof Ud))throw new Error("Currently, you cannot decache a volume that is not an ImageVolume. So, unfortunately, volumes such as nifti (which are basic Volume, without imageIds) cannot be decached.");const l={viewportId:s,type:ir.STACK,element:i,defaultOptions:{background:a}},f=r.getViewReference();o.enableElement(l);const u=o.getViewport(s);return await u.setStack(c.imageIds),u.setViewReference(f),u.render(),u}function Xt(t,e=2){if(Array.isArray(t))return t.map(i=>Xt(i,e)).join(", ");if(t==null||t==="")return"NaN";t=Number(t);const r=Math.abs(t);if(r<1e-4)return`${t}`;const n=r>=100?e-2:r>=10?e-1:r>=1?e:r>=.1?e+1:r>=.01?e+2:r>=.001?e+3:e+4;return t.toFixed(n)}function Gu(t){return Math.round(t/Ga)*Ga}function MV(t,e,r){const n=t.length===e*r*4,i=t.length===e*r*3;if(n||i){const o=new Float32Array(e*r);let a=0,s=0;const c=n?4:3;for(let l=0;l<e;l++)for(let f=0;f<r;f++){const u=t[a],d=t[a+1],h=t[a+2];o[s]=(u+d+h)/3,a+=c,s++}return o}else return t}function Cfe(t){if(t instanceof Zn)return $e.getVolume(t.getVolumeId()).imageIds;if(t.getImageIds)return t.getImageIds()}function mE(t,e){const r=[...t];return e>=r.length?(y9(r),r):(y9(r),r.slice(0,e))}function y9(t){for(let e=t.length-1;e>0;e--){const r=Math.floor(Math.random()*(e+1));[t[e],t[r]]=[t[r],t[e]]}}function fC(t){const e=t.toString(16);return e.length==1?"0"+e:e}function Sfe(t,e,r){return"#"+fC(t)+fC(e)+fC(r)}function Tfe(t){const e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null}const _fe=Object.freeze(Object.defineProperty({__proto__:null,hexToRgb:Tfe,rgbToHex:Sfe},Symbol.toStringTag,{value:"Module"}));function PV(t,e){if(t===e)return!0;if(t==null||e==null)return!1;try{return JSON.stringify(t)===JSON.stringify(e)}catch(r){return console.debug("Error in JSON.stringify during deep comparison:",r),t===e}}function Efe(t,e,r){if(!r)throw new Error("getVolume is required, use the utilities export instead ");if(t.modality)return t.modality;if(t.setVolumes)return e=e??t.getVolumeId(),!e||!r?void 0:r(e).metadata.Modality;throw new Error("Invalid viewport type")}const bfe=(t,e)=>t.reduce((r,n)=>((r[n[e]]=r[n[e]]||[]).push(n),r),{});function Dfe(t){const e=t.map(a=>{const{imagePositionPatient:s}=ct("imagePlaneModule",a)||{};return{imageId:a,imagePositionPatient:s}});if(!e.every(a=>a.imagePositionPatient))return null;const r=bfe(e,"imagePositionPatient"),n=Object.keys(r),i=r[n[0]].length;return i===1||!n.every(a=>r[a].length===i)?null:r}function Ife(t,e){const r={};let n=[];const i=Object.keys(t);for(let o=0;o<i.length;o++){const a=new Set,s=t[i[o]];for(let c=0;c<s.length;c++){const l=e(s[c].imageId)||0;if(r[l]=r[l]||[],r[l].push({imageId:s[c].imageId}),a.add(l),a.size-1<c)return}if(o==0)n=Array.from(a);else if(!Rfe(n,a))return}return r}function Ig(t,e){const r=ct(e,t);try{return parseFloat(r)}catch{return}}function Ofe(t){const e=ct("20011003",t);try{const{InlineBinary:r}=e;if(r){const n=atob(r),i=new ArrayBuffer(n.length),o=new DataView(i);for(let a=0;a<n.length;a++)o.setUint8(a,n.charCodeAt(a));return new Float32Array(i)[0]}return parseFloat(e)}catch{return}}function Mfe(t){let e=ct("0019100c",t)||ct("0019100C",t);try{const{InlineBinary:r}=e;return r&&(e=atob(r)),parseFloat(e)}catch{return}}function Pfe(t){let e=ct("00431039",t);try{const{InlineBinary:r}=e;return r&&(e=atob(r).split("//")),parseFloat(e[0])%1e5}catch{return}}function Rfe(t,e){if(t.length!=e.size)return!1;for(let r=0;r<t.length;r++)if(!e.has(t[r]))return!1;return!0}function Lfe(t){const e=ct("petImageModule",t);return e?e.frameReferenceTime:0}function vE(t){const e=Dfe(t);if(!e)return{imageIdGroups:[t],splittingTag:null};const r=["TemporalPositionIdentifier","DiffusionBValue","TriggerTime","EchoTime","EchoNumber","PhilipsPrivateBValue","SiemensPrivateBValue","GEPrivateBValue","PetFrameReferenceTime"],n=[i=>Ig(i,r[0]),i=>Ig(i,r[1]),i=>Ig(i,r[2]),i=>Ig(i,r[3]),i=>Ig(i,r[4]),Ofe,Mfe,Pfe,Lfe];for(let i=0;i<n.length;i++){const o=Ife(e,n[i]);if(o)return{imageIdGroups:Object.keys(o).map(Number.parseFloat).sort((c,l)=>c-l).map(c=>o[c].map(l=>l.imageId)),splittingTag:r[i]}}return{imageIdGroups:[t],splittingTag:null}}function Afe(t){const{imageIdGroups:e,splittingTag:r}=vE(t);return{isDynamicVolume:e.length>1,timePoints:e,splittingTag:r}}function Nfe(t,e){const r=t.length,{rescaleSlope:n,rescaleIntercept:i,suvbw:o}=e;if(e.modality==="PT"&&typeof o=="number")for(let a=0;a<r;a++)t[a]=o*(t[a]*n+i);else for(let a=0;a<r;a++)t[a]=t[a]*n+i;return t}function Hy(t,e,r){return Math.min(Math.max(e,t),r)}function oc(t,e){if(!Le(t.element))throw new Error("Scroll::Viewport is not enabled (it might be disabled)");if(t instanceof Jn&&t.getImageIds().length===0)throw new Error("Scroll::Stack Viewport has no images");const{volumeId:n,delta:i,scrollSlabs:o}=e;if(t instanceof Zn)kfe(t,n,i,o);else{const a=t.getCurrentImageIdIndex();if(a+i>t.getImageIds().length-1||a+i<0){const s={imageIdIndex:a,direction:i};it(Ze,et.STACK_SCROLL_OUT_OF_BOUNDS,s)}t.scroll(i,e.debounceLoading,e.loop)}}function kfe(t,e,r,n=!1){const i=n,{numScrollSteps:o,currentStepIndex:a,sliceRangeInfo:s}=ud(t,e,i);if(!s)return;const{sliceRange:c,spacingInNormalDirection:l,camera:f}=s,{focalPoint:u,viewPlaneNormal:d,position:h}=f,{newFocalPoint:g,newPosition:p}=Y0(u,h,c,d,l,r);t.setCamera({focalPoint:g,position:p}),t.render();const v=a+r,y={volumeId:e,viewport:t,delta:r,desiredStepIndex:v,currentStepIndex:a,numScrollSteps:o,currentImageId:t.getCurrentImageId()};(v>o||v<0)&&t.getCurrentImageId()?it(Ze,et.VOLUME_VIEWPORT_SCROLL_OUT_OF_BOUNDS,y):it(Ze,et.VOLUME_VIEWPORT_SCROLL,y)}async function oa(t,e={}){const{imageIndex:r,debounceLoading:n,volumeId:i}=e,o=Le(t);if(!o)throw new Error("Element has been disabled");const{viewport:a}=o,{imageIndex:s,numberOfSlices:c}=Vfe(a,n),f=Ffe(c,r)-s;oc(a,{delta:f,debounceLoading:n,volumeId:i})}function Vfe(t,e){return t instanceof Jn?{numberOfSlices:t.getImageIds().length,imageIndex:e?t.getTargetImageIdIndex():t.getCurrentImageIdIndex()}:{numberOfSlices:t.getNumberOfSlices(),imageIndex:t.getSliceIndex()}}function Ffe(t,e){const r=t-1;return Hy(e,0,r)}function yE(t,e,r={}){const n=$e.getVolume(t);if(!n)throw new Error(`Referenced volume with id ${t} does not exist.`);const{metadata:i,spacing:o,direction:a,dimensions:s}=n,{minX:c,maxX:l,minY:f,maxY:u,minZ:d,maxZ:h}=e,g=[Math.min(c,l),Math.min(f,u),Math.min(d,h)],p=Th(n.imageData,g),v=[Math.abs(l-c)+1,Math.abs(u-f)+1,Math.abs(h-d)+1],{targetBuffer:y}=r,m={metadata:i,dimensions:v,spacing:o,origin:p,direction:a,targetBuffer:y,scalarData:(y==null?void 0:y.type)==="Float32Array"?new Float32Array(v[0]*v[1]*v[2]):void 0},w=um(gn(),m),x=w.voxelManager.getCompleteScalarDataArray(),C=v[0]*v[1],S=s[0]*s[1],T=n.voxelManager.getCompleteScalarDataArray();for(let _=0;_<v[2];_++)for(let E=0;E<v[1];E++){const b=Th(w.imageData,[0,E,_]),D=Lr(n.imageData,b),I=D[2]*S+D[1]*s[0]+D[0],P=T.slice(I,I+v[0]),O=_*C+E*v[0];x.set(P,O)}return w.voxelManager.setCompleteScalarDataArray(x),w}function Sw(t,e){const{viewUp:r,viewPlaneNormal:n}=e,i=Ov(t,[0,0,0]),o=qc(Ke(),r),a=qc(Ke(),n),s=Tn(Ke(),o,a),c=hn(Ke(),Ov(t,o),i),l=hn(Ke(),Ov(t,a),i);Un(c,c),Un(l,l);const f=Tn(Ke(),c,l);return{worldVecRowDir:s,worldVecColDir:o,worldVecSliceDir:a,ijkVecRowDir:f,ijkVecColDir:c,ijkVecSliceDir:l}}function RV(t,e,r,n){const[i,o,a]=e,s=i*o;let c=0,l=0,f=0;const[u,d,h]=r.map(Math.round);for(let y=h-n;y<=h+n;y++)if(!(y<0||y>=a)){for(let m=d-n;m<=d+n;m++)if(!(m<0||m>=o))for(let w=u-n;w<=u+n;w++){if(w<0||w>=i)continue;const x=y*s+m*i+w,C=t[x];c+=C,l+=C*C,f++}}if(f===0){const y=h*s+d*i+u;return y>=0&&y<t.length?{mean:t[y],stdDev:0,count:1}:{mean:0,stdDev:0,count:0}}const g=c/f,p=l/f-g*g,v=Math.sqrt(Math.max(0,p));return{mean:g,stdDev:v,count:f}}const Ufe=new Set(["1.2.840.10008.5.1.4.1.1.1","1.2.840.10008.5.1.4.1.1.1.1","1.2.840.10008.5.1.4.1.1.1.1.1","1.2.840.10008.5.1.4.1.1.1.2","1.2.840.10008.5.1.4.1.1.1.2.1","1.2.840.10008.5.1.4.1.1.1.3","1.2.840.10008.5.1.4.1.1.1.3.1","1.2.840.10008.5.1.4.1.1.12.1","1.2.840.10008.5.1.4.1.1.12.1.1","1.2.840.10008.5.1.4.1.1.12.2","1.2.840.10008.5.1.4.1.1.12.2.1","1.2.840.10008.5.1.4.1.1.12.3"]);function Bfe(t){const{PixelSpacing:e,ImagerPixelSpacing:r,EstimatedRadiographicMagnificationFactor:n,PixelSpacingCalibrationType:i,PixelSpacingCalibrationDescription:o}=t,a=!0;return r?e?Vt(e,r)?{PixelSpacing:e,type:Js.PROJECTION,isProjection:a}:i||o?{PixelSpacing:e,type:Js.CALIBRATED,isProjection:a,PixelSpacingCalibrationType:i,PixelSpacingCalibrationDescription:o}:{PixelSpacing:e,type:Js.UNKNOWN,isProjection:a}:n?{PixelSpacing:r.map(c=>c/n),type:Js.ERMF,isProjection:a}:(console.warn("EstimatedRadiographicMagnificationFactor was not present. Unable to correct ImagerPixelSpacing."),{PixelSpacing:r,type:Js.PROJECTION,isProjection:a}):{PixelSpacing:e,type:Js.UNKNOWN,isProjection:a}}function Gfe(t){const{SequenceOfUltrasoundRegions:e}=t,r=Array.isArray(e);if(r&&e.length>1){console.warn("Sequence of Ultrasound Regions > one entry. This is not yet implemented, all measurements will be shown in pixels.");return}const{PhysicalDeltaX:n,PhysicalDeltaY:i}=r?e[0]:e;return{PixelSpacing:[n*10,i*10]}}function Wfe(t){const{PixelSpacing:e,SOPClassUID:r,SequenceOfUltrasoundRegions:n}=t;return n?Gfe(t):Ufe.has(r)?Bfe(t):{PixelSpacing:e,type:Js.NOT_APPLICABLE,isProjection:!1}}const LV=(t,e)=>Efe(t,e,$e.getVolume),pn=Object.freeze(Object.defineProperty({__proto__:null,FrameRange:eh,HistoryMemo:hE,PointsManager:Pv,ProgressiveIterator:Uy,RLEVoxelMap:c0,VoxelManager:fc,actorIsA:ga,applyPreset:Mk,autoLoad:ES,buildMetadata:Nk,calculateNeighborhoodStats:RV,calculateSpacingBetweenImageIds:dk,calculateViewportsSpatialRegistration:DV,calibratedPixelSpacingMetadataProvider:ufe,clamp:MS,clip:Hy,color:_fe,colormap:Nie,convertStackToVolumeViewport:wfe,convertToGrayscale:MV,convertVolumeToStackViewport:xfe,createLinearRGBTransferFunction:kk,createSigmoidRGBTransferFunction:z4,createSubVolume:yE,decimate:pk,deepClone:ds,deepEqual:PV,deepMerge:Ti,eventListener:rfe,fnv1aHash:SN,generateVolumePropsFromImageIds:sm,genericMetadataProvider:Uu,getBufferConfiguration:D4,getClosestImageId:Ql,getClosestStackImageIndexForPoint:gE,getCurrentVolumeViewportSlice:pE,getDynamicVolumeInfo:Afe,getImageDataMetadata:yw,getImageLegacy:vfe,getImageSliceDataForVolumeViewport:Gy,getMinMax:dE,getPixelSpacingInformation:Wfe,getRandomSampleFromArray:mE,getRuntimeId:xV,getScalingParameters:hk,getSliceRange:mw,getSpacingInNormalDirection:Cf,getTargetVolumeAndSpacingInNormalDir:Hh,getViewportImageCornersInWorld:jy,getViewportImageIds:Cfe,getViewportModality:LV,getViewportsWithImageURI:$y,getViewportsWithVolumeId:cm,getVoiFromSigmoidRGBTransferFunction:Ok,getVolumeActorCorners:IN,getVolumeDirectionVectors:Sw,getVolumeId:dl,getVolumeSliceRangeInfo:Ik,getVolumeViewportScrollInfo:ud,getVolumeViewportsContainingSameVolumes:ffe,hasFloatScalingParameters:X4,hasNaNValues:bS,imageIdToURI:_r,imageRetrieveMetadataProvider:h1,imageToWorldCoords:bV,indexWithinDimensions:tr,invertRgbTransferFunction:wp,isEqual:Vt,isEqualAbs:Rie,isEqualNegative:LN,isImageActor:Qs,isNumber:xr,isOpposite:ep,isPTPrescaledWithSUV:CV,isValidVolume:Sf,isVideoTransferSyntax:OV,jumpToSlice:oa,loadImageToCanvas:dfe,logger:die,makeVolumeMetadata:fk,planar:nce,pointInShapeCallback:j4,renderToCanvasCPU:TV,renderToCanvasGPU:SV,roundNumber:Xt,roundToPrecision:Gu,scaleArray:Nfe,scaleRgbTransferFunction:ife,scroll:oc,snapFocalPointToSlice:Y0,sortImageIdsAndGetSpacing:q4,spatialRegistrationMetadataProvider:S1,splitImageIdsBy4DTags:vE,transferFunctionUtils:Vie,transformIndexToWorld:Th,transformWorldToIndex:Lr,transformWorldToIndexContinuous:Ov,triggerEvent:it,updateVTKImageDataWithCornerstoneImage:ww,uuidv4:gn,windowLevel:kie,worldToImageCoords:AS},Symbol.toStringTag,{value:"Module"}));class AV extends vk{constructor(e,r){super(e,r),this._dimensionGroupNumber=1,this._loadedDimensionGroups=new Set,this._getImageIdRequests=(o,a)=>this.getImageIdsRequests(o,a),this.getImageLoadRequests=o=>{const a=this.getImageIdsToLoad();return this._getImageIdRequests(a,o)};const{imageIdGroups:n,splittingTag:i}=e;this._splittingTag=i,this._imageIdGroups=n,this.numDimensionGroups=this._imageIdGroups.length,this.numTimePoints=this.numDimensionGroups}_getImageIdsToLoad(){const e=this._imageIdGroups,r=this._dimensionGroupNumber-1,n=[...e[r]];let i=r-1,o=r+1;for(;i>=0||o<e.length;)i>=0&&n.push(...e[i--]),o<e.length&&n.push(...e[o++]);return n}getImageIdsToLoad(){return this._getImageIdsToLoad()}get dimensionGroupNumber(){return this._dimensionGroupNumber}set timePointIndex(e){console.warn("Warning: timePointIndex is deprecated. Please use dimensionGroupNumber instead. Note that timePointIndex is zero-based while dimensionGroupNumber starts at 1."),this.dimensionGroupNumber=e+1}set dimensionGroupNumber(e){this._dimensionGroupNumber!==e&&(this._dimensionGroupNumber=e,this.voxelManager.setDimensionGroupNumber(e),this.invalidateVolume(!0),it(Ze,et.DYNAMIC_VOLUME_DIMENSION_GROUP_CHANGED,{volumeId:this.volumeId,dimensionGroupNumber:e,numDimensionGroups:this.numDimensionGroups,imageIdGroupIndex:e-1,numImageIdGroups:this.numDimensionGroups,splittingTag:this.splittingTag}),it(Ze,et.DYNAMIC_VOLUME_TIME_POINT_INDEX_CHANGED,{volumeId:this.volumeId,timePointIndex:e-1,numTimePoints:this.numDimensionGroups,imageIdGroupIndex:e-1,numImageIdGroups:this.numDimensionGroups,splittingTag:this.splittingTag}))}get timePointIndex(){return console.warn("Warning: timePointIndex is deprecated. Please use dimensionGroupNumber instead. Note that timePointIndex is zero-based while dimensionGroupNumber starts at 1."),this._dimensionGroupNumber-1}scroll(e){const r=this._dimensionGroupNumber+e;r<1?this.dimensionGroupNumber=this.numDimensionGroups:r>this.numDimensionGroups?this.dimensionGroupNumber=1:this.dimensionGroupNumber=r}getCurrentDimensionGroupImageIds(){return this._imageIdGroups[this._dimensionGroupNumber-1]}getCurrentTimePointImageIds(){return console.warn("Warning: getCurrentTimePointImageIds is deprecated. Please use getCurrentDimensionGroupImageIds instead."),this.getCurrentDimensionGroupImageIds()}flatImageIdIndexToTimePointIndex(e){return console.warn("Warning: flatImageIdIndexToTimePointIndex is deprecated. Please use flatImageIdIndexToDimensionGroupNumber instead."),this.flatImageIdIndexToDimensionGroupNumber(e)-1}flatImageIdIndexToDimensionGroupNumber(e){return Math.floor(e/this._imageIdGroups[0].length)+1}flatImageIdIndexToImageIdIndex(e){return e%this._imageIdGroups[0].length}get splittingTag(){return this._splittingTag}isTimePointLoaded(e){return console.warn("Warning: isTimePointLoaded is deprecated. Please use isDimensionGroupLoaded instead. Note that timePointIndex is zero-based while dimensionGroupNumber starts at 1."),this.isDimensionGroupLoaded(e+1)}isDimensionGroupLoaded(e){return this._loadedDimensionGroups.has(e)}markDimensionGroupAsLoaded(e){this._loadedDimensionGroups.add(e),it(Ze,et.DYNAMIC_VOLUME_DIMENSION_GROUP_LOADED,{volumeId:this.volumeId,dimensionGroupNumber:e}),it(Ze,et.DYNAMIC_VOLUME_TIME_POINT_LOADED,{volumeId:this.volumeId,timePointIndex:e-1})}checkTimePointCompletion(e){console.warn("Warning: checkTimePointCompletion is deprecated. Please use checkDimensionGroupCompletion instead."),this.checkDimensionGroupCompletion(e)}checkDimensionGroupCompletion(e){const r=this.flatImageIdIndexToDimensionGroupNumber(e);this._imageIdGroups[r-1].every(o=>{const a=this.getImageIdIndex(o);return this.cachedFrames[a]===ca.FULL_RESOLUTION})&&!this.isDimensionGroupLoaded(r)&&this.markDimensionGroupAsLoaded(r)}}const qh=new O4("imageRetrievalPool");qh.setMaxSimultaneousRequests(Qt.Interaction,200);qh.setMaxSimultaneousRequests(Qt.Thumbnail,200);qh.setMaxSimultaneousRequests(Qt.Prefetch,200);qh.grabDelay=0;const w9=Symbol("DefaultSettings"),x9=Symbol("RuntimeSettings"),C9=Symbol("ObjectSettingsMap"),El=Symbol("Dictionary");class cr{constructor(e){const r=Object.create(e instanceof cr&&El in e?e[El]:null);Object.seal(Object.defineProperty(this,El,{value:r}))}set(e,r){return Ky(this[El],e,r,null)}get(e){return jfe(this[El],e)}unset(e){return zfe(this[El],e+"")}forEach(e){S9(this[El],e)}extend(){return new cr(this)}import(e){NV(e)&&Object.keys(e).forEach(r=>{Ky(this[El],r,e[r],null)})}dump(){const e={};return S9(this[El],(r,n)=>{typeof n<"u"&&kV(e,r,n)}),e}static assert(e){return e instanceof cr?e:cr.getRuntimeSettings()}static getDefaultSettings(e=null){let r=cr[w9];if(r instanceof cr||(r=new cr,cr[w9]=r),e){const n={};return r.forEach(i=>{if(i.startsWith(e)){const o=i.split(`${e}.`)[1];n[o]=r.get(i)}}),n}return r}static getRuntimeSettings(){let e=cr[x9];return e instanceof cr||(e=new cr(cr.getDefaultSettings()),cr[x9]=e),e}static getObjectSettings(e,r){let n=null;if(e instanceof cr)n=e;else if(typeof e=="object"&&e!==null){let i=cr[C9];i instanceof WeakMap||(i=new WeakMap,cr[C9]=i),n=i.get(e),n instanceof cr||(n=new cr(cr.assert(cr.getObjectSettings(r))),i.set(e,n))}return n}static extendRuntimeSettings(){return cr.getRuntimeSettings().extend()}}function zfe(t,e){if(e.endsWith(".")){let r=0;const n=e,i=n.slice(0,-1),o=i.length===0;for(const a in t)Object.prototype.hasOwnProperty.call(t,a)&&(o||a.startsWith(n)||a===i)&&(delete t[a],++r);return r>0}return delete t[e]}function S9(t,e){for(const r in t)e(r,t[r])}function $fe(t,e,r,n){let i;if(n.has(r))return Ky(t,e,null,n);n.add(r),i=0;for(const o in r)if(Object.prototype.hasOwnProperty.call(r,o)){const a=o.length===0?e:`${e}.${o}`;Ky(t,a,r[o],n)||++i}return n.delete(r),i===0}function Ky(t,e,r,n){return Hfe(e)?NV(r)?$fe(t,e,r,n instanceof WeakSet?n:new WeakSet):(t[e]=r,!0):!1}function jfe(t,e){return t[e]}function Hfe(t){let e,r,n;if(typeof t!="string"||(e=t.length-1)<0)return!1;for(n=-1;(r=t.indexOf(".",n+1))>=0;){if(r-n<2||r===e)return!1;n=r}return!0}function NV(t){if(typeof t=="object"&&t!==null){const e=Object.getPrototypeOf(t);if(e===Object.prototype||e===null)return!0}return!1}function kV(t,e,r){const n=e.indexOf(".");if(n>=0){const i=e.slice(0,n);let o=t[i];if(typeof o!="object"||o===null){const a=o;o={},typeof a<"u"&&(o[""]=a),t[i]=o}kV(o,e.slice(n+1,e.length),r)}else t[e]=r}cr.getDefaultSettings().set("useCursors",!0);function Av(t,e){return t==null||e==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function Kfe(t,e){return t==null||e==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function VV(t){let e,r,n;t.length!==2?(e=Av,r=(s,c)=>Av(t(s),c),n=(s,c)=>t(s)-c):(e=t===Av||t===Kfe?t:qfe,r=t,n=t);function i(s,c,l=0,f=s.length){if(l<f){if(e(c,c)!==0)return f;do{const u=l+f>>>1;r(s[u],c)<0?l=u+1:f=u}while(l<f)}return l}function o(s,c,l=0,f=s.length){if(l<f){if(e(c,c)!==0)return f;do{const u=l+f>>>1;r(s[u],c)<=0?l=u+1:f=u}while(l<f)}return l}function a(s,c,l=0,f=s.length){const u=i(s,c,l,f-1);return u>l&&n(s[u-1],c)>-n(s[u],c)?u-1:u}return{left:i,center:a,right:o}}function qfe(){return 0}function Xfe(t){return t===null?NaN:+t}const Yfe=VV(Av),Jfe=Yfe.right;VV(Xfe).center;const Zfe=Math.sqrt(50),Qfe=Math.sqrt(10),ede=Math.sqrt(2);function qy(t,e,r){const n=(e-t)/Math.max(0,r),i=Math.floor(Math.log10(n)),o=n/Math.pow(10,i),a=o>=Zfe?10:o>=Qfe?5:o>=ede?2:1;let s,c,l;return i<0?(l=Math.pow(10,-i)/a,s=Math.round(t*l),c=Math.round(e*l),s/l<t&&++s,c/l>e&&--c,l=-l):(l=Math.pow(10,i)*a,s=Math.round(t/l),c=Math.round(e/l),s*l<t&&++s,c*l>e&&--c),c<s&&.5<=r&&r<2?qy(t,e,r*2):[s,c,l]}function tde(t,e,r){if(e=+e,t=+t,r=+r,!(r>0))return[];if(t===e)return[t];const n=e<t,[i,o,a]=n?qy(e,t,r):qy(t,e,r);if(!(o>=i))return[];const s=o-i+1,c=new Array(s);if(n)if(a<0)for(let l=0;l<s;++l)c[l]=(o-l)/-a;else for(let l=0;l<s;++l)c[l]=(o-l)*a;else if(a<0)for(let l=0;l<s;++l)c[l]=(i+l)/-a;else for(let l=0;l<s;++l)c[l]=(i+l)*a;return c}function NS(t,e,r){return e=+e,t=+t,r=+r,qy(t,e,r)[2]}function nde(t,e,r){e=+e,t=+t,r=+r;const n=e<t,i=n?NS(e,t,r):NS(t,e,r);return(n?-1:1)*(i<0?1/-i:i)}function rde(t,e){let r;if(e===void 0)for(const n of t)n!=null&&(r>n||r===void 0&&n>=n)&&(r=n);else{let n=-1;for(let i of t)(i=e(i,++n,t))!=null&&(r>i||r===void 0&&i>=i)&&(r=i)}return r}function ide(t){if(!(o=t.length))return[];for(var e=-1,r=rde(t,ode),n=new Array(r);++e<r;)for(var i=-1,o,a=n[e]=new Array(o);++i<o;)a[i]=t[i][e];return n}function ode(t){return t.length}function T9(){return ide(arguments)}function ade(t,e){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(e).domain(t);break}return this}function wE(t,e,r){t.prototype=e.prototype=r,r.constructor=t}function FV(t,e){var r=Object.create(t.prototype);for(var n in e)r[n]=e[n];return r}function pm(){}var T1=.7,Xy=1/T1,th="\\s*([+-]?\\d+)\\s*",_1="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Jc="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",sde=/^#([0-9a-f]{3,8})$/,cde=new RegExp(`^rgb\\(${th},${th},${th}\\)$`),lde=new RegExp(`^rgb\\(${Jc},${Jc},${Jc}\\)$`),ude=new RegExp(`^rgba\\(${th},${th},${th},${_1}\\)$`),fde=new RegExp(`^rgba\\(${Jc},${Jc},${Jc},${_1}\\)$`),dde=new RegExp(`^hsl\\(${_1},${Jc},${Jc}\\)$`),hde=new RegExp(`^hsla\\(${_1},${Jc},${Jc},${_1}\\)$`),_9={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};wE(pm,E1,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:E9,formatHex:E9,formatHex8:gde,formatHsl:pde,formatRgb:b9,toString:b9});function E9(){return this.rgb().formatHex()}function gde(){return this.rgb().formatHex8()}function pde(){return UV(this).formatHsl()}function b9(){return this.rgb().formatRgb()}function E1(t){var e,r;return t=(t+"").trim().toLowerCase(),(e=sde.exec(t))?(r=e[1].length,e=parseInt(e[1],16),r===6?D9(e):r===3?new ua(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):r===8?S2(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):r===4?S2(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=cde.exec(t))?new ua(e[1],e[2],e[3],1):(e=lde.exec(t))?new ua(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=ude.exec(t))?S2(e[1],e[2],e[3],e[4]):(e=fde.exec(t))?S2(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=dde.exec(t))?M9(e[1],e[2]/100,e[3]/100,1):(e=hde.exec(t))?M9(e[1],e[2]/100,e[3]/100,e[4]):_9.hasOwnProperty(t)?D9(_9[t]):t==="transparent"?new ua(NaN,NaN,NaN,0):null}function D9(t){return new ua(t>>16&255,t>>8&255,t&255,1)}function S2(t,e,r,n){return n<=0&&(t=e=r=NaN),new ua(t,e,r,n)}function mde(t){return t instanceof pm||(t=E1(t)),t?(t=t.rgb(),new ua(t.r,t.g,t.b,t.opacity)):new ua}function kS(t,e,r,n){return arguments.length===1?mde(t):new ua(t,e,r,n??1)}function ua(t,e,r,n){this.r=+t,this.g=+e,this.b=+r,this.opacity=+n}wE(ua,kS,FV(pm,{brighter(t){return t=t==null?Xy:Math.pow(Xy,t),new ua(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?T1:Math.pow(T1,t),new ua(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new ua(fd(this.r),fd(this.g),fd(this.b),Yy(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:I9,formatHex:I9,formatHex8:vde,formatRgb:O9,toString:O9}));function I9(){return`#${id(this.r)}${id(this.g)}${id(this.b)}`}function vde(){return`#${id(this.r)}${id(this.g)}${id(this.b)}${id((isNaN(this.opacity)?1:this.opacity)*255)}`}function O9(){const t=Yy(this.opacity);return`${t===1?"rgb(":"rgba("}${fd(this.r)}, ${fd(this.g)}, ${fd(this.b)}${t===1?")":`, ${t})`}`}function Yy(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function fd(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function id(t){return t=fd(t),(t<16?"0":"")+t.toString(16)}function M9(t,e,r,n){return n<=0?t=e=r=NaN:r<=0||r>=1?t=e=NaN:e<=0&&(t=NaN),new ec(t,e,r,n)}function UV(t){if(t instanceof ec)return new ec(t.h,t.s,t.l,t.opacity);if(t instanceof pm||(t=E1(t)),!t)return new ec;if(t instanceof ec)return t;t=t.rgb();var e=t.r/255,r=t.g/255,n=t.b/255,i=Math.min(e,r,n),o=Math.max(e,r,n),a=NaN,s=o-i,c=(o+i)/2;return s?(e===o?a=(r-n)/s+(r<n)*6:r===o?a=(n-e)/s+2:a=(e-r)/s+4,s/=c<.5?o+i:2-o-i,a*=60):s=c>0&&c<1?0:a,new ec(a,s,c,t.opacity)}function yde(t,e,r,n){return arguments.length===1?UV(t):new ec(t,e,r,n??1)}function ec(t,e,r,n){this.h=+t,this.s=+e,this.l=+r,this.opacity=+n}wE(ec,yde,FV(pm,{brighter(t){return t=t==null?Xy:Math.pow(Xy,t),new ec(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?T1:Math.pow(T1,t),new ec(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,e=isNaN(t)||isNaN(this.s)?0:this.s,r=this.l,n=r+(r<.5?r:1-r)*e,i=2*r-n;return new ua(dC(t>=240?t-240:t+120,i,n),dC(t,i,n),dC(t<120?t+240:t-120,i,n),this.opacity)},clamp(){return new ec(P9(this.h),T2(this.s),T2(this.l),Yy(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 t=Yy(this.opacity);return`${t===1?"hsl(":"hsla("}${P9(this.h)}, ${T2(this.s)*100}%, ${T2(this.l)*100}%${t===1?")":`, ${t})`}`}}));function P9(t){return t=(t||0)%360,t<0?t+360:t}function T2(t){return Math.max(0,Math.min(1,t||0))}function dC(t,e,r){return(t<60?e+(r-e)*t/60:t<180?r:t<240?e+(r-e)*(240-t)/60:e)*255}function wde(t,e,r,n,i){var o=t*t,a=o*t;return((1-3*t+3*o-a)*e+(4-6*o+3*a)*r+(1+3*t+3*o-3*a)*n+a*i)/6}function hC(t){var e=t.length-1;return function(r){var n=r<=0?r=0:r>=1?(r=1,e-1):Math.floor(r*e),i=t[n],o=t[n+1],a=n>0?t[n-1]:2*i-o,s=n<e-1?t[n+2]:2*o-i;return wde((r-n/e)*e,a,i,o,s)}}const xE=t=>()=>t;function xde(t,e){return function(r){return t+r*e}}function Cde(t,e,r){return t=Math.pow(t,r),e=Math.pow(e,r)-t,r=1/r,function(n){return Math.pow(t+n*e,r)}}function Sde(t){return(t=+t)==1?BV:function(e,r){return r-e?Cde(e,r,t):xE(isNaN(e)?r:e)}}function BV(t,e){var r=e-t;return r?xde(t,r):xE(isNaN(t)?e:t)}const R9=function t(e){var r=Sde(e);function n(i,o){var a=r((i=kS(i)).r,(o=kS(o)).r),s=r(i.g,o.g),c=r(i.b,o.b),l=BV(i.opacity,o.opacity);return function(f){return i.r=a(f),i.g=s(f),i.b=c(f),i.opacity=l(f),i+""}}return n.gamma=t,n}(1);function Tde(t,e){e||(e=[]);var r=t?Math.min(e.length,t.length):0,n=e.slice(),i;return function(o){for(i=0;i<r;++i)n[i]=t[i]*(1-o)+e[i]*o;return n}}function _de(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Ede(t,e){var r=e?e.length:0,n=t?Math.min(r,t.length):0,i=new Array(n),o=new Array(r),a;for(a=0;a<n;++a)i[a]=CE(t[a],e[a]);for(;a<r;++a)o[a]=e[a];return function(s){for(a=0;a<n;++a)o[a]=i[a](s);return o}}function bde(t,e){var r=new Date;return t=+t,e=+e,function(n){return r.setTime(t*(1-n)+e*n),r}}function Jy(t,e){return t=+t,e=+e,function(r){return t*(1-r)+e*r}}function Dde(t,e){var r={},n={},i;(t===null||typeof t!="object")&&(t={}),(e===null||typeof e!="object")&&(e={});for(i in e)i in t?r[i]=CE(t[i],e[i]):n[i]=e[i];return function(o){for(i in r)n[i]=r[i](o);return n}}var VS=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,gC=new RegExp(VS.source,"g");function Ide(t){return function(){return t}}function Ode(t){return function(e){return t(e)+""}}function Mde(t,e){var r=VS.lastIndex=gC.lastIndex=0,n,i,o,a=-1,s=[],c=[];for(t=t+"",e=e+"";(n=VS.exec(t))&&(i=gC.exec(e));)(o=i.index)>r&&(o=e.slice(r,o),s[a]?s[a]+=o:s[++a]=o),(n=n[0])===(i=i[0])?s[a]?s[a]+=i:s[++a]=i:(s[++a]=null,c.push({i:a,x:Jy(n,i)})),r=gC.lastIndex;return r<e.length&&(o=e.slice(r),s[a]?s[a]+=o:s[++a]=o),s.length<2?c[0]?Ode(c[0].x):Ide(e):(e=c.length,function(l){for(var f=0,u;f<e;++f)s[(u=c[f]).i]=u.x(l);return s.join("")})}function CE(t,e){var r=typeof e,n;return e==null||r==="boolean"?xE(e):(r==="number"?Jy:r==="string"?(n=E1(e))?(e=n,R9):Mde:e instanceof E1?R9:e instanceof Date?bde:_de(e)?Tde:Array.isArray(e)?Ede:typeof e.valueOf!="function"&&typeof e.toString!="function"||isNaN(e)?Dde:Jy)(t,e)}function Pde(t,e){return t=+t,e=+e,function(r){return Math.round(t*(1-r)+e*r)}}function Og(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t(n/(e-1));return r}function Rde(t){return function(){return t}}function Lde(t){return+t}var L9=[0,1];function E0(t){return t}function FS(t,e){return(e-=t=+t)?function(r){return(r-t)/e}:Rde(isNaN(e)?NaN:.5)}function Ade(t,e){var r;return t>e&&(r=t,t=e,e=r),function(n){return Math.max(t,Math.min(e,n))}}function Nde(t,e,r){var n=t[0],i=t[1],o=e[0],a=e[1];return i<n?(n=FS(i,n),o=r(a,o)):(n=FS(n,i),o=r(o,a)),function(s){return o(n(s))}}function kde(t,e,r){var n=Math.min(t.length,e.length)-1,i=new Array(n),o=new Array(n),a=-1;for(t[n]<t[0]&&(t=t.slice().reverse(),e=e.slice().reverse());++a<n;)i[a]=FS(t[a],t[a+1]),o[a]=r(e[a],e[a+1]);return function(s){var c=Jfe(t,s,1,n)-1;return o[c](i[c](s))}}function Vde(t,e){return e.domain(t.domain()).range(t.range()).interpolate(t.interpolate()).clamp(t.clamp()).unknown(t.unknown())}function Fde(){var t=L9,e=L9,r=CE,n,i,o,a=E0,s,c,l;function f(){var d=Math.min(t.length,e.length);return a!==E0&&(a=Ade(t[0],t[d-1])),s=d>2?kde:Nde,c=l=null,u}function u(d){return d==null||isNaN(d=+d)?o:(c||(c=s(t.map(n),e,r)))(n(a(d)))}return u.invert=function(d){return a(i((l||(l=s(e,t.map(n),Jy)))(d)))},u.domain=function(d){return arguments.length?(t=Array.from(d,Lde),f()):t.slice()},u.range=function(d){return arguments.length?(e=Array.from(d),f()):e.slice()},u.rangeRound=function(d){return e=Array.from(d),r=Pde,f()},u.clamp=function(d){return arguments.length?(a=d?!0:E0,f()):a!==E0},u.interpolate=function(d){return arguments.length?(r=d,f()):r},u.unknown=function(d){return arguments.length?(o=d,u):o},function(d,h){return n=d,i=h,f()}}function Ude(){return Fde()(E0,E0)}function Bde(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)}function Zy(t,e){if((r=(t=e?t.toExponential(e-1):t.toExponential()).indexOf("e"))<0)return null;var r,n=t.slice(0,r);return[n.length>1?n[0]+n.slice(2):n,+t.slice(r+1)]}function bh(t){return t=Zy(Math.abs(t)),t?t[1]:NaN}function Gde(t,e){return function(r,n){for(var i=r.length,o=[],a=0,s=t[0],c=0;i>0&&s>0&&(c+s+1>n&&(s=Math.max(1,n-c)),o.push(r.substring(i-=s,i+s)),!((c+=s+1)>n));)s=t[a=(a+1)%t.length];return o.reverse().join(e)}}function Wde(t){return function(e){return e.replace(/[0-9]/g,function(r){return t[+r]})}}var zde=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Qy(t){if(!(e=zde.exec(t)))throw new Error("invalid format: "+t);var e;return new SE({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]})}Qy.prototype=SE.prototype;function SE(t){this.fill=t.fill===void 0?" ":t.fill+"",this.align=t.align===void 0?">":t.align+"",this.sign=t.sign===void 0?"-":t.sign+"",this.symbol=t.symbol===void 0?"":t.symbol+"",this.zero=!!t.zero,this.width=t.width===void 0?void 0:+t.width,this.comma=!!t.comma,this.precision=t.precision===void 0?void 0:+t.precision,this.trim=!!t.trim,this.type=t.type===void 0?"":t.type+""}SE.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 $de(t){e:for(var e=t.length,r=1,n=-1,i;r<e;++r)switch(t[r]){case".":n=i=r;break;case"0":n===0&&(n=r),i=r;break;default:if(!+t[r])break e;n>0&&(n=0);break}return n>0?t.slice(0,n)+t.slice(i+1):t}var GV;function jde(t,e){var r=Zy(t,e);if(!r)return t+"";var n=r[0],i=r[1],o=i-(GV=Math.max(-8,Math.min(8,Math.floor(i/3)))*3)+1,a=n.length;return o===a?n:o>a?n+new Array(o-a+1).join("0"):o>0?n.slice(0,o)+"."+n.slice(o):"0."+new Array(1-o).join("0")+Zy(t,Math.max(0,e+o-1))[0]}function A9(t,e){var r=Zy(t,e);if(!r)return t+"";var n=r[0],i=r[1];return i<0?"0."+new Array(-i).join("0")+n:n.length>i+1?n.slice(0,i+1)+"."+n.slice(i+1):n+new Array(i-n.length+2).join("0")}const N9={"%":(t,e)=>(t*100).toFixed(e),b:t=>Math.round(t).toString(2),c:t=>t+"",d:Bde,e:(t,e)=>t.toExponential(e),f:(t,e)=>t.toFixed(e),g:(t,e)=>t.toPrecision(e),o:t=>Math.round(t).toString(8),p:(t,e)=>A9(t*100,e),r:A9,s:jde,X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function k9(t){return t}var V9=Array.prototype.map,F9=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function Hde(t){var e=t.grouping===void 0||t.thousands===void 0?k9:Gde(V9.call(t.grouping,Number),t.thousands+""),r=t.currency===void 0?"":t.currency[0]+"",n=t.currency===void 0?"":t.currency[1]+"",i=t.decimal===void 0?".":t.decimal+"",o=t.numerals===void 0?k9:Wde(V9.call(t.numerals,String)),a=t.percent===void 0?"%":t.percent+"",s=t.minus===void 0?"−":t.minus+"",c=t.nan===void 0?"NaN":t.nan+"";function l(u){u=Qy(u);var d=u.fill,h=u.align,g=u.sign,p=u.symbol,v=u.zero,y=u.width,m=u.comma,w=u.precision,x=u.trim,C=u.type;C==="n"?(m=!0,C="g"):N9[C]||(w===void 0&&(w=12),x=!0,C="g"),(v||d==="0"&&h==="=")&&(v=!0,d="0",h="=");var S=p==="$"?r:p==="#"&&/[boxX]/.test(C)?"0"+C.toLowerCase():"",T=p==="$"?n:/[%p]/.test(C)?a:"",_=N9[C],E=/[defgprs%]/.test(C);w=w===void 0?6:/[gprs]/.test(C)?Math.max(1,Math.min(21,w)):Math.max(0,Math.min(20,w));function b(D){var I=S,P=T,O,L,B;if(C==="c")P=_(D)+P,D="";else{D=+D;var H=D<0||1/D<0;if(D=isNaN(D)?c:_(Math.abs(D),w),x&&(D=$de(D)),H&&+D==0&&g!=="+"&&(H=!1),I=(H?g==="("?g:s:g==="-"||g==="("?"":g)+I,P=(C==="s"?F9[8+GV/3]:"")+P+(H&&g==="("?")":""),E){for(O=-1,L=D.length;++O<L;)if(B=D.charCodeAt(O),48>B||B>57){P=(B===46?i+D.slice(O+1):D.slice(O))+P,D=D.slice(0,O);break}}}m&&!v&&(D=e(D,1/0));var A=I.length+D.length+P.length,F=A<y?new Array(y-A+1).join(d):"";switch(m&&v&&(D=e(F+D,F.length?y-P.length:1/0),F=""),h){case"<":D=I+D+P+F;break;case"=":D=I+F+D+P;break;case"^":D=F.slice(0,A=F.length>>1)+I+D+P+F.slice(A);break;default:D=F+I+D+P;break}return o(D)}return b.toString=function(){return u+""},b}function f(u,d){var h=l((u=Qy(u),u.type="f",u)),g=Math.max(-8,Math.min(8,Math.floor(bh(d)/3)))*3,p=Math.pow(10,-g),v=F9[8+g/3];return function(y){return h(p*y)+v}}return{format:l,formatPrefix:f}}var _2,WV,zV;Kde({thousands:",",grouping:[3],currency:["$",""]});function Kde(t){return _2=Hde(t),WV=_2.format,zV=_2.formatPrefix,_2}function qde(t){return Math.max(0,-bh(Math.abs(t)))}function Xde(t,e){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(bh(e)/3)))*3-bh(Math.abs(t)))}function Yde(t,e){return t=Math.abs(t),e=Math.abs(e)-t,Math.max(0,bh(e)-bh(t))+1}function Jde(t,e,r,n){var i=nde(t,e,r),o;switch(n=Qy(n??",f"),n.type){case"s":{var a=Math.max(Math.abs(t),Math.abs(e));return n.precision==null&&!isNaN(o=Xde(i,a))&&(n.precision=o),zV(n,a)}case"":case"e":case"g":case"p":case"r":{n.precision==null&&!isNaN(o=Yde(i,Math.max(Math.abs(t),Math.abs(e))))&&(n.precision=o-(n.type==="e"));break}case"f":case"%":{n.precision==null&&!isNaN(o=qde(i))&&(n.precision=o-(n.type==="%")*2);break}}return WV(n)}function Zde(t){var e=t.domain;return t.ticks=function(r){var n=e();return tde(n[0],n[n.length-1],r??10)},t.tickFormat=function(r,n){var i=e();return Jde(i[0],i[i.length-1],r??10,n)},t.nice=function(r){r==null&&(r=10);var n=e(),i=0,o=n.length-1,a=n[i],s=n[o],c,l,f=10;for(s<a&&(l=a,a=s,s=l,l=i,i=o,o=l);f-- >0;){if(l=NS(a,s,r),l===c)return n[i]=a,n[o]=s,e(n);if(l>0)a=Math.floor(a/l)*l,s=Math.ceil(s/l)*l;else if(l<0)a=Math.ceil(a*l)/l,s=Math.floor(s*l)/l;else break;c=l}return t},t}function TE(){var t=Ude();return t.copy=function(){return Vde(t,TE())},ade.apply(t,arguments),Zde(t)}function Qde(t,e){e.classHierarchy.push("vtkTexture"),t.imageLoaded=()=>{e.image.removeEventListener("load",t.imageLoaded),e.imageLoaded=!0,t.modified()},t.setJsImageData=r=>{e.jsImageData!==r&&(r!==null&&(t.setInputData(null),t.setInputConnection(null),e.image=null,e.canvas=null),e.jsImageData=r,e.imageLoaded=!0,t.modified())},t.setCanvas=r=>{e.canvas!==r&&(r!==null&&(t.setInputData(null),t.setInputConnection(null),e.image=null,e.jsImageData=null),e.canvas=r,t.modified())},t.setImage=r=>{e.image!==r&&(r!==null&&(t.setInputData(null),t.setInputConnection(null),e.canvas=null,e.jsImageData=null),e.image=r,e.imageLoaded=!1,r.complete?t.imageLoaded():r.addEventListener("load",t.imageLoaded),t.modified())},t.getDimensionality=()=>{let r=0,n=0,i=1;if(t.getInputData()){const a=t.getInputData();r=a.getDimensions()[0],n=a.getDimensions()[1],i=a.getDimensions()[2]}return e.jsImageData&&(r=e.jsImageData.width,n=e.jsImageData.height),e.canvas&&(r=e.canvas.width,n=e.canvas.height),e.image&&(r=e.image.width,n=e.image.height),(r>1)+(n>1)+(i>1)},t.getInputAsJsImageData=()=>{if(!e.imageLoaded||t.getInputData())return null;if(e.jsImageData)return e.jsImageData();if(e.canvas)return e.canvas.getContext("2d").getImageData(0,0,e.canvas.width,e.canvas.height);if(e.image){const r=document.createElement("canvas");r.width=e.image.width,r.height=e.image.height;const n=r.getContext("2d");return n.translate(0,r.height),n.scale(1,-1),n.drawImage(e.image,0,0,e.image.width,e.image.height),n.getImageData(0,0,r.width,r.height)}return null}}const e0e=(t,e,r,n)=>{const i=[1,2,1],o=4,a=i,s=o,c=t.length/(e*r);let l=e,f=r,u=t;const d=[u];for(let h=0;h<n;h++){const g=[...u];l/=2,f/=2,u=new Uint8ClampedArray(l*f*c);const p=c*l;let v=0;for(let m=0;m<u.length;m+=c){m%p===0&&(v+=2*c*l);for(let w=0;w<c;w++){let x=g[v+w];x+=g[v+c+w],x+=g[v-2*p+w],x+=g[v-2*p+c+w],x/=4,u[m+w]=x}v+=2*c}let y=[...u];for(let m=0;m<u.length;m+=c)for(let w=0;w<c;w++){let x=-(a.length-1)/2,C=s,S=0;for(let T=0;T<a.length;T++){let _=m+w+x*c;const E=_%p-(m+w)%p;E>c&&(_+=p),E<-c&&(_-=p),y[_]?S+=y[_]*a[T]:C-=a[T],x+=1}u[m+w]=S/C}y=[...u];for(let m=0;m<u.length;m+=c)for(let w=0;w<c;w++){let x=-(a.length-1)/2,C=s,S=0;for(let T=0;T<a.length;T++){const _=m+w+x*p;y[_]?S+=y[_]*a[T]:C-=a[T],x+=1}u[m+w]=S/C}d.push(u)}return d},t0e={image:null,canvas:null,jsImageData:null,imageLoaded:!1,repeat:!1,interpolate:!1,edgeClamp:!1,mipLevel:0,resizable:!1};function $V(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,t0e,r),Z.obj(t,e),Z.algo(t,e,6,0),Z.get(t,e,["canvas","image","jsImageData","imageLoaded","resizable"]),Z.setGet(t,e,["repeat","edgeClamp","interpolate","mipLevel"]),Qde(t,e)}const n0e=Z.newInstance($V,"vtkTexture"),r0e={generateMipmaps:e0e};var Bd={newInstance:n0e,extend:$V,...r0e};const i0e=[[-1,0,0],[1,0,0],[0,-1,0],[0,1,0],[0,0,-1],[0,0,1]],U9=[[8,7,11,3],[9,1,10,5],[4,9,0,8],[2,11,6,10],[0,3,2,1],[4,5,6,7]],E2=[[0,1],[1,3],[2,3],[0,2],[4,5],[5,7],[6,7],[4,6],[0,4],[1,5],[3,7],[2,6]],B9=[0,1,0,1,0,1,0,1,2,2,2,2],Pr=[[1,2],[1,2],[0,2],[0,2],[0,1],[0,1]],tn=new Float64Array(3),b2=new Float64Array(3),qn=new Float64Array(3),Yf=new Float64Array(3),Nf=new Float64Array(3),D2=new Float64Array(3),pC=new Float64Array(16);function mC(t,e){t.strokeStyle=e.strokeColor,t.lineWidth=e.strokeSize,t.fillStyle=e.fontColor,t.font=`${e.fontStyle} ${e.fontSize}px ${e.fontFamily}`}function jV(t){const e=[],r=[];for(let n=0;n<3;n++){const i=TE().domain([t[n*2],t[n*2+1]]);e[n]=i.ticks(5);const o=i.tickFormat(5);r[n]=e[n].map(o)}return{ticks:e,tickStrings:r}}function o0e(t,e){e.classHierarchy.push("vtkCubeAxesActorHelper"),t.setRenderable=r=>{e.renderable!==r&&(e.renderable=r,e.tmActor.addTexture(e.renderable.getTmTexture()),e.tmActor.setProperty(r.getProperty()),e.tmActor.setParentProp(r),t.modified())},t.createPolyDataForOneLabel=(r,n,i,o,a,s,c)=>{const l=e.renderable.get_tmAtlas().get(r);if(!l)return;const f=e.renderable.getTextPolyData().getPoints().getData(),u=e.lastSize;tn[0]=f[n*3],tn[1]=f[n*3+1],tn[2]=f[n*3+2],At(qn,tn,i),qn[0]+=.1,At(b2,qn,o),Nn(Nf,b2,tn),qn[0]-=.1,qn[1]+=.1,At(b2,qn,o),Nn(D2,b2,tn);for(let g=0;g<3;g++)Nf[g]/=.5*.1*u[0],D2[g]/=.5*.1*u[1];let d=c.ptIdx,h=c.cellIdx;tn[0]=f[n*3],tn[1]=f[n*3+1],tn[2]=f[n*3+2],a[0]<-.5?gr(qn,Nf,a[0]*s-l.width):a[0]>.5?gr(qn,Nf,a[0]*s):gr(qn,Nf,a[0]*s-l.width/2),Hr(tn,tn,qn),gr(qn,D2,a[1]*s-l.height/2),Hr(tn,tn,qn),c.points[d*3]=tn[0],c.points[d*3+1]=tn[1],c.points[d*3+2]=tn[2],c.tcoords[d*2]=l.tcoords[0],c.tcoords[d*2+1]=l.tcoords[1],d++,gr(qn,Nf,l.width),Hr(tn,tn,qn),c.points[d*3]=tn[0],c.points[d*3+1]=tn[1],c.points[d*3+2]=tn[2],c.tcoords[d*2]=l.tcoords[2],c.tcoords[d*2+1]=l.tcoords[3],d++,gr(qn,D2,l.height),Hr(tn,tn,qn),c.points[d*3]=tn[0],c.points[d*3+1]=tn[1],c.points[d*3+2]=tn[2],c.tcoords[d*2]=l.tcoords[4],c.tcoords[d*2+1]=l.tcoords[5],d++,gr(qn,Nf,l.width),Nn(tn,tn,qn),c.points[d*3]=tn[0],c.points[d*3+1]=tn[1],c.points[d*3+2]=tn[2],c.tcoords[d*2]=l.tcoords[6],c.tcoords[d*2+1]=l.tcoords[7],d++,c.polys[h*4]=3,c.polys[h*4+1]=d-4,c.polys[h*4+2]=d-3,c.polys[h*4+3]=d-2,h++,c.polys[h*4]=3,c.polys[h*4+1]=d-4,c.polys[h*4+2]=d-2,c.polys[h*4+3]=d-1,c.ptIdx+=4,c.cellIdx+=2},t.updateTexturePolyData=()=>{const r=e.camera.getCompositeProjectionMatrix(e.lastAspectRatio,-1,1);un(r,r);const n=e.renderable.getTextValues().length,i=n*4,o=n*2,a=new Float64Array(i*3),s=new Uint16Array(o*4),c=new Float32Array(i*2);Ar(pC,r);const l={ptIdx:0,cellIdx:0,polys:s,points:a,tcoords:c};let f=0,u=0,d=0;const h=e.renderable.getTextPolyData().getPoints().getData(),g=e.renderable.getTextValues();for(;f<h.length/3;){tn[0]=h[f*3],tn[1]=h[f*3+1],tn[2]=h[f*3+2],At(qn,tn,r),tn[0]=h[f*3+3],tn[1]=h[f*3+4],tn[2]=h[f*3+5],At(Yf,tn,r),Nn(qn,qn,Yf);const v=[qn[0],qn[1]];cR(v),t.createPolyDataForOneLabel(g[u],f,r,pC,v,e.renderable.getAxisTitlePixelOffset(),l),f+=2,u++;for(let y=0;y<e.renderable.getTickCounts()[d];y++)t.createPolyDataForOneLabel(g[u],f,r,pC,v,e.renderable.getTickLabelPixelOffset(),l),f++,u++;d++}const p=bt.newInstance({numberOfComponents:2,values:c,name:"TextureCoordinates"});e.tmPolyData.getPointData().setTCoords(p),e.tmPolyData.getPoints().setData(a,3),e.tmPolyData.getPoints().modified(),e.tmPolyData.getPolys().setData(s,1),e.tmPolyData.getPolys().modified(),e.tmPolyData.modified()},t.updateAPISpecificData=(r,n,i)=>{(e.lastSize[0]!==r[0]||e.lastSize[1]!==r[1])&&(e.lastSize[0]=r[0],e.lastSize[1]=r[1],e.lastAspectRatio=r[0]/r[1],e.forceUpdate=!0),e.camera=n,t.updateTexturePolyData()}}const a0e=Z.newInstance(function(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{renderable:null};Object.assign(e,{},r),Z.obj(t,e),e.tmPolyData=Er.newInstance(),e.tmMapper=la.newInstance(),e.tmMapper.setInputData(e.tmPolyData),e.tmActor=uc.newInstance({parentProp:t}),e.tmActor.setMapper(e.tmMapper),Z.setGet(t,e,["renderable"]),Z.get(t,e,["lastSize","lastAspectRatio","axisTextStyle","tickTextStyle","tmActor","ticks"]),e.forceUpdate=!1,e.lastRedrawTime={},Z.obj(e.lastRedrawTime,{mtime:0}),e.lastRebuildTime={},Z.obj(e.lastRebuildTime,{mtime:0}),e.lastSize=[-1,-1],e.lastTickBounds=[],o0e(t,e)},"vtkCubeAxesActorHelper");function s0e(t,e){e.classHierarchy.push("vtkCubeAxesActor"),t.setCamera=n=>{e.camera!==n&&(e.cameraModifiedSub&&(e.cameraModifiedSub.unsubscribe(),e.cameraModifiedSub=null),e.camera=n,n&&(e.cameraModifiedSub=n.onModified(t.update)),t.update(),t.modified())},t.computeFacesToDraw=()=>{const n=e.camera.getViewMatrix();un(n,n);let i=!1;const o=Hn.getDiagonalLength(e.dataBounds),a=Math.sin(e.faceVisibilityAngle*Math.PI/180);for(let s=0;s<6;s++){let c=!1;const l=Math.floor(s/2),f=(l+1)%3,u=(l+2)%3;e.dataBounds[f*2]!==e.dataBounds[f*2+1]&&e.dataBounds[u*2]!==e.dataBounds[u*2+1]&&(tn[l]=e.dataBounds[s]-.1*o*i0e[s][l],tn[f]=.5*(e.dataBounds[f*2]+e.dataBounds[f*2+1]),tn[u]=.5*(e.dataBounds[u*2]+e.dataBounds[u*2+1]),At(qn,tn,n),tn[l]=e.dataBounds[s],At(Yf,tn,n),Nn(qn,Yf,qn),Un(qn,qn),c=qn[2]>a,e.camera.getParallelProjection()||(Un(Yf,Yf),c=xt(Yf,qn)>a)),c!==e.lastFacesToDraw[s]&&(e.lastFacesToDraw[s]=c,i=!0)}return i},t.updatePolyData=(n,i,o)=>{let a=0,s=0;a+=8;let c=0;for(let h=0;h<12;h++)i[h]>0&&c++;if(s+=c,e.gridLines)for(let h=0;h<6;h++)n[h]&&(a+=o[Pr[h][0]].length*2+o[Pr[h][1]].length*2,s+=o[Pr[h][0]].length+o[Pr[h][1]].length);const l=new Float64Array(a*3),f=new Uint32Array(s*3);let u=0,d=0;for(let h=0;h<2;h++)for(let g=0;g<2;g++)for(let p=0;p<2;p++)l[u*3]=e.dataBounds[p],l[u*3+1]=e.dataBounds[2+g],l[u*3+2]=e.dataBounds[4+h],u++;for(let h=0;h<12;h++)i[h]>0&&(f[d*3]=2,f[d*3+1]=E2[h][0],f[d*3+2]=E2[h][1],d++);if(e.gridLines){for(let h=0;h<6;h++)if(n[h]){const g=Math.floor(h/2);let p=o[Pr[h][0]];for(let v=0;v<p.length;v++)l[u*3+g]=e.dataBounds[h],l[u*3+Pr[h][0]]=p[v],l[u*3+Pr[h][1]]=e.dataBounds[Pr[h][1]*2],u++,l[u*3+g]=e.dataBounds[h],l[u*3+Pr[h][0]]=p[v],l[u*3+Pr[h][1]]=e.dataBounds[Pr[h][1]*2+1],u++,f[d*3]=2,f[d*3+1]=u-2,f[d*3+2]=u-1,d++;p=o[Pr[h][1]];for(let v=0;v<p.length;v++)l[u*3+g]=e.dataBounds[h],l[u*3+Pr[h][1]]=p[v],l[u*3+Pr[h][0]]=e.dataBounds[Pr[h][0]*2],u++,l[u*3+g]=e.dataBounds[h],l[u*3+Pr[h][1]]=p[v],l[u*3+Pr[h][0]]=e.dataBounds[Pr[h][0]*2+1],u++,f[d*3]=2,f[d*3+1]=u-2,f[d*3+2]=u-1,d++}}e.polyData.getPoints().setData(l,3),e.polyData.getPoints().modified(),e.polyData.getLines().setData(f,1),e.polyData.getLines().modified(),e.polyData.modified()},t.updateTextData=(n,i,o,a)=>{let s=0;for(let h=0;h<12;h++)i[h]===1&&(s+=2,s+=o[B9[h]].length);const c=e.polyData.getPoints().getData(),l=new Float64Array(s*3);let f=0,u=0,d=0;for(let h=0;h<6;h++)if(n[h])for(let g=0;g<4;g++){const p=U9[h][g];if(i[p]===1){const v=B9[p],y=E2[p][0]*3,m=E2[p][1]*3;l[f*3]=.5*(c[y]+c[m]),l[f*3+1]=.5*(c[y+1]+c[m+1]),l[f*3+2]=.5*(c[y+2]+c[m+2]),f++;const w=Math.floor(h/2);l[f*3+w]=e.dataBounds[h],l[f*3+Pr[h][0]]=.5*(e.dataBounds[Pr[h][0]*2]+e.dataBounds[Pr[h][0]*2+1]),l[f*3+Pr[h][1]]=.5*(e.dataBounds[Pr[h][1]*2]+e.dataBounds[Pr[h][1]*2+1]),f++,e.textValues[u]=e.axisLabels[v],u++;const x=(v+1)%3,C=(v+2)%3,S=o[v],T=a[v];e.tickCounts[d]=S.length;for(let _=0;_<S.length;_++)l[f*3+v]=S[_],l[f*3+x]=c[y+x],l[f*3+C]=c[y+C],f++,e.textValues[u]=T[_],u++;d++}}e.textPolyData.getPoints().setData(l,3),e.textPolyData.modified()},t.update=()=>{if(!e.camera)return;const n=t.computeFacesToDraw(),i=e.lastFacesToDraw;let o=!1;for(let a=0;a<6;a++)e.dataBounds[a]!==e.lastTickBounds[a]&&(o=!0,e.lastTickBounds[a]=e.dataBounds[a]);if(n||o||e.forceUpdate){const a=new Array(12).fill(0);for(let c=0;c<6;c++)if(i[c])for(let l=0;l<4;l++)a[U9[c][l]]++;const s=e.generateTicks(e.dataBounds);t.updatePolyData(i,a,s.ticks),t.updateTextData(i,a,s.ticks,s.tickStrings),(o||e.forceUpdate)&&t.updateTextureAtlas(s.tickStrings)}e.forceUpdate=!1},t.updateTextureAtlas=n=>{e.tmContext.textBaseline="bottom",e.tmContext.textAlign="left",e._tmAtlas.clear();let i=0,o=1;for(let a=0;a<3;a++){if(!e._tmAtlas.has(e.axisLabels[a])){mC(e.tmContext,e.axisTextStyle);const s=e.tmContext.measureText(e.axisLabels[a]),c={height:s.actualBoundingBoxAscent+2,startingHeight:o,width:s.width+2,textStyle:e.axisTextStyle};e._tmAtlas.set(e.axisLabels[a],c),o+=c.height,i<c.width&&(i=c.width)}mC(e.tmContext,e.tickTextStyle);for(let s=0;s<n[a].length;s++)if(!e._tmAtlas.has(n[a][s])){const c=e.tmContext.measureText(n[a][s]),l={height:c.actualBoundingBoxAscent+2,startingHeight:o,width:c.width+2,textStyle:e.tickTextStyle};e._tmAtlas.set(n[a][s],l),o+=l.height,i<l.width&&(i=l.width)}}i=us(i),o=us(o),e._tmAtlas.forEach(a=>{a.tcoords=[0,(o-a.startingHeight-a.height)/o,a.width/i,(o-a.startingHeight-a.height)/o,a.width/i,(o-a.startingHeight)/o,0,(o-a.startingHeight)/o]}),e.tmCanvas.width=i,e.tmCanvas.height=o,e.tmContext.textBaseline="bottom",e.tmContext.textAlign="left",e.tmContext.clearRect(0,0,i,o),e._tmAtlas.forEach((a,s)=>{mC(e.tmContext,a.textStyle),e.tmContext.fillText(s,1,a.startingHeight+a.height-1)}),e.tmTexture.setCanvas(e.tmCanvas),e.tmTexture.modified()},t.onModified(()=>{e.forceUpdate=!0,t.update()}),t.setTickTextStyle=n=>{e.tickTextStyle={...e.tickTextStyle,...n},t.modified()},t.setAxisTextStyle=n=>{e.axisTextStyle={...e.axisTextStyle,...n},t.modified()},t.get_tmAtlas=()=>e._tmAtlas,t.getBounds=()=>(t.update(),Hn.setBounds(e.bounds,e.gridActor.getBounds()),Hn.scaleAboutCenter(e.bounds,e.boundsScaleFactor,e.boundsScaleFactor,e.boundsScaleFactor),e.bounds);const r=Z.chain(t.setProperty,e.gridActor.setProperty);t.setProperty=n=>r(n)[0]}function c0e(t,e,r){return{boundsScaleFactor:1.3,camera:null,dataBounds:[...Hn.INIT_BOUNDS],faceVisibilityAngle:8,gridLines:!0,axisLabels:null,axisTitlePixelOffset:35,tickLabelPixelOffset:12,generateTicks:jV,...r,axisTextStyle:{fontColor:"white",fontStyle:"normal",fontSize:18,fontFamily:"serif",...r==null?void 0:r.axisTextStyle},tickTextStyle:{fontColor:"white",fontStyle:"normal",fontSize:14,fontFamily:"serif",...r==null?void 0:r.tickTextStyle}}}function HV(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};uc.extend(t,e,c0e(t,e,r)),e.lastFacesToDraw=[!1,!1,!1,!1,!1,!1],e.axisLabels=["X-Axis","Y-Axis","Z-Axis"],e.tickCounts=[],e.textValues=[],e.lastTickBounds=[],e.tmCanvas=document.createElement("canvas"),e.tmContext=e.tmCanvas.getContext("2d"),e._tmAtlas=new Map,e.tmTexture=Bd.newInstance({resizable:!0}),e.tmTexture.setInterpolate(!1),t.getProperty().setDiffuse(0),t.getProperty().setAmbient(1),e.gridMapper=la.newInstance(),e.polyData=Er.newInstance(),e.gridMapper.setInputData(e.polyData),e.gridActor=uc.newInstance(),e.gridActor.setMapper(e.gridMapper),e.gridActor.setProperty(t.getProperty()),e.gridActor.setParentProp(t),e.textPolyData=Er.newInstance(),Z.setGet(t,e,["axisTitlePixelOffset","boundsScaleFactor","faceVisibilityAngle","gridLines","tickLabelPixelOffset","generateTicks"]),Z.setGetArray(t,e,["dataBounds"],6),Z.setGetArray(t,e,["axisLabels"],3),Z.get(t,e,["axisTextStyle","tickTextStyle","camera","tmTexture","textValues","textPolyData","tickCounts","gridActor"]),s0e(t,e)}const l0e=Z.newInstance(HV,"vtkCubeAxesActor");var KV={newInstance:l0e,extend:HV,newCubeAxesActorHelper:a0e,defaultGenerateTicks:jV};function u0e(t,e){e.classHierarchy.push("vtkOpenGLCubeAxesActor"),t.buildPass=r=>{r&&(e._openGLRenderer=t.getFirstAncestorOfType("vtkOpenGLRenderer"),e._openGLRenderWindow=e._openGLRenderer.getParent(),e.CubeAxesActorHelper.getRenderable()||e.CubeAxesActorHelper.setRenderable(e.renderable),t.prepareNodes(),t.addMissingNode(e.CubeAxesActorHelper.getTmActor()),t.addMissingNode(e.renderable.getGridActor()),t.removeUnusedNodes())},t.opaquePass=(r,n)=>{if(r){const i=e._openGLRenderer?e._openGLRenderer.getRenderable().getActiveCamera():null,o=e._openGLRenderer.getTiledSizeAndOrigin();e.CubeAxesActorHelper.updateAPISpecificData([o.usize,o.vsize],i,e._openGLRenderWindow.getRenderable())}}}const f0e={};function d0e(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,f0e,r),Qn.extend(t,e,r),e.CubeAxesActorHelper=KV.newCubeAxesActorHelper(),u0e(t,e)}const h0e=Rn(d0e,"vtkOpenGLCubeAxesActor");di("vtkCubeAxesActor",h0e);const{ColorMode:g0e,ScalarMode:kf,GetArray:vC}=aw;function p0e(t,e){e.classHierarchy.push("vtkMapper2D"),t.createDefaultLookupTable=()=>{e.lookupTable=Iy.newInstance()},t.getColorModeAsString=()=>Z.enumToString(g0e,e.colorMode),t.setColorModeToDefault=()=>t.setColorMode(0),t.setColorModeToMapScalars=()=>t.setColorMode(1),t.setColorModeToDirectScalars=()=>t.setColorMode(2),t.getScalarModeAsString=()=>Z.enumToString(kf,e.scalarMode),t.setScalarModeToDefault=()=>t.setScalarMode(0),t.setScalarModeToUsePointData=()=>t.setScalarMode(1),t.setScalarModeToUseCellData=()=>t.setScalarMode(2),t.setScalarModeToUsePointFieldData=()=>t.setScalarMode(3),t.setScalarModeToUseCellFieldData=()=>t.setScalarMode(4),t.setScalarModeToUseFieldData=()=>t.setScalarMode(5),t.getAbstractScalars=(r,n,i,o,a)=>{if(!r||!e.scalarVisibility)return{scalars:null,cellFLag:!1};let s=null,c=!1;if(n===kf.DEFAULT)s=r.getPointData().getScalars(),s||(s=r.getCellData().getScalars(),c=!0);else if(n===kf.USE_POINT_DATA)s=r.getPointData().getScalars();else if(n===kf.USE_CELL_DATA)s=r.getCellData().getScalars(),c=!0;else if(n===kf.USE_POINT_FIELD_DATA){const l=r.getPointData();i===vC.BY_ID?s=l.getArrayByIndex(o):s=l.getArrayByName(a)}else if(n===kf.USE_CELL_FIELD_DATA){const l=r.getCellData();c=!0,i===vC.BY_ID?s=l.getArrayByIndex(o):s=l.getArrayByName(a)}else if(n===kf.USE_FIELD_DATA){const l=r.getFieldData();i===vC.BY_ID?s=l.getArrayByIndex(o):s=l.getArrayByName(a)}return{scalars:s,cellFlag:c}},t.getLookupTable=()=>(e.lookupTable||t.createDefaultLookupTable(),e.lookupTable),t.getMTime=()=>{let r=e.mtime;if(e.lookupTable!==null){const n=e.lookupTable.getMTime();r=n>r?n:r}return r},t.mapScalars=(r,n)=>{const i=t.getAbstractScalars(r,e.scalarMode,e.arrayAccessMode,e.arrayId,e.colorByArrayName).scalars;if(!i){e.colorMapColors=null;return}const o=`${t.getMTime()}${i.getMTime()}${n}`;if(e.colorBuildString===o)return;e.useLookupTableScalarRange||t.getLookupTable().setRange(e.scalarRange[0],e.scalarRange[1]);const a=t.getLookupTable();a&&(a.build(),e.colorMapColors=a.mapScalars(i,e.colorMode,e.fieldDataTupleId)),e.colorBuildString=`${t.getMTime()}${i.getMTime()}${n}`},t.getPrimitiveCount=()=>{const r=t.getInputData();return{points:r.getPoints().getNumberOfValues()/3,verts:r.getVerts().getNumberOfValues()-r.getVerts().getNumberOfCells(),lines:r.getLines().getNumberOfValues()-2*r.getLines().getNumberOfCells(),triangles:r.getPolys().getNumberOfValues()-3*r.getPolys().getNumberOfCells()}}}const m0e={static:!1,lookupTable:null,scalarVisibility:!1,scalarRange:[0,1],useLookupTableScalarRange:!1,colorMode:0,scalarMode:0,arrayAccessMode:1,renderTime:0,colorByArrayName:null,transformCoordinate:null,viewSpecificProperties:null,customShaderAttributes:[]};function v0e(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,m0e,r),ML.extend(t,e,r),Z.get(t,e,["colorMapColors"]),Z.setGet(t,e,["arrayAccessMode","colorByArrayName","colorMode","lookupTable","renderTime","scalarMode","scalarVisibility","static","transformCoordinate","useLookupTableScalarRange","viewSpecificProperties","customShaderAttributes"]),Z.setGetArray(t,e,["scalarRange"],2),e.viewSpecificProperties||(e.viewSpecificProperties={}),p0e(t,e)}Z.newInstance(v0e,"vtkMapper2D");var y0e={},w0e=`//VTK::System::Dec
|
||
|
||
/*=========================================================================
|
||
|
||
Program: Visualization Toolkit
|
||
Module: vtkPolyData2DFS.glsl
|
||
|
||
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
|
||
All rights reserved.
|
||
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
|
||
|
||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||
PURPOSE. See the above copyright notice for more information.
|
||
|
||
=========================================================================*/
|
||
|
||
uniform int PrimitiveIDOffset;
|
||
|
||
// Texture coordinates
|
||
//VTK::TCoord::Dec
|
||
|
||
// Scalar coloring
|
||
//VTK::Color::Dec
|
||
|
||
// Depth Peeling
|
||
//VTK::DepthPeeling::Dec
|
||
|
||
// picking support
|
||
//VTK::Picking::Dec
|
||
|
||
// the output of this shader
|
||
//VTK::Output::Dec
|
||
|
||
// Apple Bug
|
||
//VTK::PrimID::Dec
|
||
|
||
void main()
|
||
{
|
||
// Apple Bug
|
||
//VTK::PrimID::Impl
|
||
|
||
//VTK::Color::Impl
|
||
//VTK::TCoord::Impl
|
||
|
||
//VTK::DepthPeeling::Impl
|
||
//VTK::Picking::Impl
|
||
|
||
if (gl_FragData[0].a <= 0.0)
|
||
{
|
||
discard;
|
||
}
|
||
}
|
||
`,x0e=`//VTK::System::Dec
|
||
|
||
/*=========================================================================
|
||
|
||
Program: Visualization Toolkit
|
||
Module: vtkPolyData2DVS.glsl
|
||
|
||
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
|
||
All rights reserved.
|
||
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
|
||
|
||
This software is distributed WITHOUT ANY WARRANTY; without even
|
||
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||
PURPOSE. See the above copyright notice for more information.
|
||
|
||
=========================================================================*/
|
||
|
||
// all variables that represent positions or directions have a suffix
|
||
// indicating the coordinate system they are in. The possible values are
|
||
// MC - Model Coordinates
|
||
// WC - WC world coordinates
|
||
// VC - View Coordinates
|
||
// DC - Display Coordinates
|
||
|
||
in vec4 vertexWC;
|
||
|
||
// frag position in VC
|
||
//VTK::PositionVC::Dec
|
||
|
||
// material property values
|
||
//VTK::Color::Dec
|
||
|
||
// Texture coordinates
|
||
//VTK::TCoord::Dec
|
||
|
||
// Apple Bug
|
||
//VTK::PrimID::Dec
|
||
|
||
uniform mat4 WCVCMatrix; // World to view matrix
|
||
|
||
void main()
|
||
{
|
||
// Apple Bug
|
||
//VTK::PrimID::Impl
|
||
|
||
gl_Position = WCVCMatrix*vertexWC;
|
||
|
||
//VTK::TCoord::Impl
|
||
|
||
//VTK::Color::Impl
|
||
|
||
//VTK::PositionVC::Impl
|
||
}
|
||
`;const qV={BACKGROUND:0,FOREGROUND:1};var XV={DisplayLocation:qV};const{primTypes:Ks}=ul,{ScalarMode:I2}=y0e,{vtkErrorMacro:O2}=uo,C0e={type:"StartEvent"},S0e={type:"EndEvent"};function T0e(t,e){e.classHierarchy.push("vtkOpenGLPolyDataMapper2D"),t.buildPass=n=>{n&&(e.openGLActor2D=t.getFirstAncestorOfType("vtkOpenGLActor2D"),e._openGLRenderer=e.openGLActor2D.getFirstAncestorOfType("vtkOpenGLRenderer"),e._openGLRenderWindow=e._openGLRenderer.getLastAncestorOfType("vtkOpenGLRenderWindow"),e.openGLCamera=e._openGLRenderer.getViewNodeFor(e._openGLRenderer.getRenderable().getActiveCamera()))},t.overlayPass=n=>{n&&t.render()},t.getShaderTemplate=(n,i,o)=>{n.Vertex=x0e,n.Fragment=w0e,n.Geometry=""},t.render=()=>{const n=e._openGLRenderWindow.getContext();if(e.context!==n){e.context=n;for(let a=Ks.Start;a<Ks.End;a++)e.primitives[a].setOpenGLRenderWindow(e._openGLRenderWindow)}const i=e.openGLActor2D.getRenderable(),o=e._openGLRenderer.getRenderable();t.renderPiece(o,i)},t.renderPiece=(n,i)=>{if(t.invokeEvent(C0e),e.renderable.getStatic()||e.renderable.update(),e.currentInput=e.renderable.getInputData(),t.invokeEvent(S0e),!e.currentInput){O2("No input!");return}!e.currentInput.getPoints||!e.currentInput.getPoints().getNumberOfValues()||(t.renderPieceStart(n,i),t.renderPieceDraw(n,i),t.renderPieceFinish(n,i))},t.renderPieceStart=(n,i)=>{if(e.primitiveIDOffset=0,e._openGLRenderer.getSelector())switch(e._openGLRenderer.getSelector().getCurrentPass()){default:e._openGLRenderer.getSelector().renderProp(i)}t.updateBufferObjects(n,i),e.lastBoundBO=null},t.getNeedToRebuildShaders=(n,i,o)=>n.getShaderSourceTime().getMTime()<e.renderable.getMTime()||n.getShaderSourceTime().getMTime()<e.currentInput.getMTime(),t.updateBufferObjects=(n,i)=>{t.getNeedToRebuildBufferObjects(n,i)&&t.buildBufferObjects(n,i)},t.getNeedToRebuildBufferObjects=(n,i)=>{const o=e.VBOBuildTime.getMTime();return!!(o<t.getMTime()||o<e._openGLRenderWindow.getMTime()||o<e.renderable.getMTime()||o<i.getMTime()||o<e.currentInput.getMTime()||e.renderable.getTransformCoordinate()&&o<n.getMTime())},t.buildBufferObjects=(n,i)=>{const o=e.currentInput;if(o===null)return;e.renderable.mapScalars(o,i.getProperty().getOpacity());const a=e.renderable.getColorMapColors();e.haveCellScalars=!1;const s=e.renderable.getScalarMode();e.renderable.getScalarVisibility()&&(s===I2.USE_CELL_DATA||s===I2.USE_CELL_FIELD_DATA||s===I2.USE_FIELD_DATA||!o.getPointData().getScalars())&&s!==I2.USE_POINT_FIELD_DATA&&a&&(e.haveCellScalars=!0);const c=i.getProperty().getRepresentation();let l=o.getPointData().getTCoords();e.openGLActor2D.getActiveTextures()||(l=null);const f=e.renderable.getTransformCoordinate(),d=n.getRenderWindow().getViews()[0].getViewportSize(n),h=`${o.getMTime()}A${c}B${o.getMTime()}C${a?a.getMTime():1}D${l?l.getMTime():1}E${f?n.getMTime():1}F${d}`;if(e.VBOBuildString!==h){let g=o.getPoints();if(f){const v=l1.newInstance(),y=g.getNumberOfPoints();v.setNumberOfPoints(y);const m=[];for(let w=0;w<y;++w){g.getPoint(w,m),f.setValue(m);const x=f.getComputedDoubleViewportValue(n);v.setPoint(w,x[0],x[1],0)}g=v}const p={points:g,tcoords:l,colors:a,cellOffset:0,haveCellScalars:e.haveCellSCalars,customAttributes:e.renderable.getCustomShaderAttributes().map(v=>o.getPointData().getArrayByName(v))};p.cellOffset+=e.primitives[Ks.Points].getCABO().createVBO(o.getVerts(),"verts",c,p),p.cellOffset+=e.primitives[Ks.Lines].getCABO().createVBO(o.getLines(),"lines",c,p),p.cellOffset+=e.primitives[Ks.Tris].getCABO().createVBO(o.getPolys(),"polys",c,p),p.cellOffset+=e.primitives[Ks.TriStrips].getCABO().createVBO(o.getStrips(),"strips",c,p),e.VBOBuildTime.modified(),e.VBOBuildString=h}},t.renderPieceDraw=(n,i)=>{const o=i.getProperty().getRepresentation();e.context.depthMask(!0);for(let s=Ks.Start;s<Ks.End;s++)e.primitives[s].getCABO().getElementCount()&&(e.lastBoundBO=e.primitives[s],e.primitiveIDOffset+=e.primitives[s].drawArrays(n,i,o,t))},t.renderPieceFinish=(n,i)=>{e.lastBoundBO&&e.lastBoundBO.getVAO().release()},t.replaceShaderValues=(n,i,o)=>{t.replaceShaderColor(n,i,o),t.replaceShaderTCoord(n,i,o),t.replaceShaderPicking(n,i,o),t.replaceShaderPositionVC(n,i,o)},t.replaceShaderColor=(n,i,o)=>{let a=n.Vertex,s=n.Geometry,c=n.Fragment;e.haveCellScalars&&(c=Be.substitute(c,"//VTK::Color::Dec",["uniform samplerBuffer texture1;"]).result,c=Be.substitute(c,"//VTK::Color::Impl",["gl_FragData[0] = texelFetchBuffer(texture1, gl_PrimitiveID + PrimitiveIDOffset);"]).result),e.lastBoundBO.getCABO().getColorComponents()!==0?(a=Be.substitute(a,"//VTK::Color::Dec",["in vec4 diffuseColor;","out vec4 fcolorVSOutput;"]).result,a=Be.substitute(a,"//VTK::Color::Impl",["fcolorVSOutput = diffuseColor;"]).result,s=Be.substitute(s,"//VTK::Color::Dec",[`in vec4 fcolorVSOutput[];
|
||
`,"out vec4 fcolorGSOutput;"]).result,s=Be.substitute(s,"//VTK::Color::Impl",["fcolorGSOutput = fcolorVSOutput[i];"]).result,c=Be.substitute(c,"//VTK::Color::Dec",["in vec4 fcolorVSOutput;"]).result,c=Be.substitute(c,"//VTK::Color::Impl",["gl_FragData[0] = fcolorVSOutput;"]).result):(c=Be.substitute(c,"//VTK::Color::Dec",["uniform vec4 diffuseColor;"]).result,c=Be.substitute(c,"//VTK::Color::Impl",["gl_FragData[0] = diffuseColor;"]).result),n.Vertex=a,n.Geometry=s,n.Fragment=c},t.replaceShaderTCoord=(n,i,o)=>{if(e.lastBoundBO.getCABO().getTCoordOffset()){let a=n.Vertex,s=n.Geometry,c=n.Fragment;const l=e.lastBoundBO.getCABO().getTCoordComponents();l===1?(a=Be.substitute(a,"//VTK::TCoord::Dec",["in float tcoordMC;","out float tcoordVCVSOutput;"]).result,a=Be.substitute(a,"//VTK::TCoord::Impl",["tcoordVCVSOutput = tcoordMC;"]).result,s=Be.substitute(s,"//VTK::TCoord::Dec",[`in float tcoordVCVSOutput[];
|
||
`,"out float tcoordVCGSOutput;"]).result,s=Be.substitute(s,["//VTK::TCoord::Impl","tcoordVCGSOutput = tcoordVCVSOutput[i];"]).result,c=Be.substitute(c,"//VTK::TCoord::Dec",["in float tcoordVCVSOutput;","uniform sampler2D texture1;"]).result,c=Be.substitute(c,"//VTK::TCoord::Impl",["gl_FragData[0] = gl_FragData[0]*texture2D(texture1, vec2(tcoordVCVSOutput,0));"]).result):l===2&&(a=Be.substitute(a,"//VTK::TCoord::Dec",["in vec2 tcoordMC;","out vec2 tcoordVCVSOutput;"]).result,a=Be.substitute(a,"//VTK::TCoord::Impl",["tcoordVCVSOutput = tcoordMC;"]).result,s=Be.substitute(s,"//VTK::TCoord::Dec",[`in vec2 tcoordVCVSOutput[];
|
||
`,"out vec2 tcoordVCGSOutput;"]).result,s=Be.substitute(s,"//VTK::TCoord::Impl",["tcoordVCGSOutput = tcoordVCVSOutput[i];"]).result,c=Be.substitute(c,"//VTK::TCoord::Dec",["in vec2 tcoordVCVSOutput;","uniform sampler2D texture1;"]).result,c=Be.substitute(c,"//VTK::TCoord::Impl",["gl_FragData[0] = gl_FragData[0]*texture2D(texture1, tcoordVCVSOutput.st);"]).result),e.haveCellScalars&&(s=Be.substitute(s,"//VTK::PrimID::Impl",["gl_PrimitiveID = gl_PrimitiveIDIn;"]).result),n.Vertex=a,n.Geometry=s,n.Fragment=c}},t.replaceShaderPicking=(n,i,o)=>{let a=n.Fragment;a=Be.substitute(a,"//VTK::Picking::Dec",["uniform vec3 mapperIndex;","uniform int picking;"]).result,a=Be.substitute(a,"//VTK::Picking::Impl"," gl_FragData[0] = picking != 0 ? vec4(mapperIndex,1.0) : gl_FragData[0];").result,n.Fragment=a},t.replaceShaderPositionVC=(n,i,o)=>{e.lastBoundBO.replaceShaderPositionVC(n,i,o)},t.invokeShaderCallbacks=(n,i,o)=>{const a=e.renderable.getViewSpecificProperties().ShadersCallbacks;a&&a.forEach(s=>{s.callback(s.userData,n,i,o)})},t.setMapperShaderParameters=(n,i,o)=>{if(n.getProgram().isUniformUsed("PrimitiveIDOffset")&&n.getProgram().setUniformi("PrimitiveIDOffset",e.primitiveIDOffset),n.getProgram().isAttributeUsed("vertexWC")&&(n.getVAO().addAttributeArray(n.getProgram(),n.getCABO(),"vertexWC",n.getCABO().getVertexOffset(),n.getCABO().getStride(),e.context.FLOAT,3,!1)||O2("Error setting vertexWC in shader VAO.")),n.getCABO().getElementCount()&&(e.VBOBuildTime.getMTime()>n.getAttributeUpdateTime().getMTime()||n.getShaderSourceTime().getMTime()>n.getAttributeUpdateTime().getMTime())){e.renderable.getCustomShaderAttributes().forEach((c,l)=>{n.getProgram().isAttributeUsed(`${c}MC`)&&(n.getVAO().addAttributeArray(n.getProgram(),n.getCABO(),`${c}MC`,n.getCABO().getCustomData()[l].offset,n.getCABO().getStride(),e.context.FLOAT,n.getCABO().getCustomData()[l].components,!1)||O2(`Error setting ${c}MC in shader VAO.`))}),n.getProgram().isAttributeUsed("tcoordMC")&&n.getCABO().getTCoordOffset()?n.getVAO().addAttributeArray(n.getProgram(),n.getCABO(),"tcoordMC",n.getCABO().getTCoordOffset(),n.getCABO().getStride(),e.context.FLOAT,n.getCABO().getTCoordComponents(),!1)||O2("Error setting tcoordMC in shader VAO."):n.getVAO().removeAttributeArray("tcoordMC"),e.internalColorTexture&&n.getProgram().isUniformUsed("texture1")&&n.getProgram().setUniformi("texture1",e.internalColorTexture.getTextureUnit());const a=e.openGLActor2D.getActiveTextures();if(a)for(let c=0;c<a.length;++c){const f=a[c].getTextureUnit(),u=`texture${f+1}`;n.getProgram().isUniformUsed(u)&&n.getProgram().setUniformi(u,f)}n.setMapperShaderParameters(i,o,e._openGLRenderer.getTiledSizeAndOrigin());const s=e._openGLRenderer.getSelector();n.getProgram().setUniform3fArray("mapperIndex",s?s.getPropColorValue():[0,0,0]),n.getProgram().setUniformi("picking",s?s.getCurrentPass()+1:0)}},t.setPropertyShaderParameters=(n,i,o)=>{const a=e.renderable.getColorMapColors();if(!a||a.getNumberOfComponents()===0){const s=n.getProgram(),c=o.getProperty(),l=c.getOpacity(),f=c.getColor(),u=[f[0],f[1],f[2],l];s.setUniform4f("diffuseColor",u)}},t.setLightingShaderParameters=(n,i,o)=>{};function r(n,i,o){return i.identity(o),n.reduce((a,s,c)=>c===0?s?i.copy(a,s):i.identity(a):s?i.multiply(a,a,s):a,o)}t.setCameraShaderParameters=(n,i,o)=>{const a=n.getProgram(),c=n.getCABO().getCoordShiftAndScaleEnabled()?n.getCABO().getInverseShiftAndScaleMatrix():null,f=i.getRenderWindow().getViews()[0].getViewportSize(i),u=i.getViewport(),d=o.getActualPositionCoordinate().getComputedDoubleViewportValue(i),h=[0,0,1,1],g=[0,0,1,1];if(g[0]=u[0]>=h[0]?u[0]:h[0],g[1]=u[1]>=h[1]?u[1]:h[1],g[2]=u[2]<=h[2]?u[2]:h[2],g[3]=u[3]<=h[3]?u[3]:h[3],g[0]>=g[2]||g[1]>=g[3])return;f[0]=jg(f[0]*(g[2]-g[0])/(u[2]-u[0])),f[1]=jg(f[1]*(g[3]-g[1])/(u[3]-u[1]));const p=e._openGLRenderer.getParent().getSize(),v=jg(d[0]-(g[0]-u[0])*p[0]),y=jg(d[1]-(g[1]-u[1])*p[1]),m=-v;let w=-v+f[0];const x=-y;let C=-y+f[1];m===w&&(w=m+1),x===C&&(C=x+1);const S=It(new Float64Array(16));S[0]=2/(w-m),S[1*4+1]=2/(C-x),S[0*4+3]=-1*(w+m)/(w-m),S[1*4+3]=-1*(C+x)/(C-x),S[2*4+2]=0,S[2*4+3]=o.getProperty().getDisplayLocation()===qV.FOREGROUND?-1:1,S[3*4+3]=1,un(S,S),a.setUniformMatrix("WCVCMatrix",r([S,c],s1,e.tmpMat4))},t.getAllocatedGPUMemoryInBytes=()=>{let n=0;return e.primitives.forEach(i=>{n+=i.getAllocatedGPUMemoryInBytes()}),n}}const _0e={context:null,VBOBuildTime:0,VBOBuildString:null,primitives:null,primTypes:null,shaderRebuildString:null};function E0e(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,_0e,r),Qn.extend(t,e,r),rl.implementReplaceShaderCoincidentOffset(t,e,r),rl.implementBuildShadersWithReplacements(t,e,r),e.primitives=[],e.primTypes=Ks,e.tmpMat4=It(new Float64Array(16));for(let n=Ks.Start;n<Ks.End;n++)e.primitives[n]=ul.newInstance(),e.primitives[n].setPrimitiveType(n),e.primitives[n].set({lastLightComplexity:0,lastLightCount:0,lastSelectionPass:!1},!0);Jr(t,e,["context"]),e.VBOBuildTime={},or(e.VBOBuildTime,{mtime:0}),T0e(t,e)}const b0e=Rn(E0e,"vtkOpenGLPolyDataMapper2D");di("vtkMapper2D",b0e);const{VectorMode:D0e}=sw;function yC(t,e){t.strokeStyle=e.strokeColor,t.lineWidth=e.strokeSize,t.fillStyle=e.fontColor,t.font=`${e.fontStyle} ${e.fontSize}px ${e.fontFamily}`}function YV(t,e){return r=>{const n=r.getLastSize(),i=(n[0]/700)**.8,o=(n[1]/700)**.8,a=Math.min(i,o),s=r.getAxisTextStyle(),c=r.getTickTextStyle();Object.assign(s,e.axisTextStyle),Object.assign(c,e.tickTextStyle),s.fontSize=Math.max(24*a,12),r.getLastAspectRatio()>1?c.fontSize=Math.max(20*a,10):c.fontSize=Math.max(16*a,10);const l=r.updateTextureAtlas();r.setTopTitle(!1);const f=r.getBoxSizeByReference();if(r.getLastAspectRatio()>1)r.setTickLabelPixelOffset(.3*c.fontSize),l.titleWidth<=l.tickWidth+r.getTickLabelPixelOffset()+.8*c.fontSize?(r.setTopTitle(!0),r.setAxisTitlePixelOffset(.2*c.fontSize),f[0]=2*(l.tickWidth+r.getTickLabelPixelOffset()+.8*c.fontSize)/n[0],r.setBoxPosition([.98-f[0],-.92])):(r.setAxisTitlePixelOffset(.2*c.fontSize),f[0]=2*(l.titleHeight+r.getAxisTitlePixelOffset()+l.tickWidth+r.getTickLabelPixelOffset()+.8*c.fontSize)/n[0],r.setBoxPosition([.99-f[0],-.92])),f[1]=Math.max(1.2,Math.min(1.84/o,1.84));else{r.setAxisTitlePixelOffset(1.2*c.fontSize),r.setTickLabelPixelOffset(.1*c.fontSize);const u=2*(.8*c.fontSize+l.titleHeight+r.getAxisTitlePixelOffset())/n[1],d=2*l.tickWidth/n[0];f[0]=Math.min(1.9,Math.max(1.4,1.4*d*(r.getTicks().length+3))),f[1]=u,r.setBoxPosition([-.5*f[0],-.97])}r.recomputeBarSegments(l)}}function JV(t,e){return r=>{const n=r.getLastTickBounds(),i=TE().domain([n[0],n[1]]),o=i.ticks(5),a=i.tickFormat(5);r.setTicks(o),r.setTickStrings(o.map(a))}}function I0e(t,e){e.classHierarchy.push("vtkScalarBarActorHelper"),t.setRenderable=i=>{e.renderable!==i&&(e.renderable=i,e.barActor.setProperty(i.getProperty()),e.barActor.setParentProp(i),e.barActor.setCoordinateSystemToDisplay(),e.tmActor.setProperty(i.getProperty()),e.tmActor.setParentProp(i),e.tmActor.setCoordinateSystemToDisplay(),e.generateTicks=i.generateTicks,e.axisTextStyle={...i.getAxisTextStyle()},e.tickTextStyle={...i.getTickTextStyle()},t.modified())},t.updateAPISpecificData=(i,o,a)=>{(e.lastSize[0]!==i[0]||e.lastSize[1]!==i[1])&&(e.lastSize[0]=i[0],e.lastSize[1]=i[1],e.lastAspectRatio=i[0]/i[1],e.forceUpdate=!0);const s=e.renderable.getScalarsToColors();if(!(!s||!e.renderable.getVisibility())&&(e.barMapper.setLookupTable(s),e.camera=o,e.renderWindow=a,e.forceUpdate||Math.max(s.getMTime(),t.getMTime(),e.renderable.getMTime())>e.lastRebuildTime.getMTime())){const c=s.getMappingRange();if(e.lastTickBounds=[...c],e.renderable.getGenerateTicks()(t),e.renderable.getAutomated())e.renderable.getAutoLayout()(t);else{e.axisTextStyle={...e.renderable.getAxisTextStyle()},e.tickTextStyle={...e.renderable.getTickTextStyle()},e.barPosition=[...e.renderable.getBarPosition()],e.barSize=[...e.renderable.getBarSize()],e.boxPosition=[...e.renderable.getBoxPosition()],e.boxSize=[...e.renderable.getBoxSize()],e.axisTitlePixelOffset=e.renderable.getAxisTitlePixelOffset(),e.tickLabelPixelOffset=e.renderable.getTickLabelPixelOffset();const l=t.updateTextureAtlas();t.recomputeBarSegments(l)}t.updatePolyDataForLabels(),t.updatePolyDataForBarSegments(),e.lastRebuildTime.modified(),e.forceUpdate=!1}},t.updateTextureAtlas=()=>{e.tmContext.textBaseline="bottom",e.tmContext.textAlign="left";const i={},o=new Map;let a=0,s=1;yC(e.tmContext,e.axisTextStyle);let c=e.tmContext.measureText(e.renderable.getAxisLabel()),l={height:c.actualBoundingBoxAscent+2,startingHeight:s,width:c.width+2,textStyle:e.axisTextStyle};o.set(e.renderable.getAxisLabel(),l),s+=l.height,a=l.width,i.titleWidth=l.width,i.titleHeight=l.height,i.tickWidth=0,i.tickHeight=0,yC(e.tmContext,e.tickTextStyle);const f=[...t.getTickStrings(),"NaN","Below","Above"];for(let u=0;u<f.length;u++)o.has(f[u])||(c=e.tmContext.measureText(f[u]),l={height:c.actualBoundingBoxAscent+2,startingHeight:s,width:c.width+2,textStyle:e.tickTextStyle},o.set(f[u],l),s+=l.height,a<l.width&&(a=l.width),i.tickWidth<l.width&&(i.tickWidth=l.width),i.tickHeight<l.height&&(i.tickHeight=l.height));return a=us(a),s=us(s),o.forEach(u=>{u.tcoords=[0,(s-u.startingHeight-u.height)/s,u.width/a,(s-u.startingHeight-u.height)/s,u.width/a,(s-u.startingHeight)/s,0,(s-u.startingHeight)/s]}),e.tmCanvas.width=a,e.tmCanvas.height=s,e.tmContext.textBaseline="bottom",e.tmContext.textAlign="left",e.tmContext.clearRect(0,0,a,s),o.forEach((u,d)=>{yC(e.tmContext,u.textStyle),e.tmContext.fillText(d,1,u.startingHeight+u.height-1)}),e.tmTexture.setCanvas(e.tmCanvas),e.tmTexture.modified(),e._tmAtlas=o,i},t.computeBarSize=i=>{e.vertical=e.boxSize[1]>e.boxSize[0];const o=2*i.tickHeight/e.lastSize[1],a=[1,1];if(e.vertical){const s=2*(i.tickWidth+e.tickLabelPixelOffset)/e.lastSize[0];if(e.topTitle){const c=2*(i.titleHeight+e.axisTitlePixelOffset)/e.lastSize[1];e.barSize[0]=e.boxSize[0]-s,e.barSize[1]=e.boxSize[1]-c}else{const c=2*(i.titleHeight+e.axisTitlePixelOffset)/e.lastSize[0];e.barSize[0]=e.boxSize[0]-c-s,e.barSize[1]=e.boxSize[1]}e.barPosition[0]=e.boxPosition[0]+s,e.barPosition[1]=e.boxPosition[1],a[1]=o}else{const s=(2*i.tickWidth-8)/e.lastSize[0],c=2*(i.titleHeight+e.axisTitlePixelOffset)/e.lastSize[1];e.barSize[0]=e.boxSize[0],e.barPosition[0]=e.boxPosition[0],e.barSize[1]=e.boxSize[1]-c,e.barPosition[1]=e.boxPosition[1],a[0]=s}return a},t.recomputeBarSegments=i=>{var d,h,g,p;const o=t.computeBarSize(i);e.barSegments=[];const a=[0,0],s=e.vertical?1:0,c=e.vertical?.01:.02;function l(v,y){e.barSegments.push({corners:[[...a],[a[0]+o[0],a[1]],[a[0]+o[0],a[1]+o[1]],[a[0],a[1]+o[1]]],scalars:y,title:v}),a[s]+=o[s]+c}e.renderable.getDrawNanAnnotation()&&e.renderable.getScalarsToColors().getNanColor()&&l("NaN",[NaN,NaN,NaN,NaN]),e.renderable.getDrawBelowRangeSwatch()&&((h=(d=e.renderable.getScalarsToColors()).getUseBelowRangeColor)!=null&&h.call(d))&&l("Below",[-.1,-.1,-.1,-.1]);const f=(p=(g=e.renderable.getScalarsToColors()).getUseAboveRangeColor)==null?void 0:p.call(g);a[s]+=c;const u=o[s];o[s]=f?1-2*c-o[s]-a[s]:1-c-a[s],l("ticks",e.vertical?[0,0,.995,.995]:[0,.995,.995,0]),e.renderable.getDrawAboveRangeSwatch()&&f&&(o[s]=u,a[s]+=c,l("Above",[1.1,1.1,1.1,1.1]))};const r=new Float64Array(3);t.createPolyDataForOneLabel=(i,o,a,s,c,l)=>{const f=e._tmAtlas.get(i);if(!f)return;let u=l.ptIdx,d=l.cellIdx;r[0]=(.5*o[0]+.5)*e.lastSize[0],r[1]=(.5*o[1]+.5)*e.lastSize[1],r[2]=o[2],r[0]+=c[0],r[1]+=c[1];const h=[],g=s==="vertical"?[1,0]:[0,1];s==="vertical"?(h[0]=f.width,h[1]=-f.height,a[0]==="middle"?r[1]-=f.width/2:a[0]==="right"&&(r[1]-=f.width),a[1]==="middle"?r[0]+=f.height/2:a[1]==="top"&&(r[0]+=f.height)):(h[0]=f.width,h[1]=f.height,a[0]==="middle"?r[0]-=f.width/2:a[0]==="right"&&(r[0]-=f.width),a[1]==="middle"?r[1]-=f.height/2:a[1]==="top"&&(r[1]-=f.height)),l.points[u*3]=r[0],l.points[u*3+1]=r[1],l.points[u*3+2]=r[2],l.tcoords[u*2]=f.tcoords[0],l.tcoords[u*2+1]=f.tcoords[1],u++,r[g[0]]+=h[0],l.points[u*3]=r[0],l.points[u*3+1]=r[1],l.points[u*3+2]=r[2],l.tcoords[u*2]=f.tcoords[2],l.tcoords[u*2+1]=f.tcoords[3],u++,r[g[1]]+=h[1],l.points[u*3]=r[0],l.points[u*3+1]=r[1],l.points[u*3+2]=r[2],l.tcoords[u*2]=f.tcoords[4],l.tcoords[u*2+1]=f.tcoords[5],u++,r[g[0]]-=h[0],l.points[u*3]=r[0],l.points[u*3+1]=r[1],l.points[u*3+2]=r[2],l.tcoords[u*2]=f.tcoords[6],l.tcoords[u*2+1]=f.tcoords[7],u++,l.polys[d*4]=3,l.polys[d*4+1]=u-4,l.polys[d*4+2]=u-3,l.polys[d*4+3]=u-2,d++,l.polys[d*4]=3,l.polys[d*4+1]=u-4,l.polys[d*4+2]=u-2,l.polys[d*4+3]=u-1,l.ptIdx+=4,l.cellIdx+=2};const n=new Float64Array(3);t.updatePolyDataForLabels=()=>{const i=t.getTickStrings().length+e.barSegments.length,o=i*4,a=i*2,s=new Float64Array(o*3),c=new Uint16Array(a*4),l=new Float32Array(o*2),f={ptIdx:0,cellIdx:0,polys:c,points:s,tcoords:l},u=e.vertical?0:1,d=e.vertical?1:0;n[2]=-.99;const h=e.vertical?["right","middle"]:["middle","bottom"];let g=[0,1];const p=[0,0];e.vertical?(p[0]=-e.tickLabelPixelOffset,e.topTitle?(n[0]=e.boxPosition[0]+.5*e.boxSize[0],n[1]=e.barPosition[1]+e.barSize[1],t.createPolyDataForOneLabel(e.renderable.getAxisLabel(),n,["middle","bottom"],"horizontal",[0,e.axisTitlePixelOffset],f)):(n[0]=e.barPosition[0]+e.barSize[0],n[1]=e.barPosition[1]+.5*e.barSize[1],t.createPolyDataForOneLabel(e.renderable.getAxisLabel(),n,["middle","top"],"vertical",[e.axisTitlePixelOffset,0],f)),g=[-1,0]):(p[1]=e.tickLabelPixelOffset,n[0]=e.barPosition[0]+.5*e.barSize[0],n[1]=e.barPosition[1]+e.barSize[1],t.createPolyDataForOneLabel(e.renderable.getAxisLabel(),n,["middle","bottom"],"horizontal",[0,e.axisTitlePixelOffset],f)),n[u]=e.barPosition[u]+(.5*g[u]+.5)*e.barSize[u],n[d]=e.barPosition[d]+e.barSize[d]*.5;let v=null;for(let S=0;S<e.barSegments.length;S++){const T=e.barSegments[S];T.title==="ticks"?v=T:(n[d]=e.barPosition[d]+.5*e.barSize[d]*(T.corners[2][d]+T.corners[0][d]),t.createPolyDataForOneLabel(T.title,n,h,"horizontal",p,f))}const y=e.barPosition[d]+e.barSize[d]*v.corners[0][d],m=e.barSize[d]*(v.corners[2][d]-v.corners[0][d]),w=t.getTicks(),x=t.getTickStrings();for(let S=0;S<w.length;S++){const T=(w[S]-e.lastTickBounds[0])/(e.lastTickBounds[1]-e.lastTickBounds[0]);n[d]=y+m*T,t.createPolyDataForOneLabel(x[S],n,h,"horizontal",p,f)}const C=bt.newInstance({numberOfComponents:2,values:l,name:"TextureCoordinates"});e.tmPolyData.getPointData().setTCoords(C),e.tmPolyData.getPoints().setData(s,3),e.tmPolyData.getPoints().modified(),e.tmPolyData.getPolys().setData(c,1),e.tmPolyData.getPolys().modified(),e.tmPolyData.modified()},t.updatePolyDataForBarSegments=()=>{var p,v;const i=e.renderable.getScalarsToColors();let o=0;e.renderable.getDrawNanAnnotation()&&i.getNanColor()&&(o+=1),e.renderable.getDrawBelowRangeSwatch()&&((p=i.getUseBelowRangeColor)!=null&&p.call(i))&&(o+=1),e.renderable.getDrawAboveRangeSwatch()&&((v=i.getUseAboveRangeColor)!=null&&v.call(i))&&(o+=1);const a=4*(1+o),s=a;let c=1;i.getVectorMode()===D0e.COMPONENT&&(c=i.getVectorComponent()+1);const l=new Float64Array(a*3),f=new Uint16Array(s*5),u=new Float32Array(a*c);let d=0,h=0;for(let y=0;y<e.barSegments.length;y++){const m=e.barSegments[y];for(let w=0;w<4;w++){n[0]=e.barPosition[0]+m.corners[w][0]*e.barSize[0],n[1]=e.barPosition[1]+m.corners[w][1]*e.barSize[1],l[d*3]=(.5*n[0]+.5)*e.lastSize[0],l[d*3+1]=(.5*n[1]+.5)*e.lastSize[1],l[d*3+2]=n[2];for(let x=0;x<c;x++)u[d*c+x]=e.lastTickBounds[0]+m.scalars[w]*(e.lastTickBounds[1]-e.lastTickBounds[0]);d++}f[h*5]=4,f[h*5+1]=d-4,f[h*5+2]=d-3,f[h*5+3]=d-2,f[h*5+4]=d-1,h++}const g=bt.newInstance({numberOfComponents:c,values:u,name:"Scalars"});e.polyData.getPointData().setScalars(g),e.polyData.getPoints().setData(l,3),e.polyData.getPoints().modified(),e.polyData.getPolys().setData(f,1),e.polyData.getPolys().modified(),e.polyData.modified()}}const O0e=Z.newInstance(function(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{renderable:null};Object.assign(e,{},r),Z.obj(t,e),Z.setGet(t,e,["axisTitlePixelOffset","tickLabelPixelOffset","renderable","topTitle","ticks","tickStrings"]),Z.get(t,e,["lastSize","lastAspectRatio","lastTickBounds","axisTextStyle","tickTextStyle","barActor","tmActor"]),Z.getArray(t,e,["boxPosition","boxSize"]),Z.setArray(t,e,["boxPosition","boxSize"],2),e.forceUpdate=!1,e.lastRebuildTime={},Z.obj(e.lastRebuildTime,{mtime:0}),e.lastSize=[-1,-1],e.tmCanvas=document.createElement("canvas"),e.tmContext=e.tmCanvas.getContext("2d"),e._tmAtlas=new Map,e.barMapper=la.newInstance(),e.barMapper.setInterpolateScalarsBeforeMapping(!0),e.barMapper.setUseLookupTableScalarRange(!0),e.polyData=Er.newInstance(),e.barMapper.setInputData(e.polyData),e.barActor=uc.newInstance(),e.barActor.setMapper(e.barMapper),e.tmPolyData=Er.newInstance(),e.tmMapper=la.newInstance(),e.tmMapper.setInputData(e.tmPolyData),e.tmTexture=Bd.newInstance({resizable:!0}),e.tmTexture.setInterpolate(!1),e.tmActor=uc.newInstance({parentProp:t}),e.tmActor.setMapper(e.tmMapper),e.tmActor.addTexture(e.tmTexture),e.barPosition=[0,0],e.barSize=[0,0],e.boxPosition=[.88,-.92],e.boxSize=[.1,1.1],e.lastTickBounds=[],I0e(t,e)},"vtkScalarBarActorHelper");function M0e(t,e){e.classHierarchy.push("vtkScalarBarActor"),t.setTickTextStyle=r=>{e.tickTextStyle={...e.tickTextStyle,...r},t.modified()},t.setAxisTextStyle=r=>{e.axisTextStyle={...e.axisTextStyle,...r},t.modified()},t.resetAutoLayoutToDefault=()=>{t.setAutoLayout(YV(t,e))},t.resetGenerateTicksToDefault=()=>{t.setGenerateTicks(JV())}}function P0e(t){return{automated:!0,autoLayout:null,axisLabel:"Scalar Value",barPosition:[0,0],barSize:[0,0],boxPosition:[.88,-.92],boxSize:[.1,1.1],scalarToColors:null,axisTitlePixelOffset:36,axisTextStyle:{fontColor:"white",fontStyle:"normal",fontSize:18,fontFamily:"serif"},tickLabelPixelOffset:14,tickTextStyle:{fontColor:"white",fontStyle:"normal",fontSize:14,fontFamily:"serif"},generateTicks:null,drawNanAnnotation:!0,drawBelowRangeSwatch:!0,drawAboveRangeSwatch:!0,...t}}function ZV(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,P0e(r)),e.autoLayout||(e.autoLayout=YV(t,e)),e.generateTicks||(e.generateTicks=JV()),uc.extend(t,e,r),t.getProperty().setDiffuse(0),t.getProperty().setAmbient(1),Z.setGet(t,e,["automated","autoLayout","axisTitlePixelOffset","axisLabel","scalarsToColors","tickLabelPixelOffset","generateTicks","drawNanAnnotation","drawBelowRangeSwatch","drawAboveRangeSwatch"]),Z.get(t,e,["axisTextStyle","tickTextStyle"]),Z.getArray(t,e,["barPosition","barSize","boxPosition","boxSize"]),Z.setArray(t,e,["barPosition","barSize","boxPosition","boxSize"],2),M0e(t,e)}const R0e=Z.newInstance(ZV,"vtkScalarBarActor");var QV={newInstance:R0e,extend:ZV,newScalarBarActorHelper:O0e};function L0e(t,e){e.classHierarchy.push("vtkOpenGLScalarBarActor"),t.buildPass=r=>{r&&(e._openGLRenderer=t.getFirstAncestorOfType("vtkOpenGLRenderer"),e._openGLRenderWindow=e._openGLRenderer.getParent(),e.scalarBarActorHelper.getRenderable()||e.scalarBarActorHelper.setRenderable(e.renderable),t.prepareNodes(),t.addMissingNode(e.scalarBarActorHelper.getBarActor()),t.addMissingNode(e.scalarBarActorHelper.getTmActor()),t.removeUnusedNodes())},t.opaquePass=(r,n)=>{if(r){const i=e._openGLRenderer?e._openGLRenderer.getRenderable().getActiveCamera():null,o=e._openGLRenderer.getTiledSizeAndOrigin();e.scalarBarActorHelper.updateAPISpecificData([o.usize,o.vsize],i,e._openGLRenderWindow.getRenderable())}}}const A0e={};function N0e(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,A0e,r),Qn.extend(t,e,r),e.scalarBarActorHelper=QV.newScalarBarActorHelper(),L0e(t,e)}const k0e=Rn(N0e,"vtkOpenGLScalarBarActor");di("vtkScalarBarActor",k0e);const{CoordinateSystem:G9}=rm;function V0e(t,e){e.classHierarchy.push("vtkWebGPUActor"),t.buildPass=r=>{r&&(e.WebGPURenderer=t.getFirstAncestorOfType("vtkWebGPURenderer"),e.WebGPURenderWindow=e.WebGPURenderer.getFirstAncestorOfType("vtkWebGPURenderWindow"),e.propID===void 0&&(e.propID=e.WebGPURenderWindow.getUniquePropID()),t.prepareNodes(),t.addMissingNode(e.renderable.getMapper()),t.removeUnusedNodes())},t.traverseOpaquePass=r=>{!e.renderable||!e.renderable.getNestedVisibility()||!e.renderable.getIsOpaque()||e.WebGPURenderer.getSelector()&&!e.renderable.getNestedPickable()||(t.apply(r,!0),e.children[0]&&e.children[0].traverse(r),t.apply(r,!1))},t.traverseTranslucentPass=r=>{!e.renderable||!e.renderable.getNestedVisibility()||e.renderable.getIsOpaque()||e.WebGPURenderer.getSelector()&&!e.renderable.getNestedPickable()||(t.apply(r,!0),e.children[0]&&e.children[0].traverse(r),t.apply(r,!1))},t.queryPass=(r,n)=>{if(r){if(!e.renderable||!e.renderable.getVisibility())return;e.renderable.getIsOpaque()?n.incrementOpaqueActorCount():n.incrementTranslucentActorCount()}},t.getBufferShift=r=>(t.getKeyMatrices(r),e.bufferShift),t.getKeyMatrices=r=>{if(Math.max(e.renderable.getMTime(),r.getStabilizedTime())>e.keyMatricesTime.getMTime()){e.renderable.computeMatrix();const n=e.renderable.getMatrix();e.bufferShift[0]=n[3],e.bufferShift[1]=n[7],e.bufferShift[2]=n[11];const i=r.getStabilizedCenterByReference();e.renderable.getCoordinateSystem()===G9.WORLD&&(e.bufferShift[0]-=i[0],e.bufferShift[1]-=i[1],e.bufferShift[2]-=i[2]),un(e.keyMatrices.bcwc,n),e.renderable.getIsIdentity()?It(e.keyMatrices.normalMatrix):(Cr(e.keyMatrices.normalMatrix,e.keyMatrices.bcwc),e.keyMatrices.normalMatrix[3]=0,e.keyMatrices.normalMatrix[7]=0,e.keyMatrices.normalMatrix[11]=0,Ar(e.keyMatrices.normalMatrix,e.keyMatrices.normalMatrix),un(e.keyMatrices.normalMatrix,e.keyMatrices.normalMatrix)),er(e.keyMatrices.bcwc,e.keyMatrices.bcwc,[-e.bufferShift[0],-e.bufferShift[1],-e.bufferShift[2]]),e.renderable.getCoordinateSystem()===G9.WORLD?er(e.keyMatrices.bcsc,e.keyMatrices.bcwc,[-i[0],-i[1],-i[2]]):Cr(e.keyMatrices.bcsc,e.keyMatrices.bcwc),e.keyMatricesTime.modified()}return e.keyMatrices}}const F0e={keyMatricesTime:null,keyMatrices:null,propID:void 0,bufferShift:void 0};function U0e(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,F0e,r),Qn.extend(t,e,r),e.keyMatricesTime={},Z.obj(e.keyMatricesTime,{mtime:0}),e.keyMatrices={normalMatrix:new Float64Array(16),bcwc:new Float64Array(16),bcsc:new Float64Array(16)},Z.get(t,e,["propID","keyMatricesTime"]),e.bufferShift=[0,0,0,0],V0e(t,e)}const B0e=Z.newInstance(U0e);xs("vtkActor",B0e);const{CoordinateSystem:W9}=rm;function G0e(t,e){e.classHierarchy.push("vtkWebGPUActor2D"),t.buildPass=r=>{r&&(e.WebGPURenderer=t.getFirstAncestorOfType("vtkWebGPURenderer"),e.WebGPURenderWindow=e.WebGPURenderer.getFirstAncestorOfType("vtkWebGPURenderWindow"),e.propID===void 0&&(e.propID=e.WebGPURenderWindow.getUniquePropID()),t.prepareNodes(),t.addMissingNode(e.renderable.getMapper()),t.removeUnusedNodes())},t.traverseOpaquePass=r=>{!e.renderable||!e.renderable.getNestedVisibility()||!e.renderable.getIsOpaque()||e.WebGPURenderer.getSelector()&&!e.renderable.getNestedPickable()||(t.apply(r,!0),e.children[0]&&e.children[0].traverse(r),t.apply(r,!1))},t.traverseTranslucentPass=r=>{!e.renderable||!e.renderable.getNestedVisibility()||e.renderable.getIsOpaque()||e.WebGPURenderer.getSelector()&&!e.renderable.getNestedPickable()||(t.apply(r,!0),e.children[0]&&e.children[0].traverse(r),t.apply(r,!1))},t.queryPass=(r,n)=>{if(r){if(!e.renderable||!e.renderable.getVisibility())return;e.renderable.getIsOpaque()?n.incrementOpaqueActorCount():n.incrementTranslucentActorCount()}},t.getBufferShift=r=>(t.getKeyMatrices(r),e.bufferShift),t.getKeyMatrices=r=>{if(Math.max(e.renderable.getMTime(),r.getStabilizedTime())>e.keyMatricesTime.getMTime()){e.bufferShift[0]=0,e.bufferShift[1]=0,e.bufferShift[2]=0;const n=r.getStabilizedCenterByReference();e.renderable.getCoordinateSystem()===W9.WORLD&&(e.bufferShift[0]-=n[0],e.bufferShift[1]-=n[1],e.bufferShift[2]-=n[2]),It(e.keyMatrices.bcwc),It(e.keyMatrices.normalMatrix),er(e.keyMatrices.bcwc,e.keyMatrices.bcwc,[-e.bufferShift[0],-e.bufferShift[1],-e.bufferShift[2]]),e.renderable.getCoordinateSystem()===W9.WORLD?er(e.keyMatrices.bcsc,e.keyMatrices.bcwc,[-n[0],-n[1],-n[2]]):Cr(e.keyMatrices.bcsc,e.keyMatrices.bcwc),e.keyMatricesTime.modified()}return e.keyMatrices}}const W0e={keyMatricesTime:null,keyMatrices:null,propID:void 0,bufferShift:void 0};function z0e(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,W0e,r),Qn.extend(t,e,r),e.keyMatricesTime={},Z.obj(e.keyMatricesTime,{mtime:0}),e.keyMatrices={normalMatrix:new Float64Array(16),bcwc:new Float64Array(16),bcsc:new Float64Array(16)},Z.get(t,e,["propID","keyMatricesTime"]),e.bufferShift=[0,0,0,0],G0e(t,e)}const $0e=Z.newInstance(z0e);xs("vtkActor2D",$0e);function j0e(t,e){e.classHierarchy.push("vtkWebGPUCubeAxesActor"),t.buildPass=r=>{r&&(e.WebGPURenderer=t.getFirstAncestorOfType("vtkWebGPURenderer"),e.WebGPURenderWindow=e.WebGPURenderer.getParent(),e.CubeAxesActorHelper.getRenderable()||e.CubeAxesActorHelper.setRenderable(e.renderable),t.prepareNodes(),t.addMissingNode(e.CubeAxesActorHelper.getTmActor()),t.addMissingNode(e.renderable.getGridActor()),t.removeUnusedNodes())},t.opaquePass=(r,n)=>{if(r){const i=e.WebGPURenderer?e.WebGPURenderer.getRenderable().getActiveCamera():null,o=e.WebGPURenderer.getTiledSizeAndOrigin();e.CubeAxesActorHelper.updateAPISpecificData([o.usize,o.vsize],i,e.WebGPURenderWindow.getRenderable())}}}const H0e={};function K0e(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,H0e,r),Qn.extend(t,e,r),e.CubeAxesActorHelper=KV.newCubeAxesActorHelper(),j0e(t,e)}const q0e=Rn(K0e,"vtkWebGPUCubeAxesActor");xs("vtkCubeAxesActor",q0e);const{DisplayLocation:US}=XV;function X0e(t,e){e.classHierarchy.push("vtkProperty2D"),t.setDisplayLocationToBackground=()=>t.setDisplayLocation(US.BACKGROUND),t.setDisplayLocationToForeground=()=>t.setDisplayLocation(US.FOREGROUND),t.setRepresentationToWireframe=()=>t.setRepresentation(ao.WIREFRAME),t.setRepresentationToSurface=()=>t.setRepresentation(ao.SURFACE),t.setRepresentationToPoints=()=>t.setRepresentation(ao.POINTS),t.getRepresentationAsString=()=>Z.enumToString(ao,e.representation)}const Y0e={color:[1,1,1],opacity:1,pointSize:1,lineWidth:1,representation:ao.SURFACE,displayLocation:US.FOREGROUND};function J0e(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Y0e,r),Z.obj(t,e),Z.setGet(t,e,["opacity","lineWidth","pointSize","displayLocation","representation"]),Z.setGetArray(t,e,["color"],3),X0e(t,e)}Z.newInstance(J0e,"vtkProperty2D");var Z0e={...XV};const{BufferUsage:Ki,PrimitiveTypes:Wo}=jh,{Representation:M2}=Fd,{ScalarMode:P2}=la,{CoordinateSystem:Q0e}=rm,{DisplayLocation:ehe}=Z0e,the=`
|
||
//VTK::Renderer::Dec
|
||
|
||
//VTK::Color::Dec
|
||
|
||
//VTK::Normal::Dec
|
||
|
||
//VTK::TCoord::Dec
|
||
|
||
//VTK::Select::Dec
|
||
|
||
//VTK::Mapper::Dec
|
||
|
||
//VTK::IOStructs::Dec
|
||
|
||
@vertex
|
||
fn main(
|
||
//VTK::IOStructs::Input
|
||
)
|
||
//VTK::IOStructs::Output
|
||
{
|
||
var output : vertexOutput;
|
||
|
||
var vertex: vec4<f32> = vertexBC;
|
||
|
||
//VTK::Color::Impl
|
||
|
||
//VTK::Normal::Impl
|
||
|
||
//VTK::TCoord::Impl
|
||
|
||
//VTK::Select::Impl
|
||
|
||
//VTK::Position::Impl
|
||
|
||
return output;
|
||
}
|
||
`,nhe=`
|
||
struct PBRData {
|
||
diffuse: vec3<f32>,
|
||
specular: vec3<f32>,
|
||
}
|
||
|
||
// Dot product with the max already in it
|
||
fn mdot(a: vec3<f32>, b: vec3<f32>) -> f32 {
|
||
return max(0.0, dot(a, b));
|
||
}
|
||
// Dot product with a max in it that does not allow for negative values
|
||
// Physically based rendering is accurate as long as normals are accurate,
|
||
// however this is pretty often not the case. In order to prevent negative
|
||
// values from ruining light calculations and creating zones of zero light,
|
||
// this remapping is used, which smoothly clamps the dot product between
|
||
// zero and one while still maintaining a good amount of accuracy.
|
||
fn cdot(a: vec3<f32>, b: vec3<f32>) -> f32 {
|
||
var d: f32 = max(0.0, dot(a, b));
|
||
d = pow((d + 1.0) / 2.0, 2.6);
|
||
return d;
|
||
}
|
||
|
||
// Lambertian diffuse model
|
||
fn lambertDiffuse(base: vec3<f32>, N: vec3<f32>, L: vec3<f32>) -> vec3<f32> {
|
||
var pi: f32 = 3.14159265359;
|
||
var NdotL: f32 = mdot(N, L);
|
||
NdotL = pow(NdotL, 1.5);
|
||
return (base/pi)*NdotL;
|
||
}
|
||
|
||
// Yasuhiro Fujii improvement on the Oren-Nayar model
|
||
// https://mimosa-pudica.net/improved-oren-nayar.html
|
||
// p is surface color, o is roughness
|
||
fn fujiiOrenNayar(p: vec3<f32>, o: f32, N: vec3<f32>, L: vec3<f32>, V: vec3<f32>) -> vec3<f32> {
|
||
var invpi: f32 = 0.31830988618; // 1/pi
|
||
|
||
var o2 = o*o;
|
||
var NdotL: f32 = mdot(N, L);
|
||
NdotL = pow(NdotL, 1.5); // Less physically accurate, but hides the "seams" between lights better
|
||
|
||
var NdotV: f32 = mdot(N, V);
|
||
var LdotV: f32 = mdot(L, V);
|
||
|
||
var s: f32 = LdotV - NdotL*NdotV;
|
||
var t: f32 = mix(1.0, max(NdotL, NdotV), step(0.0, s)); // Mix with step is the equivalent of an if statement
|
||
var A: vec3<f32> = 0.5*(o2 / (o2 + 0.33)) + 0.17*p*(o2 / (o2 + 0.13));
|
||
A = invpi*(1 - A);
|
||
var B: f32 = 0.45*(o2 / (o2 + 0.09));
|
||
B = invpi*B;
|
||
|
||
return p*NdotL*(A + B*(s/t));
|
||
}
|
||
|
||
// Fresnel portion of BRDF (IOR only, simplified)
|
||
fn schlickFresnelIOR(V: vec3<f32>, N: vec3<f32>, ior: f32, k: f32) -> f32 {
|
||
var NdotV: f32 = mdot(V, N);
|
||
var F0: f32 = (pow((ior - 1.0), 2.0) + k*k) / (pow((ior + 1.0), 2.0) + k*k); // This takes into account the roughness, which the other one does not
|
||
return F0 + (1.0 - F0) * pow((1.0-NdotV), 5.0);
|
||
}
|
||
|
||
// Fresnel portion of BRDF (Color ior, better)
|
||
fn schlickFresnelRGB(V: vec3<f32>, N: vec3<f32>, F0: vec3<f32>) -> vec3<f32> {
|
||
var NdotV: f32 = mdot(V, N);
|
||
return F0 + (1.0 - F0) * pow((1-NdotV), 5.0);
|
||
}
|
||
|
||
// Normal portion of BRDF
|
||
// https://learnopengl.com/PBR/Theory
|
||
// Trowbridge-Reitz GGX functions: normal, halfway, roughness^2
|
||
fn trGGX(N: vec3<f32>, H: vec3<f32>, a: f32) -> f32 {
|
||
var pi: f32 = 3.14159265359;
|
||
|
||
var a2: f32 = a*a;
|
||
var NdotH = mdot(N, H);
|
||
var NdotH2 = NdotH*NdotH;
|
||
|
||
var denom: f32 = NdotH2 * (a2 - 1.0) + 1.0;
|
||
|
||
return a2 / max((pi*denom*denom), 0.000001);
|
||
}
|
||
|
||
// A VERY bad approximation of anisotropy. Real anisotropic calculations require tangent and bitangent
|
||
fn anisotrophicTrGGX(N: vec3<f32>, H: vec3<f32>, O: vec3<f32>, s: f32, a: f32) -> f32 {
|
||
var Op: vec3<f32> = (rendererUBO.WCVCNormals * vec4<f32>(normalize(O) * s, 0.)).xyz;
|
||
|
||
var ggx1: f32 = trGGX(N + Op*s, H, a);
|
||
var ggx2: f32 = trGGX(N - Op*s, H, a);
|
||
return (0.5 * ggx1 + 0.5 * ggx2);
|
||
}
|
||
|
||
// Geometry portion of BRDF
|
||
fn schlickGGX(N: vec3<f32>, X: vec3<f32>, k: f32) -> f32 {
|
||
var NdotX = cdot(N, X);
|
||
return NdotX / max(0.000001, (NdotX*(1.0-k) + k));
|
||
}
|
||
|
||
fn smithSurfaceRoughness(N: vec3<f32>, V: vec3<f32>, L: vec3<f32>, k: f32) -> f32 {
|
||
var ggx1: f32 = min(1.0, schlickGGX(N, V, k));
|
||
var ggx2: f32 = min(1.0, schlickGGX(N, L, k));
|
||
return ggx1*ggx2;
|
||
}
|
||
|
||
// BRDF Combination
|
||
fn cookTorrance(D: f32, F: f32, G: f32, N: vec3<f32>, V: vec3<f32>, L: vec3<f32>) -> f32 {
|
||
var num: f32 = D*F*G;
|
||
var denom: f32 = 4*cdot(V, N)*cdot(L, N);
|
||
|
||
return num / max(denom, 0.000001);
|
||
}
|
||
|
||
// Different lighting calculations for different light sources
|
||
fn calcDirectionalLight(N: vec3<f32>, V: vec3<f32>, ior: f32, roughness: f32, metallic: f32, direction: vec3<f32>, color: vec3<f32>, base: vec3<f32>) -> PBRData {
|
||
var L: vec3<f32> = normalize(direction); // Light Vector
|
||
var H: vec3<f32> = normalize(L + V); // Halfway Vector
|
||
|
||
var alpha = roughness*roughness;
|
||
var k: f32 = alpha*alpha / 2;
|
||
|
||
var D: f32 = trGGX(N, H, alpha); // Distribution
|
||
// var F: f32 = schlickFresnelIOR(V, N, ior, k); // Fresnel
|
||
var G: f32 = smithSurfaceRoughness(N, V, L, k); // Geometry
|
||
|
||
var brdf: f32 = cookTorrance(D, 1.0, G, N, V, L); // Fresnel term is replaced with 1 because it is added later
|
||
var incoming: vec3<f32> = color;
|
||
var angle: f32 = mdot(L, N);
|
||
angle = pow(angle, 1.5);
|
||
|
||
var specular: vec3<f32> = brdf*incoming*angle;
|
||
// Oren-Nayar gives a clay-like effect when fully rough which some people may not want, so it might be better to give a separate
|
||
// control property for the diffuse vs specular roughness
|
||
var diffuse: vec3<f32> = incoming*fujiiOrenNayar(base, roughness, N, L, V);
|
||
// Stores the specular and diffuse separately to allow for finer post processing
|
||
var out = PBRData(diffuse, specular);
|
||
|
||
return out; // Returns angle along with color of light so the final color can be multiplied by angle as well (creates black areas)
|
||
}
|
||
|
||
// TODO: find some way to reduce the number of arguments going in here
|
||
fn calcPointLight(N: vec3<f32>, V: vec3<f32>, fragPos: vec3<f32>, ior: f32, roughness: f32, metallic: f32, position: vec3<f32>, color: vec3<f32>, base: vec3<f32>) -> PBRData {
|
||
var L: vec3<f32> = normalize(position - fragPos); // Light Vector
|
||
var H: vec3<f32> = normalize(L + V); // Halfway Vector
|
||
var dist = distance(position, fragPos);
|
||
|
||
var alpha = roughness*roughness;
|
||
var k: f32 = alpha*alpha / 2.0; // could also be pow(alpha + 1.0, 2) / 8
|
||
|
||
var D: f32 = trGGX(N, H, alpha); // Distribution
|
||
// var F: f32 = schlickFresnelIOR(V, N, ior, k); // Fresnel
|
||
var G: f32 = smithSurfaceRoughness(N, V, L, k); // Geometry
|
||
|
||
var brdf: f32 = cookTorrance(D, 1.0, G, N, V, L);
|
||
var incoming: vec3<f32> = color * (1.0 / (dist*dist));
|
||
var angle: f32 = mdot(L, N);
|
||
angle = pow(angle, 1.5); // Smoothing factor makes it less accurate, but reduces ugly "seams" bewteen light sources
|
||
|
||
var specular: vec3<f32> = brdf*incoming*angle;
|
||
var diffuse: vec3<f32> = incoming*fujiiOrenNayar(base, roughness, N, L, V);
|
||
|
||
// Stores the specular and diffuse separately to allow for finer post processing
|
||
// Could also be done (propably more properly) with a struct
|
||
var out = PBRData(diffuse, specular);
|
||
|
||
return out; // Returns angle along with color of light so the final color can be multiplied by angle as well (creates black areas)
|
||
}
|
||
|
||
// For a reason unknown to me, spheres dont seem to behave propperly with head-on spot lights
|
||
fn calcSpotLight(N: vec3<f32>, V: vec3<f32>, fragPos: vec3<f32>, ior: f32, roughness: f32, metallic: f32, position: vec3<f32>, direction: vec3<f32>, cones: vec2<f32>, color: vec3<f32>, base: vec3<f32>) -> PBRData {
|
||
var L: vec3<f32> = normalize(position - fragPos);
|
||
var H: vec3<f32> = normalize(L + V); // Halfway Vector
|
||
var dist = distance(position, fragPos);
|
||
|
||
var alpha = roughness*roughness;
|
||
var k: f32 = alpha*alpha / 2.0; // could also be pow(alpha + 1.0, 2) / 8
|
||
|
||
var D: f32 = trGGX(N, H, alpha); // Distribution
|
||
// var F: f32 = schlickFresnelIOR(V, N, ior, k); // Fresnel
|
||
var G: f32 = smithSurfaceRoughness(N, V, L, k); // Geometry
|
||
|
||
var brdf: f32 = cookTorrance(D, 1.0, G, N, V, L);
|
||
|
||
// Cones.x is the inner phi and cones.y is the outer phi
|
||
var theta: f32 = mdot(normalize(direction), L);
|
||
var epsilon: f32 = cones.x - cones.y;
|
||
var intensity: f32 = (theta - cones.y) / epsilon;
|
||
intensity = clamp(intensity, 0.0, 1.0);
|
||
intensity /= dist*dist;
|
||
|
||
var incoming: vec3<f32> = color * intensity;
|
||
|
||
var angle: f32 = mdot(L, N);
|
||
angle = pow(angle, 1.5); // Smoothing factor makes it less accurate, but reduces ugly "seams" bewteen light sources
|
||
|
||
var specular: vec3<f32> = brdf*incoming*angle;
|
||
var diffuse: vec3<f32> = incoming*fujiiOrenNayar(base, roughness, N, L, V);
|
||
|
||
// Stores the specular and diffuse separately to allow for finer post processing
|
||
// Could also be done (propably more properly) with a struct
|
||
var out = PBRData(diffuse, specular);
|
||
|
||
return out; // Returns angle along with color of light so the final color can be multiplied by angle as well (creates black areas)
|
||
}
|
||
|
||
// Environment mapping stuff
|
||
// Takes in a vector and converts it to an equivalent coordinate in a rectilinear texture. Should be replaced with cubemaps at some point
|
||
fn vecToRectCoord(dir: vec3<f32>) -> vec2<f32> {
|
||
var tau: f32 = 6.28318530718;
|
||
var pi: f32 = 3.14159265359;
|
||
var out: vec2<f32> = vec2<f32>(0.0);
|
||
|
||
out.x = atan2(dir.z, dir.x) / tau;
|
||
out.x += 0.5;
|
||
|
||
var phix: f32 = length(vec2(dir.x, dir.z));
|
||
out.y = atan2(dir.y, phix) / pi + 0.5;
|
||
|
||
return out;
|
||
}
|
||
|
||
//VTK::Renderer::Dec
|
||
|
||
//VTK::Color::Dec
|
||
|
||
//VTK::TCoord::Dec
|
||
|
||
// optional surface normal declaration
|
||
//VTK::Normal::Dec
|
||
|
||
//VTK::Select::Dec
|
||
|
||
//VTK::RenderEncoder::Dec
|
||
|
||
//VTK::Mapper::Dec
|
||
|
||
//VTK::IOStructs::Dec
|
||
|
||
@fragment
|
||
fn main(
|
||
//VTK::IOStructs::Input
|
||
)
|
||
//VTK::IOStructs::Output
|
||
{
|
||
var output : fragmentOutput;
|
||
|
||
// Temporary ambient, diffuse, and opacity
|
||
var ambientColor: vec4<f32> = mapperUBO.AmbientColor;
|
||
var diffuseColor: vec4<f32> = mapperUBO.DiffuseColor;
|
||
var opacity: f32 = mapperUBO.Opacity;
|
||
|
||
// This should be declared somewhere else
|
||
var _diffuseMap: vec4<f32> = vec4<f32>(1.0);
|
||
var _roughnessMap: vec4<f32> = vec4<f32>(1.0);
|
||
var _metallicMap: vec4<f32> = vec4<f32>(1.0);
|
||
var _normalMap: vec4<f32> = vec4<f32>(0.0, 0.0, 1.0, 0.0); // normal map was setting off the normal vector detection in fragment
|
||
var _ambientOcclusionMap: vec4<f32> = vec4<f32>(1.);
|
||
var _emissionMap: vec4<f32> = vec4<f32>(0.);
|
||
|
||
//VTK::Color::Impl
|
||
|
||
//VTK::TCoord::Impl
|
||
|
||
//VTK::Normal::Impl
|
||
|
||
var computedColor: vec4<f32> = vec4<f32>(diffuseColor.rgb, 1.0);
|
||
|
||
//VTK::Light::Impl
|
||
|
||
//VTK::Select::Impl
|
||
|
||
if (computedColor.a == 0.0) { discard; };
|
||
|
||
//VTK::Position::Impl
|
||
|
||
//VTK::RenderEncoder::Impl
|
||
|
||
return output;
|
||
}
|
||
`;function z9(t){return t.indexOf("edge")>=0}function rhe(t,e){e.classHierarchy.push("vtkWebGPUCellArrayMapper"),t.buildPass=r=>{r&&(e.is2D?(e.WebGPUActor=t.getFirstAncestorOfType("vtkWebGPUActor2D"),e.forceZValue=!0):(e.WebGPUActor=t.getFirstAncestorOfType("vtkWebGPUActor"),e.forceZValue=!1),e.coordinateSystem=e.WebGPUActor.getRenderable().getCoordinateSystem(),e.useRendererMatrix=e.coordinateSystem!==Q0e.DISPLAY,e.WebGPURenderer=e.WebGPUActor.getFirstAncestorOfType("vtkWebGPURenderer"),e.WebGPURenderWindow=e.WebGPURenderer.getParent(),e.device=e.WebGPURenderWindow.getDevice())},t.translucentPass=r=>{r&&(t.prepareToDraw(e.WebGPURenderer.getRenderEncoder()),e.renderEncoder.registerDrawCallback(e.pipeline,t.draw))},t.opaquePass=r=>{r&&(t.prepareToDraw(e.WebGPURenderer.getRenderEncoder()),e.renderEncoder.registerDrawCallback(e.pipeline,t.draw))},t.updateUBO=()=>{var o;const n=e.WebGPUActor.getRenderable().getProperty(),i=e.UBO.getSendTime();if(t.getMTime()>i||n.getMTime()>i||e.renderable.getMTime()>i){const a=e.WebGPUActor.getKeyMatrices(e.WebGPURenderer);if(e.UBO.setArray("BCWCMatrix",a.bcwc),e.UBO.setArray("BCSCMatrix",a.bcsc),e.UBO.setArray("MCWCNormals",a.normalMatrix),e.is2D){e.UBO.setValue("ZValue",e.WebGPUActor.getRenderable().getProperty().getDisplayLocation()===ehe.FOREGROUND?1:0);const l=n.getColorByReference();e.UBO.setValue("AmbientIntensity",1),e.UBO.setArray("DiffuseColor",[l[0],l[1],l[2],1]),e.UBO.setValue("DiffuseIntensity",0),e.UBO.setValue("SpecularIntensity",0)}else{let l=n.getAmbientColorByReference();e.UBO.setValue("AmbientIntensity",n.getAmbient()),e.UBO.setArray("AmbientColor",[l[0],l[1],l[2],1]),e.UBO.setValue("DiffuseIntensity",n.getDiffuse()),l=n.getDiffuseColorByReference(),e.UBO.setArray("DiffuseColor",[l[0],l[1],l[2],1]),e.UBO.setValue("Roughness",n.getRoughness()),e.UBO.setValue("BaseIOR",n.getBaseIOR()),e.UBO.setValue("Metallic",n.getMetallic()),e.UBO.setValue("NormalStrength",n.getNormalStrength()),e.UBO.setValue("Emission",n.getEmission()),e.UBO.setValue("SpecularIntensity",n.getSpecular()),l=n.getSpecularColorByReference(),e.UBO.setArray("SpecularColor",[l[0],l[1],l[2],1])}const s=(o=n.getEdgeColorByReference)==null?void 0:o.call(n);s&&e.UBO.setArray("EdgeColor",[s[0],s[1],s[2],1]),e.UBO.setValue("LineWidth",n.getLineWidth()),e.UBO.setValue("Opacity",n.getOpacity()),e.UBO.setValue("PropID",e.WebGPUActor.getPropID());const c=e.WebGPURenderWindow.getDevice();e.UBO.sendIfNeeded(c)}},t.haveWideLines=()=>{const r=e.WebGPUActor.getRenderable(),n=r.getProperty().getRepresentation();return r.getProperty().getLineWidth()<=1||e.primitiveType===Wo.Verts?!1:e.primitiveType===Wo.Triangles||e.primitiveType===Wo.TriangleStrips?n===M2.WIREFRAME:!0},t.replaceShaderPosition=(r,n,i)=>{const o=n.getShaderDescription("vertex");o.addBuiltinOutput("vec4<f32>","@builtin(position) Position"),o.hasOutput("vertexVC")||o.addOutput("vec4<f32>","vertexVC");let a=o.getCode();e.useRendererMatrix?(a=Xn.substitute(a,"//VTK::Position::Impl",[" var pCoord: vec4<f32> = rendererUBO.SCPCMatrix*mapperUBO.BCSCMatrix*vertexBC;"," output.vertexVC = rendererUBO.SCVCMatrix * mapperUBO.BCSCMatrix * vec4<f32>(vertexBC.xyz, 1.0);","//VTK::Position::Impl"]).result,e.forceZValue&&(a=Xn.substitute(a,"//VTK::Position::Impl",["pCoord = vec4<f32>(pCoord.xyz/pCoord.w, 1.0);","pCoord.z = mapperUBO.ZValue;","//VTK::Position::Impl"]).result)):(a=Xn.substitute(a,"//VTK::Position::Impl",[" var pCoord: vec4<f32> = mapperUBO.BCSCMatrix*vertexBC;"," pCoord.x = 2.0* pCoord.x / rendererUBO.viewportSize.x - 1.0;"," pCoord.y = 2.0* pCoord.y / rendererUBO.viewportSize.y - 1.0;"," pCoord.z = 0.5 - 0.5 * pCoord.z;","//VTK::Position::Impl"]).result,e.forceZValue&&(a=Xn.substitute(a,"//VTK::Position::Impl",[" pCoord.z = mapperUBO.ZValue;","//VTK::Position::Impl"]).result)),t.haveWideLines()&&(o.addBuiltinInput("u32","@builtin(instance_index) instanceIndex"),a=Xn.substitute(a,"//VTK::Position::Impl",[" var tmpPos: vec4<f32> = pCoord;"," var numSteps: f32 = ceil(mapperUBO.LineWidth - 1.0);"," var offset: f32 = (mapperUBO.LineWidth - 1.0) * (f32(input.instanceIndex / 2u) - numSteps/2.0) / numSteps;"," var tmpPos2: vec3<f32> = tmpPos.xyz / tmpPos.w;"," tmpPos2.x = tmpPos2.x + 2.0 * (f32(input.instanceIndex) % 2.0) * offset / rendererUBO.viewportSize.x;"," tmpPos2.y = tmpPos2.y + 2.0 * (f32(input.instanceIndex + 1u) % 2.0) * offset / rendererUBO.viewportSize.y;"," tmpPos2.z = min(1.0, tmpPos2.z + 0.00001);"," pCoord = vec4<f32>(tmpPos2.xyz * tmpPos.w, tmpPos.w);","//VTK::Position::Impl"]).result),a=Xn.substitute(a,"//VTK::Position::Impl",[" output.Position = pCoord;"]).result,o.setCode(a)},e.shaderReplacements.set("replaceShaderPosition",t.replaceShaderPosition),t.replaceShaderNormal=(r,n,i)=>{const o=i.getBuffer("normalMC"),a=e.WebGPUActor.getRenderable();if(o){const s=n.getShaderDescription("vertex");s.hasOutput("normalVC")||s.addOutput("vec3<f32>","normalVC",o.getArrayInformation()[0].interpolation),s.hasOutput("tangentVC")||s.addOutput("vec3<f32>","tangentVC",o.getArrayInformation()[0].interpolation),s.hasOutput("bitangentVC")||s.addOutput("vec3<f32>","bitangentVC",o.getArrayInformation()[0].interpolation);let c=s.getCode();c=Xn.substitute(c,"//VTK::Normal::Impl",[" output.normalVC = normalize((rendererUBO.WCVCNormals * mapperUBO.MCWCNormals * normalMC).xyz);"," var c1: vec3<f32> = cross(output.normalVC, vec3<f32>(0, 0, 1));"," var c2: vec3<f32> = cross(output.normalVC, vec3<f32>(0, 1, 0));"," var tangent: vec3<f32> = mix(c1, c2, distance(c1, c2));"," output.tangentVC = normalize(tangent);"," output.bitangentVC = normalize(cross(output.normalVC, tangent));"]).result,s.setCode(c);const l=n.getShaderDescription("fragment");c=l.getCode(),a.getProperty().getNormalTexture()?c=Xn.substitute(c,"//VTK::Normal::Impl",[" var normal: vec3<f32> = input.normalVC;"," if (!input.frontFacing) { normal = -normal; }"," var tangent: vec3<f32> = input.tangentVC;"," var bitangent: vec3<f32> = input.bitangentVC;"," var TCVCMatrix: mat3x3<f32> = mat3x3<f32>("," tangent.x, bitangent.x, normal.x,"," tangent.y, bitangent.y, normal.y,"," tangent.z, bitangent.z, normal.z,"," );"," var mappedNormal: vec3<f32> = TCVCMatrix * (_normalMap.xyz * 2 - 1);"," normal = mix(normal, mappedNormal, mapperUBO.NormalStrength);"," normal = normalize(normal);"]).result:c=Xn.substitute(c,"//VTK::Normal::Impl",[" var normal: vec3<f32> = input.normalVC;"," if (!input.frontFacing) { normal = -normal; }"," normal = normalize(normal);"]).result,l.setCode(c)}},e.shaderReplacements.set("replaceShaderNormal",t.replaceShaderNormal),t.replaceShaderLight=(r,n,i)=>{var l;if(r.includes("sel"))return;const o=n.getShaderDescription("vertex");o.hasOutput("vertexVC")||o.addOutput("vec4<f32>","vertexVC");const a=e.WebGPURenderer.getRenderable(),s=n.getShaderDescription("fragment");let c=s.getCode();if(c.includes("var normal:")&&e.useRendererMatrix&&!z9(r)&&!e.is2D&&!r.includes("sel")){const f=[" var pi: f32 = 3.14159265359;"," var fragPos: vec3<f32> = vec3<f32>(input.vertexVC.xyz);"," var V: vec3<f32> = mix(normalize(-fragPos), vec3<f32>(0, 0, 1), f32(rendererUBO.cameraParallel)); // View Vector"," var baseColor: vec3<f32> = _diffuseMap.rgb * diffuseColor.rgb;"," var roughness: f32 = max(0.000001, mapperUBO.Roughness * _roughnessMap.r);"," var metallic: f32 = mapperUBO.Metallic * _metallicMap.r;"," var alpha: f32 = roughness*roughness;"," var ior: f32 = mapperUBO.BaseIOR;"," var k: f32 = alpha*alpha / 2;"," var diffuse: vec3<f32> = vec3<f32>(0.);"," var specular: vec3<f32> = vec3<f32>(0.);"," var emission: vec3<f32> = _emissionMap.rgb * mapperUBO.Emission;"," {"," var i: i32 = 0;"," loop {"," if !(i < rendererUBO.LightCount) { break; }"," switch (i32(rendererLightSSBO.values[i].LightData.x)) {"," // Point Light"," case 0 {"," var color: vec3<f32> = rendererLightSSBO.values[i].LightColor.rgb * rendererLightSSBO.values[i].LightColor.w;"," var pos: vec3<f32> = (rendererLightSSBO.values[i].LightPos).xyz;"," var calculated: PBRData = calcPointLight(normal, V, fragPos, ior, roughness, metallic, pos, color, baseColor);"," diffuse += max(vec3<f32>(0), calculated.diffuse);"," specular += max(vec3<f32>(0), calculated.specular);"," }"," // Directional light"," case 1 {"," var dir: vec3<f32> = (rendererUBO.WCVCNormals * vec4<f32>(normalize(rendererLightSSBO.values[i].LightDir.xyz), 0.)).xyz;"," dir = normalize(dir);"," var color: vec3<f32> = rendererLightSSBO.values[i].LightColor.rgb * rendererLightSSBO.values[i].LightColor.w;"," var calculated: PBRData = calcDirectionalLight(normal, V, ior, roughness, metallic, dir, color, baseColor); // diffuseColor.rgb needs to be fixed with a more dynamic diffuse color"," diffuse += max(vec3<f32>(0), calculated.diffuse);"," specular += max(vec3<f32>(0), calculated.specular);"," }"," // Spot Light"," case 2 {"," var color: vec3<f32> = rendererLightSSBO.values[i].LightColor.rgb * rendererLightSSBO.values[i].LightColor.w;"," var pos: vec3<f32> = (rendererLightSSBO.values[i].LightPos).xyz;"," var dir: vec3<f32> = (rendererUBO.WCVCNormals * vec4<f32>(normalize(rendererLightSSBO.values[i].LightDir.xyz), 0.)).xyz;"," dir = normalize(dir);"," var cones: vec2<f32> = vec2<f32>(rendererLightSSBO.values[i].LightData.y, rendererLightSSBO.values[i].LightData.z);"," var calculated: PBRData = calcSpotLight(normal, V, fragPos, ior, roughness, metallic, pos, dir, cones, color, baseColor);"," diffuse += max(vec3<f32>(0), calculated.diffuse);"," specular += max(vec3<f32>(0), calculated.specular);"," }"," default { continue; }"," }"," continuing { i++; }"," }"," }"," var fresnel: f32 = schlickFresnelIOR(V, normal, ior, k); // Fresnel"," fresnel = min(1.0, fresnel);"," // This could be controlled with its own variable (that isnt base color) for better artistic control"," var fresnelMetallic: vec3<f32> = schlickFresnelRGB(V, normal, baseColor); // Fresnel for metal, takes color into account"," var kS: vec3<f32> = mix(vec3<f32>(fresnel), fresnelMetallic, metallic);"," kS = min(vec3<f32>(1.0), kS);"," var kD: vec3<f32> = (1.0 - kS) * (1.0 - metallic);"," var PBR: vec3<f32> = mapperUBO.DiffuseIntensity*kD*diffuse + kS*specular;"," PBR += emission;"," computedColor = vec4<f32>(PBR, mapperUBO.Opacity);"];(l=a.getEnvironmentTexture())!=null&&l.getImageLoaded()&&f.push(" // To get diffuse IBL, the texture is sampled with normals in worldspace"," var diffuseIBLCoords: vec3<f32> = (transpose(rendererUBO.WCVCNormals) * vec4<f32>(normal, 1.)).xyz;"," var diffuseCoords: vec2<f32> = vecToRectCoord(diffuseIBLCoords);"," // To get specular IBL, the texture is sampled as the worldspace reflection between the normal and view vectors"," // Reflections are first calculated in viewspace, then converted to worldspace to sample the environment"," var VreflN: vec3<f32> = normalize(reflect(-V, normal));"," var reflectionIBLCoords = (transpose(rendererUBO.WCVCNormals) * vec4<f32>(VreflN, 1.)).xyz;"," var specularCoords: vec2<f32> = vecToRectCoord(reflectionIBLCoords);"," var diffuseIBL = textureSampleLevel(EnvironmentTexture, EnvironmentTextureSampler, diffuseCoords, rendererUBO.MaxEnvironmentMipLevel);"," var level = roughness * rendererUBO.MaxEnvironmentMipLevel;"," var specularIBL = textureSampleLevel(EnvironmentTexture, EnvironmentTextureSampler, specularCoords, level);"," var specularIBLContribution: vec3<f32> = specularIBL.rgb*rendererUBO.BackgroundSpecularStrength;"," computedColor += vec4<f32>(specularIBLContribution*kS, 0);"," var diffuseIBLContribution: vec3<f32> = diffuseIBL.rgb*rendererUBO.BackgroundDiffuseStrength;"," diffuseIBLContribution *= baseColor * _ambientOcclusionMap.rgb;"," computedColor += vec4<f32>(diffuseIBLContribution*kD, 0);"),c=Xn.substitute(c,"//VTK::Light::Impl",f).result,s.setCode(c)}else c=Xn.substitute(c,"//VTK::Light::Impl",[" var diffuse: vec3<f32> = diffuseColor.rgb;"," var specular: vec3<f32> = mapperUBO.SpecularColor.rgb * mapperUBO.SpecularColor.a;"," computedColor = vec4<f32>(diffuse * _diffuseMap.rgb, mapperUBO.Opacity);"]).result,s.setCode(c)},e.shaderReplacements.set("replaceShaderLight",t.replaceShaderLight),t.replaceShaderColor=(r,n,i)=>{if(z9(r)){const l=n.getShaderDescription("fragment");let f=l.getCode();f=Xn.substitute(f,"//VTK::Color::Impl",["ambientColor = mapperUBO.EdgeColor;","diffuseColor = mapperUBO.EdgeColor;"]).result,l.setCode(f);return}const o=i.getBuffer("colorVI");if(!o)return;const a=n.getShaderDescription("vertex");a.addOutput("vec4<f32>","color",o.getArrayInformation()[0].interpolation);let s=a.getCode();s=Xn.substitute(s,"//VTK::Color::Impl",[" output.color = colorVI;"]).result,a.setCode(s);const c=n.getShaderDescription("fragment");s=c.getCode(),s=Xn.substitute(s,"//VTK::Color::Impl",["ambientColor = input.color;","diffuseColor = input.color;","opacity = mapperUBO.Opacity * input.color.a;"]).result,c.setCode(s)},e.shaderReplacements.set("replaceShaderColor",t.replaceShaderColor),t.replaceShaderTCoord=(r,n,i)=>{var h,g,p,v,y,m,w,x,C,S,T,_,E,b,D,I,P,O,L,B;if(!i.hasAttribute("tcoord"))return;const o=n.getShaderDescription("vertex"),a=i.getBuffer("tcoord"),s=io.getNumberOfComponentsFromBufferFormat(a.getArrayInformation()[0].format);let c=o.getCode();o.addOutput(`vec${s}<f32>`,"tcoordVS"),c=Xn.substitute(c,"//VTK::TCoord::Impl",[" output.tcoordVS = tcoord;"]).result,o.setCode(c);const l=n.getShaderDescription("fragment");c=l.getCode();const f=e.WebGPUActor.getRenderable(),u=H=>H?H.getDimensionality()===s:!1,d=[];((p=(g=(h=f.getProperty()).getDiffuseTexture)==null?void 0:g.call(h))!=null&&p.getImageLoaded()||f.getTextures()[0]||e.colorTexture)&&(u((y=(v=f.getProperty()).getDiffuseTexture)==null?void 0:y.call(v))||u(f.getTextures()[0])||u(e.colorTexture))&&d.push("_diffuseMap = textureSample(DiffuseTexture, DiffuseTextureSampler, input.tcoordVS);"),(x=(w=(m=f.getProperty()).getRoughnessTexture)==null?void 0:w.call(m))!=null&&x.getImageLoaded()&&u(f.getProperty().getRoughnessTexture())&&d.push("_roughnessMap = textureSample(RoughnessTexture, RoughnessTextureSampler, input.tcoordVS);"),(T=(S=(C=f.getProperty()).getMetallicTexture)==null?void 0:S.call(C))!=null&&T.getImageLoaded()&&u(f.getProperty().getMetallicTexture())&&d.push("_metallicMap = textureSample(MetallicTexture, MetallicTextureSampler, input.tcoordVS);"),(b=(E=(_=f.getProperty()).getNormalTexture)==null?void 0:E.call(_))!=null&&b.getImageLoaded()&&u(f.getProperty().getNormalTexture())&&d.push("_normalMap = textureSample(NormalTexture, NormalTextureSampler, input.tcoordVS);"),(P=(I=(D=f.getProperty()).getAmbientOcclusionTexture)==null?void 0:I.call(D))!=null&&P.getImageLoaded()&&u(f.getProperty().getAmbientOcclusionTexture())&&d.push("_ambientOcclusionMap = textureSample(AmbientOcclusionTexture, AmbientOcclusionTextureSampler, input.tcoordVS);"),(B=(L=(O=f.getProperty()).getEmissionTexture)==null?void 0:L.call(O))!=null&&B.getImageLoaded()&&u(f.getProperty().getEmissionTexture())&&d.push("_emissionMap = textureSample(EmissionTexture, EmissionTextureSampler, input.tcoordVS);"),c=Xn.substitute(c,"//VTK::TCoord::Impl",d).result,l.setCode(c)},e.shaderReplacements.set("replaceShaderTCoord",t.replaceShaderTCoord),t.replaceShaderSelect=(r,n,i)=>{if(r.includes("sel")){const o=n.getShaderDescription("fragment");let a=o.getCode();a=Xn.substitute(a,"//VTK::Select::Impl",[" var compositeID: u32 = 0u;"]).result,o.setCode(a)}},e.shaderReplacements.set("replaceShaderSelect",t.replaceShaderSelect),t.getUsage=(r,n)=>r===M2.POINTS||n===Wo.Points?Ki.Verts:n===Wo.Lines?Ki.Lines:r===M2.WIREFRAME?n===Wo.Triangles?Ki.LinesFromTriangles:Ki.LinesFromStrips:n===Wo.Triangles?Ki.Triangles:n===Wo.TriangleStrips?Ki.Strips:n===Wo.TriangleEdges?Ki.LinesFromTriangles:Ki.LinesFromStrips,t.getHashFromUsage=r=>`pt${r}`,t.getTopologyFromUsage=r=>{switch(r){case Ki.Triangles:return"triangle-list";case Ki.Verts:return"point-list";case Ki.Lines:default:return"line-list"}},t.buildVertexInput=()=>{var p,v;const r=e.currentInput,n=e.cellArray,i=e.primitiveType;let a=e.WebGPUActor.getRenderable().getProperty().getRepresentation();const s=e.WebGPURenderWindow.getDevice();let c=!1;i===Wo.TriangleEdges&&(c=!0,a=M2.WIREFRAME);const l=e.vertexInput,f=r.getPoints();let u;if(n){const y={hash:`R${a}P${i}${n.getMTime()}`,usage:Ki.Index,cells:n,numberOfPoints:f.getNumberOfPoints(),primitiveType:i,representation:a};u=s.getBufferManager().getBuffer(y),l.setIndexBuffer(u)}else l.setIndexBuffer(null);if(f){const y=e.WebGPUActor.getBufferShift(e.WebGPURenderer),m={hash:`${f.getMTime()}I${u.getMTime()}${y.join()}float32x4`,usage:Ki.PointArray,format:"float32x4",dataArray:f,indexBuffer:u,shift:y,packExtra:!0},w=s.getBufferManager().getBuffer(m);l.addBuffer(w,["vertexBC"])}else l.removeBufferIfPresent("vertexBC");const d=t.getUsage(a,i);if(e._usesCellNormals=!1,!e.is2D&&(d===Ki.Triangles||d===Ki.Strips)){const y=r.getPointData().getNormals(),m={format:"snorm8x4",indexBuffer:u,packExtra:!0,shift:0,scale:127};if(y){m.hash=`${y.getMTime()}I${u.getMTime()}snorm8x4`,m.dataArray=y,m.usage=Ki.PointArray;const w=s.getBufferManager().getBuffer(m);l.addBuffer(w,["normalMC"])}else if(i===Wo.Triangles){e._usesCellNormals=!0,m.hash=`PFN${f.getMTime()}I${u.getMTime()}snorm8x4`,m.dataArray=f,m.cells=n,m.usage=Ki.NormalsFromPoints;const w=s.getBufferManager().getBuffer(m);l.addBuffer(w,["normalMC"])}else l.removeBufferIfPresent("normalMC")}else l.removeBufferIfPresent("normalMC");let h=!1;if(e.renderable.getScalarVisibility()){const y=e.renderable.getColorMapColors();if(y&&!c){const m=e.renderable.getScalarMode();let w=!1;(m===P2.USE_CELL_DATA||m===P2.USE_CELL_FIELD_DATA||m===P2.USE_FIELD_DATA||!r.getPointData().getScalars())&&m!==P2.USE_POINT_FIELD_DATA&&y&&(w=!0);const x={usage:Ki.PointArray,format:"unorm8x4",hash:`${w}${y.getMTime()}I${u.getMTime()}unorm8x4`,dataArray:y,indexBuffer:u,cellData:w,cellOffset:0},C=s.getBufferManager().getBuffer(x);l.addBuffer(C,["colorVI"]),h=!0}}h||l.removeBufferIfPresent("colorVI");let g=null;if((v=(p=e.renderable).getInterpolateScalarsBeforeMapping)!=null&&v.call(p)&&e.renderable.getColorCoordinates()?g=e.renderable.getColorCoordinates():g=r.getPointData().getTCoords(),g&&!c){const y=s.getBufferManager().getBufferForPointArray(g,l.getIndexBuffer());l.addBuffer(y,["tcoord"])}else l.removeBufferIfPresent("tcoord")},t.updateTextures=()=>{var c,l,f,u,d,h,g,p,v,y,m,w,x,C,S;const r=[],n=[],i=(l=(c=e.renderable).getColorTextureMap)==null?void 0:l.call(c);i&&(e.colorTexture||(e.colorTexture=Bd.newInstance({label:"polyDataColor"})),e.colorTexture.setInputData(i),n.push(["Diffuse",e.colorTexture]));const o=e.WebGPUActor.getRenderable(),a=e.WebGPURenderer.getRenderable(),s=[];if((u=(f=o.getProperty()).getDiffuseTexture)!=null&&u.call(f)){const T=["Diffuse",o.getProperty().getDiffuseTexture()];s.push(T)}if(o.getTextures()[0]){const T=["Diffuse",o.getTextures()[0]];s.push(T)}if(e.colorTexture){const T=["Diffuse",e.colorTexture];s.push(T)}if((h=(d=o.getProperty()).getRoughnessTexture)!=null&&h.call(d)){const T=["Roughness",o.getProperty().getRoughnessTexture()];s.push(T)}if((p=(g=o.getProperty()).getMetallicTexture)!=null&&p.call(g)){const T=["Metallic",o.getProperty().getMetallicTexture()];s.push(T)}if((y=(v=o.getProperty()).getNormalTexture)!=null&&y.call(v)){const T=["Normal",o.getProperty().getNormalTexture()];s.push(T)}if((w=(m=o.getProperty()).getAmbientOcclusionTexture)!=null&&w.call(m)){const T=["AmbientOcclusion",o.getProperty().getAmbientOcclusionTexture()];s.push(T)}if((C=(x=o.getProperty()).getEmissionTexture)!=null&&C.call(x)){const T=["Emission",o.getProperty().getEmissionTexture()];s.push(T)}if((S=a.getEnvironmentTexture)!=null&&S.call(a)){const T=["Environment",a.getEnvironmentTexture()];s.push(T)}for(let T=0;T<s.length;T++)(s[T][1].getInputData()||s[T][1].getJsImageData()||s[T][1].getCanvas())&&n.push(s[T]),s[T][1].getImage()&&s[T][1].getImageLoaded()&&n.push(s[T]);for(let T=0;T<n.length;T++){const _=n[T][1],E=n[T][0],b=e.device.getTextureManager().getTextureForVTKTexture(_);if(b.getReady()){let D=!1;for(let I=0;I<e.textures.length;I++)e.textures[I]===b&&(D=!0,r[I]=!0);if(!D){r[e.textures.length]=!0;const I=b.createView(`${E}Texture`);e.textures.push(b),e.textureViews.push(I);const P=_.getInterpolate()?"linear":"nearest";let O=null;!O&&_.getEdgeClamp()&&_.getRepeat()&&(O="mirror-repeat"),!O&&_.getEdgeClamp()&&(O="clamp-to-edge"),!O&&_.getRepeat()&&(O="repeat"),E!=="Environment"?I.addSampler(e.device,{addressModeU:O,addressModeV:O,addressModeW:O,minFilter:P,magFilter:P}):I.addSampler(e.device,{addressModeU:"repeat",addressModeV:"clamp-to-edge",addressModeW:"repeat",minFilter:P,magFilter:P,mipmapFilter:"linear"})}}}for(let T=e.textures.length-1;T>=0;T--)r[T]||(e.textures.splice(T,1),e.textureViews.splice(T,1))},t.computePipelineHash=()=>{let r=`pd${e.useRendererMatrix?"r":""}${e.forceZValue?"z":""}`;if(e.primitiveType===Wo.TriangleEdges||e.primitiveType===Wo.TriangleStripEdges)r+="edge";else{if(e.vertexInput.hasAttribute("normalMC")&&(r+="n"),e.vertexInput.hasAttribute("colorVI")&&(r+="c"),e.vertexInput.hasAttribute("tcoord")){const i=e.vertexInput.getBuffer("tcoord"),o=io.getNumberOfComponentsFromBufferFormat(i.getArrayInformation()[0].format);r+=`t${o}`}e.textures.length&&(r+=`tx${e.textures.length}`)}e._usesCellNormals&&(r+="cn"),e.SSBO&&(r+="ssbo");const n=t.getHashFromUsage(e.usage);r+=n,r+=e.renderEncoder.getPipelineHash(),e.pipelineHash=r},t.updateBuffers=()=>{e.primitiveType!==Wo.TriangleEdges&&e.primitiveType!==Wo.TriangleStripEdges&&t.updateTextures();const r=e.WebGPUActor.getRenderable(),n=r.getProperty().getRepresentation();e.usage=t.getUsage(n,e.primitiveType),t.buildVertexInput();const i=e.vertexInput.getBuffer("vertexBC");if(t.setNumberOfVertices(i.getSizeInBytes()/i.getStrideInBytes()),t.setTopology(t.getTopologyFromUsage(e.usage)),t.updateUBO(),t.haveWideLines()){const o=r.getProperty();t.setNumberOfInstances(Math.ceil(o.getLineWidth()*2))}else t.setNumberOfInstances(1)}}const ihe={is2D:!1,cellArray:null,currentInput:null,cellOffset:0,primitiveType:0,colorTexture:null,renderEncoder:null,textures:null};function eF(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,ihe,r),QN.extend(t,e,r),e.fragmentShaderTemplate=nhe,e.vertexShaderTemplate=the,e._tmpMat3=ys(new Float64Array(9)),e._tmpMat4=It(new Float64Array(16)),e.UBO=J0.newInstance({label:"mapperUBO"}),e.UBO.addEntry("BCWCMatrix","mat4x4<f32>"),e.UBO.addEntry("BCSCMatrix","mat4x4<f32>"),e.UBO.addEntry("MCWCNormals","mat4x4<f32>"),e.UBO.addEntry("AmbientColor","vec4<f32>"),e.UBO.addEntry("DiffuseColor","vec4<f32>"),e.UBO.addEntry("EdgeColor","vec4<f32>"),e.UBO.addEntry("SpecularColor","vec4<f32>"),e.UBO.addEntry("AmbientIntensity","f32"),e.UBO.addEntry("DiffuseIntensity","f32"),e.UBO.addEntry("Roughness","f32"),e.UBO.addEntry("Metallic","f32"),e.UBO.addEntry("Ambient","f32"),e.UBO.addEntry("Normal","f32"),e.UBO.addEntry("Emission","f32"),e.UBO.addEntry("NormalStrength","f32"),e.UBO.addEntry("BaseIOR","f32"),e.UBO.addEntry("SpecularIntensity","f32"),e.UBO.addEntry("LineWidth","f32"),e.UBO.addEntry("Opacity","f32"),e.UBO.addEntry("ZValue","f32"),e.UBO.addEntry("PropID","u32"),e.UBO.addEntry("ClipNear","f32"),e.UBO.addEntry("ClipFar","f32"),e.UBO.addEntry("Time","u32"),Jr(t,e,["cellArray","currentInput","cellOffset","is2D","primitiveType","renderEncoder"]),e.textures=[],rhe(t,e)}const ohe=Rn(eF,"vtkWebGPUCellArrayMapper");var tF={newInstance:ohe,extend:eF};const{PrimitiveTypes:R2}=jh;function ahe(t,e){e.classHierarchy.push("vtkWebGPUPolyDataMapper"),t.createCellArrayMapper=()=>tF.newInstance(),t.buildPass=r=>{if(r){e.WebGPUActor=t.getFirstAncestorOfType("vtkWebGPUActor"),e.renderable.getStatic()||e.renderable.update();const n=e.renderable.getInputData();e.renderable.mapScalars(n,1),t.updateCellArrayMappers(n)}},t.updateCellArrayMappers=r=>{const n=[r.getVerts(),r.getLines(),r.getPolys(),r.getStrips()],i=[];let o=0;for(let a=R2.Points;a<=R2.Triangles;a++)if(n[a].getNumberOfValues()>0){e.primitives[a]||(e.primitives[a]=t.createCellArrayMapper());const s=e.primitives[a];s.setCellArray(n[a]),s.setCurrentInput(r),s.setCellOffset(o),s.setPrimitiveType(a),s.setRenderable(e.renderable),o+=n[a].getNumberOfCells(),i.push(s)}else e.primitives[a]=null;if(e.WebGPUActor.getRenderable().getProperty().getEdgeVisibility())for(let a=R2.TriangleEdges;a<=R2.TriangleStripEdges;a++)if(n[a-2].getNumberOfValues()>0){e.primitives[a]||(e.primitives[a]=t.createCellArrayMapper());const s=e.primitives[a];s.setCellArray(n[a-2]),s.setCurrentInput(r),s.setCellOffset(e.primitives[a-2].getCellOffset()),s.setPrimitiveType(a),s.setRenderable(e.renderable),i.push(s)}else e.primitives[a]=null;t.prepareNodes(),t.addMissingChildren(i),t.removeUnusedNodes()}}const she={primitives:null};function che(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,she,r),Qn.extend(t,e,r),e.primitives=[],ahe(t,e)}const lhe=Rn(che,"vtkWebGPUPolyDataMapper");xs("vtkMapper",lhe);const{PrimitiveTypes:$9}=jh;function uhe(t,e){e.classHierarchy.push("vtkWebGPUPolyDataMapper2D"),t.createCellArrayMapper=()=>tF.newInstance(),t.buildPass=r=>{if(r){e.WebGPUActor=t.getFirstAncestorOfType("vtkWebGPUActor2D"),e.renderable.getStatic()||e.renderable.update();const n=e.renderable.getInputData();e.renderable.mapScalars(n,1),t.updateCellArrayMappers(n)}},t.updateCellArrayMappers=r=>{const n=[r.getVerts(),r.getLines(),r.getPolys(),r.getStrips()],i=[];let o=0;for(let a=$9.Points;a<=$9.Triangles;a++)if(n[a].getNumberOfValues()>0){e.primitives[a]||(e.primitives[a]=t.createCellArrayMapper());const s=e.primitives[a];s.setCellArray(n[a]),s.setCurrentInput(r),s.setCellOffset(o),s.setPrimitiveType(a),s.setRenderable(e.renderable),s.setIs2D(!0),o+=n[a].getNumberOfCells(),i.push(s)}else e.primitives[a]=null;t.prepareNodes(),t.addMissingChildren(i),t.removeUnusedNodes()}}function fhe(t){return{primitives:[],...t}}function dhe(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,fhe(r)),Qn.extend(t,e,r),e.primitives=[],uhe(t,e)}const hhe=Rn(dhe,"vtkWebGPUPolyDataMapper2D");xs("vtkMapper2D",hhe);function ghe(t,e){e.classHierarchy.push("vtkWebGPUScalarBarActor"),t.buildPass=r=>{r&&(e.WebGPURenderer=t.getFirstAncestorOfType("vtkWebGPURenderer"),e.WebGPURenderWindow=e.WebGPURenderer.getParent(),e.scalarBarActorHelper.getRenderable()||e.scalarBarActorHelper.setRenderable(e.renderable),t.prepareNodes(),t.addMissingNode(e.scalarBarActorHelper.getBarActor()),t.addMissingNode(e.scalarBarActorHelper.getTmActor()),t.removeUnusedNodes())},t.opaquePass=(r,n)=>{if(r){const i=e.WebGPURenderer?e.WebGPURenderer.getRenderable().getActiveCamera():null,o=e.WebGPURenderer.getTiledSizeAndOrigin();e.scalarBarActorHelper.updateAPISpecificData([o.usize,o.vsize],i,e.WebGPURenderWindow.getRenderable())}}}const phe={};function mhe(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,phe,r),Qn.extend(t,e,r),e.scalarBarActorHelper=QV.newScalarBarActorHelper(),ghe(t,e)}const vhe=Rn(mhe,"vtkWebGPUScalarBarActor");xs("vtkScalarBarActor",vhe);function yhe(t,e){e.classHierarchy.push("vtkWebGPUTextureView"),t.create=(r,n)=>{e.texture=r,e.options=n,e.options.dimension=e.options.dimension||"2d",e.options.label=e.label,e.textureHandle=r.getHandle(),e.handle=e.textureHandle.createView(e.options),e.bindGroupLayoutEntry.texture.viewDimension=e.options.dimension;const i=io.getDetailsFromTextureFormat(e.texture.getFormat());e.bindGroupLayoutEntry.texture.sampleType=i.sampleType},t.createFromTextureHandle=(r,n)=>{e.texture=null,e.options=n,e.options.dimension=e.options.dimension||"2d",e.options.label=e.label,e.textureHandle=r,e.handle=e.textureHandle.createView(e.options),e.bindGroupLayoutEntry.texture.viewDimension=e.options.dimension;const i=io.getDetailsFromTextureFormat(n.format);e.bindGroupLayoutEntry.texture.sampleType=i.sampleType,e.bindGroupTime.modified()},t.getBindGroupEntry=()=>({resource:t.getHandle()}),t.getShaderCode=(r,n)=>{let i="f32";e.bindGroupLayoutEntry.texture.sampleType==="sint"?i="i32":e.bindGroupLayoutEntry.texture.sampleType==="uint"&&(i="u32");let o=`@binding(${r}) @group(${n}) var ${e.label}: texture_${e.options.dimension}<${i}>;`;return e.bindGroupLayoutEntry.texture.sampleType==="depth"&&(o=`@binding(${r}) @group(${n}) var ${e.label}: texture_depth_${e.options.dimension};`),o},t.addSampler=(r,n)=>{const i=ak.newInstance({label:`${e.label}Sampler`});i.create(r,n),t.setSampler(i)},t.getBindGroupTime=()=>(e.texture&&e.texture.getHandle()!==e.textureHandle&&(e.textureHandle=e.texture.getHandle(),e.handle=e.textureHandle.createView(e.options),e.bindGroupTime.modified()),e.bindGroupTime),t.getHandle=()=>(e.texture&&e.texture.getHandle()!==e.textureHandle&&(e.textureHandle=e.texture.getHandle(),e.handle=e.textureHandle.createView(e.options),e.bindGroupTime.modified()),e.handle)}const whe={texture:null,handle:null,sampler:null,label:null};function nF(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,whe,r),Z.obj(t,e),e.bindGroupLayoutEntry={visibility:GPUShaderStage.VERTEX|GPUShaderStage.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d"}},e.bindGroupTime={},Z.obj(e.bindGroupTime,{mtime:0}),Z.get(t,e,["bindGroupTime","texture"]),Z.setGet(t,e,["bindGroupLayoutEntry","label","sampler"]),yhe(t,e)}const xhe=Z.newInstance(nF);var Che={newInstance:xhe,extend:nF};const{BufferUsage:j9}=jh;function She(t,e){e.classHierarchy.push("vtkWebGPUTexture"),t.create=(r,n)=>{e.device=r,e.width=n.width,e.height=n.height,e.depth=n.depth?n.depth:1;const i=e.depth===1?"2d":"3d";e.format=n.format?n.format:"rgba8unorm",e.mipLevel=n.mipLevel?n.mipLevel:0,e.usage=n.usage?n.usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST,e.handle=e.device.getHandle().createTexture({size:[e.width,e.height,e.depth],format:e.format,usage:e.usage,label:e.label,dimension:i,mipLevelCount:e.mipLevel+1})},t.assignFromHandle=(r,n,i)=>{e.device=r,e.handle=n,e.width=i.width,e.height=i.height,e.depth=i.depth?i.depth:1,e.format=i.format?i.format:"rgba8unorm",e.usage=i.usage?i.usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST},t.writeImageData=r=>{let n=[];if(r.canvas){e.device.getHandle().queue.copyExternalImageToTexture({source:r.canvas,flipY:r.flip},{texture:e.handle,premultipliedAlpha:!0},[e.width,e.height,e.depth]),e.ready=!0;return}r.jsImageData&&!r.nativeArray&&(r.width=r.jsImageData.width,r.height=r.jsImageData.height,r.depth=1,r.format="rgba8unorm",r.flip=!0,r.nativeArray=r.jsImageData.data);const i=io.getDetailsFromTextureFormat(e.format);let o=e.width*i.stride;const a=(c,l,f)=>{const u=c.length/(l*f)*c.BYTES_PER_ELEMENT,d=i.elementSize===2&&i.sampleType==="float";if(d||u%256){const h=c,g=u/h.BYTES_PER_ELEMENT,p=i.elementSize,v=256*Math.floor((g*p+255)/256),y=v/p,m=Z.newTypedArray(d?"Uint16Array":h.constructor.name,y*l*f);for(let w=0;w<l*f;w++)if(d)for(let x=0;x<g;x++)m[w*y+x]=Hf.toHalf(h[w*g+x]);else m.set(h.subarray(w*g,(w+1)*g),w*y);return[m,v]}return[c,u]};if(r.nativeArray&&(n=r.nativeArray),r.image){const c=document.createElement("canvas");c.width=r.image.width,c.height=r.image.height;const l=c.getContext("2d");l.translate(0,c.height),l.scale(1,-1),l.drawImage(r.image,0,0,r.image.width,r.image.height,0,0,c.width,c.height),n=l.getImageData(0,0,r.image.width,r.image.height).data}const s=e.device.createCommandEncoder();if(t.getDimensionality()!==3){const c=Bd.generateMipmaps(n,e.width,e.height,e.mipLevel);let l=e.width,f=e.height;for(let u=0;u<=e.mipLevel;u++){const d=a(c[u],f,1);o=d[1];const h={dataArray:r.dataArray?r.dataArray:null,nativeArray:d[0],usage:j9.Texture},g=e.device.getBufferManager().getBuffer(h);s.copyBufferToTexture({buffer:g.getHandle(),offset:0,bytesPerRow:o,rowsPerImage:f},{texture:e.handle,mipLevel:u},[l,f,1]),l/=2,f/=2}e.device.submitCommandEncoder(s),e.ready=!0}else{const c=a(n,e.height,e.depth);o=c[1];const l={dataArray:r.dataArray?r.dataArray:null,usage:j9.Texture};l.nativeArray=c[0];const f=e.device.getBufferManager().getBuffer(l);s.copyBufferToTexture({buffer:f.getHandle(),offset:0,bytesPerRow:o,rowsPerImage:e.height},{texture:e.handle},[e.width,e.height,e.depth]),e.device.submitCommandEncoder(s),e.ready=!0}},t.getScale=()=>{const r=io.getDetailsFromTextureFormat(e.format);return r.elementSize===2&&r.sampleType==="float"?1:255},t.getNumberOfComponents=()=>io.getDetailsFromTextureFormat(e.format).numComponents,t.getDimensionality=()=>{let r=0;return e.width>1&&r++,e.height>1&&r++,e.depth>1&&r++,r},t.resizeToMatch=r=>{(r.getWidth()!==e.width||r.getHeight()!==e.height||r.getDepth()!==e.depth)&&(e.width=r.getWidth(),e.height=r.getHeight(),e.depth=r.getDepth(),e.handle=e.device.getHandle().createTexture({size:[e.width,e.height,e.depth],format:e.format,usage:e.usage,label:e.label}))},t.resize=function(r,n){let i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1;(r!==e.width||n!==e.height||i!==e.depth)&&(e.width=r,e.height=n,e.depth=i,e.handle=e.device.getHandle().createTexture({size:[e.width,e.height,e.depth],format:e.format,usage:e.usage,label:e.label}))},t.createView=function(r){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};n.dimension||(n.dimension=e.depth===1?"2d":"3d");const i=Che.newInstance({label:r});return i.create(t,n),i}}const The={device:null,handle:null,buffer:null,ready:!1,label:null};function _he(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,The,r),Z.obj(t,e),Z.get(t,e,["handle","ready","width","height","depth","format","usage"]),Z.setGet(t,e,["device","label"]),She(t,e)}Z.newInstance(_he);function Ehe(t){if(!t||t.data.length===0)throw new Error("Invalid contour set data, see publicContourSetData type for more info");if(!t.id)throw new Error("Invalid contour set data, each contour set must have an id");if(!t.data||!Array.isArray(t.data))throw new Error("Invalid contour set data, each contour set must have an array of contours");t.data.forEach(e=>{if(!e.points||!Array.isArray(e.points))throw new Error("Invalid contour set data, each contour must have an array of points");e.points.forEach(r=>{if(!r||!Array.isArray(r)||r.length!==3)throw new Error("Invalid contour set data, each point must be an array of length 3")})})}class H9{constructor(e){const{points:r,type:n}=e.data;this.id=e.id,this._points=r,this._type=n,this._color=e.color,this._segmentIndex=e.segmentIndex,this.sizeInBytes=this._getSizeInBytes()}_getSizeInBytes(){return this._points.length*3}get points(){return this._points}set points(e){this._points=e}get color(){return this._color}set color(e){this._color=e}get type(){return this._type}set type(e){this._type=e}get segmentIndex(){return this._segmentIndex}set segmentIndex(e){this._segmentIndex=e}get flatPointsArray(){return this._points.map(e=>[...e]).flat()}}class bhe{constructor(e){this._color=[200,0,0],this.id=e.id,this._contours=[],this._color=e.color??this._color,this.frameOfReferenceUID=e.frameOfReferenceUID,this._segmentIndex=e.segmentIndex,this._createEachContour(e.data),this.sizeInBytes=this._getSizeInBytes()}_createEachContour(e){e.forEach(r=>{const{points:n,type:i,color:o}=r,a=new H9({id:`${this.id}-segment-${this._segmentIndex}`,data:{points:n,type:i,segmentIndex:this._segmentIndex,color:o??this._color},segmentIndex:this._segmentIndex,color:o??this._color});this._contours.push(a)}),this._updateContourSetCentroid()}_updateContourSetCentroid(){const e=this.totalNumberOfPoints,r=this.flatPointsArray,n=r.reduce((a,s)=>[a[0]+s[0],a[1]+s[1],a[2]+s[2]],[0,0,0]),i=[n[0]/e,n[1]/e,n[2]/e],o=r.reduce((a,s)=>{const c=this._getDistance(i,s),l=this._getDistance(i,a);return c<l?s:a},r[0]);this._centroid=o}_getSizeInBytes(){return this._contours.reduce((e,r)=>e+r.sizeInBytes,0)}_getDistance(e,r){return Math.sqrt((e[0]-r[0])**2+(e[1]-r[1])**2+(e[2]-r[2])**2)}get centroid(){return this._centroid}get segmentIndex(){return this._segmentIndex}get color(){return this._color}set color(e){this._color=e,this._contours.forEach(r=>{r instanceof H9&&(r.color=e)})}get contours(){return this._contours}get flatPointsArray(){return this._contours.flatMap(e=>e.points)}get numberOfContours(){return this._contours.length}get totalNumberOfPoints(){return this._contours.reduce((e,r)=>e+r.points.length,0)}get numberOfPointsArray(){return this._contours.map(e=>e.points.length)}getPointsInContour(e){return this._contours[e].points}getNumberOfPointsInAContour(e){return this.getPointsInContour(e).length}}function Dhe(t,e){Ehe(e);const r=new bhe({id:e.id,data:e.data,color:e.color,frameOfReferenceUID:e.frameOfReferenceUID,segmentIndex:e.segmentIndex??1});return{id:t,type:Kc.CONTOUR,data:r,sizeInBytes:r.sizeInBytes}}function Ihe(t){var e,r;if(!t.id)throw new Error("Surface must have an id");if(((e=t.points)==null?void 0:e.length)===0)throw new Error("Surface must have non-empty points array");if(((r=t.polys)==null?void 0:r.length)===0)throw new Error("Surface must have non-empty polys array");if(!t.frameOfReferenceUID)throw new Error("Surface must have a frameOfReferenceUID")}function Ohe(t,e){Ihe(e);const r=new Yk({id:e.id,points:e.points,polys:e.polys,color:e.color,frameOfReferenceUID:e.frameOfReferenceUID,segmentIndex:e.segmentIndex??1});return{id:t,type:Kc.SURFACE,data:r,sizeInBytes:r.sizeInBytes}}function Mhe(t){if(!t.id)throw new Error("Mesh must have an id");if(!t.arrayBuffer)throw new Error("Mesh must have an arrayBuffer");if(!(t.format in ka))throw new Error(`Mesh format must be one of the following: ${Object.values(ka).join(", ")}`)}function Phe(t,e){e.classHierarchy.push("vtkMTLReader");function r(){e.requestCount--,e.requestCount===0&&t.invokeBusy(!1)}function n(o){if(o[0]==="#"||o.length===0)return;const a=o.split(/[ \t]+/).map(s=>s.trim()).filter(s=>s.length);if(a[0]==="newmtl")a.shift(),e.currentMaterial=a.join(" ").trim();else if(e.currentMaterial){if(a.length<2)return;if(e.materials[e.currentMaterial]||(e.materials[e.currentMaterial]={}),e.materials[e.currentMaterial][a[0]]=a.slice(1),a[0]==="map_Kd"){const s=new Image;s.onload=()=>setTimeout(r,0),s.src=[e.baseURL,a[1]].join("/"),e.materials[e.currentMaterial].image=s,e.requestCount++}}}e.dataAccessHelper||(e.dataAccessHelper=hm.get("http"));function i(o,a){return e.dataAccessHelper.fetchText(t,o,a)}t.setUrl=function(o){let a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(o.indexOf(".mtl")===-1&&!a.fullpath)e.baseURL=o,e.url=`${o}/index.mtl`;else{e.url=o;const s=o.split("/");s.pop(),e.baseURL=s.join("/")}return t.loadData(a)},t.loadData=o=>new Promise((a,s)=>{i(e.url,o).then(c=>{t.parseAsText(c),a()},c=>{s()})}),t.parseAsText=o=>{t.modified(),e.materials={},o.split(`
|
||
`).forEach(n)},t.isBusy=()=>!!e.requestCount,t.getMaterialNames=()=>Object.keys(e.materials),t.getMaterial=o=>e.materials[o],t.listImages=()=>Object.keys(e.materials).map(o=>e.materials[o].map_Kd).filter(o=>!!o).map(o=>o[0].trim()),t.setImageSrc=(o,a)=>new Promise((s,c)=>{const l=Object.keys(e.materials).find(u=>e.materials[u].map_Kd&&e.materials[u].map_Kd[0].trim()===o.trim()),f=e.materials[l];f&&f.image?(f.image.src=a,f.image.onload=()=>setTimeout(s,0)):s()}),t.applyMaterialToActor=(o,a)=>{const s=e.materials[o];if(s&&a){const c=[1,1,1],l={ambientColor:s.Ka?s.Ka.map(u=>Number(u)):c,specularColor:s.Ks?s.Ks.map(u=>Number(u)):c,diffuseColor:s.Kd?s.Kd.map(u=>Number(u)):c,opacity:s.d?Number(s.d):1,specularPower:s.Ns?Number(s.Ns):1},f=Number(s.illum||2);if(["ambient","diffuse","specular"].forEach((u,d)=>{l[u]=d<=f?1:0}),s.image){const u=Bd.newInstance({interpolate:e.interpolateTextures});u.setImage(s.image),a.addTexture(u)}a.getProperty().set(l)}}}const Rhe={numberOfOutputs:1,requestCount:0,materials:{},interpolateTextures:!0};function rF(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,Rhe,r),or(t,e),Ro(t,e,["url","baseURL"]),Jr(t,e,["dataAccessHelper","interpolateTextures","splitGroup"]),L_(t,e,"busy"),Phe(t,e)}const Lhe=Rn(rF,"vtkMTLReader");var Ahe={newInstance:Lhe,extend:rF};function iF(t,e){Mhe(e);const r=new nfe({...e}),n={id:t,type:Kc.MESH,data:r,sizeInBytes:r.sizeInBytes};switch(e.format){case ka.PLY:if(e.materialUrl){const i=new Image;return new Promise((o,a)=>{i.onload=()=>{try{const s=Bd.newInstance();s.setInterpolate(!0),s.setImage(i),r.defaultActor.addTexture(s),o(n)}catch(s){a(s)}},i.onerror=s=>a(s),i.src=e.materialUrl})}return Promise.resolve(n);case ka.OBJ:if(e.materialUrl){const i=Ahe.newInstance();return i.setUrl(e.materialUrl).then(()=>{for(let o=0;o<r.actors.length;o++){const a=r.actors[o],s=a.getMapper();if(s){const c=s.getInputData();if(c){const l=c.get("name").name;i.applyMaterialToActor(l,a)}}}return n}).catch(o=>{throw new Error(`Failed to load material: ${o}`)})}return Promise.resolve(n);case ka.STL:case ka.VTP:return Promise.resolve(n);default:return Promise.reject(new Error(`Unsupported format: ${e.format}`))}}function Nhe({url:t,signal:e,onload:r,loaderOptions:n}){return new Promise((i,o)=>{const a=new XMLHttpRequest;a.open("GET",t,!0);const s={},c=n.beforeSend(a,s),l=Object.assign({},s,c);a.responseType="arraybuffer",Object.keys(l).forEach(function(h){l[h]!==null&&a.setRequestHeader(h,l[h])});const f=function(h){r&&typeof r=="function"&&r(),e&&e.removeEventListener("abort",u),i(a.response)},u=()=>{a.abort(),a.removeEventListener("load",f),o(new Error("Request aborted"))};a.addEventListener("load",f);const d=(h,g)=>{const p={url:t,loaded:h,total:g};it(Ze,et.GEOMETRY_LOAD_PROGRESS,{data:p})};a.onprogress=function(h){d(h.loaded,h.total)},e&&e.aborted?(a.abort(),o(new Error("Request aborted"))):e&&e.addEventListener("abort",u),a.send()})}function oF(t,e,r){return{promise:new Promise((i,o)=>{khe(t,e,r).then(i).catch(o)}),cancelFn:void 0,decache:()=>{}}}async function khe(t,e,r){const i=t.split(":").slice(1).join(":"),o=await Nhe({url:i,loaderOptions:r});if(!e||!("geometryData"in e))throw new Error("Mesh must have a geometryData");return iF(i,{...e.geometryData,arrayBuffer:o})}let e5={beforeSend(t){}};function Vhe(t){e5=Object.assign(e5,t)}function Fhe(){return e5}const aF={};let Sp;function sF(t,e){const r=t.indexOf(":"),n=t.substring(0,r);let i=aF[n];if(i==null){if(Sp==null||typeof Sp!="function")throw new Error(`No geometry loader for scheme ${n} has been registered`);i=Sp}const o=i(t,e,e5);return o.promise.then(function(a){it(Ze,et.GEOMETRY_LOADED,{geometry:a})},function(a){const s={geometryId:t,error:a};it(Ze,et.GEOMETRY_LOADED_FAILED,s)}),o}function Uhe(t,e){if(t===void 0)throw new Error("loadGeometry: parameter geometryId must not be undefined");let r=$e.getGeometryLoadObject(t);return r!==void 0||(r=sF(t,e)),r.promise}async function Bhe(t,e){if(t===void 0)throw new Error("createAndCacheGeometry: parameter geometryId must not be undefined");let r=$e.getGeometryLoadObject(t);return r!==void 0||(r=sF(t,e),await $e.putGeometryLoadObject(t,r)),r.promise}function Ghe(t,e){if(t===void 0)throw new Error("createAndCacheGeometry: parameter geometryId must not be undefined");let r=$e.getGeometry(t);if(r)return r;if(e.type===Kc.CONTOUR)r=Dhe(t,e.geometryData);else if(e.type===Kc.SURFACE)r=Ohe(t,e.geometryData);else if(e.type===Kc.MESH)iF(t,e.geometryData).then(n=>{r=n});else throw new Error(`Unknown geometry type: ${e.type}`);return $e.putGeometrySync(t,r),r}function cF(t,e){aF[t]=e}function Whe(t){const e=Sp;return Sp=t,e}cF("mesh",oF);const zhe=Object.freeze(Object.defineProperty({__proto__:null,createAndCacheGeometry:Ghe,getOptions:Fhe,loadAndCacheGeometry:Bhe,loadGeometry:Uhe,registerGeometryLoader:cF,registerUnknownGeometryLoader:Whe,setOptions:Vhe},Symbol.toStringTag,{value:"Module"}));function $he(t,e){if(!e||!e.imageIds||!e.imageIds.length)throw new Error("ImageIds must be provided to create a 4D streaming image volume");const{imageIds:r}=e,{splittingTag:n,imageIdGroups:i}=vE(r),o=Math.floor(i.length/2),a=sm(i[o],t),{metadata:s,dimensions:c,spacing:l,direction:f,sizeInBytes:u,origin:d,numberOfComponents:h,dataType:g}=a,p=f.slice(6,9),v=i.map(x=>q4(x,p).sortedImageIds),y=v.flat(),m=fc.createScalarDynamicVolumeVoxelManager({dimensions:c,imageIdGroups:v,dimensionGroupNumber:1,numberOfComponents:h});let w=new AV({volumeId:t,metadata:s,dimensions:c,spacing:l,origin:d,direction:f,sizeInBytes:u,imageIds:y,imageIdGroups:v,splittingTag:n,voxelManager:m,numberOfComponents:h,dataType:g},{imageIds:y,loadStatus:{loaded:!1,loading:!1,cancelled:!1,cachedFrames:[],callbacks:[]}});return{promise:Promise.resolve(w),decache:()=>{w.destroy(),w=null},cancel:()=>{w.cancelLoading()}}}const jhe=Object.freeze(Object.defineProperty({__proto__:null,BaseVolumeViewport:fr,CONSTANTS:xf,EPSILON:Q0,EVENTS:et,Enums:Ha,ImageVolume:Ud,ProgressiveRetrieveImages:g1,RenderingEngine:aE,Settings:cr,StackViewport:Jn,StreamingDynamicImageVolume:AV,StreamingImageVolume:yk,Surface:Yk,VideoViewport:_h,Viewport:bd,VolumeViewport:Zn,VolumeViewport3D:oE,WSIViewport:zy,addImageSlicesToViewports:qk,addVolumesToViewports:Kk,cache:$e,canRenderFloatTextures:dw,convertMapperToNotSharedMapper:Ek,cornerstoneMeshLoader:oF,cornerstoneStreamingDynamicImageVolumeLoader:$he,cornerstoneStreamingImageVolumeLoader:wk,createCanvas:dm,createViewportElement:Bk,createVolumeActor:By,createVolumeMapper:_k,eventTarget:Ze,geometryLoader:zhe,getConfiguration:hw,getEnabledElement:Le,getEnabledElementByIds:fi,getEnabledElementByViewportId:Mn,getEnabledElements:IV,getOrCreateCanvas:Bc,getRenderingEngine:Nr,getRenderingEngines:Po,getShouldUseCPURendering:X0,getWebWorkerManager:fl,imageLoadPoolManager:_i,imageLoader:Lse,imageRetrievalPoolManager:qh,init:WA,isCornerstoneInitialized:zA,metaData:A4,peerImport:$A,registerImageLoader:ld,requestPoolManager:_i,resetInitialization:Kte,resetUseCPURendering:Hte,setCanvasCreator:kce,setConfiguration:qte,setPreferSizeOverAccuracy:jte,setUseCPURendering:$te,setVolumesForViewports:Hk,triggerEvent:it,utilities:pn,version:Dle,volumeLoader:$se},Symbol.toStringTag,{value:"Module"}));var ol;(function(t){t[t.Primary=1]="Primary",t[t.Secondary=2]="Secondary",t[t.Primary_And_Secondary=3]="Primary_And_Secondary",t[t.Auxiliary=4]="Auxiliary",t[t.Primary_And_Auxiliary=5]="Primary_And_Auxiliary",t[t.Secondary_And_Auxiliary=6]="Secondary_And_Auxiliary",t[t.Primary_And_Secondary_And_Auxiliary=7]="Primary_And_Secondary_And_Auxiliary",t[t.Fourth_Button=8]="Fourth_Button",t[t.Fifth_Button=16]="Fifth_Button",t[t.Wheel=524288]="Wheel",t[t.Wheel_Primary=524289]="Wheel_Primary"})(ol||(ol={}));var Ri;(function(t){t[t.Shift=16]="Shift",t[t.Ctrl=17]="Ctrl",t[t.Alt=18]="Alt",t[t.Meta=91]="Meta",t[t.ShiftCtrl=1617]="ShiftCtrl",t[t.ShiftAlt=1618]="ShiftAlt",t[t.ShiftMeta=1691]="ShiftMeta",t[t.CtrlAlt=1718]="CtrlAlt",t[t.CtrlMeta=1791]="CtrlMeta",t[t.AltMeta=1891]="AltMeta"})(Ri||(Ri={}));var En;(function(t){t.Active="Active",t.Passive="Passive",t.Enabled="Enabled",t.Disabled="Disabled"})(En||(En={}));var tc;(function(t){t.Default="",t.Highlighted="Highlighted",t.Selected="Selected",t.Locked="Locked",t.AutoGenerated="AutoGenerated"})(tc||(tc={}));var U;(function(t){t.TOOL_ACTIVATED="CORNERSTONE_TOOLS_TOOL_ACTIVATED",t.TOOLGROUP_VIEWPORT_ADDED="CORNERSTONE_TOOLS_TOOLGROUP_VIEWPORT_ADDED",t.TOOLGROUP_VIEWPORT_REMOVED="CORNERSTONE_TOOLS_TOOLGROUP_VIEWPORT_REMOVED",t.TOOL_MODE_CHANGED="CORNERSTONE_TOOLS_TOOL_MODE_CHANGED",t.CROSSHAIR_TOOL_CENTER_CHANGED="CORNERSTONE_TOOLS_CROSSHAIR_TOOL_CENTER_CHANGED",t.ANNOTATION_ADDED="CORNERSTONE_TOOLS_ANNOTATION_ADDED",t.ANNOTATION_COMPLETED="CORNERSTONE_TOOLS_ANNOTATION_COMPLETED",t.ANNOTATION_MODIFIED="CORNERSTONE_TOOLS_ANNOTATION_MODIFIED",t.ANNOTATION_REMOVED="CORNERSTONE_TOOLS_ANNOTATION_REMOVED",t.ANNOTATION_SELECTION_CHANGE="CORNERSTONE_TOOLS_ANNOTATION_SELECTION_CHANGE",t.ANNOTATION_LOCK_CHANGE="CORNERSTONE_TOOLS_ANNOTATION_LOCK_CHANGE",t.ANNOTATION_VISIBILITY_CHANGE="CORNERSTONE_TOOLS_ANNOTATION_VISIBILITY_CHANGE",t.ANNOTATION_RENDERED="CORNERSTONE_TOOLS_ANNOTATION_RENDERED",t.ANNOTATION_CUT_MERGE_PROCESS_COMPLETED="CORNERSTONE_TOOLS_ANNOTATION_CUT_MERGE_PROCESS_COMPLETED",t.ANNOTATION_INTERPOLATION_PROCESS_COMPLETED="CORNERSTONE_TOOLS_ANNOTATION_INTERPOLATION_PROCESS_COMPLETED",t.INTERPOLATED_ANNOTATIONS_REMOVED="CORNERSTONE_TOOLS_INTERPOLATED_ANNOTATIONS_REMOVED",t.SEGMENTATION_MODIFIED="CORNERSTONE_TOOLS_SEGMENTATION_MODIFIED",t.SEGMENTATION_RENDERED="CORNERSTONE_TOOLS_SEGMENTATION_RENDERED",t.SEGMENTATION_REPRESENTATION_ADDED="CORNERSTONE_TOOLS_SEGMENTATION_REPRESENTATION_ADDED",t.SEGMENTATION_ADDED="CORNERSTONE_TOOLS_SEGMENTATION_ADDED",t.SEGMENTATION_REPRESENTATION_MODIFIED="CORNERSTONE_TOOLS_SEGMENTATION_REPRESENTATION_MODIFIED",t.SEGMENTATION_REMOVED="CORNERSTONE_TOOLS_SEGMENTATION_REMOVED",t.SEGMENTATION_REPRESENTATION_REMOVED="CORNERSTONE_TOOLS_SEGMENTATION_REPRESENTATION_REMOVED",t.SEGMENTATION_DATA_MODIFIED="CORNERSTONE_TOOLS_SEGMENTATION_DATA_MODIFIED",t.HISTORY_UNDO="CORNERSTONE_TOOLS_HISTORY_UNDO",t.HISTORY_REDO="CORNERSTONE_TOOLS_HISTORY_REDO",t.KEY_DOWN="CORNERSTONE_TOOLS_KEY_DOWN",t.KEY_UP="CORNERSTONE_TOOLS_KEY_UP",t.MOUSE_DOWN="CORNERSTONE_TOOLS_MOUSE_DOWN",t.MOUSE_UP="CORNERSTONE_TOOLS_MOUSE_UP",t.MOUSE_DOWN_ACTIVATE="CORNERSTONE_TOOLS_MOUSE_DOWN_ACTIVATE",t.MOUSE_DRAG="CORNERSTONE_TOOLS_MOUSE_DRAG",t.MOUSE_MOVE="CORNERSTONE_TOOLS_MOUSE_MOVE",t.MOUSE_CLICK="CORNERSTONE_TOOLS_MOUSE_CLICK",t.MOUSE_DOUBLE_CLICK="CORNERSTONE_TOOLS_MOUSE_DOUBLE_CLICK",t.MOUSE_WHEEL="CORNERSTONE_TOOLS_MOUSE_WHEEL",t.TOUCH_START="CORNERSTONE_TOOLS_TOUCH_START",t.TOUCH_START_ACTIVATE="CORNERSTONE_TOOLS_TOUCH_START_ACTIVATE",t.TOUCH_PRESS="CORNERSTONE_TOOLS_TOUCH_PRESS",t.TOUCH_DRAG="CORNERSTONE_TOOLS_TOUCH_DRAG",t.TOUCH_END="CORNERSTONE_TOOLS_TOUCH_END",t.TOUCH_TAP="CORNERSTONE_TOOLS_TAP",t.TOUCH_SWIPE="CORNERSTONE_TOOLS_SWIPE"})(U||(U={}));var St;(function(t){t.Labelmap="Labelmap",t.Contour="Contour",t.Surface="Surface"})(St||(St={}));var od;(function(t){t.UP="UP",t.DOWN="DOWN",t.LEFT="LEFT",t.RIGHT="RIGHT"})(od||(od={}));var yt;(function(t){t.OnInteractionStart="onInteractionStart",t.OnInteractionEnd="onInteractionEnd",t.Preview="preview",t.RejectPreview="rejectPreview",t.AcceptPreview="acceptPreview",t.Fill="fill",t.Interpolate="interpolate",t.StrategyFunction="strategyFunction",t.CreateIsInThreshold="createIsInThreshold",t.Initialize="initialize",t.INTERNAL_setValue="setValue",t.AddPreview="addPreview",t.ComputeInnerCircleRadius="computeInnerCircleRadius",t.GetStatistics="getStatistics",t.EnsureImageVolumeFor3DManipulation="ensureImageVolumeFor3DManipulation",t.EnsureSegmentationVolumeFor3DManipulation="ensureSegmentationVolumeFor3DManipulation"})(yt||(yt={}));var Bt;(function(t){t.Interaction="Interaction",t.HandlesUpdated="HandlesUpdated",t.StatsUpdated="StatsUpdated",t.InitialSetup="InitialSetup",t.Completed="Completed",t.InterpolationUpdated="InterpolationUpdated",t.History="History",t.MetadataReferenceModified="MetadataReferenceModified",t.LabelChange="LabelChange"})(Bt||(Bt={}));var Wa;(function(t){t.POLYSEG_CONTOUR_TO_LABELMAP="Converting Contour to Labelmap",t.POLYSEG_SURFACE_TO_LABELMAP="Converting Surfaces to Labelmap",t.POLYSEG_CONTOUR_TO_SURFACE="Converting Contour to Surface",t.POLYSEG_LABELMAP_TO_SURFACE="Converting Labelmap to Surface",t.SURFACE_CLIPPING="Clipping Surfaces",t.COMPUTE_STATISTICS="Computing Statistics",t.INTERPOLATE_LABELMAP="Interpolating Labelmap",t.COMPUTE_LARGEST_BIDIRECTIONAL="Computing Largest Bidirectional",t.GENERATE_CONTOUR_SETS="Generating Contour Sets"})(Wa||(Wa={}));const lF=Object.freeze(Object.defineProperty({__proto__:null,AnnotationStyleStates:tc,ChangeTypes:Bt,Events:U,get KeyboardBindings(){return Ri},get MouseBindings(){return ol},SegmentationRepresentations:St,StrategyCallbacks:yt,get Swipe(){return od},ToolModes:En,WorkerTypes:Wa},Symbol.toStringTag,{value:"Module"}));let Tw={};function Hhe(){Tw={}}const K9={isInteractingWithTool:!1,isMultiPartToolActive:!1,tools:{},toolGroups:[],synchronizers:[],svgNodeCache:Tw,enabledElements:[],handleRadius:6};let Je={isInteractingWithTool:!1,isMultiPartToolActive:!1,tools:{},toolGroups:[],synchronizers:[],svgNodeCache:Tw,enabledElements:[],handleRadius:6};function Khe(){Hhe(),Je={...structuredClone({...K9,svgNodeCache:{}}),svgNodeCache:{...K9.svgNodeCache}}}var qhe="Expected a function",uF="__lodash_hash_undefined__",Xhe="[object Function]",Yhe="[object GeneratorFunction]",Jhe="[object Symbol]",Zhe=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Qhe=/^\w*$/,ege=/^\./,tge=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,nge=/[\\^$.*+?()[\]{}|]/g,rge=/\\(\\)?/g,ige=/^\[object .+?Constructor\]$/,oge=typeof Ai=="object"&&Ai&&Ai.Object===Object&&Ai,age=typeof self=="object"&&self&&self.Object===Object&&self,_E=oge||age||Function("return this")();function sge(t,e){return t==null?void 0:t[e]}function cge(t){var e=!1;if(t!=null&&typeof t.toString!="function")try{e=!!(t+"")}catch{}return e}var lge=Array.prototype,uge=Function.prototype,fF=Object.prototype,wC=_E["__core-js_shared__"],q9=function(){var t=/[^.]+$/.exec(wC&&wC.keys&&wC.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),dF=uge.toString,EE=fF.hasOwnProperty,hF=fF.toString,fge=RegExp("^"+dF.call(EE).replace(nge,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),X9=_E.Symbol,dge=lge.splice,hge=gF(_E,"Map"),b1=gF(Object,"create"),Y9=X9?X9.prototype:void 0,J9=Y9?Y9.toString:void 0;function Dd(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function gge(){this.__data__=b1?b1(null):{}}function pge(t){return this.has(t)&&delete this.__data__[t]}function mge(t){var e=this.__data__;if(b1){var r=e[t];return r===uF?void 0:r}return EE.call(e,t)?e[t]:void 0}function vge(t){var e=this.__data__;return b1?e[t]!==void 0:EE.call(e,t)}function yge(t,e){var r=this.__data__;return r[t]=b1&&e===void 0?uF:e,this}Dd.prototype.clear=gge;Dd.prototype.delete=pge;Dd.prototype.get=mge;Dd.prototype.has=vge;Dd.prototype.set=yge;function Xh(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function wge(){this.__data__=[]}function xge(t){var e=this.__data__,r=_w(e,t);if(r<0)return!1;var n=e.length-1;return r==n?e.pop():dge.call(e,r,1),!0}function Cge(t){var e=this.__data__,r=_w(e,t);return r<0?void 0:e[r][1]}function Sge(t){return _w(this.__data__,t)>-1}function Tge(t,e){var r=this.__data__,n=_w(r,t);return n<0?r.push([t,e]):r[n][1]=e,this}Xh.prototype.clear=wge;Xh.prototype.delete=xge;Xh.prototype.get=Cge;Xh.prototype.has=Sge;Xh.prototype.set=Tge;function Gd(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function _ge(){this.__data__={hash:new Dd,map:new(hge||Xh),string:new Dd}}function Ege(t){return Ew(this,t).delete(t)}function bge(t){return Ew(this,t).get(t)}function Dge(t){return Ew(this,t).has(t)}function Ige(t,e){return Ew(this,t).set(t,e),this}Gd.prototype.clear=_ge;Gd.prototype.delete=Ege;Gd.prototype.get=bge;Gd.prototype.has=Dge;Gd.prototype.set=Ige;function _w(t,e){for(var r=t.length;r--;)if(Uge(t[r][0],e))return r;return-1}function Oge(t,e){e=Lge(e,t)?[e]:Rge(e);for(var r=0,n=e.length;t!=null&&r<n;)t=t[Vge(e[r++])];return r&&r==n?t:void 0}function Mge(t){if(!mF(t)||Nge(t))return!1;var e=Bge(t)||cge(t)?fge:ige;return e.test(Fge(t))}function Pge(t){if(typeof t=="string")return t;if(DE(t))return J9?J9.call(t):"";var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function Rge(t){return pF(t)?t:kge(t)}function Ew(t,e){var r=t.__data__;return Age(e)?r[typeof e=="string"?"string":"hash"]:r.map}function gF(t,e){var r=sge(t,e);return Mge(r)?r:void 0}function Lge(t,e){if(pF(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||DE(t)?!0:Qhe.test(t)||!Zhe.test(t)||e!=null&&t in Object(e)}function Age(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function Nge(t){return!!q9&&q9 in t}var kge=bE(function(t){t=Wge(t);var e=[];return ege.test(t)&&e.push(""),t.replace(tge,function(r,n,i,o){e.push(i?o.replace(rge,"$1"):n||r)}),e});function Vge(t){if(typeof t=="string"||DE(t))return t;var e=t+"";return e=="0"&&1/t==-1/0?"-0":e}function Fge(t){if(t!=null){try{return dF.call(t)}catch{}try{return t+""}catch{}}return""}function bE(t,e){if(typeof t!="function"||e&&typeof e!="function")throw new TypeError(qhe);var r=function(){var n=arguments,i=e?e.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var a=t.apply(this,n);return r.cache=o.set(i,a),a};return r.cache=new(bE.Cache||Gd),r}bE.Cache=Gd;function Uge(t,e){return t===e||t!==t&&e!==e}var pF=Array.isArray;function Bge(t){var e=mF(t)?hF.call(t):"";return e==Xhe||e==Yhe}function mF(t){var e=typeof t;return!!t&&(e=="object"||e=="function")}function Gge(t){return!!t&&typeof t=="object"}function DE(t){return typeof t=="symbol"||Gge(t)&&hF.call(t)==Jhe}function Wge(t){return t==null?"":Pge(t)}function zge(t,e,r){var n=t==null?void 0:Oge(t,e);return n===void 0?r:n}var $ge=zge;const jge=ll($ge),Z9=Symbol("DefinedCursors"),vF=new Set(["alias","all-scroll","auto","cell","col-resize","context-menu","copy","crosshair","default","e-resize","ew-resize","grab","grabbing","help","move","ne-resize","nesw-resize","no-drop","none","not-allowed","n-resize","ns-resize","nw-resize","nwse-resize","pointer","progress","row-resize","se-resize","s-resize","sw-resize","text","vertical-text","wait","w-resize","zoom-in","zoom-out"]);class bo{constructor(e,r){this.name=e+"",this.fallback=r}getName(){return this.name+""}addFallbackStyleProperty(e){const{fallback:r}=this;return r instanceof bo?`${e}, ${r.getStyleProperty()}`:e+""}getStyleProperty(){return this.addFallbackStyleProperty(this.name)+""}static getDefinedCursor(e){const r=Q9(bo,Z9);let n=r.get(e);if(n instanceof bo)return n;if(vF.has(e))return n=new bo(e),r.set(e,n),n}static setDefinedCursor(e,r){return r instanceof bo?(Q9(bo,Z9).set(e,r),!0):!1}}function Q9(t,e){let r=t[e];return r instanceof Map||(r=new Map,Object.defineProperty(t,e,{value:r})),r}const Hge=vF.values(),Kge="image-cursor";class D1 extends bo{constructor(e,r,n,i,o){super(i||D1.getUniqueInstanceName(Kge),o),this.url=e,this.x=Number(r)||0,this.y=Number(n)||0}getStyleProperty(){const{url:e,x:r,y:n}=this;let i=`url('${e}')`;return r>=0&&n>=0&&(r>0||n>0)&&(i+=` ${r} ${n}`),this.addFallbackStyleProperty(i)}static getUniqueInstanceName(e){return`${e}-${xV(D1)}`}}const In={iconContent:"",iconSize:16,viewBox:{x:16,y:16},mousePoint:{x:8,y:8},mousePointerGroupString:`
|
||
<path stroke="{{color}}" d="M8 16L8 0"></path>
|
||
<path stroke="{{color}}" d="M16 8L0 8"></path>
|
||
`},ra={x:127,y:60},e0=`
|
||
<rect fill="{{color}}" x="80.19" y="25.03" width="47.14" height="15.85"/>
|
||
`,yu=`
|
||
<rect fill="{{color}}" x="80.19" y="25.03" width="47.14" height="15.85"/>
|
||
<rect fill="{{color}}" x="95.84" y="9.38" width="15.85" height="47.14"/>
|
||
`,L2='<path fill="{{color}}" d="M82.89,10a12.09,12.09,0,0,0-16.8-2.5l-27.5,20.4-8.5-6.3a2.93,2.93,0,0,1-1.1-3,14.66,14.66,0,0,0,.1-6.6,14.08,14.08,0,1,0-6.5,15.2,2.87,2.87,0,0,1,3.2.2l8.2,6.1-8.2,6.1a2.87,2.87,0,0,1-3.2.2,14.16,14.16,0,1,0,6.7,14.4,14,14,0,0,0-.3-5.8,2.93,2.93,0,0,1,1.1-3l8.5-6.3,27.5,20.4A11.91,11.91,0,0,0,82.89,57l-31.7-23.5ZM15.29,21a5.9,5.9,0,1,1,5.9-5.9A5.91,5.91,0,0,1,15.29,21Zm0,36.8a5.9,5.9,0,1,1,5.9-5.9A5.91,5.91,0,0,1,15.29,57.77Zm28.3-21.5a2.8,2.8,0,1,1,2.8-2.8A2.8,2.8,0,0,1,43.59,36.27Z" transform="translate(-1.17 -0.96)"/>',t0='<path fill="{{color}}" d="M8.86,2.25V66.08H72.69V2.25H8.86ZM65.28,58.67h-49v-49h49v49Z" transform="translate(-8.86 -2.25)"/>',A2='<path fill="{{color}}" d="M40.77,2.25A31.92,31.92,0,1,0,72.69,34.16,31.92,31.92,0,0,0,40.77,2.25Zm0,57.63A25.71,25.71,0,1,1,66.48,34.16,25.71,25.71,0,0,1,40.77,59.87Z" transform="translate(-8.86 -2.25)"/>',bw={Angle:On(In,{name:"Angle",iconContent:`<path fill="{{color}}" d="M1203 544q0 13-10 23l-393 393 393 393q10 10 10 23t-10 23l-50
|
||
50q-10 10-23 10t-23-10l-466-466q-10-10-10-23t10-23l466-466q10-10 23-10t23
|
||
10l50 50q10 10 10 23z" />`,viewBox:{x:1792,y:1792}}),ArrowAnnotate:On(In,{name:"ArrowAnnotate",iconContent:`<g id="arrowAnnotate-group" fill="none" stroke-width="1" stroke="{{color}}" stroke-linecap="round" stroke-linejoin="round">
|
||
<path id="arrowAnnotate-arrow" d="M23,7 l-15,15 M7,17 l0,6 6,0" stroke-width="2" />
|
||
</g>`,viewBox:{x:24,y:24}}),Bidirectional:On(In,{name:"Bidirectional",iconContent:`<g fill="{{color}}" stroke-width="3" stroke="{{color}}">
|
||
<path d="M27.63 3.21L3.12 28.81"></path>
|
||
<path d="M27.63 15.75L15.27 4.43"></path>
|
||
<path d="M16.5 4.28C16.5 4.96 15.95 5.51 15.27 5.51C14.59 5.51 14.03 4.96 14.03 4.28C14.03 3.59 14.59 3.04 15.27 3.04C15.95 3.04 16.5 3.59 16.5 4.28Z" ></path>
|
||
<path d="M28.87 3.19C28.87 3.87 28.31 4.43 27.63 4.43C26.95 4.43 26.4 3.87 26.4 3.19C26.4 2.51 26.95 1.95 27.63 1.95C28.31 1.95 28.87 2.51 28.87 3.19Z"></path>
|
||
<path d="M28.87 15.75C28.87 16.43 28.31 16.99 27.63 16.99C26.95 16.99 26.4 16.43 26.4 15.75C26.4 15.07 26.95 14.51 27.63 14.51C28.31 14.51 28.87 15.07 28.87 15.75Z"></path>
|
||
<path d="M4.73 28.44C4.73 29.12 4.17 29.68 3.49 29.68C2.81 29.68 2.25 29.12 2.25 28.44C2.25 27.76 2.81 27.2 3.49 27.2C4.17 27.2 4.73 27.76 4.73 28.44Z"></path>
|
||
</g>`,viewBox:{x:48,y:48}}),CobbAngle:On(In,{name:"CobbAngle",iconContent:`<g stroke="{{color}}" stroke-width="3">
|
||
<path d="M28.59 2.34L3.82 12.32"></path>
|
||
<path d="M28.59 29.66L3.82 19.68"></path>
|
||
<path stroke-dasharray="2" fill-opacity="0" d="M12.37
|
||
23.06C12.67 22.36 12.85 21.93 12.92 21.76C14.6 17.8 14.68 13.35 13.15
|
||
9.33C13.11 9.24 13.02 9 12.88 8.63">
|
||
</path>
|
||
</g>`,viewBox:{x:32,y:32}}),CircleROI:On(In,{name:"CircleROI",iconContent:'<circle stroke="{{color}}" fill="none" stroke-width="3" cx="16" cy="16" r="14" />',viewBox:{x:32,y:32}}),EllipticalROI:On(In,{name:"EllipticalROI",iconContent:`<path stroke="{{color}}" fill="none" stroke-width="3" d="M30.74 15.76C30.74 20.99 24.14 25.23 16
|
||
25.23C7.86 25.23 1.26 20.99 1.26 15.76C1.26 10.54 7.86 6.3 16 6.3C24.14
|
||
6.3 30.74 10.54 30.74 15.76Z" />`,viewBox:{x:32,y:32}}),FreehandROI:On(In,{name:"FreehandROI",iconContent:`<g fill="{{color}}" stroke="{{color}}" stroke-width="2">
|
||
<ellipse ry="1" rx="1" id="svg_3" cy="4.240343" cx="14.306499"/>
|
||
<line id="svg_4" y2="3.58462" x2="12.242186" y1="3.997482" x1="13.432202"/>
|
||
<line id="svg_5" y2="3.268901" x2="10.857882" y1="3.608906" x1="12.387902"/>
|
||
<line id="svg_6" y2="3.147471" x2="9.740724" y1="3.293187" x1="10.955026"/>
|
||
<line id="svg_7" y2="3.147471" x2="8.089274" y1="3.196043" x1="9.983585"/>
|
||
<line id="svg_8" y2="3.268901" x2="6.874972" y1="3.123185" x1="8.307848"/>
|
||
<line id="svg_9" y2="3.657478" x2="5.587812" y1="3.220329" x1="7.020688"/>
|
||
<line id="svg_10" y2="4.046054" x2="4.737801" y1="3.560334" x1="5.854959"/>
|
||
<line id="svg_11" y2="4.337487" x2="4.300652" y1="3.997482" x1="4.834945"/>
|
||
<line id="svg_12" y2="4.726063" x2="3.88779" y1="4.191771" x1="4.470655"/>
|
||
<line id="svg_15" y2="5.3575" x2="3.377783" y1="4.604633" x1="3.960648"/>
|
||
<line id="svg_16" y2="6.183226" x2="2.916348" y1="5.138926" x1="3.547785"/>
|
||
<line id="svg_17" y2="6.960379" x2="2.770632" y1="5.867507" x1="3.037779"/>
|
||
<line id="svg_18" y2="7.713246" x2="2.673488" y1="6.741804" x1="2.819204"/>
|
||
<line id="svg_19" y2="8.684687" x2="2.697774" y1="7.616102" x1="2.673488"/>
|
||
<line id="svg_20" y2="9.753273" x2="2.892062" y1="8.611829" x1="2.697774"/>
|
||
<line id="svg_21" y2="10.724714" x2="3.134923" y1="9.534698" x1="2.84349"/>
|
||
<line id="svg_23" y2="11.647583" x2="3.596357" y1="10.578998" x1="3.086351"/>
|
||
<line id="svg_25" y2="12.521881" x2="4.276366" y1="11.501867" x1="3.499213"/>
|
||
<line id="svg_26" y2="13.930471" x2="5.830673" y1="12.376165" x1="4.13065"/>
|
||
<line id="svg_28" y2="14.707624" x2="7.263549" y1="13.881899" x1="5.733528"/>
|
||
<line id="svg_29" y2="15.339061" x2="8.963571" y1="14.61048" x1="7.06926"/>
|
||
<line id="svg_30" y2="15.581921" x2="10.882168" y1="15.314775" x1="8.817855"/>
|
||
<line id="svg_31" y2="15.460491" x2="12.023612" y1="15.581921" x1="10.785024"/>
|
||
<line id="svg_33" y2="15.120487" x2="13.092197" y1="15.484777" x1="11.877895"/>
|
||
<line id="svg_34" y2="14.586194" x2="13.86935" y1="15.217631" x1="12.897909"/>
|
||
<line id="svg_35" y2="13.833327" x2="14.597931" y1="14.756196" x1="13.699348"/>
|
||
<line id="svg_37" y2="12.716169" x2="15.180796" y1="13.881899" x1="14.549359"/>
|
||
<line id="svg_39" y2="11.429009" x2="15.520801" y1="12.813313" x1="15.15651"/>
|
||
<ellipse ry="1" rx="1" id="svg_40" cy="10.967574" cx="15.520801"/>
|
||
</g>`,viewBox:{x:18,y:18}}),FreehandROISculptor:On(In,{name:"FreehandROISculptor",iconContent:`<g id="icon-freehand-sculpt" fill="none" stroke-width="1.5" stroke="{{color}}" stroke-linecap="round" stroke-linejoin="round">
|
||
<line id="svg_1" y2="2.559367" x2="10.184807" y1="4.467781" x1="8.81711"/>
|
||
<line id="svg_4" y2="1.493836" x2="11.727442" y1="2.766112" x1="10.089386"/>
|
||
<line id="svg_7" y2="1.080346" x2="13.047428" y1="1.748291" x1="11.345759"/>
|
||
<line id="svg_8" y2="1.000829" x2="14.351511" y1="1.112153" x1="12.77707"/>
|
||
<line id="svg_9" y2="1.350705" x2="15.242104" y1="0.905408" x1="13.969828"/>
|
||
<line id="svg_10" y2="2.098167" x2="15.862339" y1="1.14396" x1="14.955842"/>
|
||
<line id="svg_11" y2="3.195505" x2="16.41896" y1="1.939133" x1="15.766918"/>
|
||
<line id="svg_12" y2="4.292843" x2="16.530284" y1="2.925147" x1="16.387153"/>
|
||
<line id="svg_16" y2="5.644637" x2="16.196311" y1="3.831643" x1="16.593898"/>
|
||
<line id="svg_18" y2="7.266789" x2="15.623787" y1="5.19934" x1="16.275829"/>
|
||
<line id="svg_19" y2="10.813258" x2="14.526449" y1="6.726071" x1="15.766918"/>
|
||
<line id="svg_20" y2="5.056209" x2="8.085552" y1="4.181519" x1="8.976145"/>
|
||
<line id="svg_23" y2="5.326568" x2="7.481221" y1="4.78585" x1="8.403621"/>
|
||
<line id="svg_24" y2="5.565119" x2="6.749662" y1="5.294761" x1="7.624352"/>
|
||
<line id="svg_25" y2="5.994512" x2="5.429675" y1="5.533312" x1="6.956407"/>
|
||
<line id="svg_27" y2="6.551133" x2="4.284627" y1="5.962706" x1="5.572807"/>
|
||
<line id="svg_28" y2="7.584858" x2="3.044158" y1="6.392099" x1="4.427758"/>
|
||
<line id="svg_29" y2="8.84123" x2="2.185372" y1="7.489437" x1="3.219096"/>
|
||
<line id="svg_31" y2="10.606513" x2="1.644654" y1="8.602678" x1="2.280792"/>
|
||
<line id="svg_32" y2="13.214679" x2="1.48562" y1="10.352058" x1="1.724171"/>
|
||
<line id="svg_33" y2="14.375631" x2="1.676461" y1="12.992031" x1="1.453813"/>
|
||
<line id="svg_34" y2="15.298031" x2="2.264889" y1="14.152983" x1="1.517427"/>
|
||
<line id="svg_35" y2="16.172721" x2="3.521261" y1="14.948155" x1="1.915013"/>
|
||
<line id="svg_36" y2="16.824762" x2="5.207027" y1="15.997783" x1="3.28271"/>
|
||
<line id="svg_38" y2="17.063314" x2="7.035924" y1="16.745245" x1="4.968475"/>
|
||
<line id="svg_39" y2="16.888376" x2="9.278311" y1="17.047411" x1="6.733758"/>
|
||
<line id="svg_40" y2="16.284045" x2="10.661911" y1="16.983797" x1="8.992048"/>
|
||
<line id="svg_41" y2="15.313934" x2="11.647925" y1="16.395369" x1="10.455166"/>
|
||
<line id="svg_44" y2="13.898527" x2="12.82478" y1="15.425259" x1="11.504794"/>
|
||
<line id="svg_45" y2="12.037824" x2="14.144766" y1="14.312017" x1="12.522614"/>
|
||
<line id="svg_47" y2="10.59061" x2="14.605966" y1="12.228665" x1="13.953925"/>
|
||
<ellipse ry="1" rx="1" id="svg_48" cy="3.982726" cx="13.460918"/>
|
||
</g>`,viewBox:{x:18,y:18}}),Length:On(In,{name:"Length",iconContent:`<g id="length-group" fill="none" stroke-width="1" stroke="{{color}}" stroke-linecap="round" stroke-linejoin="round">
|
||
<path id="length-dashes" d="m22.5,6 -16.5,16.5" stroke-width="3" stroke-dasharray="0.6666,5" />
|
||
</g>`,viewBox:{x:24,y:24}}),Height:On(In,{name:"Height",iconContent:'<path d="m 6 22 l 8.5 0 v -16 h 8" stroke-width="3" fill="none" stroke="{{color}}" />',viewBox:{x:24,y:24}}),Probe:On(In,{name:"Probe",iconContent:`<path fill="{{color}}" d="M1152 896q0 106-75 181t-181 75-181-75-75-181 75-181 181-75 181 75
|
||
75 181zm-256-544q-148 0-273 73t-198 198-73 273 73 273 198 198 273 73 273-73
|
||
198-198 73-273-73-273-198-198-273-73zm768 544q0 209-103 385.5t-279.5
|
||
279.5-385.5 103-385.5-103-279.5-279.5-103-385.5 103-385.5 279.5-279.5
|
||
385.5-103 385.5 103 279.5 279.5 103 385.5z" />`,viewBox:{x:1792,y:1792}}),RectangleROI:On(In,{name:"RectangleROI",iconContent:`<path fill="{{color}}" d="M1312 256h-832q-66 0-113 47t-47 113v832q0 66 47
|
||
113t113 47h832q66 0 113-47t47-113v-832q0-66-47-113t-113-47zm288 160v832q0
|
||
119-84.5 203.5t-203.5 84.5h-832q-119 0-203.5-84.5t-84.5-203.5v-832q0-119
|
||
84.5-203.5t203.5-84.5h832q119 0 203.5 84.5t84.5 203.5z" />`,viewBox:{x:1792,y:1792}}),Label:On(In,{name:"Label",iconContent:`<path fill="{{color}}" d="M789 559l-170 450q33 0 136.5 2t160.5 2q19 0
|
||
57-2-87-253-184-452zm-725 1105l2-79q23-7 56-12.5t57-10.5 49.5-14.5 44.5-29
|
||
31-50.5l237-616 280-724h128q8 14 11 21l205 480q33 78 106 257.5t114 274.5q15
|
||
34 58 144.5t72 168.5q20 45 35 57 19 15 88 29.5t84 20.5q6 38 6 57 0 5-.5
|
||
13.5t-.5 12.5q-63 0-190-8t-191-8q-76 0-215 7t-178 8q0-43 4-78l131-28q1 0
|
||
12.5-2.5t15.5-3.5 14.5-4.5 15-6.5 11-8 9-11
|
||
2.5-14q0-16-31-96.5t-72-177.5-42-100l-450-2q-26 58-76.5 195.5t-50.5 162.5q0
|
||
22 14 37.5t43.5 24.5 48.5 13.5 57 8.5 41 4q1 19 1 58 0 9-2 27-58
|
||
0-174.5-10t-174.5-10q-8 0-26.5 4t-21.5 4q-80 14-188 14z" />`,viewBox:{x:1792,y:1792}}),Crosshairs:On(In,{name:"Crosshairs",iconContent:`<path fill="{{color}}" d="M1325 1024h-109q-26 0-45-19t-19-45v-128q0-26
|
||
19-45t45-19h109q-32-108-112.5-188.5t-188.5-112.5v109q0 26-19 45t-45
|
||
19h-128q-26 0-45-19t-19-45v-109q-108 32-188.5 112.5t-112.5 188.5h109q26
|
||
0 45 19t19 45v128q0 26-19 45t-45 19h-109q32 108 112.5 188.5t188.5
|
||
112.5v-109q0-26 19-45t45-19h128q26 0 45 19t19 45v109q108-32
|
||
188.5-112.5t112.5-188.5zm339-192v128q0 26-19 45t-45 19h-143q-37 161-154.5
|
||
278.5t-278.5 154.5v143q0 26-19 45t-45 19h-128q-26
|
||
0-45-19t-19-45v-143q-161-37-278.5-154.5t-154.5-278.5h-143q-26
|
||
0-45-19t-19-45v-128q0-26 19-45t45-19h143q37-161
|
||
154.5-278.5t278.5-154.5v-143q0-26 19-45t45-19h128q26 0 45 19t19 45v143q161
|
||
37 278.5 154.5t154.5 278.5h143q26 0 45 19t19 45z" />`,viewBox:{x:1792,y:1792}}),Eraser:On(In,{name:"Eraser",iconContent:`<path transform="translate(0,1792) scale(1,-1)" fill="{{color}}" d="M960 1408l336-384h-768l-336 384h768zm1013-1077q15
|
||
34 9.5 71.5t-30.5 65.5l-896 1024q-38 44-96 44h-768q-38
|
||
0-69.5-20.5t-47.5-54.5q-15-34-9.5-71.5t30.5-65.5l896-1024q38-44 96-44h768q38
|
||
0 69.5 20.5t47.5 54.5z" />`,viewBox:{x:2048,y:1792}}),Magnify:On(In,{name:"Magnify",iconContent:`<path fill="{{color}}" d="M508.5 481.6l-129-129c-2.3-2.3-5.3-3.5-8.5-3.5h-10.3C395
|
||
312 416 262.5 416 208 416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c54.5
|
||
0 104-21 141.1-55.2V371c0 3.2 1.3 6.2 3.5 8.5l129 129c4.7 4.7 12.3 4.7 17
|
||
0l9.9-9.9c4.7-4.7 4.7-12.3 0-17zM208 384c-97.3 0-176-78.7-176-176S110.7 32 208
|
||
32s176 78.7 176 176-78.7 176-176 176z" />`,viewBox:{x:512,y:512}}),Pan:On(In,{name:"Pan",iconContent:`<path fill="{{color}}" d="M1411 541l-355 355 355 355 144-144q29-31 70-14 39 17
|
||
39 59v448q0 26-19 45t-45 19h-448q-42 0-59-40-17-39 14-69l144-144-355-355-355
|
||
355 144 144q31 30 14 69-17 40-59 40h-448q-26 0-45-19t-19-45v-448q0-42 40-59
|
||
39-17 69 14l144 144 355-355-355-355-144 144q-19 19-45 19-12
|
||
0-24-5-40-17-40-59v-448q0-26 19-45t45-19h448q42 0 59 40 17 39-14 69l-144
|
||
144 355 355 355-355-144-144q-31-30-14-69 17-40 59-40h448q26 0 45 19t19
|
||
45v448q0 42-39 59-13 5-25 5-26 0-45-19z" />`,viewBox:{x:1792,y:1792}}),Rotate:On(In,{name:"Rotate",iconContent:`<path fill="{{color}}" d="M1664 256v448q0 26-19 45t-45 19h-448q-42 0-59-40-17-39
|
||
14-69l138-138q-148-137-349-137-104 0-198.5 40.5t-163.5 109.5-109.5
|
||
163.5-40.5 198.5 40.5 198.5 109.5 163.5 163.5 109.5 198.5 40.5q119 0
|
||
225-52t179-147q7-10 23-12 15 0 25 9l137 138q9 8 9.5 20.5t-7.5 22.5q-109
|
||
132-264 204.5t-327 72.5q-156 0-298-61t-245-164-164-245-61-298 61-298
|
||
164-245 245-164 298-61q147 0 284.5 55.5t244.5 156.5l130-129q29-31 70-14
|
||
39 17 39 59z" />`,viewBox:{x:1792,y:1792}}),StackScroll:On(In,{name:"StackScroll",iconContent:`<path fill="{{color}}" d="M24 21v2c0 0.547-0.453 1-1 1h-22c-0.547
|
||
0-1-0.453-1-1v-2c0-0.547 0.453-1 1-1h22c0.547 0 1 0.453 1 1zM24 13v2c0
|
||
0.547-0.453 1-1 1h-22c-0.547 0-1-0.453-1-1v-2c0-0.547 0.453-1 1-1h22c0.547
|
||
0 1 0.453 1 1zM24 5v2c0 0.547-0.453 1-1 1h-22c-0.547
|
||
0-1-0.453-1-1v-2c0-0.547 0.453-1 1-1h22c0.547 0 1 0.453 1 1z" />`,viewBox:{x:24,y:28}}),WindowLevelRegion:On(In,{name:"WindowLevelRegion",iconContent:`<path fill="{{color}}" d="M1664 416v960q0 119-84.5 203.5t-203.5 84.5h-960q-119
|
||
0-203.5-84.5t-84.5-203.5v-960q0-119 84.5-203.5t203.5-84.5h960q119 0 203.5
|
||
84.5t84.5 203.5z" />`,viewBox:{x:1792,y:1792}}),WindowLevel:On(In,{name:"WindowLevel",iconContent:`
|
||
<path fill="{{color}}" d="M14.5,3.5 a1 1 0 0 1 -11,11 Z" stroke="none" opacity="0.8" />
|
||
<circle cx="9" cy="9" r="8" fill="none" stroke-width="2" stroke="{{color}}" />`,viewBox:{x:18,y:18}}),Zoom:On(In,{name:"Zoom",iconContent:`
|
||
<path fill="{{color}}" d="M508.5 481.6l-129-129c-2.3-2.3-5.3-3.5-8.5-3.5h-10.3C395
|
||
312 416 262.5 416 208 416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c54.5
|
||
0 104-21 141.1-55.2V371c0 3.2 1.3 6.2 3.5 8.5l129 129c4.7 4.7 12.3 4.7 17
|
||
0l9.9-9.9c4.7-4.7 4.7-12.3 0-17zM208 384c-97.3 0-176-78.7-176-176S110.7 32 208
|
||
32s176 78.7 176 176-78.7 176-176 176z" />
|
||
<path fill="{{color}}" transform="scale(0.22,0.22) translate(1400,0)" d="M1216
|
||
320q0 26-19 45t-45 19h-128v1024h128q26 0 45 19t19 45-19 45l-256 256q-19
|
||
19-45 19t-45-19l-256-256q-19-19-19-45t19-45 45-19h128v-1024h-128q-26
|
||
0-45-19t-19-45 19-45l256-256q19-19 45-19t45 19l256 256q19 19 19 45z" />`,viewBox:{x:640,y:512}}),SegmentationFreeHandEraseInside:On(In,{name:"SegmentationFreeHandEraseInside",iconContent:`${L2} ${e0}`,viewBox:ra}),SegmentationFreeHandFillInside:On(In,{name:"SegmentationFreeHandFillInside",iconContent:`${L2} ${yu}`,viewBox:ra}),SegmentationFreeHandEraseOutside:On(In,{name:"SegmentationFreeHandEraseOutside",iconContent:`${L2} ${e0}`,viewBox:ra}),SegmentationFreeHandFillOutside:On(In,{name:"SegmentationFreeHandFillOutside",iconContent:`${L2} ${yu}`,viewBox:ra}),SegmentationRectangleEraseInside:On(In,{name:"SegmentationRectangleEraseInside",iconContent:`${t0} ${e0}`,viewBox:ra}),RectangleScissor:On(In,{name:"RectangleScissor",iconContent:`${t0} ${yu}`,viewBox:ra}),"RectangleScissor.FILL_INSIDE":On(In,{name:"RectangleScissor.FILL_INSIDE",iconContent:`${t0} ${yu}`,viewBox:ra}),"RectangleScissor.FILL_OUTSIDE":On(In,{name:"RectangleScissor.FILL_OUTSIDE",iconContent:`${t0} ${yu}`,viewBox:ra}),"RectangleScissor.ERASE_OUTSIDE":On(In,{name:"RectangleScissor.ERASE_OUTSIDE",iconContent:`${t0} ${e0}`,viewBox:ra}),"RectangleScissor.ERASE_INSIDE":On(In,{name:"RectangleScissor.ERASE_INSIDE",iconContent:`${t0} ${e0}`,viewBox:ra}),CircleScissor:On(In,{name:"CircleScissor",iconContent:`${A2} ${yu}`,viewBox:ra}),"CircleScissor.FILL_INSIDE":On(In,{name:"CircleScissor.FILL_INSIDE",iconContent:`${A2} ${yu}`,viewBox:ra}),"CircleScissor.ERASE_OUTSIDE":On(In,{name:"CircleScissor.ERASE_OUTSIDE",iconContent:`${A2} ${e0}`,viewBox:ra}),"CircleScissor.FILL_OUTSIDE":On(In,{name:"CircleScissor.FILL_OUTSIDE",iconContent:`${A2} ${yu}`,viewBox:ra})};function On(t,e){return Object.assign(Object.create(t),{...e,name:e.name||t.name})}function qge(t,e,r){bw[t]=On(In,{iconContent:e,viewBox:r})}function Xge(t){return bw[t]}const Yge=Object.keys(bw);class Jge{constructor(){const e={color:"rgb(255, 255, 0)",colorHighlighted:"rgb(0, 255, 0)",colorSelected:"rgb(0, 220, 0)",colorLocked:"rgb(209, 193, 90)",lineWidth:"1",lineDash:"",shadow:!0,textBoxVisibility:!0,textBoxFontFamily:"Helvetica Neue, Helvetica, Arial, sans-serif",textBoxFontSize:"14px",textBoxColor:"rgb(255, 255, 0)",textBoxColorHighlighted:"rgb(0, 255, 0)",textBoxColorSelected:"rgb(0, 255, 0)",textBoxColorLocked:"rgb(209, 193, 90)",textBoxBackground:"",textBoxLinkLineWidth:"1",textBoxLinkLineDash:"2,3",textBoxShadow:!0,markerSize:"10",angleArcLineDash:""};this._initializeConfig(e)}getAnnotationToolStyles(e){return this.config.annotations&&this.config.annotations[e]}getViewportToolStyles(e){return this.config.viewports&&this.config.viewports[e]}getToolGroupToolStyles(e){return this.config.toolGroups&&this.config.toolGroups[e]}getDefaultToolStyles(){return this.config.default}setAnnotationStyles(e,r){let n=this.config.annotations;n||(this.config={...this.config,annotations:{}},n=this.config.annotations),n[e]=r}setViewportToolStyles(e,r){let n=this.config.viewports;n||(this.config={...this.config,viewports:{}},n=this.config.viewports),n[e]=r}setToolGroupToolStyles(e,r){let n=this.config.toolGroups;n||(this.config={...this.config,toolGroups:{}},n=this.config.toolGroups),n[e]=r}setDefaultToolStyles(e){this.config.default=e}getStyleProperty(e,r){const{annotationUID:n,viewportId:i,toolGroupId:o,toolName:a}=r;return this._getToolStyle(e,n,i,o,a)}_getToolStyle(e,r,n,i,o){if(r){const s=this.getAnnotationToolStyles(r);if(s&&s[e]!==void 0)return s[e]}if(n){const s=this.getViewportToolStyles(n);if(s){if(s[o]&&s[o][e]!==void 0)return s[o][e];if(s.global&&s.global[e]!==void 0)return s.global[e]}}if(i){const s=this.getToolGroupToolStyles(i);if(s){if(s[o]&&s[o][e]!==void 0)return s[o][e];if(s.global&&s.global[e]!==void 0)return s.global[e]}}const a=this.getDefaultToolStyles();if(a[o]&&a[o][e]!==void 0)return a[o][e];if(a.global&&a.global[e]!==void 0)return a.global[e]}_initializeConfig(e){const r={};for(const n in e)r[n]=e[n];this.config={default:{global:r}}}}const IE=new Jge;function Zge(t,e,r){const n=[`${t}`];return e&&n.push(`${n[0]}${e}`),r&&n.push(`${n[n.length-1]}${r}`),n}function Dh(t,e,r,n){const i=Zge(t,r,n);for(let o=i.length-1;o>=0;--o){const a=IE.getStyleProperty(i[o],e);if(a!==void 0)return a}}const Qge="color",epe=tc.Highlighted,tpe=En.Active;class nh extends D1{constructor(e,r,n,i,o){super(e,r,n,i,o)}static getDefinedCursor(e,r=!1,n){n||(n=Dh(Qge,{},epe,tpe));const i=npe(e,r,n);let o=super.getDefinedCursor(i);if(!o){const a=Xge(e);a&&(o=rpe(a,i,r,n,super.getDefinedCursor("default")),super.setDefinedCursor(i,o))}return o}}function yF(t,e){const r=Object(e),n=Object.prototype.hasOwnProperty.bind(r);return(t+"").replace(/\{\{(\w+)\}\}/g,(i,o)=>n(o)?r[o]+"":"")}function npe(t,e,r){return`${e?"pointer":"cursor"}:${t}/${r}`}function rpe(t,e,r,n,i){const{x:o,y:a}=t.mousePoint;return new nh(ipe(t,r,{color:n}),o,a,e,i)}function ipe(t,e,r){const n=ope(t,e,r);return`${URL.createObjectURL(n)}#${t.name||"unknown"}-${e?"pointer":"cursor"}`}function ope(t,e,r){const n=(e?spe:ape)(t,r);return new Blob([n],{type:"image/svg+xml"})}function ape(t,e){const{iconContent:r,iconSize:n,viewBox:i}=t,o=`
|
||
<svg data-icon="cursor" role="img" xmlns="http://www.w3.org/2000/svg"
|
||
width="${n}" height="${n}" viewBox="0 0
|
||
${i.x} ${i.y}">
|
||
${r}
|
||
</svg>`;return yF(o,e)}function spe(t,e){const{iconContent:r,iconSize:n,viewBox:i,mousePointerGroupString:o}=t,a=n/Math.max(i.x,i.y,1),s=16+n,c=`
|
||
<svg data-icon="cursor" role="img" xmlns="http://www.w3.org/2000/svg"
|
||
width="${s}" height="${s}" viewBox="0 0 ${s} ${s}">
|
||
<g>${o}</g>
|
||
<g transform="translate(16, 16) scale(${a})">${r}</g>
|
||
</svg>`;return yF(c,e)}const eI=Symbol("ElementCursorsMap");function wF(t,e){I1(t)[0]=e,mm(t,e)}function mm(t,e){const r=I1(t);r[1]=r[0],r[0]=e,t.style.cursor=(e instanceof bo?e:bo.getDefinedCursor("auto")).getStyleProperty()}function kt(t){mm(t,I1(t)[1])}function Dt(t){mm(t,bo.getDefinedCursor("none"))}function I1(t){let e=I1[eI];e instanceof WeakMap||(e=new WeakMap,Object.defineProperty(I1,eI,{value:e}));let r=e.get(t);return r||(r=[null,null],e.set(t,r)),r}const cpe=Object.freeze(Object.defineProperty({__proto__:null,hideElementCursor:Dt,initElementCursor:wF,resetElementCursor:kt,setElementCursor:mm},Symbol.toStringTag,{value:"Module"}));function lpe(t,e){let r=nh.getDefinedCursor(e,!0);r||(r=bo.getDefinedCursor(e)),r||(console.log(`Cursor ${e} is not defined either as SVG or as a standard cursor.`),r=bo.getDefinedCursor(e)),mm(t,r)}const upe=[...Yge,...Hge],fpe=Object.freeze(Object.defineProperty({__proto__:null,CursorNames:upe,CursorSVG:bw,ImageMouseCursor:D1,MouseCursor:bo,SVGMouseCursor:nh,elementCursor:cpe,registerCursor:qge,setCursorForElement:lpe},Symbol.toStringTag,{value:"Module"}));function jr(t){return Je.toolGroups.find(e=>e.id===t)}const{Active:Mg,Passive:xC,Enabled:CC,Disabled:SC}=En,dpe=[{mouseButton:ol.Primary}];class OE{constructor(e){this.viewportsInfo=[],this.toolOptions={},this.currentActivePrimaryToolName=null,this.prevActivePrimaryToolName=null,this.restoreToolOptions={},this._toolInstances={},this.id=e}getViewportIds(){return this.viewportsInfo.map(({viewportId:e})=>e)}getViewportsInfo(){return this.viewportsInfo.slice()}getToolInstance(e){const r=this._toolInstances[e];if(!r){console.warn(`'${e}' is not registered with this toolGroup (${this.id}).`);return}return r}getToolInstances(){return this._toolInstances}hasTool(e){return!!this._toolInstances[e]}addTool(e,r={}){const n=Je.tools[e],i=typeof e<"u"&&e!=="",o=this.toolOptions[e];if(!i){console.warn("Tool with configuration did not produce a toolName: ",r);return}if(!n){console.warn(`'${e}' is not registered with the library. You need to use cornerstoneTools.addTool to register it.`);return}if(o){console.warn(`'${e}' is already registered for ToolGroup ${this.id}.`);return}const{toolClass:a}=n,s={name:e,toolGroupId:this.id,configuration:r},c=new a(s);this._toolInstances[e]=c}addToolInstance(e,r,n={}){var o;let i=(o=Je.tools[e])==null?void 0:o.toolClass;if(!i){const a=Je.tools[r].toolClass;class s extends a{}s.toolName=e,i=s,Je.tools[e]={toolClass:s}}this.addTool(i.toolName,n)}addViewport(e,r){if(typeof e!="string")throw new Error("viewportId must be defined and be a string");const n=this._findRenderingEngine(e,r);this.viewportsInfo.some(({viewportId:s})=>s===e)||this.viewportsInfo.push({viewportId:e,renderingEngineId:n});const i=this.getActivePrimaryMouseButtonTool();cr.getRuntimeSettings().get("useCursors")&&this.setViewportsCursorByToolName(i);const a={toolGroupId:this.id,viewportId:e,renderingEngineId:n};it(Ze,U.TOOLGROUP_VIEWPORT_ADDED,a)}removeViewports(e,r){const n=[];if(this.viewportsInfo.forEach((o,a)=>{let s=!1;o.renderingEngineId===e&&(s=!0,r&&o.viewportId!==r&&(s=!1)),s&&n.push(a)}),n.length)for(let o=n.length-1;o>=0;o--)this.viewportsInfo.splice(n[o],1);const i={toolGroupId:this.id,viewportId:r,renderingEngineId:e};it(Ze,U.TOOLGROUP_VIEWPORT_REMOVED,i)}setActiveStrategy(e,r){const n=this._toolInstances[e];if(n===void 0){console.warn(`Tool ${e} not added to toolGroup, can't set tool configuration.`);return}n.setActiveStrategy(r)}setToolMode(e,r,n={}){if(!e){console.warn("setToolMode: toolName must be defined");return}if(r===En.Active){this.setToolActive(e,n||this.restoreToolOptions[e]);return}if(r===En.Passive){this.setToolPassive(e);return}if(r===En.Enabled){this.setToolEnabled(e);return}if(r===En.Disabled){this.setToolDisabled(e);return}console.warn("setToolMode: mode must be defined")}setToolActive(e,r={}){const n=this._toolInstances[e];if(n===void 0){console.warn(`Tool ${e} not added to toolGroup, can't set tool mode.`);return}if(!n){console.warn(`'${e}' instance ${n} is not registered with this toolGroup, can't set tool mode.`);return}const i=this.toolOptions[e]?this.toolOptions[e].bindings:[],o=r.bindings?r.bindings:[],s={bindings:[...i,...o].reduce((u,d)=>{const h=d.numTouchPoints!==void 0,g=d.mouseButton!==void 0;return!u.some(p=>TC(p,d))&&(h||g)&&u.push(d),u},[]),mode:Mg};this.toolOptions[e]=s,this._toolInstances[e].mode=Mg;const l=cr.getRuntimeSettings().get("useCursors");if(this._hasMousePrimaryButtonBinding(r)&&l)this.setViewportsCursorByToolName(e);else if(!this.getActivePrimaryMouseButtonTool()&&l){const d=bo.getDefinedCursor("default");this._setCursorForViewports(d)}this._hasMousePrimaryButtonBinding(r)&&(this.prevActivePrimaryToolName===null?this.prevActivePrimaryToolName=e:this.prevActivePrimaryToolName=this.currentActivePrimaryToolName,this.currentActivePrimaryToolName=e),typeof n.onSetToolActive=="function"&&n.onSetToolActive(),this._renderViewports();const f={toolGroupId:this.id,toolName:e,toolBindingsOptions:r};it(Ze,U.TOOL_ACTIVATED,f),this._triggerToolModeChangedEvent(e,Mg,r)}setToolPassive(e,r){const n=this._toolInstances[e];if(n===void 0){console.warn(`Tool ${e} not added to toolGroup, can't set tool mode.`);return}const i=this.getToolOptions(e),o=Object.assign({bindings:i?i.bindings:[]},i,{mode:xC}),a=Array.isArray(r==null?void 0:r.removeAllBindings)?r.removeAllBindings:this.getDefaultPrimaryBindings();o.bindings=o.bindings.filter(c=>(r==null?void 0:r.removeAllBindings)!==!0&&!a.some(l=>TC(c,l)));let s=xC;o.bindings.length!==0&&(s=Mg,o.mode=s),this.toolOptions[e]=o,n.mode=s,typeof n.onSetToolPassive=="function"&&n.onSetToolPassive(),this._renderViewports(),this._triggerToolModeChangedEvent(e,xC)}setToolEnabled(e){const r=this._toolInstances[e];if(r===void 0){console.warn(`Tool ${e} not added to toolGroup, can't set tool mode.`);return}const n={bindings:[],mode:CC};this.toolOptions[e]=n,r.mode=CC,typeof r.onSetToolEnabled=="function"&&r.onSetToolEnabled(),this._renderViewports(),this._triggerToolModeChangedEvent(e,CC)}setToolDisabled(e){const r=this._toolInstances[e];if(r===void 0){console.warn(`Tool ${e} not added to toolGroup, can't set tool mode.`);return}const n={bindings:[],mode:SC};this.restoreToolOptions[e]=this.toolOptions[e],this.toolOptions[e]=n,r.mode=SC,typeof r.onSetToolDisabled=="function"&&r.onSetToolDisabled(),this._renderViewports(),this._triggerToolModeChangedEvent(e,SC)}getToolOptions(e){const r=this.toolOptions[e];if(r!==void 0)return r}getActivePrimaryMouseButtonTool(){return Object.keys(this.toolOptions).find(e=>{const r=this.toolOptions[e];return r.mode===Mg&&this._hasMousePrimaryButtonBinding(r)})}setViewportsCursorByToolName(e,r){const n=this._getCursor(e,r);this._setCursorForViewports(n)}_getCursor(e,r){let n,i;return r&&(n=`${e}.${r}`,i=nh.getDefinedCursor(n,!0),i)||(n=`${e}`,i=nh.getDefinedCursor(n,!0),i)||(n=e,i=nh.getDefinedCursor(n,!0),i)?i:bo.getDefinedCursor("default")}_setCursorForViewports(e){this.viewportsInfo.forEach(({renderingEngineId:r,viewportId:n})=>{const i=fi(n,r);if(!i)return;const{viewport:o}=i;wF(o.element,e)})}setToolConfiguration(e,r,n){const i=this._toolInstances[e];if(i===void 0)return console.warn(`Tool ${e} not present, can't set tool configuration.`),!1;let o;return n?o=r:o=Object.assign(i.configuration,r),i.configuration=o,typeof i.onSetToolConfiguration=="function"&&i.onSetToolConfiguration(),this._renderViewports(),!0}getDefaultMousePrimary(){return ol.Primary}getDefaultPrimaryBindings(){return dpe}getToolConfiguration(e,r){if(this._toolInstances[e]===void 0){console.warn(`Tool ${e} not present, can't set tool configuration.`);return}const n=jge(this._toolInstances[e].configuration,r)||this._toolInstances[e].configuration;return ds(n)}getPrevActivePrimaryToolName(){return this.prevActivePrimaryToolName}setActivePrimaryTool(e){const r=this.getCurrentActivePrimaryToolName();this.setToolDisabled(r),this.setToolActive(e,{bindings:[{mouseButton:ol.Primary}]})}getCurrentActivePrimaryToolName(){return this.currentActivePrimaryToolName}clone(e,r=null){let n=jr(e);return n?(console.debug(`ToolGroup ${e} already exists`),n):(n=new OE(e),Je.toolGroups.push(n),r=r??(()=>!0),Object.keys(this._toolInstances).filter(r).forEach(i=>{const o=this._toolInstances[i],a=this.toolOptions[i],s=o.mode;n.addTool(i),n.setToolMode(i,s,{bindings:a.bindings??[]})}),n)}_hasMousePrimaryButtonBinding(e){var n;const r=this.getDefaultPrimaryBindings();return(n=e==null?void 0:e.bindings)==null?void 0:n.some(i=>r.some(o=>TC(i,o)))}_renderViewports(){this.viewportsInfo.forEach(({renderingEngineId:e,viewportId:r})=>{Nr(e).renderViewport(r)})}_triggerToolModeChangedEvent(e,r,n){const i={toolGroupId:this.id,toolName:e,mode:r,toolBindingsOptions:n};it(Ze,U.TOOL_MODE_CHANGED,i)}_findRenderingEngine(e,r){const n=Po();if((n==null?void 0:n.length)===0)throw new Error("No rendering engines found.");if(r)return r;const i=n.filter(o=>o.getViewport(e));if(i.length===0){if(n.length===1)return n[0].id;throw new Error("No rendering engines found that contain the viewport with the same viewportId, you must specify a renderingEngineId.")}if(i.length>1)throw new Error("Multiple rendering engines found that contain the viewport with the same viewportId, you must specify a renderingEngineId.");return i[0].id}}function TC(t,e){return t.mouseButton!==e.mouseButton||t.numTouchPoints!==e.numTouchPoints?!1:t.modifierKey===e.modifierKey}function xF(t){if(Je.toolGroups.some(n=>n.id===t)){console.warn(`'${t}' already exists.`);return}const r=new OE(t);return Je.toolGroups.push(r),r}function CF(t){const e=Je.toolGroups.findIndex(r=>r.id===t);e>-1&&Je.toolGroups.splice(e,1)}function SF(){const t=[...Je.toolGroups];for(const e of t)CF(e.id);Je.toolGroups=[]}function vr(t,e){var n;e||(e=(n=Po().find(i=>i.getViewports().find(o=>o.id===t)))==null?void 0:n.id);const r=Je.toolGroups.filter(i=>i.viewportsInfo.some(o=>o.renderingEngineId===e&&(!o.viewportId||o.viewportId===t)));if(r.length){if(r.length>1)throw new Error(`Multiple tool groups found for renderingEngineId: ${e} and viewportId: ${t}. You should only
|
||
have one tool group per viewport in a renderingEngine.`);return r[0]}}function hpe(){return Je.toolGroups}const gpe=[En.Active,En.Passive,En.Enabled];function TF(t){return Je.toolGroups.filter(({toolOptions:e})=>{const r=Object.keys(e);for(let n=0;n<r.length;n++)if(t===r[n]&&e[t]&&gpe.includes(e[t].mode))return!0;return!1})}const _F=Object.freeze(Object.defineProperty({__proto__:null,createToolGroup:xF,destroy:SF,destroyToolGroup:CF,getAllToolGroups:hpe,getToolGroup:jr,getToolGroupForViewport:vr,getToolGroupsWithToolName:TF},Symbol.toStringTag,{value:"Module"}));function EF(t,e){const r=Le(e),{renderingEngine:n,viewportId:i}=r,o=U.ANNOTATION_ADDED,a={annotation:t,viewportId:i,renderingEngineId:n.id};it(Ze,o,a)}function bF(t){const{toolName:e}=t.metadata,r=TF(e);if(!r.length)return;const n=[];r.forEach(a=>{a.viewportsInfo.forEach(s=>{const{renderingEngineId:c,viewportId:l}=s,{FrameOfReferenceUID:f}=fi(l,c);t.metadata.FrameOfReferenceUID===f&&n.push(s)})});const i=U.ANNOTATION_ADDED,o={annotation:t};if(!n.length){it(Ze,i,o);return}n.forEach(({renderingEngineId:a,viewportId:s})=>{o.viewportId=s,o.renderingEngineId=a,it(Ze,i,o)})}function Dw(t){const e=U.ANNOTATION_REMOVED;it(Ze,e,t)}function Kt(t,e,r=Bt.HandlesUpdated){const n=e&&Le(e),{viewportId:i,renderingEngineId:o}=n||{},a=U.ANNOTATION_MODIFIED;it(Ze,a,{annotation:t,viewportId:i,renderingEngineId:o,changeType:r})}function bn(t){DF({annotation:t})}function Iw(t,e=!1){DF({annotation:t,contourHoleProcessingEnabled:e})}function DF(t){const e=U.ANNOTATION_COMPLETED;it(Ze,e,t)}const ppe=Object.freeze(Object.defineProperty({__proto__:null,triggerAnnotationAddedForElement:EF,triggerAnnotationAddedForFOR:bF,triggerAnnotationCompleted:bn,triggerAnnotationModified:Kt,triggerAnnotationRemoved:Dw,triggerContourAnnotationCompleted:Iw},Symbol.toStringTag,{value:"Module"}));let IF;function mc(){return IF}function ME(t){IF=t}function Jt(t,e){const r=mc(),n=r.getGroupKey(e);return r.getAnnotations(n,t)}function kr(t){return mc().getAnnotation(t)}function vm(){return mc().getAllAnnotations()}function Ow(t){const{annotationUID:e,parentAnnotationUID:r}=t;if(!r)return;const n=kr(r),i=n.childAnnotationUIDs.indexOf(e);n.childAnnotationUIDs.splice(i,1),t.parentAnnotationUID=void 0}function ym(t,e){const{annotationUID:r}=t,{annotationUID:n}=e;Ow(e),t.childAnnotationUIDs||(t.childAnnotationUIDs=[]),!t.childAnnotationUIDs.includes(n)&&(t.childAnnotationUIDs.push(n),e.parentAnnotationUID=r)}function OF(t){return t.parentAnnotationUID?kr(t.parentAnnotationUID):void 0}function wm(t){var e;return((e=t.childAnnotationUIDs)==null?void 0:e.map(r=>kr(r)))??[]}function qt(t,e){t.annotationUID||(t.annotationUID=gn());const r=mc();if(e instanceof HTMLDivElement){const n=r.getGroupKey(e);r.addAnnotation(t,n),EF(t,e)}else r.addAnnotation(t,void 0),bF(t);return t.annotationUID}function mpe(t,e){const r=mc(),n=r.getGroupKey(e);return r.getNumberOfAnnotations(n,t)}function en(t){var n;if(!t)return;const e=mc(),r=e.getAnnotation(t);r&&((n=r.childAnnotationUIDs)==null||n.forEach(i=>en(i)),e.removeAnnotation(t),Dw({annotation:r,annotationManagerUID:e.uid}))}function vpe(){const t=mc(),e=t.removeAllAnnotations();for(const r of e)Dw({annotation:r,annotationManagerUID:t.uid})}function ype(t,e){const r=mc(),n=r.getGroupKey(e),i=r.removeAnnotations(n,t);for(const o of i)Dw({annotation:o,annotationManagerUID:r.uid})}function MF(t){let e=t;for(;e;)e.invalidated=!0,e=e.parentAnnotationUID?kr(e.parentAnnotationUID):void 0}const wpe=Object.freeze(Object.defineProperty({__proto__:null,addAnnotation:qt,addChildAnnotation:ym,clearParentAnnotation:Ow,getAllAnnotations:vm,getAnnotation:kr,getAnnotationManager:mc,getAnnotations:Jt,getChildAnnotations:wm,getNumberOfAnnotations:mpe,getParentAnnotation:OF,invalidateAnnotation:MF,removeAllAnnotations:vpe,removeAnnotation:en,removeAnnotations:ype,setAnnotationManager:ME},Symbol.toStringTag,{value:"Module"}));function xi(t){const e=t.toolName;if(!e)throw new Error(`No Tool Found for the ToolClass ${t.name}`);Je.tools[e]||(Je.tools[e]={toolClass:t})}function xpe(t){const e=t.toolName;return!!(e&&Je.tools[e])}function Mw(t){return!!(t&&Je.tools[t])}function PF(t){const e=t.toolName;if(!e)throw new Error(`No tool found for: ${t.name}`);if(!Je.tools[e]!==void 0)delete Je.tools[e];else throw new Error(`${e} cannot be removed because it has not been added`)}function Wd(t,e){const r=e||t.currentTarget,{viewport:n}=Le(r)||{};if(!n)return;const i=Tpe(t),o=Spe(t),a=Cpe(r,o),s=n.canvasToWorld(a);return{page:o,client:i,canvas:a,world:s}}function Cpe(t,e){const r=t.getBoundingClientRect();return[e[0]-r.left-window.pageXOffset,e[1]-r.top-window.pageYOffset]}function Spe(t){return[t.pageX,t.pageY]}function Tpe(t){return[t.clientX,t.clientY]}function RF(t){const e=t.currentTarget,{viewportId:r,renderingEngineId:n}=Le(e),i=Wd(t,e),o={page:[0,0],client:[0,0],canvas:[0,0],world:[0,0,0]},a={event:t,eventName:U.MOUSE_DOUBLE_CLICK,viewportId:r,renderingEngineId:n,camera:{},element:e,startPoints:i,lastPoints:i,currentPoints:i,deltaPoints:o};!it(e,U.MOUSE_DOUBLE_CLICK,a)&&(t.stopImmediatePropagation(),t.preventDefault())}const tI=U.MOUSE_MOVE;function xm(t){const e=t.currentTarget,r=Le(e);if(!r)return;const{renderingEngineId:n,viewportId:i}=r,o=Wd(t);!it(e,tI,{renderingEngineId:n,viewportId:i,camera:{},element:e,currentPoints:o,eventName:tI,event:t})&&(t.stopImmediatePropagation(),t.preventDefault())}const{MOUSE_DOWN:nI,MOUSE_DOWN_ACTIVATE:_pe,MOUSE_CLICK:Epe,MOUSE_UP:bpe,MOUSE_DRAG:rI}=U,Dpe=400,Ipe=150,Ope=3,Mpe={mouseButton:void 0,element:null,renderingEngineId:void 0,viewportId:void 0,isClickEvent:!0,clickDelay:200,preventClickTimeout:null,startPoints:{page:[0,0],client:[0,0],canvas:[0,0],world:[0,0,0]},lastPoints:{page:[0,0],client:[0,0],canvas:[0,0],world:[0,0,0]}};let $t={mouseButton:void 0,renderingEngineId:void 0,viewportId:void 0,isClickEvent:!0,clickDelay:200,element:null,preventClickTimeout:null,startPoints:{page:[0,0],client:[0,0],canvas:[0,0],world:[0,0,0]},lastPoints:{page:[0,0],client:[0,0],canvas:[0,0],world:[0,0,0]}};const Ci={doubleClickTimeout:null,mouseDownEvent:null,mouseUpEvent:null,ignoreDoubleClick:!1};function LF(t){if(Ci.doubleClickTimeout){if(t.buttons===Ci.mouseDownEvent.buttons)return;Ci.mouseDownEvent=t,t5();return}Ci.doubleClickTimeout=setTimeout(t5,t.buttons===1?Dpe:Ipe),Ci.mouseDownEvent=t,Ci.ignoreDoubleClick=!1,$t.element=t.currentTarget,$t.mouseButton=t.buttons;const e=Le($t.element),{renderingEngineId:r,viewportId:n}=e;$t.renderingEngineId=r,$t.viewportId=n,$t.preventClickTimeout=setTimeout(Rpe,$t.clickDelay),$t.element.removeEventListener("mousemove",xm);const i=Wd(t,$t.element);$t.startPoints=Ju(i),$t.lastPoints=Ju(i),document.addEventListener("mouseup",PE),document.addEventListener("mousemove",AF)}function Ppe(t){const e=Pw($t.startPoints,$t.startPoints),r={event:t,eventName:nI,element:$t.element,mouseButton:$t.mouseButton,renderingEngineId:$t.renderingEngineId,viewportId:$t.viewportId,camera:{},startPoints:$t.startPoints,lastPoints:$t.startPoints,currentPoints:$t.startPoints,deltaPoints:e};$t.lastPoints=Ju(r.lastPoints),it(r.element,nI,r)&&it(r.element,_pe,r)}function AF(t){const e=Le($t.element);if(!(e!=null&&e.viewport))return;const r=Wd(t,$t.element),n=FF($t.element,$t.lastPoints),i=Pw(r,n);if(Ci.doubleClickTimeout)if(kF(i.canvas))t5();else return;const o={event:t,eventName:rI,mouseButton:$t.mouseButton,renderingEngineId:$t.renderingEngineId,viewportId:$t.viewportId,camera:{},element:$t.element,startPoints:Ju($t.startPoints),lastPoints:Ju(n),currentPoints:r,deltaPoints:i};!it($t.element,rI,o)&&(t.stopImmediatePropagation(),t.preventDefault()),$t.lastPoints=Ju(r)}function PE(t){if(clearTimeout($t.preventClickTimeout),Ci.doubleClickTimeout)Ci.mouseUpEvent?BS():(Ci.mouseUpEvent=t,$t.element.addEventListener("mousemove",NF));else{const e=$t.isClickEvent?Epe:bpe,r=Wd(t,$t.element),n=Pw(r,$t.lastPoints),i={event:t,eventName:e,mouseButton:$t.mouseButton,element:$t.element,renderingEngineId:$t.renderingEngineId,viewportId:$t.viewportId,camera:{},startPoints:Ju($t.startPoints),lastPoints:Ju($t.lastPoints),currentPoints:r,deltaPoints:n};it(i.element,e,i),BS()}document.removeEventListener("mousemove",AF)}function NF(t){const e=Wd(t,$t.element),r=FF($t.element,$t.lastPoints),n=Pw(e,r);kF(n.canvas)&&(t5(),xm(t))}function kF(t){return Math.abs(t[0])+Math.abs(t[1])>Ope}function Rpe(){$t.isClickEvent=!1}function t5(){Ci.ignoreDoubleClick=!0;const t=Ci.mouseDownEvent,e=Ci.mouseUpEvent;VF(),Ppe(t),e&&PE(e)}function VF(){Ci.doubleClickTimeout&&(clearTimeout(Ci.doubleClickTimeout),Ci.doubleClickTimeout=null),Ci.mouseDownEvent=null,Ci.mouseUpEvent=null}function BS(){var t,e;document.removeEventListener("mouseup",PE),(t=$t.element)==null||t.removeEventListener("mousemove",NF),(e=$t.element)==null||e.addEventListener("mousemove",xm),VF(),$t=JSON.parse(JSON.stringify(Mpe))}function Ju(t){return JSON.parse(JSON.stringify(t))}function FF(t,e){const{viewport:r}=Le(t)||{};if(!r)return e;const n=r.canvasToWorld(e.canvas);return{page:e.page,client:e.client,canvas:e.canvas,world:n}}function Pw(t,e){return!t||!e?{page:[0,0],client:[0,0],canvas:[0,0],world:[0,0,0]}:{page:_C(t.page,e.page),client:_C(t.client,e.client),canvas:_C(t.canvas,e.canvas),world:Lpe(t.world,e.world)}}function _C(t,e){return[t[0]-e[0],t[1]-e[1]]}function Lpe(t,e){return[t[0]-e[0],t[1]-e[1],t[2]-e[2]]}function Ape(){return $t.mouseButton}function UF(t){Ci.ignoreDoubleClick?(Ci.ignoreDoubleClick=!1,t.stopImmediatePropagation(),t.preventDefault()):BS()}function BF(t){t.removeEventListener("dblclick",RF),t.removeEventListener("mousedown",LF),t.removeEventListener("mousemove",xm),t.removeEventListener("dblclick",UF,{capture:!0})}function Npe(t){BF(t),t.addEventListener("dblclick",RF),t.addEventListener("mousedown",LF),t.addEventListener("mousemove",xm),t.addEventListener("dblclick",UF,{capture:!0})}const GF={enable:Npe,disable:BF},kpe=2e3,Ih={mouse:0,touch:1};let iI,oI;function WF(t,e){const r=Date.now();if(t!==iI){if(r-oI<=kpe)return e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),!1;iI=t}oI=r}const zF=WF.bind(null,Ih.mouse),$F=WF.bind(null,Ih.touch);function aI(t,e,r){const n=r?zF:$F;e.forEach(function(i){t.addEventListener(i,n,{passive:!1})})}function sI(t,e,r){const n=r?zF:$F;e.forEach(function(i){t.removeEventListener(i,n)})}const jF=["mousedown","mouseup","mousemove"],HF=["touchstart","touchend"];function KF(t){sI(t,jF,Ih.mouse),sI(t,HF,Ih.touch)}function Vpe(t){KF(t),aI(t,jF,Ih.mouse),aI(t,HF,Ih.touch)}const qF={enable:Vpe,disable:KF};function Rw(t,e){const r=e||t.currentTarget,n=t.type==="touchend"?t.changedTouches:t.touches;return Object.keys(n).map(i=>{const o=Bpe(n[i]),a=Upe(n[i]),s=Fpe(r,a),{viewport:c}=Le(r),l=c.canvasToWorld(s);return{page:a,client:o,canvas:s,world:l,touch:{identifier:i,radiusX:n[i].radiusX,radiusY:n[i].radiusY,force:n[i].force,rotationAngle:n[i].rotationAngle}}})}function Fpe(t,e){const r=t.getBoundingClientRect();return[e[0]-r.left-window.pageXOffset,e[1]-r.top-window.pageYOffset]}function Upe(t){return[t.pageX,t.pageY]}function Bpe(t){return[t.clientX,t.clientY]}function n5(t,e){const r=O1(t),n=O1(e);return{page:EC(r.page,n.page),client:EC(r.client,n.client),canvas:EC(r.canvas,n.canvas),world:Wpe(r.world,n.world)}}function RE(t,e){const r=O1(t),n=O1(e);return{page:rh(r.page,n.page),client:rh(r.client,n.client),canvas:rh(r.canvas,n.canvas),world:XF(r.world,n.world)}}function Gpe(t,e){}function r5(t,e){const r=cI(t),n=cI(e);return{page:r.page-n.page,client:r.client-n.client,canvas:r.canvas-n.canvas,world:r.world-n.world}}function Zc(t){return JSON.parse(JSON.stringify(t))}function GS(t){return JSON.parse(JSON.stringify(t))}function O1(t){return t.reduce((e,r)=>({page:[e.page[0]+r.page[0]/t.length,e.page[1]+r.page[1]/t.length],client:[e.client[0]+r.client[0]/t.length,e.client[1]+r.client[1]/t.length],canvas:[e.canvas[0]+r.canvas[0]/t.length,e.canvas[1]+r.canvas[1]/t.length],world:[e.world[0]+r.world[0]/t.length,e.world[1]+r.world[1]/t.length,e.world[2]+r.world[2]/t.length]}),{page:[0,0],client:[0,0],canvas:[0,0],world:[0,0,0]})}function cc(t){return t.reduce((e,r)=>({page:[e.page[0]+r.page[0]/t.length,e.page[1]+r.page[1]/t.length],client:[e.client[0]+r.client[0]/t.length,e.client[1]+r.client[1]/t.length],canvas:[e.canvas[0]+r.canvas[0]/t.length,e.canvas[1]+r.canvas[1]/t.length],world:[e.world[0]+r.world[0]/t.length,e.world[1]+r.world[1]/t.length,e.world[2]+r.world[2]/t.length],touch:{identifier:null,radiusX:e.touch.radiusX+r.touch.radiusX/t.length,radiusY:e.touch.radiusY+r.touch.radiusY/t.length,force:e.touch.force+r.touch.force/t.length,rotationAngle:e.touch.rotationAngle+r.touch.rotationAngle/t.length}}),{page:[0,0],client:[0,0],canvas:[0,0],world:[0,0,0],touch:{identifier:null,radiusX:0,radiusY:0,force:0,rotationAngle:0}})}function EC(t,e){return[t[0]-e[0],t[1]-e[1]]}function Wpe(t,e){return[t[0]-e[0],t[1]-e[1],t[2]-e[2]]}function cI(t){const e=[];for(let r=0;r<t.length;r++)for(let n=0;n<t.length;n++)r<n&&e.push({page:rh(t[r].page,t[n].page),client:rh(t[r].client,t[n].client),canvas:rh(t[r].canvas,t[n].canvas),world:XF(t[r].world,t[n].world)});return e.reduce((r,n)=>({page:r.page+n.page/e.length,client:r.client+n.client/e.length,canvas:r.canvas+n.canvas/e.length,world:r.world+n.world/e.length}),{page:0,client:0,canvas:0,world:0})}function rh(t,e){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2))}function XF(t,e){return Math.sqrt(Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2))}const zpe=Object.freeze(Object.defineProperty({__proto__:null,copyPoints:GS,copyPointsList:Zc,getDeltaDistance:RE,getDeltaDistanceBetweenIPoints:r5,getDeltaPoints:n5,getDeltaRotation:Gpe,getMeanPoints:O1,getMeanTouchPoints:cc},Symbol.toStringTag,{value:"Module"}));cr.getRuntimeSettings();const{TOUCH_START:lI,TOUCH_START_ACTIVATE:$pe,TOUCH_PRESS:uI,TOUCH_DRAG:fI,TOUCH_END:dI,TOUCH_TAP:hI,TOUCH_SWIPE:bC}=U,M1={page:[0,0],client:[0,0],canvas:[0,0],world:[0,0,0]},i5={page:0,client:0,canvas:0,world:0},YF={renderingEngineId:void 0,viewportId:void 0,element:null,startPointsList:[{...M1,touch:null}],lastPointsList:[{...M1,touch:null}],isTouchStart:!1,startTime:null,pressTimeout:null,pressDelay:700,pressMaxDistance:5,accumulatedDistance:i5,swipeDistanceThreshold:48,swiped:!1,swipeToleranceMs:300},JF={renderingEngineId:void 0,viewportId:void 0,element:null,startPointsList:[{...M1,touch:null}],taps:0,tapTimeout:null,tapMaxDistance:24,tapToleranceMs:300};let Et=JSON.parse(JSON.stringify(YF)),ei=JSON.parse(JSON.stringify(JF));function cf(t,e,r){return it(t,e,r)}function ZF(t){Et.element=t.currentTarget;const e=Le(Et.element),{renderingEngineId:r,viewportId:n}=e;Et.renderingEngineId=r,Et.viewportId=n,!Et.isTouchStart&&(clearTimeout(Et.pressTimeout),Et.pressTimeout=setTimeout(()=>jpe(t),Et.pressDelay),Hpe(t),document.addEventListener("touchmove",QF),document.addEventListener("touchend",eU))}function jpe(t){if(Et.accumulatedDistance.canvas>Et.pressMaxDistance)return;const r={event:t,eventName:uI,renderingEngineId:Et.renderingEngineId,viewportId:Et.viewportId,camera:{},element:Et.element,startPointsList:Zc(Et.startPointsList),lastPointsList:Zc(Et.lastPointsList),startPoints:GS(cc(Et.startPointsList)),lastPoints:GS(cc(Et.lastPointsList))};cf(r.element,uI,r)}function Hpe(t){Et.isTouchStart=!0,Et.startTime=new Date;const e=Rw(t,Et.element),r=cc(e),n=M1,i=i5,o={event:t,eventName:lI,element:Et.element,renderingEngineId:Et.renderingEngineId,viewportId:Et.viewportId,camera:{},startPointsList:e,lastPointsList:e,currentPointsList:e,startPoints:r,lastPoints:r,currentPoints:r,deltaPoints:n,deltaDistance:i};Et.startPointsList=Zc(o.startPointsList),Et.lastPointsList=Zc(o.lastPointsList),cf(o.element,lI,o)&&cf(o.element,$pe,o)}function QF(t){const e=Rw(t,Et.element),r=tU(Et.element,Et.lastPointsList),n=e.length===r.length?n5(e,r):M1,i=e.length===r.length?r5(e,r):i5,o=e.length===r.length?RE(e,Et.lastPointsList):i5;Et.accumulatedDistance={page:Et.accumulatedDistance.page+o.page,client:Et.accumulatedDistance.client+o.client,canvas:Et.accumulatedDistance.canvas+o.canvas,world:Et.accumulatedDistance.world+o.world};const a={event:t,eventName:fI,renderingEngineId:Et.renderingEngineId,viewportId:Et.viewportId,camera:{},element:Et.element,startPoints:cc(Et.startPointsList),lastPoints:cc(r),currentPoints:cc(e),startPointsList:Zc(Et.startPointsList),lastPointsList:Zc(r),currentPointsList:e,deltaPoints:n,deltaDistance:i};cf(Et.element,fI,a),qpe(t,n),Et.lastPointsList=Zc(e)}function eU(t){clearTimeout(Et.pressTimeout);const e=Rw(t,Et.element),r=tU(Et.element,Et.lastPointsList),n=e.length===r.length?n5(e,r):n5(e,e),i=e.length===r.length?r5(e,r):r5(e,e),o={event:t,eventName:dI,element:Et.element,renderingEngineId:Et.renderingEngineId,viewportId:Et.viewportId,camera:{},startPointsList:Zc(Et.startPointsList),lastPointsList:Zc(r),currentPointsList:e,startPoints:cc(Et.startPointsList),lastPoints:cc(r),currentPoints:cc(e),deltaPoints:n,deltaDistance:i};cf(o.element,dI,o),Kpe(t),Et=JSON.parse(JSON.stringify(YF)),document.removeEventListener("touchmove",QF),document.removeEventListener("touchend",eU)}function Kpe(t){const e=new Date().getTime(),r=Et.startTime.getTime();if(e-r>ei.tapToleranceMs||(ei.taps===0&&(ei.element=Et.element,ei.renderingEngineId=Et.renderingEngineId,ei.viewportId=Et.viewportId,ei.startPointsList=Et.startPointsList),ei.taps>0&&!(ei.element==Et.element&&ei.renderingEngineId==Et.renderingEngineId&&ei.viewportId==Et.viewportId)))return;const n=Rw(t,ei.element);RE(n,ei.startPointsList).canvas>ei.tapMaxDistance||(clearTimeout(ei.tapTimeout),ei.taps+=1,ei.tapTimeout=setTimeout(()=>{const o={event:t,eventName:hI,element:ei.element,renderingEngineId:ei.renderingEngineId,viewportId:ei.viewportId,camera:{},currentPointsList:n,currentPoints:cc(n),taps:ei.taps};cf(o.element,hI,o),ei=JSON.parse(JSON.stringify(JF))},ei.tapToleranceMs))}function qpe(t,e){const r=new Date().getTime(),n=Et.startTime.getTime();if(Et.swiped||r-n>Et.swipeToleranceMs)return;const[i,o]=e.canvas,a={event:t,eventName:bC,renderingEngineId:Et.renderingEngineId,viewportId:Et.viewportId,camera:{},element:Et.element,swipe:null};Math.abs(i)>Et.swipeDistanceThreshold&&(a.swipe=i>0?od.RIGHT:od.LEFT,cf(a.element,bC,a),Et.swiped=!0),Math.abs(o)>Et.swipeDistanceThreshold&&(a.swipe=o>0?od.DOWN:od.UP,cf(a.element,bC,a),Et.swiped=!0)}function tU(t,e){const{viewport:r}=Le(t);return e.map(n=>{const i=r.canvasToWorld(n.canvas);return{page:n.page,client:n.client,canvas:n.canvas,world:i,touch:n.touch}})}function nU(t){qF.disable(t),t.removeEventListener("touchstart",ZF)}function Xpe(t){nU(t),qF.enable(t),t.addEventListener("touchstart",ZF,{passive:!1})}const rU={enable:Xpe,disable:nU},gI=10,pI=40,mI=800;function Ype(t){let e=0,r=0,n=0,i=0;return"detail"in t&&(r=t.detail),"wheelDelta"in t&&(r=-t.wheelDelta/120),"wheelDeltaY"in t&&(r=-t.wheelDeltaY/120),"wheelDeltaX"in t&&(e=-t.wheelDeltaX/120),n=e*gI,i=r*gI,"deltaY"in t&&(i=t.deltaY),"deltaX"in t&&(n=t.deltaX),(n||i)&&t.deltaMode&&(t.deltaMode===1?(n*=pI,i*=pI):(n*=mI,i*=mI)),n&&!e&&(e=n<1?-1:1),i&&!r&&(r=i<1?-1:1),{spinX:e,spinY:r,pixelX:n,pixelY:i}}function iU(t){const e=t.currentTarget,r=Le(e),{renderingEngineId:n,viewportId:i}=r;if(t.deltaY>-1&&t.deltaY<1)return;t.preventDefault();const{spinX:o,spinY:a,pixelX:s,pixelY:c}=Ype(t),l=a<0?-1:1,f={event:t,eventName:U.MOUSE_WHEEL,renderingEngineId:n,viewportId:i,element:e,camera:{},detail:t,wheel:{spinX:o,spinY:a,pixelX:s,pixelY:c,direction:l},points:Wd(t)};it(e,U.MOUSE_WHEEL,f)}function Jpe(t){oU(t),t.addEventListener("wheel",iU,{passive:!1})}function oU(t){t.removeEventListener("wheel",iU)}const aU={enable:Jpe,disable:oU},Zpe={renderingEngineId:void 0,viewportId:void 0,key:void 0,keyCode:void 0,element:null};let ci={renderingEngineId:void 0,viewportId:void 0,key:void 0,keyCode:void 0,element:null};function Lw(t){ci.element=t.currentTarget;const e=Le(ci.element),{renderingEngineId:r,viewportId:n}=e;ci.renderingEngineId=r,ci.viewportId=n,ci.key=t.key,ci.keyCode=t.keyCode,t.preventDefault();const i={renderingEngineId:ci.renderingEngineId,viewportId:ci.viewportId,element:ci.element,key:ci.key,keyCode:ci.keyCode};it(i.element,U.KEY_DOWN,i),document.addEventListener("keyup",sU),document.addEventListener("visibilitychange",LE),ci.element.removeEventListener("keydown",Lw)}function LE(){document.removeEventListener("visibilitychange",LE),document.visibilityState==="hidden"&&cU()}function sU(t){const e={renderingEngineId:ci.renderingEngineId,viewportId:ci.viewportId,element:ci.element,key:ci.key,keyCode:ci.keyCode};document.removeEventListener("keyup",sU),document.removeEventListener("visibilitychange",LE),ci.element.addEventListener("keydown",Lw),ci=structuredClone(Zpe),it(e.element,U.KEY_UP,e)}function Qpe(){return ci.keyCode}function cU(){ci.keyCode=void 0}function e1e(t){lU(t),t.addEventListener("keydown",Lw)}function lU(t){t.removeEventListener("keydown",Lw)}const Yh={enable:e1e,disable:lU,getModifierKey:Qpe},{EPSILON:n0}=xf;function uU(t,e,r=!1){var f;let n=1/0,i=r?-1/0:0,o=1/0,a=r?-1/0:0,s=1/0,c=r?-1/0:0;const l=((f=t[0])==null?void 0:f.length)===3;for(let u=0;u<t.length;u++){const d=t[u];n=Math.min(d[0],n),i=Math.max(d[0],i),o=Math.min(d[1],o),a=Math.max(d[1],a),l&&(s=Math.min(d[2]??s,s),c=Math.max(d[2]??c,c))}return e?(n=Math.max(r?e[0]+n0:0,n),i=Math.min(r?e[0]-n0:e[0]-1,i),o=Math.max(r?e[1]+n0:0,o),a=Math.min(r?e[1]-n0:e[1]-1,a),l&&e.length===3&&(s=Math.max(r?e[2]+n0:0,s),c=Math.min(r?e[2]-n0:e[2]-1,c))):r||(n=Math.max(0,n),i=Math.min(1/0,i),o=Math.max(0,o),a=Math.min(1/0,a),l&&(s=Math.max(0,s),c=Math.min(1/0,c))),l?[[n,i],[o,a],[s,c]]:[[n,i],[o,a],null]}function lf(t,e){return uU(t,e,!1)}function fU(t,e){return uU(t,e,!0)}const t1e=(t,e)=>JSON.stringify(t)===JSON.stringify(e);function AE(t,e,r,n){const i=r[0]/2,o=r[1]/2,a=r[2]/2,s=new Array(8);s[0]=Lr(t,[n[0]-i,n[1]-o,n[2]-a]);const c=[[1,-1,-1],[-1,1,-1],[1,1,-1],[-1,-1,1],[1,-1,1],[-1,1,1],[1,1,1]];for(let l=0;l<7;l++){const[f,u,d]=c[l];s[l+1]=Lr(t,[n[0]+f*i,n[1]+u*o,n[2]+d*a])}return lf(s,e)}function dU(t,e){const{spacing:r}=t,n=t.voxelManager.getScalarDataLength(),i=[];let o=0;for(let a=0;a<e.length;a++){const{imageData:s,spacing:c,dimensions:l,voxelManager:f}=e[a].volume,u=e[a].volume.voxelManager.getScalarDataLength();u===n&&t1e(c,r)&&(o=a);const d=e[a].lower,h=e[a].upper;i.push({imageData:s,lower:d,upper:h,spacing:c,dimensions:l,volumeSize:u,voxelManager:f})}return{volumeInfoList:i,baseVolumeIdx:o}}const NE=new Map,n1e=t=>{const e=NE.get(t);e&&(e.isDirty=!0)},r1e=t=>{const e=NE.get(t);return e&&!e.isDirty?e.indices:null},i1e=(t,e)=>{NE.set(t,{indices:e,isDirty:!1})};function lo(t,e,r){const n={segmentationId:t,modifiedSlicesToUse:e,segmentIndex:r};n1e(t),it(Ze,U.SEGMENTATION_DATA_MODIFIED,n)}function Ka(t){const e={segmentationId:t};it(Ze,U.SEGMENTATION_MODIFIED,e)}function kE(t){const e={segmentationId:t};it(Ze,U.SEGMENTATION_REMOVED,e)}function Wc(t,e,r){const n={segmentationId:e,type:r,viewportId:t};it(Ze,U.SEGMENTATION_REPRESENTATION_MODIFIED,n)}function WS(t,e,r){const n={viewportId:t,segmentationId:e,type:r};it(Ze,U.SEGMENTATION_REPRESENTATION_REMOVED,n)}const o1e=Object.freeze(Object.defineProperty({__proto__:null,triggerSegmentationDataModified:lo,triggerSegmentationModified:Ka,triggerSegmentationRemoved:kE,triggerSegmentationRepresentationModified:Wc,triggerSegmentationRepresentationRemoved:WS},Symbol.toStringTag,{value:"Module"})),a1e={renderOutline:!0,outlineWidthAutoGenerated:3,outlineWidth:1,outlineWidthInactive:1,outlineOpacity:1,outlineOpacityInactive:.85,outlineDash:void 0,outlineDashInactive:void 0,outlineDashAutoGenerated:"5,3",activeSegmentOutlineWidthDelta:0,renderFill:!0,fillAlpha:.5,fillAlphaInactive:.3,fillAlphaAutoGenerated:.3};function s1e(){return a1e}const c1e={renderOutline:!0,renderOutlineInactive:!0,outlineWidth:3,outlineWidthInactive:2,activeSegmentOutlineWidthDelta:0,renderFill:!0,renderFillInactive:!0,fillAlpha:.5,fillAlphaInactive:.4,outlineOpacity:1,outlineOpacityInactive:.85};function l1e(){return c1e}class u1e{constructor(){this.config={global:{},segmentations:{},viewportsStyle:{}}}setStyle(e,r){const{viewportId:n,segmentationId:i,type:o,segmentIndex:a}=e,s=this.getStyle(e);let c;if(!n&&!i?c={...s,...r}:c=this.copyActiveToInactiveIfNotProvided({...s,...r},o),!o)throw new Error("Type is required to set a style");if(n){this.config.viewportsStyle[n]||(this.config.viewportsStyle[n]={renderInactiveSegmentations:!1,representations:{}});const l=this.config.viewportsStyle[n].representations;if(i){l[i]||(l[i]={}),l[i][o]||(l[i][o]={});const f=l[i][o];a!==void 0?(f.perSegment||(f.perSegment={}),f.perSegment[a]=c):f.allSegments=c}else{const f="__allSegmentations__";l[f]||(l[f]={}),l[f][o]||(l[f][o]={}),l[f][o].allSegments=c}}else if(i){this.config.segmentations[i]||(this.config.segmentations[i]={}),this.config.segmentations[i][o]||(this.config.segmentations[i][o]={});const l=this.config.segmentations[i][o];a!==void 0?(l.perSegment||(l.perSegment={}),l.perSegment[a]=c):l.allSegments=c}else this.config.global[o]=c}copyActiveToInactiveIfNotProvided(e,r){const n={...e};if(r===St.Labelmap){const i=n;i.renderOutlineInactive??(i.renderOutlineInactive=i.renderOutline),i.outlineWidthInactive??(i.outlineWidthInactive=i.outlineWidth),i.renderFillInactive??(i.renderFillInactive=i.renderFill),i.fillAlphaInactive??(i.fillAlphaInactive=i.fillAlpha),i.outlineOpacityInactive??(i.outlineOpacityInactive=i.outlineOpacity)}else if(r===St.Contour){const i=n;i.outlineWidthInactive??(i.outlineWidthInactive=i.outlineWidth),i.outlineOpacityInactive??(i.outlineOpacityInactive=i.outlineOpacity),i.outlineDashInactive??(i.outlineDashInactive=i.outlineDash),i.renderOutlineInactive??(i.renderOutlineInactive=i.renderOutline),i.renderFillInactive??(i.renderFillInactive=i.renderFill),i.fillAlphaInactive??(i.fillAlphaInactive=i.fillAlpha)}return n}getStyle(e){var s,c,l,f,u;const{viewportId:r,segmentationId:n,type:i,segmentIndex:o}=e;let a=this.getDefaultStyle(i);if(this.config.global[i]&&(a={...a,...this.config.global[i]}),(s=this.config.segmentations[n])!=null&&s[i]&&(a={...a,...this.config.segmentations[n][i].allSegments},o!==void 0&&((c=this.config.segmentations[n][i].perSegment)!=null&&c[o])&&(a={...a,...this.config.segmentations[n][i].perSegment[o]})),r&&this.config.viewportsStyle[r]){this.config.viewportsStyle[r].renderInactiveSegmentations;const d="__allSegmentations__";(l=this.config.viewportsStyle[r].representations[d])!=null&&l[i]&&(a={...a,...this.config.viewportsStyle[r].representations[d][i].allSegments}),n&&((f=this.config.viewportsStyle[r].representations[n])!=null&&f[i])&&(a={...a,...this.config.viewportsStyle[r].representations[n][i].allSegments},o!==void 0&&((u=this.config.viewportsStyle[r].representations[n][i].perSegment)!=null&&u[o])&&(a={...a,...this.config.viewportsStyle[r].representations[n][i].perSegment[o]}))}return a}getRenderInactiveSegmentations(e){var r;return(r=this.config.viewportsStyle[e])==null?void 0:r.renderInactiveSegmentations}setRenderInactiveSegmentations(e,r){this.config.viewportsStyle[e]||(this.config.viewportsStyle[e]={renderInactiveSegmentations:!1,representations:{}}),this.config.viewportsStyle[e].renderInactiveSegmentations=r}getDefaultStyle(e){switch(e){case St.Labelmap:return l1e();case St.Contour:return s1e();case St.Surface:return{};default:throw new Error(`Unknown representation type: ${e}`)}}clearSegmentationStyle(e){this.config.segmentations[e]&&delete this.config.segmentations[e]}clearAllSegmentationStyles(){this.config.segmentations={}}clearViewportStyle(e){this.config.viewportsStyle[e]&&delete this.config.viewportsStyle[e]}clearAllViewportStyles(){for(const e in this.config.viewportsStyle){const n=this.config.viewportsStyle[e].renderInactiveSegmentations;this.config.viewportsStyle[e]={renderInactiveSegmentations:n,representations:{}}}}resetToGlobalStyle(){this.clearAllSegmentationStyles(),this.clearAllViewportStyles()}hasCustomStyle(e){const{type:r}=e,n=this.getStyle(e),i=this.getDefaultStyle(r);return!PV(n,i)}}const Ua=new u1e;function f1e(t){const e={segmentationId:t};it(Ze,U.SEGMENTATION_ADDED,e)}const vI={colorLUT:[],segmentations:[],viewportSegRepresentations:{}};class d1e{constructor(e){this._stackLabelmapImageIdReferenceMap=new Map,this._labelmapImageIdReferenceMap=new Map,e||(e=gn()),this.state=Object.freeze(ds(vI)),this.uid=e}getState(){return this.state}updateState(e){const r=ds(this.state);e(r),this.state=Object.freeze(r)}getColorLUT(e){return this.state.colorLUT[e]}getNextColorLUTIndex(){return this.state.colorLUT.length}resetState(){this._stackLabelmapImageIdReferenceMap.clear(),this._labelmapImageIdReferenceMap.clear(),this.state=Object.freeze(ds(vI))}getSegmentation(e){return this.state.segmentations.find(r=>r.segmentationId===e)}updateSegmentation(e,r){this.updateState(n=>{const i=n.segmentations.find(o=>o.segmentationId===e);if(!i){console.warn(`Segmentation with id ${e} not found. Update aborted.`);return}Object.assign(i,r)}),Ka(e)}addSegmentation(e){if(this.getSegmentation(e.segmentationId))throw new Error(`Segmentation with id ${e.segmentationId} already exists`);this.updateState(r=>{const n=ds(e);if(n.representationData.Labelmap&&"volumeId"in n.representationData.Labelmap&&!("imageIds"in n.representationData.Labelmap)){const i=this.getLabelmapImageIds(n.representationData);n.representationData.Labelmap.imageIds=i}r.segmentations.push(n)}),f1e(e.segmentationId)}removeSegmentation(e){this.updateState(r=>{const n=r.segmentations.filter(i=>i.segmentationId!==e);r.segmentations.splice(0,r.segmentations.length,...n)}),kE(e)}addSegmentationRepresentation(e,r,n,i){if(!Mn(e))return;if(this.getSegmentationRepresentations(e,{type:n,segmentationId:r}).length>0){console.debug("A segmentation representation of type",n,"already exists in viewport",e,"for segmentation",r);return}this.updateState(s=>{s.viewportSegRepresentations[e]||(s.viewportSegRepresentations[e]=[],Ua.setRenderInactiveSegmentations(e,!0)),n!==St.Labelmap?this.addDefaultSegmentationRepresentation(s,e,r,n,i):this.addLabelmapRepresentation(s,e,r,i)}),Wc(e,r,n)}addDefaultSegmentationRepresentation(e,r,n,i,o){const a=e.segmentations.find(c=>c.segmentationId===n);if(!a)return;const s={};Object.keys(a.segments).forEach(c=>{s[Number(c)]={visible:!0}}),e.viewportSegRepresentations[r].push({segmentationId:n,type:i,active:!0,visible:!0,colorLUTIndex:(o==null?void 0:o.colorLUTIndex)||0,segments:s,config:{...yI(i),...o}}),this._setActiveSegmentation(e,r,n)}addLabelmapRepresentation(e,r,n,i=yI(St.Labelmap)){if(!Mn(r))return;const a=this.getSegmentation(n);if(!a)return;const{representationData:s}=a;if(!s.Labelmap)return this.addDefaultSegmentationRepresentation(e,r,n,St.Labelmap,i);this.processLabelmapRepresentationAddition(r,n),this.addDefaultSegmentationRepresentation(e,r,n,St.Labelmap,i)}async processLabelmapRepresentationAddition(e,r){const n=Mn(e);if(!n)return;const i=this.getSegmentation(r);if(!i)return;const o=n.viewport instanceof fr,{representationData:a}=i,s="volumeId"in a.Labelmap;n.viewport,!o&&!s&&this.updateLabelmapSegmentationImageReferences(e,i.segmentationId)}_updateLabelmapSegmentationReferences(e,r,n,i){const o=r.getCurrentImageId();let a=!1;for(const s of n)r.isReferenceViewable({referencedImageId:s},{asOverlay:!0})&&(a=!0,this._stackLabelmapImageIdReferenceMap.get(e).set(o,s),this._updateLabelmapImageIdReferenceMap({segmentationId:e,referenceImageId:o,labelmapImageId:s}));return i&&i(r,e,n),a?this._stackLabelmapImageIdReferenceMap.get(e).get(o):void 0}updateLabelmapSegmentationImageReferences(e,r){const n=this.getSegmentation(r);if(!n)return;this._stackLabelmapImageIdReferenceMap.has(r)||this._stackLabelmapImageIdReferenceMap.set(r,new Map);const{representationData:i}=n;if(!i.Labelmap)return;const o=this.getLabelmapImageIds(i),s=Mn(e).viewport;return this._updateLabelmapSegmentationReferences(r,s,o,null)}_updateAllLabelmapSegmentationImageReferences(e,r){const n=this.getSegmentation(r);if(!n)return;this._stackLabelmapImageIdReferenceMap.has(r)||this._stackLabelmapImageIdReferenceMap.set(r,new Map);const{representationData:i}=n;if(!i.Labelmap)return;const o=this.getLabelmapImageIds(i),s=Mn(e).viewport;this._updateLabelmapSegmentationReferences(r,s,o,(c,l,f)=>{c.getImageIds().forEach((d,h)=>{for(const g of f)c.isReferenceViewable({referencedImageId:g,sliceIndex:h},{asOverlay:!0,withNavigation:!0})&&(this._stackLabelmapImageIdReferenceMap.get(l).set(d,g),this._updateLabelmapImageIdReferenceMap({segmentationId:l,referenceImageId:d,labelmapImageId:g}))})})}getLabelmapImageIds(e){const r=e.Labelmap;let n;if(r.imageIds)n=r.imageIds;else if(!n&&r.volumeId){const i=r.volumeId;n=$e.getVolume(i).imageIds}return n}getLabelmapImageIdsForImageId(e,r){const n=this._generateMapKey({segmentationId:r,referenceImageId:e});return this._labelmapImageIdReferenceMap.get(n)}getCurrentLabelmapImageIdsForViewport(e,r){const n=Mn(e);if(!n)return;const o=n.viewport.getCurrentImageId();return this.getLabelmapImageIdsForImageId(o,r)}getCurrentLabelmapImageIdForViewport(e,r){const n=Mn(e);if(!n||!this._stackLabelmapImageIdReferenceMap.has(r))return;const o=n.viewport.getCurrentImageId();return this._stackLabelmapImageIdReferenceMap.get(r).get(o)}getStackSegmentationImageIdsForViewport(e,r){if(!this.getSegmentation(r))return[];this._updateAllLabelmapSegmentationImageReferences(e,r);const{viewport:i}=Mn(e),o=i.getImageIds(),a=this._stackLabelmapImageIdReferenceMap.get(r);return o.map(s=>a.get(s))}removeSegmentationRepresentationsInternal(e,r){const n=[];return this.updateState(i=>{if(!i.viewportSegRepresentations[e])return;const o=i.viewportSegRepresentations[e];let a=!1;if(!r||Object.values(r).every(s=>s===void 0))n.push(...o),delete i.viewportSegRepresentations[e];else{const{segmentationId:s,type:c}=r;i.viewportSegRepresentations[e]=o.filter(l=>{const f=s&&c&&l.segmentationId===s&&l.type===c||s&&!c&&l.segmentationId===s||!s&&c&&l.type===c;return f&&(n.push(l),l.active&&(a=!0)),!f}),i.viewportSegRepresentations[e].length===0?delete i.viewportSegRepresentations[e]:a&&(i.viewportSegRepresentations[e][0].active=!0)}}),n}removeSegmentationRepresentations(e,r){const n=this.removeSegmentationRepresentationsInternal(e,r);n.forEach(o=>{WS(e,o.segmentationId,o.type)});const i=this.getSegmentationRepresentations(e);return i.length>0&&i[0].active&&Wc(e,i[0].segmentationId,i[0].type),n}removeSegmentationRepresentation(e,r,n){const i=this.removeSegmentationRepresentationsInternal(e,r);return n||i.forEach(({segmentationId:o,type:a})=>{WS(e,o,a)}),i}_updateLabelmapImageIdReferenceMap({segmentationId:e,referenceImageId:r,labelmapImageId:n}){const i=this._generateMapKey({segmentationId:e,referenceImageId:r});if(!this._labelmapImageIdReferenceMap.has(i)){this._labelmapImageIdReferenceMap.set(i,[n]);return}const o=this._labelmapImageIdReferenceMap.get(i),a=Array.from(new Set([...o,n]));this._labelmapImageIdReferenceMap.set(i,a)}_setActiveSegmentation(e,r,n){const i=e.viewportSegRepresentations[r];i&&i.forEach(o=>{o.active=o.segmentationId===n})}setActiveSegmentation(e,r){this.updateState(n=>{const i=n.viewportSegRepresentations[e];i&&i.forEach(o=>{o.active=o.segmentationId===r})}),Wc(e,r)}getActiveSegmentation(e){if(!this.state.viewportSegRepresentations[e])return;const r=this.state.viewportSegRepresentations[e].find(n=>n.active);if(r)return this.getSegmentation(r.segmentationId)}getSegmentationRepresentations(e,r={}){const n=this.state.viewportSegRepresentations[e];return n?!r.type&&!r.segmentationId?n:n.filter(i=>{const o=r.type?i.type===r.type:!0,a=r.segmentationId?i.segmentationId===r.segmentationId:!0;return o&&a}):[]}getSegmentationRepresentation(e,r){return this.getSegmentationRepresentations(e,r)[0]}getSegmentationRepresentationVisibility(e,r){const n=this.getSegmentationRepresentation(e,r);return n==null?void 0:n.visible}setSegmentationRepresentationVisibility(e,r,n){this.updateState(i=>{const o=this.getSegmentationRepresentations(e,r);o&&o.forEach(a=>{a.visible=n,Object.entries(a.segments).forEach(([s,c])=>{c.visible=n})})}),Wc(e,r.segmentationId,r.type)}addColorLUT(e,r){this.updateState(n=>{n.colorLUT[r]&&console.warn("Color LUT table already exists, overwriting"),n.colorLUT[r]=ds(e)})}removeColorLUT(e){this.updateState(r=>{delete r.colorLUT[e]})}_getStackIdForImageIds(e){return e.map(r=>r.slice(-Math.round(r.length*.15))).join("_")}getAllViewportSegmentationRepresentations(){return Object.entries(this.state.viewportSegRepresentations).map(([e,r])=>({viewportId:e,representations:r}))}getSegmentationRepresentationsBySegmentationId(e){const r=[];return Object.entries(this.state.viewportSegRepresentations).forEach(([n,i])=>{const o=i.filter(a=>a.segmentationId===e);o.length>0&&r.push({viewportId:n,representations:o})}),r}_generateMapKey({segmentationId:e,referenceImageId:r}){return`${e}-${r}`}}async function hU({imageIds:t,options:e}){const r=t,n=(e==null?void 0:e.volumeId)||gn();return await Z4(n,r),{volumeId:n}}async function h1e({segmentationId:t,options:e}){const r=$n.getSegmentation(t),n=r.representationData.Labelmap,{volumeId:i}=await hU({imageIds:n.imageIds,options:e});r.representationData.Labelmap.volumeId=i}function yI(t){const e=eu.newInstance(),r=Ed.newInstance();return r.addPoint(0,0),t===St.Labelmap?{cfun:e,ofun:r}:{}}const $n=new d1e("DEFAULT");function pa(t,e={}){return $n.getSegmentationRepresentations(t,e)}function VE(t,e){const r=$n;if(!e.segmentationId||!e.type)throw new Error("getSegmentationRepresentation: No segmentationId or type provided, you need to provide at least one of them");const n=r.getSegmentationRepresentations(t,e);return n==null?void 0:n[0]}function gU(t){return $n.getSegmentationRepresentationsBySegmentationId(t)}function g1e(t,e){const r=Le(t),{viewport:n}=r,o=n.getActors().filter(a=>a.representationUID&&typeof a.representationUID=="string"&&a.representationUID.startsWith(e));n.removeActors(o.map(a=>a.uid))}function pU(t,e,r){const n=Mn(t);if(!n)return;const{renderingEngine:i,viewport:o}=n;if(!i||!o)return;const s=o.getActors().filter(r);return s.length>0?s[0]:void 0}function p1e(t,e){const r=Mn(t);if(!r)return;const{renderingEngine:n,viewport:i}=r;if(!n||!i)return;const a=i.getActors().filter(e);return a.length>0?a:void 0}function m1e(t,e){const r=Aw(t,e);return r==null?void 0:r.uid}function Tp(t,e){return p1e(t,r=>{var n;return(n=r.representationUID)==null?void 0:n.startsWith(`${e}-${St.Labelmap}`)})}function Aw(t,e){return pU(t,e,r=>{var n;return(n=r.representationUID)==null?void 0:n.startsWith(`${e}-${St.Labelmap}`)})}function v1e(t,e,r){return pU(t,e,n=>n.representationUID===mU(e,r))}function mU(t,e){return`${t}-${St.Surface}-${e}`}function y1e(t,e,r){const n=Le(t),{viewport:i}=n,o=v1e(i.id,r,e.segmentIndex),a=o==null?void 0:o.actor,s=e.visible;if(a){if(a.setVisibility(s),!s)return;const y=a.getMapper(),m=y.getInputData(),w=e.points,x=e.polys,C=m.getPoints().getData(),S=m.getPolys().getData();if(w.length===C.length&&x.length===S.length)return;const T=Er.newInstance();T.getPoints().setData(w,3);const _=_d.newInstance({values:Float32Array.from(x)});T.setPolys(_),y.setInputData(T),y.modified(),i.getRenderer().resetCameraClippingRange();return}const c=e.points,l=e.polys,f=e.color,u=Er.newInstance();u.getPoints().setData(c,3);const d=_d.newInstance({values:Float32Array.from(l)});u.setPolys(d);const h=la.newInstance({});let g;h.setInputData(u);const p=uc.newInstance();p.setMapper(h),p.getProperty().setColor(f[0]/255,f[1]/255,f[2]/255),p.getProperty().setLineWidth(2);const v=mU(r,e.segmentIndex);i.addActor({uid:gn(),actor:p,clippingFilter:g,representationUID:v}),i.resetCamera(),i.getRenderer().resetCameraClippingRange(),i.render()}function _n(t){return $n.getSegmentation(t)}function Cm(t){return $n.getColorLUT(t)}let o5={};function w1e(){return o5}function x1e(t){o5=t}let wI=!1;function Hl(){var e;if(!((e=o5.addons)!=null&&e.polySeg))return console.warn("PolySeg add-on not configured. This will prevent automatic conversion between segmentation representations (labelmap, contour, surface). To enable these features, install @cornerstonejs/polymorphic-segmentation and register it during initialization: cornerstoneTools.init({ addons: { polySeg } })."),null;const t=o5.addons.polySeg;return wI||(t.init(),wI=!0),t}function FE({segmentationId:t,type:e,data:r}){const n=_n(t);if(!n)throw new Error(`Segmentation ${t} not found`);switch(n.representationData[e]&&console.warn(`Representation data of type ${e} already exists for segmentation ${t}, overwriting it.`),e){case St.Labelmap:r&&(n.representationData[e]=r);break;case St.Contour:r&&(n.representationData[e]=r);break;case St.Surface:r&&(n.representationData[e]=r);break;default:throw new Error(`Invalid representation type ${e}`)}}function UE(t){const e=typeof t;return t!==null&&(e==="object"||e==="function")}function Jh(t,e,r){let n,i,o,a,s,c,l=0,f=!1,u=!1,d=!0;const h=!e&&e!==0&&typeof window.requestAnimationFrame=="function";if(typeof t!="function")throw new TypeError("Expected a function");e=Number(e)||0,UE(r)&&(f=!!r.leading,u="maxWait"in r,o=u?Math.max(Number(r.maxWait)||0,e):o,d="trailing"in r?!!r.trailing:d);function g(b){const D=n,I=i;return n=i=void 0,l=b,a=t.apply(I,D),a}function p(b,D){return h?window.requestAnimationFrame(b):setTimeout(b,D)}function v(b){if(h)return window.cancelAnimationFrame(b);clearTimeout(b)}function y(b){return l=b,s=p(x,e),f?g(b):a}function m(b){const D=b-c,I=b-l,P=e-D;return u?Math.min(P,o-I):P}function w(b){const D=b-c,I=b-l;return c===void 0||D>=e||D<0||u&&I>=o}function x(){const b=Date.now();if(w(b))return C(b);s=p(x,m(b))}function C(b){return s=void 0,d&&n?g(b):(n=i=void 0,a)}function S(){s!==void 0&&v(s),l=0,n=c=i=s=void 0}function T(){return s===void 0?a:C(Date.now())}function _(){return s!==void 0}function E(...b){const D=Date.now(),I=w(D);if(n=b,i=this,c=D,I){if(s===void 0)return y(c);if(u)return s=p(x,e),g(c)}return s===void 0&&(s=p(x,e)),a}return E.cancel=S,E.flush=T,E.pending=_,E}const Nv=new Map;async function BE(t,e,r,n,i){const o=await r();FE({segmentationId:t,type:e,data:o}),i==null||i(),Nv.has(t)||Nv.set(t,[]);const a=Nv.get(t);return a.includes(e)||a.push(e),C1e(n),Ka(t),o}function C1e(t){const e=r=>{S1e(r,t)};t._debouncedUpdateFunction=e,Ze.removeEventListener(U.SEGMENTATION_DATA_MODIFIED,t._debouncedUpdateFunction),Ze.addEventListener(U.SEGMENTATION_DATA_MODIFIED,t._debouncedUpdateFunction)}const S1e=Jh((t,e)=>{const r=t.detail.segmentationId,n=Nv.get(r);!n||!n.length||(e(r),n.length&&Ka(r))},300);function GE(t,e){const r=VE(t,e);return r?Object.entries(r.segments).reduce((i,[o,a])=>(a.visible||i.add(Number(o)),i),new Set):new Set}function T1e(t,e,r=!1){const n=Mn(t);if(!n)return;const{viewport:i}=n;g1e(i.element,e),r&&i.render()}async function _1e(t,e){var l;const{segmentationId:r,type:n}=e,i=_n(r);if(!i)return;let o=i.representationData[St.Surface];if(!o&&((l=Hl())!=null&&l.canComputeRequestedRepresentation(r,St.Surface))){const f=Hl();if(o=await BE(r,St.Surface,()=>f.computeSurfaceData(r,{viewport:t}),()=>f.updateSurfaceData(r,{viewport:t})),!o)throw new Error(`No Surface data found for segmentationId ${r} even we tried to compute it`)}else!o&&!Hl()&&console.debug(`No surface data found for segmentationId ${r} and PolySeg add-on is not configured. Unable to convert from other representations to surface. Please register PolySeg using cornerstoneTools.init({ addons: { polySeg } }) to enable automatic conversion.`);if(!o){console.warn(`No Surface data found for segmentationId ${r}. Skipping render.`);return}const{geometryIds:a}=o;a!=null&&a.size||console.warn(`No Surfaces found for segmentationId ${r}. Skipping render.`);const{colorLUTIndex:s}=e,c=Cm(s);a.forEach(f=>{const u=$e.getGeometry(f);if(!(u!=null&&u.data)){console.warn(`No Surfaces found for geometryId ${f}. Skipping render.`);return}const{segmentIndex:d}=u.data,g=GE(t.id,{segmentationId:r,type:n}).has(d),p=u.data,v=c[d];p.color=v.slice(0,3),p.visible=!g,y1e(t.element,p,r)}),t.render()}const vU={render:_1e,removeRepresentation:T1e};function E1e(t,e,r,n){const i=t.getViewReference(),{viewPlaneNormal:o,FrameOfReferenceUID:a}=i,s={annotationUID:(n==null?void 0:n.annotationUID)||gn(),data:{handles:{points:r}},highlighted:!1,autoGenerated:!1,invalidated:!1,isLocked:!1,isVisible:!0,metadata:{toolName:e,viewPlaneNormal:o,FrameOfReferenceUID:a,referencedImageId:b1e(t,r[0],o),...n}};return qt(s,t.element),s}function b1e(t,e,r){let n;if(t instanceof Jn)n=WE(t,e,r);else if(t instanceof fr){const i=D1e(t),o=dl(i),a=$e.getVolume(o);n=Ql(a,e,r)}else throw new Error("getReferencedImageId: viewport must be a StackViewport or BaseVolumeViewport");return n}function D1e(t){var r;const e=(r=t.getViewReferenceId)==null?void 0:r.call(t);if(e)return e;if(t instanceof fr)return`volumeId:${I1e(t)}`;throw new Error("getTargetId: viewport must have a getTargetId method")}function I1e(t){var r;const e=t.getActors();if(e)return(r=e.find(n=>n.actor.getClassName()==="vtkVolume"))==null?void 0:r.uid}function WE(t,e,r){const n=t.getImageIds();if(!n||!n.length)return;const i=n.map(o=>{const{imagePositionPatient:a}=ct("imagePlaneModule",o),s=O1e(e,a,r);return{imageId:o,distance:s}});return i.sort((o,a)=>o.distance-a.distance),i[0].imageId}function O1e(t,e,r){const n=Ke();hn(n,t,e);const i=xt(n,r);return Math.abs(i)}function yU(t,e){const{segmentation:r}=t.data,{segmentation:n}=e.data;return r.segmentationId===n.segmentationId&&r.segmentIndex===n.segmentIndex}class wU{constructor(e){this.getGroupKey=r=>{if(typeof r=="string")return r;const i=Le(r);if(!i)throw new Error("Element not enabled, you must have an enabled element if you are not providing a FrameOfReferenceUID");return i.FrameOfReferenceUID},this._imageVolumeModifiedHandler=r=>{const n=r.detail,{FrameOfReferenceUID:i}=n,a=this.annotations[i];a&&Object.keys(a).forEach(s=>{a[s].forEach(l=>{l.invalidated!==void 0&&(l.invalidated=!0)})})},this.getFramesOfReference=()=>Object.keys(this.annotations),this.getAnnotations=(r,n)=>{const i=this.annotations;return i[r]?n?i[r][n]?i[r][n]:[]:i[r]:[]},this.getAnnotation=r=>{const n=this.annotations;for(const i in n){const o=n[i];for(const a in o){const s=o[a];for(const c of s)if(r===c.annotationUID)return c}}},this.getNumberOfAnnotations=(r,n)=>{const i=this.getAnnotations(r,n);if(!i.length)return 0;if(n)return i.length;let o=0;for(const a in i)o+=i[a].length;return o},this.addAnnotation=(r,n)=>{const{metadata:i}=r,{FrameOfReferenceUID:o,toolName:a}=i;n=n||o;const s=this.annotations;let c=s[n];c||(s[n]={},c=s[n]);let l=c[a];l||(c[a]=[],l=c[a]),this.preprocessingFn&&(r=this.preprocessingFn(r)),l.push(r)},this.removeAnnotation=r=>{const{annotations:n}=this;for(const i in n){const o=n[i];for(const a in o){const s=o[a],c=s.findIndex(l=>l.annotationUID===r);c!==-1&&(s.splice(c,1),s.length===0&&delete o[a])}Object.keys(o).length===0&&delete n[i]}},this.removeAnnotations=(r,n)=>{const i=this.annotations,o=[];if(!i[r])return o;if(n){const a=i[r][n];for(const s of a)this.removeAnnotation(s.annotationUID),o.push(s)}else for(const a in i[r]){const s=i[r][a];for(const c of s)this.removeAnnotation(c.annotationUID),o.push(c)}return o},this.saveAnnotations=(r,n)=>{const i=this.annotations;if(r&&n){const o=i[r];if(!o)return;const a=o[n];return structuredClone(a)}else if(r){const o=i[r];return structuredClone(o)}return structuredClone(i)},this.restoreAnnotations=(r,n,i)=>{const o=this.annotations;if(n&&i){let a=o[n];a||(o[n]={},a=o[n]),a[i]=r}else n?o[n]=r:this.annotations=structuredClone(r)},this.getAllAnnotations=()=>Object.values(this.annotations).map(r=>Object.values(r)).flat(2),this.getNumberOfAllAnnotations=()=>{let r=0;const n=this.annotations;for(const i in n){const o=n[i];for(const a in o){const s=o[a];r+=s.length}}return r},this.removeAllAnnotations=()=>{const r=[];for(const n of this.getAllAnnotations())this.removeAnnotation(n.annotationUID),r.push(n);return r},e||(e=gn()),this.annotations={},this.uid=e,Ze.addEventListener(et.IMAGE_VOLUME_MODIFIED,this._imageVolumeModifiedHandler)}setPreprocessingFn(e){this.preprocessingFn=e}}const M1e=new wU("DEFAULT"),Zu=new Set;function xU(t,e=!0){const r=SU();t&&(e?A1e(t,Zu,r):TU(t,Zu,r)),_U(r,Zu)}function P1e(){const t=SU();N1e(Zu,t),_U(t,Zu)}function R1e(){return Array.from(Zu)}function Yr(t){return Zu.has(t)}function L1e(){return Zu.size}function CU(t){const e=Yr(t);return xU(t,e),e}function SU(){return Object.freeze({added:[],removed:[],locked:[]})}function A1e(t,e,r){if(!e.has(t)){e.add(t),r.added.push(t);const n=kr(t);n&&(n.isLocked=!0)}}function TU(t,e,r){if(e.delete(t)){r.removed.push(t);const n=kr(t);n&&(n.isLocked=!1)}}function N1e(t,e){t.forEach(r=>{TU(r,t,e)})}function _U(t,e){(t.added.length>0||t.removed.length>0)&&(e.forEach(r=>void t.locked.push(r)),it(Ze,U.ANNOTATION_LOCK_CHANGE,t))}const k1e=Object.freeze(Object.defineProperty({__proto__:null,checkAndSetAnnotationLocked:CU,getAnnotationsLocked:R1e,getAnnotationsLockedCount:L1e,isAnnotationLocked:Yr,setAnnotationLocked:xU,unlockAllAnnotations:P1e},Symbol.toStringTag,{value:"Module"})),zc=new Set;function qo(t,e=!0,r=!1){e?V1e(t,r):zE(t)}function V1e(t,e=!1){const r=bU();if(!e){DU(zc,r);const n=kr(t);n&&(n.isSelected=!0)}if(t&&!zc.has(t)){zc.add(t),r.added.push(t);const n=kr(t);n&&(n.isSelected=!0)}IU(r,zc)}function zE(t){const e=bU();if(t){if(zc.delete(t)){e.removed.push(t);const r=kr(t);r.isSelected=!1}}else DU(zc,e);IU(e,zc)}function EU(){return Array.from(zc)}function F1e(t){return EU().filter(e=>{var n;const r=kr(e);return((n=r==null?void 0:r.metadata)==null?void 0:n.toolName)===t})}function Sm(t){return zc.has(t)}function U1e(){return zc.size}function bU(){return Object.freeze({added:[],removed:[],selection:[]})}function DU(t,e){t.forEach(r=>{if(t.delete(r)){e.removed.push(r);const n=kr(r);n&&(n.isSelected=!1)}})}function IU(t,e){(t.added.length>0||t.removed.length>0)&&(e.forEach(r=>void t.selection.push(r)),it(Ze,U.ANNOTATION_SELECTION_CHANGE,t))}const B1e=Object.freeze(Object.defineProperty({__proto__:null,deselectAnnotation:zE,getAnnotationsSelected:EU,getAnnotationsSelectedByToolName:F1e,getAnnotationsSelectedCount:U1e,isAnnotationSelected:Sm,setAnnotationSelected:qo},Symbol.toStringTag,{value:"Module"})),G1e=t=>(t.data||(t.data={}),t.data.handles||(t.data.handles={}),t.data.handles.textBox||(t.data.handles.textBox={}),t),W1e=t=>(t.data||(t.data={}),t.data.cachedStats||(t.data.cachedStats={}),t),Id=new Set;function OU(t,e=!0){const r=MU();t&&(e?PU(t,Id,r):$1e(t,Id,r)),RU(r)}function z1e(){const t=MU();Id.forEach(e=>{PU(e,Id,t)}),RU(t)}function Vr(t){if(kr(t))return!Id.has(t)}function MU(){return Object.freeze({lastVisible:[],lastHidden:[],hidden:[]})}function PU(t,e,r){if(e.delete(t)){r.lastVisible.push(t);const n=kr(t);n.isVisible=!0}}function $1e(t,e,r){e.has(t)||(e.add(t),Sm(t)&&zE(t),r.lastHidden.push(t))}function RU(t){(t.lastHidden.length>0||t.lastVisible.length>0)&&(Id.forEach(e=>void t.hidden.push(e)),it(Ze,U.ANNOTATION_VISIBILITY_CHANGE,t))}function LU(t){const e=!Id.has(t);return OU(t,e),e}const j1e=Object.freeze(Object.defineProperty({__proto__:null,checkAndSetAnnotationVisibility:LU,isAnnotationVisible:Vr,setAnnotationVisibility:OU,showAllAnnotations:z1e},Symbol.toStringTag,{value:"Module"})),$E=M1e,H1e=t=>{t=G1e(t),t=W1e(t);const e=t.annotationUID,r=CU(e);t.isLocked=r;const n=LU(e);return t.isVisible=n,t};$E.setPreprocessingFn(H1e);ME($E);function K1e(){ME($E)}function tu(t){if(!t.data.segmentation)throw new Error("removeContourSegmentationAnnotation: annotation does not have a segmentation data");const{segmentationId:e,segmentIndex:r}=t.data.segmentation,n=_n(e),{annotationUIDsMap:i}=(n==null?void 0:n.representationData.Contour)||{},o=i==null?void 0:i.get(r);o&&(o.delete(t.annotationUID),o.size||i.delete(r))}function nu(t){if(t.parentAnnotationUID)return;if(!t.data.segmentation)throw new Error("addContourSegmentationAnnotation: annotation does not have a segmentation data");const{segmentationId:e,segmentIndex:r}=t.data.segmentation,n=_n(e);n.representationData.Contour||(n.representationData.Contour={annotationUIDsMap:new Map});let{annotationUIDsMap:i}=n.representationData.Contour;i||(i=new Map);let o=i==null?void 0:i.get(r);o||(o=new Set,i.set(r,o)),i.set(r,o.add(t.annotationUID))}const q1e="PlanarFreehandContourSegmentationTool";function jE(t){var o;const{polyline:e}=((o=t.data)==null?void 0:o.contour)||{};if(!e||e.length<3){console.warn("Skipping creation of new annotation due to invalid polyline:",e);return}en(t.annotationUID),tu(t);const r=e[0],n=e[e.length-1],i={metadata:{...t.metadata,toolName:q1e,originalToolName:t.metadata.originalToolName||t.metadata.toolName},data:{cachedStats:{},handles:{points:[r,n],textBox:t.data.handles.textBox?{...t.data.handles.textBox}:void 0},contour:{...t.data.contour},spline:t.data.spline,segmentation:{...t.data.segmentation}},annotationUID:gn(),highlighted:!0,invalidated:!0,isLocked:!1,isVisible:void 0,interpolationUID:t.interpolationUID,interpolationCompleted:t.interpolationCompleted};return qt(i,t.metadata.FrameOfReferenceUID),nu(i),i}var Xo;(function(t){t[t.CounterClockwise=-1]="CounterClockwise",t[t.Unknown=0]="Unknown",t[t.Clockwise=1]="Clockwise"})(Xo||(Xo={}));function HE(t,e){return t.minX<=e.maxX&&t.maxX>=e.minX&&t.minY<=e.maxY&&t.maxY>=e.minY}function a5(t,e){const r=t.maxX-t.minX,n=t.maxY-t.minY,i=[r,n],o=[t.minX+r/2,t.minY+n/2],a=[Math.abs(e[0]-o[0]),Math.abs(e[1]-o[1])],s=a[0]-i[0]*.5,c=a[1]-i[1]*.5;if(s>0&&c>0)return s*s+c*c;const l=Math.max(s,0)+Math.max(c,0);return l*l}function X1e(t,e){return Math.sqrt(a5(t,e))}const Y1e=Object.freeze(Object.defineProperty({__proto__:null,distanceToPoint:X1e,distanceToPointSquared:a5,intersectAABB:HE},Symbol.toStringTag,{value:"Module"}));class AU{}class NU{constructor(e){this.storePointData=e.storePointData}getStatistics(){console.debug("InstanceCalculator getStatistics called")}}const{PointsManager:J1e}=pn;function P1(t){return{max:[-1/0],min:[1/0],sum:[0],count:0,maxIJK:null,maxLPS:null,minIJK:null,minLPS:null,runMean:[0],m2:[0],m3:[0],m4:[0],allValues:[[]],pointsInShape:t?J1e.create3(1024):null,sumLPS:[0,0,0]}}function kU(t,e,r=null,n=null){Array.isArray(e)&&e.length>1&&t.max.length===1&&(t.max.push(t.max[0],t.max[0]),t.min.push(t.min[0],t.min[0]),t.sum.push(t.sum[0],t.sum[0]),t.runMean.push(0,0),t.m2.push(t.m2[0],t.m2[0]),t.m3.push(t.m3[0],t.m3[0]),t.m4.push(t.m4[0],t.m4[0]),t.allValues.push([],[])),t!=null&&t.pointsInShape&&r&&t.pointsInShape.push(r);const i=Array.isArray(e)?e:[e];t.count+=1,r&&(t.sumLPS[0]+=r[0],t.sumLPS[1]+=r[1],t.sumLPS[2]+=r[2]),t.max.forEach((o,a)=>{const s=i[a];t.allValues[a].push(s);const c=t.count,l=s-t.runMean[a],f=l/c,u=l*f*(c-1);t.sum[a]+=s,t.runMean[a]+=f,t.m4[a]+=u*f*f*(c*c-3*c+3)+6*f*f*t.m2[a]-4*f*t.m3[a],t.m3[a]+=u*f*(c-2)-3*f*t.m2[a],t.m2[a]+=u,s<t.min[a]&&(t.min[a]=s,a===0&&(t.minIJK=n?[...n]:null,t.minLPS=r?[...r]:null)),s>t.max[a]&&(t.max[a]=s,a===0&&(t.maxIJK=n?[...n]:null,t.maxLPS=r?[...r]:null))})}function Z1e(t){if(t.length===0)return 0;const e=[...t].sort((n,i)=>n-i),r=Math.floor(e.length/2);return e.length%2===0?(e[r-1]+e[r])/2:e[r]}function VU(t,e){const r=t.sum.map(u=>u/t.count),n=t.m2.map(u=>Math.sqrt(u/t.count)),i=t.sumLPS.map(u=>u/t.count),o=t.m3.map((u,d)=>{const h=t.m2[d]/t.count;return h===0?0:u/(t.count*Math.pow(h,1.5))}),a=t.m4.map((u,d)=>{const h=t.m2[d]/t.count;return h===0?0:u/(t.count*h*h)-3}),s=t.allValues.map(u=>Z1e(u)),c={max:{name:"max",label:"Max Pixel",value:t.max.length===1?t.max[0]:t.max,unit:e,pointIJK:t.maxIJK?[...t.maxIJK]:null,pointLPS:t.maxLPS?[...t.maxLPS]:null},min:{name:"min",label:"Min Pixel",value:t.min.length===1?t.min[0]:t.min,unit:e,pointIJK:t.minIJK?[...t.minIJK]:null,pointLPS:t.minLPS?[...t.minLPS]:null},mean:{name:"mean",label:"Mean Pixel",value:r.length===1?r[0]:r,unit:e},stdDev:{name:"stdDev",label:"Standard Deviation",value:n.length===1?n[0]:n,unit:e},count:{name:"count",label:"Voxel Count",value:t.count,unit:null},median:{name:"median",label:"Median",value:s.length===1?s[0]:s,unit:e},skewness:{name:"skewness",label:"Skewness",value:o.length===1?o[0]:o,unit:null},kurtosis:{name:"kurtosis",label:"Kurtosis",value:a.length===1?a[0]:a,unit:null},maxLPS:{name:"maxLPS",label:"Max LPS",value:t.maxLPS?Array.from(t.maxLPS):null,unit:null},minLPS:{name:"minLPS",label:"Min LPS",value:t.minLPS?Array.from(t.minLPS):null,unit:null},pointsInShape:t.pointsInShape,center:{name:"center",label:"Center",value:i?[...i]:null,unit:null},array:[]};c.array.push(c.min,c.max,c.mean,c.stdDev,c.median,c.skewness,c.kurtosis,c.count,c.maxLPS,c.minLPS),c.center.value&&c.array.push(c.center);const l=t.pointsInShape!==null,f=P1(l);return t.max=f.max,t.min=f.min,t.sum=f.sum,t.count=f.count,t.maxIJK=f.maxIJK,t.maxLPS=f.maxLPS,t.minIJK=f.minIJK,t.minLPS=f.minLPS,t.runMean=f.runMean,t.m2=f.m2,t.m3=f.m3,t.m4=f.m4,t.allValues=f.allValues,t.pointsInShape=f.pointsInShape,t.sumLPS=f.sumLPS,c}const Jf=class Jf extends AU{static statsInit(e){e.storePointData||(this.state.pointsInShape=null),this.state=P1(e.storePointData)}};Jf.state=P1(!0),Jf.statsCallback=({value:e,pointLPS:r=null,pointIJK:n=null})=>{kU(Jf.state,e,r,n)},Jf.getStatistics=e=>VU(Jf.state,e==null?void 0:e.unit);let al=Jf;class FU extends NU{constructor(e){super(e),this.state=P1(e.storePointData)}statsInit(e){this.state=P1(e.storePointData)}statsCallback(e){kU(this.state,e.value,e.pointLPS,e.pointIJK)}getStatistics(e){return VU(this.state,e==null?void 0:e.unit)}}const Q1e=Object.freeze(Object.defineProperty({__proto__:null,BasicStatsCalculator:al,Calculator:AU,InstanceBasicStatsCalculator:FU,InstanceCalculator:NU},Symbol.toStringTag,{value:"Module"}));function ru(t,e){if(t.length!==e.length)throw Error("Both points should have the same dimensionality");const[r,n,i=0]=t,[o,a,s=0]=e,c=o-r,l=a-n,f=s-i;return c*c+l*l+f*f}function Do(t,e){return Math.sqrt(ru(t,e))}function zS(t,e){const[r,n]=t,[i,o]=e,a=2*i-r,s=2*o-n;return[a,s]}const eme=Object.freeze(Object.defineProperty({__proto__:null,distanceToPoint:Do,distanceToPointSquared:ru,mirror:zS},Symbol.toStringTag,{value:"Module"}));function Qu(t){const[e,r]=t;return Do(e,r)}function ih(t){const[e,r]=t,n=Do(e,r),i=[e[0]-n,e[1]-n],o=[e[0]+n,e[1]+n];return[i,o]}const tme=Object.freeze(Object.defineProperty({__proto__:null,getCanvasCircleCorners:ih,getCanvasCircleRadius:Qu},Symbol.toStringTag,{value:"Module"}));function Nw(t,e,r={}){return r.precalculated||KE(t,r),r.precalculated(e)}const KE=(t,e={})=>{const{xRadius:r,yRadius:n,zRadius:i}=t;(e.invXRadiusSq===void 0||e.invYRadiusSq===void 0||e.invZRadiusSq===void 0)&&(e.invXRadiusSq=r!==0?1/r**2:0,e.invYRadiusSq=n!==0?1/n**2:0,e.invZRadiusSq=i!==0?1/i**2:0);const{invXRadiusSq:o,invYRadiusSq:a,invZRadiusSq:s}=e,{center:c}=t,[l,f,u]=c;return e.precalculated=d=>{const h=d[0]-l;let g=h*h*o;if(g>1)return!1;const p=d[1]-f;if(g+=p*p*a,g>1)return!1;const v=d[2]-u;return g+=v*v*s,g<=1},e};function s5(t){const[e,r,n,i]=t,o=[n[0],r[1]],a=[i[0],e[1]];return[o,a]}const nme=Object.freeze(Object.defineProperty({__proto__:null,getCanvasEllipseCorners:s5,pointInEllipse:Nw,precalculatePointInEllipse:KE},Symbol.toStringTag,{value:"Module"}));function c5(t,e,r){let n;const i=ru(t,e);if(t[0]===e[0]&&t[1]===e[1]&&(n=t),!n){const o=((r[0]-t[0])*(e[0]-t[0])+(r[1]-t[1])*(e[1]-t[1]))/i;o<0?n=t:o>1?n=e:n=[t[0]+o*(e[0]-t[0]),t[1]+o*(e[1]-t[1])]}return{point:[...n],distanceSquared:ru(r,n)}}function Tm(t,e,r){return c5(t,e,r).distanceSquared}function ui(t,e,r){if(t.length!==2||e.length!==2||r.length!==2)throw Error("lineStart, lineEnd, and point should have 2 elements of [x, y]");return Math.sqrt(Tm(t,e,r))}function N2(t){return typeof t=="number"?t?t<0?-1:1:t===t?0:NaN:NaN}function l5(t,e,r,n,i=!1){const[o,a]=t,[s,c]=e,[l,f]=r,[u,d]=n;if(i){const I=(o-s)*(f-d)-(a-c)*(l-u);if(Math.abs(I)<1e-10)return;const P=((o-l)*(f-d)-(a-f)*(l-u))/I,O=o+P*(s-o),L=a+P*(c-a);return[O,L]}const h=c-a,g=o-s,p=s*a-o*c,v=h*l+g*f+p,y=h*u+g*d+p;if(v!==0&&y!==0&&N2(v)===N2(y))return;const m=d-f,w=l-u,x=u*f-l*d,C=m*o+w*a+x,S=m*s+w*c+x;if(C!==0&&S!==0&&N2(C)===N2(S))return;const T=h*w-m*g;let _;_=g*x-w*p;const E=_/T;_=m*p-h*x;const b=_/T;return[E,b]}const Pg=.01;function kv(t,e,r){const n=t[0]<=e[0]?t[0]:e[0],i=t[0]>=e[0]?t[0]:e[0],o=t[1]<=e[1]?t[1]:e[1],a=t[1]>=e[1]?t[1]:e[1];if(!(r[0]>=n-Pg&&r[0]<=i+Pg&&r[1]>=o-Pg&&r[1]<=a+Pg))return!1;const c=(e[1]-t[1])*(r[0]-e[0])-(e[0]-t[0])*(r[1]-e[1]);return(c>=0?c:-c)<=Pg}const rme=Object.freeze(Object.defineProperty({__proto__:null,distanceToPoint:ui,distanceToPointSquared:Tm,distanceToPointSquaredInfo:c5,intersectLine:l5,isPointOnLineSegment:kv},Symbol.toStringTag,{value:"Module"}));function UU(t){if(t.length<3)return!1;const e=t.length,r=t[0],n=t[e-1],i=ru(r,n);return af(0,i)}function uf(t,e,r={closed:void 0}){if(t.length<3)return!1;const n=t.length;let i=0;const{closed:o,holes:a}=r;if(a!=null&&a.length){for(const l of a)if(uf(l,e))return!1}const s=!(o===void 0?UU(t):o),c=t.length-(s?1:2);for(let l=0;l<=c;l++){const f=t[l],u=l===n-1?0:l+1,d=t[u],h=f[0]>=d[0]?f[0]:d[0],g=f[1]>=d[1]?f[1]:d[1],p=f[1]<=d[1]?f[1]:d[1];if(e[0]<=h&&e[1]>=p&&e[1]<g){let m=f[0]===d[0];if(!m){const w=(e[1]-f[1])*(d[0]-f[0])/(d[1]-f[1])+f[0];m=e[0]<=w}i+=m?1:0}}return!!(i%2)}function _m(t,e){for(let r=0,n=e.length;r<n;r++)if(!uf(t,e[r]))return!1;return!0}function ff(t,e){let r=t;const n=(e==null?void 0:e.numDimensions)||2,i=n===3;if(!Array.isArray(t[0])){const u=t,d=u.length/n;r=new Array(u.length/n);for(let h=0,g=d;h<g;h++)r[h]=[u[h*n],u[h*n+1]],i&&r[h].push(u[h*n+2])}let o=1/0,a=1/0,s=-1/0,c=-1/0,l=1/0,f=-1/0;r=r;for(let u=0,d=r.length;u<d;u++){const[h,g,p]=r[u];o=o<h?o:h,a=a<g?a:g,s=s>h?s:h,c=c>g?c:g,i&&(l=l<p?l:p,f=f>p?f:p)}return i?{minX:o,maxX:s,minY:a,maxY:c,minZ:l,maxZ:f}:{minX:o,maxX:s,minY:a,maxY:c}}function Em(t){const e=t.length;let r=0,n=e-1;for(let i=0;i<e;i++)r+=(t[n][0]+t[i][0])*(t[n][1]-t[i][1]),n=i;return Math.abs(r/2)}function qE(t){if(t.length<3)return 0;const e=t[0];let r=0;for(let n=0,i=t.length;n<i;n++){const o=t[n],a=n===i-1?0:n+1,s=t[a],c=o[0]-e[0],l=o[1]-e[1],f=s[0]-e[0],u=s[1]-e[1];r+=c*u-l*f}return r*=.5,r}function Vv(t){return qE(t)>=0?1:-1}function ime(t){const e=Ke(),r=t[0];for(let n=0,i=t.length;n<i;n++){const o=t[n],a=n===i-1?0:n+1,s=t[a],c=o[0]-r[0],l=o[1]-r[1],f=o[2]-r[2],u=s[0]-r[0],d=s[1]-r[1],h=s[2]-r[2];e[0]+=l*h-f*d,e[1]+=f*u-c*h,e[2]+=c*d-l*u}return gr(e,e,.5),e}function ome(t){const e=ime(t);return Un(e,e)}function R1(t){const e=qE(t);return[0,0,e/Math.abs(e)]}function XE(t,e,r,n){let i=!1;const o=t[0]<e[0]?t[0]:e[0],a=t[1]<e[1]?t[1]:e[1],s=t[0]>e[0]?t[0]:e[0],c=t[1]>e[1]?t[1]:e[1],l=r[0]<n[0]?r[0]:n[0],f=r[1]<n[1]?r[1]:n[1],u=r[0]>n[0]?r[0]:n[0],d=r[1]>n[1]?r[1]:n[1];if(o>u||s<l||a>d||c<f)return!1;const h=[k2(t,e,r),k2(t,e,n),k2(r,n,t),k2(r,n,e)];return h[0]!==h[1]&&h[2]!==h[3]?!0:((h[0]===0&&V2(t,r,e)||h[1]===0&&V2(t,n,e)||h[2]===0&&V2(r,t,n)||h[3]===0&&V2(r,e,n))&&(i=!0),i)}function k2(t,e,r){const n=(e[1]-t[1])*(r[0]-e[0])-(e[0]-t[0])*(r[1]-e[1]);return n===0?0:n>0?1:2}function V2(t,e,r){return e[0]<=Math.max(t[0],r[0])&&e[0]>=Math.min(t[0],r[0])&&e[1]<=Math.max(t[1],r[1])&&e[1]>=Math.min(t[1],r[1])}function YE(t,e,r,n=!0){const i=[],o=t.length,a=o-(n?1:2);for(let s=0;s<=a;s++){const c=t[s],l=s===o-1?0:s+1,f=t[l];XE(e,r,c,f)&&i.push([s,l])}return i}const ame=.01;function BU(t,e,r,n){const i=[e[0]-t[0],e[1]-t[1]],o=[n[0]-r[0],n[1]-r[1]],a=o[1]*i[0]-o[0]*i[1];if((a>=0?a:-a)<ame){const g=[t[0]<e[0]?t[0]:e[0],t[0]>e[0]?t[0]:e[0],t[1]<e[1]?t[1]:e[1],t[1]>e[1]?t[1]:e[1]],p=[r[0]<n[0]?r[0]:n[0],r[0]>n[0]?r[0]:n[0],r[1]<n[1]?r[1]:n[1],r[1]>n[1]?r[1]:n[1]];if(!(g[0]<=p[1]&&g[1]>=p[0]&&g[2]<=p[3]&&g[3]>=p[2])||!(kv(t,e,r)||kv(t,e,n)||kv(r,n,t)))return;const m=g[0]>p[0]?g[0]:p[0],w=g[1]<p[1]?g[1]:p[1],x=g[2]>p[2]?g[2]:p[2],C=g[3]<p[3]?g[3]:p[3],S=(m+w)*.5,T=(x+C)*.5;return[S,T]}let c=t[1]-r[1],l=t[0]-r[0];const f=o[0]*c-o[1]*l,u=i[0]*c-i[1]*l;c=f/a,l=u/a;const d=t[0]+c*i[0],h=t[1]+c*i[1];return[d,h]}var dd;(function(t){t[t.Vertex=0]="Vertex",t[t.Intersection=1]="Intersection"})(dd||(dd={}));var oh;(function(t){t[t.Outside=-1]="Outside",t[t.Edge=0]="Edge",t[t.Inside=1]="Inside"})(oh||(oh={}));var b0;(function(t){t[t.Exiting=-1]="Exiting",t[t.Unknown=0]="Unknown",t[t.Entering=1]="Entering"})(b0||(b0={}));function xI(t){for(let e=0,r=t.length;e<r;e++){const n=t[e];n.next||(n.next=t[e===r-1?0:e+1])}}function GU(t,e){const r=[],n=[],i=new Map;let a=uf(e,t[0])?b0.Exiting:b0.Entering;for(let s=0,c=t.length;s<c;s++){const l=t[s],f=uf(e,l),u={type:dd.Vertex,coordinates:l,position:f?oh.Inside:oh.Outside,visited:!1,next:null};r.push(u);const d=t[s===c-1?0:s+1],h=YE(e,l,d).map(g=>{const p=g[0],v=e[g[0]],y=e[g[1]],m=BU(l,d,v,y),w=ru(l,m);return{sourceLineSegmentId:p,coordinate:m,targetStartPointDistSquared:w}});h.sort((g,p)=>g.targetStartPointDistSquared-p.targetStartPointDistSquared),h.forEach(g=>{const{sourceLineSegmentId:p,coordinate:v}=g,y={type:dd.Intersection,coordinates:v,position:oh.Edge,direction:a,visited:!1,next:null},m={...y,direction:b0.Unknown,cloned:!0};a===b0.Entering?y.next=m:m.next=y;let w=i.get(p);w||(w=[],i.set(p,w)),r.push(y),w.push(m),a*=-1})}for(let s=0,c=e.length;s<c;s++){const l=s,f=e[s],u={type:dd.Vertex,coordinates:f,visited:!1,next:null};n.push(u);const d=i.get(l);d!=null&&d.length&&d.map(h=>({intersectionPoint:h,lineSegStartDistSquared:ru(f,h.coordinates)})).sort((h,g)=>h.lineSegStartDistSquared-g.lineSegStartDistSquared).map(({intersectionPoint:h})=>h).forEach(h=>n.push(h))}return xI(r),xI(n),{targetPolylinePoints:r,sourcePolylinePoints:n}}function WU(t){for(let e=0,r=t.length;e<r;e++){const n=t[e];if(!n.visited&&n.position===oh.Outside)return n}}function kw(t,e){const r=R1(t),n=R1(e),i=xt(n,r);af(1,i)||(e=e.slice().reverse());const{targetPolylinePoints:o}=GU(t,e),a=WU(o);if(!a)return t.slice();const s=[a.coordinates];let c=a.next,l=0;const f=t.length+e.length+1e3;for(;c!==a&&l<f;){if(l++,c.type===dd.Intersection&&c.cloned){c=c.next;continue}if(s.push(c.coordinates),c=c.next,!c){console.warn("Broken linked list detected in mergePolylines, breaking loop");break}}return l>=f&&console.warn("Maximum iterations reached in mergePolylines, possible infinite loop detected"),s}function Vw(t,e){const r=R1(t),n=R1(e),i=xt(n,r);af(-1,i)||(e=e.slice().reverse());const{targetPolylinePoints:o}=GU(t,e);let a=null;const s=[];let c=0;const l=t.length*2;for(;(a=WU(o))&&c<l;){c++;const f=[a.coordinates];let u=a.next,d=0;const h=t.length+e.length+1e3;for(a.visited=!0;u!==a&&d<h;){if(d++,u.visited=!0,u.type===dd.Intersection&&u.cloned){u=u.next;continue}if(f.push(u.coordinates),u=u.next,!u){console.warn("Broken linked list detected in subtractPolylines, breaking inner loop");break}}d>=h&&console.warn("Maximum inner iterations reached in subtractPolylines, possible infinite loop detected"),s.push(f)}return c>=l&&console.warn("Maximum outer iterations reached in subtractPolylines, possible infinite loop detected"),s}function zU(t,e,r,n=!0){let i,o;n?(o=t.length-1,i=0):(o=0,i=1);for(let a=i;a<t.length;a++){const s=t[o],c=t[a];if(XE(e,r,s,c))return[o,a];o=a}}function JE(t,e){for(let r=0,n=t.length;r<n;r++){const i=t[r],o=r===n-1?0:r+1,a=t[o],s=zU(e,i,a);if((s==null?void 0:s.length)===2)return!0}return!1}const sme=.1;function ZE(t,e=sme){const r=t.length;if(r<3)return t;const n=e*e,i=[[0,r-1]],o=new Array(r).fill(!1);let a=2;for(o[0]=!0,o[r-1]=!0;i.length;){const[c,l]=i.pop();if(l-c===1)continue;const f=t[c],u=t[l];let d=-1/0,h=-1;for(let g=c+1;g<l;g++){const p=t[g],v=Tm(f,u,p);v>d&&(d=v,h=g)}d<n||(o[h]=!0,a++,i.push([h,l]),i.push([c,h]))}const s=new Array(a);for(let c=0,l=0;c<r;c++)o[c]&&(s[l++]=t[c]);return s}function $U(t,e,r,n=!0){const i=[],o=YE(t,e,r,n);for(let a=0;a<o.length;a++){const s=t[o[a][0]],c=t[o[a][1]],l=BU(e,r,s,c);i.push(l)}return i}function cme(t,e,r,n=!0){let i,o;n?(o=t.length-1,i=0):(o=0,i=1);const a=[];for(let f=i;f<t.length;f++){const u=t[o],d=t[f];XE(e,r,u,d)&&a.push([o,f]),o=f}if(a.length===0)return;const s=[];a.forEach(f=>{const u=[t[f[0]],t[f[1]]],d=[(u[0][0]+u[1][0])/2,(u[0][1]+u[1][1])/2];s.push(ur(d,e))});const c=Math.min(...s),l=s.indexOf(c);return{segment:a[l],distance:c}}const r0=.001,lme=(t,e)=>{let r,n,i;if(t instanceof Jn){const a=t.getImageData();if(!a)return;n=a.direction.slice(0,3),i=a.direction.slice(3,6),r=a.spacing}else{const a=t.getImageData(),{direction:s,spacing:c}=a,{viewPlaneNormal:l,viewUp:f}=t.getCamera(),u=s.slice(0,3),d=s.slice(3,6),h=s.slice(6,9),g=Ke();Tn(g,f,l);const p=Math.abs(xt(g,u)),v=Math.abs(xt(g,d)),y=Math.abs(xt(g,h));let m;if(Math.abs(1-p)<r0)m=c[0],n=u;else if(Math.abs(1-v)<r0)m=c[1],n=d;else if(Math.abs(1-y)<r0)m=c[2],n=h;else throw new Error("No support yet for oblique plane planar contours");const w=Math.abs(xt(f,u)),x=Math.abs(xt(f,d)),C=Math.abs(xt(f,h));let S;if(Math.abs(1-w)<r0)S=c[0],i=u;else if(Math.abs(1-x)<r0)S=c[1],i=d;else if(Math.abs(1-C)<r0)S=c[2],i=h;else throw new Error("No support yet for oblique plane planar contours");r=[m,S]}return{spacing:[r[0]/e,r[1]/e],xDir:n,yDir:i}},ume=(t,e,r)=>l4(t,e)<r,fme=(t,e,r,n)=>{const{xDir:i,yDir:o,spacing:a}=n,s=Le(t),{viewport:c}=s;if(!e.length)return e.push(r),console.log(">>>>> !canvasPoints. :: RETURN"),1;const l=c.canvasToWorld(e[e.length-1]),f=c.canvasToWorld(r),u=Ke();Nn(u,f,l);const d=Math.abs(xt(u,i)),h=Math.abs(xt(u,o)),g=Math.max(Math.floor(d/a[0]),Math.floor(h/a[0]));if(g>1){const p=e[e.length-1],v=l4(p,r),y=Wt();Br(y,r,p),fs(y,y[0]/v,y[1]/v);const m=v/g;for(let w=1;w<=g;w++)e.push([p[0]+m*y[0]*w,p[1]+m*y[1]*w])}else e.push(r);return g},dme=(t,e,r,n)=>{const i=[t[0]-e[0],t[1]-e[1]],o=[r[0]-e[0],r[1]-e[1]],a=i[0]*o[0]+i[1]*o[1];if(a<0)return!1;const s=Math.sqrt(o[0]*o[0]+o[1]*o[1]);if(s===0)return!1;const c=a/s,l=[o[0]/s,o[1]/s],f=[l[0]*c,l[1]*c],u=[e[0]+f[0],e[1]+f[1]];return!(ur(t,u)>n||ur(e,u)>ur(e,r))},hme=1e-6;function jU(t){let e;const r=mE(t,50);for(let a=0;a<3;a++)if(r.every((s,c,l)=>Math.abs(s[a]-l[0][a])<hme)){e=a;break}if(e===void 0)throw new Error("Cannot find a shared dimension index for polyline, probably oblique plane");const n=[],i=(e+1)%3,o=(e+2)%3;for(let a=0;a<t.length;a++)n.push([t[a][i],t[a][o]]);return{sharedDimensionIndex:e,projectedPolyline:n}}function QE(t,e,r={}){const{sharedDimensionIndex:n,projectedPolyline:i}=jU(e),{holes:o}=r,a=[];if(o)for(let c=0;c<o.length;c++){const l=o[c],f=[];for(let u=0;u<l.length;u++)f.push([l[u][(n+1)%3],l[u][(n+2)%3]]);a.push(f)}const s=[t[(n+1)%3],t[(n+2)%3]];return uf(i,s,{holes:a})}function HU(t){if(t.length<3)return t.slice();const e=t.map(o=>[o[0],o[1]]).sort((o,a)=>o[0]===a[0]?o[1]-a[1]:o[0]-a[0]);function r(o,a,s){return(a[0]-o[0])*(s[1]-o[1])-(a[1]-o[1])*(s[0]-o[0])}const n=[];for(const o of e){for(;n.length>=2&&r(n[n.length-2],n[n.length-1],o)<=0;)n.pop();n.push(o)}const i=[];for(let o=e.length-1;o>=0;o--){const a=e[o];for(;i.length>=2&&r(i[i.length-2],i[i.length-1],a)<=0;)i.pop();i.push(a)}return n.pop(),i.pop(),n.concat(i)}const Tf=Object.freeze(Object.defineProperty({__proto__:null,addCanvasPointsToArray:fme,containsPoint:uf,containsPoints:_m,convexHull:HU,decimate:ZE,getAABB:ff,getArea:Em,getClosestLineSegmentIntersection:cme,getFirstLineSegmentIntersectionIndexes:zU,getLineSegmentIntersectionsCoordinates:$U,getLineSegmentIntersectionsIndexes:YE,getNormal2:R1,getNormal3:ome,getSignedArea:qE,getSubPixelSpacingAndXYDirections:lme,getWindingDirection:Vv,intersectPolyline:JE,isClosed:UU,isPointInsidePolyline3D:QE,mergePolylines:kw,pointCanProjectOnLine:dme,pointsAreWithinCloseContourProximity:ume,projectTo2D:jU,subtractPolylines:Vw},Symbol.toStringTag,{value:"Module"}));function gme(t,e,r,n){const i=[t,e],o=[t+r,e],a=[t+r,e],s=[t+r,e+n],c=[t+r,e+n],l=[t,e+n],f=[t,e+n];return{top:[i,o],right:[a,s],bottom:[c,l],left:[f,[t,e]]}}function e8(t,e){if(t.length!==4||e.length!==2)throw Error("rectangle:[left, top, width, height] or point: [x,y] not defined correctly");const[r,n,i,o]=t;let a=655535;const s=gme(r,n,i,o);return Object.keys(s).forEach(c=>{const[l,f]=s[c],u=ui(l,f,e);u<a&&(a=u)}),a}const pme=Object.freeze(Object.defineProperty({__proto__:null,distanceToPoint:e8},Symbol.toStringTag,{value:"Module"}));function $S(t,e){let r=[0,0],n=Number.MAX_SAFE_INTEGER;return t.forEach(function(i){const o=mme(e,i);o<n&&(n=o,r=[...i])}),r}function mme(t,e){const[r,n]=t,[i,o]=e;return Math.sqrt(Math.pow(r-i,2)+Math.pow(n-o,2))}const jS=1e-6,CI=1,vme=0;function F2(t,e,r){const[n,i]=r;if(Math.abs(e)<jS)return t<0;const o=t/e;if(e>0){if(o>i)return 0;o>n&&(r[0]=o)}else{if(o<n)return 0;o<i&&(r[1]=o)}return 1}function tp(t,e,r,n,i){const[o,a]=t,[s,c]=e,l=s-o,f=c-a;if(n===void 0||i===void 0?(n=t,i=e):(n[0]=t[0],n[1]=t[1],i[0]=e[0],i[1]=e[1]),Math.abs(l)<jS&&Math.abs(f)<jS&&o>=r[0]&&o<=r[2]&&a>=r[1]&&a<=r[3])return CI;const u=[0,1];if(F2(r[0]-o,l,u)&&F2(o-r[2],-l,u)&&F2(r[1]-a,f,u)&&F2(a-r[3],-f,u)){const[d,h]=u;return h<1&&(i[0]=o+h*l,i[1]=a+h*f),d>0&&(n[0]+=d*l,n[1]+=d*f),CI}return vme}const yme=Object.freeze(Object.defineProperty({__proto__:null,findClosestPoint:$S,liangBarksyClip:tp},Symbol.toStringTag,{value:"Module"}));function wme(t,e){const[r,n]=t,[i,o]=e,a=hn(Ke(),n,r),s=hn(Ke(),i,o),c=xt(a,s),l=Ko(a),f=Ko(s),u=c/(l*f);return Math.acos(u)*180/Math.PI}function xme(t,e){const[r,n]=t,[i,o]=e,a=ps(Wt(),n,r),s=ps(Wt(),i,o),c=c4(a,s),l=Sy(a),f=Sy(s),u=c/(l*f);return Math.acos(u)*(180/Math.PI)}function ah(t,e){return t[0].length===3?wme(t,e):xme(t,e)}const Cme=Object.freeze(Object.defineProperty({__proto__:null,angleBetweenLines:ah},Symbol.toStringTag,{value:"Module"})),Sme=Object.freeze(Object.defineProperty({__proto__:null,BasicStatsCalculator:Q1e,aabb:Y1e,angle:Cme,circle:tme,ellipse:nme,lineSegment:rme,point:eme,polyline:Tf,rectangle:pme,vec2:yme},Symbol.toStringTag,{value:"Module"}));function vc(t,e,r,n){var g,p,v;const{canvasToWorld:i,worldToCanvas:o}=r,{data:a}=t,{targetWindingDirection:s}=e;let{points:c}=e,l=Vv(c);(g=n==null?void 0:n.decimate)!=null&&g.enabled&&(c=ZE(e.points,(p=n==null?void 0:n.decimate)==null?void 0:p.epsilon));let{closed:f}=e;const u=c.length,d=new Array(u);Vv(c);const h=OF(t);if(f===void 0){let y=!1;if(c.length>3){const m=ru(c[0],c[u-1]);y=Vt(0,m)}f=y}if((n==null?void 0:n.updateWindingDirection)!==!1){let y=h?h.data.contour.windingDirection*-1:s;y===void 0&&(y=l),y!==l&&c.reverse();const m=(((v=a.handles)==null?void 0:v.points)??[]).map(o);m.length>2&&Vv(m)!==y&&a.handles.points.reverse(),l=y}for(let y=0;y<u;y++)d[y]=i(c[y]);a.contour.polyline=d,a.contour.closed=f,a.contour.windingDirection=l,MF(t)}const Tme="viewport-element";function _me(t){const e=Le(t),{viewportId:r,renderingEngineId:n}=e,i=`${r}:${n}`,o=Eme(t);return Object.keys(Je.svgNodeCache[i]).forEach(a=>{Je.svgNodeCache[i][a].touched=!1}),{svgLayerElement:o,svgNodeCacheForCanvas:Je.svgNodeCache,getSvgNode:bme.bind(this,i),appendNode:Dme.bind(this,o,i),setNodeTouched:Ime.bind(this,i),clearUntouched:Ome.bind(this,o,i)}}function Eme(t){const e=`.${Tme}`,r=t.querySelector(e);return r==null?void 0:r.querySelector(":scope > .svg-layer")}function bme(t,e){if(Je.svgNodeCache[t]&&Je.svgNodeCache[t][e])return Je.svgNodeCache[t][e].domRef}function Dme(t,e,r,n){if(!Je.svgNodeCache[e])return null;Je.svgNodeCache[e][n]={touched:!0,domRef:r},t.appendChild(r)}function Ime(t,e){Je.svgNodeCache[t]&&Je.svgNodeCache[t][e]&&(Je.svgNodeCache[t][e].touched=!0)}function Ome(t,e){Je.svgNodeCache[e]&&Object.keys(Je.svgNodeCache[e]).forEach(r=>{const n=Je.svgNodeCache[e][r];!n.touched&&n.domRef&&(t.removeChild(n.domRef),delete Je.svgNodeCache[e][r])})}function KU(t,e){const r=_me(t);e(r),r.clearUntouched()}function hl(t,e,r){return`${t}::${e}::${r}`}function za(t,e){Object.keys(t).forEach(r=>{const n=e.getAttribute(r),i=t[r];i===void 0||i===""?e.removeAttribute(r):n!==i&&e.setAttribute(r,i)})}function gl(t,e){Object.keys(t).forEach(r=>{const n=t[r];n!==void 0&&n!==""&&e.setAttribute(r,n)})}function Yo(t,e,r,n,i,o={},a=""){const{color:s,fill:c,width:l,lineWidth:f,lineDash:u,fillOpacity:d,strokeOpacity:h}=Object.assign({color:"rgb(0, 255, 0)",fill:"transparent",width:"2",lineDash:void 0,lineWidth:void 0,strokeOpacity:1,fillOpacity:1},o),g=f||l,p="http://www.w3.org/2000/svg",v=hl(e,"circle",r),y=t.getSvgNode(v),m={cx:`${n[0]}`,cy:`${n[1]}`,r:`${i}`,stroke:s,fill:c,"stroke-width":g,"stroke-dasharray":u,"fill-opacity":d,"stroke-opacity":h};if(y)za(m,y),t.setNodeTouched(v);else{const w=document.createElementNS(p,"circle");a!==""&&w.setAttribute("data-id",a),gl(m,w),t.appendNode(w,v)}}function t8(t,e,r,n,i={},o=""){const{color:a,width:s,lineWidth:c,lineDash:l}=Object.assign({color:"rgb(0, 255, 0)",width:"2",lineWidth:void 0,lineDash:void 0},i),f=c||s,u="http://www.w3.org/2000/svg",d=hl(e,"ellipse",r),h=t.getSvgNode(d),[g,p,v,y]=n,m=Math.hypot(v[0]-y[0],v[1]-y[1]),w=Math.hypot(p[0]-g[0],p[1]-g[1]),x=Math.atan2(v[1]-y[1],v[0]-y[0])*180/Math.PI,C=[(v[0]+y[0])/2,(p[1]+g[1])/2],S=m/2,T=w/2,_={cx:`${C[0]}`,cy:`${C[1]}`,rx:`${S}`,ry:`${T}`,stroke:a,fill:"transparent",transform:`rotate(${x} ${C[0]} ${C[1]})`,"stroke-width":f,"stroke-dasharray":l};if(h)za(_,h),t.setNodeTouched(d);else{const E=document.createElementNS(u,"ellipse");o!==""&&E.setAttribute("data-id",o),gl(_,E),t.appendNode(E,d)}}function Mme(t,e,r,n,i,o={},a=""){const s=[(n[0]+i[0])/2,n[1]],c=[(n[0]+i[0])/2,i[1]],l=[n[0],(n[1]+i[1])/2],f=[i[0],(n[1]+i[1])/2];t8(t,e,r,[c,s,l,f],o={},a="")}function u5(t,e,r,n,i={},o){const{color:a,handleRadius:s,width:c,lineWidth:l,fill:f,type:u,opacity:d}=Object.assign({color:"rgb(0, 255, 0)",handleRadius:"6",width:"2",lineWidth:void 0,fill:"transparent",type:"circle",opacity:1},i),h=l||c,g="http://www.w3.org/2000/svg",p=hl(e,"handle",`hg-${r}-index-${o}`);let v;if(u==="circle")v={cx:`${n[0]}`,cy:`${n[1]}`,r:s,stroke:a,fill:f,"stroke-width":h,opacity:d};else if(u==="rect"){const w=parseFloat(s)*1.5,x=n[0]-w*.5,C=n[1]-w*.5;v={x:`${x}`,y:`${C}`,width:`${w}`,height:`${w}`,stroke:a,fill:f,"stroke-width":h,rx:`${w*.1}`,opacity:d}}else throw new Error(`Unsupported handle type: ${u}`);const y=t.getSvgNode(p);if(y)za(v,y),t.setNodeTouched(p);else{const m=document.createElementNS(g,u);gl(v,m),t.appendNode(m,p)}}function Kn(t,e,r,n,i={}){n.forEach((o,a)=>{u5(t,e,r,o,i,a)})}function an(t,e,r,n,i,o={},a=""){if(isNaN(n[0])||isNaN(n[1])||isNaN(i[0])||isNaN(i[1]))return;const{color:s="rgb(0, 255, 0)",width:c=10,lineWidth:l,lineDash:f,markerStartId:u=null,markerEndId:d=null,shadow:h=!1,strokeOpacity:g=1}=o,p=l||c,v="http://www.w3.org/2000/svg",y=hl(e,"line",r),m=t.getSvgNode(y),w=t.svgLayerElement.id,x=h?`filter:url(#shadow-${w});`:"",C={x1:`${n[0]}`,y1:`${n[1]}`,x2:`${i[0]}`,y2:`${i[1]}`,stroke:s,style:x,"stroke-width":p,"stroke-dasharray":f,"marker-start":u?`url(#${u})`:"","marker-end":d?`url(#${d})`:"","stroke-opacity":g};if(m)za(C,m),t.setNodeTouched(y);else{const S=document.createElementNS(v,"line");a!==""&&S.setAttribute("data-id",a),gl(C,S),t.appendNode(S,y)}}function qU(t,e,r,n,i,o={}){if(isNaN(n[0])||isNaN(n[1])||isNaN(i[0])||isNaN(i[1]))return;const{color:a,width:s,lineWidth:c,lineDash:l}=Object.assign({color:"rgb(0, 255, 0)",width:"2",lineWidth:void 0,lineDash:void 0},o),f=i[0]+(n[0]-i[0])/2,u=[f,n[1]],d=[f,i[1]],h={start:n,end:u},g={start:u,end:d},p={start:d,end:i};an(t,e,"1",h.start,h.end,{color:a,width:s,lineWidth:c,lineDash:l}),an(t,e,"2",g.start,g.end,{color:a,width:s,lineWidth:c,lineDash:l}),an(t,e,"3",p.start,p.end,{color:a,width:s,lineWidth:c,lineDash:l})}function dc(t,e,r,n,i){if(n.length<2)return;const{color:o="rgb(0, 255, 0)",width:a=10,fillColor:s="none",fillOpacity:c=0,lineWidth:l,lineDash:f,closePath:u=!1,markerStartId:d=null,markerEndId:h=null}=i,g=l||a,p="http://www.w3.org/2000/svg",v=hl(e,"polyline",r),y=t.getSvgNode(v);let m="";for(const x of n)m+=`${x[0].toFixed(1)}, ${x[1].toFixed(1)} `;if(u){const x=n[0];m+=`${x[0]}, ${x[1]}`}const w={points:m,stroke:o,fill:s,"fill-opacity":c,"stroke-width":g,"stroke-dasharray":f,"marker-start":d?`url(#${d})`:"","marker-end":h?`url(#${h})`:""};if(y)za(w,y),t.setNodeTouched(v);else{const x=document.createElementNS(p,"polyline");gl(w,x),t.appendNode(x,v)}}function Kl(t,e,r,n,i){const a=n.length&&n[0].length&&Array.isArray(n[0][0])?n:[n],{color:s="rgb(0, 255, 0)",width:c=10,fillColor:l="none",fillOpacity:f=0,lineWidth:u,lineDash:d,closePath:h=!1}=i,g=u||c,p="http://www.w3.org/2000/svg",v=hl(e,"path",r),y=t.getSvgNode(v);let m="";for(let x=0,C=a.length;x<C;x++){const S=a[x],T=S.length;if(!(T<2)){for(let _=0;_<T;_++){const E=S[_];m+=`${_?"L":"M"} ${E[0].toFixed(1)}, ${E[1].toFixed(1)} `}h&&(m+="Z ")}}if(!m)return;const w={d:m,stroke:s,fill:l,"fill-opacity":f,"stroke-width":g,"stroke-dasharray":d};if(y)za(w,y),t.setNodeTouched(v);else{const x=document.createElementNS(p,"path");gl(w,x),t.appendNode(x,v)}}function HS(t,e,r,n,i,o,a,s,c={},l="",f){const{color:u,fill:d,width:h,lineWidth:g,lineDash:p,fillOpacity:v,strokeOpacity:y}=Object.assign({color:"rgb(0, 255, 0)",fill:"transparent",width:"2",lineDash:void 0,lineWidth:void 0,strokeOpacity:1,fillOpacity:1},c),m=g||h,w="http://www.w3.org/2000/svg",x=hl(e,"fan",r),C=t.getSvgNode(x),S=a*Math.PI/180,T=s*Math.PI/180,_=n[0],E=n[1],b=_+o*Math.cos(S),D=E+o*Math.sin(S),I=_+o*Math.cos(T),P=E+o*Math.sin(T),O=_+i*Math.cos(S),L=E+i*Math.sin(S),B=_+i*Math.cos(T),H=E+i*Math.sin(T),A=s-a<=180?0:1;let F=`M ${b} ${D}`;F+=` A ${o} ${o} 0 ${A} 1 ${I} ${P}`,F+=` L ${B} ${H}`,F+=` A ${i} ${i} 0 ${A} 0 ${O} ${L}`,F+=" Z";const G={d:F,stroke:u,fill:d,"stroke-width":m,"stroke-dasharray":p,"fill-opacity":v,"stroke-opacity":y,"mix-blend-mode":"normal"};if(C)za(G,C),t.setNodeTouched(x);else{const X=document.createElementNS(w,"path");l!==""&&X.setAttribute("data-id",l),f!==void 0&&(X.style.zIndex=f.toString()),gl(G,X),t.appendNode(X,x)}}function df(t,e,r,n,i,o={}){const a=Object.assign({fontFamily:"Helvetica, Arial, sans-serif",fontSize:"14px",color:"rgb(255, 255, 0)",background:"",padding:25,centerX:!1,centerY:!0},o);return Pme(t,e,r,n,i,a)}function Pme(t,e,r,n=[""],i,o){const{padding:a,color:s,fontFamily:c,fontSize:l,background:f}=o;let u;const[d,h]=[i[0]+a,i[1]+a],g="http://www.w3.org/2000/svg",p=hl(e,"text",r),v=t.getSvgNode(p);if(v){const y=v.querySelector("text"),m=Array.from(y.children);for(let C=0;C<m.length;C++){const S=m[C],T=n[C]||"";S.textContent=T}if(n.length>m.length){for(let C=0;C<n.length-m.length;C++){const S=n[C+m.length],T=SI(S);y.appendChild(T)}v.appendChild(y),t.appendNode(v,p)}const w={fill:s,"font-size":l,"font-family":c},x={transform:`translate(${d} ${h})`};za(w,y),za(x,v),v.setAttribute("data-annotation-uid",e),u=TI(v,f),t.setNodeTouched(p)}else{const y=document.createElementNS(g,"g");y.setAttribute("data-annotation-uid",e),y.setAttribute("transform",`translate(${d} ${h})`);const m=Rme(t,o);for(let w=0;w<n.length;w++){const x=n[w],C=SI(x);m.appendChild(C)}y.appendChild(m),t.appendNode(y,p),u=TI(y,f)}return Object.assign({},u,{x:d,y:h,height:u.height+a,width:u.width+a})}function Rme(t,e){const{color:r,fontFamily:n,fontSize:i}=e,a=document.createElementNS("http://www.w3.org/2000/svg","text"),s="user-select: none; pointer-events: none; -webkit-tap-highlight-color: rgba(255, 255, 255, 0);",c=`filter:url(#shadow-${t.svgLayerElement.id});`,l=`${s}${c}`;return a.setAttribute("x","0"),a.setAttribute("y","0"),a.setAttribute("fill",r),a.setAttribute("font-family",n),a.setAttribute("font-size",i),a.setAttribute("style",l),a.setAttribute("pointer-events","visible"),a}function SI(t){const r=document.createElementNS("http://www.w3.org/2000/svg","tspan");return r.setAttribute("x","0"),r.setAttribute("dy","1.2em"),r.textContent=t,r}function TI(t,e){let r=t.querySelector("rect.background");if(!e)return r&&t.removeChild(r),t.getBBox();r||(r=document.createElementNS("http://www.w3.org/2000/svg","rect"),r.setAttribute("class","background"),t.insertBefore(r,t.firstChild));const n=t.getBBox(),i={x:`${n.x}`,y:`${n.y}`,width:`${n.width}`,height:`${n.height}`,fill:e};return za(i,r),n}function Lme(t,e,r,n,i,o,a={}){const s=n.length>0?$S(n,i):i,c=Ame(o),l=$S(c,s),f=Object.assign({color:"rgb(255, 255, 0)",lineWidth:"1",lineDash:"2,3"},a);an(t,e,`link-${r}`,s,l,f)}function Ame(t){const{x:e,y:r,height:n,width:i}=t,o=i/2,a=n/2,s=[e+o,r],c=[e,r+a],l=[e+o,r+n],f=[e+i,r+a];return[s,c,l,f]}function Ji(t,e,r,n,i,o,a,s={}){const c=Object.assign({handleRadius:"6",centering:{x:!1,y:!0}},s),l=df(t,e,r,n,i,c);return Lme(t,e,r,o,i,l,c),l}function n8(t,e,r,n,i={},o=""){const{color:a,width:s,lineWidth:c,lineDash:l}=Object.assign({color:"rgb(0, 255, 0)",width:"2",lineWidth:void 0,lineDash:void 0},i),f=c||s,u="http://www.w3.org/2000/svg",d=hl(e,"rect",r),h=t.getSvgNode(d),[g,p,v,y]=n,m=Math.hypot(g[0]-p[0],g[1]-p[1]),w=Math.hypot(g[0]-v[0],g[1]-v[1]),x=[(y[0]+g[0])/2,(y[1]+g[1])/2],C=[(v[0]+g[0])/2,(v[1]+g[1])/2],S=Math.atan2(x[1]-C[1],x[0]-C[0])*180/Math.PI,T={x:`${x[0]-m/2}`,y:`${x[1]-w/2}`,width:`${m}`,height:`${w}`,stroke:a,fill:"transparent",transform:`rotate(${S} ${x[0]} ${x[1]})`,"stroke-width":f,"stroke-dasharray":l};if(h)za(T,h),t.setNodeTouched(d);else{const _=document.createElementNS(u,"rect");o!==""&&_.setAttribute("data-id",o),gl(T,_),t.appendNode(_,d)}}function bm(t,e,r,n,i,o={},a=""){const s=[n[0],n[1]],c=[i[0],n[1]],l=[n[0],i[1]],f=[i[0],i[1]];n8(t,e,r,[s,c,l,f],o,a)}const _I="http://www.w3.org/2000/svg";function f5(t,e,r,n,i,o={}){if(isNaN(n[0])||isNaN(n[1])||isNaN(i[0])||isNaN(i[1]))return;const{viaMarker:a=!1,color:s="rgb(0, 255, 0)",markerSize:c=10}=o;if(!a){Nme(t,e,r,n,i,o);return}const l=t.svgLayerElement.id,u=`${`arrow-${e}`}-${l}`,d=t.svgLayerElement.querySelector("defs");let h=d.querySelector(`#${u}`);if(h){h.setAttribute("markerWidth",`${c}`),h.setAttribute("markerHeight",`${c}`);const g=h.querySelector("path");g&&g.setAttribute("fill",s)}else{h=document.createElementNS(_I,"marker"),h.setAttribute("id",u),h.setAttribute("viewBox","0 0 10 10"),h.setAttribute("refX","8"),h.setAttribute("refY","5"),h.setAttribute("markerWidth",`${c}`),h.setAttribute("markerHeight",`${c}`),h.setAttribute("orient","auto");const g=document.createElementNS(_I,"path");g.setAttribute("d","M 0 0 L 10 5 L 0 10 z"),g.setAttribute("fill",s),h.appendChild(g),d.appendChild(h)}o.markerEndId=u,an(t,e,r,n,i,o)}function Nme(t,e,r,n,i,o={}){const{color:a="rgb(0, 255, 0)",width:s=2,lineWidth:c,lineDash:l}=o,f=10,u=Math.atan2(i[1]-n[1],i[0]-n[0]),d={start:[i[0]-f*Math.cos(u-Math.PI/7),i[1]-f*Math.sin(u-Math.PI/7)],end:i},h={start:[i[0]-f*Math.cos(u+Math.PI/7),i[1]-f*Math.sin(u+Math.PI/7)],end:i};an(t,e,r,n,i,{color:a,width:s,lineWidth:c,lineDash:l}),an(t,e,"2",d.start,d.end,{color:a,width:s,lineWidth:c,lineDash:l}),an(t,e,"3",h.start,h.end,{color:a,width:s,lineWidth:c,lineDash:l})}function XU(t,e,r,n,i,o={}){const{color:a,width:s,lineWidth:c,lineDash:l}=Object.assign({color:"rgb(0, 255, 0)",width:"2",lineWidth:void 0,lineDash:void 0},o),f=c||s,u="http://www.w3.org/2000/svg",d=hl(e,"rect",r),h=t.getSvgNode(d),g=[Math.min(n[0],i[0]),Math.min(n[1],i[1])],p=Math.abs(n[0]-i[0]),v=Math.abs(n[1]-i[1]),y={x:`${g[0]}`,y:`${g[1]}`,width:`${p}`,height:`${v}`,stroke:a,fill:"black","stroke-width":f,"stroke-dasharray":l};if(h)za(y,h),t.setNodeTouched(d);else{const m=document.createElementNS(u,"rect");gl(y,m),t.appendNode(m,d)}}const kme=Object.freeze(Object.defineProperty({__proto__:null,draw:KU,drawArrow:f5,drawCircle:Yo,drawEllipse:Mme,drawEllipseByCoordinates:t8,drawFan:HS,drawHandle:u5,drawHandles:Kn,drawHeight:qU,drawLine:an,drawLinkedTextBox:Ji,drawPath:Kl,drawPolyline:dc,drawRect:bm,drawRectByCoordinates:n8,drawRedactionRect:XU,drawTextBox:df,setAttributesIfNecessary:za,setNewAttributesIfValid:gl},Symbol.toStringTag,{value:"Module"}));function YU(t,e){const r=Le(t),{renderingEngineId:n,viewportId:i}=r,o=vr(i,n);if(!o)return[];const a=[],s=Object.keys(o.toolOptions);for(let c=0;c<s.length;c++){const l=s[c],f=o.toolOptions[l];if(f&&e.includes(f.mode)){const u=o.getToolInstance(l);a.push(u)}}return a}const{Active:Vme,Passive:Fme,Enabled:Ume}=En;class Bme{constructor(){this._needsRender=new Set,this._animationFrameSet=!1,this._animationFrameHandle=null,this._renderFlaggedViewports=()=>{this._throwIfDestroyed();const e=Array.from(this._viewportElements.values());for(let r=0;r<e.length;r++){const n=e[r];if(this._needsRender.has(n)&&(this._triggerRender(n),this._needsRender.delete(n),this._needsRender.size===0))break}this._animationFrameSet=!1,this._animationFrameHandle=null,this._render()},this._viewportElements=new Map}addViewportElement(e,r){this._viewportElements.set(e,r)}removeViewportElement(e,r){this._viewportElements.delete(e),this._needsRender.delete(r),this._reset()}renderViewport(e){this._setViewportsToBeRenderedNextFrame([e])}_throwIfDestroyed(){if(this.hasBeenDestroyed)throw new Error("this.destroy() has been manually called to free up memory, can not longer use this instance. Instead make a new one.")}_setAllViewportsToBeRenderedNextFrame(){[...this._viewportElements.values()].forEach(r=>{this._needsRender.add(r)}),this._renderFlaggedViewports()}_setViewportsToBeRenderedNextFrame(e){const r=[...this._viewportElements.values()];e.forEach(n=>{r.indexOf(n)!==-1&&this._needsRender.add(n)}),this._render()}_render(){this._needsRender.size>0&&this._animationFrameSet===!1&&(this._animationFrameHandle=window.requestAnimationFrame(this._renderFlaggedViewports),this._animationFrameSet=!0)}_triggerRender(e){const r=Le(e);if(!r)return;if(!Nr(r.renderingEngineId)){console.warn("rendering Engine has been destroyed");return}const i=YU(e,[Vme,Fme,Ume]),{renderingEngineId:o,viewportId:a}=r,s={element:e,renderingEngineId:o,viewportId:a};KU(e,c=>{let l=!1;const f=u=>{if(u.renderAnnotation){const d=u.renderAnnotation(r,c);l=l||d}};i.forEach(f),l&&it(e,U.ANNOTATION_RENDERED,{...s})})}_reset(){window.cancelAnimationFrame(this._animationFrameHandle),this._needsRender.clear(),this._animationFrameSet=!1,this._animationFrameHandle=null,this._setAllViewportsToBeRenderedNextFrame()}}const r8=new Bme;function Zh(t){r8.renderViewport(t)}function We(t){t.length&&t.forEach(e=>{const r=Mn(e);if(!r){console.warn(`Viewport not available for ${e}`);return}const{viewport:n}=r;if(!n){console.warn(`Viewport not available for ${e}`);return}const i=n.element;Zh(i)})}function JU(t,e){const r=t.length,n=[];for(let i=0;i<r;i++){const o=t[i];o.getFrameOfReferenceUID()===e&&n.push(o)}return n}const{Active:Gme,Passive:Wme,Enabled:zme}=En;function Fw(t,e){const r=t.length,n=[];for(let i=0;i<r;i++){const o=t[i],a=vr(o.id,o.renderingEngineId);if(!a)continue;$me(a,e)&&n.push(o)}return n}function $me(t,e){const{toolOptions:r}=t,n=r[e];if(!n)return!1;const i=n.mode;return i===Gme||i===Wme||i===zme}function ZU(t,e,r=.999){return t.filter(n=>{const i=n.getCamera();return Math.abs(xt(i.viewPlaneNormal,e.viewPlaneNormal))>r})}function wt(t,e,r=!0){const n=Le(t),{renderingEngine:i,FrameOfReferenceUID:o}=n;let a=i.getViewports();a=JU(a,o),a=Fw(a,e);const s=i.getViewport(n.viewportId);return r&&(a=ZU(a,s.getCamera())),a.map(l=>l.id)}const jme=Object.freeze(Object.defineProperty({__proto__:null,filterViewportsWithFrameOfReferenceUID:JU,filterViewportsWithParallelNormals:ZU,filterViewportsWithToolEnabled:Fw,getViewportIdsWithToolToRender:wt},Symbol.toStringTag,{value:"Module"})),d5="PlanarFreehandContourSegmentationTool";function hf(t,e){const r=t.length,n=new Array(r);for(let i=0;i<r;i++)n[i]=e.worldToCanvas(t[i]);return n}function i8(t,e){const r=t.length,n=new Array(r);for(let i=0;i<r;i++)n[i]=e.canvasToWorld(t[i]);return n}function Uw(t,e){const r=ff(t),n=ff(e);if(!HE(r,n))return{hasIntersection:!1,isContourHole:!1};const o=JE(t,e),a=!o&&_m(e,t);return{hasIntersection:o||a,isContourHole:a}}function QU(t,e){return wm(e).map(r=>{const n=r,i=hf(n.data.contour.polyline,t);return{annotation:n,polyline:i}})}function Bw(t,e,r){ym(e,r),tu(r);const{contour:n}=r.data,i=hf(n.polyline,t);vc(r,{points:i,closed:n.closed,targetWindingDirection:e.data.contour.windingDirection===Xo.Clockwise?Xo.CounterClockwise:Xo.Clockwise},t);const{element:o}=t;a8(t,[e,r])}function o8(t,e,r,n,i){var m;if(!Mw(d5)){console.warn(`${d5} is not registered in cornerstone. Cannot combine polylines.`);return}const o=i[0],a=uf(r,o),s=QU(t,e),c=new Set(s),l=new Map,f=(w,x)=>{let C=l.get(w);C||(C=[],l.set(w,C)),C.push(x),c.delete(x)},u=[];if(a){const w=kw(r,i);u.push(w),Array.from(c.keys()).forEach(x=>f(w,x))}else Vw(r,i).forEach(x=>{u.push(x),Array.from(c.keys()).forEach(C=>{_m(x,C.polyline)&&f(x,C)})});Array.from(l.values()).forEach(w=>w.forEach(x=>Ow(x.annotation)));const{element:d}=t,{metadata:h,data:g}=e,{handles:p,segmentation:v}=g,{textBox:y}=p;en(n.annotationUID),en(e.annotationUID),tu(n),tu(e);for(let w=0;w<u.length;w++){const x=u[w];if(!x||x.length<3){console.warn("Skipping creation of new annotation due to invalid polyline:",x);continue}const C=eB(t,e,x);qt(C,d),nu(C),Kt(C,t.element),(m=l.get(x))==null||m.forEach(S=>ym(C,S.annotation))}a8(t,[e,n])}function eB(t,e,r){const n=t.canvasToWorld(r[0]),i=t.canvasToWorld(r[r.length-1]),o={metadata:{...e.metadata,toolName:d5,originalToolName:e.metadata.originalToolName||e.metadata.toolName},data:{cachedStats:{},handles:{points:[n,i],textBox:e.data.handles.textBox?{...e.data.handles.textBox}:void 0},contour:{polyline:[],closed:!0},spline:e.data.spline,segmentation:{...e.data.segmentation}},annotationUID:gn(),highlighted:!0,invalidated:!0,isLocked:!1,isVisible:void 0,interpolationUID:e.interpolationUID,interpolationCompleted:e.interpolationCompleted};return vc(o,{points:r,closed:!0,targetWindingDirection:Xo.Clockwise},t),o}function a8(t,e){const{element:r}=t,n=new Set([d5]);e.forEach(i=>{n.add(i.metadata.toolName)});for(const i of n.values())if(Mw(i)){const o=wt(r,i);We(o)}}function Gw(t,e){const r=[],n=new Set,i=new Set;for(let o=0;o<t.length;o++){if(n.has(o))continue;const a=t[o];let s=!1;for(let c=0;c<e.length;c++){if(i.has(c))continue;const l=e[c],f=Uw(a,l);if(f.hasIntersection&&!f.isContourHole){const u=kw(a,l);r.push(u),n.add(o),i.add(c),s=!0;break}}s||(r.push([...a]),n.add(o))}for(let o=0;o<e.length;o++)i.has(o)||r.push([...e[o]]);return r}function Hme(t){if(t.length===0)return[];if(t.length===1)return t[0].map(r=>[...r]);let e=t[0].map(r=>[...r]);for(let r=1;r<t.length;r++)e=Gw(e,t[r]);return e}function Kme(t,e,r){const n=t.map(o=>h5(o.data.contour.polyline,r)),i=e.map(o=>h5(o.data.contour.polyline,r));return Gw(n,i)}function h5(t,e){const r=t.length,n=new Array(r);for(let i=0;i<r;i++)n[i]=e.worldToCanvas(t[i]);return n}function Ww(t,e){const r=[],n=new Set;for(let i=0;i<t.length;i++){if(n.has(i))continue;let o=[t[i]];for(let a=0;a<e.length;a++){const s=e[a],c=[];for(const l of o){const f=Uw(l,s);if(f.hasIntersection&&!f.isContourHole){const u=Vw(l,s);c.push(...u)}else c.push(l)}o=c}r.push(...o),n.add(i)}return r}function qme(t,e){if(e.length===0)return t.map(n=>[...n]);let r=t.map(n=>[...n]);for(let n=0;n<e.length;n++)r=Ww(r,e[n]);return r}function Xme(t,e,r){const n=t.map(o=>h5(o.data.contour.polyline,r)),i=e.map(o=>h5(o.data.contour.polyline,r));return Ww(n,i)}const Yme="PlanarFreehandContourSegmentationTool";function tB(t,e,r,n){const i=new Map;return r.forEach(o=>{if(o.length<3)return;const a={annotationUID:gn(),data:{contour:{closed:!0,polyline:o},segmentation:{segmentationId:e,segmentIndex:n},handles:{}},handles:{},highlighted:!1,autoGenerated:!1,invalidated:!1,isLocked:!1,isVisible:!0,metadata:{toolName:Yme,...t.getViewReference()}};qt(a,t.element);const s=(i==null?void 0:i.get(n))||new Set;s.add(a.annotationUID),i.set(n,s)}),i}function EI(t,e){const r=[],{annotationUIDsMap:n}=t,i=n.get(e);for(const o of i){const a=kr(o),{polyline:s}=a.data.contour;r.push(s)}return r}function nB(t,e,r,n){if(!e||!e.representationData.Contour)return;const i=e.representationData.Contour,{annotationUIDsMap:o}=i;if(!o||!o.get(r)||!o.get(n))return;const a=EI(i,r),s=EI(i,n),c=a.map(f=>hf(f,t)),l=s.map(f=>hf(f,t));return{polyLinesCanvas1:c,polyLinesCanvas2:l}}function Jme(t,e,r,n,{name:i,segmentIndex:o,color:a}){const{polyLinesCanvas1:s,polyLinesCanvas2:c}=nB(t,e,r,n)||{};if(!s||c)return;const f=Gw(s,c).map(g=>i8(g,t)),u=tB(t,e.segmentationId,f,o),d=e.representationData.Contour,{annotationUIDsMap:h}=d;h&&h.set(o,u.get(o))}function Zme(t,e,r,n,{name:i,segmentIndex:o,color:a}){const{polyLinesCanvas1:s,polyLinesCanvas2:c}=nB(t,e,r,n)||{};if(!s||c)return;const f=Ww(s,c).map(g=>i8(g,t)),u=tB(t,e.segmentationId,f,o),d=e.representationData.Contour,{annotationUIDsMap:h}=d;h&&h.set(o,u.get(o))}function Dm(t){var e;return!!((e=t.data)!=null&&e.segmentation)}function rB(t,e,r){const n=[],i=ff(e);for(let o=0;o<r.length;o++){const a=r[o],s=Qme(a.data.contour.polyline,t),c=ff(s);if(!HE(i,c))continue;const f=JE(e,s),u=!f&&_m(s,e);(f||u)&&n.push({targetAnnotation:a,targetPolyline:s,isContourHole:u})}return n}function Qme(t,e){const r=t.length,n=new Array(r);for(let i=0;i<r;i++)n[i]=e.worldToCanvas(t[i]);return n}const g5="PlanarFreehandContourSegmentationTool";function iB(t,e,r,n){const i=n.filter(a=>a.isContourHole),o=n.filter(a=>!a.isContourHole);if(i.length>0){const a=i[0];i2e(t,a.targetAnnotation,e),oB(t,[e,a.targetAnnotation]);return}if(o.length!==0){if(!Mw(g5)){console.warn(`${g5} is not registered in cornerstone. Cannot process multiple intersections.`);return}e2e(t,e,r,o)}}function e2e(t,e,r,n){const{element:i}=t,o=[e],a=[],s=[];n.forEach(({targetAnnotation:d})=>{const h=r2e(t,d);s.push(...h),o.push(d)});const c=r[0];if(n.some(({targetPolyline:d})=>uf(d,c))){let d=r;n.forEach(({targetPolyline:h})=>{d=kw(d,h)}),a.push(d)}else n.forEach(({targetPolyline:d})=>{const h=Vw(d,r);a.push(...h)});o.forEach(d=>{en(d.annotationUID),tu(d)}),s.forEach(d=>Ow(d.annotation));const f=n[0].targetAnnotation,u=[];a.forEach(d=>{if(!d||d.length<3){console.warn("Skipping creation of new annotation due to invalid polyline:",d);return}const h=t2e(t,f,d);qt(h,i),nu(h),Kt(h,t.element),u.push(h)}),n2e(t,s,u),oB(t,o)}function t2e(t,e,r){const n=t.canvasToWorld(r[0]),i=t.canvasToWorld(r[r.length-1]),o={metadata:{...e.metadata,toolName:g5,originalToolName:e.metadata.originalToolName||e.metadata.toolName},data:{cachedStats:{},handles:{points:[n,i],textBox:e.data.handles.textBox?{...e.data.handles.textBox}:void 0},contour:{polyline:[],closed:!0},spline:e.data.spline,segmentation:{...e.data.segmentation}},annotationUID:gn(),highlighted:!0,invalidated:!0,isLocked:!1,isVisible:void 0,interpolationUID:e.interpolationUID,interpolationCompleted:e.interpolationCompleted};return vc(o,{points:r,closed:!0,targetWindingDirection:Xo.Clockwise},t),o}function n2e(t,e,r){e.forEach(n=>{const i=r.find(o=>{const a=s8(o.data.contour.polyline,t);return _m(a,n.polyline)});i&&ym(i,n.annotation)})}function r2e(t,e){return wm(e).map(r=>{const n=r,i=s8(n.data.contour.polyline,t);return{annotation:n,polyline:i}})}function i2e(t,e,r){ym(e,r),tu(r);const{contour:n}=r.data,i=s8(n.polyline,t);vc(r,{points:i,closed:n.closed,targetWindingDirection:e.data.contour.windingDirection===Xo.Clockwise?Xo.CounterClockwise:Xo.Clockwise},t)}function s8(t,e){const r=t.length,n=new Array(r);for(let i=0;i<r;i++)n[i]=e.worldToCanvas(t[i]);return n}function oB(t,e){const{element:r}=t,n=new Set([g5]);e.forEach(i=>{n.add(i.metadata.toolName)});for(const i of n.values())if(Mw(i)){const o=wt(r,i);We(o)}}const{isEqual:bI}=pn;function c8(t){const{metadata:e}=t;return IV().filter(r=>{if(r.FrameOfReferenceUID===e.FrameOfReferenceUID){const n=r.viewport,{viewPlaneNormal:i,viewUp:o}=n.getCamera();return bI(i,e.viewPlaneNormal)&&(!e.viewUp||bI(o,e.viewUp))}}).map(r=>r.viewport)}async function o2e(t,e,r,n=!0){const i=typeof t=="string"?kr(t):t,o=typeof e=="string"?kr(e):e;if(!i||!o)throw new Error("Both source and target annotations must be valid");r||(r=a2e(i));const a=hf(i.data.contour.polyline,r),s=hf(o.data.contour.polyline,r),c=Uw(a,s);if(!c.hasIntersection){console.warn("No intersection found between the two annotations");return}if(c.isContourHole){if(!n){console.warn("Hole processing is disabled");return}Bw(r,o,i)}else o8(r,o,s,i,a)}function a2e(t){const e=c8(t);if(!e.length)throw new Error("No viewport found for the annotation");return e[0]}const s2e=Object.freeze(Object.defineProperty({__proto__:null,addContourSegmentationAnnotation:nu,addition:Jme,areSameSegment:yU,checkIntersection:Uw,combinePolylines:o8,contourSegmentationOperation:o2e,convertContourPolylineToCanvasSpace:hf,convertContourPolylineToWorld:i8,convertContourSegmentationAnnotation:jE,createNewAnnotationFromPolyline:eB,createPolylineHole:Bw,findAllIntersectingContours:rB,getContourHolesData:QU,isContourSegmentationAnnotation:Dm,processMultipleIntersections:iB,removeContourSegmentationAnnotation:tu,subtractAnnotationPolylines:Xme,subtractMultiplePolylineSets:qme,subtractPolylineSets:Ww,subtraction:Zme,unifyAnnotationPolylines:Kme,unifyMultiplePolylineSets:Hme,unifyPolylineSets:Gw,updateViewportsForAnnotations:a8},Symbol.toStringTag,{value:"Module"}));function c2e(t){if(!t)throw new Error(`No contours found for geometryId ${t.id}`);const e=t.id;if(t.type!==Kc.CONTOUR)throw new Error(`Geometry type ${t.type} not supported for rendering.`);if(!t.data){console.warn(`No contours found for geometryId ${e}. Skipping render.`);return}}function l2e(t,e,r,n){r.size?t.render():u2e(t,e,n)}function u2e(t,e,r){const{segmentationId:n}=r,i=new Map;e.forEach(o=>{const a=$e.getGeometry(o);if(!a){console.warn(`No geometry found for geometryId ${o}. Skipping render.`);return}const s=a.data.segmentIndex;c2e(a);const c=Ua.getStyle({viewportId:t.id,segmentationId:n,type:St.Contour,segmentIndex:s}),l=a.data,f=t.getCamera().viewPlaneNormal;l.contours.forEach(u=>{const{points:d,color:h,id:g}=u,p=WE(t,d[0],f),v={annotationUID:gn(),data:{contour:{closed:!0,polyline:d},segmentation:{segmentationId:n,segmentIndex:s,color:h,id:g},handles:{}},handles:{},highlighted:!1,autoGenerated:!1,invalidated:!1,isLocked:!0,isVisible:!0,metadata:{referencedImageId:p,toolName:"PlanarFreehandContourSegmentationTool",FrameOfReferenceUID:t.getFrameOfReferenceUID(),viewPlaneNormal:t.getCamera().viewPlaneNormal}},y=t.element;qt(v,y),nu(v)}),c&&i.set(s,c)}),t.render()}function f2e(t,e,r=!1){const n=_n(e),{annotationUIDsMap:i}=n.representationData.Contour;i.forEach(o=>{o.forEach(a=>{en(a)})})}function aB(t){const e=r1e(t);if(e)return e;const r=_n(t);if(!r)throw new Error(`No segmentation found for segmentationId ${t}`);let n;if(r.representationData.Labelmap)n=d2e(r,t);else if(r.representationData.Contour)n=p2e(r);else if(r.representationData.Surface)n=m2e(r);else throw new Error(`Unsupported segmentation type: ${r.representationData}`);return i1e(t,n),n}function d2e(t,e){const r=t.representationData[St.Labelmap],n=new Set;return r.imageIds?g2e(n,r.imageIds):h2e(n,e),Array.from(n).map(Number).sort((i,o)=>i-o)}function h2e(t,e){$e.getVolume(e).voxelManager.forEach(({value:n})=>{n!==0&&t.add(n)})}function g2e(t,e){e.forEach(r=>{$e.getImage(r).voxelManager.getScalarData().forEach(o=>{o!==0&&t.add(o)})})}function p2e(t){const{annotationUIDsMap:e,geometryIds:r}=t.representationData.Contour||{};if(!r)throw new Error(`No geometryIds found for segmentationId ${t.segmentationId}`);const n=new Set([...e.keys()]);return r.forEach(i=>{const o=$e.getGeometry(i);n.add(o.data.segmentIndex)}),Array.from(n).sort((i,o)=>i-o)}function m2e(t){var r;const e=((r=t.representationData.Surface)==null?void 0:r.geometryIds)??[];return Array.from(e.keys()).map(Number).sort((n,i)=>n-i)}const i0=new Map,DI=new Map;function v2e(t,e,r=!1){const n=Mn(t);if(!n)return;const{viewport:i}=n;f2e(t,e),r&&i.render()}async function y2e(t,e){var l,f;const{segmentationId:r}=e,n=_n(r);if(!n)return;let i=n.representationData[St.Contour];const o=Hl();if(!i&&((l=Hl())!=null&&l.canComputeRequestedRepresentation(r,St.Contour))&&!i0.get(t.id)?(i0.set(t.id,!0),i=await BE(r,St.Contour,()=>o.computeContourData(r,{viewport:t}),()=>{}),i0.set(t.id,!1)):!i&&!Hl()&&console.debug(`No contour data found for segmentationId ${r} and PolySeg add-on is not configured. Unable to convert from other representations to contour. Please register PolySeg using cornerstoneTools.init({ addons: { polySeg } }) to enable automatic conversion.`),!i||!((f=i.geometryIds)!=null&&f.length))return;let a=!1;const s=t.getCamera().viewPlaneNormal;i.annotationUIDsMap&&(a=!x2e(i.annotationUIDsMap,s)),i.geometryIds.length>0&&(a=!w2e(i.geometryIds,s));const c=DI.get(t.id)||new Set;if(a&&!i0.get(t.id)&&!c.has(r)&&t.viewportStatus===_o.RENDERED){i0.set(t.id,!0);const u=aB(r),h=(await o.computeSurfaceData(r,{segmentIndices:u,viewport:t})).geometryIds,g=[];for(const m of h.values()){const x=$e.getGeometry(m).data;g.push({points:x.points,polys:x.polys,segmentIndex:x.segmentIndex,id:x.segmentIndex})}const p=await o.clipAndCacheSurfacesForViewport(g,t),v=o.extractContourData(p),y=o.createAndAddContourSegmentationsFromClippedSurfaces(v,t,r);i.annotationUIDsMap=new Map([...i.annotationUIDsMap,...y]),c.add(r),DI.set(t.id,c),i0.set(t.id,!1)}l2e(t,i.geometryIds,i.annotationUIDsMap,e)}function w2e(t,e){var u,d,h;let r=null,n=null;for(const g of t){const p=$e.getGeometry(g);if(!p)continue;const v=p.data;if(((h=(d=(u=v.contours)==null?void 0:u[0])==null?void 0:d.points)==null?void 0:h.length)>=3){r=p,n=v;break}}if(!r||!n)return!1;const o=n.contours[0].points,a=o[0],s=o[1],c=o[2];let l=Tn(Ke(),hn(Ke(),s,a),hn(Ke(),c,a));l=Un(Ke(),l);const f=xt(l,e);return Math.abs(f)>.9}function x2e(t,e){const r=Array.from(t.values()).flat().map(i=>Array.from(i)).flat(),n=mE(r,3);for(const i of n){const o=kr(i);if(o!=null&&o.metadata){if(!o.metadata.viewPlaneNormal)continue;const a=o.metadata.viewPlaneNormal,s=Math.abs(e[0]*a[0]+e[1]*a[1]+e[2]*a[2]);if(Math.abs(s-1)>.01)return!1}}return!0}const sB={render:y2e,removeRepresentation:v2e};function _f(t,e){return iu(t,e)[0]}function iu(t,e){return $n.getCurrentLabelmapImageIdsForViewport(t,e)}function C2e(t,e){return $n.getLabelmapImageIdsForImageId(t,e)}const II=new Map,S2e=({cfun:t,ofun:e,actor:r})=>{r.getProperty().setRGBTransferFunction(1,t),r.getProperty().setScalarOpacity(1,e)};async function T2e({viewport:t,volumeInputs:e,segmentationId:r}){var E;const n=t.getDefaultActor(),{actor:i}=n,{uid:o,callback:a}=n,s=t.getVolumeId();if((E=II.get(o))!=null&&E.added)return{uid:o,actor:i};const c=e,l=$e.getVolume(c[0].volumeId);if(!l)throw new Error(`imageVolume with id: ${l.volumeId} does not exist`);const{volumeId:f}=c[0],u=await J4(f);if(!u)throw new Error(`segImageVolume with id: ${u.volumeId} does not exist`);const h=u.voxelManager.getCompleteScalarDataArray(),{imageData:g}=u,p=$e.getVolume(s),y=p.voxelManager.getCompleteScalarDataArray(),m=2,w=new Float32Array(m*p.voxelManager.getScalarDataLength()),x=g.getDimensions();for(let b=0;b<x[2];++b)for(let D=0;D<x[1];++D)for(let I=0;I<x[0];++I){const P=I+x[0]*(D+x[1]*b);w[P*m+0]=y[P],w[P*m+1]=h[P]}t.removeActors([o]);const C=i.getMapper(),S=Ek(C);i.setMapper(S),S.setBlendMode(Hc.LABELMAP_EDGE_PROJECTION_BLEND);const T=S.getInputData().getPointData().getArray(0);T.setData(w),T.setNumberOfComponents(2),i.getProperty().setColorMixPreset(1),i.getProperty().setForceNearestInterpolation(1,!0),i.getProperty().setIndependentComponents(!0),t.addActor({actor:i,uid:o,callback:a,referencedId:s,representationUID:`${r}-${St.Labelmap}`}),II.set(o,{added:!0,segmentationRepresentationUID:`${r}`,originalBlendMode:t.getBlendMode()}),i.set({preLoad:S2e});function _(b){const{segmentationId:D}=b.detail,{representationData:I}=_n(D),{volumeId:P}=I.Labelmap;if(P!==u.volumeId)return;const L=$e.getVolume(P).voxelManager,B=S.getInputData(),H=B.getPointData().getArray(0),A=H.getData(),F=2,G=g.getDimensions(),X=Array.from({length:G[2]},(ee,ce)=>ce);for(const ee of X)for(let ce=0;ce<G[1];++ce)for(let Se=0;Se<G[0];++Se){const we=Se+G[0]*(ce+G[1]*ee);A[we*F+1]=L.getAtIndex(we)}H.setData(A),B.modified(),t.render()}return Ze.addEventListenerDebounced(U.SEGMENTATION_DATA_MODIFIED,_,200),Ze.addEventListener(U.SEGMENTATION_REPRESENTATION_REMOVED,async b=>{Ze.removeEventListener(U.SEGMENTATION_DATA_MODIFIED,_);const D=t.getActor(o),{element:I,id:P}=t;t.removeActors([o]);const O=await By({volumeId:o,blendMode:Hc.MAXIMUM_INTENSITY_BLEND,callback:({volumeActor:L})=>{D.callback&&D.callback({volumeActor:L,volumeId:f})}},I,P);t.addActor({actor:O,uid:o}),t.render()}),{uid:o,actor:i}}const{uuidv4:cB}=pn;async function _2e(t,e,r,n){const i=Le(t),{renderingEngine:o,viewport:a}=i,{id:s}=a,c=!0,l=!1,f=!0;if(a instanceof fr){const d=E2e(e,r);$e.getVolume(d)||await b2e(e);let h=(n==null?void 0:n.blendMode)??Hc.MAXIMUM_INTENSITY_BLEND,g=h===Hc.LABELMAP_EDGE_PROJECTION_BLEND;if(g){const v=a.getVolumeId(),y=$e.getVolume(v),w=$e.getVolume(d).dimensions,x=y.dimensions;(w[0]!==x[0]||w[1]!==x[1]||w[2]!==x[2])&&(g=!1,h=Hc.MAXIMUM_INTENSITY_BLEND,console.debug("Dimensions mismatch - falling back to regular volume addition"))}const p=[{volumeId:d,visibility:c,representationUID:`${r}-${St.Labelmap}`,useIndependentComponents:g,blendMode:h}];if(!p[0].useIndependentComponents)await Kk(o,p,[s],l,f);else return await T2e({viewport:a,volumeInputs:p,segmentationId:r})}else{const d=iu(a.id,r).map(h=>({imageId:h,representationUID:`${r}-${St.Labelmap}-${h}`}));qk(o,d,[s])}lo(r)}function E2e(t,e){let{volumeId:r}=t;if(!r){r=cB();const n=_n(e);n.representationData.Labelmap={...n.representationData.Labelmap,volumeId:r},t.volumeId=r,Ka(e)}return r}async function b2e(t){const e=t;if(!(e.imageIds.length>0))throw new Error("cannot create labelmap, no imageIds found for the volume labelmap");return await Z4(t.volumeId||cB(),e.imageIds)}function D2e(t,e){const r=Le(t),{viewport:n}=r;n.removeActors([m1e(n.id,e)])}function Od(t){return $n.getActiveSegmentation(t)}function I2e(t,e){$n.setActiveSegmentation(t,e)}function lu(t){return Od(t)}function O2e(t,e){I2e(t,e)}const M2e=Object.freeze(Object.defineProperty({__proto__:null,getActiveSegmentation:lu,setActiveSegmentation:O2e},Symbol.toStringTag,{value:"Module"}));function va(t){const e=_n(t);if(e){const r=Object.keys(e.segments).find(n=>e.segments[n].active);return r?Number(r):void 0}}const DC=255,_p=new Map;let IC=!1;function P2e(t,e,r=!1){const n=Mn(t);if(_p.forEach((o,a)=>{a.includes(e)&&_p.delete(a)}),!n)return;const{viewport:i}=n;D2e(i.element,e),r&&i.render()}async function R2e(t,e){var s;const{segmentationId:r,config:n}=e,i=_n(r);if(!i){console.warn("No segmentation found for segmentationId: ",r);return}let o=i.representationData[St.Labelmap],a=Tp(t.id,r);if(!o&&((s=Hl())!=null&&s.canComputeRequestedRepresentation(r,St.Labelmap))&&!IC){IC=!0;const c=Hl();if(o=await BE(r,St.Labelmap,()=>c.computeLabelmapData(r,{viewport:t}),()=>null,()=>{$n.processLabelmapRepresentationAddition(t.id,r),setTimeout(()=>{lo(r)},0)}),!o)throw new Error(`No labelmap data found for segmentationId ${r}.`);IC=!1}else!o&&!Hl()&&console.debug(`No labelmap data found for segmentationId ${r} and PolySeg add-on is not configured. Unable to convert from other representations to labelmap. Please register PolySeg using cornerstoneTools.init({ addons: { polySeg } }) to enable automatic conversion.`);if(o){if(t instanceof Zn)a!=null&&a.length||await MI(t,o,r,n),a=Tp(t.id,r);else{const c=iu(t.id,r);if(!(c!=null&&c.length))return;a||await MI(t,o,r,n),a=Tp(t.id,r)}if(a!=null&&a.length)for(const c of a)L2e(t.id,c,e)}}function L2e(t,e,r){var C;const{segmentationId:n}=r,{cfun:i,ofun:o}=r.config,{colorLUTIndex:a}=r,s=lu(t),c=(s==null?void 0:s.segmentationId)===n,l=Ua.getStyle({viewportId:t,type:St.Labelmap,segmentationId:n}),f=Ua.getRenderInactiveSegmentations(t),u=Cm(a),d=Math.min(256,u.length),{outlineWidth:h,renderOutline:g,outlineOpacity:p,activeSegmentOutlineWidthDelta:v}=OI(l,c),y=GE(t,{segmentationId:n,type:St.Labelmap});for(let S=0;S<d;S++){const T=S,_=u[T],b=Ua.getStyle({viewportId:t,type:St.Labelmap,segmentationId:n,segmentIndex:T}),{fillAlpha:D,outlineWidth:I,renderFill:P,renderOutline:O}=OI(l,c,b),{forceOpacityUpdate:L,forceColorUpdate:B}=A2e(t,n,T,{fillAlpha:D,renderFill:P,renderOutline:O,segmentColor:_,outlineWidth:I,segmentsHidden:y,cfun:i,ofun:o});if(B&&i.addRGBPoint(T,_[0]/DC,_[1]/DC,_[2]/DC),L)if(P){const H=y.has(T)?0:_[3]/255*D;o.removePoint(T),o.addPointLong(T,H,.5,1)}else o.addPointLong(T,.01,.5,1)}o.setClamping(!1);const m=e.actor,{preLoad:w}=((C=m.get)==null?void 0:C.call(m,"preLoad"))||{preLoad:null};if(w?w({cfun:i,ofun:o,actor:m}):(m.getProperty().setRGBTransferFunction(0,i),m.getProperty().setScalarOpacity(0,o),m.getProperty().setInterpolationTypeToNearest()),g){m.getProperty().setUseLabelOutline(g),m.getProperty().setLabelOutlineOpacity(p);const S=va(r.segmentationId),T=new Array(d-1);for(let _=1;_<d;_++){if(y.has(_)){T[_-1]=0;continue}T[_-1]=_===S?h+v:h}m.getProperty().setLabelOutlineThickness(T),m.modified(),m.getProperty().modified(),m.getMapper().modified()}else m.getProperty().setLabelOutlineThickness(new Array(d-1).fill(0));const x=c||f;m.setVisibility(x)}function OI(t,e,r){const i={...t,...r||{}},o=e?i.fillAlpha:i.fillAlphaInactive,a=e?i.outlineWidth:i.outlineWidthInactive,s=e?i.renderFill:i.renderFillInactive,c=e?i.renderOutline:i.renderOutlineInactive,l=e?i.outlineOpacity:i.outlineOpacityInactive,f=i.activeSegmentOutlineWidthDelta;return{fillAlpha:o,outlineWidth:a,renderFill:s,renderOutline:c,outlineOpacity:l,activeSegmentOutlineWidthDelta:f}}function A2e(t,e,r,{fillAlpha:n,renderFill:i,renderOutline:o,segmentColor:a,outlineWidth:s,segmentsHidden:c,cfun:l,ofun:f}){const u=`${t}-${e}-${r}`,d=_p.get(u);if(!d)return _p.set(u,{fillAlpha:n,renderFill:i,renderOutline:o,outlineWidth:s,segmentColor:a.slice(),segmentsHidden:new Set(c),cfunMTime:l.getMTime(),ofunMTime:f.getMTime()}),{forceOpacityUpdate:!0,forceColorUpdate:!0};const{fillAlpha:h,renderFill:g,renderOutline:p,outlineWidth:v,segmentColor:y,segmentsHidden:m,cfunMTime:w,ofunMTime:x}=d,C=y[0]!==a[0]||y[1]!==a[1]||y[2]!==a[2],S=y[3]!==a[3]||h!==n||g!==i||p!==o||v!==s||m!==c;return(S||C)&&_p.set(u,{fillAlpha:n,renderFill:i,renderOutline:o,outlineWidth:s,segmentColor:a.slice(),segmentsHidden:new Set(c),cfunMTime:l.getMTime(),ofunMTime:f.getMTime()}),{forceOpacityUpdate:S,forceColorUpdate:C}}async function MI(t,e,r,n){return await _2e(t.element,e,r,n)||void 0}const lB={render:R2e,removeRepresentation:P2e},{DefaultHistoryMemo:U2}=hE,Lp=class Lp{constructor(e,r){const n=Lp.mergeDefaultProps(Lp.defaults,r),i=Ti(n,e),{configuration:o={},supportedInteractionTypes:a,toolGroupId:s}=i;this.toolGroupId=s,this.supportedInteractionTypes=a||[],this.configuration=Object.assign({},o),this.mode=En.Disabled}static mergeDefaultProps(e={},r){return r?Ti(e,r):e}get toolName(){return this.getToolName()}getToolName(){return this.constructor.toolName}applyActiveStrategy(e,r){var o;const{strategies:n,activeStrategy:i}=this.configuration;return(o=n[i])==null?void 0:o.call(this,e,r)}applyActiveStrategyCallback(e,r,n,...i){var s;const{strategies:o,activeStrategy:a}=this.configuration;if(!o[a])throw new Error(`applyActiveStrategyCallback: active strategy ${a} not found, check tool configuration or spellings`);return(s=o[a][n])==null?void 0:s.call(this,e,r,...i)}setConfiguration(e){this.configuration=Ti(this.configuration,e)}setActiveStrategy(e){this.setConfiguration({activeStrategy:e})}getTargetImageData(e){if(e.startsWith("imageId:")){const r=e.split("imageId:")[1],n=_r(r);let i=$y(n);return!i||!i.length||(i=i.filter(o=>o.getCurrentImageId()===r),!i||!i.length)?void 0:i[0].getImageData()}else if(e.startsWith("volumeId:")){const r=dl(e),n=cm(r);return!n||!n.length?void 0:n[0].getImageData()}else if(e.startsWith("videoId:")){const r=_r(e),n=$y(r);return!n||!n.length?void 0:n[0].getImageData()}else throw new Error('getTargetIdImage: targetId must start with "imageId:" or "volumeId:"')}getTargetId(e){var n;const r=(n=e.getViewReferenceId)==null?void 0:n.call(e);if(r)return r;throw new Error("getTargetId: viewport must have a getViewReferenceId method")}undo(){this.doneEditMemo(),U2.undo()}redo(){U2.redo()}static createZoomPanMemo(e){const r={pan:e.getPan(),zoom:e.getZoom()},n={restoreMemo:()=>{const i=e.getPan(),o=e.getZoom();e.setZoom(r.zoom),e.setPan(r.pan),e.render(),r.pan=i,r.zoom=o}};return U2.push(n),n}doneEditMemo(){var e,r;(r=(e=this.memo)==null?void 0:e.commitMemo)!=null&&r.call(e)&&U2.push(this.memo),this.memo=null}};Lp.defaults={configuration:{strategies:{},defaultStrategy:void 0,activeStrategy:void 0,strategyOptions:{}}};let ri=Lp;ri.toolName="BaseTool";const{isEqual:N2e}=pn,{EPSILON:k2e}=xf,V2e=1-k2e;function l8(t,e,r){var c;const{viewPlaneNormal:n}=e,i=t.filter(l=>{let f=l.metadata.viewPlaneNormal;if(!l.metadata.referencedImageId&&!f&&l.metadata.FrameOfReferenceUID){for(const d of l.data.handles.points){const h=hn(Ke(),d,e.focalPoint),g=xt(h,e.viewPlaneNormal);if(!N2e(g,0))return!1}return l.metadata.viewPlaneNormal=e.viewPlaneNormal,l.metadata.cameraFocalPoint=e.focalPoint,!0}if(!f){const{referencedImageId:d}=l.metadata,{imageOrientationPatient:h}=ct("imagePlaneModule",d),g=Tt(h[0],h[1],h[2]),p=Tt(h[3],h[4],h[5]);f=Ke(),Tn(f,g,p),l.metadata.viewPlaneNormal=f}const u=Math.abs(xt(n,f))>V2e;return f&&u});if(!i.length)return[];const o=r/2,{focalPoint:a}=e,s=[];for(const l of i){const f=l.data,u=f.handles.points[0]||((c=f.contour)==null?void 0:c.polyline[0]);if(!l.isVisible)continue;const d=Ke();if(!u){s.push(l);continue}hn(d,a,u);const h=xt(d,n);Math.abs(h)<o&&s.push(l)}return s}function Im(t,e,r={}){if(t instanceof Zn){const n=t.getCamera(),{spacingInNormalDirection:i}=Hh(t,n);return l8(e,n,i)}if(t instanceof Jn){const n=t.getCurrentImageId();if(!n)return[];const i=n.indexOf(":");r.imageURI=n.substring(i+1)}return e.filter(n=>n.isVisible?n.data.isCanvasAnnotation?!0:t.isReferenceViewable(n.metadata,r):!1)}function uB(t){if(t){if(t.data&&t.highlighted)return tc.Highlighted;if(Sm(t.annotationUID))return tc.Selected;if(Yr(t.annotationUID))return tc.Locked;if(t.data&&t.autoGenerated)return tc.AutoGenerated}return tc.Default}function F2e(t,e,r){const n=Dh("textBoxFontSize",t,e,r),i=Dh("textBoxFontFamily",t,e,r);return`${n}px ${i}`}const U2e=Object.freeze(Object.defineProperty({__proto__:null,getFont:F2e,getState:uB,style:IE},Symbol.toStringTag,{value:"Module"}));class Ef extends ri{constructor(){super(...arguments),this.onImageSpacingCalibrated=e=>{const{element:r,imageId:n}=e.detail,i=_r(n),o=mc();o.getFramesOfReference().forEach(s=>{const l=o.getAnnotations(s)[this.getToolName()];!l||!l.length||(l.forEach(f=>{var d;if(!((d=f.metadata)!=null&&d.referencedImageId))return;_r(f.metadata.referencedImageId)===i&&(f.invalidated=!0,f.data.cachedStats={})}),Zh(r))})}}filterInteractableAnnotationsForElement(e,r){if(!(r!=null&&r.length))return[];const n=Le(e),{viewport:i}=n;return Im(i,r)}createAnnotation(e){const r=e.detail,{currentPoints:n,element:i}=r,{world:o}=n,a=Le(i),{viewport:s}=a,c=s.getCamera(),{viewPlaneNormal:l,viewUp:f,position:u}=c,d=this.getReferencedImageId(s,o,l,f),h=s.getViewReference({points:[o]});return{highlighted:!0,invalidated:!0,metadata:{toolName:this.getToolName(),...h,referencedImageId:d,viewUp:f,cameraPosition:u},data:{cachedStats:{},handles:{points:[],activeHandleIndex:null,textBox:{hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}}}}}}getReferencedImageId(e,r,n,i){const o=this.getTargetId(e);let a=o.split(/^[a-zA-Z]+:/)[1];if(e instanceof fr){const s=dl(o),c=$e.getVolume(s);a=Ql(c,r,n)}return a}getStyle(e,r,n){return Dh(e,r,uB(n),this.mode)}}Ef.toolName="AnnotationDisplayTool";const{DefaultHistoryMemo:B2e}=hE,{PointsManager:G2e}=pn;class Yn extends Ef{static createAnnotation(...e){let r={annotationUID:null,highlighted:!0,invalidated:!0,metadata:{toolName:this.toolName},data:{text:"",handles:{points:new Array,textBox:{hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}}},label:""}};for(const n of e)r=Ti(r,n);return r}static createAnnotationForViewport(e,...r){return this.createAnnotation({metadata:e.getViewReference()},...r)}static createAndAddAnnotation(e,...r){const n=this.createAnnotationForViewport(e,...r);qt(n,e.element),Kt(n,e.element)}constructor(e,r){var n,i;super(e,r),this.mouseMoveCallback=(o,a)=>{if(!a)return!1;const{element:s,currentPoints:c}=o.detail,l=c.canvas;let f=!1;for(const u of a){if(Yr(u.annotationUID)||!Vr(u.annotationUID))continue;const{data:d}=u,h=d.handles?d.handles.activeHandleIndex:void 0,g=this._imagePointNearToolOrHandle(s,u,l,6),p=g&&!u.highlighted,v=!g&&u.highlighted;p||v?(u.highlighted=!u.highlighted,f=!0):d.handles&&d.handles.activeHandleIndex!==h&&(f=!0)}return f},this.isSuvScaled=Yn.isSuvScaled,(n=e.configuration)!=null&&n.getTextLines&&(this.configuration.getTextLines=e.configuration.getTextLines),(i=e.configuration)!=null&&i.statsCalculator&&(this.configuration.statsCalculator=e.configuration.statsCalculator)}getHandleNearImagePoint(e,r,n,i){const o=Le(e),{viewport:a}=o,{data:s}=r,{isCanvasAnnotation:c}=s,{points:l,textBox:f}=s.handles;if(f){const{worldBoundingBox:u}=f;if(u){const d={topLeft:a.worldToCanvas(u.topLeft),topRight:a.worldToCanvas(u.topRight),bottomLeft:a.worldToCanvas(u.bottomLeft),bottomRight:a.worldToCanvas(u.bottomRight)};if(n[0]>=d.topLeft[0]&&n[0]<=d.bottomRight[0]&&n[1]>=d.topLeft[1]&&n[1]<=d.bottomRight[1])return s.handles.activeHandleIndex=null,f}}for(let u=0;u<(l==null?void 0:l.length);u++){const d=l[u],h=c?d.slice(0,2):a.worldToCanvas(d);if(ur(n,h)<i===!0)return s.handles.activeHandleIndex=u,d}s.handles.activeHandleIndex=null}getLinkedTextBoxStyle(e,r){return{visibility:this.getStyle("textBoxVisibility",e,r),fontFamily:this.getStyle("textBoxFontFamily",e,r),fontSize:this.getStyle("textBoxFontSize",e,r),color:this.getStyle("textBoxColor",e,r),shadow:this.getStyle("textBoxShadow",e,r),background:this.getStyle("textBoxBackground",e,r),lineWidth:this.getStyle("textBoxLinkLineWidth",e,r),lineDash:this.getStyle("textBoxLinkLineDash",e,r)}}static isSuvScaled(e,r,n){var o;if(e instanceof fr){const a=dl(r),s=$e.getVolume(a);return((o=s==null?void 0:s.scaling)==null?void 0:o.PT)!==void 0}const i=n&&ct("scalingModule",n);return typeof(i==null?void 0:i.suvbw)=="number"}getAnnotationStyle(e){const{annotation:r,styleSpecifier:n}=e,i=p=>this.getStyle(p,n,r),{annotationUID:o}=r,a=Vr(o),s=Yr(o),c=i("lineWidth"),l=i("lineDash"),f=i("angleArcLineDash"),u=i("color"),d=i("markerSize"),h=i("shadow"),g=this.getLinkedTextBoxStyle(n,r);return{visibility:a,locked:s,color:u,lineWidth:c,lineDash:l,lineOpacity:1,fillColor:u,fillOpacity:0,shadow:h,textbox:g,markerSize:d,angleArcLineDash:f}}_imagePointNearToolOrHandle(e,r,n,i){if(this.getHandleNearImagePoint(e,r,n,i)||this.isPointNearTool(e,r,n,i,"mouse"))return!0}static createAnnotationState(e,r){const{data:n,annotationUID:i}=e,o={...n,cachedStats:{}};delete o.contour,delete o.spline;const a={annotationUID:i,data:structuredClone(o),deleting:r},s=n.contour;return s&&(a.data.contour={...s,polyline:null,pointsManager:G2e.create3(s.polyline.length,s.polyline)}),a}static createAnnotationMemo(e,r,n){if(!r)return;const{newAnnotation:i,deleting:o=i?!1:void 0}=n||{},{annotationUID:a}=r,s=Yn.createAnnotationState(r,o),c={restoreMemo:()=>{const l=Yn.createAnnotationState(r,o),{viewport:f}=Le(e)||{};if(f==null||f.setViewReference(r.metadata),s.deleting===!0){if(s.deleting=!1,Object.assign(r.data,s.data),r.data.contour){const d=r.data;d.contour.polyline=s.data.contour.pointsManager.points,delete s.data.contour.pointsManager,d.segmentation&&nu(r)}s.data=l.data,qt(r,e),qo(r.annotationUID,!0),f==null||f.render();return}if(s.deleting===!1){s.deleting=!0,s.data=l.data,qo(r.annotationUID),en(r.annotationUID),f==null||f.render();return}const u=kr(a);if(!u){console.warn("No current annotation");return}Object.assign(u.data,s.data),u.data.contour&&(u.data.contour.polyline=s.data.contour.pointsManager.points),s.data=l.data,u.invalidated=!0,Kt(u,e,Bt.History)},id:a,operationType:"annotation"};return B2e.push(c),c}createMemo(e,r,n){this.memo||(this.memo=Yn.createAnnotationMemo(e,r,n))}static hydrateBase(e,r,n,i={}){if(!r)return null;const{viewport:o}=r,a=o.getFrameOfReferenceUID(),s=o.getCamera(),c=i.viewplaneNormal??s.viewPlaneNormal,l=i.viewUp??s.viewUp,f=i.toolInstance||new e;let u,d=c,h=l;if(i.referencedImageId)u=i.referencedImageId,d=void 0,h=void 0;else if(o instanceof Jn){const g=gE(n[0],o);g!==void 0&&(u=o.getImageIds()[g])}else if(o instanceof fr)u=f.getReferencedImageId(o,n[0],c,l);else throw new Error("Unsupported viewport type");return{FrameOfReferenceUID:a,referencedImageId:u,viewPlaneNormal:d,viewUp:h,instance:f,viewport:o}}}Yn.toolName="AnnotationTool";const{CalibrationTypes:Vf}=Ha,Ff="px",B2="voxels",fB=[1,2,3,4],W2e=["3,3","4,7"],z2e=["4,3","4,7"],KS={0:"px",1:"percent",2:"dB",3:"cm",4:"seconds",5:"hertz",6:"dB/seconds",7:"cm/sec",8:"cm²",9:"cm²/s",12:"degrees"},$2e=.001,Rg="²",ya=(t,e)=>{const{calibration:r,hasPixelSpacing:n}=t;let i=n?"mm":Ff;const o=n?"mm³":B2;let a=i+Rg,s=1,c="";if(!r||!r.type&&!r.sequenceOfUltrasoundRegions)return{unit:i,areaUnit:a,scale:s,volumeUnit:o};if(r.type===Vf.UNCALIBRATED)return{unit:Ff,areaUnit:Ff+Rg,scale:s,volumeUnit:B2};if(r.sequenceOfUltrasoundRegions){let f,u;if(Array.isArray(e)&&e.length===2)[f,u]=e;else if(typeof e=="function"){const y=e();f=y[0],u=y[1]}let d=r.sequenceOfUltrasoundRegions.filter(y=>f[0]>=y.regionLocationMinX0&&f[0]<=y.regionLocationMaxX1&&f[1]>=y.regionLocationMinY0&&f[1]<=y.regionLocationMaxY1&&u[0]>=y.regionLocationMinX0&&u[0]<=y.regionLocationMaxX1&&u[1]>=y.regionLocationMinY0&&u[1]<=y.regionLocationMaxY1);if(!(d!=null&&d.length))return{unit:i,areaUnit:a,scale:s,volumeUnit:o};if(d=d.filter(y=>fB.includes(y.regionDataType)&&W2e.includes(`${y.physicalUnitsXDirection},${y.physicalUnitsYDirection}`)),!d.length)return{unit:Ff,areaUnit:Ff+Rg,scale:s,volumeUnit:B2};const h=d[0],g=Math.abs(h.physicalDeltaX),p=Math.abs(h.physicalDeltaY);if(Vt(g,p,$2e))s=1/g,c="US Region",i=KS[h.physicalUnitsXDirection]||"unknown",a=i+Rg;else return{unit:Ff,areaUnit:Ff+Rg,scale:s,volumeUnit:B2}}else r.scale&&(s=r.scale);return[Vf.ERMF,Vf.USER,Vf.ERROR,Vf.PROJECTION,Vf.CALIBRATED,Vf.UNKNOWN].includes(r==null?void 0:r.type)&&(c=r.type),{unit:i+(c?` ${c}`:""),areaUnit:a+(c?` ${c}`:""),scale:s,volumeUnit:o+(c?` ${c}`:"")}},p5=(t,e)=>{const[r]=e,{calibration:n}=t;let i=["raw"],o=[null],a="";if(!n||!n.type&&!n.sequenceOfUltrasoundRegions)return{units:i,values:o};if(n.sequenceOfUltrasoundRegions){const s=n.sequenceOfUltrasoundRegions.filter(p=>fB.includes(p.regionDataType)&&z2e.includes(`${p.physicalUnitsXDirection},${p.physicalUnitsYDirection}`));if(!(s!=null&&s.length))return{units:i,values:o};const c=s.find(p=>r[0]>=p.regionLocationMinX0&&r[0]<=p.regionLocationMaxX1&&r[1]>=p.regionLocationMinY0&&r[1]<=p.regionLocationMaxY1);if(!c)return{units:i,values:o};const{referencePixelX0:l=0,referencePixelY0:f=0}=c,{physicalDeltaX:u,physicalDeltaY:d}=c,h=(r[1]-c.regionLocationMinY0-f)*d,g=(r[0]-c.regionLocationMinX0-l)*u;a="US Region",o=[g,h],i=[KS[c.physicalUnitsXDirection],KS[c.physicalUnitsYDirection]]}return{units:i,values:o,calibrationType:a}},u8=t=>{var e;return((e=t.calibration)==null?void 0:e.aspect)||1};function zw(t,e,r,n){const i=Ke();Tn(i,e,t);const o=Tt(...r),a=Tt(...n),s=Ke();Nn(s,o,a);const c=Ko(s);if(c<1e-4)return{worldWidth:0,worldHeight:0};const l=xt(s,i)/(c*Ko(i)),u=Math.sqrt(1-l*l)*c,d=l*c;return{worldWidth:u,worldHeight:d}}function Qh(t,e,r,n){const i=Ke();Tn(i,e,t);const o=Tt(...r),a=Tt(...n),s=Ke();Nn(s,o,a);const c=Ko(s);if(c<1e-4)return{worldWidth:0,worldHeight:0};const l=xt(s,i)/(c*Ko(i)),u=Math.sqrt(1-l*l)*c,d=l*c;return{worldWidth:u,worldHeight:d}}function f8(t,e,r,n,i=.25){const o=d8(t,e,{targetVolumeId:r,stepSize:i});let a;for(const s of o){const c=t.getIntensityFromWorld(s),l=n(c,s);l&&(a=l)}return a}function d8(t,e,{targetVolumeId:r,stepSize:n}){const i=t.getCamera(),{viewPlaneNormal:o}=i,{spacingInNormalDirection:a}=Hh(t,i,r),s=a*n||1,c=t.getBounds(),l=[];let f=[...e];for(;PI(f,c);)l.push([...f]),f[0]+=o[0]*s,f[1]+=o[1]*s,f[2]+=o[2]*s;for(f=[...e];PI(f,c);)l.push([...f]),f[0]-=o[0]*s,f[1]-=o[1]*s,f[2]-=o[2]*s;return l}const PI=function(t,e){const[r,n,i,o,a,s]=e,c=10;return t[0]>r+c&&t[0]<n-c&&t[1]>i+c&&t[1]<o-c&&t[2]>a+c&&t[2]<s-c},dB=(t,e,r,n,i,o,a,s)=>{const c=[Tt(r,n,i),Tt(o,n,i),Tt(r,a,i),Tt(o,a,i),Tt(r,n,s),Tt(o,n,s),Tt(r,a,s),Tt(o,a,s)],l=Tt(e[0],e[1],e[2]),f=Tt(t[0],t[1],t[2]),u=-xt(l,f);let d=null;for(const h of c){const g=xt(l,h)+u;if(d===null)d=Math.sign(g);else if(Math.sign(g)!==d)return!0}return!1},{EPSILON:j2e}=xf,H2e=1-j2e;function $w(t,e){const{viewPlaneNormal:r}=e,n=t.filter(i=>{let o=i.metadata.viewPlaneNormal;if(!o){const{referencedImageId:s}=i.metadata,{imageOrientationPatient:c}=ct("imagePlaneModule",s),l=Tt(c[0],c[1],c[2]),f=Tt(c[3],c[4],c[5]);o=Ke(),Tn(o,l,f),i.metadata.viewPlaneNormal=o}const a=Math.abs(xt(r,o))>H2e;return o&&a});return n.length?n:[]}const K2e={filterAnnotationsWithinSlice:l8,getWorldWidthAndHeightFromCorners:zw,getWorldWidthAndHeightFromTwoPoints:Qh,filterAnnotationsForDisplay:Im,getPointInLineOfSightWithCriteria:f8,isPlaneIntersectingAABB:dB,filterAnnotationsWithinSamePlane:$w,getPointsInLineOfSight:d8},q2e=Object.freeze(Object.defineProperty({__proto__:null,default:K2e,filterAnnotationsForDisplay:Im,filterAnnotationsWithinSamePlane:$w,filterAnnotationsWithinSlice:l8,getPointInLineOfSightWithCriteria:f8,getPointsInLineOfSight:d8,getWorldWidthAndHeightFromCorners:zw,getWorldWidthAndHeightFromTwoPoints:Qh,isPlaneIntersectingAABB:dB},Symbol.toStringTag,{value:"Module"}));function Lo(t,e,r){let n=!0,i=!0;if(typeof t!="function")throw new TypeError("Expected a function");return UE(r)&&(n="leading"in r?!!r.leading:n,i="trailing"in r?!!r.trailing:i),Jh(t,e,{leading:n,trailing:i,maxWait:e})}function X2e(t){var e;return((e=t[0])==null?void 0:e.length)===3}function Y2e(t,e){if(!e||e.length===0||e.length===t.length)return t;const r=e[e.length-1]-e[0]+1,n=hC(e.map(o=>t[o][0])),i=hC(e.map(o=>t[o][1]));if(X2e(t)){const o=hC(e.map(a=>t[a][2]));return T9(Og(n,r),Og(i,r),Og(o,r))}else return T9(Og(n,r),Og(i,r))}function J2e(t,e){const r=[],[n,i]=e,o=i-n+1,a=Math.floor(o/t);let s=0,c=Math.round((o-1)/(a-1)*s)+n;for(;c<=i;)r.push(c),s++,c=Math.round((o-1)/(a-1)*s)+n;return r}function qS(t,e,r,n){const i=r-e+1,o=Math.floor(n/100*i)??1,a=Math.floor(i/o)??1;if(isNaN(i)||!i||!a||i/a<2)return t;const s=Math.max(0,e),c=Math.min(t.length-1,r),l=t.slice(0,s),f=t.slice(c+1,t.length),u=J2e(a,[s,c]),d=Y2e(t,u);return[...l,...d,...f]}function jw(t,e){var n,i;return e!=null&&e.autoGenerated?!1:((n=t==null?void 0:t.smoothing)==null?void 0:n.smoothOnAdd)===!0||((i=t==null?void 0:t.smoothing)==null?void 0:i.smoothOnEdit)===!0}function Z2e(t,e){return Do(t,e)<.001}function Q2e(t,e){return Do(t,e)===0}function eve(t,e){for(let r=0;r<t.length;r++)for(let n=0;n<e.length;n++)if(Q2e(t[r],e[n]))return[r,n]}function D0(t,e,r){return(t+e+r)%e}function RI(t,e,r,n){const[,i,o]=t,[,a,s]=e,c=o.length,l=s.length;let f=t[0],u=e[0];if(!o[f]||!s[u]||!o[i]||!s[a])return[void 0,void 0];for(;f!==i&&u!==a;){if(r(s[u],o[f]))return[f,u];f=D0(f,c,n),u=D0(u,l,n)}return[void 0,void 0]}function tve(t,e){const[r,n]=eve(t,e)||[],i=(c,l)=>Z2e(c,l)===!1,[o,a]=RI([D0(r,t.length,1),r,t],[D0(n,e.length,1),n,e],i,1),[s]=RI([D0(o,t.length,-1),o,t],[D0(a,e.length,-1),a,e],i,-1);return[o,s]}function Hw(t,e,r){const{interpolation:n,smoothing:i}=t,o=e;if(n){const{knotsRatioPercentageOnAdd:a,knotsRatioPercentageOnEdit:s,smoothOnAdd:c=!1,smoothOnEdit:l=!1}=i,f=r?s:a;if(r?l:c){const[d,h]=r?tve(e,r):[0,e.length-1];return!e[d]||!e[h]?e:qS(e,d,h,f)}}return o}const eg=t=>{if(t.shiftKey)return t.ctrlKey?Ri.ShiftCtrl:t.altKey?Ri.ShiftAlt:t.metaKey?Ri.ShiftMeta:Ri.Shift;if(t.ctrlKey)return t.altKey?Ri.CtrlAlt:t.metaKey?Ri.CtrlMeta:Ri.Ctrl;if(t.altKey)return t.metaKey&&Ri.AltMeta||Ri.Alt;if(t.metaKey)return Ri.Meta};function h8(t,e){const r=t[0],n=t[t.length-1],i=Wt();fs(i,n[0]-r[0],n[1]-r[1]),Ul(i,i);const o=Wt(),a=Wt();fs(o,-i[1],i[0]),fs(a,i[1],-i[0]);const s=[(r[0]+n[0])/2,(r[1]+n[1])/2],c={dist:0,index:null};for(let u=0;u<t.length;u++){const d=t[u],h=l4(d,s);h>c.dist&&(c.dist=h,c.index=u)}return[t[c.index],s].map(e.canvasToWorld)}function nve(t,e){const{viewport:r}=t,n=e.data.contour.polyline.map(r.worldToCanvas);return h8(n,r)}const{addCanvasPointsToArray:g8,pointsAreWithinCloseContourProximity:hB,getFirstLineSegmentIntersectionIndexes:gB,getSubPixelSpacingAndXYDirections:rve}=Tf;function ive(t,e,r){this.isDrawing=!0;const n=t.detail,{currentPoints:i,element:o}=n,a=i.canvas,s=Le(o),{viewport:c}=s,l=eg(t.detail.event)===this.configuration.contourHoleAdditionModifierKey,{spacing:f,xDir:u,yDir:d}=rve(c,this.configuration.subPixelResolution)||{};!f||!u||!d||(this.drawData={canvasPoints:[a],polylineIndex:0,contourHoleProcessingEnabled:l,newAnnotation:!0},this.commonData={annotation:e,viewportIdsToRender:r,spacing:f,xDir:u,yDir:d,movingTextBox:!1},Je.isInteractingWithTool=!0,o.addEventListener(U.MOUSE_UP,this.mouseUpDrawCallback),o.addEventListener(U.MOUSE_DRAG,this.mouseDragDrawCallback),o.addEventListener(U.MOUSE_CLICK,this.mouseUpDrawCallback),o.addEventListener(U.TOUCH_END,this.mouseUpDrawCallback),o.addEventListener(U.TOUCH_DRAG,this.mouseDragDrawCallback),o.addEventListener(U.TOUCH_TAP,this.mouseUpDrawCallback),Dt(o))}function ove(t){Je.isInteractingWithTool=!1,t.removeEventListener(U.MOUSE_UP,this.mouseUpDrawCallback),t.removeEventListener(U.MOUSE_DRAG,this.mouseDragDrawCallback),t.removeEventListener(U.MOUSE_CLICK,this.mouseUpDrawCallback),t.removeEventListener(U.TOUCH_END,this.mouseUpDrawCallback),t.removeEventListener(U.TOUCH_DRAG,this.mouseDragDrawCallback),t.removeEventListener(U.TOUCH_TAP,this.mouseUpDrawCallback),kt(t)}function ave(t){const e=t.detail,{currentPoints:r,element:n}=e,i=r.world,o=r.canvas,a=Le(n),{viewport:s}=a,{annotation:c,viewportIdsToRender:l,xDir:f,yDir:u,spacing:d,movingTextBox:h}=this.commonData,{polylineIndex:g,canvasPoints:p,newAnnotation:v}=this.drawData;this.createMemo(n,c,{newAnnotation:v});const y=p[p.length-1],m=s.canvasToWorld(y),w=Ke();Nn(w,i,m);const x=Math.abs(xt(w,f)),C=Math.abs(xt(w,u));if(!(x<=d[0]&&C<=d[1])){if(h){this.isDrawing=!1;const{deltaPoints:S}=e,T=S.world,{textBox:_}=c.data.handles,{worldPosition:E}=_;E[0]+=T[0],E[1]+=T[1],E[2]+=T[2],_.hasMoved=!0}else{const S=this.findCrossingIndexDuringCreate(t);if(S!==void 0)this.applyCreateOnCross(t,S);else{const T=g8(n,p,o,this.commonData);this.drawData.polylineIndex=g+T}c.invalidated=!0}We(l),c.invalidated&&Kt(c,n,Bt.HandlesUpdated)}}function sve(t){const{allowOpenContours:e}=this.configuration,{canvasPoints:r,contourHoleProcessingEnabled:n}=this.drawData,i=r[0],o=r[r.length-1],a=t.detail,{element:s}=a;this.doneEditMemo(),this.drawData.newAnnotation=!1,e&&!hB(i,o,this.configuration.closeContourProximity)?this.completeDrawOpenContour(s,{contourHoleProcessingEnabled:n}):this.completeDrawClosedContour(s,{contourHoleProcessingEnabled:n})}function cve(t,e){this.removeCrossedLinesOnCompleteDraw();const{canvasPoints:r}=this.drawData,{contourHoleProcessingEnabled:n,minPointsToSave:i}=e??{};if(i&&r.length<i||this.haltDrawing(t,r))return!1;const{annotation:o,viewportIdsToRender:a}=this.commonData,s=Le(t),{viewport:c,renderingEngine:l}=s;g8(t,r,r[0],this.commonData),r.pop();const f=jw(this.configuration,o)?Hw(this.configuration,r):r;this.updateContourPolyline(o,{points:f,closed:!0,targetWindingDirection:Xo.Clockwise},c);const{textBox:u}=o.data.handles;return u!=null&&u.hasMoved||Iw(o,n),this.isDrawing=!1,this.drawData=void 0,this.commonData=void 0,We(a),this.deactivateDraw(t),!0}function lve(){const{canvasPoints:t}=this.drawData,e=t.length,r=[t[0],t[e-1]],n=t.slice(0,-1).slice(1),i=gB(n,r[0],r[1],!1);if(i){const o=i[1];o===1?this.drawData.canvasPoints=t.splice(1):this.drawData.canvasPoints=t.splice(0,o)}}function uve(t,e){const{canvasPoints:r}=this.drawData,{contourHoleProcessingEnabled:n}=e??{};if(this.haltDrawing(t,r))return!1;const{annotation:i,viewportIdsToRender:o}=this.commonData,a=Le(t),{viewport:s,renderingEngine:c}=a,l=jw(this.configuration,i)?Hw(this.configuration,r):r;this.updateContourPolyline(i,{points:l,closed:!1},s);const{textBox:f}=i.data.handles,u=i.data.contour.polyline;return i.data.handles.points=[u[0],u[u.length-1]],i.data.isOpenUShapeContour&&(i.data.openUShapeContourVectorToPeak=h8(r,s)),f.hasMoved||Iw(i,n),this.isDrawing=!1,this.drawData=void 0,this.commonData=void 0,We(o),this.deactivateDraw(t),!0}function fve(t){const e=t.detail,{currentPoints:r,lastPoints:n}=e,i=r.canvas,o=n.canvas,{canvasPoints:a}=this.drawData,s=a.slice(0,-1),c=gB(s,i,o,!1);return c===void 0?void 0:c[0]}function dve(t,e){const r=t.detail,{element:n}=r,{canvasPoints:i,contourHoleProcessingEnabled:o}=this.drawData,{annotation:a,viewportIdsToRender:s}=this.commonData;g8(n,i,i[e],this.commonData),i.pop();const c=i.slice(e),l=Em(c);if(Vt(l,0)){i.splice(e+1);return}i.splice(0,e);const f={contourHoleProcessingEnabled:o,minPointsToSave:3};this.completeDrawClosedContour(n,f)&&this.activateClosedContourEdit(t,a,s)}function hve(t){const{allowOpenContours:e}=this.configuration,{canvasPoints:r,contourHoleProcessingEnabled:n}=this.drawData,i=r[0],o=r[r.length-1];e&&!hB(i,o,this.configuration.closeContourProximity)?this.completeDrawOpenContour(t,{contourHoleProcessingEnabled:n}):this.completeDrawClosedContour(t,{contourHoleProcessingEnabled:n})}function gve(t,e){const r=Math.max(e*3,3);return t.length<r}function pve(t,e){const{subPixelResolution:r}=this.configuration;if(gve(e,r)){const{annotation:n,viewportIdsToRender:i}=this.commonData,o=Le(t),{renderingEngine:a}=o;return en(n.annotationUID),this.isDrawing=!1,this.drawData=void 0,this.commonData=void 0,We(i),this.deactivateDraw(t),!0}return!1}function mve(t){t.activateDraw=ive.bind(t),t.deactivateDraw=ove.bind(t),t.applyCreateOnCross=dve.bind(t),t.findCrossingIndexDuringCreate=fve.bind(t),t.completeDrawOpenContour=uve.bind(t),t.removeCrossedLinesOnCompleteDraw=lve.bind(t),t.mouseDragDrawCallback=ave.bind(t),t.mouseUpDrawCallback=sve.bind(t),t.completeDrawClosedContour=cve.bind(t),t.cancelDrawing=hve.bind(t),t.haltDrawing=pve.bind(t)}const{addCanvasPointsToArray:vve,getFirstLineSegmentIntersectionIndexes:Md}=Tf;function yve(t,e){const r=t.detail,{element:n,currentPoints:i,lastPoints:o}=r,a=i.canvas,s=o.canvas,{editCanvasPoints:c,prevCanvasPoints:l}=this.editData,f=Md(l,a,s,e);if(f)this.editData.startCrossingIndex=f[0],this.removePointsUpUntilFirstCrossing(e);else if(l.length>=2)if(c.length>this.configuration.checkCanvasEditFallbackProximity){const u=c[0],d=[];for(let p=0;p<l.length;p++){const v=l[p],y=ur(v,u);d.push({distance:y,index:p})}d.sort((p,v)=>p.distance-v.distance);const h=[d[0],d[1]],g=Math.min(h[0].index,h[1].index);this.editData.startCrossingIndex=g}else{const u=Wt();Br(u,c[1],c[0]),Ul(u,u);const d=6,h=[c[0][0]-u[0]*d,c[0][1]-u[1]*d],g=Md(l,h,c[0],e);if(g){const p=[h];vve(n,p,c[0],this.commonData),c.unshift(...p),this.removePointsUpUntilFirstCrossing(e),this.editData.editIndex=c.length-1,this.editData.startCrossingIndex=g[0]}}}function wve(t){const{editCanvasPoints:e,prevCanvasPoints:r}=this.editData;let n=0;for(let i=0;i<e.length-1;i++){const o=[e[i],e[i+1]],a=!!Md(r,o[0],o[1],t);if(n++,a)break}e.splice(0,n),this.editData.editIndex=e.length-1}function xve(t,e){const r=t.detail,{currentPoints:n,lastPoints:i}=r,o=n.canvas,a=i.canvas,{prevCanvasPoints:s}=this.editData;return!!Md(s,o,a,e)}function Cve(t){const{prevCanvasPoints:e,editCanvasPoints:r}=this.editData;for(let n=r.length-1;n>0;n--){const i=[r[n],r[n-1]],o=!!Md(e,i[0],i[1],t);if(r.pop(),o)break}}function Sve(){const{editCanvasPoints:t,prevCanvasPoints:e,startCrossingIndex:r}=this.editData;if(r===void 0)return;const n=t[t.length-1],i=[];for(let a=0;a<e.length;a++){const s=e[a],c=ur(s,n);i.push({distance:c,index:a})}i.sort((a,s)=>a.distance-s.distance);const o=t.slice(0,-1);for(let a=0;a<i.length;a++){const{index:s}=i[a],c=e[s],l=t[t.length-1];if(!Md(o,c,l,!1))return s}return-1}function Tve(t){const e=t.detail,{currentPoints:r,lastPoints:n}=e,i=r.canvas,o=n.canvas,{editCanvasPoints:a}=this.editData,s=a.slice(0,-2),c=Md(s,i,o,!1);if(!c)return;const l=c[0],f=a.length-l;for(let u=0;u<f;u++)a.pop()}function _ve(t){t.checkForFirstCrossing=yve.bind(t),t.removePointsUpUntilFirstCrossing=wve.bind(t),t.checkForSecondCrossing=xve.bind(t),t.findSnapIndex=Sve.bind(t),t.removePointsAfterSecondCrossing=Cve.bind(t),t.checkAndRemoveCrossesOnEditLine=Tve.bind(t)}const{getSubPixelSpacingAndXYDirections:Eve,addCanvasPointsToArray:pB,getArea:LI}=Tf;function bve(t,e,r){this.isEditingClosed=!0;const n=t.detail,{currentPoints:i,element:o}=n,a=i.canvas,s=Le(o);if(!s)return;const{viewport:c}=s,l=e.data.contour.polyline.map(c.worldToCanvas),{spacing:f,xDir:u,yDir:d}=Eve(c,this.configuration.subPixelResolution);this.editData={prevCanvasPoints:l,editCanvasPoints:[a],startCrossingIndex:void 0,editIndex:0,annotation:e},this.commonData={annotation:e,viewportIdsToRender:r,spacing:f,xDir:u,yDir:d,movingTextBox:!1},Je.isInteractingWithTool=!0,o.addEventListener(U.MOUSE_UP,this.mouseUpClosedContourEditCallback),o.addEventListener(U.MOUSE_DRAG,this.mouseDragClosedContourEditCallback),o.addEventListener(U.MOUSE_CLICK,this.mouseUpClosedContourEditCallback),o.addEventListener(U.TOUCH_END,this.mouseUpClosedContourEditCallback),o.addEventListener(U.TOUCH_DRAG,this.mouseDragClosedContourEditCallback),o.addEventListener(U.TOUCH_TAP,this.mouseUpClosedContourEditCallback),Dt(o)}function Dve(t){Je.isInteractingWithTool=!1,t.removeEventListener(U.MOUSE_UP,this.mouseUpClosedContourEditCallback),t.removeEventListener(U.MOUSE_DRAG,this.mouseDragClosedContourEditCallback),t.removeEventListener(U.MOUSE_CLICK,this.mouseUpClosedContourEditCallback),t.removeEventListener(U.TOUCH_END,this.mouseUpClosedContourEditCallback),t.removeEventListener(U.TOUCH_DRAG,this.mouseDragClosedContourEditCallback),t.removeEventListener(U.TOUCH_TAP,this.mouseUpClosedContourEditCallback),kt(t)}function Ive(t){const e=t.detail,{currentPoints:r,element:n}=e,i=r.world,o=r.canvas,a=Le(n),{viewport:s}=a,{viewportIdsToRender:c,xDir:l,yDir:f,spacing:u}=this.commonData,{editIndex:d,editCanvasPoints:h,startCrossingIndex:g,annotation:p}=this.editData;this.createMemo(n,p);const v=h[h.length-1],y=s.canvasToWorld(v),m=Ke();Nn(m,i,y);const w=Math.abs(xt(m,l)),x=Math.abs(xt(m,f));if(w<=u[0]&&x<=u[1])return;g!==void 0&&this.checkAndRemoveCrossesOnEditLine(t);const C=pB(n,h,o,this.commonData),S=d+C;if(this.editData.editIndex=S,g===void 0&&h.length>1&&this.checkForFirstCrossing(t,!0),this.editData.snapIndex=this.findSnapIndex(),this.editData.snapIndex===-1){this.finishEditAndStartNewEdit(t);return}this.editData.fusedCanvasPoints=this.fuseEditPointsWithClosedContour(t),g!==void 0&&this.checkForSecondCrossing(t,!0)&&(this.removePointsAfterSecondCrossing(!0),this.finishEditAndStartNewEdit(t)),We(c)}function Ove(t){const e=t.detail,{element:r}=e,n=Le(r),{viewport:i,renderingEngine:o}=n,{annotation:a,viewportIdsToRender:s}=this.commonData,{fusedCanvasPoints:c,editCanvasPoints:l}=this.editData;vc(a,{points:c,closed:!0,targetWindingDirection:Xo.Clockwise},i),a.autoGenerated&&(a.autoGenerated=!1),Kt(a,r);const f=l.pop();this.editData={prevCanvasPoints:c,editCanvasPoints:[f],startCrossingIndex:void 0,editIndex:0,snapIndex:void 0,annotation:a},We(s)}function Mve(t){const{prevCanvasPoints:e,editCanvasPoints:r,startCrossingIndex:n,snapIndex:i}=this.editData;if(n===void 0||i===void 0)return;const o=t.detail,{element:a}=o,s=[...r];pB(a,s,e[i],this.commonData),s.length>r.length&&s.pop();let c,l;n>i?(c=i,l=n):(c=n,l=i);const f=ur(e[c],s[0]),u=ur(e[c],s[s.length-1]),d=ur(e[l],s[0]),h=ur(e[l],s[s.length-1]),g=[];for(let C=0;C<c;C++){const S=e[C];g.push([S[0],S[1]])}let p=f+h,v=u+d;if(p<v)for(let C=0;C<s.length;C++){const S=s[C];g.push([S[0],S[1]])}else for(let C=s.length-1;C>=0;C--){const S=s[C];g.push([S[0],S[1]])}for(let C=l;C<e.length;C++){const S=e[C];g.push([S[0],S[1]])}const y=[];for(let C=c;C<l;C++){const S=e[C];y.push([S[0],S[1]])}if(p=d+u,v=h+f,p<v)for(let C=0;C<s.length;C++){const S=s[C];y.push([S[0],S[1]])}else for(let C=s.length-1;C>=0;C--){const S=s[C];y.push([S[0],S[1]])}const m=LI(g),w=LI(y);return m>w?g:y}function Pve(t){const e=t.detail,{element:r}=e;this.completeClosedContourEdit(r)}function Rve(t){var s;const e=Le(t),{viewport:r}=e,{annotation:n,viewportIdsToRender:i}=this.commonData;this.doneEditMemo();const{fusedCanvasPoints:o,prevCanvasPoints:a}=this.editData;if(o){const c=jw(this.configuration,n)?Hw(this.configuration,o,a):o,l=((s=this.configuration)==null?void 0:s.decimate)||{};vc(n,{points:c,closed:!0,targetWindingDirection:Xo.Clockwise},r,{decimate:{enabled:!!l.enabled,epsilon:l.epsilon}}),n.autoGenerated&&(n.autoGenerated=!1),Kt(n,t)}this.isEditingClosed=!1,this.editData=void 0,this.commonData=void 0,We(i),this.deactivateClosedContourEdit(t)}function Lve(t){this.completeClosedContourEdit(t)}function Ave(t){t.activateClosedContourEdit=bve.bind(t),t.deactivateClosedContourEdit=Dve.bind(t),t.mouseDragClosedContourEditCallback=Ive.bind(t),t.mouseUpClosedContourEditCallback=Pve.bind(t),t.finishEditAndStartNewEdit=Ove.bind(t),t.fuseEditPointsWithClosedContour=Mve.bind(t),t.cancelClosedContourEdit=Lve.bind(t),t.completeClosedContourEdit=Rve.bind(t)}const{addCanvasPointsToArray:mB,getSubPixelSpacingAndXYDirections:Nve}=Tf;function kve(t,e,r){this.isEditingOpen=!0;const n=t.detail,{currentPoints:i,element:o}=n,a=i.canvas,s=Le(o),{viewport:c}=s;this.doneEditMemo();const l=e.data.contour.polyline.map(c.worldToCanvas),{spacing:f,xDir:u,yDir:d}=Nve(c,this.configuration.subPixelResolution);this.editData={prevCanvasPoints:l,editCanvasPoints:[a],startCrossingIndex:void 0,editIndex:0},this.commonData={annotation:e,viewportIdsToRender:r,spacing:f,xDir:u,yDir:d,movingTextBox:!1},Je.isInteractingWithTool=!0,o.addEventListener(U.MOUSE_UP,this.mouseUpOpenContourEditCallback),o.addEventListener(U.MOUSE_DRAG,this.mouseDragOpenContourEditCallback),o.addEventListener(U.MOUSE_CLICK,this.mouseUpOpenContourEditCallback),o.addEventListener(U.TOUCH_END,this.mouseUpOpenContourEditCallback),o.addEventListener(U.TOUCH_DRAG,this.mouseDragOpenContourEditCallback),o.addEventListener(U.TOUCH_TAP,this.mouseUpOpenContourEditCallback),Dt(o)}function Vve(t){Je.isInteractingWithTool=!1,t.removeEventListener(U.MOUSE_UP,this.mouseUpOpenContourEditCallback),t.removeEventListener(U.MOUSE_DRAG,this.mouseDragOpenContourEditCallback),t.removeEventListener(U.MOUSE_CLICK,this.mouseUpOpenContourEditCallback),t.removeEventListener(U.TOUCH_END,this.mouseUpOpenContourEditCallback),t.removeEventListener(U.TOUCH_DRAG,this.mouseDragOpenContourEditCallback),t.removeEventListener(U.TOUCH_TAP,this.mouseUpOpenContourEditCallback),kt(t)}function Fve(t){const e=t.detail,{currentPoints:r,element:n}=e,i=r.world,o=r.canvas,a=Le(n),{viewport:s}=a,{viewportIdsToRender:c,xDir:l,yDir:f,spacing:u}=this.commonData,{editIndex:d,editCanvasPoints:h,startCrossingIndex:g}=this.editData,p=h[h.length-1],v=s.canvasToWorld(p),y=Ke();this.createMemo(n,this.commonData.annotation),Nn(y,i,v);const m=Math.abs(xt(y,l)),w=Math.abs(xt(y,f));if(m<=u[0]&&w<=u[1])return;g!==void 0&&this.checkAndRemoveCrossesOnEditLine(t);const x=mB(n,h,o,this.commonData),C=d+x;this.editData.editIndex=C,g===void 0&&h.length>1&&this.checkForFirstCrossing(t,!1),this.editData.snapIndex=this.findSnapIndex(),this.editData.fusedCanvasPoints=this.fuseEditPointsWithOpenContour(t),g!==void 0&&this.checkForSecondCrossing(t,!1)?(this.removePointsAfterSecondCrossing(!1),this.finishEditOpenOnSecondCrossing(t)):this.checkIfShouldOverwriteAnEnd(t)&&this.openContourEditOverwriteEnd(t),We(c)}function Uve(t){const e=t.detail,{element:r}=e,n=Le(r),{viewport:i}=n,{annotation:o,viewportIdsToRender:a}=this.commonData,s=this.fuseEditPointsForOpenContourEndEdit();vc(o,{points:s,closed:!1},i);const c=o.data.contour.polyline;o.data.handles.points=[c[0],c[c.length-1]],o.data.handles.activeHandleIndex=1,Kt(o,r),this.isEditingOpen=!1,this.editData=void 0,this.commonData=void 0,this.doneEditMemo(),this.deactivateOpenContourEdit(r),this.activateOpenContourEndEdit(t,o,a,null)}function Bve(t){const e=t.detail,{currentPoints:r,lastPoints:n}=e,i=r.canvas,o=n.canvas,{snapIndex:a,prevCanvasPoints:s,startCrossingIndex:c}=this.editData;if(c===void 0||a===void 0)return!1;if(a===-1)return!0;if(a!==0&&a!==s.length-1)return!1;const l=i,f=o,u=s[a],d=Wt(),h=Wt();fs(d,l[0]-f[0],l[1]-f[1]),fs(h,l[0]-u[0],l[1]-u[1]);const g=c4(d,h),p=Math.sqrt(d[0]*d[0]+d[1]*d[1]),v=Math.sqrt(h[0]*h[0]+h[1]*h[1]);return Math.acos(g/(p*v))<Math.PI/2}function Gve(){const{snapIndex:t,prevCanvasPoints:e,editCanvasPoints:r,startCrossingIndex:n}=this.editData,i=[];if(t===0)for(let s=e.length-1;s>=n;s--){const c=e[s];i.push([c[0],c[1]])}else for(let s=0;s<n;s++){const c=e[s];i.push([c[0],c[1]])}const o=ur(e[n],r[0]),a=ur(e[n],r[r.length-1]);if(o<a)for(let s=0;s<r.length;s++){const c=r[s];i.push([c[0],c[1]])}else for(let s=r.length-1;s>=0;s--){const c=r[s];i.push([c[0],c[1]])}return i}function Wve(t){const{prevCanvasPoints:e,editCanvasPoints:r,startCrossingIndex:n,snapIndex:i}=this.editData;if(n===void 0||i===void 0)return;const o=t.detail,{element:a}=o,s=[...r];mB(a,s,e[i],this.commonData),s.length>r.length&&s.pop();let c,l;n>i?(c=i,l=n):(c=n,l=i);const f=ur(e[c],s[0]),u=ur(e[c],s[s.length-1]),d=ur(e[l],s[0]),h=ur(e[l],s[s.length-1]),g=[];for(let y=0;y<c;y++){const m=e[y];g.push([m[0],m[1]])}const p=f+h,v=u+d;if(p<v)for(let y=0;y<s.length;y++){const m=s[y];g.push([m[0],m[1]])}else for(let y=s.length-1;y>=0;y--){const m=s[y];g.push([m[0],m[1]])}for(let y=l;y<e.length;y++){const m=e[y];g.push([m[0],m[1]])}return g}function zve(t){const e=t.detail,{element:r}=e,n=Le(r),{viewport:i,renderingEngine:o}=n,{annotation:a,viewportIdsToRender:s}=this.commonData,{fusedCanvasPoints:c,editCanvasPoints:l}=this.editData;vc(a,{points:c,closed:!1},i);const f=a.data.contour.polyline;a.data.handles.points=[f[0],f[f.length-1]],Kt(a,r);const u=l.pop();this.editData={prevCanvasPoints:c,editCanvasPoints:[u],startCrossingIndex:void 0,editIndex:0},We(s)}function $ve(t){const e=t.detail,{element:r}=e;this.completeOpenContourEdit(r)}function jve(t){var s;const e=Le(t),{viewport:r}=e,{annotation:n,viewportIdsToRender:i}=this.commonData;this.doneEditMemo();const{fusedCanvasPoints:o,prevCanvasPoints:a}=this.editData;if(o){const c=jw(this.configuration)?Hw(this.configuration,o,a):o,l=((s=this.configuration)==null?void 0:s.decimate)||{};vc(n,{points:c,closed:!1},r,{decimate:{enabled:!!l.enabled,epsilon:l.epsilon}});const f=n.data.contour.polyline;n.data.handles.points=[f[0],f[f.length-1]],n.data.isOpenUShapeContour&&(n.data.openUShapeContourVectorToPeak=h8(o,r)),Kt(n,t)}this.isEditingOpen=!1,this.editData=void 0,this.commonData=void 0,We(i),this.deactivateOpenContourEdit(t)}function Hve(t){this.completeOpenContourEdit(t)}function Kve(t){t.activateOpenContourEdit=kve.bind(t),t.deactivateOpenContourEdit=Vve.bind(t),t.mouseDragOpenContourEditCallback=Fve.bind(t),t.mouseUpOpenContourEditCallback=$ve.bind(t),t.fuseEditPointsWithOpenContour=Wve.bind(t),t.finishEditOpenOnSecondCrossing=zve.bind(t),t.checkIfShouldOverwriteAnEnd=Bve.bind(t),t.fuseEditPointsForOpenContourEndEdit=Gve.bind(t),t.openContourEditOverwriteEnd=Uve.bind(t),t.cancelOpenContourEdit=Hve.bind(t),t.completeOpenContourEdit=jve.bind(t)}const{getSubPixelSpacingAndXYDirections:qve}=Tf;function Xve(t,e,r,n){this.isDrawing=!0;const i=t.detail,{element:o}=i,a=Le(o),{viewport:s}=a,{spacing:c,xDir:l,yDir:f}=qve(s,this.configuration.subPixelResolution),u=e.data.contour.polyline.map(s.worldToCanvas);e.data.handles.activeHandleIndex===0&&u.reverse();let h=!1;n!=null&&n.worldPosition&&(h=!0),this.drawData={canvasPoints:u,polylineIndex:u.length-1},this.commonData={annotation:e,viewportIdsToRender:r,spacing:c,xDir:l,yDir:f,movingTextBox:h},Je.isInteractingWithTool=!0,o.addEventListener(U.MOUSE_UP,this.mouseUpDrawCallback),o.addEventListener(U.MOUSE_DRAG,this.mouseDragDrawCallback),o.addEventListener(U.MOUSE_CLICK,this.mouseUpDrawCallback),o.addEventListener(U.TOUCH_END,this.mouseUpDrawCallback),o.addEventListener(U.TOUCH_DRAG,this.mouseDragDrawCallback),o.addEventListener(U.TOUCH_TAP,this.mouseUpDrawCallback),Dt(o)}function Yve(t){t.activateOpenContourEndEdit=Xve.bind(t)}function vB(t){return(t.childAnnotationUIDs??[]).map(r=>kr(r).data.contour.polyline)}function Om(t,e){const r=vB(t),n=[];return r.forEach(i=>{const o=i.length,a=new Array(o);for(let s=0;s<o;s++)a[s]=e.worldToCanvas(i[s]);n.push(a)}),n}const{pointsAreWithinCloseContourProximity:Jve}=Tf;function Zve(t,e){const r={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:t.viewport.id,annotationUID:e.annotationUID},{lineWidth:n,lineDash:i,color:o,fillColor:a,fillOpacity:s}=this.getAnnotationStyle({annotation:e,styleSpecifier:r}),{closed:c}=e.data.contour;return{color:o,width:n,lineDash:i,fillColor:a,fillOpacity:s,closePath:c}}function Qve(t,e,r){var n;(n=t==null?void 0:t.viewport)!=null&&n.getImageData()&&(r.data.contour.closed?this.renderClosedContour(t,e,r):r.data.isOpenUShapeContour?(eye(t,r),this.renderOpenUShapedContour(t,e,r)):this.renderOpenContour(t,e,r))}function eye(t,e){e.data.openUShapeContourVectorToPeak||(e.data.openUShapeContourVectorToPeak=nve(t,e))}function tye(t,e,r){if(r.parentAnnotationUID)return;const{viewport:n}=t,i=this._getRenderingOptions(t,r),o=r.data.contour.polyline.map(l=>n.worldToCanvas(l)),a=Om(r,n),s=[o,...a];Kl(e,r.annotationUID,"1",s,i)}function nye(t,e,r){var c;const{viewport:n}=t,i=this._getRenderingOptions(t,r),o=r.data.contour.polyline.map(l=>n.worldToCanvas(l));dc(e,r.annotationUID,"1",o,i);const s=r.data.handles.activeHandleIndex;if(((c=this.configuration.alwaysRenderOpenContourHandles)==null?void 0:c.enabled)===!0){const l=this.configuration.alwaysRenderOpenContourHandles.radius,f="0",u=[o[0],o[o.length-1]];s===0?u.shift():s===1&&u.pop(),Kn(e,r.annotationUID,f,u,{color:i.color,handleRadius:l})}if(s!==null){const l="1",f=s===0?0:o.length-1,u=o[f];Kn(e,r.annotationUID,l,[u],{color:i.color})}}function rye(t,e,r){const{viewport:n}=t,{openUShapeContourVectorToPeak:i}=r.data,{polyline:o}=r.data.contour;if(this.renderOpenContour(t,e,r),!i)return;const a=n.worldToCanvas(o[0]),s=n.worldToCanvas(o[o.length-1]),c=[n.worldToCanvas(i[0]),n.worldToCanvas(i[1])],l=this._getRenderingOptions(t,r);dc(e,r.annotationUID,"first-to-last",[a,s],{color:l.color,width:l.width,closePath:!1,lineDash:"2,2"}),dc(e,r.annotationUID,"midpoint-to-open-contour",[c[0],c[1]],{color:l.color,width:l.width,closePath:!1,lineDash:"2,2"})}function iye(t,e,r){const n=this._getRenderingOptions(t,r),{allowOpenContours:i}=this.configuration,{canvasPoints:o}=this.drawData;if(n.closePath=!1,dc(e,r.annotationUID,"1",o,n),i){const a=o[0],s=o[o.length-1];Jve(a,s,this.configuration.closeContourProximity)?dc(e,r.annotationUID,"2",[s,a],n):Kn(e,r.annotationUID,"0",[a],{color:n.color,handleRadius:2})}}function oye(t,e,r){const{viewport:n}=t,{fusedCanvasPoints:i}=this.editData;if(i===void 0){this.renderClosedContour(t,e,r);return}const o=Om(r,n),a=[i,...o],s=this._getRenderingOptions(t,r),c="preview-1";r.parentAnnotationUID&&s.fillOpacity&&(s.fillOpacity=0),Kl(e,r.annotationUID,c,a,s)}function aye(t,e,r){const{fusedCanvasPoints:n}=this.editData;if(n===void 0){this.renderOpenContour(t,e,r);return}const i=this._getRenderingOptions(t,r);dc(e,r.annotationUID,"preview-1",n,i)}function sye(t,e,r){if(r.parentAnnotationUID)return;const{viewport:n}=t,i=this._getRenderingOptions(t,r),o=r.data.contour.polyline.map(g=>n.worldToCanvas(g)),a=Om(r,n),s="1",c=o[0],l=6,f=100,u=[];for(let g=0;g<f;g++){const p=g/f*2*Math.PI,v=c[0]+l*Math.cos(p),y=c[1]+l*Math.sin(p);u.push([v,y])}const d=[[c[0]-l*2,c[1]],[c[0]+l*2,c[1]],[c[0],c[1]-l*2],[c[0],c[1]+l*2]];Kl(e,r.annotationUID,s+"-crosshair_v",[d[0],d[1]],i),Kl(e,r.annotationUID,s+"-crosshair_h",[d[2],d[3]],i);const h=[u,...a];Kl(e,r.annotationUID,s,h,i)}function cye(t){t.renderContour=Qve.bind(t),t.renderClosedContour=tye.bind(t),t.renderOpenContour=nye.bind(t),t.renderPointContourWithMarker=sye.bind(t),t.renderOpenUShapedContour=rye.bind(t),t.renderContourBeingDrawn=iye.bind(t),t.renderClosedContourBeingEdited=oye.bind(t),t.renderOpenContourBeingEdited=aye.bind(t),t._getRenderingOptions=Zve.bind(t)}function wa(t){const e=lye(t),r=(e.top[1]+e.bottom[1])/2;return[e.right[0],r]}function lye(t){const e=[t[0],t[1]].sort(a),r=[t[0],t[1]].sort(s),n=e[e.length-1],i=r[0],o=r[r.length-1];return{top:i,bottom:o,right:n};function a(c,l){return c[0]<l[0]?-1:1}function s(c,l){return c[1]<l[1]?-1:1}}const uye=Object.freeze(Object.defineProperty({__proto__:null,getTextBoxCoordsCanvas:wa},Symbol.toStringTag,{value:"Module"}));function uu(t,e){if(t instanceof fr){const r=dl(e),n=$e.getVolume(r);return!!(n!=null&&n.scaling)&&Object.keys(n.scaling).length>0}else if(t instanceof Jn){const{preScale:r}=t.getImageData()||{};return!!(r!=null&&r.scaled)}else return!1}function XS(t,e){let r=0;for(let n=0;n<t.length-1;n++){const i=t[n],o=t[n+1];r+=Math.sqrt(Math.pow(o[0]-i[0],2)+Math.pow(o[1]-i[1],2))}if(e){const n=t[0],i=t[t.length-1];r+=Math.sqrt(Math.pow(i[0]-n[0],2)+Math.pow(i[1]-n[1],2))}return r}class fye extends Yn{constructor(e,r){super(e,r)}renderAnnotation(e,r){let n=!1;const{viewport:i}=e,{element:o}=i;if(!i.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),n;let a=Jt(this.getToolName(),o);if(!(a!=null&&a.length)||(a=this.filterInteractableAnnotationsForElement(o,a),!(a!=null&&a.length)))return n;const s=this.getTargetId(i),c={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:e.viewport.id};for(let l=0;l<a.length;l++){const f=a[l];c.annotationUID=f.annotationUID;const u=this.getAnnotationStyle({annotation:f,styleSpecifier:c});if(!u.visibility)continue;const d=this.renderAnnotationInstance({enabledElement:e,targetId:s,annotation:f,annotationStyle:u,svgDrawingHelper:r});n||(n=d),f.invalidated=!1}return n}createAnnotation(e){const r=super.createAnnotation(e);return Object.assign(r.data,{contour:{polyline:[],closed:!1}}),Object.assign(r,{interpolationUID:"",autoGenerated:!1}),r}addAnnotation(e,r){return qt(e,r)}cancelAnnotation(e){}moveAnnotation(e,r){const{points:n}=e.data.handles;for(let i=0,o=n.length;i<o;i++){const a=n[i];a[0]+=r[0],a[1]+=r[1],a[2]+=r[2]}e.invalidated=!0,wm(e).forEach(i=>this.moveAnnotation(i,r))}updateContourPolyline(e,r,n,i){var a;const o=((a=this.configuration)==null?void 0:a.decimate)||{};vc(e,r,n,{decimate:{enabled:!!o.enabled,epsilon:o.epsilon},updateWindingDirection:i==null?void 0:i.updateWindingDirection})}getPolylinePoints(e){var r;return((r=e.data.contour)==null?void 0:r.polyline)??e.data.polyline}renderAnnotationInstance(e){const{enabledElement:r,annotationStyle:n,svgDrawingHelper:i}=e,o=e.annotation;if(o.parentAnnotationUID)return;const{annotationUID:a}=o,{viewport:s}=r,{worldToCanvas:c}=s,l=this.getPolylinePoints(o).map(y=>c(y)),{lineWidth:f,lineDash:u,color:d,fillColor:h,fillOpacity:g}=n,p=Om(o,s),v=[l,...p];return Kl(i,a,"contourPolyline",v,{color:d,lineDash:u,lineWidth:Math.max(.1,f),fillColor:h,fillOpacity:g}),!0}}class dye{constructor(){this.annotationUIDs=new Set,this._isVisible=!0,this.visibleFilter=this.unboundVisibleFilter.bind(this)}unboundVisibleFilter(e){return!this._isVisible||!this.annotationUIDs.has(e)}has(e){return this.annotationUIDs.has(e)}setVisible(e=!0,r,n){this._isVisible!==e&&(this._isVisible=e,this.annotationUIDs.forEach(i=>{const o=kr(i);if(!o){this.annotationUIDs.delete(i);return}if(o.isVisible===e||!e&&(n==null?void 0:n(i))===!1)return;o.isVisible=e;const a={...r,annotation:o};it(Ze,U.ANNOTATION_MODIFIED,a)}))}get isVisible(){return this._isVisible}findNearby(e,r){const n=[...this.annotationUIDs];if(n.length===0)return null;if(!e)return n[r===1?0:n.length-1];const i=n.indexOf(e);return i===-1||i+r<0||i+r>=n.length?null:n[i+r]}add(...e){e.forEach(r=>this.annotationUIDs.add(r))}remove(...e){e.forEach(r=>this.annotationUIDs.delete(r))}clear(){this.annotationUIDs.clear()}}const rr={...wpe,...ppe,resetAnnotationManager:K1e},hye=Object.freeze(Object.defineProperty({__proto__:null,AnnotationGroup:dye,FrameOfReferenceSpecificAnnotationManager:wU,config:U2e,locking:k1e,selection:B1e,state:rr,visibility:j1e},Symbol.toStringTag,{value:"Module"})),AI="PlanarFreehandContourSegmentationTool";function p8(t,e=[]){const{viewport:r,sliceData:n,annotation:i}=t,o=new Map,{toolName:a,originalToolName:s}=i.metadata,c=s||a,l=(Jt(c,r.element)||[]).filter(f=>!f.metadata.originalToolName||f.metadata.originalToolName===c);if(c!==AI){const f=Jt(AI,r.element);f!=null&&f.length&&f.forEach(u=>{const{metadata:d}=u;d.originalToolName===c&&d.originalToolName!==d.toolName&&l.push(u)})}if(!(l!=null&&l.length))return o;for(let f=0;f<n.numberOfSlices;f++){const u=l.filter(h=>h.metadata.sliceIndex===f);if(!(u!=null&&u.length))continue;const d=u.filter(h=>e.every(g=>{const p=g.parentKey?g.parentKey(h):h,v=p==null?void 0:p[g.key];return Array.isArray(v)?v.every((y,m)=>y===g.value[m]):v===g.value}));d.length&&o.set(f,d)}return o}function gye(t,e){const r=p8(t,e),n=[];if(!(r!=null&&r.size))return n;for(const i of r.values())i.forEach(o=>{n.push(o)});return n}function yB(t,e,r){const n=Ti({data:{},metadata:{}},r);return Object.assign(n,{highlighted:!1,invalidated:!0,autoGenerated:!0,annotationUID:void 0,cachedStats:{},childAnnotationUIDs:[],parentAnnotationUID:void 0}),Object.assign(n.data,{handles:{points:e.points||e||[],interpolationSources:e.sources,activeHandleIndex:null,textBox:{hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}}},contour:{...r.data.contour,polyline:t}}),n}function pye(t,e){const r=p8(e,[{key:"interpolationUID",value:e.interpolationUID}]),n=mye(r);if(!n){console.warn("No annotations found to interpolate",r);return}const i=vye(r,t.annotationUID),o=[];for(let a=n[0]+1;a<n[1];a++)if(yye(r,a)){const s=xye(a,n,r);((s==null?void 0:s[0])===i||(s==null?void 0:s[1])===i)&&wye(s,o,a)}return{interpolationData:r,interpolationList:o}}function mye(t){let e=1/0,r=-1/0,n=!1;for(const[i,o]of t.entries())o.length&&(e=Math.min(i,e),r=Math.max(i,r),n=!0);if(n)return[e,r]}function vye(t,e){for(const[r,n]of t)for(let i=0;i<n.length;i++)if(n[i].annotationUID===e)return r}function yye(t,e){const r=t.get(e);return!(r!=null&&r.length)||r.length===1&&r[0].autoGenerated}function wye(t,e,r){const[n]=t;e[n]||(e[n]={pair:t,list:[]}),e[n].list.push(r)}function xye(t,e,r){const n=[];let i=!0;for(let o=t-1;o>=e[0];o--){const a=r.get(o);if(a!=null&&a.length){if(a[0].autoGenerated)continue;a.length>1&&(i=!1),n.push(o);break}}if(!(!i||!n.length)){for(let o=t+1;o<=e[1];o++){const a=r.get(o);if(a!=null&&a.length){if(a[0].autoGenerated)continue;a.length>1&&(i=!1),n.push(o);break}}if(!(!i||n.length<2))return n}}const{PointsManager:NI}=pn;function Cye(t,e=12){const r=NI.create3(e);r.sources=[];const{sources:n}=r,{length:i,sources:o=[]}=t,a=5;if(i<a*3)return t.subselect(e);const s=Math.floor(Math.max(2*i/e,a*2));o.forEach(()=>n.push(NI.create3(e)));const c=Sye(t,a),l=Tye(c,e),f=[];if((l==null?void 0:l.length)>2){let u=-1;const d=s/3;l.forEach(p=>{const[v,,y]=p,m=Math.ceil((v+y)/2);y-u<d||(m-v>2*d?(o0(f,u,v,s,i),u=o0(f,v,m,s,i)):u=o0(f,u,m,s,i),y-u>d&&(u=o0(f,u,y,s,i)))});const h=f[0];YS(h+i-u,i)>2*d&&o0(f,u,h-d,s,i)}else{const u=Math.floor(i/e);o0(f,-1,i-u,u,i)}return f.forEach(u=>{const d=t.getPointArray(u);r.push(d),o.forEach((h,g)=>n[g].push(h.getPoint(u)))}),r}function Sye(t,e=6){const{length:r}=t,n=Ke(),i=Ke(),o=new Float32Array(r);for(let a=0;a<r;a++){const s=t.getPoint(a),c=t.getPoint(a-e),l=t.getPoint((a+e)%r);hn(n,s,c),hn(i,l,s);const f=xt(n,i)/(wh(n)*wh(i));o[a]=f}return o}function Tye(t,e){const{max:r,deviation:n}=_ye(t),{length:i}=t;if(n<.01||i<e*3)return[];const o=[];let a=null,s,c=0;for(let l=0;l<i;l++){const f=t[l];f<r-n?a?(a[2]=l,f<s&&(s=f,c=l),a[1]=c):(s=f,c=l,a=[l,l,l]):a&&(o.push(a),a=null)}return a&&(o[0][0]===0?o[0][0]=a[0]:(a[1]=c,a[2]=i-1,o.push(a))),o}function o0(t,e,r,n,i){r<e&&(r+=i);const o=r-e,a=Math.ceil(o/n);if(a<=0)return t[t.length-1]!==r&&t.push(YS(r,i)),r;for(let s=1;s<=a;s++){const c=YS(e+s*o/a,i);t.push(c)}return t[t.length-1]}function YS(t,e){return(Math.round(t)+e)%e}function _ye(t){const{length:e}=t;let r=0,n=1/0,i=-1/0,o=0;for(let s=0;s<e;s++){const c=t[s];r+=c,n=Math.min(n,c),i=Math.max(i,c)}const a=r/e;for(let s=0;s<e;s++){const c=t[s]-a;o+=c*c}return{mean:a,max:i,min:n,sumSq:o,deviation:Math.sqrt(o/e)}}function Eye(t){const{parentAnnotationUID:e,annotationUID:r}=t;if(!e)return t.interpolationUID;const n=rr.getAnnotation(e),{interpolationUID:i}=n,o=n.childAnnotationUIDs.indexOf(r);return t.interpolationUID=`${i}-${o}`,t.interpolationUID}const{PointsManager:Lg}=pn,kI=.2;function Fv(t){if(!t.annotation)return;const{isInterpolationUpdate:e,annotation:r}=t;queueMicrotask(()=>{try{e&&(r.isInterpolationUpdate=!0,r.autoGenerated=!1),bye(t)}finally{e&&(r.autoGenerated=!0)}})}function bye(t){const{annotation:e}=t;Eye(e);const{interpolationData:r,interpolationList:n}=pye(e,t)||{};if(!r||!n)return;const i={toolName:e.metadata.toolName,toolType:e.metadata.toolName,viewport:t.viewport};for(let l=0;l<n.length;l++)n[l]&&Dye(n[l].list,n[l].pair,r,i);const{id:o,renderingEngineId:a,element:s}=t.viewport,c={annotation:e,element:s,viewportId:o,renderingEngineId:a};n.length&&it(t.viewport.element,U.ANNOTATION_INTERPOLATION_PROCESS_COMPLETED,c)}function Dye(t,e,r,n){const i=r.get(e[0])[0],o=r.get(e[1])[0],a=zI(i.data.contour.polyline),s=zI(o.data.contour.polyline),{c1Interp:c,c2Interp:l}=Rye(a,s);c.kIndex=e[0],l.kIndex=e[1],t.forEach(function(f){Iye(c,l,f,e,r,a.x.length>s.x.length,n)})}function Iye(t,e,r,n,i,o,a){const[s,c]=n,l=(r-s)/(c-s),f=i.get(s)[0],u=i.get(c)[0],d=Pye(t,e,l,o),h=l>.5?u:f,g=Cye(d);i.has(r)?Mye(d,g,r,h,a):Oye(d,g,r,h,a)}function Oye(t,e,r,n,i){var f;const o=t.points,{viewport:a}=i,s=yB(o,e,n),c=a.getViewReference({sliceIndex:r});if(!c)throw new Error(`Can't find slice ${r}`);Object.assign(s.metadata,c),rr.addAnnotation(s,a.element),(f=n.onInterpolationComplete)==null||f.call(n,s,n);const{parentAnnotationUID:l}=n;if(l){const u=rr.getAnnotation(l),d=wB(u,r,i);Bw(a,d,s)}}function wB(t,e,r){const{viewport:n}=r,i=rr.getAnnotations(t.metadata.toolName,n.element);for(let o=0;o<i.length;o++){const a=i[o];if(a.interpolationUID===t.interpolationUID&&a.metadata.sliceIndex===e)return a}}function Mye(t,e,r,n,i){const o=wB(n,r,i),a=t.points,s=yB(a,e,o);Object.assign(o,{metadata:s.metadata,data:s.data})}function Pye(t,e,r,n){const i=n?t.I:e.I,o=Lg.fromXYZ(t),a=Lg.fromXYZ(e),{length:s}=o,c=Lg.create3(s),l=Ke(),f=Ke(),u=Lg.create3(s);u.kIndex=t.kIndex;const d=Lg.create3(s);d.kIndex=e.kIndex;for(let h=0;h<t.x.length;h++)if(i[h]){const g=o.getPoint(h),p=a.getPoint(h);u.push(g),d.push(p),hn(l,p,g),c.push(dn(f,g,l,r))}return c.sources=[u,d],c}function Rye(t,e){const r=WI(t),n=WI(e),i=Math.max(Math.ceil(r[r.length-1]/kI),Math.ceil(n[n.length-1]/kI)),o=GI(r),a=GI(n),s=i+e.x.length,c=i+t.x.length,l=BI(s,o),f=BI(c,a),u=UI(s-2,t.x.length),d=UI(c-2,e.x.length),h=FI(l,u),g=FI(f,d),p=VI(t,h),v=VI(e,g);return Aye(p,v),Lye(p,v)}function Lye(t,e){const r={x:[],y:[],z:[],I:[]},n={x:[],y:[],z:[],I:[]};for(let i=0;i<t.x.length;i++)(t.I[i]||e.I[i])&&(r.x.push(t.x[i]),r.y.push(t.y[i]),r.z.push(t.z[i]),r.I.push(t.I[i]),n.x.push(e.x[i]),n.y.push(e.y[i]),n.z.push(e.z[i]),n.I.push(e.I[i]));return{c1Interp:r,c2Interp:n}}function Aye(t,e){const r=t.x.length,n={startingNode:0,totalSquaredXYLengths:1/0};for(let o=0;o<r;o++){let a=o,s=0;for(let c=0;c<r;c++)s+=(t.x[a]-e.x[c])**2+(t.y[a]-e.y[c])**2+(t.z[a]-e.z[c])**2,a++,a===r&&(a=0);s<n.totalSquaredXYLengths&&(n.totalSquaredXYLengths=s,n.startingNode=o)}const i=n.startingNode;G2(t.x,i),G2(t.y,i),G2(t.z,i),G2(t.I,i)}function G2(t,e){e-=t.length*Math.floor(e/t.length);const r=t.splice(0,e);return t.push(...r),t}function VI(t,e){const r={x:[],y:[],z:[],I:[]};for(let n=0;n<t.x.length-1;n++){r.x.push(t.x[n]),r.y.push(t.y[n]),r.z.push(t.z[n]),r.I.push(!0);const i=(t.x[n+1]-t.x[n])/(e[n]+1),o=(t.y[n+1]-t.y[n])/(e[n]+1),a=(t.z[n+1]-t.z[n])/(e[n]+1);for(let s=0;s<e[n]-1;s++)r.x.push(r.x[r.x.length-1]+i),r.y.push(r.y[r.y.length-1]+o),r.z.push(r.z[r.z.length-1]+a),r.I.push(!1)}return r}function FI(t,e){const r=[];for(let a=0;a<t.length;++a)r[a]=a;r.sort(function(a,s){return t[a]<t[s]?-1:1});const n=[];for(let a=0;a<e.length;a++)n.push(e[r[a]]);const i=n.reduce(function(a,s,c){return s&&a.push(c),a},[]),o=[];for(let a=0;a<i.length-1;a++)o.push(i[a+1]-i[a]);return o}function UI(t,e){const r=new Array(t+e);return r.fill(!1,0,t),r.fill(!0,t,t+e),r}function BI(t,e){const r=1/(t-1),n=[r];for(let i=1;i<t-2;i++)n.push(n[n.length-1]+r);return n.concat(e)}function GI(t){const e=[];for(let r=0;r<t.length;r++)e.push(t[r]/t[t.length-1]);return e}function WI(t){const e=[0];for(let r=1;r<t.x.length;r++){const n=Math.sqrt((t.x[r]-t.x[r-1])**2+(t.y[r]-t.y[r-1])**2+(t.z[r]-t.z[r-1])**2);e.push(e[r-1]+n)}return e}function zI(t){const e={x:[],y:[],z:[]};for(let r=0;r<t.length;r++)e.x[r]=t[r][0],e.y[r]=t[r][1],e.z[r]=t[r][2];return e.x.push(e.x[0]),e.y.push(e.y[0]),e.z.push(e.z[0]),e}function $I(t){const{annotation:e}=t,r=p8(t,[{key:"interpolationUID",value:t.interpolationUID}]),n=e.metadata.sliceIndex;let i=-1,o=t.sliceData.numberOfSlices;for(const[s,c]of r.entries())s===n||!c.find(f=>!f.autoGenerated)||(s<n?i=Math.max(s,i):o=Math.min(s,o));const a=[];for(const[s,c]of r.entries())s<=i||s>=o||s===n||c.forEach(l=>{l.autoGenerated&&(rr.removeAnnotation(l.annotationUID),a.push(l))});if(a.length){const s={annotations:a,element:t.viewport.element,viewportId:t.viewport.id,renderingEngineId:t.viewport.getRenderingEngine().id};it(t.viewport.element,U.INTERPOLATED_ANNOTATIONS_REMOVED,s)}if(i>=0&&o<t.sliceData.numberOfSlices){const s=r.get(o)[0],c={viewport:t.viewport,sliceData:{numberOfSlices:t.sliceData.numberOfSlices,imageIndex:s.metadata.sliceIndex},annotation:s,interpolationUID:s.interpolationUID};Fv(c)}}function Uv(t){const e=c8(t);return e.length?e[0]:void 0}const{uuidv4:Nye}=pn,kye=[Bt.HandlesUpdated,Bt.InterpolationUpdated],ss=class ss{static addTool(e){this.toolNames.includes(e)||this.toolNames.push(e)}static acceptAutoGenerated(e,r={}){const{toolNames:n,segmentationId:i,segmentIndex:o,sliceIndex:a}=r;for(const s of n||ss.toolNames){const c=rr.getAnnotations(s,e);if(c!=null&&c.length)for(const l of c){const{interpolationUID:f,data:u,autoGenerated:d,metadata:h}=l;f&&(l.interpolationCompleted=!0),d&&(o&&o!==u.segmentation.segmentIndex||a!==void 0&&h&&a!==h.sliceIndex||i&&i!==u.segmentation.segmentationId||(nu(l),l.autoGenerated=!1))}}}};ss.toolNames=[],ss.handleAnnotationCompleted=e=>{var h;const r=e.detail.annotation;if(!(r!=null&&r.metadata))return;const{toolName:n,originalToolName:i}=r.metadata;if(!ss.toolNames.includes(n)&&!ss.toolNames.includes(i))return;const o=Uv(r);if(!o){console.warn("Unable to find viewport for",r);return}const a=OC(o),s={viewport:o,sliceData:a,annotation:r,interpolationUID:r.interpolationUID},c=!!r.interpolationUID;if(r.autoGenerated=!1,c){$I(s),Fv(s);return}const l=[{key:"segmentIndex",value:r.data.segmentation.segmentIndex,parentKey:g=>g.data.segmentation},{key:"viewPlaneNormal",value:r.metadata.viewPlaneNormal,parentKey:g=>g.metadata},{key:"viewUp",value:r.metadata.viewUp,parentKey:g=>g.metadata}];let f=gye(s,l);const{sliceIndex:u}=r.metadata,d=new Set;f.forEach(g=>{if(g.interpolationCompleted||g.metadata.sliceIndex===u){const{interpolationUID:p}=g;d.add(p)}}),f=f.filter(g=>!d.has(g.interpolationUID)),r.interpolationUID=((h=f[0])==null?void 0:h.interpolationUID)||Nye(),s.interpolationUID=r.interpolationUID,Fv(s)},ss.handleAnnotationUpdate=e=>{const r=e.detail.annotation,{changeType:n=Bt.HandlesUpdated}=e.detail;if(!(r!=null&&r.metadata))return;const{toolName:i,originalToolName:o}=r.metadata;if(!ss.toolNames.includes(i)&&!ss.toolNames.includes(o)||!kye.includes(n))return;const a=Uv(r);if(!a){console.warn("Unable to find matching viewport for annotation interpolation",r);return}r.autoGenerated&&(nu(r),r.autoGenerated=!1);const s=OC(a),c={viewport:a,sliceData:s,annotation:r,interpolationUID:r.interpolationUID,isInterpolationUpdate:n===Bt.InterpolationUpdated};Fv(c)},ss.handleAnnotationDelete=e=>{const r=e.detail.annotation;if(!(r!=null&&r.metadata))return;const{toolName:n}=r.metadata;if(!ss.toolNames.includes(n)||r.autoGenerated)return;const i=Uv(r);if(!i){console.warn("No viewport, can't delete interpolated results",r);return}const o=OC(i),a={viewport:i,sliceData:o,annotation:r,interpolationUID:r.interpolationUID};r.autoGenerated=!1,$I(a)};let Qc=ss;function OC(t){return{numberOfSlices:t.getNumberOfSlices(),imageIndex:t.getCurrentImageIdIndex()}}function xB(t){t.forEach(e=>{const r=jr(e);if(!r){console.warn(`ToolGroup not available for ${e}`);return}r.getViewportsInfo().forEach(i=>{const{renderingEngineId:o,viewportId:a}=i,s=Nr(o);if(!s){console.warn(`RenderingEngine not available for ${o}`);return}const c=s.getViewport(a);Zh(c.element)})})}function tg(t){const n=$n.getState().viewportSegRepresentations;return Object.entries(n).filter(([,o])=>o.some(a=>a.segmentationId===t)).map(([o])=>o)}function Vye(t,e){const r=_n(t);if(!r)throw new Error(`No segmentation state found for ${t}`);const{segments:n}=r;return n[e].locked}function Fye(t,e,r=!0){const n=_n(t);if(!n)throw new Error(`No segmentation state found for ${t}`);const{segments:i}=n;i[e].locked=r,Ka(t)}function zd(t){const e=_n(t);if(!e)throw new Error(`No segmentation state found for ${t}`);const{segments:r}=e;return Object.keys(r).filter(i=>r[i].locked).map(i=>parseInt(i))}const Uye=Object.freeze(Object.defineProperty({__proto__:null,getLockedSegmentIndices:zd,isSegmentIndexLocked:Vye,setSegmentIndexLocked:Fye},Symbol.toStringTag,{value:"Module"}));function CB(){return $n.getNextColorLUTIndex()}const m5=[[0,0,0,0],[221,84,84,255],[77,228,121,255],[166,70,235,255],[189,180,116,255],[109,182,196,255],[204,101,157,255],[123,211,94,255],[93,87,218,255],[225,128,80,255],[73,232,172,255],[181,119,186,255],[176,193,112,255],[105,153,200,255],[208,97,120,255],[90,215,101,255],[135,83,222,255],[229,178,76,255],[122,183,181,255],[190,115,171,255],[149,197,108,255],[100,118,205,255],[212,108,93,255],[86,219,141,255],[183,79,226,255],[233,233,72,255],[118,167,187,255],[194,111,146,255],[116,201,104,255],[115,96,209,255],[216,147,89,255],[82,223,188,255],[230,75,224,255],[163,184,121,255],[114,143,191,255],[198,107,114,255],[99,206,122,255],[153,92,213,255],[220,192,85,255],[78,215,227,255],[234,71,173,255],[141,188,117,255],[110,113,195,255],[202,128,103,255],[95,210,157,255],[195,88,217,255],[206,224,81,255],[74,166,231,255],[185,120,139,255],[113,192,113,255],[133,106,199,255],[207,162,98,255],[91,214,198,255],[221,84,198,255],[159,228,77,255],[70,111,235,255],[189,119,116,255],[109,196,138,255],[165,101,204,255],[211,201,94,255],[87,191,218,255],[225,80,153,255],[106,232,73,255],[124,119,186,255],[193,142,112,255],[105,200,168,255],[203,97,208,255],[184,215,90,255],[83,147,222,255],[229,76,101,255],[122,183,130,255],[146,115,190,255],[197,171,108,255],[100,205,205,255],[212,93,177,255],[141,219,86,255],[79,97,226,255],[233,99,72,255],[118,187,150,255],[173,111,194,255],[197,201,104,255],[96,171,209,255],[216,89,137,255],[94,223,82,255],[107,75,230,255],[184,153,121,255],[114,191,175,255],[198,107,191,255],[166,206,99,255],[92,132,213,255],[220,85,91,255],[78,227,115,255],[159,71,234,255],[188,176,117,255],[110,185,195,255],[202,103,161,255],[129,210,95,255],[88,88,217,255],[224,123,81,255],[74,231,166,255],[177,120,185,255],[179,192,113,255],[106,156,199,255],[207,98,125,255],[91,214,96,255],[130,84,221,255],[228,171,77,255],[70,235,221,255],[189,116,174,255],[153,196,109,255],[101,123,204,255],[211,104,94,255],[87,218,136,255],[177,80,225,255],[232,225,73,255],[119,169,186,255],[193,112,149,255],[121,200,105,255],[111,97,208,255],[215,142,90,255],[83,222,181,255],[229,76,229,255],[165,183,122,255],[115,146,190,255],[197,108,119,255],[100,205,118,255],[148,93,212,255],[219,186,86,255],[79,220,226,255],[233,72,179,255],[144,187,118,255],[111,118,194,255],[201,124,104,255],[96,209,153,255],[189,89,216,255],[211,223,82,255],[75,172,230,255],[184,121,142,255],[117,191,114,255],[130,107,198,255],[206,157,99,255],[92,213,193,255],[220,85,203,255],[165,227,78,255],[71,118,234,255],[188,117,117,255],[110,195,135,255],[161,103,202,255],[210,195,95,255],[88,195,217,255],[224,81,158,255],[113,231,74,255],[123,120,185,255],[192,139,113,255],[106,199,164,255],[198,98,207,255],[188,214,91,255],[84,153,221,255],[228,77,108,255],[70,235,84,255],[143,116,189,255],[196,167,109,255],[101,204,199,255],[211,94,182,255],[147,218,87,255],[80,104,225,255],[232,93,73,255],[119,186,147,255],[170,112,193,255],[200,200,105,255],[97,175,208,255],[215,90,142,255],[100,222,83,255],[101,76,229,255],[183,150,122,255],[115,190,171,255],[197,108,194,255],[170,205,100,255],[93,138,212,255],[219,86,97,255],[79,226,110,255],[153,72,233,255],[187,173,118,255],[111,187,194,255],[201,104,165,255],[134,209,96,255],[89,95,216,255],[223,117,82,255],[75,230,159,255],[174,121,184,255],[182,191,114,255],[107,160,198,255],[206,99,130,255],[92,213,92,255],[124,85,220,255],[227,165,78,255],[71,234,214,255],[188,117,176,255],[156,195,110,255],[103,128,202,255],[210,100,95,255],[88,217,131,255],[170,81,224,255],[231,218,74,255],[120,172,185,255],[192,113,153,255],[125,199,106,255],[107,98,207,255],[214,137,91,255],[84,221,175,255],[222,77,228,255],[194,235,70,255],[116,149,189,255],[196,109,123,255],[101,204,114,255],[143,94,211,255],[218,180,87,255],[80,225,225,255],[232,73,186,255],[147,186,119,255],[112,122,193,255],[200,121,105,255],[97,208,148,255],[184,90,215,255],[216,222,83,255],[76,178,229,255],[183,122,145,255],[121,190,115,255],[126,108,197,255],[205,153,100,255],[93,212,187,255],[219,86,208,255],[171,226,79,255],[72,126,233,255],[187,118,121,255],[111,194,132,255],[157,104,201,255],[209,190,96,255],[89,200,216,255],[223,82,164,255],[120,230,75,255],[121,121,184,255],[191,136,114,255],[107,198,160,255],[192,99,206,255],[193,213,92,255],[85,158,220,255],[227,78,115,255],[71,234,78,255],[141,117,188,255],[195,163,110,255],[103,202,194,255],[210,95,186,255],[153,217,88,255],[81,111,224,255]];function Ep(t,e){const r=$n,n=e??CB();let i=[...t];if(Vt(i[0],[0,0,0,0])||(console.warn("addColorLUT: [0, 0, 0, 0] color is not provided for the background color (segmentIndex =0), automatically adding it"),i=[[0,0,0,0],...i]),i=i.map(o=>o.length===3?[o[0],o[1],o[2],255]:o),i.length<255){const o=m5.slice(i.length);i=[...i,...o]}return r.addColorLUT(i,n),n}function Bye(t,e){if(!t)throw new Error("addColorLUT: colorLUT is required");return Ep(t,e)}function Gye(t,e,r){if(!Cm(r))throw new Error(`setColorLUT: could not find colorLUT with index ${r}`);const n=pa(t,{segmentationId:e});if(!n)throw new Error(`viewport specific state for viewport ${t} does not exist`);n.forEach(i=>{i.colorLUTIndex=r}),Wc(t,e)}function ou(t,e,r){const n=pa(t,{segmentationId:e});if(!n||n.length===0)return null;const i=n[0],{colorLUTIndex:o}=i,a=Cm(o);let s=a[r];if(!s){if(typeof r!="number")return console.warn(`Can't create colour for LUT index ${r}`),null;s=a[r]=[0,0,0,0]}return s}function SB(t,e,r,n){const i=ou(t,e,r);for(let o=0;o<n.length;o++)i[o]=n[o];Wc(t,e)}const Wye=Object.freeze(Object.defineProperty({__proto__:null,addColorLUT:Bye,getSegmentIndexColor:ou,setColorLUT:Gye,setSegmentIndexColor:SB},Symbol.toStringTag,{value:"Module"}));function TB(t,e){return $n.getSegmentationRepresentationVisibility(t,e)}function _B({segmentationId:t,segmentIndex:e,viewportId:r,autoGenerated:n=!1}){const i=ou(r,t,e),o=TB(r,{segmentationId:t,type:St.Contour}),a=Od(r),s=(a==null?void 0:a.segmentationId)===t,l=Ua.getStyle({viewportId:r,segmentationId:t,type:St.Contour,segmentIndex:e});let f=1,u,d=1,h=0;n?(f=l.outlineWidthAutoGenerated??f,u=l.outlineDashAutoGenerated??u,d=l.outlineOpacity??d,h=l.fillAlphaAutoGenerated??h):s?(f=l.outlineWidth??f,u=l.outlineDash??u,d=l.outlineOpacity??d,h=l.fillAlpha??h):(f=l.outlineWidthInactive??f,u=l.outlineDashInactive??u,d=l.outlineOpacityInactive??d,h=l.fillAlphaInactive??h),va(t)===e&&(f+=l.activeSegmentOutlineWidthDelta),f=l.renderOutline?f:0,h=l.renderFill?h:0;const g=`rgba(${i[0]}, ${i[1]}, ${i[2]}, ${d})`,p=`rgb(${i[0]}, ${i[1]}, ${i[2]})`,y=!GE(r,{segmentationId:t,type:St.Contour}).has(e);return{color:g,fillColor:p,lineWidth:f,fillOpacity:h,lineDash:u,textbox:{color:g},visibility:o&&y}}const nb=class nb extends fye{constructor(e,r){var n;super(e,r),(n=this.configuration.interpolation)!=null&&n.enabled&&Qc.addTool(this.getToolName())}isContourSegmentationTool(){return!0}createAnnotation(e){const r=e.detail,{element:n}=r,i=Le(n);if(!i)return;const{viewport:o}=i,a=super.createAnnotation(e);if(!this.isContourSegmentationTool())return a;const s=Od(o.id);if(!s)throw new Error("No active segmentation detected, create one before using scissors tool");if(!s.representationData.Contour)throw new Error("A contour segmentation must be active");const{segmentationId:c}=s,l=va(c);return Ti(a,{data:{segmentation:{segmentationId:c,segmentIndex:l}}})}addAnnotation(e,r){const n=super.addAnnotation(e,r);return this.isContourSegmentationTool()&&nu(e),n}cancelAnnotation(e){this.isContourSegmentationTool()&&tu(e),super.cancelAnnotation(e)}getAnnotationStyle(e){const r=super.getAnnotationStyle(e);if(!this.isContourSegmentationTool())return r;const n=this._getContourSegmentationStyle(e);return Ti(r,n)}renderAnnotationInstance(e){const{annotation:r}=e,{invalidated:n}=r,i=super.renderAnnotationInstance(e);if(n&&this.isContourSegmentationTool()){const{segmentationId:o}=r.data.segmentation;lo(o);const s=tg(o).map(c=>vr(c).id);xB(s)}return i}_getContourSegmentationStyle(e){const r=e.annotation,{segmentationId:n,segmentIndex:i}=r.data.segmentation,{viewportId:o}=e.styleSpecifier,a=pa(o,{segmentationId:n});if(!(a!=null&&a.length))return{};a.length>1?a.find(v=>v.segmentationId===n&&v.type===St.Contour):a[0];const{autoGenerated:s}=r,l=zd(n).includes(i),{color:f,fillColor:u,lineWidth:d,fillOpacity:h,lineDash:g,visibility:p}=_B({segmentationId:n,segmentIndex:i,viewportId:o,autoGenerated:s});return{color:f,fillColor:u,lineWidth:d,fillOpacity:h,lineDash:g,textbox:{color:f},visibility:p,locked:l}}};nb.PreviewSegmentIndex=255;let L1=nb;function EB(t,e){const r=ct("generalSeriesModule",t);return fu(r.modality,t,e)}function fu(t,e,r){return t==="CT"?"HU":t==="PT"?zye(e,r):""}function zye(t,e){if(!e.isPreScaled)return"raw";if(e.isSuvScaled)return"SUV";const r=ct("generalSeriesModule",t);if((r==null?void 0:r.modality)==="PT"){const n=ct("petSeriesModule",t);return(n==null?void 0:n.units)||"unitless"}return"unknown"}const{pointCanProjectOnLine:jI}=Tf,{EPSILON:$ye}=xf,jye=1-$ye,rb=class rb extends L1{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{storePointData:!1,shadow:!0,preventHandleOutsideImage:!1,contourHoleAdditionModifierKey:Ri.Shift,alwaysRenderOpenContourHandles:{enabled:!1,radius:2},allowOpenContours:!0,closeContourProximity:10,checkCanvasEditFallbackProximity:6,makeClockWise:!0,subPixelResolution:4,smoothing:{smoothOnAdd:!1,smoothOnEdit:!1,knotsRatioPercentageOnAdd:40,knotsRatioPercentageOnEdit:40},interpolation:{enabled:!1,onInterpolationComplete:null},decimate:{enabled:!1,epsilon:.1},displayOnePointAsCrosshairs:!1,calculateStats:!0,getTextLines:Hye,statsCalculator:al}}){super(e,r),this.isDrawing=!1,this.isEditingClosed=!1,this.isEditingOpen=!1,this.addNewAnnotation=n=>{const i=n.detail,{element:o}=i,a=this.createAnnotation(n);this.addAnnotation(a,o);const s=wt(o,this.getToolName());return this.activateDraw(n,a,s),n.preventDefault(),We(s),a},this.handleSelectedCallback=(n,i,o)=>{const a=n.detail,{element:s}=a,c=wt(s,this.getToolName());this.activateOpenContourEndEdit(n,i,c,o)},this.toolSelectedCallback=(n,i)=>{const o=n.detail,{element:a}=o,s=wt(a,this.getToolName());i.data.contour.closed?this.activateClosedContourEdit(n,i,s):this.activateOpenContourEdit(n,i,s),n.preventDefault()},this.isPointNearTool=(n,i,o,a)=>{const s=Le(n),{viewport:c}=s,{polyline:l}=i.data.contour;let f=c.worldToCanvas(l[0]);for(let h=1;h<l.length;h++){const g=f,p=c.worldToCanvas(l[h]);if(jI(o,g,p,a))return!0;f=p}if(!i.data.contour.closed)return!1;const u=c.worldToCanvas(l[0]),d=c.worldToCanvas(l[l.length-1]);return jI(o,u,d,a)},this.cancel=n=>{const i=this.isDrawing,o=this.isEditingOpen,a=this.isEditingClosed;i?this.cancelDrawing(n):o?this.cancelOpenContourEdit(n):a&&this.cancelClosedContourEdit(n)},this._calculateCachedStats=(n,i,o,a)=>{const{data:s}=n,{cachedStats:c}=s,{polyline:l,closed:f}=s.contour,u=Object.keys(c);for(let h=0;h<u.length;h++){const g=u[h],p=this.getTargetImageData(g);if(!p)continue;const{imageData:v,metadata:y}=p,m=l.map(I=>i.worldToCanvas(I)),w={isPreScaled:uu(i,g),isSuvScaled:this.isSuvScaled(i,g,n.metadata.referencedImageId)},x=fu(y.Modality,n.metadata.referencedImageId,w),C=ya(p,()=>{const I=s.contour.polyline,P=I.length,O=new Array(P);for(let ce=0;ce<P;ce++)O[ce]=i.worldToCanvas(I[ce]);const{maxX:L,maxY:B,minX:H,minY:A}=ff(O),F=i.canvasToWorld([H,A]),G=Lr(v,F),X=i.canvasToWorld([L,B]),ee=Lr(v,X);return[G,ee]}),S=m[0],T=i.canvasToWorld(S),_=i.canvasToWorld([S[0]+1,S[1]]),E=i.canvasToWorld([S[0],S[1]+1]),b=Fi(T,_),D=Fi(T,E);f?this.updateClosedCachedStats({targetId:g,viewport:i,canvasCoordinates:m,points:l,imageData:v,metadata:y,cachedStats:c,modalityUnit:x,calibratedScale:C,deltaInX:b,deltaInY:D}):this.updateOpenCachedStats({metadata:y,canvasCoordinates:m,targetId:g,cachedStats:c,modalityUnit:x,calibratedScale:C,deltaInX:b,deltaInY:D})}const d=n.invalidated;return n.invalidated=!1,d&&Kt(n,a.viewport.element,Bt.StatsUpdated),c},this._renderStats=(n,i,o,a)=>{const{data:s}=n,c=this.getTargetId(i),l={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:o.viewport.id,annotationUID:n.annotationUID},f=this.getLinkedTextBoxStyle(l,n);if(!f.visibility)return;const u=this.configuration.getTextLines(s,c);if(!u||u.length===0)return;const d=s.contour.polyline.map(x=>i.worldToCanvas(x));if(!s.handles.textBox.hasMoved){const x=wa(d);s.handles.textBox.worldPosition=i.canvasToWorld(x)}const h=i.worldToCanvas(s.handles.textBox.worldPosition),p=Ji(a,n.annotationUID??"","1",u,h,d,{},f),{x:v,y,width:m,height:w}=p;s.handles.textBox.worldBoundingBox={topLeft:i.canvasToWorld([v,y]),topRight:i.canvasToWorld([v+m,y]),bottomLeft:i.canvasToWorld([v,y+w]),bottomRight:i.canvasToWorld([v+m,y+w])}},mve(this),_ve(this),Ave(this),Kve(this),Yve(this),cye(this),this._throttledCalculateCachedStats=Lo(this._calculateCachedStats,100,{trailing:!0})}filterInteractableAnnotationsForElement(e,r){if(!r||!r.length)return;const n=Le(e),{viewport:i}=n;let o;if(i instanceof Zn){const a=i.getCamera(),{spacingInNormalDirection:s}=Hh(i,a);o=this.filterAnnotationsWithinSlice(r,a,s)}else o=Im(i,r);return o}filterAnnotationsWithinSlice(e,r,n){const{viewPlaneNormal:i}=r,o=e.filter(l=>{let f=l.metadata.viewPlaneNormal;if(!l.metadata.referencedImageId&&!f&&l.metadata.FrameOfReferenceUID){for(const d of l.data.contour.polyline){const h=hn(Ke(),d,r.focalPoint),g=xt(h,r.viewPlaneNormal);if(!Vt(g,0))return!1}return l.metadata.viewPlaneNormal=r.viewPlaneNormal,l.metadata.cameraFocalPoint=r.focalPoint,!0}if(!f){const{referencedImageId:d}=l.metadata,{imageOrientationPatient:h}=ct("imagePlaneModule",d),g=Tt(h[0],h[1],h[2]),p=Tt(h[3],h[4],h[5]);f=Ke(),Tn(f,g,p),l.metadata.viewPlaneNormal=f}const u=Math.abs(xt(i,f))>jye;return f&&u});if(!o.length)return[];const a=n/2,{focalPoint:s}=r,c=[];for(const l of o){const u=l.data.contour.polyline[0];if(!l.isVisible)continue;const d=Ke();hn(d,s,u);const h=xt(d,i);Math.abs(h)<a&&c.push(l)}return c}isContourSegmentationTool(){return!1}createAnnotation(e){const r=e.detail.currentPoints.world,n=super.createAnnotation(e),i=a=>{a.data.handles.points.length=0};return Ti(n,{data:{contour:{polyline:[[...r]]},label:"",cachedStats:{}},onInterpolationComplete:i})}getAnnotationStyle(e){return super.getAnnotationStyle(e)}renderAnnotationInstance(e){const{enabledElement:r,targetId:n,svgDrawingHelper:i}=e,o=e.annotation;let a=!1;const{viewport:s,renderingEngine:c}=r,l=this.isDrawing,f=this.isEditingOpen,u=this.isEditingClosed;if(!(l||f||u))this.configuration.displayOnePointAsCrosshairs&&o.data.contour.polyline.length===1?this.renderPointContourWithMarker(r,i,o):this.renderContour(r,i,o);else{const d=this.commonData.annotation.annotationUID;if(o.annotationUID===d)if(l)this.renderContourBeingDrawn(r,i,o);else if(u)this.renderClosedContourBeingEdited(r,i,o);else if(f)this.renderOpenContourBeingEdited(r,i,o);else throw new Error(`Unknown ${this.getToolName()} annotation rendering state`);else this.configuration.displayOnePointAsCrosshairs&&o.data.contour.polyline.length===1?this.renderPointContourWithMarker(r,i,o):this.renderContour(r,i,o);a=!0}if(this.configuration.calculateStats)return this._calculateStatsIfActive(o,n,s,c,r),this._renderStats(o,s,r,i),a}_calculateStatsIfActive(e,r,n,i,o){var s,c,l,f;const a=(s=this.commonData)==null?void 0:s.annotation.annotationUID;if(!(e.annotationUID===a&&!((c=this.commonData)!=null&&c.movingTextBox))&&!((l=this.commonData)!=null&&l.movingTextBox)){const{data:u}=e;(f=u.cachedStats[r])!=null&&f.unit?e.invalidated&&this._throttledCalculateCachedStats(e,n,i,o):(u.cachedStats[r]={Modality:null,area:null,max:null,mean:null,stdDev:null,areaUnit:null,unit:null},this._calculateCachedStats(e,n,i,o))}}updateClosedCachedStats({viewport:e,points:r,imageData:n,metadata:i,cachedStats:o,targetId:a,modalityUnit:s,canvasCoordinates:c,calibratedScale:l,deltaInX:f,deltaInY:u}){var X,ee,ce,Se;const{scale:d,areaUnit:h,unit:g}=l,{voxelManager:p}=e.getImageData(),v=Lr(n,r[0]);v[0]=Math.floor(v[0]),v[1]=Math.floor(v[1]),v[2]=Math.floor(v[2]);let y=v[0],m=v[0],w=v[1],x=v[1],C=v[2],S=v[2];for(let we=1;we<r.length;we++){const _e=Lr(n,r[we]);_e[0]=Math.floor(_e[0]),_e[1]=Math.floor(_e[1]),_e[2]=Math.floor(_e[2]),y=Math.min(y,_e[0]),m=Math.max(m,_e[0]),w=Math.min(w,_e[1]),x=Math.max(x,_e[1]),C=Math.min(C,_e[2]),S=Math.max(S,_e[2])}const T=Lr(n,r[1]);T[0]=Math.floor(T[0]),T[1]=Math.floor(T[1]),T[2]=Math.floor(T[2]);let _=Em(c)/d/d;_*=f*u;let E=XS(c,closed)/d;E*=Math.sqrt(Math.pow(f,2)+Math.pow(u,2));const b=.01*(m-y),D=.01*(x-w),I=.01*(S-C);y=Math.floor(y-b),m=Math.ceil(m+b),w=Math.floor(w-D),x=Math.ceil(x+D),C=Math.floor(C-I),S=Math.ceil(S+I);const P=[[y,m],[w,x],[C,S]],O=n.indexToWorld([m,x,S]),L=e.worldToCanvas(O);let B=0,H=[],A=0,F;p&&(F=p.forEach(this.configuration.statsCalculator.statsCallback,{imageData:n,isInObject:(we,_e)=>{let Ve=!0;const Ge=e.worldToCanvas(we);return Ge[1]!=B&&(A=0,B=Ge[1],H=$U(c,Ge,[L[0],Ge[1]]),H.sort(function(Ne){return function(j,M){return j[Ne]===M[Ne]?0:j[Ne]<M[Ne]?-1:1}}(0))),H.length&&Ge[0]>H[0][0]&&(H.shift(),A++),A%2===0&&(Ve=!1),Ve},boundsIJK:P,returnPoints:this.configuration.storePointData}));const G=this.configuration.statsCalculator.getStatistics();o[a]={Modality:i.Modality,area:_,perimeter:E,mean:(X=G.mean)==null?void 0:X.value,max:(ee=G.max)==null?void 0:ee.value,min:(ce=G.min)==null?void 0:ce.value,stdDev:(Se=G.stdDev)==null?void 0:Se.value,statsArray:G.array,pointsInShape:F,areaUnit:h,modalityUnit:s,unit:g}}updateOpenCachedStats({targetId:e,metadata:r,canvasCoordinates:n,cachedStats:i,modalityUnit:o,calibratedScale:a,deltaInX:s,deltaInY:c}){const{scale:l,unit:f}=a;let u=XS(n,closed)/l;u*=Math.sqrt(Math.pow(s,2)+Math.pow(c,2)),i[e]={Modality:r.Modality,length:u,modalityUnit:o,unit:f}}};rb.toolName="PlanarFreehandROI";let gf=rb;function Hye(t,e){const r=t.cachedStats[e],{area:n,mean:i,stdDev:o,length:a,perimeter:s,max:c,min:l,isEmptyArea:f,unit:u,areaUnit:d,modalityUnit:h}=r||{},g=[];if(xr(n)){const p=f?"Area: Oblique not supported":`Area: ${Xt(n)} ${d}`;g.push(p)}return xr(i)&&g.push(`Mean: ${Xt(i)} ${h}`),xr(c)&&g.push(`Max: ${Xt(c)} ${h}`),xr(l)&&g.push(`Min: ${Xt(l)} ${h}`),xr(o)&&g.push(`Std Dev: ${Xt(o)} ${h}`),xr(s)&&g.push(`Perimeter: ${Xt(s)} ${u}`),xr(a)&&g.push(`${Xt(a)} ${u}`),g}const ib=class ib extends gf{constructor(e){const r=Ti({configuration:{calculateStats:!1,allowOpenContours:!1}},e);super(r)}isContourSegmentationTool(){return!0}renderAnnotationInstance(e){const r=e.annotation,{invalidated:n}=r,i=super.renderAnnotationInstance(e);if(n){const{segmentationId:o}=r.data.segmentation;lo(o)}return i}};ib.toolName="PlanarFreehandContourSegmentationTool";let sl=ib;const Kye={[St.Labelmap]:lB,[St.Contour]:sB,[St.Surface]:vU},W2=sl.toolName;class qye{constructor(){this._needsRender=new Set,this._animationFrameSet=!1,this._animationFrameHandle=null,this._getAllViewports=()=>Po().flatMap(r=>r.getViewports()),this._renderFlaggedSegmentations=()=>{this._throwIfDestroyed(),Array.from(this._needsRender).forEach(r=>{this._triggerRender(r)}),this._needsRender.clear(),this._animationFrameSet=!1,this._animationFrameHandle=null}}renderSegmentationsForViewport(e){const r=e?[e]:this._getViewportIdsForSegmentation();this._setViewportsToBeRenderedNextFrame(r)}renderSegmentation(e){const r=this._getViewportIdsForSegmentation(e);this._setViewportsToBeRenderedNextFrame(r)}_getViewportIdsForSegmentation(e){const r=this._getAllViewports(),n=[];for(const i of r){const o=i.id;if(e){const a=pa(o,{segmentationId:e});(a==null?void 0:a.length)>0&&n.push(o)}else{const a=pa(o);(a==null?void 0:a.length)>0&&n.push(o)}}return n}_throwIfDestroyed(){if(this.hasBeenDestroyed)throw new Error("this.destroy() has been manually called to free up memory, can not longer use this instance. Instead make a new one.")}_setViewportsToBeRenderedNextFrame(e){e.forEach(r=>{this._needsRender.add(r)}),this._render()}_render(){this._needsRender.size>0&&this._animationFrameSet===!1&&(this._animationFrameHandle=window.requestAnimationFrame(this._renderFlaggedSegmentations),this._animationFrameSet=!0)}_triggerRender(e){const r=pa(e);if(!(r!=null&&r.length))return;const{viewport:n}=Mn(e)||{};if(!n)return;const i=[],o=r.map(a=>{a.type===St.Contour&&this._addPlanarFreeHandToolIfAbsent(n);const s=Kye[a.type];try{const c=s.render(n,a);i.push(c)}catch(c){console.error(c)}return Promise.resolve({segmentationId:a.segmentationId,type:a.type})});Promise.allSettled(o).then(a=>{const s=a.filter(f=>f.status==="fulfilled").map(f=>f.value);function c(f){const{element:u,viewportId:d}=f.detail;u.removeEventListener(et.IMAGE_RENDERED,c),s.forEach(h=>{const g={viewportId:d,segmentationId:h.segmentationId,type:h.type};it(Ze,U.SEGMENTATION_RENDERED,{...g})})}n.element.addEventListener(et.IMAGE_RENDERED,c),n.render()})}_addPlanarFreeHandToolIfAbsent(e){W2 in Je.tools||xi(sl);const r=vr(e.id);r.hasTool(W2)||(r.addTool(W2),r.setToolPassive(W2))}}function ng(t){bB.renderSegmentationsForViewport(t)}function Kw(t){bB.renderSegmentation(t)}const bB=new qye;function Xye({modifiedSlicesToUse:t,representationData:e,type:r}){const n=$e.getVolume(e[r].volumeId);if(!n){console.warn("segmentation not found in cache");return}const{imageData:i,vtkOpenGLTexture:o}=n;let a;if((t==null?void 0:t.length)>0)a=t;else{const s=i.getDimensions()[2];a=[...Array(s).keys()]}a.forEach(s=>{o.setUpdatedFrame(s)}),i.modified()}function Yye({viewportIds:t,segmentationId:e}){t.forEach(r=>{let n=pa(r,{segmentationId:e});n=n.filter(i=>i.type===St.Labelmap),n.forEach(i=>{if(i.segmentationId!==e)return;const o=Mn(r);if(!o)return;const{viewport:a}=o;if(a instanceof Zn)return;const s=Tp(r,e);s!=null&&s.length&&s.forEach((c,l)=>{const f=c.actor.getMapper().getInputData(),u=iu(r,e),d=$e.getImage(u[l]);f.modified(),ww(f,d)})})})}const Jye=function(t){const{segmentationId:e,modifiedSlicesToUse:r}=t.detail,{representationData:n}=_n(e),i=tg(e),o=i.some(c=>{const{viewport:l}=Mn(c);return l instanceof Zn}),a=i.some(c=>{const{viewport:l}=Mn(c);return l instanceof Jn}),s=o&&a;i.forEach(c=>{const{viewport:l}=Mn(c);l instanceof Zn&&Xye({modifiedSlicesToUse:s?[]:r,representationData:n,type:St.Labelmap}),l instanceof Jn&&Yye({viewportIds:i,segmentationId:e})})},DB=function(t){const{segmentationId:e}=t.detail,{representationData:r}=_n(e);r.Labelmap&&Jye(t),Kw(e)},IB=function(t){const{segmentationId:e}=t.detail;Kw(e)};function OB(t,e){return $n.updateLabelmapSegmentationImageReferences(t,e)}const Zye=function(t){if(!t)return;const e=Le(t);if(!e)return;const{viewport:r}=e;r instanceof fr||(t.addEventListener(et.STACK_NEW_IMAGE,A1),t.addEventListener(et.IMAGE_RENDERED,A1))},Qye=function(t){t.removeEventListener(et.STACK_NEW_IMAGE,A1),t.removeEventListener(et.IMAGE_RENDERED,A1)};function A1(t){const e=t.detail,{viewportId:r,renderingEngineId:n}=e,{viewport:i}=fi(r,n),o=pa(r);if(!(o!=null&&o.length))return;const a=o.filter(l=>l.type===St.Labelmap),s=i.getActors();a.forEach(l=>{const{segmentationId:f}=l;OB(r,f)});const c=a.flatMap(l=>Tp(r,l.segmentationId)).filter(l=>l!==void 0);c.length&&(c.forEach(l=>{a.find(u=>{const d=iu(r,u.segmentationId);return d==null?void 0:d.includes(l.referencedId)})||i.removeActors([l.uid])}),a.forEach(l=>{const{segmentationId:f}=l,u=i.getCurrentImageId(),d=iu(r,f);if(!d)return;const h=g=>{const p=$e.getImage(g);if(!p){console.warn("No derived image found in the cache for segmentation representation",l);return}const v=s.find(y=>y.referencedId===g);if(v){const y=v.actor.getMapper().getInputData();y.setDerivedImage?y.setDerivedImage(p):ww(y,p)}else{const{dimensions:y,spacing:m,direction:w}=i.getImageDataMetadata(p),x=$e.getImage(u)||{imageId:u},{origin:C}=i.getImageDataMetadata(x),S=C,T=p.voxelManager.getConstructor(),_=p.voxelManager.getScalarData(),E=bt.newInstance({name:"Pixels",numberOfComponents:1,values:new T(_)}),b=nm.newInstance();b.setDimensions(y[0],y[1],1),b.setSpacing(m),b.setDirection(w),b.setOrigin(S),b.getPointData().setScalars(E),b.modified(),i.addImages([{imageId:g,representationUID:`${f}-${St.Labelmap}-${p.imageId}`,callback:({imageActor:D})=>{D.getMapper().setInputData(b)}}]),ng(r);return}};d.forEach(h),i.render(),t.type===et.IMAGE_RENDERED&&i.element.removeEventListener(et.IMAGE_RENDERED,A1)}))}const MB={enable:Zye,disable:Qye};async function e5e(t){const e=t.detail.annotation;if(!Dm(e))return;const r=n5e(e),n=r5e(r,e);if(!n.length){it(Ze,U.ANNOTATION_CUT_MERGE_PROCESS_COMPLETED,{element:r.element,sourceAnnotation:e});return}const i=hf(e.data.contour.polyline,r),o=rB(r,i,n);if(!o.length){it(Ze,U.ANNOTATION_CUT_MERGE_PROCESS_COMPLETED,{element:r.element,sourceAnnotation:e});return}if(o.length>1){iB(r,e,i,o);return}const{targetAnnotation:a,targetPolyline:s,isContourHole:c}=o[0];if(c){const{contourHoleProcessingEnabled:l=!1}=t.detail;if(!l)return;Bw(r,a,e)}else o8(r,a,s,e,i)}function t5e(t,e=!1){const r="PlanarFreehandContourSegmentationTool",n=vr(t.id,t.renderingEngineId);let i;return n?n.hasTool(r)?n.getToolOptions(r)||(i=`Tool ${r} must be in active/passive state in ${n.id} toolGroup`):i=`Tool ${r} not added to ${n.id} toolGroup`:i=`ToolGroup not found for viewport ${t.id}`,i&&!e&&console.warn(i),!i}function n5e(t){const e=c8(t);return e.find(n=>t5e(n,!0))??e[0]}function r5e(t,e){const{annotationUID:r}=e;return vm().filter(i=>i.annotationUID&&i.annotationUID!==r&&Dm(i)&&yU(i,e)&&t.isReferenceViewable(i.metadata))}function i5e(t){const e=t.detail.annotation;tu(e)}function PB(t){const e=t.detail.annotation;Dm(e)&&e5e(t)}function v5(t){if(!t.detail.removed.length)return;Po().forEach(n=>{const o=n.getViewports().map(a=>a.id);We(o)})}function RB(t){const{viewportId:e}=t.detail;We([e])}function o5e(t){const e=t.detail.annotation;Dm(e)&&i5e(t)}const LB=function(t){Zh(t.detail.element)},a5e=function(t){t.addEventListener(et.IMAGE_RENDERED,LB)},s5e=function(t){t.removeEventListener(et.IMAGE_RENDERED,LB)},AB={enable:a5e,disable:s5e},{Active:c5e}=En;function rg(t,e,r){if(Je.isInteractingWithTool)return!1;const{renderingEngineId:n,viewportId:i}=r.detail,o=vr(i,n);if(!o)return!1;let a;const s=Object.keys(o.toolOptions);for(let c=0;c<s.length;c++){const l=s[c],f=o.toolOptions[l],u=o.getToolInstance(l);if(f.mode===c5e&&typeof u[e]=="function"){a=o.getToolInstance(l);break}}a&&a[e](r)}const NB=rg.bind(null,"Mouse","mouseClickCallback"),kB=rg.bind(null,"Mouse","doubleClickCallback");function VB(t,e,r,n="mouse"){const i=n==="touch"?36:6,o=[];return e.forEach(({tool:a,annotations:s})=>{for(const c of s){if(c.isLocked||!c.isVisible)continue;const l=a.getHandleNearImagePoint(t,c,r,i);if(l){o.push({tool:a,annotation:c,handle:l});break}}}),o}function Mm(t,e){const r=[];for(let n=0;n<e.length;n++){const i=e[n];if(!i){console.warn("undefined tool in filterToolsWithAnnotationsForElement");continue}let o=Jt(i.constructor.toolName,t);o!=null&&o.length&&(typeof i.filterInteractableAnnotationsForElement=="function"&&(o=i.filterInteractableAnnotationsForElement(t,o)),(o==null?void 0:o.length)>0&&r.push({tool:i,annotations:o}))}return r}function m8(t,e,r,n="mouse"){const i=n==="touch"?36:6,o=[];return e.forEach(({tool:a,annotations:s})=>{for(const c of s){if(c.isLocked||!c.isVisible)continue;if(a.isPointNearTool(t,c,r,i,n)){o.push({tool:a,annotation:c});break}}}),o}const{Active:l5e}=En;function qw(t){const{renderingEngineId:e,viewportId:r,event:n}=t.detail,i=eg(n)||Yh.getModifierKey(),o=vr(r,e);if(!o)return null;const a=Object.keys(o.toolOptions),s=o.getDefaultMousePrimary(),c=t.detail.buttons??(n==null?void 0:n.buttons)??s;for(let l=0;l<a.length;l++){const f=a[l],u=o.toolOptions[f],d=u.bindings.length&&u.bindings.some(h=>h.mouseButton===c&&h.modifierKey===i);if(u.mode===l5e&&d)return o.getToolInstance(f)}}function Oh(t,e,r){const{renderingEngineId:n,viewportId:i}=t.detail,o=vr(i,n);if(!o)return[];const a=[],s=Object.keys(o.toolOptions);for(let c=0;c<s.length;c++){const l=s[c],f=o.toolOptions[l],u=r!=null&&f.bindings.length&&f.bindings.some(d=>d.mouseButton===r);if(e.includes(f.mode)&&(!r||u)){const d=o.getToolInstance(l);a.push(d)}}return a}function u5e(t,e){var u;const r=new Map,{renderingEngineId:n,viewportId:i}=t.detail,o=vr(i,n);if(!o)return r;const a=Object.keys(o.toolOptions),s=o.getDefaultMousePrimary(),c=t.detail.event,l=(c==null?void 0:c.buttons)??s,f=eg(c)||Yh.getModifierKey();for(let d=0;d<a.length;d++){const h=a[d],g=o.getToolInstance(h),p=((u=g.configuration)==null?void 0:u.actions)??{},v=Object.values(p);if(!(v!=null&&v.length)||!e.includes(g.mode))continue;const y=v.find(m=>{var w;return((w=m.bindings)==null?void 0:w.length)&&m.bindings.some(x=>x.mouseButton===l&&x.modifierKey===f)});y&&r.set(g,y)}return r}const{Active:f5e,Passive:d5e}=En;function h5e(t){if(Je.isInteractingWithTool)return!1;const e=t.detail,{element:r}=e,n=Le(r),{canvas:i}=e.currentPoints;if(!n)return!1;const o=u5e(t,[f5e,d5e]),a=Array.from(o.keys()),s=Mm(r,a),c=m8(r,s,i);if(c.length>0){const{tool:l,annotation:f}=c[0],u=o.get(l);return(typeof u.method=="string"?l[u.method]:u.method).call(l,t,f),!0}return!1}const{Active:g5e,Passive:p5e}=En;function FB(t){if(Je.isInteractingWithTool)return;const e=qw(t);if(e&&typeof e.preMouseDownCallback=="function"&&e.preMouseDownCallback(t))return;const r=t.detail.event.buttons===1,n=Oh(t,[g5e],t.detail.event.buttons),i=r?Oh(t,[p5e]):void 0,o=[...n||[],...i||[]];if(h5e(t))return;const s=t.detail,{element:c}=s,l=Mm(c,o),f=s.currentPoints.canvas,u=VB(c,l,f,"mouse"),d=!!t.detail.event.shiftKey;if(u.length>0){const{tool:g,annotation:p,handle:v}=HI(u);KI(p.annotationUID,d),g.handleSelectedCallback(t,p,v,"Mouse");return}const h=m8(c,l,f,"mouse");if(h.length>0){const{tool:g,annotation:p}=HI(h);KI(p.annotationUID,d),g.toolSelectedCallback(t,p,"Mouse",f);return}e&&typeof e.postMouseDownCallback=="function"&&e.postMouseDownCallback(t)}function HI(t){if(t.length>1){const e=t.find(r=>{const n=!Yr(r.annotation.annotationUID),i=Vr(r.annotation.annotationUID);return n&&i});if(e)return e}return t[0]}function KI(t,e=!1){e?Sm(t)?qo(t,!1):qo(t,!0,!0):qo(t,!0,!1)}function UB(t){if(Je.isInteractingWithTool)return;const e=qw(t);if(e&&!Je.isMultiPartToolActive&&e.addNewAnnotation){const r=e.addNewAnnotation(t,"mouse");qo(r.annotationUID)}}function BB(t){if(Je.isInteractingWithTool)return;const e=qw(t);!e||typeof e.mouseDragCallback!="function"||e.mouseDragCallback(t)}const{Active:m5e,Passive:v5e}=En;function GB(t){if(Je.isInteractingWithTool||Je.isMultiPartToolActive)return;const e=Oh(t,[m5e,v5e]),r=t.detail,{element:n}=r,i=Mm(n,e),o=e.filter(s=>!i.some(l=>l.tool.getToolName()===s.getToolName()));let a=!1;for(const{tool:s,annotations:c}of i)typeof s.mouseMoveCallback=="function"&&(a=s.mouseMoveCallback(t,c)||a);o.forEach(s=>{typeof s.mouseMoveCallback=="function"&&s.mouseMoveCallback(t)}),a===!0&&Zh(n)}const WB=rg.bind(null,"Mouse","mouseUpCallback");function zB(t){if(Je.isInteractingWithTool)return;t.detail.buttons=ol.Wheel|(t.detail.event.buttons||0);const e=qw(t);if(e)return e.mouseWheelCallback(t)}const y5e=function(t){t.addEventListener(U.MOUSE_CLICK,NB),t.addEventListener(U.MOUSE_DOWN,FB),t.addEventListener(U.MOUSE_DOWN_ACTIVATE,UB),t.addEventListener(U.MOUSE_DOUBLE_CLICK,kB),t.addEventListener(U.MOUSE_DRAG,BB),t.addEventListener(U.MOUSE_MOVE,GB),t.addEventListener(U.MOUSE_UP,WB),t.addEventListener(U.MOUSE_WHEEL,zB)},w5e=function(t){t.removeEventListener(U.MOUSE_CLICK,NB),t.removeEventListener(U.MOUSE_DOWN,FB),t.removeEventListener(U.MOUSE_DOWN_ACTIVATE,UB),t.removeEventListener(U.MOUSE_DOUBLE_CLICK,kB),t.removeEventListener(U.MOUSE_DRAG,BB),t.removeEventListener(U.MOUSE_MOVE,GB),t.removeEventListener(U.MOUSE_UP,WB),t.removeEventListener(U.MOUSE_WHEEL,zB)},$B={enable:y5e,disable:w5e},{Active:x5e}=En;function jB(t){const{renderingEngineId:e,viewportId:r}=t.detail,n=Ape(),i=Yh.getModifierKey(),o=vr(r,e);if(!o)return null;const a=Object.keys(o.toolOptions),s=o.getDefaultMousePrimary();for(let c=0;c<a.length;c++){const l=a[c],f=o.toolOptions[l];if(f.mode!==x5e)continue;if(f.bindings.length&&f.bindings.some(d=>d.mouseButton===(n??s)&&d.modifierKey===i))return o.getToolInstance(l)}}function C5e(t,e){var c;const r=new Map,{renderingEngineId:n,viewportId:i}=t.detail,o=vr(i,n);if(!o)return r;const a=Object.keys(o.toolOptions),s=t.detail.key;for(let l=0;l<a.length;l++){const f=a[l],u=o.getToolInstance(f),d=(c=u.configuration)==null?void 0:c.actions;if(!d)continue;const h=Object.values(d);if(!(h!=null&&h.length)||!e.includes(u.mode))continue;const g=h.find(p=>{var v;return(v=p.bindings)==null?void 0:v.some(y=>y.key===s)});g&&r.set(u,g)}return r}function HB(t){const e=jB(t);if(e){const{renderingEngineId:n,viewportId:i}=t.detail,o=vr(i,n),a=e.getToolName();Object.keys(o.toolOptions).includes(a)&&o.setViewportsCursorByToolName(a)}const r=C5e(t,[En.Active]);if(r!=null&&r.size){const{element:n}=t.detail;for(const[i,o]of[...r.entries()])(typeof o.method=="function"?o.method:i[o.method]).call(i,n,o,t)}}function KB(t){const e=jB(t);if(!e)return;const{renderingEngineId:r,viewportId:n}=t.detail,i=vr(n,r);cU();const o=e.getToolName();Object.keys(i.toolOptions).includes(o)&&i.setViewportsCursorByToolName(o)}const S5e=function(t){t.addEventListener(U.KEY_DOWN,HB),t.addEventListener(U.KEY_UP,KB)},T5e=function(t){t.removeEventListener(U.KEY_DOWN,HB),t.removeEventListener(U.KEY_UP,KB)},qB={enable:S5e,disable:T5e},{Active:_5e,Passive:E5e,Enabled:b5e}=En,XB=function(t){Oh(t,[_5e,E5e,b5e]).forEach(r=>{r.onCameraModified&&r.onCameraModified(t)})},D5e=function(t){t.addEventListener(et.CAMERA_MODIFIED,XB)},I5e=function(t){t.removeEventListener(et.CAMERA_MODIFIED,XB)},YB={enable:D5e,disable:I5e},{Active:O5e,Passive:M5e,Enabled:P5e}=En,JB=function(t){Oh(t,[O5e,M5e,P5e]).forEach(r=>{r.onImageSpacingCalibrated&&r.onImageSpacingCalibrated(t)})},R5e=function(t){t.addEventListener(et.IMAGE_SPACING_CALIBRATED,JB)},L5e=function(t){t.removeEventListener(et.IMAGE_SPACING_CALIBRATED,JB)},ZB={enable:R5e,disable:L5e},{Active:A5e}=En;function v8(t){const{renderingEngineId:e,viewportId:r}=t.detail,n=t.detail.event,i=vr(r,e);if(!i)return null;const o=Object.keys(i.toolOptions),a=Object.keys(n.touches).length,s=eg(n)||Yh.getModifierKey(),c=i.getDefaultMousePrimary();for(let l=0;l<o.length;l++){const f=o[l],u=i.toolOptions[f],d=u.bindings.length&&u.bindings.some(h=>(h.numTouchPoints===a||a===1&&h.mouseButton===c)&&h.modifierKey===s);if(u.mode===A5e&&d)return i.getToolInstance(f)}}function qI(t,e,r){const{renderingEngineId:n,viewportId:i}=t.detail,o=vr(i,n);if(!o)return[];const a=[],s=Object.keys(o.toolOptions);for(let c=0;c<s.length;c++){const l=s[c],f=o.toolOptions[l],u=r!=null&&f.bindings.length&&f.bindings.some(d=>d.numTouchPoints===r);if(e.includes(f.mode)&&(!r||u)){const d=o.getToolInstance(l);a.push(d)}}return a}const{Active:N5e,Passive:k5e}=En;function QB(t){if(Je.isInteractingWithTool)return;const e=v8(t);if(e&&typeof e.preTouchStartCallback=="function"&&e.preTouchStartCallback(t))return;const r=Object.keys(t.detail.event.touches).length===1,n=qI(t,[N5e],Object.keys(t.detail.event.touches).length),i=r?qI(t,[k5e]):void 0,o=[...n||[],...i||[],e],a=t.detail,{element:s}=a,c=Mm(s,o),l=a.currentPoints.canvas,f=VB(s,c,l,"touch"),u=!1;if(f.length>0){const{tool:h,annotation:g,handle:p}=XI(f);YI(g.annotationUID,u),h.handleSelectedCallback(t,g,p,"Touch");return}const d=m8(s,c,l,"touch");if(d.length>0){const{tool:h,annotation:g}=XI(d);YI(g.annotationUID,u),h.toolSelectedCallback(t,g,"Touch",l);return}e&&typeof e.postTouchStartCallback=="function"&&e.postTouchStartCallback(t)}function XI(t){return t.length>1&&t.find(e=>!Yr(e.annotation.annotationUID)&&Vr(e.annotation.annotationUID))||t[0]}function YI(t,e=!1){e?Sm(t)?qo(t,!1):qo(t,!0,!0):qo(t,!0,!1)}function eG(t){if(Je.isInteractingWithTool)return;const e=v8(t);if(e&&!Je.isMultiPartToolActive&&e.addNewAnnotation){const r=e.addNewAnnotation(t,"touch");qo(r.annotationUID)}}function tG(t){if(Je.isInteractingWithTool)return;const e=v8(t);!e||typeof e.touchDragCallback!="function"||e.touchDragCallback(t)}const nG=rg.bind(null,"Touch","touchEndCallback"),V5e=rg.bind(null,"Touch","touchTapCallback"),rG=rg.bind(null,"Touch","touchPressCallback"),F5e=function(t){t.addEventListener(U.TOUCH_START,QB),t.addEventListener(U.TOUCH_START_ACTIVATE,eG),t.addEventListener(U.TOUCH_DRAG,tG),t.addEventListener(U.TOUCH_END,nG),t.addEventListener(U.TOUCH_TAP,V5e),t.addEventListener(U.TOUCH_PRESS,rG)},U5e=function(t){t.removeEventListener(U.TOUCH_START,QB),t.removeEventListener(U.TOUCH_START_ACTIVATE,eG),t.removeEventListener(U.TOUCH_DRAG,tG),t.removeEventListener(U.TOUCH_END,nG),t.removeEventListener(U.TOUCH_PRESS,rG)},iG={enable:F5e,disable:U5e},B5e=function(){Ze.addEventListener(U.ANNOTATION_COMPLETED,Qc.handleAnnotationCompleted),Ze.addEventListener(U.ANNOTATION_MODIFIED,Qc.handleAnnotationUpdate),Ze.addEventListener(U.ANNOTATION_REMOVED,Qc.handleAnnotationDelete)},G5e=function(){Ze.removeEventListener(U.ANNOTATION_COMPLETED,Qc.handleAnnotationCompleted),Ze.removeEventListener(U.ANNOTATION_MODIFIED,Qc.handleAnnotationUpdate),Ze.removeEventListener(U.ANNOTATION_REMOVED,Qc.handleAnnotationDelete)},oG={enable:B5e,disable:G5e},{Active:W5e,Passive:z5e,Enabled:$5e}=En,aG=function(t){Oh(t,[W5e,z5e,$5e]).forEach(r=>{r.onResetCamera&&r.onResetCamera(t)})},j5e=function(t){t.addEventListener(et.CAMERA_RESET,aG)},H5e=function(t){t.removeEventListener(et.CAMERA_RESET,aG)},sG={enable:j5e,disable:H5e};function y8(t){const{element:e,viewportId:r}=t.detail,n=K5e(r);q5e(e),X5e(n,e),r8.addViewportElement(r,e),GF.enable(e),aU.enable(e),rU.enable(e),Yh.enable(e),MB.enable(e),AB.enable(e),YB.enable(e),ZB.enable(e),sG.enable(e),$B.enable(e),qB.enable(e),iG.enable(e),Je.enabledElements.push(e)}function K5e(t){const e="http://www.w3.org/2000/svg",r=document.createElementNS(e,"svg"),n=`svg-layer-${t}`;r.classList.add("svg-layer"),r.setAttribute("id",n),r.setAttribute("xmlns","http://www.w3.org/2000/svg"),r.style.width="100%",r.style.height="100%",r.style.pointerEvents="none",r.style.position="absolute";const i=document.createElementNS(e,"defs"),o=document.createElementNS(e,"filter"),a=document.createElementNS(e,"feOffset"),s=document.createElementNS(e,"feColorMatrix"),c=document.createElementNS(e,"feBlend");return o.setAttribute("id",`shadow-${n}`),o.setAttribute("filterUnits","userSpaceOnUse"),a.setAttribute("result","offOut"),a.setAttribute("in","SourceGraphic"),a.setAttribute("dx","0.5"),a.setAttribute("dy","0.5"),s.setAttribute("result","matrixOut"),s.setAttribute("in","offOut"),s.setAttribute("in2","matrix"),s.setAttribute("values","0.2 0 0 0 0 0 0.2 0 0 0 0 0 0.2 0 0 0 0 0 1 0"),c.setAttribute("in","SourceGraphic"),c.setAttribute("in2","matrixOut"),c.setAttribute("mode","normal"),o.appendChild(a),o.appendChild(s),o.appendChild(c),i.appendChild(o),r.appendChild(i),r}function q5e(t){const{viewportUid:e,renderingEngineUid:r}=t.dataset,n=`${e}:${r}`;Je.svgNodeCache[n]={}}function X5e(t,e){e.querySelector("div.viewport-element").appendChild(t)}function cG(t,e){const r=[];if(!e&&!t)throw new Error("At least one of renderingEngineId or viewportId should be given");for(let n=0;n<Je.synchronizers.length;n++){const i=Je.synchronizers[n],o=!i.isDisabled(),a=i.hasSourceViewport(e,t),s=i.hasTargetViewport(e,t);o&&(a||s)&&r.push(i)}return r}const Y5e="viewport-element";function w8(t){const{element:e,viewportId:r}=t.detail;Q5e(e),ewe(e),r8.removeViewportElement(r,e),GF.disable(e),aU.disable(e),rU.disable(e),Yh.disable(e),MB.disable(e),AB.disable(e),YB.disable(e),ZB.disable(e),sG.disable(e),$B.disable(e),qB.disable(e),iG.disable(e),J5e(e),Z5e(e),twe(e)}const J5e=t=>{const e=Le(t);if(!e)return;cG(e.viewportId,e.renderingEngineId).forEach(n=>{n.remove(e)})},Z5e=t=>{const e=Le(t);if(!e)return;const{renderingEngineId:r,viewportId:n}=e,i=vr(n,r);i&&i.removeViewports(r,n)};function Q5e(t){const{viewportUid:e,renderingEngineUid:r}=t.dataset,n=`${e}:${r}`;delete Je.svgNodeCache[n]}function ewe(t){const e=t.querySelector(`div.${Y5e}`),r=e.querySelector("svg");r&&e.removeChild(r)}const twe=function(t){const e=Je.enabledElements.findIndex(r=>r===t);e>-1&&Je.enabledElements.splice(e,1)};function lG(t){const e=YU(t,[En.Active,En.Passive]),r=Mm(t,e);for(const{tool:n}of r){const i=n.cancel(t);if(i)return i}}class x8{constructor(e,r,n,i){this._viewportOptions={},this._onEvent=o=>{var l;if(this._ignoreFiredEvents===!0||!this._targetViewports.length)return;const a=this._eventSource==="element"?Le(o.currentTarget):Mn((l=o.detail)==null?void 0:l.viewportId);if(!a)return;const{renderingEngineId:s,viewportId:c}=a;this._sourceViewports.find(f=>f.viewportId===c)&&this.fireEvent({renderingEngineId:s,viewportId:c},o)},this._enabled=!0,this._eventName=r,this._eventHandler=n,this._ignoreFiredEvents=!1,this._sourceViewports=[],this._targetViewports=[],this._options=i||{},this._eventSource=this._options.eventSource||"element",this._auxiliaryEvents=this._options.auxiliaryEvents||[],this.id=e}isDisabled(){return!this._enabled||!this._hasSourceElements()}setOptions(e,r={}){this._viewportOptions[e]=r}setEnabled(e){this._enabled=e}getOptions(e){return this._viewportOptions[e]}add(e){this.addTarget(e),this.addSource(e)}addSource(e){if(z2(this._sourceViewports,e))return;const{renderingEngineId:r,viewportId:n}=e,i=Nr(r).getViewport(n);if(!i){console.warn(`Synchronizer.addSource: No viewport for ${r} ${n}`);return}(this._eventSource==="element"?i.element:Ze).addEventListener(this._eventName,this._onEvent.bind(this)),this._auxiliaryEvents.forEach(({name:a,source:s})=>{(s==="element"?i.element:Ze).addEventListener(a,this._onEvent.bind(this))}),this._updateDisableHandlers(),this._sourceViewports.push(e)}addTarget(e){z2(this._targetViewports,e)||(this._targetViewports.push(e),this._updateDisableHandlers())}getSourceViewports(){return this._sourceViewports}getTargetViewports(){return this._targetViewports}destroy(){this._sourceViewports.forEach(e=>this.removeSource(e)),this._targetViewports.forEach(e=>this.removeTarget(e))}remove(e){this.removeTarget(e),this.removeSource(e)}removeSource(e){const r=JI(this._sourceViewports,e);if(r===-1)return;const n=this._eventSource==="element"?this.getViewportElement(e):Ze;this._sourceViewports.splice(r,1),n.removeEventListener(this._eventName,this._eventHandler),this._auxiliaryEvents.forEach(({name:i,source:o})=>{(o==="element"?this.getViewportElement(e):Ze).removeEventListener(i,this._eventHandler)}),this._updateDisableHandlers()}removeTarget(e){const r=JI(this._targetViewports,e);r!==-1&&(this._targetViewports.splice(r,1),this._updateDisableHandlers())}hasSourceViewport(e,r){return z2(this._sourceViewports,{renderingEngineId:e,viewportId:r})}hasTargetViewport(e,r){return z2(this._targetViewports,{renderingEngineId:e,viewportId:r})}fireEvent(e,r){if(this.isDisabled()||this._ignoreFiredEvents)return;this._ignoreFiredEvents=!0;const n=[];try{for(let i=0;i<this._targetViewports.length;i++){const o=this._targetViewports[i];if(e.viewportId===o.viewportId)continue;const s=this._eventHandler(this,e,o,r,this._options);s instanceof Promise&&n.push(s)}}catch(i){console.warn(`Synchronizer, for: ${this._eventName}`,i)}finally{n.length?Promise.allSettled(n).then(()=>{this._ignoreFiredEvents=!1}):this._ignoreFiredEvents=!1}}_hasSourceElements(){return this._sourceViewports.length!==0}_updateDisableHandlers(){const e=nwe(this._sourceViewports,this._targetViewports),r=this.remove.bind(this),n=i=>{r(i.detail.element)};e.forEach(i=>{const o=this.getEventSource(i);o&&(o.removeEventListener(et.ELEMENT_DISABLED,n),o.addEventListener(et.ELEMENT_DISABLED,n))})}getEventSource(e){return this._eventSource==="element"?this.getViewportElement(e):Ze}getViewportElement(e){const{renderingEngineId:r,viewportId:n}=e,i=Nr(r);if(!i)return null;const o=i.getViewport(n);return o?o.element:null}}function nwe(t,e){const r=[],n=t.concat(e);for(let i=0;i<n.length;i++){const o=n[i];r.some(a=>o.renderingEngineId===a.renderingEngineId&&o.viewportId===a.viewportId)||r.push(o)}return r}function JI(t,e){return t.findIndex(r=>e.renderingEngineId===r.renderingEngineId&&e.viewportId===r.viewportId)}function z2(t,e){return t.some(r=>r.renderingEngineId===e.renderingEngineId&&r.viewportId===e.viewportId)}function $d(t,e,r,n){if(Je.synchronizers.some(a=>a.id===t))throw new Error(`Synchronizer with id '${t}' already exists.`);const o=new x8(t,e,r,n);return Je.synchronizers.push(o),o}function rwe(){for(;Je.synchronizers.length>0;)Je.synchronizers.pop().destroy()}function iwe(t){return Je.synchronizers.find(e=>e.id===t)}function owe(){return Je.synchronizers}function awe(t){const e=Je.synchronizers.findIndex(r=>r.id===t);e>-1&&(Je.synchronizers[e].destroy(),Je.synchronizers.splice(e,1))}const uG=Object.freeze(Object.defineProperty({__proto__:null,createSynchronizer:$d,destroy:rwe,destroySynchronizer:awe,getAllSynchronizers:owe,getSynchronizer:iwe,getSynchronizersForViewport:cG},Symbol.toStringTag,{value:"Module"})),swe=Object.freeze(Object.defineProperty({__proto__:null,Synchronizer:x8,SynchronizerManager:uG,ToolGroupManager:_F,addEnabledElement:y8,addTool:xi,cancelActiveManipulations:lG,hasTool:xpe,removeEnabledElement:w8,removeTool:PF,get state(){return Je},svgNodeCache:Tw},Symbol.toStringTag,{value:"Module"})),y5=function(t){const{viewportId:e}=t.detail;ng(e)};let JS=!1;function fG(t={}){JS||(x1e(t),lwe(),uwe(),JS=!0)}function cwe(){dG(),hG(),SF(),Khe();const t=mc(),e=$n;t.restoreAnnotations({}),e.resetState(),JS=!1}function lwe(){dG();const t=et.ELEMENT_ENABLED,e=et.ELEMENT_DISABLED;Ze.addEventListener(t,y8),Ze.addEventListener(e,w8),oG.enable()}function dG(){const t=et.ELEMENT_ENABLED,e=et.ELEMENT_DISABLED;Ze.removeEventListener(t,y8),Ze.removeEventListener(e,w8),oG.disable()}function uwe(){hG(),Ze.addEventListener(U.ANNOTATION_COMPLETED,PB),Ze.addEventListener(U.ANNOTATION_MODIFIED,RB),Ze.addEventListener(U.ANNOTATION_SELECTION_CHANGE,v5),Ze.addEventListener(U.ANNOTATION_SELECTION_CHANGE,v5),Ze.addEventListener(U.ANNOTATION_REMOVED,o5e),Ze.addEventListener(U.SEGMENTATION_MODIFIED,IB),Ze.addEventListener(U.SEGMENTATION_DATA_MODIFIED,DB),Ze.addEventListener(U.SEGMENTATION_REPRESENTATION_MODIFIED,y5),Ze.addEventListener(U.SEGMENTATION_REPRESENTATION_ADDED,y5)}function hG(){Ze.removeEventListener(U.ANNOTATION_COMPLETED,PB),Ze.removeEventListener(U.ANNOTATION_MODIFIED,RB),Ze.removeEventListener(U.ANNOTATION_SELECTION_CHANGE,v5),Ze.removeEventListener(U.ANNOTATION_SELECTION_CHANGE,v5),Ze.removeEventListener(U.SEGMENTATION_MODIFIED,IB),Ze.removeEventListener(U.SEGMENTATION_DATA_MODIFIED,DB),Ze.removeEventListener(U.SEGMENTATION_REPRESENTATION_MODIFIED,y5),Ze.removeEventListener(U.SEGMENTATION_REPRESENTATION_ADDED,y5)}const fwe=Object.freeze(Object.defineProperty({__proto__:null,COLOR_LUT:m5},Symbol.toStringTag,{value:"Module"})),dwe="3.20.0";function hwe(t,e,r,n){const{camera:i}=n.detail,o=Nr(r.renderingEngineId);if(!o)throw new Error(`No RenderingEngine for Id: ${r.renderingEngineId}`);const a=o.getViewport(r.viewportId);a.setCamera(i),a.render()}const{CAMERA_MODIFIED:gwe}=et;function pwe(t){return $d(t,gwe,hwe)}function mwe(t,e,r,n,i){const o=Nr(r.renderingEngineId);if(!o)throw new Error(`No RenderingEngine for Id: ${r.renderingEngineId}`);const a=o.getViewport(r.viewportId),c=o.getViewport(e.viewportId).getViewPresentation(i);a.setViewPresentation(c),a.render()}const{CAMERA_MODIFIED:vwe}=et;function ywe(t,e){return $d(t,vwe,mwe,{viewPresentation:e})}function wwe(t,e,r,n,i){const o=n.detail,{volumeId:a,range:s,invertStateChanged:c,invert:l,colormap:f}=o,u=Nr(r.renderingEngineId);if(!u)throw new Error(`Rendering Engine does not exist: ${r.renderingEngineId}`);const d=u.getViewport(r.viewportId),h={voiRange:s};if(i!=null&&i.syncInvertState&&c&&(h.invert=l),i!=null&&i.syncColormap&&f&&(h.colormap=f),d instanceof fr)d._actors&&d._actors.size>1?d.setProperties(h,a):d.setProperties(h);else if(d instanceof Jn)d.setProperties(h);else throw new Error("Viewport type not supported.");d.render()}function xwe(t,e){return e=Object.assign({syncInvertState:!0,syncColormap:!0},e),$d(t,et.VOI_MODIFIED,wwe,{auxiliaryEvents:[{name:et.COLORMAP_MODIFIED}],...e})}function Cwe(t,e,r){const n=Nr(r.renderingEngineId);if(!n)throw new Error(`No RenderingEngine for Id: ${r.renderingEngineId}`);const i=t.getOptions(r.viewportId),o=n.getViewport(r.viewportId),a=n.getViewport(e.viewportId);if((i==null?void 0:i.syncZoom)!==!1){const s=a.getZoom();o.setZoom(s)}if((i==null?void 0:i.syncPan)!==!1){const s=a.getPan();o.setPan(s)}o.render()}const{CAMERA_MODIFIED:Swe}=et;function Twe(t){return $d(t,Swe,Cwe)}function _we(t,e){const{viewPlaneNormal:r}=t.getCamera(),{viewPlaneNormal:n}=e.getCamera(),i=xt(r,n);return Math.abs(i)>.9}const ZI=(t,e)=>S1.get("spatialRegistrationModule",t,e);async function Ewe(t,e,r){const n=Nr(r.renderingEngineId);if(!n)throw new Error(`No RenderingEngine for Id: ${r.renderingEngineId}`);const i=n.getViewport(e.viewportId),o=t.getOptions(r.viewportId);if(o!=null&&o.disabled)return;const a=n.getViewport(r.viewportId),s=i.getCurrentImageId(),l=ct("imagePlaneModule",s).imagePositionPatient,f=a.getImageIds();if(!_we(i,a))return;let u=ZI(r.viewportId,e.viewportId);if(!u){const p=i.getFrameOfReferenceUID(),v=a.getFrameOfReferenceUID();if(p===v&&(o==null?void 0:o.useInitialPosition)!==!1?u=It(ma()):(DV(i,a),u=ZI(r.viewportId,e.viewportId)),!u)return}const d=At(Ke(),l,u),h=bwe(d,f);let g=h.index;a instanceof Zn&&(g=f.length-h.index-1),h.index!==-1&&a.getCurrentImageIdIndex()!==h.index&&await oa(a.element,{imageIndex:g})}function bwe(t,e){return e.reduce((r,n,i)=>{const{imagePositionPatient:o}=ct("imagePlaneModule",n),a=Fi(o,t);return a<r.distance?{distance:a,index:i}:r},{distance:1/0,index:-1})}const{STACK_NEW_IMAGE:Dwe,VOLUME_NEW_IMAGE:p8e}=et;function gG(t){return $d(t,Dwe,Ewe,{auxiliaryEvents:[{name:"VOLUME_NEW_IMAGE"}]})}function Iwe(t,e,r){var s,c;const n=Nr(r.renderingEngineId);if(!n)throw new Error(`No RenderingEngine for Id: ${r.renderingEngineId}`);const i=n.getViewport(r.viewportId),o=n.getViewport(e.viewportId),a=(s=o.getSlabThickness)==null?void 0:s.call(o);a&&((c=i.setSlabThickness)==null||c.call(i,a),i.render())}const{CAMERA_MODIFIED:Owe}=et;function Mwe(t){return $d(t,Owe,Iwe)}const Pwe=gG,Rwe=Object.freeze(Object.defineProperty({__proto__:null,createCameraPositionSynchronizer:pwe,createImageSliceSynchronizer:gG,createPresentationViewSynchronizer:ywe,createSlabThicknessSynchronizer:Mwe,createStackImageSynchronizer:Pwe,createVOISynchronizer:xwe,createZoomPanSynchronizer:Twe},Symbol.toStringTag,{value:"Module"}));function Lwe(t,e,r=5){const n=Le(t);if(!n)throw new Error("getAnnotationNearPoint: enabledElement not found");return pG(n,e,r)}function pG(t,e,r){const{renderingEngineId:n,viewportId:i}=t,o=vr(i,n);if(!o)return null;const{_toolInstances:a}=o;for(const s in a){const c=Awe(a[s],t,e,r);if(c)return c}return null}function Awe(t,e,r,n){var s,c;const{viewport:i}=e,o=Jt(t.constructor.toolName,i==null?void 0:i.element),a=(s=i==null?void 0:i.getCurrentImageId)==null?void 0:s.call(i);if(o!=null&&o.length){const{element:l}=e.viewport;for(const f of o){const u=(c=f.metadata)==null?void 0:c.referencedImageId;if(!(a&&u&&a!==u||!t.isPointNearTool)&&(t.isPointNearTool(l,f,r,n,"")||t.getHandleNearImagePoint(l,f,r,n)))return f}}return null}const{calibratedPixelSpacingMetadataProvider:Nwe}=pn;function kwe(t,e,r){typeof r=="number"&&(r={type:Js.USER,scale:r}),Nwe.add(t,r),e.getStackViewports().forEach(i=>{i.getImageIds().includes(t)&&i.calibrateSpacing(t)})}function mG(t,e){const r=t.findIndex(([n,i])=>n===i);if(r===-1)throw new Error("3D bounding boxes not supported in an oblique plane");return t[r][0]-=e,t[r][1]+=e,t}const Vwe=Object.freeze(Object.defineProperty({__proto__:null,extend2DBoundingBoxInViewAxis:mG,getBoundingBoxAroundShape:lf,getBoundingBoxAroundShapeIJK:lf,getBoundingBoxAroundShapeWorld:fU},Symbol.toStringTag,{value:"Module"})),{transformWorldToIndex:MC}=pn;function vG(t,e,r){const[n,i]=t,o=Tt((n[0]+i[0])/2,(n[1]+i[1])/2,(n[2]+i[2])/2),a=Fi(n,i)/2,{boundsIJK:s,topLeftWorld:c,bottomRightWorld:l}=Uwe(e,r,t,o,a);return{boundsIJK:s,centerWorld:o,radiusWorld:a,topLeftWorld:c,bottomRightWorld:l}}function yG(t,e){const r=e.getDirection(),n=Tt(r[0],r[1],r[2]),i=Tt(r[3],r[4],r[5]),o=Tt(r[6],r[7],r[8]),a=qc(Ke(),o);return vG(t,e,{row:n,column:i,normal:a})}function Fwe(t,e,r){if(!r)throw new Error("viewport is required in order to calculate the sphere bounds");const n=r.getCamera(),i=Tt(n.viewUp[0],n.viewUp[1],n.viewUp[2]),o=Tt(n.viewPlaneNormal[0],n.viewPlaneNormal[1],n.viewPlaneNormal[2]),a=Ke();Tn(a,i,o);const s={row:a,normal:o,column:qc(Ke(),i)};return vG(t,e,s)}function Uwe(t,e,r,n,i){const o=t.getDimensions(),{row:a,column:s,normal:c}=e,l=Ke(),f=Ke();dn(l,n,c,i),dn(f,n,c,-i),dn(l,l,s,-i),dn(f,f,s,i),dn(l,l,a,-i),dn(f,f,a,i);const u=MC(t,l),d=MC(t,f),h=r.map(p=>MC(t,p));return{boundsIJK:lf([u,d,...h],o),topLeftWorld:l,bottomRightWorld:f}}function wG(t,e=5){return parseFloat(t[0]).toFixed(e)+","+parseFloat(t[1]).toFixed(e)+","+parseFloat(t[2]).toFixed(e)+","}class Bwe{static setStartRange(e,r,n=e.getCurrentImageIdIndex()){this.setRange(e,r,n)}static setEndRange(e,r,n=e.getCurrentImageIdIndex()){this.setRange(e,r,void 0,n)}static setRange(e,r,n,i){var c;const{metadata:o}=r;n===void 0&&(n=o.sliceIndex<i?o.sliceIndex:0,i===void 0&&(i=e.getNumberOfSlices()-1));const a=e.getSliceIndexForImage(o.multiSliceReference);i===void 0&&(i=a>=n?a:e.getNumberOfSlices()-1),i=Math.max(n,i),o.sliceIndex=Math.min(n,i),o.referencedImageId=e.getCurrentImageId(o.sliceIndex),o.referencedImageURI=void 0,i===o.sliceIndex?o.multiSliceReference=void 0:i!==((c=o.multiSliceReference)==null?void 0:c.sliceIndex)&&(o.multiSliceReference={referencedImageId:e.getCurrentImageId(i),sliceIndex:i});const s={viewportId:e.id,renderingEngineId:e.renderingEngineId,changeType:Bt.MetadataReferenceModified,annotation:r};it(Ze,U.ANNOTATION_MODIFIED,s),this.setViewportFrameRange(e,o)}static setSingle(e,r,n=e.getCurrentImageIdIndex()){this.setRange(e,r,n,n)}static getFrameRange(e){const{metadata:r}=e,{sliceIndex:n,multiSliceReference:i}=r,o=i==null?void 0:i.sliceIndex;return o?[n+1,o+1]:n+1}static getFrameRangeStr(e){const r=this.getFrameRange(e);return Array.isArray(r)?`${r[0]}-${r[1]}`:String(r)}static setViewportFrameRange(e,r){var n;e.setFrameRange&&((n=r.multiSliceReference)!=null&&n.sliceIndex)&&e.setFrameRange(r.sliceIndex+1,r.multiSliceReference.sliceIndex+1)}}function Gwe(t,e){const{viewPlaneNormal:r}=t.metadata,{viewPlaneNormal:n}=e.metadata,i=xt(r,n);if(!af(1,Math.abs(i)))return!1;const{polyline:a}=t.data.contour,{polyline:s}=e.data.contour,c=xt(r,a[0]),l=xt(r,s[0]);return af(c,l)}function xG(t,e,r){let n=-1;if(e.forEach((i,o)=>{n>=0||i.a==t.b&&(n=o)}),n>=0){const i=e[n];return e.splice(n,1),r.push(i.b),r[0]==i.b?{remainingLines:e,contourPoints:r,type:"CLOSED_PLANAR"}:xG(i,e,r)}return{remainingLines:e,contourPoints:r,type:"OPEN_PLANAR"}}function C8(t){if(t.length==0)return[];const e=[],r=t.shift();e.push(r.a),e.push(r.b);const n=xG(r,t,e);if(n.remainingLines.length==0)return[{type:n.type,contourPoints:n.contourPoints}];{const i=C8(n.remainingLines);return i.push({type:n.type,contourPoints:n.contourPoints}),i}}function Wwe(t){return C8(t)}const zwe={findContours:C8,findContoursFromReducedSet:Wwe};function $we(t,e=!1){const r=t.getPoints(),n=t.getLines(),i=new Array(r.getNumberOfPoints()).fill(0).map((c,l)=>r.getPoint(l).slice()),o=new Array(n.getNumberOfCells()).fill(0).map((c,l)=>{const f=n.getCell(l*3).slice();return{a:f[0],b:f[1]}});if(e)return{points:i,lines:o};const a=[];for(const[c,l]of i.entries()){const f=a.findIndex(u=>u[0]===l[0]&&u[1]===l[1]&&u[2]===l[2]);if(f>=0)o.map(u=>(u.a===c&&(u.a=f),u.b===c&&(u.b=f),u));else{const u=a.length;a.push(l),o.map(d=>(d.a===c&&(d.a=u),d.b===c&&(d.b=u),d))}}const s=o.filter(c=>c.a!==c.b);return{points:a,lines:s}}const jwe=(t,e)=>{const r=t[0],n=t[1];let i=!1;for(let o=0,a=e.length-1;o<e.length;a=o++){const s=e[o][0],c=e[o][1],l=e[a][0],f=e[a][1];c>n!=f>n&&r<(l-s)*(n-c)/(f-c)+s&&(i=!i)}return i};function Hwe(t,e,r){const n=[];t.contourPoints.forEach(o=>{n.push([r[o][0],r[o][1]])});let i=0;return e.contourPoints.forEach(o=>{jwe([r[o][0],r[o][1]],n)||i++}),i===0}function Kwe(t,e,r=!0){const n=t.filter(s=>s.type!=="CLOSED_PLANAR"),i=t.filter(s=>s.type==="CLOSED_PLANAR"),o=[];let a=[];return i.forEach((s,c)=>{const l=[];i.forEach((f,u)=>{c!=u&&Hwe(s,f,e)&&l.push(u)}),l.length>0?o.push({contour:s,holes:l}):a.push(c)}),r&&(o.forEach(s=>{s.contour.type="CLOSEDPLANAR_XOR",n.push(s.contour),s.holes.forEach(c=>{i[c].type="CLOSEDPLANAR_XOR",n.push(i[c]),a=a.filter(l=>l!==c)})}),a.forEach(s=>{n.push(i[s])})),n}const qwe={processContourHoles:Kwe};let QI=!1;function Xw(){if(QI)return;QI=!0;const t=()=>new Worker(new URL("/static/dv3d/assets/computeWorker-FOqOvCDJ.js",import.meta.url),{name:"compute",type:"module"}),e=fl(),n=w1e().computeWorker,i={maxWorkerInstances:1,autoTerminateOnIdle:(n==null?void 0:n.autoTerminateOnIdle)??{enabled:!0,idleTimeThreshold:2e3}};e.registerWorker("compute",t,i)}function Yw(){return $n.getState().segmentations}function Xwe(t){const{segmentationId:e,representation:r,config:n}=t,{type:i,data:o}=r,a=o?{...o}:{};if(!a)throw new Error("Segmentation representation data may not be undefined");i===St.Contour&&Ywe(a);const s=Jwe(n==null?void 0:n.segments,i,a);return n==null||delete n.segments,{segmentationId:e,label:(n==null?void 0:n.label)??null,cachedStats:(n==null?void 0:n.cachedStats)??{},segments:s,representationData:{[i]:{...a}}}}function Ywe(t){t.geometryIds=t.geometryIds??[],t.annotationUIDsMap=t.annotationUIDsMap??new Map}function Jwe(t,e,r){const n={};return t?Object.entries(t).forEach(([i,o])=>{const{label:a,locked:s,cachedStats:c,active:l,...f}=o,u={segmentIndex:Number(i),label:a??`Segment ${i}`,locked:s??!1,cachedStats:c??{},active:l??!1,...f};n[i]=u}):e===St.Surface?Zwe(n,r):n[1]=Qwe(),n}function Zwe(t,e){const{geometryIds:r}=e;r==null||r.forEach(n=>{const i=$e.getGeometry(n);if(i!=null&&i.data){const{segmentIndex:o}=i.data;t[o]={segmentIndex:o}}})}function Qwe(){return{segmentIndex:1,label:"Segment 1",locked:!1,cachedStats:{},active:!0}}function CG(t,e){const r=$n;t.forEach(n=>{const i=Xwe(n);r.addSegmentation(i),e||Ka(i.segmentationId)})}function ig(t,e,r){return TG(t,e,r)}function SG(t,e,r){return TG(t,e,r)}function TG(t,e,r){const{segmentationId:n,type:i}=e;return exe(t,n,i,r),$n.removeSegmentationRepresentations(t,{segmentationId:n,type:i})}function _G(){$n.getAllViewportSegmentationRepresentations().forEach(({viewportId:e,representations:r})=>{r.forEach(({segmentationId:n,type:i})=>{ig(e,{segmentationId:n,type:i})})}),$n.resetState()}function EG(t,e,r){ig(t,{segmentationId:e,type:St.Labelmap},r)}function bG(t,e,r){ig(t,{segmentationId:e,type:St.Contour},r)}function DG(t,e,r){ig(t,{segmentationId:e,type:St.Surface},r)}function exe(t,e,r,n){pa(t,{segmentationId:e,type:r}).forEach(a=>{a.type===St.Labelmap?lB.removeRepresentation(t,a.segmentationId,n):a.type===St.Contour?sB.removeRepresentation(t,a.segmentationId,n):a.type===St.Surface&&vU.removeRepresentation(t,a.segmentationId,n)});const{viewport:o}=Mn(t)||{};o&&o.render()}function S8(t){const e=$n;e.getAllViewportSegmentationRepresentations().filter(({representations:n})=>n.some(i=>i.segmentationId===t)).map(({viewportId:n})=>n).forEach(n=>{SG(n,{segmentationId:t})}),e.removeSegmentation(t),kE(t)}function IG(){const t=$n;t.getState().segmentations.map(n=>n.segmentationId).forEach(n=>{S8(n)}),t.resetState()}function txe(t){$n.removeColorLUT(t)}function OG(t,e){return MG(t).map(o=>(e&&o.type===e,_n(o.segmentationId))).filter(o=>o!==void 0)}function MG(t){return $n.getState().viewportSegRepresentations[t]}function nxe(t,e){return $n.getStackSegmentationImageIdsForViewport(t,e)}function rxe(){$n.resetState()}const ixe=Object.freeze(Object.defineProperty({__proto__:null,addColorLUT:Ep,addSegmentations:CG,destroy:rxe,getColorLUT:Cm,getCurrentLabelmapImageIdForViewport:_f,getCurrentLabelmapImageIdsForViewport:iu,getNextColorLUTIndex:CB,getSegmentation:_n,getSegmentationRepresentation:VE,getSegmentationRepresentations:pa,getSegmentationRepresentationsBySegmentationId:gU,getSegmentations:Yw,getStackSegmentationImageIdsForViewport:nxe,getViewportIdsWithSegmentation:tg,getViewportSegmentationRepresentations:MG,getViewportSegmentations:OG,removeAllSegmentationRepresentations:_G,removeAllSegmentations:IG,removeColorLUT:txe,removeContourRepresentation:bG,removeLabelmapRepresentation:EG,removeSegmentation:S8,removeSegmentationRepresentation:ig,removeSurfaceRepresentation:DG,updateLabelmapSegmentationImageReferences:OB},Symbol.toStringTag,{value:"Module"}));function PG(t){if("volumeId"in t){if(t=t,!$e.getVolume(t.volumeId))throw new Error(`volumeId of ${t.volumeId} not found in cache, you should load and cache volume before adding segmentation`)}else if("imageIds"in t){if(t=t,!t.imageIds)throw new Error("The segmentationInput.representationData.imageIds is undefined, please provide a valid representationData.imageIds for stack data")}else throw new Error("The segmentationInput.representationData is undefined, please provide a valid representationData")}function oxe(t){if(!t.representation.data)throw new Error("The segmentationInput.representationData.data is undefined, please provide a valid representationData.data");const e=t.representation.data;PG(e)}function axe(t){PG(t)}const sxe=Object.freeze(Object.defineProperty({__proto__:null,validate:axe,validatePublic:oxe},Symbol.toStringTag,{value:"Module"}));function RG(t){const e=$e.getVolume(t);if(!e)return null;const r=e.referencedVolumeId;let n;if(r)n=$e.getVolume(r);else{const i=e.imageIds,a=$e.getImage(i[0]).referencedImageId,s=$e.getVolumeContainingImageId(a);n=s==null?void 0:s.volume}return n}function cxe({operationData:t}){const{volumeId:e}=t;if(!e){const c=new CustomEvent(et.ERROR_EVENT,{detail:{type:"Segmentation",message:"No volume id found for the segmentation"},cancelable:!0});return Ze.dispatchEvent(c),null}const r=$e.getVolume(e),n=RG(e);if(!r||!n)return null;const{imageData:i}=r,{voxelManager:o}=r,{voxelManager:a,imageData:s}=n;return{segmentationImageData:i,segmentationVoxelManager:o,segmentationScalarData:null,imageScalarData:null,imageVoxelManager:a,imageData:s}}function lxe({operationData:t,viewport:e,strategy:r}){var f;const{segmentationId:n}=t;let i,o,a,s,c,l;if(r.ensureSegmentationVolumeFor3DManipulation)r.ensureSegmentationVolumeFor3DManipulation({operationData:t,viewport:e}),o=t.segmentationVoxelManager,i=t.segmentationImageData,a=null;else{const u=_f(e.id,n);if(!u)return null;const d=Aw(e.id,n);if(!d)return null;const h=$e.getImage(u);i=d.actor.getMapper().getInputData(),o=h.voxelManager;const g=t.imageId,p=$e.getImage(g);if(!p)return null;a=(f=p.getPixelData)==null?void 0:f.call(p)}if(r.ensureImageVolumeFor3DManipulation)r.ensureImageVolumeFor3DManipulation({operationData:t,viewport:e}),c=t.imageVoxelManager,s=t.imageScalarData,l=t.imageData;else{const u=e.getCurrentImageId();if(!u)return null;const d=$e.getImage(u);l=d?null:e.getImageData(),s=(d==null?void 0:d.getPixelData())||l.getScalarData(),c=d==null?void 0:d.voxelManager}return{segmentationImageData:i,segmentationScalarData:a,imageScalarData:s,segmentationVoxelManager:o,imageVoxelManager:c,imageData:l}}function T8({operationData:t,viewport:e,strategy:r}){return t?"volumeId"in t&&t.volumeId!=null||"referencedVolumeId"in t&&t.referencedVolumeId!=null?cxe({operationData:t}):lxe({operationData:t,viewport:e,strategy:r}):null}function og(t){const{representationData:e}=_n(t);let{volumeId:r}=e.Labelmap,n;if(r&&(n=$e.getVolume(r),n))return n;const{imageIds:i}=e.Labelmap;if(r=$e.generateVolumeId(i),!(!i||i.length===1||!Sf(i)))return n=lm(r,i),n}const LG={[yt.EnsureSegmentationVolumeFor3DManipulation]:t=>{const{operationData:e,viewport:r}=t,{segmentationId:n,imageIds:i}=e,o=r?r.getImageIds():i.map(c=>$e.getImage(c).referencedImageId);if(!Sf(o))throw new Error("Volume is not reconstructable for sphere manipulation");const s=og(n);s&&(e.segmentationVoxelManager=s.voxelManager,e.segmentationImageData=s.imageData)}};function Jw(t){if(!t||t.length<=1||!Sf(t))return;const r=$e.generateVolumeId(t);let n=$e.getVolume(r);return n||(n=lm(r,t),n)}const AG={[yt.EnsureImageVolumeFor3DManipulation]:t=>{const{operationData:e,viewport:r}=t;let n;if(r){if(n=r.getImageIds(),!Sf(n))throw new Error("Volume is not reconstructable for sphere manipulation")}else n=_n(e.segmentationId).representationData.Labelmap.imageIds.map(s=>$e.getImage(s).referencedImageId);const i=Jw(n);if(!i)throw new Error("Failed to create or get image volume");e.imageVoxelManager=i.voxelManager,e.imageData=i.imageData}},cl=(t,e)=>{it(Ze,et.WEB_WORKER_PROGRESS,{progress:e,type:t})},NG=(t,e)=>{const r=_n(t),{representationData:n}=r,{Labelmap:i}=n;if(!i)return console.debug("No labelmap found for segmentation",t),null;const o=i.volumeId,a=i.imageIds,s={segmentationId:t,volumeId:o,imageIds:a};let c=!1;if(a){const f=a.map(u=>$e.getImage(u).referencedImageId);c=Sf(f)}let l=e;return l?Array.isArray(l)||(l=[l,255]):l=[va(t)],{operationData:s,segVolumeId:o,segImageIds:a,reconstructableVolume:c,indices:l}},kG=t=>T8({operationData:t,strategy:{ensureSegmentationVolumeFor3DManipulation:LG.ensureSegmentationVolumeFor3DManipulation,ensureImageVolumeFor3DManipulation:AG.ensureImageVolumeFor3DManipulation}}),VG=t=>{const e=[],r=[];for(const n of t){const i=$e.getImage(n),o=i.getPixelData(),{origin:a,direction:s,spacing:c,dimensions:l}=yw(i);e.push({scalarData:o,dimensions:l,spacing:c,origin:a,direction:s});const f=i.referencedImageId;if(f){const u=$e.getImage(f);if(!u)continue;const d=u.getPixelData(),h=u.voxelManager,g=[u.rowPixelSpacing,u.columnPixelSpacing];r.push({scalarData:d,dimensions:h?h.dimensions:[u.columns,u.rows,1],spacing:g})}}return{segmentationInfo:e,imageInfo:r}},uxe=(t,e)=>{var a;let r;if(t){const c=$e.getVolume(t).imageIds,l=$e.getImage(c[0]);l&&(r=l.referencedImageId)}else e!=null&&e.length&&(r=$e.getImage(e[0]).referencedImageId);const n=$e.getImage(r),i=ct("scalingModule",r),o={isPreScaled:!!((a=n==null?void 0:n.preScale)!=null&&a.scaled),isSuvScaled:typeof(i==null?void 0:i.suvbw)=="number"};return{refImageId:r,modalityUnitOptions:o}},{Labelmap:fxe}=St;async function FG({segmentations:t}){Xw(),cl(Wa.GENERATE_CONTOUR_SETS,0);const{representationData:e,segments:r=[0,1],segmentationId:n}=t;let{volumeId:i}=e[fxe];if(!i){const g=og(n);g&&(i=g.volumeId)}const o=$e.getVolume(i);if(!o){console.warn(`No volume found for ${i}`);return}const c={scalarData:o.voxelManager.getCompleteScalarDataArray(),dimensions:o.dimensions,spacing:o.imageData.getSpacing(),origin:o.imageData.getOrigin(),direction:o.imageData.getDirection()},l=Array.isArray(r)?r.filter(g=>g!==null).map(g=>g.segmentIndex||g):Object.values(r).filter(g=>g!==null).map(g=>g.segmentIndex||g),f=await fl().executeTask("compute","generateContourSetsFromLabelmapVolume",{segmentation:c,indices:l,mode:"individual"}),u=o.imageIds.map(g=>{var v;const p=(v=$e.getImage(g))==null?void 0:v.referencedImageId;return p?$e.getImage(p):void 0}),d=u.map(g=>yw(g)),h=f.map(g=>{const p=r[g.segment.segmentIndex]||{};if(!g.sliceContours.length)return null;const v=g.sliceContours[0].polyData.points[0];let y;if(v){const m=d.findIndex(w=>{const{scanAxisNormal:x,origin:C}=w,S=Yc(x,C);return Dk(v,S)});m!==-1&&(y=u[m].imageId)}return{label:p.label,color:p.color,metadata:{FrameOfReferenceUID:o.metadata.FrameOfReferenceUID,referencedImageId:y},sliceContours:g.sliceContours.map(m=>({contours:m.contours,polyData:m.polyData,FrameNumber:m.sliceIndex+1,sliceIndex:m.sliceIndex,FrameOfReferenceUID:o.metadata.FrameOfReferenceUID,referencedImageId:y}))}}).filter(g=>g!==null);return cl(Wa.GENERATE_CONTOUR_SETS,100),h}class UG{constructor(){}static getContourSequence(e,r){const{data:n}=e,{projectionPoints:i,projectionPointsImageIds:o}=n.cachedStats;return i.map((a,s)=>{const c=dxe(a),l=hxe(o[s],r);return{NumberOfContourPoints:c.length/3,ContourImageSequence:l,ContourGeometricType:"CLOSED_PLANAR",ContourData:c}})}}UG.toolName="RectangleROIStartEndThreshold";function dxe(t){return[...t[0],...t[1],...t[3],...t[2]].flat().map(i=>i.toFixed(2))}function hxe(t,e){const r=e.get("sopCommonModule",t);return{ReferencedSOPClassUID:r.sopClassUID,ReferencedSOPInstanceUID:r.sopInstanceUID}}function gxe(t){if(!(t!=null&&t.data))throw new Error("Tool data is empty");if(!t.metadata||t.metadata.referencedImageId)throw new Error("Tool data is not associated with any imageId")}const Ap=class Ap{constructor(){}static convert(e,r,n){gxe(e);const{toolName:i}=e.metadata,o=Ap.TOOL_NAMES[i];if(!o)throw new Error(`Unknown tool type: ${i}, cannot convert to RTSSReport`);const a=o.getContourSequence(e,n),s=[Math.floor(Math.random()*255),Math.floor(Math.random()*255),Math.floor(Math.random()*255)];return{ReferencedROINumber:r+1,ROIDisplayColor:s,ContourSequence:a}}static register(e){Ap.TOOL_NAMES[e.toolName]=e}};Ap.TOOL_NAMES={};let w5=Ap;w5.register(UG);function pxe(t,e){Qc.acceptAutoGenerated(t,e)}const{isEqual:mxe}=pn;function ZS(t,e){const{polyline:r}=t.data.contour,{points:n}=t.data.handles,{length:i}=n;if(e===i)return r.length;if(e<0&&(e=(e+i)%i),e===0)return 0;const o=n[e],a=r.findIndex(c=>mxe(o,c));if(a!==-1)return a;let s=1/0;return r.reduce((c,l,f)=>{const u=HR(l,o);return u<s?(s=u,f):c},-1)}const vxe=Object.freeze(Object.defineProperty({__proto__:null,AnnotationToPointData:w5,acceptAutogeneratedInterpolations:pxe,areCoplanarContours:Gwe,calculatePerimeter:XS,contourFinder:zwe,detectContourHoles:qwe,findHandlePolylineIndex:ZS,generateContourSetsFromLabelmap:FG,getContourHolesDataCanvas:Om,getContourHolesDataWorld:vB,getDeduplicatedVTKPolyDataPoints:$we,updateContourPolyline:vc},Symbol.toStringTag,{value:"Module"}));function BG(t,e,r){const{imageData:n}=t,{overwrite:i,boundsIJK:o,segmentationId:a}=r;if(!a)throw new Error("Segmentation ID is required to be passed inside thresholdVolumeByRange as options");const s=(r==null?void 0:r.overlapType)||0,c=t.voxelManager,l=t.voxelManager.getScalarDataLength();if(i)for(let w=0;w<l;w++)c.setAtIndex(w,0);const{baseVolumeIdx:f,volumeInfoList:u}=dU(t,e);let d,h,g;const p=(w,x,C)=>{const S=({value:O})=>{h=h+1,O>=g.lower&&O<=g.upper&&(d=d+1)},{imageData:T,dimensions:_,lower:E,upper:b}=w,D=AE(T,_,x,C);h=0,d=0,g={lower:E,upper:b};let I=!1;const{voxelManager:P}=T.get("voxelManager");return P.forEach(S,{imageData:T,boundsIJK:D}),s===0?I=d>0:s==1&&(I=d===h),I},v=(w,x)=>{const{imageData:C,lower:S,upper:T}=w,_=C.get("voxelManager").voxelManager,E=_.toIndex(x),b=_.getAtIndex(E);return!(b<=S||b>=T)},y=({index:w,pointIJK:x,pointLPS:C})=>{let S=u.length>0;for(let T=0;T<u.length&&(u[T].volumeSize===l?S=v(u[T],x):S=p(u[T],u[f].spacing,C),!!S);T++);S&&c.setAtIndex(w,r.segmentIndex||1)};return t.voxelManager.forEach(y,{imageData:n,boundsIJK:o}),lo(r.segmentationId),t}const{transformWorldToIndex:e7}=pn,L0=class L0 extends Yn{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{storePointData:!1,shadow:!0,preventHandleOutsideImage:!1,calculateStats:!0,getTextLines:yxe,statsCalculator:al}}){super(e,r),this.addNewAnnotation=n=>{const i=n.detail,{currentPoints:o,element:a}=i,s=o.world,c=Le(a),{viewport:l}=c;this.isDrawing=!0;const f=this.constructor.createAnnotationForViewport(l,{data:{handles:{points:[[...s],[...s],[...s],[...s]],textBox:{hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}}},cachedStats:{}}});qt(f,a);const u=wt(a,this.getToolName());return this.editData={annotation:f,viewportIdsToRender:u,handleIndex:3,movingTextBox:!1,newAnnotation:!0,hasMoved:!1},this._activateDraw(a),Dt(a),n.preventDefault(),We(u),f},this.isPointNearTool=(n,i,o,a)=>{const s=Le(n),{viewport:c}=s,{data:l}=i,{points:f}=l.handles,u=c.worldToCanvas(f[0]),d=c.worldToCanvas(f[3]),h=this._getRectangleImageCoordinates([u,d]),g=[o[0],o[1]],{left:p,top:v,width:y,height:m}=h;return e8([p,v,y,m],g)<=a},this.toolSelectedCallback=(n,i)=>{const o=n.detail,{element:a}=o;i.highlighted=!0;const s=wt(a,this.getToolName());this.editData={annotation:i,viewportIdsToRender:s,movingTextBox:!1},this._activateModify(a),Dt(a);const c=Le(a),{renderingEngine:l}=c;We(s),n.preventDefault()},this.handleSelectedCallback=(n,i,o)=>{const a=n.detail,{element:s}=a,{data:c}=i;i.highlighted=!0;let l=!1,f;o.worldPosition?l=!0:f=c.handles.points.findIndex(g=>g===o);const u=wt(s,this.getToolName());this.editData={annotation:i,viewportIdsToRender:u,handleIndex:f,movingTextBox:l},this._activateModify(s),Dt(s);const d=Le(s),{renderingEngine:h}=d;We(u),n.preventDefault()},this._endCallback=n=>{const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s,newAnnotation:c,hasMoved:l}=this.editData,{data:f}=a;c&&!l||(f.handles.activeHandleIndex=null,this._deactivateModify(o),this._deactivateDraw(o),kt(o),this.doneEditMemo(),this.editData=null,this.isDrawing=!1,this.isHandleOutsideImage&&this.configuration.preventHandleOutsideImage&&en(a.annotationUID),We(s),c&&bn(a))},this._dragCallback=n=>{this.isDrawing=!0;const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s,handleIndex:c,movingTextBox:l,newAnnotation:f}=this.editData;this.createMemo(o,a,{newAnnotation:f});const{data:u}=a;if(l){const{deltaPoints:d}=i,h=d.world,{textBox:g}=u.handles,{worldPosition:p}=g;p[0]+=h[0],p[1]+=h[1],p[2]+=h[2],g.hasMoved=!0}else if(c===void 0){const{deltaPoints:d}=i,h=d.world,{points:g}=u.handles;g.forEach(p=>{p[0]+=h[0],p[1]+=h[1],p[2]+=h[2]}),a.invalidated=!0}else{const{currentPoints:d}=i,h=Le(o),{worldToCanvas:g,canvasToWorld:p}=h.viewport,v=d.world,{points:y}=u.handles;y[c]=[...v];let m,w,x,C,S,T,_,E;switch(c){case 0:case 3:m=g(y[0]),C=g(y[3]),w=[C[0],m[1]],x=[m[0],C[1]],T=p(w),_=p(x),y[1]=T,y[2]=_;break;case 1:case 2:w=g(y[1]),x=g(y[2]),m=[x[0],w[1]],C=[w[0],x[1]],S=p(m),E=p(C),y[0]=S,y[3]=E;break}a.invalidated=!0}this.editData.hasMoved=!0,Le(o),We(s),a.invalidated&&Kt(a,o,Bt.HandlesUpdated)},this.cancel=n=>{if(this.isDrawing){this.isDrawing=!1,this._deactivateDraw(n),this._deactivateModify(n),kt(n);const{annotation:i,viewportIdsToRender:o,newAnnotation:a}=this.editData,{data:s}=i;return i.highlighted=!1,s.handles.activeHandleIndex=null,We(o),a&&bn(i),this.editData=null,i.annotationUID}},this._activateDraw=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragCallback),n.addEventListener(U.MOUSE_MOVE,this._dragCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback)},this._deactivateDraw=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragCallback),n.removeEventListener(U.MOUSE_MOVE,this._dragCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.TOUCH_END,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback)},this._activateModify=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback)},this._deactivateModify=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.TOUCH_END,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback)},this.renderAnnotation=(n,i)=>{let o=!1;const{viewport:a}=n,{element:s}=a;let c=Jt(this.getToolName(),s);if(!(c!=null&&c.length)||(c=this.filterInteractableAnnotationsForElement(s,c),!(c!=null&&c.length)))return o;const l=this.getTargetId(a),f=a.getRenderingEngine(),u={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:n.viewport.id};for(let d=0;d<c.length;d++){const h=c[d],{annotationUID:g,data:p}=h,{points:v,activeHandleIndex:y}=p.handles,m=v.map(G=>a.worldToCanvas(G));u.annotationUID=g;const{color:w,lineWidth:x,lineDash:C}=this.getAnnotationStyle({annotation:h,styleSpecifier:u}),{viewPlaneNormal:S,viewUp:T}=a.getCamera();if(!p.cachedStats[l]||p.cachedStats[l].areaUnit==null)p.cachedStats[l]={Modality:null,area:null,max:null,mean:null,stdDev:null,areaUnit:null},this._calculateCachedStats(h,S,T,f,n);else if(h.invalidated&&(this._throttledCalculateCachedStats(h,S,T,f,n),a instanceof Zn)){const{referencedImageId:G}=h.metadata;for(const X in p.cachedStats)X.startsWith("imageId")&&f.getStackViewports().find(Se=>{const we=_r(G),_e=Se.hasImageURI(we),Ve=_r(Se.getCurrentImageId());return _e&&Ve!==we})&&delete p.cachedStats[X]}if(!a.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),o;let _;if(!Vr(g))continue;!Yr(g)&&!this.editData&&y!==null&&(_=[m[y]]),_&&Kn(i,g,"0",_,{color:w});const E=`${g}-rect`;n8(i,g,"0",m,{color:w,lineDash:C,lineWidth:x},E),o=!0;const D=this.getLinkedTextBoxStyle(u,h);if(!D.visibility){p.handles.textBox={hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}};continue}const I=this.configuration.getTextLines(p,l);if(!I||I.length===0)continue;if(!p.handles.textBox.hasMoved){const G=wa(m);p.handles.textBox.worldPosition=a.canvasToWorld(G)}const P=a.worldToCanvas(p.handles.textBox.worldPosition),L=Ji(i,g,"1",I,P,m,{},D),{x:B,y:H,width:A,height:F}=L;p.handles.textBox.worldBoundingBox={topLeft:a.canvasToWorld([B,H]),topRight:a.canvasToWorld([B+A,H]),bottomLeft:a.canvasToWorld([B,H+F]),bottomRight:a.canvasToWorld([B+A,H+F])}}return o},this._getRectangleImageCoordinates=n=>{const[i,o]=n;return{left:Math.min(i[0],o[0]),top:Math.min(i[1],o[1]),width:Math.abs(i[0]-o[0]),height:Math.abs(i[1]-o[1])}},this._calculateCachedStats=(n,i,o,a,s)=>{var v,y,m,w;if(!this.configuration.calculateStats)return;const{data:c}=n,{viewport:l}=s,{element:f}=l,u=c.handles.points[0],d=c.handles.points[3],{cachedStats:h}=c,g=Object.keys(h);for(let x=0;x<g.length;x++){const C=g[x],S=this.getTargetImageData(C);if(!S)continue;const{dimensions:T,imageData:_,metadata:E,voxelManager:b}=S,D=e7(_,u);D[0]=Math.floor(D[0]),D[1]=Math.floor(D[1]),D[2]=Math.floor(D[2]);const I=e7(_,d);if(I[0]=Math.floor(I[0]),I[1]=Math.floor(I[1]),I[2]=Math.floor(I[2]),this._isInsideVolume(D,I,T)){this.isHandleOutsideImage=!1;const P=Math.min(D[0],I[0]),O=Math.max(D[0],I[0]),L=Math.min(D[1],I[1]),B=Math.max(D[1],I[1]),H=Math.min(D[2],I[2]),A=Math.max(D[2],I[2]),F=[[P,O],[L,B],[H,A]],{worldWidth:G,worldHeight:X}=zw(i,o,u,d),ee=[D,I],{scale:ce,areaUnit:Se}=ya(S,ee),we=Math.abs(G*X)/(ce*ce),_e={isPreScaled:uu(l,C),isSuvScaled:this.isSuvScaled(l,C,n.metadata.referencedImageId)},Ve=fu(E.Modality,n.metadata.referencedImageId,_e);let Ge;b&&(Ge=b.forEach(this.configuration.statsCalculator.statsCallback,{boundsIJK:F,imageData:_,returnPoints:this.configuration.storePointData}));const Ne=this.configuration.statsCalculator.getStatistics();h[C]={Modality:E.Modality,area:we,mean:(v=Ne.mean)==null?void 0:v.value,stdDev:(y=Ne.stdDev)==null?void 0:y.value,max:(m=Ne.max)==null?void 0:m.value,min:(w=Ne.min)==null?void 0:w.value,statsArray:Ne.array,pointsInShape:Ge,areaUnit:Se,modalityUnit:Ve}}else this.isHandleOutsideImage=!0,h[C]={Modality:E.Modality}}const p=n.invalidated;return n.invalidated=!1,p&&Kt(n,f,Bt.StatsUpdated),h},this._isInsideVolume=(n,i,o)=>tr(n,o)&&tr(i,o),this._throttledCalculateCachedStats=Lo(this._calculateCachedStats,100,{trailing:!0})}};L0.toolName="RectangleROI",L0.hydrate=(e,r,n)=>{const i=Mn(e);if(!i)return;const{FrameOfReferenceUID:o,referencedImageId:a,viewPlaneNormal:s,instance:c,viewport:l}=L0.hydrateBase(L0,i,r,n),{toolInstance:f,...u}=n||{},d={annotationUID:(n==null?void 0:n.annotationUID)||gn(),data:{handles:{points:r,activeHandleIndex:null},label:"",cachedStats:{}},highlighted:!1,autoGenerated:!1,invalidated:!1,isLocked:!1,isVisible:!0,metadata:{toolName:c.getToolName(),viewPlaneNormal:s,FrameOfReferenceUID:o,referencedImageId:a,...u}};qt(d,l.element),We([l.id])};let au=L0;function yxe(t,e){const r=t.cachedStats[e],{area:n,mean:i,max:o,stdDev:a,areaUnit:s,modalityUnit:c,min:l}=r;if(i==null)return;const f=[];return xr(n)&&f.push(`Area: ${Xt(n)} ${s}`),xr(i)&&f.push(`Mean: ${Xt(i)} ${c}`),xr(o)&&f.push(`Max: ${Xt(o)} ${c}`),xr(l)&&f.push(`Max: ${Xt(l)} ${c}`),xr(a)&&f.push(`Std Dev: ${Xt(a)} ${c}`),f}const{transformWorldToIndex:Ag}=pn;class _8 extends au{constructor(e={},r={configuration:{storePointData:!1,numSlicesToPropagate:10,calculatePointsInsideVolume:!0,getTextLines:wxe,statsCalculator:al,showTextBox:!1,throttleTimeout:100}}){super(e,r),this.addNewAnnotation=n=>{const i=n.detail,{currentPoints:o,element:a}=i,s=o.world,c=Le(a),{viewport:l,renderingEngine:f}=c;this.isDrawing=!0;const u=l.getCamera(),{viewPlaneNormal:d,viewUp:h}=u;let g,p,v;if(l instanceof Jn)throw new Error("Stack Viewport Not implemented");{const T=this.getTargetId(l);v=dl(T),p=$e.getVolume(v),g=Ql(p,s,d)}const y=Cf(p,d),m=this._getStartCoordinate(s,d),w=this._getEndCoordinate(s,y,d),x=l.getFrameOfReferenceUID(),C={highlighted:!0,invalidated:!0,metadata:{viewPlaneNormal:[...d],enabledElement:c,viewUp:[...h],FrameOfReferenceUID:x,referencedImageId:g,toolName:this.getToolName(),volumeId:v,spacingInNormal:y},data:{label:"",startCoordinate:m,endCoordinate:w,cachedStats:{pointsInVolume:[],projectionPoints:[],projectionPointsImageIds:[g],statistics:[]},handles:{textBox:{hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}},points:[[...s],[...s],[...s],[...s]],activeHandleIndex:null},labelmapUID:null}};this._computeProjectionPoints(C,p),qt(C,a);const S=wt(a,this.getToolName());return this.editData={annotation:C,viewportIdsToRender:S,handleIndex:3,newAnnotation:!0,hasMoved:!1},this._activateDraw(a),Dt(a),n.preventDefault(),We(S),C},this._endCallback=n=>{const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s,newAnnotation:c,hasMoved:l}=this.editData,{data:f}=a;if(c&&!l)return;f.handles.activeHandleIndex=null,this._deactivateModify(o),this._deactivateDraw(o),kt(o);const u=Le(o);this.editData=null,this.isDrawing=!1,this.isHandleOutsideImage&&this.configuration.preventHandleOutsideImage&&en(a.annotationUID);const d=this.getTargetId(u.viewport),h=$e.getVolume(d.split(/volumeId:|\?/)[1]);this._computePointsInsideVolume(a,d,h,u),We(s),c?bn(a):Kt(a,o)},this.renderAnnotation=(n,i)=>{let o=!1;const{viewport:a}=n;let s=Jt(this.getToolName(),a.element);if(!(s!=null&&s.length))return o;s=$w(s,a.getCamera());const c={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:n.viewport.id};for(let l=0;l<s.length;l++){const f=s[l],{annotationUID:u,data:d,metadata:h}=f,{startCoordinate:g,endCoordinate:p}=d,{points:v,activeHandleIndex:y}=d.handles,m=v.map(A=>a.worldToCanvas(A));c.annotationUID=u;const w=this.getStyle("lineWidth",c,f),x=this.getStyle("lineDash",c,f),C=this.getStyle("color",c,f),S=a.getCamera().focalPoint,T=a.getCamera().viewPlaneNormal;let _=g,E=p;if(Array.isArray(g)){_=this._getCoordinateForViewplaneNormal(_,T);const A=this._getIndexOfCoordinatesForViewplaneNormal(T);d.handles.points.forEach(F=>{F[A]=_}),d.startCoordinate=_}Array.isArray(p)&&(E=this._getCoordinateForViewplaneNormal(E,T),d.endCoordinate=E,d.endCoordinate=E);const b=Gu(_),D=Gu(E),I=this._getCoordinateForViewplaneNormal(S,T),P=Gu(I);if(P<Math.min(b,D)||P>Math.max(b,D))continue;f.invalidated&&this._throttledCalculateCachedStats(f,n);let O=!1;if((P===b||P===D)&&(O=!0),!a.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),o;let L;if(!Vr(u))continue;!Yr(u)&&!this.editData&&y!==null&&O&&(L=[m[y]]),L&&Kn(i,u,"0",L,{color:C});let B=x;if(O||(B=2),bm(i,u,"0",m[0],m[3],{color:C,lineDash:B,lineWidth:w}),o=!0,this.configuration.showTextBox){const A=this.getLinkedTextBoxStyle(c,f);if(!A.visibility){d.handles.textBox={hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}};continue}const F=this.configuration.getTextLines(d,{metadata:h});if(!F||F.length===0)continue;if(!d.handles.textBox.hasMoved){const Ve=wa(m);d.handles.textBox.worldPosition=a.canvasToWorld(Ve)}const G=a.worldToCanvas(d.handles.textBox.worldPosition),ee=Ji(i,u,"1",F,G,m,{},A),{x:ce,y:Se,width:we,height:_e}=ee;d.handles.textBox.worldBoundingBox={topLeft:a.canvasToWorld([ce,Se]),topRight:a.canvasToWorld([ce+we,Se]),bottomLeft:a.canvasToWorld([ce,Se+_e]),bottomRight:a.canvasToWorld([ce+we,Se+_e])}}}return o},this.configuration.calculatePointsInsideVolume?this._throttledCalculateCachedStats=Lo(this._calculateCachedStatsTool,this.configuration.throttleTimeout,{trailing:!0}):this._throttledCalculateCachedStats=Jh(this._calculateCachedStatsTool,this.configuration.throttleTimeout)}_computeProjectionPoints(e,r){const{data:n,metadata:i}=e,{viewPlaneNormal:o,spacingInNormal:a}=i,{imageData:s}=r,{startCoordinate:c,endCoordinate:l}=n,{points:f}=n.handles,u=Ag(s,f[0]),d=Ag(s,f[0]),h=Ke();s.indexToWorldVec3(u,h);const g=Ke();s.indexToWorldVec3(d,g),this._getIndexOfCoordinatesForViewplaneNormal(o)==2?(h[2]=c,g[2]=l):this._getIndexOfCoordinatesForViewplaneNormal(o)==0?(h[0]=c,g[0]=l):this._getIndexOfCoordinatesForViewplaneNormal(o)==1&&(h[1]=c,g[1]=l);const p=Fi(h,g),v=[];for(let y=0;y<p;y+=a)v.push(f.map(m=>{const w=Ke();return dn(w,m,o,y),Array.from(w)}));n.cachedStats.projectionPoints=v}_computePointsInsideVolume(e,r,n,i){var S,T,_;const{data:o,metadata:a}=e,{viewPlaneNormal:s,viewUp:c}=a,{viewport:l}=i,f=o.cachedStats.projectionPoints,u=[[]],d=this.getTargetImageData(r),h=o.handles.points[0],g=o.handles.points[3],{worldWidth:p,worldHeight:v}=zw(s,c,h,g),y=ya(d,o.habdles),m=Math.abs(p*v)/(y.scale*y.scale),w={isPreScaled:uu(l,r),isSuvScaled:this.isSuvScaled(l,r,e.metadata.referencedImageId)},x=fu(a.Modality,e.metadata.referencedImageId,w);for(let E=0;E<f.length;E++){if(!n)continue;const b=f[E][0],{dimensions:D,imageData:I,voxelManager:P}=n,O=Ag(I,h),L=Ag(I,b),B=this._getIndexOfCoordinatesForViewplaneNormal(s);O[0]=Math.floor(O[0]),O[1]=Math.floor(O[1]),O[2]=Math.floor(O[2]),O[B]=L[B];const H=Ag(I,g);if(H[0]=Math.floor(H[0]),H[1]=Math.floor(H[1]),H[2]=Math.floor(H[2]),H[B]=L[B],this._isInsideVolume(O,H,D)){this.isHandleOutsideImage=!1;const A=Math.min(O[0],H[0]),F=Math.max(O[0],H[0]),G=Math.min(O[1],H[1]),X=Math.max(O[1],H[1]),ee=Math.min(O[2],H[2]),ce=Math.max(O[2],H[2]),Se=[[A,F],[G,X],[ee,ce]],we=P.forEach(this.configuration.statsCalculator.statsCallback,{boundsIJK:Se,imageData:I,returnPoints:this.configuration.storePointData});u.push(we)}}const C=this.configuration.statsCalculator.getStatistics();o.cachedStats.pointsInVolume=u,o.cachedStats.statistics={Modality:a.Modality,area:m,mean:(S=C.mean)==null?void 0:S.value,stdDev:(T=C.stdDev)==null?void 0:T.value,max:(_=C.max)==null?void 0:_.value,statsArray:C.array,areaUnit:y.areaUnit,modalityUnit:x}}_calculateCachedStatsTool(e,r){const n=e.data,{viewport:i}=r,{cachedStats:o}=n,a=this.getTargetId(i),s=$e.getVolume(a.split(/volumeId:|\?/)[1]);return this._computeProjectionPoints(e,s),this._computePointsInsideVolume(e,a,s,r),e.invalidated=!1,Kt(e,i.element),o}_getStartCoordinate(e,r){const n=e;return this._getCoordinateForViewplaneNormal(n,r)}_getEndCoordinate(e,r,n){const i=this.configuration.numSlicesToPropagate,o=Ke();return dn(o,e,n,i*r),this._getCoordinateForViewplaneNormal(o,n)}_getIndexOfCoordinatesForViewplaneNormal(e){const r=[Math.abs(e[0]),Math.abs(e[1]),Math.abs(e[2])];return r.indexOf(Math.max(...r))}_getCoordinateForViewplaneNormal(e,r){const n=this._getIndexOfCoordinatesForViewplaneNormal(r);return e[n]}}function wxe(t,e={}){const r=t.cachedStats.statistics,{area:n,mean:i,max:o,stdDev:a,areaUnit:s,modalityUnit:c}=r;if(i===void 0)return;const l=[];return l.push(`Area: ${Xt(n)} ${s}`),l.push(`Mean: ${Xt(i)} ${c}`),l.push(`Max: ${Xt(o)} ${c}`),l.push(`Std Dev: ${Xt(a)} ${c}`),l}_8.toolName="RectangleROIStartEndThreshold";class E8 extends au{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{shadow:!0,preventHandleOutsideImage:!1}}){super(e,r),this.addNewAnnotation=n=>{const i=n.detail,{currentPoints:o,element:a}=i,s=o.world,c=Le(a),{viewport:l,renderingEngine:f}=c;this.isDrawing=!0;const u=l.getCamera(),{viewPlaneNormal:d,viewUp:h}=u,g=this.getTargetId(l);let p,v;if(l instanceof Jn)p=g.split("imageId:")[1];else{v=dl(g);const x=$e.getVolume(v);p=Ql(x,s,d)}const y=l.getFrameOfReferenceUID(),m={highlighted:!0,invalidated:!0,metadata:{viewPlaneNormal:[...d],enabledElement:c,viewUp:[...h],FrameOfReferenceUID:y,referencedImageId:p,toolName:this.getToolName(),volumeId:v},data:{label:"",handles:{textBox:{hasMoved:!1,worldPosition:null,worldBoundingBox:null},points:[[...s],[...s],[...s],[...s]],activeHandleIndex:null},segmentationId:null}};qt(m,a);const w=wt(a,this.getToolName());return this.editData={annotation:m,viewportIdsToRender:w,handleIndex:3,newAnnotation:!0,hasMoved:!1},this._activateDraw(a),Dt(a),n.preventDefault(),We(w),m},this.renderAnnotation=(n,i)=>{let o=!1;const{viewport:a}=n,{element:s}=a;let c=Jt(this.getToolName(),s);if(!(c!=null&&c.length)||(c=this.filterInteractableAnnotationsForElement(s,c),!(c!=null&&c.length)))return o;const l={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:n.viewport.id};for(let f=0;f<c.length;f++){const u=c[f],{annotationUID:d,data:h}=u,{points:g,activeHandleIndex:p}=h.handles,v=g.map(S=>a.worldToCanvas(S));l.annotationUID=d;const y=this.getStyle("lineWidth",l,u),m=this.getStyle("lineDash",l,u),w=this.getStyle("color",l,u);if(!a.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),o;Kt(u,s);let x;if(!Vr(d))continue;!Yr(d)&&!this.editData&&p!==null&&(x=[v[p]]),x&&Kn(i,d,"0",x,{color:w}),bm(i,d,"0",v[0],v[3],{color:w,lineDash:m,lineWidth:y}),o=!0}return o}}}E8.toolName="RectangleROIThreshold";function GG(t,e,r={}){const n=[];return t.forEach(o=>{var h,g;const{data:a}=o,{points:s}=a.handles,{imageData:c,dimensions:l}=e;let f=s;if((h=a.cachedStats)!=null&&h.projectionPoints){const{projectionPoints:p}=a.cachedStats;f=[].concat(...p)}const u=f.map(p=>Lr(c,p));let d=lf(u,l);r.numSlicesToProject&&!((g=a.cachedStats)!=null&&g.projectionPoints)&&(d=mG(d,r.numSlicesToProject)),n.push(d)}),n.length===1?n[0]:n.reduce((o,a)=>({iMin:Math.min(o.iMin,a.iMin),jMin:Math.min(o.jMin,a.jMin),kMin:Math.min(o.kMin,a.kMin),iMax:Math.max(o.iMax,a.iMax),jMax:Math.max(o.jMax,a.jMax),kMax:Math.max(o.kMax,a.kMax)}),{iMin:1/0,jMin:1/0,kMin:1/0,iMax:-1/0,jMax:-1/0,kMax:-1/0})}function xxe(t,e,r,n){const i=t.map(s=>rr.getAnnotation(s));Cxe(i);let o;for(let s=0;s<r.length;s++)(r[s].volume.voxelManager.getScalarDataLength()===e.voxelManager.getScalarDataLength()||s===0)&&(o=GG(i,r[s].volume,n));const a=BG(e,r,{...n,boundsIJK:o,segmentationId:n.segmentationId});return a.modified(),a}function Cxe(t){const e=[E8.toolName,_8.toolName];for(const r of t){const n=r.metadata.toolName;if(!e.includes(n))throw new Error("rectangleROIThresholdVolumeByRange only supports RectangleROIThreshold and RectangleROIStartEndThreshold annotations")}}function WG(t,e=1,r="mergedLabelmap"){t.forEach(({direction:l,dimensions:f,origin:u,spacing:d})=>{if(!Vt(f,t[0].dimensions)||!Vt(l,t[0].direction)||!Vt(d,t[0].spacing)||!Vt(u,t[0].origin))throw new Error("labelmaps must have the same size and shape")});const n=t[0],i=n.voxelManager.getConstructor(),o=new i(n.voxelManager.getScalarDataLength());t.forEach(l=>{const f=l.voxelManager,u=f.getScalarDataLength();for(let d=0;d<u;d++)f.getAtIndex(d)===e&&(o[d]=e)});const a={scalarData:o,metadata:n.metadata,spacing:n.spacing,origin:n.origin,direction:n.direction,dimensions:n.dimensions},s=$e.getVolume(r);let c;return s?(c=s,c.voxelManager.setCompleteScalarDataArray(o)):c=um(r,a),c}async function Sxe(t){const{viewportId:e,renderingEngineId:r,options:n}=t;let{segmentationId:i}=t;const o=fi(e,r);if(!o)throw new Error("element disabled");const{viewport:a}=o;if(!(a instanceof Zn))throw new Error("Segmentation only supports VolumeViewport");const{uid:s}=a.getDefaultActor();if(i===void 0&&(i=`${s}-based-segmentation-${(n==null?void 0:n.volumeId)??gn().slice(0,8)}`),n){const c=structuredClone(n);await um(i,c)}else{const c=a.getVolumeId();fm(c,{volumeId:i})}return i}function b8(t,e,r={}){const n=r.onFlood,i=r.onBoundary,o=r.equals,a=r.filter,s=r.diagonals||!1,c=C(e),l=S(),f=[],u=[],d=new Set,h=r.bounds;for(f.push({currentArgs:e});f.length>0;)g(f.pop());return{flooded:u};function g(_){const E=_.currentArgs,b=_.previousArgs;p(E)||(v(E),y(E)?(m(E),x(E)):w(b))}function p(_){const[E,b,D=0]=_,I=E+32768+65536*(b+32768+65536*(D+32768));return d.has(I)}function v(_){const[E,b,D=0]=_,I=E+32768+65536*(b+32768+65536*(D+32768));d.add(I)}function y(_){const E=C(_);return o?o(E,c):E===c}function m(_){u.push(_),n&&n(..._)}function w(_){const[E,b,D=0]=_,I=E+32768+65536*(b+32768+65536*(D+32768));h==null||h.set(I,_),i&&i(..._)}function x(_){for(let E=0;E<l.length;E+=1){const b=l[E],D=_.slice(0);for(let I=0;I<_.length;I+=1)D[I]+=b[I];(a==null?void 0:a(D))!==!1&&(p(D)||f.push({currentArgs:D,previousArgs:_}))}}function C(_){return t(..._)}function S(){return T(e.length).filter(function(E){const b=Txe(E);return b!==0&&(b===1||s)})}function T(_){const E=[],b=function(D){return D.split("").map(function(I){return parseInt(I,10)-1})};for(let D=0;D<Math.pow(3,_);D+=1){const I=_xe(D.toString(3),"0",_);E.push(b(I))}return E}}function Txe(t){let e=0;for(let r=0;r<t.length;r+=1)t[r]!==0&&(e+=1);return e}function _xe(t,e,r){return(new Array(r+1).join(e)+t).slice(-r)}const Exe={[yt.OnInteractionStart]:t=>{const{segmentIndex:e,previewSegmentIndex:r,segmentationVoxelManager:n,centerIJK:i,viewPlaneNormal:o,segmentationImageData:a,configuration:s}=t;if(!(s!=null&&s.useCenterSegmentIndex))return;let c=!1,l=!1;const f=[...n.getBoundsIJK()];Math.abs(o[0])>.8?f[0]=[i[0],i[0]]:Math.abs(o[1])>.8?f[1]=[i[1],i[1]]:Math.abs(o[2])>.8&&(f[2]=[i[2],i[2]]);const u=({value:h})=>{c||(c=h===e),l||(l=h===r)};if(n.forEach(u,{imageData:a,isInObject:t.isInObject,boundsIJK:f}),!c&&!l){t.centerSegmentIndexInfo.segmentIndex=null;return}const d=n.getAtIJKPoint(i);t.centerSegmentIndexInfo.segmentIndex=d,t.centerSegmentIndexInfo.hasSegmentIndex=c,t.centerSegmentIndexInfo.hasPreviewIndex=l}},bxe={[yt.Initialize]:t=>{var y;const{operationName:e,centerIJK:r,segmentationVoxelManager:n,imageVoxelManager:i,configuration:o,segmentIndex:a,viewport:s}=t;if(!((y=o==null?void 0:o.threshold)!=null&&y.isDynamic)||!r||!a||e===yt.RejectPreview||e===yt.OnInteractionEnd)return;const c=n.getBoundsIJK(),{range:l,dynamicRadius:f=0}=o.threshold,u=l?0:f,{viewPlaneNormal:d}=s.getCamera(),h=c.map((m,w)=>{const[x,C]=m;return[Math.max(x,r[w]-u),Math.min(C,r[w]+u)]});Math.abs(d[0])>.8?h[0]=[r[0],r[0]]:Math.abs(d[1])>.8?h[1]=[r[1],r[1]]:Math.abs(d[2])>.8&&(h[2]=[r[2],r[2]]);const g=l||[1/0,-1/0],p=u*u,v=({value:m,pointIJK:w})=>{if(lS(r,w)>p)return;const C=Array.isArray(m)?wh(m):m;g[0]=Math.min(C,g[0]),g[1]=Math.max(C,g[1])};i.forEach(v,{boundsIJK:h}),o.threshold.range=g},[yt.OnInteractionStart]:t=>{var r;const{configuration:e}=t;(r=e==null?void 0:e.threshold)!=null&&r.isDynamic&&(e.threshold.range=null)},[yt.ComputeInnerCircleRadius]:t=>{const{configuration:e,viewport:r}=t,{dynamicRadius:n=0,isDynamic:i}=e.threshold;if(!i){e.threshold.dynamicRadiusInCanvas=0;return}if(n===0)return;const o=r.getImageData();if(!o)return;const{spacing:a}=o,s=[r.element.clientWidth/2,r.element.clientHeight/2],c=n*a[0],f=r.canvasToWorld(s).map(h=>h+c),u=r.worldToCanvas(f),d=Math.abs(s[0]-u[0]);e.threshold.dynamicRadiusInCanvas||(e.threshold.dynamicRadiusInCanvas=0),e.threshold.dynamicRadiusInCanvas=3+d}},Dxe={[yt.Initialize]:t=>{t.segmentIndex=0}},{isEqual:PC}=pn,t7={toIJK:t=>t,fromIJK:t=>t,type:"acquistion"},Ixe={toIJK:([t,e,r])=>[r,t,e],fromIJK:([t,e,r])=>[e,r,t],type:"jk"},Oxe={toIJK:([t,e,r])=>[t,r,e],fromIJK:([t,e,r])=>[t,r,e],type:"ik"};function zG(t,e){if(!(t instanceof fr))return{...t7,boundsIJKPrime:e};const{viewPlaneNormal:r}=t.getCamera(),n=PC(Math.abs(r[0]),1)&&Ixe||PC(Math.abs(r[1]),1)&&Oxe||PC(Math.abs(r[2]),1)&&t7;return n?{...n,boundsIJKPrime:n.fromIJK(e)}:{toIJK:null,boundsIJKPrime:null,fromIJK:null,error:`Only mappings orthogonal to acquisition plane are permitted, but requested ${r}`}}const{RLEVoxelMap:Mxe,VoxelManager:Pxe}=pn,Rxe=65535;var to;(function(t){t[t.SEGMENT=-1]="SEGMENT",t[t.ISLAND=-2]="ISLAND",t[t.INTERIOR=-3]="INTERIOR",t[t.EXTERIOR=-4]="EXTERIOR",t[t.INTERIOR_SMALL=-5]="INTERIOR_SMALL",t[t.INTERIOR_TEST=-6]="INTERIOR_TEST"})(to||(to={}));class Pd{constructor(e){this.fillInternalEdge=!1,this.maxInternalRemove=128,this.maxInternalRemove=(e==null?void 0:e.maxInternalRemove)??this.maxInternalRemove,this.fillInternalEdge=(e==null?void 0:e.fillInternalEdge)??this.fillInternalEdge}initialize(e,r,n){const i=!!r.sourceVoxelManager,o=i?r.sourceVoxelManager:r,a=i?r:Pxe.createRLEHistoryVoxelManager(o),{segmentIndex:s=1,previewSegmentIndex:c=1}=n,l=n.points||o.getPoints();if(!(l!=null&&l.length))return;const f=o.getBoundsIJK().map((x,C)=>[Math.min(x[0],...l.map(S=>S[C])),Math.max(x[1],...l.map(S=>S[C]))]);if(f.find(x=>x[0]<0||x[1]>Rxe))return;const{toIJK:u,fromIJK:d,boundsIJKPrime:h,error:g}=zG(e,f);if(g){console.warn("Not performing island removal for planes not orthogonal to acquisition plane",g);return}const[p,v,y]=d(o.dimensions),m=new Mxe(p,v,y),w=(x,C,S)=>{const T=o.toIndex(u([x,C,S])),_=o.getAtIndex(T);if(_===c||_===s)return to.SEGMENT};return m.fillFrom(w,h),m.normalizer={toIJK:u,fromIJK:d,boundsIJKPrime:h},this.segmentSet=m,this.previewVoxelManager=a,this.segmentIndex=s,this.previewSegmentIndex=c??s,this.selectedPoints=l,!0}floodFillSegmentIsland(){const{selectedPoints:e,segmentSet:r}=this;let n=0;const{fromIJK:i}=r.normalizer;return e.forEach(o=>{const a=i(o),s=r.toIndex(a),[c,l,f]=a;r.get(s)===to.SEGMENT&&(n+=r.floodFill(c,l,f,to.ISLAND))}),n}removeExternalIslands(){const{previewVoxelManager:e,segmentSet:r}=this,{toIJK:n}=r.normalizer,i=(o,a)=>{const[,s,c]=r.toIJK(o);if(a.value!==to.ISLAND)for(let l=a.start;l<a.end;l++){const f=n([l,s,c]),u=e.getAtIJKPoint(f);e.setAtIJKPoint(f,u===void 0?0:null)}};r.forEach(i,{rowModified:!0})}removeInternalIslands(){const{segmentSet:e,previewVoxelManager:r,previewSegmentIndex:n}=this,{height:i,normalizer:o,width:a}=e,{toIJK:s}=o;return e.forEachRow((c,l)=>{let f;for(const u of[...l])if(u.value===to.ISLAND){if(!f){if(this.fillInternalEdge&&u.start>0)for(let d=0;d<u.start;d++)e.set(c+d,to.INTERIOR);f=u;continue}for(let d=f.end;d<u.start;d++)e.set(c+d,to.INTERIOR);f=u}if(this.fillInternalEdge&&(f==null?void 0:f.end)<a)for(let u=f.end;u<a;u++)e.set(c+u,to.INTERIOR)}),e.forEach((c,l)=>{if(l.value!==to.INTERIOR)return;const[,f,u]=e.toIJK(c),d=f>0?e.getRun(f-1,u):null,h=f+1<i?e.getRun(f+1,u):null,g=f===i-1,p=f===0,v=Pd.covers(l,d)||p&&this.fillInternalEdge,y=Pd.covers(l,h)||g&&this.fillInternalEdge;l.end-l.start>2&&(!v||!y)&&e.floodFill(l.start,f,u,to.EXTERIOR,{singlePlane:!0})}),e.forEach((c,l)=>{if(l.value!==to.INTERIOR)return;const[,f,u]=e.toIJK(c),g=e.floodFill(l.start,f,u,to.INTERIOR_TEST)>this.maxInternalRemove?to.EXTERIOR:to.INTERIOR_SMALL;e.floodFill(l.start,f,u,g)}),e.forEach((c,l)=>{if(l.value===to.INTERIOR_SMALL)for(let f=l.start;f<l.end;f++){const u=s(e.toIJK(c+f));r.setAtIJKPoint(u,n)}}),r.getArrayOfModifiedSlices()}static covers(e,r){if(!r)return!1;let{start:n}=e;const{end:i}=e;for(const o of r)if(n>=o.start&&n<o.end&&(n=o.end,n>=i))return!0;return!1}}const Lxe={[yt.OnInteractionEnd]:t=>{const{previewSegmentIndex:e,segmentIndex:r,viewport:n,segmentationVoxelManager:i,activeStrategy:o,memo:a}=t;if(o!=="THRESHOLD_INSIDE_SPHERE_WITH_ISLAND_REMOVAL"||r===null)return;const s=new Pd,c=(a==null?void 0:a.voxelManager)||i;if(!s.initialize(n,c,{previewSegmentIndex:e,segmentIndex:r}))return;s.floodFillSegmentIsland(),s.removeExternalIslands(),s.removeInternalIslands();const l=c.getArrayOfModifiedSlices();l&&lo(t.segmentationId,l,e)}},Axe={[yt.Preview]:function(t){var o,a;const{previewSegmentIndex:e,configuration:r,enabledElement:n}=t;if(!e||!r)return;(o=this.onInteractionStart)==null||o.call(this,n,t);const i=this.fill(n,t);return i&&((a=this.onInteractionEnd)==null||a.call(this,n,t)),i},[yt.Initialize]:t=>{const{segmentIndex:e,previewColor:r,previewSegmentIndex:n}=t;if(n==null||e==null)return;const i=tg(t.segmentationId);i==null||i.forEach(o=>{SB(o,t.segmentationId,n,r)})},[yt.AcceptPreview]:t=>{const{previewSegmentIndex:e,segmentationVoxelManager:r,memo:n,segmentIndex:i,centerSegmentIndexInfo:o}=t||{},{changedIndices:a}=o||{},s=n,c=({index:l})=>{const f=r.getAtIndex(l);(a==null?void 0:a.length)>0?a.includes(l)&&s.voxelManager.setAtIndex(l,0):f===e&&s.voxelManager.setAtIndex(l,i)};r.forEach(c),lo(t.segmentationId,r.getArrayOfModifiedSlices(),i),t.centerSegmentIndexInfo.changedIndices=[]},[yt.RejectPreview]:t=>{t&&EV.undoIf(e=>{const r=e;if(!(r!=null&&r.voxelManager))return!1;const{segmentationVoxelManager:n}=r;let i=!1;const o=({value:a})=>{a===t.previewSegmentIndex&&(i=!0)};return n.forEach(o),i})}},Nxe={[yt.Fill]:t=>{var l;const{segmentsLocked:e,segmentationImageData:r,segmentationVoxelManager:n,brushStrategy:i,centerIJK:o}=t,a=(l=i.createIsInThreshold)==null?void 0:l.call(i,t),{setValue:s}=i,c=a?f=>{const{value:u,index:d}=f;e.includes(u)||!a(d)||s(t,f)}:f=>s(t,f);n.forEach(c,{imageData:r,isInObject:t.isInObject,boundsIJK:t.isInObjectBoundsIJK}),n.addPoint(o)}};function kxe({operationData:t,existingValue:e,index:r}){const{previewSegmentIndex:n,memo:i,centerSegmentIndexInfo:o,previewOnHover:a,segmentIndex:s}=t,{hasPreviewIndex:c,hasSegmentIndex:l,segmentIndex:f}=o;if(f===0&&l&&c){if(e===s||a)return;if(e===n){i.voxelManager.setAtIndex(r,0);return}return}if(f===0&&l&&!c){if(e===0||e!==s)return;i.voxelManager.setAtIndex(r,n),o.changedIndices.push(r);return}if(f===0&&!l&&c){if(e===s||a)return;if(e===n){i.voxelManager.setAtIndex(r,0);return}return}if(f===0&&!l&&!c){if(e===s)return;if(e===n){i.voxelManager.setAtIndex(r,n);return}return}if(f===n&&l&&c){if(e===s)return;i.voxelManager.setAtIndex(r,n);return}if(f===n&&!l&&c){if(e===s)return;i.voxelManager.setAtIndex(r,n);return}if(f===s&&l&&c){if(e===s)return;i.voxelManager.setAtIndex(r,n);return}if(f===s&&l&&!c){if(e===s)return;i.voxelManager.setAtIndex(r,n);return}}const Vxe={[yt.INTERNAL_setValue]:(t,{value:e,index:r})=>{const{segmentsLocked:n,previewSegmentIndex:i,memo:o,segmentationVoxelManager:a,centerSegmentIndexInfo:s,segmentIndex:c}=t,l=a.getAtIndex(r);if(!n.includes(e)&&!(!s&&l===c)&&!((s==null?void 0:s.segmentIndex)!==0&&l===c)){if((s==null?void 0:s.segmentIndex)===null){o.voxelManager.setAtIndex(r,i??c);return}if(!i){let f=c;s&&(f=s.segmentIndex),o.voxelManager.setAtIndex(r,f);return}kxe({operationData:t,existingValue:l,index:r})}}},Fxe={[yt.CreateIsInThreshold]:t=>{const{imageVoxelManager:e,segmentIndex:r,configuration:n}=t;if(!(!n||!r))return i=>{var c;const o=e.getAtIndex(i),a=Array.isArray(o)?Ko(o):o,{threshold:s}=n||{};return(c=s==null?void 0:s.range)!=null&&c.length?s.range[0]<=a&&a<=s.range[1]:!0}}},n7=10;function x5(){return{maxIJKs:[]}}function $G(t,e){const{value:r}=e,{maxIJKs:n}=t,i=n.length;if(typeof r!="number"||i>=n7&&r<n[0].value)return;const o={value:e.value,pointLPS:e.pointLPS?[e.pointLPS[0],e.pointLPS[1],e.pointLPS[2]]:void 0,pointIJK:e.pointIJK?[e.pointIJK[0],e.pointIJK[1],e.pointIJK[2]]:void 0};if(!i||r>=n[i-1].value)n.push(o);else for(let a=0;a<i;a++)if(r<=n[a].value){n.splice(a,0,o);break}i>=n7&&n.splice(0,1)}function jG(t,e,r){const{spacing:n,calibration:i}=r,{volumeUnit:o}=ya({calibration:i,hasPixelSpacing:!0},[]),a=n?n[0]*n[1]*n[2]:1;return e.volume={value:Array.isArray(e.count.value)?e.count.value.map(s=>s*a):e.count.value*a,unit:o,name:"volume",label:"Volume"},e.maxIJKs=t.maxIJKs.filter(s=>s.pointIJK!==void 0),e.array.push(e.volume),t.maxIJKs=[],e}const ob=class ob extends al{static statsInit(e){super.statsInit(e),this.volumetricState=x5()}static statsCallback(e){super.statsCallback(e),$G(this.volumetricState,e)}static getStatistics(e){const r={...e,unit:(e==null?void 0:e.unit)||"none",calibration:e==null?void 0:e.calibration,hasPixelSpacing:e==null?void 0:e.hasPixelSpacing},n=super.getStatistics(r);return jG(this.volumetricState,n,r)}};ob.volumetricState=x5();let hd=ob;class r7 extends FU{constructor(e){super(e),this.volumetricState=x5()}statsInit(e){super.statsInit(e),this.volumetricState=x5()}statsCallback(e){super.statsCallback(e),$G(this.volumetricState,e)}getStatistics(e){const r={...e,unit:(e==null?void 0:e.unit)||"none",calibration:e==null?void 0:e.calibration,hasPixelSpacing:e==null?void 0:e.hasPixelSpacing},n=super.getStatistics(r);return jG(this.volumetricState,n,r)}}const Uxe=Math.pow(3*1e3/(4*Math.PI),1/3);async function HG({segmentationId:t,segmentIndices:e,mode:r="collective"}){Xw(),cl(Wa.COMPUTE_STATISTICS,0);const n=NG(t,e);if(!n)return;const{operationData:i,segVolumeId:o,segImageIds:a,reconstructableVolume:s,indices:c}=n,{refImageId:l,modalityUnitOptions:f}=uxe(o,a),u=EB(l,f);return s?await Bxe({operationData:i,indices:c,unit:u,mode:r}):await Gxe({segImageIds:a,indices:c,unit:u,mode:r})}async function Bxe({operationData:t,indices:e,unit:r,mode:n}){var p;const i=kG(t),{segmentationVoxelManager:o,imageVoxelManager:a,segmentationImageData:s,imageData:c}=i;if(!o||!s)return;const l=s.getSpacing(),{boundsIJK:f}=o;if(!f)return hd.getStatistics({spacing:l});const d={scalarData:o.getCompleteScalarDataArray(),dimensions:s.getDimensions(),spacing:s.getSpacing(),origin:s.getOrigin(),direction:s.getDirection()},h={scalarData:a.getCompleteScalarDataArray(),dimensions:c.getDimensions(),spacing:c.getSpacing(),origin:c.getOrigin(),direction:c.getDirection()};if(!((p=h.scalarData)!=null&&p.length))return;const g=await fl().executeTask("compute","calculateSegmentsStatisticsVolume",{segmentationInfo:d,imageInfo:h,indices:e,unit:r,mode:n});if(cl(Wa.COMPUTE_STATISTICS,100),n==="collective")return C5({stats:g,unit:r,spacing:l,segmentationImageData:s,imageVoxelManager:a});{const v={};return Object.entries(g).forEach(([y,m])=>{v[y]=C5({stats:m,unit:r,spacing:l,segmentationImageData:s,imageVoxelManager:a})}),v}}const RC=(t,e)=>{if(!t.array)return;const r=t.array.findIndex(n=>n.name===e.name);r!==-1?t.array[r]=e:t.array.push(e)},C5=({stats:t,unit:e,spacing:r,segmentationImageData:n,imageVoxelManager:i})=>{if(t.mean.unit=e,t.max.unit=e,t.min.unit=e,e!=="SUV")return t;const o=r.map(a=>Math.max(1,Math.round(1.1*Uxe/a)));for(const a of t.maxIJKs){const s=Wxe(a,o,n,i,r);if(!s)continue;const{mean:c}=s;(!t.peakValue||t.peakValue.value<=c.value)&&(t.peakValue={name:"peakValue",label:"Peak Value",value:c.value,unit:e},t.peakPoint={name:"peakLPS",label:"Peak SUV Point",value:a.pointLPS?[...a.pointLPS]:null,unit:null},RC(t,t.peakValue),RC(t,t.peakPoint))}if(t.volume&&t.mean){const a=t.volume.value,s=t.mean.value;t.lesionGlycolysis={name:"lesionGlycolysis",label:"Lesion Glycolysis",value:a*s,unit:`${t.volume.unit}·${e}`},RC(t,t.lesionGlycolysis)}return t};async function Gxe({segImageIds:t,indices:e,unit:r,mode:n}){cl(Wa.COMPUTE_STATISTICS,0);const{segmentationInfo:i,imageInfo:o}=VG(t),a=await fl().executeTask("compute","calculateSegmentsStatisticsStack",{segmentationInfo:i,imageInfo:o,indices:e,mode:n});cl(Wa.COMPUTE_STATISTICS,100);const s=i[0].spacing,c=i[0],l=o[0].voxelManager;if(n==="collective")return C5({stats:a,unit:r,spacing:s,segmentationImageData:c,imageVoxelManager:l});{const f={};return Object.entries(a).forEach(([u,d])=>{f[u]=C5({stats:d,unit:r,spacing:s,segmentationImageData:c,imageVoxelManager:l})}),f}}function Wxe(t,e,r,n,i){const{pointIJK:o,pointLPS:a}=t;if(!o)return;const s=o.map((f,u)=>[f-e[u],f+e[u]]),c=(f,u)=>{const d=(u[0]-o[0])/e[0],h=(u[1]-o[1])/e[1],g=(u[2]-o[2])/e[2];return d*d+h*h+g*g<=1},l=({pointIJK:f,pointLPS:u})=>{const d=n.getAtIJKPoint(f);d!==void 0&&hd.statsCallback({value:d,pointLPS:u,pointIJK:f})};return hd.statsInit({storePointData:!1}),j4(r,{pointInShapeFn:c,callback:l,boundsIJK:s}),hd.getStatistics({spacing:i})}const zxe={[yt.GetStatistics]:function(t,e,r){const{indices:n}=r,{segmentationId:i,viewport:o}=e;HG({segmentationId:i,segmentIndices:n})}},on={determineSegmentIndex:Exe,dynamicThreshold:bxe,erase:Dxe,islandRemoval:Lxe,preview:Axe,regionFill:Nxe,setValue:Vxe,threshold:Fxe,labelmapStatistics:zxe,ensureSegmentationVolumeFor3DManipulation:LG,ensureImageVolumeFor3DManipulation:AG},Zf=class Zf{constructor(e,...r){this._initialize=[],this._fill=[],this._onInteractionStart=[],this.fill=(n,i)=>{const o=this.initialize(n,i,yt.Fill);if(!o)return;this._fill.forEach(c=>c(o));const{segmentationVoxelManager:a,segmentIndex:s}=o;return lo(o.segmentationId,a.getArrayOfModifiedSlices(),s),o},this.onInteractionStart=(n,i)=>{const o=this.initialize(n,i);o&&this._onInteractionStart.forEach(a=>a.call(this,o))},this.addPreview=(n,i)=>{const o=this.initialize(n,i,yt.AddPreview);if(o)return o},this.configurationName=e,this.compositions=r,r.forEach(n=>{const i=typeof n=="function"?n():n;if(i)for(const o in i){if(!Zf.childFunctions[o])throw new Error(`Didn't find ${o} as a brush strategy`);Zf.childFunctions[o](this,i[o])}}),this.strategyFunction=(n,i)=>this.fill(n,i);for(const n of Object.keys(Zf.childFunctions))this.strategyFunction[n]=this[n]}initialize(e,r,n){const{viewport:i}=e,o=T8({operationData:r,viewport:i,strategy:this});if(!o)return null;const{imageVoxelManager:a,segmentationVoxelManager:s,segmentationImageData:c}=o,l=r.createMemo(r.segmentationId,s),f={operationName:n,...r,segmentIndex:r.segmentIndex,enabledElement:e,imageVoxelManager:a,segmentationVoxelManager:s,segmentationImageData:c,viewport:i,centerWorld:null,isInObject:null,isInObjectBoundsIJK:null,brushStrategy:this,memo:l};return this._initialize.forEach(u=>u(f)),f}};Zf.COMPOSITIONS=on,Zf.childFunctions={[yt.OnInteractionStart]:Gs(yt.OnInteractionStart,yt.Initialize),[yt.OnInteractionEnd]:Gs(yt.OnInteractionEnd,yt.Initialize),[yt.Fill]:Gs(yt.Fill),[yt.Initialize]:Gs(yt.Initialize),[yt.CreateIsInThreshold]:$2(yt.CreateIsInThreshold),[yt.Interpolate]:Gs(yt.Interpolate,yt.Initialize),[yt.AcceptPreview]:Gs(yt.AcceptPreview,yt.Initialize),[yt.RejectPreview]:Gs(yt.RejectPreview,yt.Initialize),[yt.INTERNAL_setValue]:$2(yt.INTERNAL_setValue),[yt.Preview]:$2(yt.Preview,!1),[yt.ComputeInnerCircleRadius]:Gs(yt.ComputeInnerCircleRadius),[yt.EnsureSegmentationVolumeFor3DManipulation]:Gs(yt.EnsureSegmentationVolumeFor3DManipulation),[yt.EnsureImageVolumeFor3DManipulation]:Gs(yt.EnsureImageVolumeFor3DManipulation),[yt.AddPreview]:Gs(yt.AddPreview),[yt.GetStatistics]:$2(yt.GetStatistics),compositions:null};let hc=Zf;function Gs(t,e){const r=`_${t}`;return(n,i)=>{n[r]||(n[r]=[]),n[r].push(i),n[t]||(n[t]=e?(o,a,...s)=>{const c=n[e](o,a,t);let l;return n[r].forEach(f=>{const u=f.call(n,c,...s);l||(l=u)}),l}:(o,...a)=>{n[r].forEach(s=>s.call(n,o,...a))})}}function $2(t,e=!0){return(r,n)=>{if(r[t])throw new Error(`The singleton method ${t} already exists`);r[t]=e?n:(i,o,...a)=>(o.enabledElement=i,n.call(r,o,...a))}}function KG(t,e){const{center:r,radius:n}=t,i=t.radius2||n*n;return(e[0]-r[0])*(e[0]-r[0])+(e[1]-r[1])*(e[1]-r[1])+(e[2]-r[2])*(e[2]-r[2])<=i}const{transformWorldToIndex:i7,isEqual:LC}=pn,qG={[yt.Initialize]:t=>{const{points:e,viewport:r,segmentationImageData:n}=t;if(!e)return;const i=Tt(0,0,0);e.forEach(d=>{Hr(i,i,d)}),gr(i,i,1/e.length),t.centerWorld=i,t.centerIJK=i7(n,i);const o=e.map(d=>r.worldToCanvas(d)),[a,s]=s5(o),c=r.canvasToWorld(a),l=r.canvasToWorld(s),f=e.map(d=>i7(n,d)),u=lf(f,n.getDimensions());t.isInObject=XG({topLeftWorld:c,bottomRightWorld:l,center:i}),t.isInObjectBoundsIJK=u}};function XG(t){const{topLeftWorld:e,bottomRightWorld:r,center:n}=t,i=Math.abs(e[0]-r[0])/2,o=Math.abs(e[1]-r[1])/2,a=Math.abs(e[2]-r[2])/2,s=Math.max(i,o,a);if(LC(i,s)&&LC(o,s)&&LC(a,s)){const f={center:n,radius:s,radius2:s*s};return u=>KG(f,u)}const c={center:n,xRadius:i,yRadius:o,zRadius:a},{precalculated:l}=KE(c,{});return l}const YG=new hc("Circle",on.regionFill,on.setValue,qG,on.determineSegmentIndex,on.preview,on.labelmapStatistics),$xe=new hc("CircleThreshold",on.regionFill,on.setValue,qG,on.determineSegmentIndex,on.dynamicThreshold,on.threshold,on.preview,on.islandRemoval,on.labelmapStatistics),Zw=YG.strategyFunction,jxe=$xe.strategyFunction;function Hxe(){throw new Error("Not yet implemented")}const{transformWorldToIndex:Kxe}=pn,qxe={[yt.Initialize]:t=>{const{points:e,viewport:r,segmentationImageData:n}=t;if(!e)return;const i=Tt(0,0,0);e.forEach(c=>{Hr(i,i,c)}),gr(i,i,1/e.length),t.centerWorld=i,t.centerIJK=Kxe(n,i);const{boundsIJK:o,topLeftWorld:a,bottomRightWorld:s}=Fwe(e.slice(0,2),n,r);t.isInObjectBoundsIJK=o,t.isInObject=XG({topLeftWorld:a,bottomRightWorld:s,center:i})}},Qw=new hc("Sphere",on.regionFill,on.setValue,qxe,on.determineSegmentIndex,on.preview,on.labelmapStatistics,on.ensureSegmentationVolumeFor3DManipulation),JG=Qw.strategyFunction,Xxe=new hc("SphereThreshold",...Qw.compositions,on.dynamicThreshold,on.threshold,on.ensureSegmentationVolumeFor3DManipulation,on.ensureImageVolumeFor3DManipulation),Yxe=new hc("SphereThreshold",...Qw.compositions,on.dynamicThreshold,on.threshold,on.islandRemoval,on.ensureSegmentationVolumeFor3DManipulation,on.ensureImageVolumeFor3DManipulation),Jxe=Xxe.strategyFunction,Zxe=Yxe.strategyFunction,Qxe=new hc("EraseSphere",on.erase,...Qw.compositions),ZG=Qxe.strategyFunction,eCe=new hc("EraseCircle",on.erase,...YG.compositions),QG=eCe.strategyFunction,{VoxelManager:QS,RLEVoxelMap:tCe}=pn;function eT(t,e){return tW(t,e)}function eW(t){const{segmentationVoxelManager:e,undoVoxelManager:r,redoVoxelManager:n}=this,i=t===!1?n:r;i.forEach(({value:a,pointIJK:s})=>{e.setAtIJKPoint(s,a)});const o=i.getArrayOfModifiedSlices();lo(this.segmentationId,o)}function tW(t,e){const r=QS.createRLEHistoryVoxelManager(e);return{segmentationId:t,restoreMemo:eW,commitMemo:nCe,segmentationVoxelManager:e,voxelManager:r,id:gn(),operationType:"labelmap"}}function nCe(){if(this.redoVoxelManager)return!0;if(!this.voxelManager.modifiedSlices.size)return!1;const{segmentationVoxelManager:t}=this,e=QS.createRLEHistoryVoxelManager(t);tCe.copyMap(e.map,this.voxelManager.map);for(const n of this.voxelManager.modifiedSlices.keys())e.modifiedSlices.add(n);this.undoVoxelManager=e;const r=QS.createRLEVolumeVoxelManager({dimensions:this.segmentationVoxelManager.dimensions});return this.redoVoxelManager=r,e.forEach(({index:n,pointIJK:i,value:o})=>{const a=t.getAtIJKPoint(i);a!==o&&r.setAtIndex(n,a)}),!0}const rCe=Object.freeze(Object.defineProperty({__proto__:null,createLabelmapMemo:eT,createRleMemo:tW,restoreMemo:eW},Symbol.toStringTag,{value:"Module"})),{isEqual:j2}=pn,iCe=Tt(1,0,0),oCe=Tt(0,1,0),aCe=Tt(0,0,1),o7=[iCe,oCe,aCe];function nW(t){const e=Nn(Ke(),t[0],t[1]),r=Nn(Ke(),t[0],t[2]),n=a7(e,o7),i=a7(r,o7);return[...n,...i].every(a=>j2(a,0)||j2(a,90)||j2(a,180)||j2(a,270))}function a7(t,e){return e.map(r=>s4(t,r)*180/Math.PI)}const{transformWorldToIndex:rW}=pn,iW={[yt.Initialize]:t=>{const{points:e,imageVoxelManager:r,viewport:n,segmentationImageData:i,segmentationVoxelManager:o}=t;if(!e)return;const a=Tt(0,0,0);e.forEach(l=>{Hr(a,a,l)}),gr(a,a,1/e.length),t.centerWorld=a,t.centerIJK=rW(i,a);const{boundsIJK:s,pointInShapeFn:c}=sCe(n,e,i);t.isInObject=c,t.isInObjectBoundsIJK=s}};function sCe(t,e,r){let n=e.map(w=>rW(r,w));n=n.map(w=>w.map(x=>Math.round(x)));const i=lf(n,r.getDimensions()),a=t instanceof Jn||nW(n),s=r.getDirection(),c=r.getSpacing(),{viewPlaneNormal:l}=t.getCamera(),f=Cf({direction:s,spacing:c},l),u=fU(e);let[[d,h],[g,p],[v,y]]=u;return d-=f,h+=f,g-=f,p+=f,v-=f,y+=f,{boundsIJK:i,pointInShapeFn:a?()=>!0:w=>{const[x,C,S]=w,T=x>=d&&x<=h,_=C>=g&&C<=p,E=S>=v&&S<=y;return T&&_&&E}}}const cCe=new hc("Rectangle",on.regionFill,on.setValue,iW,on.determineSegmentIndex,on.preview,on.labelmapStatistics),lCe=new hc("RectangleThreshold",on.regionFill,on.setValue,iW,on.determineSegmentIndex,on.dynamicThreshold,on.threshold,on.preview,on.islandRemoval,on.labelmapStatistics),D8=cCe.strategyFunction,uCe=lCe.strategyFunction,fCe=Object.freeze(Object.defineProperty({__proto__:null,fillInsideCircle:Zw,fillInsideRectangle:D8,fillOutsideCircle:Hxe,thresholdInsideRectangle:uCe},Symbol.toStringTag,{value:"Module"})),Np=class Np extends ri{constructor(e,r){super(e,r),this.memoMap=new Map,this.acceptedMemoIds=new Map,this.centerSegmentIndexInfo={segmentIndex:null,hasSegmentIndex:!1,hasPreviewIndex:!1,changedIndices:[]}}_historyRedoHandler(e){const{id:r,operationType:n}=e.detail;if(n==="labelmap"){if(this.acceptedMemoIds.has(r)){this._hoverData=null;const i=this.acceptedMemoIds.get(r),o=i==null?void 0:i.element,a=this.getOperationData(o);a.segmentIndex=i==null?void 0:i.segmentIndex,o&&this.applyActiveStrategyCallback(Le(o),a,yt.AcceptPreview)}this._previewData.isDrag=!0}}get _previewData(){return Np.previewData}createMemo(e,r){const n=r.id;if(this.memo&&this.memo.segmentationVoxelManager===r)return this.memo;let i=this.memoMap.get(n);return i?i.redoVoxelManager&&(i=eT(e,r),this.memoMap.set(n,i)):(i=eT(e,r),this.memoMap.set(n,i)),this.memo=i,i}createEditData(e){const r=Le(e),{viewport:n}=r,i=Od(n.id);if(!i){const l=new CustomEvent(et.ERROR_EVENT,{detail:{type:"Segmentation",message:"No active segmentation detected, create a segmentation representation before using the brush tool"},cancelable:!0});return Ze.dispatchEvent(l),null}const{segmentationId:o}=i,a=zd(o),{representationData:s}=_n(o);return this.getEditData({viewport:n,representationData:s,segmentsLocked:a,segmentationId:o})}getEditData({viewport:e,representationData:r,segmentsLocked:n,segmentationId:i}){var o,a,s;if(e instanceof fr){const{volumeId:c}=r[St.Labelmap],l=e.getActors();if(e instanceof Jn){const g=new CustomEvent(et.ERROR_EVENT,{detail:{type:"Segmentation",message:"Cannot perform brush operation on the selected viewport"},cancelable:!0});return Ze.dispatchEvent(g),null}const u=l.map(g=>$e.getVolume(g.referencedId)),d=$e.getVolume(c),h=((o=u.find(g=>Vt(g.dimensions,d.dimensions)))==null?void 0:o.volumeId)||((a=u[0])==null?void 0:a.volumeId);return{volumeId:c,referencedVolumeId:((s=this.configuration.threshold)==null?void 0:s.volumeId)??h,segmentsLocked:n}}else{const c=_f(e.id,i);return c?{imageId:c,segmentsLocked:n}:void 0}}createHoverData(e,r){const n=Le(e),{viewport:i}=n,o=i.getCamera(),{viewPlaneNormal:a,viewUp:s}=o,c=[i.id],{segmentIndex:l,segmentationId:f,segmentColor:u}=this.getActiveSegmentationData(i)||{};return{brushCursor:{metadata:{viewPlaneNormal:[...a],viewUp:[...s],FrameOfReferenceUID:i.getFrameOfReferenceUID(),referencedImageId:"",toolName:this.getToolName(),segmentColor:u},data:{}},centerCanvas:r,segmentIndex:l,viewport:i,segmentationId:f,segmentColor:u,viewportIdsToRender:c}}getActiveSegmentationData(e){const r=e.id,n=Od(r);if(!n)return;const{segmentationId:i}=n,o=va(i);if(!o)return;const a=ou(r,i,o);return{segmentIndex:o,segmentationId:i,segmentColor:a}}getOperationData(e){var v,y,m,w;const r=this._editData||this.createEditData(e),{segmentIndex:n,segmentationId:i,brushCursor:o}=this._hoverData||this.createHoverData(e),{data:a,metadata:s={}}=o||{},{viewPlaneNormal:c,viewUp:l}=s,f=(y=(v=this.configuration.preview)==null?void 0:v.previewColors)==null?void 0:y[n],{viewport:u}=Le(e),d=ou(u.id,i,n);if(!f&&!d)return;let h=null,g=null;return(m=this.configuration.preview)!=null&&m.enabled&&(h=f||dCe(...d),g=255),{...r,points:(w=a==null?void 0:a.handles)==null?void 0:w.points,segmentIndex:n,viewPlaneNormal:c,previewOnHover:!this._previewData.isDrag,toolGroupId:this.toolGroupId,segmentationId:i,viewUp:l,centerSegmentIndexInfo:this.centerSegmentIndexInfo,activeStrategy:this.configuration.activeStrategy,configuration:this.configuration,previewColor:h,previewSegmentIndex:g,createMemo:this.createMemo.bind(this)}}addPreview(e=this._previewData.element,r){const{_previewData:n}=this,i=r==null?void 0:r.acceptReject;i===!0?this.acceptPreview(e):i===!1&&this.rejectPreview(e);const o=Le(e),a=this.applyActiveStrategyCallback(o,this.getOperationData(e),yt.AddPreview);return n.isDrag=!0,a}rejectPreview(e=this._previewData.element){if(!e)return;this.doneEditMemo();const r=Le(e);this.applyActiveStrategyCallback(r,this.getOperationData(e),yt.RejectPreview),this._previewData.preview=null,this._previewData.isDrag=!1}acceptPreview(e=this._previewData.element){if(!e)return;const r=this.getOperationData(e);this.memo&&this.memo.id&&this.acceptedMemoIds.set(this.memo.id,{element:e,segmentIndex:r.segmentIndex});const n=Le(e);this.applyActiveStrategyCallback(n,r,yt.AcceptPreview),this.doneEditMemo(),this._previewData.preview=null,this._previewData.isDrag=!1}static viewportContoursToLabelmap(e,r){var v;const n=(r==null?void 0:r.removeContours)??!0,i=vm(),o=Im(e,i);if(!(o!=null&&o.length))return;const a=o.filter(y=>{var m,w;return(w=(m=y.data.contour)==null?void 0:m.polyline)==null?void 0:w.length});if(!a.length)return;const c=new Np({},{configuration:{strategies:{FILL_INSIDE_CIRCLE:Zw},activeStrategy:"FILL_INSIDE_CIRCLE"}}).addPreview(e.element),{memo:l,segmentationId:f}=c,u=l==null?void 0:l.voxelManager,d=u.sourceVoxelManager||u,{dimensions:h}=u,g=e.getDefaultActor().actor.getMapper().getInputData();for(const y of a){const m=[[1/0,-1/0],[1/0,-1/0],[1/0,-1/0]],{polyline:w}=y.data.contour;for(const I of w)g.worldToIndex(I).forEach((O,L)=>{m[L][0]=Math.min(m[L][0],O),m[L][1]=Math.max(m[L][1],O)});m.forEach((I,P)=>{I[0]=Math.round(Math.max(0,I[0])),I[1]=Math.round(Math.min(h[P]-1,I[1]))});const x=va(f),C=((v=y.data.handles)==null?void 0:v[0])||w[0],S=g.worldToIndex(C).map(Math.round),T=d.getAtIJKPoint(S)||0;let _=!1,E=!1;for(const I of w){const P=g.worldToIndex(I).map(Math.round),O=d.getAtIJKPoint(P);O===T?_=!0:O>=0&&(E=!0)}const D=_&&E?T:T===0?x:0;for(let I=m[0][0];I<=m[0][1];I++)for(let P=m[1][0];P<=m[1][1];P++)for(let O=m[2][0];O<=m[2][1];O++){const L=g.indexToWorld([I,P,O]);QE(L,w)&&u.setAtIJK(I,P,O,D)}n&&en(y.annotationUID)}const p=u.getArrayOfModifiedSlices();lo(f,p)}};Np.previewData={preview:null,element:null,timerStart:0,timer:null,startPoint:[NaN,NaN],isDrag:!1};let Rd=Np;function dCe(t,e,r,n,i=.4){return[Math.round(t+(255-t)*i),Math.round(e+(255-e)*i),Math.round(r+(255-r)*i),n]}class ex extends Rd{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{strategies:{FILL_INSIDE_CIRCLE:Zw,ERASE_INSIDE_CIRCLE:QG,FILL_INSIDE_SPHERE:JG,ERASE_INSIDE_SPHERE:ZG,THRESHOLD_INSIDE_CIRCLE:jxe,THRESHOLD_INSIDE_SPHERE:Jxe,THRESHOLD_INSIDE_SPHERE_WITH_ISLAND_REMOVAL:Zxe},defaultStrategy:"FILL_INSIDE_CIRCLE",activeStrategy:"FILL_INSIDE_CIRCLE",brushSize:25,useCenterSegmentIndex:!1,preview:{enabled:!1,previewColors:{0:[255,255,255,128]},previewTimeMs:250,previewMoveDistance:8,dragMoveDistance:4,dragTimeMs:500},actions:{[yt.AcceptPreview]:{method:yt.AcceptPreview,bindings:[{key:"Enter"}]},[yt.RejectPreview]:{method:yt.RejectPreview,bindings:[{key:"Escape"}]},[yt.Interpolate]:{method:yt.Interpolate,bindings:[{key:"i"}],configuration:{useBallStructuringElement:!0,noUseDistanceTransform:!0,noUseExtrapolation:!0}},interpolateExtrapolation:{method:yt.Interpolate,bindings:[{key:"e"}],configuration:{}}}}}){super(e,r),this.onSetToolPassive=n=>{this.disableCursor()},this.onSetToolEnabled=()=>{this.disableCursor()},this.onSetToolDisabled=n=>{this.disableCursor()},this.preMouseDownCallback=n=>{const i=n.detail,{element:o}=i,a=Le(o);this._editData=this.createEditData(o),this._activateDraw(o),Dt(o),n.preventDefault(),this._previewData.isDrag=!1,this._previewData.timerStart=Date.now();const s=this._hoverData||this.createHoverData(o);We(s.viewportIdsToRender);const c=this.getOperationData(o);return this.applyActiveStrategyCallback(a,c,yt.OnInteractionStart),!0},this.mouseMoveCallback=n=>{if(this.mode===En.Active){if(this.updateCursor(n),!this.configuration.preview.enabled)return;const{previewTimeMs:i,previewMoveDistance:o,dragMoveDistance:a}=this.configuration.preview,{currentPoints:s,element:c}=n.detail,{canvas:l}=s,{startPoint:f,timer:u,timerStart:d,isDrag:h}=this._previewData;if(h)return;const g=ur(l,f),p=Date.now()-d;if((g>o||p>i&&g>a)&&(u&&(window.clearTimeout(u),this._previewData.timer=null),h||this.rejectPreview(c)),!this._previewData.timer){const v=window.setTimeout(this.previewCallback,250);Object.assign(this._previewData,{timerStart:Date.now(),timer:v,startPoint:l,element:c})}}},this.previewCallback=()=>{if(this._previewData.isDrag){this._previewData.timer=null;return}this._previewData.timer=null;const n=this.getOperationData(this._previewData.element),i=Le(this._previewData.element);if(!i)return;const{viewport:o}=i,a=this.configuration.activeStrategy,s=T8({operationData:n,viewport:o,strategy:a});if(!n)return;const c=this.createMemo(n.segmentationId,s.segmentationVoxelManager);this._previewData.preview=this.applyActiveStrategyCallback(Le(this._previewData.element),{...n,...s,memo:c},yt.Preview)},this._dragCallback=n=>{const i=n.detail,{element:o,currentPoints:a}=i,s=Le(o);this.updateCursor(n);const{viewportIdsToRender:c}=this._hoverData;We(c);const l=ur(a.canvas,this._previewData.startPoint),{dragTimeMs:f,dragMoveDistance:u}=this.configuration.preview;!this._previewData.isDrag&&Date.now()-this._previewData.timerStart<f&&l<u||(this._previewData.timer&&(window.clearTimeout(this._previewData.timer),this._previewData.timer=null),this._previewData.preview=this.applyActiveStrategy(s,this.getOperationData(o)),this._previewData.element=o,this._previewData.timerStart=Date.now()+f,this._previewData.isDrag=!0,this._previewData.startPoint=a.canvas)},this._endCallback=n=>{const i=n.detail,{element:o}=i,a=Le(o),s=this.getOperationData(o);!this._previewData.preview&&!this._previewData.isDrag&&this.applyActiveStrategy(a,s),this.doneEditMemo(),this._deactivateDraw(o),kt(o),this.updateCursor(n),this._editData=null,this.applyActiveStrategyCallback(a,s,yt.OnInteractionEnd),this._previewData.isDrag||this.acceptPreview(o)},this._activateDraw=n=>{n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback)},this._deactivateDraw=n=>{n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback)}}disableCursor(){this._hoverData=void 0,this.rejectPreview()}updateCursor(e){const r=e.detail,{element:n}=r,{currentPoints:i}=r,o=i.canvas;this._hoverData=this.createHoverData(n,o),this._calculateCursor(n,o),this._hoverData&&We(this._hoverData.viewportIdsToRender)}_calculateCursor(e,r){const n=Le(e),{viewport:i}=n,{canvasToWorld:o}=i,a=i.getCamera(),{brushSize:s}=this.configuration,c=Tt(a.viewUp[0],a.viewUp[1],a.viewUp[2]),l=Tt(a.viewPlaneNormal[0],a.viewPlaneNormal[1],a.viewPlaneNormal[2]),f=Ke();Tn(f,c,l);const u=o([r[0],r[1]]),d=Ke(),h=Ke(),g=Ke(),p=Ke();for(let x=0;x<=2;x++)d[x]=u[x]-c[x]*s,h[x]=u[x]+c[x]*s,g[x]=u[x]-f[x]*s,p[x]=u[x]+f[x]*s;if(!this._hoverData)return;const{brushCursor:v}=this._hoverData,{data:y}=v;y.handles===void 0&&(y.handles={}),y.handles.points=[d,h,g,p];const m=this.configuration.activeStrategy,w=this.configuration.strategies[m];typeof(w==null?void 0:w.computeInnerCircleRadius)=="function"&&w.computeInnerCircleRadius({configuration:this.configuration,viewport:i}),y.invalidated=!1}getStatistics(e,r){if(!e)return;const n=Le(e);return this.applyActiveStrategyCallback(n,this.getOperationData(e),yt.GetStatistics,r)}rejectPreview(e=this._previewData.element){if(!e)return;this.doneEditMemo();const r=Le(e);r&&(this.applyActiveStrategyCallback(r,this.getOperationData(e),yt.RejectPreview),this._previewData.preview=null,this._previewData.isDrag=!1)}acceptPreview(e=this._previewData.element){e&&super.acceptPreview(e)}interpolate(e,r){if(!e)return;const n=Le(e);this._previewData.preview=this.applyActiveStrategyCallback(n,this.getOperationData(e),yt.Interpolate,r.configuration),this._previewData.isDrag=!0}invalidateBrushCursor(){if(this._hoverData===void 0)return;const{data:e}=this._hoverData.brushCursor,{viewport:r}=this._hoverData;e.invalidated=!0;const{segmentColor:n}=this.getActiveSegmentationData(r)||{};this._hoverData.brushCursor.metadata.segmentColor=n}renderAnnotation(e,r){var m,w;if(!this._hoverData)return;const{viewport:n}=e;if(!this._hoverData.viewportIdsToRender.includes(n.id))return;const o=this._hoverData.brushCursor;if(o.data.invalidated===!0){const{centerCanvas:x}=this._hoverData,{element:C}=n;this._calculateCursor(C,x)}const a=o.metadata;if(!a)return;const s=a.brushCursorUID,c=o.data,{points:l}=c.handles,f=l.map(x=>n.worldToCanvas(x)),u=f[0],d=f[1],h=[Math.floor((u[0]+d[0])/2),Math.floor((u[1]+d[1])/2)],g=Math.abs(u[1]-Math.floor((u[1]+d[1])/2)),p=`rgb(${((m=a.segmentColor)==null?void 0:m.slice(0,3))||[0,0,0]})`;if(!n.getRenderingEngine()){console.warn("Rendering Engine has been destroyed");return}Yo(r,s,"0",h,g,{color:p,lineDash:this.centerSegmentIndexInfo.segmentIndex===0?[1,2]:null});const{dynamicRadiusInCanvas:y}=((w=this.configuration)==null?void 0:w.threshold)||{dynamicRadiusInCanvas:0};y&&Yo(r,s,"1",h,y,{color:p})}}ex.toolName="Brush";function ag(t,e){const r=jr(t);if(r===void 0)return;const n=r._toolInstances;return Object.keys(n).length?e&&n[e]?[n[e]]:Object.values(n).filter(o=>o instanceof ex):void 0}function hCe(t,e,r){const n=jr(t);if(n===void 0)return;ag(t,r).forEach(l=>{l.configuration.brushSize=e,l.invalidateBrushCursor()});const o=n.getViewportsInfo(),a=Object.keys(o).map(l=>o[l]);if(!a.length)return;const{renderingEngineId:s}=a[0],c=n.getViewportIds();Nr(s),We(c)}function gCe(t,e){const r=jr(t);if(r===void 0)return;const n=r._toolInstances;if(!Object.keys(n).length)return;const o=ag(t,e)[0];if(o)return o.configuration.brushSize}function pCe(t,e){const r=jr(t);if(r===void 0||(ag(t).forEach(a=>{a.configuration.activeStrategy.toLowerCase().includes("threshold")&&(a.configuration={...a.configuration,threshold:{...a.configuration.threshold,...e}})}),!r.getViewportsInfo().length))return;const o=r.getViewportIds();We(o)}function mCe(t){const e=jr(t);if(e===void 0)return;const r=e._toolInstances;if(!Object.keys(r).length)return;const i=ag(t)[0];if(i)return i.configuration.threshold.range}const kp=class kp{static statsInit(e){const{storePointData:r,indices:n,mode:i}=e;this.mode=i,this.indices=n,this.calculators.clear(),this.mode==="individual"?n.forEach(o=>{this.calculators.set(o,new r7({storePointData:r}))}):this.calculators.set(n,new r7({storePointData:r}))}static statsCallback(e){const{segmentIndex:r,...n}=e;if(!r)throw new Error("Segment index is required for stats calculation");const i=this.mode==="individual"?this.calculators.get(r):this.calculators.get(this.indices);if(!i)throw new Error(`No calculator found for segment ${r}`);i.statsCallback(n)}static getStatistics(e){if(this.mode==="individual"){const n={};return this.calculators.forEach((i,o)=>{n[o]=i.getStatistics(e)}),n}return this.calculators.get(this.indices).getStatistics(e)}};kp.calculators=new Map,kp.indices=[],kp.mode="collective";let tT=kp;function vCe(t,e,r,n,i){if(!i)throw new Error("Segmentation ID is required to be passed inside thresholdSegmentationByRange");const{baseVolumeIdx:o,volumeInfoList:a}=dU(t,r),{voxelManager:s}=a[o],c=s,l=t.voxelManager.getScalarDataLength(),f=t.voxelManager;return a.forEach(u=>{const{volumeSize:d}=u;d===l?wCe(f,c,e,u):yCe(f,c,e,u,a,o,n)}),lo(i),t}function yCe(t,e,r,n,i,o,a){const{imageData:s,lower:c,upper:l,dimensions:f}=n;let u,d,h;const g=t.getScalarDataLength();for(let p=0;p<g;p++)if(g.getAtIndex(p)===r){const v=AE(s,f,i[o].spacing,i[o].imageData.getPoint(p)),y=({value:w})=>{u=u+1,w>=h.lower&&w<=h.upper&&(d=d+1)};u=0,d=0,h={lower:c,upper:l};let m=!1;t.forEach(y,{imageData:s,boundsIJK:v}),m=a===0?d>0:d===u,t.setAtIndex(p,m?r:0)}return{total:u,range:h,overlaps:d}}function wCe(t,e,r,n){const{lower:i,upper:o}=n,a=t.getScalarDataLength();for(let s=0;s<a;s++)if(t.getAtIndex[s]===r){const c=e.getAtIndex(s);t.setAtIndex(s,c>=i&&c<=o?r:0)}}function s7(t,e,r){const n=r.toIJK(t),i=r.toIJK(e),o=Ke(),{testIJK:a}=r,s=hn(Ke(),n,i),c=Math.round(Math.max(...s.map(Math.abs)));if(c<2)return!0;const l=gr(Ke(),s,1/c);for(let f=1;f<c;f++)if(dn(o,i,l,f),!a(o))return!1;return!0}function xCe({dimensions:t,imageData:e,voxelManager:r,segmentIndex:n,containedSegmentIndices:i}){const o=t[0],a=o*t[1];return{testCenter:(s,c)=>{const l=Hr(Ke(),s,c).map(v=>v/2),f=e.worldToIndex(l).map(Math.round),[u,d,h]=f,g=u+d*o+h*a,p=r.getAtIndex(g);return p===n||(i==null?void 0:i.has(p))},toIJK:s=>e.worldToIndex(s),testIJK:s=>{const[c,l,f]=s,u=Math.round(c)+Math.round(l)*o+Math.round(f)*a,d=r.getAtIndex(u);return d===n||(i==null?void 0:i.has(d))}}}function CCe(t,e,r){const n=$e.getVolume(t);if(!n){console.warn(`No volume found for ${t}`);return}return xCe({dimensions:n.dimensions,imageData:n.imageData,voxelManager:n.voxelManager,segmentIndex:e,containedSegmentIndices:r})}const Ng=.01;function SCe(t,e,r){const{sliceContours:n}=t,{segmentIndex:i,containedSegmentIndices:o}=r;let a;const s=CCe(e,i,o);for(const c of n){const l=TCe(c,s,a);l&&(a=l)}return a&&Object.assign(a,r),a}function TCe(t,e,r={maxMajor:0,maxMinor:0}){const{points:n}=t.polyData,{maxMinor:i,maxMajor:o}=r;let a=o*o,s=i*i,c;for(let v=0;v<n.length;v++)for(let y=v+1;y<n.length;y++){const m=n[v],w=n[y],x=lS(m,w);x<a||x-Ng<a+Ng&&c||e.testCenter(m,w)&&s7(m,w,e)&&(a=x-Ng,c=[v,y],s=0)}if(!c)return;a=Math.sqrt(a+Ng);const l=n[c[0]],f=n[c[1]],u=hn(Ke(),l,f);gr(u,u,1/a);let d;for(let v=0;v<n.length;v++)for(let y=v+1;y<n.length;y++){const m=n[v],w=n[y],x=lS(m,w);if(x<=s)continue;const C=hn(Ke(),m,w);Math.abs(xt(C,u))/Math.sqrt(x)>Ng||e.testCenter(m,w)&&s7(m,w,e)&&(s=x,d=[v,y])}if(!d)return;s=Math.sqrt(s);const h=n[d[0]],g=n[d[1]];return{majorAxis:[l,f],minorAxis:[h,g],maxMajor:a,maxMinor:s,...t}}async function oW(t){const e=await FG({segmentations:t});if(!(e!=null&&e.length)||!e[0].sliceContours.length)return;const{segments:r=[null,{label:"Unspecified",color:null,containedSegmentIndices:null}]}=t,n=og(t.segmentationId);if(!n)return;const i=r.findIndex(o=>!!o);if(i!==-1)return r[i].segmentIndex=i,SCe(e[0],n.volumeId,r[i])}function aW(t,e){const{majorAxis:r,minorAxis:n,label:i="",sliceIndex:o}=t,[a,s]=r,[c,l]=n,f=[a,s,c,l];return{highlighted:!0,invalidated:!0,metadata:{toolName:"Bidirectional",...e.getViewReference({sliceIndex:o})},data:{handles:{points:f,textBox:{hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}},activeHandleIndex:null},label:i,cachedStats:{}},isLocked:!1,isVisible:!0}}const{transformWorldToIndex:H2}=pn,A0=class A0 extends Yn{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{preventHandleOutsideImage:!1,getTextLines:_Ce}}){super(e,r),this.isPointNearTool=(n,i,o,a)=>{const s=Le(n),{viewport:c}=s,{data:l}=i,{points:f}=l.handles;let u=c.worldToCanvas(f[0]),d=c.worldToCanvas(f[1]),h={start:{x:u[0],y:u[1]},end:{x:d[0],y:d[1]}},g=ui([h.start.x,h.start.y],[h.end.x,h.end.y],[o[0],o[1]]);return g<=a||(u=c.worldToCanvas(f[2]),d=c.worldToCanvas(f[3]),h={start:{x:u[0],y:u[1]},end:{x:d[0],y:d[1]}},g=ui([h.start.x,h.start.y],[h.end.x,h.end.y],[o[0],o[1]]),g<=a)},this.toolSelectedCallback=(n,i)=>{const o=n.detail,{element:a}=o;i.highlighted=!0;const s=wt(a,this.getToolName());this.editData={annotation:i,viewportIdsToRender:s,movingTextBox:!1},this._activateModify(a);const c=Le(a),{renderingEngine:l}=c;We(s),Dt(a),n.preventDefault()},this.handleSelectedCallback=(n,i,o)=>{const a=n.detail,{element:s}=a,c=i.data;i.highlighted=!0;let l=!1,f;o.worldPosition?l=!0:f=c.handles.points.findIndex(g=>g===o);const u=wt(s,this.getToolName());Dt(s),this.editData={annotation:i,viewportIdsToRender:u,handleIndex:f,movingTextBox:l},this._activateModify(s);const d=Le(s),{renderingEngine:h}=d;We(u),n.preventDefault()},this._endCallback=n=>{const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s,newAnnotation:c,hasMoved:l}=this.editData,{data:f}=a;if(c&&!l)return;this.doneEditMemo(),f.handles.activeHandleIndex=null,this._deactivateModify(o),this._deactivateDraw(o),kt(o);const{renderingEngine:u}=Le(o);if(this.editData.handleIndex!==void 0){const{points:d}=f.handles,h=Fi(d[0],d[1]);if(Fi(d[2],d[3])>h){const p=[[...d[2]],[...d[3]]],v=[...d[0]],y=[...d[1]],m=Wt();fs(m,p[1][0]-p[0][0],p[1][1]-p[1][0]);const w=Wt();fs(w,-m[1],m[0]);const x=Wt();fs(x,y[0]-v[0],y[1]-v[0]);let C;c4(x,w)>0?C=[v,y]:C=[y,v],f.handles.points=[p[0],p[1],C[0],C[1]]}}this.isHandleOutsideImage&&this.configuration.preventHandleOutsideImage&&en(a.annotationUID),We(s),c&&bn(a),this.editData=null,this.isDrawing=!1},this._dragDrawCallback=n=>{this.isDrawing=!0;const i=n.detail,{currentPoints:o,element:a}=i,s=Le(a),{viewport:c}=s,{worldToCanvas:l}=c,{annotation:f,viewportIdsToRender:u,handleIndex:d,newAnnotation:h}=this.editData;this.createMemo(a,f,{newAnnotation:h});const{data:g}=f,p=o.world;g.handles.points[d]=[...p];const v=g.handles.points.map(l),y={longLineSegment:{start:{x:v[0][0],y:v[0][1]},end:{x:v[1][0],y:v[1][1]}},shortLineSegment:{start:{x:v[2][0],y:v[2][1]},end:{x:v[3][0],y:v[3][1]}}},w=ur(v[0],v[1])/3,x=y.longLineSegment.start.x-y.longLineSegment.end.x,C=y.longLineSegment.start.y-y.longLineSegment.end.y,S=Math.sqrt(x*x+C*C),T=x/S,_=C/S,E=(y.longLineSegment.start.x+y.longLineSegment.end.x)/2,b=(y.longLineSegment.start.y+y.longLineSegment.end.y)/2,D=E+w*_,I=b-w*T,P=E-w*_,O=b+w*T;g.handles.points[2]=c.canvasToWorld([D,I]),g.handles.points[3]=c.canvasToWorld([P,O]),f.invalidated=!0,We(u),Kt(f,a,Bt.HandlesUpdated),this.editData.hasMoved=!0},this._dragModifyCallback=n=>{this.isDrawing=!0;const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s,handleIndex:c,movingTextBox:l,newAnnotation:f}=this.editData;this.createMemo(o,a,{newAnnotation:f});const{data:u}=a;if(l){const{deltaPoints:d}=i,h=d.world,{textBox:g}=u.handles,{worldPosition:p}=g;p[0]+=h[0],p[1]+=h[1],p[2]+=h[2],g.hasMoved=!0}else if(c===void 0){const{deltaPoints:d}=i,h=d.world;u.handles.points.forEach(p=>{p[0]+=h[0],p[1]+=h[1],p[2]+=h[2]}),a.invalidated=!0}else this._dragModifyHandle(n),a.invalidated=!0;We(s),a.invalidated&&Kt(a,o,Bt.HandlesUpdated)},this._dragModifyHandle=n=>{const i=n.detail,{currentPoints:o,element:a}=i,s=Le(a),{viewport:c}=s,{annotation:l,handleIndex:f}=this.editData,{data:u}=l,d=o.world,h=[c.worldToCanvas(u.handles.points[0]),c.worldToCanvas(u.handles.points[1]),c.worldToCanvas(u.handles.points[2]),c.worldToCanvas(u.handles.points[3])],g={start:{x:h[0][0],y:h[0][1]},end:{x:h[1][0],y:h[1][1]}},p={start:{x:h[2][0],y:h[2][1]},end:{x:h[3][0],y:h[3][1]}},v=[...d],y=c.worldToCanvas(v);if(f===0||f===1){const w=h[f===0?1:0],x=fs(Wt(),y[0]-w[0],y[1]-w[1]),C=fs(Wt(),h[f][0]-w[0],h[f][1]-w[1]);Ul(x,x),Ul(C,C);const S={start:{x:w[0],y:w[1]},end:{x:y[0],y:y[1]}};if(this._movingLongAxisWouldPutItThroughShortAxis(S,p))return;const T=w,_=this._getSignedAngle(C,x);let E=h[2][0],b=h[2][1],D=h[3][0],I=h[3][1];E-=T[0],b-=T[1],D-=T[0],I-=T[1];const P=E*Math.cos(_)-b*Math.sin(_),O=E*Math.sin(_)+b*Math.cos(_),L=D*Math.cos(_)-I*Math.sin(_),B=D*Math.sin(_)+I*Math.cos(_);E=P+T[0],b=O+T[1],D=L+T[0],I=B+T[1];const H=c.canvasToWorld([E,b]),A=c.canvasToWorld([D,I]);u.handles.points[f]=v,u.handles.points[2]=H,u.handles.points[3]=A}else{const m=f===2?3:2,w={longLineSegment:{start:g.start,end:g.end},shortLineSegment:{start:p.start,end:p.end}},x=Br(Wt(),[w.longLineSegment.end.x,w.longLineSegment.end.y],[w.longLineSegment.start.x,w.longLineSegment.start.y]),C=Ul(Wt(),x),S=Br(Wt(),[y[0],y[1]],[h[f][0],h[f][1]]),T=Sy(S),_=this._getSignedAngle(C,S),E=Math.cos(_)*T,b=XY(Wt(),[h[m][0],h[m][1]],C,E);if(this._movingLongAxisWouldPutItThroughShortAxis({start:{x:y[0],y:y[1]},end:{x:b[0],y:b[1]}},{start:{x:w.longLineSegment.start.x,y:w.longLineSegment.start.y},end:{x:w.longLineSegment.end.x,y:w.longLineSegment.end.y}})||!l5([y[0],y[1]],[b[0],b[1]],[g.start.x,g.start.y],[g.end.x,g.end.y]))return;u.handles.points[m]=c.canvasToWorld(b),u.handles.points[f]=v}},this.cancel=n=>{if(this.isDrawing){this.isDrawing=!1,this._deactivateDraw(n),this._deactivateModify(n),kt(n);const{annotation:i,viewportIdsToRender:o,newAnnotation:a}=this.editData,{data:s}=i;return i.highlighted=!1,s.handles.activeHandleIndex=null,We(o),a&&bn(i),this.editData=null,i.annotationUID}},this._activateDraw=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragDrawCallback),n.addEventListener(U.MOUSE_MOVE,this._dragDrawCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragDrawCallback)},this._deactivateDraw=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragDrawCallback),n.removeEventListener(U.MOUSE_MOVE,this._dragDrawCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback),n.removeEventListener(U.TOUCH_END,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragDrawCallback)},this._activateModify=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragModifyCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragModifyCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback)},this._deactivateModify=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragModifyCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.TOUCH_END,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragModifyCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback)},this.renderAnnotation=(n,i)=>{let o=!0;const{viewport:a}=n,{element:s}=a;let c=Jt(this.getToolName(),s);if(!(c!=null&&c.length)||(c=this.filterInteractableAnnotationsForElement(s,c),!(c!=null&&c.length)))return o;const l=this.getTargetId(a),f=a.getRenderingEngine(),u={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:n.viewport.id};for(let d=0;d<c.length;d++){const h=c[d],{annotationUID:g,data:p}=h,{points:v,activeHandleIndex:y}=p.handles,m=v.map(ee=>a.worldToCanvas(ee));u.annotationUID=g;const{color:w,lineWidth:x,lineDash:C,shadow:S}=this.getAnnotationStyle({annotation:h,styleSpecifier:u});if(!p.cachedStats[l]||p.cachedStats[l].unit==null?(p.cachedStats[l]={length:null,width:null,unit:null},this._calculateCachedStats(h,f,n)):h.invalidated&&this._throttledCalculateCachedStats(h,f,n),!a.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),o;let T;if(!Vr(g))continue;!Yr(g)&&!this.editData&&y!==null&&(T=[m[y]]),T&&Kn(i,g,"0",T,{color:w});const _=`${g}-line-1`,E=`${g}-line-2`;an(i,g,"0",m[0],m[1],{color:w,lineDash:C,lineWidth:x,shadow:S},_),an(i,g,"1",m[2],m[3],{color:w,lineDash:C,lineWidth:x,shadow:S},E),o=!0;const I=this.getLinkedTextBoxStyle(u,h);if(!I.visibility){p.handles.textBox={hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}};continue}const P=this.configuration.getTextLines(p,l);if(!P||P.length===0)continue;let O;p.handles.textBox.hasMoved||(O=wa(m),p.handles.textBox.worldPosition=a.canvasToWorld(O));const L=a.worldToCanvas(p.handles.textBox.worldPosition),H=Ji(i,g,"1",P,L,m,{},I),{x:A,y:F,width:G,height:X}=H;p.handles.textBox.worldBoundingBox={topLeft:a.canvasToWorld([A,F]),topRight:a.canvasToWorld([A+G,F]),bottomLeft:a.canvasToWorld([A,F+X]),bottomRight:a.canvasToWorld([A+G,F+X])}}return o},this._movingLongAxisWouldPutItThroughShortAxis=(n,i)=>{const o=Wt();fs(o,i.end.x-i.start.x,i.end.y-i.start.y),Ul(o,o);const a={start:{x:i.start.x-o[0]*10,y:i.start.y-o[1]*10},end:{x:i.end.x+o[0]*10,y:i.end.y+o[1]*10}};return!l5([a.start.x,a.start.y],[a.end.x,a.end.y],[n.start.x,n.start.y],[n.end.x,n.end.y])},this._calculateCachedStats=(n,i,o)=>{const{data:a}=n,{element:s}=o.viewport,c=a.handles.points[0],l=a.handles.points[1],f=a.handles.points[2],u=a.handles.points[3],{cachedStats:d}=a,h=Object.keys(d);for(let p=0;p<h.length;p++){const v=h[p],y=this.getTargetImageData(v);if(!y)continue;const{imageData:m,dimensions:w}=y,x=H2(m,c),C=H2(m,l),S=H2(m,f),T=H2(m,u),_=[x,C],E=[S,T],{scale:b,unit:D}=ya(y,_),{scale:I,unit:P}=ya(y,E),O=this._calculateLength(c,l)/b,L=this._calculateLength(f,u)/I,B=O>L?O:L,H=O>L?L:O,A=O>L?D:P,F=O>L?P:D;this._isInsideVolume(x,C,S,T,w)?this.isHandleOutsideImage=!1:this.isHandleOutsideImage=!0,d[v]={length:B,width:H,unit:A,widthUnit:F}}const g=n.invalidated;return n.invalidated=!1,g&&Kt(n,s,Bt.StatsUpdated),d},this._isInsideVolume=(n,i,o,a,s)=>tr(n,s)&&tr(i,s)&&tr(o,s)&&tr(a,s),this._getSignedAngle=(n,i)=>Math.atan2(n[0]*i[1]-n[1]*i[0],n[0]*i[0]+n[1]*i[1]),this._throttledCalculateCachedStats=Lo(this._calculateCachedStats,100,{trailing:!0})}addNewAnnotation(e){const r=e.detail,{currentPoints:n,element:i}=r,o=n.world,a=Le(i),{viewport:s,renderingEngine:c}=a;this.isDrawing=!0;const l=s.getCamera(),{viewPlaneNormal:f,viewUp:u}=l,d=this.getReferencedImageId(s,o,f,u),h=s.getFrameOfReferenceUID(),g={highlighted:!0,invalidated:!0,metadata:{toolName:this.getToolName(),viewPlaneNormal:[...f],viewUp:[...u],FrameOfReferenceUID:h,referencedImageId:d,...s.getViewReference({points:[o]})},data:{handles:{points:[[...o],[...o],[...o],[...o]],textBox:{hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}},activeHandleIndex:null},label:"",cachedStats:{}}};qt(g,i);const p=wt(i,this.getToolName());return this.editData={annotation:g,viewportIdsToRender:p,handleIndex:1,movingTextBox:!1,newAnnotation:!0,hasMoved:!1},this._activateDraw(i),Dt(i),e.preventDefault(),We(p),g}_calculateLength(e,r){const n=e[0]-r[0],i=e[1]-r[1],o=e[2]-r[2];return Math.sqrt(n*n+i*i+o*o)}};A0.toolName="Bidirectional",A0.hydrate=(e,r,n)=>{const i=Mn(e);if(!i)return;const{FrameOfReferenceUID:o,referencedImageId:a,viewPlaneNormal:s,instance:c,viewport:l}=A0.hydrateBase(A0,i,r[0],n),[f,u]=r,[d,h]=f,[g,p]=u,v=[d,h,g,p],{toolInstance:y,...m}=n||{},w={annotationUID:(n==null?void 0:n.annotationUID)||gn(),data:{handles:{points:v,activeHandleIndex:null,textBox:{hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}}},cachedStats:{}},highlighted:!1,autoGenerated:!1,invalidated:!1,isLocked:!1,isVisible:!0,metadata:{toolName:c.getToolName(),viewPlaneNormal:s,FrameOfReferenceUID:o,referencedImageId:a,...m}};return qt(w,l.element),We([l.id]),w};let N1=A0;function _Ce(t,e){const{cachedStats:r,label:n}=t,{length:i,width:o,unit:a}=r[e],s=[];return n&&s.push(n),i===void 0||s.push(`L: ${Xt(i)} ${a||a}`,`W: ${Xt(o)} ${a}`),s}async function ECe(t,e){console.warn("Deprecation Alert: There is a new getSegmentLargestBidirectional function that handles volume, stack and individual segment cases properly. This function is deprecated and will be removed in a future version.");const{data:r}=e,n=Le(t),i=(r.getSegment||bCe)(n,r);if(!i)return;const o=n.viewport.getFrameOfReferenceUID(),a=Yw(),{segmentIndex:s,segmentationId:c}=i,l=rr.getAnnotations(this.toolName||N1.toolName,o);let f=!1;const u=l.filter(h=>{const g=h.data.segment;return g?(g.segmentationId===c&&g.segmentIndex===s&&(f=!0,h.data.segment=g),!0):!1});f||u.push({data:{segment:i}});let d;if(u.forEach(async h=>{const g=[],p=h.data.segment,{segmentIndex:v,segmentationId:y}=p;g[v]=p,rr.removeAnnotation(h.annotationUID);const m=await oW({...a.find(C=>C.segmentationId===y),segments:g});if(!m)return;const w=aW(m,n.viewport);w.annotationUID=h.annotationUID,w.data.segment=p;const x=rr.addAnnotation(w,o);if(p.segmentIndex===i.segmentIndex&&p.segmentationId===i.segmentationId){d=m;const{style:C}=i;C&&IE.setAnnotationStyles(x,C)}}),d){const{sliceIndex:h}=d,g=n.viewport.getImageIds();oa(t,{imageIndex:g.length-1-h}),n.viewport.render()}else console.warn("No bidirectional found");return d}function bCe(t,e){var a;const r=Yw();if(!r.length)return;const n=e.segmentationId||r[0].segmentationId,i=e.segmentIndex??va(n);if(!i)return;const o=(a=e.segmentData)==null?void 0:a.get(i);return{label:`Segment ${i}`,segmentIndex:i,segmentationId:n,...o}}function sW(t){const e=jr(t);if(e===void 0)return;ag(t).forEach(a=>{a.invalidateBrushCursor()});const n=e.getViewportsInfo();if(!Object.keys(n).map(a=>n[a]).length)return;const o=e.getViewportIds();We(o)}function I8(t,e,r={}){const n=_n(t),i=n.representationData,o=(r==null?void 0:r.representationType)??Object.keys(i)[0];if(!o)throw new Error(`Segmentation ${t} does not have any representations`);switch(o){case St.Labelmap:return DCe(n,e,r);case St.Contour:return ICe(n,e,r);default:return}}function DCe(t,e,{viewport:r}){const n=t.representationData.Labelmap;if(r instanceof fr){const{volumeId:h}=n,g=$e.getVolume(h);return g?g.imageData.getScalarValueFromWorld(e):void 0}const i=iu(r.id,t.segmentationId);if(i.length>1){console.warn("Segment selection for labelmaps with multiple imageIds in stack viewports is not supported yet.");return}const o=i[0];if(!$e.getImage(o))return;const s=Aw(r.id,t.segmentationId),c=s==null?void 0:s.actor.getMapper().getInputData(),l=Lr(c,e),f=c.getDimensions();return(c.voxelManager||fc.createScalarVolumeVoxelManager({dimensions:f,scalarData:c.getPointData().getScalars().getData()})).getAtIJKPoint(l)}function ICe(t,e,{viewport:r}){const n=t.representationData.Contour,i=Array.from(n.annotationUIDsMap.keys()),{viewPlaneNormal:o}=r.getCamera();for(const a of i){const s=n.annotationUIDsMap.get(a);if(s)for(const c of s){const l=kr(c);if(!l)continue;const{polyline:f}=l.data.contour;if(Vt(o,l.metadata.viewPlaneNormal)&&QE(e,f))return Number(a)}}}function cW(t,e,{viewport:r,searchRadius:n}){const o=_n(t).representationData.Labelmap;if(r instanceof fr){const{volumeId:p}=o,v=$e.getVolume(p);if(!v)return;const y=v.voxelManager,m=v.imageData,w=Lr(m,e),x=y.getAtIJK(w[0],w[1],w[2]),C=r.worldToCanvas(e);return MCe(C,x,r,m,n)?x:void 0}const a=_f(r.id,t);if(!$e.getImage(a))return;const c=Aw(r.id,t),l=c==null?void 0:c.actor.getMapper().getInputData(),f=Lr(l,e),u=l.getDimensions(),d=l.voxelManager||fc.createScalarVolumeVoxelManager({dimensions:u,scalarData:l.getPointData().getScalars().getData()}),h=d.getAtIJKPoint(f);return OCe(f,u,d,h)?h:void 0}function lW(t,e,r=1){const n=Array.from({length:2*r+1},(i,o)=>o-r);for(const i of n)for(const o of n)for(const a of n){if(i===0&&o===0&&a===0)continue;const s=t(i,o,a);if(s!==void 0&&e!==s)return!0}return!1}function OCe(t,e,r,n,i){return lW((a,s,c)=>{const l=[t[0]+a,t[1]+s,t[2]+c];return r.getAtIJK(l[0],l[1],l[2])},n,i)}function MCe(t,e,r,n,i){return lW((a,s)=>{const c=[t[0]+a,t[1]+s],l=r.canvasToWorld(c),f=n.get("voxelManager").voxelManager,u=Lr(n,l);return f.getAtIJK(u[0],u[1],u[2])},e,i)}function uW(t){const e=_n(t),{annotationUIDsMap:r}=e.representationData.Contour;for(const[n,i]of r.entries())if(Array.from(i).find(a=>kr(a).highlighted))return n}const PCe=`
|
||
const MAX_STRENGTH = 65535f;
|
||
|
||
// Workgroup size - X*Y*Z must be multiple of 32 for better performance
|
||
override workGroupSizeX = 1u;
|
||
override workGroupSizeY = 1u;
|
||
override workGroupSizeZ = 1u;
|
||
|
||
// Compare the current voxel to neighbors using a 9x9x9 window
|
||
override windowSize = 9i;
|
||
|
||
struct Params {
|
||
size: vec3u,
|
||
iteration: u32,
|
||
}
|
||
|
||
// New structure to track bounds of modified voxels
|
||
struct Bounds {
|
||
minX: atomic<i32>,
|
||
minY: atomic<i32>,
|
||
minZ: atomic<i32>,
|
||
maxX: atomic<i32>,
|
||
maxY: atomic<i32>,
|
||
maxZ: atomic<i32>,
|
||
}
|
||
|
||
@group(0) @binding(0) var<uniform> params: Params;
|
||
@group(0) @binding(1) var<storage> volumePixelData: array<f32>;
|
||
@group(0) @binding(2) var<storage, read_write> labelmap: array<u32>;
|
||
@group(0) @binding(3) var<storage, read_write> strengthData: array<f32>;
|
||
@group(0) @binding(4) var<storage> prevLabelmap: array<u32>;
|
||
@group(0) @binding(5) var<storage> prevStrengthData: array<f32>;
|
||
@group(0) @binding(6) var<storage, read_write> updatedVoxelsCounter: array<atomic<u32>>;
|
||
@group(0) @binding(7) var<storage, read_write> modifiedBounds: Bounds;
|
||
|
||
fn getPixelIndex(ijkPos: vec3u) -> u32 {
|
||
let numPixelsPerSlice = params.size.x * params.size.y;
|
||
return ijkPos.x + ijkPos.y * params.size.x + ijkPos.z * numPixelsPerSlice;
|
||
}
|
||
|
||
fn updateBounds(position: vec3i) {
|
||
// Atomically update min bounds (use min operation)
|
||
let oldMinX = atomicMin(&modifiedBounds.minX, position.x);
|
||
let oldMinY = atomicMin(&modifiedBounds.minY, position.y);
|
||
let oldMinZ = atomicMin(&modifiedBounds.minZ, position.z);
|
||
|
||
// Atomically update max bounds (use max operation)
|
||
let oldMaxX = atomicMax(&modifiedBounds.maxX, position.x);
|
||
let oldMaxY = atomicMax(&modifiedBounds.maxY, position.y);
|
||
let oldMaxZ = atomicMax(&modifiedBounds.maxZ, position.z);
|
||
}
|
||
|
||
@compute @workgroup_size(workGroupSizeX, workGroupSizeY, workGroupSizeZ)
|
||
fn main(
|
||
@builtin(global_invocation_id) globalId: vec3u,
|
||
) {
|
||
// Make sure it will not get out of bounds for volume with sizes that
|
||
// are not multiple of workGroupSize
|
||
if (
|
||
globalId.x >= params.size.x ||
|
||
globalId.y >= params.size.y ||
|
||
globalId.z >= params.size.z
|
||
) {
|
||
return;
|
||
}
|
||
|
||
// Initialize bounds for the first iteration
|
||
if (params.iteration == 0 && globalId.x == 0 && globalId.y == 0 && globalId.z == 0) {
|
||
// Initialize to opposite extremes to ensure any update will improve the bounds
|
||
atomicStore(&modifiedBounds.minX, i32(params.size.x));
|
||
atomicStore(&modifiedBounds.minY, i32(params.size.y));
|
||
atomicStore(&modifiedBounds.minZ, i32(params.size.z));
|
||
atomicStore(&modifiedBounds.maxX, -1);
|
||
atomicStore(&modifiedBounds.maxY, -1);
|
||
atomicStore(&modifiedBounds.maxZ, -1);
|
||
}
|
||
|
||
let currentCoord = vec3i(globalId);
|
||
let currentPixelIndex = getPixelIndex(globalId);
|
||
|
||
let numPixels = arrayLength(&volumePixelData);
|
||
let currentPixelValue = volumePixelData[currentPixelIndex];
|
||
|
||
if (params.iteration == 0) {
|
||
// All non-zero initial labels are given maximum strength
|
||
strengthData[currentPixelIndex] = select(MAX_STRENGTH, 0., labelmap[currentPixelIndex] == 0);
|
||
|
||
// Update bounds for non-zero initial labels
|
||
if (labelmap[currentPixelIndex] != 0) {
|
||
updateBounds(currentCoord);
|
||
}
|
||
return;
|
||
}
|
||
|
||
// It should at least copy the values from previous state
|
||
var newLabel = prevLabelmap[currentPixelIndex];
|
||
var newStrength = prevStrengthData[currentPixelIndex];
|
||
|
||
let window = i32(ceil(f32(windowSize - 1) * .5));
|
||
let minWindow = -1i * window;
|
||
let maxWindow = 1i * window;
|
||
|
||
for (var k = minWindow; k <= maxWindow; k++) {
|
||
for (var j = minWindow; j <= maxWindow; j++) {
|
||
for (var i = minWindow; i <= maxWindow; i++) {
|
||
// Skip current voxel
|
||
if (i == 0 && j == 0 && k == 0) {
|
||
continue;
|
||
}
|
||
|
||
let neighborCoord = currentCoord + vec3i(i, j, k);
|
||
|
||
// Boundary conditions. Do not grow outside of the volume
|
||
if (
|
||
neighborCoord.x < 0i || neighborCoord.x >= i32(params.size.x) ||
|
||
neighborCoord.y < 0i || neighborCoord.y >= i32(params.size.y) ||
|
||
neighborCoord.z < 0i || neighborCoord.z >= i32(params.size.z)
|
||
) {
|
||
continue;
|
||
}
|
||
|
||
let neighborIndex = getPixelIndex(vec3u(neighborCoord));
|
||
let neighborPixelValue = volumePixelData[neighborIndex];
|
||
let prevNeighborStrength = prevStrengthData[neighborIndex];
|
||
let strengthCost = abs(neighborPixelValue - currentPixelValue);
|
||
let takeoverStrength = prevNeighborStrength - strengthCost;
|
||
|
||
if (takeoverStrength > newStrength) {
|
||
newLabel = prevLabelmap[neighborIndex];
|
||
newStrength = takeoverStrength;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
if (labelmap[currentPixelIndex] != newLabel) {
|
||
atomicAdd(&updatedVoxelsCounter[params.iteration], 1u);
|
||
|
||
// Update bounds for modified voxels
|
||
updateBounds(currentCoord);
|
||
}
|
||
|
||
labelmap[currentPixelIndex] = newLabel;
|
||
strengthData[currentPixelIndex] = newStrength;
|
||
}
|
||
`,RCe=1024*1024*1024,c7=1.99*RCe,AC={windowSize:3,maxProcessingTime:3e4,inspection:{numCyclesInterval:5,numCyclesBelowThreshold:3,threshold:1e-4}};async function tx(t,e,r=AC){var Re;const n=[8,8,4],{windowSize:i,maxProcessingTime:o}=Object.assign({},AC,r),a=Object.assign({},AC.inspection,r.inspection),s=$e.getVolume(t),c=$e.getVolume(e),[l,f,u]=s.dimensions;if(c.dimensions[0]!==l||c.dimensions[1]!==f||c.dimensions[2]!==u)throw new Error("Volume and labelmap must have the same size");let d=Math.floor(Math.sqrt(f**2+l**2+u**2)/2);d=Math.min(d,500);const h=c.voxelManager.getCompleteScalarDataArray();let g=s.voxelManager.getCompleteScalarDataArray();g instanceof Float32Array||(g=new Float32Array(g));const p={maxStorageBufferBindingSize:c7,maxBufferSize:c7},y=await(await((Re=navigator.gpu)==null?void 0:Re.requestAdapter())).requestDevice({requiredLimits:p}),m=g.byteLength,w=d*Uint32Array.BYTES_PER_ELEMENT,x=6*Int32Array.BYTES_PER_ELEMENT,C=y.createShaderModule({code:PCe}),S=3,T=new Uint32Array([l,f,u,0]),_=y.createBuffer({size:T.byteLength,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),E=y.createBuffer({size:m,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_DST});y.queue.writeBuffer(E,0,g);const b=[0,1].map(()=>y.createBuffer({size:m,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST}));y.queue.writeBuffer(b[0],0,new Uint32Array(h));const D=[0,1].map(()=>y.createBuffer({size:m,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST})),I=y.createBuffer({size:w,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST}),P=y.createBuffer({size:x,usage:GPUBufferUsage.STORAGE|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST}),O=new Int32Array([l,f,u,-1,-1,-1]);y.queue.writeBuffer(P,0,O);const L=y.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.COMPUTE,buffer:{type:"uniform"}},{binding:1,visibility:GPUShaderStage.COMPUTE,buffer:{type:"read-only-storage"}},{binding:2,visibility:GPUShaderStage.COMPUTE,buffer:{type:"storage"}},{binding:3,visibility:GPUShaderStage.COMPUTE,buffer:{type:"storage"}},{binding:4,visibility:GPUShaderStage.COMPUTE,buffer:{type:"read-only-storage"}},{binding:5,visibility:GPUShaderStage.COMPUTE,buffer:{type:"read-only-storage"}},{binding:6,visibility:GPUShaderStage.COMPUTE,buffer:{type:"storage"}},{binding:7,visibility:GPUShaderStage.COMPUTE,buffer:{type:"storage"}}]}),B=[0,1].map(Fe=>{const je=b[Fe],Xe=D[Fe],se=b[(Fe+1)%2],ue=D[(Fe+1)%2];return y.createBindGroup({layout:L,entries:[{binding:0,resource:{buffer:_}},{binding:1,resource:{buffer:E}},{binding:2,resource:{buffer:je}},{binding:3,resource:{buffer:Xe}},{binding:4,resource:{buffer:se}},{binding:5,resource:{buffer:ue}},{binding:6,resource:{buffer:I}},{binding:7,resource:{buffer:P}}]})}),H=y.createComputePipeline({layout:y.createPipelineLayout({bindGroupLayouts:[L]}),compute:{module:C,entryPoint:"main",constants:{workGroupSizeX:n[0],workGroupSizeY:n[1],workGroupSizeZ:n[2],windowSize:i}}}),A=[Math.ceil(l/n[0]),Math.ceil(f/n[1]),Math.ceil(u/n[2])],F=y.createBuffer({size:w,usage:GPUBufferUsage.MAP_READ|GPUBufferUsage.COPY_DST}),G=o?performance.now()+o:0;let X=a.numCyclesInterval,ee=0;for(let Fe=0;Fe<d;Fe++){T[S]=Fe,y.queue.writeBuffer(_,0,T);const je=y.createCommandEncoder(),Xe=je.beginComputePass();if(Xe.setPipeline(H),Xe.setBindGroup(0,B[Fe%2]),Xe.dispatchWorkgroups(A[0],A[1],A[2]),Xe.end(),je.copyBufferToBuffer(I,Fe*Uint32Array.BYTES_PER_ELEMENT,F,Fe*Uint32Array.BYTES_PER_ELEMENT,Uint32Array.BYTES_PER_ELEMENT),y.queue.submit([je.finish()]),Fe>0&&!(Fe%X)){await F.mapAsync(GPUMapMode.READ,0,w);const ue=F.getMappedRange(0,w),pe=new Uint32Array(ue.slice(0))[Fe]/g.length;if(F.unmap(),Fe>=1&&pe<a.threshold){if(X=1,ee++,ee===a.numCyclesBelowThreshold)break}else X=a.numCyclesInterval}if(G&&performance.now()>G){console.warn(`Exceeded processing time limit (${o})ms`);break}}const ce=y.createCommandEncoder(),Se=(d+1)%2,we=y.createBuffer({size:m,usage:GPUBufferUsage.MAP_READ|GPUBufferUsage.COPY_DST}),_e=y.createBuffer({size:x,usage:GPUBufferUsage.MAP_READ|GPUBufferUsage.COPY_DST});ce.copyBufferToBuffer(b[Se],0,we,0,m),ce.copyBufferToBuffer(P,0,_e,0,x),y.queue.submit([ce.finish()]),await we.mapAsync(GPUMapMode.READ,0,m);const Ve=we.getMappedRange(0,m),Ge=new Uint32Array(Ve);h.set(Ge),we.unmap(),await _e.mapAsync(GPUMapMode.READ,0,x);const Ne=_e.getMappedRange(0,x),j=new Int32Array(Ne.slice(0));_e.unmap();const M=j[0],q=j[1],K=j[2],J=j[3],re=j[4],ie=j[5];c.voxelManager.setCompleteScalarDataArray(h),c.voxelManager.clearBounds(),c.voxelManager.setBounds([[M,J],[q,re],[K,ie]])}const{transformWorldToIndex:k1}=pn,LCe=254,ACe=255,NCe=.1,kCe=.8;function VCe(t,e){const{topLeftWorld:r,bottomRightWorld:n}=e,i=k1(t.imageData,r),o=k1(t.imageData,n);return{...e,topLeftIJK:i,bottomRightIJK:o}}function FCe(t,e){const r=t.imageData.getDirection(),n=Tt(r[3],r[4],r[5]),{center:i,radius:o}=e,a=t.imageData,s=dn(Ke(),i,n,-o),c=dn(Ke(),i,n,o),l=yG([c,s],a);return VCe(t,l)}function UCe(t,e,r){const n=t.imageData,i=r.getCamera(),{ijkVecRowDir:o,ijkVecColDir:a}=Sw(n,i);if([o,a].some(f=>!Vt(Math.abs(f[0]),1)&&!Vt(Math.abs(f[1]),1)&&!Vt(Math.abs(f[2]),1))){console.warn("Oblique view is not supported!");return}const{boundsIJK:c}=FCe(t,e),l={minX:c[0][0],maxX:c[0][1]+1,minY:c[1][0],maxY:c[1][1]+1,minZ:c[2][0],maxZ:c[2][1]+1};return yE(t.volumeId,l,{targetBuffer:{type:"Float32Array"}})}function BCe(t,e,r,n){const i=t.voxelManager.getCompleteScalarDataArray(),o=r.center,[a,s,c]=t.dimensions,l=a*s,f=k1(t.imageData,o),u=i[f[2]*l+f[1]*a+f[0]],d=n.positiveSeedValue??LCe,h=n.positiveSeedVariance??NCe,g=Math.abs(u*h),p=u-g,v=u+g,y=[[-1,0,0],[1,0,0],[0,-1,0],[0,1,0],[0,0,-1],[0,0,1]],m=f[2]*l+f[1]*a+f[0];e.voxelManager.setAtIndex(m,d);const w=[f];for(;w.length;){const x=w.shift(),[C,S,T]=x;for(let _=0,E=y.length;_<E;_++){const b=y[_],D=C+b[0],I=S+b[1],P=T+b[2];if(D<0||D>=a||I<0||I>=s||P<0||P>=c)continue;const O=P*l+I*a+D,L=i[O];e.voxelManager.getAtIndex(O)===d||L<p||L>v||(e.voxelManager.setAtIndex(O,d),w.push([D,I,P]))}}}function GCe(t,e,r,n,i){const o=t.voxelManager.getCompleteScalarDataArray(),[a,s,c]=e.dimensions,l=a*s,{worldVecRowDir:f,worldVecSliceDir:u}=Sw(e.imageData,n.getCamera()),d=k1(t.imageData,r.center),h=o[d[2]*a*s+d[1]*a+d[0]],g=i.negativeSeedVariance??kCe,p=(i==null?void 0:i.negativeSeedValue)??ACe,v=Math.abs(h*g),y=h-v,m=h+v,w=360,x=2*Math.PI/w,C=nw(sf(),u,x),S=jR(f);for(let T=0;T<w;T++){const _=dn(Ke(),r.center,S,r.radius),E=k1(e.imageData,_),[b,D,I]=E;if(WY(S,S,C),b<0||b>=a||D<0||D>=s||I<0||I>=c)continue;const P=b+D*a+I*l,O=o[P];(O<y||O>m)&&e.voxelManager.setAtIndex(P,p)}}async function WCe(t,e,r,n){const i=await fm(t.volumeId);return BCe(t,i,e,n),GCe(t,i,e,r,n),i}async function fW(t,e,r,n){const i=$e.getVolume(t),o=UCe(i,e,r),a=await WCe(o,e,r,n);return await tx(o.volumeId,a.volumeId),a}const zCe=254,$Ce=255,jCe=[-1/0,-995],HCe=[0,1900];function KCe(t,e,r){const{negativeSeedValue:n=$Ce,negativePixelRange:i=jCe}=r,o=t.voxelManager.getCompleteScalarDataArray(),[a,s,c]=e.dimensions,l=Math.floor(c/2),f=new Array(a*s).fill(!1),u=l*a*s,d=(g,p)=>{const v=[[g,p]];for(;v.length;){const[y,m]=v.shift(),w=m*a+y;if(y<0||y>=a||m<0||m>=s||f[w])continue;f[w]=!0;const x=u+w,C=o[x];C<i[0]||C>i[1]||(e.voxelManager.setAtIndex(x,n),v.push([y-1,m]),v.push([y+1,m]),v.push([y,m-1]),v.push([y,m+1]))}},h=(g,p,v,y)=>{for(let m=g;m!==p;m+=v){const w=y*a+m,x=u+w,C=o[x];if(C<i[0]||C>i[1])break;f[w]||d(m,y)}};for(let g=0;g<s;g++)h(0,a-1,1,g),h(a-1,0,-1,g)}function qCe(t,e,r){const{positiveSeedValue:n=zCe,positivePixelRange:i=HCe}=r,o=t.voxelManager.getCompleteScalarDataArray();e.voxelManager.getCompleteScalarDataArray();const[a,s,c]=e.dimensions,l=Math.floor(c/2),f=Math.max(l-3,0),u=Math.max(f+5,c),d=a*s;for(let h=f;h<u;h++){const g=h*d;for(let p=0;p<s;p++){const v=p*a;for(let y=0;y<a;y++){const m=g+v+y,w=o[m];w>=i[0]&&w<=i[1]&&e.voxelManager.setAtIndex(m,n)}}}}async function XCe(t,e){const r=fm(t.volumeId);return qCe(t,r,e),KCe(t,r,e),r}async function dW(t,e,r){const{boundingBox:n}=e,{ijkTopLeft:i,ijkBottomRight:o}=n,a={minX:i[0],maxX:o[0],minY:i[1],maxY:o[1],minZ:i[2],maxZ:o[2]},s=yE(t,a,{targetBuffer:{type:"Float32Array"}}),c=await XCe(s,r);return await tx(s.volumeId,c.volumeId),c}const YCe=254,JCe=255,ZCe=1,hW=1.8,QCe=3.2,nT=30,e3e=70,t3e=50,{transformWorldToIndex:n3e}=pn,np=1e5;function gW(t,e,r){const{dimensions:n,imageData:i}=t,[o,a,s]=n,c=t.voxelManager,l=c.getCompleteScalarDataArray(),f=o*a,u=(r==null?void 0:r.initialNeighborhoodRadius)??ZCe,d=(r==null?void 0:r.positiveStdDevMultiplier)??hW,h=(r==null?void 0:r.negativeStdDevMultiplier)??QCe,g=(r==null?void 0:r.negativeSeedMargin)??nT,p=(r==null?void 0:r.negativeSeedsTargetPatches)??e3e,v=n3e(i,e).map(Math.round),y=c.toIndex(v);if(v[0]<0||v[0]>=o||v[1]<0||v[1]>=a||v[2]<0||v[2]>=s)return console.warn("Click position is outside volume bounds."),null;const m=RV(l,n,v,u);m.count===0&&(m.mean=l[y],m.stdDev=0);const w=m.mean-d*m.stdDev,x=m.mean+d*m.stdDev,C=[[-1,0,0],[1,0,0],[0,-1,0],[0,1,0],[0,0,-1],[0,0,1]];let S=1/0,T=1/0,_=1/0,E=-1/0,b=-1/0,D=-1/0;const I=new Set,P=[],O=l[y];if(O>=w&&O<=x)I.add(y),P.push(v),S=E=v[0],T=b=v[1],_=D=v[2];else return console.warn("Clicked voxel intensity is outside the calculated positive range. No positive seeds generated."),{positiveSeedIndices:new Set,negativeSeedIndices:new Set};let L=0;for(;L<P.length&&I.size<np;){const[K,J,re]=P[L++];S=Math.min(K,S),T=Math.min(J,T),_=Math.min(re,_),E=Math.max(K,E),b=Math.max(J,b),D=Math.max(re,D);for(let ie=0;ie<C.length;ie++){const[Re,Fe,je]=C[ie],Xe=K+Re,se=J+Fe,ue=re+je;if(Xe<0||Xe>=o||se<0||se>=a||ue<0||ue>=s)continue;const Pe=ue*f+se*o+Xe;if(I.has(Pe))continue;const pe=l[Pe];pe>=w&&pe<=x&&(I.add(Pe),I.size<np&&P.push([Xe,se,ue]))}}if(I.size>=np&&console.debug(`Reached maximum number of positive seeds (${np}). Stopping BFS.`),I.size===0)return console.warn("No positive seeds found after BFS."),{positiveSeedIndices:new Set,negativeSeedIndices:new Set};let B=0,H=0;I.forEach(K=>{const J=l[K];B+=J,H+=J*J});const A=I.size,F=B/A,G=H/A-F*F,X=Math.sqrt(Math.max(0,G)),ee=h*X,ce=Math.max(0,S-g),Se=Math.max(0,T-g),we=Math.max(0,_-g),_e=Math.min(o-1,E+g),Ve=Math.min(a-1,b+g),Ge=Math.min(s-1,D+g),Ne=new Set;let j=0,M=0;const q=p*t3e;for(;M<p&&j<q;){j++;const K=Math.floor(Math.random()*(_e-ce+1)+ce),J=Math.floor(Math.random()*(Ve-Se+1)+Se),re=Math.floor(Math.random()*(Ge-we+1)+we),ie=re*f+J*o+K;if(I.has(ie)||Ne.has(ie))continue;const Re=l[ie];if(Math.abs(Re-F)>ee){let Fe=!1;for(let je=-1;je<=1;je++){const Xe=J+je;if(!(Xe<0||Xe>=a))for(let se=-1;se<=1;se++){const ue=K+se;if(ue<0||ue>=o)continue;const Pe=re*f+Xe*o+ue;I.has(Pe)||Ne.has(Pe)||(Ne.add(Pe),Fe=!0)}}Fe&&M++}}return Ne.size===0&&console.warn("Could not find any negative seeds. GrowCut might fail or produce poor results."),console.debug("positiveSeedIndices",I.size),console.debug("negativeSeedIndices",Ne.size),{positiveSeedIndices:I,negativeSeedIndices:Ne}}async function pW({referencedVolumeId:t,worldPosition:e,options:r}){const n=$e.getVolume(t),i=fm(t);i.voxelManager.forEach(({index:f,value:u})=>{u!==0&&i.voxelManager.setAtIndex(f,0)});const o=r.seeds??gW(n,e,r),a=(r==null?void 0:r.positiveSeedValue)??YCe,s=(r==null?void 0:r.negativeSeedValue)??JCe;if(!o)return null;const{positiveSeedIndices:c,negativeSeedIndices:l}=o;return c.size<10||c.size>np||l.size<10?(console.warn("Not enough seeds found. GrowCut might fail or produce poor results."),i):(c.forEach(f=>{i.voxelManager.setAtIndex(f,a)}),l.forEach(f=>{i.voxelManager.setAtIndex(f,s)}),await tx(t,i.volumeId,r),i)}const r3e=Object.freeze(Object.defineProperty({__proto__:null,run:tx,runGrowCutForBoundingBox:dW,runGrowCutForSphere:fW,runOneClickGrowCut:pW},Symbol.toStringTag,{value:"Module"}));function i3e(t,e){const{segmentationId:r,config:n}=e,i={colorLUTIndex:o3e(n),...n};$n.addSegmentationRepresentation(t,r,e.type,i),e.type===St.Contour&&We([t]),Ka(r)}function o3e(t){const{colorLUTOrIndex:e}=t||{};return e===void 0?Ep(JSON.parse(JSON.stringify(m5))):typeof e=="number"?e:Array.isArray(e)&&e.every(n=>Array.isArray(n)&&n.length===4)?Ep(e):Ep(JSON.parse(JSON.stringify(m5)))}function sg(t,e){e.map(r=>i3e(t,r))}function O8(t,e){return sg(t,e.map(r=>({...r,type:St.Contour})))}function a3e(t){const e={};for(const[r,n]of Object.entries(t))e[r]=O8(r,n);return e}function mW(t,e){return sg(t,e.map(r=>({...r,type:St.Labelmap})))}function s3e(t){for(const[e,r]of Object.entries(t))mW(e,r.map(n=>({...n,type:St.Labelmap})))}function vW(t,e){return sg(t,e.map(r=>({...r,type:St.Surface})))}function c3e(t){const e={};for(const[r,n]of Object.entries(t))e[r]=vW(r,n);return e}async function l3e({segmentationId:t,viewportId:e,imageIds:r,options:n}){const i=_n(t);if(n!=null&&n.removeOriginal){const o=i.representationData.Labelmap;$e.getVolume(o.volumeId)&&$e.removeVolumeLoadObject(o.volumeId),i.representationData.Labelmap={imageIds:r}}else i.representationData.Labelmap={...i.representationData.Labelmap,imageIds:r};await sg(e,[{segmentationId:t,type:St.Labelmap}]),Ze.addEventListenerOnce(U.SEGMENTATION_RENDERED,()=>lo(t))}async function u3e({volumeId:t}){return{imageIds:$e.getVolume(t).imageIds}}function f3e({segmentationId:t,options:e}){const r=_n(t);if(!r)return;const{volumeId:n}=r.representationData.Labelmap,i=$e.getVolume(n);return l3e({segmentationId:t,viewportId:e.viewportId,imageIds:i.imageIds,options:e})}async function yW(t){return hU(t)}async function d3e({segmentationId:t,segmentIndices:e,mode:r="individual"}){Xw(),cl(Wa.COMPUTE_LARGEST_BIDIRECTIONAL,0);const n=NG(t,e);if(!n)return;const{operationData:i,segImageIds:o,reconstructableVolume:a,indices:s}=n,c=a?await h3e({operationData:i,indices:s,mode:r}):await g3e({segImageIds:o,indices:s,mode:r});return cl(Wa.COMPUTE_LARGEST_BIDIRECTIONAL,100),c}async function h3e({operationData:t,indices:e,mode:r}){const n=kG(t),{segmentationVoxelManager:i,segmentationImageData:o}=n,s={scalarData:i.getCompleteScalarDataArray(),dimensions:o.getDimensions(),spacing:o.getSpacing(),origin:o.getOrigin(),direction:o.getDirection()};return await fl().executeTask("compute","getSegmentLargestBidirectionalInternal",{segmentationInfo:s,indices:e,mode:r})}async function g3e({segImageIds:t,indices:e,mode:r}){const{segmentationInfo:n}=VG(t);return await fl().executeTask("compute","getSegmentLargestBidirectionalInternal",{segmentationInfo:n,indices:e,mode:r,isStack:!0})}function p3e(t){const e=_n(t);if(!e)return null;let r;const n=e.representationData.Labelmap;if("imageIds"in n){const{imageIds:i}=n,o=$e.getImage(i[0]),a=$e.getVolumeContainingImageId(o.referencedImageId);if(a!=null&&a.volume)return a.volume;r=i.map(s=>$e.getImage(s).referencedImageId)}else if("volumeId"in n){const{volumeId:i,referencedVolumeId:o}=n;if(o){const s=$e.getVolume(o);if(s)return s}const a=$e.getVolume(i);a&&(r=a.imageIds.map(s=>$e.getImage(s).referencedImageId))}return Jw(r)}async function m3e({segmentationIds:t,segmentIndex:e}){Xw(),cl(Wa.COMPUTE_STATISTICS,0);const r=_n(t[0]),{imageIds:n}=r.representationData.Labelmap;if(!Sf(n))throw new Error("Invalid volume - TMTV cannot be calculated");return await v3e({segmentationIds:t,segmentIndex:e})}async function v3e({segmentationIds:t,segmentIndex:e}){const r=t.map(p=>og(p)),n=WG(r,e);if(!n)throw new Error("Invalid volume - TMTV cannot be calculated");const{imageData:i,dimensions:o,direction:a,origin:s,voxelManager:c}=n,l=i.getSpacing(),u={scalarData:c.getCompleteScalarDataArray(),dimensions:o,spacing:l,origin:s,direction:a},d=p3e(t[0]),h={dimensions:d.dimensions,spacing:d.spacing,origin:d.origin,direction:d.direction,scalarData:d.voxelManager.getCompleteScalarDataArray()};if(h.scalarData.length===0||u.scalarData.length===0)return{[e]:{name:"TMTV",value:0}};const g=await fl().executeTask("compute","computeMetabolicStats",{segmentationInfo:u,imageInfo:h});return cl(Wa.COMPUTE_STATISTICS,100),g}const y3e=Object.freeze(Object.defineProperty({__proto__:null,IslandRemoval:Pd,LabelmapMemo:rCe,SegmentStatsCalculator:tT,VolumetricCalculator:hd,computeMetabolicStats:m3e,computeStackLabelmapFromVolume:u3e,computeVolumeLabelmapFromStack:yW,contourAndFindLargestBidirectional:oW,createBidirectionalToolData:aW,createLabelmapVolumeForViewport:Sxe,createMergedLabelmapForIndex:WG,floodFill:b8,getBrushSizeForToolGroup:gCe,getBrushThresholdForToolGroup:mCe,getBrushToolInstances:ag,getHoveredContourSegmentationAnnotation:uW,getOrCreateImageVolume:Jw,getOrCreateSegmentationVolume:og,getReferenceVolumeForSegmentationVolume:RG,getSegmentIndexAtLabelmapBorder:cW,getSegmentIndexAtWorldPoint:I8,getSegmentLargestBidirectional:d3e,getStatistics:HG,getUniqueSegmentIndices:aB,growCut:r3e,invalidateBrushCursor:sW,rectangleROIThresholdVolumeByRange:xxe,segmentContourAction:ECe,setBrushSizeForToolGroup:hCe,setBrushThresholdForToolGroup:pCe,thresholdSegmentationByRange:vCe,thresholdVolumeByRange:BG,triggerSegmentationRender:ng,triggerSegmentationRenderBySegmentationId:Kw,validateLabelmap:sxe},Symbol.toStringTag,{value:"Module"}));function w3e(t){let e="";const r=t[0]<0?"R":"L",n=t[1]<0?"A":"P",i=t[2]<0?"F":"H",o=[Math.abs(t[0]),Math.abs(t[1]),Math.abs(t[2])],a=1e-4;for(let s=0;s<3;s++)if(o[0]>a&&o[0]>o[1]&&o[0]>o[2])e+=r,o[0]=0;else if(o[1]>a&&o[1]>o[0]&&o[1]>o[2])e+=n,o[1]=0;else if(o[2]>a&&o[2]>o[0]&&o[2]>o[1])e+=i,o[2]=0;else if(o[0]>a&&o[1]>a&&o[0]===o[1])e+=r+n,o[0]=0,o[1]=0;else if(o[0]>a&&o[2]>a&&o[0]===o[2])e+=r+i,o[0]=0,o[2]=0;else if(o[1]>a&&o[2]>a&&o[1]===o[2])e+=n+i,o[1]=0,o[2]=0;else break;return e}function x3e(t){let e=t.replace("H","f");return e=e.replace("F","h"),e=e.replace("R","l"),e=e.replace("L","r"),e=e.replace("A","p"),e=e.replace("P","a"),e=e.toUpperCase(),e}const C3e=Object.freeze(Object.defineProperty({__proto__:null,getOrientationStringLPS:w3e,invertOrientationStringLPS:x3e},Symbol.toStringTag,{value:"Module"}));var sh;(function(t){t.CLIP_STOPPED="CORNERSTONE_CINE_TOOL_STOPPED",t.CLIP_STARTED="CORNERSTONE_CINE_TOOL_STARTED"})(sh||(sh={}));const M8={};function wW(t,e){const r=Le(t),{viewportId:n}=r;M8[n]=e}function P8(t){const e=Le(t),{viewportId:r}=e;return M8[r]}function S3e(t){return M8[t]}const{ViewportStatus:xW}=Ha,{triggerEvent:NC}=pn,CW=!0,rT=new Map;function T3e(t,e){let r,n;if(t===void 0)throw new Error("playClip: element must not be undefined");const i=Le(t);if(!i)throw new Error("playClip: element must be a valid Cornerstone enabled element");e||(e={}),e.dynamicCineEnabled=e.dynamicCineEnabled??!0;const{viewport:o}=i,a=O3e(o,e);let s=P8(t);const c=e.dynamicCineEnabled;if(c&&TW(t),s?iT(t,{stopDynamicCine:!c,viewportId:o.id}):(s={intervalId:void 0,framesPerSecond:30,lastFrameTimeStamp:void 0,ignoreFrameTimeVector:!1,usingFrameTimeVector:!1,frameTimeVector:e.frameTimeVector??void 0,speed:e.frameTimeVectorSpeedMultiplier??1,reverse:e.reverse??!1,loop:e.loop??!0,bounce:e.bounce??!1},wW(t,s)),s.dynamicCineEnabled=e.dynamicCineEnabled,(e.framesPerSecond<0||e.framesPerSecond>0)&&(s.framesPerSecond=Number(e.framesPerSecond),s.reverse=s.framesPerSecond<0,s.ignoreFrameTimeVector=!0),s.ignoreFrameTimeVector!==!0&&s.frameTimeVector&&s.frameTimeVector.length===a.numScrollSteps&&a.frameTimeVectorEnabled){const{timeouts:u,isTimeVarying:d}=_3e(s.frameTimeVector,s.speed);r=u,n=d}e.bounce!==void 0&&(s.bounce=e.bounce);const l=()=>{const{numScrollSteps:u,currentStepIndex:d}=a;let h=d+(s.reverse?-1:1);if(h<0||h>=u)if(s.bounce)s.reverse=!s.reverse,h=d+(s.reverse?-1:1),h=Math.max(0,Math.min(u-1,h));else if(s.loop)h=s.reverse?u-1:0;else{iT(t,{stopDynamicCine:!c,viewportId:o.id}),NC(t,sh.CLIP_STOPPED,{element:t});return}const p=h-d;if(p)try{a.scroll(p)}catch(v){console.warn("Play clip not scrolling",v),_W(s),NC(t,sh.CLIP_STOPPED,{element:t})}};if(c){const u=R8(o);u&&rT.set(u.volumeId,t)}a.play?s.framesPerSecond=a.play(e.framesPerSecond):r&&r.length>0&&n?(s.usingFrameTimeVector=!0,s.intervalId=window.setTimeout(function u(){s.intervalId=window.setTimeout(u,r[a.currentStepIndex]),l()},0)):(s.usingFrameTimeVector=!1,s.intervalId=window.setInterval(l,1e3/Math.abs(s.framesPerSecond)));const f={element:t};NC(t,sh.CLIP_STARTED,f)}function SW(t,e={}){iT(t,{stopDynamicCine:!0,...e})}function iT(t,e={stopDynamicCine:!0,viewportId:void 0}){const{stopDynamicCine:r,viewportId:n}=e,i=Le(t);let o;const a=i==null?void 0:i.viewport;if(i){const{viewport:s}=i;o=P8(s.element)}else if(n)o=S3e(n);else return;o&&_W(o),a instanceof _h?a.pause():r&&a instanceof fr&&TW(t)}function TW(t){const{viewport:e}=Le(t);if(e instanceof Zn){const r=R8(e);if(r!=null&&r.isDynamicVolume()){const n=rT.get(r.volumeId);rT.delete(r.volumeId),n&&n!==t&&SW(n)}}}function _3e(t,e){let r,n,i,o=0;const a=t.length,s=[];let c=!1;for((typeof e!="number"||e<=0)&&(e=1),r=1;r<a;r++)i=Number(t[r])/e|0,s.push(i),r===1?n=i:i!==n&&(c=!0),o+=i;return s.length>0&&(c?i=o/s.length|0:i=s[0],s.push(i)),{timeouts:s,isTimeVarying:c}}function _W(t){const e=t.intervalId;typeof e<"u"&&(t.intervalId=void 0,t.usingFrameTimeVector?clearTimeout(e):clearInterval(e))}function R8(t){if(!(t instanceof Zn))return;const e=t.getAllVolumeIds();if(!(e!=null&&e.length))return;const n=e.find(i=>{var o;return(o=$e.getVolume(i))==null?void 0:o.isDynamicVolume()})??e[0];return $e.getVolume(n)}function E3e(t,e){const r=t.getImageIds();return{get numScrollSteps(){return r.length},get currentStepIndex(){return t.getTargetImageIdIndex()},get frameTimeVectorEnabled(){return!0},waitForRenderedCount:0,scroll(n){if(this.waitForRenderedCount<=e&&t.viewportStatus!==xW.RENDERED){this.waitForRenderedCount++;return}this.waitForRenderedCount=0,oc(t,{delta:n,debounceLoading:CW})}}}function b3e(t,e){return{get numScrollSteps(){return t.getNumberOfSlices()},get currentStepIndex(){return t.getSliceIndex()},get frameTimeVectorEnabled(){return!0},waitForRenderedCount:0,scroll(r){if(this.waitForRenderedCount<=e&&t.viewportStatus!==xW.RENDERED){this.waitForRenderedCount++;return}this.waitForRenderedCount=0,oc(t,{delta:r,debounceLoading:CW})},play(r){return r&&t.setPlaybackRate(r/24),t.play(),t.getFrameRate()}}}function D3e(t,e){const{volumeId:r}=e,n={viewPlaneNormal:Ke(),scrollInfo:null},i=()=>{const o=t.getCamera();if(!n.scrollInfo||!cS(o.viewPlaneNormal,n.viewPlaneNormal)){const s=ud(t,r);n.viewPlaneNormal=o.viewPlaneNormal,n.scrollInfo=s}return n.scrollInfo};return{get numScrollSteps(){return i().numScrollSteps},get currentStepIndex(){return i().currentStepIndex},get frameTimeVectorEnabled(){const o=t.getCamera(),a=e.direction.slice(6,9).map(c=>-c),s=xt(a,o.viewPlaneNormal);return af(s,1)},scroll(o){i().currentStepIndex+=o,oc(t,{delta:o})}}}function I3e(t){return{get numScrollSteps(){return t.numDimensionGroups},get currentStepIndex(){return t.dimensionGroupNumber-1},get frameTimeVectorEnabled(){return!1},scroll(e){t.scroll(e)}}}function O3e(t,e){if(t instanceof Jn)return E3e(t,e.waitForRendered??30);if(t instanceof Zn){const r=R8(t);return e.dynamicCineEnabled&&(r!=null&&r.isDynamicVolume())?I3e(r):D3e(t,r)}if(t instanceof _h)return b3e(t,e.waitForRendered??30);throw new Error("Unknown viewport type")}const M3e=Object.freeze(Object.defineProperty({__proto__:null,Events:sh,addToolState:wW,getToolState:P8,playClip:T3e,stopClip:SW},Symbol.toStringTag,{value:"Module"}));function P3e(t,e){var n,i,o;const r=(e==null?void 0:e.knotsRatioPercentage)||30;return!((o=(i=(n=t==null?void 0:t.data)==null?void 0:n.contour)==null?void 0:i.polyline)!=null&&o.length)||r<=0}function R3e(t,e){const r=ma(),n=Hr(Ke(),e,t),i=Math.abs(t[0])>.1?Tt(-t[1],t[0],0):Tt(0,-t[2],t[1]);return a4(r,e,n,i),r}function K2(t,e=Math.floor(Math.random()*(t.length-1))){if(e===0)return 0;const r=[...t],{length:n}=t;for(let i=0;i<n;i++)t[i]=r[(i+e+n)%n];return e}function EW(t,e){if(P3e(t,e))return!1;const{viewPlaneNormal:r}=t.metadata,{closed:n,polyline:i}=t.data.contour,o=R3e(r,t.data.contour.polyline[0]),a=t.data.contour.polyline.map(f=>{const u=At(Ke(),f,o);return[u[0],u[1]]});let s=n?K2(a):0,c=qS(a,0,a.length,(e==null?void 0:e.knotsRatioPercentage)||30);if(c===a)return!1;K2(c,-s);for(let f=1;f<(e==null?void 0:e.loop);f++)s=n?K2(c):0,c=qS(c,0,a.length,(e==null?void 0:e.knotsRatioPercentage)||30),K2(c,-s);const l=Ar(ma(),o);return t.data.contour.polyline=c.map(f=>At([0,0,0],[...f,0],l)),!0}const L3e={smoothAnnotation:EW},A3e=Object.freeze(Object.defineProperty({__proto__:null,default:L3e,smoothAnnotation:EW},Symbol.toStringTag,{value:"Module"})),N3e=Object.freeze(Object.defineProperty({__proto__:null,getBoundsIJKFromRectangleAnnotations:GG,isAxisAlignedRectangle:nW},Symbol.toStringTag,{value:"Module"})),bW={};function DW(t,e){const r=Le(t),{viewportId:n}=r;bW[n]=e}function cg(t){const e=Le(t),{viewportId:r}=e;return bW[r]}const gd=Qt.Prefetch,IW=0;function k3e(t,e){t=Math.round(t)||0,e=Math.round(e)||0;const r=[];let n=e-t+1;if(n<=0)return r;for(;n--;)r[n]=e--;return r}function V3e(t,e){let r=0,n=t.length-1;return t.forEach((i,o)=>{i<e?r=Math.max(o,r):i>e&&(n=Math.min(o,n))}),{low:r,high:n}}function lg(t){const e=Le(t);if(!e)return null;const{viewport:r}=e;return r instanceof Jn?{currentImageIdIndex:r.getCurrentImageIdIndex(),imageIds:r.getImageIds()}:null}function nx(t){return function(e){const r=e.detail;let n;try{n=lg(t)}catch{return}if(!n||!n.imageIds||n.imageIds.length===0)return;const o=n.imageIds.indexOf(r.imageId);if(o<0)return;const a=cg(t);!a||!a.indicesToRequest||!a.indicesToRequest.length||a.indicesToRequest.push(o)}}const F3e=t=>{const e=new Set(t.imageIds);return r=>r.type!==gd||!e.has(r.additionalDetails.imageId)};let bp={maxImagesToPrefetch:1/0,preserveExistingPool:!0},oT;const U3e=10;function OW(t){var g,p;const e=cg(t);if(!e)return;const r=e||{},n=lg(t);if(!((g=n==null?void 0:n.imageIds)!=null&&g.length)){console.warn("CornerstoneTools.stackPrefetch: No images in stack.");return}const{currentImageIdIndex:i}=n;if(r.enabled=r.enabled&&(((p=r.indicesToRequest)==null?void 0:p.length)??0)>0,r.enabled===!1)return;function o(v){const y=r.indicesToRequest.indexOf(v);y>-1&&r.indicesToRequest.splice(y,1)}if(e.indicesToRequest.sort((v,y)=>v-y),r.indicesToRequest.slice().forEach(function(v){const y=n.imageIds[v];if(!y)return;(Math.abs(i-v)<6?$e.getImageLoadObject(y):$e.isLoaded(y))&&o(v)}),!r.indicesToRequest.length)return;bp.preserveExistingPool||_i.clearRequestStack(gd);const s=V3e(r.indicesToRequest,n.currentImageIdIndex);let c,l,f=s.low,u=s.high;const d=[];for(;f>=0||u<r.indicesToRequest.length;){const v=n.currentImageIdIndex,y=v-r.indicesToRequest[f]>bp.maxImagesToPrefetch,m=r.indicesToRequest[u]-v>bp.maxImagesToPrefetch,w=!y&&f>=0,x=!m&&u<r.indicesToRequest.length;if(!x&&!w)break;w&&(l=r.indicesToRequest[f--],c=n.imageIds[l],d.push(c)),x&&(l=r.indicesToRequest[u++],c=n.imageIds[l],d.push(c))}const h=(v,y)=>ws(v,y);d.forEach(v=>{const y={requestType:gd};_i.addRequest(h.bind(null,v,y),gd,{imageId:v},IW)})}function aT(t){clearTimeout(oT),oT=setTimeout(function(){const e=t.target;try{OW(e)}catch{return}},U3e)}function B3e(t){const e=lg(t);if(!e||!e.imageIds||e.imageIds.length===0){console.warn("CornerstoneTools.stackPrefetch: No images in stack.");return}const r={indicesToRequest:k3e(0,e.imageIds.length-1),enabled:!0,direction:1},n=r.indicesToRequest.indexOf(e.currentImageIdIndex);r.indicesToRequest.splice(n,1),DW(t,r),OW(t),t.removeEventListener(et.STACK_NEW_IMAGE,aT),t.addEventListener(et.STACK_NEW_IMAGE,aT);const i=nx(t);Ze.removeEventListener(et.IMAGE_CACHE_IMAGE_REMOVED,i),Ze.addEventListener(et.IMAGE_CACHE_IMAGE_REMOVED,i)}function G3e(t){clearTimeout(oT),t.removeEventListener(et.STACK_NEW_IMAGE,aT);const e=nx(t);Ze.removeEventListener(et.IMAGE_CACHE_IMAGE_REMOVED,e);const r=cg(t);r&&r.indicesToRequest.length&&(r.enabled=!1,_i.clearRequestStack(gd))}function W3e(){return bp}function z3e(t){bp=t}const $3e={enable:B3e,disable:G3e,getConfiguration:W3e,setConfiguration:z3e};let V1={maxImagesToPrefetch:1/0,minBefore:2,maxAfter:2,directionExtraImages:10,preserveExistingPool:!1},sT;const j3e=5,H3e=t=>{var n;const e=lg(t);if(!e)return;if(!((n=e.imageIds)!=null&&n.length)){console.warn("CornerstoneTools.stackPrefetch: No images in stack.");return}A8(t),L8(t),t.removeEventListener(et.STACK_NEW_IMAGE,cT),t.addEventListener(et.STACK_NEW_IMAGE,cT);const r=nx(t);Ze.removeEventListener(et.IMAGE_CACHE_IMAGE_REMOVED,r),Ze.addEventListener(et.IMAGE_CACHE_IMAGE_REMOVED,r)};function L8(t){var l,f;const e=lg(t);if(!e)return;if(!((l=e==null?void 0:e.imageIds)!=null&&l.length)){console.warn("CornerstoneTools.stackPrefetch: No images in stack.");return}const r=cg(t);if(!r)return;const n=r||{};if(n.enabled=n.enabled&&(((f=n.indicesToRequest)==null?void 0:f.length)??0)>0,n.enabled===!1)return;function i(u){const d=n.indicesToRequest.indexOf(u);d>-1&&n.indicesToRequest.splice(d,1)}const o=n.indicesToRequest.slice(),{currentImageIdIndex:a}=e;if(o.forEach(u=>{const d=e.imageIds[u];if(!d)return;(Math.abs(a-u)<6?$e.getImageLoadObject(d):$e.isLoaded(d))&&i(u)}),!n.indicesToRequest.length)return;V1.preserveExistingPool||_i.filterRequests(F3e(e));function s(u){var v,y;const d=e.imageIds.indexOf(u);i(d);const h=$e.getCachedImageBasedOnImageURI(u),{stats:g}=n,p=((v=h==null?void 0:h.image)==null?void 0:v.decodeTimeInMS)||0;if(p){g.imageIds.set(u,p),g.decodeTimeInMS+=p;const m=((y=h==null?void 0:h.image)==null?void 0:y.loadTimeInMS)||0;g.loadTimeInMS+=m}if(!n.indicesToRequest.length&&h!=null&&h.sizeInBytes){const{sizeInBytes:m}=h,w=$e.getMaxCacheSize()/4/m;if(!n.cacheFill)g.initialTime=Date.now()-g.start,g.initialSize=g.imageIds.size,A8(t,w),L8(t);else if(g.imageIds.size){g.fillTime=Date.now()-g.start;const{size:x}=g.imageIds;g.fillSize=x}}}const c=(u,d)=>ws(u,d).then(()=>s(u));n.indicesToRequest.forEach(u=>{const d=e.imageIds[u],h={requestType:gd};_i.addRequest(c.bind(null,d,h),gd,{imageId:d},IW)})}function cT(t){clearTimeout(sT),sT=setTimeout(function(){const e=t.target;try{A8(e),L8(e)}catch{return}},j3e)}const K3e=t=>t<0?-1:1,A8=(t,e)=>{var d;const r=lg(t);if(!r)return;if(!((d=r.imageIds)!=null&&d.length)){console.warn("CornerstoneTools.stackPrefetch: No images in stack.");return}const{currentImageIdIndex:n}=r;let{maxAfter:i=2,minBefore:o=2}=V1;const{directionExtraImages:a=10}=V1,s=cg(t)||{indicesToRequest:[],currentImageIdIndex:n,stackCount:0,enabled:!0,direction:1,stats:{start:Date.now(),imageIds:new Map,decodeTimeInMS:0,loadTimeInMS:0,totalBytes:0}},c=n-s.currentImageIdIndex;if(s.direction=K3e(c),s.currentImageIdIndex=n,s.enabled=!0,s.stackCount<100&&(s.stackCount+=a),Math.abs(c)>i||!c)if(s.stackCount=0,e){const h=n/r.imageIds.length;o=Math.ceil(e*h),i=Math.ceil(e*(1-h)),s.cacheFill=!0}else s.cacheFill=!1;else c<0?(o+=s.stackCount,i=0):(i+=s.stackCount,o=0);const l=Math.max(0,n-o),f=Math.min(r.imageIds.length-1,n+i),u=[];for(let h=n+1;h<=f;h++)u.push(h);for(let h=n-1;h>=l;h--)u.push(h);s.indicesToRequest=u,DW(t,s)};function q3e(t){clearTimeout(sT),t.removeEventListener(et.STACK_NEW_IMAGE,cT);const e=nx(t);Ze.removeEventListener(et.IMAGE_CACHE_IMAGE_REMOVED,e);const r=cg(t);r&&(r.enabled=!1)}function X3e(){return V1}function Y3e(t){V1=t}const J3e={enable:H3e,disable:q3e,getConfiguration:X3e,setConfiguration:Y3e},Z3e=Object.freeze(Object.defineProperty({__proto__:null,isViewportPreScaled:uu},Symbol.toStringTag,{value:"Module"}));function Q3e(t,e){let r;const n=e.dimensionGroupNumbers||e.frameNumbers||Array.from({length:t.numDimensionGroups},(i,o)=>o+1);if(e.frameNumbers&&console.warn("Warning: frameNumbers parameter is deprecated. Please use dimensionGroupNumbers instead."),!e.maskVolumeId&&!e.worldCoordinate)throw new Error("You should provide either maskVolumeId or imageCoordinate");if(e.maskVolumeId&&e.worldCoordinate)throw new Error("You can only use one of maskVolumeId or imageCoordinate");if(e.maskVolumeId){const i=$e.getVolume(e.maskVolumeId);if(!i)throw new Error("Segmentation volume not found");const[o,a]=tSe(n,t,i);return[o,a]}return e.worldCoordinate?eSe(n,e.worldCoordinate,t):r}function eSe(t,e,r){const{dimensions:n,imageData:i}=r,o=i.worldToIndex(e);if(o[0]=Math.floor(o[0]),o[1]=Math.floor(o[1]),o[2]=Math.floor(o[2]),!tr(o,n))throw new Error("outside bounds");const a=n[0],s=n[0]*n[1],c=[];return t.forEach(l=>{const f=o[2]*s+o[1]*a+o[0];c.push(r.voxelManager.getAtIndexAndDimensionGroup(f,l))}),c}function tSe(t,e,r){const{imageData:n}=r,i=r.voxelManager,o=i.getScalarDataLength(),a=[];a.length=o;let s=0;for(let d=0,h=o;d<h;d++)i.getAtIndex(d)!==0&&(a[s++]=d);a.length=s;const c=[],l=e.voxelManager.getScalarDataLength()===o&&JSON.stringify(e.spacing)===JSON.stringify(r.spacing),f=[];if(l){for(let d=0;d<a.length;d++){const h=[],g=a[d];for(let p=0;p<t.length;p++)h.push(e.voxelManager.getAtIndexAndDimensionGroup(g,t[p]));c.push(h),f.push(i.toIJK(g))}return[c,f]}const u=({pointLPS:d,value:h,pointIJK:g})=>{if(h===0)return;const p=AE(e.imageData,e.dimensions,e.spacing,d);let v=0;const y=new Map;t.forEach(x=>y.set(x,0));const m=({index:x})=>{for(let C=0;C<t.length;C++){const S=e.voxelManager.getAtIndexAndDimensionGroup(x,t[C]),T=t[C];y.set(T,y.get(T)+S)}v++};e.voxelManager.forEach(m,{imageData:e.imageData,boundsIJK:p});const w=[];y.forEach(x=>{w.push(x/v)}),f.push(g),c.push(w)};return r.voxelManager.forEach(u,{imageData:n}),[c,f]}function MW(t,e){const r=t.getScalarDataLength(),n=new Float32Array(r);for(const i of e){const o=t.getDimensionGroupScalarData(i);for(let a=0;a<r;a++)n[a]+=o[a]}return n}function nSe(t,e){const r=MW(t,e),n=e.length;for(let i=0;i<r.length;i++)r[i]/=n;return r}const PW={[K0.SUM]:(t,e,r)=>{const n=MW(t,e);for(let i=0;i<n.length;i++)r(i,n[i])},[K0.AVERAGE]:(t,e,r)=>{const n=nSe(t,e);for(let i=0;i<n.length;i++)r(i,n[i])},[K0.SUBTRACT]:(t,e,r)=>{if(e.length!==2)throw new Error("Please provide only 2 dimension groups for subtraction.");const n=t.getScalarDataLength(),i=t.getDimensionGroupScalarData(e[0]),o=t.getDimensionGroupScalarData(e[1]);for(let a=0;a<n;a++){const s=i[a]-o[a];r(a,s)}}};function rSe(t,e,r){const{dimensionGroupNumbers:n,frameNumbers:i}=r;i&&console.warn("Warning: frameNumbers parameter is deprecated. Please use dimensionGroupNumbers instead.");const o=n||i||Array.from({length:t.numDimensionGroups},(f,u)=>u+1);if(o.length<=1)throw new Error("Please provide two or more dimension groups");const a=t.voxelManager,s=a.getScalarDataLength(),c=PW[e];if(!c)throw new Error(`Unsupported operation: ${e}`);const l=new Float32Array(s);return c(a,o,(f,u)=>{l[f]=u}),l}function iSe(t,e,r){const{dimensionGroupNumbers:n,frameNumbers:i,targetVolume:o}=r;if(!o)throw new Error("A target volume must be provided");i&&console.warn("Warning: frameNumbers parameter is deprecated. Please use dimensionGroupNumbers instead.");const a=n||i||Array.from({length:t.numDimensionGroups},(f,u)=>u+1);if(a.length<=1)throw new Error("Please provide two or more dimension groups");const s=t.voxelManager,c=o.voxelManager,l=PW[e];if(!l)throw new Error(`Unsupported operation: ${e}`);l(s,a,(f,u)=>{c.setAtIndex(f,u)}),c.resetModifiedSlices();for(let f=0;f<o.dimensions[2];f++)c.modifiedSlices.add(f)}const oSe=Object.freeze(Object.defineProperty({__proto__:null,generateImageFromTimeData:rSe,getDataInTime:Q3e,updateVolumeFromTimeData:iSe},Symbol.toStringTag,{value:"Module"}));function RW(t,e){const r=e*3;if(r<t.length)return Tt(t[r],t[r+1],t[r+2])}function LW(t){const e=t.getLines().getData();let r=0;const n=new Map;for(;r<e.length;){const s=e[r++],c=[];for(let l=0;l<s;l++)c.push(e[r+l]);n.set(c[0],c),r+=s}const i=[],o=s=>{for(const[c,l]of s.entries())if(l!==void 0)return c;return-1};let a=o(n);for(;a!==-1;){const s=[a];for(;n.has(a);){const c=n.get(a)[1];n.has(c)&&s.push(c),n.delete(a),a=c}i.push(s),a=o(n)}return i.length?i:void 0}function AW(t){const e=LW(t);if(!e)return;const r=t.getPoints().getData();return e.map(n=>n.map(i=>RW(r,i)))}const aSe=Object.freeze(Object.defineProperty({__proto__:null,getPoint:RW,getPolyDataPointIndexes:LW,getPolyDataPoints:AW},Symbol.toStringTag,{value:"Module"}));var Va;(function(t){t.Top="top",t.Left="left",t.Bottom="bottom",t.Right="right"})(Va||(Va={}));const sSe=Object.freeze(Object.defineProperty({__proto__:null,get ColorbarRangeTextPosition(){return Va}},Symbol.toStringTag,{value:"Module"})),Gl=t=>t&&t.upper>t.lower,S5=t=>!!t&&t.width>0&&t.height>0,F1=(t,e)=>!!t&&!!e&&t.lower===e.lower&&t.upper===e.upper,NW=(t,e)=>!!t&&!!e&&t.width===e.width&&t.height===e.height,cSe=(t,e,r)=>[t[0]*(1-r)+e[0]*r,t[1]*(1-r)+e[1]*r,t[2]*(1-r)+e[2]*r],{clamp:lSe}=pn;class N8{constructor(e){N8.validateProps(e);const{colormap:r,size:n={width:20,height:100},imageRange:i={lower:0,upper:1},voiRange:o={lower:0,upper:1},container:a,showFullPixelValueRange:s=!1}=e;this._colormap=r,this._imageRange=i,this._voiRange=o,this._showFullImageRange=s,this._canvas=this._createRootElement(n),a&&this.appendTo(a)}get colormap(){return this._colormap}set colormap(e){this._colormap=e,this.render()}get size(){const{width:e,height:r}=this._canvas;return{width:e,height:r}}set size(e){const{_canvas:r}=this;!S5(e)||NW(r,e)||(this._setCanvasSize(r,e),this.render())}get imageRange(){return{...this._imageRange}}set imageRange(e){!Gl(e)||F1(e,this._imageRange)||(this._imageRange=e,this.render())}get voiRange(){return{...this._voiRange}}set voiRange(e){!Gl(e)||F1(e,this._voiRange)||(this._voiRange=e,this.render())}get showFullImageRange(){return this._showFullImageRange}set showFullImageRange(e){e!==this._showFullImageRange&&(this._showFullImageRange=e,this.render())}appendTo(e){e.appendChild(this._canvas),this.render()}dispose(){const{_canvas:e}=this,{parentElement:r}=e;r==null||r.removeChild(e)}static validateProps(e){const{size:r,imageRange:n,voiRange:i}=e;if(r&&!S5(r))throw new Error('Invalid "size"');if(n&&!Gl(n))throw new Error('Invalid "imageRange"');if(i&&!Gl(i))throw new Error('Invalid "voiRange"')}_setCanvasSize(e,r){const{width:n,height:i}=r;e.width=n,e.height=i,Object.assign(e.style,{width:`${n}px`,height:`${i}px`})}_createRootElement(e){const r=document.createElement("canvas");return Object.assign(r.style,{position:"absolute",top:"0",left:"0",pointerEvents:"none",boxSizing:"border-box"}),this._setCanvasSize(r,e),r}render(){if(!this._canvas.isConnected)return;const{_colormap:e}=this,{RGBPoints:r}=e,n=r.length/4,i=v=>{const y=4*v;if(!(v<0||v>=n))return{index:v,position:r[y],color:[r[y+1],r[y+2],r[y+3]]}},{width:o,height:a}=this._canvas,s=this._canvas.getContext("2d");if(!s)return;const c=o>a,l=c?o:a,{_voiRange:f}=this,u=this._showFullImageRange?this._imageRange:{...f};let d,h=i(0);const g=(u.upper-u.lower)/(l-1);let p=u.lower;for(let v=0;v<l;v++){const y=(p-f.lower)/Math.abs(f.upper-f.lower);if(h)for(let x=h.index;x<n&&!(y<=h.position);x++)d=h,h=i(x+1);let m;if(!d)m=[...h.color];else if(!h)m=[...d.color];else{const x=(y-d.position)/(h.position-d.position);m=cSe(d.color,h.color,x)}const w=m.map(x=>lSe(Math.round(x*255),0,255));s.fillStyle=`rgb(${w[0]}, ${w[1]}, ${w[2]})`,c?s.fillRect(v,0,1,a):s.fillRect(0,a-v-1,o,1),p+=g}}}const Uf={FONT:"10px Arial",COLOR:"white",TICK_SIZE:5,TICK_WIDTH:1,TICK_LABEL_MARGIN:3,MAX_NUM_TICKS:8,TICKS_STEPS:[1,2.5,5,10]};class k8{constructor(e){k8.validateProps(e);const{top:r=0,left:n=0,size:i={width:20,height:100},imageRange:o={lower:0,upper:1},voiRange:a={lower:0,upper:1},ticks:s,container:c,showFullPixelValueRange:l=!1}=e,{style:f,position:u}=s??{};this._imageRange=o,this._voiRange=a,this._font=(f==null?void 0:f.font)??Uf.FONT,this._color=(f==null?void 0:f.color)??Uf.COLOR,this._tickSize=(f==null?void 0:f.tickSize)??Uf.TICK_SIZE,this._tickWidth=(f==null?void 0:f.tickWidth)??Uf.TICK_WIDTH,this._labelMargin=(f==null?void 0:f.labelMargin)??Uf.TICK_LABEL_MARGIN,this._maxNumTicks=(f==null?void 0:f.maxNumTicks)??Uf.MAX_NUM_TICKS,this._rangeTextPosition=u??Va.Right,this._showFullPixelValueRange=l,this._canvas=this._createCanvasElement(i,r,n),c&&this.appendTo(c)}get size(){const{width:e,height:r}=this._canvas;return{width:e,height:r}}set size(e){const{_canvas:r}=this;!S5(e)||NW(r,e)||(this._setCanvasSize(r,e),this.render())}get top(){return Number.parseInt(this._canvas.style.top)}set top(e){const{_canvas:r}=this,n=this.top;e!==n&&(r.style.top=`${e}px`,this.render())}get left(){return Number.parseInt(this._canvas.style.left)}set left(e){const{_canvas:r}=this,n=this.left;e!==n&&(r.style.left=`${e}px`,this.render())}get imageRange(){return{...this._imageRange}}set imageRange(e){!Gl(e)||F1(e,this._imageRange)||(this._imageRange=e,this.render())}get voiRange(){return{...this._voiRange}}set voiRange(e){!Gl(e)||F1(e,this._voiRange)||(this._voiRange=e,this.render())}get tickSize(){return this._tickSize}set tickSize(e){e!==this._tickSize&&(this._tickSize=e,this.render())}get tickWidth(){return this._tickWidth}set tickWidth(e){e!==this._tickWidth&&(this._tickWidth=e,this.render())}get color(){return this._color}set color(e){e!==this._color&&(this._color=e,this.render())}get showFullPixelValueRange(){return this._showFullPixelValueRange}set showFullPixelValueRange(e){e!==this._showFullPixelValueRange&&(this._showFullPixelValueRange=e,this.render())}get visible(){return this._canvas.style.display==="block"}set visible(e){e!==this.visible&&(this._canvas.style.display=e?"block":"none",e&&this.render())}appendTo(e){e.appendChild(this._canvas),this.render()}static validateProps(e){const{size:r,imageRange:n,voiRange:i}=e;if(r&&!S5(r))throw new Error('Invalid "size"');if(n&&!Gl(n))throw new Error('Invalid "imageRange"');if(i&&!Gl(i))throw new Error('Invalid "voiRange"')}_setCanvasSize(e,r){const{width:n,height:i}=r;e.width=n,e.height=i,Object.assign(e.style,{width:`${n}px`,height:`${i}px`})}_createCanvasElement(e,r,n){const i=document.createElement("canvas");return Object.assign(i.style,{display:"none",position:"absolute",boxSizing:"border-box",top:`${r}px`,left:`${n}px`}),this._setCanvasSize(i,e),i}_getTicks(e){const{lower:r,upper:n}=e,o=(n-r)/(this._maxNumTicks-1),a=Math.pow(10,-Math.floor(Math.log10(Math.abs(o)))),s=o*a,l=Uf.TICKS_STEPS.find(g=>g>=s)/a,f=Math.ceil(n/l)*l,u=Math.floor(r/l)*l,d=Math.round((f-u)/l)+1,h=[];for(let g=0;g<d;g++)h.push(u+g*l);return{scaleMin:u,scaleMax:f,step:l,ticks:h}}_getLeftTickInfo({position:e,labelMeasure:r}){const{width:n}=this._canvas,o=[n-this.tickSize-r.width-this._labelMargin,e],a={start:[n-this._tickSize,e],end:[n,e]};return{labelPoint:o,tickPoints:a}}_getRightTickInfo({position:e}){const r=[this._tickSize+this._labelMargin,e],n={start:[0,e],end:[this._tickSize,e]};return{labelPoint:r,tickPoints:n}}_getTopTickInfo({position:e,labelMeasure:r}){const{height:n}=this._canvas,i=n-this.tickSize-this._labelMargin,o=[e,i],a={start:[e,n-this._tickSize],end:[e,n]};return{labelPoint:o,tickPoints:a}}_getBottomTickInfo({position:e,labelMeasure:r}){const n=[e,this._tickSize+this._labelMargin],i={start:[e,0],end:[e,this._tickSize]};return{labelPoint:n,tickPoints:i}}render(){const{_canvas:e}=this;if(!e.isConnected||!this.visible)return;const{width:r,height:n}=e,i=r>=n,o=i?r:n,a=e.getContext("2d"),{_voiRange:s}=this,c=this._showFullPixelValueRange?this._imageRange:{...s},l=c.upper-c.lower,{ticks:f}=this._getTicks(c);a.clearRect(0,0,r,n),a.font=this._font,a.textBaseline=i?"top":"middle",a.textAlign=i?"center":"left",a.fillStyle=this._color,a.strokeStyle=this._color,a.lineWidth=this.tickWidth,f.forEach(u=>{let d=Math.round(o*((u-c.lower)/l));if(i||(d=n-d),d<0||d>o)return;const h=u.toString(),g=a.measureText(h);let p;i?this._rangeTextPosition===Va.Top?p=this._getTopTickInfo({position:d,labelMeasure:g}):p=this._getBottomTickInfo({position:d,labelMeasure:g}):this._rangeTextPosition===Va.Left?p=this._getLeftTickInfo({position:d,labelMeasure:g}):p=this._getRightTickInfo({position:d});const{labelPoint:v,tickPoints:y}=p,{start:m,end:w}=y;return a.beginPath(),a.moveTo(m[0],m[1]),a.lineTo(w[0],w[1]),a.fillText(h,v[0],v[1]),a.stroke(),d})}}function uSe(t,e,r){return(t>=e?[Va.Top,Va.Bottom]:[Va.Left,Va.Right]).includes(r)}class fSe{constructor({id:e,container:r}){this._containerResizeCallback=n=>{let i,o;const{contentRect:a,contentBoxSize:s}=n[0];a?(i=a.width,o=a.height):s!=null&&s.length&&(i=s[0].inlineSize,o=s[0].blockSize),this._containerSize={width:i,height:o},this.onContainerResize()},this._id=e,this._containerSize={width:0,height:0},this._rootElement=this.createRootElement(e),this._containerResizeObserver=new ResizeObserver(this._containerResizeCallback),r&&this.appendTo(r)}get id(){return this._id}get rootElement(){return this._rootElement}appendTo(e){const{_rootElement:r,_containerResizeObserver:n}=this,{parentElement:i}=r;!e||e===i||(i&&n.unobserve(i),e.appendChild(r),n.observe(e))}destroy(){const{_rootElement:e,_containerResizeObserver:r}=this,{parentElement:n}=e;n==null||n.removeChild(e),r.disconnect()}get containerSize(){return{...this._containerSize}}createRootElement(e){const r=document.createElement("div");return r.id=e,r.classList.add("widget"),Object.assign(r.style,{width:"100%",height:"100%"}),r}onContainerResize(){}}const kg={MULTIPLIER:1,RANGE_TEXT_POSITION:Va.Right,TICKS_BAR_SIZE:50};class U1 extends fSe{constructor(e){var r;super(e),this._isMouseOver=!1,this._isInteracting=!1,this._mouseOverCallback=n=>{this._isMouseOver=!0,this.showTicks(),n.stopPropagation()},this._mouseOutCallback=n=>{this._isMouseOver=!1,this.hideTicks(),n.stopPropagation()},this._mouseDownCallback=n=>{this._isInteracting=!0,this.showTicks(),this._addVOIEventListeners(n),n.stopPropagation()},this._mouseDragCallback=(n,i)=>{const o=this.getVOIMultipliers(),a=this._getPointsFromMouseEvent(n),{points:s,voiRange:c}=i,l=ps(Wt(),a.local,s.local),f=l[0]*o[0],u=l[1]*o[1];if(!f&&!u)return;const{lower:d,upper:h}=c;let{windowWidth:g,windowCenter:p}=om(d,h);g=Math.max(g+f,1),p+=u;const v=Yu(g,p);this.voiRange=v,n.stopPropagation(),n.preventDefault()},this._mouseUpCallback=n=>{this._isInteracting=!1,this.hideTicks(),this._removeVOIEventListeners(),n.stopPropagation()},this._eventListenersManager=new wV,this._colormaps=U1.getColormapsMap(e),this._activeColormapName=U1.getInitialColormapName(e),this._canvas=this._createCanvas(e),this._ticksBar=this._createTicksBar(e),this._rangeTextPosition=((r=e.ticks)==null?void 0:r.position)??kg.RANGE_TEXT_POSITION,this._canvas.appendTo(this.rootElement),this._ticksBar.appendTo(this.rootElement),this._addRootElementEventListeners()}get activeColormapName(){return this._activeColormapName}set activeColormapName(e){if(e===this._activeColormapName)return;const r=this._colormaps.get(e);if(!r){console.warn(`Invalid colormap name (${e})`);return}this._activeColormapName=e,this._canvas.colormap=r}get imageRange(){return this._canvas.imageRange}set imageRange(e){this._canvas.imageRange=e,this._ticksBar.imageRange=e}get voiRange(){return this._canvas.voiRange}set voiRange(e){const{voiRange:r}=this._canvas;!Gl(e)||F1(e,r)||(this._canvas.voiRange=e,this._ticksBar.voiRange=e,this.onVoiChange(e))}get showFullImageRange(){return this._canvas.showFullImageRange}set showFullImageRange(e){this._canvas.showFullImageRange=e,this._ticksBar.showFullPixelValueRange=e}destroy(){super.destroy(),this._eventListenersManager.reset()}createRootElement(){const e=document.createElement("div");return Object.assign(e.style,{position:"relative",fontSize:"0",width:"100%",height:"100%"}),e}onContainerResize(){super.onContainerResize(),this.updateTicksBar(),this._canvas.size=this.containerSize}getVOIMultipliers(){return[kg.MULTIPLIER,kg.MULTIPLIER]}onVoiChange(e){}showTicks(){this.updateTicksBar(),this._ticksBar.visible=!0}hideTicks(){this._isInteracting||this._isMouseOver||(this._ticksBar.visible=!1)}static getColormapsMap(e){const{colormaps:r}=e;return r.reduce((n,i)=>n.set(i.Name,i),new Map)}static getInitialColormapName(e){const{activeColormapName:r,colormaps:n}=e;return!!r&&n.some(o=>o.Name===r)?r:n[0].Name}_createCanvas(e){const{imageRange:r,voiRange:n,showFullPixelValueRange:i}=e,o=this._colormaps.get(this._activeColormapName);return new N8({colormap:o,imageRange:r,voiRange:n,showFullPixelValueRange:i})}_createTicksBar(e){const r=e.ticks;return new k8({imageRange:e.imageRange,voiRange:e.voiRange,ticks:r,showFullPixelValueRange:e.showFullPixelValueRange})}_getPointsFromMouseEvent(e){const{rootElement:r}=this,n=[e.clientX,e.clientY],i=[e.pageX,e.pageY],o=r.getBoundingClientRect(),a=[i[0]-o.left-window.pageXOffset,i[1]-o.top-window.pageYOffset];return{client:n,page:i,local:a}}updateTicksBar(){const{width:e,height:r}=this.containerSize;if(e===0&&r===0)return;const{_ticksBar:n,_rangeTextPosition:i}=this,o=e>=r,a=o?e:kg.TICKS_BAR_SIZE,s=o?kg.TICKS_BAR_SIZE:r;if(!uSe(e,r,i))throw new Error("Invalid rangeTextPosition value for the current colobar orientation");let c,l;n.size={width:a,height:s},o?(l=0,c=i===Va.Top?-s:r):(c=0,l=i===Va.Left?-a:e),n.top=c,n.left=l}_addRootElementEventListeners(){const{_eventListenersManager:e}=this,{rootElement:r}=this;e.addEventListener(r,"mouseover",this._mouseOverCallback),e.addEventListener(r,"mouseout",this._mouseOutCallback),e.addEventListener(r,"mousedown",this._mouseDownCallback)}_addVOIEventListeners(e){const{_eventListenersManager:r}=this,n=this._getPointsFromMouseEvent(e),i={...this._canvas.voiRange},o={points:n,voiRange:i};this._removeVOIEventListeners(),r.addEventListener(document,"voi.mouseup",this._mouseUpCallback),r.addEventListener(document,"voi.mousemove",a=>this._mouseDragCallback(a,o))}_removeVOIEventListeners(){const{_eventListenersManager:e}=this;e.removeEventListener(document,"voi.mouseup"),e.removeEventListener(document,"voi.mousemove")}}const kC=4;function dSe(t,e,r){if(LV(t,e)==="PT"){const{clientWidth:i,clientHeight:o}=t.element,a=5/Math.max(i,o),s=uu(t,e),{fixedPTWindowWidth:c=!0}=r??{},l=c?0:a;return s?[l,a]:[l,kC]}return[kC,kC]}const{Events:wu}=Ha,q2={lower:-1e3,upper:1e3};class I0 extends U1{constructor(e){const{element:r,volumeId:n}=e,i=I0._getImageRange(r,n),o=I0._getVOIRange(r,n);super({...e,imageRange:i,voiRange:o}),this.autoHideTicks=()=>{if(this._hideTicksTimeoutId)return;const a=this._hideTicksTime-Date.now();a<=0?this.hideTicks():this._hideTicksTimeoutId=window.setTimeout(()=>{this._hideTicksTimeoutId=0,this.autoHideTicks()},a)},this._stackNewImageCallback=()=>{this.imageRange=I0._getImageRange(this._element)},this._imageVolumeModifiedCallback=a=>{const{volumeId:s}=a.detail;if(s!==this._volumeId)return;const{_element:c}=this;this.imageRange=I0._getImageRange(c,s)},this._viewportVOIModifiedCallback=a=>{const{viewportId:s,volumeId:c,range:l,colormap:f}=a.detail,{viewport:u}=this.enabledElement;s!==u.id||c!==this._volumeId||(this.voiRange=l,f&&(this.activeColormapName=f.name),this.showAndAutoHideTicks())},this._viewportColormapModifiedCallback=a=>{const{viewportId:s,colormap:c,volumeId:l}=a.detail,{viewport:f}=this.enabledElement;s!==f.id||l!==this._volumeId||(this.activeColormapName=c.name)},this._element=r,this._volumeId=n,this._addCornerstoneEventListener()}get element(){return this._element}get enabledElement(){return Le(this._element)}getVOIMultipliers(){const{viewport:e}=this.enabledElement;return dSe(e,this._volumeId)}onVoiChange(e){super.onVoiChange(e);const{viewport:r}=this.enabledElement;if(r instanceof Jn)r.setProperties({voiRange:e}),r.render();else if(r instanceof Zn){const{_volumeId:n}=this,i=cm(n);r.setProperties({voiRange:e},n),i.forEach(o=>o.render())}}static _getImageRange(e,r){const n=Le(e),{viewport:i}=n,o=i.getImageActor(r);if(!o)return q2;const s=o.getMapper().getInputData().getPointData().getScalars();let c;if(s)c=s.getRange();else{if(!r)throw new Error("volumeId is required when scalarData is not available");const l=$e.getVolume(r),[f,u]=l.voxelManager.getRange();c=[f,u]}return c[0]===0&&c[1]===0?q2:{lower:c[0],upper:c[1]}}static _getVOIRange(e,r){const n=Le(e),{viewport:i}=n,o=i.getImageActor(r);if(!o)return q2;const a=o.getProperty().getRGBTransferFunction(0).getRange();return a[0]===0&&a[1]===0?q2:{lower:a[0],upper:a[1]}}showAndAutoHideTicks(e=1e3){this._hideTicksTime=Date.now()+e,this.showTicks(),this.autoHideTicks()}_addCornerstoneEventListener(){const{_element:e}=this;Ze.addEventListener(wu.IMAGE_VOLUME_MODIFIED,this._imageVolumeModifiedCallback),e.addEventListener(wu.STACK_NEW_IMAGE,this._stackNewImageCallback),e.addEventListener(wu.VOI_MODIFIED,this._viewportVOIModifiedCallback),e.addEventListener(wu.COLORMAP_MODIFIED,this._viewportColormapModifiedCallback)}destroy(){super.destroy();const{_element:e}=this;Ze.removeEventListener(wu.IMAGE_VOLUME_MODIFIED,this._imageVolumeModifiedCallback),e.removeEventListener(wu.STACK_NEW_IMAGE,this._stackNewImageCallback),e.removeEventListener(wu.VOI_MODIFIED,this._viewportVOIModifiedCallback),e.removeEventListener(wu.COLORMAP_MODIFIED,this._viewportColormapModifiedCallback)}}const hSe=Object.freeze(Object.defineProperty({__proto__:null,Colorbar:U1,Enums:sSe,ViewportColorbar:I0},Symbol.toStringTag,{value:"Module"}));function kW(t,e,r,n,i){const o=[];let a=0;const s=t.scalarData;let c,l,f;if(t.color)for(l=0;l<i;l++)for(f=0;f<n;f++){c=((l+r)*t.columns+(f+e))*4;const u=s[c],d=s[c+1],h=s[c+2];o[a++]=.2126*u+.7152*d+.0722*h}else for(l=0;l<i;l++)for(f=0;f<n;f++)c=(l+r)*t.columns+(f+e),o[a++]=s[c];return o}function VW(t,e,r){const n=t.length;let i=r,o=e,a=0;if(n<2)return{min:i,max:o,mean:(e+r)/2};for(let s=0;s<n;s++){const c=t[s];i=Math.min(i,c),o=Math.max(o,c),a+=c}return{min:i,max:o,mean:a/n}}function FW(t){if(t instanceof Zn)return gSe(t);if(t instanceof Jn)return pSe(t);throw new Error("Viewport not supported")}function gSe(t){const{scalarData:e,width:r,height:n}=pE(t),{min:i,max:o}=dE(e);return{scalarData:e,minPixelValue:i,maxPixelValue:o,width:r,height:n,rows:r,columns:n}}function pSe(t){const e=t.getImageData(),{scalarData:r}=e,{min:n,max:i}=dE(r),o=e.dimensions[0],a=e.dimensions[1],{rows:s,columns:c,color:l}=t.getCornerstoneImage();return{scalarData:r,width:o,height:a,minPixelValue:n,maxPixelValue:i,rows:s,columns:c,color:l}}const mSe=Object.freeze(Object.defineProperty({__proto__:null,calculateMinMaxMean:VW,extractWindowLevelRegionToolData:FW,getLuminanceFromRegion:kW},Symbol.toStringTag,{value:"Module"})),vSe=Object.freeze(Object.defineProperty({__proto__:null,colorbar:hSe,windowLevel:mSe},Symbol.toStringTag,{value:"Module"})),{transformWorldToIndex:lT}=pn;function ySe(t,e,r,n){const{boundsIJK:i,centerWorld:o,radiusWorld:a}=wSe(e,t,n),s={center:o,radius:a},c=t.getDimensions();fc.createScalarVolumeVoxelManager({dimensions:c,scalarData:t.getPointData().getScalars().getData()}).forEach(r,{boundsIJK:i,isInObject:f=>KG(s,f),imageData:t})}function wSe(t,e,r){const[n,i]=t,o=Tt((n[0]+i[0])/2,(n[1]+i[1])/2,(n[2]+i[2])/2),a=Fi(n,i)/2;let s;if(!r){const c=lT(e,o),l=e.getSpacing(),f=Math.min(...l),u=Math.ceil(a/f);return s=[[c[0]-u,c[0]+u],[c[1]-u,c[1]+u],[c[2]-u,c[2]+u]],{boundsIJK:s,centerWorld:o,radiusWorld:a}}return s=xSe(e,r,t,o,a),{boundsIJK:s,centerWorld:o,radiusWorld:a}}function xSe(t,e,r,n,i){const[o,a]=r,s=t.getDimensions(),c=e.getCamera(),l=Tt(c.viewUp[0],c.viewUp[1],c.viewUp[2]),f=Tt(c.viewPlaneNormal[0],c.viewPlaneNormal[1],c.viewPlaneNormal[2]),u=Ke();Tn(u,l,f);const d=Ke(),h=Ke();dn(d,a,f,i),dn(h,o,f,-i),dn(d,d,u,-i),dn(h,h,u,i);const g=[lT(t,d),lT(t,h)];return lf(g,s)}function UW(t){if(!Array.isArray(t)||t.length!==9)throw new Error("Matrix must be an array of 9 numbers");if(!t.every(e=>typeof e=="number"&&!isNaN(e)))throw new Error("Matrix must contain only valid numbers")}function BW(t){UW(t);const e=[[t[0],t[1],t[2]],[t[3],t[4],t[5]],[t[6],t[7],t[8]]],r=e[0][0]*(e[1][1]*e[2][2]-e[1][2]*e[2][1])-e[0][1]*(e[1][0]*e[2][2]-e[1][2]*e[2][0])+e[0][2]*(e[1][0]*e[2][1]-e[1][1]*e[2][0]);if(Math.abs(r)<1e-10)throw new Error("Matrix is not invertible (determinant is zero)");const n=[[e[1][1]*e[2][2]-e[1][2]*e[2][1],-(e[0][1]*e[2][2]-e[0][2]*e[2][1]),e[0][1]*e[1][2]-e[0][2]*e[1][1]],[-(e[1][0]*e[2][2]-e[1][2]*e[2][0]),e[0][0]*e[2][2]-e[0][2]*e[2][0],-(e[0][0]*e[1][2]-e[0][2]*e[1][0])],[e[1][0]*e[2][1]-e[1][1]*e[2][0],-(e[0][0]*e[2][1]-e[0][1]*e[2][0]),e[0][0]*e[1][1]-e[0][1]*e[1][0]]],i=[];for(let o=0;o<3;o++)for(let a=0;a<3;a++)i.push(n[o][a]/r);return i}function VC(t){const e=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);return t.map(r=>r/e)}function CSe(t){UW(t);const e=t.slice(0,3),r=t.slice(3,6),n=t.slice(6,9),i=VC(e),o=VC(r),a=VC(n),s={x:[1,0,0],y:[0,1,0],z:[0,0,1]},c=1e-10,l=i.every((u,d)=>Math.abs(u-s.x[d])<c)&&o.every((u,d)=>Math.abs(u-s.y[d])<c)&&a.every((u,d)=>Math.abs(u-s.z[d])<c),f=l?[...s.x,...s.y,...s.z]:BW([...i,...o,...a]);return{isStandard:l,rotationMatrix:f}}function SSe(t,e,r){const n=t[0]-e[0],i=t[1]-e[1],o=t[2]-e[2];return[r[0]*n+r[1]*i+r[2]*o+e[0],r[3]*n+r[4]*i+r[5]*o+e[1],r[6]*n+r[7]*i+r[8]*o+e[2]]}function TSe(t,e,r){const n=[];for(let i=0;i<r.length;i+=3){const o=r.slice(i,i+3),a=SSe(o,e,t);n.push(...a)}return n}const _Se=Object.freeze(Object.defineProperty({__proto__:null,checkStandardBasis:CSe,inverse3x3Matrix:BW,rotatePoints:TSe},Symbol.toStringTag,{value:"Module"}));function GW(t,e,r){t.data.label=r,Kt(t,e,Bt.LabelChange)}function ESe(t,e){const{data:r}=t,{points:n}=r.handles,{focalPoint:i,viewPlaneNormal:o}=e.getCamera(),a=xt(hn(Ke(),n[0],i),o);return n.forEach(s=>{Hr(s,s,gr(Ke(),[-o[0],-o[1],-o[2]],a))}),e instanceof Jn&&(t.metadata.referencedImageId=e.getCurrentImageId()),t}function bSe(t,e,r){const n=e*r,i=t.length/n;if(![1,3,4].includes(i))throw new Error("Buffer must be 1, 3, or 4 channels per pixel");const o=Array.from({length:r},()=>new Array(e).fill(!1));for(let v=0;v<r;v++)for(let y=0;y<e;y++){const w=(v*e+y)*i;let x=!1;for(let C=0;C<Math.min(3,i);C++)if(t[w+C]>0){x=!0;break}o[v][y]=x}const a=Array.from({length:r},()=>new Array(e).fill(0));let s=0;const c={};for(let v=0;v<r;v++)for(let y=0;y<e;y++)if(o[v][y]&&a[v][y]===0){s++;const m=(C,S)=>C<0||C>=e||S<0||S>=r?!1:o[S][C]&&a[S][C]===0;let w=0;b8(m,[y,v],{onFlood:(C,S)=>{a[S][C]=s,w++},diagonals:!1}),c[s]=w}if(s===0)return[];const l=Object.keys(c).reduce((v,y)=>c[v]>c[y]?v:y);function f(v,y){if(a[y][v]!==+l)return!1;for(const[m,w]of[[1,0],[-1,0],[0,1],[0,-1]]){const x=v+m,C=y+w;if(x<0||x>=e||C<0||C>=r||a[C][x]!==+l)return!0}return!1}let u=null;e:for(let v=0;v<r;v++)for(let y=0;y<e;y++)if(f(y,v)){u=[y,v];break e}if(!u)return[];const d=[[1,0],[1,1],[0,1],[-1,1],[-1,0],[-1,-1],[0,-1],[1,-1]],h=[];let g=u,p=[u[0]-1,u[1]];do{h.push([g[0],g[1]]);const v=p[0]-g[0],y=p[1]-g[1];let m=d.findIndex(x=>x[0]===v&&x[1]===y);m<0&&(m=0);let w=null;for(let x=1;x<=8;x++){const[C,S]=d[(m+x)%8],T=g[0]+C,_=g[1]+S;if(T>=0&&T<e&&_>=0&&_<r&&f(T,_)){w=[T,_];const[E,b]=d[(m+x-1+8)%8];p=[g[0]+E,g[1]+b];break}}if(!w)break;g=w}while(g[0]!==u[0]||g[1]!==u[1]);return h}function DSe(t){const e=ZE(t,2),r=HU(e);return{simplified:e,hull:r}}function ISe(t,e=7){if(!t.length)throw new Error("Convex hull is empty");const r=t.length,n=y=>(y+1)%r,i=(y,m)=>{const w=[];for(let x=y;w.push(x),x!==m;x=n(x));return w};let o=0,a=0;for(let y=1;y<r;y++)t[y][0]<t[o][0]&&(o=y),t[y][0]>t[a][0]&&(a=y);const s=t[o],c=t[a],l=i(o,a),f=i(a,o),u=Math.min(...t.map(y=>y[1])),d=l.some(y=>t[y][1]===u)?l:f,h=Math.min(...d.map(y=>t[y][1]));let g=d.map(y=>t[y]).filter(y=>Math.abs(y[1]-h)<=e);g.length<2&&(g=d.map(y=>t[y]).sort((y,m)=>y[1]-m[1]).slice(0,2));const p=g.reduce((y,m)=>m[0]<y[0]?m:y,g[0]),v=g.reduce((y,m)=>m[0]>y[0]?m:y,g[0]);return{P1:p,P2:s,P3:c,P4:v}}function OSe(t,e,r,n,i,o={}){const{maxDist:a=15,slack:s=2}=o,c={P1:{dx:-1,dy:-1},P2:{dx:-1,dy:1},P3:{dx:1,dy:1},P4:{dx:1,dy:-1}};function l(f,{dx:u,dy:d},h=5){const g=u<0?f[0]-a:f[0]-s,p=u<0?f[0]+s:f[0]+a,v=d<0?f[1]-a:f[1]-s,y=d<0?f[1]+s:f[1]+a;let m=f;for(const[w,x]of i){if(w<g||w>p||x<v||x>y)continue;const C=Math.round(w),S=Math.round(x);if(C<0||C>=e||S<0||S>=r)continue;const T=(C-m[0])*u,_=(S-m[0])*d;t[S*e+C]>h&&(T>0||_>0)&&(m=[w,x])}return m}return{P1:l(n.P1,c.P1),P2:l(n.P2,c.P2),P3:l(n.P3,c.P3),P4:l(n.P4,c.P4)}}function MSe(t,e,r,n,i){const o=ISe(n);return OSe(t,e,r,o,i,{maxDist:20})}function l7(t,e){return Math.atan2(e[1]-t[1],e[0]-t[0])}function PSe(t){const{P1:e,P2:r,P3:n,P4:i}=t,o=l5(e,r,i,n,!0);if(!o)throw new Error("Fan edges appear parallel — no apex found");const a=o;let s=l7(a,e)*(180/Math.PI),c=l7(a,i)*(180/Math.PI);if(c<=s){const p=s;s=c,c=p}const l=Math.hypot(e[0]-a[0],e[1]-a[1]),f=Math.hypot(i[0]-a[0],i[1]-a[1]),u=Math.hypot(r[0]-a[0],r[1]-a[1]),d=Math.hypot(n[0]-a[0],n[1]-a[1]),h=Math.min(l,f),g=Math.max(u,d);return{center:a,startAngle:s,endAngle:c,innerRadius:h,outerRadius:g}}function rp(t,e,r,n,i={}){const{strokeStyle:o="#f00",lineWidth:a=2,quality:s=.92}=i,c=document.createElement("canvas");c.width=e,c.height=r;const l=c.getContext("2d"),f=e*r,u=t.length/f,d=l.createImageData(e,r),h=d.data;for(let g=0;g<f;g++){const p=g*u,v=g*4;if(u===1){const y=t[p];h[v]=y,h[v+1]=y,h[v+2]=y,h[v+3]=255}else h[v]=t[p],h[v+1]=t[p+1],h[v+2]=t[p+2],h[v+3]=u===4?t[p+3]:255}if(l.putImageData(d,0,0),n.length>0){l.strokeStyle=o,l.lineWidth=a,l.beginPath(),l.moveTo(n[0][0]+.5,n[0][1]+.5);for(let g=1;g<n.length;g++)l.lineTo(n[g][0]+.5,n[g][1]+.5);l.closePath(),l.stroke()}return c.toDataURL("image/jpeg",s)}function V8(t){const e=$e.getImage(t);if(!e)return;const r=e.width,n=e.height;return{pixelData:e.getPixelData(),width:r,height:n}}function WW(t,e){const r=document.createElement("a");r.href=t,r.download=e,document.body.appendChild(r),r.style.display="none",r.click(),r.remove()}function RSe(t,e,r,n,i={}){const{center:o,startAngle:a,endAngle:s,innerRadius:c,outerRadius:l}=n,{strokeStyle:f="#0ff",lineWidth:u=2,quality:d=.92}=i,h=a*Math.PI/180,g=s*Math.PI/180,p=document.createElement("canvas");p.width=e,p.height=r;const v=p.getContext("2d"),y=e*r,m=t.length/y,w=v.createImageData(e,r),x=w.data;for(let C=0;C<y;C++){const S=C*4;if(m===1){const T=t[C];x[S]=T,x[S+1]=T,x[S+2]=T,x[S+3]=255}else{const T=C*m;x[S]=t[T],x[S+1]=t[T+1],x[S+2]=t[T+2],x[S+3]=m===4?t[T+3]:255}}v.putImageData(w,0,0),v.beginPath();for(let C=h;C<=g;C+=.01){const S=o[0]+c*Math.cos(C),T=o[1]+c*Math.sin(C);C===h?v.moveTo(S,T):v.lineTo(S,T)}for(let C=g;C>=h;C-=.01){const S=o[0]+l*Math.cos(C),T=o[1]+l*Math.sin(C);v.lineTo(S,T)}return v.closePath(),v.strokeStyle=f,v.lineWidth=u,v.stroke(),p.toDataURL("image/jpeg",d)}function LSe(t,e=5){const{contour:r,simplified:n,hull:i,refined:o,fanGeometry:a}=F8(t),{pixelData:s,width:c,height:l}=V8(t)||{};if(!s)return;let f;e===1?f=rp(s,c,l,r):e===2?f=rp(s,c,l,n):e===3?f=rp(s,c,l,i):e===4?f=rp(s,c,l,[o.P1,o.P2,o.P3,o.P4]):f=RSe(s,c,l,a,{strokeStyle:"#f00",lineWidth:3,quality:.95}),WW(f,"contour.jpg")}function F8(t){const{pixelData:e,width:r,height:n}=V8(t)||{};if(!e)return;const i=bSe(e,r,n),{simplified:o,hull:a}=DSe(i),s=MSe(e,r,n,a,o),c=PSe({P1:s.P1,P2:s.P2,P3:s.P3,P4:s.P4});return{contour:i,simplified:o,hull:a,refined:s,fanGeometry:c}}const ASe=Object.freeze(Object.defineProperty({__proto__:null,calculateFanGeometry:F8,default:WW,downloadFanJpeg:LSe,exportContourJpeg:rp,getPixelData:V8},Symbol.toStringTag,{value:"Module"})),NSe=Xt,kSe=Object.freeze(Object.defineProperty({__proto__:null,AnnotationMultiSlice:Bwe,IslandRemoval:Pd,annotationHydration:E1e,boundingBox:Vwe,calibrateImageSpacing:kwe,cine:M3e,contourSegmentation:s2e,contours:vxe,debounce:Jh,drawing:uye,dynamicVolume:oSe,geometricSurfaceUtils:_Se,getAnnotationNearPoint:Lwe,getAnnotationNearPointOnEnabledElement:pG,getCalibratedAspect:u8,getCalibratedLengthUnitsAndScale:ya,getCalibratedProbeUnitsAndValue:p5,getClosestImageIdForStackViewport:WE,getOrCreateImageVolume:Jw,getPixelValueUnits:fu,getPixelValueUnitsImageId:EB,getSphereBoundsInfo:yG,getViewportForAnnotation:Uv,isObject:UE,math:Sme,moveAnnotationToViewPlane:ESe,normalizeViewportPlane:zG,orientation:C3e,planar:q2e,planarFreehandROITool:A3e,pointInSurroundingSphereCallback:ySe,pointToString:wG,polyDataUtils:aSe,rectangleROITool:N3e,roundNumber:NSe,segmentation:y3e,setAnnotationLabel:GW,stackContextPrefetch:J3e,stackPrefetch:$3e,throttle:Lo,touch:zpe,triggerAnnotationRender:Zh,triggerAnnotationRenderForToolGroupIds:xB,triggerAnnotationRenderForViewportIds:We,triggerEvent:it,usFanExtraction:ASe,viewport:Z3e,viewportFilters:jme,voi:vSe},Symbol.toStringTag,{value:"Module"})),VSe=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));function zW(t,e){const r=$n;t.forEach(n=>{r.updateSegmentation(n.segmentationId,n.payload),e||Ka(n.segmentationId)})}function FSe(t,e,r){$n.setSegmentationRepresentationVisibility(t,e,r)}function USe(t,e,r){const n=pa(t,e);n&&n.forEach(i=>{FSe(t,{segmentationId:i.segmentationId,type:i.type},r)})}function BSe(t,e){return TB(t,e)}function GSe(t,e,r,n){const i=pa(t,e);i&&(i.forEach(o=>{o.segments[r].visible=n}),Kw(e.segmentationId),Wc(t,e.segmentationId))}function WSe(t,e,r){return!$W(t,e).has(r)}function $W(t,e){const r=VE(t,e);return r?Object.entries(r.segments).reduce((i,[o,a])=>(a.visible||i.add(Number(o)),i),new Set):new Set}const zSe=Object.freeze(Object.defineProperty({__proto__:null,getHiddenSegmentIndices:$W,getSegmentIndexVisibility:WSe,getSegmentationRepresentationVisibility:BSe,setSegmentIndexVisibility:GSe,setSegmentationRepresentationVisibility:USe},Symbol.toStringTag,{value:"Module"}));function $Se(t){return Ua.getStyle(t)}function jSe(t,e){Ua.setStyle(t,e),!t.viewportId&&!t.segmentationId&&Yw().forEach(n=>{ng(n.segmentationId)}),Wc(t.viewportId,t.segmentationId,t.type)}function HSe(t,e){Ua.setRenderInactiveSegmentations(t,e),ng(t),OG(t).forEach(n=>{Wc(t,n.segmentationId)})}function KSe(t){return Ua.getRenderInactiveSegmentations(t)}function qSe(){Ua.resetToGlobalStyle(),ng()}function XSe(t){return Ua.hasCustomStyle(t)}const YSe=Object.freeze(Object.defineProperty({__proto__:null,getRenderInactiveSegmentations:KSe,getStyle:$Se,hasCustomStyle:XSe,resetToGlobalStyle:qSe,setRenderInactiveSegmentations:HSe,setStyle:jSe},Symbol.toStringTag,{value:"Module"})),JSe=Object.freeze(Object.defineProperty({__proto__:null,color:Wye,style:YSe,visibility:zSe},Symbol.toStringTag,{value:"Module"}));function T5(t,e){const r=_n(t);typeof e=="string"&&(console.warn("segmentIndex is a string, converting to number"),e=Number(e)),Object.values(r.segments).forEach(i=>{i.active=!1}),r.segments[e]||(r.segments[e]={segmentIndex:e,label:"",locked:!1,cachedStats:{},active:!1}),r.segments[e].active!==!0&&(r.segments[e].active=!0,Ka(t));const n=tg(t);n.forEach(i=>{pa(i,{segmentationId:t}).forEach(a=>{a.segments[e]||(a.segments[e]={visible:!0})})}),n.forEach(i=>{const o=vr(i);sW(o.id)})}const ZSe=Object.freeze(Object.defineProperty({__proto__:null,getActiveSegmentIndex:va,setActiveSegmentIndex:T5},Symbol.toStringTag,{value:"Module"}));async function QSe(t){const e=h1e(t);return Ka(t.segmentationId),e}function jW(t,e){const r=_n(t);if(r.representationData.Labelmap){const{representationData:n}=r,i=n.Labelmap;("imageIds"in i||"volumeId"in i)&&("imageIds"in i?i.imageIds.map(a=>$e.getImage(a)):[$e.getVolume(i.volumeId)]).forEach(a=>{if(!a)return;const{voxelManager:s}=a;s.forEach(({value:c,index:l})=>{c===e&&s.setAtIndex(l,0)})}),lo(t)}else throw new Error("Invalid segmentation type, only labelmap is supported right now")}function eTe(t,e,r={setNextSegmentAsActive:!0}){jW(t,e);const n=va(t)===e,i=_n(t),{segments:o}=i;delete o[e];const a={...o};if(zW([{segmentationId:t,payload:{segments:a}}]),n&&r.setNextSegmentAsActive){const c=Object.keys(o).map(Number).sort((d,h)=>d-h),l=c.indexOf(e),f=c[l+1],u=c[l-1];f!==void 0?T5(t,f):u!==void 0&&T5(t,u)}tg(t).forEach(c=>{pa(c,{segmentationId:t}).forEach(f=>{delete f.segments[e]})})}function tTe(t){const e=$n,r=_n(t);return e.getLabelmapImageIds(r.representationData)}const nTe={clearSegmentValue:jW,convertStackToVolumeLabelmap:QSe,computeVolumeLabelmapFromStack:yW,convertVolumeToStackLabelmap:f3e},rTe=Object.freeze(Object.defineProperty({__proto__:null,activeSegmentation:M2e,addContourRepresentationToViewport:O8,addContourRepresentationToViewportMap:a3e,addLabelmapRepresentationToViewport:mW,addLabelmapRepresentationToViewportMap:s3e,addRepresentationData:FE,addSegmentationRepresentations:sg,addSegmentations:CG,addSurfaceRepresentationToViewport:vW,addSurfaceRepresentationToViewportMap:c3e,config:JSe,defaultSegmentationStateManager:$n,getActiveSegmentation:Od,getCurrentLabelmapImageIdsForViewport:iu,getLabelmapImageIds:tTe,getLabelmapImageIdsForImageId:C2e,helpers:nTe,removeAllSegmentationRepresentations:_G,removeAllSegmentations:IG,removeContourRepresentation:bG,removeLabelmapRepresentation:EG,removeSegment:eTe,removeSegmentation:S8,removeSegmentationRepresentation:ig,removeSegmentationRepresentations:SG,removeSurfaceRepresentation:DG,segmentIndex:ZSe,segmentLocking:Uye,segmentationStyle:Ua,state:ixe,strategies:fCe,triggerSegmentationEvents:o1e,updateSegmentations:zW},Symbol.toStringTag,{value:"Module"}));class U8{constructor(e){this._controlPoints=[],this._invalidated=!1,this._length=0,this._controlPoints=[],this._resolution=(e==null?void 0:e.resolution)??20,this._fixedResolution=(e==null?void 0:e.fixedResolution)??!1,this._closed=(e==null?void 0:e.closed)??!1,this._invalidated=!0}get controlPoints(){return this._controlPoints}get numControlPoints(){return this._controlPoints.length}get resolution(){return this._resolution}set resolution(e){this._fixedResolution||this._resolution===e||(this._resolution=e,this.invalidated=!0)}get fixedResolution(){return this._fixedResolution}get closed(){return this._closed}set closed(e){this._closed!==e&&(this._closed=e,this.invalidated=!0)}get aabb(){return this._update(),this._aabb}get length(){return this._update(),this._length}get invalidated(){return this._invalidated}set invalidated(e){this._invalidated=e}hasTangentPoints(){return!1}addControlPoint(e){this._controlPoints.push([e[0],e[1]]),this.invalidated=!0}addControlPoints(e){e.forEach(r=>this.addControlPoint(r))}addControlPointAtU(e){const r=this._getLineSegmentAt(e),{start:n,end:i}=r.points,o=Math.floor(e),a=this._curveSegments[o],s=e-Math.floor(o),c=[n[0]+s*(i[0]-n[0]),n[1]+s*(i[1]-n[1])],l=this._controlPoints.indexOf(a.controlPoints.p1)+1;return this._controlPoints.splice(l,0,c),this.invalidated=!0,{index:l,point:c}}deleteControlPointByIndex(e){const r=this._closed?3:1;return e>=0&&e<this._controlPoints.length&&this._controlPoints.length>r?(this._controlPoints.splice(e,1),this.invalidated=!0,!0):!1}clearControlPoints(){this._controlPoints=[],this.invalidated=!0}setControlPoints(e){this.clearControlPoints(),this.addControlPoints(e)}updateControlPoint(e,r){if(e<0||e>=this._controlPoints.length)throw new Error("Index out of bounds");this._controlPoints[e]=[...r],this.invalidated=!0}getControlPoints(){return this._controlPoints.map(e=>[e[0],e[1]])}getClosestControlPoint(e){const r=this._controlPoints;let n=1/0,i=-1;for(let o=0,a=r.length;o<a;o++){const s=r[o],c=e[0]-s[0],l=e[1]-s[1],f=c*c+l*l;f<n&&(n=f,i=o)}return{index:i,point:i===-1?void 0:[...r[i]],distance:Math.sqrt(n)}}getClosestControlPointWithinDistance(e,r){const n=this.getClosestControlPoint(e);return n.distance<=r?n:void 0}getClosestPoint(e){this._update();const r=this._getCurveSegmmentsDistanceSquaredInfo(e);if(!r.length)return;r.sort((u,d)=>u.distanceSquared-d.distanceSquared);let n,i=-1,o=1/0,a,s;for(let u=0;u<r.length;u++){const d=r[u];if(d.distanceSquared>o)continue;const{curveSegmentIndex:h,curveSegment:g}=d,{lineSegments:p}=g;for(let v=0;v<p.length;v++){const y=p[v],{point:m,distanceSquared:w}=c5(y.points.start,y.points.end,e);w<o&&(s=y,i=h,a=d.curveSegment,n=m,o=w)}}const l=(s.previousLineSegmentsLength+Do(s.points.start,n))/a.length,f=i+l;return{point:n,uValue:f,distance:Math.sqrt(o)}}getClosestPointOnControlPointLines(e){const r=[...this._controlPoints];if(this._closed&&r.push(this._controlPoints[0]),!r.length)return;let n,i=1/0,o=r[0];for(let a=1,s=r.length;a<s;a++){const c=r[a],{point:l,distanceSquared:f}=c5(o,c,e);f<i&&(n=l,i=f),o=c}return{point:n,distance:Math.sqrt(i)}}getPolylinePoints(){return this._update(),this._convertCurveSegmentsToPolyline(this._curveSegments)}getPreviewPolylinePoints(e,r){if(this._closed)return[];this._update();const n=this.getClosestControlPointWithinDistance(e,r),i=(n==null?void 0:n.index)===0,o=this.getPreviewCurveSegments(e,i);return o!=null&&o.length?this._convertCurveSegmentsToPolyline(o):[]}isPointNearCurve(e,r){this._update();const n=this._getCurveSegmmentsWithinDistance(e,r),i=r*r;for(let o=0;o<n.length;o++){const{lineSegments:a}=n[o];for(let s=0;s<a.length;s++){const c=a[s];if(Tm(c.points.start,c.points.end,e)<=i)return!0}}return!1}containsPoint(e){if(this._update(),this._controlPoints.length<3)return!1;const n=[...this._curveSegments],i=this._getClosingCurveSegmentWithStraightLineSegment();i&&n.push(i);let o=0;for(let a=0;a<n.length;a++){const s=n[a],{aabb:c}=s;if(!(e[0]<=c.maxX&&e[1]>=c.minY&&e[1]<c.maxY))continue;const{lineSegments:f}=s;for(let u=0;u<f.length;u++){const d=f[u],{aabb:h}=d;if(e[0]<=h.maxX&&e[1]>=h.minY&&e[1]<h.maxY){const{start:p,end:v}=d.points,y=p[0]===v[0],m=(e[1]-p[1])*(v[0]-p[0])/(v[1]-p[1])+p[0];o+=y||e[0]<=m?1:0}}}return o%2===1}_update(){if(!this._invalidated)return;const e=this.getSplineCurves();let r=0,n=1/0,i=1/0,o=-1/0,a=-1/0;for(let s=0,c=e.length;s<c;s++){const{aabb:l,length:f}=e[s];n=n<=l.minX?n:l.minX,i=i<=l.minY?i:l.minY,o=o>=l.maxX?o:l.maxX,a=a>=l.maxY?a:l.maxY,r+=f}this._curveSegments=e,this._aabb={minX:n,minY:i,maxX:o,maxY:a},this._length=r,this._invalidated=!1}_convertCurveSegmentsToPolyline(e){this._update();const r=[];return e.forEach(({lineSegments:n},i)=>{n.forEach((o,a)=>{i===0&&a===0&&r.push([...o.points.start]),r.push([...o.points.end])})}),r}_getCurveSegmmentsDistanceSquaredInfo(e){this._update();const r=[],{_curveSegments:n}=this;for(let i=0;i<n.length;i++){const o=n[i],a=a5(o.aabb,e);r.push({curveSegmentIndex:i,curveSegment:o,distanceSquared:a})}return r}_getCurveSegmmentsWithinDistance(e,r){this._update();const n=r*r;if(a5(this.aabb,e)>n)return[];const i=this._getCurveSegmmentsDistanceSquaredInfo(e),o=[];for(let a=0,s=i.length;a<s;a++){const{curveSegment:c,distanceSquared:l}=i[a];l<=n&&o.push(c)}return o}_getLineSegmentAt(e){this._update();const r=Math.floor(e),n=e-r,i=this._curveSegments[r],{lineSegments:o}=i,a=i.length*n;for(let s=0;s<o.length;s++){const c=o[s],l=c.previousLineSegmentsLength+c.length;if(a>=c.previousLineSegmentsLength&&a<=l)return c}}_getClosingCurveSegmentWithStraightLineSegment(){if(this.closed)return;const e=this._controlPoints,r=e[0],n=e[e.length-1],i={points:{start:[...r],end:[...n]},aabb:{minX:Math.min(r[0],n[0]),minY:Math.min(r[1],n[1]),maxX:Math.max(r[0],n[0]),maxY:Math.max(r[1],n[1])}};return{aabb:{minX:i.aabb.minX,minY:i.aabb.minY,maxX:i.aabb.maxX,maxY:i.aabb.maxY},lineSegments:[i]}}}const iTe=1e-8;class B8 extends U8{getPreviewCurveSegments(e,r){const n=this._getNumCurveSegments()+1,i=Math.max(0,n-2),o=r?n:n-1,a=this.getTransformMatrix(),s=[...this.controlPoints],c=[];r||s.push(e);for(let l=i;l<=o;l++){const f=this._getCurveSegment(l,a,s,r);c.push(f)}return c}getSplineCurves(){const e=this._getNumCurveSegments(),r=new Array(e);if(e<=0)return[];const n=this.getTransformMatrix();let i=0;for(let o=0;o<e;o++){const a=this._getCurveSegment(o,n);a.previousCurveSegmentsLength=i,r[o]=a,i+=a.length}return r}_getNumCurveSegments(e=this.controlPoints,r=this.closed){return r?e.length:Math.max(0,e.length-1)}_getPoint(e,r,n=this.controlPoints,i=this.closed){const o=this._getNumCurveSegments(n,i),a=Math.floor(e);let s=a%o;const c=e-a;if(s<0||s>=o)if(this.closed)s=(o+s)%o;else return;const{p0:f,p1:u,p2:d,p3:h}=this._getCurveSegmentPoints(s,n,i),g=c*c,p=g*c,v=Sv(1,c,g,p),y=Vu(qR(),v,r);return[K6(y,Sv(f[0],u[0],d[0],h[0])),K6(y,Sv(f[1],u[1],d[1],h[1]))]}_getCurveSegmentPoints(e,r=this.controlPoints,n=this.closed){const i=this._getNumCurveSegments(r,n),o=e,a=o-1,s=n?(o+1)%i:o+1,c=s+1,l=r[o],f=r[s];let u,d;return a>=0?u=r[a]:u=n?r[r.length-1]:zS(f,l),c<r.length?d=r[c]:d=n?r[0]:zS(l,f),{p0:u,p1:l,p2:f,p3:d}}_getLineSegments(e,r,n=this.controlPoints,i=this.closed){const o=this._getNumCurveSegments(n,i),a=this.resolution+1,s=1/a,c=e;let l=c+1;!i&&e===o-1&&(l-=iTe);const f=[];let u,d,h=0;for(let g=0,p=c;g<=a;g++,p+=s){p=p>l?l:p;const v=this._getPoint(p,r,n,i);if(!g){u=v;continue}d=v;const y=d[0]-u[0],m=d[1]-u[1],w=Math.sqrt(y**2+m**2),x={minX:u[0]<=d[0]?u[0]:d[0],maxX:u[0]>=d[0]?u[0]:d[0],minY:u[1]<=d[1]?u[1]:d[1],maxY:u[1]>=d[1]?u[1]:d[1]};f.push({points:{start:u,end:d},aabb:x,length:w,previousLineSegmentsLength:h}),u=d,h+=w}return f}_getCurveSegment(e,r=this.getTransformMatrix(),n=this.controlPoints,i=this.closed){const{p0:o,p1:a,p2:s,p3:c}=this._getCurveSegmentPoints(e,n,i),l=this._getLineSegments(e,r,n,i);let f=0,u=1/0,d=1/0,h=-1/0,g=-1/0;return l.forEach(({aabb:p,length:v})=>{u=Math.min(u,p.minX),d=Math.min(d,p.minY),h=Math.max(h,p.maxX),g=Math.max(g,p.maxY),f+=v}),{controlPoints:{p0:o,p1:a,p2:s,p3:c},aabb:{minX:u,minY:d,maxX:h,maxY:g},length:f,previousCurveSegmentsLength:0,lineSegments:l}}}const oTe=$R(ma(),Q_(1,4,1,0,-3,0,3,0,3,-6,3,0,-1,3,-3,1),1/6);class HW extends B8{getTransformMatrix(){return oTe}}class B1 extends B8{constructor(e){super(e),this._scale=(e==null?void 0:e.scale)??.5,this._fixedScale=(e==null?void 0:e.fixedScale)??!1}get scale(){return this._scale}set scale(e){this._fixedScale||this._scale===e||(this._scale=e,this.invalidated=!0)}get fixedScale(){return this._fixedScale}getTransformMatrix(){const{scale:e}=this,r=2*e;return[0,1,0,0,-e,0,e,0,r,e-3,3-r,-e,-e,2-e,e-2,e]}}class KW extends B1{constructor(){super({scale:.5,fixedScale:!0})}}class qW extends B1{constructor(){super({resolution:0,fixedResolution:!0,scale:0,fixedScale:!0})}}class XW extends U8{getSplineCurves(){return[]}getLineSegments(){return[]}getPreviewCurveSegments(e,r){return[]}}const aTe=[1,0,0,-2,2,0,1,-2,1];class sTe extends XW{hasTangentPoints(){return!0}getTransformMatrix(){return aTe}}const cTe=Object.freeze(Object.defineProperty({__proto__:null,BSpline:HW,CardinalSpline:B1,CatmullRomSpline:KW,CubicSpline:B8,LinearSpline:qW,QuadraticBezier:sTe,QuadraticSpline:XW,Spline:U8},Symbol.toStringTag,{value:"Module"}));class ef extends ri{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"]}){super(e,r)}touchDragCallback(e){this._dragCallback(e)}mouseDragCallback(e){this._dragCallback(e)}_dragCallback(e){const{element:r,deltaPoints:n}=e.detail,i=Le(r),o=n.world;if(o[0]===0&&o[1]===0&&o[2]===0)return;const a=i.viewport.getCamera(),{focalPoint:s,position:c}=a,l=[c[0]-o[0],c[1]-o[1],c[2]-o[2]],f=[s[0]-o[0],s[1]-o[1],s[2]-o[2]];i.viewport.setCamera({focalPoint:f,position:l}),i.viewport.render()}}ef.toolName="Pan";class YW extends ri{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{rotateIncrementDegrees:2,rotateSampleDistanceFactor:2}}){super(e,r),this._resizeObservers=new Map,this._hasResolutionChanged=!1,this.preMouseDownCallback=n=>{const i=n.detail,{element:o}=i,a=Le(o),{viewport:s}=a,f=s.getDefaultActor().actor.getMapper();if(!("getSampleDistance"in f||"getCurrentSampleDistance"in f))return!0;const d=f.getSampleDistance();if(!this._hasResolutionChanged){const{rotateSampleDistanceFactor:h}=this.configuration;f.setSampleDistance(d*h),this._hasResolutionChanged=!0,this.cleanUp!==null&&document.removeEventListener("mouseup",this.cleanUp),this.cleanUp=()=>{f.setSampleDistance(d),s.render(),this._hasResolutionChanged=!1},document.addEventListener("mouseup",this.cleanUp,{once:!0})}return!0},this._getViewportsInfo=()=>jr(this.toolGroupId).viewportsInfo,this.onSetToolActive=()=>{const n=()=>{this._getViewportsInfo().forEach(({viewportId:o,renderingEngineId:a})=>{if(!this._resizeObservers.has(o)){const{viewport:s}=fi(o,a)||{viewport:null};if(!s)return;const{element:c}=s,l=new ResizeObserver(()=>{const f=fi(o,a);if(!f)return;const{viewport:u}=f,d=u.getViewPresentation();u.resetCamera(),u.setViewPresentation(d),u.render()});l.observe(c),this._resizeObservers.set(o,l)}})};n(),this._viewportAddedListener=i=>{i.detail.toolGroupId===this.toolGroupId&&n()},Ze.addEventListener(U.TOOLGROUP_VIEWPORT_ADDED,this._viewportAddedListener)},this.onSetToolDisabled=()=>{this._resizeObservers.forEach((n,i)=>{n.disconnect(),this._resizeObservers.delete(i)}),this._viewportAddedListener&&(Ze.removeEventListener(U.TOOLGROUP_VIEWPORT_ADDED,this._viewportAddedListener),this._viewportAddedListener=null)},this.rotateCamera=(n,i,o,a)=>{const s=n.getVtkActiveCamera(),c=s.getViewUp(),l=s.getFocalPoint(),f=s.getPosition(),u=[0,0,0],d=[0,0,0],h=[0,0,0],g=It(new Float32Array(16));er(g,g,i),To(g,g,a,o),er(g,g,[-i[0],-i[1],-i[2]]),At(u,f,g),At(d,l,g),It(g),To(g,g,a,o),At(h,c,g),n.setCamera({position:u,viewUp:h,focalPoint:d})},this.touchDragCallback=this._dragCallback.bind(this),this.mouseDragCallback=this._dragCallback.bind(this)}_dragCallback(e){const{element:r,currentPoints:n,lastPoints:i}=e.detail,o=n.canvas,a=i.canvas,{rotateIncrementDegrees:s}=this.configuration,c=Le(r),{viewport:l}=c,f=l.getCamera(),u=r.clientWidth,d=r.clientHeight,h=[o[0]/u,o[1]/d],g=[a[0]/u,a[1]/d],p=[u*.5,d*.5],v=l.canvasToWorld(p),m=(1+Math.abs([.5,.5][0]))**2,w=[g[0],0,0],x=[h[0],0,0],C=w[0]**2,S=x[0]**2,T=C>m?0:Math.sqrt(m-C),_=S>m?0:Math.sqrt(m-S),E=[w[0],0,T];Gt.normalize(E);const b=[x[0],0,_];Gt.normalize(b);const D=Gt.dot(E,b);if(Math.abs(D)>1e-4){const I=-2*Math.acos(Gt.clampValue(D,-1,1))*Math.sign(h[0]-g[0])*s,P=f.viewUp,O=f.viewPlaneNormal,L=[0,0,0],B=[0,0,0];Gt.cross(P,O,L),Gt.normalize(L),Gt.cross(O,L,B),Gt.normalize(B),Gt.normalize(P),this.rotateCamera(l,v,B,I);const H=(g[1]-h[1])*s;this.rotateCamera(l,v,L,H),l.render()}}}YW.toolName="TrackballRotate";const FC=4,lTe=1024,uTe="PT";class Mh extends ri{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"]}){super(e,r),this._getImageDynamicRangeFromMiddleSlice=(n,i)=>{const o=Math.floor(i[2]/2),a=i[0]*i[1];let s,c;n instanceof Float32Array?(s=4,c=Float32Array):n instanceof Uint8Array?(s=1,c=Uint8Array):n instanceof Uint16Array?(s=2,c=Uint16Array):n instanceof Int16Array&&(s=2,c=Int16Array);const l=n.buffer,f=o*a*s,u=new c(l,f,a),{max:d,min:h}=this._getMinMax(u,a);return d-h}}touchDragCallback(e){this.mouseDragCallback(e)}mouseDragCallback(e){var g,p;const{element:r,deltaPoints:n}=e.detail,i=Le(r),{viewport:o}=i;let a,s,c,l,f,u,d=!1;const h=o.getProperties();if(o instanceof Zn){a=o.getVolumeId(),u=cm(a),{lower:s,upper:c}=h.voiRange;const v=$e.getVolume(a);if(!v)throw new Error("Volume not found "+a);l=v.metadata.Modality,d=v.scaling&&Object.keys(v.scaling).length>0}else if(h.voiRange){l=o.modality,{lower:s,upper:c}=h.voiRange;const{preScale:v={scaled:!1}}=((g=o.getImageData)==null?void 0:g.call(o))||{};d=v.scaled&&((p=v.scalingParameters)==null?void 0:p.suvbw)!==void 0}else throw new Error("Viewport is not a valid type");if(l===uTe&&d?f=this.getPTScaledNewRange({deltaPointsCanvas:n.canvas,lower:s,upper:c,clientHeight:r.clientHeight,isPreScaled:d,viewport:o,volumeId:a}):f=this.getNewRange({viewport:o,deltaPointsCanvas:n.canvas,volumeId:a,lower:s,upper:c}),!(f.lower>=f.upper)&&(o.setProperties({voiRange:f}),o.render(),o instanceof Zn)){u.forEach(v=>{o!==v&&v.render()});return}}getPTScaledNewRange({deltaPointsCanvas:e,lower:r,upper:n,clientHeight:i,viewport:o,volumeId:a,isPreScaled:s}){let c=FC;s?c=5/i:c=this._getMultiplierFromDynamicRange(o,a)||FC;const f=e[1]*c;return n-=f,n=s?Math.max(n,.1):n,{lower:r,upper:n}}getNewRange({viewport:e,deltaPointsCanvas:r,volumeId:n,lower:i,upper:o}){const a=this._getMultiplierFromDynamicRange(e,n)||FC,s=r[0]*a,c=r[1]*a;let{windowWidth:l,windowCenter:f}=om(i,o);l+=s,f+=c,l=Math.max(l,1);const u=e.getProperties().VOILUTFunction;return Yu(l,f,u)}_getMultiplierFromDynamicRange(e,r){var o;let n;if(r){const a=$e.getVolume(r),{voxelManager:s}=e.getImageData(),l=s.getMiddleSliceData().reduce((d,h)=>[Math.min(d[0],h),Math.max(d[1],h)],[1/0,-1/0]),f=(o=a==null?void 0:a.metadata)==null?void 0:o.BitsStored,u=f?2**f:1/0;n=Math.min(l,u)}else n=this._getImageDynamicRangeFromViewport(e);const i=n/lTe;return i>1?Math.round(i):i}_getImageDynamicRangeFromViewport(e){const{imageData:r,voxelManager:n}=e.getImageData();if(n!=null&&n.getRange){const s=n.getRange();return s[1]-s[0]}const i=r.getDimensions();if(r.getRange){const s=r.getRange();return s[1]-s[0]}let o;if(r.getScalarData?o=r.getScalarData():o=r.getPointData().getScalars().getData(),i[2]!==1)return this._getImageDynamicRangeFromMiddleSlice(o,i);let a;if(o.getRange)a=o.getRange();else{const{min:s,max:c}=this._getMinMax(o,o.length);a=[s,c]}return a[1]-a[0]}_getMinMax(e,r){let n=1/0,i=-1/0;for(let o=0;o<r;o++){const a=e[o];a<n&&(n=a),a>i&&(i=a)}return{max:i,min:n}}}Mh.toolName="WindowLevel";class JW extends Yn{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{minWindowWidth:10}}){super(e,r),this.addNewAnnotation=n=>{const i=n.detail,{currentPoints:o,element:a}=i,s=o.world,c=Le(a),{viewport:l}=c;this.isDrawing=!0;const f=l.getCamera(),{viewPlaneNormal:u,viewUp:d}=f,h=this.getReferencedImageId(l,s,u,d),g=l.getFrameOfReferenceUID(),p={invalidated:!0,highlighted:!0,metadata:{toolName:this.getToolName(),viewPlaneNormal:[...u],viewUp:[...d],FrameOfReferenceUID:g,referencedImageId:h},data:{handles:{points:[[...s],[...s],[...s],[...s]]},cachedStats:{}}};qt(p,a);const v=wt(a,this.getToolName());return this.editData={annotation:p,viewportIdsToRender:v},this._activateDraw(a),Dt(a),n.preventDefault(),We(v),p},this._endCallback=n=>{const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s}=this.editData;this._deactivateDraw(o),kt(o),this.editData=null,this.isDrawing=!1,en(a.annotationUID),We(s),bn(a),this.applyWindowLevelRegion(a,o)},this._dragCallback=n=>{this.isDrawing=!0;const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s}=this.editData,{data:c}=a,{currentPoints:l}=i,f=Le(o),{worldToCanvas:u,canvasToWorld:d}=f.viewport,h=l.world,{points:g}=c.handles,p=3;g[p]=[...h];const v=u(g[0]),y=u(g[3]),m=[y[0],v[1]],w=[v[0],y[1]],x=d(m),C=d(w);g[1]=x,g[2]=C,a.invalidated=!0,We(s)},this._activateDraw=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragCallback),n.addEventListener(U.MOUSE_MOVE,this._dragCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback)},this._deactivateDraw=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragCallback),n.removeEventListener(U.MOUSE_MOVE,this._dragCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.TOUCH_END,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback)},this.renderAnnotation=(n,i)=>{let o=!1;const{viewport:a}=n,{element:s}=a;let c=Jt(this.getToolName(),s);if(!(c!=null&&c.length)||(c=this.filterInteractableAnnotationsForElement(s,c),!(c!=null&&c.length)))return o;const l={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:n.viewport.id};for(let f=0;f<c.length;f++){const u=c[f],{annotationUID:d,data:h}=u,{points:g}=h.handles,p=g.map(C=>a.worldToCanvas(C));l.annotationUID=d;const{color:v,lineWidth:y,lineDash:m}=this.getAnnotationStyle({annotation:u,styleSpecifier:l});if(!a.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),o;const w=`${d}-rect`;bm(i,d,"0",p[0],p[3],{color:v,lineDash:m,lineWidth:y},w),o=!0}return o},this.applyWindowLevelRegion=(n,i)=>{const o=Le(i),{viewport:a}=o,s=FW(a),{data:c}=n,{points:l}=c.handles,f=l.map(T=>a.worldToCanvas(T)),u=f[0],d=f[3];let h=Math.min(u[0],d[0]),g=Math.min(u[1],d[1]),p=Math.abs(u[0]-d[0]),v=Math.abs(u[1]-d[1]);h=Hy(h,0,s.width),g=Hy(g,0,s.height),p=Math.floor(Math.min(p,Math.abs(s.width-h))),v=Math.floor(Math.min(v,Math.abs(s.height-g)));const y=kW(s,Math.round(h),Math.round(g),p,v),m=VW(y,s.minPixelValue,s.maxPixelValue);this.configuration.minWindowWidth===void 0&&(this.configuration.minWindowWidth=10);const w=Math.max(Math.abs(m.max-m.min),this.configuration.minWindowWidth),x=m.mean,C=a.getProperties().VOILUTFunction,S=Yu(w,x,C);a.setProperties({voiRange:S}),a.render()},this.cancel=()=>null,this.isPointNearTool=()=>null,this.toolSelectedCallback=()=>null,this.handleSelectedCallback=()=>null,this._activateModify=()=>null,this._deactivateModify=()=>null}}JW.toolName="WindowLevelRegion";class Ld extends ri{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{invert:!1,debounceIfNotLoaded:!0,loop:!1}}){super(e,r),this.deltaY=1}mouseWheelCallback(e){this._scroll(e)}mouseDragCallback(e){this._dragCallback(e)}touchDragCallback(e){this._dragCallback(e)}_dragCallback(e){this._scrollDrag(e)}_scrollDrag(e){const{deltaPoints:r,viewportId:n,renderingEngineId:i}=e.detail,{viewport:o}=fi(n,i),{debounceIfNotLoaded:a,invert:s,loop:c}=this.configuration,l=r.canvas[1];let f;o instanceof Zn&&(f=o.getVolumeId());const u=this._getPixelPerImage(o),d=l+this.deltaY;if(u)if(Math.abs(d)>=u){const h=Math.round(d/u);oc(o,{delta:s?-h:h,volumeId:f,debounceLoading:a,loop:c}),this.deltaY=d%u}else this.deltaY=d}_scroll(e){const{wheel:r,element:n}=e.detail,{direction:i}=r,{invert:o}=this.configuration,{viewport:a}=Le(n),s=i*(o?-1:1);oc(a,{delta:s,debounceLoading:this.configuration.debounceIfNotLoaded,loop:this.configuration.loop,volumeId:a instanceof fr?a.getVolumeId():void 0,scrollSlabs:this.configuration.scrollSlabs})}_getPixelPerImage(e){const{element:r}=e,n=e.getNumberOfSlices();return Math.max(2,r.offsetHeight/Math.max(n,8))}}Ld.toolName="StackScroll";class Ph extends ri{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"]}){super(e,r),this.mouseWheelCallback=n=>{const{element:i,wheel:o}=n.detail,a=Le(i),{viewport:s}=a,{invert:c}=this.configuration,l=o.direction*10*(c?-1:1);this.setAngle(s,l)},this.touchDragCallback=this._dragCallback.bind(this),this.mouseDragCallback=this._dragCallback.bind(this)}_dragCallback(e){const{element:r,currentPoints:n,startPoints:i}=e.detail,o=n.world,a=i.world,s=Le(r),{viewport:c}=s,l=c.getCamera(),f=r.clientWidth,u=r.clientHeight,d=[f*.5,u*.5],h=c.canvasToWorld(d);let g=ah([a,h],[h,o]);const{viewPlaneNormal:p}=l,v=hn(Ke(),h,a),y=hn(Ke(),h,o),m=Tn(Ke(),v,y);xt(p,m)>0&&(g=-g),!Number.isNaN(g)&&this.setAngle(c,g)}setAngle(e,r){const{viewPlaneNormal:n,viewUp:i}=e.getCamera();if(e instanceof fr){const o=(r+360)%360*Math.PI/180,a=It(new Float32Array(16));To(a,a,o,n);const s=At(Ke(),i,a);e.setCamera({viewUp:s})}else{const{rotation:o}=e.getViewPresentation();e.setViewPresentation({rotation:(o+r+360)%360})}e.render()}}Ph.toolName="PlanarRotate";class Wl extends ri{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{zoomToCenter:!1,minZoomScale:.001,maxZoomScale:3e3,pinchToZoom:!0,pan:!0,invert:!1}}){super(e,r),this.preMouseDownCallback=n=>{const i=n.detail,{element:o,currentPoints:a}=i,s=a.world,l=Le(o).viewport.getCamera(),{focalPoint:f}=l;this.initialMousePosWorld=s;let u=Tt(f[0]-s[0],f[1]-s[1],f[2]-s[2]);return u=Un(Ke(),u),this.dirVec=u,!1},this.preTouchStartCallback=n=>{if(!this.configuration.pinchToZoom)return this.preMouseDownCallback(n)},this._dragParallelProjection=(n,i,o,a=!1)=>{var T,_,E;const{element:s,deltaPoints:c}=n.detail,l=a?n.detail.deltaDistance.canvas:c.canvas[1],f=[s.clientWidth,s.clientHeight],{parallelScale:u,focalPoint:d,position:h}=o,g=5/f[1],p=l*g*(this.configuration.invert?-1:1),v=(1-p)*u;let y=d,m=h;if(!this.configuration.zoomToCenter){const b=Fi(d,this.initialMousePosWorld);m=dn(Ke(),h,this.dirVec,-b*p),y=dn(Ke(),d,this.dirVec,-b*p)}const w=i.getImageData();let x=[1,1,1],C=v,S=!1;if(w){x=w.spacing;const{dimensions:b}=w,D=b[0]*x[0],I=b[1]*x[1],P=f[0]/f[1],O=(T=i.options)==null?void 0:T.displayArea,L=((_=O==null?void 0:O.imageArea)==null?void 0:_[0])??1.1,B=((E=O==null?void 0:O.imageArea)==null?void 0:E[1])??1.1,H=D*L,A=I*B,F=H/A;let G;F>P?G=H/P*.5:G=A*.5;const{minZoomScale:X,maxZoomScale:ee}=this.configuration,ce=G/ee,Se=G/X;v<ce?(C=ce,S=!0):v>Se&&(C=Se,S=!0)}i.setCamera({parallelScale:C,focalPoint:S?d:y,position:S?h:m})},this._dragPerspectiveProjection=(n,i,o,a=!1)=>{const{element:s,deltaPoints:c}=n.detail,l=a?n.detail.deltaDistance.canvas:c.canvas[1],f=[s.clientWidth,s.clientHeight],{position:u,focalPoint:d,viewPlaneNormal:h}=o,g=Gt.distance2BetweenPoints(u,d),p=Math.sqrt(g)/f[1],v=[-h[0],-h[1],-h[2]],y=this.configuration.invert?l/p:l*p;let m=y*v[0];u[0]+=m,d[0]+=m,m=y*v[1],u[1]+=m,d[1]+=m,m=y*v[2],u[2]+=m,d[2]+=m,i.setCamera({position:u,focalPoint:d})},this.initialMousePosWorld=[0,0,0],this.dirVec=[0,0,0],this.configuration.pinchToZoom?this.touchDragCallback=this._pinchCallback.bind(this):this.touchDragCallback=this._dragCallback.bind(this),this.mouseDragCallback=this._dragCallback.bind(this)}mouseWheelCallback(e){this._zoom(e)}_pinchCallback(e){if(e.detail.currentPointsList.length>1){const{element:n,currentPoints:i}=e.detail,o=Le(n),{viewport:a}=o,s=a.getCamera(),c=i.world,{focalPoint:l}=s;this.initialMousePosWorld=c;let f=Tt(l[0]-c[0],l[1]-c[1],l[2]-c[2]);f=Un(Ke(),f),this.dirVec=f,s.parallelProjection?this._dragParallelProjection(e,a,s,!0):this._dragPerspectiveProjection(e,a,s,!0),a.render()}this.configuration.pan&&this._panCallback(e)}_dragCallback(e){const{element:r}=e.detail,n=Le(r),{viewport:i}=n,o=i.getCamera();o.parallelProjection?this._dragParallelProjection(e,i,o):this._dragPerspectiveProjection(e,i,o),i.render()}_zoom(e){const{element:r,points:n}=e.detail,i=Le(r),{viewport:o}=i;o.getCamera();const s=e.detail.wheel.direction,c={detail:{element:r,eventName:U.MOUSE_WHEEL,renderingEngineId:i.renderingEngineId,viewportId:o.id,camera:{},deltaPoints:{page:n.page,client:n.client,world:n.world,canvas:[0,-s*5]},startPoints:n,lastPoints:n,currentPoints:n}};o.type===ir.STACK&&this.preMouseDownCallback(c),this._dragCallback(c)}_panCallback(e){const{element:r,deltaPoints:n}=e.detail,i=Le(r),o=n.world,a=i.viewport.getCamera(),{focalPoint:s,position:c}=a,l=[c[0]-o[0],c[1]-o[1],c[2]-o[2]],f=[s[0]-o[0],s[1]-o[1],s[2]-o[2]];i.viewport.setCamera({focalPoint:f,position:l}),i.viewport.render()}}Wl.toolName="Zoom";class ZW extends ri{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{targetViewportIds:[]}}){super(e,r)}mouseClickCallback(e){const{element:r,currentPoints:n}=e.detail,i=Le(r),{viewport:o,renderingEngine:a}=i,s=o.getVolumeId();if(!s)throw new Error("MIPJumpToClickTool: targetId is not a volumeId, you should only use MIPJumpToClickTool with a volumeId as the targetId");let c=-1/0;const l=(g,p)=>{if(g>c)return c=g,p},f=f8(o,n.world,s,l);if(!f||!f.length)return;const{targetViewportIds:u,toolGroupId:d}=this.configuration;a.getViewports().filter(g=>{if((u==null?void 0:u.indexOf(g.id))>=0)return!0;const p=vr(g.id,a.id);return!!(d&&d===(p==null?void 0:p.id))}).forEach(g=>{g instanceof Zn?g.jumpToWorld(f):console.warn("Cannot jump to specified world coordinates for a viewport that is not a VolumeViewport")})}}ZW.toolName="MIPJumpToClickTool";const{RENDERING_DEFAULTS:UC}=xf;function fTe(){return"rgb(0, 200, 0)"}function dTe(){return!0}function hTe(){return!0}function gTe(){return!0}const Ws={DRAG:1,ROTATE:2,SLAB:3};class Uc extends Yn{constructor(e={},r={supportedInteractionTypes:["Mouse"],configuration:{shadow:!0,viewportIndicators:!1,viewportIndicatorsConfig:{radius:5,x:null,y:null},autoPan:{enabled:!1,panSize:10},handleRadius:3,enableHDPIHandles:!1,referenceLinesCenterGapRadius:20,filterActorUIDsToSetSlabThickness:[],slabThicknessBlendMode:Hc.MAXIMUM_INTENSITY_BLEND,mobile:{enabled:!1,opacity:.8,handleRadius:9}}}){var n,i,o,a;super(e,r),this.toolCenter=[0,0,0],this.initializeViewport=({renderingEngineId:s,viewportId:c})=>{const l=fi(c,s);if(!l)return;const{FrameOfReferenceUID:f,viewport:u}=l,{element:d}=u,{position:h,focalPoint:g,viewPlaneNormal:p}=u.getCamera();let v=this._getAnnotations(l);v=this.filterInteractableAnnotationsForElement(d,v),v!=null&&v.length&&en(v[0].annotationUID);const y={highlighted:!1,metadata:{cameraPosition:[...h],cameraFocalPoint:[...g],FrameOfReferenceUID:f,toolName:this.getToolName()},data:{handles:{rotationPoints:[],slabThicknessPoints:[],toolCenter:this.toolCenter},activeOperation:null,activeViewportIds:[],viewportId:c}};return qt(y,d),{normal:p,point:u.canvasToWorld([u.canvas.clientWidth/2,u.canvas.clientHeight/2])}},this._getViewportsInfo=()=>jr(this.toolGroupId).viewportsInfo,this.resetCrosshairs=()=>{const s=this._getViewportsInfo();for(const c of s){const{viewportId:l,renderingEngineId:f}=c,u=fi(l,f),d=u.viewport;d.resetCamera({resetPan:!0,resetZoom:!0,resetToCenter:!0,resetRotation:!0,suppressEvents:!0}),d.resetSlabThickness();const{element:m}=d;let w=this._getAnnotations(u);w=this.filterInteractableAnnotationsForElement(m,w),w.length&&en(w[0].annotationUID),d.render()}this._computeToolCenter(s)},this.computeToolCenter=()=>{const s=this._getViewportsInfo();this._computeToolCenter(s)},this._computeToolCenter=s=>{if(!s.length||s.length===1){console.warn("For crosshairs to operate, at least two viewports must be given.");return}const[c,l,f]=s,{normal:u,point:d}=this.initializeViewport(c),{normal:h,point:g}=this.initializeViewport(l);let p=[0,0,0],v=Ke();f?{normal:p,point:v}=this.initializeViewport(f):(Hr(v,d,g),gr(v,v,.5),Tn(p,u,h));const y=Yc(u,d),m=Yc(h,g),w=Yc(p,v),x=bk(y,m,w);this.setToolCenter(x)},this.addNewAnnotation=s=>{const c=s.detail,{element:l}=c,{currentPoints:f}=c,u=f.world,d=Le(l),{viewport:h}=d;this._jump(d,u);const g=this._getAnnotations(d),p=this.filterInteractableAnnotationsForElement(h.element,g),{data:v}=p[0],{rotationPoints:y}=v.handles,m=[];for(let w=0;w<y.length-1;++w){const x=y[w][1],C=this._getReferenceLineControllable(x.id),S=this._getReferenceLineDraggableRotatable(x.id);!C||!S||(m.push(x.id),w++)}return v.activeViewportIds=[...m],v.handles.activeOperation=Ws.DRAG,s.preventDefault(),Dt(l),this._activateModify(l),p[0]},this.cancel=()=>{console.log("Not implemented yet")},this.handleSelectedCallback=(s,c)=>{const l=s.detail,{element:f}=l;c.highlighted=!0,this._activateModify(f),Dt(f),s.preventDefault()},this.isPointNearTool=(s,c,l,f)=>!!this._pointNearTool(s,c,l,6),this.toolSelectedCallback=(s,c,l)=>{const f=s.detail,{element:u}=f;c.highlighted=!0,this._activateModify(u),Dt(u),s.preventDefault()},this.onCameraModified=s=>{var E;const c=s.detail,{element:l}=c,f=Le(l),{renderingEngine:u}=f,d=f.viewport,h=this._getAnnotations(f),p=this.filterInteractableAnnotationsForElement(l,h)[0];if(!p)return;const v=d.getCamera(),y=p.metadata.cameraPosition,m=[0,0,0];Gt.subtract(v.position,y,m);const w=p.metadata.cameraFocalPoint,x=[0,0,0];Gt.subtract(v.focalPoint,w,x),p.metadata.cameraPosition=[...v.position],p.metadata.cameraFocalPoint=[...v.focalPoint];const C=this._getReferenceLineControllable(d.id),S=this._getReferenceLineDraggableRotatable(d.id);if(!Vt(v.position,y,.001)&&C&&S){let b=!1;Vt(m,x,.001)||(b=!0);const I=Math.abs(Gt.dot(m,v.viewPlaneNormal))<.01;!b&&!I&&(this.toolCenter[0]+=m[0],this.toolCenter[1]+=m[1],this.toolCenter[2]+=m[2],it(Ze,U.CROSSHAIR_TOOL_CENTER_CHANGED,{toolGroupId:this.toolGroupId,toolCenter:this.toolCenter}))}(E=this.configuration.autoPan)!=null&&E.enabled&&vr(d.id,u.id).getViewportIds().filter(I=>I!==d.id).forEach(I=>{this._autoPanViewportIfNecessary(I,u)});const _=wt(l,this.getToolName(),!1);We(_)},this.onResetCamera=s=>{this.resetCrosshairs()},this.mouseMoveCallback=(s,c)=>{const{element:l,currentPoints:f}=s.detail,u=f.canvas;let d=!1;for(let h=0;h<c.length;h++){const g=c[h];if(Yr(g.annotationUID))continue;const{data:p,highlighted:v}=g;if(!p.handles)continue;const y=p.handles.activeOperation,m=p.activeViewportIds&&p.activeViewportIds.length>0?[...p.activeViewportIds]:[];p.activeViewportIds=[],p.handles.activeOperation=null;const w=this.getHandleNearImagePoint(l,g,u,6);let x=!1;w?x=!0:x=this._pointNearTool(l,g,u,6),x&&!v||!x&&v?(g.highlighted=!v,d=!0):(p.handles.activeOperation!==y||!this._areViewportIdArraysEqual(p.activeViewportIds,m))&&(d=!0)}return d},this.filterInteractableAnnotationsForElement=(s,c)=>{if(!c||!c.length)return[];const l=Le(s),{viewportId:f}=l;return c.filter(d=>d.data.viewportId===f)},this.renderAnnotation=(s,c)=>{let l=!1;const{viewport:f,renderingEngine:u}=s,{element:d}=f,h=this._getAnnotations(s),g=f.getCamera(),v=this.filterInteractableAnnotationsForElement(d,h)[0];if(!(h!=null&&h.length)||!(v!=null&&v.data))return l;const y=v.annotationUID,{clientWidth:m,clientHeight:w}=f.canvas,x=Math.sqrt(m*m+w*w),C=Math.min(m,w),S=v.data,T=f.worldToCanvas(this.toolCenter),_=this._filterAnnotationsByUniqueViewportOrientations(s,h),E=[],b=[0,0,m,w];_.forEach(L=>{const{data:B}=L;B.handles.toolCenter=this.toolCenter;const H=u.getViewport(B.viewportId),A=H.getCamera(),F=this._getReferenceLineControllable(H.id),G=this._getReferenceLineDraggableRotatable(H.id),X=this._getReferenceLineSlabThicknessControlsOn(H.id),{clientWidth:ee,clientHeight:ce}=H.canvas,Se=Math.sqrt(ee*ee+ce*ce),we=[ee*.5,ce*.5],_e=H.canvasToWorld(we),Ve=[0,0,0];Gt.cross(g.viewPlaneNormal,A.viewPlaneNormal,Ve),Gt.normalize(Ve),Gt.multiplyScalar(Ve,Se);const Ge=[0,0,0];Gt.add(_e,Ve,Ge);const Ne=[0,0,0];Gt.subtract(_e,Ve,Ne);const j=f.worldToCanvas(Ge),M=f.worldToCanvas(_e),q=Wt();Br(q,j,M),Ul(q,q);const K=Wt();Al(K,q,x*100);const J=Wt();Al(J,q,C*.4);const re=Wt();Al(re,q,C*.2);const ie=Wt(),Re=this.configuration.referenceLinesCenterGapRadius;Al(ie,q,_.length===2?Re:0);const Fe=Wt(),je=Wt(),Xe=Wt(),se=Wt();let ue=e2(T);(!G||!F)&&(ue=e2(M)),no(Fe,ue,ie),no(je,ue,K),Br(Xe,ue,ie),Br(se,ue,K),tp(Fe,je,b),tp(Xe,se,b);const Pe=Wt();Br(Pe,T,J);const pe=Wt();no(pe,T,J);let Ee=e2(T);!G&&X&&(Ee=e2(M));let Qe=[...this.toolCenter];!G&&X&&(Qe=[..._e]);const fe=[0,0,0];Gt.subtract(Ge,Ne,fe),Gt.normalize(fe);const{viewPlaneNormal:ft}=g,{matrix:pt}=Ni.buildFromDegree().rotate(90,ft),dt=[0,0,0];At(dt,fe,pt);const Ue=H.getSlabThickness(),nt=[...dt];Gt.multiplyScalar(nt,Ue);const at=[0,0,0];Gt.add(Qe,nt,at);const ot=f.worldToCanvas(at),lt=Wt();Br(lt,Ee,ot);const _t=Wt();Br(_t,Ee,K),no(_t,_t,lt);const vt=Wt();no(vt,Ee,K),no(vt,vt,lt),tp(_t,vt,b);const Mt=Wt();no(Mt,Ee,K),Br(Mt,Mt,lt);const Ft=Wt();Br(Ft,Ee,K),Br(Ft,Ft,lt),tp(Mt,Ft,b);const wn=Wt(),Dn=Wt(),Nt=Wt(),xn=Wt();Br(wn,Ee,re),no(wn,wn,lt),no(Dn,Ee,re),no(Dn,Dn,lt),Br(Nt,Ee,re),Br(Nt,Nt,lt),no(xn,Ee,re),Br(xn,xn,lt),E.push([H,Fe,je,Xe,se,_t,vt,Mt,Ft,Pe,pe,wn,Dn,Nt,xn])});const D=[],I=[],P=this._getReferenceLineColor(f.id),O=P!==void 0?P:"rgb(200, 200, 200)";if(E.forEach((L,B)=>{var Ve,Ge,Ne,j;const H=L[0],A=this._getReferenceLineColor(H.id),F=this._getReferenceLineControllable(H.id),G=this._getReferenceLineDraggableRotatable(H.id)||((Ve=this.configuration.mobile)==null?void 0:Ve.enabled),X=this._getReferenceLineSlabThicknessControlsOn(H.id)||((Ge=this.configuration.mobile)==null?void 0:Ge.enabled),ee=S.activeViewportIds.find(M=>M===H.id);let ce=A!==void 0?A:"rgb(200, 200, 200)",Se=1;const we=S.handles.activeOperation!==null&&S.handles.activeOperation===Ws.DRAG&ⅇwe&&(Se=2.5);let _e=`${B}`;if(F&&G?(_e=`${B}One`,an(c,y,_e,L[1],L[2],{color:ce,lineWidth:Se}),_e=`${B}Two`,an(c,y,_e,L[3],L[4],{color:ce,lineWidth:Se})):an(c,y,_e,L[2],L[4],{color:ce,lineWidth:Se}),F){ce=A!==void 0?A:"rgb(200, 200, 200)";const M=S.handles.activeOperation===Ws.ROTATE,q=[L[9],L[10]],K=[f.canvasToWorld(L[9]),H,L[1],L[2]],J=[f.canvasToWorld(L[10]),H,L[3],L[4]];D.push(K,J);const re=S.handles.activeOperation===Ws.SLAB,ie=[L[11],L[12],L[13],L[14]],Re=[f.canvasToWorld(L[11]),H,L[5],L[6]],Fe=[f.canvasToWorld(L[12]),H,L[5],L[6]],je=[f.canvasToWorld(L[13]),H,L[7],L[8]],Xe=[f.canvasToWorld(L[14]),H,L[7],L[8]];I.push(Re,Fe,je,Xe);let se=this.configuration.handleRadius*(this.configuration.enableHDPIHandles?window.devicePixelRatio:1),ue=1;if((Ne=this.configuration.mobile)!=null&&Ne.enabled&&(se=this.configuration.mobile.handleRadius,ue=this.configuration.mobile.opacity),(we||(j=this.configuration.mobile)!=null&&j.enabled)&&!M&&!re&&G&&X){let pe=`${B}One`;Kn(c,y,pe,q,{color:ce,handleRadius:se,opacity:ue,type:"circle"}),pe=`${B}Two`,Kn(c,y,pe,ie,{color:ce,handleRadius:se,opacity:ue,type:"rect"})}else if(we&&!M&&!re&&G){const pe=`${B}`;Kn(c,y,pe,q,{color:ce,handleRadius:se,opacity:ue,type:"circle"})}else if(ee&&!M&&!re&&X){const pe=`${B}`;Kn(c,y,pe,ie,{color:ce,handleRadius:se,opacity:ue,type:"rect"})}else if(M&&G){const pe=`${B}`,Ee=this.configuration.handleRadius*(this.configuration.enableHDPIHandles?window.devicePixelRatio:1);Kn(c,y,pe,q,{color:ce,handleRadius:Ee,fill:ce,type:"circle"})}else if(re&&ee&&X){const pe=this.configuration.handleRadius*(this.configuration.enableHDPIHandles?window.devicePixelRatio:1);Kn(c,y,_e,ie,{color:ce,handleRadius:pe,fill:ce,type:"rect"})}H.getSlabThickness()>.5&&X&&(_e=`${B}STOne`,an(c,y,_e,L[5],L[6],{color:ce,width:1,lineDash:[2,3]}),_e=`${B}STTwo`,an(c,y,_e,L[7],L[8],{color:ce,width:L,lineDash:[2,3]}))}}),l=!0,S.handles.rotationPoints=D,S.handles.slabThicknessPoints=I,this.configuration.viewportIndicators){const{viewportIndicatorsConfig:L}=this.configuration,B=(L==null?void 0:L.xOffset)||.95,H=(L==null?void 0:L.yOffset)||.05,A=[m*B,w*H],F=(L==null?void 0:L.circleRadius)||x*.01;Yo(c,y,"0",A,F,{color:O,fill:O})}return l},this._getAnnotations=s=>{const{viewport:c}=s,l=Jt(this.getToolName(),c.element)||[],f=this._getViewportsInfo().map(({viewportId:d})=>d);return l.filter(d=>{const{data:h}=d;return f.includes(h.viewportId)})},this._onNewVolume=()=>{const s=this._getViewportsInfo();this._computeToolCenter(s)},this._areViewportIdArraysEqual=(s,c)=>s.length!==c.length?!1:(s.forEach(l=>{let f=!1;for(let u=0;u<c.length;++u)if(l===c[u]){f=!0;break}if(f===!1)return!1}),!0),this._getAnnotationsForViewportsWithDifferentCameras=(s,c)=>{const{viewportId:l,renderingEngine:f,viewport:u}=s,d=c.filter(y=>y.data.viewportId!==l);if(!d||!d.length)return[];const h=u.getCamera(),{viewPlaneNormal:g,position:p}=h;return d.filter(y=>{const{viewportId:m}=y.data,x=f.getViewport(m).getCamera();return!(Vt(x.viewPlaneNormal,g,.01)&&Vt(x.position,p,1))})},this._filterViewportWithSameOrientation=(s,c,l)=>{const{renderingEngine:f}=s,{data:u}=c,d=f.getViewport(u.viewportId),h=l.filter(y=>{const{data:m}=y,w=f.getViewport(m.viewportId);return this._getReferenceLineControllable(w.id)===!0});if(!h||!h.length)return[];const g=d.getCamera(),p=g.viewPlaneNormal;return Gt.normalize(p),h.filter(y=>{const{viewportId:m}=y.data,x=f.getViewport(m).getCamera(),C=x.viewPlaneNormal;return Gt.normalize(C),Vt(p,C,.01)&&Vt(g.viewUp,x.viewUp,.01)})},this._filterAnnotationsByUniqueViewportOrientations=(s,c)=>{const{renderingEngine:l,viewport:f}=s,d=f.getCamera().viewPlaneNormal;Gt.normalize(d);const h=c.filter(y=>{const{data:m}=y,w=l.getViewport(m.viewportId),x=this._getReferenceLineControllable(w.id);return f!==w&&x===!0}),g=[];for(let y=0;y<h.length;++y){const m=h[y],{viewportId:w}=m.data,C=l.getViewport(w).getCamera(),S=C.viewPlaneNormal;if(Gt.normalize(S),Vt(d,S,.01)||ep(d,S,.01))continue;let T=!1;for(let _=0;_<g.length;++_){const E=g[_],{viewportId:b}=E.data,I=l.getViewport(b).getCamera();Vt(I.viewPlaneNormal,C.viewPlaneNormal,.01)&&Vt(I.position,C.position,1)&&(T=!0)}T||g.push(m)}const p=c.filter(y=>{const{data:m}=y,w=l.getViewport(m.viewportId),x=this._getReferenceLineControllable(w.id);return f!==w&&x!==!0});for(let y=0;y<p.length;++y){const m=p[y],{viewportId:w}=m.data,C=l.getViewport(w).getCamera(),S=C.viewPlaneNormal;if(Gt.normalize(S),Vt(d,S,.01)||ep(d,S,.01))continue;let T=!1;for(let _=0;_<g.length;++_){const E=g[_],{viewportId:b}=E.data,I=l.getViewport(b).getCamera();Vt(I.viewPlaneNormal,C.viewPlaneNormal,.01)&&Vt(I.position,C.position,1)&&(T=!0)}T||g.push(m)}const v=this._getAnnotationsForViewportsWithDifferentCameras(s,c);for(let y=0;y<v.length;++y){const m=v[y];if(g.some(_=>_===m))continue;const{viewportId:w}=m.data,C=l.getViewport(w).getCamera(),S=C.viewPlaneNormal;if(Gt.normalize(S),Vt(d,S,.01)||ep(d,S,.01))continue;let T=!1;for(let _=0;_<g.length;++_){const E=g[_],{viewportId:b}=E.data,I=l.getViewport(b).getCamera();Vt(I.viewPlaneNormal,C.viewPlaneNormal,.01)&&Vt(I.position,C.position,1)&&(T=!0)}T||g.push(m)}return g},this._checkIfViewportsRenderingSameScene=(s,c)=>{const l=s.getAllVolumeIds(),f=c.getAllVolumeIds();return l.length===f.length&&l.every(u=>f.includes(u))},this._jump=(s,c)=>{Je.isInteractingWithTool=!0;const{viewport:l,renderingEngine:f}=s,u=this._getAnnotations(s),d=[0,0,0];Gt.subtract(c,this.toolCenter,d);const g=this._getAnnotationsForViewportsWithDifferentCameras(s,u).filter(p=>{const{data:v}=p,y=f.getViewport(v.viewportId),m=this._checkIfViewportsRenderingSameScene(l,y);return this._getReferenceLineControllable(y.id)&&this._getReferenceLineDraggableRotatable(y.id)&&m});return g.length===0?(Je.isInteractingWithTool=!1,!1):(this._applyDeltaShiftToSelectedViewportCameras(f,g,d),Je.isInteractingWithTool=!1,!0)},this._activateModify=s=>{var c;Je.isInteractingWithTool=!((c=this.configuration.mobile)!=null&&c.enabled),s.addEventListener(U.MOUSE_UP,this._endCallback),s.addEventListener(U.MOUSE_DRAG,this._dragCallback),s.addEventListener(U.MOUSE_CLICK,this._endCallback),s.addEventListener(U.TOUCH_END,this._endCallback),s.addEventListener(U.TOUCH_DRAG,this._dragCallback),s.addEventListener(U.TOUCH_TAP,this._endCallback)},this._deactivateModify=s=>{Je.isInteractingWithTool=!1,s.removeEventListener(U.MOUSE_UP,this._endCallback),s.removeEventListener(U.MOUSE_DRAG,this._dragCallback),s.removeEventListener(U.MOUSE_CLICK,this._endCallback),s.removeEventListener(U.TOUCH_END,this._endCallback),s.removeEventListener(U.TOUCH_DRAG,this._dragCallback),s.removeEventListener(U.TOUCH_TAP,this._endCallback)},this._endCallback=s=>{const c=s.detail,{element:l}=c;this.editData.annotation.data.handles.activeOperation=null,this.editData.annotation.data.activeViewportIds=[],this._deactivateModify(l),kt(l),this.editData=null;const u=wt(l,this.getToolName(),!1);We(u)},this._dragCallback=s=>{const c=s.detail,l=c.deltaPoints.world;if(Math.abs(l[0])<.001&&Math.abs(l[1])<.001&&Math.abs(l[2])<.001)return;const{element:f}=c,u=Le(f),{renderingEngine:d,viewport:h}=u,g=this._getAnnotations(u),v=this.filterInteractableAnnotationsForElement(f,g)[0];if(!v)return;const{handles:y}=v.data,{currentPoints:m}=s.detail,w=m.canvas;if(y.activeOperation===Ws.DRAG){const C=this._getAnnotationsForViewportsWithDifferentCameras(u,g).filter(S=>{const{data:T}=S,_=d.getViewport(T.viewportId),E=this._getReferenceLineControllable(_.id),b=this._getReferenceLineDraggableRotatable(_.id);return E===!0&&b===!0&&v.data.activeViewportIds.find(D=>D===_.id)});this._applyDeltaShiftToSelectedViewportCameras(d,C,l)}else if(y.activeOperation===Ws.ROTATE){const C=this._getAnnotationsForViewportsWithDifferentCameras(u,g).filter(B=>{const{data:H}=B,A=d.getViewport(H.viewportId),F=this._getReferenceLineControllable(A.id),G=this._getReferenceLineDraggableRotatable(A.id);return F===!0&&G===!0}),S=Wt(),T=Wt(),_=[this.toolCenter[0],this.toolCenter[1],this.toolCenter[2]],E=h.worldToCanvas(_),b=c.currentPoints.canvas,D=Wt();ps(D,b,c.deltaPoints.canvas),ps(S,D,E),ps(T,b,E);let I=JY(S,T);this._isClockWise(E,D,b)&&(I*=-1),I=Math.round(I*100)/100;const P=h.getCamera().viewPlaneNormal,{matrix:O}=Ni.buildFromRadian().translate(_[0],_[1],_[2]).rotate(I,P).translate(-_[0],-_[1],-_[2]),L=[];C.forEach(B=>{const{data:H}=B;H.handles.toolCenter=_;const A=d.getViewport(H.viewportId),F=A.getCamera(),{viewUp:G,position:X,focalPoint:ee}=F;G[0]+=X[0],G[1]+=X[1],G[2]+=X[2],At(ee,ee,O),At(X,X,O),At(G,G,O),G[0]-=X[0],G[1]-=X[1],G[2]-=X[2],A.setCamera({position:X,viewUp:G,focalPoint:ee}),L.push(A.id)}),d.renderViewports(L)}else if(y.activeOperation===Ws.SLAB){const C=this._getAnnotationsForViewportsWithDifferentCameras(u,g).filter(_=>{const{data:E}=_,b=d.getViewport(E.viewportId),D=this._getReferenceLineControllable(b.id),I=this._getReferenceLineSlabThicknessControlsOn(b.id);return D===!0&&I===!0&&v.data.activeViewportIds.find(P=>P===b.id)});if(C.length===0)return;const S=this._filterViewportWithSameOrientation(u,C[0],g),T=[];T.push(h.id),S.forEach(_=>{const{data:E}=_,b=d.getViewport(E.viewportId),I=b.getCamera().viewPlaneNormal,P=Gt.dot(l,I),O=[...I];if(Gt.multiplyScalar(O,P),Math.abs(O[0])>.001||Math.abs(O[1])>.001||Math.abs(O[2])>.001){const L=Math.sqrt(O[0]*O[0]+O[1]*O[1]+O[2]*O[2]),B=c.lastPoints.world,H=[0,0,0],A=[this.toolCenter[0],this.toolCenter[1],this.toolCenter[2]];if(!this._getReferenceLineDraggableRotatable(b.id)){const{rotationPoints:Ge}=this.editData.annotation.data.handles,Ne=Ge.filter(j=>j[1].uid===b.id);if(Ne.length===2){const j=h.canvasToWorld(Ne[0][3]),M=h.canvasToWorld(Ne[1][3]);Gt.add(j,M,A),Gt.multiplyScalar(A,.5)}}Gt.subtract(B,A,H);const G=Gt.dot(H,I),X=[...I];Gt.multiplyScalar(X,G);const ee=[X[0],X[1],X[2]];Un(ee,ee);const ce=[O[0],O[1],O[2]];Un(ce,ce);let Se=b.getSlabThickness();ep(ee,ce,.001)?Se-=L:Se+=L,Se=Math.abs(Se),Se=Math.max(UC.MINIMUM_SLAB_THICKNESS,Se),this._pointNearReferenceLine(v,w,6,b)&&(Se=UC.MINIMUM_SLAB_THICKNESS),vr(b.id,d.id).getToolInstance(this.getToolName()).setSlabThickness(b,Se),T.push(b.id)}}),d.renderViewports(T)}},this._pointNearReferenceLine=(s,c,l,f)=>{const{data:u}=s,{rotationPoints:d}=u.handles;for(let h=0;h<d.length-1;++h){const g=d[h][1];if(g.id!==f.id||!this._getReferenceLineControllable(g.id))continue;const v={start:{x:d[h][2][0],y:d[h][2][1]},end:{x:d[h][3][0],y:d[h][3][1]}},y=ui([v.start.x,v.start.y],[v.end.x,v.end.y],[c[0],c[1]]),m={start:{x:d[h+1][2][0],y:d[h+1][2][1]},end:{x:d[h+1][3][0],y:d[h+1][3][1]}},w=ui([m.start.x,m.start.y],[m.end.x,m.end.y],[c[0],c[1]]);if(y<=l||w<=l)return!0;h++}return!1},this._getReferenceLineColor=((n=e.configuration)==null?void 0:n.getReferenceLineColor)||fTe,this._getReferenceLineControllable=((i=e.configuration)==null?void 0:i.getReferenceLineControllable)||dTe,this._getReferenceLineDraggableRotatable=((o=e.configuration)==null?void 0:o.getReferenceLineDraggableRotatable)||hTe,this._getReferenceLineSlabThicknessControlsOn=((a=e.configuration)==null?void 0:a.getReferenceLineSlabThicknessControlsOn)||gTe}onSetToolActive(){const e=this._getViewportsInfo();this._unsubscribeToViewportNewVolumeSet(e),this._subscribeToViewportNewVolumeSet(e),this._computeToolCenter(e)}onSetToolPassive(){const e=this._getViewportsInfo();this._computeToolCenter(e)}onSetToolEnabled(){const e=this._getViewportsInfo();this._computeToolCenter(e)}onSetToolDisabled(){const e=this._getViewportsInfo();this._unsubscribeToViewportNewVolumeSet(e),e.forEach(({renderingEngineId:r,viewportId:n})=>{const i=fi(n,r);if(!i)return;const o=this._getAnnotations(i);o!=null&&o.length&&o.forEach(a=>{en(a.annotationUID)})})}setToolCenter(e,r=!1){this.toolCenter=e;const n=this._getViewportsInfo();We(n.map(({viewportId:i})=>i)),r||it(Ze,U.CROSSHAIR_TOOL_CENTER_CHANGED,{toolGroupId:this.toolGroupId,toolCenter:this.toolCenter})}getHandleNearImagePoint(e,r,n,i){const o=Le(e),{viewport:a}=o;let s=this._getRotationHandleNearImagePoint(a,r,n,i);if(s!==null||(s=this._getSlabThicknessHandleNearImagePoint(a,r,n,i),s!==null))return s}_unsubscribeToViewportNewVolumeSet(e){e.forEach(({viewportId:r,renderingEngineId:n})=>{const{viewport:i}=fi(r,n),{element:o}=i;o.removeEventListener(et.VOLUME_VIEWPORT_NEW_VOLUME,this._onNewVolume)})}_subscribeToViewportNewVolumeSet(e){e.forEach(({viewportId:r,renderingEngineId:n})=>{const{viewport:i}=fi(r,n),{element:o}=i;o.addEventListener(et.VOLUME_VIEWPORT_NEW_VOLUME,this._onNewVolume)})}_autoPanViewportIfNecessary(e,r){const n=r.getViewport(e),{clientWidth:i,clientHeight:o}=n.canvas,a=n.worldToCanvas(this.toolCenter),s=this.configuration.autoPan.panSize,c=[a[0],a[1]];if(a[0]<0?c[0]=s:a[0]>i&&(c[0]=i-s),a[1]<0?c[1]=s:a[1]>o&&(c[1]=o-s),c[0]===a[0]&&c[1]===a[1])return;const l=n.canvasToWorld(c),f=[l[0]-this.toolCenter[0],l[1]-this.toolCenter[1],l[2]-this.toolCenter[2]],u=n.getCamera(),{focalPoint:d,position:h}=u,g=[h[0]-f[0],h[1]-f[1],h[2]-f[2]],p=[d[0]-f[0],d[1]-f[1],d[2]-f[2]];n.setCamera({focalPoint:p,position:g}),n.render()}setSlabThickness(e,r){let n;const{filterActorUIDsToSetSlabThickness:i}=this.configuration;i&&i.length>0&&(n=i);let o=this.configuration.slabThicknessBlendMode;r===UC.MINIMUM_SLAB_THICKNESS&&(o=Hc.COMPOSITE),e.setBlendMode(o,n,!1),e.setSlabThickness(r,n)}_isClockWise(e,r,n){return(r[0]-e[0])*(n[1]-e[1])-(r[1]-e[1])*(n[0]-e[0])>0}_applyDeltaShiftToSelectedViewportCameras(e,r,n){r.forEach(i=>{this._applyDeltaShiftToViewportCamera(e,i,n)})}_applyDeltaShiftToViewportCamera(e,r,n){const{data:i}=r,o=e.getViewport(i.viewportId),a=o.getCamera(),s=a.viewPlaneNormal,c=Gt.dot(n,s),l=[...s];if(Gt.multiplyScalar(l,c),Math.abs(l[0])>.001||Math.abs(l[1])>.001||Math.abs(l[2])>.001){const f=[0,0,0],u=[0,0,0];Gt.add(a.focalPoint,l,f),Gt.add(a.position,l,u),o.setCamera({focalPoint:f,position:u}),o.render()}}_getRotationHandleNearImagePoint(e,r,n,i){const{data:o}=r,{rotationPoints:a}=o.handles;for(let s=0;s<a.length;s++){const c=a[s][0],l=a[s][1];if(!this._getReferenceLineControllable(l.id)||!this._getReferenceLineDraggableRotatable(l.id))continue;const d=e.worldToCanvas(c);if(ur(n,d)<i)return o.handles.activeOperation=Ws.ROTATE,this.editData={annotation:r},c}return null}_getSlabThicknessHandleNearImagePoint(e,r,n,i){const{data:o}=r,{slabThicknessPoints:a}=o.handles;for(let s=0;s<a.length;s++){const c=a[s][0],l=a[s][1];if(!this._getReferenceLineControllable(l.id)||!this._getReferenceLineSlabThicknessControlsOn(l.id))continue;const d=e.worldToCanvas(c);if(ur(n,d)<i)return o.handles.activeOperation=Ws.SLAB,o.activeViewportIds=[l.id],this.editData={annotation:r},c}return null}_pointNearTool(e,r,n,i){const o=Le(e),{viewport:a}=o,{clientWidth:s,clientHeight:c}=a.canvas,l=Math.sqrt(s*s+c*c),{data:f}=r,{rotationPoints:u}=f.handles,{slabThicknessPoints:d}=f.handles,h=[];for(let g=0;g<u.length-1;++g){const p=u[g][1],v=this._getReferenceLineControllable(p.id),y=this._getReferenceLineDraggableRotatable(p.id);if(!v||!y)continue;const m={start:{x:u[g][2][0],y:u[g][2][1]},end:{x:u[g][3][0],y:u[g][3][1]}},w=ui([m.start.x,m.start.y],[m.end.x,m.end.y],[n[0],n[1]]),x={start:{x:u[g+1][2][0],y:u[g+1][2][1]},end:{x:u[g+1][3][0],y:u[g+1][3][1]}},C=ui([x.start.x,x.start.y],[x.end.x,x.end.y],[n[0],n[1]]);(w<=i||C<=i)&&(h.push(p.id),f.handles.activeOperation=Ws.DRAG),g++}for(let g=0;g<d.length-1;++g){const p=d[g][1];if(h.find(P=>P===p.id))continue;const v=this._getReferenceLineControllable(p.id),y=this._getReferenceLineSlabThicknessControlsOn(p.id);if(!v||!y)continue;const m=d[g][2],w=d[g][3],x=Wt();no(x,m,w),Al(x,x,.5);const C=Wt();Br(C,m,x),Ul(C,C);const S=Wt();Al(S,C,l*.05);const T=Wt(),_=Wt();no(T,x,S),Br(_,x,S);const E={start:{x:T[0],y:T[1]},end:{x:m[0],y:m[1]}},b=ui([E.start.x,E.start.y],[E.end.x,E.end.y],[n[0],n[1]]),D={start:{x:_[0],y:_[1]},end:{x:w[0],y:w[1]}},I=ui([D.start.x,D.start.y],[D.end.x,D.end.y],[n[0],n[1]]);(b<=i||I<=i)&&(h.push(p.id),f.handles.activeOperation=null),g++}return f.activeViewportIds=[...h],this.editData={annotation:r},f.handles.activeOperation===Ws.DRAG}}Uc.toolName="Crosshairs";const X2="magnify-viewport";class QW extends ri{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{magnifySize:10,magnifyWidth:250,magnifyHeight:250}}){super(e,r),this._hasBeenRemoved=!1,this.preMouseDownCallback=n=>{const i=n.detail,{element:o,currentPoints:a}=i,s=Le(o),{viewport:c,renderingEngine:l}=s;if(!(c instanceof Jn))throw new Error("MagnifyTool only works on StackViewports");const f=this._getReferencedImageId(c);if(!f)throw new Error("MagnifyTool: No referenced image id found, reconstructed planes not supported yet");const u=wt(o,this.getToolName());return this.editData={referencedImageId:f,viewportIdsToRender:u,enabledElement:s,renderingEngine:l,currentPoints:a},this._createMagnificationViewport(),this._activateDraw(o),Dt(o),n.preventDefault(),We(u),!0},this.preTouchStartCallback=n=>{this.preMouseDownCallback(n)},this._createMagnificationViewport=()=>{const{enabledElement:n,referencedImageId:i,viewportIdsToRender:o,renderingEngine:a,currentPoints:s}=this.editData,{viewport:c}=n,{element:l}=c,f=c.getProperties(),{rotation:u}=c.getViewPresentation(),{canvas:d,world:h}=s;let g;if(g=l.querySelector(".magnifyTool"),g===null){const v=document.createElement("div");v.classList.add("magnifyTool"),v.style.display="block",v.style.width=`${this.configuration.magnifyWidth}px`,v.style.height=`${this.configuration.magnifyHeight}px`,v.style.position="absolute",g=v,l.querySelector(".viewport-element").appendChild(v);const m={viewportId:X2,type:ir.STACK,element:g};a.enableElement(m)}g.style.top=`${d[1]-this.configuration.magnifyHeight/2}px`,g.style.left=`${d[0]-this.configuration.magnifyWidth/2}px`;const p=a.getViewport(X2);p.setStack([i]).then(()=>{if(this._hasBeenRemoved)return;p.setProperties(f),p.setViewPresentation({rotation:u});const{parallelScale:v}=c.getCamera(),{focalPoint:y,position:m,viewPlaneNormal:w}=p.getCamera(),x=Math.sqrt(Math.pow(y[0]-m[0],2)+Math.pow(y[1]-m[1],2)+Math.pow(y[2]-m[2],2)),C=[h[0],h[1],h[2]],S=[C[0]+x*w[0],C[1]+x*w[1],C[2]+x*w[2]];p.setCamera({parallelScale:v*(1/this.configuration.magnifySize),focalPoint:C,position:S}),p.render()}),g.style.display="block",We(o)},this._dragCallback=n=>{const i=n.detail,{deltaPoints:o,element:a,currentPoints:s}=i,c=o.world,l=s.canvas,f=Le(a),{renderingEngine:u}=f,d=u.getViewport(X2),h=a.querySelector(".magnifyTool");if(!h)return;h.style.top=`${l[1]-this.configuration.magnifyHeight/2}px`,h.style.left=`${l[0]-this.configuration.magnifyWidth/2}px`;const{focalPoint:g,position:p}=d.getCamera(),v=[p[0]+c[0],p[1]+c[1],p[2]+c[2]],y=[g[0]+c[0],g[1]+c[1],g[2]+c[2]];d.setCamera({focalPoint:y,position:v}),d.render()},this._dragEndCallback=n=>{const{element:i}=n.detail,o=Le(i),{renderingEngine:a}=o;a.disableElement(X2);const s=i.querySelector(".viewport-element"),c=s.querySelector(".magnifyTool");s.removeChild(c),this._deactivateDraw(i),kt(i),this._hasBeenRemoved=!0},this._activateDraw=n=>{Je.isInteractingWithTool=!0,this._hasBeenRemoved=!1,n.addEventListener(U.MOUSE_UP,this._dragEndCallback),n.addEventListener(U.MOUSE_DRAG,this._dragCallback),n.addEventListener(U.MOUSE_CLICK,this._dragEndCallback),n.addEventListener(U.TOUCH_END,this._dragEndCallback),n.addEventListener(U.TOUCH_DRAG,this._dragCallback)},this._deactivateDraw=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_UP,this._dragEndCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragCallback),n.removeEventListener(U.MOUSE_CLICK,this._dragEndCallback),n.removeEventListener(U.TOUCH_END,this._dragEndCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragCallback)}}_getReferencedImageId(e){const r=this.getTargetId(e);let n;return e instanceof Jn&&(n=r.split("imageId:")[1]),n}}QW.toolName="Magnify";const pTe="advancedMagnifyTool",mTe=125,{Events:xu}=Ha,u7=t=>t.uid!==t.referencedId;var uT;(function(t){t.ShowZoomFactorsList="showZoomFactorsList"})(uT||(uT={}));const vTe="AdvancedMagnify",yTe=1-Ga,ab=class ab extends Yn{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{shadow:!0,magnifyingGlass:{radius:125,zoomFactor:3,zoomFactorList:[1.5,2,2.5,3,3.5,4,4.5,5],autoPan:{enabled:!0,padding:10}},actions:{showZoomFactorsList:{method:"showZoomFactorsList",bindings:[{mouseButton:ol.Secondary,modifierKey:Ri.Shift}]}}}}){super(e,r),this.addNewAnnotation=n=>{const i=n.detail,{currentPoints:o,element:a}=i,s=Le(a),{viewport:c,renderingEngine:l}=s,f=o.world,u=o.canvas,{magnifyingGlass:d}=this.configuration,{radius:h,zoomFactor:g,autoPan:p}=d,v=this._getCanvasHandlePoints(u,h),y=c.getCamera(),{viewPlaneNormal:m,viewUp:w}=y,x=this.getReferencedImageId(c,f,m,w),C=gn(),S=gn(),T=c.getFrameOfReferenceUID(),_={annotationUID:C,highlighted:!0,invalidated:!0,metadata:{toolName:this.getToolName(),viewPlaneNormal:[...m],viewUp:[...w],FrameOfReferenceUID:T,referencedImageId:x},data:{sourceViewportId:c.id,magnifyViewportId:S,zoomFactor:g,isCanvasAnnotation:!0,handles:{points:v,activeHandleIndex:null}}};this.magnifyViewportManager.createViewport(_,{magnifyViewportId:S,sourceEnabledElement:s,position:u,radius:h,zoomFactor:g,autoPan:{enabled:p.enabled,padding:p.padding,callback:b=>{const D=_.data.handles.points,{canvas:I}=b.delta;for(let P=0,O=D.length;P<O;P++){const L=D[P];L[0]+=I[0],L[1]+=I[1],_.invalidated=!0}}}}),qt(_,a);const E=wt(a,this.getToolName());return n.preventDefault(),We(E),_},this.onSetToolDisabled=()=>{this.magnifyViewportManager.dispose(),vm().forEach(i=>{i.metadata.toolName===this.getToolName()&&en(i.annotationUID)})},this.isPointNearTool=(n,i,o,a)=>{const{data:s}=i,{points:c}=s.handles,l=c,f=l[0],u=l[2],d=l[3],h=Math.abs(u[1]-f[1])*.5,g=[d[0]+h,f[1]+h],p=Qu([g,o]);return Math.abs(p-h)<a*2},this.toolSelectedCallback=(n,i)=>{const o=n.detail,{element:a}=o;i.highlighted=!0;const s=wt(a,this.getToolName());this.editData={annotation:i,viewportIdsToRender:s},Dt(a),this._activateModify(a),We(s),n.preventDefault()},this.handleSelectedCallback=(n,i,o)=>{const a=n.detail,{element:s}=a,{data:c}=i;i.highlighted=!0;const{points:l}=c.handles,f=l.findIndex(d=>d===o),u=wt(s,this.getToolName());this.editData={annotation:i,viewportIdsToRender:u,handleIndex:f},this._activateModify(s),Dt(s),We(u),n.preventDefault()},this._endCallback=n=>{const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s,newAnnotation:c}=this.editData,{data:l}=a;l.handles.activeHandleIndex=null,this._deactivateModify(o),kt(o),this.editData=null,this.isDrawing=!1,We(s),c&&bn(a)},this._dragDrawCallback=n=>{this.isDrawing=!0;const i=n.detail,{deltaPoints:o}=i,a=(o==null?void 0:o.canvas)??[0,0,0],{annotation:s,viewportIdsToRender:c}=this.editData,{points:l}=s.data.handles;l.forEach(f=>{f[0]+=a[0],f[1]+=a[1]}),s.invalidated=!0,this.editData.hasMoved=!0,We(c)},this._dragModifyCallback=n=>{this.isDrawing=!0;const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s,handleIndex:c}=this.editData,{data:l}=a;if(c===void 0){const{deltaPoints:f}=i,u=f.canvas;l.handles.points.forEach(h=>{h[0]+=u[0],h[1]+=u[1]}),a.invalidated=!0}else this._dragHandle(n),a.invalidated=!0;We(s)},this._dragHandle=n=>{const i=n.detail,{annotation:o}=this.editData,{data:a}=o,{points:s}=a.handles,c=s,l=c[0],f=c[2],u=c[3],d=Math.abs(f[1]-l[1])*.5,h=[u[0]+d,l[1]+d],{currentPoints:g}=i,p=g.canvas,v=Qu([h,p]),y=this._getCanvasHandlePoints(h,v);s[0]=y[0],s[1]=y[1],s[2]=y[2],s[3]=y[3]},this.cancel=n=>{if(!this.isDrawing)return;this.isDrawing=!1,this._deactivateModify(n),kt(n);const{annotation:i,viewportIdsToRender:o,newAnnotation:a}=this.editData,{data:s}=i;return i.highlighted=!1,s.handles.activeHandleIndex=null,We(o),a&&bn(i),this.editData=null,i.annotationUID},this._activateModify=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragModifyCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragModifyCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback)},this._deactivateModify=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragModifyCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.TOUCH_END,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragModifyCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback)},this.renderAnnotation=(n,i)=>{let o=!1;const{viewport:a}=n,{element:s}=a;let c=Jt(this.getToolName(),s);if(!(c!=null&&c.length))return o;c=c==null?void 0:c.filter(u=>u.data.sourceViewportId===a.id);const l=this.filterInteractableAnnotationsForElement(s,c);if(!(l!=null&&l.length))return o;const f={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:n.viewport.id};for(let u=0;u<l.length;u++){const d=l[u],{annotationUID:h,data:g}=d,{magnifyViewportId:p,zoomFactor:v,handles:y}=g,{points:m,activeHandleIndex:w}=y;f.annotationUID=h,this.getStyle("lineWidth",f,d),this.getStyle("lineDash",f,d);const x=this.getStyle("color",f,d),C=m,S=C[0],T=C[2],_=C[3],E=Math.abs(T[1]-S[1])*.5,b=[_[0]+E,S[1]+E];if(!a.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),o;let D;if(!Vr(h))continue;!Yr(h)&&!this.editData&&w!==null&&(D=[C[w]]),D&&Kn(i,h,"0",D,{color:x});const I=`${h}-advancedMagnify`;Yo(i,h,"0",b,E,{color:x,lineWidth:5},I);const O=this.magnifyViewportManager.getViewport(p);O.position=b,O.radius=E,O.zoomFactor=v,O.update(),o=!0}return o},this._getCanvasHandlePoints=(n,i)=>[[n[0],n[1]-i,0],[n[0]+i,n[1],0],[n[0],n[1]+i,0],[n[0]-i,n[1],0]],this.magnifyViewportManager=O0.getInstance()}showZoomFactorsList(e,r){const{element:n,currentPoints:i}=e.detail,o=Le(n),{viewport:a}=o,{canvas:s}=i,c=n.querySelector(":scope .viewport-element"),l=r.data.zoomFactor,f=()=>u.parentElement.removeChild(u),u=this._getZoomFactorsListDropdown(l,d=>{d!==void 0&&(r.data.zoomFactor=Number.parseFloat(d),r.invalidated=!0),f(),a.render()});Object.assign(u.style,{left:`${s[0]}px`,top:`${s[1]}px`}),c.appendChild(u),u.focus()}_getZoomFactorsListDropdown(e,r){const{zoomFactorList:n}=this.configuration.magnifyingGlass,i=document.createElement("select");return i.size=5,Object.assign(i.style,{width:"50px",position:"absolute"}),["mousedown","mouseup","mousemove","click"].forEach(o=>{i.addEventListener(o,a=>a.stopPropagation())}),i.addEventListener("change",o=>{o.stopPropagation(),r(i.value)}),i.addEventListener("keydown",o=>{var s;((o.keyCode??o.which===27)||((s=o.key)==null?void 0:s.toLowerCase())==="escape")&&(o.stopPropagation(),r())}),n.forEach(o=>{const a=document.createElement("option");a.label=o,a.title=`Zoom factor ${o.toFixed(1)}`,a.value=o,a.defaultSelected=o===e,i.add(a)}),i}};ab.Actions=uT;let G1=ab;class O0{constructor(){this.createViewport=(e,r)=>{const{magnifyViewportId:n,sourceEnabledElement:i,position:o,radius:a,zoomFactor:s,autoPan:c}=r,{viewport:l}=i,{element:f}=l,u=new wTe({magnifyViewportId:n,sourceEnabledElement:i,radius:a,position:o,zoomFactor:s,autoPan:c});return this._addSourceElementEventListener(f),this._magnifyViewportsMap.set(u.viewportId,{annotation:e,magnifyViewport:u,magnifyViewportInfo:r}),u},this._annotationRemovedCallback=e=>{const{annotation:r}=e.detail;r.metadata.toolName===vTe&&this.destroyViewport(r.data.magnifyViewportId)},this._newStackImageCallback=e=>{const{viewportId:r,imageId:n}=e.detail,i=this._getMagnifyViewportsMapEntriesBySourceViewportId(r),{viewport:o}=Mn(r);o.stackActorReInitialized&&this._reset(r),i.forEach(({annotation:a})=>{a.metadata.referencedImageId=n,a.invalidated=!0})},this._newVolumeImageCallback=e=>{const{renderingEngineId:r,viewportId:n}=e.detail,o=Nr(r).getViewport(n),{viewPlaneNormal:a}=o.getCamera();this._getMagnifyViewportsMapEntriesBySourceViewportId(n).forEach(({annotation:c})=>{const{viewPlaneNormal:l}=c.metadata;if(!(Math.abs(xt(l,a))>yTe))return;const{handles:u}=c.data,d=o.canvasToWorld([0,0]),h=hn(Ke(),d,u.points[0]),g=xt(h,a),p=gr(Ke(),a,g);for(let v=0,y=u.points.length;v<y;v++){const m=u.points[v];m[0]+=p[0],m[1]+=p[1],m[2]+=p[2]}c.invalidated=!0})},this._magnifyViewportsMap=new Map,this._initialize()}static getInstance(){return O0._singleton=O0._singleton??new O0,O0._singleton}getViewport(e){var r;return(r=this._magnifyViewportsMap.get(e))==null?void 0:r.magnifyViewport}dispose(){this._removeEventListeners(),this._destroyViewports()}destroyViewport(e){const r=this._magnifyViewportsMap.get(e);if(r){const{magnifyViewport:n}=r,{viewport:i}=n.sourceEnabledElement,{element:o}=i;this._removeSourceElementEventListener(o),n.dispose(),this._magnifyViewportsMap.delete(e)}}_destroyViewports(){Array.from(this._magnifyViewportsMap.keys()).forEach(r=>this.destroyViewport(r))}_getMagnifyViewportsMapEntriesBySourceViewportId(e){return Array.from(this._magnifyViewportsMap.values()).filter(({magnifyViewport:n})=>{const{viewport:i}=n.sourceEnabledElement;return i.id===e})}_reset(e){this._getMagnifyViewportsMapEntriesBySourceViewportId(e).forEach(({magnifyViewport:n,annotation:i,magnifyViewportInfo:o})=>{this.destroyViewport(n.viewportId);const a=Mn(e);this.createViewport(i,{...o,sourceEnabledElement:{...a}})})}_addEventListeners(){Ze.addEventListener(U.ANNOTATION_REMOVED,this._annotationRemovedCallback)}_removeEventListeners(){Ze.removeEventListener(U.ANNOTATION_REMOVED,this._annotationRemovedCallback)}_addSourceElementEventListener(e){e.addEventListener(xu.STACK_NEW_IMAGE,this._newStackImageCallback);const r=i=>{const{viewportId:o}=i.detail;this._reset(o)};e.addEventListener(xu.VIEWPORT_NEW_IMAGE_SET,r);const n=i=>{const{viewportId:o}=i.detail;this._reset(o)};e.addEventListener(xu.VOLUME_VIEWPORT_NEW_VOLUME,n),e.addEventListener(xu.VOLUME_NEW_IMAGE,this._newVolumeImageCallback),e.newStackHandler=r,e.newVolumeHandler=n}_removeSourceElementEventListener(e){e.removeEventListener(xu.STACK_NEW_IMAGE,this._newStackImageCallback),e.removeEventListener(xu.VOLUME_NEW_IMAGE,this._newVolumeImageCallback),e.removeEventListener(xu.VIEWPORT_NEW_IMAGE_SET,e.newStackHandler),e.removeEventListener(xu.VOLUME_VIEWPORT_NEW_VOLUME,e.newVolumeHandler),delete e.newStackHandler,delete e.newVolumeHandler}_initialize(){this._addEventListeners()}}class wTe{constructor({magnifyViewportId:e,sourceEnabledElement:r,radius:n=mTe,position:i=[0,0],zoomFactor:o,autoPan:a}){this._enabledElement=null,this._sourceToolGroup=null,this._magnifyToolGroup=null,this._isViewportReady=!1,this._radius=0,this._resized=!1,this._canAutoPan=!1,this._viewportId=e??gn(),this._sourceEnabledElement=r,this._autoPan=a,this.radius=n,this.position=i,this.zoomFactor=o,this.visible=!0,this._browserMouseDownCallback=this._browserMouseDownCallback.bind(this),this._browserMouseUpCallback=this._browserMouseUpCallback.bind(this),this._handleToolModeChanged=this._handleToolModeChanged.bind(this),this._mouseDragCallback=this._mouseDragCallback.bind(this),this._resizeViewportAsync=Jh(this._resizeViewport.bind(this),1),this._initialize()}get sourceEnabledElement(){return this._sourceEnabledElement}get viewportId(){return this._viewportId}get radius(){return this._radius}set radius(e){Math.abs(this._radius-e)>1e-5&&(this._radius=e,this._resized=!0)}update(){const{radius:e,position:r,visible:n}=this,{viewport:i}=this._enabledElement,{element:o}=i,a=2*e,[s,c]=r;this._resized&&(this._resizeViewportAsync(),this._resized=!1),Object.assign(o.style,{display:n?"block":"hidden",width:`${a}px`,height:`${a}px`,left:`${-e}px`,top:`${-e}px`,transform:`translate(${s}px, ${c}px)`}),this._isViewportReady&&(this._syncViewports(),i.render())}dispose(){const{viewport:e}=this._enabledElement,{element:r}=e,n=e.getRenderingEngine();this._removeEventListeners(r),n.disableElement(e.id),r.parentNode&&r.parentNode.removeChild(r)}_handleToolModeChanged(e){var s;const{_magnifyToolGroup:r}=this,{toolGroupId:n,toolName:i,mode:o,toolBindingsOptions:a}=e.detail;if(((s=this._sourceToolGroup)==null?void 0:s.id)===n)switch(o){case En.Active:r.setToolActive(i,a);break;case En.Passive:r.setToolPassive(i);break;case En.Enabled:r.setToolEnabled(i);break;case En.Disabled:r.setToolDisabled(i);break;default:throw new Error(`Unknow tool mode (${o})`)}}_inheritBorderRadius(e){const r=e.querySelector(".viewport-element"),n=e.querySelector(".cornerstone-canvas");r.style.borderRadius="inherit",n.style.borderRadius="inherit"}_createViewportNode(){const e=document.createElement("div"),{radius:r}=this,n=r*2;return e.classList.add(pTe),Object.assign(e.style,{display:"block",width:`${n}px`,height:`${n}px`,position:"absolute",overflow:"hidden",borderRadius:"50%",boxSizing:"border-box",left:`${-r}px`,top:`${-r}px`,transform:"translate(-1000px, -1000px)"}),e}_convertZoomFactorToParallelScale(e,r,n){const{parallelScale:i}=e.getCamera(),o=r.canvas.offsetWidth/e.canvas.offsetWidth;return i*(1/n)*o}_isStackViewport(e){return"setStack"in e}_isVolumeViewport(e){return"addVolumes"in e}_cloneToolGroups(e,r){const n=e.getActors(),i=`${r.id}-toolGroup`,o=vr(e.id,e.renderingEngineId),a=o.clone(i,s=>{const c=o.getToolInstance(s);return c instanceof Yn&&!(c instanceof G1)});return a.addViewport(r.id,r.renderingEngineId),n.filter(u7).forEach(s=>{sg(this.viewportId,[{segmentationId:s.referencedId,type:St.Labelmap}])}),{sourceToolGroup:o,magnifyToolGroup:a}}_cloneStack(e,r){const n=e.getImageIds();r.setStack(n).then(()=>{this._isViewportReady=!0,this.update()})}_cloneVolumes(e,r){const i=e.getActors().filter(o=>!u7(o)).map(o=>({volumeId:o.uid}));return r.setVolumes(i).then(()=>{this._isViewportReady=!0,this.update()}),r}_cloneViewport(e,r){const{viewportId:n}=this,i=e.getRenderingEngine(),{options:o}=e,a={element:r,viewportId:n,type:e.type,defaultOptions:{...o}};i.enableElement(a);const s=i.getViewport(n);this._isStackViewport(e)?this._cloneStack(e,s):this._isVolumeViewport(e)&&this._cloneVolumes(e,s),this._inheritBorderRadius(r);const c=this._cloneToolGroups(e,s);this._sourceToolGroup=c.sourceToolGroup,this._magnifyToolGroup=c.magnifyToolGroup}_cancelMouseEventCallback(e){e.stopPropagation(),e.preventDefault()}_browserMouseUpCallback(e){const{element:r}=this._enabledElement.viewport;document.removeEventListener("mouseup",this._browserMouseUpCallback),r.addEventListener("mouseup",this._cancelMouseEventCallback),r.addEventListener("mousemove",this._cancelMouseEventCallback)}_browserMouseDownCallback(e){var n;const{element:r}=this._enabledElement.viewport;this._canAutoPan=!!((n=e.target)!=null&&n.closest(".advancedMagnifyTool")),document.addEventListener("mouseup",this._browserMouseUpCallback),r.removeEventListener("mouseup",this._cancelMouseEventCallback),r.removeEventListener("mousemove",this._cancelMouseEventCallback)}_mouseDragCallback(e){if(!Je.isInteractingWithTool)return;const{_autoPan:r}=this;if(!r.enabled||!this._canAutoPan)return;const{currentPoints:n}=e.detail,{viewport:i}=this._enabledElement,{canvasToWorld:o}=i,{canvas:a}=n,{radius:s}=this,c=[s,s],l=Do(c,a),f=s-r.padding;if(l<=f)return;const u=l-f,d=ps(Wt(),a,c);Ul(d,d),Al(d,d,u);const h=no(Wt(),this.position,d),g=o(this.position),p=o(h),v=hn(Ke(),p,g),y={points:{currentPosition:{canvas:this.position,world:g},newPosition:{canvas:h,world:p}},delta:{canvas:d,world:v}};r.callback(y)}_addBrowserEventListeners(e){document.addEventListener("mousedown",this._browserMouseDownCallback,!0),e.addEventListener("mousedown",this._cancelMouseEventCallback),e.addEventListener("mouseup",this._cancelMouseEventCallback),e.addEventListener("mousemove",this._cancelMouseEventCallback),e.addEventListener("dblclick",this._cancelMouseEventCallback)}_removeBrowserEventListeners(e){document.removeEventListener("mousedown",this._browserMouseDownCallback,!0),document.removeEventListener("mouseup",this._browserMouseUpCallback),e.removeEventListener("mousedown",this._cancelMouseEventCallback),e.removeEventListener("mouseup",this._cancelMouseEventCallback),e.removeEventListener("mousemove",this._cancelMouseEventCallback),e.removeEventListener("dblclick",this._cancelMouseEventCallback)}_addEventListeners(e){Ze.addEventListener(U.TOOL_MODE_CHANGED,this._handleToolModeChanged),e.addEventListener(U.MOUSE_MOVE,this._mouseDragCallback),e.addEventListener(U.MOUSE_DRAG,this._mouseDragCallback),this._addBrowserEventListeners(e)}_removeEventListeners(e){Ze.removeEventListener(U.TOOL_MODE_CHANGED,this._handleToolModeChanged),e.addEventListener(U.MOUSE_MOVE,this._mouseDragCallback),e.addEventListener(U.MOUSE_DRAG,this._mouseDragCallback),this._removeBrowserEventListeners(e)}_initialize(){const{_sourceEnabledElement:e}=this,{viewport:r}=e,{canvas:n}=r,i=this._createViewportNode();n.parentNode.appendChild(i),this._addEventListeners(i),this._cloneViewport(r,i),this._enabledElement=Le(i)}_syncViewportsCameras(e,r){const n=e.canvasToWorld(this.position),i=this._convertZoomFactorToParallelScale(e,r,this.zoomFactor),{focalPoint:o,position:a,viewPlaneNormal:s}=r.getCamera(),c=Math.sqrt(Math.pow(o[0]-a[0],2)+Math.pow(o[1]-a[1],2)+Math.pow(o[2]-a[2],2)),l=[n[0],n[1],n[2]],f=[l[0]+c*s[0],l[1]+c*s[1],l[2]+c*s[2]];r.setCamera({parallelScale:i,focalPoint:l,position:f})}_syncStackViewports(e,r){r.setImageIdIndex(e.getCurrentImageIdIndex())}_syncViewports(){const{viewport:e}=this._sourceEnabledElement,{viewport:r}=this._enabledElement,n=e.getProperties();r.getImageData()&&(r.setProperties(n),this._syncViewportsCameras(e,r),this._isStackViewport(e)&&this._syncStackViewports(e,r),this._syncViewportsCameras(e,r),r.render())}_resizeViewport(){const{viewport:e}=this._enabledElement;e.getRenderingEngine().resize()}}G1.toolName="AdvancedMagnify";const{EPSILON:BC}=xf;class pd extends Ef{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{sourceViewportId:"",enforceSameFrameOfReference:!0,showFullDimension:!1}}){super(e,r),this.editData=null,this._init=()=>{var h;const i=Po()[0];if(!i)return;let o=i.getViewports();o=Fw(o,this.getToolName());const a=i.getViewport(this.configuration.sourceViewportId);if(!(a!=null&&a.getImageData()))return;const{element:s}=a,{viewUp:c,viewPlaneNormal:l}=a.getCamera(),f=jy(a);let u=(h=this.editData)==null?void 0:h.annotation;const d=a.getFrameOfReferenceUID();if(u)this.editData.annotation.data.handles.points=f;else{const g={highlighted:!0,invalidated:!0,metadata:{toolName:this.getToolName(),viewPlaneNormal:[...l],viewUp:[...c],FrameOfReferenceUID:d,referencedImageId:null},data:{handles:{points:f}}};qt(g,s),u=g}this.editData={sourceViewportId:a.id,renderingEngine:i,annotation:u},We(o.filter(g=>g.id!==a.id).map(g=>g.id))},this.onSetToolEnabled=()=>{this._init()},this.onSetToolConfiguration=()=>{this._init()},this.onCameraModified=n=>{this._init()},this.renderAnnotation=(n,i)=>{var G,X;const{viewport:o}=n;if(!this.editData)return!1;const{annotation:a,sourceViewportId:s}=this.editData;let c=!1;const{viewport:l}=Mn(s)||{};if(!l||l.id===o.id||!a||!((X=(G=a==null?void 0:a.data)==null?void 0:G.handles)!=null&&X.points)||this.configuration.enforceSameFrameOfReference&&l.getFrameOfReferenceUID()!==o.getFrameOfReferenceUID())return c;const f={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:n.viewport.id},u=a.data.handles.points[0],d=a.data.handles.points[1],h=a.data.handles.points[2],g=a.data.handles.points[3],{focalPoint:p,viewPlaneNormal:v,viewUp:y}=o.getCamera(),{viewPlaneNormal:m}=l.getCamera();if(this.isParallel(v,m))return c;const w=Yc(v,p),x=[u,h,d,g],C=[u,d,h,g];let S=x,T=Nn(Ke(),x[0],x[1]);T=Un(Ke(),T);let _=Nn(Ke(),x[2],x[0]);_=Un(Ke(),_);const E=Tn(Ke(),T,_);if(this.isParallel(E,v))return c;this.isPerpendicular(T,v)&&(S=C);const b=Sh(S[0],S[1],w),D=Sh(S[2],S[3],w),{annotationUID:I}=a;f.annotationUID=I;const P=this.getStyle("lineWidth",f,a),O=this.getStyle("lineDash",f,a),L=this.getStyle("color",f,a),B=this.getStyle("shadow",f,a);let H=[b,D].map(ee=>o.worldToCanvas(ee));if(this.configuration.showFullDimension&&(H=this.handleFullDimension(o,b,v,y,D,H)),H.length<2)return c;const A=`${I}-line`;return an(i,I,"1",H[0],H[1],{color:L,width:P,lineDash:O,shadow:B},A),c=!0,c},this.isPerpendicular=(n,i)=>{const o=xt(n,i);return Math.abs(o)<BC}}handleFullDimension(e,r,n,i,o,a){e.getRenderingEngine();const s=this.getTargetId(e),c=this.getTargetImageData(s),l=this.getReferencedImageId(e,r,n,i);if(l&&c)try{const{imageData:f,dimensions:u}=c,[d,h,g,p]=[f.indexToWorld([0,0,0]),f.indexToWorld([u[0]-1,0,0]),f.indexToWorld([u[0]-1,u[1]-1,0]),f.indexToWorld([0,u[1]-1,0])].map(m=>AS(l,m)),[v,y]=[r,o].map(m=>AS(l,m));a=[[d,h],[h,g],[p,g],[d,p]].map(([m,w])=>this.intersectInfiniteLines(m,w,v,y)).filter(m=>m&&this.isInBound(m,u)).map(m=>{const w=bV(l,m);return e.worldToCanvas(w)})}catch(f){console.log(f)}return a}intersectInfiniteLines(e,r,n,i){const[o,a]=e,[s,c]=r,[l,f]=n,[u,d]=i,h=c-a,g=o-s,p=s*a-o*c,v=d-f,y=l-u,m=u*f-l*d;if(Math.abs(h*y-v*g)<BC)return;const w=(g*m-y*p)/(h*y-v*g),x=(v*p-h*m)/(h*y-v*g);return[w,x]}isParallel(e,r){return Math.abs(xt(e,r))>1-BC}isInBound(e,r){return e[0]>=0&&e[0]<=r[0]&&e[1]>=0&&e[1]<=r[1]}}pd.toolName="ReferenceLines";const{EPSILON:f7}=xf;class ez extends Ef{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{sourceImageIds:[]}}){super(e,r),this.onSetToolEnabled=()=>{this._init()},this.onSetToolActive=()=>{this._init()},this._init=()=>{const n=this.configuration.sourceImageIds;if(!(n!=null&&n.length)){console.warn("OverlayGridTool: No sourceImageIds provided in configuration");return}const i=ct("imagePlaneModule",n[0]);if(!i){console.warn("OverlayGridTool: No imagePlaneModule found for sourceImageIds");return}const{frameOfReferenceUID:o}=i,a=jr(this.toolGroupId).viewportsInfo;if(!(a!=null&&a.length)){console.warn("OverlayGridTool: No viewports found");return}const s=Jt(this.getToolName(),o);if(!(s!=null&&s.length)){const c=n.map(f=>this.calculateImageIdPointSets(f)),l={highlighted:!0,invalidated:!0,metadata:{toolName:this.getToolName(),FrameOfReferenceUID:o,referencedImageId:null},data:{viewportData:new Map,pointSets:c}};qt(l,o)}We(a.map(({viewportId:c})=>c))},this.calculateImageIdPointSets=n=>{const{imagePositionPatient:i,rows:o,columns:a,rowCosines:s,columnCosines:c,rowPixelSpacing:l,columnPixelSpacing:f}=ct("imagePlaneModule",n),u=[...i],d=[...i],h=[...i],g=[...i];return dn(d,i,c,a*f),dn(h,i,s,o*l),dn(g,h,c,a*f),{pointSet1:[u,h,d,g],pointSet2:[u,d,h,g]}},this.renderAnnotation=(n,i)=>{const o=this.configuration.sourceImageIds;let a=!1;if(!(o!=null&&o.length))return a;const{viewport:s,FrameOfReferenceUID:c}=n;if(s.getImageIds().length<2)return a;const f=Jt(this.getToolName(),c);if(!(f!=null&&f.length))return a;const u=f[0],{annotationUID:d}=u,{focalPoint:h,viewPlaneNormal:g}=s.getCamera(),p={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:n.viewport.id},v=this.getImageIdNormal(o[0]);if(this.isParallel(g,v))return a;const y=Yc(g,h),m=u.data.pointSets,w=u.data.viewportData;for(let x=0;x<o.length;x++){const{pointSet1:C,pointSet2:S}=m[x],T=w.get(s.id)||this.initializeViewportData(w,s.id);if(!T.pointSetsToUse[x]){let H=C,A=Nn(Ke(),C[0],C[1]);A=Un(Ke(),A),this.isPerpendicular(A,g)&&(H=S),T.pointSetsToUse[x]=H,T.lineStartsWorld[x]=Sh(H[0],H[1],y),T.lineEndsWorld[x]=Sh(H[2],H[3],y)}const _=T.lineStartsWorld[x],E=T.lineEndsWorld[x];p.annotationUID=d;const b=this.getStyle("lineWidth",p,u),D=this.getStyle("lineDash",p,u),I=this.getStyle("color",p,u),P=this.getStyle("shadow",p,u),O=[_,E].map(H=>s.worldToCanvas(H)),L=`${d}-line`,B=`${x}`;an(i,d,B,O[0],O[1],{color:I,width:b,lineDash:D,shadow:P},L)}return a=!0,a},this.initializeViewportData=(n,i)=>(n.set(i,{pointSetsToUse:[],lineStartsWorld:[],lineEndsWorld:[]}),n.get(i)),this.isPerpendicular=(n,i)=>{const o=xt(n,i);return Math.abs(o)<f7}}isParallel(e,r){return Math.abs(xt(e,r))>1-f7}getImageIdNormal(e){const{imageOrientationPatient:r}=ct("imagePlaneModule",e),n=Tt(r[0],r[1],r[2]),i=Tt(r[3],r[4],r[5]);return Tn(Ke(),n,i)}}ez.toolName="OverlayGrid";class tz extends Ef{constructor(e={},r={configuration:{opacity:.5}}){super(e,r),this._init=()=>{var s;const n=jr(this.toolGroupId).viewportsInfo;if(!(n!=null&&n.length)){console.warn(this.getToolName()+"Tool: No viewports found");return}const i=(s=Nr(n[0].renderingEngineId))==null?void 0:s.getViewport(n[0].viewportId);if(!i)return;const o=i.getFrameOfReferenceUID(),a=Jt(this.getToolName(),o);if(!(a!=null&&a.length)){const c=new Map;xTe(c,n);const l={highlighted:!0,invalidated:!0,metadata:{toolName:this.getToolName(),FrameOfReferenceUID:o,referencedImageId:null},data:{actorsWorldPointsMap:c}};qt(l,o)}We(n.map(({viewportId:c})=>c))},this.onSetToolEnabled=()=>{this._init()},this.onCameraModified=n=>{this._init()},this.renderAnnotation=(n,i)=>{const{viewport:o,FrameOfReferenceUID:a}=n;let s=!1;const c=Jt(this.getToolName(),a);if(!(c!=null&&c.length))return s;const l=c[0],{annotationUID:f}=l,u=l.data.actorsWorldPointsMap;nz(u,o);const d=o.getActors(),h=rz(o);return d.forEach(g=>{if(!(g!=null&&g.clippingFilter))return;const p=u.get(g.uid);if(!p||!p.get(h))return;let v=1;const{worldPointsSet:y,color:m}=p.get(h);for(let w=0;w<y.length;w++){const C=y[w].map(_=>o.worldToCanvas(_)),S={color:m,fillColor:m,fillOpacity:this.configuration.opacity,closePath:!0,lineWidth:2},T=g.uid+"#"+v;Kl(i,f,T,C,S),v++}}),s=!0,s}}}function xTe(t,e){e.forEach(({viewportId:r,renderingEngineId:n})=>{var o;const i=(o=Nr(n))==null?void 0:o.getViewport(r);nz(t,i)})}function nz(t,e){const r=e.getActors(),n=rz(e);r.forEach(i=>{if(!(i!=null&&i.clippingFilter))return;let o=t.get(i.uid);if(o||(o=new Map,t.set(i.uid,o)),!o.get(n)){const a=i.clippingFilter.getOutputData(),s=AW(a);if(!s)return;const c=i.actor.getProperty().getColor(),l=CTe(c);o.set(n,{worldPointsSet:s,color:l})}})}function rz(t){const{viewPlaneNormal:e}=t.getCamera(),r=t.getCurrentImageIdIndex();return`${t.id}-${wG(e)}-${r}`}function CTe(t){function e(r){let n=Math.floor(r*255).toString(16);return n.length===1&&(n="0"+n),n}return"#"+e(t[0])+e(t[1])+e(t[2])}tz.toolName="SegmentationIntersection";class La extends Ef{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{shadow:!0,preventHandleOutsideImage:!1,displayThreshold:5,positionSync:!0,disableCursor:!1}}){super(e,r),this.isDrawing=!1,this.isHandleOutsideImage=!1,this._elementWithCursor=null,this._currentCursorWorldPosition=null,this._currentCanvasPosition=null,this._disableCursorEnabled=!1,this.mouseMoveCallback=n=>{const{detail:i}=n,{element:o,currentPoints:a}=i;this._currentCursorWorldPosition=a.world,this._currentCanvasPosition=a.canvas,this._elementWithCursor=o;const s=this.getActiveAnnotation(o);return s===null?(this.createInitialAnnotation(a.world,o),!1):(this.updateAnnotationPosition(o,s),!1)},this.createInitialAnnotation=(n,i)=>{const o=Le(i);if(!o)throw new Error("No enabled element found");const{viewport:a,renderingEngine:s}=o;this.isDrawing=!0;const c=a.getCamera(),{viewPlaneNormal:l,viewUp:f}=c;if(!l||!f)throw new Error("Camera not found");const u=this.getReferencedImageId(a,n,l,f),d=a.getFrameOfReferenceUID(),h={highlighted:!0,invalidated:!0,metadata:{toolName:this.getToolName(),viewPlaneNormal:[...l],viewUp:[...f],FrameOfReferenceUID:d,referencedImageId:u},data:{label:"",handles:{points:[[...n]],activeHandleIndex:null,textBox:{hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}}}}};if(Jt(this.getToolName(),i).length>0)return null;if(qt(h,i)===null)return;const v=wt(i,this.getToolName(),!1);We(v)},this.onCameraModified=n=>{const i=n.detail,{element:o,previousCamera:a,camera:s}=i,l=Le(o).viewport;if(o!==this._elementWithCursor)return;const f=a.focalPoint,u=s.viewPlaneNormal,d=s.focalPoint,h=[0,0,0];if(Gt.subtract(d,f,h),h.reduce((v,y)=>v+y,0)===0)return;const g=Gt.dot(h,u);if(Math.abs(g)<.01||!this._currentCanvasPosition)return;const p=l.canvasToWorld(this._currentCanvasPosition);this._currentCursorWorldPosition=p,this.updateAnnotationPosition(o,this.getActiveAnnotation(o))},this.renderAnnotation=(n,i)=>{let o=!1;const{viewport:a,FrameOfReferenceUID:s}=n,c=this._elementWithCursor===a.element;this.configuration.positionSync&&!c&&this.updateViewportImage(a);const{element:l}=a;let f=Jt(this.getToolName(),l);if(!(f!=null&&f.length)||(f=this.filterInteractableAnnotationsForElement(l,f),!(f!=null&&f.length)))return o;const u={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:n.viewport.id};for(let d=0;d<f.length;d++){const h=f[d],{annotationUID:g,data:p}=h,{handles:v}=p,{points:y}=v;if(!g)return o;u.annotationUID=g;const m=parseFloat(this.getStyle("lineWidth",u,h)),w=m,x=this.getStyle("lineDash",u,h),C=this.getStyle("color",u,h);if(y[0].some(I=>isNaN(I)))return o;const S=y.map(I=>a.worldToCanvas(I));if(!a.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),o;if(!Vr(g))continue;const T={upper:"upper",right:"right",lower:"lower",left:"left"},[_,E]=S[0],b=c?20:7,D=c?5:7;an(i,g,T.upper,[_,E-(b/2+D)],[_,E-b/2],{color:C,lineDash:x,lineWidth:w}),an(i,g,T.lower,[_,E+(b/2+D)],[_,E+b/2],{color:C,lineDash:x,lineWidth:w}),an(i,g,T.right,[_+(b/2+D),E],[_+b/2,E],{color:C,lineDash:x,lineWidth:w}),an(i,g,T.left,[_-(b/2+D),E],[_-b/2,E],{color:C,lineDash:x,lineWidth:w}),o=!0}return o},this._disableCursorEnabled=this.configuration.disableCursor}onSetToolActive(){if(this._disableCursorEnabled=this.configuration.disableCursor,!this._disableCursorEnabled)return;const e=jr(this.toolGroupId).viewportsInfo;if(!e)return;e.map(n=>fi(n.viewportId,n.renderingEngineId)).forEach(n=>{n&&Dt(n.viewport.element)})}onSetToolDisabled(){if(!this._disableCursorEnabled)return;const e=jr(this.toolGroupId).viewportsInfo;if(!e)return;e.map(n=>fi(n.viewportId,n.renderingEngineId)).forEach(n=>{n&&kt(n.viewport.element)})}getActiveAnnotation(e){const r=Jt(this.getToolName(),e);return r.length?r[0]:null}updateAnnotationPosition(e,r){var a,s;const n=this._currentCursorWorldPosition;if(!n||!((s=(a=r.data)==null?void 0:a.handles)!=null&&s.points))return;r.data.handles.points=[[...n]],r.invalidated=!0;const i=wt(e,this.getToolName(),!1);Le(e)&&We(i)}filterInteractableAnnotationsForElement(e,r){var d,h,g;if(!(r instanceof Array)||r.length===0)return[];const n=r[0],i=(d=Le(e))==null?void 0:d.viewport;if(!i)return[];const o=i.getCamera(),{viewPlaneNormal:a,focalPoint:s}=o;if(!a||!s)return[];const c=(g=(h=n.data)==null?void 0:h.handles)==null?void 0:g.points;if(!(c instanceof Array)||c.length!==1)return[];const l=c[0],f=Yc(a,s);return m1(f,l)<this.configuration.displayThreshold?[n]:[]}updateViewportImage(e){const r=this._currentCursorWorldPosition;if(!(!r||r.some(n=>isNaN(n)))){if(e instanceof Jn){const n=gE(r,e);if(n===null)return;n!==e.getCurrentImageIdIndex()&&e.setImageIdIndex(n)}else if(e instanceof Zn){const{focalPoint:n,viewPlaneNormal:i}=e.getCamera();if(!n||!i)return;const o=Yc(i,n),a=m1(o,r,!0);if(Math.abs(a)<.5)return;const s=Un(Ke(),Tt(...i)),c=gr(Ke(),s,a),l=Hr(Ke(),Tt(...n),c);{e.setCamera({focalPoint:l});const f=e.getRenderingEngine();f&&f.renderViewport(e.id)}}}}}La.toolName="ReferenceCursors";const d7=[];class iz extends Ef{constructor(e={},r={configuration:{viewportId:"",scaleLocation:"bottom"}}){super(e,r),this.editData=null,this._init=()=>{var g,p;const i=Po()[0];if(!i)return;const o=jr(this.toolGroupId).viewportsInfo;if(!o)return;const a=o.map(v=>fi(v.viewportId,v.renderingEngineId));let{viewport:s}=a[0];const{FrameOfReferenceUID:c}=a[0];if(this.configuration.viewportId&&a.forEach(v=>{v.viewport.id==this.configuration.viewportId&&(s=v.viewport)}),!s)return;const{viewUp:l,viewPlaneNormal:f}=s.getCamera(),u=jy(s);let d=(g=this.editData)==null?void 0:g.annotation;const h=Jt(this.getToolName(),s.element);h.length&&(d=h.filter(v=>v.data.viewportId==s.id)[0]),a.forEach(v=>{const{viewport:y}=v;if(!d7.includes(y.id)){const m={metadata:{toolName:this.getToolName(),viewPlaneNormal:[...f],viewUp:[...l],FrameOfReferenceUID:c,referencedImageId:null},data:{handles:{points:jy(y)},viewportId:y.id}};d7.push(y.id),qt(m,y.element),d=m}}),(p=this.editData)!=null&&p.annotation&&this.editData.annotation.data.viewportId==s.id&&(this.editData.annotation.data.handles.points=u,this.editData.annotation.data.viewportId=s.id),this.editData={viewport:s,renderingEngine:i,annotation:d}},this.onSetToolEnabled=()=>{this._init()},this.onCameraModified=n=>{this.configuration.viewportId=n.detail.viewportId,this._init()},this.computeScaleSize=(n,i,o)=>{const a=[16e3,8e3,4e3,2e3,1e3,500,250,100,50,25,10,5,2];let s;return o=="top"||o=="bottom"?s=a.filter(c=>c<n*.6&&c>n*.2):s=a.filter(c=>c<i*.6&&c>i*.2),s[0]},this.computeEndScaleTicks=(n,i)=>{const o={bottom:[[0,-10],[0,-10]],top:[[0,10],[0,10]],left:[[0,0],[10,0]],right:[[0,0],[-10,0]]},a=[[n[1][0]+o[i][0][0],n[1][1]+o[i][0][0]],[n[1][0]+o[i][1][0],n[1][1]+o[i][1][1]]],s=[[n[0][0]+o[i][0][0],n[0][1]+o[i][0][0]],[n[0][0]+o[i][1][0],n[0][1]+o[i][1][1]]];return{endTick1:a,endTick2:s}},this.computeInnerScaleTicks=(n,i,o,a,s)=>{let c;i=="bottom"||i=="top"?c=s[0][0]-a[0][0]:(i=="left"||i=="right")&&(c=s[0][1]-a[0][1]);const l=[],f=[],u=[];let d=n;n>=50&&(d=n/10);const h=c/d;for(let g=0;g<d-1;g++){const p={bottom:[[h*(g+1),0],[h*(g+1),5]],top:[[h*(g+1),0],[h*(g+1),-5]],left:[[0,h*(g+1)],[-5,h*(g+1)]],right:[[0,h*(g+1)],[5,h*(g+1)]]};l.push(`${o}-tick${g}`),f.push(`tick${g}`),(g+1)%5==0?u.push([[a[0][0]+p[i][0][0],a[0][1]+p[i][0][1]],[a[1][0]+p[i][0][0],a[1][1]+p[i][0][1]]]):u.push([[a[0][0]+p[i][0][0],a[0][1]+p[i][0][1]],[a[1][0]+p[i][1][0],a[1][1]+p[i][1][1]]])}return{tickIds:l,tickUIDs:f,tickCoordinates:u}},this.computeWorldScaleCoordinates=(n,i,o)=>{let a,s=Nn(Ke(),o[0],o[1]);s=Un(Ke(),s);let c=Nn(Ke(),o[2],o[0]);c=Un(Ke(),c);const l={bottom:[o[1],o[2]],top:[o[0],o[3]],right:[o[2],o[3]],left:[o[0],o[1]]},f=Hr(Ke(),l[i][0],l[i][0]).map(d=>d/2),u=n/2/Math.sqrt(Math.pow(s[0],2)+Math.pow(s[1],2)+Math.pow(s[2],2));return i=="top"||i=="bottom"?a=[Nn(Ke(),f,c.map(d=>d*u)),Hr(Ke(),f,c.map(d=>d*u))]:(i=="left"||i=="right")&&(a=[Hr(Ke(),f,s.map(d=>d*u)),Nn(Ke(),f,s.map(d=>d*u))]),a},this.computeCanvasScaleCoordinates=(n,i,o,a,s)=>{let c;if(s=="top"||s=="bottom"){const l=i[0][0]-i[1][0];c=[[n.width/2-l/2,o.height],[n.width/2+l/2,o.height]]}else if(s=="left"||s=="right"){const l=i[0][1]-i[1][1];c=[[a.width,n.height/2-l/2],[a.width,n.height/2+l/2]]}return c},this.computeScaleBounds=(n,i,o,a)=>{const s=i*Math.min(1e3,n.width),c=o*Math.min(1e3,n.height),l={bottom:[-c,-s],top:[c,s],left:[c,s],right:[-c,-s]},f={bottom:[n.height,n.width],top:[0,n.width],left:[n.height,0],right:[n.height,n.width]};return{height:f[a][0]+l[a][0],width:f[a][1]+l[a][1]}}}renderAnnotation(e,r){if(!this.editData||!this.editData.viewport)return;const n=this.configuration.scaleLocation,{viewport:i}=e,a=Jt(this.getToolName(),i.element).filter(_e=>_e.data.viewportId==i.id)[0],s=e.viewport.canvas,c=!1;if(!i)return c;const l={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:e.viewport.id},f={width:s.width/window.devicePixelRatio||1,height:s.height/window.devicePixelRatio||1},u=a.data.handles.points[0],d=a.data.handles.points[1],h=a.data.handles.points[2],g=a.data.handles.points[3],p=[u,h,d,g],v=Fi(h,g),y=Fi(u,h),m=this.computeScaleBounds(f,.05,.05,n),w=this.computeScaleBounds(f,.05,.05,n),x=this.computeScaleSize(v,y,n),C=this.computeWorldScaleCoordinates(x,n,p).map(_e=>i.worldToCanvas(_e)),S=this.computeCanvasScaleCoordinates(f,C,w,m,n),T=this.computeEndScaleTicks(S,n),{annotationUID:_}=a;l.annotationUID=_;const E=this.getStyle("lineWidth",l,a),b=this.getStyle("lineDash",l,a),D=this.getStyle("color",l,a),I=this.getStyle("shadow",l,a),P=`${_}-scaleline`;an(r,_,"1",S[0],S[1],{color:D,width:E,lineDash:b,shadow:I},P);const L=`${_}-left`;an(r,_,"2",T.endTick1[0],T.endTick1[1],{color:D,width:E,lineDash:b,shadow:I},L);const H=`${_}-right`;an(r,_,"3",T.endTick2[0],T.endTick2[1],{color:D,width:E,lineDash:b,shadow:I},H);const F={bottom:[-10,-42],top:[-12,-35],left:[-40,-20],right:[-50,-20]},G=[S[0][0]+F[n][0],S[0][1]+F[n][1]],X=this._getTextLines(x),{tickIds:ee,tickUIDs:ce,tickCoordinates:Se}=this.computeInnerScaleTicks(x,n,_,T.endTick1,T.endTick2);for(let _e=0;_e<ce.length;_e++)an(r,_,ce[_e],Se[_e][0],Se[_e][1],{color:D,width:E,lineDash:b,shadow:I},ee[_e]);return df(r,_,"text0",X,[G[0],G[1]],{fontFamily:"Helvetica Neue, Helvetica, Arial, sans-serif",fontSize:"14px",lineDash:"2,3",lineWidth:"1",shadow:!0,color:D}),c}_getTextLines(e){let r,n;return e>=50?(r=e/10,n=" cm"):(r=e,n=" mm"),[r.toString().concat(n)]}}iz.toolName="ScaleOverlay";const oz=(t,e,r)=>{var a,s,c;if(!((c=(s=(a=e==null?void 0:e.data)==null?void 0:a.contour)==null?void 0:s.polyline)!=null&&c.length))return;const{polyline:n}=e.data.contour,{length:i}=n;let o=1/0;for(let l=0;l<i;l++){const f=t.worldToCanvas(n[l]),u=Do(f,r);o=Math.min(o,u)}if(!(o===1/0||isNaN(o)))return o},kc=class kc{constructor(){this.toolInfo={toolSize:null,maxToolSize:null}}renderShape(e,r,n){Yo(e,"SculptorTool","0",r,this.toolInfo.toolSize,n)}pushHandles(e,r){const{points:n,mouseCanvasPoint:i}=r,o={first:void 0,last:void 0},a=Do(e.canvasToWorld(i),e.canvasToWorld([i[0]+this.toolInfo.toolSize,i[1]]));for(let s=0;s<n.length;s++){const c=e.worldToCanvas(n[s]);Do(c,i)>this.toolInfo.toolSize||(this.pushOneHandle(s,a,r),o.first===void 0&&(o.first=s),o.last=s)}if(o.first!==void 0&&o.last!==void 0)for(let s=0;s<kc.CHAIN_MAINTENANCE_ITERATIONS;s++)this.maintainChainStructure(r,o);return o}configureToolSize(e){const r=this.toolInfo;if(r.toolSize&&r.maxToolSize)return;const i=e.detail.element,a=Math.min(i.clientWidth,i.clientHeight)/12;r.toolSize=a,r.maxToolSize=a}updateToolSize(e,r,n){const i=this.toolInfo,o=oz(r,n,e);o>0&&(i.toolSize=Math.min(i.maxToolSize,o))}getMaxSpacing(e){return Math.max(this.toolInfo.toolSize/4,e)}getInsertPosition(e,r,n){let i;const{points:o,element:a,mouseCanvasPoint:s}=n,c=this.toolInfo.toolSize,l=Le(a),{viewport:f}=l,u=f.worldToCanvas(o[e]),d=f.worldToCanvas(o[r]),h=[(u[0]+d[0])/2,(u[1]+d[1])/2],g=Do(s,h);if(g<c){const v={x:(h[0]-s[0])/g,y:(h[1]-s[1])/g};i=[s[0]+c*v.x,s[1]+c*v.y]}else i=h;return f.canvasToWorld(i)}pushOneHandle(e,r,n){const{points:i,mousePoint:o}=n,a=i[e],s=this.directionalVector(o,a),c=dn(Ke(),o,s,r);a[0]=c[0],a[1]=c[1],a[2]=c[2]}directionalVector(e,r){return Un(Ke(),[r[0]-e[0],r[1]-e[1],r[2]-e[2]])}calculateMeanConsecutiveDistance(e){if(e.length<2)return 0;let r=0;const n=e.length;for(let i=0;i<n;i++){const o=(i+1)%n,a=Do(e[i],e[o]);r+=a}return r/n}maintainChainStructure(e,r){const{points:n}=e,i=r.first,o=r.last,a=Math.round((i+o)/2),s=n.length;e.meanDistance||(e.meanDistance=this.calculateMeanConsecutiveDistance(n));const c=e.meanDistance*kc.MAX_INTER_DISTANCE_FACTOR;for(let l=a;l>=0;l--){if(l>=s-1||l<0)continue;const f=l+1,u=Do(n[l],n[f]);if(u>c){const d=this.directionalVector(n[l],n[f]),g=(u-e.meanDistance)/e.meanDistance*e.meanDistance*kc.CHAIN_PULL_STRENGTH_FACTOR;n[l][0]+=d[0]*g,n[l][1]+=d[1]*g,n[l][2]+=d[2]*g}}for(let l=a+1;l<s;l++){if(l>=s||l<=0)continue;const f=l-1,u=Do(n[l],n[f]);if(u>c){const d=this.directionalVector(n[l],n[f]),g=(u-e.meanDistance)/e.meanDistance*e.meanDistance*kc.CHAIN_PULL_STRENGTH_FACTOR;n[l][0]+=d[0]*g,n[l][1]+=d[1]*g,n[l][2]+=d[2]*g}}}};kc.shapeName="Circle",kc.CHAIN_MAINTENANCE_ITERATIONS=3,kc.CHAIN_PULL_STRENGTH_FACTOR=.3,kc.MAX_INTER_DISTANCE_FACTOR=1.2;let Dp=kc;class Rh extends ri{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{minSpacing:1,referencedToolNames:["PlanarFreehandROI","PlanarFreehandContourSegmentationTool"],toolShape:"circle",referencedToolName:"PlanarFreehandROI",updateCursorSize:"dynamic"}}){super(e,r),this.registeredShapes=new Map,this.isActive=!1,this.commonData={activeAnnotationUID:null,viewportIdsToRender:[],isEditingOpenContour:!1,canvasLocation:void 0},this.preMouseDownCallback=n=>{const i=n.detail,o=i.element;if(this.configureToolSize(n),this.selectFreehandTool(i),this.commonData.activeAnnotationUID!==null)return this.isActive=!0,Dt(o),this.activateModify(o),!0},this.mouseMoveCallback=n=>{this.mode===En.Active?(this.configureToolSize(n),this.updateCursor(n)):this.commonData.canvasLocation=void 0},this.endCallback=n=>{const i=n.detail,{element:o}=i,a=this.configuration,s=Le(o);this.isActive=!1,this.deactivateModify(o),kt(o);const{renderingEngineId:c,viewportId:l}=s,u=vr(l,c).getToolInstance(a.referencedToolName),h=this.filterSculptableAnnotationsForElement(o).find(g=>g.annotationUID===this.commonData.activeAnnotationUID);u.configuration.calculateStats&&(h.invalidated=!0),Kt(h,o,Bt.HandlesUpdated)},this.dragCallback=n=>{const i=n.detail,o=i.element;this.updateCursor(n);const a=this.filterSculptableAnnotationsForElement(o),s=a.find(l=>l.annotationUID===this.commonData.activeAnnotationUID);if(!(a!=null&&a.length)||!this.isActive)return;const c=s.data.contour.polyline;this.sculpt(i,c)},this.registerShapes(Dp.shapeName,Dp),this.setToolShape(this.configuration.toolShape)}registerShapes(e,r){const n=new r;this.registeredShapes.set(e,n)}sculpt(e,r){const n=this.configuration,i=e.element,o=Le(i),{viewport:a}=o,s=this.registeredShapes.get(this.selectedShape);this.sculptData={mousePoint:e.currentPoints.world,mouseCanvasPoint:e.currentPoints.canvas,deltaWorld:e.deltaPoints.world,points:r,maxSpacing:s.getMaxSpacing(n.minSpacing),element:i};const c=s.pushHandles(a,this.sculptData);c.first!==void 0&&this.insertNewHandles(c)}interpolatePointsWithinMaxSpacing(e,r,n,i){const{element:o}=this.sculptData,a=Le(o),{viewport:s}=a,c=h7(e+1,r.length),l=s.worldToCanvas(r[e]),f=s.worldToCanvas(r[c]);Do(l,f)>i&&n.push(e)}updateCursor(e){const r=e.detail,n=r.element,i=Le(n),{renderingEngine:o,viewport:a}=i;this.commonData.viewportIdsToRender=[a.id];const s=this.filterSculptableAnnotationsForElement(n);if(!(s!=null&&s.length))return;const c=s.find(l=>l.annotationUID===this.commonData.activeAnnotationUID);if(this.commonData.canvasLocation=r.currentPoints.canvas,this.isActive)c.highlighted=!0;else{const l=this.registeredShapes.get(this.selectedShape),f=r.currentPoints.canvas;this.configuration.updateCursorSize==="dynamic"&&l.updateToolSize(f,a,c)}We(this.commonData.viewportIdsToRender)}filterSculptableAnnotationsForElement(e){const r=this.configuration,n=Le(e),{renderingEngineId:i,viewportId:o}=n,a=[],c=vr(o,i).getToolInstance(r.referencedToolName);return r.referencedToolNames.forEach(l=>{const f=Jt(l,e);f&&a.push(...f)}),c.filterInteractableAnnotationsForElement(e,a)}configureToolSize(e){this.registeredShapes.get(this.selectedShape).configureToolSize(e)}insertNewHandles(e){const r=this.findNewHandleIndices(e);let n=0;for(let i=0;i<(r==null?void 0:r.length);i++){const o=r[i]+1+n;this.insertHandleRadially(o),n++}}findNewHandleIndices(e){const{points:r,maxSpacing:n}=this.sculptData,i=[];for(let o=e.first;o<=e.last;o++)this.interpolatePointsWithinMaxSpacing(o,r,i,n);return i}insertHandleRadially(e){const{points:r}=this.sculptData;if(e>r.length-1&&this.commonData.isEditingOpenContour)return;const n=this.registeredShapes.get(this.selectedShape),i=e-1,o=h7(e,r.length),s=n.getInsertPosition(i,o,this.sculptData);r.splice(e,0,s)}selectFreehandTool(e){const r=this.getClosestFreehandToolOnElement(e);r!==void 0&&(this.commonData.activeAnnotationUID=r)}getClosestFreehandToolOnElement(e){const{element:r}=e,n=Le(r),{viewport:i}=n,o=this.configuration,a=this.filterSculptableAnnotationsForElement(r);if(!(a!=null&&a.length))return;const s=e.currentPoints.canvas,c={distance:1/0,toolIndex:void 0,annotationUID:void 0};for(let l=0;l<(a==null?void 0:a.length);l++){if(a[l].isLocked||!a[l].isVisible)continue;const f=oz(i,a[l],s);f!==-1&&f<c.distance&&(c.distance=f,c.toolIndex=l,c.annotationUID=a[l].annotationUID)}return this.commonData.isEditingOpenContour=!a[c.toolIndex].data.contour.closed,o.referencedToolName=a[c.toolIndex].metadata.toolName,c.annotationUID}activateModify(e){e.addEventListener(U.MOUSE_UP,this.endCallback),e.addEventListener(U.MOUSE_CLICK,this.endCallback),e.addEventListener(U.MOUSE_DRAG,this.dragCallback),e.addEventListener(U.TOUCH_TAP,this.endCallback),e.addEventListener(U.TOUCH_END,this.endCallback),e.addEventListener(U.TOUCH_DRAG,this.dragCallback)}deactivateModify(e){e.removeEventListener(U.MOUSE_UP,this.endCallback),e.removeEventListener(U.MOUSE_CLICK,this.endCallback),e.removeEventListener(U.MOUSE_DRAG,this.dragCallback),e.removeEventListener(U.TOUCH_TAP,this.endCallback),e.removeEventListener(U.TOUCH_END,this.endCallback),e.removeEventListener(U.TOUCH_DRAG,this.dragCallback)}setToolShape(e){this.selectedShape=this.registeredShapes.get(e)??Dp.shapeName}renderAnnotation(e,r){const{viewport:n}=e,{element:i}=n,o=this.commonData.viewportIdsToRender;if(!this.commonData.canvasLocation||this.mode!==En.Active||!o.includes(n.id))return;const a=this.filterSculptableAnnotationsForElement(i);if(!(a!=null&&a.length))return;const s={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:e.viewport.id};let c=Dh("color",s,tc.Default,this.mode);this.isActive&&(c=Dh("color",s,tc.Highlighted,this.mode)),this.registeredShapes.get(this.selectedShape).renderShape(r,this.commonData.canvasLocation,{color:c})}}const h7=(t,e)=>(t+e)%e;Rh.toolName="SculptorTool";const STe={Z:[0,0,1]};class az extends ri{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{direction:STe.Z,rotateIncrementDegrees:30}}){super(e,r)}mouseWheelCallback(e){const{element:r,wheel:n}=e.detail,i=Le(r),{viewport:o}=i,{direction:a,rotateIncrementDegrees:s}=this.configuration,c=o.getCamera(),{viewUp:l,position:f,focalPoint:u}=c,{direction:d}=n,[h,g,p]=u,[v,y,m]=a,w=d*(s*Math.PI)/180,x=[0,0,0],C=[0,0,0],S=[0,0,0],T=It(new Float32Array(16));er(T,T,[h,g,p]),To(T,T,w,[v,y,m]),er(T,T,[-h,-g,-p]),At(x,f,T),At(C,u,T),It(T),To(T,T,w,[v,y,m]),At(S,l,T),o.setCamera({position:x,viewUp:S,focalPoint:C}),o.render()}}az.toolName="VolumeRotateMouseWheel";const Vp=class Vp extends Yn{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{shadow:!0,getTextCallback:TTe,changeTextCallback:_Te,preventHandleOutsideImage:!1}}){super(e,r),this.isPointNearTool=(n,i,o,a)=>{const s=Le(n),{viewport:c}=s,{annotationUID:l}=i,f=i.data.handles.points[0],u=c.worldToCanvas(f);if(ur(o,u)<a)return!0;const h=n.querySelector("svg");if(!h)return!1;const g=h.querySelector(`g[data-annotation-uid="${l}"]`);if(!g)return!1;const p=g,v=p.getBBox(),y=p.getAttribute("transform");let m=0,w=0;if(y){const T=y.match(/translate\(([-\d.]+)\s+([-\d.]+)\)/);T&&(m=parseFloat(T[1]),w=parseFloat(T[2]))}const x=v.x+m,C=v.y+w;return o[0]>=x&&o[0]<=x+v.width&&o[1]>=C&&o[1]<=C+v.height},this.addNewAnnotation=n=>{const i=n.detail,{currentPoints:o,element:a}=i,s=o.world,c=Le(a),{viewport:l}=c;Dt(a),this.isDrawing=!0;const f=l.getCamera(),{viewPlaneNormal:u,viewUp:d}=f,h=this.getReferencedImageId(l,s,u,d),g=l.getFrameOfReferenceUID(),p={annotationUID:null,highlighted:!0,invalidated:!0,metadata:{toolName:this.getToolName(),viewPlaneNormal:[...u],viewUp:[...d],FrameOfReferenceUID:g,referencedImageId:h,...l.getViewReference({points:[s]})},data:{text:"",handles:{points:[[...s],[...s]]},label:""}};qt(p,a);const v=wt(a,this.getToolName());return this.editData={annotation:p,newAnnotation:!0,viewportIdsToRender:v,offset:[0,0,0]},n.preventDefault(),We(v),this.configuration.getTextCallback(y=>{if(!y){en(p.annotationUID),We(v),this.isDrawing=!1;return}kt(a),p.data.text=y,bn(p),We(v)}),this.createMemo(a,p,{newAnnotation:!0}),p},this.toolSelectedCallback=(n,i)=>{const o=n.detail,{element:a,currentPoints:s}=o;i.highlighted=!0;const c=wt(a,this.getToolName());let l=[0,0,0];if(s&&s.world){const f=s.world,u=i.data.handles.points[0];l=[u[0]-f[0],u[1]-f[1],u[2]-f[2]]}this.editData={annotation:i,viewportIdsToRender:c,offset:l},this._activateModify(a),Dt(a),We(c),n.preventDefault()},this._endCallback=n=>{const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s,newAnnotation:c}=this.editData;this._deactivateDraw(o),this._deactivateModify(o),kt(o),c&&this.createMemo(o,a,{newAnnotation:c}),this.editData=null,this.isDrawing=!1,this.doneEditMemo(),this.isHandleOutsideImage&&this.configuration.preventHandleOutsideImage&&en(a.annotationUID),We(s),c&&bn(a)},this._dragCallback=n=>{const i=n.detail,{currentPoints:o,element:a}=i,s=o.world,{annotation:c,viewportIdsToRender:l,offset:f}=this.editData;f?c.data.handles.points[0]=[s[0]+f[0],s[1]+f[1],s[2]+f[2]]:c.data.handles.points[0]=[...s],c.invalidated=!0,We(l),Kt(c,a,Bt.LabelChange)},this.cancel=n=>{if(this.isDrawing){this.isDrawing=!1,this._deactivateModify(n),kt(n);const{annotation:i,viewportIdsToRender:o,newAnnotation:a}=this.editData,{data:s}=i;return i.highlighted=!1,s.handles.activeHandleIndex=null,We(o),a&&bn(i),this.editData=null,i.annotationUID}},this._activateModify=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragCallback)},this._deactivateModify=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragCallback),n.removeEventListener(U.TOUCH_END,this._endCallback)},this._activateDraw=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragCallback),n.addEventListener(U.MOUSE_MOVE,this._dragCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragCallback)},this._deactivateDraw=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragCallback),n.removeEventListener(U.MOUSE_MOVE,this._dragCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback),n.removeEventListener(U.TOUCH_END,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragCallback)},this.renderAnnotation=(n,i)=>{let o=!1;const{viewport:a}=n,{element:s}=a;let c=Jt(this.getToolName(),s);if(!(c!=null&&c.length))return o;c=this.filterInteractableAnnotationsForElement(s,c);const l={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:n.viewport.id};for(let f=0;f<c.length;f++){const u=c[f],{annotationUID:d,data:h}=u,g=h.handles.points[0];l.annotationUID=d;const p=a.worldToCanvas(g);if(o=!0,!a.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),o;if(!Vr(d)||!h.text)continue;const v=this.getLinkedTextBoxStyle(l,u);df(i,d,"1",[h.text],p,{...v,padding:0})}return o}}handleSelectedCallback(e,r,n,i){}_doneChangingTextCallback(e,r,n){r.data.text=n;const i=wt(e,this.getToolName());We(i),Kt(r,e)}_isInsideVolume(e,r,n){return tr(e,n)&&tr(r,n)}};Vp.toolName="Label",Vp.hydrate=(e,r,n,i)=>{const o=Mn(e);if(!o)return;const{viewport:a}=o,s=a.getFrameOfReferenceUID(),{viewPlaneNormal:c,viewUp:l}=a.getCamera(),f=new Vp,u=f.getReferencedImageId(a,r,c,l),d={annotationUID:(i==null?void 0:i.annotationUID)||gn(),data:{text:n,handles:{points:[r]}},highlighted:!1,autoGenerated:!1,invalidated:!1,isLocked:!1,isVisible:!0,metadata:{toolName:f.getToolName(),viewPlaneNormal:c,FrameOfReferenceUID:s,referencedImageId:u,...i}};qt(d,a.element),We([a.id])};let _5=Vp;function TTe(t){return t(prompt("Enter your annotation:"))}function _Te(t,e,r){return r(prompt("Enter your annotation:"))}_5.toolName="Label";const{transformWorldToIndex:g7}=pn,N0=class N0 extends Yn{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{preventHandleOutsideImage:!1,getTextLines:ETe,actions:{undo:{method:"undo",bindings:[{key:"z"}]},redo:{method:"redo",bindings:[{key:"y"}]}}}}){super(e,r),this.addNewAnnotation=n=>{const i=n.detail,{currentPoints:o,element:a}=i,s=o.world,c=Le(a),{viewport:l}=c;Dt(a),this.isDrawing=!0;const{viewPlaneNormal:f,viewUp:u,position:d}=l.getCamera(),h=this.getReferencedImageId(l,s,f,u),g={highlighted:!0,invalidated:!0,metadata:{...l.getViewReference({points:[s]}),toolName:this.getToolName(),referencedImageId:h,viewUp:u,cameraPosition:d},data:{handles:{points:[[...s],[...s]],activeHandleIndex:null,textBox:{hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}}},label:"",cachedStats:{}}};qt(g,a);const p=wt(a,this.getToolName());return this.editData={annotation:g,viewportIdsToRender:p,handleIndex:1,movingTextBox:!1,newAnnotation:!0,hasMoved:!1},this._activateDraw(a),n.preventDefault(),We(p),g},this.isPointNearTool=(n,i,o,a)=>{const s=Le(n),{viewport:c}=s,{data:l}=i,[f,u]=l.handles.points,d=c.worldToCanvas(f),h=c.worldToCanvas(u),g={start:{x:d[0],y:d[1]},end:{x:h[0],y:h[1]}};return ui([g.start.x,g.start.y],[g.end.x,g.end.y],[o[0],o[1]])<=a},this.toolSelectedCallback=(n,i)=>{const o=n.detail,{element:a}=o;i.highlighted=!0;const s=wt(a,this.getToolName());this.editData={annotation:i,viewportIdsToRender:s,movingTextBox:!1},this._activateModify(a),Dt(a),We(s),n.preventDefault()},this._endCallback=n=>{const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s,newAnnotation:c,hasMoved:l}=this.editData,{data:f}=a;c&&!l||(f.handles.activeHandleIndex=null,this._deactivateModify(o),this._deactivateDraw(o),kt(o),this.isHandleOutsideImage&&this.configuration.preventHandleOutsideImage&&en(a.annotationUID),We(s),this.doneEditMemo(),c&&bn(a),this.editData=null,this.isDrawing=!1)},this._dragCallback=n=>{this.isDrawing=!0;const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s,handleIndex:c,movingTextBox:l,newAnnotation:f}=this.editData,{data:u}=a;if(this.createMemo(o,a,{newAnnotation:f}),l){const{deltaPoints:d}=i,h=d.world,{textBox:g}=u.handles,{worldPosition:p}=g;p[0]+=h[0],p[1]+=h[1],p[2]+=h[2],g.hasMoved=!0}else if(c===void 0){const{deltaPoints:d}=i,h=d.world;u.handles.points.forEach(p=>{p[0]+=h[0],p[1]+=h[1],p[2]+=h[2]}),a.invalidated=!0}else{const{currentPoints:d}=i,h=d.world;u.handles.points[c]=[...h],a.invalidated=!0}this.editData.hasMoved=!0,We(s),a.invalidated&&Kt(a,o,Bt.HandlesUpdated)},this.cancel=n=>{if(this.isDrawing){this.isDrawing=!1,this._deactivateDraw(n),this._deactivateModify(n),kt(n);const{annotation:i,viewportIdsToRender:o,newAnnotation:a}=this.editData,{data:s}=i;return i.highlighted=!1,s.handles.activeHandleIndex=null,We(o),a&&bn(i),this.editData=null,i.annotationUID}},this._activateModify=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback)},this._deactivateModify=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.TOUCH_END,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback)},this._activateDraw=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragCallback),n.addEventListener(U.MOUSE_MOVE,this._dragCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback)},this._deactivateDraw=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragCallback),n.removeEventListener(U.MOUSE_MOVE,this._dragCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.TOUCH_END,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback)},this.renderAnnotation=(n,i)=>{let o=!1;const{viewport:a}=n,{element:s}=a;let c=Jt(this.getToolName(),s);if(!(c!=null&&c.length)||(c=this.filterInteractableAnnotationsForElement(s,c),!(c!=null&&c.length)))return o;const l=this.getTargetId(a),f=a.getRenderingEngine(),u={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:n.viewport.id};for(let d=0;d<c.length;d++){const h=c[d],{annotationUID:g,data:p}=h,{points:v,activeHandleIndex:y}=p.handles;u.annotationUID=g;const{color:m,lineWidth:w,lineDash:x,shadow:C}=this.getAnnotationStyle({annotation:h,styleSpecifier:u}),S=v.map(F=>a.worldToCanvas(F));if(!p.cachedStats[l]||p.cachedStats[l].unit==null?(p.cachedStats[l]={length:null,unit:null},this._calculateCachedStats(h,f,n)):h.invalidated&&this._throttledCalculateCachedStats(h,f,n),!a.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),o;let T;if(!Vr(g))continue;!Yr(g)&&!this.editData&&y!==null&&(T=[S[y]]),T&&Kn(i,g,"0",S,{color:m,lineDash:x,lineWidth:w});const _=`${g}-line`;if(an(i,g,"1",S[0],S[1],{color:m,width:w,lineDash:x,shadow:C},_),o=!0,!a.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),o;const b=this.getLinkedTextBoxStyle(u,h);if(!b.visibility){p.handles.textBox={hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}};continue}const D=this.configuration.getTextLines(p,l);if(!p.handles.textBox.hasMoved){const F=wa(S);p.handles.textBox.worldPosition=a.canvasToWorld(F)}const I=a.worldToCanvas(p.handles.textBox.worldPosition),O=Ji(i,g,"1",D,I,S,{},b),{x:L,y:B,width:H,height:A}=O;p.handles.textBox.worldBoundingBox={topLeft:a.canvasToWorld([L,B]),topRight:a.canvasToWorld([L+H,B]),bottomLeft:a.canvasToWorld([L,B+A]),bottomRight:a.canvasToWorld([L+H,B+A])}}return o},this._throttledCalculateCachedStats=Lo(this._calculateCachedStats,100,{trailing:!0})}handleSelectedCallback(e,r,n){const i=e.detail,{element:o}=i,{data:a}=r;r.highlighted=!0;let s=!1,c;n.worldPosition?s=!0:c=a.handles.points.findIndex(f=>f===n);const l=wt(o,this.getToolName());this.editData={annotation:r,viewportIdsToRender:l,handleIndex:c,movingTextBox:s},this._activateModify(o),Dt(o),We(l),e.preventDefault()}_calculateLength(e,r){const n=e[0]-r[0],i=e[1]-r[1],o=e[2]-r[2];return Math.sqrt(n*n+i*i+o*o)}_calculateCachedStats(e,r,n){const i=e.data,{element:o}=n.viewport,a=i.handles.points[0],s=i.handles.points[1],{cachedStats:c}=i,l=Object.keys(c);for(let u=0;u<l.length;u++){const d=l[u],h=this.getTargetImageData(d);if(!h)continue;const{imageData:g,dimensions:p}=h,v=g7(g,a),y=g7(g,s),m=[v,y],{scale:w,unit:x}=ya(h,m),C=this._calculateLength(a,s)/w;this._isInsideVolume(v,y,p)?this.isHandleOutsideImage=!1:this.isHandleOutsideImage=!0,c[d]={length:C,unit:x}}const f=e.invalidated;return e.invalidated=!1,f&&Kt(e,o,Bt.StatsUpdated),c}_isInsideVolume(e,r,n){return tr(e,n)&&tr(r,n)}};N0.toolName="Length",N0.hydrate=(e,r,n)=>{const i=Mn(e);if(!i)return;const{FrameOfReferenceUID:o,referencedImageId:a,viewPlaneNormal:s,instance:c,viewport:l}=N0.hydrateBase(N0,i,r,n),{toolInstance:f,...u}=n||{},d={annotationUID:(n==null?void 0:n.annotationUID)||gn(),data:{handles:{points:r}},highlighted:!1,autoGenerated:!1,invalidated:!1,isLocked:!1,isVisible:!0,metadata:{toolName:c.getToolName(),viewPlaneNormal:s,FrameOfReferenceUID:o,referencedImageId:a,...u}};qt(d,l.element),We([l.id])};let pf=N0;function ETe(t,e){const r=t.cachedStats[e],{length:n,unit:i}=r;return n==null||isNaN(n)?void 0:[`${Xt(n)} ${i}`]}const{transformWorldToIndex:p7}=pn,sb=class sb extends Yn{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{preventHandleOutsideImage:!1,getTextLines:bTe}}){super(e,r),this.addNewAnnotation=n=>{const i=n.detail,{currentPoints:o,element:a}=i,s=o.world,c=Le(a),{viewport:l,renderingEngine:f}=c;Dt(a),this.isDrawing=!0;const{viewPlaneNormal:u,viewUp:d,position:h}=l.getCamera(),g=this.getReferencedImageId(l,s,u,d),p={highlighted:!0,invalidated:!0,metadata:{...l.getViewReference({points:[s]}),toolName:this.getToolName(),referencedImageId:g,viewUp:d,cameraPosition:h},data:{handles:{points:[[...s],[...s]],activeHandleIndex:null,textBox:{hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}}},label:"",cachedStats:{}}};qt(p,a);const v=wt(a,this.getToolName());return this.editData={annotation:p,viewportIdsToRender:v,handleIndex:1,movingTextBox:!1,newAnnotation:!0,hasMoved:!1},this._activateDraw(a),n.preventDefault(),We(v),p},this.isPointNearTool=(n,i,o,a)=>{const s=Le(n),{viewport:c}=s,{data:l}=i,[f,u]=l.handles.points,d=c.worldToCanvas(f),h=c.worldToCanvas(u),g={start:{x:d[0],y:d[1]},end:{x:h[0],y:h[1]}};return ui([g.start.x,g.start.y],[g.end.x,g.end.y],[o[0],o[1]])<=a},this.toolSelectedCallback=(n,i)=>{const o=n.detail,{element:a}=o;i.highlighted=!0;const s=wt(a,this.getToolName());this.editData={annotation:i,viewportIdsToRender:s,movingTextBox:!1},this._activateModify(a),Dt(a),Le(a),We(s),n.preventDefault()},this._endCallback=n=>{const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s,newAnnotation:c,hasMoved:l}=this.editData,{data:f}=a;if(c&&!l)return;f.handles.activeHandleIndex=null,this._deactivateModify(o),this._deactivateDraw(o),kt(o);const u=Le(o),{renderingEngine:d}=u;this.isHandleOutsideImage&&this.configuration.preventHandleOutsideImage&&en(a.annotationUID),We(s),c&&bn(a),this.editData=null,this.isDrawing=!1},this._dragCallback=n=>{this.isDrawing=!0;const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s,handleIndex:c,movingTextBox:l}=this.editData,{data:f}=a;if(l){const{deltaPoints:h}=i,g=h.world,{textBox:p}=f.handles,{worldPosition:v}=p;v[0]+=g[0],v[1]+=g[1],v[2]+=g[2],p.hasMoved=!0}else if(c===void 0){const{deltaPoints:h}=i,g=h.world;f.handles.points.forEach(v=>{v[0]+=g[0],v[1]+=g[1],v[2]+=g[2]}),a.invalidated=!0}else{const{currentPoints:h}=i,g=h.world;f.handles.points[c]=[...g],a.invalidated=!0}this.editData.hasMoved=!0;const u=Le(o),{renderingEngine:d}=u;We(s)},this.cancel=n=>{if(this.isDrawing){this.isDrawing=!1,this._deactivateDraw(n),this._deactivateModify(n),kt(n);const{annotation:i,viewportIdsToRender:o,newAnnotation:a}=this.editData,{data:s}=i;return i.highlighted=!1,s.handles.activeHandleIndex=null,Le(n),We(o),a&&bn(i),this.editData=null,i.annotationUID}},this._activateModify=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback)},this._deactivateModify=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.TOUCH_END,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback)},this._activateDraw=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragCallback),n.addEventListener(U.MOUSE_MOVE,this._dragCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback)},this._deactivateDraw=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragCallback),n.removeEventListener(U.MOUSE_MOVE,this._dragCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.TOUCH_END,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback)},this.renderAnnotation=(n,i)=>{let o=!1;const{viewport:a}=n,{element:s}=a;let c=Jt(this.getToolName(),s);if(!(c!=null&&c.length)||(c=this.filterInteractableAnnotationsForElement(s,c),!(c!=null&&c.length)))return o;const l=this.getTargetId(a),f=a.getRenderingEngine(),u={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:n.viewport.id};for(let d=0;d<c.length;d++){const h=c[d],{annotationUID:g,data:p}=h,{points:v,activeHandleIndex:y}=p.handles;u.annotationUID=g;const{color:m,lineWidth:w,lineDash:x,shadow:C}=this.getAnnotationStyle({annotation:h,styleSpecifier:u}),S=v.map(A=>a.worldToCanvas(A));let T;if(!p.cachedStats[l]||p.cachedStats[l].unit==null?(p.cachedStats[l]={length:null,unit:null},this._calculateCachedStats(h,f,n)):h.invalidated&&this._throttledCalculateCachedStats(h,f,n),!Vr(g))continue;if(!Yr(g)&&!this.editData&&y!==null&&(T=[S[y]]),T&&Kn(i,g,"0",S,{color:m,lineDash:x,lineWidth:w}),qU(i,g,"0",S[0],S[1],{color:m,width:w,lineDash:x}),o=!0,!a.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),o;const E=this.getLinkedTextBoxStyle(u,h);if(!E.visibility){p.handles.textBox={hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}};continue}const b=this.configuration.getTextLines(p,l);if(!p.handles.textBox.hasMoved){const A=wa(S);p.handles.textBox.worldPosition=a.canvasToWorld(A)}const D=a.worldToCanvas(p.handles.textBox.worldPosition),P=Ji(i,g,"1",b,D,S,{},E),{x:O,y:L,width:B,height:H}=P;p.handles.textBox.worldBoundingBox={topLeft:a.canvasToWorld([O,L]),topRight:a.canvasToWorld([O+B,L]),bottomLeft:a.canvasToWorld([O,L+H]),bottomRight:a.canvasToWorld([O+B,L+H])}}return o},this._throttledCalculateCachedStats=Lo(this._calculateCachedStats,100,{trailing:!0})}handleSelectedCallback(e,r,n){const i=e.detail,{element:o}=i,{data:a}=r;r.highlighted=!0;let s=!1,c;n.worldPosition?s=!0:c=a.handles.points.findIndex(d=>d===n);const l=wt(o,this.getToolName());this.editData={annotation:r,viewportIdsToRender:l,handleIndex:c,movingTextBox:s},this._activateModify(o),Dt(o);const f=Le(o),{renderingEngine:u}=f;We(l),e.preventDefault()}_calculateHeight(e,r){const n=r[0]-e[0],i=r[1]-e[1],o=r[2]-e[2];if(n==0)return i!=0?Math.abs(o):0;if(i==0)return Math.abs(o);if(o==0)return Math.abs(i)}_calculateCachedStats(e,r,n){const i=e.data,{element:o}=n.viewport,a=i.handles.points[0],s=i.handles.points[1],{cachedStats:c}=i,l=Object.keys(c);for(let u=0;u<l.length;u++){const d=l[u],h=this.getTargetImageData(d);if(!h)continue;const{imageData:g,dimensions:p}=h,v=p7(g,a),y=p7(g,s),m=[v,y],{scale:w,unit:x}=ya(h,m),C=this._calculateHeight(a,s)/w,S=this._isInsideVolume(v,y,p);this.isHandleOutsideImage=S,c[d]={height:C,unit:x}}const f=e.invalidated;return e.invalidated=!1,f&&Kt(e,o,Bt.StatsUpdated),c}_isInsideVolume(e,r,n){return tr(e,n)&&tr(r,n)}};sb.toolName="Height";let fT=sb;function bTe(t,e){const r=t.cachedStats[e],{height:n,unit:i}=r;return n==null||isNaN(n)?void 0:[`${Xt(n)} ${i}`]}const{transformWorldToIndex:DTe}=pn,Du=class Du extends Yn{constructor(e={},r){super(e,Yn.mergeDefaultProps(Du.probeDefaults,r)),this.addNewAnnotation=n=>{const i=n.detail,{currentPoints:o,element:a}=i,s=o.world,c=Le(a),{viewport:l}=c;this.isDrawing=!0;const f=this.constructor.createAnnotationForViewport(l,{data:{handles:{points:[[...s]]}}});qt(f,a);const u=wt(a,this.getToolName());return this.editData={annotation:f,newAnnotation:!0,viewportIdsToRender:u},this._activateModify(a),Dt(a),n.preventDefault(),We(u),f},this._endCallback=n=>{const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s,newAnnotation:c}=this.editData,{viewportId:l,renderingEngine:f}=Le(o);this.eventDispatchDetail={viewportId:l,renderingEngineId:f.id},this._deactivateModify(o),kt(o),c&&this.createMemo(o,a,{newAnnotation:c}),this.editData=null,this.isDrawing=!1,this.doneEditMemo(),this.isHandleOutsideImage&&this.configuration.preventHandleOutsideImage&&en(a.annotationUID),We(s),c&&bn(a)},this._dragCallback=n=>{this.isDrawing=!0;const i=n.detail,{currentPoints:o,element:a}=i,s=o.world,{annotation:c,viewportIdsToRender:l,newAnnotation:f}=this.editData,{data:u}=c;this.createMemo(a,c,{newAnnotation:f}),u.handles.points[0]=[...s],c.invalidated=!0,We(l)},this.cancel=n=>{if(this.isDrawing){this.isDrawing=!1,this._deactivateModify(n),kt(n);const{annotation:i,viewportIdsToRender:o,newAnnotation:a}=this.editData,{data:s}=i;return i.highlighted=!1,s.handles.activeHandleIndex=null,We(o),a&&bn(i),this.editData=null,i.annotationUID}},this._activateModify=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback)},this._deactivateModify=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.TOUCH_END,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback)},this.renderAnnotation=(n,i)=>{let o=!1;const{viewport:a}=n,{element:s}=a;let c=Jt(this.getToolName(),s);if(!(c!=null&&c.length)||(c=this.filterInteractableAnnotationsForElement(s,c),!(c!=null&&c.length)))return o;const l=this.getTargetId(a),f=a.getRenderingEngine(),u={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:n.viewport.id};for(let d=0;d<c.length;d++){const h=c[d],g=h.annotationUID,p=h.data,v=p.handles.points[0],y=a.worldToCanvas(v);u.annotationUID=g;const{color:m,lineWidth:w}=this.getAnnotationStyle({annotation:h,styleSpecifier:u});if(p.cachedStats||(p.cachedStats={}),!p.cachedStats[l]||p.cachedStats[l].value===null)p.cachedStats[l]={Modality:null,index:null,value:null},this._calculateCachedStats(h,f,n,Bt.StatsUpdated);else if(h.invalidated&&(this._calculateCachedStats(h,f,n),a instanceof Zn)){const{referencedImageId:T}=h.metadata;for(const _ in p.cachedStats)_.startsWith("imageId")&&f.getStackViewports().find(D=>{const I=_r(T),P=D.hasImageURI(I),O=_r(D.getCurrentImageId());return P&&O!==I})&&delete p.cachedStats[_]}if(!a.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),o;if(!Vr(g))continue;Kn(i,g,"0",[y],{color:m,lineWidth:w,handleRadius:this.configuration.handleRadius}),o=!0;const C=this.getLinkedTextBoxStyle(u,h);if(!C.visibility)continue;const S=this.configuration.getTextLines(p,l);if(S){const T=[y[0]+this.configuration.textCanvasOffset.x,y[1]+this.configuration.textCanvasOffset.y];df(i,g,"0",S,[T[0],T[1]],C)}}return o}}isPointNearTool(e,r,n,i){const o=Le(e),{viewport:a}=o,{data:s}=r,c=s.handles.points[0],l=a.worldToCanvas(c);return ur(n,l)<i}toolSelectedCallback(){}getHandleNearImagePoint(e,r,n,i){const o=Le(e),{viewport:a}=o,{data:s}=r,c=s.handles.points[0],l=a.worldToCanvas(c);if(ur(n,l)<i===!0)return c}handleSelectedCallback(e,r){const n=e.detail,{element:i}=n;r.highlighted=!0;const o=wt(i,this.getToolName());this.editData={annotation:r,viewportIdsToRender:o},this._activateModify(i),Dt(i),We(o),e.preventDefault()}_calculateCachedStats(e,r,n,i=Bt.StatsUpdated){const o=e.data,{renderingEngineId:a,viewport:s}=n,{element:c}=s,l=o.handles.points[0],{cachedStats:f}=o,u=Object.keys(f);for(let h=0;h<u.length;h++){const g=u[h],p={isPreScaled:uu(s,g),isSuvScaled:this.isSuvScaled(s,g,e.metadata.referencedImageId)},v=this.getTargetImageData(g);if(!v)continue;const{dimensions:y,imageData:m,metadata:w,voxelManager:x}=v,C=w.Modality;let S=DTe(m,l);if(S=GY(S,S),tr(S,y)){this.isHandleOutsideImage=!1;let T=x.getAtIJKPoint(S);if(g.startsWith("imageId:")){const E=g.split("imageId:")[1],b=_r(E),I=$y(b)[0];S[2]=I.getCurrentImageIdIndex()}let _;if(C==="US"){const E=p5(v,[S]),b=E.values.every(D=>D!==null);T=b?E.values:T,_=b?E.units:"raw"}else _=fu(C,e.metadata.referencedImageId,p);f[g]={index:S,value:T,Modality:C,modalityUnit:_}}else this.isHandleOutsideImage=!0,f[g]={index:S,Modality:C}}const d=e.invalidated;return e.invalidated=!1,d&&Kt(e,c,i),f}};Du.toolName="Probe",Du.probeDefaults={supportedInteractionTypes:["Mouse","Touch"],configuration:{shadow:!0,preventHandleOutsideImage:!1,getTextLines:ITe,handleRadius:"6",textCanvasOffset:{x:6,y:-6}}},Du.hydrate=(e,r,n)=>{const i=Mn(e);if(!i)return;const{FrameOfReferenceUID:o,referencedImageId:a,viewPlaneNormal:s,viewUp:c,instance:l,viewport:f}=Du.hydrateBase(Du,i,r,n),{toolInstance:u,...d}=n||{},h={annotationUID:(n==null?void 0:n.annotationUID)||gn(),data:{handles:{points:r}},highlighted:!1,autoGenerated:!1,invalidated:!1,isLocked:!1,isVisible:!0,metadata:{toolName:l.getToolName(),viewPlaneNormal:s,FrameOfReferenceUID:o,referencedImageId:a,...d}};qt(h,f.element),We([f.id])};let su=Du;function ITe(t,e){const r=t.cachedStats[e],{index:n,value:i,modalityUnit:o}=r;if(i===void 0||!n)return;const a=[];if(a.push(`(${n[0]}, ${n[1]}, ${n[2]})`),i instanceof Array&&o instanceof Array)for(let s=0;s<i.length;s++)a.push(`${Xt(i[s])} ${o[s]}`);else a.push(`${Xt(i)} ${o}`);return a}const cb=class cb extends su{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{shadow:!0,preventHandleOutsideImage:!1,getTextLines:OTe}}){super(e,r),this.postMouseDownCallback=n=>{const i=n.detail,{currentPoints:o,element:a}=i,s=o.world,c=Le(a),{viewport:l,renderingEngine:f}=c;this.isDrawing=!0;const u=l.getCamera(),{viewPlaneNormal:d,viewUp:h}=u,g=this.getReferencedImageId(l,s,d,h),p={invalidated:!0,highlighted:!0,isVisible:!0,metadata:{toolName:this.getToolName(),viewPlaneNormal:[...d],viewUp:[...h],FrameOfReferenceUID:l.getFrameOfReferenceUID(),referencedImageId:g},data:{label:"",handles:{points:[[...s]]},cachedStats:{}}},v=wt(a,this.getToolName());return this.editData={annotation:p,newAnnotation:!0,viewportIdsToRender:v},this._activateModify(a),Dt(a),n.preventDefault(),We(v),p},this.postTouchStartCallback=n=>this.postMouseDownCallback(n),this.renderAnnotation=(n,i)=>{let o=!1;const{viewport:a}=n;if(!this.editData)return o;const s=this.filterInteractableAnnotationsForElement(a.element,[this.editData.annotation]);if(!(s!=null&&s.length))return o;const c=this.getTargetId(a),l=a.getRenderingEngine(),f={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:n.viewport.id},u=this.editData.annotation,d=u.annotationUID,h=u.data,g=h.handles.points[0],p=a.worldToCanvas(g);f.annotationUID=d;const{color:v}=this.getAnnotationStyle({annotation:u,styleSpecifier:f});if(!h.cachedStats[c]||h.cachedStats[c].value===null?(h.cachedStats[c]={Modality:null,index:null,value:null},this._calculateCachedStats(u,l,n)):u.invalidated&&this._calculateCachedStats(u,l,n),!a.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),o;Kn(i,d,"0",[p],{color:v}),o=!0;const m=this.configuration.getTextLines(h,c);if(m){const w=[p[0]+6,p[1]-6];df(i,d,"0",m,[w[0],w[1]],this.getLinkedTextBoxStyle(f,u))}return o}}};cb.toolName="DragProbe";let dT=cb;function OTe(t,e){const r=t.cachedStats[e],{index:n,value:i,modalityUnit:o}=r;if(i===void 0)return;const a=[];return a.push(`(${n[0]}, ${n[1]}, ${n[2]})`),a.push(`${i.toFixed(2)} ${o}`),a}const{transformWorldToIndex:m7}=pn,k0=class k0 extends Yn{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{shadow:!0,preventHandleOutsideImage:!1,storePointData:!1,centerPointRadius:0,calculateStats:!0,getTextLines:MTe,statsCalculator:al}}){super(e,r),this.isHandleOutsideImage=!1,this.addNewAnnotation=n=>{const i=n.detail,{currentPoints:o,element:a}=i,s=o.world;o.canvas;const c=Le(a),{viewport:l,renderingEngine:f}=c;this.isDrawing=!0;const u=l.getCamera(),{viewPlaneNormal:d,viewUp:h}=u,g=this.getReferencedImageId(l,s,d,h),p=l.getFrameOfReferenceUID(),v={highlighted:!0,invalidated:!0,metadata:{toolName:this.getToolName(),viewPlaneNormal:[...d],viewUp:[...h],FrameOfReferenceUID:p,referencedImageId:g,...l.getViewReference({points:[s]})},data:{label:"",handles:{textBox:{hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}},points:[[...s],[...s],[...s],[...s]],activeHandleIndex:null},cachedStats:{},initialRotation:l.getRotation()}};qt(v,a);const y=wt(a,this.getToolName());return this.editData={annotation:v,viewportIdsToRender:y,centerWorld:s,newAnnotation:!0,hasMoved:!1},this._activateDraw(a),Dt(a),n.preventDefault(),We(y),v},this.isPointNearTool=(n,i,o,a)=>{const s=Le(n),{viewport:c}=s,{data:l}=i,{points:f}=l.handles,u=f.map(_=>c.worldToCanvas(_)),[d,h,g,p]=u,v=Math.hypot(g[0]-p[0],g[1]-p[1]),y=Math.hypot(h[0]-d[0],h[1]-d[1]),m=Math.atan2(g[1]-p[1],g[0]-p[0]),w=[(g[0]+p[0])/2,(h[1]+d[1])/2],x={center:w,xRadius:(v-a)/2,yRadius:(y-a)/2,angle:m},C={center:w,xRadius:(v+a)/2,yRadius:(y+a)/2,angle:m},S=this._pointInEllipseCanvas(x,o);return!!(this._pointInEllipseCanvas(C,o)&&!S)},this.toolSelectedCallback=(n,i)=>{const o=n.detail,{element:a}=o;i.highlighted=!0;const s=wt(a,this.getToolName());this.editData={annotation:i,viewportIdsToRender:s,movingTextBox:!1},Dt(a),this._activateModify(a);const c=Le(a),{renderingEngine:l}=c;We(s),n.preventDefault()},this.handleSelectedCallback=(n,i,o)=>{const a=n.detail,{element:s}=a,{data:c}=i;i.highlighted=!0;let l=!1,f,u,d,h,g,p;if(o.worldPosition)l=!0;else{const{points:y}=c.handles,{viewport:m}=Le(s),{worldToCanvas:w,canvasToWorld:x}=m;f=y.findIndex(S=>S===o);const C=y.map(w);p=C[f],h=Math.abs(C[2][0]-C[3][0]),g=Math.abs(C[0][1]-C[1][1]),u=[(C[2][0]+C[3][0])/2,(C[0][1]+C[1][1])/2],d=x(u)}const v=wt(s,this.getToolName());this.editData={annotation:i,viewportIdsToRender:v,handleIndex:f,canvasWidth:h,canvasHeight:g,centerWorld:d,originalHandleCanvas:p,movingTextBox:l},this._activateModify(s),Dt(s),We(v),n.preventDefault()},this._endCallback=n=>{const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s,newAnnotation:c,hasMoved:l}=this.editData,{data:f}=a;c&&!l||(this.doneEditMemo(),a.highlighted=!1,f.handles.activeHandleIndex=null,this._deactivateModify(o),this._deactivateDraw(o),kt(o),this.editData=null,this.isDrawing=!1,this.isHandleOutsideImage&&this.configuration.preventHandleOutsideImage&&en(a.annotationUID),We(s),c&&bn(a))},this._dragDrawCallback=n=>{this.isDrawing=!0;const i=n.detail,{element:o}=i,{currentPoints:a}=i,s=a.canvas,c=Le(o),{viewport:l}=c,{canvasToWorld:f}=l,{annotation:u,viewportIdsToRender:d,centerWorld:h,newAnnotation:g}=this.editData;this.createMemo(o,u,{newAnnotation:g});const p=l.worldToCanvas(h),{data:v}=u,y=Math.abs(s[0]-p[0]),m=Math.abs(s[1]-p[1]),w=[p[0],p[1]-m],x=[p[0],p[1]+m],C=[p[0]-y,p[1]],S=[p[0]+y,p[1]];v.handles.points=[f(w),f(x),f(C),f(S)],u.invalidated=!0,this.editData.hasMoved=!0,We(d),Kt(u,o,Bt.HandlesUpdated)},this._dragModifyCallback=n=>{this.isDrawing=!0;const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s,handleIndex:c,movingTextBox:l,newAnnotation:f}=this.editData;this.createMemo(o,a,{newAnnotation:f});const{data:u}=a;if(l){const{deltaPoints:g}=i,p=g.world,{textBox:v}=u.handles,{worldPosition:y}=v;y[0]+=p[0],y[1]+=p[1],y[2]+=p[2],v.hasMoved=!0}else if(c===void 0){const{deltaPoints:g}=i,p=g.world;u.handles.points.forEach(y=>{y[0]+=p[0],y[1]+=p[1],y[2]+=p[2]}),a.invalidated=!0}else this._dragHandle(n),a.invalidated=!0;const d=Le(o),{renderingEngine:h}=d;We(s),a.invalidated&&Kt(a,o,Bt.HandlesUpdated)},this._dragHandle=n=>{const i=n.detail,{element:o}=i,{viewport:a}=Le(o),{canvasToWorld:s,worldToCanvas:c}=a,{annotation:l,canvasWidth:f,canvasHeight:u,handleIndex:d,centerWorld:h,originalHandleCanvas:g}=this.editData,p=a.worldToCanvas(h),{data:v}=l,{points:y}=v.handles,{currentPoints:m}=i,w=m.canvas;if(d===0||d===1){const x=Math.abs(w[1]-p[1]),C=[p[0],p[1]-x],S=[p[0],p[1]+x];y[0]=s(C),y[1]=s(S);const T=w[0]-g[0],_=f/2+T,E=[p[0]-_,p[1]],b=[p[0]+_,p[1]];y[2]=s(E),y[3]=s(b)}else{const x=Math.abs(w[0]-p[0]),C=[p[0]-x,p[1]],S=[p[0]+x,p[1]];y[2]=s(C),y[3]=s(S);const T=w[1]-g[1],_=u/2+T,E=[p[0],p[1]-_],b=[p[0],p[1]+_];y[0]=s(E),y[1]=s(b)}},this.cancel=n=>{if(this.isDrawing){this.isDrawing=!1,this._deactivateDraw(n),this._deactivateModify(n),kt(n);const{annotation:i,viewportIdsToRender:o,newAnnotation:a}=this.editData,{data:s}=i;return i.highlighted=!1,s.handles.activeHandleIndex=null,We(o),a&&bn(i),this.editData=null,i.annotationUID}},this._activateModify=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragModifyCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragModifyCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback)},this._deactivateModify=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragModifyCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.TOUCH_END,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragModifyCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback)},this._activateDraw=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragDrawCallback),n.addEventListener(U.MOUSE_MOVE,this._dragDrawCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragDrawCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback)},this._deactivateDraw=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragDrawCallback),n.removeEventListener(U.MOUSE_MOVE,this._dragDrawCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.TOUCH_END,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragDrawCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback)},this.renderAnnotation=(n,i)=>{let o=!1;const{viewport:a}=n,{element:s}=a;let c=Jt(this.getToolName(),s);if(!(c!=null&&c.length)||(c=this.filterInteractableAnnotationsForElement(s,c),!(c!=null&&c.length)))return o;const l=this.getTargetId(a),f=a.getRenderingEngine(),u={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:n.viewport.id};for(let d=0;d<c.length;d++){const h=c[d],{annotationUID:g,data:p}=h,{handles:v}=p,{points:y,activeHandleIndex:m}=v;u.annotationUID=g;const{color:w,lineWidth:x,lineDash:C}=this.getAnnotationStyle({annotation:h,styleSpecifier:u}),S=y.map(ee=>a.worldToCanvas(ee)),T=s5(S),{centerPointRadius:_}=this.configuration;if(!p.cachedStats[l]||p.cachedStats[l].areaUnit==null)p.cachedStats[l]={Modality:null,area:null,max:null,mean:null,stdDev:null,areaUnit:null},this._calculateCachedStats(h,a,f);else if(h.invalidated&&(this._throttledCalculateCachedStats(h,a,f,n),a instanceof Zn)){const{referencedImageId:ee}=h.metadata;for(const ce in p.cachedStats)ce.startsWith("imageId")&&f.getStackViewports().find(_e=>{const Ve=_r(ee),Ge=_e.hasImageURI(Ve),Ne=_r(_e.getCurrentImageId());return Ge&&Ne!==Ve})&&delete p.cachedStats[ce]}if(!a.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),o;let E;if(!Vr(g))continue;!Yr(g)&&!this.editData&&m!==null&&(E=[S[m]]),E&&Kn(i,g,"0",E,{color:w});const b=`${g}-ellipse`,D="0";if(t8(i,g,D,S,{color:w,lineDash:C,lineWidth:x},b),_>0&&Math.min(Math.abs(T[0][0]-T[1][0])/2,Math.abs(T[0][1]-T[1][1])/2)>3*_){const ce=this._getCanvasEllipseCenter(S);Yo(i,g,`${D}-center`,ce,_,{color:w,lineDash:C,lineWidth:x})}o=!0;const I=this.getLinkedTextBoxStyle(u,h);if(!I.visibility){p.handles.textBox={hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}};continue}const P=this.configuration.getTextLines(p,l);if(!P||P.length===0)continue;let O;p.handles.textBox.hasMoved||(O=wa(T),p.handles.textBox.worldPosition=a.canvasToWorld(O));const L=a.worldToCanvas(p.handles.textBox.worldPosition),H=Ji(i,g,"1",P,L,S,{},I),{x:A,y:F,width:G,height:X}=H;p.handles.textBox.worldBoundingBox={topLeft:a.canvasToWorld([A,F]),topRight:a.canvasToWorld([A+G,F]),bottomLeft:a.canvasToWorld([A,F+X]),bottomRight:a.canvasToWorld([A+G,F+X])}}return o},this._calculateCachedStats=(n,i,o)=>{var C,S,T,_;if(!this.configuration.calculateStats)return;const a=n.data,{element:s}=i,{points:c}=a.handles,l=c.map(E=>i.worldToCanvas(E)),{viewPlaneNormal:f,viewUp:u}=i.getCamera(),[d,h]=s5(l),g=i.canvasToWorld(d),p=i.canvasToWorld(h),{cachedStats:v}=a,y=Object.keys(v),m=g,w=p;for(let E=0;E<y.length;E++){const b=y[E],D=this.getTargetImageData(b);if(!D)continue;const{dimensions:I,imageData:P,metadata:O,voxelManager:L}=D,B=m7(P,m);B[0]=Math.floor(B[0]),B[1]=Math.floor(B[1]),B[2]=Math.floor(B[2]);const H=m7(P,w);H[0]=Math.floor(H[0]),H[1]=Math.floor(H[1]),H[2]=Math.floor(H[2]),this.isHandleOutsideImage=!this._isInsideVolume(B,H,I);const A=Math.min(B[0],H[0]),F=Math.max(B[0],H[0]),G=Math.min(B[1],H[1]),X=Math.max(B[1],H[1]),ee=Math.min(B[2],H[2]),ce=Math.max(B[2],H[2]),Se=[[A,F],[G,X],[ee,ce]],_e={center:[(g[0]+p[0])/2,(g[1]+p[1])/2,(g[2]+p[2])/2],xRadius:Math.abs(g[0]-p[0])/2,yRadius:Math.abs(g[1]-p[1])/2,zRadius:Math.abs(g[2]-p[2])/2},{worldWidth:Ve,worldHeight:Ge}=Qh(f,u,m,w),Ne=Ve===0&&Ge===0,j=[B,H],{scale:M,areaUnit:q}=ya(D,j),K=Math.abs(Math.PI*(Ve/2)*(Ge/2))/M/M,J={isPreScaled:uu(i,b),isSuvScaled:this.isSuvScaled(i,b,n.metadata.referencedImageId)},re=fu(O.Modality,n.metadata.referencedImageId,J);let ie;L&&L.forEach(this.configuration.statsCalculator.statsCallback,{boundsIJK:Se,imageData:P,isInObject:Fe=>Nw(_e,Fe,{fast:!0}),returnPoints:this.configuration.storePointData});const Re=this.configuration.statsCalculator.getStatistics();v[b]={Modality:O.Modality,area:K,mean:(C=Re.mean)==null?void 0:C.value,max:(S=Re.max)==null?void 0:S.value,min:(T=Re.min)==null?void 0:T.value,stdDev:(_=Re.stdDev)==null?void 0:_.value,statsArray:Re.array,pointsInShape:ie,isEmptyArea:Ne,areaUnit:q,modalityUnit:re}}const x=n.invalidated;return n.invalidated=!1,x&&Kt(n,s,Bt.StatsUpdated),v},this._isInsideVolume=(n,i,o)=>tr(n,o)&&tr(i,o),this._throttledCalculateCachedStats=Lo(this._calculateCachedStats,100,{trailing:!0})}_pointInEllipseCanvas(e,r){const{xRadius:n,yRadius:i,center:o,angle:a}=e,s=YY(Wt(),r,o,-a);if(n<=0||i<=0)return!1;const c=[s[0]-o[0],s[1]-o[1]];return c[0]*c[0]/(n*n)+c[1]*c[1]/(i*i)<=1}_getCanvasEllipseCenter(e){const[r,n,i,o]=e,a=[i[0],n[1]],s=[o[0],r[1]];return[(a[0]+s[0])/2,(a[1]+s[1])/2]}};k0.toolName="EllipticalROI",k0.hydrate=(e,r,n)=>{const i=Mn(e);if(!i)return;const{FrameOfReferenceUID:o,referencedImageId:a,viewPlaneNormal:s,instance:c,viewport:l}=k0.hydrateBase(k0,i,r,n),{toolInstance:f,...u}=n||{},d={annotationUID:(n==null?void 0:n.annotationUID)||gn(),data:{handles:{points:r,activeHandleIndex:null},label:"",cachedStats:{}},highlighted:!1,autoGenerated:!1,invalidated:!1,isLocked:!1,isVisible:!0,metadata:{toolName:c.getToolName(),viewPlaneNormal:s,FrameOfReferenceUID:o,referencedImageId:a,...u}};qt(d,l.element),We([l.id])};let Ad=k0;function MTe(t,e){const r=t.cachedStats[e],{area:n,mean:i,stdDev:o,max:a,isEmptyArea:s,areaUnit:c,modalityUnit:l,min:f}=r,u=[];if(xr(n)){const d=s?"Area: Oblique not supported":`Area: ${Xt(n)} ${c}`;u.push(d)}return xr(i)&&u.push(`Mean: ${Xt(i)} ${l}`),xr(a)&&u.push(`Max: ${Xt(a)} ${l}`),xr(f)&&u.push(`Min: ${Xt(f)} ${l}`),xr(o)&&u.push(`Std Dev: ${Xt(o)} ${l}`),u}const{transformWorldToIndex:v7}=pn,V0=class V0 extends Yn{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{shadow:!0,preventHandleOutsideImage:!1,storePointData:!1,centerPointRadius:0,calculateStats:!0,getTextLines:PTe,statsCalculator:al}}){super(e,r),this.isHandleOutsideImage=!1,this.addNewAnnotation=n=>{const i=n.detail,{currentPoints:o,element:a}=i,s=o.world,c=Le(a),{viewport:l,renderingEngine:f}=c;this.isDrawing=!0;const u=l.getCamera(),{viewPlaneNormal:d,viewUp:h}=u,g=this.getReferencedImageId(l,s,d,h),p=l.getFrameOfReferenceUID(),v={highlighted:!0,invalidated:!0,metadata:{toolName:this.getToolName(),viewPlaneNormal:[...d],viewUp:[...h],FrameOfReferenceUID:p,referencedImageId:g,...l.getViewReference({points:[s]})},data:{label:"",handles:{textBox:{hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}},points:[[...s],[...s]],activeHandleIndex:null},cachedStats:{}}};qt(v,a);const y=wt(a,this.getToolName());return this.editData={annotation:v,viewportIdsToRender:y,newAnnotation:!0,hasMoved:!1},this._activateDraw(a),Dt(a),n.preventDefault(),We(y),v},this.isPointNearTool=(n,i,o,a)=>{const s=Le(n),{viewport:c}=s,{data:l}=i,{points:f}=l.handles,u=f.map(g=>c.worldToCanvas(g)),d=Qu(u),h=Qu([u[0],o]);return Math.abs(h-d)<a/2},this.toolSelectedCallback=(n,i)=>{const o=n.detail,{element:a}=o;i.highlighted=!0;const s=wt(a,this.getToolName());this.editData={annotation:i,viewportIdsToRender:s,movingTextBox:!1},Dt(a),this._activateModify(a);const c=Le(a),{renderingEngine:l}=c;We(s),n.preventDefault()},this.handleSelectedCallback=(n,i,o)=>{const a=n.detail,{element:s}=a,{data:c}=i;i.highlighted=!0;let l=!1,f;if(o.worldPosition)l=!0;else{const{points:g}=c.handles;f=g.findIndex(p=>p===o)}const u=wt(s,this.getToolName());this.editData={annotation:i,viewportIdsToRender:u,handleIndex:f,movingTextBox:l},this._activateModify(s),Dt(s);const d=Le(s),{renderingEngine:h}=d;We(u),n.preventDefault()},this._endCallback=n=>{const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s,newAnnotation:c,hasMoved:l}=this.editData,{data:f}=a;if(c&&!l)return;this.doneEditMemo(),a.highlighted=!1,f.handles.activeHandleIndex=null,this._deactivateModify(o),this._deactivateDraw(o),kt(o);const{renderingEngine:u}=Le(o);this.editData=null,this.isDrawing=!1,this.isHandleOutsideImage&&this.configuration.preventHandleOutsideImage&&en(a.annotationUID),We(s),c&&bn(a)},this._dragDrawCallback=n=>{this.isDrawing=!0;const i=n.detail,{element:o}=i,{currentPoints:a}=i,s=a.canvas,c=Le(o),{viewport:l}=c,{canvasToWorld:f}=l,{annotation:u,viewportIdsToRender:d,newAnnotation:h}=this.editData;this.createMemo(o,u,{newAnnotation:h});const{data:g}=u;g.handles.points=[g.handles.points[0],f(s)],u.invalidated=!0,this.editData.hasMoved=!0,We(d),Kt(u,o,Bt.HandlesUpdated)},this._dragModifyCallback=n=>{this.isDrawing=!0;const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s,handleIndex:c,movingTextBox:l,newAnnotation:f}=this.editData;this.createMemo(o,a,{newAnnotation:f});const{data:u}=a;if(l){const{deltaPoints:g}=i,p=g.world,{textBox:v}=u.handles,{worldPosition:y}=v;y[0]+=p[0],y[1]+=p[1],y[2]+=p[2],v.hasMoved=!0}else if(c===void 0){const{deltaPoints:g}=i,p=g.world;u.handles.points.forEach(y=>{y[0]+=p[0],y[1]+=p[1],y[2]+=p[2]}),a.invalidated=!0}else this._dragHandle(n),a.invalidated=!0;const d=Le(o),{renderingEngine:h}=d;We(s),a.invalidated&&Kt(a,o,Bt.HandlesUpdated)},this._dragHandle=n=>{const i=n.detail,{element:o}=i,a=Le(o),{canvasToWorld:s,worldToCanvas:c}=a.viewport,{annotation:l,handleIndex:f}=this.editData,{data:u}=l,{points:d}=u.handles,h=d.map(v=>c(v)),{currentPoints:g}=i,p=g.canvas;if(f===0){const v=p[0]-h[0][0],y=p[1]-h[0][1],m=p,w=[h[1][0]+v,h[1][1]+y];d[0]=s(m),d[1]=s(w)}else d[1]=s(p)},this.cancel=n=>{if(this.isDrawing){this.isDrawing=!1,this._deactivateDraw(n),this._deactivateModify(n),kt(n);const{annotation:i,viewportIdsToRender:o,newAnnotation:a}=this.editData,{data:s}=i;return i.highlighted=!1,s.handles.activeHandleIndex=null,We(o),a&&bn(i),this.editData=null,i.annotationUID}},this._activateModify=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragModifyCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragModifyCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback)},this._deactivateModify=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragModifyCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.TOUCH_END,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragModifyCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback)},this._activateDraw=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragDrawCallback),n.addEventListener(U.MOUSE_MOVE,this._dragDrawCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragDrawCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback)},this._deactivateDraw=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragDrawCallback),n.removeEventListener(U.MOUSE_MOVE,this._dragDrawCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.TOUCH_END,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragDrawCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback)},this.renderAnnotation=(n,i)=>{let o=!1;const{viewport:a}=n,{element:s}=a;let c=Jt(this.getToolName(),s);if(!(c!=null&&c.length)||(c=this.filterInteractableAnnotationsForElement(s,c),!(c!=null&&c.length)))return o;const l=this.getTargetId(a),f=a.getRenderingEngine(),u={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:n.viewport.id};for(let d=0;d<c.length;d++){const h=c[d],{annotationUID:g,data:p}=h,{handles:v}=p,{points:y,activeHandleIndex:m}=v;u.annotationUID=g;const{color:w,lineWidth:x,lineDash:C}=this.getAnnotationStyle({annotation:h,styleSpecifier:u}),S=y.map(Se=>a.worldToCanvas(Se)),T=S[0],_=Qu(S),E=ih(S),{centerPointRadius:b}=this.configuration;if(!p.cachedStats[l]||p.cachedStats[l].areaUnit==null)p.cachedStats[l]={Modality:null,area:null,max:null,mean:null,stdDev:null,areaUnit:null,radius:null,radiusUnit:null,perimeter:null},this._calculateCachedStats(h,a,f,n);else if(h.invalidated&&(this._throttledCalculateCachedStats(h,a,f,n),a instanceof Zn)){const{referencedImageId:Se}=h.metadata;for(const we in p.cachedStats)we.startsWith("imageId")&&f.getStackViewports().find(Ge=>{const Ne=_r(Se),j=Ge.hasImageURI(Ne),M=_r(Ge.getCurrentImageId());return j&&M!==Ne})&&delete p.cachedStats[we]}if(!a.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),o;let D;if(!Vr(g))continue;!Yr(g)&&!this.editData&&m!==null&&(D=[S[m]]),D&&Kn(i,g,"0",D,{color:w});const I=`${g}-circle`,P="0";Yo(i,g,P,T,_,{color:w,lineDash:C,lineWidth:x},I),b>0&&_>3*b&&Yo(i,g,`${P}-center`,T,b,{color:w,lineDash:C,lineWidth:x}),o=!0;const O=this.getLinkedTextBoxStyle(u,h);if(!O.visibility){p.handles.textBox={hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}};continue}const L=this.configuration.getTextLines(p,l);if(!L||L.length===0)continue;let B;p.handles.textBox.hasMoved||(B=wa(E),p.handles.textBox.worldPosition=a.canvasToWorld(B));const H=a.worldToCanvas(p.handles.textBox.worldPosition),F=Ji(i,g,"1",L,H,S,{},O),{x:G,y:X,width:ee,height:ce}=F;p.handles.textBox.worldBoundingBox={topLeft:a.canvasToWorld([G,X]),topRight:a.canvasToWorld([G+ee,X]),bottomLeft:a.canvasToWorld([G,X+ce]),bottomRight:a.canvasToWorld([G+ee,X+ce])}}return o},this._calculateCachedStats=(n,i,o,a)=>{var S,T,_,E;if(!this.configuration.calculateStats)return;const s=n.data,{element:c}=i,l=n.invalidated,{points:f}=s.handles,u=f.map(b=>i.worldToCanvas(b)),{viewPlaneNormal:d,viewUp:h}=i.getCamera(),[g,p]=ih(u),v=i.canvasToWorld(g),y=i.canvasToWorld(p),{cachedStats:m}=s,w=Object.keys(m),x=v,C=y;for(let b=0;b<w.length;b++){const D=w[b],I=this.getTargetImageData(D);if(!I)continue;const{dimensions:P,imageData:O,metadata:L,voxelManager:B}=I,H=v7(O,x);H[0]=Math.floor(H[0]),H[1]=Math.floor(H[1]),H[2]=Math.floor(H[2]);const A=v7(O,C);if(A[0]=Math.floor(A[0]),A[1]=Math.floor(A[1]),A[2]=Math.floor(A[2]),this._isInsideVolume(H,A,P)){const F=Math.min(H[0],A[0]),G=Math.max(H[0],A[0]),X=Math.min(H[1],A[1]),ee=Math.max(H[1],A[1]),ce=Math.min(H[2],A[2]),Se=Math.max(H[2],A[2]),we=[[F,G],[X,ee],[ce,Se]],_e=[(v[0]+y[0])/2,(v[1]+y[1])/2,(v[2]+y[2])/2],Ve=Math.abs(v[0]-y[0])/2,Ge=Math.abs(v[1]-y[1])/2,Ne=Math.abs(v[2]-y[2])/2,j={center:_e,xRadius:Ve<Q0/2?0:Ve,yRadius:Ge<Q0/2?0:Ge,zRadius:Ne<Q0/2?0:Ne},{worldWidth:M,worldHeight:q}=Qh(d,h,x,C),K=M===0&&q===0,J=[H,A],{scale:re,unit:ie,areaUnit:Re}=ya(I,J),Fe=u8(I),je=Math.abs(Math.PI*(M/re/2)*(q/Fe/re/2)),Xe={isPreScaled:uu(i,D),isSuvScaled:this.isSuvScaled(i,D,n.metadata.referencedImageId)},se=fu(L.Modality,n.metadata.referencedImageId,Xe);let ue;B&&(ue=B.forEach(this.configuration.statsCalculator.statsCallback,{isInObject:pe=>Nw(j,pe,{fast:!0}),boundsIJK:we,imageData:O,returnPoints:this.configuration.storePointData}));const Pe=this.configuration.statsCalculator.getStatistics();m[D]={Modality:L.Modality,area:je,mean:(S=Pe.mean)==null?void 0:S.value,max:(T=Pe.max)==null?void 0:T.value,min:(_=Pe.min)==null?void 0:_.value,pointsInShape:ue,stdDev:(E=Pe.stdDev)==null?void 0:E.value,statsArray:Pe.array,isEmptyArea:K,areaUnit:Re,radius:M/2/re,radiusUnit:ie,perimeter:2*Math.PI*(M/2)/re,modalityUnit:se}}else this.isHandleOutsideImage=!0,m[D]={Modality:L.Modality}}return n.invalidated=!1,l&&Kt(n,c,Bt.StatsUpdated),m},this._isInsideVolume=(n,i,o)=>tr(n,o)&&tr(i,o),this._throttledCalculateCachedStats=Lo(this._calculateCachedStats,100,{trailing:!0})}};V0.toolName="CircleROI",V0.hydrate=(e,r,n)=>{const i=Mn(e);if(!i)return;const{FrameOfReferenceUID:o,referencedImageId:a,viewPlaneNormal:s,instance:c,viewport:l}=V0.hydrateBase(V0,i,r,n),{toolInstance:f,...u}=n||{},d={annotationUID:(n==null?void 0:n.annotationUID)||gn(),data:{handles:{points:r,textBox:{hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}},activeHandleIndex:null},label:"",cachedStats:{}},highlighted:!1,autoGenerated:!1,invalidated:!1,isLocked:!1,isVisible:!0,metadata:{toolName:c.getToolName(),viewPlaneNormal:s,FrameOfReferenceUID:o,referencedImageId:a,...u}};qt(d,l.element),We([l.id])};let E5=V0;function PTe(t,e){const r=t.cachedStats[e],{radius:n,radiusUnit:i,area:o,mean:a,stdDev:s,max:c,min:l,isEmptyArea:f,areaUnit:u,modalityUnit:d}=r,h=[];if(xr(n)){const g=f?"Radius: Oblique not supported":`Radius: ${Xt(n)} ${i}`;h.push(g)}if(xr(o)){const g=f?"Area: Oblique not supported":`Area: ${Xt(o)} ${u}`;h.push(g)}return xr(a)&&h.push(`Mean: ${Xt(a)} ${d}`),xr(c)&&h.push(`Max: ${Xt(c)} ${d}`),xr(l)&&h.push(`Min: ${Xt(l)} ${d}`),xr(s)&&h.push(`Std Dev: ${Xt(s)} ${d}`),h}const Y2=5,lb=class lb extends Yn{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{shadow:!0,preventHandleOutsideImage:!1,degrees:[45,135,225,315],diameters:[10,30,60]}}){super(e,r),this.isHandleOutsideImage=!1,this.addNewAnnotation=n=>{const i=n.detail,{currentPoints:o,element:a}=i,s=o.world,c=Le(a),{viewport:l,renderingEngine:f}=c;this.isDrawing=!0;const u=l.getCamera(),{viewPlaneNormal:d,viewUp:h}=u,g=this.getReferencedImageId(l,s,d,h),p=l.getFrameOfReferenceUID(),v={highlighted:!0,invalidated:!0,metadata:{toolName:this.getToolName(),viewPlaneNormal:[...d],viewUp:[...h],FrameOfReferenceUID:p,referencedImageId:g,...l.getViewReference({points:[s]})},data:{label:"",handles:{points:[[...s]]}}};qt(v,a);const y=wt(a,this.getToolName());return this.editData={annotation:v,viewportIdsToRender:y,newAnnotation:!0},this._activateDraw(a),Dt(a),n.preventDefault(),We(y),v},this.isPointNearTool=(n,i,o,a)=>{const s=Le(n),{viewport:c}=s,{data:l}=i,{points:f}=l.handles,u=c.worldToCanvas(f[0]),d=Qu([u,o]);return Math.abs(d)<a},this.toolSelectedCallback=(n,i)=>{const o=n.detail,{element:a}=o;i.highlighted=!0;const s=wt(a,this.getToolName());this.editData={annotation:i,viewportIdsToRender:s},Dt(a),this._activateModify(a);const c=Le(a),{renderingEngine:l}=c;We(s),n.preventDefault()},this.handleSelectedCallback=(n,i)=>{const o=n.detail,{element:a}=o;i.highlighted=!0;const s=wt(a,this.getToolName());this.editData={annotation:i,viewportIdsToRender:s},this._activateModify(a),Dt(a);const c=Le(a),{renderingEngine:l}=c;We(s),n.preventDefault()},this._endCallback=n=>{const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s,newAnnotation:c,hasMoved:l}=this.editData,{data:f}=a;if(c&&!l)return;a.highlighted=!1,f.handles.activeHandleIndex=null,this._deactivateModify(o),this._deactivateDraw(o),kt(o);const{renderingEngine:u}=Le(o);this.editData=null,this.isDrawing=!1,this.isHandleOutsideImage&&this.configuration.preventHandleOutsideImage&&en(a.annotationUID),We(s),c&&bn(a)},this._dragDrawCallback=n=>{this.isDrawing=!0;const i=n.detail,{element:o}=i,{currentPoints:a}=i,s=a.canvas,c=Le(o),{renderingEngine:l,viewport:f}=c,{canvasToWorld:u}=f,{annotation:d,viewportIdsToRender:h}=this.editData,{data:g}=d;g.handles.points=[u(s),u(s)],d.invalidated=!0,this.editData.hasMoved=!0,We(h)},this._dragModifyCallback=n=>{this.isDrawing=!0;const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s}=this.editData,{data:c}=a,{deltaPoints:l}=i,f=l.world;c.handles.points.forEach(g=>{g[0]+=f[0],g[1]+=f[1],g[2]+=f[2]}),a.invalidated=!0;const d=Le(o),{renderingEngine:h}=d;We(s)},this._dragHandle=n=>{const i=n.detail,{element:o}=i,a=Le(o),{canvasToWorld:s,worldToCanvas:c}=a.viewport,{annotation:l}=this.editData,{data:f}=l,{points:u}=f.handles,d=u.map(w=>c(w)),{currentPoints:h}=i,g=h.canvas,p=g[0]-d[0][0],v=g[1]-d[0][1],y=g,m=[d[1][0]+p,d[1][1]+v];u[0]=s(y),u[1]=s(m)},this.cancel=n=>{if(this.isDrawing){this.isDrawing=!1,this._deactivateDraw(n),this._deactivateModify(n),kt(n);const{annotation:i,viewportIdsToRender:o,newAnnotation:a}=this.editData,{data:s}=i;i.highlighted=!1,s.handles.activeHandleIndex=null;const{renderingEngine:c}=Le(n);return We(o),a&&bn(i),this.editData=null,i.annotationUID}},this._activateModify=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragModifyCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragModifyCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback)},this._deactivateModify=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragModifyCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.TOUCH_END,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragModifyCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback)},this._activateDraw=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragDrawCallback),n.addEventListener(U.MOUSE_MOVE,this._dragDrawCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragDrawCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback)},this._deactivateDraw=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragDrawCallback),n.removeEventListener(U.MOUSE_MOVE,this._dragDrawCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.TOUCH_END,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragDrawCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback)},this.renderAnnotation=(n,i)=>{let o=!1;const{viewport:a}=n,{element:s}=a;let c=Jt(this.getToolName(),s);if(!(c!=null&&c.length)||(c=this.filterInteractableAnnotationsForElement(s,c),!(c!=null&&c.length)))return o;const l={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:n.viewport.id};for(let f=0;f<c.length;f++){const u=c[f],{annotationUID:d,data:h}=u,{handles:g}=h,{points:p}=g;l.annotationUID=d;const{color:v,lineWidth:y,lineDash:m}=this.getAnnotationStyle({annotation:u,styleSpecifier:l}),x=p.map(D=>a.worldToCanvas(D))[0];if(!a.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),o;if(!Vr(d))continue;let C=`${d}-crosshair-vertical`,S=[x[0],x[1]+Y2],T=[x[0],x[1]-Y2];an(i,d,C,S,T,{color:v,lineDash:m,lineWidth:y}),C=`${d}-crosshair-horizontal`,S=[x[0]+Y2,x[1]],T=[x[0]-Y2,x[1]],an(i,d,C,S,T,{color:v,lineDash:m,lineWidth:y});const _=this.configuration.diameters.map(D=>this.worldMeasureToCanvas(D,a));for(let D=0;D<_.length;D++){const I=`${d}-circle-${D}`,P=`${d}-circle-${D}`;Yo(i,d,P,x,_[D]/2,{color:v,lineDash:m,lineWidth:y},I)}const E=D=>D*Math.PI/180,b=this.configuration.degrees.map(D=>E(D));for(let D=0;D<b.length;D++){const I=`${d}-line-${D}`,P=[Math.cos(b[D])*_[0]/2+x[0],Math.sin(b[D])*_[0]/2+x[1]],O=[Math.cos(b[D])*_[2]/2+x[0],Math.sin(b[D])*_[2]/2+x[1]];an(i,d,I,P,O,{color:v,lineDash:m,lineWidth:y})}o=!0}return o}}worldMeasureToCanvas(e,r){const n=r.canvasToWorld([r.canvas.width/2,r.canvas.height/2]),{viewUp:i}=r.getCamera(),o=dn(Ke(),n,i,e),a=r.worldToCanvas(n),s=r.worldToCanvas(o);return Math.sqrt(Math.pow(s[0]-a[0],2)+Math.pow(s[1]-a[1],2))}};lb.toolName="ETDRSGrid";let hT=lb;const y7=3,w7=10,RTe={resolution:20,controlPointAdditionDistance:6,controlPointDeletionDistance:6,showControlPointsConnectors:!1,controlPointAdditionEnabled:!0,controlPointDeletionEnabled:!0};var Pl;(function(t){t.Cardinal="CARDINAL",t.Linear="LINEAR",t.CatmullRom="CATMULLROM",t.BSpline="BSPLINE"})(Pl||(Pl={}));var Ip;(function(t){t.AddControlPoint="addControlPoint",t.DeleteControlPoint="deleteControlPoint"})(Ip||(Ip={}));const Iu=class Iu extends L1{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{preventHandleOutsideImage:!1,calculateStats:!0,simplifiedSpline:!1,getTextLines:LTe,contourHoleAdditionModifierKey:Ri.Shift,decimate:{enabled:!1,epsilon:.1},spline:{configuration:{[Pl.Cardinal]:{Class:B1,scale:.5},[Pl.CatmullRom]:{Class:KW},[Pl.Linear]:{Class:qW},[Pl.BSpline]:{Class:HW,controlPointAdditionEnabled:!1,controlPointDeletionEnabled:!1,showControlPointsConnectors:!0}},type:Pl.CatmullRom,drawPreviewEnabled:!0,lastControlPointDeletionKeys:["Backspace","Delete"]},actions:{[Ip.AddControlPoint]:{method:"addControlPointCallback",bindings:[{mouseButton:ol.Primary,modifierKey:Ri.Shift}]},[Ip.DeleteControlPoint]:{method:"deleteControlPointCallback",bindings:[{mouseButton:ol.Primary,modifierKey:Ri.Ctrl}]}}}}){super(e,r),this.splineToolNames=["CatmullRomSplineROI","LinearSplineROI","BSplineROI","CardinalSplineROI"],this.isHandleOutsideImage=!1,this.fireChangeOnUpdate=null,this.isPointNearTool=(n,i,o,a)=>{const{instance:s}=i.data.spline;return s.isPointNearCurve(o,a)},this.toolSelectedCallback=(n,i)=>{const o=n.detail,{element:a}=o;i.highlighted=!0;const s=wt(a,this.getToolName());this.editData={annotation:i,viewportIdsToRender:s,movingTextBox:!1},this._activateModify(a),We(s),n.preventDefault()},this.handleSelectedCallback=(n,i,o)=>{const a=n.detail,{element:s}=a,{data:c}=i;i.highlighted=!0;let l=!1,f;if(o.worldPosition)l=!0;else{const{points:d}=c.handles;f=d.findIndex(h=>h===o)}const u=wt(s,this.getToolName());this.editData={annotation:i,viewportIdsToRender:u,handleIndex:f,movingTextBox:l},this._activateModify(s),We(u),n.preventDefault()},this._endCallback=n=>{const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s,newAnnotation:c,contourHoleProcessingEnabled:l}=this.editData,{data:f}=a;a.autoGenerated=!1,f.handles.activeHandleIndex=null,this._deactivateModify(o),this._deactivateDraw(o),kt(o);const u=Le(o),d=this.getTargetImageData(this.getTargetId(u.viewport)),{imageData:h,dimensions:g}=d;this.isHandleOutsideImage=f.handles.points.map(v=>Lr(h,v)).some(v=>!tr(v,g)),this.isHandleOutsideImage&&this.configuration.preventHandleOutsideImage&&en(a.annotationUID);const p=c?Bt.Completed:Bt.HandlesUpdated;this.fireChangeOnUpdate?(this.fireChangeOnUpdate.annotationUID=a.annotationUID,this.fireChangeOnUpdate.changeType=p):this.fireChangeOnUpdate={annotationUID:a.annotationUID,changeType:p,contourHoleProcessingEnabled:l},We(s),this.doneEditMemo(),this.editData=null,this.isDrawing=!1},this._keyDownCallback=n=>{const i=n.detail,{element:o}=i,a=i.key??"",{lastControlPointDeletionKeys:s}=this.configuration.spline;if(!s.includes(a))return;const{annotation:l}=this.editData,{data:f}=l;if(f.handles.points.length===y7){this.cancel(o);return}else{const u=f.handles.points.length-1;this._deleteControlPointByIndex(o,l,u)}n.preventDefault()},this._mouseMoveCallback=n=>{const{drawPreviewEnabled:i}=this.configuration.spline;if(!i)return;const{element:o}=n.detail,{renderingEngine:a}=Le(o),s=wt(o,this.getToolName());this.editData.lastCanvasPoint=n.detail.currentPoints.canvas,We(s),n.preventDefault()},this._mouseDownCallback=n=>{const i=n.type===U.MOUSE_DOUBLE_CLICK,{annotation:o,viewportIdsToRender:a}=this.editData,{data:s}=o;if(s.contour.closed)return;this.doneEditMemo();const c=n.detail,{currentPoints:l,element:f}=c,{canvas:u,world:d}=l;let h=s.handles.points.length>=2&&i,g=!0;if(s.handles.points.length&&this.createMemo(f,o,{newAnnotation:s.handles.points.length===1}),s.handles.points.length>=3){this.createMemo(f,o);const{instance:p}=s.spline,v=p.getClosestControlPointWithinDistance(u,w7);(v==null?void 0:v.index)===0&&(g=!1,h=!0)}g&&s.handles.points.push(d),s.contour.closed=s.contour.closed||h,o.invalidated=!0,We(a),s.contour.closed&&this._endCallback(n),n.preventDefault()},this._dragCallback=n=>{this.isDrawing=!0;const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s,handleIndex:c,movingTextBox:l,newAnnotation:f}=this.editData,{data:u}=a;if(this.createMemo(o,a,{newAnnotation:f}),l){const{deltaPoints:g}=i,p=g.world,{textBox:v}=u.handles,{worldPosition:y}=v;y[0]+=p[0],y[1]+=p[1],y[2]+=p[2],v.hasMoved=!0}else if(c===void 0){const{deltaPoints:g}=i,p=g.world;this.moveAnnotation(a,p)}else{const{currentPoints:g}=i,p=g.world;u.handles.points[c]=[...p],a.invalidated=!0}this.editData.hasMoved=!0;const d=Le(o),{renderingEngine:h}=d;We(s)},this.triggerAnnotationCompleted=(n,i)=>{const o=U.ANNOTATION_COMPLETED,a={annotation:n,changeType:Bt.Completed,contourHoleProcessingEnabled:i};it(Ze,o,a)},this.triggerAnnotationModified=(n,i,o=Bt.StatsUpdated)=>{const{viewportId:a,renderingEngineId:s}=i,c=U.ANNOTATION_MODIFIED;it(Ze,c,{annotation:n,viewportId:a,renderingEngineId:s,changeType:o})},this.triggerChangeEvent=(n,i,o=Bt.StatsUpdated,a)=>{o===Bt.Completed?this.triggerAnnotationCompleted(n,a):this.triggerAnnotationModified(n,i,o)},this._activateModify=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback)},this._deactivateModify=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.TOUCH_END,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback)},this._activateDraw=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.KEY_DOWN,this._keyDownCallback),n.addEventListener(U.MOUSE_MOVE,this._mouseMoveCallback),n.addEventListener(U.MOUSE_DOWN,this._mouseDownCallback),n.addEventListener(U.MOUSE_DOUBLE_CLICK,this._mouseDownCallback),n.addEventListener(U.TOUCH_TAP,this._mouseDownCallback)},this._deactivateDraw=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.KEY_DOWN,this._keyDownCallback),n.removeEventListener(U.MOUSE_MOVE,this._mouseMoveCallback),n.removeEventListener(U.MOUSE_DOWN,this._mouseDownCallback),n.removeEventListener(U.MOUSE_DOUBLE_CLICK,this._mouseDownCallback),n.removeEventListener(U.TOUCH_TAP,this._mouseDownCallback)},this._renderStats=(n,i,o,a)=>{const s=n.data,c=this.getTargetId(i);if(!s.spline.instance.closed||!a.visibility)return;const l=this.configuration.getTextLines(s,c);if(!l||l.length===0)return;const f=s.handles.points.map(m=>i.worldToCanvas(m));if(!s.handles.textBox.hasMoved){const m=wa(f);s.handles.textBox.worldPosition=i.canvasToWorld(m)}const u=i.worldToCanvas(s.handles.textBox.worldPosition),h=Ji(o,n.annotationUID??"","textBox",l,u,f,{},a),{x:g,y:p,width:v,height:y}=h;s.handles.textBox.worldBoundingBox={topLeft:i.canvasToWorld([g,p]),topRight:i.canvasToWorld([g+v,p]),bottomLeft:i.canvasToWorld([g,p+y]),bottomRight:i.canvasToWorld([g+v,p+y])}},this.addControlPointCallback=(n,i)=>{const{data:o}=i,a=o.spline.type,s=this._getSplineConfig(a),c=s.controlPointAdditionDistance;if(s.controlPointAdditionEnabled===!1)return;const l=n.detail,{element:f}=l,u=Le(f),{renderingEngine:d,viewport:h}=u,{canvasToWorld:g}=h,{instance:p}=o.spline,v=n.detail.currentPoints.canvas,y=p.getClosestPoint(v);if(y.distance>c)return;const{index:m,point:w}=p.addControlPointAtU(y.uValue);o.handles.points.splice(m,0,g(w)),i.invalidated=!0;const x=wt(f,this.getToolName());We(x)},this.deleteControlPointCallback=(n,i)=>{const o=i.data.spline.type,a=this._getSplineConfig(o),s=a.controlPointDeletionDistance;if(a.controlPointDeletionEnabled===!1)return;const c=n.detail,{element:l,currentPoints:f}=c,{canvas:u}=f,{instance:d}=i.data.spline,h=d.getClosestControlPointWithinDistance(u,s);h&&this._deleteControlPointByIndex(l,i,h.index)},this._calculateCachedStats=(n,i)=>{if(!this.configuration.calculateStats)return;const o=n.data;if(!o.contour.closed)return;const a=Le(i);if(!a)return;const{viewport:s}=a,{cachedStats:c}=o,{polyline:l}=o.contour,f=Object.keys(c);for(let d=0;d<f.length;d++){const h=f[d],g=this.getTargetImageData(h);if(!g)continue;const{metadata:p}=g,v=l.map(D=>s.worldToCanvas(D)),y=v[0],m=s.canvasToWorld(y),w=s.canvasToWorld([y[0]+1,y[1]]),x=s.canvasToWorld([y[0],y[1]+1]),C=Fi(m,w),S=Fi(m,x),{imageData:T}=g,{scale:_,areaUnit:E}=ya(g,()=>{const{maxX:D,maxY:I,minX:P,minY:O}=ff(v),L=s.canvasToWorld([P,O]),B=Lr(T,L),H=s.canvasToWorld([D,I]),A=Lr(T,H);return[B,A]});let b=Em(v)/_/_;b*=C*S,c[h]={Modality:p.Modality,area:b,areaUnit:E}}const u=n.invalidated;return n.invalidated=!1,u&&this.triggerAnnotationModified(n,a,Bt.StatsUpdated),c},this._throttledCalculateCachedStats=Lo(this._calculateCachedStats,100,{trailing:!0}),this.annotationCompletedBinded=this.annotationCompleted.bind(this)}annotationCompleted(e){var n;const{sourceAnnotation:r}=e.detail;!this.splineToolNames.includes((n=r==null?void 0:r.metadata)==null?void 0:n.toolName)||!this.configuration.simplifiedSpline||!this.isContourSegmentationTool()||jE(r)}initializeListeners(){Ze.addEventListener(U.ANNOTATION_COMPLETED,this.annotationCompletedBinded)}removeListeners(){Ze.removeEventListener(U.ANNOTATION_COMPLETED,this.annotationCompletedBinded)}onSetToolEnabled(){this.initializeListeners()}onSetToolActive(){this.initializeListeners()}onSetToolDisabled(){this.removeListeners()}addNewAnnotation(e){const r=e.detail,{currentPoints:n,element:i}=r,{canvas:o}=n,a=eg(e.detail.event)===this.configuration.contourHoleAdditionModifierKey,s=Le(i),{renderingEngine:c}=s,l=this.createAnnotation(e);this.isDrawing=!0,this.addAnnotation(l,i);const f=wt(i,this.getToolName());return this.editData={annotation:l,viewportIdsToRender:f,movingTextBox:!1,newAnnotation:!0,hasMoved:!1,lastCanvasPoint:o,contourHoleProcessingEnabled:a},this._activateDraw(i),e.preventDefault(),We(f),l}cancel(e){if(!this.isDrawing)return;this.isDrawing=!1,this._deactivateDraw(e),this._deactivateModify(e),kt(e);const{annotation:r,viewportIdsToRender:n,newAnnotation:i}=this.editData;i&&en(r.annotationUID),super.cancelAnnotation(r);const o=Le(e),{renderingEngine:a}=o;return We(n),this.editData=null,r.annotationUID}isContourSegmentationTool(){return!1}renderAnnotationInstance(e){var O,L,B;const{enabledElement:r,targetId:n,svgDrawingHelper:i,annotationStyle:o}=e,{viewport:a}=r,{worldToCanvas:s}=a,{element:c}=a,l=e.annotation,{annotationUID:f,data:u,highlighted:d}=l,{handles:h}=u,{points:g,activeHandleIndex:p}=h,v=(O=this.editData)==null?void 0:O.newAnnotation,{lineWidth:y,lineDash:m,color:w,locked:x}=o,C=g.map(H=>s(H)),{drawPreviewEnabled:S}=this.configuration.spline,T=l.data.spline.type,_=this._getSplineConfig(T),E=l.data.spline.instance,b=wm(l);if(b.findIndex(H=>!H)!==-1)throw new Error(`Can't find annotation for child ${l.childAnnotationUIDs.join()}`);[l,...b].filter(H=>this._isSplineROIAnnotation(H)).forEach(H=>{const F=this._updateSplineInstance(c,H).getPolylinePoints();this.updateContourPolyline(H,{points:F,closed:u.contour.closed,targetWindingDirection:Xo.Clockwise},a,{updateWindingDirection:u.contour.closed})}),super.renderAnnotationInstance(e),!u.cachedStats[n]||u.cachedStats[n].areaUnit==null?(u.cachedStats[n]={Modality:null,area:null,areaUnit:null},this._calculateCachedStats(l,c)):l.invalidated&&this._throttledCalculateCachedStats(l,c);let P;if(!x&&!this.editData&&p!==null&&(P=[C[p]]),(P||v||d)&&Kn(i,f,"0",C,{color:w,lineWidth:y,handleRadius:"3"}),S&&E.numControlPoints>1&&((L=this.editData)!=null&&L.lastCanvasPoint)&&!E.closed){const{lastCanvasPoint:H}=this.editData,A=E.getPreviewPolylinePoints(H,w7);dc(i,f,"previewSplineChange",A,{color:"#9EA0CA",lineDash:m,lineWidth:1})}if(_.showControlPointsConnectors){const H=[...C];E.closed&&H.push(C[0]),dc(i,f,"controlPointsConnectors",H,{color:"rgba(255, 255, 255, 0.5)",lineWidth:1})}return this._renderStats(l,a,i,o.textbox),((B=this.fireChangeOnUpdate)==null?void 0:B.annotationUID)===f&&(this.triggerChangeEvent(l,r,this.fireChangeOnUpdate.changeType,this.fireChangeOnUpdate.contourHoleProcessingEnabled),this.fireChangeOnUpdate=null),l.invalidated=!1,!0}createInterpolatedSplineControl(e){var o;if((o=e.data.handles.points)!=null&&o.length)return;const{polyline:r}=e.data.contour;if(!r||!r.length)return;e.data.handles.points=[];const{points:n}=e.data.handles,i=Math.max(10,Math.floor(r.length/20));for(let a=0;a<r.length-i;a+=i)n.push(r[a]);n.push(r[r.length-1])}createAnnotation(e){var l;const r=super.createAnnotation(e),{world:n}=e.detail.currentPoints,{type:i}=this.configuration.spline,o=this._getSplineConfig(i),a=new o.Class,s=()=>({type:o.type,instance:a,resolution:o.resolution});let c;return(l=this.configuration.interpolation)!=null&&l.enabled&&(c=f=>{var u;(u=f.data).spline||(u.spline=s()),this.createInterpolatedSplineControl(f)}),Ti(r,{data:{handles:{points:[[...n]]},spline:s(),cachedStats:{}},onInterpolationComplete:c})}_deleteControlPointByIndex(e,r,n){const i=Le(e),{points:o}=r.data.handles;o.length===3?en(r.annotationUID):o.splice(n,1);const{renderingEngine:a}=i,s=wt(e,this.getToolName());r.invalidated=!0,We(s)}_isSplineROIAnnotation(e){var r;return!!((r=e.data)!=null&&r.spline)}_getSplineConfig(e){const{configuration:r}=this,n=r.spline.configuration;return Object.assign({type:e},RTe,n[e])}_updateSplineInstance(e,r){const n=Le(e),{viewport:i}=n,{worldToCanvas:o}=i,{data:a}=r,{type:s,instance:c}=r.data.spline,l=this._getSplineConfig(s),u=a.handles.points.map(o),d=l.resolution!==void 0?parseInt(l.resolution):void 0,h=l.scale!==void 0?parseFloat(l.scale):void 0;return c.setControlPoints(u),c.closed=!!a.contour.closed,!c.fixedResolution&&d!==void 0&&c.resolution!==d&&(c.resolution=d,r.invalidated=!0),c instanceof B1&&!c.fixedScale&&h!==void 0&&c.scale!==h&&(c.scale=h,r.invalidated=!0),c}};Iu.toolName="SplineROI",Iu.SplineTypes=Pl,Iu.Actions=Ip,Iu.hydrate=(e,r,n)=>{const i=Mn(e);if(!i)return;if(r.length<y7){console.warn("Spline requires at least 3 control points");return}const{FrameOfReferenceUID:o,referencedImageId:a,viewPlaneNormal:s,viewUp:c,instance:l,viewport:f}=Iu.hydrateBase(Iu,i,r,n),u=(n==null?void 0:n.splineType)||Pl.CatmullRom,h=l._getSplineConfig(u).Class,g=new h,{toolInstance:p,...v}=n||{},y={annotationUID:(n==null?void 0:n.annotationUID)||gn(),data:{handles:{points:r},label:"",cachedStats:{},spline:{type:u,instance:g},contour:{closed:!0}},highlighted:!1,autoGenerated:!1,invalidated:!0,isLocked:!1,isVisible:!0,metadata:{toolName:l.getToolName(),viewPlaneNormal:s,FrameOfReferenceUID:o,referencedImageId:a,...v}};qt(y,f.element),We([f.id])};let b5=Iu;function LTe(t,e){const r=t.cachedStats[e],{area:n,isEmptyArea:i,areaUnit:o}=r,a=[];if(n){const s=i?"Area: Oblique not supported":`Area: ${Xt(n)} ${o}`;a.push(s)}return a}const ub=class ub extends b5{constructor(e){const r=Ti({configuration:{calculateStats:!1}},e);super(r),this.annotationCutMergeCompletedBinded=this.annotationCutMergeCompleted.bind(this)}isContourSegmentationTool(){return!0}initializeListeners(){Ze.addEventListener(U.ANNOTATION_CUT_MERGE_PROCESS_COMPLETED,this.annotationCutMergeCompletedBinded)}removeListeners(){Ze.removeEventListener(U.ANNOTATION_CUT_MERGE_PROCESS_COMPLETED,this.annotationCutMergeCompletedBinded)}annotationCutMergeCompleted(e){var n;const{sourceAnnotation:r}=e.detail;!this.splineToolNames.includes((n=r==null?void 0:r.metadata)==null?void 0:n.toolName)||!this.configuration.simplifiedSpline||jE(r)}};ub.toolName="SplineContourSegmentationTool";let gT=ub;class ATe{constructor({numBits:e,getPriority:r,areEqual:n}){this._bucketCount=1<<e,this._mask=this._bucketCount-1,this._size=0,this._currentBucketIndex=0,this._buckets=this._buildArray(this._bucketCount),this._getPriority=typeof r<"u"?r:i=>i,this._areEqual=typeof n=="function"?n:(i,o)=>i===o}push(e){const r=this._getBucketIndex(e),n=this._buckets[r],i={value:e,next:n};this._buckets[r]=i,this._size++}pop(){if(this._size===0)throw new Error("Cannot pop because the queue is empty.");for(;this._buckets[this._currentBucketIndex]===null;)this._currentBucketIndex=(this._currentBucketIndex+1)%this._bucketCount;const e=this._buckets[this._currentBucketIndex];return this._buckets[this._currentBucketIndex]=e.next,this._size--,e.value}remove(e){if(!e)return!1;const r=this._getBucketIndex(e),n=this._buckets[r];let i=n,o;for(;i!==null&&!this._areEqual(e,i.value);)o=i,i=i.next;return i===null?!1:(i===n?this._buckets[r]=i.next:o.next=i.next,this._size--,!0)}isEmpty(){return this._size===0}_getBucketIndex(e){return this._getPriority(e)&this._mask}_buildArray(e){const r=new Array(e);return r.fill(null),r}}const GC=4294967295,NTe=2/(3*Math.PI);class D5{constructor(e,r,n){this._getPointIndex=(o,a)=>{const{width:s}=this;return o*s+a},this._getPointCoordinate=o=>{const a=o%this.width,s=Math.floor(o/this.width);return[a,s]},this._getPointCost=o=>Math.round(this.searchGranularity*this.costs[o]);const i=e.length;this.searchGranularityBits=8,this.searchGranularity=1<<this.searchGranularityBits,this.width=r,this.height=n,this.grayscalePixelData=e,this.laplace=null,this.gradXNew=null,this.gradYNew=null,this.laplace=this._computeLaplace(),this.gradMagnitude=this._computeGradient(),this.gradXNew=this._computeGradientX(),this.gradYNew=this._computeGradientY(),this.visited=new Array(i),this.parents=new Uint32Array(i),this.costs=new Float32Array(i)}startSearch(e){const r=this._getPointIndex(e[1],e[0]);this.startPoint=null,this.visited.fill(!1),this.parents.fill(GC),this.costs.fill(1/0),this.priorityQueueNew=new ATe({numBits:this.searchGranularityBits,getPriority:this._getPointCost}),this.startPoint=e,this.costs[r]=0,this.priorityQueueNew.push(r)}findMinNearby(e,r=2){const[n,i]=e,{costs:o}=this,a=[Math.max(0,n-r),Math.min(n+r+1,this.width)],s=[Math.max(0,i-r),Math.min(i+r+1,this.height)];let c=o[this._getPointIndex(i,n)]*.8,l=e;for(let f=a[0];f<a[1];f++)for(let u=s[0];u<s[1];u++){const d=1-(Math.abs(f-e[0])+Math.abs(u-e[1]))/r/2,g=o[this._getPointIndex(u,f)]*.8+d*.2;g<c&&(l=[f,u],c=g)}return l}findPathToPoint(e){if(!this.startPoint)throw new Error("There is no search in progress");const{startPoint:r,_getPointIndex:n,_getPointCoordinate:i}=this,o=n(r[1],r[0]),a=n(e[1],e[0]),{visited:s,parents:c,costs:l,priorityQueueNew:f}=this;if(a===o)return[];for(;!f.isEmpty()&&c[a]===GC;){const h=f.pop();if(s[h])continue;const g=i(h),p=this._getNeighborPoints(g);s[h]=!0;for(let v=0,y=p.length;v<y;v++){const m=p[v],w=n(m[1],m[0]),x=this._getWeightedDistance(g,m),C=l[h]+x;C<l[w]&&(l[w]!==1/0&&f.remove(w),l[w]=C,c[w]=h,f.push(w))}}const u=[];let d=a;for(;d!==GC;)u.push(i(d)),d=c[d];return u.reverse()}_getDeltaX(e,r){const{grayscalePixelData:n,width:i}=this;let o=this._getPointIndex(r,e);return e+1===i&&o--,n[o+1]-n[o]}_getDeltaY(e,r){const{grayscalePixelData:n,width:i,height:o}=this;let a=this._getPointIndex(r,e);return r+1===o&&(a-=i),n[a]-n[a+i]}_getGradientMagnitude(e,r){const n=this._getDeltaX(e,r),i=this._getDeltaY(e,r);return Math.sqrt(n*n+i*i)}_getLaplace(e,r){const{grayscalePixelData:n,_getPointIndex:i}=this,o=n[i(r-2,e)],a=n[i(r-1,e-1)],s=n[i(r-1,e)],c=n[i(r-1,e+1)],l=n[i(r,e-2)],f=n[i(r,e-1)],u=n[i(r,e)],d=n[i(r,e+1)],h=n[i(r,e+2)],g=n[i(r+1,e-1)],p=n[i(r+1,e)],v=n[i(r+1,e+1)],y=n[i(r+2,e)];let m=o;return m+=a+2*s+c,m+=l+2*f-16*u+2*d+h,m+=g+2*p+v,m+=y,m}_computeGradient(){const{width:e,height:r}=this,n=new Float32Array(e*r);let i=0,o=0,a=0,s=0;for(s=0;s<r-1;s++){for(a=0;a<e-1;a++)n[i]=this._getGradientMagnitude(a,s),o=Math.max(n[i],o),i++;n[i]=n[i-1],i++}for(let c=n.length;i<c;i++)n[i]=n[i-e];for(let c=0,l=n.length;c<l;c++)n[c]=1-n[c]/o;return n}_computeLaplace(){const{width:e,height:r,_getPointIndex:n}=this,i=new Float32Array(e*r);i.fill(1,0,n(2,0));for(let o=2;o<r-2;o++){i[n(o,0)]=1,i[n(o,1)]=1;for(let a=2;a<e-2;a++)i[n(o,a)]=this._getLaplace(a,o)>.33?0:1;i[n(o,e-2)]=1,i[n(o,e-1)]=1}return i.fill(1,n(r-2,0)),i}_computeGradientX(){const{width:e,height:r}=this,n=new Float32Array(e*r);let i=0;for(let o=0;o<r;o++)for(let a=0;a<e;a++)n[i++]=this._getDeltaX(a,o);return n}_computeGradientY(){const{width:e,height:r}=this,n=new Float32Array(e*r);let i=0;for(let o=0;o<r;o++)for(let a=0;a<e;a++)n[i++]=this._getDeltaY(a,o);return n}_getGradientUnitVector(e,r){const{gradXNew:n,gradYNew:i,_getPointIndex:o}=this,a=n[o(r,e)],s=i[o(r,e)];let c=Math.sqrt(a*a+s*s);return c=Math.max(c,1e-100),[a/c,s/c]}_getGradientDirection(e,r,n,i){const o=this._getGradientUnitVector(e,r),a=this._getGradientUnitVector(n,i);let s=o[1]*(n-e)-o[0]*(i-r),c=a[1]*(n-e)-a[0]*(i-r);s<0&&(s=-s,c=-c),e!==n&&r!==i&&(s*=Math.SQRT1_2,c*=Math.SQRT1_2),c=Math.min(Math.max(c,-1),1);const l=NTe*(Math.acos(Math.min(s,1))+Math.acos(c));return isNaN(l)||!isFinite(l)?(console.warn("Found non-direction:",e,r,n,i,s,c,l),1):l}getCost(e,r){return this._getWeightedDistance(e,r)}_getWeightedDistance(e,r){const{_getPointIndex:n,width:i,height:o}=this,[a,s]=e,[c,l]=r;if(c<0||c>=i||l<0||l>=o)return 1;if(a<0||s<0||a>=i||s>=o)return 0;const f=n(l,c);let u=this.gradMagnitude[f];(a===c||s===l)&&(u*=Math.SQRT1_2);const d=this.laplace[f],h=this._getGradientDirection(a,s,c,l);return .43*u+.43*d+.11*h}_getNeighborPoints(e){const{width:r,height:n}=this,i=[],o=Math.max(e[0]-1,0),a=Math.max(e[1]-1,0),s=Math.min(e[0]+1,r-1),c=Math.min(e[1]+1,n-1);for(let l=a;l<=c;l++)for(let f=o;f<=s;f++)(f!==e[0]||l!==e[1])&&i.push([f,l]);return i}static createInstanceFromRawPixelData(e,r,n,i){const o=e.length,a=new Float32Array(o),{lower:s,upper:c}=i,l=c-s;for(let f=0,u=e.length;f<u;f++)a[f]=Math.max(0,Math.min(1,(e[f]-s)/l));return new D5(a,r,n)}}class Dl{constructor(e,r){this.pointArray=e?e.slice():[],this._controlPointIndexes=r?r.slice():[]}getPoint(e){return this.pointArray[e]}getLastPoint(){return this.pointArray[this.pointArray.length-1]}isControlPoint(e){const r=this.pointArray.indexOf(e);if(r!==-1)return this._controlPointIndexes.indexOf(r)!==-1;throw new Error("Error: isControlPoint called with not in list point.")}addPoint(e){this.pointArray.push(e)}addControlPoint(e){const r=this.pointArray.indexOf(e);if(r!==-1)this._controlPointIndexes.push(r);else throw new Error("Cannot mark a non registered point as control point.")}getControlPoints(){return this._controlPointIndexes.map(e=>this.pointArray[e])}getNumControlPoints(){return this._controlPointIndexes.length}removeLastControlPoint(){this._controlPointIndexes.length&&this._controlPointIndexes.pop()}getLastControlPoint(){if(this._controlPointIndexes.length)return this.pointArray[this._controlPointIndexes[this._controlPointIndexes.length-1]]}removeLastPoints(e){this.pointArray.splice(this.pointArray.length-e,e)}addPoints(e){this.pointArray=this.pointArray.concat(e)}prependPath(e){const r=e.pointArray.length,n=[];this.pointArray=e.pointArray.concat(this.pointArray);for(let i=0;i<this._controlPointIndexes.length;++i)n[i]=this._controlPointIndexes[i]+r;this._controlPointIndexes=e._controlPointIndexes.concat(n)}appendPath(e){this.addPoints(e.pointArray),e._controlPointIndexes.forEach(r=>this._controlPointIndexes.push(r))}}const kTe=10**2,fb=class fb extends L1{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{getTextLines:VTe,calculateStats:!0,preventHandleOutsideImage:!1,contourHoleAdditionModifierKey:Ri.Shift,snapHandleNearby:2,interpolation:{enabled:!1,nearestEdge:2,showInterpolationPolyline:!1},decimate:{enabled:!1,epsilon:.1},actions:{cancelInProgress:{method:"cancelInProgress",bindings:[{key:"Escape"}]}}}}){super(e,r),this.isHandleOutsideImage=!1,this.isPointNearTool=(n,i,o,a)=>{const s=Le(n),{viewport:c}=s,l=a*a,f=i.data.contour.polyline.map(d=>c.worldToCanvas(d));let u=f[f.length-1];for(let d=0;d<f.length;d++){const h=f[d];if(Tm(u,h,o)<=l)return!0;u=h}return!1},this.toolSelectedCallback=(n,i)=>{const o=n.detail,{element:a}=o;i.highlighted=!0;const s=wt(a,this.getToolName());this.editData={annotation:i,viewportIdsToRender:s,movingTextBox:!1};const c=Le(a),{renderingEngine:l}=c;this._activateModify(a),We(s),n.preventDefault()},this.handleSelectedCallback=(n,i,o)=>{const a=n.detail,{element:s}=a,{data:c}=i;i.highlighted=!0;let l=!1,f;if(o.worldPosition)l=!0;else{const{points:g}=c.handles;f=g.findIndex(p=>p===o)}const u=wt(s,this.getToolName());this.editData={annotation:i,viewportIdsToRender:u,handleIndex:f,movingTextBox:l},this._activateModify(s);const d=Le(s),{renderingEngine:h}=d;We(u),n.preventDefault()},this._endCallback=(n,i=!1)=>{const o=n.detail,{element:a}=o,{annotation:s,viewportIdsToRender:c,newAnnotation:l,contourHoleProcessingEnabled:f}=this.editData,{data:u}=s;this.doneEditMemo(),u.handles.activeHandleIndex=null,this._deactivateModify(a),this._deactivateDraw(a),kt(a);const d=Le(a);if(this.isHandleOutsideImage&&this.configuration.preventHandleOutsideImage||i){en(s.annotationUID),this.clearEditData(),We(c);return}We(c);const h=l?Bt.Completed:Bt.HandlesUpdated;this.triggerChangeEvent(s,d,h,f),this.clearEditData()},this.triggerChangeEvent=(n,i,o=Bt.StatsUpdated,a=!1)=>{o===Bt.Completed?Iw(n,a):Kt(n,i.viewport.element,o)},this._mouseDownCallback=n=>{const i=n.type===U.MOUSE_DOUBLE_CLICK,{annotation:o,viewportIdsToRender:a,worldToSlice:s,sliceToWorld:c,newAnnotation:l}=this.editData;if(this.editData.closed)return;const f=n.detail,{element:u}=f,{currentPoints:d}=f,{canvas:h,world:g}=d;let p=g;const v=Le(u),{viewport:y,renderingEngine:m}=v,w=this.editData.currentPath.getControlPoints();let x=w.length>=2&&i;if(this.doneEditMemo(),this.createMemo(u,o,{newAnnotation:l&&w.length===1}),w.length>=2){const T={index:-1,distSquared:1/0};for(let _=0,E=w.length;_<E;_++){const b=w[_],D=c(b),I=y.worldToCanvas(D),P=ru(h,I);P<=kTe&&P<T.distSquared&&(T.distSquared=P,T.index=_)}T.index===0&&(x=!0)}const{snapHandleNearby:C}=this.configuration;if(C&&!this.editData.closed){const T=new Dl,_=this.scissors.findMinNearby(s(g),1),E=this.scissors.findPathToPoint(_);T.addPoints(E),T.prependPath(this.editData.confirmedPath),p=c(_),this.editData.currentPath=T}this.editData.closed=this.editData.closed||x,this.editData.confirmedPath=this.editData.currentPath;const S=this.editData.currentPath.getLastPoint();this.editData.confirmedPath.addControlPoint(S),o.data.handles.points.push(c(S)),this.scissors.startSearch(s(p)),o.invalidated=!0,We(a),this.editData.closed&&(this.updateAnnotation(this.editData.confirmedPath),this._endCallback(n)),n.preventDefault()},this._mouseMoveCallback=n=>{const{element:i,currentPoints:o}=n.detail,{world:a,canvas:s}=o,{renderingEngine:c}=Le(i),l=wt(i,this.getToolName());this.editData.lastCanvasPoint=s;const{width:f,height:u}=this.scissors,{worldToSlice:d}=this.editData,h=d(a);if(h[0]<0||h[1]<0||h[0]>=f||h[1]>=u)return;const g=this.scissors.findPathToPoint(h),p=new Dl;p.addPoints(g),p.prependPath(this.editData.confirmedPath),this.editData.currentPath=p,We(l),n.preventDefault()},this._dragCallback=n=>{this.isDrawing=!0;const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s,movingTextBox:c,handleIndex:l,newAnnotation:f}=this.editData;this.createMemo(o,a,{newAnnotation:f});const{data:u}=a;if(c){const{deltaPoints:g}=i,p=g.world,{textBox:v}=u.handles,{worldPosition:y}=v;y[0]+=p[0],y[1]+=p[1],y[2]+=p[2],v.hasMoved=!0}else if(l===void 0)console.warn("Drag annotation not implemented");else{const{currentPoints:g}=i,p=g.world;this.editHandle(p,o,a,l)}this.editData.hasMoved=!0;const d=Le(o),{renderingEngine:h}=d;We(s)},this.cancel=n=>{if(!this.isDrawing)return;this.isDrawing=!1,this._deactivateDraw(n),this._deactivateModify(n),kt(n);const{annotation:i,viewportIdsToRender:o,newAnnotation:a}=this.editData;return a&&en(i.annotationUID),We(o),this.doneEditMemo(),this.scissors=null,i.annotationUID},this._activateModify=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback)},this._deactivateModify=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.TOUCH_END,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback)},this._activateDraw=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.MOUSE_MOVE,this._mouseMoveCallback),n.addEventListener(U.MOUSE_DOWN,this._mouseDownCallback),n.addEventListener(U.MOUSE_DOUBLE_CLICK,this._mouseDownCallback),n.addEventListener(U.TOUCH_TAP,this._mouseDownCallback)},this._deactivateDraw=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_MOVE,this._mouseMoveCallback),n.removeEventListener(U.MOUSE_DOWN,this._mouseDownCallback),n.removeEventListener(U.MOUSE_DOUBLE_CLICK,this._mouseDownCallback),n.removeEventListener(U.TOUCH_TAP,this._mouseDownCallback)},this._calculateCachedStats=(n,i)=>{if(!this.configuration.calculateStats)return;const o=n.data;if(!o.contour.closed)return;const a=Le(i),{viewport:s,renderingEngine:c}=a,{cachedStats:l}=o,{polyline:f}=o.contour,u=Object.keys(l);for(let h=0;h<u.length;h++){const g=u[h],p=this.getTargetImageData(g);if(!p)continue;const{metadata:v}=p,y=f.map(I=>s.worldToCanvas(I)),m=y[0],w=s.canvasToWorld(m),x=s.canvasToWorld([m[0]+1,m[1]]),C=s.canvasToWorld([m[0],m[1]+1]),S=Fi(w,x),T=Fi(w,C),{imageData:_}=p,{scale:E,areaUnit:b}=ya(p,()=>{const{maxX:I,maxY:P,minX:O,minY:L}=ff(y),B=s.canvasToWorld([O,L]),H=Lr(_,B),A=s.canvasToWorld([I,P]),F=Lr(_,A);return[H,F]});let D=Em(y)/E/E;D*=S*T,l[g]={Modality:v.Modality,area:D,areaUnit:b}}const d=n.invalidated;return n.invalidated=!1,d&&this.triggerAnnotationModified(n,a,Bt.StatsUpdated),l},this._renderStats=(n,i,o,a)=>{const s=n.data,c=this.getTargetId(i);if(!s.contour.closed||!a.visibility)return;const l=this.configuration.getTextLines(s,c);if(!l||l.length===0)return;const f=s.handles.points.map(m=>i.worldToCanvas(m));if(!s.handles.textBox.hasMoved){const m=wa(f);s.handles.textBox.worldPosition=i.canvasToWorld(m)}const u=i.worldToCanvas(s.handles.textBox.worldPosition),h=Ji(o,n.annotationUID??"","textBox",l,u,f,{},a),{x:g,y:p,width:v,height:y}=h;s.handles.textBox.worldBoundingBox={topLeft:i.canvasToWorld([g,p]),topRight:i.canvasToWorld([g+v,p]),bottomLeft:i.canvasToWorld([g,p+y]),bottomRight:i.canvasToWorld([g+v,p+y])}},this.triggerAnnotationModified=(n,i,o=Bt.StatsUpdated)=>{const{viewportId:a,renderingEngineId:s}=i,c=U.ANNOTATION_MODIFIED;it(Ze,c,{annotation:n,viewportId:a,renderingEngineId:s,changeType:o})},this._throttledCalculateCachedStats=Lo(this._calculateCachedStats,100,{trailing:!0})}setupBaseEditData(e,r,n,i,o){var T,_;const a=Le(r),{viewport:s}=a;this.isDrawing=!0;const c=s.getImageData(),{imageData:l}=c;let f,u,d,h,g;if(!(s instanceof Zn))d=c.dimensions[0],h=c.dimensions[1],f=E=>{const b=Lr(l,E);return[b[0],b[1]]},u=E=>Th(l,[E[0],E[1],0]),g=c.scalarData;else if(s instanceof Zn){const E=pE(s),{sliceToIndexMatrix:b,indexToSliceMatrix:D}=E;f=I=>{const P=Lr(l,I),O=At([0,0,0],P,D);return[O[0],O[1]]},u=I=>{const P=At([0,0,0],[I[0],I[1],0],b);return Th(l,P)},g=E.scalarData,d=E.width,h=E.height}else throw new Error("Viewport not supported");g=MV(g,d,h);const{voiRange:p}=s.getProperties(),v=f(e);this.scissors=D5.createInstanceFromRawPixelData(g,d,h,p),i&&(this.scissorsNext=D5.createInstanceFromRawPixelData(g,d,h,p),this.scissorsNext.startSearch(f(i))),this.scissors.startSearch(v);const y=!i,m=new Dl,w=new Dl,x=y?void 0:new Dl;m.addPoint(v),m.addControlPoint(v);const C=wt(r,this.getToolName()),S=s.worldToCanvas(e);this.editData={annotation:n,viewportIdsToRender:C,newAnnotation:y,hasMoved:!1,lastCanvasPoint:S,confirmedPath:m,currentPath:w,confirmedPathNext:x,closed:!1,handleIndex:((T=this.editData)==null?void 0:T.handleIndex)??((_=n.handles)==null?void 0:_.activeHandleIndex),worldToSlice:f,sliceToWorld:u,contourHoleProcessingEnabled:o}}addNewAnnotation(e){const r=e.detail,{currentPoints:n,element:i}=r,{world:o}=n,a=this.createAnnotation(e),s=eg(e.detail.event)===this.configuration.contourHoleAdditionModifierKey;return this.setupBaseEditData(o,i,a,void 0,s),this.addAnnotation(a,i),this._activateDraw(i),e.preventDefault(),We(this.editData.viewportIdsToRender),a}clearEditData(){this.editData=null,this.scissors=null,this.scissorsNext=null,this.isDrawing=!1}editHandle(e,r,n,i){var w;const{data:o}=n,{points:a}=o.handles,{length:s}=a,c=a[(i-1+s)%s],l=a[(i+1)%s];if(!((w=this.editData)!=null&&w.confirmedPathNext)){this.setupBaseEditData(c,r,n,l);const{polyline:x}=o.contour,C=new Dl,S=new Dl,{worldToSlice:T}=this.editData,_=ZS(n,i-1),E=ZS(n,i+1);if(E===-1||_===-1)throw new Error(`Can't find handle index ${E===-1&&l} ${_===-1&&c}`);i===0?S.addPoints(x.slice(E+1,_).map(T)):(C.addPoints(x.slice(0,_+1).map(T)),S.addPoints(x.slice(E,x.length).map(T))),this.editData.confirmedPath=C,this.editData.confirmedPathNext=S}const{editData:f,scissors:u}=this,{worldToSlice:d,sliceToWorld:h}=f,{activeHandleIndex:g}=o.handles;if(g==null)o.handles.activeHandleIndex=i;else if(g!==i)throw new Error(`Trying to edit a different handle than the one currently being edited ${i}!==${o.handles.activeHandleIndex}`);const p=d(e);if(p[0]<0||p[0]>=u.width||p[1]<0||p[1]>=u.height)return;a[i]=h(p);const v=u.findPathToPoint(p),y=this.scissorsNext.findPathToPoint(p),m=new Dl;m.prependPath(f.confirmedPath),i!==0&&m.addPoints(v),m.addPoints(y.reverse()),m.appendPath(f.confirmedPathNext),i===0&&m.addPoints(v),f.currentPath=m,n.invalidated=!0,f.hasMoved=!0,f.closed=!0}renderAnnotation(e,r){var n;return this.updateAnnotation((n=this.editData)==null?void 0:n.currentPath),super.renderAnnotation(e,r)}isContourSegmentationTool(){return!1}createAnnotation(e){const r=super.createAnnotation(e),{world:n}=e.detail.currentPoints;return Ti(r,{data:{handles:{points:[[...n]]}}})}cancelInProgress(e,r,n){if(!this.editData){this.undo();return}this._endCallback(n,!0)}renderAnnotationInstance(e){var m,w,x,C;const{annotation:r,enabledElement:n,svgDrawingHelper:i,annotationStyle:o,targetId:a}=e,{viewport:s}=n,{element:c}=s,{worldToCanvas:l}=s,{annotationUID:f,data:u,highlighted:d}=r,{handles:h}=u,g=(m=this.editData)==null?void 0:m.newAnnotation,{lineWidth:p,lineDash:v,color:y}=o;if(d||g&&r.annotationUID===((x=(w=this.editData)==null?void 0:w.annotation)==null?void 0:x.annotationUID)){const S="0",T=h.points.map(l);Kn(i,f,S,T,{color:y,lineDash:v,lineWidth:p})}return super.renderAnnotationInstance(e),!u.cachedStats[a]||((C=u.cachedStats[a])==null?void 0:C.areaUnit)===null?(u.cachedStats[a]={Modality:null,area:null,areaUnit:null},this._calculateCachedStats(r,c)):r.invalidated&&this._throttledCalculateCachedStats(r,c),this._renderStats(r,s,i,o.textbox),!0}updateAnnotation(e){if(!this.editData||!e)return;const{annotation:r,sliceToWorld:n,worldToSlice:i,closed:o,newAnnotation:a}=this.editData;let{pointArray:s}=e;s.length>1&&(s=[...s,s[0]]);const c=a&&o?Xo.Clockwise:void 0;this.updateContourPolyline(r,{points:s,closed:o,targetWindingDirection:c},{canvasToWorld:n,worldToCanvas:i})}};fb.toolName="LivewireContour";let I5=fb;function VTe(t,e){const r=t.cachedStats[e],{area:n,areaUnit:i}=r,o=[];if(n){const a=`Area: ${Xt(n)} ${i}`;o.push(a)}return o}const db=class db extends I5{updateInterpolatedAnnotation(e,r){this.editData||!e.invalidated||!e.data.handles.interpolationSources||(e.data.contour.originalPolyline=e.data.contour.polyline,queueMicrotask(()=>{if(!e.data.handles.interpolationSources)return;const{points:n}=e.data.handles,{element:i}=r.viewport;this.setupBaseEditData(n[0],i,e);const{length:o}=n,{scissors:a}=this,{nearestEdge:s,repeatInterpolation:c}=this.configuration.interpolation;e.data.handles.originalPoints=n;const{worldToSlice:l,sliceToWorld:f}=this.editData,u=[];if(s){let h=l(n[n.length-1]);n.forEach((g,p)=>{const v=l(g);h=v,u.push(v),a.startSearch(h),a.findPathToPoint(v),a.findPathToPoint(l(n[(p+3)%n.length]));const y=a.findMinNearby(v,s);Vt(v,y)||(u[p]=y,h=y,n[p]=f(y))})}const d=new Dl;for(let h=0;h<o;h++){a.startSearch(l(n[h]));const g=a.findPathToPoint(l(n[(h+1)%o]));d.addPoints(g)}this.updateAnnotation(d),this.scissors=null,this.scissorsNext=null,this.editData=null,e.data.handles.interpolationSources=null,c&&Kt(e,r.viewport.element,Bt.InterpolationUpdated)}))}renderAnnotationInstance(e){var u;const{enabledElement:r,svgDrawingHelper:n}=e,i=e.annotation,{annotationUID:o}=i,{viewport:a}=r,{worldToCanvas:s}=a,{showInterpolationPolyline:c}=this.configuration.interpolation||{};(u=this.updateInterpolatedAnnotation)==null||u.call(this,i,r);const{originalPolyline:l}=i.data.contour,f=super.renderAnnotationInstance(e);if(c&&l&&i.autoGenerated){const d=l.map(s);d.push(d[0]),dc(n,o,"interpolationContour-0",d,{color:"#70ffff",lineWidth:1,fillOpacity:0})}return f}isContourSegmentationTool(){return!0}};db.toolName="LivewireContourSegmentationTool";let pT=db;const F0=class F0 extends Yn{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{shadow:!0,getTextCallback:FTe,changeTextCallback:UTe,preventHandleOutsideImage:!1,arrowFirst:!0,arrowHeadStyle:"legacy"}}){super(e,r),this.addNewAnnotation=n=>{const i=n.detail,{currentPoints:o,element:a}=i,s=o.world,c=Le(a),{viewport:l,renderingEngine:f}=c;Dt(a),this.isDrawing=!0;const u=l.getCamera(),{viewPlaneNormal:d,viewUp:h}=u,g=this.getReferencedImageId(l,s,d,h),{arrowFirst:p}=this.configuration,v=l.getFrameOfReferenceUID(),y={highlighted:!0,invalidated:!0,metadata:{toolName:this.getToolName(),viewPlaneNormal:[...d],viewUp:[...h],FrameOfReferenceUID:v,referencedImageId:g,...l.getViewReference({points:[s]})},data:{text:"",handles:{points:[[...s],[...s]],activeHandleIndex:null,arrowFirst:p,textBox:{hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}}},label:""}};qt(y,a);const m=wt(a,this.getToolName());return this.editData={annotation:y,viewportIdsToRender:m,handleIndex:1,movingTextBox:!1,newAnnotation:!0,hasMoved:!1},this._activateDraw(a),n.preventDefault(),We(m),y},this.isPointNearTool=(n,i,o,a)=>{const s=Le(n),{viewport:c}=s,{data:l}=i,[f,u]=l.handles.points,d=c.worldToCanvas(f),h=c.worldToCanvas(u),g={start:{x:d[0],y:d[1]},end:{x:h[0],y:h[1]}};return ui([g.start.x,g.start.y],[g.end.x,g.end.y],[o[0],o[1]])<=a},this.toolSelectedCallback=(n,i)=>{const o=n.detail,{element:a}=o;i.highlighted=!0;const s=wt(a,this.getToolName());this.editData={annotation:i,viewportIdsToRender:s,movingTextBox:!1},this._activateModify(a),Dt(a);const c=Le(a),{renderingEngine:l}=c;We(s),n.preventDefault()},this._endCallback=n=>{const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s,newAnnotation:c,hasMoved:l,movingTextBox:f}=this.editData,{data:u}=a;c&&!l||(u.handles.activeHandleIndex=null,this._deactivateModify(o),this._deactivateDraw(o),kt(o),this.isHandleOutsideImage&&this.configuration.preventHandleOutsideImage&&en(a.annotationUID),c?this.configuration.getTextCallback(d=>{if(!d){en(a.annotationUID),We(s),this.editData=null,this.isDrawing=!1;return}a.data.text=d,Kt(a,o,Bt.HandlesUpdated),bn(a),this.createMemo(o,a,{newAnnotation:!!this.memo}),GW(a,o,d),We(s)}):f||Kt(a,o,Bt.HandlesUpdated),this.doneEditMemo(),this.editData=null,this.isDrawing=!1)},this._dragCallback=n=>{this.isDrawing=!0;const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s,handleIndex:c,movingTextBox:l,newAnnotation:f}=this.editData;this.createMemo(o,a,{newAnnotation:f});const{data:u}=a;if(l){const{deltaPoints:d}=i,h=d.world,{textBox:g}=u.handles,{worldPosition:p}=g;p[0]+=h[0],p[1]+=h[1],p[2]+=h[2],g.hasMoved=!0}else if(c===void 0){const{deltaPoints:d}=i,h=d.world;u.handles.points.forEach(p=>{p[0]+=h[0],p[1]+=h[1],p[2]+=h[2]}),a.invalidated=!0}else{const{currentPoints:d}=i,h=d.world;u.handles.points[c]=[...h],a.invalidated=!0}this.editData.hasMoved=!0,We(s),a.invalidated&&Kt(a,o,Bt.HandlesUpdated)},this.touchTapCallback=n=>{n.detail.taps==2&&this.doubleClickCallback(n)},this.doubleClickCallback=n=>{const i=n.detail,{element:o}=i;let a=Jt(this.getToolName(),o);if(a=this.filterInteractableAnnotationsForElement(o,a),!(a!=null&&a.length))return;const s=a.find(l=>this.isPointNearTool(o,l,i.currentPoints.canvas,6));if(!s)return;const c=s;this.configuration.changeTextCallback(s,n.detail,this._doneChangingTextCallback.bind(this,o,c)),this.editData=null,this.isDrawing=!1,n.stopImmediatePropagation(),n.preventDefault()},this.cancel=n=>{if(this.isDrawing){this.isDrawing=!1,this._deactivateDraw(n),this._deactivateModify(n),kt(n);const{annotation:i,viewportIdsToRender:o,newAnnotation:a}=this.editData,{data:s}=i;return i.highlighted=!1,s.handles.activeHandleIndex=null,We(o),a&&bn(i),this.editData=null,i.annotationUID}},this._activateModify=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragCallback)},this._deactivateModify=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragCallback),n.removeEventListener(U.TOUCH_END,this._endCallback)},this._activateDraw=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragCallback),n.addEventListener(U.MOUSE_MOVE,this._dragCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragCallback)},this._deactivateDraw=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragCallback),n.removeEventListener(U.MOUSE_MOVE,this._dragCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback),n.removeEventListener(U.TOUCH_END,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragCallback)},this.renderAnnotation=(n,i)=>{let o=!1;const{viewport:a}=n,{element:s}=a;let c=Jt(this.getToolName(),s);if(!(c!=null&&c.length)||(c=this.filterInteractableAnnotationsForElement(s,c),!(c!=null&&c.length)))return o;const l={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:n.viewport.id};for(let f=0;f<c.length;f++){const u=c[f],{annotationUID:d,data:h}=u,{handles:g,text:p}=h,{points:v,activeHandleIndex:y}=g;l.annotationUID=d;const{color:m,lineWidth:w,lineDash:x,markerSize:C}=this.getAnnotationStyle({annotation:u,styleSpecifier:l}),S=v.map(H=>a.worldToCanvas(H));let T;if(!Yr(d)&&!this.editData&&y!==null&&(T=[S[y]]),!a.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),o;if(!Vr(d))continue;T&&Kn(i,d,"0",S,{color:m,lineWidth:w});const _="1";if(this.configuration.arrowFirst?f5(i,d,_,S[1],S[0],{color:m,width:w,lineDash:x,viaMarker:this.configuration.arrowHeadStyle!=="legacy",markerSize:C}):f5(i,d,_,S[0],S[1],{color:m,width:w,lineDash:x,viaMarker:this.configuration.arrowHeadStyle!=="legacy",markerSize:C}),o=!0,!p)continue;const E=this.getLinkedTextBoxStyle(l,u);if(!E.visibility){h.handles.textBox={hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}};continue}if(!h.handles.textBox.hasMoved){const H=S[1];h.handles.textBox.worldPosition=a.canvasToWorld(H)}const b=a.worldToCanvas(h.handles.textBox.worldPosition),I=Ji(i,d,"1",[p],b,S,{},E),{x:P,y:O,width:L,height:B}=I;h.handles.textBox.worldBoundingBox={topLeft:a.canvasToWorld([P,O]),topRight:a.canvasToWorld([P+L,O]),bottomLeft:a.canvasToWorld([P,O+B]),bottomRight:a.canvasToWorld([P+L,O+B])}}return o}}handleSelectedCallback(e,r,n){const i=e.detail,{element:o}=i,{data:a}=r;r.highlighted=!0;let s=!1,c;n.worldPosition?s=!0:c=a.handles.points.findIndex(d=>d===n);const l=wt(o,this.getToolName());this.editData={annotation:r,viewportIdsToRender:l,handleIndex:c,movingTextBox:s},this._activateModify(o),Dt(o);const f=Le(o),{renderingEngine:u}=f;We(l),e.preventDefault()}_doneChangingTextCallback(e,r,n){r.data.text=n,Le(e);const i=wt(e,this.getToolName());We(i),Kt(r,e)}_isInsideVolume(e,r,n){return tr(e,n)&&tr(r,n)}};F0.toolName="ArrowAnnotate",F0.hydrate=(e,r,n,i)=>{const o=Mn(e);if(!o)return;const{FrameOfReferenceUID:a,referencedImageId:s,viewPlaneNormal:c,instance:l,viewport:f}=F0.hydrateBase(F0,o,r,i),{toolInstance:u,...d}=i||{},h={annotationUID:(i==null?void 0:i.annotationUID)||gn(),data:{text:n||"",handles:{points:r}},highlighted:!1,autoGenerated:!1,invalidated:!1,isLocked:!1,isVisible:!0,metadata:{toolName:l.getToolName(),viewPlaneNormal:c,FrameOfReferenceUID:a,referencedImageId:s,...d}};qt(h,f.element),We([f.id])};let mf=F0;function FTe(t){return t(prompt("Enter your annotation:"))}function UTe(t,e,r){return r(prompt("Enter your annotation:"))}const U0=class U0 extends Yn{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{shadow:!0,showAngleArc:!1,arcOffset:5,preventHandleOutsideImage:!1,getTextLines:BTe}}){super(e,r),this.addNewAnnotation=n=>{if(this.angleStartedNotYetCompleted)return;this.angleStartedNotYetCompleted=!0;const i=n.detail,{currentPoints:o,element:a}=i,s=o.world,c=Le(a),{viewport:l,renderingEngine:f}=c;Dt(a),this.isDrawing=!0;const u=l.getCamera(),{viewPlaneNormal:d,viewUp:h}=u,g=this.getReferencedImageId(l,s,d,h),p=l.getFrameOfReferenceUID(),v={highlighted:!0,invalidated:!0,metadata:{toolName:this.getToolName(),viewPlaneNormal:[...d],viewUp:[...h],FrameOfReferenceUID:p,referencedImageId:g,...l.getViewReference({points:[s]})},data:{handles:{points:[[...s],[...s]],activeHandleIndex:null,textBox:{hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}}},label:"",cachedStats:{}}};qt(v,a);const y=wt(a,this.getToolName());return this.editData={annotation:v,viewportIdsToRender:y,handleIndex:1,movingTextBox:!1,newAnnotation:!0,hasMoved:!1},this._activateDraw(a),n.preventDefault(),We(y),v},this.isPointNearTool=(n,i,o,a)=>{const s=Le(n),{viewport:c}=s,{data:l}=i,[f,u,d]=l.handles.points,h=c.worldToCanvas(f),g=c.worldToCanvas(u),p={start:{x:h[0],y:h[1]},end:{x:g[0],y:g[1]}};if(ui([p.start.x,p.start.y],[p.end.x,p.end.y],[o[0],o[1]])<=a)return!0;if(!d)return!1;const y=c.worldToCanvas(d),m={start:{x:g[0],y:g[1]},end:{x:y[0],y:y[1]}};return ui([m.start.x,m.start.y],[m.end.x,m.end.y],[o[0],o[1]])<=a},this.toolSelectedCallback=(n,i)=>{const o=n.detail,{element:a}=o;i.highlighted=!0;const s=wt(a,this.getToolName());this.editData={annotation:i,viewportIdsToRender:s,movingTextBox:!1},this._activateModify(a),Dt(a);const c=Le(a),{renderingEngine:l}=c;We(s),n.preventDefault()},this._endCallback=n=>{const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s,newAnnotation:c,hasMoved:l}=this.editData,{data:f}=a;if(c&&!l)return;if(this.angleStartedNotYetCompleted&&f.handles.points.length===2){this.editData.handleIndex=2;return}this.angleStartedNotYetCompleted=!1,f.handles.activeHandleIndex=null,this._deactivateModify(o),this._deactivateDraw(o),kt(o);const u=Le(o),{renderingEngine:d}=u;this.isHandleOutsideImage&&this.configuration.preventHandleOutsideImage&&en(a.annotationUID),We(s),this.doneEditMemo(),c&&bn(a),this.editData=null,this.isDrawing=!1},this._dragCallback=n=>{this.isDrawing=!0;const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s,handleIndex:c,movingTextBox:l,newAnnotation:f}=this.editData,{data:u}=a;if(this.createMemo(o,a,{newAnnotation:f}),l){const{deltaPoints:g}=i,p=g.world,{textBox:v}=u.handles,{worldPosition:y}=v;y[0]+=p[0],y[1]+=p[1],y[2]+=p[2],v.hasMoved=!0}else if(c===void 0){const{deltaPoints:g}=i,p=g.world;u.handles.points.forEach(y=>{y[0]+=p[0],y[1]+=p[1],y[2]+=p[2]}),a.invalidated=!0}else{const{currentPoints:g}=i,p=g.world;u.handles.points[c]=[...p],a.invalidated=!0}this.editData.hasMoved=!0;const d=Le(o),{renderingEngine:h}=d;We(s),a.invalidated&&Kt(a,o,Bt.HandlesUpdated)},this.cancel=n=>{if(this.isDrawing){this.isDrawing=!1,this._deactivateDraw(n),this._deactivateModify(n),kt(n);const{annotation:i,viewportIdsToRender:o,newAnnotation:a}=this.editData,{data:s}=i;return i.highlighted=!1,s.handles.activeHandleIndex=null,We(o),a&&bn(i),this.editData=null,this.angleStartedNotYetCompleted=!1,i.annotationUID}},this._activateModify=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragCallback)},this._deactivateModify=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback),n.removeEventListener(U.TOUCH_END,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragCallback)},this._activateDraw=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragCallback),n.addEventListener(U.MOUSE_MOVE,this._dragCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragCallback)},this._deactivateDraw=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragCallback),n.removeEventListener(U.MOUSE_MOVE,this._dragCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback),n.removeEventListener(U.TOUCH_END,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragCallback)},this.renderAnnotation=(n,i)=>{var d;let o=!1;const{viewport:a}=n,{element:s}=a;let c=Jt(this.getToolName(),s);if(!(c!=null&&c.length)||(c=this.filterInteractableAnnotationsForElement(s,c),!(c!=null&&c.length)))return o;const l=this.getTargetId(a),f=a.getRenderingEngine(),u={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:n.viewport.id};for(let h=0;h<c.length;h++){const g=c[h],{annotationUID:p,data:v}=g,{points:y,activeHandleIndex:m}=v.handles;u.annotationUID=p;const{color:w,lineWidth:x,lineDash:C,angleArcLineDash:S}=this.getAnnotationStyle({annotation:g,styleSpecifier:u}),T=y.map(F=>a.worldToCanvas(F));!v.cachedStats[l]||v.cachedStats[l].angle==null?(v.cachedStats[l]={angle:null},this._calculateCachedStats(g,f,n)):g.invalidated&&this._throttledCalculateCachedStats(g,f,n);let _;if(!Yr(g.annotationUID)&&!this.editData&&m!==null&&(_=[T[m]]),!a.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),o;if(!Vr(p))continue;_&&Kn(i,p,"0",T,{color:w,lineDash:C,lineWidth:x});let E="1";if(an(i,p,E,T[0],T[1],{color:w,width:x,lineDash:C}),o=!0,T.length!==3)return o;if(E="2",an(i,p,E,T[1],T[2],{color:w,width:x,lineDash:C}),this.configuration.showAngleArc){const F=T[1],G=this.configuration.arcOffset,X=Math.min(ui([F[0],F[1]],[T[0][0],T[0][1]],[T[2][0],T[2][1]]),ui([F[0],F[1]],[T[2][0],T[2][1]],[T[0][0],T[0][1]]))/G,ee=[];let ce=Math.atan2(T[0][1]-F[1],T[0][0]-F[0]),Se=Math.atan2(T[2][1]-F[1],T[2][0]-F[0]);if(Se<ce&&(Se+=2*Math.PI),Se-ce>Math.PI){const Ve=ce;ce=Se,Se=Ve+2*Math.PI}const _e=32;for(let Ve=0;Ve<=_e;Ve++){const Ge=ce+Ve/_e*(Se-ce);ee.push([F[0]+X*Math.cos(Ge),F[1]+X*Math.sin(Ge)])}Kl(i,p,"3",ee,{color:w,width:x,lineDash:S})}if(!((d=v.cachedStats[l])!=null&&d.angle))continue;const b=this.getLinkedTextBoxStyle(u,g);if(!b.visibility){v.handles.textBox={hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}};continue}const D=this.configuration.getTextLines(v,l);if(!v.handles.textBox.hasMoved){const F=T[1];v.handles.textBox.worldPosition=a.canvasToWorld(F)}const I=a.worldToCanvas(v.handles.textBox.worldPosition),O=Ji(i,p,"1",D,I,T,{},b),{x:L,y:B,width:H,height:A}=O;v.handles.textBox.worldBoundingBox={topLeft:a.canvasToWorld([L,B]),topRight:a.canvasToWorld([L+H,B]),bottomLeft:a.canvasToWorld([L,B+A]),bottomRight:a.canvasToWorld([L+H,B+A])}}return o},this._throttledCalculateCachedStats=Lo(this._calculateCachedStats,100,{trailing:!0})}handleSelectedCallback(e,r,n){const i=e.detail,{element:o}=i,{data:a}=r;r.highlighted=!0;let s=!1,c;n.worldPosition?s=!0:c=a.handles.points.findIndex(d=>d===n);const l=wt(o,this.getToolName());this.editData={annotation:r,viewportIdsToRender:l,handleIndex:c,movingTextBox:s},this._activateModify(o),Dt(o);const f=Le(o),{renderingEngine:u}=f;We(l),e.preventDefault()}_calculateCachedStats(e,r,n){const i=e.data,{element:o}=n.viewport;if(i.handles.points.length!==3)return;const a=i.handles.points[0],s=i.handles.points[1],c=i.handles.points[2],{cachedStats:l}=i,f=Object.keys(l);for(let d=0;d<f.length;d++){const h=f[d],g=ah([a,s],[s,c]),{dimensions:p,imageData:v}=this.getTargetImageData(h);this.isHandleOutsideImage=[a,s,c].map(y=>Lr(v,y)).some(y=>!tr(y,p)),l[h]={angle:isNaN(g)?"Incomplete Angle":g}}const u=e.invalidated;return e.invalidated=!1,u&&Kt(e,o,Bt.StatsUpdated),l}};U0.toolName="Angle",U0.hydrate=(e,r,n)=>{const i=Mn(e);if(!i)return;const{FrameOfReferenceUID:o,referencedImageId:a,viewPlaneNormal:s,instance:c,viewport:l}=U0.hydrateBase(U0,i,r,n),{toolInstance:f,...u}=n||{},d={annotationUID:(n==null?void 0:n.annotationUID)||gn(),data:{handles:{points:r}},highlighted:!1,autoGenerated:!1,invalidated:!1,isLocked:!1,isVisible:!0,metadata:{toolName:c.getToolName(),viewPlaneNormal:s,FrameOfReferenceUID:o,referencedImageId:a,...u}};qt(d,l.element),We([l.id])};let mT=U0;function BTe(t,e){const r=t.cachedStats[e],{angle:n}=r;return n===void 0?void 0:isNaN(n)?[`${n}`]:[`${Xt(n)} °`]}const GTe=(...t)=>{const e=t[0].length===2?[0,0]:[0,0,0],r=t.length;for(const n of t)e[0]+=n[0]/r,e[1]+=n[1]/r,e.length===3&&(e[2]+=n[2]/r);return e},bl=GTe,hb=class hb extends Yn{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{shadow:!0,preventHandleOutsideImage:!1,getTextLines:WTe,showArcLines:!1}}){super(e,r),this.addNewAnnotation=n=>{if(this.angleStartedNotYetCompleted)return;this.angleStartedNotYetCompleted=!0;const i=n.detail,{currentPoints:o,element:a}=i,s=o.world,c=Le(a),{viewport:l,renderingEngine:f}=c;Dt(a),this.isDrawing=!0;const u=l.getCamera(),{viewPlaneNormal:d,viewUp:h}=u,g=this.getReferencedImageId(l,s,d,h),p=l.getFrameOfReferenceUID(),v={highlighted:!0,invalidated:!0,metadata:{toolName:this.getToolName(),viewPlaneNormal:[...d],viewUp:[...h],FrameOfReferenceUID:p,referencedImageId:g,...l.getViewReference({points:[s]})},data:{handles:{points:[[...s],[...s]],activeHandleIndex:null,textBox:{hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}}},label:"",cachedStats:{}}};qt(v,a);const y=wt(a,this.getToolName());return this.editData={annotation:v,viewportIdsToRender:y,handleIndex:1,movingTextBox:!1,newAnnotation:!0,hasMoved:!1},this._activateDraw(a),n.preventDefault(),We(y),v},this.isPointNearTool=(n,i,o,a)=>{const s=Le(n),{viewport:c}=s,{data:l}=i,{distanceToPoint:f,distanceToPoint2:u}=this.distanceToLines({viewport:c,points:l.handles.points,canvasCoords:o,proximity:a});return f<=a||u<=a},this.toolSelectedCallback=(n,i,o,a,s=6)=>{const c=n.detail,{element:l}=c;i.highlighted=!0;const f=wt(l,this.getToolName()),u=Le(l),{renderingEngine:d,viewport:h}=u,{isNearFirstLine:g,isNearSecondLine:p}=this.distanceToLines({viewport:h,points:i.data.handles.points,canvasCoords:a,proximity:s});this.editData={annotation:i,viewportIdsToRender:f,movingTextBox:!1,isNearFirstLine:g,isNearSecondLine:p},this._activateModify(l),Dt(l),We(f),n.preventDefault()},this._endCallback=n=>{const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s,newAnnotation:c,hasMoved:l}=this.editData,{data:f}=a;if(c&&!l)return;if(this.doneEditMemo(),this.angleStartedNotYetCompleted&&f.handles.points.length<4){kt(o),this.editData.handleIndex=f.handles.points.length;return}this.angleStartedNotYetCompleted=!1,f.handles.activeHandleIndex=null,this._deactivateModify(o),this._deactivateDraw(o),kt(o);const u=Le(o),{renderingEngine:d}=u;this.isHandleOutsideImage&&this.configuration.preventHandleOutsideImage&&en(a.annotationUID),We(s),c&&bn(a),this.editData=null,this.isDrawing=!1},this._mouseDownCallback=n=>{const{annotation:i,handleIndex:o}=this.editData,a=n.detail,{element:s,currentPoints:c}=a,l=c.world,{data:f}=i;if(o===1){f.handles.points[1]=l,this.editData.hasMoved=f.handles.points[1][0]!==f.handles.points[0][0]||f.handles.points[1][1]!==f.handles.points[0][0];return}if(o===3){f.handles.points[3]=l,this.editData.hasMoved=f.handles.points[3][0]!==f.handles.points[2][0]||f.handles.points[3][1]!==f.handles.points[2][0],this.angleStartedNotYetCompleted=!1;return}this.editData.hasMoved=!1,Dt(s),f.handles.points[2]=f.handles.points[3]=l,this.editData.handleIndex=f.handles.points.length-1},this._dragCallback=n=>{this.isDrawing=!0;const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s,handleIndex:c,movingTextBox:l,isNearFirstLine:f,isNearSecondLine:u,newAnnotation:d}=this.editData;this.createMemo(o,a,{newAnnotation:d});const{data:h}=a;if(l){const{deltaPoints:v}=i,y=v.world,{textBox:m}=h.handles,{worldPosition:w}=m;w[0]+=y[0],w[1]+=y[1],w[2]+=y[2],m.hasMoved=!0}else if(c===void 0&&(f||u)){const{deltaPoints:v}=i,y=v.world,m=h.handles.points;f?[m[0],m[1]].forEach(x=>{x[0]+=y[0],x[1]+=y[1],x[2]+=y[2]}):u&&[m[2],m[3]].forEach(x=>{x[0]+=y[0],x[1]+=y[1],x[2]+=y[2]}),a.invalidated=!0}else{const{currentPoints:v}=i,y=v.world;h.handles.points[c]=[...y],a.invalidated=!0}this.editData.hasMoved=!0;const g=Le(o),{renderingEngine:p}=g;We(s),a.invalidated&&Kt(a,o,Bt.HandlesUpdated)},this.cancel=n=>{if(!this.isDrawing)return;this.isDrawing=!1,this._deactivateDraw(n),this._deactivateModify(n),kt(n);const{annotation:i,viewportIdsToRender:o,newAnnotation:a}=this.editData,{data:s}=i;s.handles.points.length<4&&en(i.annotationUID),i.highlighted=!1,s.handles.activeHandleIndex=null;const c=Le(n),{renderingEngine:l}=c;return We(o),a&&bn(i),this.editData=null,this.angleStartedNotYetCompleted=!1,i.annotationUID},this._activateModify=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragCallback),n.addEventListener(U.TOUCH_START,this._mouseDownCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback)},this._deactivateModify=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.TOUCH_END,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragCallback),n.removeEventListener(U.TOUCH_START,this._mouseDownCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback)},this._activateDraw=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragCallback),n.addEventListener(U.MOUSE_MOVE,this._dragCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.MOUSE_DOWN,this._mouseDownCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragCallback),n.addEventListener(U.TOUCH_START,this._mouseDownCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback)},this._deactivateDraw=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragCallback),n.removeEventListener(U.MOUSE_MOVE,this._dragCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.MOUSE_DOWN,this._mouseDownCallback),n.removeEventListener(U.TOUCH_END,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragCallback),n.removeEventListener(U.TOUCH_START,this._mouseDownCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback)},this.renderAnnotation=(n,i)=>{var d;let o=!1;const{viewport:a}=n,{element:s}=a;let c=Jt(this.getToolName(),s);if(!(c!=null&&c.length)||(c=this.filterInteractableAnnotationsForElement(s,c),!(c!=null&&c.length)))return o;const l=this.getTargetId(a),f=a.getRenderingEngine(),u={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:n.viewport.id};for(let h=0;h<c.length;h++){const g=c[h],{annotationUID:p,data:v}=g,{points:y,activeHandleIndex:m}=v.handles;u.annotationUID=p;const{color:w,lineWidth:x,lineDash:C}=this.getAnnotationStyle({annotation:g,styleSpecifier:u}),S=y.map(Ge=>a.worldToCanvas(Ge));!v.cachedStats[l]||v.cachedStats[l].angle==null?(v.cachedStats[l]={angle:null,arc1Angle:null,arc2Angle:null,points:{world:{arc1Start:null,arc1End:null,arc2Start:null,arc2End:null,arc1Angle:null,arc2Angle:null},canvas:{arc1Start:null,arc1End:null,arc2Start:null,arc2End:null,arc1Angle:null,arc2Angle:null}}},this._calculateCachedStats(g,f,n)):g.invalidated&&this._throttledCalculateCachedStats(g,f,n);let T;if(!Yr(p)&&!this.editData&&m!==null&&(T=[S[m]]),!a.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),o;if(!Vr(p))continue;T&&Kn(i,p,"0",S,{color:w,lineDash:C,lineWidth:x});const _=[S[0],S[1]],E=[S[2],S[3]];let b="line1";if(an(i,p,b,_[0],_[1],{color:w,width:x,lineDash:C}),o=!0,S.length<4)return o;b="line2",an(i,p,b,E[0],E[1],{color:w,width:x,lineDash:C}),b="linkLine";const D=bl(_[0],_[1]),I=bl(E[0],E[1]);an(i,p,b,D,I,{color:w,lineWidth:"1",lineDash:"1,4"});const{arc1Start:P,arc1End:O,arc2End:L,arc2Start:B}=v.cachedStats[l].points.canvas,{arc1Angle:H,arc2Angle:A}=v.cachedStats[l];if(this.configuration.showArcLines&&(b="arc1",an(i,p,b,P,O,{color:w,lineWidth:"1"}),b="arc2",an(i,p,b,B,L,{color:w,lineWidth:"1"})),!((d=v.cachedStats[l])!=null&&d.angle))continue;const F=this.getLinkedTextBoxStyle(u,g);if(!F.visibility){v.handles.textBox={hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}};continue}const G=this.configuration.getTextLines(v,l);if(!v.handles.textBox.hasMoved){const Ge=wa(S);v.handles.textBox.worldPosition=a.canvasToWorld(Ge)}const X=a.worldToCanvas(v.handles.textBox.worldPosition),ce=Ji(i,p,"cobbAngleText",G,X,S,{},F),{x:Se,y:we,width:_e,height:Ve}=ce;if(v.handles.textBox.worldBoundingBox={topLeft:a.canvasToWorld([Se,we]),topRight:a.canvasToWorld([Se+_e,we]),bottomLeft:a.canvasToWorld([Se,we+Ve]),bottomRight:a.canvasToWorld([Se+_e,we+Ve])},this.configuration.showArcLines){const Ge="arcAngle1",Ne=[`${H.toFixed(2)} °`],j=bl(P,O);df(i,p,Ge,Ne,j,{...F,padding:3});const M="arcAngle2",q=[`${A.toFixed(2)} °`],K=bl(B,L);df(i,p,M,q,K,{...F,padding:3})}}return o},this.distanceToLines=({viewport:n,points:i,canvasCoords:o,proximity:a})=>{const[s,c,l,f]=i,u=n.worldToCanvas(s),d=n.worldToCanvas(c),h=n.worldToCanvas(l),g=n.worldToCanvas(f),p={start:{x:u[0],y:u[1]},end:{x:d[0],y:d[1]}},v={start:{x:h[0],y:h[1]},end:{x:g[0],y:g[1]}},y=ui([p.start.x,p.start.y],[p.end.x,p.end.y],[o[0],o[1]]),m=ui([v.start.x,v.start.y],[v.end.x,v.end.y],[o[0],o[1]]);let w=!1,x=!1;return y<=a?w=!0:m<=a&&(x=!0),{distanceToPoint:y,distanceToPoint2:m,isNearFirstLine:w,isNearSecondLine:x}},this.getArcsStartEndPoints=({firstLine:n,secondLine:i,mid1:o,mid2:a})=>{const s=[o,a],c=ah(n,s),l=ah(i,s),f=c>90?1:0,u=l>90?0:1,d=bl(s[0],s[1]),h=Math.sqrt((s[1][0]-s[0][0])**2+(s[1][1]-s[0][1])**2),g=.1,p=bl(n[0],n[1]),v=bl(i[0],i[1]),y=[n[f][0]-p[0],n[f][1]-p[1]],m=Math.sqrt(y[0]**2+y[1]**2),w=[y[0]/m,y[1]/m],x=[p[0]+w[0]*h*g,p[1]+w[1]*h*g],C=[d[0]-o[0],d[1]-o[1]],S=Math.sqrt(C[0]**2+C[1]**2),T=[C[0]/S,C[1]/S],_=[o[0]+T[0]*h*g,o[1]+T[1]*h*g],E=[i[u][0]-v[0],i[u][1]-v[1]],b=Math.sqrt(E[0]**2+E[1]**2),D=[E[0]/b,E[1]/b],I=[v[0]+D[0]*h*g,v[1]+D[1]*h*g],P=[d[0]-a[0],d[1]-a[1]],O=Math.sqrt(P[0]**2+P[1]**2),L=[P[0]/O,P[1]/O],B=[a[0]+L[0]*h*g,a[1]+L[1]*h*g];return{arc1Start:x,arc1End:_,arc2Start:I,arc2End:B,arc1Angle:c>90?180-c:c,arc2Angle:l>90?180-l:l}},this._throttledCalculateCachedStats=Lo(this._calculateCachedStats,25,{trailing:!0})}handleSelectedCallback(e,r,n,i="mouse"){const o=e.detail,{element:a}=o,{data:s}=r;r.highlighted=!0;let c=!1,l;n.worldPosition?c=!0:l=s.handles.points.findIndex(u=>u===n);const f=wt(a,this.getToolName());this.editData={annotation:r,viewportIdsToRender:f,handleIndex:l,movingTextBox:c},this._activateModify(a),Dt(a),We(f),e.preventDefault()}_calculateCachedStats(e,r,n){const i=e.data;if(i.handles.points.length!==4)return;const o=[null,null],a=[null,null];let s=Number.MAX_VALUE;for(let _=0;_<2;_+=1)for(let E=2;E<4;E+=1){const b=Fi(i.handles.points[_],i.handles.points[E]);b<s&&(s=b,o[1]=i.handles.points[_],o[0]=i.handles.points[(_+1)%2],a[0]=i.handles.points[E],a[1]=i.handles.points[2+(E-1)%2])}const{viewport:c}=n,{element:l}=c,f=i.handles.points.map(_=>c.worldToCanvas(_)),u=[f[0],f[1]],d=[f[2],f[3]],h=bl(u[0],u[1]),g=bl(d[0],d[1]),{arc1Start:p,arc1End:v,arc2End:y,arc2Start:m,arc1Angle:w,arc2Angle:x}=this.getArcsStartEndPoints({firstLine:u,secondLine:d,mid1:h,mid2:g}),{cachedStats:C}=i,S=Object.keys(C);for(let _=0;_<S.length;_++){const E=S[_];C[E]={angle:ah(o,a),arc1Angle:w,arc2Angle:x,points:{canvas:{arc1Start:p,arc1End:v,arc2End:y,arc2Start:m},world:{arc1Start:c.canvasToWorld(p),arc1End:c.canvasToWorld(v),arc2End:c.canvasToWorld(y),arc2Start:c.canvasToWorld(m)}}}}const T=e.invalidated;return e.invalidated=!1,T&&Kt(e,l,Bt.StatsUpdated),C}};hb.toolName="CobbAngle";let vT=hb;function WTe(t,e){const r=t.cachedStats[e],{angle:n}=r;return n===void 0?void 0:[`${n.toFixed(2)} °`]}const{transformWorldToIndex:x7}=pn,gb=class gb extends Yn{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{shadow:!0,preventHandleOutsideImage:!1,getTextLines:zTe,displayBothAxesDistances:!1}}){super(e,r),this.addNewAnnotation=n=>{if(this.startedDrawing)return;this.startedDrawing=!0;const i=n.detail,{currentPoints:o,element:a}=i,s=o.world,c=Le(a),{viewport:l,renderingEngine:f}=c;if(!(l instanceof Jn))throw new Error("UltrasoundDirectionalTool can only be used on a StackViewport");Dt(a),this.isDrawing=!0;const u=l.getCamera(),{viewPlaneNormal:d,viewUp:h}=u,g=this.getReferencedImageId(l,s,d,h),p=l.getFrameOfReferenceUID(),v={highlighted:!0,invalidated:!0,metadata:{toolName:this.getToolName(),viewPlaneNormal:[...d],viewUp:[...h],FrameOfReferenceUID:p,referencedImageId:g},data:{handles:{points:[[...s],[...s]],activeHandleIndex:null,textBox:{hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}}},label:"",cachedStats:{}}};qt(v,a);const y=wt(a,this.getToolName());return this.editData={annotation:v,viewportIdsToRender:y,handleIndex:1,movingTextBox:!1,newAnnotation:!0,hasMoved:!1},this._activateDraw(a),n.preventDefault(),We(y),v},this.isPointNearTool=(n,i,o,a)=>{const s=Le(n),{viewport:c}=s,{data:l}=i,[f,u]=l.handles.points,d=c.worldToCanvas(f),h=c.worldToCanvas(u),g={start:{x:d[0],y:d[1]},end:{x:h[0],y:h[1]}};return ui([g.start.x,g.start.y],[g.end.x,g.end.y],[o[0],o[1]])<=a},this._endCallback=n=>{const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s,newAnnotation:c,hasMoved:l}=this.editData,{data:f}=a;if(c&&!l)return;if(this.startedDrawing&&f.handles.points.length===1){this.editData.handleIndex=1;return}this.startedDrawing=!1,f.handles.activeHandleIndex=null,this._deactivateModify(o),this._deactivateDraw(o),kt(o);const u=Le(o),{renderingEngine:d}=u;this.isHandleOutsideImage&&this.configuration.preventHandleOutsideImage&&en(a.annotationUID),We(s),c&&bn(a),this.editData=null,this.isDrawing=!1},this._dragCallback=n=>{this.isDrawing=!0;const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s,handleIndex:c,movingTextBox:l}=this.editData,{data:f}=a;if(l){const{deltaPoints:h}=i,g=h.world,{textBox:p}=f.handles,{worldPosition:v}=p;v[0]+=g[0],v[1]+=g[1],v[2]+=g[2],p.hasMoved=!0}else if(c===void 0){const{deltaPoints:h}=i,g=h.world;f.handles.points.forEach(v=>{v[0]+=g[0],v[1]+=g[1],v[2]+=g[2]}),a.invalidated=!0}else{const{currentPoints:h}=i,g=h.world;f.handles.points[c]=[...g],a.invalidated=!0}this.editData.hasMoved=!0;const u=Le(o),{renderingEngine:d}=u;We(s)},this.cancel=n=>{if(this.isDrawing){this.isDrawing=!1,this._deactivateDraw(n),this._deactivateModify(n),kt(n);const{annotation:i,viewportIdsToRender:o,newAnnotation:a}=this.editData,{data:s}=i;return i.highlighted=!1,s.handles.activeHandleIndex=null,We(o),a&&bn(i),this.editData=null,this.startedDrawing=!1,i.annotationUID}},this._activateModify=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragCallback)},this._deactivateModify=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback),n.removeEventListener(U.TOUCH_END,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragCallback)},this._activateDraw=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragCallback),n.addEventListener(U.MOUSE_MOVE,this._dragCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragCallback)},this._deactivateDraw=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragCallback),n.removeEventListener(U.MOUSE_MOVE,this._dragCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback),n.removeEventListener(U.TOUCH_END,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragCallback)},this.renderAnnotation=(n,i)=>{let o=!1;const{viewport:a}=n,{element:s}=a;let c=Jt(this.getToolName(),s);if(!(c!=null&&c.length)||(c=this.filterInteractableAnnotationsForElement(s,c),!(c!=null&&c.length)))return o;const l=this.getTargetId(a),f=a.getRenderingEngine(),u={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:n.viewport.id};for(let d=0;d<c.length;d++){const h=c[d],{annotationUID:g,data:p}=h,{points:v}=p.handles;u.annotationUID=g;const y=this.getStyle("color",u,h),m=v.map(O=>a.worldToCanvas(O));if(!p.cachedStats[l]||p.cachedStats[l].xValues==null?(p.cachedStats[l]={xValues:[0,0],yValues:[0,0],isHorizontal:!1,units:[""],isUnitless:!1},this._calculateCachedStats(h,f,n)):h.invalidated&&this._throttledCalculateCachedStats(h,f,n),!a.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),o;let w="0";if(u5(i,g,w,m[0],{color:y},0),o=!0,m.length!==2)return o;if(w="1",u5(i,g,w,m[1],{color:y},1),p.cachedStats[l].isUnitless){const O=`${g}-line-1`;an(i,g,"1",m[0],m[1],{color:y,width:1,shadow:this.configuration.shadow},O)}else{const O=m[0],L=m[1],B=L[1]-O[1],H=L[0]-O[0],A=p.cachedStats[l].isHorizontal;let F=[0,0];A?F=[O[0]+H,O[1]]:F=[O[0],O[1]+B];let G=`${g}-line-1`,X="1";an(i,g,X,m[0],F,{color:y,width:1,shadow:this.configuration.shadow},G),G=`${g}-line-2`,X="2",an(i,g,X,m[1],F,{color:y,width:1,lineDash:[1,1],shadow:this.configuration.shadow},G)}const C=this.getLinkedTextBoxStyle(u,h);if(!C.visibility){p.handles.textBox={hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}};continue}const S=this.configuration.getTextLines(p,l,this.configuration);if(!p.handles.textBox.hasMoved){const O=m[1];p.handles.textBox.worldPosition=a.canvasToWorld(O)}const T=a.worldToCanvas(p.handles.textBox.worldPosition),E=Ji(i,g,"1",S,T,m,{},C),{x:b,y:D,width:I,height:P}=E;p.handles.textBox.worldBoundingBox={topLeft:a.canvasToWorld([b,D]),topRight:a.canvasToWorld([b+I,D]),bottomLeft:a.canvasToWorld([b,D+P]),bottomRight:a.canvasToWorld([b+I,D+P])}}return o},this._throttledCalculateCachedStats=Lo(this._calculateCachedStats,100,{trailing:!0})}toolSelectedCallback(e,r,n,i){}handleSelectedCallback(e,r,n){const i=e.detail,{element:o}=i,{data:a}=r;r.highlighted=!0;const s=wt(o,this.getToolName());let c;n.worldPosition||(c=a.handles.points.findIndex(u=>u===n)),this.editData={handleIndex:c,annotation:r,viewportIdsToRender:s},this._activateModify(o),Dt(o);const l=Le(o),{renderingEngine:f}=l;We(s),e.preventDefault()}_calculateCachedStats(e,r,n){const i=e.data,{element:o}=n.viewport;if(i.handles.points.length!==2)return;const{cachedStats:a}=i,s=Object.keys(a);for(let l=0;l<s.length;l++){const f=s[l],u=this.getTargetImageData(f);if(!u)continue;const{imageData:d}=u,h=i.handles.points[0],g=i.handles.points[1],p=x7(d,h),v=x7(d,g),{values:y,units:m}=p5(u,[p]),{values:w,units:x}=p5(u,[v]);let C,S,T,_,E=!1;if(m[0]!==x[0]||m[1]!==x[1]||m[0]==="raw"&&x[0]==="raw"){const b=Do(h,g);C=[b,0],S=[b,0],T=["px"],E=!0}else{const b=n.viewport.worldToCanvas(h),D=n.viewport.worldToCanvas(g),I=D[1]-b[1],P=D[0]-b[0];_=Math.abs(P)>Math.abs(I),C=[y[0],w[0]],S=[y[1],w[1]],T=[m[0],m[1]]}a[f]={xValues:C,yValues:S,isHorizontal:_,units:T,isUnitless:E}}const c=e.invalidated;return e.invalidated=!1,c&&Kt(e,o,Bt.StatsUpdated),a}};gb.toolName="UltrasoundDirectionalTool";let yT=gb;function zTe(t,e,r){const n=t.cachedStats[e],{xValues:i,yValues:o,units:a,isUnitless:s,isHorizontal:c}=n;if(s)return[`${Xt(i[0])} px`];if(r.displayBothAxesDistances){const l=Math.abs(i[1]-i[0]),f=Math.abs(o[1]-o[0]);return[`${Xt(l)} ${a[0]}`,`${Xt(f)} ${a[1]}`]}if(c){const l=Math.abs(i[1]-i[0]);return[`${Xt(l)} ${a[0]}`]}else{const l=Math.abs(o[1]-o[0]);return[`${Xt(l)} ${a[1]}`]}}function $Te(t){return(t%360+360)%360}function wT(t,e){const r=e[0]-t[0],n=e[1]-t[1],i=Math.atan2(n,r)*(180/Math.PI);return $Te(i)}function O5(t,e){const r=wT(t,e[0]),n=wT(t,e[1]);return r<n?[r,n]:[n,r]}function xT(t){if(!t.length)return[];t.sort((r,n)=>r[0]-n[0]);const e=[t[0].slice()];for(let r=1;r<t.length;r++){const n=e[e.length-1],i=t[r];i[0]<=n[1]?n[1]=Math.max(n[1],i[1]):e.push(i.slice())}return e}function C7(t,e){const[r,n]=e;if(n<=r)return[];const i=t.map(([f,u])=>[Math.max(f,r),Math.min(u,n)]).filter(([f,u])=>u>f);if(i.length===0)return[[r,n]];i.sort((f,u)=>f[0]-u[0]);const o=[];let[a,s]=i[0];for(let f=1;f<i.length;f++){const[u,d]=i[f];u<=s?s=Math.max(s,d):(o.push([a,s]),[a,s]=[u,d])}o.push([a,s]);const c=[];let l=r;for(const[f,u]of o)f>l&&c.push([l,f]),l=Math.max(l,u);return l<n&&c.push([l,n]),c}function sz(t,e){const r=[];for(const n of e){const i=Math.max(t[0],n[0]),o=Math.min(t[1],n[1]);i<o&&r.push([i,o])}return r}function jTe(t,e,r){const n=e.map(f=>O5(t,f)),i=xT(n),o=i.reduce((f,[u,d])=>f+(d-u),0);if(o===0)return 0;const a=[];for(const f of r){const u=O5(t,f),d=sz(u,i);a.push(...d)}const l=xT(a).reduce((f,[u,d])=>f+(d-u),0)/o*100;return Math.min(100,Math.max(0,l))}const{transformIndexToWorld:S7}=pn,sr=class sr extends Yn{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{preventHandleOutsideImage:!1,getTextLines:HTe,center:null,innerRadius:null,outerRadius:null,startAngle:null,endAngle:null,bLineColor:"rgb(60, 255, 60)",pleuraColor:"rgb(0, 4, 255)",drawDepthGuide:!0,depth_ratio:.5,depthGuideColor:"rgb(0, 255, 255)",depthGuideThickness:4,depthGuideDashLength:20,depthGuideDashGap:16,depthGuideOpacity:.2,fanOpacity:.1,showFanAnnotations:!0,updatePercentageCallback:null,actions:{undo:{method:"undo",bindings:[{key:"z"}]},redo:{method:"redo",bindings:[{key:"y"}]}}}}){super(e,r),this.pleuraAnnotations=[],this.bLineAnnotations=[],this.addNewAnnotation=n=>{const i=n.detail,{currentPoints:o,element:a}=i,s=o.world,c=Le(a),{viewport:l}=c;Dt(a),this.isDrawing=!0;const{viewPlaneNormal:f,viewUp:u,position:d}=l.getCamera(),h=this.getReferencedImageId(l,s,f,u),g={highlighted:!0,invalidated:!0,metadata:{...l.getViewReference({points:[s]}),toolName:this.getToolName(),referencedImageId:h,viewUp:u,cameraPosition:d},data:{handles:{points:[[...s],[...s]],activeHandleIndex:null},annotationType:this.getActiveAnnotationType(),label:""}};qt(g,a);const p=wt(a,this.getToolName());return this.editData={annotation:g,viewportIdsToRender:p,handleIndex:1,movingTextBox:!1,newAnnotation:!0,hasMoved:!1},this._activateDraw(a),n.preventDefault(),We(p),g},this.isPointNearTool=(n,i,o,a)=>{const s=Le(n),{viewport:c}=s,{data:l}=i,[f,u]=l.handles.points,d=c.worldToCanvas(f),h=c.worldToCanvas(u),g={start:{x:d[0],y:d[1]},end:{x:h[0],y:h[1]}};return ui([g.start.x,g.start.y],[g.end.x,g.end.y],[o[0],o[1]])<=a},this.toolSelectedCallback=(n,i)=>{const o=n.detail,{element:a}=o;i.highlighted=!0;const s=wt(a,this.getToolName());this.editData={annotation:i,viewportIdsToRender:s,movingTextBox:!1},this._activateModify(a),Dt(a),We(s),n.preventDefault()},this._endCallback=n=>{const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s,newAnnotation:c,hasMoved:l}=this.editData,{data:f}=a;c&&!l||(f.handles.activeHandleIndex=null,this._deactivateModify(o),this._deactivateDraw(o),kt(o),this.isHandleOutsideImage&&this.configuration.preventHandleOutsideImage&&en(a.annotationUID),We(s),this.doneEditMemo(),c&&bn(a),this.editData=null,this.isDrawing=!1)},this._dragCallback=n=>{this.isDrawing=!0;const i=n.detail,{element:o}=i,{viewport:a}=Le(o)||{};if(!a)return;const{annotation:s,viewportIdsToRender:c,handleIndex:l,movingTextBox:f,newAnnotation:u}=this.editData,{data:d}=s;if(this.createMemo(o,s,{newAnnotation:u}),f){const{deltaPoints:h}=i,g=h.world,{textBox:p}=d.handles,{worldPosition:v}=p;v[0]+=g[0],v[1]+=g[1],v[2]+=g[2],p.hasMoved=!0}else if(l===void 0){const{deltaPoints:h}=i,g=h.world,p=d.handles.points;p.every(y=>{const m=[y[0]+g[0],y[1]+g[1],y[2]+g[2]];return this.isInsideFanShape(a,m)})&&(p.forEach(y=>{y[0]+=g[0],y[1]+=g[1],y[2]+=g[2]}),s.invalidated=!0)}else{const{currentPoints:h}=i,g=h.world;this.isInsideFanShape(a,g)&&(d.handles.points[l]=[...g],s.invalidated=!0)}this.editData.hasMoved=!0,We(c),s.invalidated&&Kt(s,o,Bt.HandlesUpdated)},this.cancel=n=>{if(this.isDrawing){this.isDrawing=!1,this._deactivateDraw(n),this._deactivateModify(n),kt(n);const{annotation:i,viewportIdsToRender:o,newAnnotation:a}=this.editData,{data:s}=i;return i.highlighted=!1,s.handles.activeHandleIndex=null,We(o),a&&bn(i),this.editData=null,i.annotationUID}},this._activateModify=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback)},this._deactivateModify=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.TOUCH_END,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback)},this._activateDraw=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragCallback),n.addEventListener(U.MOUSE_MOVE,this._dragCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback)},this._deactivateDraw=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragCallback),n.removeEventListener(U.MOUSE_MOVE,this._dragCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.TOUCH_END,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback)},this.renderAnnotation=(n,i)=>{let o=!1;const{viewport:a}=n,{element:s}=a;if(!this.getFanShapeGeometryParameters(a))return;const{imageData:c}=a.getImageData()||{};if(!c)return o;this.configuration.drawDepthGuide&&this.drawDepthGuide(i,a);let l=Jt(this.getToolName(),s);if(!(l!=null&&l.length)||(l=this.filterInteractableAnnotationsForElement(s,l),!(l!=null&&l.length)))return o;this.getTargetId(a),a.getRenderingEngine();const f={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:n.viewport.id},u=a.worldToCanvas(S7(c,this.configuration.center)),d=this.getIndexToCanvasRatio(a),h=this.configuration.innerRadius*d,g=this.configuration.outerRadius*d,p=a.getCurrentImageId(),v=l.filter(T=>T.data.annotationType===sr.USPleuraBLineAnnotationType.PLEURA&&T.metadata.referencedImageId===p).map(T=>{const _=T.data.handles.points.map(b=>a.worldToCanvas(b));return O5(u,_)}),y=xT(v),m=[],w=[],x=T=>{const{annotationUID:_,data:E}=T,{points:b,activeHandleIndex:D}=E.handles;f.annotationUID=_;const{color:I,lineWidth:P,lineDash:O,shadow:L}=this.getAnnotationStyle({annotation:T,styleSpecifier:f}),B=b.map(G=>a.worldToCanvas(G));if(!a.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),o;let H;if(!Vr(_))return;!Yr(_)&&!this.editData&&D!==null&&(H=[B[D]]),H&&Kn(i,_,"0",B,{color:this.getColorForLineType(T),fill:this.getColorForLineType(T),lineDash:O,lineWidth:P});const A=`${_}-line`;if(an(i,_,"1",B[0],B[1],{color:this.getColorForLineType(T),width:P,lineDash:O,shadow:L},A),this.configuration.showFanAnnotations){const G=O5(u,B);let X=0;T.data.annotationType===sr.USPleuraBLineAnnotationType.BLINE?C7(w,G).forEach(ce=>{sz(ce,y).forEach(we=>{X++;const _e=X,Ve=`${_}-fan-${_e}`,Ge=`2-${_e}`;HS(i,_,Ge,u,h,g,we[0],we[1],{color:"transparent",fill:this.getColorForLineType(T),fillOpacity:this.configuration.fanOpacity,width:P,lineDash:O,shadow:L},Ve,10),w.push(we)})}):T.data.annotationType===sr.USPleuraBLineAnnotationType.PLEURA&&C7(m,G).forEach((ce,Se)=>{X++;const we=X,_e=`${_}-fan-${we}`,Ve=`2-${we}`;HS(i,_,Ve,u,h,g,ce[0],ce[1],{color:"transparent",fill:this.getColorForLineType(T),fillOpacity:this.configuration.fanOpacity,width:P,lineDash:O,shadow:L},_e,5),m.push(ce)})}};return l.filter(T=>T.data.annotationType===sr.USPleuraBLineAnnotationType.PLEURA&&T.metadata.referencedImageId===p).forEach(T=>{if(!a.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),o;x(T)}),l.filter(T=>T.data.annotationType===sr.USPleuraBLineAnnotationType.BLINE&&T.metadata.referencedImageId===p).forEach(T=>{if(!a.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),o;x(T)}),o=!0,this.configuration.updatePercentageCallback&&a&&this.configuration.updatePercentageCallback(this.calculateBLinePleuraPercentage(a)),o},this.activeAnnotationType=sr.USPleuraBLineAnnotationType.BLINE}static filterAnnotations(e,r=()=>!0){const n=Jt(sr.toolName,e);return n!=null&&n.length?n.filter(o=>{const a=o.metadata.referencedImageId;return r(a)}):[]}static countAnnotations(e,r=()=>!0){const n=Jt(sr.toolName,e),{viewport:i}=Le(e),o=i.getImageIds(),a=c=>{const l=o.findIndex(f=>f===c);return l===-1?0:l};if(!(n!=null&&n.length))return;const s=new Map;return n.forEach(c=>{const l=c.metadata.referencedImageId;if(!r(l))return;const{annotationType:f}=c.data;let u;s.has(l)?u=s.get(l):u={frame:a(l),bLine:0,pleura:0},f===sr.USPleuraBLineAnnotationType.PLEURA?u.pleura++:f===sr.USPleuraBLineAnnotationType.BLINE&&u.bLine++,s.set(l,u)}),s}static deleteAnnotations(e,r=()=>!1){const n=Jt(sr.toolName,e);n!=null&&n.length&&n.forEach(i=>{r(i.metadata.referencedImageId)&&en(i.annotationUID)})}setActiveAnnotationType(e){this.activeAnnotationType=e}getActiveAnnotationType(){return this.activeAnnotationType}deleteLastAnnotationType(e,r){let n;const i=Jt(sr.toolName,e);if(r===sr.USPleuraBLineAnnotationType.PLEURA?n=i.filter(o=>o.data.annotationType===sr.USPleuraBLineAnnotationType.PLEURA):r===sr.USPleuraBLineAnnotationType.BLINE&&(n=i.filter(o=>o.data.annotationType===sr.USPleuraBLineAnnotationType.BLINE)),(n==null?void 0:n.length)>0){const o=n.pop();en(o.annotationUID)}}handleSelectedCallback(e,r,n){const i=e.detail,{element:o}=i,{data:a}=r;r.highlighted=!0;let s=!1,c;n.worldPosition?s=!0:c=a.handles.points.findIndex(f=>f===n);const l=wt(o,this.getToolName());this.editData={annotation:r,viewportIdsToRender:l,handleIndex:c,movingTextBox:s},this._activateModify(o),Dt(o),We(l),e.preventDefault()}isInsideFanShape(e,r){if(!this.getFanShapeGeometryParameters(e))return!1;const{imageData:n}=e.getImageData()||{};if(n){const i=e.worldToCanvas(n.indexToWorld(this.configuration.center)),o=e.worldToCanvas(r),a=wT(i,o);return a>=this.configuration.startAngle&&a<=this.configuration.endAngle}}updateFanGeometryConfiguration(e){e&&(this.isFanShapeGeometryParametersValid(e)&&(this.configuration.center=[e.center[0],e.center[1],0]),this.configuration.innerRadius=e.innerRadius,this.configuration.outerRadius=e.outerRadius,this.configuration.startAngle=e.startAngle,this.configuration.endAngle=e.endAngle)}deriveFanGeometryFromViewport(e){const r=e.getCurrentImageId(),{fanGeometry:n}=F8(r)||{};n&&this.updateFanGeometryConfiguration(n)}isFanShapeGeometryParametersValid(e){return e||(e=this.configuration),(e==null?void 0:e.center)&&(e==null?void 0:e.innerRadius)>0&&(e==null?void 0:e.outerRadius)&&(e==null?void 0:e.startAngle)>0&&(e==null?void 0:e.startAngle)<360&&(e==null?void 0:e.endAngle)>0&&(e==null?void 0:e.endAngle)<360}getFanShapeGeometryParameters(e){if(this.isFanShapeGeometryParametersValid())return!0;if(!this.isFanShapeGeometryParametersValid()){const r=e.getCurrentImageId(),n=ct("ultrasoundFanShapeGeometry",r);this.updateFanGeometryConfiguration(n)}return this.isFanShapeGeometryParametersValid()||this.deriveFanGeometryFromViewport(e),this.isFanShapeGeometryParametersValid()}calculateBLinePleuraPercentage(e){if(!this.getFanShapeGeometryParameters(e))return;const{imageData:r}=e.getImageData()||{};if(!r)return;const{element:n}=e,i=e.worldToCanvas(r.indexToWorld(this.configuration.center)),o=e.getCurrentImageId(),a=Jt(this.getToolName(),n)||[],s=a.filter(l=>l.data.annotationType===sr.USPleuraBLineAnnotationType.PLEURA&&l.metadata.referencedImageId===o).map(l=>l.data.handles.points.map(u=>e.worldToCanvas(u))),c=a.filter(l=>l.data.annotationType===sr.USPleuraBLineAnnotationType.BLINE&&l.metadata.referencedImageId===o).map(l=>l.data.handles.points.map(u=>e.worldToCanvas(u)));return jTe(i,s,c)}getColorForLineType(e){const{annotationType:r}=e.data,{bLineColor:n,pleuraColor:i}=this.configuration;return r===sr.USPleuraBLineAnnotationType.BLINE?n:r===sr.USPleuraBLineAnnotationType.PLEURA?i:n}getIndexToCanvasRatio(e){const{imageData:r}=e.getImageData()||{},n=e.worldToCanvas(r.indexToWorld([1,0,0])),i=e.worldToCanvas(r.indexToWorld([2,0,0])),o=[i[0]-n[0],i[1]-n[1]];return Math.sqrt(o[0]*o[0]+o[1]*o[1])}drawDepthGuide(e,r){if(!this.getFanShapeGeometryParameters(r))return;const{imageData:n}=r.getImageData()||{};if(!n)return;const i=g=>g*180/Math.PI,o=g=>g*Math.PI/180,a=g=>r.worldToCanvas(S7(n,g)),s=this.configuration.innerRadius+this.configuration.depth_ratio*(this.configuration.outerRadius-this.configuration.innerRadius),c=this.configuration.startAngle,f=this.configuration.endAngle-c,u=o(f)*s;let d=Math.round(u/(this.configuration.depthGuideDashLength+this.configuration.depthGuideDashGap));d<=0&&(d=Math.max(15,Math.round(f/5)));const h=f/d;for(let g=0;g<d;g++){const p=o(c+g*h),v=o(c+g*h+i(this.configuration.depthGuideDashLength)/s),y=[this.configuration.center[0]+s*Math.cos(p),this.configuration.center[1]+s*Math.sin(p),0],m=[this.configuration.center[0]+s*Math.cos(v),this.configuration.center[1]+s*Math.sin(v),0];an(e,r.id,`depthGuide-${g}`,a(y),a(m),{color:this.configuration.depthGuideColor,lineWidth:this.configuration.depthGuideThickness,strokeOpacity:this.configuration.depthGuideOpacity})}}_isInsideVolume(e,r,n){return tr(e,n)&&tr(r,n)}};sr.toolName="UltrasoundPleuraBLineTool",sr.USPleuraBLineAnnotationType={BLINE:"bLine",PLEURA:"pleura"},sr.hydrate=(e,r,n)=>{const i=Mn(e);if(!i)return;const{FrameOfReferenceUID:o,referencedImageId:a,viewPlaneNormal:s,instance:c,viewport:l}=sr.hydrateBase(sr,i,r,n),{toolInstance:f,...u}=n||{},d={annotationUID:(n==null?void 0:n.annotationUID)||gn(),data:{handles:{points:r}},highlighted:!1,autoGenerated:!1,invalidated:!1,isLocked:!1,isVisible:!0,metadata:{toolName:c.getToolName(),viewPlaneNormal:s,FrameOfReferenceUID:o,referencedImageId:a,...u}};qt(d,l.element),We([l.id])};let CT=sr;function HTe(t,e){return[""]}const Fp=class Fp extends Yn{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{getTextCallback:KTe,changeTextCallback:qTe,canvasPosition:[10,10],canvasSize:10,handleRadius:"6",seriesLevel:!1,isPoint:!1}}){super(e,r),this.addNewAnnotation=n=>{const i=n.detail,{element:o,currentPoints:a}=i,s=Le(o),{viewport:c}=s,l=a.world,f=this.constructor.createAnnotationForViewport(c,{data:{handles:{points:[[...l]]},seriesLevel:this.configuration.seriesLevel,isPoint:this.configuration.isPoint}});qt(f,o);const u=wt(o,this.getToolName());return n.preventDefault(),We(u),this.configuration.getTextCallback(d=>{if(!d){en(f.annotationUID),We(u),this.isDrawing=!1;return}f.data.text=d,bn(f),We(u)}),this.createMemo(o,f,{newAnnotation:!0}),f},this.isPointNearTool=(n,i,o,a)=>{const s=Le(n),{viewport:c}=s,{data:l}=i;if(!(l!=null&&l.isPoint))return!1;const{canvasPosition:f,canvasSize:u}=this.configuration;return f!=null&&f.length?Math.abs(o[0]-f[0]+u/2)<=u/2&&Math.abs(o[1]-f[1]+u/2)<=u/2:!1},this.toolSelectedCallback=(n,i)=>{i.highlighted=!0,n.preventDefault()},this._endCallback=n=>{const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s,newAnnotation:c}=this.editData,{viewportId:l,renderingEngine:f}=Le(o);this.eventDispatchDetail={viewportId:l,renderingEngineId:f.id},this._deactivateModify(o),kt(o),c&&this.createMemo(o,a,{newAnnotation:c}),this.editData=null,this.isDrawing=!1,this.doneEditMemo(),this.isHandleOutsideImage&&this.configuration.preventHandleOutsideImage&&en(a.annotationUID),We(s),c&&bn(a)},this.doubleClickCallback=n=>{const i=n.detail,{element:o}=i;let a=Jt(this.getToolName(),o);if(a=this.filterInteractableAnnotationsForElement(o,a),!(a!=null&&a.length))return;const s=a.find(l=>this.isPointNearTool(o,l,i.currentPoints.canvas,6));if(!s)return;const c=s;this.createMemo(o,c),this.configuration.changeTextCallback(s,n.detail,this._doneChangingTextCallback.bind(this,o,c)),this.isDrawing=!1,this.doneEditMemo(),n.stopImmediatePropagation(),n.preventDefault()},this._dragCallback=n=>{this.isDrawing=!0;const i=n.detail,{currentPoints:o,element:a}=i,s=o.world,{annotation:c,viewportIdsToRender:l,newAnnotation:f}=this.editData,{data:u}=c;this.createMemo(a,c,{newAnnotation:f}),u.handles.points[0]=[...s],c.invalidated=!0,We(l)},this._activateModify=n=>{Je.isInteractingWithTool=!0,n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback)},this._deactivateModify=n=>{Je.isInteractingWithTool=!1,n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.TOUCH_END,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback)},this.renderAnnotation=(n,i)=>{let o=!1;const{viewport:a}=n,{element:s}=a;let c=Jt(this.getToolName(),s);if(!(c!=null&&c.length)||(c=this.filterInteractableAnnotationsForElement(s,c),!(c!=null&&c.length)))return o;const l={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:n.viewport.id};for(let f=0;f<c.length;f++){const u=c[f],{annotationUID:d,data:h}=u;l.annotationUID=d;const{color:g,lineWidth:p}=this.getAnnotationStyle({annotation:u,styleSpecifier:l}),{canvasPosition:v,canvasSize:y}=this.configuration,m="1";if(h!=null&&h.isPoint){const w=h.handles.points[0],x=a.worldToCanvas(w);Kn(i,d,m,[x],{color:g,lineWidth:p,handleRadius:this.configuration.handleRadius})}else v!=null&&v.length&&f5(i,d,m,v.map(w=>w+y),v,{color:g,width:1});if(o=!0,!a.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),o}return o}}handleSelectedCallback(e,r){const n=e.detail,{element:i}=n;r.highlighted=!0;const o=wt(i,this.getToolName());this.editData={annotation:r,viewportIdsToRender:o},this._activateModify(i),Dt(i),We(o),e.preventDefault()}static setPoint(e,r=!e.data.isPoint,n){e.data.isPoint=r,Kt(e,n)}_doneChangingTextCallback(e,r,n){r.data.text=n;const i=wt(e,this.getToolName());We(i),Kt(r,e)}cancel(e){if(this.isDrawing){this.isDrawing=!1,this._deactivateModify(e),kt(e);const{annotation:r,viewportIdsToRender:n,newAnnotation:i}=this.editData,{data:o}=r;return r.highlighted=!1,o.handles.activeHandleIndex=null,We(n),i&&bn(r),this.editData=null,r.annotationUID}}_isInsideVolume(e,r,n){return tr(e,n)&&tr(r,n)}};Fp.toolName="KeyImage",Fp.dataSeries={data:{seriesLevel:!0}},Fp.dataPoint={data:{isPoint:!0}};let ST=Fp;function KTe(t){return t(prompt("Enter your annotation:"))}function qTe(t,e,r){return r(prompt("Enter your annotation:"))}class cz extends ri{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"]}){super(e,r),this.preMouseDownCallback=n=>this._deleteNearbyAnnotations(n,"mouse"),this.preTouchStartCallback=n=>this._deleteNearbyAnnotations(n,"touch")}_deleteNearbyAnnotations(e,r){const{renderingEngineId:n,viewportId:i,element:o,currentPoints:a}=e.detail,s=vr(i,n);if(!s)return!1;const c=s._toolInstances,l=[];for(const f in c){const u=c[f];if(typeof u.isPointNearTool!="function"||typeof u.filterInteractableAnnotationsForElement!="function")continue;const d=Jt(f,o),h=u.filterInteractableAnnotationsForElement(o,d);if(h)for(const g of h)u.isPointNearTool(o,g,a.canvas,10,r)&&l.push(g.annotationUID)}for(const f of l){qo(f);const u=kr(f);Yn.createAnnotationMemo(o,u,{deleting:!0}),en(f)}return e.preventDefault(),!0}}cz.toolName="Eraser";const{transformWorldToIndex:T7,transformIndexToWorld:XTe}=pn,Up=class Up extends ri{constructor(e,r){const n=Ti({configuration:{positiveStdDevMultiplier:hW,shrinkExpandIncrement:.1,islandRemoval:{enabled:!1}}},r);super(e,n)}async preMouseDownCallback(e){const r=e.detail,{element:n,currentPoints:i}=r,{world:o}=i,a=Le(n),{viewport:s,renderingEngine:c}=a,{viewUp:l}=s.getCamera(),{segmentationId:f,segmentIndex:u,labelmapVolumeId:d,referencedVolumeId:h}=await this.getLabelmapSegmentationData(s);if(!this._isOrthogonalView(s,h))throw new Error("Oblique view is not supported yet");return this.growCutData={metadata:{...s.getViewReference({points:[o]}),viewUp:l},segmentation:{segmentationId:f,segmentIndex:u,labelmapVolumeId:d,referencedVolumeId:h},viewportId:s.id,renderingEngineId:c.id},e.preventDefault(),!0}shrink(){this._runLastCommand({shrinkExpandAmount:-this.configuration.shrinkExpandIncrement})}expand(){this._runLastCommand({shrinkExpandAmount:this.configuration.shrinkExpandIncrement})}refresh(){this._runLastCommand()}async getGrowCutLabelmap(e){throw new Error("Not implemented")}async runGrowCut(){const{growCutData:e,configuration:r}=this,{segmentation:{segmentationId:n,segmentIndex:i,labelmapVolumeId:o}}=e,a=$e.getVolume(o);let s=0;const c=async({shrinkExpandAmount:l=0}={})=>{l!==0&&(this.seeds=null),s+=l;const f=Math.max(.1,r.positiveStdDevMultiplier+s),u=l<0?Math.max(1,nT-Math.abs(s)*3):nT+s*3,d={...e,options:{...e.options||{},positiveSeedValue:i,negativeSeedValue:255,positiveStdDevMultiplier:f,negativeSeedMargin:u}},h=await this.getGrowCutLabelmap(d),{isPartialVolume:g}=r;(g?this.applyPartialGrowCutLabelmap:this.applyGrowCutLabelmap)(n,i,a,h),this._removeIslands(d)};await c(),Up.lastGrowCutCommand=c,this.growCutData=null}applyPartialGrowCutLabelmap(e,r,n,i){const o=i.voxelManager.getCompleteScalarDataArray(),a=n.voxelManager,[s,c,l]=i.dimensions,[f,u]=n.dimensions,d=s*c,h=f*u;for(let g=0;g<l;g++)for(let p=0;p<c;p++){const v=[0,p,g],y=XTe(i.imageData,v),m=T7(n.imageData,y),[w,x,C]=m,S=p*s+g*d,T=w+x*f+C*h;for(let _=0;_<s;_++){const E=o[S+_]===r?r:0;a.setAtIndex(T+_,E)}}lo(e)}applyGrowCutLabelmap(e,r,n,i){const o=n.voxelManager;i.voxelManager.forEach(({value:s,index:c})=>{s===r&&o.setAtIndex(c,s)}),lo(e)}_runLastCommand({shrinkExpandAmount:e=0}={}){const r=Up.lastGrowCutCommand;r&&r({shrinkExpandAmount:e})}async getLabelmapSegmentationData(e){const r=lu(e.id);if(!r)throw new Error("No active segmentation found");const{segmentationId:n}=r,i=va(n),{representationData:o}=_n(n),a=o[St.Labelmap];let{volumeId:s,referencedVolumeId:c}=a;if(!s){const l=e.getImageIds();if(Sf(l))s=og(n).volumeId;else{const f=e.getCurrentImageId(),u=$e.getImage(f),d=d1(f);c=this._createFakeVolume([u.imageId,d.imageId]).volumeId;const g=_f(e.id,n),p=d1(g);s=this._createFakeVolume([g,p.imageId]).volumeId}}if(!c){const{imageIds:l}=a,f=l.map(h=>$e.getImage(h).referencedImageId),u=$e.generateVolumeId(f),d=$e.getVolume(u);c=d?d.volumeId:(await lm(u,f)).volumeId}return{segmentationId:n,segmentIndex:i,labelmapVolumeId:s,referencedVolumeId:c}}_createFakeVolume(e){const r=$e.generateVolumeId(e),n=$e.getVolume(r);if(n)return n;const i=sm(e,r),o=i.spacing;o[2]===0&&(o[2]=1);const a=new Ud({volumeId:r,dataType:i.dataType,metadata:structuredClone(i.metadata),dimensions:i.dimensions,spacing:i.spacing,origin:i.origin,direction:i.direction,referencedVolumeId:i.referencedVolumeId,imageIds:i.imageIds,referencedImageIds:i.referencedImageIds});return $e.putVolumeSync(r,a),a}_isOrthogonalView(e,r){const i=$e.getVolume(r).imageData,o=e.getCamera(),{ijkVecColDir:a,ijkVecSliceDir:s}=Sw(i,o);return[a,s].every(c=>Vt(Math.abs(c[0]),1)||Vt(Math.abs(c[1]),1)||Vt(Math.abs(c[2]),1))}getRemoveIslandData(e){}_removeIslands(e){const{islandRemoval:r}=this.configuration;if(!r.enabled)return;const{segmentation:{segmentIndex:n,labelmapVolumeId:i},renderingEngineId:o,viewportId:a}=e,s=$e.getVolume(i),c=this.getRemoveIslandData(e);if(!c)return;const[l,f]=s.dimensions,u=l*f,{worldIslandPoints:d=[],islandPointIndexes:h=[]}=c;let g=[...(c==null?void 0:c.ijkIslandPoints)??[]];const v=Nr(o).getViewport(a),{voxelManager:y}=s,m=new Pd;g=g.concat(d.map(w=>T7(s.imageData,w))),g=g.concat(h.map(w=>{const x=w%l,C=Math.floor(w/l)%f,S=Math.floor(w/u);return[x,C,S]})),m.initialize(v,y,{points:g,previewSegmentIndex:n,segmentIndex:n}),m.floodFillSegmentIsland(),m.removeExternalIslands(),m.removeInternalIslands()}getSegmentStyle({segmentationId:e,viewportId:r,segmentIndex:n}){return _B({segmentationId:e,segmentIndex:n,viewportId:r})}};Up.lastGrowCutCommand=null;let Lh=Up;Lh.toolName="GrowCutBaseTool";const pb=class pb extends Lh{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{isPartialVolume:!0,positiveSeedVariance:.5,negativeSeedVariance:.9}}){super(e,r),this._dragCallback=n=>{const i=n.detail,{element:o,currentPoints:a}=i,{world:s}=a,c=Le(o),{viewport:l}=c;this.growCutData.circleBorderPoint=s,We([l.id])},this._endCallback=async n=>{const i=n.detail,{element:o}=i,a=Le(o),{viewport:s}=a;this.runGrowCut(),this._deactivateDraw(o),this.growCutData=null,kt(o),We([s.id])},this._deactivateDraw=n=>{n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback)}}async preMouseDownCallback(e){const r=e.detail,{element:n,currentPoints:i}=r,{world:o}=i,a=Le(n),{viewport:s,renderingEngine:c}=a;return await super.preMouseDownCallback(e),Object.assign(this.growCutData,{circleCenterPoint:o,circleBorderPoint:o}),this._activateDraw(n),Dt(n),We([s.id]),!0}async getGrowCutLabelmap(e){const{segmentation:{referencedVolumeId:r},renderingEngineId:n,viewportId:i,circleCenterPoint:o,circleBorderPoint:a,options:s}=e,l=Nr(n).getViewport(i),f=wh(hn(Ke(),o,a));return fW(r,{center:o,radius:f},l,s)}_activateDraw(e){e.addEventListener(U.MOUSE_UP,this._endCallback),e.addEventListener(U.MOUSE_DRAG,this._dragCallback),e.addEventListener(U.MOUSE_CLICK,this._endCallback)}renderAnnotation(e,r){if(!this.growCutData)return;const{viewport:n}=e,{segmentation:i,circleCenterPoint:o,circleBorderPoint:a}=this.growCutData,s=n.worldToCanvas(o),c=n.worldToCanvas(a),l=ps(Wt(),c,s),f=ZY(l);if(Vt(f,0))return;const u="growcut",d="0",{color:h}=this.getSegmentStyle({segmentationId:i.segmentationId,segmentIndex:i.segmentIndex,viewportId:n.id});Yo(r,u,d,s,f,{color:h})}};pb.toolName="RegionSegment";let TT=pb;const mb=class mb extends Lh{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{isPartialVolume:!1,positiveSeedVariance:.4,negativeSeedVariance:.9,subVolumePaddingPercentage:.1,islandRemoval:{enabled:!1}}}){super(e,r),this.mouseTimer=null,this.allowedToProceed=!1}mouseMoveCallback(e){if(this.mode!==En.Active)return;const r=e.detail,{currentPoints:n,element:i}=r,{world:o}=n;i.style.cursor="default",this.mouseTimer!==null&&(window.clearTimeout(this.mouseTimer),this.mouseTimer=null),this.mouseTimer=window.setTimeout(()=>{this.onMouseStable(e,o,i)},this.configuration.mouseStabilityDelay||500)}async onMouseStable(e,r,n){await super.preMouseDownCallback(e);const i=$e.getVolume(this.growCutData.segmentation.referencedVolumeId),o=gW(i,r,{})||{positiveSeedIndices:new Set,negativeSeedIndices:new Set},{positiveSeedIndices:a,negativeSeedIndices:s}=o;let c;a.size/s.size>20||s.size<30?(c="not-allowed",this.allowedToProceed=!1):(c="copy",this.allowedToProceed=!0);const l=Le(n);n&&(n.style.cursor=c,requestAnimationFrame(()=>{n.style.cursor!==c&&(n.style.cursor=c)})),this.allowedToProceed&&(this.seeds=o),l&&l.viewport&&l.viewport.render()}async preMouseDownCallback(e){if(!this.allowedToProceed)return!1;const r=e.detail,{currentPoints:n,element:i}=r;Le(i)&&(i.style.cursor="wait",requestAnimationFrame(()=>{i.style.cursor!=="wait"&&(i.style.cursor="wait")}));const{world:a}=n;return await super.preMouseDownCallback(e),this.growCutData=Ti(this.growCutData,{worldPoint:a,islandRemoval:{worldIslandPoints:[a]}}),this.growCutData.worldPoint=a,this.growCutData.islandRemoval={worldIslandPoints:[a]},await this.runGrowCut(),i&&(i.style.cursor="default"),!0}getRemoveIslandData(e){const{worldPoint:r}=e;return{worldIslandPoints:[r]}}async getGrowCutLabelmap(e){const{segmentation:{referencedVolumeId:r},worldPoint:n,options:i}=e,{subVolumePaddingPercentage:o}=this.configuration,a={...i,subVolumePaddingPercentage:o,seeds:this.seeds};return pW({referencedVolumeId:r,worldPosition:n,options:a})}};mb.toolName="RegionSegmentPlus";let _T=mb;const YTe=[-1/0,-995],JTe=[0,1900],ZTe=[1e3,1900],{transformWorldToIndex:J2,transformIndexToWorld:WC}=pn;class lz extends Lh{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{isPartialVolume:!0,positivePixelRange:JTe,negativePixelRange:YTe,islandRemoval:{enabled:!0,islandPixelRange:ZTe}}}){super(e,r),this._dragCallback=n=>{const i=n.detail,{element:o,currentPoints:a}=i,{world:s}=a,c=Le(o),{viewport:l}=c,f=this._getHorizontalLineWorldPoints(c,s);this.growCutData.horizontalLines[1]=f,We([l.id])},this._endCallback=async n=>{const i=n.detail,{element:o}=i,a=Le(o),{viewport:s}=a;await this.runGrowCut(),this._deactivateDraw(o),this.growCutData=null,kt(o),We([s.id])},this._deactivateDraw=n=>{n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback)}}async preMouseDownCallback(e){const r=e.detail,{element:n,currentPoints:i}=r,{world:o}=i,a=Le(n),{viewport:s,renderingEngine:c}=a,l=this._getHorizontalLineWorldPoints(a,o);return await super.preMouseDownCallback(e),this.growCutData.horizontalLines=[l,l],this._activateDraw(n),Dt(n),We([s.id]),!0}renderAnnotation(e,r){if(!this.growCutData)return;const{segmentation:n,horizontalLines:i}=this.growCutData;if(i.length!==2)return;const{viewport:o}=e,{segmentationId:a,segmentIndex:s}=n,[c,l]=i,[f,u]=c,[d,h]=l,g=[f,u,h,d].map(S=>o.worldToCanvas(S)),p="growCutRect",v="0",{color:y,fillColor:m,lineWidth:w,fillOpacity:x,lineDash:C}=this.getSegmentStyle({segmentationId:a,segmentIndex:s,viewportId:o.id});dc(r,p,v,g,{color:y,fillColor:m,fillOpacity:x,lineWidth:w,lineDash:C,closePath:!0})}async getGrowCutLabelmap(e){const{segmentation:{segmentIndex:r,referencedVolumeId:n},renderingEngineId:i,viewportId:o,horizontalLines:a}=e,c=Nr(i).getViewport(o),[l,f]=a,u=[l[0],l[1],f[1],f[0]],d=$e.getVolume(n),{topLeft:h,bottomRight:g}=this._getWorldBoundingBoxFromProjectedSquare(c,u),p=J2(d.imageData,h),v=J2(d.imageData,g),y={boundingBox:{ijkTopLeft:p,ijkBottomRight:v}},m=this.configuration,w={positiveSeedValue:r,negativeSeedValue:255,negativePixelRange:m.negativePixelRange,positivePixelRange:m.positivePixelRange};return dW(n,y,w)}getRemoveIslandData(){const{segmentation:{segmentIndex:e,referencedVolumeId:r,labelmapVolumeId:n}}=this.growCutData,i=$e.getVolume(r),o=$e.getVolume(n),a=i.voxelManager.getCompleteScalarDataArray(),s=o.voxelManager.getCompleteScalarDataArray(),{islandPixelRange:c}=this.configuration.islandRemoval,l=[];for(let f=0,u=s.length;f<u;f++){if(s[f]!==e)continue;const d=a[f];d>=c[0]&&d<=c[1]&&l.push(f)}return{islandPointIndexes:l}}_activateDraw(e){e.addEventListener(U.MOUSE_UP,this._endCallback),e.addEventListener(U.MOUSE_DRAG,this._dragCallback),e.addEventListener(U.MOUSE_CLICK,this._endCallback)}_projectWorldPointAcrossSlices(e,r,n){const i=this._getViewportVolume(e),{dimensions:o}=i,a=J2(i.imageData,r),s=n.findIndex(f=>Vt(Math.abs(f),1));if(s===-1)throw new Error("Non-orthogonal direction vector");const c=[...a],l=[...a];return c[s]=0,l[s]=o[s]-1,[c,l]}_getCuboidIJKEdgePointsFromProjectedWorldPoint(e,r){const{viewPlaneNormal:n}=e.getCamera();return this._projectWorldPointAcrossSlices(e,r,n)}_getWorldCuboidCornerPoints(e,r){const n=[],i=this._getViewportVolume(e);return r.forEach(o=>{const s=this._getCuboidIJKEdgePointsFromProjectedWorldPoint(e,o).map(c=>WC(i.imageData,c));n.push(...s)}),n}_getWorldBoundingBoxFromProjectedSquare(e,r){const n=this._getWorldCuboidCornerPoints(e,r),i=[...n[0]],o=[...n[0]];return n.forEach(a=>{UY(i,i,a),BY(o,o,a)}),{topLeft:i,bottomRight:o}}_getViewportVolume(e){if(!(e instanceof fr))throw new Error("Viewport is not a BaseVolumeViewport");const r=e.getAllVolumeIds()[0];return $e.getVolume(r)}_getHorizontalLineIJKPoints(e,r){const{viewport:n}=e,i=this._getViewportVolume(n),{dimensions:o}=i,a=J2(i.imageData,r),{viewUp:s,viewPlaneNormal:c}=n.getCamera(),f=Tn(Ke(),s,c).findIndex(h=>Vt(Math.abs(h),1)),u=[...a],d=[...a];return u[f]=0,d[f]=o[f]-1,[u,d]}_getHorizontalLineWorldPoints(e,r){const{viewport:n}=e,i=this._getViewportVolume(n),[o,a]=this._getHorizontalLineIJKPoints(e,r),s=WC(i.imageData,o),c=WC(i.imageData,a);return[s,c]}}lz.toolName="WholeBodySegment";function QTe(t,e,r=!0){const n=Object.assign({},e,{segmentIndex:0});D8(t,n)}function e_e(t,e){QTe(t,e,!0)}class uz extends Rd{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{strategies:{FILL_INSIDE:D8,ERASE_INSIDE:e_e},defaultStrategy:"FILL_INSIDE",activeStrategy:"FILL_INSIDE"}}){super(e,r),this.preMouseDownCallback=n=>{if(this.isDrawing===!0)return;const i=n.detail,{currentPoints:o,element:a}=i,s=o.world,c=Le(a),{viewport:l}=c;this.isDrawing=!0;const f=l.getCamera(),{viewPlaneNormal:u,viewUp:d}=f,h=lu(l.id);if(!h)throw new Error("No active segmentation detected, create one before using scissors tool");const{segmentationId:g}=h,p=va(g),v=zd(g),y=ou(l.id,g,p),{representationData:m}=_n(g),w=m[St.Labelmap],x={highlighted:!0,invalidated:!0,metadata:{viewPlaneNormal:[...u],viewUp:[...d],FrameOfReferenceUID:l.getFrameOfReferenceUID(),referencedImageId:"",toolName:this.getToolName(),segmentColor:y},data:{handles:{points:[[...s],[...s],[...s],[...s]],activeHandleIndex:null}}},C=wt(a,this.getToolName());if(this.editData={annotation:x,segmentIndex:p,segmentationId:g,segmentsLocked:v,segmentColor:y,viewportIdsToRender:C,handleIndex:3,movingTextBox:!1,newAnnotation:!0,hasMoved:!1,volumeId:null,referencedVolumeId:null,imageId:null},l instanceof fr){const{volumeId:S}=w,T=$e.getVolume(S);this.editData={...this.editData,volumeId:S,referencedVolumeId:T.referencedVolumeId}}else{const S=_f(l.id,g);this.editData={...this.editData,imageId:S}}return this._activateDraw(a),Dt(a),n.preventDefault(),We(C),!0},this._dragCallback=n=>{this.isDrawing=!0;const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s,handleIndex:c}=this.editData,{data:l}=a,{currentPoints:f}=i,u=Le(o),{worldToCanvas:d,canvasToWorld:h}=u.viewport,g=f.world,{points:p}=l.handles;p[c]=[...g];let v,y,m,w,x,C,S,T;switch(c){case 0:case 3:v=d(p[0]),w=d(p[3]),y=[w[0],v[1]],m=[v[0],w[1]],C=h(y),S=h(m),p[1]=C,p[2]=S;break;case 1:case 2:y=d(p[1]),m=d(p[2]),v=[m[0],y[1]],w=[y[0],m[1]],x=h(v),T=h(w),p[0]=x,p[3]=T;break}a.invalidated=!0,this.editData.hasMoved=!0,We(s)},this._endCallback=n=>{const i=n.detail,{element:o}=i,{annotation:a,newAnnotation:s,hasMoved:c}=this.editData,{data:l}=a;if(s&&!c)return;l.handles.activeHandleIndex=null,this._deactivateDraw(o),kt(o);const f=Le(o),u={...this.editData,points:l.handles.points,createMemo:this.createMemo.bind(this)};this.editData=null,this.isDrawing=!1,this.applyActiveStrategy(f,u),this.doneEditMemo()},this._activateDraw=n=>{n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragCallback),n.addEventListener(U.MOUSE_MOVE,this._dragCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback)},this._deactivateDraw=n=>{n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragCallback),n.removeEventListener(U.MOUSE_MOVE,this._dragCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback),n.removeEventListener(U.TOUCH_END,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragCallback)},this.renderAnnotation=(n,i)=>{let o=!1;if(!this.editData)return o;const{viewport:a}=n,{annotation:s}=this.editData,c=s.metadata,l=s.annotationUID,f=s.data,{points:u}=f.handles,d=u.map(p=>a.worldToCanvas(p)),h=`rgb(${c.segmentColor.slice(0,3)})`;return a.getRenderingEngine()?(bm(i,l,"0",d[0],d[3],{color:h}),o=!0,o):(console.warn("Rendering Engine has been destroyed"),o)}}}uz.toolName="RectangleScissor";class fz extends Rd{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{strategies:{FILL_INSIDE:Zw,ERASE_INSIDE:QG},defaultStrategy:"FILL_INSIDE",activeStrategy:"FILL_INSIDE"}}){super(e,r),this.preMouseDownCallback=n=>{if(this.isDrawing===!0)return;const i=n.detail,{currentPoints:o,element:a}=i,s=o.world,c=o.canvas,l=Le(a),{viewport:f}=l;this.isDrawing=!0;const u=f.getCamera(),{viewPlaneNormal:d,viewUp:h}=u,g=lu(f.id);if(!g)throw new Error("No active segmentation detected, create one before using scissors tool");const{segmentationId:p}=g,v=va(p),y=zd(p),m=ou(f.id,p,v),{representationData:w}=_n(p),x=w.Labelmap;if(!x)throw new Error("No labelmap data found for the active segmentation, create one before using scissors tool");const C={invalidated:!0,highlighted:!0,metadata:{viewPlaneNormal:[...d],viewUp:[...h],FrameOfReferenceUID:f.getFrameOfReferenceUID(),referencedImageId:"",toolName:this.getToolName(),segmentColor:m},data:{handles:{points:[[...s],[...s],[...s],[...s]],activeHandleIndex:null},isDrawing:!0,cachedStats:{}}},S=[f.id];if(this.editData={annotation:C,centerCanvas:c,segmentIndex:v,segmentationId:p,segmentsLocked:y,segmentColor:m,viewportIdsToRender:S,handleIndex:3,movingTextBox:!1,newAnnotation:!0,hasMoved:!1,volumeId:null,referencedVolumeId:null,imageId:null},f instanceof fr){const{volumeId:T}=x,_=$e.getVolume(T);this.editData={...this.editData,volumeId:T,referencedVolumeId:_.referencedVolumeId}}else{const T=_f(f.id,p);this.editData={...this.editData,imageId:T}}return this._activateDraw(a),Dt(a),n.preventDefault(),We(S),!0},this._dragCallback=n=>{this.isDrawing=!0;const i=n.detail,{element:o}=i,{currentPoints:a}=i,s=a.canvas,c=Le(o),{renderingEngine:l,viewport:f}=c,{canvasToWorld:u}=f,{annotation:d,viewportIdsToRender:h,centerCanvas:g}=this.editData,{data:p}=d,v=Math.abs(s[0]-g[0]),y=Math.abs(s[1]-g[1]),m=Math.sqrt(v*v+y*y),w=[g[0],g[1]+m],x=[g[0],g[1]-m],C=[g[0]-m,g[1]],S=[g[0]+m,g[1]];p.handles.points=[u(w),u(x),u(C),u(S)],d.invalidated=!0,this.editData.hasMoved=!0,We(h)},this._endCallback=n=>{const i=n.detail,{element:o}=i,{annotation:a,newAnnotation:s,hasMoved:c}=this.editData,{data:l}=a,{viewPlaneNormal:f,viewUp:u}=a.metadata;if(s&&!c)return;l.handles.activeHandleIndex=null,this._deactivateDraw(o),kt(o);const d=Le(o),h={...this.editData,points:l.handles.points,viewPlaneNormal:f,viewUp:u,createMemo:this.createMemo.bind(this)};this.editData=null,this.isDrawing=!1,this.applyActiveStrategy(d,h),this.doneEditMemo()},this._activateDraw=n=>{n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.MOUSE_MOVE,this._dragCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragCallback),n.addEventListener(U.TOUCH_END,this._endCallback)},this._deactivateDraw=n=>{n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.MOUSE_MOVE,this._dragCallback),n.removeEventListener(U.TOUCH_END,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback)},this.renderAnnotation=(n,i)=>{let o=!1;if(!this.editData)return o;const{viewport:a}=n,{viewportIdsToRender:s}=this.editData;if(!s.includes(a.id))return o;const{annotation:c}=this.editData,l=c.metadata,f=c.annotationUID,u=c.data,{points:d}=u.handles,h=d.map(x=>a.worldToCanvas(x)),g=h[0],p=h[1],v=[Math.floor((g[0]+p[0])/2),Math.floor((g[1]+p[1])/2)],y=Math.abs(g[1]-Math.floor((g[1]+p[1])/2)),m=`rgb(${l.segmentColor.slice(0,3)})`;return a.getRenderingEngine()?(Yo(i,f,"0",v,y,{color:m}),o=!0,o):(console.warn("Rendering Engine has been destroyed"),o)}}}fz.toolName="CircleScissor";class dz extends Rd{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{strategies:{FILL_INSIDE:JG,ERASE_INSIDE:ZG},defaultStrategy:"FILL_INSIDE",activeStrategy:"FILL_INSIDE"}}){super(e,r),this.preMouseDownCallback=n=>{if(this.isDrawing===!0)return;this.doneEditMemo();const i=n.detail,{currentPoints:o,element:a}=i,s=o.world,c=o.canvas,l=Le(a),{viewport:f}=l;this.isDrawing=!0;const u=f.getCamera(),{viewPlaneNormal:d,viewUp:h}=u,g=lu(f.id);if(!g)throw new Error("No active segmentation detected, create one before using scissors tool");const{segmentationId:p}=g,v=va(p),y=zd(p),m=ou(f.id,p,v);this.isDrawing=!0;const w={metadata:{viewPlaneNormal:[...d],viewUp:[...h],FrameOfReferenceUID:f.getFrameOfReferenceUID(),referencedImageId:"",toolName:this.getToolName(),segmentColor:m},data:{invalidated:!0,handles:{points:[[...s],[...s],[...s],[...s]],activeHandleIndex:null},cachedStats:{},highlighted:!0}},x=[f.id];this.editData={annotation:w,centerCanvas:c,segmentIndex:v,segmentationId:p,segmentsLocked:y,segmentColor:m,toolGroupId:this.toolGroupId,viewportIdsToRender:x,handleIndex:3,movingTextBox:!1,newAnnotation:!0,hasMoved:!1,volumeId:null,referencedVolumeId:null,imageId:null};const{representationData:C}=_n(p),S=this.getEditData({viewport:f,representationData:C,segmentsLocked:y,segmentationId:p});return this.editData={...this.editData,...S},this._activateDraw(a),Dt(a),n.preventDefault(),We(x),!0},this._dragCallback=n=>{this.isDrawing=!0;const i=n.detail,{element:o}=i,{currentPoints:a}=i,s=a.canvas,c=Le(o),{renderingEngine:l,viewport:f}=c,{canvasToWorld:u}=f,{annotation:d,viewportIdsToRender:h,centerCanvas:g}=this.editData,{data:p}=d,v=Math.abs(s[0]-g[0]),y=Math.abs(s[1]-g[1]),m=Math.sqrt(v*v+y*y),w=[g[0],g[1]+m],x=[g[0],g[1]-m],C=[g[0]-m,g[1]],S=[g[0]+m,g[1]];p.handles.points=[u(w),u(x),u(C),u(S)],d.invalidated=!0,this.editData.hasMoved=!0,We(h)},this._endCallback=n=>{const i=n.detail,{element:o}=i,{annotation:a,newAnnotation:s,hasMoved:c,segmentIndex:l,segmentsLocked:f}=this.editData,{data:u}=a,{viewPlaneNormal:d,viewUp:h}=a.metadata;if(s&&!c)return;a.highlighted=!1,u.handles.activeHandleIndex=null,this._deactivateDraw(o),kt(o);const g=Le(o),p={...this.editData,points:u.handles.points,segmentIndex:l,segmentsLocked:f,viewPlaneNormal:d,viewUp:h,createMemo:this.createMemo.bind(this)};this.editData=null,this.isDrawing=!1,this.applyActiveStrategy(g,p),this.doneEditMemo()},this._activateDraw=n=>{n.addEventListener(U.MOUSE_UP,this._endCallback),n.addEventListener(U.MOUSE_DRAG,this._dragCallback),n.addEventListener(U.MOUSE_CLICK,this._endCallback),n.addEventListener(U.MOUSE_MOVE,this._dragCallback),n.addEventListener(U.TOUCH_END,this._endCallback),n.addEventListener(U.TOUCH_TAP,this._endCallback),n.addEventListener(U.TOUCH_DRAG,this._dragCallback)},this._deactivateDraw=n=>{n.removeEventListener(U.MOUSE_UP,this._endCallback),n.removeEventListener(U.MOUSE_DRAG,this._dragCallback),n.removeEventListener(U.MOUSE_CLICK,this._endCallback),n.removeEventListener(U.MOUSE_MOVE,this._dragCallback),n.removeEventListener(U.TOUCH_END,this._endCallback),n.removeEventListener(U.TOUCH_DRAG,this._dragCallback),n.removeEventListener(U.TOUCH_TAP,this._endCallback)},this.renderAnnotation=(n,i)=>{let o=!1;if(!this.editData)return o;const{viewport:a}=n,{viewportIdsToRender:s}=this.editData;if(!s.includes(a.id))return o;const{annotation:c}=this.editData,l=c.metadata,f=c.annotationUID,u=c.data,{points:d}=u.handles,h=d.map(x=>a.worldToCanvas(x)),g=h[0],p=h[1],v=[Math.floor((g[0]+p[0])/2),Math.floor((g[1]+p[1])/2)],y=Math.abs(g[1]-Math.floor((g[1]+p[1])/2)),m=`rgb(${l.segmentColor.slice(0,3)})`;return a.getRenderingEngine()?(Yo(i,f,"0",v,y,{color:m}),o=!0,o):(console.warn("Rendering Engine has been destroyed"),o)}}}dz.toolName="SphereScissor";const{transformWorldToIndex:Vg}=pn;class hz extends E5{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{storePointData:!1,numSlicesToPropagate:10,calculatePointsInsideVolume:!0,getTextLines:t_e,statsCalculator:al,showTextBox:!1,throttleTimeout:100}}){super(e,r),this.isHandleOutsideImage=!1,this.addNewAnnotation=n=>{const i=n.detail,{currentPoints:o,element:a}=i,s=o.world,c=Le(a),{viewport:l,renderingEngine:f}=c;this.isDrawing=!0;const u=l.getCamera(),{viewPlaneNormal:d,viewUp:h}=u;let g,p,v;if(l instanceof Jn)throw new Error("Stack Viewport Not implemented");{const T=this.getTargetId(l);v=dl(T),p=$e.getVolume(v),g=Ql(p,s,d)}const y=Cf(p,d),m=this._getStartCoordinate(s,y,d),w=this._getEndCoordinate(s,y,d),x=l.getFrameOfReferenceUID(),C={highlighted:!0,invalidated:!0,metadata:{toolName:this.getToolName(),viewPlaneNormal:[...d],viewUp:[...h],FrameOfReferenceUID:x,referencedImageId:g,volumeId:v,spacingInNormal:y,enabledElement:c},data:{label:"",startCoordinate:m,endCoordinate:w,handles:{textBox:{hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}},points:[[...s],[...s]],activeHandleIndex:null},cachedStats:{pointsInVolume:[],projectionPoints:[],statistics:[]},labelmapUID:null}};this._computeProjectionPoints(C,p),qt(C,a);const S=wt(a,this.getToolName());return this.editData={annotation:C,viewportIdsToRender:S,newAnnotation:!0,hasMoved:!1},this._activateDraw(a),Dt(a),n.preventDefault(),We(S),C},this._endCallback=n=>{const i=n.detail,{element:o}=i,{annotation:a,viewportIdsToRender:s,newAnnotation:c,hasMoved:l}=this.editData,{data:f}=a;if(c&&!l)return;a.highlighted=!1,f.handles.activeHandleIndex=null,this._deactivateModify(o),this._deactivateDraw(o),kt(o);const u=Le(o);this.editData=null,this.isDrawing=!1,this.isHandleOutsideImage&&this.configuration.preventHandleOutsideImage&&en(a.annotationUID);const d=this.getTargetId(u.viewport),h=$e.getVolume(d.split(/volumeId:|\?/)[1]);this._computePointsInsideVolume(a,h,d,u),We(s),c?bn(a):Kt(a,o)},this.renderAnnotation=(n,i)=>{let o=!1;const{viewport:a}=n;let s=Jt(this.getToolName(),a.element);if(!(s!=null&&s.length))return o;s=$w(s,a.getCamera());const c={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:n.viewport.id};for(let l=0;l<s.length;l++){const f=s[l],{annotationUID:u,data:d,metadata:h}=f,{startCoordinate:g,endCoordinate:p}=d,{points:v,activeHandleIndex:y}=d.handles;c.annotationUID=u;const m=this.getStyle("lineWidth",c,f),w=this.getStyle("lineDash",c,f),x=this.getStyle("color",c,f),C=v.map(Se=>a.worldToCanvas(Se)),S=C[0],T=Qu(C),{centerPointRadius:_}=this.configuration,E=ih(C),b=a.getCamera().focalPoint,D=a.getCamera().viewPlaneNormal;let I=g,P=p;Array.isArray(g)&&(I=this._getCoordinateForViewplaneNormal(I,D),d.startCoordinate=I),Array.isArray(p)&&(P=this._getCoordinateForViewplaneNormal(P,D),d.endCoordinate=P);const O=Gu(d.startCoordinate),L=Gu(d.endCoordinate),B=this._getCoordinateForViewplaneNormal(b,D),H=Gu(B);if(H<Math.min(O,L)||H>Math.max(O,L))continue;const A=Gu((d.startCoordinate+d.endCoordinate)/2);let F=!1;if(H===A&&(F=!0),d.handles.points[0][this._getIndexOfCoordinatesForViewplaneNormal(D)]=A,f.invalidated&&this._throttledCalculateCachedStats(f,n),!a.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),o;let G;if(!Vr(u))continue;!Yr(u)&&!this.editData&&y!==null&&F&&(G=[C[y]]),G&&Kn(i,u,"0",G,{color:x});let X=m,ee=w;F?(X=m,ee=[]):ee=[5,5];const ce="0";if(Yo(i,u,ce,S,T,{color:x,lineDash:ee,lineWidth:X}),_>0&&T>3*_&&Yo(i,u,`${ce}-center`,S,_,{color:x,lineDash:w,lineWidth:m}),o=!0,this.configuration.showTextBox){const Se=this.getLinkedTextBoxStyle(c,f);if(!Se.visibility){d.handles.textBox={hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}};continue}const we=this.configuration.getTextLines(d,{metadata:h});if(!we||we.length===0)continue;let _e;d.handles.textBox.hasMoved||(_e=wa(E),d.handles.textBox.worldPosition=a.canvasToWorld(_e));const Ve=a.worldToCanvas(d.handles.textBox.worldPosition),Ne=Ji(i,u,"1",we,Ve,C,{},Se),{x:j,y:M,width:q,height:K}=Ne;d.handles.textBox.worldBoundingBox={topLeft:a.canvasToWorld([j,M]),topRight:a.canvasToWorld([j+q,M]),bottomLeft:a.canvasToWorld([j,M+K]),bottomRight:a.canvasToWorld([j+q,M+K])}}}return o},this.configuration.calculatePointsInsideVolume?this._throttledCalculateCachedStats=Lo(this._calculateCachedStatsTool,this.configuration.throttleTimeout,{trailing:!0}):this._throttledCalculateCachedStats=Jh(this._calculateCachedStatsTool,this.configuration.throttleTimeout)}_computeProjectionPoints(e,r){const{data:n,metadata:i}=e,{viewPlaneNormal:o,spacingInNormal:a}=i,{imageData:s}=r,{startCoordinate:c,endCoordinate:l}=n,{points:f}=n.handles,u=Vg(s,f[0]),d=Vg(s,f[0]),h=ds(f),g=Ke();s.indexToWorldVec3(u,g);const p=Ke();s.indexToWorldVec3(d,p),this._getIndexOfCoordinatesForViewplaneNormal(o)==2?(g[2]=c,p[2]=l,h[0][2]=c,h[1][2]=c):this._getIndexOfCoordinatesForViewplaneNormal(o)==0?(g[0]=c,p[0]=l,h[0][0]=c,h[1][0]=c):this._getIndexOfCoordinatesForViewplaneNormal(o)==1&&(g[1]=c,p[1]=l,h[0][1]=c,h[1][1]=c);const v=Fi(g,p),y=[];for(let m=0;m<v;m+=a)y.push(h.map(w=>{const x=Ke();return dn(x,w,o,m),Array.from(x)}));n.cachedStats.projectionPoints=y}_computePointsInsideVolume(e,r,n,i){var b,D,I;const{data:o,metadata:a}=e,{viewPlaneNormal:s,viewUp:c}=a,{viewport:l}=i,f=o.cachedStats.projectionPoints,u=[[]],d=this.getTargetImageData(n),h=o.handles.points.map(P=>l.worldToCanvas(P)),[g,p]=ih(h),v=l.canvasToWorld(g),y=l.canvasToWorld(p),{worldWidth:m,worldHeight:w}=Qh(s,c,v,y),x=ya(d,o.handles),C=u8(d),S=Math.abs(Math.PI*(m/x.scale/2)*(w/C/x.scale/2)),T={isPreScaled:uu(l,n),isSuvScaled:this.isSuvScaled(l,n,e.metadata.referencedImageId)},_=fu(a.Modality,e.metadata.referencedImageId,T);for(let P=0;P<f.length;P++){if(!r)continue;const O=f[P][0],L=f[P].map(Ne=>l.worldToCanvas(Ne)),[B,H]=ih(L),A=l.canvasToWorld(B),F=l.canvasToWorld(H),G=A,X=F,{dimensions:ee,imageData:ce,voxelManager:Se}=r,we=Vg(ce,G),_e=Vg(ce,O),Ve=this._getIndexOfCoordinatesForViewplaneNormal(s);we[0]=Math.floor(we[0]),we[1]=Math.floor(we[1]),we[2]=Math.floor(we[2]),we[Ve]=_e[Ve];const Ge=Vg(ce,X);if(Ge[0]=Math.floor(Ge[0]),Ge[1]=Math.floor(Ge[1]),Ge[2]=Math.floor(Ge[2]),Ge[Ve]=_e[Ve],this._isInsideVolume(we,Ge,ee)){const Ne=Math.min(we[0],Ge[0]),j=Math.max(we[0],Ge[0]),M=Math.min(we[1],Ge[1]),q=Math.max(we[1],Ge[1]),K=Math.min(we[2],Ge[2]),J=Math.max(we[2],Ge[2]),re=[[Ne,j],[M,q],[K,J]],Re={center:O,xRadius:Math.abs(A[0]-F[0])/2,yRadius:Math.abs(A[1]-F[1])/2,zRadius:Math.abs(A[2]-F[2])/2},Fe=Se.forEach(this.configuration.statsCalculator.statsCallback,{isInObject:je=>Nw(Re,je),boundsIJK:re,imageData:ce,returnPoints:this.configuration.storePointData});u.push(Fe)}}const E=this.configuration.statsCalculator.getStatistics();o.cachedStats.pointsInVolume=u,o.cachedStats.statistics={Modality:a.Modality,area:S,mean:(b=E.mean)==null?void 0:b.value,stdDev:(D=E.stdDev)==null?void 0:D.value,max:(I=E.max)==null?void 0:I.value,statsArray:E.array,areaUnit:x.areaUnit,modalityUnit:_}}_calculateCachedStatsTool(e,r){const n=e.data,{viewport:i}=r,{cachedStats:o}=n,a=this.getTargetId(i),s=$e.getVolume(a.split(/volumeId:|\?/)[1]);return this._computeProjectionPoints(e,s),this._computePointsInsideVolume(e,s,a,r),e.invalidated=!1,Kt(e,i.element),o}_getStartCoordinate(e,r,n){const i=this.configuration.numSlicesToPropagate,o=Math.round(i/2),a=Ke();return dn(a,e,n,o*-r),this._getCoordinateForViewplaneNormal(a,n)}_getEndCoordinate(e,r,n){const i=this.configuration.numSlicesToPropagate,o=i-Math.round(i/2),a=Ke();return dn(a,e,n,o*r),this._getCoordinateForViewplaneNormal(a,n)}_getIndexOfCoordinatesForViewplaneNormal(e){const r=[Math.abs(e[0]),Math.abs(e[1]),Math.abs(e[2])];return r.indexOf(Math.max(...r))}_getCoordinateForViewplaneNormal(e,r){const n=this._getIndexOfCoordinatesForViewplaneNormal(r);return e[n]}}function t_e(t,e={}){const r=t.cachedStats.statistics,{area:n,mean:i,max:o,stdDev:a,areaUnit:s,modalityUnit:c}=r;if(i===void 0)return;const l=[];return l.push(`Area: ${Xt(n)} ${s}`),l.push(`Mean: ${Xt(i)} ${c}`),l.push(`Max: ${Xt(o)} ${c}`),l.push(`Std Dev: ${Xt(a)} ${c}`),l}hz.toolName="CircleROIStartEndThreshold";const{transformWorldToIndex:_7,isEqual:zC}=pn;class gz extends ri{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"]}){super(e,r),this.preMouseDownCallback=n=>{const i=n.detail,{currentPoints:o,element:a}=i,s=o.world,c=Le(a),{viewport:l}=c,f=l.getCamera(),{viewPlaneNormal:u}=f,d=lu(l.id);if(!d)throw new Error("No active segmentation detected, create one before using scissors tool");const{segmentationId:h}=d,g=va(h),p=zd(h),{representationData:v}=_n(h);let y,m,w,x;if(this.doneEditMemo(),l instanceof fr){const{volumeId:L}=v[St.Labelmap],B=$e.getVolume(L);({dimensions:y,direction:m}=B),x=B.voxelManager,w=_7(B.imageData,s)}else{const L=_f(l.id,h);if(!L)throw new Error("No active segmentation imageId detected, create one before using scissors tool");const{imageData:B}=l.getImageData();y=B.getDimensions(),m=B.getDirection(),x=$e.getImage(L).voxelManager,w=_7(B,s)}const C=this.getFixedDimension(u,m);if(C===void 0){console.warn("Oblique paint fill not yet supported");return}const{floodFillGetter:S,getLabelValue:T,getScalarDataPositionFromPlane:_,inPlaneSeedPoint:E,fixedDimensionValue:b}=this.generateHelpers(x,y,w,C);if(w[0]<0||w[0]>=y[0]||w[1]<0||w[1]>=y[1]||w[2]<0||w[2]>=y[2])return;const D=T(w[0],w[1],w[2]);if(p.includes(D))return;const I=b8(S,E),{flooded:P}=I;P.forEach(L=>{const B=_(L[0],L[1]);x.setAtIndex(B,g)});const O=this.getFramesModified(C,b,I);return lo(h,O),!0},this.getFramesModified=(n,i,o)=>{const{flooded:a}=o;if(n===2)return[i];let s=1/0,c=-1/0;for(let f=0;f<a.length;f++){const u=a[f][1];u<s&&(s=u),u>c&&(c=u)}const l=[];for(let f=s;f<=c;f++)l.push(f);return l},this.generateHelpers=(n,i,o,a=2)=>{let s,c;switch(a){case 0:s=o[0],c=[o[1],o[2]];break;case 1:s=o[1],c=[o[0],o[2]];break;case 2:s=o[2],c=[o[0],o[1]];break;default:throw new Error(`Invalid fixedDimension: ${a}`)}const l=(h,g,p)=>n.toIndex([h,g,p]),f=(h,g,p)=>n.getAtIJK(h,g,p),u=this.generateFloodFillGetter(i,a,s,f);return{getScalarDataPositionFromPlane:this.generateGetScalarDataPositionFromPlane(l,a,s),getLabelValue:f,floodFillGetter:u,inPlaneSeedPoint:c,fixedDimensionValue:s}},this.generateFloodFillGetter=(n,i,o,a)=>{let s;switch(i){case 0:s=(c,l)=>{if(!(c>=n[1]||c<0||l>=n[2]||l<0))return a(o,c,l)};break;case 1:s=(c,l)=>{if(!(c>=n[0]||c<0||l>=n[2]||l<0))return a(c,o,l)};break;case 2:s=(c,l)=>{if(!(c>=n[0]||c<0||l>=n[1]||l<0))return a(c,l,o)};break;default:throw new Error(`Invalid fixedDimension: ${i}`)}return s},this.generateGetScalarDataPositionFromPlane=(n,i,o)=>{let a;switch(i){case 0:a=(s,c)=>n(o,s,c);break;case 1:a=(s,c)=>n(s,o,c);break;case 2:a=(s,c)=>n(s,c,o);break;default:throw new Error(`Invalid fixedDimension: ${i}`)}return a}}getFixedDimension(e,r){const n=r.slice(0,3),i=r.slice(3,6),o=r.slice(6,9),a=[Math.abs(e[0]),Math.abs(e[1]),Math.abs(e[2])],s=[Math.abs(n[0]),Math.abs(n[1]),Math.abs(n[2])];if(zC(a,s))return 0;const c=[Math.abs(i[0]),Math.abs(i[1]),Math.abs(i[2])];if(zC(a,c))return 1;const l=[Math.abs(o[0]),Math.abs(o[1]),Math.abs(o[2])];if(zC(a,l))return 2}}gz.toolName="PaintFill";const n_e={TOP_LEFT:"TOP_LEFT",TOP_RIGHT:"TOP_RIGHT",BOTTOM_LEFT:"BOTTOM_LEFT",BOTTOM_RIGHT:"BOTTOM_RIGHT"};var G8={Corners:n_e};const{vtkErrorMacro:$C}=Z,{Corners:Z2}=G8;function r_e(t,e){e.classHierarchy.push("vtkOrientationMarkerWidget");const r={...t},n=[],i=ZA.newInstance(),o=new ResizeObserver(d=>{t.updateViewport()});let a=null,s=null,c=null,l=null,f=null;function u(){e._interactor.isAnimating()||t.updateMarkerOrientation()}e._onParentRendererChanged=()=>t.updateViewport(),t.computeViewport=()=>{const d=e.parentRenderer||e._interactor.getCurrentRenderer(),[h,g,p,v]=d.getViewport(),y=e._interactor.getView(),m=y.getSize(),[w,x]=y.getViewportSize(d),C=Math.min(w,x);let S=e.viewportSize*C;S=Math.max(Math.min(e.minPixelSize,C),Math.min(e.maxPixelSize,S));const T=S/m[0],_=S/m[1];switch(e.viewportCorner){case Z2.TOP_LEFT:return[h,v-_,h+T,v];case Z2.TOP_RIGHT:return[p-T,v-_,p,v];case Z2.BOTTOM_LEFT:return[h,g,h+T,g+_];case Z2.BOTTOM_RIGHT:return[p-T,g,p,g+_];default:return $C("Invalid widget corner"),null}},t.updateViewport=()=>{e.enabled&&(i.setViewport(...t.computeViewport()),e._interactor.render())},t.updateMarkerOrientation=()=>{const h=(e.parentRenderer||e._interactor.getCurrentRenderer()).getActiveCamera();if(!h)return;const g=h.getReferenceByName("position"),p=h.getReferenceByName("focalPoint"),v=h.getReferenceByName("viewUp");if(n[0]!==g[0]||n[1]!==g[1]||n[2]!==g[2]||n[3]!==p[0]||n[4]!==p[1]||n[5]!==p[2]||n[6]!==v[0]||n[7]!==v[1]||n[8]!==v[2]){n[0]=g[0],n[1]=g[1],n[2]=g[2],n[3]=p[0],n[4]=p[1],n[5]=p[2],n[6]=v[0],n[7]=v[1],n[8]=v[2];const y=i.getActiveCamera();y.setPosition(g[0],g[1],g[2]),y.setFocalPoint(p[0],p[1],p[2]),y.setViewUp(v[0],v[1],v[2]),i.resetCamera()}},t.setEnabled=d=>{var h,g;if(d){if(e.enabled)return;if(!e.actor){$C("Must set actor before enabling orientation marker.");return}if(!e._interactor){$C("Must set interactor before enabling orientation marker.");return}const p=e.parentRenderer||e._interactor.getCurrentRenderer(),v=p.getRenderWindow();v.addRenderer(i),v.getNumberOfLayers()<2&&v.setNumberOfLayers(2),i.setLayer(v.getNumberOfLayers()-1),i.setInteractive(e.interactiveRenderer),i.addViewProp(e.actor),e.actor.setVisibility(!0),a=p.onEvent(y=>{y.type==="ActiveCameraEvent"&&(s&&s.unsubscribe(),s=y.camera.onModified(u))}),s=p.getActiveCamera().onModified(u),c=e._interactor.onAnimation(t.updateMarkerOrientation),l=e._interactor.onEndAnimation(t.updateMarkerOrientation),o.observe(e._interactor.getView().getCanvas()),t.updateViewport(),t.updateMarkerOrientation(),e.enabled=!0}else{if(!e.enabled)return;e.enabled=!1,o.disconnect(),a.unsubscribe(),a=null,s.unsubscribe(),s=null,c.unsubscribe(),c=null,l.unsubscribe(),l=null,e.actor.setVisibility(!1),i.removeViewProp(e.actor);const p=(g=(h=e._interactor)==null?void 0:h.findPokedRenderer())==null?void 0:g.getRenderWindow();p&&p.removeRenderer(i)}t.modified()},t.setViewportCorner=d=>{d!==e.viewportCorner&&(e.viewportCorner=d,t.updateViewport())},t.setViewportSize=d=>{const h=Math.min(1,Math.max(0,d));h!==e.viewportSize&&(e.viewportSize=h,t.updateViewport())},t.setActor=d=>{const h=e.enabled;t.setEnabled(!1),e.actor=d,t.setEnabled(h)},t.getRenderer=()=>i,t.delete=()=>{r.delete(),f&&(f.unsubscribe(),f=null),a&&(a.unsubscribe(),a=null),s&&(s.unsubscribe(),s=null),c&&(c.unsubscribe(),c=null),l&&(l.unsubscribe(),l=null),o.disconnect()},f=t.onModified(t.updateViewport)}const i_e={viewportCorner:G8.Corners.BOTTOM_LEFT,viewportSize:.2,minPixelSize:50,maxPixelSize:200,parentRenderer:null,interactiveRenderer:!1};function pz(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,i_e,r),Z.obj(t,e),Z.get(t,e,["enabled","viewportCorner","viewportSize","interactiveRenderer"]),Z.setGet(t,e,["_interactor","minPixelSize","maxPixelSize","parentRenderer"]),Z.get(t,e,["actor"]),Z.moveToProtected(t,e,["interactor"]),r_e(t,e)}const o_e=Z.newInstance(pz,"vtkOrientationMarkerWidget");var E7={newInstance:o_e,extend:pz,...G8};function mz(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[0,0,0,0];const[r,n,i,o]=e,s=t.getContext("2d").getImageData(r,n,i||t.width,o||t.height),c=nm.newInstance({type:"vtkImageData"});c.setOrigin(0,0,0),c.setSpacing(1,1,1),c.setExtent(0,(i||t.width)-1,0,(o||t.height)-1,0,0);const l=bt.newInstance({numberOfComponents:4,values:new Uint8Array(s.data.buffer)});return l.setName("scalars"),c.getPointData().setScalars(l),c}function a_e(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{flipX:!1,flipY:!1,rotate:0};const r=document.createElement("canvas");r.width=t.width,r.height=t.height;const n=r.getContext("2d"),{flipX:i,flipY:o,rotate:a}=e;return n.translate(r.width/2,r.height/2),n.scale(i?-1:1,o?-1:1),n.rotate(a*Math.PI/180),n.drawImage(t,-t.width/2,-t.height/2),mz(r)}var s_e={canvasToImageData:mz,imageToImageData:a_e};const vz={default:{defaultStyle:{fontStyle:"bold",fontFamily:"Arial",fontColor:"black",fontSizeScale:t=>t/2,faceColor:"white",edgeThickness:.1,edgeColor:"black",resolution:400},xMinusFaceProperty:{text:"X-",faceColor:"yellow"},xPlusFaceProperty:{text:"X+",faceColor:"yellow"},yMinusFaceProperty:{text:"Y-",faceColor:"red"},yPlusFaceProperty:{text:"Y+",faceColor:"red"},zMinusFaceProperty:{text:"Z-",faceColor:"#008000"},zPlusFaceProperty:{text:"Z+",faceColor:"#008000"}},lps:{xMinusFaceProperty:{text:"R",faceRotation:-90},xPlusFaceProperty:{text:"L",faceRotation:90},yMinusFaceProperty:{text:"A",faceRotation:0},yPlusFaceProperty:{text:"P",faceRotation:180},zMinusFaceProperty:{text:"I",faceRotation:180},zPlusFaceProperty:{text:"S",faceRotation:0}}};function yz(t,e){e.set(t)}function c_e(t,e){return yz(vz[t],e)}function l_e(t,e){vz[t]=e}var u_e={applyDefinitions:yz,applyPreset:c_e,registerStylePreset:l_e};const f_e={xPlus:0,xMinus:1,yPlus:2,yMinus:3,zPlus:4,zMinus:5};function d_e(t,e){e.classHierarchy.push("vtkAnnotatedCubeActor"),e.xPlusFaceProperty={...e.xPlusFaceProperty},e.xMinusFaceProperty={...e.xMinusFaceProperty},e.yPlusFaceProperty={...e.yPlusFaceProperty},e.yMinusFaceProperty={...e.yMinusFaceProperty},e.zPlusFaceProperty={...e.zPlusFaceProperty},e.zMinusFaceProperty={...e.zMinusFaceProperty};let r=null;const n=document.createElement("canvas"),i=la.newInstance(),o=Bd.newInstance();o.setInterpolate(!0);function a(c){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;l&&Object.assign(e[`${c}FaceProperty`],l);const f={...e.defaultStyle,...e[`${c}FaceProperty`]};n.width=f.resolution,n.height=f.resolution;const u=n.getContext("2d");u.fillStyle=f.faceColor,u.fillRect(0,0,n.width,n.height),f.edgeThickness>0&&(u.strokeStyle=f.edgeColor,u.lineWidth=f.edgeThickness*n.width,u.strokeRect(0,0,n.width,n.height)),u.save(),u.translate(0,n.height),u.scale(1,-1),u.translate(n.width/2,n.height/2),u.rotate(-Math.PI*(f.faceRotation/180));const d=f.fontSizeScale(f.resolution);u.fillStyle=f.fontColor,u.textAlign="center",u.textBaseline="middle",u.font=`${f.fontStyle} ${d}px "${f.fontFamily}"`,u.fillText(f.text,0,0),u.restore();const h=s_e.canvasToImageData(n);o.setInputData(h,f_e[c]),t.modified()}function s(){r=GN.newInstance({generate3DTextureCoordinates:!0}),i.setInputConnection(r.getOutputPort()),a("xPlus"),a("xMinus"),a("yPlus"),a("yMinus"),a("zPlus"),a("zMinus")}t.setDefaultStyle=c=>{e.defaultStyle={...e.defaultStyle,...c},s()},t.setXPlusFaceProperty=c=>a("xPlus",c),t.setXMinusFaceProperty=c=>a("xMinus",c),t.setYPlusFaceProperty=c=>a("yPlus",c),t.setYMinusFaceProperty=c=>a("yMinus",c),t.setZPlusFaceProperty=c=>a("zPlus",c),t.setZMinusFaceProperty=c=>a("zMinus",c),s(),i.setInputConnection(r.getOutputPort()),t.setMapper(i),t.addTexture(o)}const h_e={defaultStyle:{text:"",faceColor:"white",faceRotation:0,fontFamily:"Arial",fontColor:"black",fontStyle:"normal",fontSizeScale:t=>t/1.8,edgeThickness:.1,edgeColor:"black",resolution:200}};function wz(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,h_e,r),uc.extend(t,e,r),Z.get(t,e,["defaultStyle","xPlusFaceProperty","xMinusFaceProperty","yPlusFaceProperty","yMinusFaceProperty","zPlusFaceProperty","zMinusFaceProperty"]),d_e(t,e)}const g_e=Z.newInstance(wz,"vtkAnnotatedCubeActor");var b7={newInstance:g_e,extend:wz,Presets:u_e};const{vtkErrorMacro:p_e}=Z;function m_e(t,e){let r=0;return t.map((n,i)=>i===r?(r+=n+1,n):n+e)}function Q2(t,e,r,n){t.set(m_e(e,r),n)}function v_e(t,e){e.classHierarchy.push("vtkAppendPolyData"),t.requestData=(r,n)=>{const i=t.getNumberOfInputPorts();if(!i){p_e("No input specified.");return}if(i===1){n[0]=r[0];return}const o=Er.newInstance();let a=0,s=0,c=1,l=1,f=0,u=0,d=0,h=0,g=!0,p=!0,v=!0;for(let D=0;D<i;D++){const I=r[D];if(!I)continue;const P=I.getPoints().getNumberOfPoints();a+=P,f+=I.getVerts().getNumberOfValues(),u+=I.getLines().getNumberOfValues(),d+=I.getStrips().getNumberOfValues(),h+=I.getPolys().getNumberOfValues(),P&&(l&&(l=0,s=I.getPoints().getDataType()),c=I.getPoints().getDataType(),s=s>c?s:c);const O=I.getPointData();O?(g=g&&O.getNormals()!==null,p=p&&O.getTCoords()!==null,v=v&&O.getScalars()!==null):(g=!1,p=!1,v=!1)}e.outputPointsPrecision===Ty.SINGLE?s=rn.FLOAT:e.outputPointsPrecision===Ty.DOUBLE&&(s=rn.DOUBLE);const y=l1.newInstance({dataType:s});y.setNumberOfPoints(a);const m=y.getData(),w=new Uint32Array(f),x=new Uint32Array(u),C=new Uint32Array(d),S=new Uint32Array(h);let T=null,_=null,E=null;const b=r[i-1];if(g){const D=b.getPointData().getNormals();T=bt.newInstance({numberOfComponents:3,numberOfTuples:a,size:3*a,dataType:D.getDataType(),name:D.getName()})}if(p){const D=b.getPointData().getTCoords();_=bt.newInstance({numberOfComponents:2,numberOfTuples:a,size:2*a,dataType:D.getDataType(),name:D.getName()})}if(v){const D=b.getPointData().getScalars();E=bt.newInstance({numberOfComponents:D.getNumberOfComponents(),numberOfTuples:a,size:a*D.getNumberOfComponents(),dataType:D.getDataType(),name:D.getName()})}a=0,f=0,u=0,d=0,h=0;for(let D=0;D<i;D++){const I=r[D];m.set(I.getPoints().getData(),a*3),Q2(w,I.getVerts().getData(),a,f),f+=I.getVerts().getNumberOfValues(),Q2(x,I.getLines().getData(),a,u),u+=I.getLines().getNumberOfValues(),Q2(C,I.getStrips().getData(),a,d),d+=I.getStrips().getNumberOfValues(),Q2(S,I.getPolys().getData(),a,h),h+=I.getPolys().getNumberOfValues();const P=I.getPointData();if(g){const O=P.getNormals();T.getData().set(O.getData(),a*3)}if(p){const O=P.getTCoords();_.getData().set(O.getData(),a*2)}if(v){const O=P.getScalars();E.getData().set(O.getData(),a*E.getNumberOfComponents())}a+=I.getPoints().getNumberOfPoints()}o.setPoints(y),o.getVerts().setData(w),o.getLines().setData(x),o.getStrips().setData(C),o.getPolys().setData(S),T&&o.getPointData().setNormals(T),_&&o.getPointData().setTCoords(_),E&&o.getPointData().setScalars(E),n[0]=o}}const y_e={outputPointsPrecision:Ty.DEFAULT};function xz(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,y_e,r),Z.setGet(t,e,["outputPointsPrecision"]),Z.obj(t,e),Z.algo(t,e,1,1),v_e(t,e)}const w_e=Z.newInstance(xz,"vtkAppendPolyData");var Cz={newInstance:w_e,extend:xz};function x_e(t,e){e.classHierarchy.push("vtkConeSource");function r(n,i){if(e.deleted)return;let o=i[0];const a=2*Math.PI/e.resolution,s=-e.height/2,c=e.resolution+1,l=4*e.resolution+1+e.resolution;let f=0;const u=Z.newTypedArray(e.pointType,c*3);let d=0;const h=new Uint32Array(l);u[0]=e.height/2,u[1]=0,u[2]=0,e.capping&&(h[d++]=e.resolution);for(let g=0;g<e.resolution;g++)f++,u[f*3+0]=s,u[f*3+1]=e.radius*Math.cos(g*a),u[f*3+2]=e.radius*Math.sin(g*a),e.capping&&(h[e.resolution-d+++1]=f);for(let g=0;g<e.resolution;g++)h[d++]=3,h[d++]=0,h[d++]=g+1,h[d++]=g+2>e.resolution?1:g+2;Ni.buildFromRadian().translate(...e.center).rotateFromDirections([1,0,0],e.direction).apply(u),o=Er.newInstance(),o.getPoints().setData(u,3),o.getPolys().setData(h,1),i[0]=o}t.requestData=r}const C_e={height:1,radius:.5,resolution:6,center:[0,0,0],direction:[1,0,0],capping:!0,pointType:"Float64Array"};function Sz(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,C_e,r),Z.obj(t,e),Z.setGet(t,e,["height","radius","resolution","capping"]),Z.setGetArray(t,e,["center","direction"],3),Z.algo(t,e,0,1),x_e(t,e)}const S_e=Z.newInstance(Sz,"vtkConeSource");var T_e={newInstance:S_e,extend:Sz};function __e(t,e){e.classHierarchy.push("vtkCylinderSource");function r(n,i){if(e.deleted)return;let o=i[0];const a=2*Math.PI/e.resolution;let s=2*e.resolution,c=5*e.resolution;e.capping&&(s=4*e.resolution,c=7*e.resolution+2);const l=Z.newTypedArray(e.pointType,s*3);let f=0;const u=new Uint32Array(c),d=new Float32Array(s*3),h=bt.newInstance({numberOfComponents:3,values:d,name:"Normals"}),g=new Float32Array(s*2),p=bt.newInstance({numberOfComponents:2,values:g,name:"TCoords"}),v=[0,0,0],y=[0,0,0],m=[0,0,0],w=[0,0,0],x=[0,0],C=[0,0],S=e.otherRadius==null?e.radius:e.otherRadius;for(let T=0;T<e.resolution;T++){v[0]=Math.cos(T*a+e.initAngle),y[0]=v[0],m[0]=e.radius*v[0]+e.center[0],w[0]=m[0],x[0]=Math.abs(2*T/e.resolution-1),C[0]=x[0],m[1]=.5*e.height+e.center[1],w[1]=-.5*e.height+e.center[1],x[1]=0,C[1]=1,v[2]=-Math.sin(T*a+e.initAngle),y[2]=v[2],m[2]=S*v[2]+e.center[2],w[2]=m[2];const _=2*T;for(let E=0;E<3;E++)d[_*3+E]=v[E],d[(_+1)*3+E]=y[E],l[_*3+E]=m[E],l[(_+1)*3+E]=w[E],E<2&&(g[_*2+E]=x[E],g[(_+1)*2+E]=C[E])}for(let T=0;T<e.resolution;T++){u[f++]=4,u[f++]=2*T,u[f++]=2*T+1;const _=(2*T+3)%(2*e.resolution);u[f++]=_,u[f++]=_-1}if(e.capping){for(let T=0;T<e.resolution;T++){m[0]=e.radius*Math.cos(T*a+e.initAngle),w[0]=m[0],x[0]=m[0],C[0]=m[0],m[0]+=e.center[0],w[0]+=e.center[0],v[1]=1,y[1]=-1,m[1]=.5*e.height+e.center[1],w[1]=-.5*e.height+e.center[1],m[2]=-S*Math.sin(T*a+e.initAngle),w[2]=m[2],x[1]=m[2],C[1]=m[2],m[2]+=e.center[2],w[2]+=e.center[2];const _=2*e.resolution+T,E=3*e.resolution+e.resolution-T-1;for(let b=0;b<3;b++)d[3*_+b]=v[b],d[3*E+b]=y[b],l[3*_+b]=m[b],l[3*E+b]=w[b],b<2&&(g[2*_+b]=x[b],g[2*E+b]=C[b])}u[f++]=e.resolution;for(let T=0;T<e.resolution;T++)u[f++]=2*e.resolution+T;u[f++]=e.resolution;for(let T=0;T<e.resolution;T++)u[f++]=3*e.resolution+T}Ni.buildFromRadian().translate(...e.center).rotateFromDirections([0,1,0],e.direction).translate(...e.center.map(T=>T*-1)).apply(l),o=Er.newInstance(),o.getPoints().setData(l,3),o.getPolys().setData(u,1),o.getPointData().setNormals(h),o.getPointData().setTCoords(p),i[0]=o}t.requestData=r}const E_e={height:1,initAngle:0,radius:1,resolution:6,center:[0,0,0],direction:[0,1,0],capping:!0,pointType:"Float64Array"};function Tz(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,E_e,r),Z.obj(t,e),Z.setGet(t,e,["height","initAngle","otherRadius","radius","resolution","capping"]),Z.setGetArray(t,e,["center","direction"],3),Z.algo(t,e,0,1),__e(t,e)}const b_e=Z.newInstance(Tz,"vtkCylinderSource");var D_e={newInstance:b_e,extend:Tz};function I_e(t,e){e.classHierarchy.push("vtkArrowSource");function r(n,i){if(e.deleted)return;const o=D_e.newInstance({capping:!0});o.setResolution(e.shaftResolution),o.setRadius(e.shaftRadius),o.setHeight(1-e.tipLength),o.setCenter(0,(1-e.tipLength)*.5,0);const a=o.getOutputData(),s=a.getPoints().getData(),c=a.getPointData().getNormals().getData();Ni.buildFromDegree().rotateZ(-90).apply(s).apply(c);const l=T_e.newInstance();l.setResolution(e.tipResolution),l.setHeight(e.tipLength),l.setRadius(e.tipRadius);const f=l.getOutputData(),u=f.getPoints().getData();Ni.buildFromRadian().translate(1-e.tipLength*.5,0,0).apply(u);const d=Cz.newInstance();d.setInputData(a),d.addInputData(f);const h=d.getOutputData(),g=h.getPoints().getData();Ni.buildFromRadian().translate(-.5+e.tipLength*.5,0,0).apply(g),e.invert?(Ni.buildFromRadian().rotateFromDirections([1,0,0],e.direction).scale(-1,-1,-1).apply(g),i[0]=h):(Ni.buildFromRadian().rotateFromDirections([1,0,0],e.direction).scale(1,1,1).apply(g),i[0]=d.getOutputData())}t.requestData=r}const O_e={tipResolution:6,tipRadius:.1,tipLength:.35,shaftResolution:6,shaftRadius:.03,invert:!1,direction:[1,0,0],pointType:"Float64Array"};function _z(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Object.assign(e,O_e,r),Z.obj(t,e),Z.setGet(t,e,["tipResolution","tipRadius","tipLength","shaftResolution","shaftRadius","invert"]),Z.setGetArray(t,e,["direction"],3),Z.algo(t,e,0,1),I_e(t,e)}const M_e=Z.newInstance(_z,"vtkArrowSource");var jC={newInstance:M_e,extend:_z};function HC(t){const e=t.getPoints().getBounds(),r=[-(e[0]+e[1])*.5,-(e[2]+e[3])*.5,-(e[4]+e[5])*.5];Ni.buildFromDegree().translate(...r).apply(t.getPoints().getData())}function KC(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;const n=t.getPoints().getBounds(),i=[0,0,0];r?i[e]=-n[e*2+1]:i[e]=-n[e*2],Ni.buildFromDegree().translate(...i).apply(t.getPoints().getData())}function qC(t,e,r,n){const i=t.getPoints().getData().length,o=new Uint8ClampedArray(i);let a=0;for(;a<i;)o[a++]=e,o[a++]=r,o[a++]=n;t.getPointData().setScalars(bt.newInstance({name:"color",numberOfComponents:3,values:o}))}function P_e(t,e){e.classHierarchy.push("vtkAxesActor");const r=la.newInstance();t.setMapper(r),t.update=()=>{let i={...e.config,...e.xConfig};const o=jC.newInstance({direction:[1,0,0],...i}).getOutputData();e.config.recenter?HC(o):KC(o,0,i.invert),qC(o,...i.color),i={...e.config,...e.yConfig};const a=jC.newInstance({direction:[0,1,0],...i}).getOutputData();e.config.recenter?HC(a):KC(a,1,i.invert),qC(a,...i.color),i={...e.config,...e.zConfig};const s=jC.newInstance({direction:[0,0,1],...i}).getOutputData();e.config.recenter?HC(s):KC(s,2,i.invert),qC(s,...i.color);const c=Cz.newInstance();c.setInputData(o),c.addInputData(a),c.addInputData(s),r.setInputConnection(c.getOutputPort())},t.update();const n=Z.debounce(t.update,0);t.setXAxisColor=i=>t.setXConfig({...t.getXConfig(),color:i}),t.setYAxisColor=i=>t.setYConfig({...t.getYConfig(),color:i}),t.setZAxisColor=i=>t.setZConfig({...t.getZConfig(),color:i}),t.getXAxisColor=()=>e.getXConfig().color,t.getYAxisColor=()=>e.getYConfig().color,t.getZAxisColor=()=>e.getZConfig().color,e._onConfigChanged=n,e._onXConfigChanged=n,e._onYConfigChanged=n,e._onZConfigChanged=n}function R_e(t){return{config:{recenter:!0,tipResolution:60,tipRadius:.1,tipLength:.2,shaftResolution:60,shaftRadius:.03,invert:!1,...t==null?void 0:t.config},xConfig:{color:[255,0,0],invert:!1,...t==null?void 0:t.xConfig},yConfig:{color:[255,255,0],invert:!1,...t==null?void 0:t.yConfig},zConfig:{color:[0,128,0],invert:!1,...t==null?void 0:t.zConfig}}}function Ez(t,e){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};uc.extend(t,e,R_e(r)),Z.setGet(t,e,["config","xConfig","yConfig","zConfig"]),P_e(t,e)}const L_e=Z.newInstance(Ez,"vtkAxesActor");var A_e={newInstance:L_e,extend:Ez},M5;(function(t){t[t.ANNOTATED_CUBE=1]="ANNOTATED_CUBE",t[t.AXES=2]="AXES",t[t.CUSTOM=3]="CUSTOM"})(M5||(M5={}));const Vc=class Vc extends ri{constructor(e={},r={configuration:{orientationWidget:{enabled:!0,viewportCorner:E7.Corners.BOTTOM_RIGHT,viewportSize:.15,minPixelSize:100,maxPixelSize:300},overlayMarkerType:Vc.OVERLAY_MARKER_TYPES.ANNOTATED_CUBE,overlayConfiguration:{[Vc.OVERLAY_MARKER_TYPES.ANNOTATED_CUBE]:{faceProperties:{xPlus:{text:"L",faceColor:"#ffff00",faceRotation:90},xMinus:{text:"R",faceColor:"#ffff00",faceRotation:270},yPlus:{text:"P",faceColor:"#00ffff",fontColor:"white",faceRotation:180},yMinus:{text:"A",faceColor:"#00ffff",fontColor:"white"},zPlus:{text:"S"},zMinus:{text:"I"}},defaultStyle:{fontStyle:"bold",fontFamily:"Arial",fontColor:"black",fontSizeScale:n=>n/2,faceColor:"#0000ff",edgeThickness:.1,edgeColor:"black",resolution:400}},[Vc.OVERLAY_MARKER_TYPES.AXES]:{},[Vc.OVERLAY_MARKER_TYPES.CUSTOM]:{polyDataURL:"https://raw.githubusercontent.com/Slicer/Slicer/80ad0a04dacf134754459557bf2638c63f3d1d1b/Base/Logic/Resources/OrientationMarkers/Human.vtp"}}}}){super(e,r),this._resizeObservers=new Map,this.onSetToolEnabled=()=>{this.initViewports(),this._subscribeToViewportEvents()},this.onSetToolActive=()=>{this.initViewports(),this._subscribeToViewportEvents()},this.onSetToolDisabled=()=>{this.cleanUpData(),this._unsubscribeToViewportNewVolumeSet()},this._getViewportsInfo=()=>jr(this.toolGroupId).viewportsInfo,this.resize=n=>{const i=this.orientationMarkers[n];if(!i)return;const{orientationWidget:o}=i;o.updateViewport()},this.orientationMarkers={},this.updatingOrientationMarker={}}_unsubscribeToViewportNewVolumeSet(){const e=()=>{this._getViewportsInfo().forEach(({viewportId:n,renderingEngineId:i})=>{const{viewport:o}=fi(n,i),{element:a}=o;a.removeEventListener(et.VOLUME_VIEWPORT_NEW_VOLUME,this.initViewports.bind(this)),this._resizeObservers.get(n).unobserve(a)})};Ze.removeEventListener(U.TOOLGROUP_VIEWPORT_ADDED,r=>{r.detail.toolGroupId===this.toolGroupId&&(e(),this.initViewports())})}_subscribeToViewportEvents(){const e=()=>{this._getViewportsInfo().forEach(({viewportId:n,renderingEngineId:i})=>{const{viewport:o}=fi(n,i),{element:a}=o;this.initViewports(),a.addEventListener(et.VOLUME_VIEWPORT_NEW_VOLUME,this.initViewports.bind(this));const s=new ResizeObserver(()=>{setTimeout(()=>{const c=fi(n,i);if(!c)return;const{viewport:l}=c;this.resize(n),l.render()},100)});s.observe(a),this._resizeObservers.set(n,s)})};e(),Ze.addEventListener(U.TOOLGROUP_VIEWPORT_ADDED,r=>{r.detail.toolGroupId===this.toolGroupId&&(e(),this.initViewports())})}cleanUpData(){Po()[0].getViewports().forEach(i=>{const o=this.orientationMarkers[i.id];if(!o)return;const{actor:a,orientationWidget:s}=o;s==null||s.setEnabled(!1),s==null||s.delete(),a==null||a.delete(),i.getRenderingEngine().offscreenMultiRenderWindow.getRenderWindow().render(),i.getRenderingEngine().render(),delete this.orientationMarkers[i.id]})}initViewports(){const r=Po()[0];if(!r)return;let n=r.getViewports();n=Fw(n,this.getToolName()),n.forEach(i=>{const o=i.getWidget(this.getToolName());(!o||o.isDeleted())&&this.addAxisActorInViewport(i)})}async addAxisActorInViewport(e){const r=e.id;if(!this.updatingOrientationMarker[r]){this.updatingOrientationMarker[r]=!0;const n=this.configuration.overlayMarkerType,i=this.configuration.overlayConfiguration[n];if(this.orientationMarkers[r]){const{actor:g,orientationWidget:p}=this.orientationMarkers[r];e.getRenderer().removeActor(g),p.setEnabled(!1)}let o;n===1?o=this.createAnnotationCube(i):n===2?o=A_e.newInstance():n===3&&(o=await this.createCustomActor());const a=e.getRenderer(),s=e.getRenderingEngine().offscreenMultiRenderWindow.getRenderWindow(),{enabled:c,viewportCorner:l,viewportSize:f,minPixelSize:u,maxPixelSize:d}=this.configuration.orientationWidget,h=E7.newInstance({actor:o,interactor:s.getInteractor(),parentRenderer:a});h.setEnabled(c),h.setViewportCorner(l),h.setViewportSize(f),h.setMinPixelSize(u),h.setMaxPixelSize(d),h.updateMarkerOrientation(),this.orientationMarkers[r]={orientationWidget:h,actor:o},e.addWidget(this.getToolName(),h),s.render(),e.getRenderingEngine().render(),this.updatingOrientationMarker[r]=!1}}async createCustomActor(){const e=this.configuration.overlayConfiguration[M5.CUSTOM].polyDataURL,n=await(await fetch(e)).arrayBuffer(),i=mV.newInstance();i.parseAsArrayBuffer(n),i.update();const o=Er.newInstance();o.shallowCopy(i.getOutputData()),o.getPointData().setActiveScalars("Color");const a=la.newInstance();a.setInputData(o),a.setColorModeToDirectScalars();const s=uc.newInstance();return s.setMapper(a),s.rotateZ(180),s}createAnnotationCube(e){const r=b7.newInstance();return r.setDefaultStyle({...e.defaultStyle}),r.setXPlusFaceProperty({...e.faceProperties.xPlus}),r.setXMinusFaceProperty({...e.faceProperties.xMinus}),r.setYPlusFaceProperty({...e.faceProperties.yPlus}),r.setYMinusFaceProperty({...e.faceProperties.yMinus}),r.setZPlusFaceProperty({...e.faceProperties.zPlus}),r.setZMinusFaceProperty({...e.faceProperties.zMinus}),r}async createAnnotatedCubeActor(){const e=b7.newInstance(),{faceProperties:r,defaultStyle:n}=this.configuration.annotatedCube;return e.setDefaultStyle(n),Object.keys(r).forEach(i=>{const o=`set${i.charAt(0).toUpperCase()+i.slice(1)}FaceProperty`;e[o](r[i])}),e}};Vc.CUBE=1,Vc.AXIS=2,Vc.VTPFILE=3,Vc.OVERLAY_MARKER_TYPES=M5;let P5=Vc;P5.toolName="OrientationMarker";const Bp=class Bp extends ri{constructor(e={},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{hoverTimeout:100,mode:Bp.SelectMode.Border,searchRadius:6}}){super(e,r),this.mouseMoveCallback=n=>{if(this.mode===En.Active)return this.hoverTimer&&clearTimeout(this.hoverTimer),this.hoverTimer=setTimeout(()=>{this._setActiveSegment(n),this.hoverTimer=null},this.configuration.hoverTimeout),!0},this.onSetToolEnabled=()=>{this.onSetToolActive()},this.onSetToolActive=()=>{this.hoverTimer=null},this.onSetToolDisabled=()=>{this.hoverTimer=null},this.hoverTimer=null}_setActiveSegment(e={}){if(Je.isInteractingWithTool)return;const{element:r,currentPoints:n}=e.detail,i=n.world,o=Le(r);if(!o)return;const{viewport:a}=o,s=lu(a.id);s&&this._setActiveSegmentForType(s,i,a)}_setActiveSegmentForType(e,r,n){if(!n.getImageData())return;const{segmentationId:o,representationData:a}=e;let s;if(this.configuration.mode===Bp.SelectMode.Inside?s=I8(o,r,{viewport:n}):a.Labelmap?s=cW(o,r,{viewport:n,searchRadius:this.configuration.searchRadius}):a.Contour?s=uW(o):a.Surface,!s||s===0)return;T5(o,s);const l=n.getRenderingEngine().getViewports().map(f=>f.id);Ka(o),We(l)}};Bp.SelectMode={Inside:"Inside",Border:"Border"};let R5=Bp;R5.toolName="SegmentSelectTool";const B0=class B0 extends N1{constructor(e={}){super(e),this.renderAnnotation=(r,n)=>{let i=!0;const{viewport:o}=r,{element:a}=o,s=o.id;let c=Jt(this.getToolName(),a);if(!(c!=null&&c.length)||(c=this.filterInteractableAnnotationsForElement(a,c),!(c!=null&&c.length)))return i;const l=this.getTargetId(o),f=o.getRenderingEngine(),u={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:r.viewport.id};for(let d=0;d<c.length;d++){const h=c[d],{annotationUID:g,data:p}=h,{points:v,activeHandleIndex:y}=p.handles,m=v.map(we=>o.worldToCanvas(we));u.annotationUID=g;const{segmentIndex:w,segmentationId:x}=h.metadata,{lineWidth:C,lineDash:S,shadow:T}=this.getAnnotationStyle({annotation:h,styleSpecifier:u}),E=`rgb(${ou(s,x,w).slice(0,3).join(",")})`;if(!p.cachedStats[l]||p.cachedStats[l].unit==null?(p.cachedStats[l]={length:null,width:null,unit:null},this._calculateCachedStats(h,f,r)):h.invalidated&&this._throttledCalculateCachedStats(h,f,r),!o.getRenderingEngine())return console.warn("Rendering Engine has been destroyed"),i;let b;if(!Vr(g))continue;!Yr(g)&&!this.editData&&y!==null&&(b=[m[y]]),b&&Kn(n,g,"0",b,{color:E});const D=`${g}-line-1`,I=`${g}-line-2`;an(n,g,"0",m[0],m[1],{color:E,lineWidth:C,lineDash:S,shadow:T},D),an(n,g,"1",m[2],m[3],{color:E,lineWidth:C,lineDash:S,shadow:T},I),i=!0;const L=this.getLinkedTextBoxStyle(u,h);if(!L.visibility){p.handles.textBox={hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}};continue}L.color=E;const B=this.configuration.getTextLines(p,l);if(!B||B.length===0)continue;let H;p.handles.textBox.hasMoved||(H=wa(m),p.handles.textBox.worldPosition=o.canvasToWorld(H));const A=o.worldToCanvas(p.handles.textBox.worldPosition),G=Ji(n,g,"1",B,A,m,{},L),{x:X,y:ee,width:ce,height:Se}=G;p.handles.textBox.worldBoundingBox={topLeft:o.canvasToWorld([X,ee]),topRight:o.canvasToWorld([X+ce,ee]),bottomLeft:o.canvasToWorld([X,ee+Se]),bottomRight:o.canvasToWorld([X+ce,ee+Se])}}return i}}addNewAnnotation(e){const r=e.detail,{currentPoints:n,element:i}=r,o=n.world,a=Le(i),{viewport:s}=a;this.isDrawing=!0;const c=s.getCamera(),{viewPlaneNormal:l,viewUp:f}=c,u=this.getReferencedImageId(s,o,l,f),d=s.getFrameOfReferenceUID(),h={highlighted:!0,invalidated:!0,metadata:{toolName:this.getToolName(),viewPlaneNormal:[...l],viewUp:[...f],FrameOfReferenceUID:d,referencedImageId:u,...s.getViewReference({points:[o]})},data:{handles:{points:[[...o],[...o],[...o],[...o]],textBox:{hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}},activeHandleIndex:null},label:"",cachedStats:{}}};qt(h,i);const g=wt(i,this.getToolName());return this.editData={annotation:h,viewportIdsToRender:g,handleIndex:1,movingTextBox:!1,newAnnotation:!0,hasMoved:!1},this._activateDraw(i),Dt(i),e.preventDefault(),We(g),h}};B0.toolName="SegmentBidirectional",B0.hydrate=(e,r,n)=>{const i=Mn(e);if(!i)return;const{viewport:o}=i,c=vm().filter(T=>T.metadata.toolName==="SegmentBidirectional").find(T=>{const{metadata:_}=T;return _.segmentIndex===(n==null?void 0:n.segmentIndex)&&_.segmentationId===(n==null?void 0:n.segmentationId)});c&&en(c.annotationUID);const{FrameOfReferenceUID:l,referencedImageId:f,viewPlaneNormal:u,instance:d}=B0.hydrateBase(B0,i,r[0],n),[h,g]=r,[p,v]=h,[y,m]=g,w=[p,v,y,m],{toolInstance:x,...C}=n||{},S={annotationUID:(n==null?void 0:n.annotationUID)||gn(),data:{handles:{points:w,activeHandleIndex:null,textBox:{hasMoved:!1,worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}}},cachedStats:{}},highlighted:!1,autoGenerated:!1,invalidated:!1,isLocked:!1,isVisible:!0,metadata:{segmentIndex:n==null?void 0:n.segmentIndex,segmentationId:n==null?void 0:n.segmentationId,toolName:d.getToolName(),viewPlaneNormal:u,FrameOfReferenceUID:l,referencedImageId:f,...C}};return qt(S,o.element),We([o.id]),S};let ET=B0;class bz extends ri{constructor(e={data:{handles:{textBox:{worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}}}}},r={supportedInteractionTypes:["Mouse","Touch"],configuration:{hoverTimeout:100,searchRadius:6}}){super(e,r),this.mouseMoveCallback=n=>(this.hoverTimer&&clearTimeout(this.hoverTimer),this.hoverTimer=setTimeout(()=>{this._setHoveredSegment(n),this.hoverTimer=null},this.configuration.hoverTimeout),!0),this.onSetToolEnabled=()=>{this.onSetToolActive()},this.onSetToolActive=()=>{this.hoverTimer=null},this.onSetToolDisabled=()=>{this.hoverTimer=null},this.data=e.data??{handles:{textBox:{worldPosition:[0,0,0],worldBoundingBox:{topLeft:[0,0,0],topRight:[0,0,0],bottomLeft:[0,0,0],bottomRight:[0,0,0]}}}},this.hoverTimer=null}_setHoveredSegment(e={}){if(Je.isInteractingWithTool)return;const{element:r,currentPoints:n}=e.detail,i=n.world,o=Le(r);if(!o)return;const{viewport:a}=o,s=lu(a.id);s&&this._setHoveredSegmentForType(s,i,a)}_setHoveredSegmentForType(e,r,n){if(!n.getImageData())return;const{segmentationId:o}=e,a=I8(o,r,{viewport:n}),s=e.segments[a],c=s==null?void 0:s.label,l=n.worldToCanvas(r);if(this._editData={hoveredSegmentIndex:a,hoveredSegmentLabel:c,canvasCoordinates:l,worldPoint:r},!a||a===0)return;const u=n.getRenderingEngine().getViewports().map(d=>d.id);Ka(o),We(u)}renderAnnotation(e,r){if(!this._editData)return;const{viewport:n}=e,{hoveredSegmentIndex:i,hoveredSegmentLabel:o,canvasCoordinates:a,worldPoint:s}=this._editData;if(!i)return;const c=n.worldToCanvas(s),l=Ji(r,"segmentSelectLabelAnnotation","segmentSelectLabelTextBox",[o||"(unnamed segment)"],c,[a],{},{}),f=a[0],u=a[1],{width:d,height:h}=l;this.data.handles.textBox.worldBoundingBox={topLeft:n.canvasToWorld([f,u]),topRight:n.canvasToWorld([f+d,u]),bottomLeft:n.canvasToWorld([f,u+h]),bottomRight:n.canvasToWorld([f+d,u+h])}}}bz.toolName="SegmentLabelTool";const Co=class Co extends sl{constructor(e={}){const r=Ti({configuration:{calculateStats:!1,allowOpenContours:!1}},e);super(r),this.onViewportAddedToToolGroupBinded=this.onViewportAddedToToolGroup.bind(this),this.onSegmentationModifiedBinded=this.onSegmentationModified.bind(this)}initializeListeners(){Co.annotationsToViewportMap.clear(),Co.viewportIdsChecked=[],Ze.addEventListener(U.ANNOTATION_MODIFIED,this.annotationModified),Ze.addEventListener(U.ANNOTATION_COMPLETED,this.annotationCompleted),Ze.addEventListener(U.TOOLGROUP_VIEWPORT_ADDED,this.onViewportAddedToToolGroupBinded),Ze.addEventListener(U.SEGMENTATION_MODIFIED,this.onSegmentationModifiedBinded)}cleanUpListeners(){Co.annotationsToViewportMap.clear(),Co.viewportIdsChecked=[],Ze.removeEventListener(U.ANNOTATION_MODIFIED,this.annotationModified),Ze.removeEventListener(U.ANNOTATION_COMPLETED,this.annotationCompleted),Ze.removeEventListener(U.TOOLGROUP_VIEWPORT_ADDED,this.onViewportAddedToToolGroup.bind(this)),Ze.removeEventListener(U.SEGMENTATION_MODIFIED,this.onSegmentationModified.bind(this))}async checkContourSegmentation(e){if(Co.viewportIdsChecked.includes(e))return;const r=Od(e);if(!r)return console.log("No active segmentation detected"),!1;const n=r.segmentationId;return r.representationData.Contour?Co.viewportIdsChecked.push(e):(Co.viewportIdsChecked.push(e),await O8(e,[{segmentationId:n,type:St.Contour}]),FE({segmentationId:n,type:St.Contour,data:{}})),!0}onViewportAddedToToolGroup(e){const{toolGroupId:r,viewportId:n}=e.detail;r===this.toolGroupId&&this.checkContourSegmentation(n)}onSegmentationModified(e){const{segmentationId:r}=e.detail||{};if(!r)return;const n=gU(r);n&&n.forEach(async({viewportId:i})=>await this.checkContourSegmentation(i))}onSetToolEnabled(){this.initializeListeners()}onSetToolActive(){this.initializeListeners()}onSetToolDisabled(){this.cleanUpListeners()}annotationModified(e){var a;const{annotation:r,renderingEngineId:n,viewportId:i}=e.detail,o=(a=Nr(n))==null?void 0:a.getViewport(i);o&&Co.annotationsToViewportMap.set(r.annotationUID,o)}annotationCompleted(e){var i,o;const{annotation:r}=e.detail,{polyline:n}=((i=r.data)==null?void 0:i.contour)||{};if(((o=r==null?void 0:r.metadata)==null?void 0:o.toolName)===Co.toolName&&n&&Co.annotationsToViewportMap.has(r.annotationUID)){const a=Co.annotationsToViewportMap.get(r.annotationUID);n.length>3&&ex.viewportContoursToLabelmap(a)}}};Co.toolName="LabelMapEditWithContour",Co.annotationsToViewportMap=new Map,Co.viewportIdsChecked=[];let bT=Co;const vb=class vb extends Yn{constructor(e={}){super(e,{supportedInteractionTypes:["Mouse","Touch"],configuration:{shadow:!0,preventHandleOutsideImage:!1}}),this.addNewAnnotation=r=>{const n=r.detail,{currentPoints:i,element:o}=n,a=i.world,s=Le(o),{viewport:c}=s;this.isDrawing=!0;const l=this.constructor.createAnnotationForViewport(c,{data:{handles:{points:[[...a],[...a],[...a],[...a]]}}});qt(l,o);const f=wt(o,this.getToolName(),!1);return this.editData={annotation:l,viewportUIDsToRender:f,handleIndex:3,newAnnotation:!0,hasMoved:!1},this._activateDraw(o),Dt(o),r.preventDefault(),We(f),l},this.getHandleNearImagePoint=(r,n,i,o)=>{const a=Le(r),{viewport:s}=a,{data:c}=n,{points:l}=c.handles;for(let f=0;f<l.length;f++){const u=l[f],d=s.worldToCanvas(u);if(ur(i,d)<o===!0)return c.handles.activeHandleIndex=f,u}c.handles.activeHandleIndex=null},this.isPointNearTool=(r,n,i,o)=>{const a=Le(r),{viewport:s}=a,{data:c}=n,{points:l}=c.handles,f=s.worldToCanvas(l[0]),u=s.worldToCanvas(l[3]),d=this._getRectangleImageCoordinates([f,u]),h=[i[0],i[1]],{left:g,top:p,width:v,height:y}=d;if(e8([g,p,v,y],h)<=o)return!0},this.toolSelectedCallback=(r,n,i="mouse")=>{const o=r.detail,{element:a}=o,{data:s}=n;s.active=!0;const c=wt(a,this.getToolName(),!1);this.editData={annotation:n,viewportUIDsToRender:c},this._activateModify(a),Dt(a),We(c),r.preventDefault()},this.handleSelectedCallback=(r,n,i,o="mouse")=>{const a=r.detail,{element:s}=a,{data:c}=n;c.active=!0;let l;i.worldPosition||(l=c.handles.points.findIndex(u=>u===i));const f=wt(s,this.getToolName(),!1);this.editData={annotation:n,viewportUIDsToRender:f,handleIndex:l},this._activateModify(s),Dt(s),We(f),r.preventDefault()},this._endCallback=r=>{const n=r.detail,{element:i}=n,{annotation:o,viewportUIDsToRender:a,newAnnotation:s,hasMoved:c}=this.editData,{data:l}=o;s&&!c||(this.doneEditMemo(),l.active=!1,l.handles.activeHandleIndex=null,this._deactivateModify(i),this._deactivateDraw(i),kt(i),this.editData=null,this.isDrawing=!1,this.isHandleOutsideImage&&this.configuration.preventHandleOutsideImage&&en(o.annotationUID),We(a))},this._dragCallback=r=>{this.isDrawing=!0;const n=r.detail,{element:i}=n,{annotation:o,viewportUIDsToRender:a,handleIndex:s,newAnnotation:c}=this.editData;this.createMemo(i,o,{newAnnotation:c});const{data:l}=o;if(s===void 0){const{deltaPoints:f}=n,u=f.world,{points:d}=l.handles;d.forEach(h=>{h[0]+=u[0],h[1]+=u[1],h[2]+=u[2]}),l.invalidated=!0}else{const{currentPoints:f}=n,u=Le(i),{worldToCanvas:d,canvasToWorld:h}=u.viewport,g=f.world,{points:p}=l.handles;p[s]=[...g];let v,y,m,w,x,C,S,T;switch(s){case 0:case 3:v=d(p[0]),w=d(p[3]),y=[w[0],v[1]],m=[v[0],w[1]],C=h(y),S=h(m),p[1]=C,p[2]=S;break;case 1:case 2:y=d(p[1]),m=d(p[2]),v=[m[0],y[1]],w=[y[0],m[1]],x=h(v),T=h(w),p[0]=x,p[3]=T;break}l.invalidated=!0}this.editData.hasMoved=!0,Le(i),We(a)},this._activateDraw=r=>{Je.isInteractingWithTool=!0,r.addEventListener(U.MOUSE_UP,this._endCallback),r.addEventListener(U.MOUSE_DRAG,this._dragCallback),r.addEventListener(U.MOUSE_MOVE,this._dragCallback),r.addEventListener(U.MOUSE_CLICK,this._endCallback),r.addEventListener(U.TOUCH_END,this._endCallback),r.addEventListener(U.TOUCH_DRAG,this._dragCallback)},this._deactivateDraw=r=>{Je.isInteractingWithTool=!1,r.removeEventListener(U.MOUSE_UP,this._endCallback),r.removeEventListener(U.MOUSE_DRAG,this._dragCallback),r.removeEventListener(U.MOUSE_MOVE,this._dragCallback),r.removeEventListener(U.MOUSE_CLICK,this._endCallback),r.removeEventListener(U.TOUCH_END,this._endCallback),r.removeEventListener(U.TOUCH_DRAG,this._dragCallback)},this._activateModify=r=>{Je.isInteractingWithTool=!0,r.addEventListener(U.MOUSE_UP,this._endCallback),r.addEventListener(U.MOUSE_DRAG,this._dragCallback),r.addEventListener(U.MOUSE_CLICK,this._endCallback),r.addEventListener(U.TOUCH_END,this._endCallback),r.addEventListener(U.TOUCH_DRAG,this._dragCallback)},this._deactivateModify=r=>{Je.isInteractingWithTool=!1,r.removeEventListener(U.MOUSE_UP,this._endCallback),r.removeEventListener(U.MOUSE_DRAG,this._dragCallback),r.removeEventListener(U.MOUSE_CLICK,this._endCallback),r.removeEventListener(U.TOUCH_END,this._endCallback),r.removeEventListener(U.TOUCH_DRAG,this._dragCallback)},this.renderAnnotation=(r,n)=>{const{viewport:o}=r,{element:a}=o;let s=Jt(this.getToolName(),a);if(!(s!=null&&s.length)||(s=this.filterInteractableAnnotationsForElement(a,s),!(s!=null&&s.length)))return!1;const c={toolGroupId:this.toolGroupId,toolName:this.getToolName(),viewportId:r.viewport.id};for(let l=0;l<s.length;l++){const f=s[l],{annotationUID:u}=f,d=f.data,{points:h,activeHandleIndex:g}=d.handles,p=h.map(C=>o.worldToCanvas(C)),v=this.getStyle("lineWidth",c,f),y=this.getStyle("lineDash",c,f),m=this.getStyle("color",c,f);if(!o.getRenderingEngine()){console.warn("Rendering Engine has been destroyed");return}let w;!this.editData&&g!==null&&(w=[p[g]]),w&&Kn(n,u,"0",w,{color:m}),XU(n,u,"0",p[0],p[3],{color:"black",lineDash:y,lineWidth:v})}},this._getRectangleImageCoordinates=r=>{const[n,i]=r;return{left:Math.min(n[0],i[0]),top:Math.min(n[1],i[1]),width:Math.abs(n[0]-i[0]),height:Math.abs(n[1]-i[1])}},this._calculateCachedStats=(r,n,i,o,a)=>{const{data:s}=r,{viewportUID:c,renderingEngineUID:l,sceneUID:f}=a,u=s.handles.points[0],d=s.handles.points[3],{cachedStats:h}=s,g=Object.keys(h);for(let v=0;v<g.length;v++){const y=g[v],{imageVolume:m}=this._getImageVolumeFromTargetUID(y,o),{dimensions:w,scalarData:x,vtkImageData:C,metadata:S}=m,T=Tt(0,0,0),_=Tt(0,0,0);if(C.worldToIndexVec3(u,T),T[0]=Math.floor(T[0]),T[1]=Math.floor(T[1]),T[2]=Math.floor(T[2]),C.worldToIndexVec3(d,_),_[0]=Math.floor(_[0]),_[1]=Math.floor(_[1]),_[2]=Math.floor(_[2]),this._isInsideVolume(T,_,w)){this.isHandleOutsideImage=!1;const E=Math.min(T[0],_[0]),b=Math.max(T[0],_[0]),D=Math.min(T[1],_[1]),I=Math.max(T[1],_[1]),P=Math.min(T[2],_[2]),O=Math.max(T[2],_[2]),{worldWidth:L,worldHeight:B}=Qh(n,i,u,d),H=L*B;let A=0,F=0,G=0;const X=w[0],ee=w[0]*w[1];for(let ce=P;ce<=O;ce++)for(let Se=D;Se<=I;Se++)for(let we=E;we<=b;we++){const _e=x[ce*ee+Se*X+we];A++,F+=_e}F/=A;for(let ce=P;ce<=O;ce++)for(let Se=D;Se<=I;Se++)for(let we=E;we<=b;we++){const Ve=x[ce*ee+Se*X+we]-F;G+=Ve*Ve}G/=A,G=Math.sqrt(G),h[y]={Modality:S.Modality,area:H,mean:F,stdDev:G}}else this.isHandleOutsideImage=!0,h[y]={Modality:S.Modality}}const p=r.invalidated;if(r.invalidated=!1,p){const v=U.ANNOTATION_MODIFIED,y={annotation:r,viewportUID:c,renderingEngineUID:l,sceneUID:f,changeType:Bt.StatsUpdated};it(Ze,v,y)}return h},this._isInsideVolume=(r,n,i)=>tr(r,i)&&tr(n,i),this._getTargetVolumeUID=r=>{if(this.configuration.volumeUID)return this.configuration.volumeUID;const n=r.getVolumeActors();if(!(!n&&!n.length))return n[0].uid},this._throttledCalculateCachedStats=Lo(this._calculateCachedStats,100,{trailing:!0})}cancel(e){if(!this.isDrawing)return;this.isDrawing=!1,this._deactivateDraw(e),this._deactivateModify(e),kt(e);const{annotation:r,viewportUIDsToRender:n}=this.editData,{data:i}=r;return i.active=!1,i.handles.activeHandleIndex=null,We(n),this.editData=null,r.metadata.annotationUID}_getImageVolumeFromTargetUID(e,r){let n,i;if(e.startsWith("stackTarget")){const o=e.indexOf(":"),a=e.substring(o+1);n=r.getViewport(a).getImageData()}else n=$e.getVolume(e);return{imageVolume:n,viewport:i}}_getTargetStackUID(e){return`stackTarget:${e.uid}`}};vb.toolName="VideoRedaction";let DT=vb;const Dz=Object.freeze(Object.defineProperty({__proto__:null,AdvancedMagnifyTool:G1,AngleTool:mT,AnnotationDisplayTool:Ef,AnnotationTool:Yn,ArrowAnnotateTool:mf,BaseTool:ri,BidirectionalTool:N1,BrushTool:ex,CONSTANTS:fwe,CircleROIStartEndThresholdTool:hz,CircleROITool:E5,CircleScissorsTool:fz,CobbAngleTool:vT,CrosshairsTool:Uc,DragProbeTool:dT,ETDRSGridTool:hT,EllipticalROITool:Ad,Enums:lF,EraserTool:cz,HeightTool:fT,KeyImageTool:ST,LabelMapEditWithContourTool:bT,LabelTool:_5,LabelmapBaseTool:Rd,LengthTool:pf,LivewireContourSegmentationTool:pT,LivewireContourTool:I5,MIPJumpToClickTool:ZW,MagnifyTool:QW,OrientationMarkerTool:P5,OverlayGridTool:ez,PaintFillTool:gz,PanTool:ef,PlanarFreehandContourSegmentationTool:sl,PlanarFreehandROITool:gf,PlanarRotateTool:Ph,ProbeTool:su,RectangleROIStartEndThresholdTool:_8,RectangleROIThresholdTool:E8,RectangleROITool:au,RectangleScissorsTool:uz,ReferenceCursors:La,ReferenceLinesTool:pd,RegionSegmentPlusTool:_T,RegionSegmentTool:TT,ScaleOverlayTool:iz,SculptorTool:Rh,SegmentBidirectionalTool:ET,SegmentLabelTool:bz,SegmentSelectTool:R5,SegmentationIntersectionTool:tz,SphereScissorsTool:dz,SplineContourSegmentationTool:gT,SplineROITool:b5,StackScrollTool:Ld,Synchronizer:x8,SynchronizerManager:uG,ToolGroupManager:_F,TrackballRotateTool:YW,Types:VSe,UltrasoundDirectionalTool:yT,UltrasoundPleuraBLineTool:CT,VideoRedactionTool:DT,VolumeRotateTool:az,WholeBodySegmentTool:lz,WindowLevelRegionTool:JW,WindowLevelTool:Mh,ZoomTool:Wl,addTool:xi,annotation:hye,cancelActiveManipulations:lG,cursors:fpe,destroy:cwe,drawing:kme,init:fG,removeTool:PF,segmentation:rTe,splines:cTe,get state(){return Je},store:swe,synchronizers:Rwe,utilities:kSe,version:dwe},Symbol.toStringTag,{value:"Module"}));function Iz(t,e,r){if(t===void 0)throw new Error("decodeRGB: rgbBuffer must be defined");if(t.length%3!==0)throw new Error(`decodeRGB: rgbBuffer length ${t.length} must be divisible by 3`);const n=t.length/3;let i=0,o=0;if(r){for(let a=0;a<n;a++)e[o++]=t[i++],e[o++]=t[i++],e[o++]=t[i++],e[o++]=255;return}e.set(t)}function Oz(t,e,r){if(t===void 0)throw new Error("decodeRGB: rgbBuffer must be defined");if(t.length%3!==0)throw new Error(`decodeRGB: rgbBuffer length ${t.length} must be divisible by 3`);const n=t.length/3;let i=0,o=0,a=n,s=n*2;if(r)for(let c=0;c<n;c++)e[i++]=t[o++],e[i++]=t[a++],e[i++]=t[s++],e[i++]=255;else for(let c=0;c<n;c++)e[i++]=t[o++],e[i++]=t[a++],e[i++]=t[s++]}function Mz(t,e,r){if(t===void 0)throw new Error("convertYBRFullByPixel: ybrBuffer must be defined");if(t.length%3!==0)throw new Error(`convertYBRFullByPixel: ybrBuffer length ${t.length} must be divisible by 3`);const n=t.length/3;let i=0,o=0;if(r){for(let a=0;a<n;a++){const s=t[i++],c=t[i++],l=t[i++];e[o++]=s+1.402*(l-128),e[o++]=s-.34414*(c-128)-.71414*(l-128),e[o++]=s+1.772*(c-128),e[o++]=255}return}for(let a=0;a<n;a++){const s=t[i++],c=t[i++],l=t[i++];e[o++]=s+1.402*(l-128),e[o++]=s-.34414*(c-128)-.71414*(l-128),e[o++]=s+1.772*(c-128)}}function Pz(t,e,r){if(t===void 0)throw new Error("convertYBRFullByPlane: ybrBuffer must be defined");if(t.length%3!==0)throw new Error(`convertYBRFullByPlane: ybrBuffer length ${t.length} must be divisible by 3`);const n=t.length/3;let i=0,o=0,a=n,s=n*2;if(r){for(let c=0;c<n;c++){const l=t[o++],f=t[a++],u=t[s++];e[i++]=l+1.402*(u-128),e[i++]=l-.34414*(f-128)-.71414*(u-128),e[i++]=l+1.772*(f-128),e[i++]=255}return}for(let c=0;c<n;c++){const l=t[o++],f=t[a++],u=t[s++];e[i++]=l+1.402*(u-128),e[i++]=l-.34414*(f-128)-.71414*(u-128),e[i++]=l+1.772*(f-128)}}function N_e(t,e,r){if(t===void 0)throw new Error("convertYBRFull422ByPixel: ybrBuffer must be defined");if(t.length%2!==0)throw new Error(`convertYBRFull422ByPixel: ybrBuffer length ${t.length} must be divisible by 2`);const n=t.length/2;let i=0,o=0;if(r){for(let a=0;a<n;a+=2){const s=t[i++],c=t[i++],l=t[i++],f=t[i++];e[o++]=s+1.402*(f-128),e[o++]=s-.34414*(l-128)-.71414*(f-128),e[o++]=s+1.772*(l-128),e[o++]=255,e[o++]=c+1.402*(f-128),e[o++]=c-.34414*(l-128)-.71414*(f-128),e[o++]=c+1.772*(l-128),e[o++]=255}return}for(let a=0;a<n;a+=2){const s=t[i++],c=t[i++],l=t[i++],f=t[i++];e[o++]=s+1.402*(f-128),e[o++]=s-.34414*(l-128)-.71414*(f-128),e[o++]=s+1.772*(l-128),e[o++]=c+1.402*(f-128),e[o++]=c-.34414*(l-128)-.71414*(f-128),e[o++]=c+1.772*(l-128)}}function XC(t,e){const r=t.length,n=new Uint8ClampedArray(r);for(let i=0;i<r;++i)n[i]=t[i]>>e;return n}function YC(t,e,r){const n=t[`${e}PaletteColorLookupTableData`];if(n)return Promise.resolve(n);const i=ct("imagePixelModule",t.imageId);return i&&typeof i.then=="function"?i.then(o=>o?o[`${e}PaletteColorLookupTableData`]:r):Promise.resolve(i?i[`${e}PaletteColorLookupTableData`]:r)}function Rz(t,e,r){const n=t.columns*t.rows,i=t.pixelData;Promise.all([YC(t,"red",null),YC(t,"green",null),YC(t,"blue",null)]).then(([o,a,s])=>{if(!o||!a||!s)throw new Error("The image does not have a complete color palette. R, G, and B palette data are required.");const c=o.length;let l=0,f=0;const u=t.redPaletteColorLookupTableDescriptor[1],d=t.redPaletteColorLookupTableDescriptor[2]===8?0:8,h=XC(o,d),g=XC(a,d),p=XC(s,d);if(r){for(let v=0;v<n;++v){let y=i[l++];y<u?y=0:y>u+c-1?y=c-1:y-=u,e[f++]=h[y],e[f++]=g[y],e[f++]=p[y],e[f++]=255}return}for(let v=0;v<n;++v){let y=i[l++];y<u?y=0:y>u+c-1?y=c-1:y-=u,e[f++]=h[y],e[f++]=g[y],e[f++]=p[y]}})}function JC(t,e){if(!(!t.elements[e]||t.elements[e].length!==6))return[t.uint16(e,0),t.uint16(e,1),t.uint16(e,2)]}function ZC(t,e,r){const n=[],i=t.elements[e];for(let o=0;o<r[0];o++)r[2]===16?n[o]=t.uint16(e,o):n[o]=t.byteArray[o+i.dataOffset];return n}function k_e(t,e){e.redPaletteColorLookupTableDescriptor=JC(t,"x00281101"),e.greenPaletteColorLookupTableDescriptor=JC(t,"x00281102"),e.bluePaletteColorLookupTableDescriptor=JC(t,"x00281103"),e.redPaletteColorLookupTableDescriptor[0]===0&&(e.redPaletteColorLookupTableDescriptor[0]=65536,e.greenPaletteColorLookupTableDescriptor[0]=65536,e.bluePaletteColorLookupTableDescriptor[0]=65536);const r=e.redPaletteColorLookupTableDescriptor[0],i=t.elements.x00281201.length===r?8:16;e.redPaletteColorLookupTableDescriptor[2]!==i&&(e.redPaletteColorLookupTableDescriptor[2]=i,e.greenPaletteColorLookupTableDescriptor[2]=i,e.bluePaletteColorLookupTableDescriptor[2]=i),e.redPaletteColorLookupTableData=ZC(t,"x00281201",e.redPaletteColorLookupTableDescriptor),e.greenPaletteColorLookupTableData=ZC(t,"x00281202",e.greenPaletteColorLookupTableDescriptor),e.bluePaletteColorLookupTableData=ZC(t,"x00281203",e.bluePaletteColorLookupTableDescriptor)}function V_e(t,e){t.uint16("x00280103")===0?(e.smallestPixelValue=t.uint16("x00280106"),e.largestPixelValue=t.uint16("x00280107")):(e.smallestPixelValue=t.int16("x00280106"),e.largestPixelValue=t.int16("x00280107"))}function Lz(t){const e={samplesPerPixel:t.uint16("x00280002"),photometricInterpretation:t.string("x00280004"),rows:t.uint16("x00280010"),columns:t.uint16("x00280011"),bitsAllocated:t.uint16("x00280100"),bitsStored:t.uint16("x00280101"),highBit:t.uint16("x00280102"),pixelRepresentation:t.uint16("x00280103"),planarConfiguration:t.uint16("x00280006"),pixelAspectRatio:t.string("x00280034")};return V_e(t,e),e.photometricInterpretation==="PALETTE COLOR"&&t.elements.x00281101&&k_e(t,e),e}function F_e(t,e){let r=e.uint16("x00283002",0);r===0&&(r=65535);let n=0;t===0?n=e.uint16("x00283002",1):n=e.int16("x00283002",1);const i=e.uint16("x00283002",2),o={id:"1",firstValueMapped:n,numBitsPerEntry:i,lut:[]};for(let a=0;a<r;a++)t===0?o.lut[a]=e.uint16("x00283006",a):o.lut[a]=e.int16("x00283006",a);return o}function IT(t,e){if(!e||!e.items||!e.items.length)return;const r=[];for(let n=0;n<e.items.length;n++){const i=e.items[n].dataSet,o=F_e(t,i);o&&r.push(o)}return r}function U_e(t){const e=t.uint16("x00280103"),r=t.uint16("x00280101");return e===0?0:-1<<r-1}function Az(t){const e=t.string("x00080016");if(e==="1.2.840.10008.5.1.4.1.1.2"||e==="1.2.840.10008.5.1.4.1.1.2.1")return 1;const r=t.floatString("x00281052"),n=t.floatString("x00281053");return r!==void 0&&n!==void 0?U_e(t)*n+r<0?1:0:t.elements.x00283000&&t.elements.x00283000.length>0?0:t.uint16("x00280103")}function gc(t,e,r){const n=[],i=t.string(e);if(!i)return;const o=i.split("\\");if(!(r&&o.length<r)){for(let a=0;a<o.length;a++)n.push(parseFloat(o[a]));return n}}var Nz={exports:{}};/*! dicom-parser - 1.8.12 - 2023-02-20 | (c) 2017 Chris Hafey | https://github.com/cornerstonejs/dicomParser */(function(t,e){(function(r,n){t.exports=n(el)})(Ai,function(r){return i=[function(a,s){a.exports=r},function(a,s,c){c.r(s),c.d(s,"isStringVr",function(){return f}),c.d(s,"isPrivateTag",function(){return u}),c.d(s,"parsePN",function(){return d}),c.d(s,"parseTM",function(){return h}),c.d(s,"parseDA",function(){return p}),c.d(s,"explicitElementToString",function(){return v}),c.d(s,"explicitDataSetToJS",function(){return y}),c.d(s,"createJPEGBasicOffsetTable",function(){return x}),c.d(s,"parseDicomDataSetExplicit",function(){return ee}),c.d(s,"parseDicomDataSetImplicit",function(){return ce}),c.d(s,"readFixedString",function(){return _}),c.d(s,"alloc",function(){return Se}),c.d(s,"version",function(){return we}),c.d(s,"bigEndianByteArrayParser",function(){return _e}),c.d(s,"ByteStream",function(){return Ne}),c.d(s,"sharedCopy",function(){return Ve}),c.d(s,"DataSet",function(){return D}),c.d(s,"findAndSetUNElementLength",function(){return T}),c.d(s,"findEndOfEncapsulatedElement",function(){return S}),c.d(s,"findItemDelimitationItemAndSetElementLength",function(){return I}),c.d(s,"littleEndianByteArrayParser",function(){return j}),c.d(s,"parseDicom",function(){return K}),c.d(s,"readDicomElementExplicit",function(){return X}),c.d(s,"readDicomElementImplicit",function(){return O}),c.d(s,"readEncapsulatedImageFrame",function(){return Fe}),c.d(s,"readEncapsulatedPixelData",function(){return Xe}),c.d(s,"readEncapsulatedPixelDataFromFragments",function(){return re}),c.d(s,"readPart10Header",function(){return M}),c.d(s,"readSequenceItemsExplicit",function(){return F}),c.d(s,"readSequenceItemsImplicit",function(){return H}),c.d(s,"readSequenceItem",function(){return L}),c.d(s,"readTag",function(){return C});var l={AE:!0,AS:!0,AT:!1,CS:!0,DA:!0,DS:!0,DT:!0,FL:!1,FD:!1,IS:!0,LO:!0,LT:!0,OB:!1,OD:!1,OF:!1,OW:!1,PN:!0,SH:!0,SL:!1,SQ:!1,SS:!1,ST:!0,TM:!0,UI:!0,UL:!1,UN:void 0,UR:!0,US:!1,UT:!0},f=function(se){return l[se]},u=function(se){if(se=parseInt(se[4],16),isNaN(se))throw"dicomParser.isPrivateTag: cannot parse last character of group";return se%2==1},d=function(se){if(se!==void 0)return se=se.split("^"),{familyName:se[0],givenName:se[1],middleName:se[2],prefix:se[3],suffix:se[4]}};function h(se,ue){if(2<=se.length){var Pe=parseInt(se.substring(0,2),10),pe=4<=se.length?parseInt(se.substring(2,4),10):void 0,Ee=6<=se.length?parseInt(se.substring(4,6),10):void 0,Qe=8<=se.length?se.substring(7,13):void 0,Qe=Qe?parseInt(Qe,10)*Math.pow(10,6-Qe.length):void 0;if(ue&&(isNaN(Pe)||pe!==void 0&&isNaN(pe)||Ee!==void 0&&isNaN(Ee)||Qe!==void 0&&isNaN(Qe)||Pe<0||23<Pe||pe&&(pe<0||59<pe)||Ee&&(Ee<0||59<Ee)||Qe&&(Qe<0||999999<Qe)))throw"invalid TM '".concat(se,"'");return{hours:Pe,minutes:pe,seconds:Ee,fractionalSeconds:Qe}}if(ue)throw"invalid TM '".concat(se,"'")}function g(se,ue,Pe){return!isNaN(Pe)&&0<ue&&ue<=12&&0<se&&se<=function(pe,Ee){switch(pe){case 2:return Ee%4==0&&Ee%100||Ee%400==0?29:28;case 9:case 4:case 6:case 11:return 30;default:return 31}}(ue,Pe)}function p(se,ue){if(se&&se.length===8){var Pe=parseInt(se.substring(0,4),10),pe=parseInt(se.substring(4,6),10),Ee=parseInt(se.substring(6,8),10);if(ue&&g(Ee,pe,Pe)!==!0)throw"invalid DA '".concat(se,"'");return{year:Pe,month:pe,day:Ee}}if(ue)throw"invalid DA '".concat(se,"'")}function v(se,ue){if(se===void 0||ue===void 0)throw"dicomParser.explicitElementToString: missing required parameters";if(ue.vr===void 0)throw"dicomParser.explicitElementToString: cannot convert implicit element to string";var Pe,pe=ue.vr,Ee=ue.tag;function Qe(ft,pt){for(var dt="",Ue=0;Ue<ft;Ue++)Ue!==0&&(dt+="/"),dt+=pt.call(se,Ee,Ue).toString();return dt}if(f(pe)===!0)Pe=se.string(Ee);else{if(pe==="AT"){var fe=se.uint32(Ee);return fe===void 0?void 0:"x".concat((fe=fe<0?4294967295+fe+1:fe).toString(16).toUpperCase())}pe==="US"?Pe=Qe(ue.length/2,se.uint16):pe==="SS"?Pe=Qe(ue.length/2,se.int16):pe==="UL"?Pe=Qe(ue.length/4,se.uint32):pe==="SL"?Pe=Qe(ue.length/4,se.int32):pe==="FD"?Pe=Qe(ue.length/8,se.double):pe==="FL"&&(Pe=Qe(ue.length/4,se.float))}return Pe}function y(se,ue){if(se===void 0)throw"dicomParser.explicitDataSetToJS: missing required parameter dataSet";ue=ue||{omitPrivateAttibutes:!0,maxElementLength:128};var Pe,pe={};for(Pe in se.elements){var Ee=se.elements[Pe];if(ue.omitPrivateAttibutes!==!0||!u(Pe))if(Ee.items){for(var Qe=[],fe=0;fe<Ee.items.length;fe++)Qe.push(y(Ee.items[fe].dataSet,ue));pe[Pe]=Qe}else{var ft=void 0;Ee.length<ue.maxElementLength&&(ft=v(se,Ee)),pe[Pe]=ft!==void 0?ft:{dataOffset:Ee.dataOffset,length:Ee.length}}}return pe}function m(se,ue){return se.byteArray[ue]===255&&se.byteArray[ue+1]===217}function w(se,ue,Pe){for(var pe,Ee,Qe=Pe;Qe<ue.fragments.length;Qe++)if(pe=se,Ee=Qe,Ee=ue.fragments[Ee],!(!m(pe,Ee.position+Ee.length-2)&&!m(pe,Ee.position+Ee.length-3)))return Qe}function x(se,ue,Pe){if(se===void 0)throw"dicomParser.createJPEGBasicOffsetTable: missing required parameter dataSet";if(ue===void 0)throw"dicomParser.createJPEGBasicOffsetTable: missing required parameter pixelDataElement";if(ue.tag!=="x7fe00010")throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010'";if(ue.encapsulatedPixelData!==!0||ue.hadUndefinedLength!==!0||ue.basicOffsetTable===void 0||ue.fragments===void 0||ue.fragments.length<=0)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(Pe&&Pe.length<=0)throw"dicomParser.createJPEGBasicOffsetTable: parameter 'fragments' must not be zero length";Pe=Pe||ue.fragments;for(var pe=[],Ee=0;;){pe.push(ue.fragments[Ee].offset);var Qe=w(se,ue,Ee);if(Qe===void 0||Qe===ue.fragments.length-1)return pe;Ee=Qe+1}}function C(Pe){if(Pe===void 0)throw"dicomParser.readTag: missing required parameter 'byteStream'";var ue=256*Pe.readUint16()*256,Pe=Pe.readUint16();return"x".concat("00000000".concat((ue+Pe).toString(16)).substr(-8))}function S(se,ue,Pe){if(se===void 0)throw"dicomParser.findEndOfEncapsulatedElement: missing required parameter 'byteStream'";if(ue===void 0)throw"dicomParser.findEndOfEncapsulatedElement: missing required parameter 'element'";if(ue.encapsulatedPixelData=!0,ue.basicOffsetTable=[],ue.fragments=[],C(se)!=="xfffee000")throw"dicomParser.findEndOfEncapsulatedElement: basic offset table not found";for(var pe=se.readUint32()/4,Ee=0;Ee<pe;Ee++){var Qe=se.readUint32();ue.basicOffsetTable.push(Qe)}for(var fe=se.position;se.position<se.byteArray.length;){var ft=C(se),pt=se.readUint32();if(ft==="xfffee0dd")return se.seek(pt),void(ue.length=se.position-ue.dataOffset);if(ft!=="xfffee000")return Pe&&Pe.push("unexpected tag ".concat(ft," while searching for end of pixel data element with undefined length")),pt>se.byteArray.length-se.position&&(pt=se.byteArray.length-se.position),ue.fragments.push({offset:se.position-fe-8,position:se.position,length:pt}),se.seek(pt),void(ue.length=se.position-ue.dataOffset);ue.fragments.push({offset:se.position-fe-8,position:se.position,length:pt}),se.seek(pt)}Pe&&Pe.push("pixel data element ".concat(ue.tag," missing sequence delimiter tag xfffee0dd"))}function T(se,ue){if(se===void 0)throw"dicomParser.findAndSetUNElementLength: missing required parameter 'byteStream'";for(var Pe=se.byteArray.length-8;se.position<=Pe;)if(se.readUint16()===65534){var pe=se.readUint16();if(pe===57565)return se.readUint32()!==0&&se.warnings("encountered non zero length following item delimiter at position ".concat(se.position-4," while reading element of undefined length with tag ").concat(ue.tag)),void(ue.length=se.position-ue.dataOffset)}ue.length=se.byteArray.length-ue.dataOffset,se.seek(se.byteArray.length-se.position)}function _(se,ue,Pe){if(Pe<0)throw"dicomParser.readFixedString - length cannot be less than 0";if(ue+Pe>se.length)throw"dicomParser.readFixedString: attempt to read past end of buffer";for(var pe,Ee="",Qe=0;Qe<Pe;Qe++){if((pe=se[ue+Qe])===0)return ue+=Pe,Ee;Ee+=String.fromCharCode(pe)}return Ee}function E(se,ue){for(var Pe=0;Pe<ue.length;Pe++){var pe=ue[Pe];pe.enumerable=pe.enumerable||!1,pe.configurable=!0,"value"in pe&&(pe.writable=!0),Object.defineProperty(se,pe.key,pe)}}function b(se,ue){return se.parser!==void 0?se.parser:ue}var D=function(){function se(pe,Ee,Qe){(function(fe,ft){if(!(fe instanceof ft))throw new TypeError("Cannot call a class as a function")})(this,se),this.byteArrayParser=pe,this.byteArray=Ee,this.elements=Qe}var ue,Pe;return ue=se,(Pe=[{key:"uint16",value:function(pe,Ee){if(pe=this.elements[pe],Ee=Ee!==void 0?Ee:0,pe&&pe.length!==0)return b(pe,this.byteArrayParser).readUint16(this.byteArray,pe.dataOffset+2*Ee)}},{key:"int16",value:function(pe,Ee){if(pe=this.elements[pe],Ee=Ee!==void 0?Ee:0,pe&&pe.length!==0)return b(pe,this.byteArrayParser).readInt16(this.byteArray,pe.dataOffset+2*Ee)}},{key:"uint32",value:function(pe,Ee){if(pe=this.elements[pe],Ee=Ee!==void 0?Ee:0,pe&&pe.length!==0)return b(pe,this.byteArrayParser).readUint32(this.byteArray,pe.dataOffset+4*Ee)}},{key:"int32",value:function(pe,Ee){if(pe=this.elements[pe],Ee=Ee!==void 0?Ee:0,pe&&pe.length!==0)return b(pe,this.byteArrayParser).readInt32(this.byteArray,pe.dataOffset+4*Ee)}},{key:"float",value:function(pe,Ee){if(pe=this.elements[pe],Ee=Ee!==void 0?Ee:0,pe&&pe.length!==0)return b(pe,this.byteArrayParser).readFloat(this.byteArray,pe.dataOffset+4*Ee)}},{key:"double",value:function(pe,Ee){if(pe=this.elements[pe],Ee=Ee!==void 0?Ee:0,pe&&pe.length!==0)return b(pe,this.byteArrayParser).readDouble(this.byteArray,pe.dataOffset+8*Ee)}},{key:"numStringValues",value:function(pe){if(pe=this.elements[pe],pe&&0<pe.length)return pe=_(this.byteArray,pe.dataOffset,pe.length).match(/\\/g),pe===null?1:pe.length+1}},{key:"string",value:function(pe,Ee){if(pe=this.elements[pe],pe&&pe.Value)return pe.Value;if(pe&&0<pe.length)return pe=_(this.byteArray,pe.dataOffset,pe.length),0<=Ee?pe.split("\\")[Ee].trim():pe.trim()}},{key:"text",value:function(pe,Ee){if(pe=this.elements[pe],pe&&0<pe.length)return pe=_(this.byteArray,pe.dataOffset,pe.length),0<=Ee?pe.split("\\")[Ee].replace(/ +$/,""):pe.replace(/ +$/,"")}},{key:"floatString",value:function(pe,Ee){var Qe=this.elements[pe];if(Qe&&0<Qe.length&&(Ee=this.string(pe,Ee=Ee!==void 0?Ee:0),Ee!==void 0))return parseFloat(Ee)}},{key:"intString",value:function(pe,Ee){var Qe=this.elements[pe];if(Qe&&0<Qe.length&&(Ee=this.string(pe,Ee=Ee!==void 0?Ee:0),Ee!==void 0))return parseInt(Ee)}},{key:"attributeTag",value:function(pe){var Ee=this.elements[pe];if(Ee&&Ee.length===4){var Qe=b(Ee,this.byteArrayParser).readUint16,pe=this.byteArray,Ee=Ee.dataOffset;return"x".concat("00000000".concat((256*Qe(pe,Ee)*256+Qe(pe,Ee+2)).toString(16)).substr(-8))}}}])&&E(ue.prototype,Pe),Object.defineProperty(ue,"prototype",{writable:!1}),se}();function I(se,ue){if(se===void 0)throw"dicomParser.readDicomElementImplicit: missing required parameter 'byteStream'";for(var Pe=se.byteArray.length-8;se.position<=Pe;)if(se.readUint16()===65534){var pe=se.readUint16();if(pe===57357)return se.readUint32()!==0&&se.warnings("encountered non zero length following item delimiter at position ".concat(se.position-4," while reading element of undefined length with tag ").concat(ue.tag)),void(ue.length=se.position-ue.dataOffset)}ue.length=se.byteArray.length-ue.dataOffset,se.seek(se.byteArray.length-se.position)}var P=function(se,ue){return se.vr!==void 0?se.vr==="SQ":ue.position+4<=ue.byteArray.length?(se=C(ue),ue.seek(-4),se==="xfffee000"||se==="xfffee0dd"):(ue.warnings.push("eof encountered before finding sequence item tag or sequence delimiter tag in peeking to determine VR"),!1)};function O(se,ue,Pe){if(se===void 0)throw"dicomParser.readDicomElementImplicit: missing required parameter 'byteStream'";var pe=C(se),pe={tag:pe,vr:Pe!==void 0?Pe(pe):void 0,length:se.readUint32(),dataOffset:se.position};return pe.length===4294967295&&(pe.hadUndefinedLength=!0),pe.tag===ue||(!P(pe,se)||u(pe.tag)&&!pe.hadUndefinedLength?pe.hadUndefinedLength?I(se,pe):se.seek(pe.length):(H(se,pe,Pe),u(pe.tag)&&(pe.items=void 0))),pe}function L(se){if(se===void 0)throw"dicomParser.readSequenceItem: missing required parameter 'byteStream'";var ue={tag:C(se),length:se.readUint32(),dataOffset:se.position};if(ue.tag!=="xfffee000")throw"dicomParser.readSequenceItem: item tag (FFFE,E000) not found at offset ".concat(se.position);return ue}function B(se,ue){var Pe=L(se);return Pe.length===4294967295?(Pe.hadUndefinedLength=!0,Pe.dataSet=function(pe,Ee){for(var Qe={};pe.position<pe.byteArray.length;){var fe=O(pe,void 0,Ee);if((Qe[fe.tag]=fe).tag==="xfffee00d")return new D(pe.byteArrayParser,pe.byteArray,Qe)}return pe.warnings.push("eof encountered before finding sequence item delimiter in sequence item of undefined length"),new D(pe.byteArrayParser,pe.byteArray,Qe)}(se,ue),Pe.length=se.position-Pe.dataOffset):(Pe.dataSet=new D(se.byteArrayParser,se.byteArray,{}),ce(Pe.dataSet,se,se.position+Pe.length,{vrCallback:ue})),Pe}function H(se,ue,Pe){if(se===void 0)throw"dicomParser.readSequenceItemsImplicit: missing required parameter 'byteStream'";if(ue===void 0)throw"dicomParser.readSequenceItemsImplicit: missing required parameter 'element'";ue.items=[],(ue.length===4294967295?function(pe,Ee,Qe){for(;pe.position+4<=pe.byteArray.length;){var fe=C(pe);if(pe.seek(-4),fe==="xfffee0dd")return Ee.length=pe.position-Ee.dataOffset,pe.seek(8);fe=B(pe,Qe),Ee.items.push(fe)}pe.warnings.push("eof encountered before finding sequence delimiter in sequence of undefined length"),Ee.length=pe.byteArray.length-Ee.dataOffset}:function(pe,Ee,Qe){for(var fe=Ee.dataOffset+Ee.length;pe.position<fe;){var ft=B(pe,Qe);Ee.items.push(ft)}})(se,ue,Pe)}function A(se,ue){var Pe=L(se);return Pe.length===4294967295?(Pe.hadUndefinedLength=!0,Pe.dataSet=function(pe,Ee){for(var Qe={};pe.position<pe.byteArray.length;){var fe=X(pe,Ee);if((Qe[fe.tag]=fe).tag==="xfffee00d")return new D(pe.byteArrayParser,pe.byteArray,Qe)}return Ee.push("eof encountered before finding item delimiter tag while reading sequence item of undefined length"),new D(pe.byteArrayParser,pe.byteArray,Qe)}(se,ue),Pe.length=se.position-Pe.dataOffset):(Pe.dataSet=new D(se.byteArrayParser,se.byteArray,{}),ee(Pe.dataSet,se,se.position+Pe.length)),Pe}function F(se,ue,Pe){if(se===void 0)throw"dicomParser.readSequenceItemsExplicit: missing required parameter 'byteStream'";if(ue===void 0)throw"dicomParser.readSequenceItemsExplicit: missing required parameter 'element'";ue.items=[],(ue.length===4294967295?function(pe,Ee,Qe){for(;pe.position+4<=pe.byteArray.length;){var fe=C(pe);if(pe.seek(-4),fe==="xfffee0dd")return Ee.length=pe.position-Ee.dataOffset,pe.seek(8);fe=A(pe,Qe),Ee.items.push(fe)}Qe.push("eof encountered before finding sequence delimitation tag while reading sequence of undefined length"),Ee.length=pe.position-Ee.dataOffset}:function(pe,Ee,Qe){for(var fe=Ee.dataOffset+Ee.length;pe.position<fe;){var ft=A(pe,Qe);Ee.items.push(ft)}})(se,ue,Pe)}var G=function(se){return se==="OB"||se==="OD"||se==="OL"||se==="OW"||se==="SQ"||se==="OF"||se==="UC"||se==="UR"||se==="UT"||se==="UN"?4:2};function X(se,ue,Pe){if(se===void 0)throw"dicomParser.readDicomElementExplicit: missing required parameter 'byteStream'";var pe={tag:C(se),vr:se.readFixedString(2)};return G(pe.vr)===2?pe.length=se.readUint16():(se.seek(2),pe.length=se.readUint32()),pe.dataOffset=se.position,pe.length===4294967295&&(pe.hadUndefinedLength=!0),pe.tag===Pe||(pe.vr==="SQ"?F(se,pe,ue):pe.length===4294967295?pe.tag==="x7fe00010"?S(se,pe,ue):(pe.vr==="UN"?H:I)(se,pe):se.seek(pe.length)),pe}function ee(se,ue,Pe){var pe=3<arguments.length&&arguments[3]!==void 0?arguments[3]:{};if(Pe=Pe===void 0?ue.byteArray.length:Pe,ue===void 0)throw"dicomParser.parseDicomDataSetExplicit: missing required parameter 'byteStream'";if(Pe<ue.position||Pe>ue.byteArray.length)throw"dicomParser.parseDicomDataSetExplicit: invalid value for parameter 'maxP osition'";for(var Ee=se.elements;ue.position<Pe;){var Qe=X(ue,se.warnings,pe.untilTag);if((Ee[Qe.tag]=Qe).tag===pe.untilTag)return}if(ue.position>Pe)throw"dicomParser:parseDicomDataSetExplicit: buffer overrun"}function ce(se,ue,Pe){var pe=3<arguments.length&&arguments[3]!==void 0?arguments[3]:{};if(Pe=Pe===void 0?se.byteArray.length:Pe,ue===void 0)throw"dicomParser.parseDicomDataSetImplicit: missing required parameter 'byteStream'";if(Pe<ue.position||Pe>ue.byteArray.length)throw"dicomParser.parseDicomDataSetImplicit: invalid value for parameter 'maxPosition'";for(var Ee=se.elements;ue.position<Pe;){var Qe=O(ue,pe.untilTag,pe.vrCallback);if((Ee[Qe.tag]=Qe).tag===pe.untilTag)return}}function Se(se,ue){if(typeof Buffer<"u"&&se instanceof Buffer)return Buffer.alloc(ue);if(se instanceof Uint8Array)return new Uint8Array(ue);throw"dicomParser.alloc: unknown type for byteArray"}var we="1.8.12",_e={readUint16:function(se,ue){if(ue<0)throw"bigEndianByteArrayParser.readUint16: position cannot be less than 0";if(ue+2>se.length)throw"bigEndianByteArrayParser.readUint16: attempt to read past end of buffer";return(se[ue]<<8)+se[ue+1]},readInt16:function(se,ue){if(ue<0)throw"bigEndianByteArrayParser.readInt16: position cannot be less than 0";if(ue+2>se.length)throw"bigEndianByteArrayParser.readInt16: attempt to read past end of buffer";return ue=(se[ue]<<8)+se[ue+1],ue=32768&ue?ue-65535-1:ue},readUint32:function(se,ue){if(ue<0)throw"bigEndianByteArrayParser.readUint32: position cannot be less than 0";if(ue+4>se.length)throw"bigEndianByteArrayParser.readUint32: attempt to read past end of buffer";return 256*(256*(256*se[ue]+se[ue+1])+se[ue+2])+se[ue+3]},readInt32:function(se,ue){if(ue<0)throw"bigEndianByteArrayParser.readInt32: position cannot be less than 0";if(ue+4>se.length)throw"bigEndianByteArrayParser.readInt32: attempt to read past end of buffer";return(se[ue]<<24)+(se[ue+1]<<16)+(se[ue+2]<<8)+se[ue+3]},readFloat:function(se,ue){if(ue<0)throw"bigEndianByteArrayParser.readFloat: position cannot be less than 0";if(ue+4>se.length)throw"bigEndianByteArrayParser.readFloat: attempt to read past end of buffer";var Pe=new Uint8Array(4);return Pe[3]=se[ue],Pe[2]=se[ue+1],Pe[1]=se[ue+2],Pe[0]=se[ue+3],new Float32Array(Pe.buffer)[0]},readDouble:function(se,ue){if(ue<0)throw"bigEndianByteArrayParser.readDouble: position cannot be less than 0";if(ue+8>se.length)throw"bigEndianByteArrayParser.readDouble: attempt to read past end of buffer";var Pe=new Uint8Array(8);return Pe[7]=se[ue],Pe[6]=se[ue+1],Pe[5]=se[ue+2],Pe[4]=se[ue+3],Pe[3]=se[ue+4],Pe[2]=se[ue+5],Pe[1]=se[ue+6],Pe[0]=se[ue+7],new Float64Array(Pe.buffer)[0]}};function Ve(se,ue,Pe){if(typeof Buffer<"u"&&se instanceof Buffer)return se.slice(ue,ue+Pe);if(se instanceof Uint8Array)return new Uint8Array(se.buffer,se.byteOffset+ue,Pe);throw"dicomParser.from: unknown type for byteArray"}function Ge(se,ue){for(var Pe=0;Pe<ue.length;Pe++){var pe=ue[Pe];pe.enumerable=pe.enumerable||!1,pe.configurable=!0,"value"in pe&&(pe.writable=!0),Object.defineProperty(se,pe.key,pe)}}var Ne=function(){function se(pe,Ee,Qe){if(function(fe,ft){if(!(fe instanceof ft))throw new TypeError("Cannot call a class as a function")}(this,se),pe===void 0)throw"dicomParser.ByteStream: missing required parameter 'byteArrayParser'";if(Ee===void 0)throw"dicomParser.ByteStream: missing required parameter 'byteArray'";if(!(Ee instanceof Uint8Array)&&(typeof Buffer>"u"||!(Ee instanceof Buffer)))throw"dicomParser.ByteStream: parameter byteArray is not of type Uint8Array or Buffer";if(Qe<0)throw"dicomParser.ByteStream: parameter 'position' cannot be less than 0";if(Qe>=Ee.length)throw"dicomParser.ByteStream: parameter 'position' cannot be greater than or equal to 'byteArray' length";this.byteArrayParser=pe,this.byteArray=Ee,this.position=Qe||0,this.warnings=[]}var ue,Pe;return ue=se,(Pe=[{key:"seek",value:function(pe){if(this.position+pe<0)throw"dicomParser.ByteStream.prototype.seek: cannot seek to position < 0";this.position+=pe}},{key:"readByteStream",value:function(pe){if(this.position+pe>this.byteArray.length)throw"dicomParser.ByteStream.prototype.readByteStream: readByteStream - buffer overread";var Ee=Ve(this.byteArray,this.position,pe);return this.position+=pe,new se(this.byteArrayParser,Ee)}},{key:"getSize",value:function(){return this.byteArray.length}},{key:"readUint16",value:function(){var pe=this.byteArrayParser.readUint16(this.byteArray,this.position);return this.position+=2,pe}},{key:"readUint32",value:function(){var pe=this.byteArrayParser.readUint32(this.byteArray,this.position);return this.position+=4,pe}},{key:"readFixedString",value:function(pe){var Ee=_(this.byteArray,this.position,pe);return this.position+=pe,Ee}}])&&Ge(ue.prototype,Pe),Object.defineProperty(ue,"prototype",{writable:!1}),se}(),j={readUint16:function(se,ue){if(ue<0)throw"littleEndianByteArrayParser.readUint16: position cannot be less than 0";if(ue+2>se.length)throw"littleEndianByteArrayParser.readUint16: attempt to read past end of buffer";return se[ue]+256*se[ue+1]},readInt16:function(se,ue){if(ue<0)throw"littleEndianByteArrayParser.readInt16: position cannot be less than 0";if(ue+2>se.length)throw"littleEndianByteArrayParser.readInt16: attempt to read past end of buffer";return ue=se[ue]+(se[ue+1]<<8),ue=32768&ue?ue-65535-1:ue},readUint32:function(se,ue){if(ue<0)throw"littleEndianByteArrayParser.readUint32: position cannot be less than 0";if(ue+4>se.length)throw"littleEndianByteArrayParser.readUint32: attempt to read past end of buffer";return se[ue]+256*se[ue+1]+256*se[ue+2]*256+256*se[ue+3]*256*256},readInt32:function(se,ue){if(ue<0)throw"littleEndianByteArrayParser.readInt32: position cannot be less than 0";if(ue+4>se.length)throw"littleEndianByteArrayParser.readInt32: attempt to read past end of buffer";return se[ue]+(se[ue+1]<<8)+(se[ue+2]<<16)+(se[ue+3]<<24)},readFloat:function(se,ue){if(ue<0)throw"littleEndianByteArrayParser.readFloat: position cannot be less than 0";if(ue+4>se.length)throw"littleEndianByteArrayParser.readFloat: attempt to read past end of buffer";var Pe=new Uint8Array(4);return Pe[0]=se[ue],Pe[1]=se[ue+1],Pe[2]=se[ue+2],Pe[3]=se[ue+3],new Float32Array(Pe.buffer)[0]},readDouble:function(se,ue){if(ue<0)throw"littleEndianByteArrayParser.readDouble: position cannot be less than 0";if(ue+8>se.length)throw"littleEndianByteArrayParser.readDouble: attempt to read past end of buffer";var Pe=new Uint8Array(8);return Pe[0]=se[ue],Pe[1]=se[ue+1],Pe[2]=se[ue+2],Pe[3]=se[ue+3],Pe[4]=se[ue+4],Pe[5]=se[ue+5],Pe[6]=se[ue+6],Pe[7]=se[ue+7],new Float64Array(Pe.buffer)[0]}};function M(se){var ue=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{};if(se===void 0)throw"dicomParser.readPart10Header: missing required parameter 'byteArray'";var Pe=ue.TransferSyntaxUID,pe=new Ne(j,se);return function(){var Ee=function(){if(pe.getSize()<=132&&Pe)return!1;if(pe.seek(128),pe.readFixedString(4)==="DICM")return!0;if(!(ue||{}).TransferSyntaxUID)throw"dicomParser.readPart10Header: DICM prefix not found at location 132 - this is not a valid DICOM P10 file.";return pe.seek(0),!1}(),Qe=[],fe={};if(!Ee)return pe.position=0,{elements:{x00020010:{tag:"x00020010",vr:"UI",Value:Pe}},warnings:Qe};for(;pe.position<pe.byteArray.length;){var ft=pe.position,pt=X(pe,Qe);if("x0002ffff"<pt.tag){pe.position=ft;break}pt.parser=j,fe[pt.tag]=pt}return(Ee=new D(pe.byteArrayParser,pe.byteArray,fe)).warnings=pe.warnings,Ee.position=pe.position,Ee}()}var q="1.2.840.10008.1.2.2";function K(se){var ue=1<arguments.length&&arguments[1]!==void 0?arguments[1]:{};if(se===void 0)throw new Error("dicomParser.parseDicom: missing required parameter 'byteArray'");var Pe,pe=function(Qe){if(Qe.elements.x00020010===void 0)throw new Error("dicomParser.parseDicom: missing required meta header attribute 0002,0010");return Qe=Qe.elements.x00020010,Qe&&Qe.Value||_(se,Qe.dataOffset,Qe.length)};function Ee(pt){var ft=pe(pt),fe=ft!=="1.2.840.10008.1.2",ft=function(dt,Ue){var nt=Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]";if(dt!=="1.2.840.10008.1.2.1.99")return new Ne(dt===q?_e:j,se,Ue);if(ue&&ue.inflater)return dt=ue.inflater(se,Ue),new Ne(j,dt,0);if(nt==!0){var at=c(0),ot=Ve(se,Ue,se.length-Ue),at=at.inflateRawSync(ot),ot=Se(se,at.length+Ue);return se.copy(ot,0,0,Ue),at.copy(ot,Ue),new Ne(j,ot,0)}if(typeof pako>"u")throw"dicomParser.parseDicom: no inflater available to handle deflate transfer syntax";return at=se.slice(Ue),ot=pako.inflateRaw(at),(at=Se(se,ot.length+Ue)).set(se.slice(0,Ue),0),at.set(ot,Ue),new Ne(j,at,0)}(ft,pt.position),pt=new D(ft.byteArrayParser,ft.byteArray,{});pt.warnings=ft.warnings;try{(fe?ee:ce)(pt,ft,ft.byteArray.length,ue)}catch(dt){throw{exception:dt,dataSet:pt}}return pt}return function(Qe,fe){for(var ft in Qe.elements)Qe.elements.hasOwnProperty(ft)&&(fe.elements[ft]=Qe.elements[ft]);return Qe.warnings!==void 0&&(fe.warnings=Qe.warnings.concat(fe.warnings)),fe}(Pe=M(se,ue),Ee(Pe))}var J=function(se,ue,Pe){for(var pe=0,Ee=ue;Ee<ue+Pe;Ee++)pe+=se[Ee].length;return pe};function re(se,fe,Pe,pe,Ee){if(Ee=Ee||fe.fragments,se===void 0)throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'dataSet'";if(fe===void 0)throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'pixelDataElement'";if(Pe===void 0)throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'startFragmentIndex'";if((pe=pe||1)===void 0)throw"dicomParser.readEncapsulatedPixelDataFromFragments: missing required parameter 'numFragments'";if(fe.tag!=="x7fe00010")throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010";if(fe.encapsulatedPixelData!==!0||fe.hadUndefinedLength!==!0||fe.basicOffsetTable===void 0||fe.fragments===void 0||fe.fragments.length<=0)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(Pe<0)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragmentIndex' must be >= 0";if(Pe>=fe.fragments.length)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragmentIndex' must be < number of fragments";if(pe<1)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'numFragments' must be > 0";if(Pe+pe>fe.fragments.length)throw"dicomParser.readEncapsulatedPixelDataFromFragments: parameter 'startFragment' + 'numFragments' < number of fragments";var Qe=new Ne(se.byteArrayParser,se.byteArray,fe.dataOffset),fe=L(Qe);if(fe.tag!=="xfffee000")throw"dicomParser.readEncapsulatedPixelData: missing basic offset table xfffee000";Qe.seek(fe.length);var ft=Qe.position;if(pe===1)return Ve(Qe.byteArray,ft+Ee[Pe].offset+8,Ee[Pe].length);for(var fe=J(Ee,Pe,pe),pt=Se(Qe.byteArray,fe),dt=0,Ue=Pe;Ue<Pe+pe;Ue++)for(var nt=ft+Ee[Ue].offset+8,at=0;at<Ee[Ue].length;at++)pt[dt++]=Qe.byteArray[nt++];return pt}var ie=function(se,ue){for(var Pe=0;Pe<se.length;Pe++)if(se[Pe].offset===ue)return Pe},Re=function(se,ue,Pe,pe){if(se===ue.length-1)return Pe.length-pe;for(var Ee=ue[se+1],Qe=pe+1;Qe<Pe.length;Qe++)if(Pe[Qe].offset===Ee)return Qe-pe;throw"dicomParser.calculateNumberOfFragmentsForFrame: could not find fragment with offset matching basic offset table"};function Fe(se,ue,Pe,pe,Ee){if(pe=pe||ue.basicOffsetTable,Ee=Ee||ue.fragments,se===void 0)throw"dicomParser.readEncapsulatedImageFrame: missing required parameter 'dataSet'";if(ue===void 0)throw"dicomParser.readEncapsulatedImageFrame: missing required parameter 'pixelDataElement'";if(Pe===void 0)throw"dicomParser.readEncapsulatedImageFrame: missing required parameter 'frameIndex'";if(pe===void 0)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' does not have basicOffsetTable";if(ue.tag!=="x7fe00010")throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to non pixel data tag (expected tag = x7fe00010)";if(ue.encapsulatedPixelData!==!0)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have encapsulated pixel data";if(ue.hadUndefinedLength!==!0)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have undefined length";if(ue.fragments===void 0)throw"dicomParser.readEncapsulatedImageFrame: parameter 'pixelDataElement' refers to pixel data element that does not have fragments";if(pe.length===0)throw"dicomParser.readEncapsulatedImageFrame: basicOffsetTable has zero entries";if(Pe<0)throw"dicomParser.readEncapsulatedImageFrame: parameter 'frameIndex' must be >= 0";if(Pe>=pe.length)throw"dicomParser.readEncapsulatedImageFrame: parameter 'frameIndex' must be < basicOffsetTable.length";var Qe=pe[Pe],Qe=ie(Ee,Qe);if(Qe===void 0)throw"dicomParser.readEncapsulatedImageFrame: unable to find fragment that matches basic offset table entry";return re(se,ue,Qe,Re(Pe,pe,Ee,Qe),Ee)}var je=!1;function Xe(se,ue,Pe){if(je||(je=!0,console&&console.log&&console.log("WARNING: dicomParser.readEncapsulatedPixelData() has been deprecated")),se===void 0)throw"dicomParser.readEncapsulatedPixelData: missing required parameter 'dataSet'";if(ue===void 0)throw"dicomParser.readEncapsulatedPixelData: missing required parameter 'element'";if(Pe===void 0)throw"dicomParser.readEncapsulatedPixelData: missing required parameter 'frame'";if(ue.tag!=="x7fe00010")throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to non pixel data tag (expected tag = x7fe00010)";if(ue.encapsulatedPixelData!==!0||ue.hadUndefinedLength!==!0||ue.basicOffsetTable===void 0||ue.fragments===void 0)throw"dicomParser.readEncapsulatedPixelData: parameter 'element' refers to pixel data element that does not have encapsulated pixel data";if(Pe<0)throw"dicomParser.readEncapsulatedPixelData: parameter 'frame' must be >= 0";return ue.basicOffsetTable.length!==0?Fe(se,ue,Pe):re(se,ue,0,ue.fragments.length)}s.default={isStringVr:f,isPrivateTag:u,parsePN:d,parseTM:h,parseDA:p,explicitElementToString:v,explicitDataSetToJS:y,createJPEGBasicOffsetTable:x,parseDicomDataSetExplicit:ee,parseDicomDataSetImplicit:ce,readFixedString:_,alloc:Se,version:we,bigEndianByteArrayParser:_e,ByteStream:Ne,sharedCopy:Ve,DataSet:D,findAndSetUNElementLength:T,findEndOfEncapsulatedElement:S,findItemDelimitationItemAndSetElementLength:I,littleEndianByteArrayParser:j,parseDicom:K,readDicomElementExplicit:X,readDicomElementImplicit:O,readEncapsulatedImageFrame:Fe,readEncapsulatedPixelData:Xe,readEncapsulatedPixelDataFromFragments:re,readPart10Header:M,readSequenceItemsExplicit:F,readSequenceItemsImplicit:H,readSequenceItem:L,readTag:C,LEI:"1.2.840.10008.1.2",LEE:"1.2.840.10008.1.2.1"}}],o={},n.m=i,n.c=o,n.d=function(a,s,c){n.o(a,s)||Object.defineProperty(a,s,{enumerable:!0,get:c})},n.r=function(a){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})},n.t=function(a,s){if(1&s&&(a=n(a)),8&s||4&s&&typeof a=="object"&&a&&a.__esModule)return a;var c=Object.create(null);if(n.r(c),Object.defineProperty(c,"default",{enumerable:!0,value:a}),2&s&&typeof a!="string")for(var l in a)n.d(c,l,(function(f){return a[f]}).bind(null,l));return c},n.n=function(a){var s=a&&a.__esModule?function(){return a.default}:function(){return a};return n.d(s,"a",s),s},n.o=function(a,s){return Object.prototype.hasOwnProperty.call(a,s)},n.p="",n(n.s=1);function n(a){if(o[a])return o[a].exports;var s=o[a]={i:a,l:!1,exports:{}};return i[a].call(s.exports,s,s.exports,n),s.l=!0,s.exports}var i,o})})(Nz);var lr=Nz.exports;function Pm(t){const e=t.indexOf(":");let r=t.substring(e+1);const n=r.indexOf("frame=");let i;if(n!==-1){const s=r.substring(n+6);i=parseInt(s,10),r=r.substring(0,n-1)}const o=t.substring(0,e),a=i!==void 0?i-1:void 0;return{scheme:o,url:r,frame:i,pixelDataFrame:a}}let OT={open(t,e){t.open("get",e,!0)},beforeSend(){},beforeProcessing(t){return Promise.resolve(t.response)},imageCreated(){},strict:!1};function kz(t){OT=Object.assign(OT,t)}function Rm(){return OT}function rx(t,e,r={},n={}){const i=Rm(),o=c=>{if(typeof i.errorInterceptor=="function"){const l=new Error("request failed");l.request=c,l.response=c.response,l.status=c.status,i.errorInterceptor(l)}},a=new XMLHttpRequest,s=new Promise((c,l)=>{i.open(a,t,r,n);const f=i.beforeSend(a,e,r,n);a.responseType="arraybuffer";const u=Object.assign({},r,f);Object.keys(u).forEach(function(d){u[d]!==null&&(d==="Accept"&&t.indexOf("accept=")!==-1||a.setRequestHeader(d,u[d]))}),n.deferred={resolve:c,reject:l},n.url=t,n.imageId=e,a.onloadstart=function(d){i.onloadstart&&i.onloadstart(d,n),it(Ze,"cornerstoneimageloadstart",{url:t,imageId:e})},a.onloadend=function(d){i.onloadend&&i.onloadend(d,n),it(Ze,"cornerstoneimageloadend",{url:t,imageId:e})},a.onreadystatechange=function(d){i.onreadystatechange&&i.onreadystatechange(d,n),a.readyState===4&&(a.status===200||a.status===206?i.beforeProcessing(a).then(c).catch(()=>{o(a),l(a)}):(o(a),l(a)))},a.onprogress=function(d){const h=d.loaded;let g,p;d.lengthComputable&&(g=d.total,p=Math.round(h/g*100)),it(Ze,"cornerstoneimageloadprogress",{url:t,imageId:e,loaded:h,total:g,percentComplete:p}),i.onprogress&&i.onprogress(d,n)},a.onerror=function(){o(a),l(a)},a.onabort=function(){o(a),l(a)},a.send()});return s.xhr=a,s}function B_e(t,e,r){if(r+t.length>e.length)return!1;let n=r;for(let i=0;i<t.length;i++)if(t[i]!==e[n++])return!1;return!0}function G_e(t){const e=new Uint8Array(t.length);for(let r=0,n=t.length;r<n;r++)e[r]=t.charCodeAt(r);return e}function MT(t,e,r){r=r||0;const n=G_e(e);for(let i=r;i<t.length;i++)if(n[0]===t[i]&&B_e(n,t,i))return i;return-1}const{ImageQualityStatus:D7}=Ha;function W8(t,e,r){r||(r={});const n=new Uint8Array(e),i=!!(r!=null&&r.isPartial);if(t.indexOf("multipart")===-1)return{contentType:t,imageQualityStatus:i?D7.SUBRESOLUTION:D7.FULL_RESOLUTION,pixelData:n};let{tokenIndex:o,responseHeaders:a,boundary:s,multipartContentType:c}=r;if(o||(o=MT(n,`\r
|
||
\r
|
||
`)),o===-1)throw new Error("invalid response - no multipart mime header");if(!s&&(a=$_e(n,0,o).split(`\r
|
||
`),s=W_e(a),!s))throw new Error("invalid response - no boundary marker");const l=o+4,f=MT(n,s,l);if(f===-1&&!i)throw new Error("invalid response - terminating boundary not found");return c||(c=z_e(a)),r.tokenIndex=o,r.boundary=s,r.responseHeaders=a,r.multipartContentType=c,r.isPartial=f===-1,{contentType:c,extractDone:!i||f!==-1,tokenIndex:o,responseHeaders:a,boundary:s,multipartContentType:c,pixelData:e.slice(l,f-2)}}function W_e(t){for(let e=0;e<t.length;e++)if(t[e].substr(0,2)==="--")return t[e]}function z_e(t){for(let e=0;e<t.length;e++)if(t[e].substr(0,13)==="Content-Type:")return t[e].substr(13).trim()}function $_e(t,e,r){e=e||0,r=r||t.length-e;let n="";for(let i=e;i<e+r;i++)n+=String.fromCharCode(t[i]);return n}const{ImageQualityStatus:I7}=Ha;function z8(t,e=!0){return e?t.imageQualityStatus??I7.FULL_RESOLUTION:I7.SUBRESOLUTION}const{ProgressiveIterator:j_e}=pn;function Vz(t,e,r={},n={}){const i=Rm(),{retrieveOptions:o={},streamingData:a={}}=n,s=o.minChunkSize||128*1024,c=f=>{if(typeof i.errorInterceptor=="function"){const u=new Error("request failed");i.errorInterceptor(u)}},l=new j_e("streamRequest");return l.generate(async(f,u)=>{var g,p;const d=(g=i.beforeSend)==null?void 0:g.call(i,null,t,r,{}),h=Object.assign({},r,d);Object.keys(h).forEach(function(v){h[v]===null&&(h[v]=void 0),v==="Accept"&&t.indexOf("accept=")!==-1&&(h[v]=void 0)});try{const v=await fetch(t,{headers:h,signal:void 0});if(v.status!==200)throw new Error(`Couldn't retrieve ${t} got status ${v.status}`);const y=v.body.getReader(),m=v.headers,w=m.get("content-type"),x=Number(m.get("Content-Length"));let C=!1,S=a.encodedData,T=a.lastSize||0;for(a.isPartial=!0;!C;){const{done:_,value:E}=await y.read();if(S=H_e(S,E),!S){if(C)throw new Error(`Done but no image frame available ${e}`);continue}if(C=_||S.byteLength===x,!C&&S.length<T+s)continue;T=S.length,a.isPartial=!_;const b=W8(w,S,a),D=z8(o,C),I={url:t,imageId:e,...b,percentComplete:_?100:((p=b.pixelData)==null?void 0:p.length)*100/x,imageQualityStatus:D,done:C};f.add(I,C)}}catch(v){c(),console.error(v),u(v)}}),l.getNextPromise()}function H_e(t,e){if(!t)return e;if(!e)return t;const r=new Uint8Array(t.length+e.length);return r.set(t,0),r.set(e,t.length),r}const K_e={xhrRequest:rx,streamRequest:Vz,setOptions:kz,getOptions:Rm};function q_e(t){const e=t.elements.x7fe00010.fragments,r=t.byteArray.length;for(const n of e){const{position:i,length:o}=n;o>r-i&&(console.log(`Truncated fragment, changing fragment length from ${n.length} to ${r-i}`),n.length=r-i)}return t}function X_e(t){let e=lr.parseDicom(t,{untilTag:"x7fe00010"});e.elements.x7fe00010||console.warn("Pixel data not found!");let r;try{r=lr.parseDicom(t)}catch(n){console.error(n),console.log("pixel data dataset:",n.dataSet),r=n.dataSet}return e.elements.x7fe00010=r.elements.x7fe00010,e=q_e(e),e}async function Fz(t,e,r){const n=X_e(t),{uri:i,imageId:o,fileTotalLength:a}=r;return n.fetchMore=async function(s){const c=Object.assign({uri:i,imageId:o,fetchedLength:t.length,lengthToFetch:a-t.length},s),{fetchedLength:l,lengthToFetch:f}=c,{arrayBuffer:u}=await e(i,o,{byteRange:`${l}-${l+f}`}),d=new Uint8Array(u),h=new Uint8Array(n.byteArray.length+d.length);return h.set(n.byteArray),h.set(d,n.byteArray.length),Fz(h,e,r)},n}function Y_e(t,e){if(!t)return;const{NumberOfFrames:r,PerFrameFunctionalGroupsSequence:n,SharedFunctionalGroupsSequence:i}=Bz(t);if(n||r>1){const{shared:o,perFrame:a}=Uz(n,i,e);return{NumberOfFrames:r,PerFrameFunctionalInformation:a,SharedFunctionalInformation:o}}return{NumberOfFrames:r}}function Uz(t,e,r){const n={};(e?Object.values(e.items[0].dataSet.elements):[]).map(o=>n[o.tag]=o);const i={};return(t?Object.values(t.items[r-1].dataSet.elements):[]).map(o=>i[o.tag]=o),{shared:n,perFrame:i}}function Bz(t){if(!t)return;const{elements:e,...r}=t,{x52009230:n,x52009229:i,...o}=e;return{NumberOfFrames:t.intString("x00280008"),PerFrameFunctionalGroupsSequence:n,SharedFunctionalGroupsSequence:i,otherElements:o,otherAttributtes:r}}function J_e(t,e){if(!e)return;const{NumberOfFrames:r,PerFrameFunctionalGroupsSequence:n,SharedFunctionalGroupsSequence:i,otherElements:o}=Bz(e);if(n||r>1){const{shared:a,perFrame:s}=Uz(n,i,t),c={elements:{...o,...a,...s}},l=Object.create(e);return Object.assign(l,c)}return e}let ki={};const Z_e=()=>{ki={}};function $8(t){if(ki[t])return ki[t]}function Q_e(t){const e=$8(t);return Gz(e)}function Gz(t){if(!t)return!1;const e=t.intString("x00280008");return e&&e>1}function e4e(t){return t.indexOf("&frame=")}function t4e(t){const e=e4e(t),r=e===-1?t:t.slice(0,e),n=parseInt(t.slice(e+7),10)||1;let i;return ki[r]?i=ki[r].dataSet:i=void 0,{dataSet:i,frame:n}}function n4e(t){const e=[],r=$8(t);if(Gz(r)){const n=r.intString("x00280008");for(let i=1;i<=n;i++)e.push(`${t}&frame=${i}`)}else e.push(t);return e}const Wz={_get:$8,generateMultiframeWADOURIs:n4e,retrieveMultiframeDataset:t4e,isMultiframeDataset:Q_e};let Ah=0,$f={};function r4e(t){return ki[t]!==void 0}function i4e(t){let e;if(t.includes("&frame=")){const{frame:r,dataSet:n}=Wz.retrieveMultiframeDataset(t);e=J_e(r,n)}else ki[t]&&(e=ki[t].dataSet);return e}function o4e(t,e){const r=ki[t];if(!r){console.error(`No loaded dataSet for uri ${t}`);return}Ah-=r.dataSet.byteArray.length,r.dataSet=e,Ah+=e.byteArray.length,it(Ze,"datasetscachechanged",{uri:t,action:"updated",cacheInfo:ix()})}function a4e(t,e=rx,r){if(ki[t])return new Promise(o=>{ki[t].cacheCount++,o(ki[t].dataSet)});if($f[t])return $f[t].cacheCount++,$f[t];const n=e(t,r),i=new Promise((o,a)=>{n.then(async function(s){const c={isPartialContent:!1,fileTotalLength:null};if(!(s instanceof ArrayBuffer)){if(!s.arrayBuffer)return a(new Error("If not returning ArrayBuffer, must return object with `arrayBuffer` parameter"));c.isPartialContent=s.flags.isPartialContent,c.fileTotalLength=s.flags.fileTotalLength,s=s.arrayBuffer}const l=new Uint8Array(s);let f;try{c.isPartialContent?f=await Fz(l,e,{uri:t,imageId:r,fileTotalLength:c.fileTotalLength}):f=lr.parseDicom(l)}catch(u){return a(u)}ki[t]={dataSet:f,cacheCount:i.cacheCount},Ah+=f.byteArray.length,o(f),it(Ze,"datasetscachechanged",{uri:t,action:"loaded",cacheInfo:ix()})},a).then(()=>{delete $f[t]},()=>{delete $f[t]})});return i.cacheCount=1,$f[t]=i,i}function s4e(t){ki[t]&&(ki[t].cacheCount--,ki[t].cacheCount===0&&(Ah-=ki[t].dataSet.byteArray.length,delete ki[t],it(Ze,"datasetscachechanged",{uri:t,action:"unloaded",cacheInfo:ix()})))}function ix(){return{cacheSizeInBytes:Ah,numberOfDataSetsCached:Object.keys(ki).length}}function c4e(){Z_e(),$f={},Ah=0}const ch={isLoaded:r4e,load:a4e,unload:s4e,getInfo:ix,purge:c4e,get:i4e,update:o4e};function l4e(t){const e=[];for(let r=0;r<=30;r+=2){let n=`x60${r.toString(16)}`;n.length===4&&(n=`x600${r.toString(16)}`);const i=t.elements[`${n}3000`];if(!i)continue;const o=[];for(let a=0;a<i.length;a++)for(let s=0;s<8;s++){const c=t.byteArray[i.dataOffset+a];o[a*8+s]=c>>s&1}e.push({rows:t.uint16(`${n}0010`),columns:t.uint16(`${n}0011`),type:t.string(`${n}0040`),x:t.int16(`${n}0050`,1)-1,y:t.int16(`${n}0050`,0)-1,pixelData:o,description:t.string(`${n}0022`),label:t.string(`${n}1500`),roiArea:t.string(`${n}1301`),roiMean:t.string(`${n}1302`),roiStandardDeviation:t.string(`${n}1303`)})}return{overlays:e}}function ug(t){return t==="RECON TOMO"||t==="RECON GATED TOMO"}function j8(t,e){const r=t.string("x00080008");if(r){const n=r.split("\\");if(n.length>e)return n[e]}}function u4e(t){let e;const r=t.string("x00080060");if(r!=null&&r.includes("NM")){const n=j8(t,2);n&&ug(n)&&t.elements.x00540022&&(e=gc(t.elements.x00540022.items[0].dataSet,"x00200037",6))}return e}function f4e(t){let e;const r=t.string("x00080060");if(r!=null&&r.includes("NM")){const n=j8(t,2);n&&ug(n)&&t.elements.x00540022&&(e=gc(t.elements.x00540022.items[0].dataSet,"x00200032",3))}return e}function O7(t){let e=gc(t,"x00200037",6);return!e&&t.elements.x00209116&&(e=gc(t.elements.x00209116.items[0].dataSet,"x00200037",6)),e||(e=u4e(t)),e}function M7(t){let e=gc(t,"x00200032",3);return!e&&t.elements.x00209113&&(e=gc(t.elements.x00209113.items[0].dataSet,"x00200032",3)),e||(e=f4e(t)),e}function P7(t){let e=gc(t,"x00280030",2);return!e&&t.elements.x00289110&&(e=gc(t.elements.x00289110.items[0].dataSet,"x00280030",2)),e}function R7(t){let e;return t.elements.x00180050?e=t.floatString("x00180050"):t.elements.x00289110&&t.elements.x00289110.items.length&&t.elements.x00289110.items[0].dataSet.elements.x00180050&&(e=t.elements.x00289110.items[0].dataSet.floatString("x00180050")),e}function zz(t,e,r){const n={};for(const i of r)try{const o=e(i,t);if(o){const a={};for(const s in o)if(s in o){const c=d4e(s);a[c]=o[s]}Object.assign(n,a)}}catch(o){console.error(`Error retrieving ${i} data:`,o)}return n}const d4e=t=>t.charAt(0).toUpperCase()+t.slice(1),$z=["multiframeModule","generalSeriesModule","patientStudyModule","imagePlaneModule","nmMultiframeGeometryModule","imagePixelModule","modalityLutModule","voiLutModule","sopCommonModule","petIsotopeModule","overlayPlaneModule","transferSyntax","petSeriesModule","petImageModule"];function L7(t){const e=t.elements.x00186011;return!e||!e.items?[]:e.items.map(n=>{const i=n.dataSet.double("x0018602c"),o=n.dataSet.double("x0018602e"),a=n.dataSet.uint16("x00186024"),s=n.dataSet.uint16("x00186026"),c=n.dataSet.uint16("x0018601a"),l=n.dataSet.uint16("x0018601e"),f=n.dataSet.uint16("x00186018"),u=n.dataSet.uint16("x0018601c"),d=n.dataSet.int32("x00186020")||null,h=n.dataSet.int32("x00186022")||null,g=n.dataSet.uint16("x0018602a"),p=n.dataSet.uint16("x00186028"),v=n.dataSet.uint16("x00186012"),y=n.dataSet.uint16("x00186014"),m=n.dataSet.uint16("x00186016"),w=n.dataSet.uint16("x00186030");return{regionLocationMinY0:c,regionLocationMaxY1:l,regionLocationMinX0:f,regionLocationMaxX1:u,referencePixelX0:d,referencePixelY0:h,physicalDeltaX:i,physicalDeltaY:o,physicalUnitsXDirection:a,physicalUnitsYDirection:s,referencePhysicalPixelValueY:g,referencePhysicalPixelValueX:p,regionSpatialFormat:v,regionDataType:y,regionFlags:m,transducerFrequency:w}})}function H8(t,e){const{MetadataModules:r}=Ha;if(Array.isArray(e))return;const n=Pm(e);if(t===r.MULTIFRAME){const a=Wz.retrieveMultiframeDataset(n.url);return a.dataSet?Y_e(a.dataSet,a.frame):void 0}let i=n.url;n.frame&&(i=`${i}&frame=${n.frame}`);const o=ch.get(i);if(o)return jz(t,e,o)}function jz(t,e,r){const{MetadataModules:n}=Ha;if(t===n.GENERAL_STUDY)return{studyDescription:r.string("x00081030"),studyDate:lr.parseDA(r.string("x00080020")),studyTime:lr.parseTM(r.string("x00080030")||""),accessionNumber:r.string("x00080050")};if(t===n.GENERAL_SERIES)return{modality:r.string("x00080060"),seriesInstanceUID:r.string("x0020000e"),seriesDescription:r.string("x0008103e"),seriesNumber:r.intString("x00200011"),studyInstanceUID:r.string("x0020000d"),seriesDate:lr.parseDA(r.string("x00080021")),seriesTime:lr.parseTM(r.string("x00080031")||""),acquisitionDate:lr.parseDA(r.string("x00080022")),acquisitionTime:lr.parseTM(r.string("x00080032")||"")};if(t===n.GENERAL_IMAGE)return{sopInstanceUID:r.string("x00080018"),instanceNumber:r.intString("x00200013"),lossyImageCompression:r.string("x00282110"),lossyImageCompressionRatio:r.floatString("x00282112"),lossyImageCompressionMethod:r.string("x00282114")};if(t===n.PATIENT)return{patientID:r.string("x00100020"),patientName:r.string("x00100010")};if(t===n.PATIENT_STUDY)return{patientAge:r.intString("x00101010"),patientSize:r.floatString("x00101020"),patientSex:r.string("x00100040"),patientWeight:r.floatString("x00101030")};if(t===n.NM_MULTIFRAME_GEOMETRY){const i=r.string("x00080060"),o=j8(r,2);return{modality:i,imageType:r.string("x00080008"),imageSubType:o,imageOrientationPatient:O7(r),imagePositionPatient:M7(r),sliceThickness:R7(r),pixelSpacing:P7(r),numberOfFrames:r.uint16("x00280008"),isNMReconstructable:ug(o)&&i.includes("NM")}}if(t===n.IMAGE_PLANE){const i=O7(r),o=M7(r),a=P7(r),s=R7(r);let c=null,l=null;a&&(l=a[0],c=a[1]);let f=null,u=null;return i&&(f=[parseFloat(i[0]),parseFloat(i[1]),parseFloat(i[2])],u=[parseFloat(i[3]),parseFloat(i[4]),parseFloat(i[5])]),{frameOfReferenceUID:r.string("x00200052"),rows:r.uint16("x00280010"),columns:r.uint16("x00280011"),imageOrientationPatient:i,rowCosines:f,columnCosines:u,imagePositionPatient:o,sliceThickness:s,sliceLocation:r.floatString("x00201041"),pixelSpacing:a,rowPixelSpacing:l,columnPixelSpacing:c}}if(t===n.CINE)return{frameTime:r.floatString("x00181063")};if(t===n.IMAGE_PIXEL)return Lz(r);if(t===n.VOI_LUT){const i=Az(r);return{windowCenter:gc(r,"x00281050",1),windowWidth:gc(r,"x00281051",1),voiLUTSequence:IT(i,r.elements.x00283010),voiLUTFunction:r.string("x00281056")}}if(t===n.MODALITY_LUT)return{rescaleIntercept:r.floatString("x00281052"),rescaleSlope:r.floatString("x00281053"),rescaleType:r.string("x00281054"),modalityLUTSequence:IT(r.uint16("x00280103"),r.elements.x00283000)};if(t===n.SOP_COMMON)return{sopClassUID:r.string("x00080016"),sopInstanceUID:r.string("x00080018")};if(t===n.PET_ISOTOPE){const i=r.elements.x00540016;if(i===void 0)return;const o=i.items[0].dataSet;return{radiopharmaceuticalInfo:{radiopharmaceuticalStartTime:lr.parseTM(o.string("x00181072")||""),radionuclideTotalDose:o.floatString("x00181074"),radionuclideHalfLife:o.floatString("x00181075")}}}if(t===n.OVERLAY_PLANE)return l4e(r);if(t==="transferSyntax"){let i;try{i=r.string("x00020010")}catch{}return{transferSyntaxUID:i}}if(t===n.PET_SERIES)return{correctedImage:r.string("x00280051"),units:r.string("x00541001"),decayCorrection:r.string("x00541102")};if(t===n.PET_IMAGE)return{frameReferenceTime:r.floatString(r.string("x00541300")||""),actualFrameDuration:r.intString(r.string("x00181242"))};if(t===n.ULTRASOUND_ENHANCED_REGION)return L7(r);if(t===n.CALIBRATION&&r.string("x00080060")==="US")return{sequenceOfUltrasoundRegions:L7(r)};if(t==="instance")return zz(e,H8,$z)}let ox=[];function h4e(t){return`dicomfile:${ox.push(t)-1}`}function g4e(t){return ox[t]}function p4e(t){ox[t]=void 0}function m4e(){ox=[]}const Hz={add:h4e,get:g4e,remove:p4e,purge:m4e};function v4e(t){const e=t.intString("x00280008"),r=t.elements.x7fe00010;return e!==r.fragments.length}function Kz(t,e){if(t.elements.x7fe00010&&t.elements.x7fe00010.basicOffsetTable.length)return lr.readEncapsulatedImageFrame(t,t.elements.x7fe00010,e);if(v4e(t)){const l=lr.createJPEGBasicOffsetTable(t,t.elements.x7fe00010);return lr.readEncapsulatedImageFrame(t,t.elements.x7fe00010,e,l)}const r=t.elements.x7fe00010.fragments,n=new lr.ByteStream(t.byteArrayParser,t.byteArray,t.elements.x7fe00010.dataOffset),i=lr.readSequenceItem(n);if(i.tag!=="xfffee000")throw"dicomParser.readEncapsulatedPixelData: missing basic offset table xfffee000";n.seek(i.length);const o=n.position;if(e+1>r.length)throw"dicomParser.readEncapsulatedPixelData: frame exceeds number of fragments";const s=o+r[e].offset+8,c=r[e].length;return new Uint8Array(n.byteArray.buffer.slice(n.byteArray.byteOffset+s,n.byteArray.byteOffset+s+c))}function y4e(t,e){return t&1<<e}function qz(t,e,r){const n=new Uint8Array(r);for(let i=0;i<r;i++){const o=Math.floor(i/8),a=t[o+e],s=i%8;n[i]=y4e(a,s)?1:0}return n}function Xz(t,e){const r=t.elements.x7fe00010||t.elements.x7fe00008,n=t.uint16("x00280100"),i=t.uint16("x00280010"),o=t.uint16("x00280011");let a=t.uint16("x00280002");t.string("x00280004")==="YBR_FULL_422"&&(a=2,console.warn(`Using SamplesPerPixel of 2 for YBR_FULL_422 photometric interpretation.
|
||
See http://dicom.nema.org/medical/dicom/current/output/chtml/part03/sect_C.7.6.3.html for more information.`));const c=r.dataOffset,l=i*o*a;let f;if(n===8){if(f=c+e*l,f>=t.byteArray.length)throw new Error("frame exceeds size of pixelData");return new Uint8Array(t.byteArray.buffer.slice(f,f+l))}else if(n===16){if(f=c+e*l*2,f>=t.byteArray.length)throw new Error("frame exceeds size of pixelData");return new Uint8Array(t.byteArray.buffer.slice(f,f+l*2))}else if(n===1){if(f=c+e*l*.125,f>=t.byteArray.length)throw new Error("frame exceeds size of pixelData");return qz(t.byteArray,f,l)}else if(n===32){if(f=c+e*l*4,f>=t.byteArray.length)throw new Error("frame exceeds size of pixelData");return new Uint8Array(t.byteArray.buffer.slice(f,f+l*4))}throw new Error("unsupported pixel format")}function Yz(t){const e=Pm(t),r=parseInt(e.url,10),n=Hz.get(r);return new Promise((i,o)=>{const a=new FileReader;a.onload=s=>{const c=s.target.result;i(c)},a.onerror=o,a.readAsArrayBuffer(n)})}function K8(t,e=0){const r=t.elements.x7fe00010||t.elements.x7fe00008;return r?r.encapsulatedPixelData?Kz(t,e):Xz(t,e):null}function ax(t){let e=t[0],r=t[0],n;const i=t.length;for(let o=1;o<i;o++)n=t[o],e=Math.min(e,n),r=Math.max(r,n);return{min:e,max:r}}function QC(t,e,r){t.planarConfiguration===0?Iz(t.pixelData,e,r):Oz(t.pixelData,e,r)}function w4e(t,e,r){t.planarConfiguration===0?Mz(t.pixelData,e,r):Pz(t.pixelData,e,r)}function Jz(t,e,r){if(t.photometricInterpretation==="RGB")QC(t,e,r);else if(t.photometricInterpretation==="YBR_RCT")QC(t,e,r);else if(t.photometricInterpretation==="YBR_ICT")QC(t,e,r);else if(t.photometricInterpretation==="PALETTE COLOR")Rz(t,e,r);else if(t.photometricInterpretation==="YBR_FULL_422")N_e(t.pixelData,e,r);else if(t.photometricInterpretation==="YBR_FULL")w4e(t,e,r);else throw new Error(`No color space conversion for photometric interpretation ${t.photometricInterpretation}`)}function x4e(t){if(t===void 0)return!1;const{rows:e,columns:r,photometricInterpretation:n,pixelDataLength:i,planarConfiguration:o}=t;return i===4*r*e||n==="PALETTE COLOR"?!1:n.endsWith("420")?i===(3*Math.ceil(r/2)+Math.floor(r/2))*e:n.endsWith("422")?i===(3*Math.ceil(r/2)+Math.floor(r/2))*Math.ceil(e/2)+Math.floor(e/2)*r:n!=="RGB"||o===1}function C4e(t){return S4e(String.fromCharCode.apply(null,Array.prototype.slice.apply(new Uint8Array(t))))}function S4e(t){let e;try{return decodeURIComponent(escape(t))}catch(r){if(e=r,e instanceof URIError)return t;throw e}}function Zz(t,e,r){const n=new Date().getTime(),i=new Blob([e],{type:"image/jpeg"});return new Promise((o,a)=>{const s=new FileReader;s.readAsBinaryString===void 0?s.readAsArrayBuffer(i):s.readAsBinaryString(i),s.onload=function(){const c=new Image;c.onload=function(){r.height=c.height,r.width=c.width,t.rows=c.height,t.columns=c.width;const l=r.getContext("2d");l.drawImage(this,0,0);const f=l.getImageData(0,0,c.width,c.height),u=new Date().getTime();t.pixelData=new Uint8Array(f.data.buffer),t.imageData=f,t.decodeTimeInMS=u-n;const d=ax(t.pixelData);t.smallestPixelValue=d.min,t.largestPixelValue=d.max,t.pixelDataLength=t.pixelData.length,o(t)},c.onerror=function(l){a(l)},s.readAsBinaryString===void 0?c.src=`data:image/jpeg;base64,${window.btoa(C4e(s.result))}`:c.src=`data:image/jpeg;base64,${window.btoa(s.result)}`},s.onerror=c=>{a(c)}})}function ia(t,e,r,n,i){const o={...n};delete o.loader,delete o.streamingData;const a=fl(),s=o.priority||void 0;return o.transferPixelData&&r.buffer,a.executeTask("dicomImageLoader","decodeTask",{imageFrame:t,transferSyntax:e,pixelData:r,options:o,decodeConfig:i},{priority:s,requestType:o==null?void 0:o.requestType})}function T4e(t,e,r,n,i={},o){switch(e){case"1.2.840.10008.1.2":return ia(t,e,r,i,o);case"1.2.840.10008.1.2.1":return ia(t,e,r,i,o);case"1.2.840.10008.1.2.2":return ia(t,e,r,i,o);case"1.2.840.10008.1.2.1.99":return ia(t,e,r,i,o);case"1.2.840.10008.1.2.5":return ia(t,e,r,i,o);case"1.2.840.10008.1.2.4.50":return t.bitsAllocated===8&&(t.samplesPerPixel===3||t.samplesPerPixel===4)?Zz(t,r,n):ia(t,e,r,i,o);case"1.2.840.10008.1.2.4.51":return ia(t,e,r,i,o);case"1.2.840.10008.1.2.4.57":return ia(t,e,r,i,o);case"1.2.840.10008.1.2.4.70":return ia(t,e,r,i,o);case"1.2.840.10008.1.2.4.80":return ia(t,e,r,i,o);case"1.2.840.10008.1.2.4.81":return ia(t,e,r,i,o);case"1.2.840.10008.1.2.4.90":return ia(t,e,r,i,o);case"1.2.840.10008.1.2.4.91":return ia(t,e,r,i,o);case"3.2.840.10008.1.2.4.96":case"1.2.840.10008.1.2.4.201":case"1.2.840.10008.1.2.4.202":case"1.2.840.10008.1.2.4.203":return ia(t,e,r,i,o)}return Promise.reject(new Error(`No decoder for transfer syntax ${e}`))}function Qz(t){const e=ct("imagePixelModule",t);return{samplesPerPixel:e.samplesPerPixel,photometricInterpretation:e.photometricInterpretation,planarConfiguration:e.planarConfiguration,rows:e.rows,columns:e.columns,bitsAllocated:e.bitsAllocated,bitsStored:e.bitsStored,pixelRepresentation:e.pixelRepresentation,smallestPixelValue:e.smallestPixelValue,largestPixelValue:e.largestPixelValue,redPaletteColorLookupTableDescriptor:e.redPaletteColorLookupTableDescriptor,greenPaletteColorLookupTableDescriptor:e.greenPaletteColorLookupTableDescriptor,bluePaletteColorLookupTableDescriptor:e.bluePaletteColorLookupTableDescriptor,redPaletteColorLookupTableData:e.redPaletteColorLookupTableData,greenPaletteColorLookupTableData:e.greenPaletteColorLookupTableData,bluePaletteColorLookupTableData:e.bluePaletteColorLookupTableData,pixelData:void 0,imageId:t}}function _4e(t,e){const r=t.get("modalityLutModule",e)||{},n=t.get("generalSeriesModule",e)||{},{modality:i}=n,o={rescaleSlope:r.rescaleSlope,rescaleIntercept:r.rescaleIntercept,modality:i},a=t.get("scalingModule",e)||{};return{...o,...i==="PT"&&{suvbw:a.suvbw},...i==="RTDOSE"&&{doseGridScaling:a.DoseGridScaling,doseSummation:a.DoseSummation,doseType:a.DoseType,doseUnit:a.DoseUnit}}}function q8(t){return t==="RGB"||t==="PALETTE COLOR"||t==="YBR_FULL"||t==="YBR_FULL_422"||t==="YBR_PARTIAL_422"||t==="YBR_PARTIAL_420"||t==="YBR_RCT"||t==="YBR_ICT"}function E4e(t,e){const r=t.length/4;let n=0,i=0;for(let o=0;o<r;o++)e[i++]=t[n++],e[i++]=t[n++],e[i++]=t[n++],n++;return e}function b4e(t){return t!=="1.2.840.10008.5.1.4.1.1.12.1"&&t!=="1.2.840.10008.5.1.4.1.1.12.2.1"}function X8(t,e){let r;return Number.isInteger(t)&&Number.isInteger(e)&&(t>=0?e<=255?r=Uint8Array:e<=65535?r=Uint16Array:e<=4294967295&&(r=Uint32Array):t>=-128&&e<=127?r=Int8Array:t>=-32768&&e<=32767&&(r=Int16Array)),r||Float32Array}function D4e(t,e,r){return X8(t,e)===r}function I4e(t){const e=t.smallestPixelValue,r=t.largestPixelValue,n=X8(e,r);if(n){const i=new n(t.pixelData);t.pixelData=i}else throw new Error("Could not apply a typed array to the pixel data")}let A7="";function sx(t,e,r,n={}){const i=n.useRGBA;if(n.preScale={enabled:n.preScale&&n.preScale.enabled!==void 0?n.preScale.enabled:!0},!(e!=null&&e.length))return Promise.reject(new Error("The pixel data is missing"));const{MetadataModules:o}=Ha,a=document.createElement("canvas"),s=Qz(t);if(s.decodeLevel=n.decodeLevel,n.allowFloatRendering=dw(),n.preScale.enabled){const u=_4e(A4,t);u&&(n.preScale={...n.preScale,scalingParameters:u})}const{decodeConfig:c}=Rm();Object.keys(s).forEach(u=>{(typeof s[u]=="function"||s[u]instanceof Promise)&&delete s[u]});const l=T4e(s,r,e,a,n,c),f=q8(s.photometricInterpretation);return new Promise((u,d)=>{l.then(function(h){let g=!1;if(n.targetBuffer&&n.targetBuffer.type&&!f){const{arrayBuffer:_,type:E,offset:b=0,length:D}=n.targetBuffer,I=h.pixelDataLength,P=b,O=D??I-P,L={Uint8Array,Uint16Array,Int16Array,Float32Array,Uint32Array};if(O!==h.pixelDataLength)throw new Error(`target array for image does not have the same length (${O}) as the decoded image length (${h.pixelDataLength}).`);const B=L[E],H=_?new B(_,P,O):new B(h.pixelData);if(O!==h.pixelDataLength)throw new Error("target array for image does not have the same length as the decoded image length.");h.pixelData=H,g=!0}g||I4e(h);const p=ct(o.IMAGE_PLANE,t)||{},v=ct(o.VOI_LUT,t)||{},y=ct(o.MODALITY_LUT,t)||{},m=ct(o.SOP_COMMON,t)||{},w=ct(o.CALIBRATION,t)||{},{rows:x,columns:C}=h;if(f){if(x4e(h)){a.height=h.rows,a.width=h.columns;let b=a.getContext("2d").createImageData(h.columns,h.rows);i||(b={...b,data:new Uint8ClampedArray(3*h.columns*h.rows)}),Jz(h,b.data,i),h.imageData=b,h.pixelData=b.data,h.pixelDataLength=b.data.length}else if(!i&&h.pixelDataLength===4*x*C){const E=new Uint8Array(h.pixelData.length/4*3);h.pixelData=E4e(h.pixelData,E),h.pixelDataLength=h.pixelData.length}const _=ax(h.pixelData);h.smallestPixelValue=_.min,h.largestPixelValue=_.max}const S=fc.createImageVoxelManager({scalarData:h.pixelData,width:h.columns,height:h.rows,numberOfComponents:h.samplesPerPixel}),T={imageId:t,dataType:h.pixelData.constructor.name,color:f,calibration:w,columnPixelSpacing:p.columnPixelSpacing,columns:h.columns,height:h.rows,preScale:h.preScale,intercept:y.rescaleIntercept?y.rescaleIntercept:0,slope:y.rescaleSlope?y.rescaleSlope:1,invert:h.photometricInterpretation==="MONOCHROME1",minPixelValue:h.smallestPixelValue,maxPixelValue:h.largestPixelValue,rowPixelSpacing:p.rowPixelSpacing,rows:h.rows,sizeInBytes:h.pixelData.byteLength,width:h.columns,windowCenter:v.windowCenter?v.windowCenter[0]:void 0,windowWidth:v.windowWidth?v.windowWidth[0]:void 0,voiLUTFunction:v.voiLUTFunction?v.voiLUTFunction:void 0,decodeTimeInMS:h.decodeTimeInMS,floatPixelData:void 0,imageFrame:h,voxelManager:S,rgba:f&&i,getPixelData:()=>h.pixelData,getCanvas:void 0,numberOfComponents:h.samplesPerPixel};if(T.color&&(T.getCanvas=function(){if(A7===t)return a;const _=T.columns,E=T.rows;a.height=E,a.width=_;const b=a.getContext("2d"),D=b.createImageData(_,E),I=h.pixelData;if(I.length===_*E*4)for(let P=0;P<I.length;P++)D.data[P]=I[P];else if(I.length===_*E*3){let P=0;for(let O=0;O<I.length;O+=3)D.data[P++]=I[O],D.data[P++]=I[O+1],D.data[P++]=I[O+2],D.data[P++]=255}return h.pixelData=D.data,h.pixelDataLength=D.data.length,h.imageData=D,b.putImageData(h.imageData,0,0),A7=t,a}),y.modalityLUTSequence&&y.modalityLUTSequence.length>0&&b4e(m.sopClassUID)&&(T.modalityLUT=y.modalityLUTSequence[0]),v.voiLUTSequence&&v.voiLUTSequence.length>0&&(T.voiLUT=v.voiLUTSequence[0]),T.color&&(T.windowWidth=256,T.windowCenter=128),T.windowCenter===void 0||T.windowWidth===void 0){const _=T.imageFrame.smallestPixelValue,E=T.imageFrame.largestPixelValue;T.windowWidth=E-_,T.windowCenter=(E+_)/2}u(T)},d)})}const{ImageQualityStatus:e$}=Ha;function O4e(t,e){t.decache=function(){const r=Pm(e);ch.unload(r.url)}}function t$(t,e,r=0,n,i,o){const a=new Date().getTime(),s={cancelFn:void 0,promise:void 0};return s.promise=new Promise((c,l)=>{t.then(f=>{const u=K8(f,r),d=f.string("x00020010"),h=new Date().getTime(),g=sx(e,u,d,i);O4e(s,e),g.then(p=>{p=p,p.data=f,p.sharedCacheKey=n;const v=new Date().getTime();p.loadTimeInMS=h-a,p.totalTimeInMS=v-a,p.imageQualityStatus=e$.FULL_RESOLUTION,o!==void 0&&o.imageDoneCallback!==void 0&&o.imageDoneCallback(p),c(p)},function(p){l({error:p,dataSet:f})})},function(f){l({error:f})})}),s}function M4e(t,e,r=0,n,i){const o=new Date().getTime();return{promise:new Promise((s,c)=>{const l=new Date().getTime();let f;try{const u=K8(t,r),d=t.string("x00020010");f=sx(e,u,d,i)}catch(u){c({error:u,dataSet:t});return}f.then(u=>{u=u,u.data=t;const d=new Date().getTime();u.loadTimeInMS=l-o,u.totalTimeInMS=d-o,u.imageQualityStatus=e$.FULL_RESOLUTION,s(u)},c)}),cancelFn:void 0}}function n$(t){if(t==="dicomweb"||t==="wadouri")return rx;if(t==="dicomfile")return Yz}function Bv(t,e={}){const r=Pm(t);e=Object.assign({},e),delete e.loader;const n=n$(r.scheme);if(ch.isLoaded(r.url)){const o=ch.get(r.url,n,t);return M4e(o,t,r.pixelDataFrame,r.url,e)}const i=ch.load(r.url,n,t);return t$(i,t,r.frame,r.url,e)}function r$(){ld("dicomweb",Bv),ld("wadouri",Bv),ld("dicomfile",Bv),zh(H8)}const P4e={getImagePixelModule:Lz,getLUTs:IT,getModalityLUTOutputPixelRepresentation:Az,getNumberValues:gc,metaDataProvider:H8,metadataForDataset:jz},R4e={metaData:P4e,dataSetCacheManager:ch,fileManager:Hz,getEncapsulatedImageFrame:Kz,getUncompressedImageFrame:Xz,loadFileRequest:Yz,loadImageFromPromise:t$,getLoaderForScheme:n$,getPixelData:K8,loadImage:Bv,parseImageId:Pm,unpackBinaryFrame:qz,register:r$};function Ht(t,e,r){return e=e||0,!t||!t.Value||Array.isArray(t.Value)&&t.Value.length<=e?r:t.Value[e]}function L4e(t,e,r){const n=Ht(t,e,r);if(n!==void 0)return parseFloat(String(n))}function Fn(t,e){const r=Ht(t,e);if(r!==void 0)return parseFloat(r)}function So(t,e){if(!t||!t.Value||!Array.isArray(t.Value)||e&&t.Value.length<e)return;const r=[];for(let n=0;n<t.Value.length;n++)r.push(parseFloat(t.Value[n]));return r}function A4e(t){const e=[];for(let r=0;r<=30;r+=2){let n=`x60${r.toString(16)}`;n.length===4&&(n=`x600${r.toString(16)}`);const i=Ht(t[`${n}3000`]);if(!i)continue;const o=[];for(let a=0;a<i.length;a++)for(let s=0;s<8;s++){const c=t.Value[i.dataOffset+a];o[a*8+s]=c>>s&1}e.push({rows:Fn(t[`${n}0010`]),columns:Fn(t[`${n}0011`]),type:Ht(t[`${n}0040`]),x:Fn(t[`${n}0050`],1)-1,y:Fn(t[`${n}0050`],0)-1,pixelData:o,description:Ht(t[`${n}0022`]),label:Ht(t[`${n}1500`]),roiArea:Ht(t[`${n}1301`]),roiMean:Ht(t[`${n}1302`]),roiStandardDeviation:Ht(t[`${n}1303`])})}return{overlays:e}}function cx(t){const e=t.indexOf(":");return t.substring(e+1)}function lh(t,e=!0){return t&&t.Value?t.Value[0]&&e?t.Value[0]:t.Value:t}function i$(t,e,r){const n=(e?Object.values(e[0]):[]).map(o=>{var a;return(a=o.Value)==null?void 0:a[0]}).filter(o=>o!==void 0&&typeof o=="object"),i=(t?Object.values(t[r-1]):[]).map(o=>{var a;return(a=o.Value)==null?void 0:a[0]}).filter(o=>o!==void 0&&typeof o=="object");return{shared:n,perFrame:i}}function o$(t){let{52009230:e,52009229:r,"00280008":n,...i}=t;return e=lh(e,!1),r=lh(r,!1),n=lh(n),{PerFrameFunctionalGroupsSequence:e,SharedFunctionalGroupsSequence:r,NumberOfFrames:n,rest:i}}function N4e(t,e){const{PerFrameFunctionalGroupsSequence:r,SharedFunctionalGroupsSequence:n,NumberOfFrames:i,rest:o}=o$(e);if(r||i>1){const{shared:a,perFrame:s}=i$(r,n,t),c=Object.assign(e,{frameNumber:t});return[...a,...s].forEach(l=>{Object.entries(l).forEach(([f,u])=>{c[f]=u})}),Object.assign(o,{"00280008":i},c)}return e}let Lm=[],L5={};function a$(t){const e=t.indexOf("/frames/")+8,r=t.slice(0,e),n=parseInt(t.slice(e),10);return{metadata:Lm[`${r}1`],frame:n}}function k4e(t){const e=cx(t);return a$(e)}function V4e(t){if(t[52009230]!==void 0||t[52009229]!==void 0)return!0;const e=Ht(t["00280008"]);return e&&e>1}function F4e(t,e){const r=cx(t);Object.defineProperty(e,"isMultiframe",{value:V4e(e),enumerable:!1}),Lm[r]=e}function U4e(t){const e=cx(t),r=Lm[e];if(r&&!(r!=null&&r.isMultiframe))return r;const n=L5[e];if(n)return n;const i=a$(e);if(!i||!i.metadata)return;const{metadata:o,frame:a}=i;if(o){const s=N4e(a,o);return L5[e]=s,s}}function B4e(t){const e=cx(t);Lm[e]=void 0,L5[e]=void 0}function G4e(){Lm=[],L5={}}const Y8={add:F4e,get:U4e,remove:B4e,purge:G4e};function s$(t){return Ht(t["00080060"]).includes("NM")}function J8(t,e){const r=lh(t["00080008"],!1);if(r)return r[e]}function W4e(t){let e;const r=J8(t,2);if(r&&ug(r)){const n=lh(t["00540022"]);n&&(e=So(n["00200037"],6))}return e}function z4e(t){let e;const r=J8(t,2);if(r&&ug(r)){const n=lh(t["00540022"]);n&&(e=So(n["00200032"],3))}return e}function N7(t){let e=So(t["00200037"],6);return!e&&s$(t)&&(e=W4e(t)),e}function k7(t){let e=So(t["00200032"],3);return!e&&s$(t)&&(e=z4e(t)),e}function xo(t,e){const r=So(t[e]);return r?r[0]:null}function $4e(t){var e;return(e=t==null?void 0:t.Value)!=null&&e.length?Array.isArray(t.Value)?t.Value:typeof t.Value=="object"?(console.warn("Warning: Value should be an array, but an object was found. Encapsulating the object in an array."),[t.Value]):[]:[]}function V7(t){const e=$4e(t["00186011"]);return!e||!e.length?null:e.map(n=>{const i=xo(n,"0018602C"),o=xo(n,"0018602E"),a=xo(n,"00186024"),s=xo(n,"00186026"),c=xo(n,"0018601A"),l=xo(n,"0018601E"),f=xo(n,"00186018"),u=xo(n,"0018601C"),d=xo(n,"00186020"),h=xo(n,"00186022"),g=xo(n,"0018602A"),p=xo(n,"00186028"),v=xo(n,"00186012"),y=xo(n,"00186014"),m=xo(n,"00186016"),w=xo(n,"00186030");return{regionLocationMinY0:c,regionLocationMaxY1:l,regionLocationMinX0:f,regionLocationMaxX1:u,referencePixelX0:d,referencePixelY0:h,physicalDeltaX:i,physicalDeltaY:o,physicalUnitsXDirection:a,physicalUnitsYDirection:s,referencePhysicalPixelValueY:g,referencePhysicalPixelValueX:p,regionSpatialFormat:v,regionDataType:y,regionFlags:m,transducerFrequency:w}})}function Z8(t,e){const{MetadataModules:r}=Ha;if(t===r.MULTIFRAME){const{metadata:i,frame:o}=k4e(e);if(!i)return;const{PerFrameFunctionalGroupsSequence:a,SharedFunctionalGroupsSequence:s,NumberOfFrames:c}=o$(i);if(a||c>1){const{shared:l,perFrame:f}=i$(a,s,o);return{NumberOfFrames:c,PerFrameFunctionalInformation:f,SharedFunctionalInformation:l}}return{NumberOfFrames:c}}const n=Y8.get(e);if(n){if(t===r.GENERAL_STUDY)return{studyDescription:Ht(n["00081030"]),studyDate:lr.parseDA(Ht(n["00080020"])),studyTime:lr.parseTM(Ht(n["00080030"],0,"")),accessionNumber:Ht(n["00080050"])};if(t===r.GENERAL_SERIES)return{modality:Ht(n["00080060"]),seriesInstanceUID:Ht(n["0020000E"]),seriesDescription:Ht(n["0008103E"]),seriesNumber:Fn(n["00200011"]),studyInstanceUID:Ht(n["0020000D"]),seriesDate:lr.parseDA(Ht(n["00080021"])),seriesTime:lr.parseTM(Ht(n["00080031"],0,"")),acquisitionDate:lr.parseDA(Ht(n["00080022"])),acquisitionTime:lr.parseTM(Ht(n["00080032"],0,""))};if(t===r.GENERAL_IMAGE)return{sopInstanceUID:Ht(n["00080018"]),instanceNumber:Fn(n["00200013"]),lossyImageCompression:Ht(n["00282110"]),lossyImageCompressionRatio:Fn(n["00282112"]),lossyImageCompressionMethod:Ht(n["00282114"])};if(t===r.PATIENT)return{patientID:Ht(n["00100020"]),patientName:Ht(n["00100010"])};if(t===r.PATIENT_STUDY)return{patientAge:Fn(n["00101010"]),patientSize:Fn(n["00101020"]),patientSex:Ht(n["00100040"]),patientWeight:Fn(n["00101030"])};if(t===r.NM_MULTIFRAME_GEOMETRY){const i=Ht(n["00080060"]),o=J8(n,2);return{modality:i,imageType:Ht(n["00080008"]),imageSubType:o,imageOrientationPatient:N7(n),imagePositionPatient:k7(n),sliceThickness:Fn(n["00180050"]),spacingBetweenSlices:Fn(n["00180088"]),pixelSpacing:So(n["00280030"],2),numberOfFrames:Fn(n["00280008"]),isNMReconstructable:ug(o)&&i.includes("NM")}}if(t===r.IMAGE_PLANE){let i=N7(n),o=k7(n);const a=So(n["00280030"],2);let s=null,c=null,l=null,f=null,u=!1;return a?(c=a[0],s=a[1]):(u=!0,c=1,s=1),i?(l=[parseFloat(i[0]),parseFloat(i[1]),parseFloat(i[2])],f=[parseFloat(i[3]),parseFloat(i[4]),parseFloat(i[5])]):(l=[1,0,0],f=[0,1,0],u=!0,i=[...l,...f]),o||(o=[0,0,0],u=!0),{frameOfReferenceUID:Ht(n["00200052"]),rows:Fn(n["00280010"]),columns:Fn(n["00280011"]),imageOrientationPatient:i,rowCosines:l,columnCosines:f,imagePositionPatient:o,sliceThickness:Fn(n["00180050"]),sliceLocation:Fn(n["00201041"]),pixelSpacing:a,rowPixelSpacing:c,columnPixelSpacing:s,usingDefaultValues:u}}if(t===r.ULTRASOUND_ENHANCED_REGION)return V7(n);if(t===r.CALIBRATION&&Ht(n["00080060"])==="US")return{sequenceOfUltrasoundRegions:V7(n)};if(t===r.IMAGE_URL)return j4e(e,n);if(t===r.CINE)return H4e(e,n);if(t===r.IMAGE_PIXEL)return{samplesPerPixel:Fn(n["00280002"]),photometricInterpretation:Ht(n["00280004"]),rows:Fn(n["00280010"]),columns:Fn(n["00280011"]),bitsAllocated:Fn(n["00280100"]),bitsStored:Fn(n["00280101"]),highBit:Ht(n["00280102"]),pixelRepresentation:Fn(n["00280103"]),planarConfiguration:Fn(n["00280006"]),pixelAspectRatio:Ht(n["00280034"]),smallestPixelValue:Fn(n["00280106"]),largestPixelValue:Fn(n["00280107"]),redPaletteColorLookupTableDescriptor:So(n["00281101"]),greenPaletteColorLookupTableDescriptor:So(n["00281102"]),bluePaletteColorLookupTableDescriptor:So(n["00281103"]),redPaletteColorLookupTableData:So(n["00281201"]),greenPaletteColorLookupTableData:So(n["00281202"]),bluePaletteColorLookupTableData:So(n["00281203"])};if(t===r.VOI_LUT)return{windowCenter:So(n["00281050"],1),windowWidth:So(n["00281051"],1),voiLUTFunction:Ht(n["00281056"])};if(t===r.MODALITY_LUT)return{rescaleIntercept:Fn(n["00281052"]),rescaleSlope:Fn(n["00281053"]),rescaleType:Ht(n["00281054"])};if(t===r.SOP_COMMON)return{sopClassUID:Ht(n["00080016"]),sopInstanceUID:Ht(n["00080018"])};if(t===r.PET_ISOTOPE){const i=Ht(n["00540016"]);return i===void 0?void 0:{radiopharmaceuticalInfo:{radiopharmaceuticalStartTime:lr.parseTM(Ht(i["00181072"],0,"")),radiopharmaceuticalStartDateTime:Ht(i["00181078"],0,""),radionuclideTotalDose:Fn(i["00181074"]),radionuclideHalfLife:Fn(i["00181075"])}}}if(t===r.OVERLAY_PLANE)return A4e(n);if(t==="transferSyntax")return c$(e,n);if(t===r.PET_SERIES)return{correctedImage:Ht(n["00280051"]),units:Ht(n["00541001"]),decayCorrection:Ht(n["00541102"])};if(t===r.PET_IMAGE)return{frameReferenceTime:Fn(n["00541300"]),actualFrameDuration:Fn(n["00181242"])};if(t==="instance")return zz(e,Z8,$z)}}function j4e(t,e){const{transferSyntaxUID:r}=c$(t,e),n=OV(r),i=t.substring(7),o=i.replace("/frames/","/thumbnail/");let a=i.replace("/frames/","/rendered/");return n&&(a=a.replace("/rendered/1","/rendered")),{isVideo:n,rendered:a,thumbnail:o}}function H4e(t,e){return{cineRate:Ht(e["00180040"]),numberOfFrames:Fn(e["00280008"])}}function c$(t,e){return{transferSyntaxUID:Ht(e["00020010"])||Ht(e["00083002"])}}function K4e(t,e,r={},n={}){const i=Rm(),{retrieveOptions:o={},streamingData:a}=n,s=a.chunkSize||X4e(e,o,"chunkSize")||65536,c=f=>{if(typeof i.errorInterceptor=="function"){const u=new Error("request failed");i.errorInterceptor(u)}else console.warn("rangeRequest:Caught",f)};return new Promise(async(f,u)=>{const d=Object.assign({},r);Object.keys(d).forEach(function(h){(d[h]===null||d[h]===void 0)&&delete d[h]});try{a.encodedData||(a.chunkSize=s,a.rangesFetched=0);const h=Y4e(a,o),{encodedData:g,responseHeaders:p}=await q4e(t,d,h,a),v=p.get("content-type"),{totalBytes:y}=a,m=y===g.byteLength,w=W8(v,g,{isPartial:!0}),x=z8(o,m||w.extractDone);f({...w,imageQualityStatus:x,percentComplete:w.extractDone?100:s*100/y})}catch(h){c(h),console.error(h),u(h)}})}async function q4e(t,e,r,n){r&&(e=Object.assign(e,{Range:`bytes=${r[0]}-${r[1]}`}));let{encodedData:i}=n;if(r[1]&&(i==null?void 0:i.byteLength)>r[1])return n;const o=await fetch(t,{headers:e,signal:void 0}),a=await o.arrayBuffer(),s=new Uint8Array(a),{status:c}=o;let l;i?(l=new Uint8Array(i.length+s.length),l.set(i,0),l.set(s,i.length),n.rangesFetched=1):(l=new Uint8Array(s.length),l.set(s,0),n.rangesFetched++),n.encodedData=i=l,n.responseHeaders=o.headers;const f=o.headers.get("Content-Range");return f?n.totalBytes=Number(f.split("/")[1]):c!==206||!r?n.totalBytes=i==null?void 0:i.byteLength:r[1]===""||(i==null?void 0:i.length)<r[1]?n.totalBytes=i.byteLength:n.totalBytes=Number.MAX_SAFE_INTEGER,n}function X4e(t,e,r){const n=e[r];if(typeof n!="function")return n;const i=Y8.get(t);return n(i,t)}function Y4e(t,e){const{totalBytes:r,encodedData:n,chunkSize:i=65536}=t,{rangeIndex:o=0}=e;return o===-1&&(!r||!n)?[0,""]:o===-1||(n==null?void 0:n.byteLength)>r-i?[(n==null?void 0:n.byteLength)||0,""]:[(n==null?void 0:n.byteLength)||0,i*(o+1)-1]}function Q8(t,e,r="application/octet-stream",n){const{streamingData:i,retrieveOptions:o={}}=n||{},a={Accept:r};let s=o.urlArguments?`${t}${t.indexOf("?")===-1?"?":"&"}${o.urlArguments}`:t;if(o.framesPath&&(s=s.replace("/frames/",o.framesPath)),(i==null?void 0:i.url)!==s&&(n.streamingData={url:s}),o.rangeIndex!==void 0)return K4e(s,e,a,n);if(o.streaming)return Vz(s,e,a,n);const c=rx(s,e,a),{xhr:l}=c;return c.then(function(f){const u=l.getResponseHeader("Content-Type")||"application/octet-stream",d=W8(u,new Uint8Array(f));return d.imageQualityStatus=z8(o,!0),d})}const{ProgressiveIterator:F7}=pn,{ImageQualityStatus:U7}=Ha,J4e=new Set(["3.2.840.10008.1.2.4.96","1.2.840.10008.1.2.4.202","1.2.840.10008.1.2.4.203"]);function Z4e(t){const e="1.2.840.10008.1.2";if(!t)return e;const r=t.split(";"),n={};r.forEach(o=>{const a=o.split("=");if(a.length!==2)return;const s=a[1].trim().replace(/"/g,"");n[a[0].trim()]=s});const i={"image/jpeg":"1.2.840.10008.1.2.4.50","image/x-dicom-rle":"1.2.840.10008.1.2.5","image/x-jls":"1.2.840.10008.1.2.4.80","image/jls":"1.2.840.10008.1.2.4.80","image/jll":"1.2.840.10008.1.2.4.70","image/jp2":"1.2.840.10008.1.2.4.90","image/jpx":"1.2.840.10008.1.2.4.92","image/jphc":"3.2.840.10008.1.2.4.96","image/jxl":"1.2.840.10008.1.2.4.140"};return n["transfer-syntax"]?n["transfer-syntax"]:t&&!Object.keys(n).length&&i[t]?i[t]:n.type&&i[n.type]?i[n.type]:i[t]?i[t]:e}function Q4e(){return qh}const eEe="multipart/related; type=application/octet-stream; transfer-syntax=*";function l$(t,e={}){const r=Q4e(),n=new Date().getTime(),i=new F7("decompress");async function o(f,u,d){i.generate(async h=>{var v;const g=F7.as(Q8(f,u,d,e));let p=10;for await(const y of g){const{pixelData:m,imageQualityStatus:w=U7.FULL_RESOLUTION,percentComplete:x,done:C=!0,extractDone:S=!0}=y,T=Z4e(y.contentType);if(!S&&!J4e.has(T))continue;const _=y.decodeLevel??(w===U7.FULL_RESOLUTION?0:tEe(x,(v=e.retrieveOptions)==null?void 0:v.decodeLevel));if(!(!C&&p<=_))try{const E={...e,decodeLevel:_},b=await sx(u,m,T,E),D=new Date().getTime();b.loadTimeInMS=D-n,b.transferSyntaxUID=T,b.imageQualityStatus=w,h.add(b,C),p=_}catch(E){if(S)throw console.warn("Couldn't decode",E),E}}})}const a=e.requestType||Qt.Interaction,s=e.additionalDetails||{imageId:t},c=e.priority===void 0?5:e.priority,l=t.substring(7);return r.addRequest(o.bind(this,l,t,eEe),a,s,c),{promise:i.getDonePromise(),cancelFn:void 0}}function tEe(t,e=4){const r=t/100-.02;return r>1/4?Math.min(e,0):r>1/16?Math.min(e,1):r>1/64?Math.min(e,2):Math.min(e,3)}function u$(){ld("wadors",l$),zh(Z8)}const nEe={getNumberString:L4e,getNumberValue:Fn,getNumberValues:So,getValue:Ht,metaDataProvider:Z8},rEe={metaData:nEe,findIndexOfString:MT,getPixelData:Q8,loadImage:l$,metaDataManager:Y8,register:u$};function iEe(){u$(),r$()}const oEe=()=>new Worker(new URL("/static/dv3d/assets/decodeImageFrameWorker-DhtpjVX0.js",import.meta.url),{type:"module"});function f$(t={}){kz(t),iEe();const e=fl(),r=(t==null?void 0:t.maxWebWorkers)||aEe();e.registerWorker("dicomImageLoader",oEe,{maxWorkerInstances:r})}function aEe(){return typeof navigator<"u"&&navigator.hardwareConcurrency?Math.max(1,Math.floor(navigator.hardwareConcurrency/2)):1}function sEe(t,e){if(e=e||t.transferSyntax,t.bitsAllocated===8&&e==="1.2.840.10008.1.2.4.50"&&(t.samplesPerPixel===3||t.samplesPerPixel===4))return!0}const cEe={IMPLICIT_VR_LITTLE_ENDIAN:"1.2.840.10008.1.2",EXPLICIT_VR_LITTLE_ENDIAN:"1.2.840.10008.1.2.1",DEFLATED_EXPLICIT_VR_LITTLE_ENDIAN:"1.2.840.10008.1.2.1.99",EXPLICIT_VR_BIG_ENDIAN:"1.2.840.10008.1.2.2",JPEG_BASELINE_PROCESS_1:"1.2.840.10008.1.2.4.50",JPEG_EXTENDED_PROCESS_2_4:"1.2.840.10008.1.2.4.51",JPEG_EXTENDED_PROCESSES_3_5:"1.2.840.10008.1.2.4.52",JPEG_SPECTRAL_SELECTION_NONHIERARCHICAL_PROCESSES_6_8:"1.2.840.10008.1.2.4.53",JPEG_SPECTRAL_SELECTION_NONHIERARCHICAL_PROCESSES_7_9:"1.2.840.10008.1.2.4.54",JPEG_FULL_PROGRESSION_NONHIERARCHICAL_PROCESSES_10_12:"1.2.840.10008.1.2.4.55",JPEG_FULL_PROGRESSION_NONHIERARCHICAL_PROCESSES_11_13:"1.2.840.10008.1.2.4.56",JPEG_LOSSLESS_NONHIERARCHICAL_PROCESS_14:"1.2.840.10008.1.2.4.57",JPEG_LOSSLESS_NONHIERARCHICAL_PROCESS_15:"1.2.840.10008.1.2.4.58",JPEG_EXTENDED_HIERARCHICAL_PROCESSES_16_18:"1.2.840.10008.1.2.4.59",JPEG_EXTENDED_HIERARCHICAL_PROCESSES_17_19:"1.2.840.10008.1.2.4.60",JPEG_SPECTRAL_SELECTION_HIERARCHICAL_PROCESSES_20_22:"1.2.840.10008.1.2.4.61",JPEG_SPECTRAL_SELECTION_HIERARCHICAL_PROCESSES_21_23:"1.2.840.10008.1.2.4.62",JPEG_FULL_PROGRESSION_HIERARCHICAL_PROCESSES_24_26:"1.2.840.10008.1.2.4.63",JPEG_FULL_PROGRESSION_HIERARCHICAL_PROCESSES_25_27:"1.2.840.10008.1.2.4.64",JPEG_LOSSLESS_NONHIERARCHICAL_PROCESS_28:"1.2.840.10008.1.2.4.65",JPEG_LOSSLESS_NONHIERARCHICAL_PROCESS_29:"1.2.840.10008.1.2.4.66",JPEG_LOSSLESS_NONHIERARCHICAL_FIRST_ORDER_PREDICTION_PROCESS_14:"1.2.840.10008.1.2.4.70",JPEG_LS_LOSSLESS_IMAGE_COMPRESSION:"1.2.840.10008.1.2.4.80",JPEG_LS_LOSSY_NEAR_LOSSLESS_IMAGE_COMPRESSION:"1.2.840.10008.1.2.4.81",JPEG_2000_IMAGE_COMPRESSION_LOSSLESS_ONLY:"1.2.840.10008.1.2.4.90",JPEG_2000_IMAGE_COMPRESSION:"1.2.840.10008.1.2.4.91",JPEG_2000_PART_2_MULTICOMPONENT_IMAGE_COMPRESSION_LOSSLESS_ONLY:"1.2.840.10008.1.2.4.92",JPEG_2000_PART_2_MULTICOMPONENT_IMAGE_COMPRESSION:"1.2.840.10008.1.2.4.93",JPIP_REFERENCED:"1.2.840.10008.1.2.4.94",JPIP_REFERENCED_DEFLATE:"1.2.840.10008.1.2.4.95",MPEG2_MAIN_PROFILE_MAIN_LEVEL:"1.2.840.10008.1.2.4.100",MPEG4_AVC_H264_HIGH_PROFILE_LEVEL_4_1:"1.2.840.10008.1.2.4.101",MPEG4_AVC_H264_BD_COMPATIBLE_HIGH_PROFILE_LEVEL_4_1:"1.2.840.10008.1.2.4.102",MPEG4_AVC_H264_HIGH_PROFILE_FOR_2D_VIDEO:"1.2.840.10008.1.2.4.103",MPEG4_AVC_H264_HIGH_PROFILE_FOR_3D_VIDEO:"1.2.840.10008.1.2.4.104",JPIP_LOSSLESS:"1.2.840.10008.1.2.4.96",JPIP_PART2_MULTICOMPONENT_IMAGE_COMPRESSION:"1.2.840.10008.1.2.4.97",RFC_2557_MIME_ENCAPSULATION:"1.2.840.10008.1.2.6.1",JPEG_XR_IMAGE_COMPRESSION:"1.2.840.10008.1.2.6.2",JPEG_2000_IMAGE_COMPRESSION_LOSSLESS_ONLY_RETIRED:"1.2.840.10008.1.2.4.90R",JPEG_2000_IMAGE_COMPRESSION_RETIRED:"1.2.840.10008.1.2.4.91R",JPEG_2000_PART_2_MULTICOMPONENT_IMAGE_COMPRESSION_LOSSLESS_ONLY_RETIRED:"1.2.840.10008.1.2.4.92R",JPEG_2000_PART_2_MULTICOMPONENT_IMAGE_COMPRESSION_RETIRED:"1.2.840.10008.1.2.4.93R"},lEe=Object.freeze(Object.defineProperty({__proto__:null,transferSyntaxes:cEe},Symbol.toStringTag,{value:"Module"}));function uEe(t,e){const{rows:r,columns:n,data:i}=t,{rows:o,columns:a,data:s}=e,c=[],l=[],f=[];for(let u=0;u<a;u++){const d=u*(n-1)/(a-1);c[u]=Math.floor(d),l[u]=Math.min(c[u]+1,n-1),f[u]=d-c[u]}for(let u=0;u<o;u++){const d=u*(r-1)/(o-1),h=Math.floor(d)*n,g=Math.min(h+n,(r-1)*n),p=d-Math.floor(d),v=1-p,y=u*a;for(let m=0;m<a;m++){const w=i[h+c[m]],x=i[h+l[m]],C=i[g+c[m]],S=i[g+l[m]],T=1-f[m];s[y+m]=(w*T+x*f[m])*v+(C*T+S*f[m])*p}}return s}function fEe(t,e){const{rows:r,columns:n,pixelData:i,samplesPerPixel:o=1}=t,{rows:a,columns:s,pixelData:c}=e,l=[];for(let f=0;f<s;f++){const u=f*(n-1)/(s-1);l[f]=Math.floor(u)*o}for(let f=0;f<a;f++){const u=f*(r-1)/(a-1),d=Math.floor(u)*n*o,h=f*s;for(let g=0;g<s;g++)for(let p=0;p<o;p++)c[h+g+p]=i[d+l[g]+p]}return c}async function B7(t,e){let r=e.buffer,n=e.byteOffset;const i=e.length;if(t.bitsAllocated===16)n%2&&(r=r.slice(n),n=0),t.pixelRepresentation===0?t.pixelData=new Uint16Array(r,n,i/2):t.pixelData=new Int16Array(r,n,i/2);else if(t.bitsAllocated===8||t.bitsAllocated===1)t.pixelData=e;else if(t.bitsAllocated===32){if(n%2&&(r=r.slice(n),n=0),t.floatPixelData||t.doubleFloatPixelData)throw new Error("Float pixel data is not supported for parsing into ImageFrame");t.pixelRepresentation===0?t.pixelData=new Uint32Array(r,n,i/4):t.pixelRepresentation===1?t.pixelData=new Int32Array(r,n,i/4):t.pixelData=new Float32Array(r,n,i/4)}return t}function dEe(t){return(t&255)<<8|t>>8&255}async function hEe(t,e){if(t.bitsAllocated===16){let r=e.buffer,n=e.byteOffset;const i=e.length;n%2&&(r=r.slice(n),n=0),t.pixelRepresentation===0?t.pixelData=new Uint16Array(r,n,i/2):t.pixelData=new Int16Array(r,n,i/2);for(let o=0;o<t.pixelData.length;o++)t.pixelData[o]=dEe(t.pixelData[o])}else t.bitsAllocated===8&&(t.pixelData=e);return t}async function gEe(t,e){if(t.bitsAllocated===8)return t.planarConfiguration?mEe(t,e):pEe(t,e);if(t.bitsAllocated===16)return vEe(t,e);throw new Error("unsupported pixel format for RLE")}function pEe(t,e){const r=e,n=t.rows*t.columns,i=new ArrayBuffer(n*t.samplesPerPixel),o=new DataView(r.buffer,r.byteOffset),a=new Int8Array(r.buffer,r.byteOffset),s=new Int8Array(i);let c=0;const l=o.getInt32(0,!0);for(let f=0;f<l;++f){c=f;let u=o.getInt32((f+1)*4,!0),d=o.getInt32((f+2)*4,!0);d===0&&(d=r.length);const h=n*l;for(;u<d;){const g=a[u++];if(g>=0&&g<=127)for(let p=0;p<g+1&&c<h;++p)s[c]=a[u++],c+=t.samplesPerPixel;else if(g<=-1&&g>=-127){const p=a[u++];for(let v=0;v<-g+1&&c<h;++v)s[c]=p,c+=t.samplesPerPixel}}}return t.pixelData=new Uint8Array(i),t}function mEe(t,e){const r=e,n=t.rows*t.columns,i=new ArrayBuffer(n*t.samplesPerPixel),o=new DataView(r.buffer,r.byteOffset),a=new Int8Array(r.buffer,r.byteOffset),s=new Int8Array(i);let c=0;const l=o.getInt32(0,!0);for(let f=0;f<l;++f){c=f*n;let u=o.getInt32((f+1)*4,!0),d=o.getInt32((f+2)*4,!0);d===0&&(d=r.length);const h=n*l;for(;u<d;){const g=a[u++];if(g>=0&&g<=127)for(let p=0;p<g+1&&c<h;++p)s[c]=a[u++],c++;else if(g<=-1&&g>=-127){const p=a[u++];for(let v=0;v<-g+1&&c<h;++v)s[c]=p,c++}}}return t.pixelData=new Uint8Array(i),t}function vEe(t,e){const r=e,n=t.rows*t.columns,i=new ArrayBuffer(n*t.samplesPerPixel*2),o=new DataView(r.buffer,r.byteOffset),a=new Int8Array(r.buffer,r.byteOffset),s=new Int8Array(i),c=o.getInt32(0,!0);for(let l=0;l<c;++l){let f=0;const u=l===0?1:0;let d=o.getInt32((l+1)*4,!0),h=o.getInt32((l+2)*4,!0);for(h===0&&(h=r.length);d<h;){const g=a[d++];if(g>=0&&g<=127)for(let p=0;p<g+1&&f<n;++p)s[f*2+u]=a[d++],f++;else if(g<=-1&&g>=-127){const p=a[d++];for(let v=0;v<-g+1&&f<n;++v)s[f*2+u]=p,f++}}}return t.pixelRepresentation===0?t.pixelData=new Uint16Array(i):t.pixelData=new Int16Array(i),t}var d$={exports:{}};(function(t,e){var r=(()=>{var n=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename<"u"&&(n=n||__filename),function(i){i=i||{};var o=typeof i<"u"?i:{},a,s;o.ready=new Promise(function(R,V){a=R,s=V});var c=Object.assign({},o),l="./this.program",f=(R,V)=>{throw V},u=typeof window=="object",d=typeof importScripts=="function",h=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",g="";function p(R){return o.locateFile?o.locateFile(R,g):g+R}var v,y,m;if(h){var w=el,x=el;d?g=x.dirname(g)+"/":g=__dirname+"/",v=(R,V)=>(R=pe(R)?new URL(R):x.normalize(R),w.readFileSync(R,V?void 0:"utf8")),m=R=>{var V=v(R,!0);return V.buffer||(V=new Uint8Array(V)),V},y=(R,V,Y)=>{R=pe(R)?new URL(R):x.normalize(R),w.readFile(R,function(ye,xe){ye?Y(ye):V(xe.buffer)})},process.argv.length>1&&(l=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),process.on("uncaughtException",function(R){if(!(R instanceof pt))throw R}),process.on("unhandledRejection",function(R){throw R}),f=(R,V)=>{throw process.exitCode=R,V},o.inspect=function(){return"[Emscripten Module object]"}}else(u||d)&&(d?g=self.location.href:typeof document<"u"&&document.currentScript&&(g=document.currentScript.src),n&&(g=n),g.indexOf("blob:")!==0?g=g.substr(0,g.replace(/[?#].*/,"").lastIndexOf("/")+1):g="",v=R=>{var V=new XMLHttpRequest;return V.open("GET",R,!1),V.send(null),V.responseText},d&&(m=R=>{var V=new XMLHttpRequest;return V.open("GET",R,!1),V.responseType="arraybuffer",V.send(null),new Uint8Array(V.response)}),y=(R,V,Y)=>{var ye=new XMLHttpRequest;ye.open("GET",R,!0),ye.responseType="arraybuffer",ye.onload=()=>{if(ye.status==200||ye.status==0&&ye.response){V(ye.response);return}Y()},ye.onerror=Y,ye.send(null)});var C=o.print||console.log.bind(console),S=o.printErr||console.warn.bind(console);Object.assign(o,c),c=null,o.arguments&&o.arguments,o.thisProgram&&(l=o.thisProgram),o.quit&&(f=o.quit);var T;o.wasmBinary&&(T=o.wasmBinary),o.noExitRuntime,typeof WebAssembly!="object"&&se("no native wasm support detected");var _,E=!1;function b(R,V){R||se(V)}var D=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function I(R,V,Y){for(var ye=V+Y,xe=V;R[xe]&&!(xe>=ye);)++xe;if(xe-V>16&&R.buffer&&D)return D.decode(R.subarray(V,xe));for(var Ce="";V<xe;){var Te=R[V++];if(!(Te&128)){Ce+=String.fromCharCode(Te);continue}var Me=R[V++]&63;if((Te&224)==192){Ce+=String.fromCharCode((Te&31)<<6|Me);continue}var Ae=R[V++]&63;if((Te&240)==224?Te=(Te&15)<<12|Me<<6|Ae:Te=(Te&7)<<18|Me<<12|Ae<<6|R[V++]&63,Te<65536)Ce+=String.fromCharCode(Te);else{var qe=Te-65536;Ce+=String.fromCharCode(55296|qe>>10,56320|qe&1023)}}return Ce}function P(R,V){return R?I(F,R,V):""}function O(R,V,Y,ye){if(!(ye>0))return 0;for(var xe=Y,Ce=Y+ye-1,Te=0;Te<R.length;++Te){var Me=R.charCodeAt(Te);if(Me>=55296&&Me<=57343){var Ae=R.charCodeAt(++Te);Me=65536+((Me&1023)<<10)|Ae&1023}if(Me<=127){if(Y>=Ce)break;V[Y++]=Me}else if(Me<=2047){if(Y+1>=Ce)break;V[Y++]=192|Me>>6,V[Y++]=128|Me&63}else if(Me<=65535){if(Y+2>=Ce)break;V[Y++]=224|Me>>12,V[Y++]=128|Me>>6&63,V[Y++]=128|Me&63}else{if(Y+3>=Ce)break;V[Y++]=240|Me>>18,V[Y++]=128|Me>>12&63,V[Y++]=128|Me>>6&63,V[Y++]=128|Me&63}}return V[Y]=0,Y-xe}function L(R,V,Y){return O(R,F,V,Y)}function B(R){for(var V=0,Y=0;Y<R.length;++Y){var ye=R.charCodeAt(Y);ye<=127?V++:ye<=2047?V+=2:ye>=55296&&ye<=57343?(V+=4,++Y):V+=3}return V}var H,A,F,G,X,ee,ce,Se,we;function _e(R){H=R,o.HEAP8=A=new Int8Array(R),o.HEAP16=G=new Int16Array(R),o.HEAP32=ee=new Int32Array(R),o.HEAPU8=F=new Uint8Array(R),o.HEAPU16=X=new Uint16Array(R),o.HEAPU32=ce=new Uint32Array(R),o.HEAPF32=Se=new Float32Array(R),o.HEAPF64=we=new Float64Array(R)}o.INITIAL_MEMORY;var Ve,Ge=[],Ne=[],j=[];function M(){if(o.preRun)for(typeof o.preRun=="function"&&(o.preRun=[o.preRun]);o.preRun.length;)J(o.preRun.shift());dt(Ge)}function q(){dt(Ne)}function K(){if(o.postRun)for(typeof o.postRun=="function"&&(o.postRun=[o.postRun]);o.postRun.length;)ie(o.postRun.shift());dt(j)}function J(R){Ge.unshift(R)}function re(R){Ne.unshift(R)}function ie(R){j.unshift(R)}var Re=0,Fe=null;function je(R){Re++,o.monitorRunDependencies&&o.monitorRunDependencies(Re)}function Xe(R){if(Re--,o.monitorRunDependencies&&o.monitorRunDependencies(Re),Re==0&&Fe){var V=Fe;Fe=null,V()}}function se(R){o.onAbort&&o.onAbort(R),R="Aborted("+R+")",S(R),E=!0,R+=". Build with -sASSERTIONS for more info.";var V=new WebAssembly.RuntimeError(R);throw s(V),V}var ue="data:application/octet-stream;base64,";function Pe(R){return R.startsWith(ue)}function pe(R){return R.startsWith("file://")}var Ee;Ee="libjpegturbowasm_decode.wasm",Pe(Ee)||(Ee=p(Ee));function Qe(R){try{if(R==Ee&&T)return new Uint8Array(T);if(m)return m(R);throw"both async and sync fetching of the wasm failed"}catch(V){se(V)}}function fe(){if(!T&&(u||d)){if(typeof fetch=="function"&&!pe(Ee))return fetch(Ee,{credentials:"same-origin"}).then(function(R){if(!R.ok)throw"failed to load wasm binary file at '"+Ee+"'";return R.arrayBuffer()}).catch(function(){return Qe(Ee)});if(y)return new Promise(function(R,V){y(Ee,function(Y){R(new Uint8Array(Y))},V)})}return Promise.resolve().then(function(){return Qe(Ee)})}function ft(){var R={a:de};function V(Te,Me){var Ae=Te.exports;o.asm=Ae,_=o.asm.K,_e(_.buffer),Ve=o.asm.M,re(o.asm.L),Xe()}je();function Y(Te){V(Te.instance)}function ye(Te){return fe().then(function(Me){return WebAssembly.instantiate(Me,R)}).then(function(Me){return Me}).then(Te,function(Me){S("failed to asynchronously prepare wasm: "+Me),se(Me)})}function xe(){return!T&&typeof WebAssembly.instantiateStreaming=="function"&&!Pe(Ee)&&!pe(Ee)&&!h&&typeof fetch=="function"?fetch(Ee,{credentials:"same-origin"}).then(function(Te){var Me=WebAssembly.instantiateStreaming(Te,R);return Me.then(Y,function(Ae){return S("wasm streaming compile failed: "+Ae),S("falling back to ArrayBuffer instantiation"),ye(Y)})}):ye(Y)}if(o.instantiateWasm)try{var Ce=o.instantiateWasm(R,V);return Ce}catch(Te){S("Module.instantiateWasm callback failed with error: "+Te),s(Te)}return xe().catch(s),{}}function pt(R){this.name="ExitStatus",this.message="Program terminated with exit("+R+")",this.status=R}function dt(R){for(;R.length>0;)R.shift()(o)}function Ue(R){this.excPtr=R,this.ptr=R-24,this.set_type=function(V){ce[this.ptr+4>>2]=V},this.get_type=function(){return ce[this.ptr+4>>2]},this.set_destructor=function(V){ce[this.ptr+8>>2]=V},this.get_destructor=function(){return ce[this.ptr+8>>2]},this.set_refcount=function(V){ee[this.ptr>>2]=V},this.set_caught=function(V){V=V?1:0,A[this.ptr+12>>0]=V},this.get_caught=function(){return A[this.ptr+12>>0]!=0},this.set_rethrown=function(V){V=V?1:0,A[this.ptr+13>>0]=V},this.get_rethrown=function(){return A[this.ptr+13>>0]!=0},this.init=function(V,Y){this.set_adjusted_ptr(0),this.set_type(V),this.set_destructor(Y),this.set_refcount(0),this.set_caught(!1),this.set_rethrown(!1)},this.add_ref=function(){var V=ee[this.ptr>>2];ee[this.ptr>>2]=V+1},this.release_ref=function(){var V=ee[this.ptr>>2];return ee[this.ptr>>2]=V-1,V===1},this.set_adjusted_ptr=function(V){ce[this.ptr+16>>2]=V},this.get_adjusted_ptr=function(){return ce[this.ptr+16>>2]},this.get_exception_ptr=function(){var V=te(this.get_type());if(V)return ce[this.excPtr>>2];var Y=this.get_adjusted_ptr();return Y!==0?Y:this.excPtr}}function nt(R,V,Y){var ye=new Ue(R);throw ye.init(V,Y),R}var at={};function ot(R){for(;R.length;){var V=R.pop(),Y=R.pop();Y(V)}}function lt(R){return this.fromWireType(ee[R>>2])}var _t={},vt={},Mt={},Ft=48,wn=57;function Dn(R){if(R===void 0)return"_unknown";R=R.replace(/[^a-zA-Z0-9_]/g,"$");var V=R.charCodeAt(0);return V>=Ft&&V<=wn?"_"+R:R}function Nt(R,V){return R=Dn(R),new Function("body","return function "+R+`() {
|
||
"use strict"; return body.apply(this, arguments);
|
||
};
|
||
`)(V)}function xn(R,V){var Y=Nt(V,function(ye){this.name=V,this.message=ye;var xe=new Error(ye).stack;xe!==void 0&&(this.stack=this.toString()+`
|
||
`+xe.replace(/^Error(:[^\n]*)?\n/,""))});return Y.prototype=Object.create(R.prototype),Y.prototype.constructor=Y,Y.prototype.toString=function(){return this.message===void 0?this.name:this.name+": "+this.message},Y}var Ui=void 0;function br(R){throw new Ui(R)}function Ye(R,V,Y){R.forEach(function(Me){Mt[Me]=V});function ye(Me){var Ae=Y(Me);Ae.length!==R.length&&br("Mismatched type converter count");for(var qe=0;qe<R.length;++qe)hi(R[qe],Ae[qe])}var xe=new Array(V.length),Ce=[],Te=0;V.forEach((Me,Ae)=>{vt.hasOwnProperty(Me)?xe[Ae]=vt[Me]:(Ce.push(Me),_t.hasOwnProperty(Me)||(_t[Me]=[]),_t[Me].push(()=>{xe[Ae]=vt[Me],++Te,Te===Ce.length&&ye(xe)}))}),Ce.length===0&&ye(xe)}function ut(R){var V=at[R];delete at[R];var Y=V.rawConstructor,ye=V.rawDestructor,xe=V.fields,Ce=xe.map(Te=>Te.getterReturnType).concat(xe.map(Te=>Te.setterArgumentType));Ye([R],Ce,Te=>{var Me={};return xe.forEach((Ae,qe)=>{var rt=Ae.fieldName,mt=Te[qe],ht=Ae.getter,zt=Ae.getterContext,Ut=Te[qe+xe.length],Gn=Ae.setter,ai=Ae.setterContext;Me[rt]={read:vi=>mt.fromWireType(ht(zt,vi)),write:(vi,bf)=>{var rs=[];Gn(ai,vi,Ut.toWireType(rs,bf)),ot(rs)}}}),[{name:V.name,fromWireType:function(Ae){var qe={};for(var rt in Me)qe[rt]=Me[rt].read(Ae);return ye(Ae),qe},toWireType:function(Ae,qe){for(var rt in Me)if(!(rt in qe))throw new TypeError('Missing field: "'+rt+'"');var mt=Y();for(rt in Me)Me[rt].write(mt,qe[rt]);return Ae!==null&&Ae.push(ye,mt),mt},argPackAdvance:8,readValueFromPointer:lt,destructorFunction:ye}]})}function Rt(R,V,Y,ye,xe){}function mn(R){switch(R){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+R)}}function Fr(){for(var R=new Array(256),V=0;V<256;++V)R[V]=String.fromCharCode(V);Lt=R}var Lt=void 0;function Cn(R){for(var V="",Y=R;F[Y];)V+=Lt[F[Y++]];return V}var Yt=void 0;function jt(R){throw new Yt(R)}function hi(R,V,Y={}){if(!("argPackAdvance"in V))throw new TypeError("registerType registeredInstance requires argPackAdvance");var ye=V.name;if(R||jt('type "'+ye+'" must have a positive integer typeid pointer'),vt.hasOwnProperty(R)){if(Y.ignoreDuplicateRegistrations)return;jt("Cannot register type '"+ye+"' twice")}if(vt[R]=V,delete Mt[R],_t.hasOwnProperty(R)){var xe=_t[R];delete _t[R],xe.forEach(Ce=>Ce())}}function Bi(R,V,Y,ye,xe){var Ce=mn(Y);V=Cn(V),hi(R,{name:V,fromWireType:function(Te){return!!Te},toWireType:function(Te,Me){return Me?ye:xe},argPackAdvance:8,readValueFromPointer:function(Te){var Me;if(Y===1)Me=A;else if(Y===2)Me=G;else if(Y===4)Me=ee;else throw new TypeError("Unknown boolean type size: "+V);return this.fromWireType(Me[Te>>Ce])},destructorFunction:null})}function Ao(R){if(!(this instanceof Di)||!(R instanceof Di))return!1;for(var V=this.$$.ptrType.registeredClass,Y=this.$$.ptr,ye=R.$$.ptrType.registeredClass,xe=R.$$.ptr;V.baseClass;)Y=V.upcast(Y),V=V.baseClass;for(;ye.baseClass;)xe=ye.upcast(xe),ye=ye.baseClass;return V===ye&&Y===xe}function jn(R){return{count:R.count,deleteScheduled:R.deleteScheduled,preservePointerOnDelete:R.preservePointerOnDelete,ptr:R.ptr,ptrType:R.ptrType,smartPtr:R.smartPtr,smartPtrType:R.smartPtrType}}function fo(R){function V(Y){return Y.$$.ptrType.registeredClass.name}jt(V(R)+" instance already deleted")}var Ei=!1;function xa(R){}function Bn(R){R.smartPtr?R.smartPtrType.rawDestructor(R.smartPtr):R.ptrType.registeredClass.rawDestructor(R.ptr)}function Ct(R){R.count.value-=1;var V=R.count.value===0;V&&Bn(R)}function Zt(R,V,Y){if(V===Y)return R;if(Y.baseClass===void 0)return null;var ye=Zt(R,V,Y.baseClass);return ye===null?null:Y.downcast(ye)}var ar={};function Qo(){return Object.keys(Zi).length}function Dr(){var R=[];for(var V in Zi)Zi.hasOwnProperty(V)&&R.push(Zi[V]);return R}var ho=[];function bi(){for(;ho.length;){var R=ho.pop();R.$$.deleteScheduled=!1,R.delete()}}var Ur=void 0;function Cs(R){Ur=R,ho.length&&Ur&&Ur(bi)}function go(){o.getInheritedInstanceCount=Qo,o.getLiveInheritedInstances=Dr,o.flushPendingDeletes=bi,o.setDelayFunction=Cs}var Zi={};function Ca(R,V){for(V===void 0&&jt("ptr should not be undefined");R.baseClass;)V=R.upcast(V),R=R.baseClass;return V}function gi(R,V){return V=Ca(R,V),Zi[V]}function Sa(R,V){(!V.ptrType||!V.ptr)&&br("makeClassHandle requires ptr and ptrType");var Y=!!V.smartPtrType,ye=!!V.smartPtr;return Y!==ye&&br("Both smartPtrType and smartPtr must be specified"),V.count={value:1},Gi(Object.create(R,{$$:{value:V}}))}function ln(R){var V=this.getPointee(R);if(!V)return this.destructor(R),null;var Y=gi(this.registeredClass,V);if(Y!==void 0){if(Y.$$.count.value===0)return Y.$$.ptr=V,Y.$$.smartPtr=R,Y.clone();var ye=Y.clone();return this.destructor(R),ye}function xe(){return this.isSmartPointer?Sa(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:V,smartPtrType:this,smartPtr:R}):Sa(this.registeredClass.instancePrototype,{ptrType:this,ptr:R})}var Ce=this.registeredClass.getActualType(V),Te=ar[Ce];if(!Te)return xe.call(this);var Me;this.isConst?Me=Te.constPointerType:Me=Te.pointerType;var Ae=Zt(V,this.registeredClass,Me.registeredClass);return Ae===null?xe.call(this):this.isSmartPointer?Sa(Me.registeredClass.instancePrototype,{ptrType:Me,ptr:Ae,smartPtrType:this,smartPtr:R}):Sa(Me.registeredClass.instancePrototype,{ptrType:Me,ptr:Ae})}function Gi(R){return typeof FinalizationRegistry>"u"?(Gi=V=>V,R):(Ei=new FinalizationRegistry(V=>{Ct(V.$$)}),Gi=V=>{var Y=V.$$,ye=!!Y.smartPtr;if(ye){var xe={$$:Y};Ei.register(V,xe,V)}return V},xa=V=>Ei.unregister(V),Gi(R))}function Ss(){if(this.$$.ptr||fo(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var R=Gi(Object.create(Object.getPrototypeOf(this),{$$:{value:jn(this.$$)}}));return R.$$.count.value+=1,R.$$.deleteScheduled=!1,R}function ea(){this.$$.ptr||fo(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&jt("Object already scheduled for deletion"),xa(this),Ct(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)}function Qi(){return!this.$$.ptr}function po(){return this.$$.ptr||fo(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&jt("Object already scheduled for deletion"),ho.push(this),ho.length===1&&Ur&&Ur(bi),this.$$.deleteScheduled=!0,this}function Zr(){Di.prototype.isAliasOf=Ao,Di.prototype.clone=Ss,Di.prototype.delete=ea,Di.prototype.isDeleted=Qi,Di.prototype.deleteLater=po}function Di(){}function sn(R,V,Y){if(R[V].overloadTable===void 0){var ye=R[V];R[V]=function(){return R[V].overloadTable.hasOwnProperty(arguments.length)||jt("Function '"+Y+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+R[V].overloadTable+")!"),R[V].overloadTable[arguments.length].apply(this,arguments)},R[V].overloadTable=[],R[V].overloadTable[ye.argCount]=ye}}function pi(R,V,Y){o.hasOwnProperty(R)?(jt("Cannot register public name '"+R+"' twice"),sn(o,R,R),o.hasOwnProperty(Y)&&jt("Cannot register multiple overloads of a function with the same number of arguments ("+Y+")!"),o[R].overloadTable[Y]=V):o[R]=V}function No(R,V,Y,ye,xe,Ce,Te,Me){this.name=R,this.constructor=V,this.instancePrototype=Y,this.rawDestructor=ye,this.baseClass=xe,this.getActualType=Ce,this.upcast=Te,this.downcast=Me,this.pureVirtualFunctions=[]}function Wi(R,V,Y){for(;V!==Y;)V.upcast||jt("Expected null or instance of "+Y.name+", got an instance of "+V.name),R=V.upcast(R),V=V.baseClass;return R}function Ii(R,V){if(V===null)return this.isReference&&jt("null is not a valid "+this.name),0;V.$$||jt('Cannot pass "'+ba(V)+'" as a '+this.name),V.$$.ptr||jt("Cannot pass deleted object as a pointer of type "+this.name);var Y=V.$$.ptrType.registeredClass,ye=Wi(V.$$.ptr,Y,this.registeredClass);return ye}function Ts(R,V){var Y;if(V===null)return this.isReference&&jt("null is not a valid "+this.name),this.isSmartPointer?(Y=this.rawConstructor(),R!==null&&R.push(this.rawDestructor,Y),Y):0;V.$$||jt('Cannot pass "'+ba(V)+'" as a '+this.name),V.$$.ptr||jt("Cannot pass deleted object as a pointer of type "+this.name),!this.isConst&&V.$$.ptrType.isConst&&jt("Cannot convert argument of type "+(V.$$.smartPtrType?V.$$.smartPtrType.name:V.$$.ptrType.name)+" to parameter type "+this.name);var ye=V.$$.ptrType.registeredClass;if(Y=Wi(V.$$.ptr,ye,this.registeredClass),this.isSmartPointer)switch(V.$$.smartPtr===void 0&&jt("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:V.$$.smartPtrType===this?Y=V.$$.smartPtr:jt("Cannot convert argument of type "+(V.$$.smartPtrType?V.$$.smartPtrType.name:V.$$.ptrType.name)+" to parameter type "+this.name);break;case 1:Y=V.$$.smartPtr;break;case 2:if(V.$$.smartPtrType===this)Y=V.$$.smartPtr;else{var xe=V.clone();Y=this.rawShare(Y,ji.toHandle(function(){xe.delete()})),R!==null&&R.push(this.rawDestructor,Y)}break;default:jt("Unsupporting sharing policy")}return Y}function ko(R,V){if(V===null)return this.isReference&&jt("null is not a valid "+this.name),0;V.$$||jt('Cannot pass "'+ba(V)+'" as a '+this.name),V.$$.ptr||jt("Cannot pass deleted object as a pointer of type "+this.name),V.$$.ptrType.isConst&&jt("Cannot convert argument of type "+V.$$.ptrType.name+" to parameter type "+this.name);var Y=V.$$.ptrType.registeredClass,ye=Wi(V.$$.ptr,Y,this.registeredClass);return ye}function _s(R){return this.rawGetPointee&&(R=this.rawGetPointee(R)),R}function eo(R){this.rawDestructor&&this.rawDestructor(R)}function zi(R){R!==null&&R.delete()}function $i(){Ir.prototype.getPointee=_s,Ir.prototype.destructor=eo,Ir.prototype.argPackAdvance=8,Ir.prototype.readValueFromPointer=lt,Ir.prototype.deleteObject=zi,Ir.prototype.fromWireType=ln}function Ir(R,V,Y,ye,xe,Ce,Te,Me,Ae,qe,rt){this.name=R,this.registeredClass=V,this.isReference=Y,this.isConst=ye,this.isSmartPointer=xe,this.pointeeType=Ce,this.sharingPolicy=Te,this.rawGetPointee=Me,this.rawConstructor=Ae,this.rawShare=qe,this.rawDestructor=rt,!xe&&V.baseClass===void 0?ye?(this.toWireType=Ii,this.destructorFunction=null):(this.toWireType=ko,this.destructorFunction=null):this.toWireType=Ts}function yc(R,V,Y){o.hasOwnProperty(R)||br("Replacing nonexistant public symbol"),o[R].overloadTable!==void 0&&Y!==void 0||(o[R]=V,o[R].argCount=Y)}function Vo(R,V,Y){var ye=o["dynCall_"+R];return Y&&Y.length?ye.apply(null,[V].concat(Y)):ye.call(null,V)}var Fo=[];function yr(R){var V=Fo[R];return V||(R>=Fo.length&&(Fo.length=R+1),Fo[R]=V=Ve.get(R)),V}function wc(R,V,Y){if(R.includes("j"))return Vo(R,V,Y);var ye=yr(V).apply(null,Y);return ye}function mi(R,V){var Y=[];return function(){return Y.length=0,Object.assign(Y,arguments),wc(R,V,Y)}}function Or(R,V){R=Cn(R);function Y(){return R.includes("j")?mi(R,V):yr(V)}var ye=Y();return typeof ye!="function"&&jt("unknown function pointer with signature "+R+": "+V),ye}var qa=void 0;function mo(R){var V=he(R),Y=Cn(V);return Q(V),Y}function ii(R,V){var Y=[],ye={};function xe(Ce){if(!ye[Ce]&&!vt[Ce]){if(Mt[Ce]){Mt[Ce].forEach(xe);return}Y.push(Ce),ye[Ce]=!0}}throw V.forEach(xe),new qa(R+": "+Y.map(mo).join([", "]))}function ta(R,V,Y,ye,xe,Ce,Te,Me,Ae,qe,rt,mt,ht){rt=Cn(rt),Ce=Or(xe,Ce),Me&&(Me=Or(Te,Me)),qe&&(qe=Or(Ae,qe)),ht=Or(mt,ht);var zt=Dn(rt);pi(zt,function(){ii("Cannot construct "+rt+" due to unbound types",[ye])}),Ye([R,V,Y],ye?[ye]:[],function(Ut){Ut=Ut[0];var Gn,ai;ye?(Gn=Ut.registeredClass,ai=Gn.instancePrototype):ai=Di.prototype;var vi=Nt(zt,function(){if(Object.getPrototypeOf(this)!==bf)throw new Yt("Use 'new' to construct "+rt);if(rs.constructor_body===void 0)throw new Yt(rt+" has no accessible constructor");var wb=rs.constructor_body[arguments.length];if(wb===void 0)throw new Yt("Tried to invoke ctor of "+rt+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(rs.constructor_body).toString()+") parameters instead!");return wb.apply(this,arguments)}),bf=Object.create(ai,{constructor:{value:vi}});vi.prototype=bf;var rs=new No(rt,vi,bf,ht,Gn,Ce,Me,qe),Am=new Ir(rt,rs,!0,!1,!1),fg=new Ir(rt+"*",rs,!1,!1,!1),yb=new Ir(rt+" const*",rs,!1,!0,!1);return ar[R]={pointerType:fg,constPointerType:yb},yc(zt,vi),[Am,fg,yb]})}function Es(R,V){for(var Y=[],ye=0;ye<R;ye++)Y.push(ce[V+ye*4>>2]);return Y}function Xa(R,V){if(!(R instanceof Function))throw new TypeError("new_ called with constructor type "+typeof R+" which is not a function");var Y=Nt(R.name||"unknownFunctionName",function(){});Y.prototype=R.prototype;var ye=new Y,xe=R.apply(ye,V);return xe instanceof Object?xe:ye}function Ta(R,V,Y,ye,xe){var Ce=V.length;Ce<2&&jt("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var Te=V[1]!==null&&Y!==null,Me=!1,Ae=1;Ae<V.length;++Ae)if(V[Ae]!==null&&V[Ae].destructorFunction===void 0){Me=!0;break}for(var qe=V[0].name!=="void",rt="",mt="",Ae=0;Ae<Ce-2;++Ae)rt+=(Ae!==0?", ":"")+"arg"+Ae,mt+=(Ae!==0?", ":"")+"arg"+Ae+"Wired";var ht="return function "+Dn(R)+"("+rt+`) {
|
||
if (arguments.length !== `+(Ce-2)+`) {
|
||
throwBindingError('function `+R+" called with ' + arguments.length + ' arguments, expected "+(Ce-2)+` args!');
|
||
}
|
||
`;Me&&(ht+=`var destructors = [];
|
||
`);var zt=Me?"destructors":"null",Ut=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],Gn=[jt,ye,xe,ot,V[0],V[1]];Te&&(ht+="var thisWired = classParam.toWireType("+zt+`, this);
|
||
`);for(var Ae=0;Ae<Ce-2;++Ae)ht+="var arg"+Ae+"Wired = argType"+Ae+".toWireType("+zt+", arg"+Ae+"); // "+V[Ae+2].name+`
|
||
`,Ut.push("argType"+Ae),Gn.push(V[Ae+2]);if(Te&&(mt="thisWired"+(mt.length>0?", ":"")+mt),ht+=(qe?"var rv = ":"")+"invoker(fn"+(mt.length>0?", ":"")+mt+`);
|
||
`,Me)ht+=`runDestructors(destructors);
|
||
`;else for(var Ae=Te?1:2;Ae<V.length;++Ae){var ai=Ae===1?"thisWired":"arg"+(Ae-2)+"Wired";V[Ae].destructorFunction!==null&&(ht+=ai+"_dtor("+ai+"); // "+V[Ae].name+`
|
||
`,Ut.push(ai+"_dtor"),Gn.push(V[Ae].destructorFunction))}qe&&(ht+=`var ret = retType.fromWireType(rv);
|
||
return ret;
|
||
`),ht+=`}
|
||
`,Ut.push(ht);var vi=Xa(Function,Ut).apply(null,Gn);return vi}function Vn(R,V,Y,ye,xe,Ce){b(V>0);var Te=Es(V,Y);xe=Or(ye,xe),Ye([],[R],function(Me){Me=Me[0];var Ae="constructor "+Me.name;if(Me.registeredClass.constructor_body===void 0&&(Me.registeredClass.constructor_body=[]),Me.registeredClass.constructor_body[V-1]!==void 0)throw new Yt("Cannot register multiple constructors with identical number of parameters ("+(V-1)+") for class '"+Me.name+"'! Overload resolution is currently only performed using the parameter count, not actual type info!");return Me.registeredClass.constructor_body[V-1]=()=>{ii("Cannot construct "+Me.name+" due to unbound types",Te)},Ye([],Te,function(qe){return qe.splice(1,0,null),Me.registeredClass.constructor_body[V-1]=Ta(Ae,qe,null,xe,Ce),[]}),[]})}function _a(R,V,Y,ye,xe,Ce,Te,Me){var Ae=Es(Y,ye);V=Cn(V),Ce=Or(xe,Ce),Ye([],[R],function(qe){qe=qe[0];var rt=qe.name+"."+V;V.startsWith("@@")&&(V=Symbol[V.substring(2)]),Me&&qe.registeredClass.pureVirtualFunctions.push(V);function mt(){ii("Cannot call "+rt+" due to unbound types",Ae)}var ht=qe.registeredClass.instancePrototype,zt=ht[V];return zt===void 0||zt.overloadTable===void 0&&zt.className!==qe.name&&zt.argCount===Y-2?(mt.argCount=Y-2,mt.className=qe.name,ht[V]=mt):(sn(ht,V,rt),ht[V].overloadTable[Y-2]=mt),Ye([],Ae,function(Ut){var Gn=Ta(rt,Ut,qe,Ce,Te);return ht[V].overloadTable===void 0?(Gn.argCount=Y-2,ht[V]=Gn):ht[V].overloadTable[Y-2]=Gn,[]}),[]})}var Qr=[],Mr=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function xc(R){R>4&&--Mr[R].refcount===0&&(Mr[R]=void 0,Qr.push(R))}function oi(){for(var R=0,V=5;V<Mr.length;++V)Mr[V]!==void 0&&++R;return R}function Ya(){for(var R=5;R<Mr.length;++R)if(Mr[R]!==void 0)return Mr[R];return null}function Sn(){o.count_emval_handles=oi,o.get_first_emval=Ya}var ji={toValue:R=>(R||jt("Cannot use deleted val. handle = "+R),Mr[R].value),toHandle:R=>{switch(R){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:{var V=Qr.length?Qr.pop():Mr.length;return Mr[V]={refcount:1,value:R},V}}}};function Ea(R,V){V=Cn(V),hi(R,{name:V,fromWireType:function(Y){var ye=ji.toValue(Y);return xc(Y),ye},toWireType:function(Y,ye){return ji.toHandle(ye)},argPackAdvance:8,readValueFromPointer:lt,destructorFunction:null})}function ba(R){if(R===null)return"null";var V=typeof R;return V==="object"||V==="array"||V==="function"?R.toString():""+R}function Oi(R,V){switch(V){case 2:return function(Y){return this.fromWireType(Se[Y>>2])};case 3:return function(Y){return this.fromWireType(we[Y>>3])};default:throw new TypeError("Unknown float type: "+R)}}function bs(R,V,Y){var ye=mn(Y);V=Cn(V),hi(R,{name:V,fromWireType:function(xe){return xe},toWireType:function(xe,Ce){return Ce},argPackAdvance:8,readValueFromPointer:Oi(V,ye),destructorFunction:null})}function na(R,V,Y){switch(V){case 0:return Y?function(xe){return A[xe]}:function(xe){return F[xe]};case 1:return Y?function(xe){return G[xe>>1]}:function(xe){return X[xe>>1]};case 2:return Y?function(xe){return ee[xe>>2]}:function(xe){return ce[xe>>2]};default:throw new TypeError("Unknown integer type: "+R)}}function Cc(R,V,Y,ye,xe){V=Cn(V);var Ce=mn(Y),Te=mt=>mt;if(ye===0){var Me=32-8*Y;Te=mt=>mt<<Me>>>Me}var Ae=V.includes("unsigned"),qe=(mt,ht)=>{},rt;Ae?rt=function(mt,ht){return qe(ht,this.name),ht>>>0}:rt=function(mt,ht){return qe(ht,this.name),ht},hi(R,{name:V,fromWireType:Te,toWireType:rt,argPackAdvance:8,readValueFromPointer:na(V,Ce,ye!==0),destructorFunction:null})}function Uo(R,V,Y){var ye=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],xe=ye[V];function Ce(Te){Te=Te>>2;var Me=ce,Ae=Me[Te],qe=Me[Te+1];return new xe(H,qe,Ae)}Y=Cn(Y),hi(R,{name:Y,fromWireType:Ce,argPackAdvance:8,readValueFromPointer:Ce},{ignoreDuplicateRegistrations:!0})}function Da(R,V){V=Cn(V);var Y=V==="std::string";hi(R,{name:V,fromWireType:function(ye){var xe=ce[ye>>2],Ce=ye+4,Te;if(Y)for(var Me=Ce,Ae=0;Ae<=xe;++Ae){var qe=Ce+Ae;if(Ae==xe||F[qe]==0){var rt=qe-Me,mt=P(Me,rt);Te===void 0?Te=mt:(Te+="\0",Te+=mt),Me=qe+1}}else{for(var ht=new Array(xe),Ae=0;Ae<xe;++Ae)ht[Ae]=String.fromCharCode(F[Ce+Ae]);Te=ht.join("")}return Q(ye),Te},toWireType:function(ye,xe){xe instanceof ArrayBuffer&&(xe=new Uint8Array(xe));var Ce,Te=typeof xe=="string";Te||xe instanceof Uint8Array||xe instanceof Uint8ClampedArray||xe instanceof Int8Array||jt("Cannot pass non-string to std::string"),Y&&Te?Ce=B(xe):Ce=xe.length;var Me=le(4+Ce+1),Ae=Me+4;if(ce[Me>>2]=Ce,Y&&Te)L(xe,Ae,Ce+1);else if(Te)for(var qe=0;qe<Ce;++qe){var rt=xe.charCodeAt(qe);rt>255&&(Q(Ae),jt("String has UTF-16 code units that do not fit in 8 bits")),F[Ae+qe]=rt}else for(var qe=0;qe<Ce;++qe)F[Ae+qe]=xe[qe];return ye!==null&&ye.push(Q,Me),Me},argPackAdvance:8,readValueFromPointer:lt,destructorFunction:function(ye){Q(ye)}})}var Sc=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0;function Ja(R,V){for(var Y=R,ye=Y>>1,xe=ye+V/2;!(ye>=xe)&&X[ye];)++ye;if(Y=ye<<1,Y-R>32&&Sc)return Sc.decode(F.subarray(R,Y));for(var Ce="",Te=0;!(Te>=V/2);++Te){var Me=G[R+Te*2>>1];if(Me==0)break;Ce+=String.fromCharCode(Me)}return Ce}function pl(R,V,Y){if(Y===void 0&&(Y=2147483647),Y<2)return 0;Y-=2;for(var ye=V,xe=Y<R.length*2?Y/2:R.length,Ce=0;Ce<xe;++Ce){var Te=R.charCodeAt(Ce);G[V>>1]=Te,V+=2}return G[V>>1]=0,V-ye}function ml(R){return R.length*2}function vl(R,V){for(var Y=0,ye="";!(Y>=V/4);){var xe=ee[R+Y*4>>2];if(xe==0)break;if(++Y,xe>=65536){var Ce=xe-65536;ye+=String.fromCharCode(55296|Ce>>10,56320|Ce&1023)}else ye+=String.fromCharCode(xe)}return ye}function yl(R,V,Y){if(Y===void 0&&(Y=2147483647),Y<4)return 0;for(var ye=V,xe=ye+Y-4,Ce=0;Ce<R.length;++Ce){var Te=R.charCodeAt(Ce);if(Te>=55296&&Te<=57343){var Me=R.charCodeAt(++Ce);Te=65536+((Te&1023)<<10)|Me&1023}if(ee[V>>2]=Te,V+=4,V+4>xe)break}return ee[V>>2]=0,V-ye}function wl(R){for(var V=0,Y=0;Y<R.length;++Y){var ye=R.charCodeAt(Y);ye>=55296&&ye<=57343&&++Y,V+=4}return V}function Ds(R,V,Y){Y=Cn(Y);var ye,xe,Ce,Te,Me;V===2?(ye=Ja,xe=pl,Te=ml,Ce=()=>X,Me=1):V===4&&(ye=vl,xe=yl,Te=wl,Ce=()=>ce,Me=2),hi(R,{name:Y,fromWireType:function(Ae){for(var qe=ce[Ae>>2],rt=Ce(),mt,ht=Ae+4,zt=0;zt<=qe;++zt){var Ut=Ae+4+zt*V;if(zt==qe||rt[Ut>>Me]==0){var Gn=Ut-ht,ai=ye(ht,Gn);mt===void 0?mt=ai:(mt+="\0",mt+=ai),ht=Ut+V}}return Q(Ae),mt},toWireType:function(Ae,qe){typeof qe!="string"&&jt("Cannot pass non-string to C++ string type "+Y);var rt=Te(qe),mt=le(4+rt+V);return ce[mt>>2]=rt>>Me,xe(qe,mt+4,rt+V),Ae!==null&&Ae.push(Q,mt),mt},argPackAdvance:8,readValueFromPointer:lt,destructorFunction:function(Ae){Q(Ae)}})}function xl(R,V,Y,ye,xe,Ce){at[R]={name:Cn(V),rawConstructor:Or(Y,ye),rawDestructor:Or(xe,Ce),fields:[]}}function Is(R,V,Y,ye,xe,Ce,Te,Me,Ae,qe){at[R].fields.push({fieldName:Cn(V),getterReturnType:Y,getter:Or(ye,xe),getterContext:Ce,setterArgumentType:Te,setter:Or(Me,Ae),setterContext:qe})}function Cl(R,V){V=Cn(V),hi(R,{isVoid:!0,name:V,argPackAdvance:0,fromWireType:function(){},toWireType:function(Y,ye){}})}function Os(){throw 1/0}var Ms={};function Tc(R){var V=Ms[R];return V===void 0?Cn(R):V}function Za(){return typeof globalThis=="object"?globalThis:function(){return Function}()("return this")()}function Ps(R){return R===0?ji.toHandle(Za()):(R=Tc(R),ji.toHandle(Za()[R]))}function Rs(R){R>4&&(Mr[R].refcount+=1)}function Qa(R,V){var Y=vt[R];return Y===void 0&&jt(V+" has unknown type "+mo(R)),Y}function _c(R){for(var V="",Y=0;Y<R;++Y)V+=(Y!==0?", ":"")+"arg"+Y;for(var ye=()=>ce,xe="return function emval_allocator_"+R+`(constructor, argTypes, args) {
|
||
var HEAPU32 = getMemory();
|
||
`,Y=0;Y<R;++Y)xe+="var argType"+Y+" = requireRegisteredType(HEAPU32[((argTypes)>>2)], 'parameter "+Y+`');
|
||
var arg`+Y+" = argType"+Y+`.readValueFromPointer(args);
|
||
args += argType`+Y+`['argPackAdvance'];
|
||
argTypes += 4;
|
||
`;return xe+="var obj = new constructor("+V+`);
|
||
return valueToHandle(obj);
|
||
}
|
||
`,new Function("requireRegisteredType","Module","valueToHandle","getMemory",xe)(Qa,o,ji.toHandle,ye)}var Ls={};function Ec(R,V,Y,ye){R=ji.toValue(R);var xe=Ls[V];return xe||(xe=_c(V),Ls[V]=xe),xe(R,Y,ye)}function As(R,V){R=Qa(R,"_emval_take_value");var Y=R.readValueFromPointer(V);return ji.toHandle(Y)}function bc(){se("")}function Dc(R,V,Y){F.copyWithin(R,V,V+Y)}function Ic(){return 2147483648}function Oc(R){try{return _.grow(R-H.byteLength+65535>>>16),_e(_.buffer),1}catch{}}function es(R){var V=F.length;R=R>>>0;var Y=Ic();if(R>Y)return!1;let ye=(Ae,qe)=>Ae+(qe-Ae%qe)%qe;for(var xe=1;xe<=4;xe*=2){var Ce=V*(1+.2/xe);Ce=Math.min(Ce,R+100663296);var Te=Math.min(Y,ye(Math.max(R,Ce),65536)),Me=Oc(Te);if(Me)return!0}return!1}var ts={};function vo(){return l||"./this.program"}function Bo(){if(!Bo.strings){var R=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",V={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:R,_:vo()};for(var Y in ts)ts[Y]===void 0?delete V[Y]:V[Y]=ts[Y];var ye=[];for(var Y in V)ye.push(Y+"="+V[Y]);Bo.strings=ye}return Bo.strings}function Hi(R,V,Y){for(var ye=0;ye<R.length;++ye)A[V++>>0]=R.charCodeAt(ye);A[V>>0]=0}function Ns(R,V){var Y=0;return Bo().forEach(function(ye,xe){var Ce=V+Y;ce[R+xe*4>>2]=Ce,Hi(ye,Ce),Y+=ye.length+1}),0}function ks(R,V){var Y=Bo();ce[R>>2]=Y.length;var ye=0;return Y.forEach(function(xe){ye+=xe.length+1}),ce[V>>2]=ye,0}function ns(R){f(R,new pt(R))}function Vs(R,V){ns(R)}var Ia=Vs;function Fs(R){return 52}function oe(R,V,Y,ye,xe){return 70}var ae=[null,[],[]];function De(R,V){var Y=ae[R];V===0||V===10?((R===1?C:S)(I(Y,0)),Y.length=0):Y.push(V)}function He(R,V,Y,ye){for(var xe=0,Ce=0;Ce<Y;Ce++){var Te=ce[V>>2],Me=ce[V+4>>2];V+=8;for(var Ae=0;Ae<Me;Ae++)De(R,F[Te+Ae]);xe+=Me}return ce[ye>>2]=xe,0}function tt(R){var V=o["_"+R];return V}function z(R,V){A.set(R,V)}function ne(R,V,Y,ye,xe){var Ce={string:Ut=>{var Gn=0;if(Ut!=null&&Ut!==0){var ai=(Ut.length<<2)+1;Gn=k(ai),L(Ut,Gn,ai)}return Gn},array:Ut=>{var Gn=k(Ut.length);return z(Ut,Gn),Gn}};function Te(Ut){return V==="string"?P(Ut):V==="boolean"?!!Ut:Ut}var Me=tt(R),Ae=[],qe=0;if(ye)for(var rt=0;rt<ye.length;rt++){var mt=Ce[Y[rt]];mt?(qe===0&&(qe=me()),Ae[rt]=mt(ye[rt])):Ae[rt]=ye[rt]}var ht=Me.apply(null,Ae);function zt(Ut){return qe!==0&&N(qe),Te(Ut)}return ht=zt(ht),ht}Ui=o.InternalError=xn(Error,"InternalError"),Fr(),Yt=o.BindingError=xn(Error,"BindingError"),Zr(),go(),$i(),qa=o.UnboundTypeError=xn(Error,"UnboundTypeError"),Sn();var de={g:nt,A:ut,w:Rt,F:Bi,u:ta,t:Vn,c:_a,E:Ea,m:bs,b:Cc,a:Uo,l:Da,h:Ds,J:xl,d:Is,G:Cl,x:Os,i:xc,r:Ps,p:Rs,q:Ec,s:As,j:bc,D:Dc,y:es,z:Ns,B:ks,I:Ia,C:Fs,v:oe,k:He,o:Ie,n:Oe,H:be,f:ve,e:ke};ft(),o.___wasm_call_ctors=function(){return(o.___wasm_call_ctors=o.asm.L).apply(null,arguments)};var le=o._malloc=function(){return(le=o._malloc=o.asm.N).apply(null,arguments)},Q=o._free=function(){return(Q=o._free=o.asm.O).apply(null,arguments)},he=o.___getTypeName=function(){return(he=o.___getTypeName=o.asm.P).apply(null,arguments)};o.__embind_initialize_bindings=function(){return(o.__embind_initialize_bindings=o.asm.Q).apply(null,arguments)};var ge=o._setThrew=function(){return(ge=o._setThrew=o.asm.R).apply(null,arguments)},me=o.stackSave=function(){return(me=o.stackSave=o.asm.S).apply(null,arguments)},N=o.stackRestore=function(){return(N=o.stackRestore=o.asm.T).apply(null,arguments)},k=o.stackAlloc=function(){return(k=o.stackAlloc=o.asm.U).apply(null,arguments)},te=o.___cxa_is_pointer_type=function(){return(te=o.___cxa_is_pointer_type=o.asm.V).apply(null,arguments)};o.dynCall_jiji=function(){return(o.dynCall_jiji=o.asm.W).apply(null,arguments)};function ve(R,V){var Y=me();try{yr(R)(V)}catch(ye){if(N(Y),ye!==ye+0)throw ye;ge(1,0)}}function Ie(R,V){var Y=me();try{return yr(R)(V)}catch(ye){if(N(Y),ye!==ye+0)throw ye;ge(1,0)}}function ke(R,V,Y,ye){var xe=me();try{yr(R)(V,Y,ye)}catch(Ce){if(N(xe),Ce!==Ce+0)throw Ce;ge(1,0)}}function be(R,V,Y,ye){var xe=me();try{return yr(R)(V,Y,ye)}catch(Ce){if(N(xe),Ce!==Ce+0)throw Ce;ge(1,0)}}function Oe(R,V,Y){var ye=me();try{return yr(R)(V,Y)}catch(xe){if(N(ye),xe!==xe+0)throw xe;ge(1,0)}}o.ccall=ne;var W;Fe=function R(){W||$(),W||(Fe=R)};function $(R){if(Re>0||(M(),Re>0))return;function V(){W||(W=!0,o.calledRun=!0,!E&&(q(),a(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),K()))}o.setStatus?(o.setStatus("Running..."),setTimeout(function(){setTimeout(function(){o.setStatus("")},1),V()},1)):V()}if(o.preInit)for(typeof o.preInit=="function"&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return $(),i.ready}})();t.exports=r})(d$);var yEe=d$.exports;const wEe=ll(yEe),xEe=new URL("/static/dv3d/libjpegturbowasm_decode.wasm",import.meta.url),Gv={codec:void 0,decoder:void 0};function CEe(){if(Gv.codec)return Promise.resolve();const t=wEe({locateFile:e=>e.endsWith(".wasm")?xEe.toString():e});return new Promise((e,r)=>{t.then(n=>{Gv.codec=n,Gv.decoder=new n.JPEGDecoder,e()},r)})}async function SEe(t,e){await CEe();const r=Gv.decoder;r.getEncodedBuffer(t.length).set(t),r.decode();const i=r.getFrameInfo(),o=r.getDecodedBuffer(),a={columns:i.width,rows:i.height,bitsPerPixel:i.bitsPerSample,signed:e.signed,bytesPerPixel:e.bytesPerPixel,componentsPerPixel:i.componentCount},s=TEe(i,o),c={frameInfo:i};return{...e,pixelData:s,imageInfo:a,encodeOptions:c,...c,...a}}function TEe(t,e){return t.isSigned?new Int8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}const _Ee="modulepreload",EEe=function(t){return"/static/dv3d/"+t},G7={},h$=function(e,r,n){let i=Promise.resolve();if(r&&r.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),s=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));i=Promise.allSettled(r.map(c=>{if(c=EEe(c),c in G7)return;G7[c]=!0;const l=c.endsWith(".css"),f=l?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${f}`))return;const u=document.createElement("link");if(u.rel=l?"stylesheet":_Ee,l||(u.as="script"),u.crossOrigin="",u.href=c,s&&u.setAttribute("nonce",s),document.head.appendChild(u),l)return new Promise((d,h)=>{u.addEventListener("load",d),u.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${c}`)))})}))}function o(a){const s=new Event("vite:preloadError",{cancelable:!0});if(s.payload=a,window.dispatchEvent(s),!s.defaultPrevented)throw a}return i.then(a=>{for(const s of a||[])s.status==="rejected"&&o(s.reason);return e().catch(o)})},Op={JpegImage:void 0,decodeConfig:{}};function bEe(t){return Op.decodeConfig=t,Op.JpegImage?Promise.resolve():new Promise((e,r)=>{h$(()=>import("./jpeg.js"),[]).then(n=>{Op.JpegImage=n.default,e()}).catch(r)})}async function DEe(t,e){if(await bEe(),typeof Op.JpegImage>"u")throw new Error("No JPEG Baseline decoder loaded");const r=new Op.JpegImage;if(r.parse(e),r.colorTransform=!1,t.bitsAllocated===8)return t.pixelData=r.getData(t.columns,t.rows),t;if(t.bitsAllocated===16)return t.pixelData=r.getData16(t.columns,t.rows),t}const Mp={jpeg:void 0,decodeConfig:{}};function IEe(t){return Mp.decodeConfig=t,Mp.jpeg?Promise.resolve():new Promise((e,r)=>{h$(async()=>{const{Decoder:n}=await import("./lossless.js");return{Decoder:n}},[]).then(({Decoder:n})=>{const i=new n;Mp.jpeg=i,e()},r)})}async function W7(t,e){if(await IEe(),typeof Mp.jpeg>"u")throw new Error("No JPEG Lossless decoder loaded");const r=t.bitsAllocated<=8?1:2,n=e.buffer,i=Mp.jpeg.decode(n,e.byteOffset,e.length,r);return t.pixelRepresentation===0?t.bitsAllocated===16?(t.pixelData=new Uint16Array(i.buffer),t):(t.pixelData=new Uint8Array(i.buffer),t):(t.pixelData=new Int16Array(i.buffer),t)}var g$={exports:{}};(function(t,e){var r=(()=>{var n=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename<"u"&&(n=n||__filename),function(i){i=i||{};var o=typeof i<"u"?i:{},a,s;o.ready=new Promise(function(oe,ae){a=oe,s=ae});var c=Object.assign({},o),l=typeof window=="object",f=typeof importScripts=="function",u=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",d="";function h(oe){return o.locateFile?o.locateFile(oe,d):d+oe}var g,p,v;if(u){var y=el,m=el;f?d=m.dirname(d)+"/":d=__dirname+"/",g=(oe,ae)=>(oe=se(oe)?new URL(oe):m.normalize(oe),y.readFileSync(oe,ae?void 0:"utf8")),v=oe=>{var ae=g(oe,!0);return ae.buffer||(ae=new Uint8Array(ae)),ae},p=(oe,ae,De)=>{oe=se(oe)?new URL(oe):m.normalize(oe),y.readFile(oe,function(He,tt){He?De(He):ae(tt.buffer)})},process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),process.on("uncaughtException",function(oe){if(!(oe instanceof Qe))throw oe}),process.on("unhandledRejection",function(oe){throw oe}),o.inspect=function(){return"[Emscripten Module object]"}}else(l||f)&&(f?d=self.location.href:typeof document<"u"&&document.currentScript&&(d=document.currentScript.src),n&&(d=n),d.indexOf("blob:")!==0?d=d.substr(0,d.replace(/[?#].*/,"").lastIndexOf("/")+1):d="",g=oe=>{var ae=new XMLHttpRequest;return ae.open("GET",oe,!1),ae.send(null),ae.responseText},f&&(v=oe=>{var ae=new XMLHttpRequest;return ae.open("GET",oe,!1),ae.responseType="arraybuffer",ae.send(null),new Uint8Array(ae.response)}),p=(oe,ae,De)=>{var He=new XMLHttpRequest;He.open("GET",oe,!0),He.responseType="arraybuffer",He.onload=()=>{if(He.status==200||He.status==0&&He.response){ae(He.response);return}De()},He.onerror=De,He.send(null)});o.print||console.log.bind(console);var w=o.printErr||console.warn.bind(console);Object.assign(o,c),c=null,o.arguments&&o.arguments,o.thisProgram&&o.thisProgram,o.quit&&o.quit;var x;o.wasmBinary&&(x=o.wasmBinary),o.noExitRuntime,typeof WebAssembly!="object"&&Fe("no native wasm support detected");var C,S=!1;function T(oe,ae){oe||Fe(ae)}var _=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function E(oe,ae,De){for(var He=ae+De,tt=ae;oe[tt]&&!(tt>=He);)++tt;if(tt-ae>16&&oe.buffer&&_)return _.decode(oe.subarray(ae,tt));for(var z="";ae<tt;){var ne=oe[ae++];if(!(ne&128)){z+=String.fromCharCode(ne);continue}var de=oe[ae++]&63;if((ne&224)==192){z+=String.fromCharCode((ne&31)<<6|de);continue}var le=oe[ae++]&63;if((ne&240)==224?ne=(ne&15)<<12|de<<6|le:ne=(ne&7)<<18|de<<12|le<<6|oe[ae++]&63,ne<65536)z+=String.fromCharCode(ne);else{var Q=ne-65536;z+=String.fromCharCode(55296|Q>>10,56320|Q&1023)}}return z}function b(oe,ae){return oe?E(B,oe,ae):""}function D(oe,ae,De,He){if(!(He>0))return 0;for(var tt=De,z=De+He-1,ne=0;ne<oe.length;++ne){var de=oe.charCodeAt(ne);if(de>=55296&&de<=57343){var le=oe.charCodeAt(++ne);de=65536+((de&1023)<<10)|le&1023}if(de<=127){if(De>=z)break;ae[De++]=de}else if(de<=2047){if(De+1>=z)break;ae[De++]=192|de>>6,ae[De++]=128|de&63}else if(de<=65535){if(De+2>=z)break;ae[De++]=224|de>>12,ae[De++]=128|de>>6&63,ae[De++]=128|de&63}else{if(De+3>=z)break;ae[De++]=240|de>>18,ae[De++]=128|de>>12&63,ae[De++]=128|de>>6&63,ae[De++]=128|de&63}}return ae[De]=0,De-tt}function I(oe,ae,De){return D(oe,B,ae,De)}function P(oe){for(var ae=0,De=0;De<oe.length;++De){var He=oe.charCodeAt(De);He<=127?ae++:He<=2047?ae+=2:He>=55296&&He<=57343?(ae+=4,++De):ae+=3}return ae}var O,L,B,H,A,F,G,X,ee;function ce(oe){O=oe,o.HEAP8=L=new Int8Array(oe),o.HEAP16=H=new Int16Array(oe),o.HEAP32=F=new Int32Array(oe),o.HEAPU8=B=new Uint8Array(oe),o.HEAPU16=A=new Uint16Array(oe),o.HEAPU32=G=new Uint32Array(oe),o.HEAPF32=X=new Float32Array(oe),o.HEAPF64=ee=new Float64Array(oe)}o.INITIAL_MEMORY;var Se,we=[],_e=[],Ve=[];function Ge(){if(o.preRun)for(typeof o.preRun=="function"&&(o.preRun=[o.preRun]);o.preRun.length;)M(o.preRun.shift());fe(we)}function Ne(){fe(_e)}function j(){if(o.postRun)for(typeof o.postRun=="function"&&(o.postRun=[o.postRun]);o.postRun.length;)K(o.postRun.shift());fe(Ve)}function M(oe){we.unshift(oe)}function q(oe){_e.unshift(oe)}function K(oe){Ve.unshift(oe)}var J=0,re=null;function ie(oe){J++,o.monitorRunDependencies&&o.monitorRunDependencies(J)}function Re(oe){if(J--,o.monitorRunDependencies&&o.monitorRunDependencies(J),J==0&&re){var ae=re;re=null,ae()}}function Fe(oe){o.onAbort&&o.onAbort(oe),oe="Aborted("+oe+")",w(oe),S=!0,oe+=". Build with -sASSERTIONS for more info.";var ae=new WebAssembly.RuntimeError(oe);throw s(ae),ae}var je="data:application/octet-stream;base64,";function Xe(oe){return oe.startsWith(je)}function se(oe){return oe.startsWith("file://")}var ue;ue="charlswasm_decode.wasm",Xe(ue)||(ue=h(ue));function Pe(oe){try{if(oe==ue&&x)return new Uint8Array(x);if(v)return v(oe);throw"both async and sync fetching of the wasm failed"}catch(ae){Fe(ae)}}function pe(){if(!x&&(l||f)){if(typeof fetch=="function"&&!se(ue))return fetch(ue,{credentials:"same-origin"}).then(function(oe){if(!oe.ok)throw"failed to load wasm binary file at '"+ue+"'";return oe.arrayBuffer()}).catch(function(){return Pe(ue)});if(p)return new Promise(function(oe,ae){p(ue,function(De){oe(new Uint8Array(De))},ae)})}return Promise.resolve().then(function(){return Pe(ue)})}function Ee(){var oe={a:ts};function ae(ne,de){var le=ne.exports;o.asm=le,C=o.asm.z,ce(C.buffer),Se=o.asm.C,q(o.asm.A),Re()}ie();function De(ne){ae(ne.instance)}function He(ne){return pe().then(function(de){return WebAssembly.instantiate(de,oe)}).then(function(de){return de}).then(ne,function(de){w("failed to asynchronously prepare wasm: "+de),Fe(de)})}function tt(){return!x&&typeof WebAssembly.instantiateStreaming=="function"&&!Xe(ue)&&!se(ue)&&!u&&typeof fetch=="function"?fetch(ue,{credentials:"same-origin"}).then(function(ne){var de=WebAssembly.instantiateStreaming(ne,oe);return de.then(De,function(le){return w("wasm streaming compile failed: "+le),w("falling back to ArrayBuffer instantiation"),He(De)})}):He(De)}if(o.instantiateWasm)try{var z=o.instantiateWasm(oe,ae);return z}catch(ne){w("Module.instantiateWasm callback failed with error: "+ne),s(ne)}return tt().catch(s),{}}function Qe(oe){this.name="ExitStatus",this.message="Program terminated with exit("+oe+")",this.status=oe}function fe(oe){for(;oe.length>0;)oe.shift()(o)}function ft(oe){this.excPtr=oe,this.ptr=oe-24,this.set_type=function(ae){G[this.ptr+4>>2]=ae},this.get_type=function(){return G[this.ptr+4>>2]},this.set_destructor=function(ae){G[this.ptr+8>>2]=ae},this.get_destructor=function(){return G[this.ptr+8>>2]},this.set_refcount=function(ae){F[this.ptr>>2]=ae},this.set_caught=function(ae){ae=ae?1:0,L[this.ptr+12>>0]=ae},this.get_caught=function(){return L[this.ptr+12>>0]!=0},this.set_rethrown=function(ae){ae=ae?1:0,L[this.ptr+13>>0]=ae},this.get_rethrown=function(){return L[this.ptr+13>>0]!=0},this.init=function(ae,De){this.set_adjusted_ptr(0),this.set_type(ae),this.set_destructor(De),this.set_refcount(0),this.set_caught(!1),this.set_rethrown(!1)},this.add_ref=function(){var ae=F[this.ptr>>2];F[this.ptr>>2]=ae+1},this.release_ref=function(){var ae=F[this.ptr>>2];return F[this.ptr>>2]=ae-1,ae===1},this.set_adjusted_ptr=function(ae){G[this.ptr+16>>2]=ae},this.get_adjusted_ptr=function(){return G[this.ptr+16>>2]},this.get_exception_ptr=function(){var ae=Vs(this.get_type());if(ae)return G[this.excPtr>>2];var De=this.get_adjusted_ptr();return De!==0?De:this.excPtr}}function pt(oe,ae,De){var He=new ft(oe);throw He.init(ae,De),oe}var dt={};function Ue(oe){for(;oe.length;){var ae=oe.pop(),De=oe.pop();De(ae)}}function nt(oe){return this.fromWireType(F[oe>>2])}var at={},ot={},lt={},_t=48,vt=57;function Mt(oe){if(oe===void 0)return"_unknown";oe=oe.replace(/[^a-zA-Z0-9_]/g,"$");var ae=oe.charCodeAt(0);return ae>=_t&&ae<=vt?"_"+oe:oe}function Ft(oe,ae){return oe=Mt(oe),new Function("body","return function "+oe+`() {
|
||
"use strict"; return body.apply(this, arguments);
|
||
};
|
||
`)(ae)}function wn(oe,ae){var De=Ft(ae,function(He){this.name=ae,this.message=He;var tt=new Error(He).stack;tt!==void 0&&(this.stack=this.toString()+`
|
||
`+tt.replace(/^Error(:[^\n]*)?\n/,""))});return De.prototype=Object.create(oe.prototype),De.prototype.constructor=De,De.prototype.toString=function(){return this.message===void 0?this.name:this.name+": "+this.message},De}var Dn=void 0;function Nt(oe){throw new Dn(oe)}function xn(oe,ae,De){oe.forEach(function(de){lt[de]=ae});function He(de){var le=De(de);le.length!==oe.length&&Nt("Mismatched type converter count");for(var Q=0;Q<oe.length;++Q)Cn(oe[Q],le[Q])}var tt=new Array(ae.length),z=[],ne=0;ae.forEach((de,le)=>{ot.hasOwnProperty(de)?tt[le]=ot[de]:(z.push(de),at.hasOwnProperty(de)||(at[de]=[]),at[de].push(()=>{tt[le]=ot[de],++ne,ne===z.length&&He(tt)}))}),z.length===0&&He(tt)}function Ui(oe){var ae=dt[oe];delete dt[oe];var De=ae.rawConstructor,He=ae.rawDestructor,tt=ae.fields,z=tt.map(ne=>ne.getterReturnType).concat(tt.map(ne=>ne.setterArgumentType));xn([oe],z,ne=>{var de={};return tt.forEach((le,Q)=>{var he=le.fieldName,ge=ne[Q],me=le.getter,N=le.getterContext,k=ne[Q+tt.length],te=le.setter,ve=le.setterContext;de[he]={read:Ie=>ge.fromWireType(me(N,Ie)),write:(Ie,ke)=>{var be=[];te(ve,Ie,k.toWireType(be,ke)),Ue(be)}}}),[{name:ae.name,fromWireType:function(le){var Q={};for(var he in de)Q[he]=de[he].read(le);return He(le),Q},toWireType:function(le,Q){for(var he in de)if(!(he in Q))throw new TypeError('Missing field: "'+he+'"');var ge=De();for(he in de)de[he].write(ge,Q[he]);return le!==null&&le.push(He,ge),ge},argPackAdvance:8,readValueFromPointer:nt,destructorFunction:He}]})}function br(oe,ae,De,He,tt){}function Ye(oe){switch(oe){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+oe)}}function ut(){for(var oe=new Array(256),ae=0;ae<256;++ae)oe[ae]=String.fromCharCode(ae);Rt=oe}var Rt=void 0;function mn(oe){for(var ae="",De=oe;B[De];)ae+=Rt[B[De++]];return ae}var Fr=void 0;function Lt(oe){throw new Fr(oe)}function Cn(oe,ae,De={}){if(!("argPackAdvance"in ae))throw new TypeError("registerType registeredInstance requires argPackAdvance");var He=ae.name;if(oe||Lt('type "'+He+'" must have a positive integer typeid pointer'),ot.hasOwnProperty(oe)){if(De.ignoreDuplicateRegistrations)return;Lt("Cannot register type '"+He+"' twice")}if(ot[oe]=ae,delete lt[oe],at.hasOwnProperty(oe)){var tt=at[oe];delete at[oe],tt.forEach(z=>z())}}function Yt(oe,ae,De,He,tt){var z=Ye(De);ae=mn(ae),Cn(oe,{name:ae,fromWireType:function(ne){return!!ne},toWireType:function(ne,de){return de?He:tt},argPackAdvance:8,readValueFromPointer:function(ne){var de;if(De===1)de=L;else if(De===2)de=H;else if(De===4)de=F;else throw new TypeError("Unknown boolean type size: "+ae);return this.fromWireType(de[ne>>z])},destructorFunction:null})}function jt(oe){if(!(this instanceof Qi)||!(oe instanceof Qi))return!1;for(var ae=this.$$.ptrType.registeredClass,De=this.$$.ptr,He=oe.$$.ptrType.registeredClass,tt=oe.$$.ptr;ae.baseClass;)De=ae.upcast(De),ae=ae.baseClass;for(;He.baseClass;)tt=He.upcast(tt),He=He.baseClass;return ae===He&&De===tt}function hi(oe){return{count:oe.count,deleteScheduled:oe.deleteScheduled,preservePointerOnDelete:oe.preservePointerOnDelete,ptr:oe.ptr,ptrType:oe.ptrType,smartPtr:oe.smartPtr,smartPtrType:oe.smartPtrType}}function Bi(oe){function ae(De){return De.$$.ptrType.registeredClass.name}Lt(ae(oe)+" instance already deleted")}var Ao=!1;function jn(oe){}function fo(oe){oe.smartPtr?oe.smartPtrType.rawDestructor(oe.smartPtr):oe.ptrType.registeredClass.rawDestructor(oe.ptr)}function Ei(oe){oe.count.value-=1;var ae=oe.count.value===0;ae&&fo(oe)}function xa(oe,ae,De){if(ae===De)return oe;if(De.baseClass===void 0)return null;var He=xa(oe,ae,De.baseClass);return He===null?null:De.downcast(He)}var Bn={};function Ct(){return Object.keys(Ur).length}function Zt(){var oe=[];for(var ae in Ur)Ur.hasOwnProperty(ae)&&oe.push(Ur[ae]);return oe}var ar=[];function Qo(){for(;ar.length;){var oe=ar.pop();oe.$$.deleteScheduled=!1,oe.delete()}}var Dr=void 0;function ho(oe){Dr=oe,ar.length&&Dr&&Dr(Qo)}function bi(){o.getInheritedInstanceCount=Ct,o.getLiveInheritedInstances=Zt,o.flushPendingDeletes=Qo,o.setDelayFunction=ho}var Ur={};function Cs(oe,ae){for(ae===void 0&&Lt("ptr should not be undefined");oe.baseClass;)ae=oe.upcast(ae),oe=oe.baseClass;return ae}function go(oe,ae){return ae=Cs(oe,ae),Ur[ae]}function Zi(oe,ae){(!ae.ptrType||!ae.ptr)&&Nt("makeClassHandle requires ptr and ptrType");var De=!!ae.smartPtrType,He=!!ae.smartPtr;return De!==He&&Nt("Both smartPtrType and smartPtr must be specified"),ae.count={value:1},gi(Object.create(oe,{$$:{value:ae}}))}function Ca(oe){var ae=this.getPointee(oe);if(!ae)return this.destructor(oe),null;var De=go(this.registeredClass,ae);if(De!==void 0){if(De.$$.count.value===0)return De.$$.ptr=ae,De.$$.smartPtr=oe,De.clone();var He=De.clone();return this.destructor(oe),He}function tt(){return this.isSmartPointer?Zi(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:ae,smartPtrType:this,smartPtr:oe}):Zi(this.registeredClass.instancePrototype,{ptrType:this,ptr:oe})}var z=this.registeredClass.getActualType(ae),ne=Bn[z];if(!ne)return tt.call(this);var de;this.isConst?de=ne.constPointerType:de=ne.pointerType;var le=xa(ae,this.registeredClass,de.registeredClass);return le===null?tt.call(this):this.isSmartPointer?Zi(de.registeredClass.instancePrototype,{ptrType:de,ptr:le,smartPtrType:this,smartPtr:oe}):Zi(de.registeredClass.instancePrototype,{ptrType:de,ptr:le})}function gi(oe){return typeof FinalizationRegistry>"u"?(gi=ae=>ae,oe):(Ao=new FinalizationRegistry(ae=>{Ei(ae.$$)}),gi=ae=>{var De=ae.$$,He=!!De.smartPtr;if(He){var tt={$$:De};Ao.register(ae,tt,ae)}return ae},jn=ae=>Ao.unregister(ae),gi(oe))}function Sa(){if(this.$$.ptr||Bi(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var oe=gi(Object.create(Object.getPrototypeOf(this),{$$:{value:hi(this.$$)}}));return oe.$$.count.value+=1,oe.$$.deleteScheduled=!1,oe}function ln(){this.$$.ptr||Bi(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&Lt("Object already scheduled for deletion"),jn(this),Ei(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)}function Gi(){return!this.$$.ptr}function Ss(){return this.$$.ptr||Bi(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&Lt("Object already scheduled for deletion"),ar.push(this),ar.length===1&&Dr&&Dr(Qo),this.$$.deleteScheduled=!0,this}function ea(){Qi.prototype.isAliasOf=jt,Qi.prototype.clone=Sa,Qi.prototype.delete=ln,Qi.prototype.isDeleted=Gi,Qi.prototype.deleteLater=Ss}function Qi(){}function po(oe,ae,De){if(oe[ae].overloadTable===void 0){var He=oe[ae];oe[ae]=function(){return oe[ae].overloadTable.hasOwnProperty(arguments.length)||Lt("Function '"+De+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+oe[ae].overloadTable+")!"),oe[ae].overloadTable[arguments.length].apply(this,arguments)},oe[ae].overloadTable=[],oe[ae].overloadTable[He.argCount]=He}}function Zr(oe,ae,De){o.hasOwnProperty(oe)?((De===void 0||o[oe].overloadTable!==void 0&&o[oe].overloadTable[De]!==void 0)&&Lt("Cannot register public name '"+oe+"' twice"),po(o,oe,oe),o.hasOwnProperty(De)&&Lt("Cannot register multiple overloads of a function with the same number of arguments ("+De+")!"),o[oe].overloadTable[De]=ae):(o[oe]=ae,De!==void 0&&(o[oe].numArguments=De))}function Di(oe,ae,De,He,tt,z,ne,de){this.name=oe,this.constructor=ae,this.instancePrototype=De,this.rawDestructor=He,this.baseClass=tt,this.getActualType=z,this.upcast=ne,this.downcast=de,this.pureVirtualFunctions=[]}function sn(oe,ae,De){for(;ae!==De;)ae.upcast||Lt("Expected null or instance of "+De.name+", got an instance of "+ae.name),oe=ae.upcast(oe),ae=ae.baseClass;return oe}function pi(oe,ae){if(ae===null)return this.isReference&&Lt("null is not a valid "+this.name),0;ae.$$||Lt('Cannot pass "'+Sn(ae)+'" as a '+this.name),ae.$$.ptr||Lt("Cannot pass deleted object as a pointer of type "+this.name);var De=ae.$$.ptrType.registeredClass,He=sn(ae.$$.ptr,De,this.registeredClass);return He}function No(oe,ae){var De;if(ae===null)return this.isReference&&Lt("null is not a valid "+this.name),this.isSmartPointer?(De=this.rawConstructor(),oe!==null&&oe.push(this.rawDestructor,De),De):0;ae.$$||Lt('Cannot pass "'+Sn(ae)+'" as a '+this.name),ae.$$.ptr||Lt("Cannot pass deleted object as a pointer of type "+this.name),!this.isConst&&ae.$$.ptrType.isConst&&Lt("Cannot convert argument of type "+(ae.$$.smartPtrType?ae.$$.smartPtrType.name:ae.$$.ptrType.name)+" to parameter type "+this.name);var He=ae.$$.ptrType.registeredClass;if(De=sn(ae.$$.ptr,He,this.registeredClass),this.isSmartPointer)switch(ae.$$.smartPtr===void 0&&Lt("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:ae.$$.smartPtrType===this?De=ae.$$.smartPtr:Lt("Cannot convert argument of type "+(ae.$$.smartPtrType?ae.$$.smartPtrType.name:ae.$$.ptrType.name)+" to parameter type "+this.name);break;case 1:De=ae.$$.smartPtr;break;case 2:if(ae.$$.smartPtrType===this)De=ae.$$.smartPtr;else{var tt=ae.clone();De=this.rawShare(De,oi.toHandle(function(){tt.delete()})),oe!==null&&oe.push(this.rawDestructor,De)}break;default:Lt("Unsupporting sharing policy")}return De}function Wi(oe,ae){if(ae===null)return this.isReference&&Lt("null is not a valid "+this.name),0;ae.$$||Lt('Cannot pass "'+Sn(ae)+'" as a '+this.name),ae.$$.ptr||Lt("Cannot pass deleted object as a pointer of type "+this.name),ae.$$.ptrType.isConst&&Lt("Cannot convert argument of type "+ae.$$.ptrType.name+" to parameter type "+this.name);var De=ae.$$.ptrType.registeredClass,He=sn(ae.$$.ptr,De,this.registeredClass);return He}function Ii(oe){return this.rawGetPointee&&(oe=this.rawGetPointee(oe)),oe}function Ts(oe){this.rawDestructor&&this.rawDestructor(oe)}function ko(oe){oe!==null&&oe.delete()}function _s(){eo.prototype.getPointee=Ii,eo.prototype.destructor=Ts,eo.prototype.argPackAdvance=8,eo.prototype.readValueFromPointer=nt,eo.prototype.deleteObject=ko,eo.prototype.fromWireType=Ca}function eo(oe,ae,De,He,tt,z,ne,de,le,Q,he){this.name=oe,this.registeredClass=ae,this.isReference=De,this.isConst=He,this.isSmartPointer=tt,this.pointeeType=z,this.sharingPolicy=ne,this.rawGetPointee=de,this.rawConstructor=le,this.rawShare=Q,this.rawDestructor=he,!tt&&ae.baseClass===void 0?He?(this.toWireType=pi,this.destructorFunction=null):(this.toWireType=Wi,this.destructorFunction=null):this.toWireType=No}function zi(oe,ae,De){o.hasOwnProperty(oe)||Nt("Replacing nonexistant public symbol"),o[oe].overloadTable!==void 0&&De!==void 0?o[oe].overloadTable[De]=ae:(o[oe]=ae,o[oe].argCount=De)}function $i(oe,ae,De){var He=o["dynCall_"+oe];return De&&De.length?He.apply(null,[ae].concat(De)):He.call(null,ae)}var Ir=[];function yc(oe){var ae=Ir[oe];return ae||(oe>=Ir.length&&(Ir.length=oe+1),Ir[oe]=ae=Se.get(oe)),ae}function Vo(oe,ae,De){if(oe.includes("j"))return $i(oe,ae,De);var He=yc(ae).apply(null,De);return He}function Fo(oe,ae){var De=[];return function(){return De.length=0,Object.assign(De,arguments),Vo(oe,ae,De)}}function yr(oe,ae){oe=mn(oe);function De(){return oe.includes("j")?Fo(oe,ae):yc(ae)}var He=De();return typeof He!="function"&&Lt("unknown function pointer with signature "+oe+": "+ae),He}var wc=void 0;function mi(oe){var ae=Bo(oe),De=mn(ae);return Hi(ae),De}function Or(oe,ae){var De=[],He={};function tt(z){if(!He[z]&&!ot[z]){if(lt[z]){lt[z].forEach(tt);return}De.push(z),He[z]=!0}}throw ae.forEach(tt),new wc(oe+": "+De.map(mi).join([", "]))}function qa(oe,ae,De,He,tt,z,ne,de,le,Q,he,ge,me){he=mn(he),z=yr(tt,z),de&&(de=yr(ne,de)),Q&&(Q=yr(le,Q)),me=yr(ge,me);var N=Mt(he);Zr(N,function(){Or("Cannot construct "+he+" due to unbound types",[He])}),xn([oe,ae,De],He?[He]:[],function(k){k=k[0];var te,ve;He?(te=k.registeredClass,ve=te.instancePrototype):ve=Qi.prototype;var Ie=Ft(N,function(){if(Object.getPrototypeOf(this)!==ke)throw new Fr("Use 'new' to construct "+he);if(be.constructor_body===void 0)throw new Fr(he+" has no accessible constructor");var R=be.constructor_body[arguments.length];if(R===void 0)throw new Fr("Tried to invoke ctor of "+he+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(be.constructor_body).toString()+") parameters instead!");return R.apply(this,arguments)}),ke=Object.create(ve,{constructor:{value:Ie}});Ie.prototype=ke;var be=new Di(he,Ie,ke,me,te,z,de,Q),Oe=new eo(he,be,!0,!1,!1),W=new eo(he+"*",be,!1,!1,!1),$=new eo(he+" const*",be,!1,!0,!1);return Bn[oe]={pointerType:W,constPointerType:$},zi(N,Ie),[Oe,W,$]})}function mo(oe,ae){for(var De=[],He=0;He<oe;He++)De.push(G[ae+He*4>>2]);return De}function ii(oe,ae){if(!(oe instanceof Function))throw new TypeError("new_ called with constructor type "+typeof oe+" which is not a function");var De=Ft(oe.name||"unknownFunctionName",function(){});De.prototype=oe.prototype;var He=new De,tt=oe.apply(He,ae);return tt instanceof Object?tt:He}function ta(oe,ae,De,He,tt){var z=ae.length;z<2&&Lt("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var ne=ae[1]!==null&&De!==null,de=!1,le=1;le<ae.length;++le)if(ae[le]!==null&&ae[le].destructorFunction===void 0){de=!0;break}for(var Q=ae[0].name!=="void",he="",ge="",le=0;le<z-2;++le)he+=(le!==0?", ":"")+"arg"+le,ge+=(le!==0?", ":"")+"arg"+le+"Wired";var me="return function "+Mt(oe)+"("+he+`) {
|
||
if (arguments.length !== `+(z-2)+`) {
|
||
throwBindingError('function `+oe+" called with ' + arguments.length + ' arguments, expected "+(z-2)+` args!');
|
||
}
|
||
`;de&&(me+=`var destructors = [];
|
||
`);var N=de?"destructors":"null",k=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],te=[Lt,He,tt,Ue,ae[0],ae[1]];ne&&(me+="var thisWired = classParam.toWireType("+N+`, this);
|
||
`);for(var le=0;le<z-2;++le)me+="var arg"+le+"Wired = argType"+le+".toWireType("+N+", arg"+le+"); // "+ae[le+2].name+`
|
||
`,k.push("argType"+le),te.push(ae[le+2]);if(ne&&(ge="thisWired"+(ge.length>0?", ":"")+ge),me+=(Q?"var rv = ":"")+"invoker(fn"+(ge.length>0?", ":"")+ge+`);
|
||
`,de)me+=`runDestructors(destructors);
|
||
`;else for(var le=ne?1:2;le<ae.length;++le){var ve=le===1?"thisWired":"arg"+(le-2)+"Wired";ae[le].destructorFunction!==null&&(me+=ve+"_dtor("+ve+"); // "+ae[le].name+`
|
||
`,k.push(ve+"_dtor"),te.push(ae[le].destructorFunction))}Q&&(me+=`var ret = retType.fromWireType(rv);
|
||
return ret;
|
||
`),me+=`}
|
||
`,k.push(me);var Ie=ii(Function,k).apply(null,te);return Ie}function Es(oe,ae,De,He,tt,z){T(ae>0);var ne=mo(ae,De);tt=yr(He,tt),xn([],[oe],function(de){de=de[0];var le="constructor "+de.name;if(de.registeredClass.constructor_body===void 0&&(de.registeredClass.constructor_body=[]),de.registeredClass.constructor_body[ae-1]!==void 0)throw new Fr("Cannot register multiple constructors with identical number of parameters ("+(ae-1)+") for class '"+de.name+"'! Overload resolution is currently only performed using the parameter count, not actual type info!");return de.registeredClass.constructor_body[ae-1]=()=>{Or("Cannot construct "+de.name+" due to unbound types",ne)},xn([],ne,function(Q){return Q.splice(1,0,null),de.registeredClass.constructor_body[ae-1]=ta(le,Q,null,tt,z),[]}),[]})}function Xa(oe,ae,De,He,tt,z,ne,de){var le=mo(De,He);ae=mn(ae),z=yr(tt,z),xn([],[oe],function(Q){Q=Q[0];var he=Q.name+"."+ae;ae.startsWith("@@")&&(ae=Symbol[ae.substring(2)]),de&&Q.registeredClass.pureVirtualFunctions.push(ae);function ge(){Or("Cannot call "+he+" due to unbound types",le)}var me=Q.registeredClass.instancePrototype,N=me[ae];return N===void 0||N.overloadTable===void 0&&N.className!==Q.name&&N.argCount===De-2?(ge.argCount=De-2,ge.className=Q.name,me[ae]=ge):(po(me,ae,he),me[ae].overloadTable[De-2]=ge),xn([],le,function(k){var te=ta(he,k,Q,z,ne);return me[ae].overloadTable===void 0?(te.argCount=De-2,me[ae]=te):me[ae].overloadTable[De-2]=te,[]}),[]})}var Ta=[],Vn=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function _a(oe){oe>4&&--Vn[oe].refcount===0&&(Vn[oe]=void 0,Ta.push(oe))}function Qr(){for(var oe=0,ae=5;ae<Vn.length;++ae)Vn[ae]!==void 0&&++oe;return oe}function Mr(){for(var oe=5;oe<Vn.length;++oe)if(Vn[oe]!==void 0)return Vn[oe];return null}function xc(){o.count_emval_handles=Qr,o.get_first_emval=Mr}var oi={toValue:oe=>(oe||Lt("Cannot use deleted val. handle = "+oe),Vn[oe].value),toHandle:oe=>{switch(oe){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:{var ae=Ta.length?Ta.pop():Vn.length;return Vn[ae]={refcount:1,value:oe},ae}}}};function Ya(oe,ae){ae=mn(ae),Cn(oe,{name:ae,fromWireType:function(De){var He=oi.toValue(De);return _a(De),He},toWireType:function(De,He){return oi.toHandle(He)},argPackAdvance:8,readValueFromPointer:nt,destructorFunction:null})}function Sn(oe){if(oe===null)return"null";var ae=typeof oe;return ae==="object"||ae==="array"||ae==="function"?oe.toString():""+oe}function ji(oe,ae){switch(ae){case 2:return function(De){return this.fromWireType(X[De>>2])};case 3:return function(De){return this.fromWireType(ee[De>>3])};default:throw new TypeError("Unknown float type: "+oe)}}function Ea(oe,ae,De){var He=Ye(De);ae=mn(ae),Cn(oe,{name:ae,fromWireType:function(tt){return tt},toWireType:function(tt,z){return z},argPackAdvance:8,readValueFromPointer:ji(ae,He),destructorFunction:null})}function ba(oe,ae,De,He,tt,z){var ne=mo(ae,De);oe=mn(oe),tt=yr(He,tt),Zr(oe,function(){Or("Cannot call "+oe+" due to unbound types",ne)},ae-1),xn([],ne,function(de){var le=[de[0],null].concat(de.slice(1));return zi(oe,ta(oe,le,null,tt,z),ae-1),[]})}function Oi(oe,ae,De){switch(ae){case 0:return De?function(tt){return L[tt]}:function(tt){return B[tt]};case 1:return De?function(tt){return H[tt>>1]}:function(tt){return A[tt>>1]};case 2:return De?function(tt){return F[tt>>2]}:function(tt){return G[tt>>2]};default:throw new TypeError("Unknown integer type: "+oe)}}function bs(oe,ae,De,He,tt){ae=mn(ae);var z=Ye(De),ne=ge=>ge;if(He===0){var de=32-8*De;ne=ge=>ge<<de>>>de}var le=ae.includes("unsigned"),Q=(ge,me)=>{},he;le?he=function(ge,me){return Q(me,this.name),me>>>0}:he=function(ge,me){return Q(me,this.name),me},Cn(oe,{name:ae,fromWireType:ne,toWireType:he,argPackAdvance:8,readValueFromPointer:Oi(ae,z,He!==0),destructorFunction:null})}function na(oe,ae,De){var He=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],tt=He[ae];function z(ne){ne=ne>>2;var de=G,le=de[ne],Q=de[ne+1];return new tt(O,Q,le)}De=mn(De),Cn(oe,{name:De,fromWireType:z,argPackAdvance:8,readValueFromPointer:z},{ignoreDuplicateRegistrations:!0})}function Cc(oe,ae){ae=mn(ae);var De=ae==="std::string";Cn(oe,{name:ae,fromWireType:function(He){var tt=G[He>>2],z=He+4,ne;if(De)for(var de=z,le=0;le<=tt;++le){var Q=z+le;if(le==tt||B[Q]==0){var he=Q-de,ge=b(de,he);ne===void 0?ne=ge:(ne+="\0",ne+=ge),de=Q+1}}else{for(var me=new Array(tt),le=0;le<tt;++le)me[le]=String.fromCharCode(B[z+le]);ne=me.join("")}return Hi(He),ne},toWireType:function(He,tt){tt instanceof ArrayBuffer&&(tt=new Uint8Array(tt));var z,ne=typeof tt=="string";ne||tt instanceof Uint8Array||tt instanceof Uint8ClampedArray||tt instanceof Int8Array||Lt("Cannot pass non-string to std::string"),De&&ne?z=P(tt):z=tt.length;var de=vo(4+z+1),le=de+4;if(G[de>>2]=z,De&&ne)I(tt,le,z+1);else if(ne)for(var Q=0;Q<z;++Q){var he=tt.charCodeAt(Q);he>255&&(Hi(le),Lt("String has UTF-16 code units that do not fit in 8 bits")),B[le+Q]=he}else for(var Q=0;Q<z;++Q)B[le+Q]=tt[Q];return He!==null&&He.push(Hi,de),de},argPackAdvance:8,readValueFromPointer:nt,destructorFunction:function(He){Hi(He)}})}var Uo=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0;function Da(oe,ae){for(var De=oe,He=De>>1,tt=He+ae/2;!(He>=tt)&&A[He];)++He;if(De=He<<1,De-oe>32&&Uo)return Uo.decode(B.subarray(oe,De));for(var z="",ne=0;!(ne>=ae/2);++ne){var de=H[oe+ne*2>>1];if(de==0)break;z+=String.fromCharCode(de)}return z}function Sc(oe,ae,De){if(De===void 0&&(De=2147483647),De<2)return 0;De-=2;for(var He=ae,tt=De<oe.length*2?De/2:oe.length,z=0;z<tt;++z){var ne=oe.charCodeAt(z);H[ae>>1]=ne,ae+=2}return H[ae>>1]=0,ae-He}function Ja(oe){return oe.length*2}function pl(oe,ae){for(var De=0,He="";!(De>=ae/4);){var tt=F[oe+De*4>>2];if(tt==0)break;if(++De,tt>=65536){var z=tt-65536;He+=String.fromCharCode(55296|z>>10,56320|z&1023)}else He+=String.fromCharCode(tt)}return He}function ml(oe,ae,De){if(De===void 0&&(De=2147483647),De<4)return 0;for(var He=ae,tt=He+De-4,z=0;z<oe.length;++z){var ne=oe.charCodeAt(z);if(ne>=55296&&ne<=57343){var de=oe.charCodeAt(++z);ne=65536+((ne&1023)<<10)|de&1023}if(F[ae>>2]=ne,ae+=4,ae+4>tt)break}return F[ae>>2]=0,ae-He}function vl(oe){for(var ae=0,De=0;De<oe.length;++De){var He=oe.charCodeAt(De);He>=55296&&He<=57343&&++De,ae+=4}return ae}function yl(oe,ae,De){De=mn(De);var He,tt,z,ne,de;ae===2?(He=Da,tt=Sc,ne=Ja,z=()=>A,de=1):ae===4&&(He=pl,tt=ml,ne=vl,z=()=>G,de=2),Cn(oe,{name:De,fromWireType:function(le){for(var Q=G[le>>2],he=z(),ge,me=le+4,N=0;N<=Q;++N){var k=le+4+N*ae;if(N==Q||he[k>>de]==0){var te=k-me,ve=He(me,te);ge===void 0?ge=ve:(ge+="\0",ge+=ve),me=k+ae}}return Hi(le),ge},toWireType:function(le,Q){typeof Q!="string"&&Lt("Cannot pass non-string to C++ string type "+De);var he=ne(Q),ge=vo(4+he+ae);return G[ge>>2]=he>>de,tt(Q,ge+4,he+ae),le!==null&&le.push(Hi,ge),ge},argPackAdvance:8,readValueFromPointer:nt,destructorFunction:function(le){Hi(le)}})}function wl(oe,ae,De,He,tt,z){dt[oe]={name:mn(ae),rawConstructor:yr(De,He),rawDestructor:yr(tt,z),fields:[]}}function Ds(oe,ae,De,He,tt,z,ne,de,le,Q){dt[oe].fields.push({fieldName:mn(ae),getterReturnType:De,getter:yr(He,tt),getterContext:z,setterArgumentType:ne,setter:yr(de,le),setterContext:Q})}function xl(oe,ae){ae=mn(ae),Cn(oe,{isVoid:!0,name:ae,argPackAdvance:0,fromWireType:function(){},toWireType:function(De,He){}})}var Is={};function Cl(oe){var ae=Is[oe];return ae===void 0?mn(oe):ae}function Os(){return typeof globalThis=="object"?globalThis:function(){return Function}()("return this")()}function Ms(oe){return oe===0?oi.toHandle(Os()):(oe=Cl(oe),oi.toHandle(Os()[oe]))}function Tc(oe){oe>4&&(Vn[oe].refcount+=1)}function Za(oe,ae){var De=ot[oe];return De===void 0&&Lt(ae+" has unknown type "+mi(oe)),De}function Ps(oe){for(var ae="",De=0;De<oe;++De)ae+=(De!==0?", ":"")+"arg"+De;for(var He=()=>G,tt="return function emval_allocator_"+oe+`(constructor, argTypes, args) {
|
||
var HEAPU32 = getMemory();
|
||
`,De=0;De<oe;++De)tt+="var argType"+De+" = requireRegisteredType(HEAPU32[((argTypes)>>2)], 'parameter "+De+`');
|
||
var arg`+De+" = argType"+De+`.readValueFromPointer(args);
|
||
args += argType`+De+`['argPackAdvance'];
|
||
argTypes += 4;
|
||
`;return tt+="var obj = new constructor("+ae+`);
|
||
return valueToHandle(obj);
|
||
}
|
||
`,new Function("requireRegisteredType","Module","valueToHandle","getMemory",tt)(Za,o,oi.toHandle,He)}var Rs={};function Qa(oe,ae,De,He){oe=oi.toValue(oe);var tt=Rs[ae];return tt||(tt=Ps(ae),Rs[ae]=tt),tt(oe,De,He)}function _c(oe,ae){oe=Za(oe,"_emval_take_value");var De=oe.readValueFromPointer(ae);return oi.toHandle(De)}function Ls(){Fe("")}function Ec(oe,ae,De){B.copyWithin(oe,ae,ae+De)}function As(){return 2147483648}function bc(oe){try{return C.grow(oe-O.byteLength+65535>>>16),ce(C.buffer),1}catch{}}function Dc(oe){var ae=B.length;oe=oe>>>0;var De=As();if(oe>De)return!1;let He=(le,Q)=>le+(Q-le%Q)%Q;for(var tt=1;tt<=4;tt*=2){var z=ae*(1+.2/tt);z=Math.min(z,oe+100663296);var ne=Math.min(De,He(Math.max(oe,z),65536)),de=bc(ne);if(de)return!0}return!1}function Ic(oe){var ae=o["_"+oe];return ae}function Oc(oe,ae){L.set(oe,ae)}function es(oe,ae,De,He,tt){var z={string:k=>{var te=0;if(k!=null&&k!==0){var ve=(k.length<<2)+1;te=ns(ve),I(k,te,ve)}return te},array:k=>{var te=ns(k.length);return Oc(k,te),te}};function ne(k){return ae==="string"?b(k):ae==="boolean"?!!k:k}var de=Ic(oe),le=[],Q=0;if(He)for(var he=0;he<He.length;he++){var ge=z[De[he]];ge?(Q===0&&(Q=Ns()),le[he]=ge(He[he])):le[he]=He[he]}var me=de.apply(null,le);function N(k){return Q!==0&&ks(Q),ne(k)}return me=N(me),me}Dn=o.InternalError=wn(Error,"InternalError"),ut(),Fr=o.BindingError=wn(Error,"BindingError"),ea(),bi(),_s(),wc=o.UnboundTypeError=wn(Error,"UnboundTypeError"),xc();var ts={h:pt,q:Ui,r:br,w:Yt,p:qa,o:Es,c:Xa,v:Ya,k:Ea,e:ba,b:bs,a:na,j:Cc,g:yl,u:wl,d:Ds,x:xl,i:_a,m:Ms,l:Tc,y:Qa,n:_c,f:Ls,t:Ec,s:Dc};Ee(),o.___wasm_call_ctors=function(){return(o.___wasm_call_ctors=o.asm.A).apply(null,arguments)};var vo=o._malloc=function(){return(vo=o._malloc=o.asm.B).apply(null,arguments)},Bo=o.___getTypeName=function(){return(Bo=o.___getTypeName=o.asm.D).apply(null,arguments)};o.__embind_initialize_bindings=function(){return(o.__embind_initialize_bindings=o.asm.E).apply(null,arguments)};var Hi=o._free=function(){return(Hi=o._free=o.asm.F).apply(null,arguments)},Ns=o.stackSave=function(){return(Ns=o.stackSave=o.asm.G).apply(null,arguments)},ks=o.stackRestore=function(){return(ks=o.stackRestore=o.asm.H).apply(null,arguments)},ns=o.stackAlloc=function(){return(ns=o.stackAlloc=o.asm.I).apply(null,arguments)},Vs=o.___cxa_is_pointer_type=function(){return(Vs=o.___cxa_is_pointer_type=o.asm.J).apply(null,arguments)};o.ccall=es;var Ia;re=function oe(){Ia||Fs(),Ia||(re=oe)};function Fs(oe){if(J>0||(Ge(),J>0))return;function ae(){Ia||(Ia=!0,o.calledRun=!0,!S&&(Ne(),a(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),j()))}o.setStatus?(o.setStatus("Running..."),setTimeout(function(){setTimeout(function(){o.setStatus("")},1),ae()},1)):ae()}if(o.preInit)for(typeof o.preInit=="function"&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return Fs(),i.ready}})();t.exports=r})(g$);var OEe=g$.exports;const MEe=ll(OEe),PEe=new URL("/static/dv3d/charlswasm_decode.wasm",import.meta.url),M0={codec:void 0,decoder:void 0,decodeConfig:{}};function REe(t){return typeof t=="number"?M0.codec.getExceptionMessage(t):t}function LEe(t){if(M0.decodeConfig=t,M0.codec)return Promise.resolve();const e=MEe({locateFile:r=>r.endsWith(".wasm")?PEe.toString():r});return new Promise((r,n)=>{e.then(i=>{M0.codec=i,M0.decoder=new i.JpegLSDecoder,r()},n)})}async function z7(t,e){try{await LEe();const r=M0.decoder;r.getEncodedBuffer(t.length).set(t),r.decode();const i=r.getFrameInfo(),o=r.getInterleaveMode(),a=r.getNearLossless(),s=r.getDecodedBuffer(),c={columns:i.width,rows:i.height,bitsPerPixel:i.bitsPerSample,signed:e.signed,bytesPerPixel:e.bytesPerPixel,componentsPerPixel:i.componentCount},l=AEe(i,s,e.signed),f={nearLossless:a,interleaveMode:o,frameInfo:i};return{...e,pixelData:l,imageInfo:c,encodeOptions:f,...f,...c}}catch(r){throw REe(r)}}function AEe(t,e,r){return t.bitsPerSample>8?r?new Int16Array(e.buffer,e.byteOffset,e.byteLength/2):new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2):r?new Int8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var p$={exports:{}};(function(t,e){var r=(()=>{var n=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename<"u"&&(n=n||__filename),function(i){i=i||{};var o=typeof i<"u"?i:{},a,s;o.ready=new Promise(function(N,k){a=N,s=k});var c=Object.assign({},o),l="./this.program",f=typeof window=="object",u=typeof importScripts=="function",d=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",h="";function g(N){return o.locateFile?o.locateFile(N,h):h+N}var p,v,y;if(d){var m=el,w=el;u?h=w.dirname(h)+"/":h=__dirname+"/",p=(N,k)=>(N=Pe(N)?new URL(N):w.normalize(N),m.readFileSync(N,k?void 0:"utf8")),y=N=>{var k=p(N,!0);return k.buffer||(k=new Uint8Array(k)),k},v=(N,k,te)=>{N=Pe(N)?new URL(N):w.normalize(N),m.readFile(N,function(ve,Ie){ve?te(ve):k(Ie.buffer)})},process.argv.length>1&&(l=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),process.on("uncaughtException",function(N){if(!(N instanceof ft))throw N}),process.on("unhandledRejection",function(N){throw N}),o.inspect=function(){return"[Emscripten Module object]"}}else(f||u)&&(u?h=self.location.href:typeof document<"u"&&document.currentScript&&(h=document.currentScript.src),n&&(h=n),h.indexOf("blob:")!==0?h=h.substr(0,h.replace(/[?#].*/,"").lastIndexOf("/")+1):h="",p=N=>{var k=new XMLHttpRequest;return k.open("GET",N,!1),k.send(null),k.responseText},u&&(y=N=>{var k=new XMLHttpRequest;return k.open("GET",N,!1),k.responseType="arraybuffer",k.send(null),new Uint8Array(k.response)}),v=(N,k,te)=>{var ve=new XMLHttpRequest;ve.open("GET",N,!0),ve.responseType="arraybuffer",ve.onload=()=>{if(ve.status==200||ve.status==0&&ve.response){k(ve.response);return}te()},ve.onerror=te,ve.send(null)});var x=o.print||console.log.bind(console),C=o.printErr||console.warn.bind(console);Object.assign(o,c),c=null,o.arguments&&o.arguments,o.thisProgram&&(l=o.thisProgram),o.quit&&o.quit;var S;o.wasmBinary&&(S=o.wasmBinary),o.noExitRuntime,typeof WebAssembly!="object"&&Xe("no native wasm support detected");var T,_=!1;function E(N,k){N||Xe(k)}var b=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function D(N,k,te){for(var ve=k+te,Ie=k;N[Ie]&&!(Ie>=ve);)++Ie;if(Ie-k>16&&N.buffer&&b)return b.decode(N.subarray(k,Ie));for(var ke="";k<Ie;){var be=N[k++];if(!(be&128)){ke+=String.fromCharCode(be);continue}var Oe=N[k++]&63;if((be&224)==192){ke+=String.fromCharCode((be&31)<<6|Oe);continue}var W=N[k++]&63;if((be&240)==224?be=(be&15)<<12|Oe<<6|W:be=(be&7)<<18|Oe<<12|W<<6|N[k++]&63,be<65536)ke+=String.fromCharCode(be);else{var $=be-65536;ke+=String.fromCharCode(55296|$>>10,56320|$&1023)}}return ke}function I(N,k){return N?D(A,N,k):""}function P(N,k,te,ve){if(!(ve>0))return 0;for(var Ie=te,ke=te+ve-1,be=0;be<N.length;++be){var Oe=N.charCodeAt(be);if(Oe>=55296&&Oe<=57343){var W=N.charCodeAt(++be);Oe=65536+((Oe&1023)<<10)|W&1023}if(Oe<=127){if(te>=ke)break;k[te++]=Oe}else if(Oe<=2047){if(te+1>=ke)break;k[te++]=192|Oe>>6,k[te++]=128|Oe&63}else if(Oe<=65535){if(te+2>=ke)break;k[te++]=224|Oe>>12,k[te++]=128|Oe>>6&63,k[te++]=128|Oe&63}else{if(te+3>=ke)break;k[te++]=240|Oe>>18,k[te++]=128|Oe>>12&63,k[te++]=128|Oe>>6&63,k[te++]=128|Oe&63}}return k[te]=0,te-Ie}function O(N,k,te){return P(N,A,k,te)}function L(N){for(var k=0,te=0;te<N.length;++te){var ve=N.charCodeAt(te);ve<=127?k++:ve<=2047?k+=2:ve>=55296&&ve<=57343?(k+=4,++te):k+=3}return k}var B,H,A,F,G,X,ee,ce,Se;function we(N){B=N,o.HEAP8=H=new Int8Array(N),o.HEAP16=F=new Int16Array(N),o.HEAP32=X=new Int32Array(N),o.HEAPU8=A=new Uint8Array(N),o.HEAPU16=G=new Uint16Array(N),o.HEAPU32=ee=new Uint32Array(N),o.HEAPF32=ce=new Float32Array(N),o.HEAPF64=Se=new Float64Array(N)}o.INITIAL_MEMORY;var _e,Ve=[],Ge=[],Ne=[];function j(){if(o.preRun)for(typeof o.preRun=="function"&&(o.preRun=[o.preRun]);o.preRun.length;)K(o.preRun.shift());pt(Ve)}function M(){pt(Ge)}function q(){if(o.postRun)for(typeof o.postRun=="function"&&(o.postRun=[o.postRun]);o.postRun.length;)re(o.postRun.shift());pt(Ne)}function K(N){Ve.unshift(N)}function J(N){Ge.unshift(N)}function re(N){Ne.unshift(N)}var ie=0,Re=null;function Fe(N){ie++,o.monitorRunDependencies&&o.monitorRunDependencies(ie)}function je(N){if(ie--,o.monitorRunDependencies&&o.monitorRunDependencies(ie),ie==0&&Re){var k=Re;Re=null,k()}}function Xe(N){o.onAbort&&o.onAbort(N),N="Aborted("+N+")",C(N),_=!0,N+=". Build with -sASSERTIONS for more info.";var k=new WebAssembly.RuntimeError(N);throw s(k),k}var se="data:application/octet-stream;base64,";function ue(N){return N.startsWith(se)}function Pe(N){return N.startsWith("file://")}var pe;pe="openjpegwasm_decode.wasm",ue(pe)||(pe=g(pe));function Ee(N){try{if(N==pe&&S)return new Uint8Array(S);if(y)return y(N);throw"both async and sync fetching of the wasm failed"}catch(k){Xe(k)}}function Qe(){if(!S&&(f||u)){if(typeof fetch=="function"&&!Pe(pe))return fetch(pe,{credentials:"same-origin"}).then(function(N){if(!N.ok)throw"failed to load wasm binary file at '"+pe+"'";return N.arrayBuffer()}).catch(function(){return Ee(pe)});if(v)return new Promise(function(N,k){v(pe,function(te){N(new Uint8Array(te))},k)})}return Promise.resolve().then(function(){return Ee(pe)})}function fe(){var N={a:He};function k(be,Oe){var W=be.exports;o.asm=W,T=o.asm.E,we(T.buffer),_e=o.asm.G,J(o.asm.F),je()}Fe();function te(be){k(be.instance)}function ve(be){return Qe().then(function(Oe){return WebAssembly.instantiate(Oe,N)}).then(function(Oe){return Oe}).then(be,function(Oe){C("failed to asynchronously prepare wasm: "+Oe),Xe(Oe)})}function Ie(){return!S&&typeof WebAssembly.instantiateStreaming=="function"&&!ue(pe)&&!Pe(pe)&&!d&&typeof fetch=="function"?fetch(pe,{credentials:"same-origin"}).then(function(be){var Oe=WebAssembly.instantiateStreaming(be,N);return Oe.then(te,function(W){return C("wasm streaming compile failed: "+W),C("falling back to ArrayBuffer instantiation"),ve(te)})}):ve(te)}if(o.instantiateWasm)try{var ke=o.instantiateWasm(N,k);return ke}catch(be){C("Module.instantiateWasm callback failed with error: "+be),s(be)}return Ie().catch(s),{}}function ft(N){this.name="ExitStatus",this.message="Program terminated with exit("+N+")",this.status=N}function pt(N){for(;N.length>0;)N.shift()(o)}function dt(N){this.excPtr=N,this.ptr=N-24,this.set_type=function(k){ee[this.ptr+4>>2]=k},this.get_type=function(){return ee[this.ptr+4>>2]},this.set_destructor=function(k){ee[this.ptr+8>>2]=k},this.get_destructor=function(){return ee[this.ptr+8>>2]},this.set_refcount=function(k){X[this.ptr>>2]=k},this.set_caught=function(k){k=k?1:0,H[this.ptr+12>>0]=k},this.get_caught=function(){return H[this.ptr+12>>0]!=0},this.set_rethrown=function(k){k=k?1:0,H[this.ptr+13>>0]=k},this.get_rethrown=function(){return H[this.ptr+13>>0]!=0},this.init=function(k,te){this.set_adjusted_ptr(0),this.set_type(k),this.set_destructor(te),this.set_refcount(0),this.set_caught(!1),this.set_rethrown(!1)},this.add_ref=function(){var k=X[this.ptr>>2];X[this.ptr>>2]=k+1},this.release_ref=function(){var k=X[this.ptr>>2];return X[this.ptr>>2]=k-1,k===1},this.set_adjusted_ptr=function(k){ee[this.ptr+16>>2]=k},this.get_adjusted_ptr=function(){return ee[this.ptr+16>>2]},this.get_exception_ptr=function(){var k=he(this.get_type());if(k)return ee[this.excPtr>>2];var te=this.get_adjusted_ptr();return te!==0?te:this.excPtr}}function Ue(N,k,te){var ve=new dt(N);throw ve.init(k,te),N}var nt={};function at(N){for(;N.length;){var k=N.pop(),te=N.pop();te(k)}}function ot(N){return this.fromWireType(X[N>>2])}var lt={},_t={},vt={},Mt=48,Ft=57;function wn(N){if(N===void 0)return"_unknown";N=N.replace(/[^a-zA-Z0-9_]/g,"$");var k=N.charCodeAt(0);return k>=Mt&&k<=Ft?"_"+N:N}function Dn(N,k){return N=wn(N),new Function("body","return function "+N+`() {
|
||
"use strict"; return body.apply(this, arguments);
|
||
};
|
||
`)(k)}function Nt(N,k){var te=Dn(k,function(ve){this.name=k,this.message=ve;var Ie=new Error(ve).stack;Ie!==void 0&&(this.stack=this.toString()+`
|
||
`+Ie.replace(/^Error(:[^\n]*)?\n/,""))});return te.prototype=Object.create(N.prototype),te.prototype.constructor=te,te.prototype.toString=function(){return this.message===void 0?this.name:this.name+": "+this.message},te}var xn=void 0;function Ui(N){throw new xn(N)}function br(N,k,te){N.forEach(function(Oe){vt[Oe]=k});function ve(Oe){var W=te(Oe);W.length!==N.length&&Ui("Mismatched type converter count");for(var $=0;$<N.length;++$)jt(N[$],W[$])}var Ie=new Array(k.length),ke=[],be=0;k.forEach((Oe,W)=>{_t.hasOwnProperty(Oe)?Ie[W]=_t[Oe]:(ke.push(Oe),lt.hasOwnProperty(Oe)||(lt[Oe]=[]),lt[Oe].push(()=>{Ie[W]=_t[Oe],++be,be===ke.length&&ve(Ie)}))}),ke.length===0&&ve(Ie)}function Ye(N){var k=nt[N];delete nt[N];var te=k.rawConstructor,ve=k.rawDestructor,Ie=k.fields,ke=Ie.map(be=>be.getterReturnType).concat(Ie.map(be=>be.setterArgumentType));br([N],ke,be=>{var Oe={};return Ie.forEach((W,$)=>{var R=W.fieldName,V=be[$],Y=W.getter,ye=W.getterContext,xe=be[$+Ie.length],Ce=W.setter,Te=W.setterContext;Oe[R]={read:Me=>V.fromWireType(Y(ye,Me)),write:(Me,Ae)=>{var qe=[];Ce(Te,Me,xe.toWireType(qe,Ae)),at(qe)}}}),[{name:k.name,fromWireType:function(W){var $={};for(var R in Oe)$[R]=Oe[R].read(W);return ve(W),$},toWireType:function(W,$){for(var R in Oe)if(!(R in $))throw new TypeError('Missing field: "'+R+'"');var V=te();for(R in Oe)Oe[R].write(V,$[R]);return W!==null&&W.push(ve,V),V},argPackAdvance:8,readValueFromPointer:ot,destructorFunction:ve}]})}function ut(N,k,te,ve,Ie){}function Rt(N){switch(N){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+N)}}function mn(){for(var N=new Array(256),k=0;k<256;++k)N[k]=String.fromCharCode(k);Fr=N}var Fr=void 0;function Lt(N){for(var k="",te=N;A[te];)k+=Fr[A[te++]];return k}var Cn=void 0;function Yt(N){throw new Cn(N)}function jt(N,k,te={}){if(!("argPackAdvance"in k))throw new TypeError("registerType registeredInstance requires argPackAdvance");var ve=k.name;if(N||Yt('type "'+ve+'" must have a positive integer typeid pointer'),_t.hasOwnProperty(N)){if(te.ignoreDuplicateRegistrations)return;Yt("Cannot register type '"+ve+"' twice")}if(_t[N]=k,delete vt[N],lt.hasOwnProperty(N)){var Ie=lt[N];delete lt[N],Ie.forEach(ke=>ke())}}function hi(N,k,te,ve,Ie){var ke=Rt(te);k=Lt(k),jt(N,{name:k,fromWireType:function(be){return!!be},toWireType:function(be,Oe){return Oe?ve:Ie},argPackAdvance:8,readValueFromPointer:function(be){var Oe;if(te===1)Oe=H;else if(te===2)Oe=F;else if(te===4)Oe=X;else throw new TypeError("Unknown boolean type size: "+k);return this.fromWireType(Oe[be>>ke])},destructorFunction:null})}function Bi(N){if(!(this instanceof Zr)||!(N instanceof Zr))return!1;for(var k=this.$$.ptrType.registeredClass,te=this.$$.ptr,ve=N.$$.ptrType.registeredClass,Ie=N.$$.ptr;k.baseClass;)te=k.upcast(te),k=k.baseClass;for(;ve.baseClass;)Ie=ve.upcast(Ie),ve=ve.baseClass;return k===ve&&te===Ie}function Ao(N){return{count:N.count,deleteScheduled:N.deleteScheduled,preservePointerOnDelete:N.preservePointerOnDelete,ptr:N.ptr,ptrType:N.ptrType,smartPtr:N.smartPtr,smartPtrType:N.smartPtrType}}function jn(N){function k(te){return te.$$.ptrType.registeredClass.name}Yt(k(N)+" instance already deleted")}var fo=!1;function Ei(N){}function xa(N){N.smartPtr?N.smartPtrType.rawDestructor(N.smartPtr):N.ptrType.registeredClass.rawDestructor(N.ptr)}function Bn(N){N.count.value-=1;var k=N.count.value===0;k&&xa(N)}function Ct(N,k,te){if(k===te)return N;if(te.baseClass===void 0)return null;var ve=Ct(N,k,te.baseClass);return ve===null?null:te.downcast(ve)}var Zt={};function ar(){return Object.keys(go).length}function Qo(){var N=[];for(var k in go)go.hasOwnProperty(k)&&N.push(go[k]);return N}var Dr=[];function ho(){for(;Dr.length;){var N=Dr.pop();N.$$.deleteScheduled=!1,N.delete()}}var bi=void 0;function Ur(N){bi=N,Dr.length&&bi&&bi(ho)}function Cs(){o.getInheritedInstanceCount=ar,o.getLiveInheritedInstances=Qo,o.flushPendingDeletes=ho,o.setDelayFunction=Ur}var go={};function Zi(N,k){for(k===void 0&&Yt("ptr should not be undefined");N.baseClass;)k=N.upcast(k),N=N.baseClass;return k}function Ca(N,k){return k=Zi(N,k),go[k]}function gi(N,k){(!k.ptrType||!k.ptr)&&Ui("makeClassHandle requires ptr and ptrType");var te=!!k.smartPtrType,ve=!!k.smartPtr;return te!==ve&&Ui("Both smartPtrType and smartPtr must be specified"),k.count={value:1},ln(Object.create(N,{$$:{value:k}}))}function Sa(N){var k=this.getPointee(N);if(!k)return this.destructor(N),null;var te=Ca(this.registeredClass,k);if(te!==void 0){if(te.$$.count.value===0)return te.$$.ptr=k,te.$$.smartPtr=N,te.clone();var ve=te.clone();return this.destructor(N),ve}function Ie(){return this.isSmartPointer?gi(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:k,smartPtrType:this,smartPtr:N}):gi(this.registeredClass.instancePrototype,{ptrType:this,ptr:N})}var ke=this.registeredClass.getActualType(k),be=Zt[ke];if(!be)return Ie.call(this);var Oe;this.isConst?Oe=be.constPointerType:Oe=be.pointerType;var W=Ct(k,this.registeredClass,Oe.registeredClass);return W===null?Ie.call(this):this.isSmartPointer?gi(Oe.registeredClass.instancePrototype,{ptrType:Oe,ptr:W,smartPtrType:this,smartPtr:N}):gi(Oe.registeredClass.instancePrototype,{ptrType:Oe,ptr:W})}function ln(N){return typeof FinalizationRegistry>"u"?(ln=k=>k,N):(fo=new FinalizationRegistry(k=>{Bn(k.$$)}),ln=k=>{var te=k.$$,ve=!!te.smartPtr;if(ve){var Ie={$$:te};fo.register(k,Ie,k)}return k},Ei=k=>fo.unregister(k),ln(N))}function Gi(){if(this.$$.ptr||jn(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var N=ln(Object.create(Object.getPrototypeOf(this),{$$:{value:Ao(this.$$)}}));return N.$$.count.value+=1,N.$$.deleteScheduled=!1,N}function Ss(){this.$$.ptr||jn(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&Yt("Object already scheduled for deletion"),Ei(this),Bn(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)}function ea(){return!this.$$.ptr}function Qi(){return this.$$.ptr||jn(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&Yt("Object already scheduled for deletion"),Dr.push(this),Dr.length===1&&bi&&bi(ho),this.$$.deleteScheduled=!0,this}function po(){Zr.prototype.isAliasOf=Bi,Zr.prototype.clone=Gi,Zr.prototype.delete=Ss,Zr.prototype.isDeleted=ea,Zr.prototype.deleteLater=Qi}function Zr(){}function Di(N,k,te){if(N[k].overloadTable===void 0){var ve=N[k];N[k]=function(){return N[k].overloadTable.hasOwnProperty(arguments.length)||Yt("Function '"+te+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+N[k].overloadTable+")!"),N[k].overloadTable[arguments.length].apply(this,arguments)},N[k].overloadTable=[],N[k].overloadTable[ve.argCount]=ve}}function sn(N,k,te){o.hasOwnProperty(N)?(Yt("Cannot register public name '"+N+"' twice"),Di(o,N,N),o.hasOwnProperty(te)&&Yt("Cannot register multiple overloads of a function with the same number of arguments ("+te+")!"),o[N].overloadTable[te]=k):o[N]=k}function pi(N,k,te,ve,Ie,ke,be,Oe){this.name=N,this.constructor=k,this.instancePrototype=te,this.rawDestructor=ve,this.baseClass=Ie,this.getActualType=ke,this.upcast=be,this.downcast=Oe,this.pureVirtualFunctions=[]}function No(N,k,te){for(;k!==te;)k.upcast||Yt("Expected null or instance of "+te.name+", got an instance of "+k.name),N=k.upcast(N),k=k.baseClass;return N}function Wi(N,k){if(k===null)return this.isReference&&Yt("null is not a valid "+this.name),0;k.$$||Yt('Cannot pass "'+Ea(k)+'" as a '+this.name),k.$$.ptr||Yt("Cannot pass deleted object as a pointer of type "+this.name);var te=k.$$.ptrType.registeredClass,ve=No(k.$$.ptr,te,this.registeredClass);return ve}function Ii(N,k){var te;if(k===null)return this.isReference&&Yt("null is not a valid "+this.name),this.isSmartPointer?(te=this.rawConstructor(),N!==null&&N.push(this.rawDestructor,te),te):0;k.$$||Yt('Cannot pass "'+Ea(k)+'" as a '+this.name),k.$$.ptr||Yt("Cannot pass deleted object as a pointer of type "+this.name),!this.isConst&&k.$$.ptrType.isConst&&Yt("Cannot convert argument of type "+(k.$$.smartPtrType?k.$$.smartPtrType.name:k.$$.ptrType.name)+" to parameter type "+this.name);var ve=k.$$.ptrType.registeredClass;if(te=No(k.$$.ptr,ve,this.registeredClass),this.isSmartPointer)switch(k.$$.smartPtr===void 0&&Yt("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:k.$$.smartPtrType===this?te=k.$$.smartPtr:Yt("Cannot convert argument of type "+(k.$$.smartPtrType?k.$$.smartPtrType.name:k.$$.ptrType.name)+" to parameter type "+this.name);break;case 1:te=k.$$.smartPtr;break;case 2:if(k.$$.smartPtrType===this)te=k.$$.smartPtr;else{var Ie=k.clone();te=this.rawShare(te,Sn.toHandle(function(){Ie.delete()})),N!==null&&N.push(this.rawDestructor,te)}break;default:Yt("Unsupporting sharing policy")}return te}function Ts(N,k){if(k===null)return this.isReference&&Yt("null is not a valid "+this.name),0;k.$$||Yt('Cannot pass "'+Ea(k)+'" as a '+this.name),k.$$.ptr||Yt("Cannot pass deleted object as a pointer of type "+this.name),k.$$.ptrType.isConst&&Yt("Cannot convert argument of type "+k.$$.ptrType.name+" to parameter type "+this.name);var te=k.$$.ptrType.registeredClass,ve=No(k.$$.ptr,te,this.registeredClass);return ve}function ko(N){return this.rawGetPointee&&(N=this.rawGetPointee(N)),N}function _s(N){this.rawDestructor&&this.rawDestructor(N)}function eo(N){N!==null&&N.delete()}function zi(){$i.prototype.getPointee=ko,$i.prototype.destructor=_s,$i.prototype.argPackAdvance=8,$i.prototype.readValueFromPointer=ot,$i.prototype.deleteObject=eo,$i.prototype.fromWireType=Sa}function $i(N,k,te,ve,Ie,ke,be,Oe,W,$,R){this.name=N,this.registeredClass=k,this.isReference=te,this.isConst=ve,this.isSmartPointer=Ie,this.pointeeType=ke,this.sharingPolicy=be,this.rawGetPointee=Oe,this.rawConstructor=W,this.rawShare=$,this.rawDestructor=R,!Ie&&k.baseClass===void 0?ve?(this.toWireType=Wi,this.destructorFunction=null):(this.toWireType=Ts,this.destructorFunction=null):this.toWireType=Ii}function Ir(N,k,te){o.hasOwnProperty(N)||Ui("Replacing nonexistant public symbol"),o[N].overloadTable!==void 0&&te!==void 0||(o[N]=k,o[N].argCount=te)}function yc(N,k,te){var ve=o["dynCall_"+N];return te&&te.length?ve.apply(null,[k].concat(te)):ve.call(null,k)}var Vo=[];function Fo(N){var k=Vo[N];return k||(N>=Vo.length&&(Vo.length=N+1),Vo[N]=k=_e.get(N)),k}function yr(N,k,te){if(N.includes("j"))return yc(N,k,te);var ve=Fo(k).apply(null,te);return ve}function wc(N,k){var te=[];return function(){return te.length=0,Object.assign(te,arguments),yr(N,k,te)}}function mi(N,k){N=Lt(N);function te(){return N.includes("j")?wc(N,k):Fo(k)}var ve=te();return typeof ve!="function"&&Yt("unknown function pointer with signature "+N+": "+k),ve}var Or=void 0;function qa(N){var k=ne(N),te=Lt(k);return z(k),te}function mo(N,k){var te=[],ve={};function Ie(ke){if(!ve[ke]&&!_t[ke]){if(vt[ke]){vt[ke].forEach(Ie);return}te.push(ke),ve[ke]=!0}}throw k.forEach(Ie),new Or(N+": "+te.map(qa).join([", "]))}function ii(N,k,te,ve,Ie,ke,be,Oe,W,$,R,V,Y){R=Lt(R),ke=mi(Ie,ke),Oe&&(Oe=mi(be,Oe)),$&&($=mi(W,$)),Y=mi(V,Y);var ye=wn(R);sn(ye,function(){mo("Cannot construct "+R+" due to unbound types",[ve])}),br([N,k,te],ve?[ve]:[],function(xe){xe=xe[0];var Ce,Te;ve?(Ce=xe.registeredClass,Te=Ce.instancePrototype):Te=Zr.prototype;var Me=Dn(ye,function(){if(Object.getPrototypeOf(this)!==Ae)throw new Cn("Use 'new' to construct "+R);if(qe.constructor_body===void 0)throw new Cn(R+" has no accessible constructor");var zt=qe.constructor_body[arguments.length];if(zt===void 0)throw new Cn("Tried to invoke ctor of "+R+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(qe.constructor_body).toString()+") parameters instead!");return zt.apply(this,arguments)}),Ae=Object.create(Te,{constructor:{value:Me}});Me.prototype=Ae;var qe=new pi(R,Me,Ae,Y,Ce,ke,Oe,$),rt=new $i(R,qe,!0,!1,!1),mt=new $i(R+"*",qe,!1,!1,!1),ht=new $i(R+" const*",qe,!1,!0,!1);return Zt[N]={pointerType:mt,constPointerType:ht},Ir(ye,Me),[rt,mt,ht]})}function ta(N,k){for(var te=[],ve=0;ve<N;ve++)te.push(ee[k+ve*4>>2]);return te}function Es(N,k){if(!(N instanceof Function))throw new TypeError("new_ called with constructor type "+typeof N+" which is not a function");var te=Dn(N.name||"unknownFunctionName",function(){});te.prototype=N.prototype;var ve=new te,Ie=N.apply(ve,k);return Ie instanceof Object?Ie:ve}function Xa(N,k,te,ve,Ie){var ke=k.length;ke<2&&Yt("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var be=k[1]!==null&&te!==null,Oe=!1,W=1;W<k.length;++W)if(k[W]!==null&&k[W].destructorFunction===void 0){Oe=!0;break}for(var $=k[0].name!=="void",R="",V="",W=0;W<ke-2;++W)R+=(W!==0?", ":"")+"arg"+W,V+=(W!==0?", ":"")+"arg"+W+"Wired";var Y="return function "+wn(N)+"("+R+`) {
|
||
if (arguments.length !== `+(ke-2)+`) {
|
||
throwBindingError('function `+N+" called with ' + arguments.length + ' arguments, expected "+(ke-2)+` args!');
|
||
}
|
||
`;Oe&&(Y+=`var destructors = [];
|
||
`);var ye=Oe?"destructors":"null",xe=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],Ce=[Yt,ve,Ie,at,k[0],k[1]];be&&(Y+="var thisWired = classParam.toWireType("+ye+`, this);
|
||
`);for(var W=0;W<ke-2;++W)Y+="var arg"+W+"Wired = argType"+W+".toWireType("+ye+", arg"+W+"); // "+k[W+2].name+`
|
||
`,xe.push("argType"+W),Ce.push(k[W+2]);if(be&&(V="thisWired"+(V.length>0?", ":"")+V),Y+=($?"var rv = ":"")+"invoker(fn"+(V.length>0?", ":"")+V+`);
|
||
`,Oe)Y+=`runDestructors(destructors);
|
||
`;else for(var W=be?1:2;W<k.length;++W){var Te=W===1?"thisWired":"arg"+(W-2)+"Wired";k[W].destructorFunction!==null&&(Y+=Te+"_dtor("+Te+"); // "+k[W].name+`
|
||
`,xe.push(Te+"_dtor"),Ce.push(k[W].destructorFunction))}$&&(Y+=`var ret = retType.fromWireType(rv);
|
||
return ret;
|
||
`),Y+=`}
|
||
`,xe.push(Y);var Me=Es(Function,xe).apply(null,Ce);return Me}function Ta(N,k,te,ve,Ie,ke){E(k>0);var be=ta(k,te);Ie=mi(ve,Ie),br([],[N],function(Oe){Oe=Oe[0];var W="constructor "+Oe.name;if(Oe.registeredClass.constructor_body===void 0&&(Oe.registeredClass.constructor_body=[]),Oe.registeredClass.constructor_body[k-1]!==void 0)throw new Cn("Cannot register multiple constructors with identical number of parameters ("+(k-1)+") for class '"+Oe.name+"'! Overload resolution is currently only performed using the parameter count, not actual type info!");return Oe.registeredClass.constructor_body[k-1]=()=>{mo("Cannot construct "+Oe.name+" due to unbound types",be)},br([],be,function($){return $.splice(1,0,null),Oe.registeredClass.constructor_body[k-1]=Xa(W,$,null,Ie,ke),[]}),[]})}function Vn(N,k,te,ve,Ie,ke,be,Oe){var W=ta(te,ve);k=Lt(k),ke=mi(Ie,ke),br([],[N],function($){$=$[0];var R=$.name+"."+k;k.startsWith("@@")&&(k=Symbol[k.substring(2)]),Oe&&$.registeredClass.pureVirtualFunctions.push(k);function V(){mo("Cannot call "+R+" due to unbound types",W)}var Y=$.registeredClass.instancePrototype,ye=Y[k];return ye===void 0||ye.overloadTable===void 0&&ye.className!==$.name&&ye.argCount===te-2?(V.argCount=te-2,V.className=$.name,Y[k]=V):(Di(Y,k,R),Y[k].overloadTable[te-2]=V),br([],W,function(xe){var Ce=Xa(R,xe,$,ke,be);return Y[k].overloadTable===void 0?(Ce.argCount=te-2,Y[k]=Ce):Y[k].overloadTable[te-2]=Ce,[]}),[]})}var _a=[],Qr=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function Mr(N){N>4&&--Qr[N].refcount===0&&(Qr[N]=void 0,_a.push(N))}function xc(){for(var N=0,k=5;k<Qr.length;++k)Qr[k]!==void 0&&++N;return N}function oi(){for(var N=5;N<Qr.length;++N)if(Qr[N]!==void 0)return Qr[N];return null}function Ya(){o.count_emval_handles=xc,o.get_first_emval=oi}var Sn={toValue:N=>(N||Yt("Cannot use deleted val. handle = "+N),Qr[N].value),toHandle:N=>{switch(N){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:{var k=_a.length?_a.pop():Qr.length;return Qr[k]={refcount:1,value:N},k}}}};function ji(N,k){k=Lt(k),jt(N,{name:k,fromWireType:function(te){var ve=Sn.toValue(te);return Mr(te),ve},toWireType:function(te,ve){return Sn.toHandle(ve)},argPackAdvance:8,readValueFromPointer:ot,destructorFunction:null})}function Ea(N){if(N===null)return"null";var k=typeof N;return k==="object"||k==="array"||k==="function"?N.toString():""+N}function ba(N,k){switch(k){case 2:return function(te){return this.fromWireType(ce[te>>2])};case 3:return function(te){return this.fromWireType(Se[te>>3])};default:throw new TypeError("Unknown float type: "+N)}}function Oi(N,k,te){var ve=Rt(te);k=Lt(k),jt(N,{name:k,fromWireType:function(Ie){return Ie},toWireType:function(Ie,ke){return ke},argPackAdvance:8,readValueFromPointer:ba(k,ve),destructorFunction:null})}function bs(N,k,te){switch(k){case 0:return te?function(Ie){return H[Ie]}:function(Ie){return A[Ie]};case 1:return te?function(Ie){return F[Ie>>1]}:function(Ie){return G[Ie>>1]};case 2:return te?function(Ie){return X[Ie>>2]}:function(Ie){return ee[Ie>>2]};default:throw new TypeError("Unknown integer type: "+N)}}function na(N,k,te,ve,Ie){k=Lt(k);var ke=Rt(te),be=V=>V;if(ve===0){var Oe=32-8*te;be=V=>V<<Oe>>>Oe}var W=k.includes("unsigned"),$=(V,Y)=>{},R;W?R=function(V,Y){return $(Y,this.name),Y>>>0}:R=function(V,Y){return $(Y,this.name),Y},jt(N,{name:k,fromWireType:be,toWireType:R,argPackAdvance:8,readValueFromPointer:bs(k,ke,ve!==0),destructorFunction:null})}function Cc(N,k,te){var ve=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],Ie=ve[k];function ke(be){be=be>>2;var Oe=ee,W=Oe[be],$=Oe[be+1];return new Ie(B,$,W)}te=Lt(te),jt(N,{name:te,fromWireType:ke,argPackAdvance:8,readValueFromPointer:ke},{ignoreDuplicateRegistrations:!0})}function Uo(N,k){k=Lt(k);var te=k==="std::string";jt(N,{name:k,fromWireType:function(ve){var Ie=ee[ve>>2],ke=ve+4,be;if(te)for(var Oe=ke,W=0;W<=Ie;++W){var $=ke+W;if(W==Ie||A[$]==0){var R=$-Oe,V=I(Oe,R);be===void 0?be=V:(be+="\0",be+=V),Oe=$+1}}else{for(var Y=new Array(Ie),W=0;W<Ie;++W)Y[W]=String.fromCharCode(A[ke+W]);be=Y.join("")}return z(ve),be},toWireType:function(ve,Ie){Ie instanceof ArrayBuffer&&(Ie=new Uint8Array(Ie));var ke,be=typeof Ie=="string";be||Ie instanceof Uint8Array||Ie instanceof Uint8ClampedArray||Ie instanceof Int8Array||Yt("Cannot pass non-string to std::string"),te&&be?ke=L(Ie):ke=Ie.length;var Oe=tt(4+ke+1),W=Oe+4;if(ee[Oe>>2]=ke,te&&be)O(Ie,W,ke+1);else if(be)for(var $=0;$<ke;++$){var R=Ie.charCodeAt($);R>255&&(z(W),Yt("String has UTF-16 code units that do not fit in 8 bits")),A[W+$]=R}else for(var $=0;$<ke;++$)A[W+$]=Ie[$];return ve!==null&&ve.push(z,Oe),Oe},argPackAdvance:8,readValueFromPointer:ot,destructorFunction:function(ve){z(ve)}})}var Da=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0;function Sc(N,k){for(var te=N,ve=te>>1,Ie=ve+k/2;!(ve>=Ie)&&G[ve];)++ve;if(te=ve<<1,te-N>32&&Da)return Da.decode(A.subarray(N,te));for(var ke="",be=0;!(be>=k/2);++be){var Oe=F[N+be*2>>1];if(Oe==0)break;ke+=String.fromCharCode(Oe)}return ke}function Ja(N,k,te){if(te===void 0&&(te=2147483647),te<2)return 0;te-=2;for(var ve=k,Ie=te<N.length*2?te/2:N.length,ke=0;ke<Ie;++ke){var be=N.charCodeAt(ke);F[k>>1]=be,k+=2}return F[k>>1]=0,k-ve}function pl(N){return N.length*2}function ml(N,k){for(var te=0,ve="";!(te>=k/4);){var Ie=X[N+te*4>>2];if(Ie==0)break;if(++te,Ie>=65536){var ke=Ie-65536;ve+=String.fromCharCode(55296|ke>>10,56320|ke&1023)}else ve+=String.fromCharCode(Ie)}return ve}function vl(N,k,te){if(te===void 0&&(te=2147483647),te<4)return 0;for(var ve=k,Ie=ve+te-4,ke=0;ke<N.length;++ke){var be=N.charCodeAt(ke);if(be>=55296&&be<=57343){var Oe=N.charCodeAt(++ke);be=65536+((be&1023)<<10)|Oe&1023}if(X[k>>2]=be,k+=4,k+4>Ie)break}return X[k>>2]=0,k-ve}function yl(N){for(var k=0,te=0;te<N.length;++te){var ve=N.charCodeAt(te);ve>=55296&&ve<=57343&&++te,k+=4}return k}function wl(N,k,te){te=Lt(te);var ve,Ie,ke,be,Oe;k===2?(ve=Sc,Ie=Ja,be=pl,ke=()=>G,Oe=1):k===4&&(ve=ml,Ie=vl,be=yl,ke=()=>ee,Oe=2),jt(N,{name:te,fromWireType:function(W){for(var $=ee[W>>2],R=ke(),V,Y=W+4,ye=0;ye<=$;++ye){var xe=W+4+ye*k;if(ye==$||R[xe>>Oe]==0){var Ce=xe-Y,Te=ve(Y,Ce);V===void 0?V=Te:(V+="\0",V+=Te),Y=xe+k}}return z(W),V},toWireType:function(W,$){typeof $!="string"&&Yt("Cannot pass non-string to C++ string type "+te);var R=be($),V=tt(4+R+k);return ee[V>>2]=R>>Oe,Ie($,V+4,R+k),W!==null&&W.push(z,V),V},argPackAdvance:8,readValueFromPointer:ot,destructorFunction:function(W){z(W)}})}function Ds(N,k,te,ve,Ie,ke){nt[N]={name:Lt(k),rawConstructor:mi(te,ve),rawDestructor:mi(Ie,ke),fields:[]}}function xl(N,k,te,ve,Ie,ke,be,Oe,W,$){nt[N].fields.push({fieldName:Lt(k),getterReturnType:te,getter:mi(ve,Ie),getterContext:ke,setterArgumentType:be,setter:mi(Oe,W),setterContext:$})}function Is(N,k){k=Lt(k),jt(N,{isVoid:!0,name:k,argPackAdvance:0,fromWireType:function(){},toWireType:function(te,ve){}})}var Cl={};function Os(N){var k=Cl[N];return k===void 0?Lt(N):k}function Ms(){return typeof globalThis=="object"?globalThis:function(){return Function}()("return this")()}function Tc(N){return N===0?Sn.toHandle(Ms()):(N=Os(N),Sn.toHandle(Ms()[N]))}function Za(N){N>4&&(Qr[N].refcount+=1)}function Ps(N,k){var te=_t[N];return te===void 0&&Yt(k+" has unknown type "+qa(N)),te}function Rs(N){for(var k="",te=0;te<N;++te)k+=(te!==0?", ":"")+"arg"+te;for(var ve=()=>ee,Ie="return function emval_allocator_"+N+`(constructor, argTypes, args) {
|
||
var HEAPU32 = getMemory();
|
||
`,te=0;te<N;++te)Ie+="var argType"+te+" = requireRegisteredType(HEAPU32[((argTypes)>>2)], 'parameter "+te+`');
|
||
var arg`+te+" = argType"+te+`.readValueFromPointer(args);
|
||
args += argType`+te+`['argPackAdvance'];
|
||
argTypes += 4;
|
||
`;return Ie+="var obj = new constructor("+k+`);
|
||
return valueToHandle(obj);
|
||
}
|
||
`,new Function("requireRegisteredType","Module","valueToHandle","getMemory",Ie)(Ps,o,Sn.toHandle,ve)}var Qa={};function _c(N,k,te,ve){N=Sn.toValue(N);var Ie=Qa[k];return Ie||(Ie=Rs(k),Qa[k]=Ie),Ie(N,te,ve)}function Ls(N,k){N=Ps(N,"_emval_take_value");var te=N.readValueFromPointer(k);return Sn.toHandle(te)}function Ec(){Xe("")}function As(){return 2147483648}function bc(){return As()}function Dc(N,k,te){A.copyWithin(N,k,k+te)}function Ic(N){try{return T.grow(N-B.byteLength+65535>>>16),we(T.buffer),1}catch{}}function Oc(N){var k=A.length;N=N>>>0;var te=As();if(N>te)return!1;let ve=(W,$)=>W+($-W%$)%$;for(var Ie=1;Ie<=4;Ie*=2){var ke=k*(1+.2/Ie);ke=Math.min(ke,N+100663296);var be=Math.min(te,ve(Math.max(N,ke),65536)),Oe=Ic(be);if(Oe)return!0}return!1}var es={};function ts(){return l||"./this.program"}function vo(){if(!vo.strings){var N=(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",k={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:N,_:ts()};for(var te in es)es[te]===void 0?delete k[te]:k[te]=es[te];var ve=[];for(var te in k)ve.push(te+"="+k[te]);vo.strings=ve}return vo.strings}function Bo(N,k,te){for(var ve=0;ve<N.length;++ve)H[k++>>0]=N.charCodeAt(ve);H[k>>0]=0}function Hi(N,k){var te=0;return vo().forEach(function(ve,Ie){var ke=k+te;ee[N+Ie*4>>2]=ke,Bo(ve,ke),te+=ve.length+1}),0}function Ns(N,k){var te=vo();ee[N>>2]=te.length;var ve=0;return te.forEach(function(Ie){ve+=Ie.length+1}),ee[k>>2]=ve,0}function ks(N){return 52}function ns(N,k,te,ve,Ie){return 70}var Vs=[null,[],[]];function Ia(N,k){var te=Vs[N];k===0||k===10?((N===1?x:C)(D(te,0)),te.length=0):te.push(k)}function Fs(N,k,te,ve){for(var Ie=0,ke=0;ke<te;ke++){var be=ee[k>>2],Oe=ee[k+4>>2];k+=8;for(var W=0;W<Oe;W++)Ia(N,A[be+W]);Ie+=Oe}return ee[ve>>2]=Ie,0}function oe(N){var k=o["_"+N];return k}function ae(N,k){H.set(N,k)}function De(N,k,te,ve,Ie){var ke={string:xe=>{var Ce=0;if(xe!=null&&xe!==0){var Te=(xe.length<<2)+1;Ce=Q(Te),O(xe,Ce,Te)}return Ce},array:xe=>{var Ce=Q(xe.length);return ae(xe,Ce),Ce}};function be(xe){return k==="string"?I(xe):k==="boolean"?!!xe:xe}var Oe=oe(N),W=[],$=0;if(ve)for(var R=0;R<ve.length;R++){var V=ke[te[R]];V?($===0&&($=de()),W[R]=V(ve[R])):W[R]=ve[R]}var Y=Oe.apply(null,W);function ye(xe){return $!==0&&le($),be(xe)}return Y=ye(Y),Y}xn=o.InternalError=Nt(Error,"InternalError"),mn(),Cn=o.BindingError=Nt(Error,"BindingError"),po(),Cs(),zi(),Or=o.UnboundTypeError=Nt(Error,"UnboundTypeError"),Ya();var He={D:Ue,e:Ye,t:ut,B:hi,r:ii,q:Ta,b:Vn,A:ji,l:Oi,d:na,a:Cc,k:Uo,f:wl,g:Ds,c:xl,C:Is,h:Mr,o:Tc,m:Za,n:_c,p:Ls,i:Ec,v:bc,z:Dc,u:Oc,w:Hi,x:Ns,y:ks,s:ns,j:Fs};fe(),o.___wasm_call_ctors=function(){return(o.___wasm_call_ctors=o.asm.F).apply(null,arguments)};var tt=o._malloc=function(){return(tt=o._malloc=o.asm.H).apply(null,arguments)},z=o._free=function(){return(z=o._free=o.asm.I).apply(null,arguments)},ne=o.___getTypeName=function(){return(ne=o.___getTypeName=o.asm.J).apply(null,arguments)};o.__embind_initialize_bindings=function(){return(o.__embind_initialize_bindings=o.asm.K).apply(null,arguments)};var de=o.stackSave=function(){return(de=o.stackSave=o.asm.L).apply(null,arguments)},le=o.stackRestore=function(){return(le=o.stackRestore=o.asm.M).apply(null,arguments)},Q=o.stackAlloc=function(){return(Q=o.stackAlloc=o.asm.N).apply(null,arguments)},he=o.___cxa_is_pointer_type=function(){return(he=o.___cxa_is_pointer_type=o.asm.O).apply(null,arguments)};o.dynCall_iji=function(){return(o.dynCall_iji=o.asm.P).apply(null,arguments)},o.dynCall_jji=function(){return(o.dynCall_jji=o.asm.Q).apply(null,arguments)},o.dynCall_iiji=function(){return(o.dynCall_iiji=o.asm.R).apply(null,arguments)},o.dynCall_jiji=function(){return(o.dynCall_jiji=o.asm.S).apply(null,arguments)},o.ccall=De;var ge;Re=function N(){ge||me(),ge||(Re=N)};function me(N){if(ie>0||(j(),ie>0))return;function k(){ge||(ge=!0,o.calledRun=!0,!_&&(M(),a(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),q()))}o.setStatus?(o.setStatus("Running..."),setTimeout(function(){setTimeout(function(){o.setStatus("")},1),k()},1)):k()}if(o.preInit)for(typeof o.preInit=="function"&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return me(),i.ready}})();t.exports=r})(p$);var NEe=p$.exports;const kEe=ll(NEe),VEe=new URL("/static/dv3d/openjpegwasm_decode.wasm",import.meta.url),ip={codec:void 0,decoder:void 0,decodeConfig:{}};function FEe(t){if(ip.decodeConfig=t,ip.codec)return Promise.resolve();const e=kEe({locateFile:r=>r.endsWith(".wasm")?VEe.toString():r});return new Promise((r,n)=>{e.then(i=>{ip.codec=i,ip.decoder=new i.J2KDecoder,r()},n)})}async function $7(t,e){await FEe();const r=ip.decoder,n=r.getEncodedBuffer(t.length);n.set(t),r.decode();const i=r.getFrameInfo(),o=r.getDecodedBuffer();new Uint8Array(o.length).set(o);const s=`x: ${r.getImageOffset().x}, y: ${r.getImageOffset().y}`,c=r.getNumDecompositions(),l=r.getNumLayers(),f=["unknown","LRCP","RLCP","RPCL","PCRL","CPRL"][r.getProgressionOrder()+1],u=r.getIsReversible(),d=`${r.getBlockDimensions().width} x ${r.getBlockDimensions().height}`,h=`${r.getTileSize().width} x ${r.getTileSize().height}`,g=`${r.getTileOffset().x}, ${r.getTileOffset().y}`,p=r.getColorSpace(),v=`${o.length.toLocaleString()} bytes`,y=`${(o.length/n.length).toFixed(2)}:1`,m={columns:i.width,rows:i.height,bitsPerPixel:i.bitsPerSample,signed:i.isSigned,bytesPerPixel:e.bytesPerPixel,componentsPerPixel:i.componentCount},w=UEe(i,o),x={imageOffset:s,numDecompositions:c,numLayers:l,progessionOrder:f,reversible:u,blockDimensions:d,tileSize:h,tileOffset:g,colorTransform:p,decodedSize:v,compressionRatio:y};return{...e,pixelData:w,imageInfo:m,encodeOptions:x,...x,...m}}function UEe(t,e){return t.bitsPerSample>8?t.isSigned?new Int16Array(e.buffer,e.byteOffset,e.byteLength/2):new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2):t.isSigned?new Int8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var m$={exports:{}};(function(t,e){var r=(()=>{var n=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename<"u"&&(n=n||__filename),function(o){o=o||{};var o=typeof o<"u"?o:{},a,s;o.ready=new Promise(function(W,$){a=W,s=$});var c=Object.assign({},o),l=typeof window=="object",f=typeof importScripts=="function",u=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",d="";function h(W){return o.locateFile?o.locateFile(W,d):d+W}var g,p,v;if(u){var y=el,m=el;f?d=m.dirname(d)+"/":d=__dirname+"/",g=(W,$)=>(W=ue(W)?new URL(W):m.normalize(W),y.readFileSync(W,$?void 0:"utf8")),v=W=>{var $=g(W,!0);return $.buffer||($=new Uint8Array($)),$},p=(W,$,R)=>{W=ue(W)?new URL(W):m.normalize(W),y.readFile(W,function(V,Y){V?R(V):$(Y.buffer)})},process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),process.on("uncaughtException",function(W){if(!(W instanceof fe))throw W}),process.on("unhandledRejection",function(W){throw W}),o.inspect=function(){return"[Emscripten Module object]"}}else(l||f)&&(f?d=self.location.href:typeof document<"u"&&document.currentScript&&(d=document.currentScript.src),n&&(d=n),d.indexOf("blob:")!==0?d=d.substr(0,d.replace(/[?#].*/,"").lastIndexOf("/")+1):d="",g=W=>{var $=new XMLHttpRequest;return $.open("GET",W,!1),$.send(null),$.responseText},f&&(v=W=>{var $=new XMLHttpRequest;return $.open("GET",W,!1),$.responseType="arraybuffer",$.send(null),new Uint8Array($.response)}),p=(W,$,R)=>{var V=new XMLHttpRequest;V.open("GET",W,!0),V.responseType="arraybuffer",V.onload=()=>{if(V.status==200||V.status==0&&V.response){$(V.response);return}R()},V.onerror=R,V.send(null)});var w=o.print||console.log.bind(console),x=o.printErr||console.warn.bind(console);Object.assign(o,c),c=null,o.arguments&&o.arguments,o.thisProgram&&o.thisProgram,o.quit&&o.quit;var C;o.wasmBinary&&(C=o.wasmBinary),o.noExitRuntime,typeof WebAssembly!="object"&&je("no native wasm support detected");var S,T=!1;function _(W,$){W||je($)}var E=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function b(W,$,R){for(var V=$+R,Y=$;W[Y]&&!(Y>=V);)++Y;if(Y-$>16&&W.buffer&&E)return E.decode(W.subarray($,Y));for(var ye="";$<Y;){var xe=W[$++];if(!(xe&128)){ye+=String.fromCharCode(xe);continue}var Ce=W[$++]&63;if((xe&224)==192){ye+=String.fromCharCode((xe&31)<<6|Ce);continue}var Te=W[$++]&63;if((xe&240)==224?xe=(xe&15)<<12|Ce<<6|Te:xe=(xe&7)<<18|Ce<<12|Te<<6|W[$++]&63,xe<65536)ye+=String.fromCharCode(xe);else{var Me=xe-65536;ye+=String.fromCharCode(55296|Me>>10,56320|Me&1023)}}return ye}function D(W,$){return W?b(H,W,$):""}function I(W,$,R,V){if(!(V>0))return 0;for(var Y=R,ye=R+V-1,xe=0;xe<W.length;++xe){var Ce=W.charCodeAt(xe);if(Ce>=55296&&Ce<=57343){var Te=W.charCodeAt(++xe);Ce=65536+((Ce&1023)<<10)|Te&1023}if(Ce<=127){if(R>=ye)break;$[R++]=Ce}else if(Ce<=2047){if(R+1>=ye)break;$[R++]=192|Ce>>6,$[R++]=128|Ce&63}else if(Ce<=65535){if(R+2>=ye)break;$[R++]=224|Ce>>12,$[R++]=128|Ce>>6&63,$[R++]=128|Ce&63}else{if(R+3>=ye)break;$[R++]=240|Ce>>18,$[R++]=128|Ce>>12&63,$[R++]=128|Ce>>6&63,$[R++]=128|Ce&63}}return $[R]=0,R-Y}function P(W,$,R){return I(W,H,$,R)}function O(W){for(var $=0,R=0;R<W.length;++R){var V=W.charCodeAt(R);V<=127?$++:V<=2047?$+=2:V>=55296&&V<=57343?($+=4,++R):$+=3}return $}var L,B,H,A,F,G,X,ee,ce;function Se(W){L=W,o.HEAP8=B=new Int8Array(W),o.HEAP16=A=new Int16Array(W),o.HEAP32=G=new Int32Array(W),o.HEAPU8=H=new Uint8Array(W),o.HEAPU16=F=new Uint16Array(W),o.HEAPU32=X=new Uint32Array(W),o.HEAPF32=ee=new Float32Array(W),o.HEAPF64=ce=new Float64Array(W)}o.INITIAL_MEMORY;var we,_e=[],Ve=[],Ge=[];function Ne(){if(o.preRun)for(typeof o.preRun=="function"&&(o.preRun=[o.preRun]);o.preRun.length;)q(o.preRun.shift());ft(_e)}function j(){ft(Ve)}function M(){if(o.postRun)for(typeof o.postRun=="function"&&(o.postRun=[o.postRun]);o.postRun.length;)J(o.postRun.shift());ft(Ge)}function q(W){_e.unshift(W)}function K(W){Ve.unshift(W)}function J(W){Ge.unshift(W)}var re=0,ie=null;function Re(W){re++,o.monitorRunDependencies&&o.monitorRunDependencies(re)}function Fe(W){if(re--,o.monitorRunDependencies&&o.monitorRunDependencies(re),re==0&&ie){var $=ie;ie=null,$()}}function je(W){o.onAbort&&o.onAbort(W),W="Aborted("+W+")",x(W),T=!0,W+=". Build with -sASSERTIONS for more info.";var $=new WebAssembly.RuntimeError(W);throw s($),$}var Xe="data:application/octet-stream;base64,";function se(W){return W.startsWith(Xe)}function ue(W){return W.startsWith("file://")}var Pe;Pe="openjphjs.wasm",se(Pe)||(Pe=h(Pe));function pe(W){try{if(W==Pe&&C)return new Uint8Array(C);if(v)return v(W);throw"both async and sync fetching of the wasm failed"}catch($){je($)}}function Ee(){if(!C&&(l||f)){if(typeof fetch=="function"&&!ue(Pe))return fetch(Pe,{credentials:"same-origin"}).then(function(W){if(!W.ok)throw"failed to load wasm binary file at '"+Pe+"'";return W.arrayBuffer()}).catch(function(){return pe(Pe)});if(p)return new Promise(function(W,$){p(Pe,function(R){W(new Uint8Array(R))},$)})}return Promise.resolve().then(function(){return pe(Pe)})}function Qe(){var W={env:oe,wasi_snapshot_preview1:oe};function $(xe,Ce){var Te=xe.exports;o.asm=Te,S=o.asm.memory,Se(S.buffer),we=o.asm.__indirect_function_table,K(o.asm.__wasm_call_ctors),Fe()}Re();function R(xe){$(xe.instance)}function V(xe){return Ee().then(function(Ce){return WebAssembly.instantiate(Ce,W)}).then(function(Ce){return Ce}).then(xe,function(Ce){x("failed to asynchronously prepare wasm: "+Ce),je(Ce)})}function Y(){return!C&&typeof WebAssembly.instantiateStreaming=="function"&&!se(Pe)&&!ue(Pe)&&!u&&typeof fetch=="function"?fetch(Pe,{credentials:"same-origin"}).then(function(xe){var Ce=WebAssembly.instantiateStreaming(xe,W);return Ce.then(R,function(Te){return x("wasm streaming compile failed: "+Te),x("falling back to ArrayBuffer instantiation"),V(R)})}):V(R)}if(o.instantiateWasm)try{var ye=o.instantiateWasm(W,$);return ye}catch(xe){x("Module.instantiateWasm callback failed with error: "+xe),s(xe)}return Y().catch(s),{}}function fe(W){this.name="ExitStatus",this.message="Program terminated with exit("+W+")",this.status=W}function ft(W){for(;W.length>0;)W.shift()(o)}function pt(W,$,R,V){je("Assertion failed: "+D(W)+", at: "+[$?D($):"unknown filename",R,V?D(V):"unknown function"])}var dt=[];function Ue(W){W.add_ref()}function nt(W){var $=new Mt(W);return $.get_caught()||$.set_caught(!0),$.set_rethrown(!1),dt.push($),Ue($),$.get_exception_ptr()}var at=0,ot=[];function lt(W){var $=ot[W];return $||(W>=ot.length&&(ot.length=W+1),ot[W]=$=we.get(W)),$}function _t(W){if(W.release_ref()&&!W.get_rethrown()){var $=W.get_destructor();$&<($)(W.excPtr),He(W.excPtr)}}function vt(){_setThrew(0);var W=dt.pop();_t(W),at=0}function Mt(W){this.excPtr=W,this.ptr=W-24,this.set_type=function($){X[this.ptr+4>>2]=$},this.get_type=function(){return X[this.ptr+4>>2]},this.set_destructor=function($){X[this.ptr+8>>2]=$},this.get_destructor=function(){return X[this.ptr+8>>2]},this.set_refcount=function($){G[this.ptr>>2]=$},this.set_caught=function($){$=$?1:0,B[this.ptr+12>>0]=$},this.get_caught=function(){return B[this.ptr+12>>0]!=0},this.set_rethrown=function($){$=$?1:0,B[this.ptr+13>>0]=$},this.get_rethrown=function(){return B[this.ptr+13>>0]!=0},this.init=function($,R){this.set_adjusted_ptr(0),this.set_type($),this.set_destructor(R),this.set_refcount(0),this.set_caught(!1),this.set_rethrown(!1)},this.add_ref=function(){var $=G[this.ptr>>2];G[this.ptr>>2]=$+1},this.release_ref=function(){var $=G[this.ptr>>2];return G[this.ptr>>2]=$-1,$===1},this.set_adjusted_ptr=function($){X[this.ptr+16>>2]=$},this.get_adjusted_ptr=function(){return X[this.ptr+16>>2]},this.get_exception_ptr=function(){var $=he(this.get_type());if($)return X[this.excPtr>>2];var R=this.get_adjusted_ptr();return R!==0?R:this.excPtr}}function Ft(W){throw at||(at=W),W}function wn(){var W=at;if(!W)return z(0),0;var $=new Mt(W);$.set_adjusted_ptr(W);var R=$.get_type();if(!R)return z(0),W;for(var V=0;V<arguments.length;V++){var Y=arguments[V];if(Y===0||Y===R)break;var ye=$.ptr+16;if(Q(Y,R,ye))return z(Y),W}return z(R),W}function Dn(){var W=at;if(!W)return z(0),0;var $=new Mt(W);$.set_adjusted_ptr(W);var R=$.get_type();if(!R)return z(0),W;for(var V=0;V<arguments.length;V++){var Y=arguments[V];if(Y===0||Y===R)break;var ye=$.ptr+16;if(Q(Y,R,ye))return z(Y),W}return z(R),W}function Nt(W,$,R){var V=new Mt(W);throw V.init($,R),at=W,W}var xn={};function Ui(W){for(;W.length;){var $=W.pop(),R=W.pop();R($)}}function br(W){return this.fromWireType(G[W>>2])}var Ye={},ut={},Rt={},mn=48,Fr=57;function Lt(W){if(W===void 0)return"_unknown";W=W.replace(/[^a-zA-Z0-9_]/g,"$");var $=W.charCodeAt(0);return $>=mn&&$<=Fr?"_"+W:W}function Cn(W,$){return W=Lt(W),new Function("body","return function "+W+`() {
|
||
"use strict"; return body.apply(this, arguments);
|
||
};
|
||
`)($)}function Yt(W,$){var R=Cn($,function(V){this.name=$,this.message=V;var Y=new Error(V).stack;Y!==void 0&&(this.stack=this.toString()+`
|
||
`+Y.replace(/^Error(:[^\n]*)?\n/,""))});return R.prototype=Object.create(W.prototype),R.prototype.constructor=R,R.prototype.toString=function(){return this.message===void 0?this.name:this.name+": "+this.message},R}var jt=void 0;function hi(W){throw new jt(W)}function Bi(W,$,R){W.forEach(function(Ce){Rt[Ce]=$});function V(Ce){var Te=R(Ce);Te.length!==W.length&&hi("Mismatched type converter count");for(var Me=0;Me<W.length;++Me)ar(W[Me],Te[Me])}var Y=new Array($.length),ye=[],xe=0;$.forEach((Ce,Te)=>{ut.hasOwnProperty(Ce)?Y[Te]=ut[Ce]:(ye.push(Ce),Ye.hasOwnProperty(Ce)||(Ye[Ce]=[]),Ye[Ce].push(()=>{Y[Te]=ut[Ce],++xe,xe===ye.length&&V(Y)}))}),ye.length===0&&V(Y)}function Ao(W){var $=xn[W];delete xn[W];var R=$.rawConstructor,V=$.rawDestructor,Y=$.fields,ye=Y.map(xe=>xe.getterReturnType).concat(Y.map(xe=>xe.setterArgumentType));Bi([W],ye,xe=>{var Ce={};return Y.forEach((Te,Me)=>{var Ae=Te.fieldName,qe=xe[Me],rt=Te.getter,mt=Te.getterContext,ht=xe[Me+Y.length],zt=Te.setter,Ut=Te.setterContext;Ce[Ae]={read:Gn=>qe.fromWireType(rt(mt,Gn)),write:(Gn,ai)=>{var vi=[];zt(Ut,Gn,ht.toWireType(vi,ai)),Ui(vi)}}}),[{name:$.name,fromWireType:function(Te){var Me={};for(var Ae in Ce)Me[Ae]=Ce[Ae].read(Te);return V(Te),Me},toWireType:function(Te,Me){for(var Ae in Ce)if(!(Ae in Me))throw new TypeError('Missing field: "'+Ae+'"');var qe=R();for(Ae in Ce)Ce[Ae].write(qe,Me[Ae]);return Te!==null&&Te.push(V,qe),qe},argPackAdvance:8,readValueFromPointer:br,destructorFunction:V}]})}function jn(W,$,R,V,Y){}function fo(W){switch(W){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+W)}}function Ei(){for(var W=new Array(256),$=0;$<256;++$)W[$]=String.fromCharCode($);xa=W}var xa=void 0;function Bn(W){for(var $="",R=W;H[R];)$+=xa[H[R++]];return $}var Ct=void 0;function Zt(W){throw new Ct(W)}function ar(W,$,R={}){if(!("argPackAdvance"in $))throw new TypeError("registerType registeredInstance requires argPackAdvance");var V=$.name;if(W||Zt('type "'+V+'" must have a positive integer typeid pointer'),ut.hasOwnProperty(W)){if(R.ignoreDuplicateRegistrations)return;Zt("Cannot register type '"+V+"' twice")}if(ut[W]=$,delete Rt[W],Ye.hasOwnProperty(W)){var Y=Ye[W];delete Ye[W],Y.forEach(ye=>ye())}}function Qo(W,$,R,V,Y){var ye=fo(R);$=Bn($),ar(W,{name:$,fromWireType:function(xe){return!!xe},toWireType:function(xe,Ce){return Ce?V:Y},argPackAdvance:8,readValueFromPointer:function(xe){var Ce;if(R===1)Ce=B;else if(R===2)Ce=A;else if(R===4)Ce=G;else throw new TypeError("Unknown boolean type size: "+$);return this.fromWireType(Ce[xe>>ye])},destructorFunction:null})}function Dr(W){if(!(this instanceof zi)||!(W instanceof zi))return!1;for(var $=this.$$.ptrType.registeredClass,R=this.$$.ptr,V=W.$$.ptrType.registeredClass,Y=W.$$.ptr;$.baseClass;)R=$.upcast(R),$=$.baseClass;for(;V.baseClass;)Y=V.upcast(Y),V=V.baseClass;return $===V&&R===Y}function ho(W){return{count:W.count,deleteScheduled:W.deleteScheduled,preservePointerOnDelete:W.preservePointerOnDelete,ptr:W.ptr,ptrType:W.ptrType,smartPtr:W.smartPtr,smartPtrType:W.smartPtrType}}function bi(W){function $(R){return R.$$.ptrType.registeredClass.name}Zt($(W)+" instance already deleted")}var Ur=!1;function Cs(W){}function go(W){W.smartPtr?W.smartPtrType.rawDestructor(W.smartPtr):W.ptrType.registeredClass.rawDestructor(W.ptr)}function Zi(W){W.count.value-=1;var $=W.count.value===0;$&&go(W)}function Ca(W,$,R){if($===R)return W;if(R.baseClass===void 0)return null;var V=Ca(W,$,R.baseClass);return V===null?null:R.downcast(V)}var gi={};function Sa(){return Object.keys(Zr).length}function ln(){var W=[];for(var $ in Zr)Zr.hasOwnProperty($)&&W.push(Zr[$]);return W}var Gi=[];function Ss(){for(;Gi.length;){var W=Gi.pop();W.$$.deleteScheduled=!1,W.delete()}}var ea=void 0;function Qi(W){ea=W,Gi.length&&ea&&ea(Ss)}function po(){o.getInheritedInstanceCount=Sa,o.getLiveInheritedInstances=ln,o.flushPendingDeletes=Ss,o.setDelayFunction=Qi}var Zr={};function Di(W,$){for($===void 0&&Zt("ptr should not be undefined");W.baseClass;)$=W.upcast($),W=W.baseClass;return $}function sn(W,$){return $=Di(W,$),Zr[$]}function pi(W,$){(!$.ptrType||!$.ptr)&&hi("makeClassHandle requires ptr and ptrType");var R=!!$.smartPtrType,V=!!$.smartPtr;return R!==V&&hi("Both smartPtrType and smartPtr must be specified"),$.count={value:1},Wi(Object.create(W,{$$:{value:$}}))}function No(W){var $=this.getPointee(W);if(!$)return this.destructor(W),null;var R=sn(this.registeredClass,$);if(R!==void 0){if(R.$$.count.value===0)return R.$$.ptr=$,R.$$.smartPtr=W,R.clone();var V=R.clone();return this.destructor(W),V}function Y(){return this.isSmartPointer?pi(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:$,smartPtrType:this,smartPtr:W}):pi(this.registeredClass.instancePrototype,{ptrType:this,ptr:W})}var ye=this.registeredClass.getActualType($),xe=gi[ye];if(!xe)return Y.call(this);var Ce;this.isConst?Ce=xe.constPointerType:Ce=xe.pointerType;var Te=Ca($,this.registeredClass,Ce.registeredClass);return Te===null?Y.call(this):this.isSmartPointer?pi(Ce.registeredClass.instancePrototype,{ptrType:Ce,ptr:Te,smartPtrType:this,smartPtr:W}):pi(Ce.registeredClass.instancePrototype,{ptrType:Ce,ptr:Te})}function Wi(W){return typeof FinalizationRegistry>"u"?(Wi=$=>$,W):(Ur=new FinalizationRegistry($=>{Zi($.$$)}),Wi=$=>{var R=$.$$,V=!!R.smartPtr;if(V){var Y={$$:R};Ur.register($,Y,$)}return $},Cs=$=>Ur.unregister($),Wi(W))}function Ii(){if(this.$$.ptr||bi(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var W=Wi(Object.create(Object.getPrototypeOf(this),{$$:{value:ho(this.$$)}}));return W.$$.count.value+=1,W.$$.deleteScheduled=!1,W}function Ts(){this.$$.ptr||bi(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&Zt("Object already scheduled for deletion"),Cs(this),Zi(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)}function ko(){return!this.$$.ptr}function _s(){return this.$$.ptr||bi(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&Zt("Object already scheduled for deletion"),Gi.push(this),Gi.length===1&&ea&&ea(Ss),this.$$.deleteScheduled=!0,this}function eo(){zi.prototype.isAliasOf=Dr,zi.prototype.clone=Ii,zi.prototype.delete=Ts,zi.prototype.isDeleted=ko,zi.prototype.deleteLater=_s}function zi(){}function $i(W,$,R){if(W[$].overloadTable===void 0){var V=W[$];W[$]=function(){return W[$].overloadTable.hasOwnProperty(arguments.length)||Zt("Function '"+R+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+W[$].overloadTable+")!"),W[$].overloadTable[arguments.length].apply(this,arguments)},W[$].overloadTable=[],W[$].overloadTable[V.argCount]=V}}function Ir(W,$,R){o.hasOwnProperty(W)?((R===void 0||o[W].overloadTable!==void 0&&o[W].overloadTable[R]!==void 0)&&Zt("Cannot register public name '"+W+"' twice"),$i(o,W,W),o.hasOwnProperty(R)&&Zt("Cannot register multiple overloads of a function with the same number of arguments ("+R+")!"),o[W].overloadTable[R]=$):(o[W]=$,R!==void 0&&(o[W].numArguments=R))}function yc(W,$,R,V,Y,ye,xe,Ce){this.name=W,this.constructor=$,this.instancePrototype=R,this.rawDestructor=V,this.baseClass=Y,this.getActualType=ye,this.upcast=xe,this.downcast=Ce,this.pureVirtualFunctions=[]}function Vo(W,$,R){for(;$!==R;)$.upcast||Zt("Expected null or instance of "+R.name+", got an instance of "+$.name),W=$.upcast(W),$=$.baseClass;return W}function Fo(W,$){if($===null)return this.isReference&&Zt("null is not a valid "+this.name),0;$.$$||Zt('Cannot pass "'+Ja($)+'" as a '+this.name),$.$$.ptr||Zt("Cannot pass deleted object as a pointer of type "+this.name);var R=$.$$.ptrType.registeredClass,V=Vo($.$$.ptr,R,this.registeredClass);return V}function yr(W,$){var R;if($===null)return this.isReference&&Zt("null is not a valid "+this.name),this.isSmartPointer?(R=this.rawConstructor(),W!==null&&W.push(this.rawDestructor,R),R):0;$.$$||Zt('Cannot pass "'+Ja($)+'" as a '+this.name),$.$$.ptr||Zt("Cannot pass deleted object as a pointer of type "+this.name),!this.isConst&&$.$$.ptrType.isConst&&Zt("Cannot convert argument of type "+($.$$.smartPtrType?$.$$.smartPtrType.name:$.$$.ptrType.name)+" to parameter type "+this.name);var V=$.$$.ptrType.registeredClass;if(R=Vo($.$$.ptr,V,this.registeredClass),this.isSmartPointer)switch($.$$.smartPtr===void 0&&Zt("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:$.$$.smartPtrType===this?R=$.$$.smartPtr:Zt("Cannot convert argument of type "+($.$$.smartPtrType?$.$$.smartPtrType.name:$.$$.ptrType.name)+" to parameter type "+this.name);break;case 1:R=$.$$.smartPtr;break;case 2:if($.$$.smartPtrType===this)R=$.$$.smartPtr;else{var Y=$.clone();R=this.rawShare(R,Da.toHandle(function(){Y.delete()})),W!==null&&W.push(this.rawDestructor,R)}break;default:Zt("Unsupporting sharing policy")}return R}function wc(W,$){if($===null)return this.isReference&&Zt("null is not a valid "+this.name),0;$.$$||Zt('Cannot pass "'+Ja($)+'" as a '+this.name),$.$$.ptr||Zt("Cannot pass deleted object as a pointer of type "+this.name),$.$$.ptrType.isConst&&Zt("Cannot convert argument of type "+$.$$.ptrType.name+" to parameter type "+this.name);var R=$.$$.ptrType.registeredClass,V=Vo($.$$.ptr,R,this.registeredClass);return V}function mi(W){return this.rawGetPointee&&(W=this.rawGetPointee(W)),W}function Or(W){this.rawDestructor&&this.rawDestructor(W)}function qa(W){W!==null&&W.delete()}function mo(){ii.prototype.getPointee=mi,ii.prototype.destructor=Or,ii.prototype.argPackAdvance=8,ii.prototype.readValueFromPointer=br,ii.prototype.deleteObject=qa,ii.prototype.fromWireType=No}function ii(W,$,R,V,Y,ye,xe,Ce,Te,Me,Ae){this.name=W,this.registeredClass=$,this.isReference=R,this.isConst=V,this.isSmartPointer=Y,this.pointeeType=ye,this.sharingPolicy=xe,this.rawGetPointee=Ce,this.rawConstructor=Te,this.rawShare=Me,this.rawDestructor=Ae,!Y&&$.baseClass===void 0?V?(this.toWireType=Fo,this.destructorFunction=null):(this.toWireType=wc,this.destructorFunction=null):this.toWireType=yr}function ta(W,$,R){o.hasOwnProperty(W)||hi("Replacing nonexistant public symbol"),o[W].overloadTable!==void 0&&R!==void 0?o[W].overloadTable[R]=$:(o[W]=$,o[W].argCount=R)}function Es(W,$,R){var V=o["dynCall_"+W];return R&&R.length?V.apply(null,[$].concat(R)):V.call(null,$)}function Xa(W,$,R){if(W.includes("j"))return Es(W,$,R);var V=lt($).apply(null,R);return V}function Ta(W,$){var R=[];return function(){return R.length=0,Object.assign(R,arguments),Xa(W,$,R)}}function Vn(W,$){W=Bn(W);function R(){return W.includes("j")?Ta(W,$):lt($)}var V=R();return typeof V!="function"&&Zt("unknown function pointer with signature "+W+": "+$),V}var _a=void 0;function Qr(W){var $=tt(W),R=Bn($);return De($),R}function Mr(W,$){var R=[],V={};function Y(ye){if(!V[ye]&&!ut[ye]){if(Rt[ye]){Rt[ye].forEach(Y);return}R.push(ye),V[ye]=!0}}throw $.forEach(Y),new _a(W+": "+R.map(Qr).join([", "]))}function xc(W,$,R,V,Y,ye,xe,Ce,Te,Me,Ae,qe,rt){Ae=Bn(Ae),ye=Vn(Y,ye),Ce&&(Ce=Vn(xe,Ce)),Me&&(Me=Vn(Te,Me)),rt=Vn(qe,rt);var mt=Lt(Ae);Ir(mt,function(){Mr("Cannot construct "+Ae+" due to unbound types",[V])}),Bi([W,$,R],V?[V]:[],function(ht){ht=ht[0];var zt,Ut;V?(zt=ht.registeredClass,Ut=zt.instancePrototype):Ut=zi.prototype;var Gn=Cn(mt,function(){if(Object.getPrototypeOf(this)!==ai)throw new Ct("Use 'new' to construct "+Ae);if(vi.constructor_body===void 0)throw new Ct(Ae+" has no accessible constructor");var fg=vi.constructor_body[arguments.length];if(fg===void 0)throw new Ct("Tried to invoke ctor of "+Ae+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(vi.constructor_body).toString()+") parameters instead!");return fg.apply(this,arguments)}),ai=Object.create(Ut,{constructor:{value:Gn}});Gn.prototype=ai;var vi=new yc(Ae,Gn,ai,rt,zt,ye,Ce,Me),bf=new ii(Ae,vi,!0,!1,!1),rs=new ii(Ae+"*",vi,!1,!1,!1),Am=new ii(Ae+" const*",vi,!1,!0,!1);return gi[W]={pointerType:rs,constPointerType:Am},ta(mt,Gn),[bf,rs,Am]})}function oi(W,$){for(var R=[],V=0;V<W;V++)R.push(X[$+V*4>>2]);return R}function Ya(W,$){if(!(W instanceof Function))throw new TypeError("new_ called with constructor type "+typeof W+" which is not a function");var R=Cn(W.name||"unknownFunctionName",function(){});R.prototype=W.prototype;var V=new R,Y=W.apply(V,$);return Y instanceof Object?Y:V}function Sn(W,$,R,V,Y){var ye=$.length;ye<2&&Zt("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var xe=$[1]!==null&&R!==null,Ce=!1,Te=1;Te<$.length;++Te)if($[Te]!==null&&$[Te].destructorFunction===void 0){Ce=!0;break}for(var Me=$[0].name!=="void",Ae="",qe="",Te=0;Te<ye-2;++Te)Ae+=(Te!==0?", ":"")+"arg"+Te,qe+=(Te!==0?", ":"")+"arg"+Te+"Wired";var rt="return function "+Lt(W)+"("+Ae+`) {
|
||
if (arguments.length !== `+(ye-2)+`) {
|
||
throwBindingError('function `+W+" called with ' + arguments.length + ' arguments, expected "+(ye-2)+` args!');
|
||
}
|
||
`;Ce&&(rt+=`var destructors = [];
|
||
`);var mt=Ce?"destructors":"null",ht=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],zt=[Zt,V,Y,Ui,$[0],$[1]];xe&&(rt+="var thisWired = classParam.toWireType("+mt+`, this);
|
||
`);for(var Te=0;Te<ye-2;++Te)rt+="var arg"+Te+"Wired = argType"+Te+".toWireType("+mt+", arg"+Te+"); // "+$[Te+2].name+`
|
||
`,ht.push("argType"+Te),zt.push($[Te+2]);if(xe&&(qe="thisWired"+(qe.length>0?", ":"")+qe),rt+=(Me?"var rv = ":"")+"invoker(fn"+(qe.length>0?", ":"")+qe+`);
|
||
`,Ce)rt+=`runDestructors(destructors);
|
||
`;else for(var Te=xe?1:2;Te<$.length;++Te){var Ut=Te===1?"thisWired":"arg"+(Te-2)+"Wired";$[Te].destructorFunction!==null&&(rt+=Ut+"_dtor("+Ut+"); // "+$[Te].name+`
|
||
`,ht.push(Ut+"_dtor"),zt.push($[Te].destructorFunction))}Me&&(rt+=`var ret = retType.fromWireType(rv);
|
||
return ret;
|
||
`),rt+=`}
|
||
`,ht.push(rt);var Gn=Ya(Function,ht).apply(null,zt);return Gn}function ji(W,$,R,V,Y,ye){_($>0);var xe=oi($,R);Y=Vn(V,Y),Bi([],[W],function(Ce){Ce=Ce[0];var Te="constructor "+Ce.name;if(Ce.registeredClass.constructor_body===void 0&&(Ce.registeredClass.constructor_body=[]),Ce.registeredClass.constructor_body[$-1]!==void 0)throw new Ct("Cannot register multiple constructors with identical number of parameters ("+($-1)+") for class '"+Ce.name+"'! Overload resolution is currently only performed using the parameter count, not actual type info!");return Ce.registeredClass.constructor_body[$-1]=()=>{Mr("Cannot construct "+Ce.name+" due to unbound types",xe)},Bi([],xe,function(Me){return Me.splice(1,0,null),Ce.registeredClass.constructor_body[$-1]=Sn(Te,Me,null,Y,ye),[]}),[]})}function Ea(W,$,R,V,Y,ye,xe,Ce){var Te=oi(R,V);$=Bn($),ye=Vn(Y,ye),Bi([],[W],function(Me){Me=Me[0];var Ae=Me.name+"."+$;$.startsWith("@@")&&($=Symbol[$.substring(2)]),Ce&&Me.registeredClass.pureVirtualFunctions.push($);function qe(){Mr("Cannot call "+Ae+" due to unbound types",Te)}var rt=Me.registeredClass.instancePrototype,mt=rt[$];return mt===void 0||mt.overloadTable===void 0&&mt.className!==Me.name&&mt.argCount===R-2?(qe.argCount=R-2,qe.className=Me.name,rt[$]=qe):($i(rt,$,Ae),rt[$].overloadTable[R-2]=qe),Bi([],Te,function(ht){var zt=Sn(Ae,ht,Me,ye,xe);return rt[$].overloadTable===void 0?(zt.argCount=R-2,rt[$]=zt):rt[$].overloadTable[R-2]=zt,[]}),[]})}var ba=[],Oi=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function bs(W){W>4&&--Oi[W].refcount===0&&(Oi[W]=void 0,ba.push(W))}function na(){for(var W=0,$=5;$<Oi.length;++$)Oi[$]!==void 0&&++W;return W}function Cc(){for(var W=5;W<Oi.length;++W)if(Oi[W]!==void 0)return Oi[W];return null}function Uo(){o.count_emval_handles=na,o.get_first_emval=Cc}var Da={toValue:W=>(W||Zt("Cannot use deleted val. handle = "+W),Oi[W].value),toHandle:W=>{switch(W){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:{var $=ba.length?ba.pop():Oi.length;return Oi[$]={refcount:1,value:W},$}}}};function Sc(W,$){$=Bn($),ar(W,{name:$,fromWireType:function(R){var V=Da.toValue(R);return bs(R),V},toWireType:function(R,V){return Da.toHandle(V)},argPackAdvance:8,readValueFromPointer:br,destructorFunction:null})}function Ja(W){if(W===null)return"null";var $=typeof W;return $==="object"||$==="array"||$==="function"?W.toString():""+W}function pl(W,$){switch($){case 2:return function(R){return this.fromWireType(ee[R>>2])};case 3:return function(R){return this.fromWireType(ce[R>>3])};default:throw new TypeError("Unknown float type: "+W)}}function ml(W,$,R){var V=fo(R);$=Bn($),ar(W,{name:$,fromWireType:function(Y){return Y},toWireType:function(Y,ye){return ye},argPackAdvance:8,readValueFromPointer:pl($,V),destructorFunction:null})}function vl(W,$,R,V,Y,ye){var xe=oi($,R);W=Bn(W),Y=Vn(V,Y),Ir(W,function(){Mr("Cannot call "+W+" due to unbound types",xe)},$-1),Bi([],xe,function(Ce){var Te=[Ce[0],null].concat(Ce.slice(1));return ta(W,Sn(W,Te,null,Y,ye),$-1),[]})}function yl(W,$,R){switch($){case 0:return R?function(Y){return B[Y]}:function(Y){return H[Y]};case 1:return R?function(Y){return A[Y>>1]}:function(Y){return F[Y>>1]};case 2:return R?function(Y){return G[Y>>2]}:function(Y){return X[Y>>2]};default:throw new TypeError("Unknown integer type: "+W)}}function wl(W,$,R,V,Y){$=Bn($);var ye=fo(R),xe=qe=>qe;if(V===0){var Ce=32-8*R;xe=qe=>qe<<Ce>>>Ce}var Te=$.includes("unsigned"),Me=(qe,rt)=>{},Ae;Te?Ae=function(qe,rt){return Me(rt,this.name),rt>>>0}:Ae=function(qe,rt){return Me(rt,this.name),rt},ar(W,{name:$,fromWireType:xe,toWireType:Ae,argPackAdvance:8,readValueFromPointer:yl($,ye,V!==0),destructorFunction:null})}function Ds(W,$,R){var V=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],Y=V[$];function ye(xe){xe=xe>>2;var Ce=X,Te=Ce[xe],Me=Ce[xe+1];return new Y(L,Me,Te)}R=Bn(R),ar(W,{name:R,fromWireType:ye,argPackAdvance:8,readValueFromPointer:ye},{ignoreDuplicateRegistrations:!0})}function xl(W,$){$=Bn($);var R=$==="std::string";ar(W,{name:$,fromWireType:function(V){var Y=X[V>>2],ye=V+4,xe;if(R)for(var Ce=ye,Te=0;Te<=Y;++Te){var Me=ye+Te;if(Te==Y||H[Me]==0){var Ae=Me-Ce,qe=D(Ce,Ae);xe===void 0?xe=qe:(xe+="\0",xe+=qe),Ce=Me+1}}else{for(var rt=new Array(Y),Te=0;Te<Y;++Te)rt[Te]=String.fromCharCode(H[ye+Te]);xe=rt.join("")}return De(V),xe},toWireType:function(V,Y){Y instanceof ArrayBuffer&&(Y=new Uint8Array(Y));var ye,xe=typeof Y=="string";xe||Y instanceof Uint8Array||Y instanceof Uint8ClampedArray||Y instanceof Int8Array||Zt("Cannot pass non-string to std::string"),R&&xe?ye=O(Y):ye=Y.length;var Ce=ae(4+ye+1),Te=Ce+4;if(X[Ce>>2]=ye,R&&xe)P(Y,Te,ye+1);else if(xe)for(var Me=0;Me<ye;++Me){var Ae=Y.charCodeAt(Me);Ae>255&&(De(Te),Zt("String has UTF-16 code units that do not fit in 8 bits")),H[Te+Me]=Ae}else for(var Me=0;Me<ye;++Me)H[Te+Me]=Y[Me];return V!==null&&V.push(De,Ce),Ce},argPackAdvance:8,readValueFromPointer:br,destructorFunction:function(V){De(V)}})}var Is=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0;function Cl(W,$){for(var R=W,V=R>>1,Y=V+$/2;!(V>=Y)&&F[V];)++V;if(R=V<<1,R-W>32&&Is)return Is.decode(H.subarray(W,R));for(var ye="",xe=0;!(xe>=$/2);++xe){var Ce=A[W+xe*2>>1];if(Ce==0)break;ye+=String.fromCharCode(Ce)}return ye}function Os(W,$,R){if(R===void 0&&(R=2147483647),R<2)return 0;R-=2;for(var V=$,Y=R<W.length*2?R/2:W.length,ye=0;ye<Y;++ye){var xe=W.charCodeAt(ye);A[$>>1]=xe,$+=2}return A[$>>1]=0,$-V}function Ms(W){return W.length*2}function Tc(W,$){for(var R=0,V="";!(R>=$/4);){var Y=G[W+R*4>>2];if(Y==0)break;if(++R,Y>=65536){var ye=Y-65536;V+=String.fromCharCode(55296|ye>>10,56320|ye&1023)}else V+=String.fromCharCode(Y)}return V}function Za(W,$,R){if(R===void 0&&(R=2147483647),R<4)return 0;for(var V=$,Y=V+R-4,ye=0;ye<W.length;++ye){var xe=W.charCodeAt(ye);if(xe>=55296&&xe<=57343){var Ce=W.charCodeAt(++ye);xe=65536+((xe&1023)<<10)|Ce&1023}if(G[$>>2]=xe,$+=4,$+4>Y)break}return G[$>>2]=0,$-V}function Ps(W){for(var $=0,R=0;R<W.length;++R){var V=W.charCodeAt(R);V>=55296&&V<=57343&&++R,$+=4}return $}function Rs(W,$,R){R=Bn(R);var V,Y,ye,xe,Ce;$===2?(V=Cl,Y=Os,xe=Ms,ye=()=>F,Ce=1):$===4&&(V=Tc,Y=Za,xe=Ps,ye=()=>X,Ce=2),ar(W,{name:R,fromWireType:function(Te){for(var Me=X[Te>>2],Ae=ye(),qe,rt=Te+4,mt=0;mt<=Me;++mt){var ht=Te+4+mt*$;if(mt==Me||Ae[ht>>Ce]==0){var zt=ht-rt,Ut=V(rt,zt);qe===void 0?qe=Ut:(qe+="\0",qe+=Ut),rt=ht+$}}return De(Te),qe},toWireType:function(Te,Me){typeof Me!="string"&&Zt("Cannot pass non-string to C++ string type "+R);var Ae=xe(Me),qe=ae(4+Ae+$);return X[qe>>2]=Ae>>Ce,Y(Me,qe+4,Ae+$),Te!==null&&Te.push(De,qe),qe},argPackAdvance:8,readValueFromPointer:br,destructorFunction:function(Te){De(Te)}})}function Qa(W,$,R,V,Y,ye){xn[W]={name:Bn($),rawConstructor:Vn(R,V),rawDestructor:Vn(Y,ye),fields:[]}}function _c(W,$,R,V,Y,ye,xe,Ce,Te,Me){xn[W].fields.push({fieldName:Bn($),getterReturnType:R,getter:Vn(V,Y),getterContext:ye,setterArgumentType:xe,setter:Vn(Ce,Te),setterContext:Me})}function Ls(W,$){$=Bn($),ar(W,{isVoid:!0,name:$,argPackAdvance:0,fromWireType:function(){},toWireType:function(R,V){}})}function Ec(W){W>4&&(Oi[W].refcount+=1)}function As(W,$){var R=ut[W];return R===void 0&&Zt($+" has unknown type "+Qr(W)),R}function bc(W,$){W=As(W,"_emval_take_value");var R=W.readValueFromPointer($);return Da.toHandle(R)}function Dc(){je("")}function Ic(W,$,R){H.copyWithin(W,$,$+R)}function Oc(){return 2147483648}function es(W){try{return S.grow(W-L.byteLength+65535>>>16),Se(S.buffer),1}catch{}}function ts(W){var $=H.length;W=W>>>0;var R=Oc();if(W>R)return!1;let V=(Te,Me)=>Te+(Me-Te%Me)%Me;for(var Y=1;Y<=4;Y*=2){var ye=$*(1+.2/Y);ye=Math.min(ye,W+100663296);var xe=Math.min(R,V(Math.max(W,ye),65536)),Ce=es(xe);if(Ce)return!0}return!1}function vo(W){return 52}function Bo(W,$,R,V,Y){return 70}var Hi=[null,[],[]];function Ns(W,$){var R=Hi[W];$===0||$===10?((W===1?w:x)(b(R,0)),R.length=0):R.push($)}function ks(W,$,R,V){for(var Y=0,ye=0;ye<R;ye++){var xe=X[$>>2],Ce=X[$+4>>2];$+=8;for(var Te=0;Te<Ce;Te++)Ns(W,H[xe+Te]);Y+=Ce}return X[V>>2]=Y,0}function ns(W){return W}function Vs(W){var $=o["_"+W];return $}function Ia(W,$){B.set(W,$)}function Fs(W,$,R,V,Y){var ye={string:ht=>{var zt=0;if(ht!=null&&ht!==0){var Ut=(ht.length<<2)+1;zt=le(Ut),P(ht,zt,Ut)}return zt},array:ht=>{var zt=le(ht.length);return Ia(ht,zt),zt}};function xe(ht){return $==="string"?D(ht):$==="boolean"?!!ht:ht}var Ce=Vs(W),Te=[],Me=0;if(V)for(var Ae=0;Ae<V.length;Ae++){var qe=ye[R[Ae]];qe?(Me===0&&(Me=ne()),Te[Ae]=qe(V[Ae])):Te[Ae]=V[Ae]}var rt=Ce.apply(null,Te);function mt(ht){return Me!==0&&de(Me),xe(ht)}return rt=mt(rt),rt}jt=o.InternalError=Yt(Error,"InternalError"),Ei(),Ct=o.BindingError=Yt(Error,"BindingError"),eo(),po(),mo(),_a=o.UnboundTypeError=Yt(Error,"UnboundTypeError"),Uo();var oe={__assert_fail:pt,__cxa_begin_catch:nt,__cxa_end_catch:vt,__cxa_find_matching_catch_2:wn,__cxa_find_matching_catch_3:Dn,__cxa_throw:Nt,__resumeException:Ft,_embind_finalize_value_object:Ao,_embind_register_bigint:jn,_embind_register_bool:Qo,_embind_register_class:xc,_embind_register_class_constructor:ji,_embind_register_class_function:Ea,_embind_register_emval:Sc,_embind_register_float:ml,_embind_register_function:vl,_embind_register_integer:wl,_embind_register_memory_view:Ds,_embind_register_std_string:xl,_embind_register_std_wstring:Rs,_embind_register_value_object:Qa,_embind_register_value_object_field:_c,_embind_register_void:Ls,_emval_decref:bs,_emval_incref:Ec,_emval_take_value:bc,abort:Dc,emscripten_memcpy_big:Ic,emscripten_resize_heap:ts,fd_close:vo,fd_seek:Bo,fd_write:ks,invoke_i:ve,invoke_ii:ge,invoke_iii:ke,invoke_iiii:te,invoke_v:k,invoke_vi:me,invoke_viiii:N,invoke_viiiiii:Ie,llvm_eh_typeid_for:ns};Qe(),o.___wasm_call_ctors=function(){return(o.___wasm_call_ctors=o.asm.__wasm_call_ctors).apply(null,arguments)};var ae=o._malloc=function(){return(ae=o._malloc=o.asm.malloc).apply(null,arguments)},De=o._free=function(){return(De=o._free=o.asm.free).apply(null,arguments)},He=o.___cxa_free_exception=function(){return(He=o.___cxa_free_exception=o.asm.__cxa_free_exception).apply(null,arguments)},tt=o.___getTypeName=function(){return(tt=o.___getTypeName=o.asm.__getTypeName).apply(null,arguments)};o.__embind_initialize_bindings=function(){return(o.__embind_initialize_bindings=o.asm._embind_initialize_bindings).apply(null,arguments)},o.___errno_location=function(){return(o.___errno_location=o.asm.__errno_location).apply(null,arguments)};var z=o.setTempRet0=function(){return(z=o.setTempRet0=o.asm.setTempRet0).apply(null,arguments)},ne=o.stackSave=function(){return(ne=o.stackSave=o.asm.stackSave).apply(null,arguments)},de=o.stackRestore=function(){return(de=o.stackRestore=o.asm.stackRestore).apply(null,arguments)},le=o.stackAlloc=function(){return(le=o.stackAlloc=o.asm.stackAlloc).apply(null,arguments)},Q=o.___cxa_can_catch=function(){return(Q=o.___cxa_can_catch=o.asm.__cxa_can_catch).apply(null,arguments)},he=o.___cxa_is_pointer_type=function(){return(he=o.___cxa_is_pointer_type=o.asm.__cxa_is_pointer_type).apply(null,arguments)};o.dynCall_ji=function(){return(o.dynCall_ji=o.asm.dynCall_ji).apply(null,arguments)},o.dynCall_iiji=function(){return(o.dynCall_iiji=o.asm.dynCall_iiji).apply(null,arguments)},o.dynCall_jiji=function(){return(o.dynCall_jiji=o.asm.dynCall_jiji).apply(null,arguments)};function ge(W,$){var R=ne();try{return lt(W)($)}catch(V){if(de(R),V!==V+0)throw V;_setThrew(1,0)}}function me(W,$){var R=ne();try{lt(W)($)}catch(V){if(de(R),V!==V+0)throw V;_setThrew(1,0)}}function N(W,$,R,V,Y){var ye=ne();try{lt(W)($,R,V,Y)}catch(xe){if(de(ye),xe!==xe+0)throw xe;_setThrew(1,0)}}function k(W){var $=ne();try{lt(W)()}catch(R){if(de($),R!==R+0)throw R;_setThrew(1,0)}}function te(W,$,R,V){var Y=ne();try{return lt(W)($,R,V)}catch(ye){if(de(Y),ye!==ye+0)throw ye;_setThrew(1,0)}}function ve(W){var $=ne();try{return lt(W)()}catch(R){if(de($),R!==R+0)throw R;_setThrew(1,0)}}function Ie(W,$,R,V,Y,ye,xe){var Ce=ne();try{lt(W)($,R,V,Y,ye,xe)}catch(Te){if(de(Ce),Te!==Te+0)throw Te;_setThrew(1,0)}}function ke(W,$,R){var V=ne();try{return lt(W)($,R)}catch(Y){if(de(V),Y!==Y+0)throw Y;_setThrew(1,0)}}o.ccall=Fs;var be;ie=function W(){be||Oe(),be||(ie=W)};function Oe(W){if(re>0||(Ne(),re>0))return;function $(){be||(be=!0,o.calledRun=!0,!T&&(j(),a(o),o.onRuntimeInitialized&&o.onRuntimeInitialized(),M()))}o.setStatus?(o.setStatus("Running..."),setTimeout(function(){setTimeout(function(){o.setStatus("")},1),$()},1)):$()}if(o.preInit)for(typeof o.preInit=="function"&&(o.preInit=[o.preInit]);o.preInit.length>0;)o.preInit.pop()();return Oe(),o.ready}})();t.exports=r})(m$);var BEe=m$.exports;const GEe=ll(BEe),WEe=new URL("/static/dv3d/openjphjs.wasm",import.meta.url),op={codec:void 0,decoder:void 0,decodeConfig:{}};function zEe(t,e,r){const n={width:e,height:r};for(;t>0;)n.width=Math.ceil(n.width/2),n.height=Math.ceil(n.height/2),t--;return n}function $Ee(t){if(op.decodeConfig=t,op.codec)return Promise.resolve();const e=GEe({locateFile:r=>r.endsWith(".wasm")?WEe.toString():r});return new Promise((r,n)=>{e.then(i=>{op.codec=i,op.decoder=new i.HTJ2KDecoder,r()},n)})}async function jEe(t,e){await $Ee();const r=new op.codec.HTJ2KDecoder,n=r.getEncodedBuffer(t.length);n.set(t);const i=e.decodeLevel||0;r.decodeSubResolution(i);const o=r.getFrameInfo();if(e.decodeLevel>0){const{width:E,height:b}=zEe(e.decodeLevel,o.width,o.height);o.width=E,o.height=b}const a=r.getDecodedBuffer();new Uint8Array(a.length).set(a);const c=`x: ${r.getImageOffset().x}, y: ${r.getImageOffset().y}`,l=r.getNumDecompositions(),f=r.getNumLayers(),u=["unknown","LRCP","RLCP","RPCL","PCRL","CPRL"][r.getProgressionOrder()+1],d=r.getIsReversible(),h=`${r.getBlockDimensions().width} x ${r.getBlockDimensions().height}`,g=`${r.getTileSize().width} x ${r.getTileSize().height}`,p=`${r.getTileOffset().x}, ${r.getTileOffset().y}`,v=`${a.length.toLocaleString()} bytes`,y=`${(a.length/n.length).toFixed(2)}:1`,m={columns:o.width,rows:o.height,bitsPerPixel:o.bitsPerSample,signed:o.isSigned,bytesPerPixel:e.bytesPerPixel,componentsPerPixel:o.componentCount};let w=HEe(o,a);const{buffer:x,byteOffset:C,byteLength:S}=w,T=x.slice(C,C+S);w=new w.constructor(T);const _={imageOffset:c,numDecompositions:l,numLayers:f,progessionOrder:u,reversible:d,blockDimensions:h,tileSize:g,tileOffset:p,decodedSize:v,compressionRatio:y};return{...e,pixelData:w,imageInfo:m,encodeOptions:_,..._,...m}}function HEe(t,e){return t.bitsPerSample>8?t.isSigned?new Int16Array(e.buffer,e.byteOffset,e.byteLength/2):new Uint16Array(e.buffer,e.byteOffset,e.byteLength/2):t.isSigned?new Int8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function KEe(t,e){const r=t.length,{rescaleSlope:n,rescaleIntercept:i,suvbw:o,doseGridScaling:a}=e;if(e.modality==="PT"&&typeof o=="number"&&!isNaN(o))for(let s=0;s<r;s++)t[s]=o*(t[s]*n+i);else if(e.modality==="RTDOSE"&&typeof a=="number"&&!isNaN(a))for(let s=0;s<r;s++)t[s]=t[s]*a;else for(let s=0;s<r;s++)t[s]=t[s]*n+i;return!0}const qEe={bilinear:uEe,replicate:fEe},j7={Uint8Array,Uint16Array,Int16Array,Float32Array,Uint32Array};function XEe(t,e,r,n){var m,w,x;const i=t.pixelRepresentation!==void 0&&t.pixelRepresentation===1,o=i&&t.bitsStored!==void 0?32-t.bitsStored:void 0;if(i&&o!==void 0)for(let C=0;C<t.pixelData.length;C++)t.pixelData[C]=t.pixelData[C]<<o>>o;let a=t.pixelData;t.pixelDataLength=t.pixelData.length;const{min:s,max:c}=ax(t.pixelData),l=typeof e.allowFloatRendering<"u"?e.allowFloatRendering:!0;let f=q8(t.photometricInterpretation)&&((m=e.targetBuffer)==null?void 0:m.offset)===void 0;const d=((w=e.preScale)==null?void 0:w.enabled)&&Object.values(e.preScale.scalingParameters).some(C=>typeof C=="number"&&!Number.isInteger(C)),h=!e.preScale.enabled||!l&&d,g=(x=e.targetBuffer)==null?void 0:x.type;if(g&&e.preScale.enabled&&!h){const C=e.preScale.scalingParameters,S=PT(s,c,C);f=!D4e(S.min,S.max,j7[g])}g&&!f?a=JEe(e,t,j7,a):e.preScale.enabled&&!h?a=ZEe(e,s,c,t):a=v$(s,c,t);let p=s,v=c;if(e.preScale.enabled&&!h){const C=e.preScale.scalingParameters;if(y$(C),YEe(C)){KEe(a,C),t.preScale={...e.preScale,scaled:!0};const T=PT(s,c,C);p=T.min,v=T.max}}else h&&(t.preScale={enabled:!0,scaled:!1},p=s,v=c);t.pixelData=a,t.smallestPixelValue=p,t.largestPixelValue=v;const y=new Date().getTime();return t.decodeTimeInMS=y-r,t}function YEe(t){const{rescaleSlope:e,rescaleIntercept:r,modality:n,doseGridScaling:i,suvbw:o}=t;return typeof e=="number"&&typeof r=="number"||n==="RTDOSE"&&typeof i=="number"||n==="PT"&&typeof o=="number"}function JEe(t,e,r,n){const{arrayBuffer:i,type:o,offset:a=0,length:s,rows:c}=t.targetBuffer,l=r[o];if(!l)throw new Error(`target array ${o} is not supported, or doesn't exist.`);c&&c!=e.rows&&e8e(e,t.targetBuffer,l);const f=e.pixelDataLength,u=a,d=s??f-u,h=e.pixelData;if(d!==h.length)throw new Error(`target array for image does not have the same length (${d}) as the decoded image length (${h.length}).`);const g=i?new l(i,u,d):new l(d);return g.set(h,0),n=g,n}function ZEe(t,e,r,n){const i=t.preScale.scalingParameters;y$(i);const o=PT(e,r,i);return v$(o.min,o.max,n)}function v$(t,e,r){const n=X8(t,e),i=new n(r.pixelData.length);return i.set(r.pixelData,0),i}function PT(t,e,r){const{rescaleSlope:n,rescaleIntercept:i,modality:o,doseGridScaling:a,suvbw:s}=r;return o==="PT"&&typeof s=="number"&&!isNaN(s)?{min:s*(t*n+i),max:s*(e*n+i)}:o==="RTDOSE"&&typeof a=="number"&&!isNaN(a)?{min:t*a,max:e*a}:typeof n=="number"&&typeof i=="number"?{min:n*t+i,max:n*e+i}:{min:t,max:e}}function y$(t){if(!t)throw new Error("options.preScale.scalingParameters must be defined if preScale.enabled is true, and scalingParameters cannot be derived from the metadata providers.")}function QEe(t,e,r){const{samplesPerPixel:n}=t,{rows:i,columns:o}=e,a=i*o*n,s=new r(a),c=s.byteLength/a;return{pixelData:s,rows:i,columns:o,frameInfo:{...t.frameInfo,rows:i,columns:o},imageInfo:{...t.imageInfo,rows:i,columns:o,bytesPerPixel:c}}}function e8e(t,e,r){const n=QEe(t,e,r),{scalingType:i="replicate"}=e;return qEe[i](t,n),Object.assign(t,n),t.pixelDataLength=t.pixelData.length,t}async function w$(t,e,r,n,i,o){const a=new Date().getTime();let s=null,c;switch(e){case"1.2.840.10008.1.2":case"1.2.840.10008.1.2.1":s=B7(t,r);break;case"1.2.840.10008.1.2.2":s=hEe(t,r);break;case"1.2.840.10008.1.2.1.99":s=B7(t,r);break;case"1.2.840.10008.1.2.5":s=gEe(t,r);break;case"1.2.840.10008.1.2.4.50":c={...t},s=SEe(r,c);break;case"1.2.840.10008.1.2.4.51":s=DEe(t,r);break;case"1.2.840.10008.1.2.4.57":s=W7(t,r);break;case"1.2.840.10008.1.2.4.70":s=W7(t,r);break;case"1.2.840.10008.1.2.4.80":c={signed:t.pixelRepresentation===1,bytesPerPixel:t.bitsAllocated<=8?1:2,...t},s=z7(r,c);break;case"1.2.840.10008.1.2.4.81":c={signed:t.pixelRepresentation===1,bytesPerPixel:t.bitsAllocated<=8?1:2,...t},s=z7(r,c);break;case"1.2.840.10008.1.2.4.90":c={...t},s=$7(r,c);break;case"1.2.840.10008.1.2.4.91":c={...t},s=$7(r,c);break;case"3.2.840.10008.1.2.4.96":case"1.2.840.10008.1.2.4.201":case"1.2.840.10008.1.2.4.202":case"1.2.840.10008.1.2.4.203":c={...t},s=jEe(r,c);break;default:throw new Error(`no decoder for transfer syntax ${e}`)}if(!s)throw new Error("decodePromise not defined");const l=await s,f=XEe(l,i,a);return o==null||o(f),f}const t8e={decodeTask({imageFrame:t,transferSyntax:e,decodeConfig:r,options:n,pixelData:i,callbackFn:o}){return w$(t,e,i,r,n,o)}};I4(t8e);const Il={constants:lEe,convertRGBColorByPixel:Iz,convertRGBColorByPlane:Oz,convertYBRFullByPixel:Mz,convertYBRFullByPlane:Pz,convertPALETTECOLOR:Rz,wadouri:R4e,wadors:rEe,init:f$,convertColorSpace:Jz,createImage:sx,decodeJPEGBaseline8BitColor:Zz,getImageFrame:Qz,getPixelData:Q8,getMinMax:ax,isColorImage:q8,isJPEGBaseline8BitColor:sEe,internal:K_e,decodeImageFrame:w$};class Nh extends mf{}xb(Nh,"toolName","NoLabelArrowAnnotate");function H7(t,e){const r=ct("imagePlaneModule",t);if(!r)return;const{rowCosines:n,columnCosines:i,imagePositionPatient:o,rowPixelSpacing:a,columnPixelSpacing:s}=r;if(!n||!i||!o)return;const c=s||1,l=a||1,f=n,u=i,d=o;return[d[0]+e.x*u[0]*c+e.y*f[0]*l,d[1]+e.x*u[1]*c+e.y*f[1]*l,d[2]+e.x*u[2]*c+e.y*f[2]*l]}window.cornerstone3dTools=Dz;window.cornerstone3d=jhe;window.cornerstoneDICOMImageLoader=Il;const{MouseBindings:Fg,KeyboardBindings:K7}=lF,{IMAGE_RENDERED:Ug}=et,n8e=[{name:"Soft Tissue",center:40,width:400},{name:"Lung",center:-600,width:1500},{name:"Bone",center:300,width:1500},{name:"Brain",center:40,width:80},{name:"Abdomen",center:60,width:400}],q7=t=>{const e=(t||"").toUpperCase(),r=[{name:"Reset to default",action:"reset"},{name:"Auto level",action:"autolevel"}];return e!=="CT"?r:[...r,...n8e.map(n=>({name:n.name,action:"preset",center:n.center,width:n.width}))]},l0=[{label:"Window/Level",value:Mh.toolName,icon:"🌓"},{label:"Pan",value:ef.toolName,icon:"✋"},{label:"Zoom",value:Wl.toolName,icon:"🔍"},{label:"Stack Scroll",value:Ld.toolName,icon:"📚"},{label:"Rotate",value:Ph.toolName,icon:"↺"},{label:"Length",value:pf.toolName,icon:"📏"},{label:"Probe",value:su.toolName,icon:"🔎"},{label:"Arrow (No Label)",value:Nh.toolName,icon:"➡️"},{label:"Arrow Annotate",value:mf.toolName,icon:"✈️"},{label:"Rectangle ROI",value:au.toolName,icon:"▭"},{label:"Ellipse ROI",value:Ad.toolName,icon:"◯"},{label:"Freehand ROI",value:gf.toolName,icon:"✏️"},{label:"Freehand Contour Segmentation",value:sl.toolName,icon:"🖊️"},{label:"Sculptor",value:Rh.toolName,icon:"🔧"},{label:"Reference Cursors",value:La.toolName,icon:"⦿"}],r8e=3,i8e=220;function o8e(t){if(!t)return"🔖";const e=l0.find(r=>r.value===t||r.label===t);return(e==null?void 0:e.icon)||"🔖"}function zs(t){return t?t.startsWith("wadouri:")?t.replace(/^wadouri:+/,"").replace(/^:+/,""):t:""}function RT(t){return/([?&])frame=\d+/i.test(t)}function X7(t,e){const r=Math.max(1,Math.floor(e));return RT(t)?t.replace(/([?&])frame=\d+/i,`$1frame=${r}`):`${t}&frame=${r}`}function Y7(t){const e=t.match(/[?&]frame=(\d+)/i);if(!e)return null;const r=Number(e[1]);return Number.isFinite(r)&&r>0?Math.floor(r):null}function J7(t){return t?t.split(/\\|,/).map(e=>Number(e.trim())).filter(e=>Number.isFinite(e)):[]}function a0(t){return t.startsWith("wadouri:")||t.startsWith("external:")?t:`wadouri:${t}`}function e3(t){const e=new Set,r=[];for(const n of t)!n||e.has(n)||(e.add(n),r.push(n));return r}function a8e(t){try{const e=t.getContext("2d",{willReadFrequently:!0});if(!e)return!0;const r=t.width||160,n=t.height||160,o=e.getImageData(0,0,r,n).data;let a=255,s=0,c=0,l=0;for(let d=0;d<n;d+=8)for(let h=0;h<r;h+=8){const g=(d*r+h)*4,p=o[g],v=o[g+1],y=o[g+2],m=o[g+3],w=(p+v+y)/3;m>0&&w>12&&(c+=1),a=Math.min(a,w),s=Math.max(s,w),l+=1}if(l===0)return!0;const f=c/l,u=s-a;return f>.015||u>8}catch{return!0}}const Z7=[{label:"Left",value:"Primary"},{label:"Middle",value:"Auxiliary"},{label:"Right",value:"Secondary"}],ev=[{label:"Left",value:"Primary",mask:1},{label:"Middle",value:"Auxiliary",mask:4},{label:"Right",value:"Secondary",mask:2},{label:"Left + Right",value:"Primary_and_Secondary",mask:3},{label:"Left + Middle",value:"Primary_and_Auxiliary",mask:5},{label:"Right + Middle",value:"Secondary_and_Auxiliary",mask:6},{label:"Left + Right + Middle",value:"Primary_and_Secondary_and_Auxiliary",mask:7},{label:"Fourth Button",value:"Fourth_Button",mask:8},{label:"Fifth Button",value:"Fifth_Button",mask:16},{label:"Mouse Wheel",value:"Wheel",mask:524288},{label:"Mouse Wheel + Left",value:"Wheel_Primary",mask:524289}];function s8e({container_id:t,imageStacks:e,autoCacheStack:r,annotationJson:n,viewerState:i,...o}){var Ms,Tc,Za,Ps,Rs,Qa,_c,Ls,Ec,As,bc,Dc,Ic,Oc,es,ts,vo,Bo,Hi,Ns,ks,ns,Vs,Ia,Fs,oe,ae,De,He,tt;const a=st.useRef(null),s=st.useRef(null),c=st.useRef(!1),l="dv3d_mouseToolBindings",f="dv3d_ctrlMouseToolBindings",[u,d]=st.useState(!1),[h,g]=st.useState(!1),[p,v]=st.useState(320),y=`dv3d_stackPanelWidth_${t||"default"}`,m=st.useRef({resizing:!1,startX:0,startWidth:320}),w=240,x=720,C=220,S=40,T=14,_=st.useRef(null),[E,b]=st.useState(null),[D,I]=st.useState(null),[P,O]=st.useState(!1),L=9,B="renderingEngine_"+t,H="TOOL_GROUP_"+t,A=st.useRef(null),F=st.useRef(!1),[G,X]=st.useState(!0),[ee,ce]=st.useState(!1),[Se,we]=st.useState([]),[_e,Ve]=st.useState(0),[Ge,Ne]=st.useState(null),[j,M]=st.useState(!1),[q,K]=st.useState(null),[J,re]=st.useState(()=>Array(L).fill([])),ie=z=>{typeof z=="function"?re(ne=>{const de=z(ne);return console.log("setViewportImageIds (fn):",de),de}):(console.log("setViewportImageIds:",z),re(z))},[Re,Fe]=st.useState(()=>Array(L).fill(0)),[je,Xe]=st.useState(()=>Array(L).fill(null).map(()=>[])),[se,ue]=st.useState(()=>Array(L).fill(0)),[Pe,pe]=st.useState(()=>Array(L).fill(!1)),[Ee,Qe]=st.useState(()=>Array(L).fill(12)),[fe,ft]=st.useState(()=>Array(L).fill(!1)),pt=st.useRef({}),dt=st.useRef({}),[Ue,nt]=st.useState({}),at=st.useRef({}),ot=st.useRef({}),lt=st.useCallback((z,ne)=>{nt(de=>{const le=de[z];if(le&&le!==ne&&le.startsWith("blob:"))try{URL.revokeObjectURL(le)}catch{}const Q={...de,[z]:ne};return at.current=Q,Q})},[]);st.useEffect(()=>{at.current=Ue},[Ue]),st.useEffect(()=>()=>{Object.values(at.current).forEach(z=>{if(typeof z=="string"&&z.startsWith("blob:"))try{URL.revokeObjectURL(z)}catch{}})},[]),st.useEffect(()=>{try{const z=localStorage.getItem(y);if(z){const ne=Number(z);Number.isNaN(ne)||v(Math.max(w,Math.min(x,Math.round(ne))))}}catch{}},[y]),st.useEffect(()=>{try{localStorage.setItem(y,String(Math.round(p)))}catch{}},[y,p]);function _t(z){if(!z)return null;try{if(z.tagName&&z.tagName.toLowerCase()==="canvas")return z}catch{}try{const ne=z.querySelector&&z.querySelector("canvas");if(ne)return ne}catch{}try{const ne=z.children||[];for(let de=0;de<ne.length;de++){const le=_t(ne[de]);if(le)return le}}catch{}return null}function vt(z){if(!z||z.startsWith("wadouri:"))return!1;if(z.startsWith("external:")||z.startsWith("blob:")||z.startsWith("data:image/"))return!0;const ne=z.toLowerCase();return!!(ne.endsWith(".png")||ne.endsWith(".jpg")||ne.endsWith(".jpeg")||ne.endsWith(".gif"))}function Mt(z,ne,de){let he=1,ge=0,me=0,N=!1,k=0,te=0;ne.style.transformOrigin="0 0",ne.style.willChange="transform",ne.style.cursor="grab";const ve=(Ae,qe=.1,rt=10)=>Math.min(rt,Math.max(qe,Ae)),Ie=()=>{ne.style.transform=`translate(${ge}px, ${me}px) scale(${he})`};let ke=!0,be=!0;const Oe=Ae=>{if(!be)return;Ae.preventDefault();const qe=ne.getBoundingClientRect(),rt=Ae.clientX-qe.left,mt=Ae.clientY-qe.top,ht=-Ae.deltaY,zt=1+(ht>0?.1:-.1)*Math.min(4,Math.abs(ht)/100),Ut=ve(he*zt,.1,10);ge=(ge-rt)*(Ut/he)+rt,me=(me-mt)*(Ut/he)+mt,he=Ut,Ie()},W=Ae=>{Ae.button===0&&ke&&(N=!0,k=Ae.clientX,te=Ae.clientY,ne.style.cursor="grabbing",Ae.preventDefault())},$=Ae=>{if(!N)return;const qe=Ae.clientX-k,rt=Ae.clientY-te;ge+=qe,me+=rt,k=Ae.clientX,te=Ae.clientY,Ie()},R=Ae=>{N&&(N=!1,ne.style.cursor="grab")},V=Ae=>{he=1,ge=0,me=0,Ie()};let Y=0;const ye=(Ae,qe)=>Math.hypot(qe.clientX-Ae.clientX,qe.clientY-Ae.clientY),xe=Ae=>{Ae.touches.length===1?ke&&(N=!0,k=Ae.touches[0].clientX,te=Ae.touches[0].clientY):Ae.touches.length===2&&(Y=ye(Ae.touches[0],Ae.touches[1]))},Ce=Ae=>{if(Ae.touches.length===1&&N){const qe=Ae.touches[0].clientX-k,rt=Ae.touches[0].clientY-te;ge+=qe,me+=rt,k=Ae.touches[0].clientX,te=Ae.touches[0].clientY,Ie()}else if(Ae.touches.length===2&&be){const qe=ye(Ae.touches[0],Ae.touches[1]);if(Y>0){const rt=qe/Y,mt=ne.getBoundingClientRect(),ht=(Ae.touches[0].clientX+Ae.touches[1].clientX)/2-mt.left,zt=(Ae.touches[0].clientY+Ae.touches[1].clientY)/2-mt.top,Ut=ve(he*rt,.1,10);ge=(ge-ht)*(Ut/he)+ht,me=(me-zt)*(Ut/he)+zt,he=Ut,Ie()}Y=qe}Ae.preventDefault()},Te=Ae=>{Ae.touches.length===0&&(N=!1,Y=0)};return z.addEventListener("wheel",Oe,{passive:!1}),z.addEventListener("mousedown",W),window.addEventListener("mousemove",$),window.addEventListener("mouseup",R),ne.addEventListener("dblclick",V),z.addEventListener("touchstart",xe,{passive:!1}),z.addEventListener("touchmove",Ce,{passive:!1}),z.addEventListener("touchend",Te),{cleanup:()=>{z.removeEventListener("wheel",Oe),z.removeEventListener("mousedown",W),window.removeEventListener("mousemove",$),window.removeEventListener("mouseup",R),ne.removeEventListener("dblclick",V),z.removeEventListener("touchstart",xe),z.removeEventListener("touchmove",Ce),z.removeEventListener("touchend",Te),ne.style.transform="",ne.style.cursor="",ne.style.willChange=""},setAllowPan:Ae=>{ke=Ae},setAllowZoom:Ae=>{be=Ae}}}const[Ft,wn]=st.useState(!1),[Dn,Nt]=st.useState(null),[xn,Ui]=st.useState(!1),[br,Ye]=st.useState(null);st.useEffect(()=>{const z=de=>{try{const le=de&&de.message?String(de.message):"";(le.includes("releaseGraphicsResources")||le.includes("openGLTexture")||le.includes("getDefaultActor")||le.includes("setColormapGPU")||le.includes(`can't access property "actor"`)||le.toLowerCase().includes("webgl")||le.toLowerCase().includes("colormap"))&&(console.error("Detected graphics/rendering error:",de),Ye(le||null),Ui(!0))}catch{}},ne=de=>{try{const le=de&&de.reason||"",Q=typeof le=="string"?le:le&&le.message?le.message:String(le);(Q.includes("releaseGraphicsResources")||Q.includes("openGLTexture")||Q.includes("getDefaultActor")||Q.includes("setColormapGPU")||Q.includes(`can't access property "actor"`)||Q.toLowerCase().includes("webgl")||Q.toLowerCase().includes("colormap"))&&(console.error("Detected graphics/rendering rejection:",de),Ye(Q||null),Ui(!0))}catch{}};return window.addEventListener("error",z),window.addEventListener("unhandledrejection",ne),()=>{window.removeEventListener("error",z),window.removeEventListener("unhandledrejection",ne)}},[]),st.useEffect(()=>{let z=!1;if(n||i){Nt(n?"annotations":"viewerState");const ne=setTimeout(()=>{if(z)return;const de=t||"default";if(n)try{const le=window[`importAnnotations_${de}`]||window.importAnnotations;typeof le=="function"&&le(n)}catch(le){console.error("Failed to import annotations from prop:",le)}if(i)try{const le=window[`importViewerState_${de}`]||window.importViewerState;typeof le=="function"&&le(i)}catch(le){console.error("Failed to import viewer state from prop:",le)}Nt(null)},2e3);return()=>{z=!0,clearTimeout(ne),Nt(null)}}},[n,i,t]),st.useEffect(()=>{let z=!0;return e().then(async ne=>{var Q,he;if(!z)return;const de=Array.isArray(ne)?ne:[],le=await Promise.all(de.map(async ge=>{if(Array.isArray(ge)){const ve=await Ei(ge),Ie=await Bn(ve);return{imageIds:ve,seriesGroups:Ie}}const me=Array.isArray(ge.imageIds)?ge.imageIds:Array.isArray(ge.i)?ge.i:[],N=await Ei(me);let k;if(Array.isArray(ge.series)){const Ie=(await Promise.all(ge.series.map(async(ke,be)=>{const Oe=Array.isArray(ke==null?void 0:ke.imageIds)?ke.imageIds:Array.isArray(ke==null?void 0:ke.i)?ke.i:[],W=await Ei(Oe),R=(typeof(ke==null?void 0:ke.name)=="string"?ke.name:"").trim()||`Series ${be+1}`;return{key:String((ke==null?void 0:ke.seriesInstanceUID)||(ke==null?void 0:ke.seriesId)||`SERIES_${be}`),label:R,imageIds:W,seriesInstanceUID:ke==null?void 0:ke.seriesInstanceUID,bValue:Number.isFinite(Number(ke==null?void 0:ke.bValue))?Number(ke.bValue):null}}))).filter(ke=>ke.imageIds.length>0);Ie.length>0&&(k=Ie)}(!k||k.length===0)&&(k=await Bn(N));let te=ge.studyInstanceUID;if(!te&&N.length>0)try{const ve=N[0];if(typeof fetch=="function"&&typeof window.dicomParser<"u"&&ve.startsWith("wadouri:")){const Ie=zs(ve),be=await(await fetch(Ie)).arrayBuffer();te=window.dicomParser.parseDicom(new Uint8Array(be)).string("x0020000d")}}catch{}return{imageIds:N,seriesGroups:k,studyInstanceUID:te,studyId:ge.studyId,name:ge.name,caseId:ge.caseId}}));if(we(le),le[0]){const ge=le[0],me=((he=(Q=ge.seriesGroups)==null?void 0:Q[0])==null?void 0:he.imageIds)||ge.imageIds;await jn(me),ie(Array(L).fill(me||[])),Xe(Array(L).fill(null).map(()=>ge.seriesGroups||[])),ue(Array(L).fill(0))}else ie(Array(L).fill([])),Xe(Array(L).fill(null).map(()=>[])),ue(Array(L).fill(0))}).catch(ne=>{console.error("Failed to load imageStacks:",ne),we([]),ie(Array(L).fill([]))}),()=>{z=!1}},[]);const ut=async(z,ne)=>{var ge;const de=Se[ne];if(!de)return;let le=de.seriesGroups;const Q=de.imageIds;await jn(Q,{force:!0}),(!le||le.length===0)&&(le=await Bn(Q),we(me=>{const N=[...me];return N[ne]?(N[ne]={...N[ne],seriesGroups:le},N):me}));const he=((ge=le[0])==null?void 0:ge.imageIds)||Q;Nt("displayset");try{pi(me=>{const N=[...me];return N[z]="stack",N}),ie(me=>{const N=[...me];return N[z]=he,N}),Fe(me=>{const N=[...me];return N[z]=ne,N}),Xe(me=>{const N=[...me];return N[z]=le||[],N}),ue(me=>{const N=[...me];return N[z]=0,N}),await jn(he)}finally{Nt(null)}},[Rt,mn]=st.useState(!1),[Fr,Lt]=st.useState(!0),[Cn,Yt]=st.useState(!1),[jt,hi]=st.useState(!1),Bi=()=>{console.log("Sorting viewport imageIds by slice location"),ie(z=>{const ne=z.map((de,le)=>{if(!de||de.length===0)return de;const ge=[...de.map(me=>{const N=ct("imagePlaneModule",me);let k=null;return N&&(N.sliceLocation!==void 0?k=Number(N.sliceLocation):N.imagePositionPatient&&Array.isArray(N.imagePositionPatient)&&N.imagePositionPatient.length===3&&(k=Number(N.imagePositionPatient[2]))),{imageId:me,sortKey:k}})].sort((me,N)=>me.sortKey!==null&&N.sortKey!==null?me.sortKey-N.sortKey:me.imageId.localeCompare(N.imageId)).map(me=>me.imageId);return JSON.stringify(ge)===JSON.stringify(de)?de:ge});return wn(!0),ne})},Ao=st.useCallback(async(z,ne,de=0)=>{if(!ne||Ue[z]||ot.current[z])return;if(vt(ne)){try{const ge=new Image;ge.crossOrigin="anonymous";const me=ne.replace(/^external:/,"");ge.src=me,await new Promise((ve,Ie)=>{ge.onload=()=>ve(!0),ge.onerror=ke=>Ie(ke)});const N=document.createElement("canvas"),k=160;N.width=k,N.height=k;const te=N.getContext("2d");if(te){const ve=Math.min(k/ge.width,k/ge.height),Ie=ge.width*ve,ke=ge.height*ve,be=(k-Ie)/2,Oe=(k-ke)/2;te.fillStyle="#000",te.fillRect(0,0,k,k),te.drawImage(ge,be,Oe,Ie,ke),lt(z,N.toDataURL("image/png"))}else lt(z,"BROKEN")}catch{lt(z,"BROKEN")}return}const le=A.current;if(!le)return;ot.current[z]=!0;const Q=`THUMB_${t||"main"}_${z}`,he=document.createElement("div");he.style.width="160px",he.style.height="160px",he.style.position="absolute",he.style.left="-9999px",he.style.top="0",document.body.appendChild(he);try{le.enableElement({viewportId:Q,type:ir.STACK,element:he});const ge=le.getViewport(Q);if(!ge)return;try{ge.setStack([ne])}catch{}await new Promise(N=>{let k=!1;const te=setTimeout(()=>{k||(k=!0,N(!1))},2e3),ve=()=>{k||(k=!0,clearTimeout(te),N(!0))};try{if(ge&&ge.element&&ge.element.addEventListener(Ug,ve,{once:!0}),typeof ge.render=="function")try{const Ie=ge.render();Ie&&typeof Ie.then=="function"&&Ie.catch(()=>{})}catch{}}catch{clearTimeout(te),N(!1)}});let me=_t(he)||(ge&&ge.element?_t(ge.element):null);if(me||(await new Promise(N=>setTimeout(N,150)),me=_t(he)||(ge&&ge.element?_t(ge.element):null)),me){if(!a8e(me)&&de<r8e){const k=i8e*(de+1);ot.current[z]=!1,setTimeout(()=>{Ao(z,ne,de+1)},k);return}try{if(typeof me.toBlob=="function"){const k=await new Promise(te=>{me.toBlob(ve=>{if(!ve){te(null);return}te(URL.createObjectURL(ve))},"image/png")});k?lt(z,k):lt(z,me.toDataURL("image/png"))}else lt(z,me.toDataURL("image/png"))}catch{lt(z,"BROKEN")}}else lt(z,"BROKEN")}catch{try{lt(z,"BROKEN")}catch{}}finally{try{le.disableElement(Q)}catch{}he&&he.parentNode&&he.parentNode.removeChild(he)}},[t,Ue,lt]);st.useEffect(()=>{!Se||Se.length===0||!A.current||Se.forEach((ne,de)=>{const le=Array.isArray(ne.imageIds)?ne.imageIds:[],Q=Math.floor(le.length/2),he=le[Q]||le[0]||null;!Ue[de]&&!ot.current[de]&&Ao(de,he)})},[Se,Ao,Ue]);const jn=async(z,ne)=>{console.log("Setting loaded imageIds:",z),console.log("autoCacheStack:",r);const de=[];if(!!(r||ne!=null&&ne.force)){for(const Q of z)if(Q.startsWith("wadouri:"))try{const he=zs(Q);if(Il.wadouri.dataSetCacheManager){const ge=Il.wadouri.dataSetCacheManager.load(he);ge&&typeof ge.then=="function"&&de.push(ge)}else console.warn("MetaDataManager not found. Unable to cache metadata.")}catch(he){console.warn(`Failed to cache metadata for ${Q}:`,he)}await Promise.all(de),Ur&&(console.log("Sorting viewport imageIds by slice location"),Bi())}},fo=st.useCallback(async z=>{var ge;if(!z.startsWith("wadouri:")||RT(z))return 1;const ne=a0(z),de=zs(ne),le=`wadouri:${de}`,Q=pt.current[le];if(Q!==void 0)return Q;const he=me=>{if(!me||typeof me.intString!="function")return 1;const N=Number(me.intString("x00280008"));return Number.isFinite(N)&&N>1?Math.floor(N):1};try{const me=ct("multiframeModule",ne),N=Number(me==null?void 0:me.numberOfFrames);if(Number.isFinite(N)&&N>1)return pt.current[le]=Math.floor(N),Math.floor(N)}catch{}try{const me=(ge=Il==null?void 0:Il.wadouri)==null?void 0:ge.dataSetCacheManager;if(me!=null&&me.get){const N=me.get(de),k=he(N);return pt.current[le]=k,k}}catch{}try{const N=await(await fetch(de)).arrayBuffer(),k=lr.parseDicom(new Uint8Array(N)),te=he(k);return pt.current[le]=te,te}catch{return pt.current[le]=1,1}},[]),Ei=st.useCallback(async z=>{const ne=[];for(const de of z||[]){const le=a0(de);if(!le.startsWith("wadouri:")||RT(le)){ne.push(le);continue}const Q=await fo(le);if(Q<=1){ne.push(le);continue}for(let he=1;he<=Q;he++)ne.push(X7(le,he))}return e3(ne)},[fo]),xa=st.useCallback(async z=>{var he;if(!z.startsWith("wadouri:"))return[];const ne=a0(z),de=zs(ne).replace(/[?&]frame=\d+/i,""),le=dt.current[de];if(le)return le;const Q=ge=>{if(!ge||typeof ge.string!="function")return[];const me=J7(ge.string("x00189087"));if(me.length>0)return me;const N=J7(ge.string("x20011003"));return N.length>0?N:[]};try{const ge=(he=Il==null?void 0:Il.wadouri)==null?void 0:he.dataSetCacheManager;if(ge!=null&&ge.get){const me=ge.get(de),N=Q(me);if(N.length>0)return dt.current[de]=N,N}}catch{}try{const me=await(await fetch(de)).arrayBuffer(),N=lr.parseDicom(new Uint8Array(me)),k=Q(N);return dt.current[de]=k,k}catch{return dt.current[de]=[],[]}},[]),Bn=st.useCallback(async z=>{if(!Array.isArray(z)||z.length===0)return[];const ne=new Map;z.forEach(he=>{const ge=zs(a0(he)).replace(/[?&]frame=\d+/i,""),me=ne.get(ge)||[];me.push(he),ne.set(ge,me)}),ne.forEach((he,ge)=>{he.sort((me,N)=>{const k=Y7(me)||1,te=Y7(N)||1;return k-te}),ne.set(ge,he)});const de=new Map;await Promise.all(Array.from(ne.keys()).map(async he=>{const ge=`wadouri:${he}`,me=await xa(ge);de.set(he,me)}));const le=new Map;return z.forEach(he=>{const ge=ct("generalSeriesModule",he)||{},me=ct("generalImageModule",he)||{},N=ct("mrImageModule",he)||{},k=(ge.seriesInstanceUID||"").trim(),te=(ge.seriesDescription||"").trim(),ve=Number(ge.seriesNumber),Ie=Number(me.temporalPositionIdentifier),ke=Number(me.triggerTime);let be=Number(N.diffusionBValue??N.diffusionbValue??N.bValue),Oe=Number.isFinite(be)?be:null;if(Oe===null){const ye=zs(a0(he)).replace(/[?&]frame=\d+/i,""),xe=de.get(ye)||[];if(xe.length>0){const Ce=ne.get(ye)||[he],Te=Math.max(0,Ce.indexOf(he)),Me=Math.max(1,Ce.length);if(xe.length===1)Oe=xe[0];else if(xe.length===Me)Oe=xe[Math.min(xe.length-1,Te)];else if(xe.length===2&&Me%2===0)Oe=Te<Me/2?xe[0]:xe[1];else{const Ae=Math.min(xe.length-1,Math.floor(Te/Me*xe.length));Oe=xe[Ae]}}}const W=Number.isFinite(Ie)?`t${Ie}`:"",$=Number.isFinite(ke)?`tr${Math.round(ke)}`:"",R=Oe!==null?`b${Math.round(Oe)}`:"",Y=[k||"NO_UID",R,W,$].filter(Boolean).join("|")||"SERIES_0";le.has(Y)||le.set(Y,{imageIds:[],seriesInstanceUID:k||void 0,seriesDescription:te||void 0,seriesNumber:Number.isFinite(ve)?ve:void 0,bValue:Oe}),le.get(Y).imageIds.push(he)}),le.size<=1?[{key:"SERIES_0",label:"Series 1",imageIds:e3(z)}]:Array.from(le.entries()).map(([he,ge],me)=>{const N=[];ge.seriesDescription&&N.push(ge.seriesDescription),ge.seriesNumber!==void 0&&N.push(`#${ge.seriesNumber}`),ge.bValue!==null&&ge.bValue!==void 0&&N.push(`b=${Math.round(ge.bValue)}`);const k=N.length>0?N.join(" • "):`Series ${me+1}`;return{key:he,label:k,imageIds:e3(ge.imageIds),seriesInstanceUID:ge.seriesInstanceUID,bValue:ge.bValue}})},[xa]),[Ct,Zt]=st.useState({rows:1,cols:1}),[ar,Qo]=st.useState(!1),Dr=st.useRef([]),ho=st.useRef({}),bi=st.useRef({}),[Ur,Cs]=st.useState(!1),[go,Zi]=st.useState(!0),Ca=st.useCallback(z=>{const ne=z.currentTarget.getBoundingClientRect(),de=z.clientX-ne.left,le=z.clientY-ne.top,Q=ne.width,he=ne.height,ge=Math.min(Q,he)*.24,me=[{zone:"left",distance:de},{zone:"right",distance:Q-de},{zone:"top",distance:le},{zone:"bottom",distance:he-le}];return me.sort((N,k)=>N.distance-k.distance),me[0].distance<=ge?me[0].zone:"center"},[]),gi=st.useCallback(z=>z==="left"||z==="right"?Ct.cols<3?z:"center":(z==="top"||z==="bottom")&&Ct.rows<3?z:"center",[Ct]),Sa=[];for(let z=1;z<=3;z++)for(let ne=1;ne<=3;ne++)Sa.push({rows:z,cols:ne});const[ln,Gi]=st.useState(()=>Array(Ct.rows*Ct.cols).fill({index:0,total:0,windowCenter:"",windowWidth:"",slicePosition:"",modality:"",orientation:"",resolution:"",spacing:"",focalPoint:""})),[Ss,ea]=st.useState(()=>Array(L).fill(null).map(()=>[])),Qi=st.useRef(Array(L).fill("")),po=st.useRef(Array(L).fill(null)),Zr=st.useRef(Array(L).fill(null)),Di=st.useRef(Array(L).fill(null)),[sn,pi]=st.useState(()=>Array(L).fill("stack")),[No,Wi]=st.useState(()=>Array(Ct.rows*Ct.cols).fill(!1)),[Ii,Ts]=st.useState({Primary:Ld.toolName,Auxiliary:ef.toolName,Secondary:Mh.toolName,Primary_and_Secondary:Wl.toolName,Fourth_Button:Ph.toolName,Wheel:Ld.toolName}),[ko,_s]=st.useState({Primary:pf.toolName,Auxiliary:su.toolName,Secondary:Nh.toolName}),[eo,zi]=st.useState(!1);st.useEffect(()=>{const z=de=>{de.ctrlKey&&zi(!0)},ne=de=>{de.ctrlKey||zi(!1)};return window.addEventListener("keydown",z),window.addEventListener("keyup",ne),()=>{window.removeEventListener("keydown",z),window.removeEventListener("keyup",ne)}},[]);const[$i,Ir]=st.useState(!1),[yc,Vo]=st.useState(null),Fo=(z,ne)=>{qo&&qo(ne),Is(de=>{const le=[...de];return le[z]=ne,le})},yr=(z,ne,de)=>{const le=rr.getAllAnnotations()||[];le.forEach(he=>{he.annotationUID===ne&&(he.isSelected=!1)}),rr.removeAnnotation(ne),A.current.render();const Q=de.filter(he=>he.annotationUID!==ne);Is(he=>{const ge=[...he],me=Q.length>0?Q[0].annotationUID:null;return ge[z]=me,le.forEach(N=>{N.isSelected=N.annotationUID===me}),qo(me),A.current.render(),ge})},wc=()=>{const z=J.findIndex(Q=>Q&&Q.length>0);if(z===-1){Vo("No images loaded."),Ir(!0);return}const ne=J[z][0],de=["imagePlaneModule","generalSeriesModule","generalStudyModule","patientModule","imagePixelModule","voiLutModule","modalityLutModule","sopCommonModule","petIsotopeModule","multiframeModule","cineModule","overlayPlaneModule","generalImageModule","stackModule","voiLutModule","modalityLutModule","petSeriesModule","petImageModule","petIsotopeModule","petSeriesModule","petImageModule","petIsotopeModule","petSeriesModule","petImageModule","petIsotopeModule","petSeriesModule","petImageModule","petIsotopeModule"],le={};de.forEach(Q=>{const he=ct(Q,ne);he!==void 0&&(le[Q]=he)}),Vo(ze.jsx("pre",{style:{maxHeight:600,overflow:"auto",fontSize:13,color:"#fff"},children:JSON.stringify(le,null,2)})),Ir(!0)};st.useEffect(()=>{try{const z=localStorage.getItem(l),ne=localStorage.getItem(f);z&&Ts(JSON.parse(z)),ne&&_s(JSON.parse(ne))}catch{}},[]),st.useEffect(()=>{try{localStorage.setItem(l,JSON.stringify(Ii))}catch{}},[Ii]),st.useEffect(()=>{try{localStorage.setItem(f,JSON.stringify(ko))}catch{}},[ko]),st.useEffect(()=>(window.loadDicomStackFromFiles=z=>{const ne=Array.from(z);Ya({target:{files:ne}})},()=>{window.loadDicomStackFromFiles=void 0}),[]),st.useEffect(()=>{const z=()=>{M(!1),K(null),Ne(null)};return document.addEventListener("dragend",z),()=>document.removeEventListener("dragend",z)},[]);const[mi,Or]=st.useState(!1),[qa,mo]=st.useState(!1);st.useEffect(()=>{const z=jr(H);z&&["ArrowAnnotate","NoLabelArrowAnnotate","Length","RectangleROI","EllipticalROI","PlanarFreehandROI","PlanarFreehandContourSegmentation"].forEach(ne=>{z.setToolConfiguration(ne,{color:"#00e676",selectedColor:"#ffeb3b"})})},[H]),st.useEffect(()=>{const z=le=>{le.altKey&&Or(!0),le.shiftKey&&mo(!0)},ne=le=>{le.altKey||Or(!1),le.shiftKey||mo(!1)},de=()=>{Or(!1),mo(!1)};return window.addEventListener("keydown",z),window.addEventListener("keyup",ne),window.addEventListener("blur",de),()=>{window.removeEventListener("keydown",z),window.removeEventListener("keyup",ne),window.removeEventListener("blur",de)}},[]),st.useEffect(()=>{const z=jr(H);if(!z)return;if(qa||go&&mi){const de=Ct.rows*Ct.cols;J.slice(0,de).filter((Q,he)=>sn[he]==="stack"&&Array.isArray(Q)&&Q.length>0).forEach(Q=>{jn(Q,{force:!0}).catch(he=>{console.warn("Reference cursor metadata warm-up failed:",he)})}),z.hasTool(La.toolName)||z.addTool(La.toolName),z.setToolEnabled(La.toolName),z.setToolActive(La.toolName)}else z.hasTool(La.toolName)&&z.setToolDisabled(La.toolName)},[mi,qa,go,Ct.rows,Ct.cols,J,sn,jn]);const ii=st.useCallback(()=>{[jr(H)].forEach(ne=>{if(ne){l0.forEach(le=>{ne.setToolPassive(le.value,{removeAllBindings:!0})}),ne.setToolDisabled(La.toolName);const de={};Object.entries(Ii).forEach(([le,Q])=>{de[Q]||(de[Q]=[]);const he=ev.find(ge=>ge.value===le);he?de[Q].push({mouseButton:he.mask}):Fg[le]&&de[Q].push({mouseButton:Fg[le]})}),Object.entries(ko).forEach(([le,Q])=>{if(!Q)return;de[Q]||(de[Q]=[]);const he=ev.find(ge=>ge.value===le);he?de[Q].push({mouseButton:he.mask,modifierKey:K7.Ctrl}):Fg[le]&&de[Q].push({mouseButton:Fg[le],modifierKey:K7.Ctrl})}),Object.entries(de).forEach(([le,Q])=>{ne.setToolActive(le,{bindings:Q})});try{const le=Ii.Primary,Q=Ii.Wheel,he=Ii.Auxiliary,ge=le===ef.toolName||he===ef.toolName,me=le===Wl.toolName||Q===Wl.toolName||Ii.Primary_and_Secondary===Wl.toolName;Dr.current.forEach(N=>{if(!N)return;const k=N._externalPanZoom;k&&(typeof k.setAllowPan=="function"&&k.setAllowPan(!!ge),typeof k.setAllowZoom=="function"&&k.setAllowZoom(!!me))})}catch{}}})},[Ii,ko]),[ta,Es]=st.useState(!1),[Xa,Ta]=st.useState("add"),Vn=st.useRef(null),_a=st.useCallback(z=>{h&&(z.preventDefault(),z.stopPropagation(),m.current={resizing:!0,startX:z.clientX,startWidth:p},document.body.style.cursor="col-resize",document.body.style.userSelect="none")},[h,p]);st.useEffect(()=>{const z=de=>{if(!m.current.resizing)return;const le=m.current.startX-de.clientX,Q=Math.max(w,Math.min(x,m.current.startWidth+le));v(Q)},ne=()=>{m.current.resizing&&(m.current.resizing=!1,document.body.style.cursor="",document.body.style.userSelect="")};return window.addEventListener("mousemove",z),window.addEventListener("mouseup",ne),()=>{window.removeEventListener("mousemove",z),window.removeEventListener("mouseup",ne),document.body.style.cursor="",document.body.style.userSelect=""}},[]);const Qr=ta?C-S/2:-S+T;st.useEffect(()=>{try{Vn.current&&(Vn.current.setAttribute("webkitdirectory","true"),Vn.current.setAttribute("directory",""),Vn.current.setAttribute("mozdirectory",""))}catch{}},[]);async function Mr(z,ne=""){const de=[],le=z.entries?z.entries():z.values();for await(const Q of le)try{let he,ge;if(Array.isArray(Q)&&Q.length>=2?(ge=Q[0],he=Q[1]):(he=Q,ge=he.name),!he)continue;if(he.kind==="file"){const me=await he.getFile();try{Object.defineProperty(me,"webkitRelativePath",{value:ne+(ge||he.name),configurable:!0})}catch{}de.push(me)}else if(he.kind==="directory"){const me=await Mr(he,ne+(ge||he.name)+"/");de.push(...me)}}catch(he){console.debug("collectFilesFromDirectoryHandle: skipping entry due to error",he)}return de}const xc=async()=>{var z;if(window.showDirectoryPicker)try{const ne=await window.showDirectoryPicker(),de=await Mr(ne);de&&de.length>0?await Ya({target:{files:de}}):alert("No files found in selected folder.");return}catch(ne){console.warn("showDirectoryPicker failed or cancelled",ne)}(z=Vn.current)==null||z.click()},oi=st.useRef(null),Ya=async z=>{const ne=z.target.files;if(!ne||ne.length===0)return;Cs(!1);const de=Array.from(ne).sort((ge,me)=>ge.name.localeCompare(me.name)),le=await Promise.all(de.map(async ge=>{const me=ge.type&&ge.type.startsWith("image/");let N,k,te,ve,Ie=1,ke=!1;if(!me)try{const Oe=await ge.arrayBuffer(),W=lr.parseDicom(new Uint8Array(Oe));N=W.string("x0020000d"),k=W.string("x0020000e");const $=W.string("x00200013");$!=null&&$!==""&&(te=parseInt($,10));const R=W.string("x00201041")||W.string("x00201040");R!=null&&R!==""&&(ve=parseFloat(R));const V=W.string("x00280008");if(V!=null&&V!==""){const Y=Number(V);Number.isFinite(Y)&&Y>1&&(Ie=Math.floor(Y))}ke=!0}catch{ke=!1}const be=me?`external:${URL.createObjectURL(ge)}`:`wadouri:${URL.createObjectURL(ge)}`;return{file:ge,imageId:be,studyInstanceUID:N,seriesInstanceUID:k,instanceNumber:te,sliceLocation:ve,numberOfFrames:Ie,isImage:me,parsedSuccessfully:ke}})),Q=new Map;for(const ge of le){if(!ge.isImage&&!ge.parsedSuccessfully){console.debug("Skipping non-DICOM/non-image file:",ge.file.name);continue}const me=ge.seriesInstanceUID||ge.studyInstanceUID||(ge.file.webkitRelativePath?ge.file.webkitRelativePath.split("/")[0]:ge.file.name);Q.has(me)||Q.set(me,{entries:[],studyInstanceUID:ge.studyInstanceUID,seriesInstanceUID:ge.seriesInstanceUID}),Q.get(me).entries.push(ge)}const he=[];for(const[ge,me]of Q.entries()){const N=me.entries;N.sort((ve,Ie)=>Ur&&ve.sliceLocation!==void 0&&Ie.sliceLocation!==void 0?ve.sliceLocation-Ie.sliceLocation:ve.instanceNumber!==void 0&&Ie.instanceNumber!==void 0?ve.instanceNumber-Ie.instanceNumber:(ve.file.webkitRelativePath||ve.file.name).localeCompare(Ie.file.webkitRelativePath||Ie.file.name));const k=N.flatMap(ve=>{if(ve.isImage||!Number.isFinite(ve.numberOfFrames)||ve.numberOfFrames<=1)return[ve.imageId];const Ie=[];for(let ke=1;ke<=ve.numberOfFrames;ke++)Ie.push(X7(ve.imageId,ke));return Ie}),te=await Bn(k);he.push({imageIds:k,studyInstanceUID:me.studyInstanceUID,seriesInstanceUID:me.seriesInstanceUID,seriesGroups:te})}if(he.length!==0)if(Xa==="replace"){try{const ge=A.current;if(ge)for(let me=0;me<L;me++){const N=`CT_${me}`;try{ge.getViewport(N)&&ge.disableElement(N)}catch{}try{const k=Dr.current[me];if(k){try{k._externalPanZoom&&k._externalPanZoom.cleanup&&k._externalPanZoom.cleanup()}catch{}try{k._resizeObserver&&(k._resizeObserver.disconnect(),k._resizeObserver=void 0)}catch{}k.innerHTML="",k._cornerstoneEnabled=!1,k._lastViewportType=void 0}}catch{}}}catch{}we(he),ie(()=>{var me,N;const ge=Array(L).fill([]);for(let k=0;k<L;k++){const te=he[k]||he[0],ve=((N=(me=te==null?void 0:te.seriesGroups)==null?void 0:me[0])==null?void 0:N.imageIds)||(te==null?void 0:te.imageIds)||[];ge[k]=ve}return ge}),Fe(Array(L).fill(0)),Xe(()=>{const ge=Array(L).fill(null).map(()=>[]);for(let me=0;me<L;me++){const N=he[me]||he[0];ge[me]=(N==null?void 0:N.seriesGroups)||[]}return ge}),ue(Array(L).fill(0));for(const ge of he)jn(ge.imageIds)}else we(ge=>{const me=[...ge,...he];ie(N=>{var ve,Ie;const k=[...N],te=he[he.length-1];return k[0]=((Ie=(ve=te.seriesGroups)==null?void 0:ve[0])==null?void 0:Ie.imageIds)||te.imageIds,k}),Fe(N=>{const k=[...N];return k[0]=me.length-1,k}),Xe(N=>{var te;const k=[...N];return k[0]=((te=he[he.length-1])==null?void 0:te.seriesGroups)||[],k}),ue(N=>{const k=[...N];return k[0]=0,k});for(const N of he)jn(N.imageIds);return me})},Sn=st.useCallback((z,ne)=>{var Ie,ke;if(!ne)return;let de=0,le=0,Q="",he="",ge="",me="",N="",k="",te="",ve="";if(sn[z]==="stack"){de=typeof ne.getCurrentImageIdIndex=="function"?ne.getCurrentImageIdIndex():0;const be=typeof ne.getImageIds=="function"?ne.getImageIds():[];le=be.length;const Oe=be[de];if(Oe){const W=ct("generalSeriesModule",Oe),$=ct("imagePlaneModule",Oe),R=ct("imagePixelModule",Oe);me=(W==null?void 0:W.modality)||"",R!=null&&R.rows&&(R!=null&&R.columns)&&(k=`${R.columns} x ${R.rows}`);const V=[$==null?void 0:$.columnPixelSpacing,$==null?void 0:$.rowPixelSpacing,$==null?void 0:$.sliceThickness].filter(Y=>Y!=null&&Y!=="");V.length>0&&(te=V.join(" x "))}if(typeof ne.getCamera=="function"){const W=ne.getCamera();W!=null&&W.focalPoint&&Array.isArray(W.focalPoint)&&(ve=W.focalPoint.map($=>$.toFixed(1)).join(", "))}if(de>=0&&ea(W=>{const $=[...W],R=new Set($[z]||[]);return R.has(de)?W:(R.add(de),$[z]=Array.from(R).sort((V,Y)=>V-Y),$)}),typeof ne.getProperties=="function"){const W=ne.getProperties();if(W.voiRange){const{lower:$,upper:R}=W.voiRange;Q=((R+$)/2).toFixed(0),he=(R-$).toFixed(0),po.current[z]===null&&(po.current[z]={lower:$,upper:R})}}}else if(sn[z]==="volume"){if(typeof ne.getSliceIndex=="function"&&(de=ne.getSliceIndex()),typeof ne.getNumberOfSlices=="function"&&(le=ne.getNumberOfSlices()),typeof ne.getProperties=="function"){let Oe;if(ne.volumeIds&&ne.volumeIds.size>0){const W=Array.from(ne.volumeIds)[0];Oe=ne.getProperties(W)}else Oe=ne.getProperties();if(Oe&&Oe.voiRange){const{lower:W,upper:$}=Oe.voiRange;Q=(($+W)/2).toFixed(0),he=($-W).toFixed(0),po.current[z]===null&&(po.current[z]={lower:W,upper:$})}}if(typeof ne.getSlicePlaneCoordinates=="function"){const Oe=ne.getSlicePlaneCoordinates();Oe&&typeof Oe.position=="number"&&(ge=Oe.position.toFixed(2)+" mm")}const be=(Ie=J[z])==null?void 0:Ie[0];if(be){const Oe=ct("generalSeriesModule",be),W=ct("imagePlaneModule",be),$=ct("imagePixelModule",be);me=(Oe==null?void 0:Oe.modality)||"",N=String(((ke=ne.viewportProperties)==null?void 0:ke.orientation)||"").toUpperCase(),$!=null&&$.rows&&($!=null&&$.columns)&&(k=`${$.columns} x ${$.rows}`);const R=[W==null?void 0:W.columnPixelSpacing,W==null?void 0:W.rowPixelSpacing,W==null?void 0:W.sliceThickness].filter(V=>V!=null&&V!=="");R.length>0&&(te=R.join(" x "))}if(typeof ne.getCamera=="function"){const Oe=ne.getCamera();Oe!=null&&Oe.focalPoint&&Array.isArray(Oe.focalPoint)&&(ve=Oe.focalPoint.map(W=>W.toFixed(1)).join(", "))}}Gi(be=>{const Oe=[...be];return Oe[z]={index:de+1,total:le,windowCenter:Q,windowWidth:he,slicePosition:ge,modality:me,orientation:N,resolution:k,spacing:te,focalPoint:ve},Oe})},[sn,J]);st.useEffect(()=>{ea(z=>{let ne=!1;const de=[...z];for(let le=0;le<L;le++){const Q=J[le]||[],he=`${Q.length}:${Q[0]||""}:${Q[Q.length-1]||""}`;Qi.current[le]!==he&&(Qi.current[le]=he,po.current[le]=null,Di.current[le]=null,de[le]=[],ne=!0)}return ne?de:z})},[J]);function ji(){for(let z=0;z<Ct.rows*Ct.cols;z++){const ne=`CT_${z}`,de=A.current;if(de){const le=de.getViewport(ne);le&&typeof le.getProperties=="function"&&(ho.current[z]=le.getProperties()),le&&typeof le.getCurrentImageIdIndex=="function"&&(bi.current[z]=le.getCurrentImageIdIndex())}}}const Ea=async(z,ne,de,le)=>{var Ce;const Q=await Ei(ne.map(a0));if(Q.length===0)return;await jn(Q,{force:!0});const he=await Bn(Q),ge=((Ce=he[0])==null?void 0:Ce.imageIds)||Q;let me=0;we(Te=>(me=Te.length,[...Te,{imageIds:Q,name:de,seriesGroups:he}]));const N=gi(le);if(N==="center"){Nt("displayset");try{pi(Te=>{const Me=[...Te];return Me[z]="stack",Me}),ie(Te=>{const Me=[...Te];return Me[z]=ge,Me}),Fe(Te=>{const Me=[...Te];return Me[z]=me,Me}),Xe(Te=>{const Me=[...Te];return Me[z]=he,Me}),ue(Te=>{const Me=[...Te];return Me[z]=0,Me}),Ve(z),await jn(ge)}finally{Nt(null)}return}const k=Ct.rows,te=Ct.cols,ve=Math.floor(z/te),Ie=z%te,ke=N==="top"||N==="bottom"?k+1:k,be=N==="left"||N==="right"?te+1:te;if(ke>3||be>3||ke*be>L){Nt("displayset");try{pi(Te=>{const Me=[...Te];return Me[z]="stack",Me}),ie(Te=>{const Me=[...Te];return Me[z]=Q,Me}),Fe(Te=>{const Me=[...Te];return Me[z]=me,Me}),Ve(z),await jn(Q)}finally{Nt(null)}return}const Oe=N==="top"?ve:N==="bottom"?ve+1:ve,W=N==="left"?Ie:N==="right"?Ie+1:Ie,$=Oe*be+W,R=Array(L).fill([]),V=Array(L).fill("stack"),Y=Array(L).fill(0),ye=Array(L).fill(null).map(()=>[]),xe=Array(L).fill(0);for(let Te=0;Te<k*te;Te++){const Me=Math.floor(Te/te),Ae=Te%te;let qe=Me,rt=Ae;(N==="left"||N==="right")&&Me===ve&&(rt=Ae<Ie?Ae:Ae>Ie||N==="left"?Ae+1:Ae),(N==="top"||N==="bottom")&&Ae===Ie&&(qe=Me<ve?Me:Me>ve||N==="top"?Me+1:Me);const mt=qe*be+rt;R[mt]=J[Te]||[],V[mt]=sn[Te]||"stack",Y[mt]=Re[Te]??0,ye[mt]=je[Te]||[],xe[mt]=se[Te]??0}R[$]=ge,V[$]="stack",Y[$]=me,ye[$]=he,xe[$]=0,Nt("displayset");try{ji(),Zt({rows:ke,cols:be}),ie(R),pi(V),Fe(Y),Xe(ye),ue(xe),Ve($),await jn(ge)}finally{Nt(null)}},ba=async(z,ne,de)=>{var xe;const le=Se[ne];if(!le)return;let Q=le.seriesGroups;const he=le.imageIds||[];await jn(he,{force:!0}),(!Q||Q.length===0)&&(Q=await Bn(he),we(Ce=>{const Te=[...Ce];return Te[ne]?(Te[ne]={...Te[ne],seriesGroups:Q},Te):Ce}));const ge=((xe=Q[0])==null?void 0:xe.imageIds)||he,me=gi(de);if(me==="center"){await ut(z,ne),Ve(z);return}const N=Ct.rows,k=Ct.cols,te=Math.floor(z/k),ve=z%k,Ie=me==="top"||me==="bottom"?N+1:N,ke=me==="left"||me==="right"?k+1:k;if(Ie>3||ke>3||Ie*ke>L){await ut(z,ne),Ve(z);return}const be=Array(L).fill([]),Oe=Array(L).fill("stack"),W=Array(L).fill(0),$=Array(L).fill(null).map(()=>[]),R=Array(L).fill(0),V=me==="top"?te:me==="bottom"?te+1:te,Y=me==="left"?ve:me==="right"?ve+1:ve,ye=V*ke+Y;for(let Ce=0;Ce<N*k;Ce++){const Te=Math.floor(Ce/k),Me=Ce%k;let Ae=Te,qe=Me;(me==="left"||me==="right")&&Te===te&&(Me<ve?qe=Me:Me>ve?qe=Me+1:qe=me==="left"?Me+1:Me),(me==="top"||me==="bottom")&&Me===ve&&(Te<te?Ae=Te:Te>te?Ae=Te+1:Ae=me==="top"?Te+1:Te);const rt=Ae*ke+qe;be[rt]=J[Ce]||[],Oe[rt]=sn[Ce]||"stack",W[rt]=Re[Ce]??0,$[rt]=je[Ce]||[],R[rt]=se[Ce]??0}be[ye]=ge,Oe[ye]="stack",W[ye]=ne,$[ye]=Q||[],R[ye]=0,Nt("displayset");try{ji(),Zt({rows:Ie,cols:ke}),ie(be),pi(Oe),Fe(W),Xe($),ue(R),Ve(ye),await jn(ge)}finally{Nt(null)}};st.useEffect(()=>{const z=async()=>{var he;if(console.log("setup"),!c.current){c.current=!0,await WA(),await fG(),f$();try{ld("external",ge=>({promise:(async()=>{const N=ge.replace(/^external:/,""),k=new Image;k.crossOrigin="anonymous",k.src=N,await new Promise((W,$)=>{k.onload=()=>W(!0),k.onerror=R=>$(R)});const te=k.naturalWidth||k.width,ve=k.naturalHeight||k.height,Ie=document.createElement("canvas");Ie.width=te,Ie.height=ve;const ke=Ie.getContext("2d");if(!ke)throw new Error("Unable to create canvas context");ke.drawImage(k,0,0,te,ve);const be=ke.getImageData(0,0,te,ve);return{imageId:ge,minPixelValue:0,maxPixelValue:255,slope:1,intercept:0,rows:ve,columns:te,height:ve,width:te,color:!0,rgba:!0,sizeInBytes:be.data.length,getPixelData:()=>be.data,getImageData:()=>be,getCanvas:()=>Ie}})()}))}catch(ge){console.warn("Failed to register external image loader",ge)}}let de=A.current;if(!de){de=new aE(B),A.current=de;try{Se&&Se.length>0&&Se.forEach((ge,me)=>{const N=Array.isArray(ge.imageIds)?ge.imageIds:[],k=Math.floor(N.length/2),te=N[k]||N[0]||null;te&&!Ue[me]&&!ot.current[me]&&Ao(me,te)})}catch{}}let le=jr(H);le||(le=c8e(H)),sn.slice(0,Ct.rows*Ct.cols).filter(ge=>ge==="volume").length,Ja(le);for(let ge=0;ge<L;ge++){let me=J[ge];if(!me||me.length===0)continue;const N=`CT_${ge}`,k=Dr.current[ge];if(!k)continue;const te=sn[ge]==="volume"?ir.ORTHOGRAPHIC:ir.STACK;(!k._cornerstoneEnabled||k._lastViewportType!==te)&&(de.getViewport(N)&&de.disableElement(N),de.enableElement({viewportId:N,type:te,element:k}),k._cornerstoneEnabled=!0,k._lastViewportType=te);const ve=de.getViewport(N);if(!ve)continue;if(!k._resizeObserver){const ke=new window.ResizeObserver(()=>{if(k.offsetWidth>0&&k.offsetHeight>0){de.resize();const be=de.getViewport(N);be&&typeof be.resize=="function"&&be.resize(),be&&typeof be.render=="function"&&be.render()}});ke.observe(k),k._resizeObserver=ke}if(sn[ge]==="stack"){if(me&&me.length>0){const ke=me[0];if(vt(ke))try{try{const W=k._externalPanZoom;W&&typeof W.cleanup=="function"&&W.cleanup()}catch{}k.innerHTML="";const be=document.createElement("img");be.style.width="100%",be.style.height="100%",be.style.objectFit="contain",be.style.display="block",be.src=ke.replace(/^external:/,""),be.setAttribute("draggable","false"),k.appendChild(be);const Oe=Mt(k,be);k._externalPanZoom=Oe,le.removeViewports(B,N)}catch(be){console.warn("Failed to render external image in viewport",be)}else try{ve.setStack(me)}catch(be){console.warn("viewport.setStack failed",be)}}Rt?le.removeViewports(B,N):le.addViewport(N,B)}else if(sn[ge]==="volume"){le.addViewport(N,B);const ke=`myVolumeId_${ge}`;(await p1(ke,{imageIds:me})).load(),ve.setVolumes([{volumeId:ke}]),ve.render(),k._overlayListener&&ve.element.removeEventListener(Ug,k._overlayListener);const Oe=()=>Sn(ge,ve);ve.element.addEventListener(Ug,Oe),k._overlayListener=Oe,Sn(ge,ve);continue}if(ve.render(),!F.current){bi.current[ge]!==void 0&&typeof ve.setImageIdIndex=="function"&&oa(ve.element,{imageIndex:bi.current[ge]});const ke=ho.current[ge];if(ke&&typeof ve.setProperties=="function"){const{voiRange:be,invert:Oe,interpolationType:W,VOILUTFunction:$,colormap:R}=ke,V={};be&&be.lower!==void 0&&be.upper!==void 0&&(V.voiRange=be),Oe!==void 0&&(V.invert=Oe),W!==void 0&&(V.interpolationType=W),$&&(V.VOILUTFunction=$),R!=null&&(typeof R=="string"||typeof R=="object"&&!("actor"in R))&&(V.colormap=R),setTimeout(()=>{console.log("Restoring properties (timeout) for viewport",ge,V),ve.setProperties(V),ve.render()},100)}}k._overlayListener&&ve.element.removeEventListener(Ug,k._overlayListener);const Ie=()=>Sn(ge,ve);ve.element.addEventListener(Ug,Ie),k._overlayListener=Ie,Sn(ge,ve)}for(let ge=0;ge<Ct.rows*Ct.cols;ge++){const me=`CT_${ge}`;((he=A.current)==null?void 0:he.getViewport(me))&&sn[ge]}const Q=[];for(let ge=0;ge<Ct.rows*Ct.cols;ge++)sn[ge]==="volume"&&Q.push(`CT_${ge}`);le&&Rt&&(Q.length>=2?(le.hasTool(Uc.toolName)||le.addTool(Uc.toolName),le.setToolEnabled(Uc.toolName),le.setToolConfiguration(Uc.toolName,{}),le.setToolActive(Uc.toolName,{bindings:[{mouseButton:Fg.Primary}]})):le.hasTool(Uc.toolName)&&le.setToolDisabled(Uc.toolName)),ii()},ne=requestAnimationFrame(()=>{z()});return()=>{Dr.current.forEach(de=>{de&&de._resizeObserver&&(de._resizeObserver.disconnect(),delete de._resizeObserver)}),cancelAnimationFrame(ne)}},[s,Sn,Ct,sn,J]);const Oi=st.useCallback(z=>{const ne=`CT_${z}`,le=A.current.getViewport(ne);le&&typeof le.resetCamera=="function"&&(le.resetCamera(),console.log("Restoring viewport properties for viewport",z),le.resetProperties(),le.render())},[]),bs=st.useCallback((z,ne,de)=>{const le=`CT_${z}`;try{const Q=A.current;if(Q){const he=Q.getViewport(le);he&&typeof he.setProperties=="function"&&(console.log(`Applying preset to viewport ${z}: center=${ne}, width=${de}`),he.setProperties({voiRange:{lower:ne-de/2,upper:ne+de/2}}),he.render(),Sn(z,he))}}catch{}},[Sn]),na=st.useCallback((z,ne=!1)=>{const de=`CT_${z}`;try{const le=A.current,Q=le==null?void 0:le.getViewport(de);if(!Q)return!1;const he=typeof Q.getImageIds=="function"?Q.getImageIds():J[z]||[],ge=typeof Q.getCurrentImageIdIndex=="function"?Q.getCurrentImageIdIndex():0,me=he[ge]||he[0],N=po.current[z],k=me?ct("voiLutModule",me)||{}:{},te=me?ct("imagePixelModule",me)||{}:{},ve=me?ct("modalityLutModule",me)||{}:{},Ie=Array.isArray(k.windowCenter)?k.windowCenter[0]:k.windowCenter,ke=Array.isArray(k.windowWidth)?k.windowWidth[0]:k.windowWidth,be=Number(te.smallestPixelValue??te.smallestImagePixelValue),Oe=Number(te.largestPixelValue??te.largestImagePixelValue),W=Number(ve.rescaleSlope??1),$=Number(ve.rescaleIntercept??0);if(N)Q.setProperties({voiRange:N});else if(Number.isFinite(Number(Ie))&&Number.isFinite(Number(ke))&&Number(ke)>0){const R=Number(Ie),V=Number(ke);Q.setProperties({voiRange:{lower:R-V/2,upper:R+V/2}})}else Number.isFinite(be)&&Number.isFinite(Oe)&&Oe>be?Q.setProperties({voiRange:{lower:be*W+$,upper:Oe*W+$}}):typeof Q.resetProperties=="function"&&Q.resetProperties();return ne&&typeof Q.resetCamera=="function"&&Q.resetCamera(),Q.render(),Sn(z,Q),!0}catch(le){return console.warn("Failed to apply default window level",le),!1}},[Sn,J]),Cc=st.useCallback(z=>{const ne=`CT_${z}`;(async()=>{const de=A.current;if(!de)return;const le=de.getViewport(ne);if(!le)return;const Q=typeof le.getImageIds=="function"?le.getImageIds():J[z]||[],he=typeof le.getCurrentImageIdIndex=="function"?le.getCurrentImageIdIndex():0,ge=Q[he]||Q[0];if(!ge){na(z);return}const me=ct("imagePixelModule",ge)||{},N=ct("modalityLutModule",ge)||{},k=ct("voiLutModule",ge)||{},te=po.current[z];let ve=Number(me.smallestPixelValue??me.smallestImagePixelValue),Ie=Number(me.largestPixelValue??me.largestImagePixelValue),ke=Number(N.rescaleSlope??1),be=Number(N.rescaleIntercept??0);if(!Number.isFinite(ve)||!Number.isFinite(Ie)||Ie<=ve)try{const $=await ws(ge);ve=Number($==null?void 0:$.minPixelValue),Ie=Number($==null?void 0:$.maxPixelValue),ke=Number(($==null?void 0:$.slope)??ke),be=Number(($==null?void 0:$.intercept)??be)}catch{const R=Q.filter(V=>!!V).slice(0,6);for(const V of R)try{const Y=await ws(V);if(ve=Number(Y==null?void 0:Y.minPixelValue),Ie=Number(Y==null?void 0:Y.maxPixelValue),ke=Number((Y==null?void 0:Y.slope)??ke),be=Number((Y==null?void 0:Y.intercept)??be),Number.isFinite(ve)&&Number.isFinite(Ie)&&Ie>ve)break}catch{}}const Oe=Array.isArray(k.windowCenter)?k.windowCenter[0]:k.windowCenter,W=Array.isArray(k.windowWidth)?k.windowWidth[0]:k.windowWidth;if(Number.isFinite(ve)&&Number.isFinite(Ie)&&Ie>ve)le.setProperties({voiRange:{lower:ve*ke+be,upper:Ie*ke+be}});else if(Number.isFinite(Number(Oe))&&Number.isFinite(Number(W))&&Number(W)>0){const $=Number(Oe),R=Number(W);le.setProperties({voiRange:{lower:$-R/2,upper:$+R/2}})}else if(te)le.setProperties({voiRange:te});else{na(z);return}le.render(),Sn(z,le)})().catch(()=>{na(z)})},[na,Sn,J]),Uo=st.useCallback((z,ne,de=!0,le=!0)=>{if(de&&(Zr.current[z]=ne),ne.action==="reset"){na(z,le);return}if(ne.action==="autolevel"){Cc(z);return}const Q=ne;bs(z,Q.center,Q.width)},[na,bs,Cc]);st.useEffect(()=>{const z=()=>{const de=A.current;if(!de)return;const le=Ct.rows*Ct.cols;for(let Q=0;Q<le;Q++){if(sn[Q]!=="stack")continue;const he=Zr.current[Q];if(!he)continue;const ge=de.getViewport(`CT_${Q}`);if(!ge||typeof ge.getImageIds!="function")continue;const me=ge.getImageIds()||[];if(!me.length)continue;const N=typeof ge.getCurrentImageIdIndex=="function"?ge.getCurrentImageIdIndex():0,k=me[N]||me[0];k&&Di.current[Q]!==k&&(Di.current[Q]=k,Uo(Q,he,!1,!1))}},ne=window.setTimeout(z,0);return()=>window.clearTimeout(ne)},[Uo,ln,Ct,sn]),st.useEffect(()=>{const z=ne=>{var me,N;const de=ne.target;if(de){const k=(me=de.tagName)==null?void 0:me.toLowerCase(),te=de.getAttribute("contenteditable")==="true";if(k==="input"||k==="textarea"||k==="select"||te)return}if(ne.ctrlKey||ne.altKey||ne.metaKey||_e===null)return;const le=(N=ln[_e])==null?void 0:N.modality,Q=q7(le);if(ne.key==="0"){const k=Q.find(te=>te.action==="reset");k&&(Uo(_e,k),ne.preventDefault());return}if(!/^[1-9]$/.test(ne.key))return;const he=Number(ne.key)-1,ge=Q.filter(k=>k.action==="preset");he>=ge.length||(Uo(_e,ge[he]),ne.preventDefault())};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[_e,Uo,ln]);const Da=st.useCallback((z,ne)=>{const de=je[z]||[];if(de.length<=1)return;const le=Math.max(0,Math.min(de.length-1,ne)),Q=de[le];if(!Q||Q.imageIds.length===0)return;const he=A.current,ge=he==null?void 0:he.getViewport(`CT_${z}`);let me=0;if(ge&&typeof ge.getCurrentImageIdIndex=="function"){const k=(J[z]||[]).length,te=ge.getCurrentImageIdIndex(),ve=k>1?te/(k-1):0;me=Math.max(0,Math.min(Q.imageIds.length-1,Math.round(ve*Math.max(0,Q.imageIds.length-1))))}ue(N=>{const k=[...N];return k[z]=le,k}),ie(N=>{const k=[...N];return k[z]=Q.imageIds,k}),jn(Q.imageIds,{force:!0}),window.setTimeout(()=>{var k;const N=(k=A.current)==null?void 0:k.getViewport(`CT_${z}`);!N||typeof N.setImageIdIndex!="function"||(oa(N.element,{imageIndex:me}),N.render(),Sn(z,N))},25)},[je,jn,Sn,J]);st.useEffect(()=>{const z=[],ne=Ct.rows*Ct.cols;for(let de=0;de<ne;de++){if(!Pe[de]||sn[de]!=="stack")continue;const le=J[de]||[];if(le.length<2)continue;const Q=Math.max(1,Math.min(60,Math.round(Ee[de]||12))),he=Math.max(16,Math.round(1e3/Q)),ge=window.setInterval(()=>{var Ie,ke;const me=(Ie=A.current)==null?void 0:Ie.getViewport(`CT_${de}`);if(!me||typeof me.getCurrentImageIdIndex!="function"||typeof me.setImageIdIndex!="function")return;const k=(((ke=me.getImageIds)==null?void 0:ke.call(me))||le).length;if(k<2)return;const ve=(me.getCurrentImageIdIndex()+1)%k;oa(me.element,{imageIndex:ve}),me.render()},he);z.push(ge)}return()=>{z.forEach(de=>window.clearInterval(de))}},[Ee,Pe,Ct,J,sn]);const Sc=st.useCallback(()=>{const z=a.current;z&&(document.fullscreenElement===z?document.exitFullscreen():z.requestFullscreen?z.requestFullscreen():z.webkitRequestFullscreen?z.webkitRequestFullscreen():z.msRequestFullscreen&&z.msRequestFullscreen())},[]);st.useEffect(()=>{Gi(Array(Ct.rows*Ct.cols).fill({index:0,total:0,windowCenter:"",windowWidth:"",slicePosition:"",modality:"",orientation:"",resolution:"",spacing:"",focalPoint:""})),Wi(Array(Ct.rows*Ct.cols).fill(!1)),ft(Array(L).fill(!1))},[Ct]),st.useEffect(()=>{ii()},[Ii,ko,eo,ii]),st.useEffect(()=>{if(!No.some(Boolean))return;const z=ne=>{const de=document.querySelector(".preset-menu");de&&!de.contains(ne.target)&&Wi(le=>le.map(()=>!1))};return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[No]),st.useEffect(()=>{if(!ar)return;const z=ne=>{const de=_.current;de&&!de.contains(ne.target)&&(Qo(!1),O(!1))};return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},[ar]),st.useEffect(()=>{const z=ne=>{if(ne.button===3||ne.button===4)return ne.preventDefault(),!1};return window.addEventListener("mousedown",z,!0),window.addEventListener("mouseup",z,!0),window.addEventListener("auxclick",z,!0),()=>{window.removeEventListener("mousedown",z,!0),window.removeEventListener("mouseup",z,!0),window.removeEventListener("auxclick",z,!0)}},[]),st.useEffect(()=>{const z=a.current;if(!z)return;const ne=de=>{de.preventDefault()};return z.addEventListener("contextmenu",ne),()=>{z.removeEventListener("contextmenu",ne)}},[]),st.useEffect(()=>{if(!Fr)return;const z=jr(H);Ja(z)},[_e,Fr]),st.useEffect(()=>{oi.current&&(oi.current.setAttribute("webkitdirectory","true"),oi.current.setAttribute("directory","true"))},[]),st.useEffect(()=>(window.loadDicomStackFromWadouriList=async z=>{var he;if(!z||z.length===0)return;const ne=await Ei(z);await jn(ne,{force:!0});const de=await Bn(ne),le=((he=de[0])==null?void 0:he.imageIds)||ne;let Q;try{const ge=ne[0];if(ge&&ge.startsWith("wadouri:")){const me=zs(ge),k=await(await fetch(me)).arrayBuffer();Q=lr.parseDicom(new Uint8Array(k)).string("x0020000d")}}catch{}we(ge=>{const me=[...ge,{imageIds:ne,studyInstanceUID:Q,seriesGroups:de}];return ie(N=>{const k=[...N];return k[0]=le,k}),Fe(N=>{const k=[...N];return k[0]=me.length-1,k}),Xe(N=>{const k=[...N];return k[0]=de,k}),ue(N=>{const k=[...N];return k[0]=0,k}),jn(le),me})},()=>{window.loadDicomStackFromWadouriList=void 0}),[Bn,Ei,we,jn,Fe,ie]),st.useEffect(()=>{!Ur||!J.every(ne=>!ne||ne.length===0||ne.every(de=>!!ct("imagePlaneModule",de)))||ie(ne=>{let de=!1;const le=ne.map(Q=>{if(!Q||Q.length===0)return Q;const me=[...Q.map(N=>({imageId:N,sliceLoc:(()=>{const k=ct("imagePlaneModule",N);return k&&k.sliceLocation!==void 0?Number(k.sliceLocation):null})()}))].sort((N,k)=>N.sliceLoc!==null&&k.sliceLoc!==null?N.sliceLoc-k.sliceLoc:N.imageId.localeCompare(k.imageId)).map(N=>N.imageId);return JSON.stringify(me)!==JSON.stringify(Q)?(de=!0,me):Q});return de&&wn(!0),le})},[Ur,Se]);function Ja(z){if(!z)return;const ne=`CT_${_e}`;Fr?(z.setToolEnabled(pd.toolName),z.setToolConfiguration(pd.toolName,{sourceViewportId:ne})):z.setToolDisabled(pd.toolName)}function pl(){var ne,de,le;const z=A.current;if(z)for(let Q=0;Q<L;Q++){const he=z.getViewport(`CT_${Q}`);he&&((ne=he.resetCamera)==null||ne.call(he),(de=he.resetProperties)==null||de.call(he),(le=he.render)==null||le.call(he))}rr!=null&&rr.removeAllAnnotations&&rr.removeAllAnnotations()}function ml(){const z=A.current;if(z)for(let ne=0;ne<L;ne++){const de=`CT_${ne}`;try{z.getViewport(de)&&z.disableElement(de)}catch{}}for(let ne=0;ne<L;ne++){const de=Dr.current[ne];if(de){if(de._resizeObserver){try{de._resizeObserver.disconnect()}catch{}de._resizeObserver=void 0}de._cornerstoneEnabled=!1,de._lastViewportType=void 0,de._overlayListener=void 0,de.innerHTML=""}}rr!=null&&rr.removeAllAnnotations&&rr.removeAllAnnotations(),we([]),ie(Array(L).fill([])),Fe(Array(L).fill(0)),Xe(Array(L).fill(null).map(()=>[])),ue(Array(L).fill(0)),pe(Array(L).fill(!1)),ft(Array(L).fill(!1)),pi(Array(L).fill("stack")),Object.values(at.current).forEach(ne=>{if(typeof ne=="string"&&ne.startsWith("blob:"))try{URL.revokeObjectURL(ne)}catch{}}),at.current={},nt({}),ot.current={},wn(!1),Ve(0)}function vl(z,ne){var ge,me;if(console.log("Truncating stack from",z,"to",ne),console.log(Ft),Ct.rows!==1||Ct.cols!==1||Se.length!==1||!J[0]||J[0].length===0||Ft)return alert("Truncation is only allowed when a single stack is loaded in a single viewport (and the order has not been modified in the viewer)."),!1;const de=Se[0],le=de.imageIds;if(z<0||ne>=le.length||z>=ne)return alert("Invalid truncation bounds."),!1;const Q=le.slice(z,ne+1);we([{...de,imageIds:Q}]),ie([Q]),Fe([0]);const he=A.current;if(he){const N=he.getViewport("CT_0");N&&typeof N.setStack=="function"&&(N.setStack(Q),(ge=N.setImageIdIndex)==null||ge.call(N,0),(me=N.render)==null||me.call(N))}return!0}function yl(z=0){const ne=A.current;if(!ne)return null;const de=ne.getViewport(`CT_${z}`);return!de||typeof de.getCurrentImageIdIndex!="function"?null:de.getCurrentImageIdIndex()}st.useEffect(()=>{const z=t||"default";function ne(le,Q){const he=A.current;if(!he)return;const ge=he.getViewport(`CT_${le}`);if(!ge||typeof ge.getImageIds!="function")return;const N=ge.getImageIds().map(ve=>zs(ve)),k=zs(Q),te=N.indexOf(k);te!==-1&&typeof ge.setImageIdIndex=="function"&&(oa(ge.element,{imageIndex:te}),Sn(le,ge))}window[`getViewport_${z}`]=le=>{const Q=A.current;if(Q)return Q.getViewport(`CT_${le}`)},window[`getAllViewports_${z}`]=()=>{const le=A.current;return le?Array.from({length:L},(Q,he)=>le.getViewport(`CT_${he}`)).filter(Boolean):[]},window[`jumpToSliceByImageId_${z}`]=ne,window[`resetViewer_${z}`]=pl,window[`clearViewer_${z}`]=ml,window[`truncateStack_${z}`]=vl,window[`getCurrentStackPosition_${z}`]=yl,window[`loadAdditionalStack_${z}`]=async(le,Q)=>{var k,te;if(!Array.isArray(le)||le.length===0)return;const he=await Ei(le);await jn(he,{force:!0});const ge=await Bn(he),me=((k=ge[0])==null?void 0:k.imageIds)||he;let N=Q;if(!N&&((te=he[0])!=null&&te.startsWith("wadouri:")))try{const ve=zs(he[0]),ke=await(await fetch(ve)).arrayBuffer();N=lr.parseDicom(new Uint8Array(ke)).string("x0020000d")}catch{}we(ve=>[...ve,{imageIds:he,studyInstanceUID:N,seriesGroups:ge}]),ie(ve=>{const Ie=[...ve],ke=Ie.findIndex(be=>!be||be.length===0);return ke!==-1&&(Ie[ke]=me,Xe(be=>{const Oe=[...be];return Oe[ke]=ge,Oe}),ue(be=>{const Oe=[...be];return Oe[ke]=0,Oe})),Ie}),jn(me)},window[`loadExternalStack_${z}`]=async(le,Q)=>{!Array.isArray(le)||le.length===0||await Ea(_e??0,le,Q||"Series","center")},window[`loadExternalStackNewViewport_${z}`]=async(le,Q)=>{if(!Array.isArray(le)||le.length===0)return;await Ea(_e??0,le,Q||"Series","right")},window[`exportViewerState_${z}`]=()=>{var be;const le=Ct.rows*Ct.cols,Q=sn.slice(0,le),he=Re.slice(0,le),ge=Se.map(Oe=>({i:Oe.imageIds,u:Oe.studyInstanceUID,g:Oe.seriesGroups}));console.log("Exporting viewer state with",le,"active viewports"),console.log("modes",Q);const me=A.current,N=[],k=[],te=[],ve=[],Ie=[];for(let Oe=0;Oe<le;Oe++){let W=null,$=null,R=null,V=null,Y=null;if(console.log("Exporting state for viewport",Oe),me){console.log("Rendering engine found, exporting state for viewport",Oe);const ye=`CT_${Oe}`,xe=me.getViewport(ye);if(xe){if(typeof xe.getProperties=="function"){const{voiRange:Ce,invert:Te,interpolationType:Me,VOILUTFunction:Ae,colormap:qe}=xe.getProperties();W={voiRange:Ce,invert:Te,interpolationType:Me,VOILUTFunction:Ae,colormap:qe}}typeof xe.getCurrentImageIdIndex=="function"&&($=xe.getCurrentImageIdIndex()),typeof xe.getCamera=="function"&&(R=xe.getCamera()),console.log("viewport",ye,"properties",W),Q[Oe]==="volume"&&(console.log("Getting orientation for viewport",Oe),console.log("viewport.viewportProperties",xe.viewportProperties),V=((be=xe.viewportProperties)==null?void 0:be.orientation)||null,typeof xe.getSliceIndex=="function"&&(Y=xe.getSliceIndex()))}}N.push(W),k.push($),te.push(R),ve.push(V),Ie.push(Y)}return JSON.stringify({grid:Ct,modes:Q,stacks:ge,stackIdx:he,stackPos:k,props:N,cam:te,orientations:ve,volumeSliceIndices:Ie})},window[`importViewerState_${z}`]=le=>{try{F.current=!0;const Q=typeof le=="string"?JSON.parse(le):le;if(Q.grid&&Zt(Q.grid),Q.modes&&pi(Q.modes),Q.stacks&&we(Q.stacks.map(N=>({imageIds:N.i,studyInstanceUID:N.u,seriesGroups:Array.isArray(N.g)?N.g:void 0}))),Q.stackIdx&&Q.stacks){const N=Q.stackIdx.map(k=>{var te;return((te=Q.stacks[k])==null?void 0:te.i)||[]});ie(N),Fe(Q.stackIdx),Xe(()=>{const k=Array(L).fill(null).map(()=>[]);for(let te=0;te<Math.min(L,Q.stackIdx.length);te++){const ve=Q.stackIdx[te],Ie=Q.stacks[ve];k[te]=Array.isArray(Ie==null?void 0:Ie.g)?Ie.g:[]}return k}),ue(Array(L).fill(0))}const he=30;let ge=0;async function me(){var Ie,ke,be,Oe,W,$,R,V,Y,ye,xe;const N=A.current;if(!N){F.current=!1;return}const k=((Ie=Q.grid)==null?void 0:Ie.rows)*((ke=Q.grid)==null?void 0:ke.cols)||1;let te=!0;for(let Ce=0;Ce<k;Ce++){console.log("Checking viewport",Ce);const Te=N.getViewport(`CT_${Ce}`);if(!Te){te=!1;break}const Me=(be=Q.stackIdx)==null?void 0:be[Ce],Ae=(Oe=Q.stacks)==null?void 0:Oe[Me],qe=(Ae==null?void 0:Ae.i)||[];if(qe.length)try{const rt=((W=Te.getImageIds)==null?void 0:W.call(Te))||[];if(rt.length!==qe.length||!rt.every((mt,ht)=>mt===qe[ht])){console.warn(`Viewport ${Ce}: importedImageIds do not match viewportImageIds`,{importedImageIds:qe,viewportImageIds:rt}),te=!1;break}}catch{te=!1}}if(!te&&ge<he){ge++,setTimeout(()=>{me()},500);return}for(let Ce=0;Ce<k;Ce++){console.log("Setting stack/volume for viewport",Ce);const Te=N.getViewport(`CT_${Ce}`);if(!Te)continue;const Me=($=Q.stackIdx)==null?void 0:$[Ce],Ae=(R=Q.stacks)==null?void 0:R[Me],qe=(Ae==null?void 0:Ae.i)||[];if(qe.length)if(console.log("mode",(V=Q.modes)==null?void 0:V[Ce]),((Y=Q.modes)==null?void 0:Y[Ce])==="volume"){try{const rt=`myVolumeId_${Ce}`;(await p1(rt,{imageIds:qe})).load(),Te.setVolumes([{volumeId:rt}]),Te.render()}catch(rt){console.warn("Failed to create/load volume for viewport",Ce,rt)}if(Q.orientations&&Q.orientations[Ce]&&typeof Te.setOrientation=="function")try{Te.setOrientation(Q.orientations[Ce]),Te.render()}catch{}Q.volumeSliceIndices&&setTimeout(()=>{try{oa(Te.element,{imageIndex:Q.volumeSliceIndices[Ce]})}catch{}},100)}else{try{Te.setStack&&(Te.setStack(qe),Te.render())}catch(rt){console.warn("Failed to set stack for viewport",Ce,rt)}if(Q.stackPos&&typeof Q.stackPos[Ce]=="number"&&typeof Te.setImageIdIndex=="function")try{pn&&oa?oa(Te.element,{imageIndex:Q.stackPos[Ce]}):Te.setImageIdIndex(Q.stackPos[Ce])}catch{}}}const ve=1500;console.log(`Waiting ${ve}ms before applying properties/camera to viewports`),await new Promise(Ce=>setTimeout(Ce,ve));for(let Ce=0;Ce<k;Ce++){console.log("Applying props/camera for viewport",Ce);const Te=N.getViewport(`CT_${Ce}`);if(!Te)continue;const Me=(ye=Q.stackIdx)==null?void 0:ye[Ce],Ae=(xe=Q.stacks)==null?void 0:xe[Me];if(((Ae==null?void 0:Ae.i)||[]).length){if(Q.props&&Q.props[Ce]&&typeof Te.setProperties=="function"){console.log("Restoring properties for viewport",Ce,Q.props[Ce]);const rt={...Q.props[Ce]};if(rt.colormap!==void 0&&rt.colormap!==null){const mt=rt.colormap;if(typeof mt!="string")if(typeof mt=="object"){const ht={};typeof mt.name=="string"&&(ht.name=mt.name),mt.opacity!==void 0&&typeof mt.opacity=="number"&&(ht.opacity=mt.opacity),Object.keys(ht).length===0?delete rt.colormap:rt.colormap=ht}else delete rt.colormap}try{Te.setProperties(rt),Te.render()}catch(mt){console.warn("viewport.setProperties failed, retrying without colormap",mt);try{const ht={...rt};delete ht.colormap,Te.setProperties(ht),Te.render()}catch(ht){console.error("Retrying viewport.setProperties without colormap also failed",ht)}}}if(Q.cam&&Q.cam[Ce]&&typeof Te.setCamera=="function")try{Te.setCamera(Q.cam[Ce]),Te.render()}catch{}}}F.current=!1}setTimeout(()=>{me()},100)}catch(Q){F.current=!1,alert("Failed to import viewer state: "+Q)}},window[`exportAnnotations_${z}`]=()=>{try{let le=rr.getAllAnnotations();if(console.log("Exporting annotations:",le),Array.isArray(le)){const Q=[pf.toolName,Nh.toolName,mf.toolName,au.toolName,Ad.toolName,gf.toolName,sl.toolName,su.toolName,Rh.toolName];le=le.filter(he=>Q.includes(he.metadata.toolName))}else return"{}";return JSON.stringify(le,null,2)}catch(le){return alert("Failed to export annotations: "+le),"{}"}},window.__pendingImportAnnotations=window.__pendingImportAnnotations||{};const de=le=>{try{const Q=window.__pendingImportAnnotations&&window.__pendingImportAnnotations[le];if(!Q||!Q.length)return;const he=rr;if(!he||typeof he.addAnnotation!="function")return;for(;(window.__pendingImportAnnotations[le]||[]).length;){const ge=(window.__pendingImportAnnotations[le]||[]).shift();ge&&Array.isArray(ge)&&ge.forEach(me=>{try{he.addAnnotation(me,me.annotationUID)}catch(N){console.error("Failed to add queued annotation",N,me)}})}A.current&&A.current.render()}catch(Q){console.error("Error flushing pending annotations:",Q)}};return window[`importAnnotations_${z}`]=le=>{try{const Q=typeof le=="string"?JSON.parse(le):le,he=rr;if(!he||typeof he.addAnnotation!="function"){window.__pendingImportAnnotations[z]=window.__pendingImportAnnotations[z]||[],window.__pendingImportAnnotations[z].push(Q),console.warn("importAnnotations: annotation state not ready, queued import",z),setTimeout(()=>de(z),500);return}if(he.removeAllAnnotations)try{he.removeAllAnnotations()}catch(ge){console.warn("removeAllAnnotations failed",ge)}Array.isArray(Q)&&Q.forEach(ge=>{try{he.addAnnotation(ge,ge.annotationUID)}catch(me){console.error("Failed to add annotation",me,ge)}}),A.current&&A.current.render()}catch(Q){console.error("Failed to import annotations:",Q,{apiKey:z,cornerstoneTools:!!Dz,renderingEngine:!!A.current});try{alert("Failed to import annotations: "+Q)}catch{}}try{de(z)}catch{}},window[`importLegacyAnnotations_${z}`]=le=>{rr.removeAllAnnotations&&rr.removeAllAnnotations();let Q;try{Q=typeof le=="string"?JSON.parse(le):le}catch{alert("Invalid legacy annotation JSON");return}const he={ArrowAnnotate:"ArrowAnnotate"};Object.entries(Q).forEach(([ge,me])=>{console.log("Importing legacy annotations for imageId:",ge),Object.entries(me).forEach(([N,k])=>{const te=he[N]||N;k.data&&Array.isArray(k.data)&&k.data.forEach(ve=>{const Ie=H7(ge,{x:ve.handles.start.y,y:ve.handles.start.x}),ke=H7(ge,{x:ve.handles.end.y,y:ve.handles.end.x});console.log("Importing legacy annotation:"),console.log(" Image ID:",ge),console.log(" Start World:",Ie),console.log(" End World:",ke);const be=ct("imagePlaneModule",ge);console.log(A4);let Oe=ct("frameOfReferenceUID",ge);!Oe&&be&&be.frameOfReferenceUID&&(Oe=be.frameOfReferenceUID);const W=be!=null&&be.rowCosines&&(be!=null&&be.columnCosines)?[be.rowCosines[1]*be.columnCosines[2]-be.rowCosines[2]*be.columnCosines[1],be.rowCosines[2]*be.columnCosines[0]-be.rowCosines[0]*be.columnCosines[2],be.rowCosines[0]*be.columnCosines[1]-be.rowCosines[1]*be.columnCosines[0]]:void 0;Array.isArray(W)&&W.length,typeof ve.rotation=="number"&&ve.rotation;const $={annotationUID:ve.uuid,metadata:{toolName:te,referencedImageId:ge,FrameOfReferenceUID:Oe,viewPlaneNormal:W},data:{handles:{points:[Ie,ke],textBox:ve.handles.textBox},text:ve.text||""},visibility:ve.visible!==!1,active:ve.active||!1};rr.addAnnotation($,$.annotationUID)})})}),A.current&&A.current.render()},window[`importLegacyViewport_${z}`]=le=>{let Q;try{Q=typeof le=="string"?JSON.parse(le):le}catch{alert("Invalid legacy viewport JSON");return}const he=A.current;if(!he)return;const ge=`CT_${_e??0}`,me=he.getViewport(ge);if(!me)return;const N={};if(Q.voi&&(N.voiRange={lower:Q.voi.windowCenter-Q.voi.windowWidth/2,upper:Q.voi.windowCenter+Q.voi.windowWidth/2}),typeof Q.invert=="boolean"&&(N.invert=Q.invert),typeof Q.pixelReplication=="boolean"&&(N.interpolationType=Q.pixelReplication?0:1),typeof Q.hflip=="boolean"&&(N.hflip=Q.hflip),typeof Q.vflip=="boolean"&&(N.vflip=Q.vflip),typeof me.setProperties=="function"&&me.setProperties(N),Q.translation||Q.scale){const k=me.getCamera?me.getCamera():{};Q.translation&&(k.translation={...k.translation,...Q.translation}),Q.scale&&(k.parallelScale=200/Q.scale),console.log("Applying legacy camera properties:",k),typeof me.setCamera=="function"&&me.setCamera(k)}typeof Q.rotation=="number"&&me.setRotation(Q.rotation),me.render(),Sn(_e??0,me)},()=>{window[`exportViewerState_${z}`]=void 0,window[`importViewerState_${z}`]=void 0,window[`exportAnnotations_${z}`]=void 0,window[`importAnnotations_${z}`]=void 0,window[`importLegacyAnnotations_${z}`]=void 0,window[`importLegacyViewport_${z}`]=void 0,window[`jumpToSliceByImageId_${z}`]=void 0,window[`resetViewer_${z}`]=void 0,window[`clearViewer_${z}`]=void 0,window[`truncateStack_${z}`]=void 0,window[`getCurrentStackPosition_${z}`]=void 0,window[`loadAdditionalStack_${z}`]=void 0,window[`loadExternalStack_${z}`]=void 0,window[`loadExternalStackNewViewport_${z}`]=void 0,window[`getViewport_${z}`]=void 0,window[`getAllViewports_${z}`]=void 0}},[Ct,sn,Re,Se,J,Zt,pi,Fe,we,ie,we,ie,jn]),st.useEffect(()=>{const z=a.current;if(!z)return;function ne(de){if(console.log("Handling arrow key navigation",de.key),console.log("activeViewport",_e),_e===null)return;const le=A.current;if(!le)return;const Q=le.getViewport(`CT_${_e}`);if(Q){if(console.log(Q),sn[_e]==="stack"){if(typeof Q.getCurrentImageIdIndex!="function"||typeof Q.setImageIdIndex!="function")return;const he=J[_e];if(!he||he.length===0)return;de.key==="ArrowUp"||de.key==="ArrowRight"?(oc(Q,{delta:-1}),de.preventDefault()):(de.key==="ArrowDown"||de.key==="ArrowLeft")&&(oc(Q,{delta:1}),de.preventDefault())}sn[_e]==="volume"&&typeof Q.getSliceIndex=="function"&&typeof Q.getNumberOfSlices=="function"&&Q.getNumberOfSlices()>1&&(de.key==="ArrowUp"||de.key==="ArrowRight"?(oc(Q,{delta:-1}),de.preventDefault()):(de.key==="ArrowDown"||de.key==="ArrowLeft")&&(oc(Q,{delta:1}),de.preventDefault()))}}return z.addEventListener("keydown",ne),()=>{z.removeEventListener("keydown",ne)}},[_e,sn,J,Sn]);const wl=_e!==null?Re[_e]:0,Ds=Se[wl];Ds==null||Ds.studyInstanceUID;const[xl,Is]=st.useState(()=>Array(L).fill(null)),Cl=Ct.rows*Ct.cols,Os=[];for(let z=0;z<Cl;z++){const ne=z<Ct.rows*Ct.cols,de=(q==null?void 0:q.viewportIdx)===z?q.zone:null,le=de?gi(de):null;Os.push(ze.jsxs("div",{ref:Q=>Dr.current[z]=Q,style:{flex:1,border:ne?"1px solid #222":"none",background:"#000",minWidth:0,minHeight:0,position:"relative",overflow:"hidden",flexDirection:"column",gridRow:Math.floor(z/Ct.cols)+1,gridColumn:z%Ct.cols+1,height:"100%",boxShadow:_e===z?"0 0 0 4px #1976d2, 0 0 16px 4px #1976d2cc":void 0,zIndex:_e===z?10:1},onClick:()=>{Ve(z),Qo(!1)},onDoubleClick:()=>Oi(z),onDragEnter:Q=>{const he=Q.dataTransfer.types,ge=he.includes("text/stack-idx"),me=he.includes("text/dv3d-imageids");if(!ge&&!me)return;Q.preventDefault(),me&&M(!0);const N=Ca(Q);K({viewportIdx:z,zone:N})},onDragOver:Q=>{const he=Q.dataTransfer.types,ge=he.includes("text/stack-idx"),me=he.includes("text/dv3d-imageids");if(!ge&&!me)return;Q.preventDefault();const N=Ca(Q),k=gi(N);K({viewportIdx:z,zone:N}),Q.dataTransfer.dropEffect=k===N?"copy":"move"},onDragLeave:Q=>{if((q==null?void 0:q.viewportIdx)!==z)return;const he=Q.relatedTarget;he&&Q.currentTarget.contains(he)||K(null)},onDrop:Q=>{Q.preventDefault();const he=Q.dataTransfer.getData("text/dv3d-imageids");if(he){const N=Q.dataTransfer.getData("text/dv3d-stack-name")||"Series";try{const k=JSON.parse(he),te=Ca(Q);Ea(z,k,N,te).catch(ve=>{console.error("Failed to apply external drop:",ve)})}catch(k){console.error("Invalid text/dv3d-imageids payload:",k)}K(null),M(!1);return}const ge=Q.dataTransfer.getData("text/stack-idx"),me=parseInt(ge,10);if(!isNaN(me)){const N=Ca(Q);ba(z,me,N).catch(k=>{console.error("Failed to apply dropped stack:",k)})}K(null),Ne(null),M(!1)},children:[(Ge!==null||j)&&de&&ze.jsx("div",{style:{position:"absolute",inset:0,zIndex:19,pointerEvents:"none",background:"rgba(0,0,0,0.08)"},children:ze.jsx("div",{style:{position:"absolute",left:le==="left"?0:le==="right"?"50%":"20%",top:le==="top"?0:le==="bottom"?"50%":"20%",width:le==="left"||le==="right"?"50%":"60%",height:le==="top"||le==="bottom"?"50%":"60%",border:"2px solid #90caf9",boxShadow:"0 0 0 9999px rgba(17, 29, 45, 0.22)",background:"rgba(25, 118, 210, 0.28)",borderRadius:6,display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",fontSize:12,fontWeight:700,textTransform:"uppercase",letterSpacing:.4},children:le==="center"?"Load Here":`Split ${le}`})}),ze.jsx("button",{style:{position:"absolute",top:8,left:8,zIndex:20,background:"#333",color:"#fff",border:"none",borderRadius:"4px",padding:"4px 8px",cursor:"pointer",fontSize:"12px",opacity:.85},onClick:()=>{pi(Q=>{const he=[...Q];return he[z]=Q[z]==="stack"?"volume":"stack",he})},children:sn[z]==="stack"?"Volume":"Stack"}),sn[z]==="volume"&&ze.jsxs("div",{style:{position:"absolute",top:8,left:70,zIndex:21,display:"flex",gap:"6px",background:"rgba(34,34,34,0.85)",borderRadius:"4px",padding:"2px 6px",alignItems:"center"},children:[ze.jsx("button",{style:{background:"#444",color:"#fff",border:"none",borderRadius:"3px",padding:"2px 8px",cursor:"pointer",fontSize:"12px",marginRight:"2px"},onClick:()=>{const Q=A.current,he=Q==null?void 0:Q.getViewport(`CT_${z}`);he&&he.setOrientation&&(he.setOrientation("axial"),he.render())},children:"Axial"}),ze.jsx("button",{style:{background:"#444",color:"#fff",border:"none",borderRadius:"3px",padding:"2px 8px",cursor:"pointer",fontSize:"12px",marginRight:"2px"},onClick:()=>{const Q=A.current,he=Q==null?void 0:Q.getViewport(`CT_${z}`);he&&he.setOrientation&&(he.setOrientation("sagittal"),he.render())},children:"Sagittal"}),ze.jsx("button",{style:{background:"#444",color:"#fff",border:"none",borderRadius:"3px",padding:"2px 8px",cursor:"pointer",fontSize:"12px"},onClick:()=>{const Q=A.current,he=Q==null?void 0:Q.getViewport(`CT_${z}`);he&&he.setOrientation&&(he.setOrientation("coronal"),he.render())},children:"Coronal"})]}),ze.jsxs("button",{style:{position:"absolute",top:40,left:8,zIndex:20,background:"#111",color:"#fff",border:"none",borderRadius:"4px",padding:"4px 8px",cursor:"pointer",fontSize:"13px",opacity:.85,marginTop:"4px",display:"flex",alignItems:"center",gap:"6px"},title:"Toggle Fullscreen",onClick:Q=>{Q.stopPropagation();const he=Dr.current[z];document.fullscreenElement===he?document.exitFullscreen():he!=null&&he.requestFullscreen?he.requestFullscreen():he!=null&&he.webkitRequestFullscreen?he.webkitRequestFullscreen():he!=null&&he.msRequestFullscreen&&he.msRequestFullscreen()},onMouseEnter:()=>b(z),onMouseLeave:()=>b(null),children:[ze.jsx("span",{style:{fontSize:"18px",lineHeight:1},children:"⛶"}),E===z&&ze.jsx("span",{style:{marginLeft:6},children:document.fullscreenElement===Dr.current[z]?"Exit Fullscreen":"Fullscreen"})]}),sn[z]==="stack"&&G&&(()=>{var ke;const Q=J[z],ge=(rr.getAllAnnotations()||[]).filter(be=>be.metadata&&be.metadata.referencedImageId&&Q.includes(be.metadata.referencedImageId)&&be.metadata.toolName!==La.toolName);if(!ge.length)return null;const me=A.current,N=me==null?void 0:me.getViewport(`CT_${z}`),k=((ke=N==null?void 0:N.getCurrentImageIdIndex)==null?void 0:ke.call(N))??0,te=Q[k],ve=ge.filter(be=>be.metadata.referencedImageId===te),Ie=xl[z];return ze.jsxs("div",{style:{position:"absolute",left:"50%",bottom:60,transform:"translateX(-50%)",zIndex:30,display:"flex",gap:4,pointerEvents:"auto",alignItems:"center"},children:[ze.jsx("button",{style:{background:"rgba(30,30,30,0.7)",color:"#fff",border:"none",borderRadius:"50%",width:28,height:28,fontSize:"16px",fontWeight:"bold",cursor:"pointer",opacity:.7,display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 1px 4px rgba(0,0,0,0.18)",transition:"opacity 0.2s"},title:"Previous Annotation","aria-label":"Previous Annotation",onClick:()=>{const be=A.current,Oe=be==null?void 0:be.getViewport(`CT_${z}`);if(!Oe||typeof Oe.getCurrentImageIdIndex!="function")return;const W=Oe.getCurrentImageIdIndex(),$=Q7(W,Q,ge,-1);if($!==null&&typeof Oe.setImageIdIndex=="function"){oa(Oe.element,{imageIndex:$}),Sn(z,Oe);const R=Q[$],V=ge.filter(Y=>Y.metadata.referencedImageId===R);Fo(z,V.length>0?V[0].annotationUID:null)}},children:ze.jsx("span",{"aria-hidden":"true",children:"◀"})}),ze.jsx("button",{style:{background:"rgba(30,30,30,0.7)",color:"#fff",border:"none",borderRadius:"50%",width:28,height:28,fontSize:"16px",fontWeight:"bold",cursor:"pointer",opacity:.7,display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 1px 4px rgba(0,0,0,0.18)",transition:"opacity 0.2s"},title:"Next Annotation","aria-label":"Next Annotation",onClick:()=>{const be=A.current,Oe=be==null?void 0:be.getViewport(`CT_${z}`);if(!Oe||typeof Oe.getCurrentImageIdIndex!="function")return;const W=Oe.getCurrentImageIdIndex(),$=Q7(W,Q,ge,1);if($!==null&&typeof Oe.setImageIdIndex=="function"){oa(Oe.element,{imageIndex:$}),Sn(z,Oe);const R=Q[$],V=ge.filter(Y=>Y.metadata.referencedImageId===R);Fo(z,V.length>0?V[0].annotationUID:null)}},children:ze.jsx("span",{"aria-hidden":"true",children:"▶"})}),ve.length>0&&ze.jsx("div",{style:{display:"flex",gap:2,alignItems:"center"},children:ve.map(be=>ze.jsxs("div",{style:{display:"flex",alignItems:"center",background:Ie===be.annotationUID?"rgb(4, 225, 0)":"#444",color:Ie===be.annotationUID?"#222":"#fff",borderRadius:"4px",padding:"2px 6px",marginRight:2,cursor:"pointer",border:Ie===be.annotationUID?"2px solid #1976d2":"none",fontWeight:Ie===be.annotationUID?"bold":"normal"},onClick:()=>Fo(z,be.annotationUID),children:[ze.jsxs("span",{style:{marginRight:4},title:be.metadata.toolName||"Annotation",children:[Ie===be.annotationUID?"★ ":"",ze.jsx("span",{style:{fontSize:14,lineHeight:1},children:o8e(be.metadata.toolName)})]}),ze.jsx("button",{style:{background:"transparent",color:"#f44336",border:"1px solid #f44336",borderRadius:3,width:16,height:16,fontSize:10,lineHeight:1,cursor:"pointer",marginLeft:4,display:"flex",alignItems:"center",justifyContent:"center",opacity:.95,padding:0},title:"Delete this annotation","aria-label":"Delete annotation",onClick:Oe=>{Oe.stopPropagation(),yr(z,be.annotationUID,ve)},children:ze.jsx("span",{"aria-hidden":"true",children:"✖"})})]},be.annotationUID))})]})})(),ze.jsx("div",{style:{position:"absolute",left:8,bottom:8,background:"rgba(0,0,0,0.7)",color:"#fff",padding:"6px 12px",borderRadius:"4px",fontSize:"14px",zIndex:10,pointerEvents:"none",minWidth:"120px",userSelect:"none"},children:sn[z]==="stack"?ze.jsxs(ze.Fragment,{children:[ze.jsxs("div",{children:["Image: ",(Ms=ln[z])==null?void 0:Ms.index," / ",(Tc=ln[z])==null?void 0:Tc.total]}),ze.jsxs("div",{children:["WC: ",(Za=ln[z])==null?void 0:Za.windowCenter," WW: ",(Ps=ln[z])==null?void 0:Ps.windowWidth]}),ee&&ze.jsxs(ze.Fragment,{children:[ze.jsxs("div",{children:["Ori: ",((Rs=ln[z])==null?void 0:Rs.orientation)||"N/A"]}),((Qa=ln[z])==null?void 0:Qa.resolution)&&ze.jsxs("div",{children:["Res: ",(_c=ln[z])==null?void 0:_c.resolution]}),((Ls=ln[z])==null?void 0:Ls.spacing)&&ze.jsxs("div",{children:["Spacing: ",(Ec=ln[z])==null?void 0:Ec.spacing]}),((As=ln[z])==null?void 0:As.focalPoint)&&ze.jsxs("div",{children:["Pos: ",(bc=ln[z])==null?void 0:bc.focalPoint]})]})]}):ze.jsxs("div",{children:["Slice: ",(Dc=ln[z])==null?void 0:Dc.index," / ",(Ic=ln[z])==null?void 0:Ic.total,((Oc=ln[z])==null?void 0:Oc.slicePosition)&&ze.jsxs("span",{children:[" (",(es=ln[z])==null?void 0:es.slicePosition,")"]}),ze.jsx("br",{}),"WC: ",(ts=ln[z])==null?void 0:ts.windowCenter," WW: ",(vo=ln[z])==null?void 0:vo.windowWidth,ee&&ze.jsxs(ze.Fragment,{children:[ze.jsx("br",{}),"Ori: ",((Bo=ln[z])==null?void 0:Bo.orientation)||"N/A",((Hi=ln[z])==null?void 0:Hi.resolution)&&ze.jsxs(ze.Fragment,{children:[ze.jsx("br",{}),"Res: ",(Ns=ln[z])==null?void 0:Ns.resolution]}),((ks=ln[z])==null?void 0:ks.spacing)&&ze.jsxs(ze.Fragment,{children:[ze.jsx("br",{}),"Spacing: ",(ns=ln[z])==null?void 0:ns.spacing]}),((Vs=ln[z])==null?void 0:Vs.focalPoint)&&ze.jsxs(ze.Fragment,{children:[ze.jsx("br",{}),"Pos: ",(Ia=ln[z])==null?void 0:Ia.focalPoint]})]})]})}),ze.jsxs("div",{style:{position:"absolute",right:8,bottom:8,zIndex:110,pointerEvents:"auto",display:"flex",alignItems:"flex-end",gap:6},children:[ze.jsx("button",{style:{background:fe[z]?"rgba(30,120,200,0.95)":"rgba(0,0,0,0.7)",color:"#fff",border:"1px solid rgba(255,255,255,0.2)",borderRadius:"4px",fontSize:"12px",fontWeight:700,padding:"6px 9px",cursor:"pointer",minHeight:30},title:fe[z]?"Hide cine controls":"Show cine controls",onClick:Q=>{Q.stopPropagation(),ft(he=>{const ge=[...he],me=!ge[z];return ge[z]=me,me||pe(N=>{const k=[...N];return k[z]=!1,k}),ge})},children:"Cine"}),ze.jsxs("div",{className:"preset-menu",style:{background:"rgba(0,0,0,0.7)",color:"#fff",borderRadius:"4px",fontSize:"14px",minWidth:"120px",overflow:"hidden",cursor:"pointer",position:"relative",boxShadow:No[z]?"0 2px 8px rgba(0,0,0,0.3)":void 0,pointerEvents:"auto"},onClick:Q=>Q.stopPropagation(),children:[ze.jsxs("div",{style:{padding:"6px 12px",fontWeight:"bold",userSelect:"none"},onClick:Q=>{Q.stopPropagation(),Wi(he=>{const ge=[...he];return ge[z]=!ge[z],ge})},children:["Presets (",((Fs=ln[z])==null?void 0:Fs.modality)||"Unknown",")",ze.jsx("span",{style:{float:"right",fontWeight:"normal"},children:No[z]?"▲":"▼"})]}),No[z]&&ze.jsx("div",{className:"preset-menu-content",style:{background:"rgba(0,0,0,0.95)",borderRadius:"0 0 4px 4px",padding:"6px 0 6px 0",display:"flex",flexDirection:"column",zIndex:111,pointerEvents:"auto"},onClick:Q=>Q.stopPropagation(),children:(()=>{var ge;const Q=q7((ge=ln[z])==null?void 0:ge.modality);let he=0;return Q.map(me=>{let N="";return me.action==="reset"?N="0":me.action==="preset"&&(he+=1,N=String(he)),ze.jsxs("button",{title:N?`Shortcut: ${N}`:void 0,style:{display:"block",width:"100%",margin:"2px 0",background:me.action==="preset"?"#333":"#444",color:"#fff",border:"none",borderRadius:"3px",cursor:"pointer",padding:me.action==="preset"?"4px 0":"6px 0",fontSize:"13px",opacity:.9,fontWeight:me.action==="preset"?"normal":"600"},onClick:k=>{k.stopPropagation(),Uo(z,me),Wi(te=>{const ve=[...te];return ve[z]=!1,ve})},children:[me.name,N?` (${N})`:""]},me.name)})})()})]})]}),sn[z]==="stack"&&(fe[z]||(je[z]||[]).length>1)&&ze.jsxs("div",{style:{position:"absolute",left:"50%",bottom:8,transform:"translateX(-50%)",zIndex:36,background:"rgba(15,15,15,0.82)",border:"1px solid rgba(255,255,255,0.18)",borderRadius:8,padding:"6px 10px",display:"flex",alignItems:"center",gap:8,pointerEvents:"auto",minWidth:200,maxWidth:"72%"},onClick:Q=>Q.stopPropagation(),children:[fe[z]&&((oe=ln[z])==null?void 0:oe.total)>1&&ze.jsxs(ze.Fragment,{children:[ze.jsx("button",{style:{background:Pe[z]?"#d32f2f":"#2e7d32",color:"#fff",border:"none",borderRadius:4,fontSize:12,padding:"4px 8px",cursor:"pointer"},title:Pe[z]?"Pause cine":"Play cine",onClick:()=>{pe(Q=>{const he=[...Q];return he[z]=!he[z],he})},children:Pe[z]?"Pause":"Play"}),ze.jsxs("label",{style:{color:"#ddd",fontSize:11,display:"flex",alignItems:"center",gap:4},children:["FPS",ze.jsx("input",{type:"range",min:1,max:30,step:1,value:Math.max(1,Math.min(30,Math.round(Ee[z]||12))),onChange:Q=>{const he=Number(Q.target.value);Qe(ge=>{const me=[...ge];return me[z]=he,me})}}),ze.jsx("span",{style:{minWidth:22,textAlign:"right"},children:Math.round(Ee[z]||12)})]})]}),(je[z]||[]).length>1&&ze.jsxs(ze.Fragment,{children:[ze.jsx("span",{style:{color:"#fff",fontSize:12,whiteSpace:"nowrap"},children:"Series"}),ze.jsx("input",{type:"range",min:0,max:Math.max(0,(je[z]||[]).length-1),step:1,value:Math.max(0,Math.min((je[z]||[]).length-1,se[z]||0)),onChange:Q=>{Da(z,Number(Q.target.value))},style:{width:140}}),ze.jsx("span",{style:{color:"#e0e0e0",fontSize:11,maxWidth:180,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:((De=(ae=je[z])==null?void 0:ae[se[z]||0])==null?void 0:De.label)||"",children:((tt=(He=je[z])==null?void 0:He[se[z]||0])==null?void 0:tt.label)||"Series"})]})]}),sn[z]==="stack"&&J[z]&&ze.jsx("div",{style:{position:"absolute",top:"10%",right:8,width:"14px",height:"80%",maxHeight:"100%",minHeight:0,zIndex:35,display:J[z].length>0?"flex":"none",alignItems:"flex-start",justifyContent:"center",pointerEvents:"auto",flexDirection:"column",padding:0},children:(()=>{const Q=J[z]||[],he=Q.length;if(he===0)return null;const ge=A.current,me=ge==null?void 0:ge.getViewport(`CT_${z}`),N=me&&typeof me.getCurrentImageIdIndex=="function"?me.getCurrentImageIdIndex():-1,k=new Set(Ss[z]||[]),te=Q.map(Oe=>Oe.startsWith("external:")?!0:!!ct("imagePlaneModule",Oe)||!!ct("generalSeriesModule",Oe)),ve=te.reduce((Oe,W)=>Oe+(W?1:0),0),Ie=Q.reduce((Oe,W,$)=>Oe+(k.has($)?1:0),0),ke=Math.min(he,180),be=Array.from({length:ke},()=>({loaded:!1,viewed:!1,current:!1}));for(let Oe=0;Oe<he;Oe++){const W=he===1?0:Math.min(ke-1,Math.floor(Oe/(he-1)*(ke-1)));te[Oe]&&(be[W].loaded=!0),k.has(Oe)&&(be[W].viewed=!0),Oe===N&&(be[W].current=!0)}return ze.jsxs("div",{style:{width:"10px",height:"100%",maxHeight:"100%",minHeight:0,borderRadius:"6px",background:"#191919",position:"relative",display:"flex",flexDirection:"column",justifyContent:"flex-start",boxShadow:"0 0 8px #2196f3cc",overflow:"hidden",cursor:"pointer"},title:`Loaded ${ve}/${he} • Viewed ${Ie}/${he}`,onClick:Oe=>{var xe;const $=Oe.currentTarget.getBoundingClientRect(),R=Math.min($.height,Math.max(0,Oe.clientY-$.top)),V=$.height>0?R/$.height:0,Y=Math.min(he-1,Math.max(0,Math.round(V*(he-1)))),ye=(xe=A.current)==null?void 0:xe.getViewport(`CT_${z}`);ye&&typeof ye.setImageIdIndex=="function"&&sn[z]==="stack"&&(oa(ye.element,{imageIndex:Y}),Sn(z,ye))},children:[be.map((Oe,W)=>{let $="#3f3f3f";return Oe.loaded&&($="#2e7d32"),Oe.viewed&&($="#1565c0"),Oe.current&&($="#fbc02d"),ze.jsx("div",{style:{width:"100%",height:`${100/ke}%`,minHeight:1,background:$,opacity:Oe.loaded||Oe.viewed||Oe.current?.95:.45,borderBottom:W<ke-1?"1px solid #222":"none",pointerEvents:"none"}},W)}),N>=0&&he>ke&&ze.jsx("div",{style:{position:"absolute",left:0,right:0,top:`${N/Math.max(1,he-1)*100}%`,height:2,background:"#ffeb3b",boxShadow:"0 0 4px #ffeb3b",transform:"translateY(-1px)",pointerEvents:"none"}})]})})()}),sn[z]==="volume"&&(()=>{const Q=A.current,he=Q==null?void 0:Q.getViewport(`CT_${z}`);let ge=0,me=0;return he&&typeof he.getNumberOfSlices=="function"&&typeof he.getSliceIndex=="function"&&(ge=he.getNumberOfSlices(),me=he.getSliceIndex()),ge>1?ze.jsx("div",{style:{position:"absolute",top:"10%",right:8,width:"12px",height:"80%",maxHeight:"100%",minHeight:0,zIndex:30,display:"flex",alignItems:"flex-start",justifyContent:"center",pointerEvents:"auto",flexDirection:"column",padding:0},children:ze.jsx("div",{style:{width:"8px",height:"100%",maxHeight:"100%",minHeight:0,borderRadius:"6px",background:"#222",position:"relative",display:"flex",flexDirection:"column",justifyContent:"flex-start",boxShadow:"0 0 8px #2196f3cc",overflow:"hidden",cursor:"pointer"},onClick:N=>{const te=N.currentTarget.getBoundingClientRect(),ve=N.clientY-te.top,Ie=Math.floor(ve/te.height*ge),ke=A.current,be=ke==null?void 0:ke.getViewport(`CT_${z}`);be&&(oa(be.element,{imageIndex:Ie}),be.render(),Sn(z,be))},children:Array.from({length:ge}).map((N,k)=>{const te=k===me;return ze.jsx("div",{style:{width:"100%",height:`${100/ge}%`,minHeight:te?1:0,background:te?"linear-gradient(to right, #ffeb3b 60%, #ff9800 100%)":"#444",opacity:te?.95:.4,transition:"background 0.3s, opacity 0.3s",borderBottom:k<ge-1?"1px solid #222":"none",pointerEvents:"none",cursor:"pointer"},title:te?`Current slice #${k+1}`:`Go to slice #${k+1}`},k)})})}):null})(),ne&&(Se.length>1||!J[z]||J[z].length===0)&&ze.jsx("div",{style:{position:"absolute",left:0,right:0,bottom:sn[z]==="stack"&&(fe[z]||(je[z]||[]).length>1)?56:8,zIndex:20,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",width:"100%",background:"none",borderRadius:"0",padding:0},children:ze.jsxs("div",{style:{position:"relative"},children:[ze.jsxs("button",{onClick:Q=>{Q.stopPropagation(),I(he=>he===z?null:z)},style:{padding:"6px 12px",background:"#333",color:"#fff",border:"1px solid #444",borderRadius:"4px",cursor:"pointer",pointerEvents:"auto",fontSize:13},title:"Choose stack",children:[(()=>{const Q=Array.isArray(Re)?Re[z]:void 0,he=typeof Q=="number"&&Se[Q]?Se[Q]:void 0,ge=he&&Array.isArray(he.imageIds)?he.imageIds:[],me=he?he.name||(he.caseId?`Case: ${he.caseId}`:void 0):void 0;if(me)return me;if(ge.length>0)return`Stack ${typeof Q=="number"?Q+1:"1"}`;const N=J[z]||[];return N.length>0?`Stack (${N.length} images)`:"No stack"})(),ze.jsx("span",{style:{marginLeft:8,opacity:.8},children:D===z?"▲":"▼"})]}),D===z&&ze.jsx("div",{ref:Q=>{Q&&Q.focus()},tabIndex:0,style:{position:"absolute",left:0,bottom:"110%",background:"#222",border:"1px solid #444",borderRadius:"4px",boxShadow:"0 2px 8px rgba(0,0,0,0.3)",zIndex:100,minWidth:220,maxHeight:260,overflowY:"auto",overscrollBehavior:"contain",scrollbarWidth:"thin",padding:6},role:"listbox",onMouseDown:Q=>Q.stopPropagation(),onWheel:Q=>{var ge;try{Q.stopPropagation()}catch{}try{Q.preventDefault()}catch{}const he=Q.currentTarget;if(he){const me=Q.deltaY??((ge=Q.nativeEvent)==null?void 0:ge.deltaY)??0;he.scrollTop+=me}},onBlur:Q=>{setTimeout(()=>{Q.currentTarget.contains(document.activeElement)||I(null)},0)},children:(()=>{const Q={};return Se.forEach((he,ge)=>{const me=he.studyId||he.studyInstanceUID||"Unspecified";Q[me]||(Q[me]=[]),Q[me].push({idx:ge,stack:he})}),Object.keys(Q).map(he=>ze.jsxs("div",{style:{marginBottom:6},children:[ze.jsx("div",{style:{fontSize:12,color:"#aaa",padding:"4px 8px",fontWeight:700},children:he==="Unspecified"?"Unspecified study":`Study: ${he}`}),ze.jsx("div",{children:Q[he].map(({idx:ge,stack:me})=>{const N=Array.isArray(me.imageIds)?me.imageIds:[],k=me&&(me.name||me.caseId)?me.name||`Case: ${me.caseId}`:`Stack ${ge+1}`,te=N.length,ve=!Array.isArray(N)||te===0;return ze.jsxs("button",{role:"option","aria-selected":!1,title:ve?"Invalid stack descriptor":`${k} — ${te} image${te===1?"":"s"}${me!=null&&me.caseId?` — case ${me.caseId}`:""}`,style:{display:"flex",flexDirection:"column",alignItems:"flex-start",width:"100%",padding:"8px 12px",background:"transparent",color:"#fff",border:"none",textAlign:"left",cursor:ve?"not-allowed":"pointer"},onClick:Ie=>{if(Ie.stopPropagation(),ve){console.warn(`Attempted to select invalid stack at index ${ge}`,me);return}ut(z,ge).catch(ke=>console.error("Failed to load stack:",ke)),I(null)},children:[ze.jsx("div",{style:{fontWeight:"600",fontSize:13},children:k}),ze.jsxs("div",{style:{fontSize:12,opacity:.7},children:[te," image",te===1?"":"s",me!=null&&me.caseId?` • case ${me.caseId}`:""]})]},ge)})})]},he))})()})]})})]},z))}return ze.jsxs("div",{ref:a,style:{position:"relative",inset:0,width:"100%",height:"100%",boxSizing:"border-box",background:"#222",padding:"12px",overflow:"hidden"},children:[Dn&&ze.jsx("div",{style:{position:"absolute",zIndex:3e3,top:0,left:0,width:"100%",height:"100%",background:"rgba(0,0,0,0.7)",color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:28,fontWeight:"bold",letterSpacing:1},children:Dn==="annotations"?"Loading Annotations...":Dn==="displayset"?"Loading Display Set...":"Loading Viewer State..."}),xn&&ze.jsxs("div",{style:{position:"fixed",top:12,left:12,right:12,zIndex:1e4,background:"#fff3cd",color:"#856404",border:"1px solid #ffeeba",padding:"10px 14px",borderRadius:6,display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[ze.jsxs("div",{style:{flex:1,fontSize:14},children:[ze.jsx("strong",{children:"Graphics error:"})," The viewer encountered a WebGL/graphics error and may be unstable. Please reload the page.",br?ze.jsx("div",{style:{marginTop:6,fontSize:12,color:"#6b4f00"},children:br}):null]}),ze.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[ze.jsx("button",{onClick:()=>window.location.reload(),style:{padding:"6px 10px"},children:"Reload"}),ze.jsx("button",{onClick:()=>Ui(!1),style:{padding:"6px 10px"},children:"Dismiss"})]})]}),!h&&ze.jsx("button",{onClick:()=>g(!0),"aria-pressed":!1,title:"Open stacks",style:{position:"absolute",right:8,top:76,zIndex:120,width:24,height:42,background:"#1976d2",color:"#fff",border:"none",borderRadius:5,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 2px 8px rgba(0,0,0,0.3)",pointerEvents:"auto"},children:"▶"}),ze.jsxs("div",{children:[ze.jsx("button",{style:{position:"absolute",top:"50%",transform:"translateY(-50%)",left:Qr,zIndex:200,width:S,height:S,background:"#222",color:"#fff",border:"none",borderRadius:"50%",fontWeight:"bold",cursor:"pointer",fontSize:"22px",boxShadow:"0 2px 8px rgba(0,0,0,0.2)",transition:"left 0.25s cubic-bezier(.4,2,.6,1), background 0.2s"},onClick:()=>Es(z=>!z),"aria-label":"Open menu",children:"☰"}),ta&&ze.jsx("div",{style:{position:"absolute",top:0,left:0,width:C,height:"100%",background:"#222",color:"#fff",zIndex:199,boxShadow:"2px 0 12px rgba(0,0,0,0.3)",flexDirection:"column",padding:"24px 16px 16px 16px",display:"flex",overflow:"hidden"},children:ze.jsxs("div",{style:{flex:1,minHeight:0,overflowY:"auto",display:"flex",flexDirection:"column"},children:[ze.jsxs("div",{style:{fontWeight:"bold",fontSize:18,marginBottom:24},children:["Menu",ze.jsx("button",{style:{float:"right",background:"transparent",color:"#fff",border:"none",fontSize:"22px",cursor:"pointer"},onClick:()=>Es(!1),"aria-label":"Close menu",children:"×"})]}),ze.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",marginBottom:8},children:[ze.jsxs("label",{style:{fontSize:13},children:[ze.jsx("input",{type:"radio",name:"folderLoadMode",value:"add",checked:Xa==="add",onChange:()=>Ta("add")})," Add (append)"]}),ze.jsxs("label",{style:{fontSize:13},children:[ze.jsx("input",{type:"radio",name:"folderLoadMode",value:"replace",checked:Xa==="replace",onChange:()=>Ta("replace")})," Replace all"]})]}),ze.jsx("button",{style:{padding:"10px 18px",background:"#333",color:"#fff",border:"none",borderRadius:"4px",fontWeight:"bold",cursor:"pointer",fontSize:"15px",marginBottom:"18px",width:"100%"},onClick:xc,children:"Load DICOM Folder"}),ze.jsx("input",{ref:Vn,type:"file",style:{display:"none"},multiple:!0,onChange:Ya}),ze.jsx("input",{ref:oi,type:"file",style:{display:"none"},multiple:!0,onChange:Ya,accept:".dcm,application/dicom"}),ze.jsxs("div",{style:{marginBottom:"18px",display:"flex",alignItems:"center",gap:"8px"},children:[ze.jsx("input",{type:"checkbox",id:"orderBySliceLocation",checked:Ur,onChange:z=>Cs(z.target.checked),style:{accentColor:"#666"}}),ze.jsx("label",{htmlFor:"orderBySliceLocation",style:{fontSize:"15px",cursor:"pointer"},children:"Order by Slice Location"})]}),ze.jsx("button",{style:{padding:"10px 18px",background:"#333",color:"#fff",border:"none",borderRadius:"4px",fontWeight:"bold",cursor:"pointer",fontSize:"15px",marginBottom:"18px",width:"100%"},onClick:wc,children:"Show DICOM Metadata"}),ze.jsxs("button",{style:{padding:"10px 18px",background:Rt?"#1976d2":"#333",color:"#fff",border:"none",borderRadius:"4px",fontWeight:"bold",cursor:"pointer",fontSize:"15px",marginBottom:"18px",width:"100%"},onClick:()=>mn(z=>!z),children:[Rt?"Disable":"Enable"," Cross Reference Lines"]}),ze.jsxs("button",{style:{padding:"10px 18px",background:Fr?"#1976d2":"#333",color:"#fff",border:"none",borderRadius:"4px",fontWeight:"bold",cursor:"pointer",fontSize:"15px",marginBottom:"18px",width:"100%"},onClick:()=>Lt(z=>!z),children:[Fr?"Disable":"Enable"," Reference Lines"]}),ze.jsx("button",{onClick:Bi,style:{margin:8,padding:8},children:"Sort All Viewports by Slice Location"}),ze.jsx("button",{style:{padding:"10px 18px",background:go?"#1976d2":"#333",color:"#fff",border:"none",borderRadius:"4px",fontWeight:"bold",cursor:"pointer",fontSize:"15px",marginBottom:"18px",width:"100%"},onClick:()=>Zi(z=>!z),children:go?"Disable Alt Key for Reference Cursors (Shift always works)":"Enable Alt Key for Reference Cursors (Shift always works)"}),ze.jsxs("button",{style:{padding:"10px 18px",background:G?"#1976d2":"#333",color:"#fff",border:"none",borderRadius:"4px",fontWeight:"bold",cursor:"pointer",fontSize:"15px",marginBottom:"18px",width:"100%"},onClick:()=>X(z=>!z),children:[G?"Hide":"Show"," Annotation Navigation"]}),ze.jsxs("button",{style:{padding:"10px 18px",background:ee?"#1976d2":"#333",color:"#fff",border:"none",borderRadius:"4px",fontWeight:"bold",cursor:"pointer",fontSize:"15px",marginBottom:"18px",width:"100%"},onClick:()=>ce(z=>!z),children:[ee?"Disable":"Enable"," Volume Diagnostics"]})]})})]}),ze.jsxs("div",{ref:_,className:"grid-menu-hover-container",style:{position:"absolute",top:ar||P?8:-18,left:"50%",transform:"translateX(-50%)",zIndex:100,display:"flex",flexDirection:"row",alignItems:"flex-start",gap:8,width:"auto",pointerEvents:"auto",transition:"top 180ms ease",paddingTop:28,marginTop:-28,paddingBottom:12},onMouseEnter:()=>O(!0),onMouseLeave:()=>{ar||O(!1)},children:[ze.jsxs("button",{style:{height:40,padding:"6px 12px 6px 10px",background:"#222",color:"#fff",border:"none",borderRadius:"0 0 4px 4px",fontWeight:"bold",cursor:"pointer",fontSize:"14px",boxShadow:"0 2px 8px rgba(0,0,0,0.2)",display:"inline-flex",alignItems:"center",gap:8},title:"Toggle viewer fullscreen",onFocus:()=>O(!0),onClick:()=>{O(!0),Sc()},children:[ze.jsx("span",{style:{fontSize:16,lineHeight:1},children:"⛶"}),ze.jsx("span",{children:"Fullscreen"})]}),ze.jsxs("div",{style:{position:"relative",display:"flex",flexDirection:"column",alignItems:"stretch"},children:[ze.jsxs("button",{className:"grid-menu-btn",style:{height:40,padding:"6px 14px 6px 10px",background:"#222",color:"#fff",border:"none",borderRadius:"0 0 4px 4px",fontWeight:"bold",cursor:"pointer",fontSize:"14px",boxShadow:"0 2px 8px rgba(0,0,0,0.2)",display:"inline-flex",alignItems:"center",gap:10,justifyContent:"space-between",minWidth:136},onFocus:()=>O(!0),onClick:()=>{O(!0),Qo(z=>!z)},tabIndex:0,children:[ze.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[ze.jsx("span",{style:{display:"grid",gridTemplateColumns:`repeat(${Ct.cols}, 5px)`,gridTemplateRows:`repeat(${Ct.rows}, 5px)`,gap:2,padding:1},children:Array.from({length:Ct.rows*Ct.cols}).map((z,ne)=>ze.jsx("span",{style:{width:5,height:5,borderRadius:1,background:"#90caf9",display:"block"}},ne))}),ze.jsxs("span",{children:[Ct.rows,"x",Ct.cols]})]}),ze.jsx("span",{style:{opacity:.8},children:ar?"▲":"▼"})]}),ar&&ze.jsx("div",{style:{position:"absolute",top:"calc(100% + 8px)",right:0,background:"#222",color:"#fff",borderRadius:"6px",boxShadow:"0 2px 12px rgba(0,0,0,0.4)",padding:"12px",display:"grid",gridTemplateColumns:"repeat(3, minmax(68px, 1fr))",gap:"8px",zIndex:200,pointerEvents:"auto"},onMouseDown:z=>z.stopPropagation(),children:Sa.map(z=>ze.jsxs("button",{style:{minWidth:"68px",height:"54px",background:z.rows===Ct.rows&&z.cols===Ct.cols?"#444":"#333",color:"#fff",border:"none",borderRadius:"4px",fontWeight:"bold",cursor:"pointer",fontSize:"13px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:6},onClick:()=>{ji(),Zt({rows:z.rows,cols:z.cols}),Qo(!1),O(!1)},children:[ze.jsx("span",{style:{display:"grid",gridTemplateColumns:`repeat(${z.cols}, 6px)`,gridTemplateRows:`repeat(${z.rows}, 6px)`,gap:2},children:Array.from({length:z.rows*z.cols}).map((ne,de)=>ze.jsx("span",{style:{width:6,height:6,borderRadius:1,background:"#90caf9",display:"block"}},de))}),ze.jsxs("span",{children:[z.rows,"x",z.cols]})]},`${z.rows}x${z.cols}`))})]})]}),ze.jsxs("div",{style:{display:"flex",flexDirection:"row",height:"calc(100% - 48px)",gap:8},children:[ze.jsxs("div",{style:{flex:1,display:"grid",margin:3,gridTemplateRows:`repeat(${Ct.rows}, 1fr)`,gridTemplateColumns:`repeat(${Ct.cols}, 1fr)`,gap:"5px",minHeight:0,minWidth:0,zIndex:1,position:"relative"},children:[Os,ze.jsx("button",{style:{position:"absolute",top:8,right:8,zIndex:2600,padding:"6px 12px",background:"#222",color:"#fff",border:"none",borderRadius:"4px",cursor:"pointer",opacity:.85,userSelect:"none"},onClick:()=>d(!0),children:"Settings"})]}),ze.jsxs("div",{style:{width:h?p:0,transition:"width 220ms ease",display:"flex",flexDirection:"column",pointerEvents:h?"auto":"none",overflow:"hidden",position:"relative"},children:[h&&ze.jsx("div",{onMouseDown:_a,title:"Resize stacks panel",style:{position:"absolute",left:0,top:0,width:8,height:"100%",cursor:"col-resize",zIndex:2800,background:"linear-gradient(to right, rgba(100,181,246,0.25), rgba(100,181,246,0))"}}),ze.jsx("div",{style:{pointerEvents:"auto",width:"100%",height:"100%"},children:ze.jsxs("div",{style:{height:"100%",width:"100%",background:"#1f2428",color:"#fff",boxShadow:"0 2px 14px rgba(0,0,0,0.45)",borderLeft:"1px solid #2f3336",transform:"translateX(0)",transition:"transform 220ms ease",display:"flex",flexDirection:"column",overflow:"hidden"},children:[ze.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",borderBottom:"1px solid #2b2f31"},children:[ze.jsx("div",{style:{fontWeight:700},children:"Stacks"}),ze.jsxs("div",{style:{fontSize:12,color:"#9bb4c8"},children:["Active VP: ",_e!==null?_e+1:"-"]}),ze.jsx("div",{style:{display:"flex",gap:8,alignItems:"center"},children:ze.jsx("button",{title:"Close",onClick:()=>{g(!1)},style:{background:"transparent",color:"#fff",border:"none",cursor:"pointer",fontSize:16},children:"×"})})]}),ze.jsx("div",{style:{overflowY:"auto",padding:8,flex:1},children:Se.length===0?ze.jsx("div",{style:{color:"#999",padding:12},children:"No stacks available"}):ze.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:Se.map((z,ne)=>{const de=Array.isArray(z.imageIds)?z.imageIds:[],le=z.name||(z.caseId?`Case: ${z.caseId}`:`Stack ${ne+1}`),Q=de.length,he=!Array.isArray(de)||Q===0,ge=Re.includes(ne),me=_e!==null&&Re[_e]===ne,N=Math.floor(de.length/2),k=de[N]||de[0],te=k?zs(k):null;return ze.jsxs("div",{draggable:!he,onDragStart:ve=>{he||(Ne(ne),K(null),ve.dataTransfer.setData("text/stack-idx",String(ne)),ve.dataTransfer.effectAllowed="copy")},onDragEnd:()=>{Ne(null),K(null)},onClick:()=>{if(he)return;ut(_e??0,ne)},style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 10px",background:me?"#0d47a1":ge?"#1976d2":"transparent",color:ge?"#fff":"#ddd",border:me?"1px solid #64b5f6":"1px solid transparent",borderRadius:6,cursor:he?"not-allowed":"pointer"},children:[ze.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[(()=>{const ve=Ue[ne],Ie=ve&&ve!=="BROKEN"?ve:null,ke=Ie||te||null;return ke?ze.jsx("img",{"data-thumb-stack":ne,src:ke,alt:le,style:{width:56,height:56,objectFit:"cover",borderRadius:4,background:"#111"},onError:()=>{if(console.warn("Thumbnail <img> failed to load for stack",ne,ke),!!Ie){lt(ne,"BROKEN");return}ot.current[ne]||Ao(ne,k)}}):ze.jsx("div",{style:{width:56,height:56,borderRadius:4,background:"#111",display:"flex",alignItems:"center",justifyContent:"center",color:"#777"},children:"No Img"})})(),ze.jsxs("div",{style:{display:"flex",flexDirection:"column"},children:[ze.jsx("div",{style:{fontWeight:600},children:le}),ze.jsxs("div",{style:{fontSize:12,opacity:.7},children:[Q," img",Q===1?"":"s"]})]})]}),ze.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:4},children:[ze.jsx("div",{style:{fontSize:12,opacity:.8},children:z.studyId||""}),me&&ze.jsx("div",{style:{fontSize:11,color:"#bbdefb",fontWeight:700},children:"ACTIVE"})]})]},ne)})})})]})})]})]}),u&&ze.jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",background:"rgba(0,0,0,0.4)",zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>d(!1),children:ze.jsxs("div",{style:{background:"#222",color:"#fff",borderRadius:"8px",minWidth:"320px",minHeight:"180px",padding:"24px",boxShadow:"0 4px 24px rgba(0,0,0,0.4)",position:"relative"},onClick:z=>z.stopPropagation(),children:[ze.jsx("div",{style:{fontSize:"20px",marginBottom:"16px"},children:"Settings"}),ze.jsxs("div",{style:{marginBottom:"24px"},children:[ze.jsx("div",{style:{marginBottom:12,fontWeight:"bold"},children:"Mouse Button Tool Bindings"}),Z7.map(z=>ze.jsxs("div",{style:{marginBottom:10},children:[ze.jsxs("label",{style:{marginRight:8},children:[z.label," Button:"]}),ze.jsx("select",{value:Ii[z.value],onChange:ne=>Ts(de=>({...de,[z.value]:ne.target.value})),style:{background:"#333",color:"#fff",border:"1px solid #444",borderRadius:"4px",padding:"4px 8px",fontSize:"14px"},children:l0.map(ne=>ze.jsx("option",{value:ne.value,title:ne.label,children:`${ne.icon?`${ne.icon} `:""}${ne.label}`},ne.value))})]},z.value)),ze.jsxs("div",{style:{margin:"12px 0"},children:[ze.jsxs("button",{style:{background:"#333",color:"#fff",border:"none",borderRadius:"4px",padding:"4px 12px",cursor:"pointer",fontSize:"14px",marginBottom:"8px"},onClick:()=>Yt(z=>!z),children:[Cn?"Hide":"Show"," Advanced Mouse Bindings"]}),Cn&&ze.jsx("div",{style:{marginTop:8},children:ev.slice(3).map(z=>ze.jsxs("div",{style:{marginBottom:10},children:[ze.jsxs("label",{style:{marginRight:8},children:[z.label,":"]}),ze.jsxs("select",{value:Ii[z.value]||"",onChange:ne=>Ts(de=>({...de,[z.value]:ne.target.value})),style:{background:"#333",color:"#fff",border:"1px solid #444",borderRadius:"4px",padding:"4px 8px",fontSize:"14px"},children:[ze.jsx("option",{value:"",children:"(None)"}),l0.map(ne=>ze.jsx("option",{value:ne.value,title:ne.label,children:`${ne.icon?`${ne.icon} `:""}${ne.label}`},ne.value))]})]},z.value))})]}),ze.jsx("div",{style:{margin:"18px 0 8px 0",fontWeight:"bold"},children:"Ctrl + Mouse Button Tool Bindings"}),Z7.map(z=>ze.jsxs("div",{style:{marginBottom:10},children:[ze.jsxs("label",{style:{marginRight:8},children:[z.label," + Ctrl:"]}),ze.jsxs("select",{value:ko[z.value]||"",onChange:ne=>_s(de=>({...de,[z.value]:ne.target.value})),style:{background:"#333",color:"#fff",border:"1px solid #444",borderRadius:"4px",padding:"4px 8px",fontSize:"14px"},children:[ze.jsx("option",{value:"",children:"(None)"}),l0.map(ne=>ze.jsx("option",{value:ne.value,title:ne.label,children:`${ne.icon?`${ne.icon} `:""}${ne.label}`},ne.value))]})]},z.value+"_ctrl")),ze.jsxs("div",{style:{margin:"12px 0"},children:[ze.jsxs("button",{style:{background:"#333",color:"#fff",border:"none",borderRadius:"4px",padding:"4px 12px",cursor:"pointer",fontSize:"14px",marginBottom:"8px"},onClick:()=>hi(z=>!z),children:[jt?"Hide":"Show"," Advanced Ctrl + Mouse Bindings"]}),jt&&ze.jsx("div",{style:{marginTop:8},children:ev.slice(3).map(z=>ze.jsxs("div",{style:{marginBottom:10},children:[ze.jsxs("label",{style:{marginRight:8},children:[z.label," + Ctrl:"]}),ze.jsxs("select",{value:ko[z.value]||"",onChange:ne=>_s(de=>({...de,[z.value]:ne.target.value})),style:{background:"#333",color:"#fff",border:"1px solid #444",borderRadius:"4px",padding:"4px 8px",fontSize:"14px"},children:[ze.jsx("option",{value:"",children:"(None)"}),l0.map(ne=>ze.jsx("option",{value:ne.value,title:ne.label,children:`${ne.icon?`${ne.icon} `:""}${ne.label}`},ne.value))]})]},z.value+"_ctrl"))})]})]}),ze.jsx("button",{style:{position:"absolute",top:12,right:12,background:"transparent",color:"#fff",border:"none",fontSize:"20px",cursor:"pointer"},onClick:()=>d(!1),"aria-label":"Close",children:"×"})]})}),$i&&ze.jsx("div",{style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",background:"rgba(0,0,0,0.5)",zIndex:2e3,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>Ir(!1),children:ze.jsxs("div",{style:{background:"#222",color:"#fff",borderRadius:"8px",minWidth:"320px",maxWidth:"80vw",maxHeight:"80vh",padding:"24px",boxShadow:"0 4px 24px rgba(0,0,0,0.4)",position:"relative",overflow:"auto"},onClick:z=>z.stopPropagation(),children:[ze.jsx("div",{style:{fontSize:"20px",marginBottom:"16px"},children:"DICOM Metadata"}),yc,ze.jsx("button",{style:{position:"absolute",top:12,right:12,background:"transparent",color:"#fff",border:"none",fontSize:"20px",cursor:"pointer"},onClick:()=>Ir(!1),"aria-label":"Close",children:"×"})]})})]})}function c8e(t){console.log("Setting up tools...",t),xi(ef),xi(Mh),xi(Ld),xi(Wl),xi(Ph),xi(pf),xi(su),xi(mf),xi(au),xi(Ad),xi(gf),xi(sl),xi(Rh),xi(La),xi(Uc),xi(pd),xi(Nh);let e=jr(t);return e||(e=xF(t),e.addTool(Mh.toolName),e.addTool(ef.toolName),e.addTool(Wl.toolName),e.addTool(Ld.toolName,{loop:!1}),e.addTool(Ph.toolName),e.addTool(pf.toolName),e.addTool(Nh.toolName,{getTextCallback:()=>""}),e.addTool(mf.toolName),e.addTool(su.toolName,{statsCalculator:()=>null}),e.addTool(au.toolName,{calculateStats:!1,getTextCallback:()=>""}),e.addTool(Ad.toolName,{getTextCallback:()=>""}),e.addTool(gf.toolName,{calculateStats:!1}),e.addTool(sl.toolName,{}),e.addTool(Rh.toolName,{}),e.addTool(pd.toolName),e.addTool(La.toolName)),e}function Q7(t,e,r,n){if(!r.length||!e.length)return null;const i=r.map(o=>e.findIndex(a=>a===o.metadata.referencedImageId)).filter(o=>o!==-1).sort((o,a)=>o-a);if(!i.length)return null;if(n===1){for(let o of i)if(o>t)return o;return i[0]}else{for(let o=i.length-1;o>=0;o--)if(i[o]<t)return i[o];return i[i.length-1]}}async function l8e(){return[Array.from({length:15},(e,r)=>`wadouri:/test_images/stack2/IMG${r+1}.dcm`),Array.from({length:25},(e,r)=>`wadouri:/test_images/stack5/IMG${r+1}.dcm`),Array.from({length:26},(e,r)=>`wadouri:/test_images/stack3/IMG${r+1}.dcm`)]}const t3=new WeakMap,u8e=t=>{const e=t.trim();return!e||e.startsWith("external:")||e.startsWith("wadors:")?e:e.startsWith("wadouri:")?`wadouri:${e.slice(8).replace(/^:+/,"")}`:`wadouri:${e.replace(/^:+/,"")}`},W1=t=>t.map(u8e),eO=t=>t?{imageIds:W1(t)}:{imageIds:[]},f8e=t=>{if(!t)return[];if(Array.isArray(t)&&t.length>0&&typeof t[0]=="string")return[eO(t)];if(!Array.isArray(t))return[];const e=[];return t.forEach((r,n)=>{if(r&&typeof r=="object"&&Array.isArray(r.stacks)){const i=r.caseId||r.caseUID||r.case||void 0,o=r.studyId||r.studyUID||r.studyInstanceUID||void 0;r.stacks.forEach((a,s)=>{let c=[];if(Array.isArray(a)?c=a:Array.isArray(a.imageIds)?c=a.imageIds:Array.isArray(a.i)&&(c=a.i),!Array.isArray(c)||c.length===0||!c.every(l=>typeof l=="string")){console.warn(`data-named-stacks: skipping invalid nested stack at parsed[${n}].stacks[${s}]`,a);return}e.push({imageIds:W1(c),name:a.name||a.label||void 0,caseId:i,studyId:a.studyId||o})});return}if(r&&typeof r=="object"&&(Array.isArray(r.imageIds)||Array.isArray(r.i))){const i=Array.isArray(r.imageIds)?r.imageIds:r.i;if(!Array.isArray(i)||i.length===0||!i.every(o=>typeof o=="string")){console.warn(`data-named-stacks: skipping invalid stack object at parsed[${n}]`,r);return}e.push({imageIds:W1(i),name:r.name||r.label||void 0,caseId:r.caseId||r.caseUID||void 0,studyId:r.studyId||r.studyUID||r.studyInstanceUID||void 0});return}if(Array.isArray(r)&&r.length>0&&typeof r[0]=="string"){e.push(eO(r));return}console.warn(`data-named-stacks: unknown or invalid entry at parsed[${n}] — skipping`,r)}),e},d8e=t=>JSON.stringify({id:t.id||"",empty:t.getAttribute("data-empty")||"",namedStacks:t.getAttribute("data-named-stacks")||"",images:t.getAttribute("data-images")||"",autoCache:t.getAttribute("data-auto-cache-stack")||"",annotation:t.getAttribute("data-annotationjson")||"",viewerState:t.getAttribute("data-viewerstate")||""}),tO=(t,e)=>!(e!=null&&e.containerIds)||e.containerIds.length===0?!0:e.containerIds.includes(t.id||""),nO=(t,e,r)=>{const n=d8e(t),i=t3.get(t);if(i&&!(r!=null&&r.force)&&i.signature===n)return;i&&(i.root.unmount(),t3.delete(t));const o=pP(t);o.render(ze.jsx(s8e,{container_id:t.id||"",imageStacks:e,autoCacheStack:t.getAttribute("data-auto-cache-stack")==="true"||t.getAttribute("data-auto-cache-stack")==="1",annotationJson:t.getAttribute("data-annotationjson")||void 0,viewerState:t.getAttribute("data-viewerstate")||void 0})),t3.set(t,{root:o,signature:n})};function eb(t){document.querySelectorAll(".dicom-viewer-test-root").forEach(n=>{if(!tO(n,t))return;n.id,nO(n,()=>l8e(),t)}),document.querySelectorAll(".dicom-viewer-root").forEach(n=>{if(!tO(n,t))return;let i;const o=n.getAttribute("data-empty")==="true",a=n.getAttribute("data-named-stacks"),s=n.getAttribute("data-images");if(o)i=()=>Promise.resolve([]);else if(a){let c;try{c=JSON.parse(a)}catch(f){console.error("Invalid data-named-stacks JSON:",f),c=[]}const l=f8e(c);i=()=>Promise.resolve(l)}else if(s){let c;try{c=JSON.parse(s)}catch(l){console.error("Invalid data-images JSON:",l),c=[]}Array.isArray(c)&&c.length>0&&typeof c[0]=="string"?i=()=>Promise.resolve([W1(c)]):Array.isArray(c)?i=()=>Promise.resolve(c.map(l=>Array.isArray(l)?W1(l):[])):i=()=>Promise.resolve([[]])}else i=()=>Promise.resolve([]);nO(n,i,t)})}eb();window.mountDicomViewers=eb;window.remountDicomViewer=t=>{eb({force:!0,containerIds:[t]})};
|