@vertexvis/viewer-toolkit-react 0.0.2-canary.9 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,7 @@
1
- "use strict";var e=require("tslib"),t=require("react/jsx-runtime"),n=require("@vertexvis/ui-react"),o=require("react"),r=require("react-dom"),i=require("quick-format-unescaped"),s=require("@vertexvis/geometry"),a=require("@vertexvis/viewer-react"),l=require("@vertexvis/viewer"),c=require("@vertexvis/ui/loader"),u=require("@vertexvis/viewer/loader");function d(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var f,p=d(o),h={exports:{}};
1
+ "use strict";var e=require("react/jsx-runtime"),t=require("tslib"),n=require("quick-format-unescaped"),o=require("react"),r=require("react-dom"),i=require("@vertexvis/ui-react"),a=require("@vertexvis/geometry"),s=require("@vertexvis/viewer-react"),l=require("@vertexvis/viewer"),c=require("@vertexvis/ui/loader"),u=require("@vertexvis/viewer/loader");function _interopNamespaceDefault(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var d=_interopNamespaceDefault(o),p={exports:{}};const f=n;p.exports=pino;const h=pfGlobalThisOrFallback().console||{},m={mapHttpRequest:mock,mapHttpResponse:mock,wrapRequestSerializer:passthrough,wrapResponseSerializer:passthrough,wrapErrorSerializer:passthrough,req:mock,res:mock,err:asErrValue,errWithCause:asErrValue};function levelToValue(e,t){return"silent"===e?1/0:t.levels.values[e]}const v=Symbol("pino.logFuncs"),g=Symbol("pino.hierarchy"),b={error:"log",fatal:"error",warn:"error",info:"log",debug:"log",trace:"log"};function appendChildLogger(e,t){const n={logger:t,parent:e[g]};t[g]=n}function setupBaseLogFunctions(e,t,n){const o={};t.forEach((e=>{o[e]=n[e]?n[e]:h[e]||h[b[e]||"log"]||noop})),e[v]=o}function shouldSerialize(e,t){if(Array.isArray(e)){const t=undefined;return e.filter((function(e){return"!stdSerializers.err"!==e}))}return!0===e&&Object.keys(t)}function pino(e){(e=e||{}).browser=e.browser||{};const t=e.browser.transmit;if(t&&"function"!=typeof t.send)throw Error("pino: transmit option must have a send function");const n=e.browser.write||h;e.browser.write&&(e.browser.asObject=!0);const o=e.serializers||{},r=shouldSerialize(e.browser.serialize,o);let i=e.browser.serialize;Array.isArray(e.browser.serialize)&&e.browser.serialize.indexOf("!stdSerializers.err")>-1&&(i=!1);const a=Object.keys(e.customLevels||{}),s=["error","fatal","warn","info","debug","trace"].concat(a);"function"==typeof n&&s.forEach((function(e){n[e]=n})),(!1===e.enabled||e.browser.disabled)&&(e.level="silent");const l=e.level||"info",c=Object.create(n);c.log||(c.log=noop),setupBaseLogFunctions(c,s,n),appendChildLogger({},c),Object.defineProperty(c,"levelVal",{get:getLevelVal}),Object.defineProperty(c,"level",{get:getLevel,set:setLevel});const u={transmit:t,serialize:r,asObject:e.browser.asObject,formatters:e.browser.formatters,levels:s,timestamp:getTimeFunction(e),messageKey:e.messageKey||"msg",onChild:e.onChild||noop};function getLevelVal(){return levelToValue(this.level,this)}function getLevel(){return this._level}function setLevel(e){if("silent"!==e&&!this.levels.values[e])throw Error("unknown level "+e);this._level=e,set(this,u,c,"error"),set(this,u,c,"fatal"),set(this,u,c,"warn"),set(this,u,c,"info"),set(this,u,c,"debug"),set(this,u,c,"trace"),a.forEach((e=>{set(this,u,c,e)}))}function child(n,i,a){if(!i)throw new Error("missing bindings for child Pino");a=a||{},r&&i.serializers&&(a.serializers=i.serializers);const s=a.serializers;if(r&&s){var l=Object.assign({},o,s),c=!0===e.browser.serialize?Object.keys(l):r;delete i.serializers,applySerializers([i],c,l,this._stdErrSerialize)}function Child(e){this._childLevel=1+(0|e._childLevel),this.bindings=i,l&&(this.serializers=l,this._serialize=c),t&&(this._logEvent=createLogEventShape([].concat(e._logEvent.bindings,i)))}Child.prototype=this;const u=new Child(this);return appendChildLogger(this,u),u.child=function(...e){return child.call(this,n,...e)},u.level=a.level||this.level,n.onChild(u),u}return c.levels=getLevels(e),c.level=l,c.setMaxListeners=c.getMaxListeners=c.emit=c.addListener=c.on=c.prependListener=c.once=c.prependOnceListener=c.removeListener=c.removeAllListeners=c.listeners=c.listenerCount=c.eventNames=c.write=c.flush=noop,c.serializers=o,c._serialize=r,c._stdErrSerialize=i,c.child=function(...e){return child.call(this,u,...e)},t&&(c._logEvent=createLogEventShape()),c}function getLevels(e){const t=e.customLevels||{},n=undefined,o=undefined;return{values:Object.assign({},pino.levels.values,t),labels:Object.assign({},pino.levels.labels,invertObject(t))}}function invertObject(e){const t={};return Object.keys(e).forEach((function(n){t[e[n]]=n})),t}function getBindingChain(e){const t=[];e.bindings&&t.push(e.bindings);let n=e[g];for(;n.parent;)n=n.parent,n.logger.bindings&&t.push(n.logger.bindings);return t.reverse()}function set(e,t,n,o){if(Object.defineProperty(e,o,{value:levelToValue(e.level,n)>levelToValue(o,n)?noop:n[v][o],writable:!0,enumerable:!0,configurable:!0}),e[o]===noop){if(!t.transmit)return;const r=undefined,i=levelToValue(t.transmit.level||e.level,n),a=undefined;if(levelToValue(o,n)<i)return}e[o]=createWrap(e,t,n,o);const r=getBindingChain(e);0!==r.length&&(e[o]=prependBindingsInArguments(r,e[o]))}function prependBindingsInArguments(e,t){return function(){return t.apply(this,[...e,...arguments])}}function createWrap(e,t,n,o){return r=e[v][o],function LOG(){const i=t.timestamp(),a=new Array(arguments.length),s=Object.getPrototypeOf&&Object.getPrototypeOf(this)===h?h:this;for(var l=0;l<a.length;l++)a[l]=arguments[l];var c=!1;if(t.serialize&&(applySerializers(a,this._serialize,this.serializers,this._stdErrSerialize),c=!0),t.asObject||t.formatters?r.call(s,asObject(this,o,a,i,t)):r.apply(s,a),t.transmit){const r=void 0,s=levelToValue(t.transmit.level||e._level,n),l=levelToValue(o,n);if(l<s)return;transmit(this,{ts:i,methodLevel:o,methodValue:l,transmitValue:n.levels.values[t.transmit.level||e._level],send:t.transmit.send,val:levelToValue(e._level,n)},a,c)}};var r}function asObject(e,t,n,o,r){const{level:i,log:a=e=>e}=r.formatters||{},s=n.slice();let l=s[0];const c={};if(o&&(c.time=o),i){const n=i(t,e.levels.values[t]);Object.assign(c,n)}else c.level=e.levels.values[t];let u=1+(0|e._childLevel);if(u<1&&(u=1),null!==l&&"object"==typeof l){for(;u--&&"object"==typeof s[0];)Object.assign(c,s.shift());l=s.length?f(s.shift(),s):void 0}else"string"==typeof l&&(l=f(s.shift(),s));void 0!==l&&(c[r.messageKey]=l);const d=undefined;return a(c)}function applySerializers(e,t,n,o){for(const r in e)if(o&&e[r]instanceof Error)e[r]=pino.stdSerializers.err(e[r]);else if("object"==typeof e[r]&&!Array.isArray(e[r])&&t)for(const o in e[r])t.indexOf(o)>-1&&o in n&&(e[r][o]=n[o](e[r][o]))}function transmit(e,t,n,o=!1){const r=t.send,i=t.ts,a=t.methodLevel,s=t.methodValue,l=t.val,c=e._logEvent.bindings;o||applySerializers(n,e._serialize||Object.keys(e.serializers),e.serializers,void 0===e._stdErrSerialize||e._stdErrSerialize),e._logEvent.ts=i,e._logEvent.messages=n.filter((function(e){return-1===c.indexOf(e)})),e._logEvent.level.label=a,e._logEvent.level.value=s,r(a,e._logEvent,l),e._logEvent=createLogEventShape(c)}function createLogEventShape(e){return{ts:0,messages:[],bindings:e||[],level:{label:"",value:0}}}function asErrValue(e){const t={type:e.constructor.name,msg:e.message,stack:e.stack};for(const n in e)void 0===t[n]&&(t[n]=e[n]);return t}function getTimeFunction(e){return"function"==typeof e.timestamp?e.timestamp:!1===e.timestamp?nullTime:epochTime}function mock(){return{}}function passthrough(e){return e}function noop(){}function nullTime(){return!1}function epochTime(){return Date.now()}function unixTime(){return Math.round(Date.now()/1e3)}function isoTime(){return new Date(Date.now()).toISOString()}function pfGlobalThisOrFallback(){function defd(e){return void 0!==e&&e}try{return"undefined"!=typeof globalThis||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch(e){return defd(self)||defd(window)||defd(this)||{}}}var S;pino.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},pino.stdSerializers=m,pino.stdTimeFunctions=Object.assign({},{nullTime:nullTime,epochTime:epochTime,unixTime:unixTime,isoTime:isoTime}),p.exports.default=pino,p.exports.pino=pino;const w=(0,p.exports)({formatters:{level:e=>({level:e})}}),logger_error=(e,t)=>{null!=t?w.error(t,e):w.error(e)},logger_info=(e,t)=>{null!=t?w.info(t,e):w.info(e)},logger_warn=(e,t)=>{null!=t?w.warn(t,e):w.warn(e)},logger_debug=(e,t)=>{null!=t?w.debug(t,e):w.debug(e)};function err(e){const t=new Error(e);if(void 0===t.stack)try{throw t}catch(e){}return t}var _,A=err;function isPromise(e){return!!e&&"function"==typeof e.then}var E=isPromise;function nullthrows(e,t){if(null!=e)return e;throw A(null!=t?t:"Got unexpected null or undefined")}var T=nullthrows;function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class V{getValue(){throw A("BaseLoadable")}toPromise(){throw A("BaseLoadable")}valueMaybe(){throw A("BaseLoadable")}valueOrThrow(){throw A(`Loadable expected value, but in "${this.state}" state`)}promiseMaybe(){throw A("BaseLoadable")}promiseOrThrow(){throw A(`Loadable expected promise, but in "${this.state}" state`)}errorMaybe(){throw A("BaseLoadable")}errorOrThrow(){throw A(`Loadable expected error, but in "${this.state}" state`)}is(e){return e.state===this.state&&e.contents===this.contents}map(e){throw A("BaseLoadable")}}class C extends V{constructor(e){super(),_defineProperty(this,"state","hasValue"),_defineProperty(this,"contents",void 0),this.contents=e}getValue(){return this.contents}toPromise(){return Promise.resolve(this.contents)}valueMaybe(){return this.contents}valueOrThrow(){return this.contents}promiseMaybe(){}errorMaybe(){}map(e){try{const t=e(this.contents);return E(t)?loadableWithPromise(t):isLoadable(t)?t:loadableWithValue(t)}catch(t){return E(t)?loadableWithPromise(t.next((()=>this.map(e)))):loadableWithError(t)}}}class k extends V{constructor(e){super(),_defineProperty(this,"state","hasError"),_defineProperty(this,"contents",void 0),this.contents=e}getValue(){throw this.contents}toPromise(){return Promise.reject(this.contents)}valueMaybe(){}promiseMaybe(){}errorMaybe(){return this.contents}errorOrThrow(){return this.contents}map(e){return this}}class N extends V{constructor(e){super(),_defineProperty(this,"state","loading"),_defineProperty(this,"contents",void 0),this.contents=e}getValue(){throw this.contents}toPromise(){return this.contents}valueMaybe(){}promiseMaybe(){return this.contents}promiseOrThrow(){return this.contents}errorMaybe(){}map(e){return loadableWithPromise(this.contents.then((t=>{const n=e(t);if(isLoadable(n)){const e=n;switch(e.state){case"hasValue":case"loading":return e.contents;case"hasError":throw e.contents}}return n})).catch((t=>{if(E(t))return t.then((()=>this.map(e).contents));throw t})))}}function loadableWithValue(e){return Object.freeze(new C(e))}function loadableWithError(e){return Object.freeze(new k(e))}function loadableWithPromise(e){return Object.freeze(new N(e))}function loadableLoading(){return Object.freeze(new N(new Promise((()=>{}))))}function loadableAllArray(e){return e.every((e=>"hasValue"===e.state))?loadableWithValue(e.map((e=>e.contents))):e.some((e=>"hasError"===e.state))?loadableWithError(T(e.find((e=>"hasError"===e.state)),"Invalid loadable passed to loadableAll").contents):loadableWithPromise(Promise.all(e.map((e=>e.contents))))}function loadableAll(e){const t=undefined,n=(Array.isArray(e)?e:Object.getOwnPropertyNames(e).map((t=>e[t]))).map((e=>isLoadable(e)?e:E(e)?loadableWithPromise(e):loadableWithValue(e))),o=loadableAllArray(n);return Array.isArray(e)?o:o.map((t=>Object.getOwnPropertyNames(e).reduce(((e,n,o)=>({...e,[n]:t[o]})),{})))}function isLoadable(e){return e instanceof V}const R={of:e=>E(e)?loadableWithPromise(e):isLoadable(e)?e:loadableWithValue(e),error:e=>loadableWithError(e),loading:()=>loadableLoading(),all:loadableAll,isLoadable:isLoadable};var I={loadableWithValue:loadableWithValue,loadableWithError:loadableWithError,loadableWithPromise:loadableWithPromise,loadableLoading:loadableLoading,loadableAll:loadableAll,isLoadable:isLoadable,RecoilLoadable:R},O=I.loadableWithValue,L=I.loadableWithError,P=I.loadableWithPromise,j=I.loadableLoading,M=I.loadableAll,D=I.isLoadable,B=I.RecoilLoadable,U=Object.freeze({__proto__:null,loadableWithValue:O,loadableWithError:L,loadableWithPromise:P,loadableLoading:j,loadableAll:M,isLoadable:D,RecoilLoadable:B});const F={RECOIL_DUPLICATE_ATOM_KEY_CHECKING_ENABLED:!0,RECOIL_GKS_ENABLED:new Set(["recoil_hamt_2020","recoil_sync_external_store","recoil_suppress_rerender_in_callback","recoil_memory_managament_2020"])};function readProcessEnvBooleanFlag(e,t){var n,o;const r=null===(n=process.env[e])||void 0===n||null===(o=n.toLowerCase())||void 0===o?void 0:o.trim();if(null==r||""===r)return;const i=undefined;if(!["true","false"].includes(r))throw A(`process.env.${e} value must be 'true', 'false', or empty: ${r}`);t("true"===r)}function readProcessEnvStringArrayFlag(e,t){var n;const o=null===(n=process.env[e])||void 0===n?void 0:n.trim();null!=o&&""!==o&&t(o.split(/\s*,\s*|\s+/))}function applyProcessEnvFlagOverrides(){var e;"undefined"!=typeof process&&null!=(null===(e=process)||void 0===e?void 0:e.env)&&(readProcessEnvBooleanFlag("RECOIL_DUPLICATE_ATOM_KEY_CHECKING_ENABLED",(e=>{F.RECOIL_DUPLICATE_ATOM_KEY_CHECKING_ENABLED=e})),readProcessEnvStringArrayFlag("RECOIL_GKS_ENABLED",(e=>{e.forEach((e=>{F.RECOIL_GKS_ENABLED.add(e)}))})))}applyProcessEnvFlagOverrides();var H=F;function Recoil_gkx_OSS(e){return H.RECOIL_GKS_ENABLED.has(e)}Recoil_gkx_OSS.setPass=e=>{H.RECOIL_GKS_ENABLED.add(e)},Recoil_gkx_OSS.setFail=e=>{H.RECOIL_GKS_ENABLED.delete(e)},Recoil_gkx_OSS.clear=()=>{H.RECOIL_GKS_ENABLED.clear()};var W=Recoil_gkx_OSS;function recoverableViolation(e,t,{error:n}={}){return"production"!==process.env.NODE_ENV&&console.error(e,n),null}var $,G=recoverableViolation,K,q,Y;const Z=null!==(K=o.createMutableSource)&&void 0!==K?K:o.unstable_createMutableSource,X=null!==(q=o.useMutableSource)&&void 0!==q?q:o.unstable_useMutableSource,J=null!==(Y=o.useSyncExternalStore)&&void 0!==Y?Y:o.unstable_useSyncExternalStore;let Q=!1;function currentRendererSupportsUseSyncExternalStore(){var e;const{ReactCurrentDispatcher:t,ReactCurrentOwner:n}=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,r=undefined,i=null!=(null!==(e=null==t?void 0:t.current)&&void 0!==e?e:n.currentDispatcher).useSyncExternalStore;return!J||i||Q||(Q=!0,G("A React renderer without React 18+ API support is being used with React 18+.")),i}function reactMode(){return W("recoil_transition_support")?{mode:"TRANSITION_SUPPORT",early:!0,concurrent:!0}:W("recoil_sync_external_store")&&null!=J?{mode:"SYNC_EXTERNAL_STORE",early:!0,concurrent:!1}:W("recoil_mutable_source")&&null!=X&&"undefined"!=typeof window&&!window.$disableRecoilValueMutableSource_TEMP_HACK_DO_NOT_USE?W("recoil_suppress_rerender_in_callback")?{mode:"MUTABLE_SOURCE",early:!0,concurrent:!0}:{mode:"MUTABLE_SOURCE",early:!1,concurrent:!1}:W("recoil_suppress_rerender_in_callback")?{mode:"LEGACY",early:!0,concurrent:!1}:{mode:"LEGACY",early:!1,concurrent:!1}}var ee={createMutableSource:Z,useMutableSource:X,useSyncExternalStore:J,currentRendererSupportsUseSyncExternalStore:currentRendererSupportsUseSyncExternalStore,reactMode:reactMode};class te{constructor(e){_defineProperty(this,"key",void 0),this.key=e}toJSON(){return{key:this.key}}}class ne extends te{}class oe extends te{}function isRecoilValue(e){return e instanceof ne||e instanceof oe}var re={AbstractRecoilValue:te,RecoilState:ne,RecoilValueReadOnly:oe,isRecoilValue:isRecoilValue},ie=re.AbstractRecoilValue,ae=re.RecoilState,se=re.RecoilValueReadOnly,le=re.isRecoilValue,ce=Object.freeze({__proto__:null,AbstractRecoilValue:ie,RecoilState:ae,RecoilValueReadOnly:se,isRecoilValue:le});function sprintf(e,...t){let n=0;return e.replace(/%s/g,(()=>String(t[n++])))}var ue=sprintf;function expectationViolation(e,...t){if("production"!==process.env.NODE_ENV){const n=ue.call(null,e,...t),o=new Error(n);o.name="Expectation Violation",console.error(o)}}var de,pe=expectationViolation;function mapIterable(e,t){return function*(){let n=0;for(const o of e)yield t(o,n++)}()}var fe=mapIterable;class he{}const me=new he,ve=new Map,ge=new Map;function recoilValuesForKeys(e){return fe(e,(e=>T(ge.get(e))))}function checkForDuplicateAtomKey(e){if(ve.has(e)){const t=`Duplicate atom key "${e}". This is a FATAL ERROR in\n production. But it is safe to ignore this warning if it occurred because of\n hot module replacement.`;"production"!==process.env.NODE_ENV?pe(t,"recoil"):console.warn(t)}}function registerNode(e){H.RECOIL_DUPLICATE_ATOM_KEY_CHECKING_ENABLED&&checkForDuplicateAtomKey(e.key),ve.set(e.key,e);const t=null==e.set?new ce.RecoilValueReadOnly(e.key):new ce.RecoilState(e.key);return ge.set(e.key,t),t}class ye extends Error{}function getNode(e){const t=ve.get(e);if(null==t)throw new ye(`Missing definition for RecoilValue: "${e}""`);return t}function getNodeMaybe(e){return ve.get(e)}const be=new Map;function deleteNodeConfigIfPossible(e){var t;if(!W("recoil_memory_managament_2020"))return;const n=ve.get(e);var o;null!=n&&null!==(t=n.shouldDeleteConfigOnRelease)&&void 0!==t&&t.call(n)&&(ve.delete(e),null===(o=getConfigDeletionHandler(e))||void 0===o||o(),be.delete(e))}function setConfigDeletionHandler(e,t){W("recoil_memory_managament_2020")&&(void 0===t?be.delete(e):be.set(e,t))}function getConfigDeletionHandler(e){return be.get(e)}var Se={recoilValues:ge,registerNode:registerNode,getNode:getNode,getNodeMaybe:getNodeMaybe,deleteNodeConfigIfPossible:deleteNodeConfigIfPossible,setConfigDeletionHandler:setConfigDeletionHandler,getConfigDeletionHandler:getConfigDeletionHandler,recoilValuesForKeys:recoilValuesForKeys,DefaultValue:he,DEFAULT_VALUE:me};function enqueueExecution(e,t){t()}var xe={enqueueExecution:enqueueExecution};function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}var we=createCommonjsModule((function(e){var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n={},o=5,r=Math.pow(2,5),i=r-1,a=r/2,s=r/4,l={},c=function constant(e){return function(){return e}},u=n.hash=function(e){var n=void 0===e?"undefined":t(e);if("number"===n)return e;"string"!==n&&(e+="");for(var o=0,r=0,i=e.length;r<i;++r){var a;o=(o<<5)-o+e.charCodeAt(r)|0}return o},d=function popcount(e){return e=(e=(858993459&(e-=e>>1&1431655765))+(e>>2&858993459))+(e>>4)&252645135,e+=e>>8,127&(e+=e>>16)},p=function hashFragment(e,t){return t>>>e&i},f=function toBitmap(e){return 1<<e},h=function fromBitmap(e,t){return d(e&t-1)},m=function arrayUpdate(e,t,n,o){var r=o;if(!e){var i=o.length;r=new Array(i);for(var a=0;a<i;++a)r[a]=o[a]}return r[t]=n,r},v=function arraySpliceOut(e,t,n){var o=n.length-1,r=0,i=0,a=n;if(e)r=i=t;else for(a=new Array(o);r<t;)a[i++]=n[r++];for(++r;r<=o;)a[i++]=n[r++];return e&&(a.length=o),a},g=function arraySpliceIn(e,t,n,o){var r=o.length;if(e){for(var i=r;i>=t;)o[i--]=o[i];return o[t]=n,o}for(var a=0,s=0,l=new Array(r+1);a<t;)l[s++]=o[a++];for(l[t]=n;a<r;)l[++s]=o[a++];return l},b=1,S=2,w=3,_=4,A={__hamt_isEmpty:!0},E=function isEmptyNode(e){return e===A||e&&e.__hamt_isEmpty},T=function Leaf(e,t,n,o){return{type:1,edit:e,hash:t,key:n,value:o,_modify:j}},V=function Collision(e,t,n){return{type:2,edit:e,hash:t,children:n,_modify:M}},C=function IndexedNode(e,t,n){return{type:3,edit:e,mask:t,children:n,_modify:D}},k=function ArrayNode(e,t,n){return{type:4,edit:e,size:t,children:n,_modify:B}},N=function isLeaf(e){return e===A||1===e.type||2===e.type},R=function expand(e,t,n,o,r){for(var i=[],a=o,s=0,l=0;a;++l)1&a&&(i[l]=r[s++]),a>>>=1;return i[t]=n,k(e,s+1,i)},I=function pack(e,t,n,o){for(var r=new Array(t-1),i=0,a=0,s=0,l=o.length;s<l;++s)if(s!==n){var c=o[s];c&&!E(c)&&(r[i++]=c,a|=1<<s)}return C(e,a,r)},O=function mergeLeaves(e,t,n,o,r,i){if(n===r)return V(e,n,[i,o]);var a=p(t,n),s=p(t,r);return C(e,f(a)|f(s),a===s?[mergeLeaves(e,t+5,n,o,r,i)]:a<s?[o,i]:[i,o])},L=function updateCollisionList(e,t,n,o,r,i,a,s){for(var c=r.length,u=0;u<c;++u){var d=r[u];if(n(a,d.key)){var p=d.value,f=i(p);return f===p?r:f===l?(--s.value,v(e,u,r)):m(e,u,T(t,o,a,f),r)}}var h=i();return h===l?r:(++s.value,m(e,c,T(t,o,a,h),r))},P=function canEditNode(e,t){return e===t.edit},j=function Leaf__modify(e,t,n,o,r,i,a){if(t(i,this.key)){var s=o(this.value);return s===this.value?this:s===l?(--a.value,A):P(e,this)?(this.value=s,this):T(e,r,i,s)}var c=o();return c===l?this:(++a.value,O(e,n,this.hash,this,r,T(e,r,i,c)))},M=function Collision__modify(e,t,n,o,r,i,a){if(r===this.hash){var s=P(e,this),c=L(s,e,t,this.hash,this.children,o,i,a);return c===this.children?this:c.length>1?V(e,this.hash,c):c[0]}var u=o();return u===l?this:(++a.value,O(e,n,this.hash,this,r,T(e,r,i,u)))},D=function IndexedNode__modify(e,t,n,o,r,i,s){var l=this.mask,c=this.children,u=p(n,r),d=f(u),b=h(l,d),S=l&d,w=S?c[b]:A,_=w._modify(e,t,n+5,o,r,i,s);if(w===_)return this;var T=P(e,this),V=l,k=void 0;if(S&&E(_)){if(!(V&=~d))return A;if(c.length<=2&&N(c[1^b]))return c[1^b];k=v(T,b,c)}else if(S||E(_))k=m(T,b,_,c);else{if(c.length>=a)return R(e,u,_,l,c);V|=d,k=g(T,b,_,c)}return T?(this.mask=V,this.children=k,this):C(e,V,k)},B=function ArrayNode__modify(e,t,n,o,r,i,a){var l=this.size,c=this.children,u=p(n,r),d=c[u],f=(d||A)._modify(e,t,n+5,o,r,i,a);if(d===f)return this;var h=P(e,this),v=void 0;if(E(d)&&!E(f))++l,v=m(h,u,f,c);else if(!E(d)&&E(f)){if(--l<=s)return I(e,l,u,c);v=m(h,u,A,c)}else v=m(h,u,f,c);return h?(this.size=l,this.children=v,this):k(e,l,v)};function Map(e,t,n,o,r){this._editable=e,this._edit=t,this._config=n,this._root=o,this._size=r}A._modify=function(e,t,n,o,r,i,a){var s=o();return s===l?A:(++a.value,T(e,r,i,s))},Map.prototype.setTree=function(e,t){return this._editable?(this._root=e,this._size=t,this):e===this._root?this:new Map(this._editable,this._edit,this._config,e,t)};var U=n.tryGetHash=function(e,t,n,o){for(var r=o._root,i=0,a=o._config.keyEq;;)switch(r.type){case 1:return a(n,r.key)?r.value:e;case 2:if(t===r.hash)for(var s=r.children,l=0,c=s.length;l<c;++l){var u=s[l];if(a(n,u.key))return u.value}return e;case 3:var d=p(i,t),m=f(d);if(r.mask&m){r=r.children[h(r.mask,m)],i+=5;break}return e;case 4:if(r=r.children[p(i,t)]){i+=5;break}return e;default:return e}};Map.prototype.tryGetHash=function(e,t,n){return U(e,t,n,this)};var F=n.tryGet=function(e,t,n){return U(e,n._config.hash(t),t,n)};Map.prototype.tryGet=function(e,t){return F(e,t,this)};var H=n.getHash=function(e,t,n){return U(void 0,e,t,n)};Map.prototype.getHash=function(e,t){return H(e,t,this)},n.get=function(e,t){return U(void 0,t._config.hash(e),e,t)},Map.prototype.get=function(e,t){return F(t,e,this)};var W=n.has=function(e,t,n){return U(l,e,t,n)!==l};Map.prototype.hasHash=function(e,t){return W(e,t,this)};var $=n.has=function(e,t){return W(t._config.hash(e),e,t)};Map.prototype.has=function(e){return $(e,this)};var G=function defKeyCompare(e,t){return e===t};n.make=function(e){return new Map(0,0,{keyEq:e&&e.keyEq||G,hash:e&&e.hash||u},A,0)},n.empty=n.make();var K=n.isEmpty=function(e){return e&&!!E(e._root)};Map.prototype.isEmpty=function(){return K(this)};var q=n.modifyHash=function(e,t,n,o){var r={value:o._size},i=o._root._modify(o._editable?o._edit:NaN,o._config.keyEq,0,e,t,n,r);return o.setTree(i,r.value)};Map.prototype.modifyHash=function(e,t,n){return q(n,e,t,this)};var Y=n.modify=function(e,t,n){return q(e,n._config.hash(t),t,n)};Map.prototype.modify=function(e,t){return Y(t,e,this)};var Z=n.setHash=function(e,t,n,o){return q(c(n),e,t,o)};Map.prototype.setHash=function(e,t,n){return Z(e,t,n,this)};var X=n.set=function(e,t,n){return Z(n._config.hash(e),e,t,n)};Map.prototype.set=function(e,t){return X(e,t,this)};var J=c(l),Q=n.removeHash=function(e,t,n){return q(J,e,t,n)};Map.prototype.removeHash=Map.prototype.deleteHash=function(e,t){return Q(e,t,this)};var ee=n.remove=function(e,t){return Q(t._config.hash(e),e,t)};Map.prototype.remove=Map.prototype.delete=function(e){return ee(e,this)};var te=n.beginMutation=function(e){return new Map(e._editable+1,e._edit+1,e._config,e._root,e._size)};Map.prototype.beginMutation=function(){return te(this)};var ne=n.endMutation=function(e){return e._editable=e._editable&&e._editable-1,e};Map.prototype.endMutation=function(){return ne(this)};var oe=n.mutate=function(e,t){var n=te(t);return e(n),ne(n)};Map.prototype.mutate=function(e){return oe(e,this)};var re=function appk(e){return e&&ie(e[0],e[1],e[2],e[3],e[4])},ie=function lazyVisitChildren(e,t,n,o,r){for(;n<e;){var i=t[n++];if(i&&!E(i))return ae(i,o,[e,t,n,o,r])}return re(r)},ae=function lazyVisit(e,t,n){switch(e.type){case 1:return{value:t(e),rest:n};case 2:case 4:case 3:var o=e.children;return ie(o.length,o,0,t,n);default:return re(n)}},se={done:!0};function MapIterator(e){this.v=e}MapIterator.prototype.next=function(){if(!this.v)return se;var e=this.v;return this.v=re(e.rest),e},MapIterator.prototype[Symbol.iterator]=function(){return this};var le=function visit(e,t){return new MapIterator(ae(e._root,t))},ce=function buildPairs(e){return[e.key,e.value]},ue=n.entries=function(e){return le(e,ce)};Map.prototype.entries=Map.prototype[Symbol.iterator]=function(){return ue(this)};var de=function buildKeys(e){return e.key},pe=n.keys=function(e){return le(e,de)};Map.prototype.keys=function(){return pe(this)};var fe=function buildValues(e){return e.value},he=n.values=Map.prototype.values=function(e){return le(e,fe)};Map.prototype.values=function(){return he(this)};var me=n.fold=function(e,t,n){var o=n._root;if(1===o.type)return e(t,o.value,o.key);for(var r=[o.children],i=void 0;i=r.pop();)for(var a=0,s=i.length;a<s;){var l=i[a++];l&&l.type&&(1===l.type?t=e(t,l.value,l.key):r.push(l.children))}return t};Map.prototype.fold=function(e,t){return me(e,t,this)};var ve=n.forEach=function(e,t){return me((function(n,o,r){return e(o,r,t)}),null,t)};Map.prototype.forEach=function(e){return ve(e,this)};var ge=n.count=function(e){return e._size};Map.prototype.count=function(){return ge(this)},Object.defineProperty(Map.prototype,"size",{get:Map.prototype.count}),e.exports?e.exports=n:(void 0).hamt=n}));class _e{constructor(e){_defineProperty(this,"_map",void 0),this._map=new Map(null==e?void 0:e.entries())}keys(){return this._map.keys()}entries(){return this._map.entries()}get(e){return this._map.get(e)}has(e){return this._map.has(e)}set(e,t){return this._map.set(e,t),this}delete(e){return this._map.delete(e),this}clone(){return persistentMap(this)}toMap(){return new Map(this._map)}}class Ae{constructor(e){if(_defineProperty(this,"_hamt",we.empty.beginMutation()),e instanceof Ae){const t=e._hamt.endMutation();e._hamt=t.beginMutation(),this._hamt=t.beginMutation()}else if(e)for(const[t,n]of e.entries())this._hamt.set(t,n)}keys(){return this._hamt.keys()}entries(){return this._hamt.entries()}get(e){return this._hamt.get(e)}has(e){return this._hamt.has(e)}set(e,t){return this._hamt.set(e,t),this}delete(e){return this._hamt.delete(e),this}clone(){return persistentMap(this)}toMap(){return new Map(this._hamt)}}function persistentMap(e){return W("recoil_hamt_2020")?new Ae(e):new _e(e)}var Ee,Te=persistentMap,Ve=Object.freeze({__proto__:null,persistentMap:Te});function differenceSets(e,...t){const n=new Set;e:for(const o of e){for(const e of t)if(e.has(o))continue e;n.add(o)}return n}var Ce=differenceSets;function mapMap(e,t){const n=new Map;return e.forEach(((e,o)=>{n.set(o,t(e,o))})),n}var ke=mapMap;function makeGraph(){return{nodeDeps:new Map,nodeToNodeSubscriptions:new Map}}function cloneGraph(e){return{nodeDeps:ke(e.nodeDeps,(e=>new Set(e))),nodeToNodeSubscriptions:ke(e.nodeToNodeSubscriptions,(e=>new Set(e)))}}function mergeDepsIntoGraph(e,t,n,o){const{nodeDeps:r,nodeToNodeSubscriptions:i}=n,a=r.get(e);if(a&&o&&a!==o.nodeDeps.get(e))return;r.set(e,t);const s=null==a?t:Ce(t,a);for(const t of s){i.has(t)||i.set(t,new Set);const n=undefined;T(i.get(t)).add(e)}if(a){const n=Ce(a,t);for(const t of n){if(!i.has(t))return;const n=T(i.get(t));n.delete(e),0===n.size&&i.delete(t)}}}function saveDepsToStore(e,t,n,o){var r,i,a,s;const l=n.getState();o!==l.currentTree.version&&o!==(null===(r=l.nextTree)||void 0===r?void 0:r.version)&&o!==(null===(i=l.previousTree)||void 0===i?void 0:i.version)&&G("Tried to save dependencies to a discarded tree");const c=n.getGraph(o);if(mergeDepsIntoGraph(e,t,c),o===(null===(a=l.previousTree)||void 0===a?void 0:a.version)){const o=undefined;mergeDepsIntoGraph(e,t,n.getGraph(l.currentTree.version),c)}if(o===(null===(s=l.previousTree)||void 0===s?void 0:s.version)||o===l.currentTree.version){var u;const o=null===(u=l.nextTree)||void 0===u?void 0:u.version;if(void 0!==o){const r=undefined;mergeDepsIntoGraph(e,t,n.getGraph(o),c)}}}var Ne={cloneGraph:cloneGraph,graph:makeGraph,saveDepsToStore:saveDepsToStore};let Re=0;const Ie=undefined;let Oe=0;const Le=undefined;let Pe=0;const je=undefined;var Me={getNextTreeStateVersion:()=>Re++,getNextStoreID:()=>Oe++,getNextComponentID:()=>Pe++};const{persistentMap:De}=Ve,{graph:Be}=Ne,{getNextTreeStateVersion:ze}=Me;function makeEmptyTreeState(){const e=ze();return{version:e,stateID:e,transactionMetadata:{},dirtyAtoms:new Set,atomValues:De(),nonvalidatedAtoms:De()}}function makeEmptyStoreState(){const e=makeEmptyTreeState();return{currentTree:e,nextTree:null,previousTree:null,commitDepth:0,knownAtoms:new Set,knownSelectors:new Set,transactionSubscriptions:new Map,nodeTransactionSubscriptions:new Map,nodeToComponentSubscriptions:new Map,queuedComponentCallbacks_DEPRECATED:[],suspendedComponentResolvers:new Set,graphsByVersion:(new Map).set(e.version,Be()),retention:{referenceCounts:new Map,nodesRetainedByZone:new Map,retainablesToCheckForRelease:new Set},nodeCleanupFunctions:new Map}}var Ue={makeEmptyStoreState:makeEmptyStoreState,getNextTreeStateVersion:ze};class Fe{}var He={RetentionZone:Fe};function setByAddingToSet(e,t){const n=new Set(e);return n.add(t),n}var We={setByAddingToSet:setByAddingToSet};function*filterIterable(e,t){let n=0;for(const o of e)t(o,n++)&&(yield o)}var $e=filterIterable;function lazyProxy(e,t){const n=undefined;return new Proxy(e,{get:(e,n)=>(!(n in e)&&n in t&&(e[n]=t[n]()),e[n]),ownKeys:e=>Object.keys(e)})}var Ge=lazyProxy;const{getNode:Ke,getNodeMaybe:qe,recoilValuesForKeys:Ye}=Se,{RetentionZone:Ze}=He,{setByAddingToSet:Xe}=We,Je=Object.freeze(new Set);class Qe extends Error{}function initializeRetentionForNode(e,t,n){if(!W("recoil_memory_managament_2020"))return()=>{};const{nodesRetainedByZone:o}=e.getState().retention;function addToZone(e){let n=o.get(e);n||o.set(e,n=new Set),n.add(t)}if(n instanceof Ze)addToZone(n);else if(Array.isArray(n))for(const e of n)addToZone(e);return()=>{if(!W("recoil_memory_managament_2020"))return;const{retention:o}=e.getState();function deleteFromZone(e){const n=o.nodesRetainedByZone.get(e);null==n||n.delete(t),n&&0===n.size&&o.nodesRetainedByZone.delete(e)}if(n instanceof Ze)deleteFromZone(n);else if(Array.isArray(n))for(const e of n)deleteFromZone(e)}}function initializeNodeIfNewToStore(e,t,n,o){const r=e.getState();if(r.nodeCleanupFunctions.has(n))return;const i=Ke(n),a=initializeRetentionForNode(e,n,i.retainedBy),s=i.init(e,t,o);r.nodeCleanupFunctions.set(n,(()=>{s(),a()}))}function initializeNode(e,t,n){initializeNodeIfNewToStore(e,e.getState().currentTree,t,n)}function cleanUpNode(e,t){var n;const o=e.getState();null===(n=o.nodeCleanupFunctions.get(t))||void 0===n||n(),o.nodeCleanupFunctions.delete(t)}function getNodeLoadable(e,t,n){return initializeNodeIfNewToStore(e,t,n,"get"),Ke(n).get(e,t)}function peekNodeLoadable(e,t,n){return Ke(n).peek(e,t)}function setUnvalidatedAtomValue_DEPRECATED(e,t,n){var o;const r=qe(t);return null==r||null===(o=r.invalidate)||void 0===o||o.call(r,e),{...e,atomValues:e.atomValues.clone().delete(t),nonvalidatedAtoms:e.nonvalidatedAtoms.clone().set(t,n),dirtyAtoms:Xe(e.dirtyAtoms,t)}}function setNodeValue(e,t,n,o){const r=Ke(n);if(null==r.set)throw new Qe(`Attempt to set read-only RecoilValue: ${n}`);const i=r.set;return initializeNodeIfNewToStore(e,t,n,"set"),i(e,t,o)}function peekNodeInfo(e,t,n){const o=e.getState(),r=e.getGraph(t.version),i=Ke(n).nodeType;return Ge({type:i},{loadable:()=>peekNodeLoadable(e,t,n),isActive:()=>o.knownAtoms.has(n)||o.knownSelectors.has(n),isSet:()=>"selector"!==i&&t.atomValues.has(n),isModified:()=>t.dirtyAtoms.has(n),deps:()=>{var e;return Ye(null!==(e=r.nodeDeps.get(n))&&void 0!==e?e:[])},subscribers:()=>{var r,i;return{nodes:Ye($e(getDownstreamNodes(e,t,new Set([n])),(e=>e!==n))),components:fe(null!==(r=null===(i=o.nodeToComponentSubscriptions.get(n))||void 0===i?void 0:i.values())&&void 0!==r?r:[],(([e])=>({name:e})))}}})}function getDownstreamNodes(e,t,n){const o=new Set,r=Array.from(n),i=e.getGraph(t.version);for(let e=r.pop();e;e=r.pop()){var a;o.add(e);const t=null!==(a=i.nodeToNodeSubscriptions.get(e))&&void 0!==a?a:Je;for(const e of t)o.has(e)||r.push(e)}return o}var et={getNodeLoadable:getNodeLoadable,peekNodeLoadable:peekNodeLoadable,setNodeValue:setNodeValue,initializeNode:initializeNode,cleanUpNode:cleanUpNode,setUnvalidatedAtomValue_DEPRECATED:setUnvalidatedAtomValue_DEPRECATED,peekNodeInfo:peekNodeInfo,getDownstreamNodes:getDownstreamNodes};let tt=null;function setInvalidateMemoizedSnapshot(e){tt=e}function invalidateMemoizedSnapshot(){var e;null===(e=tt)||void 0===e||e()}var nt={setInvalidateMemoizedSnapshot:setInvalidateMemoizedSnapshot,invalidateMemoizedSnapshot:invalidateMemoizedSnapshot};const{getDownstreamNodes:ot,getNodeLoadable:rt,setNodeValue:it}=et,{getNextComponentID:at}=Me,{getNode:st,getNodeMaybe:lt}=Se,{DefaultValue:ct}=Se,{reactMode:ut}=ee,{AbstractRecoilValue:dt,RecoilState:pt,RecoilValueReadOnly:ft,isRecoilValue:ht}=ce,{invalidateMemoizedSnapshot:mt}=nt;function getRecoilValueAsLoadable(e,{key:t},n=e.getState().currentTree){var o,r;const i=e.getState();n.version!==i.currentTree.version&&n.version!==(null===(o=i.nextTree)||void 0===o?void 0:o.version)&&n.version!==(null===(r=i.previousTree)||void 0===r?void 0:r.version)&&G("Tried to read from a discarded tree");const a=rt(e,n,t);return"loading"===a.state&&a.contents.catch((()=>{})),a}function applyAtomValueWrites(e,t){const n=e.clone();return t.forEach(((e,t)=>{"hasValue"===e.state&&e.contents instanceof ct?n.delete(t):n.set(t,e)})),n}function valueFromValueOrUpdater(e,t,{key:n},o){if("function"==typeof o){const r=rt(e,t,n);if("loading"===r.state){const e=`Tried to set atom or selector "${n}" using an updater function while the current state is pending, this is not currently supported.`;throw G(e),A(e)}if("hasError"===r.state)throw r.contents;return o(r.contents)}return o}function applyAction(e,t,n){if("set"===n.type){const{recoilValue:o,valueOrUpdater:r}=n,i=valueFromValueOrUpdater(e,t,o,r),a=it(e,t,o.key,i);for(const[e,n]of a.entries())writeLoadableToTreeState(t,e,n)}else if("setLoadable"===n.type){const{recoilValue:{key:e},loadable:o}=n;writeLoadableToTreeState(t,e,o)}else if("markModified"===n.type){const{recoilValue:{key:e}}=n;t.dirtyAtoms.add(e)}else if("setUnvalidated"===n.type){var o;const{recoilValue:{key:e},unvalidatedValue:r}=n,i=lt(e);null==i||null===(o=i.invalidate)||void 0===o||o.call(i,t),t.atomValues.delete(e),t.nonvalidatedAtoms.set(e,r),t.dirtyAtoms.add(e)}else G(`Unknown action ${n.type}`)}function writeLoadableToTreeState(e,t,n){"hasValue"===n.state&&n.contents instanceof ct?e.atomValues.delete(t):e.atomValues.set(t,n),e.dirtyAtoms.add(t),e.nonvalidatedAtoms.delete(t)}function applyActionsToStore(e,t){e.replaceState((n=>{const o=copyTreeState(n);for(const n of t)applyAction(e,o,n);return invalidateDownstreams(e,o),mt(),o}))}function queueOrPerformStateUpdate(e,t){if(vt.length){const n=vt[vt.length-1];let o=n.get(e);o||n.set(e,o=[]),o.push(t)}else applyActionsToStore(e,[t])}const vt=[];function batchStart(){const e=new Map;return vt.push(e),()=>{for(const[t,n]of e)applyActionsToStore(t,n);const t=undefined;vt.pop()!==e&&G("Incorrect order of batch popping")}}function copyTreeState(e){return{...e,atomValues:e.atomValues.clone(),nonvalidatedAtoms:e.nonvalidatedAtoms.clone(),dirtyAtoms:new Set(e.dirtyAtoms)}}function invalidateDownstreams(e,t){const n=ot(e,t,t.dirtyAtoms);for(const e of n){var o,r;null===(o=lt(e))||void 0===o||null===(r=o.invalidate)||void 0===r||r.call(o,t)}}function setRecoilValue(e,t,n){queueOrPerformStateUpdate(e,{type:"set",recoilValue:t,valueOrUpdater:n})}function setRecoilValueLoadable(e,t,n){if(n instanceof ct)return setRecoilValue(e,t,n);queueOrPerformStateUpdate(e,{type:"setLoadable",recoilValue:t,loadable:n})}function markRecoilValueModified(e,t){queueOrPerformStateUpdate(e,{type:"markModified",recoilValue:t})}function setUnvalidatedRecoilValue(e,t,n){queueOrPerformStateUpdate(e,{type:"setUnvalidated",recoilValue:t,unvalidatedValue:n})}function subscribeToRecoilValue(e,{key:t},n,o=null){const r=at(),i=e.getState();i.nodeToComponentSubscriptions.has(t)||i.nodeToComponentSubscriptions.set(t,new Map),T(i.nodeToComponentSubscriptions.get(t)).set(r,[null!=o?o:"<not captured>",n]);const a=ut();if(a.early&&("LEGACY"===a.mode||"MUTABLE_SOURCE"===a.mode)){const o=e.getState().nextTree;o&&o.dirtyAtoms.has(t)&&n(o)}return{release:()=>{const n=e.getState(),o=n.nodeToComponentSubscriptions.get(t);void 0!==o&&o.has(r)?(o.delete(r),0===o.size&&n.nodeToComponentSubscriptions.delete(t)):G(`Subscription missing at release time for atom ${t}. This is a bug in Recoil.`)}}}function refreshRecoilValue(e,t){var n;const{currentTree:o}=e.getState(),r=st(t.key);null===(n=r.clearCache)||void 0===n||n.call(r,e,o)}var gt={AbstractRecoilValue:dt,getRecoilValueAsLoadable:getRecoilValueAsLoadable,setRecoilValue:setRecoilValue,setRecoilValueLoadable:setRecoilValueLoadable,markRecoilValueModified:markRecoilValueModified,setUnvalidatedRecoilValue:setUnvalidatedRecoilValue,subscribeToRecoilValue:subscribeToRecoilValue,applyAtomValueWrites:applyAtomValueWrites,batchStart:batchStart,writeLoadableToTreeState:writeLoadableToTreeState,invalidateDownstreams:invalidateDownstreams,copyTreeState:copyTreeState,refreshRecoilValue:refreshRecoilValue};function someSet(e,t,n){const o=e.entries();let r=o.next();for(;!r.done;){const i=r.value;if(t.call(n,i[1],i[0],e))return!0;r=o.next()}return!1}var yt=someSet;const{cleanUpNode:bt}=et,{deleteNodeConfigIfPossible:St,getNode:xt}=Se,{RetentionZone:wt}=He,_t=12e4,At=new Set;function releaseRetainablesNowOnCurrentTree(e,t){const n=e.getState(),o=n.currentTree;if(n.nextTree)return void G("releaseNodesNowOnCurrentTree should only be called at the end of a batch");const r=new Set;for(const e of t)if(e instanceof wt)for(const t of nodesRetainedByZone(n,e))r.add(t);else r.add(e);const i=findReleasableNodes(e,r);for(const t of i)releaseNode(e,o,t)}function findReleasableNodes(e,t){const n=e.getState(),o=n.currentTree,r=e.getGraph(o.version),i=new Set,a=new Set;return findReleasableNodesInner(t),i;function findReleasableNodesInner(t){const s=new Set,l=getDownstreamNodesInTopologicalOrder(e,o,t,i,a);for(const e of l){var c;if("recoilRoot"===xt(e).retainedBy){a.add(e);continue}if((null!==(c=n.retention.referenceCounts.get(e))&&void 0!==c?c:0)>0){a.add(e);continue}if(zonesThatCouldRetainNode(e).some((e=>n.retention.referenceCounts.get(e)))){a.add(e);continue}const t=r.nodeToNodeSubscriptions.get(e);t&&yt(t,(e=>a.has(e)))?a.add(e):(i.add(e),s.add(e))}const u=new Set;for(const e of s)for(const t of null!==(d=r.nodeDeps.get(e))&&void 0!==d?d:At){var d;i.has(t)||u.add(t)}u.size&&findReleasableNodesInner(u)}}function getDownstreamNodesInTopologicalOrder(e,t,n,o,r){const i=e.getGraph(t.version),a=[],s=new Set;for(;n.size>0;)visit(T(n.values().next().value));return a;function visit(e){if(o.has(e)||r.has(e))return void n.delete(e);if(s.has(e))return;const t=i.nodeToNodeSubscriptions.get(e);if(t)for(const e of t)visit(e);s.add(e),n.delete(e),a.push(e)}}function releaseNode(e,t,n){if(!W("recoil_memory_managament_2020"))return;bt(e,n);const o=e.getState();o.knownAtoms.delete(n),o.knownSelectors.delete(n),o.nodeTransactionSubscriptions.delete(n),o.retention.referenceCounts.delete(n);const r=zonesThatCouldRetainNode(n);for(const e of r){var i;null===(i=o.retention.nodesRetainedByZone.get(e))||void 0===i||i.delete(n)}t.atomValues.delete(n),t.dirtyAtoms.delete(n),t.nonvalidatedAtoms.delete(n);const a=o.graphsByVersion.get(t.version);if(a){const e=a.nodeDeps.get(n);if(void 0!==e){a.nodeDeps.delete(n);for(const t of e){var s;null===(s=a.nodeToNodeSubscriptions.get(t))||void 0===s||s.delete(n)}}a.nodeToNodeSubscriptions.delete(n)}St(n)}function nodesRetainedByZone(e,t){var n;return null!==(n=e.retention.nodesRetainedByZone.get(t))&&void 0!==n?n:At}function zonesThatCouldRetainNode(e){const t=xt(e).retainedBy;return void 0===t||"components"===t||"recoilRoot"===t?[]:t instanceof wt?[t]:t}function scheduleOrPerformPossibleReleaseOfRetainable(e,t){const n=e.getState();n.nextTree?n.retention.retainablesToCheckForRelease.add(t):releaseRetainablesNowOnCurrentTree(e,new Set([t]))}function updateRetainCount(e,t,n){var o;if(!W("recoil_memory_managament_2020"))return;const r=e.getState().retention.referenceCounts,i=(null!==(o=r.get(t))&&void 0!==o?o:0)+n;0===i?updateRetainCountToZero(e,t):r.set(t,i)}function updateRetainCountToZero(e,t){if(!W("recoil_memory_managament_2020"))return;const n=undefined;e.getState().retention.referenceCounts.delete(t),scheduleOrPerformPossibleReleaseOfRetainable(e,t)}function releaseScheduledRetainablesNow(e){if(!W("recoil_memory_managament_2020"))return;const t=e.getState();releaseRetainablesNowOnCurrentTree(e,t.retention.retainablesToCheckForRelease),t.retention.retainablesToCheckForRelease.clear()}function retainedByOptionWithDefault(e){return void 0===e?"recoilRoot":e}var Et={SUSPENSE_TIMEOUT_MS:_t,updateRetainCount:updateRetainCount,releaseScheduledRetainablesNow:releaseScheduledRetainablesNow,retainedByOptionWithDefault:retainedByOptionWithDefault};const{unstable_batchedUpdates:Tt}=r;var Vt={unstable_batchedUpdates:Tt};const{unstable_batchedUpdates:Ct}=Vt;var kt={unstable_batchedUpdates:Ct};const{batchStart:Nt}=gt,{unstable_batchedUpdates:Rt}=kt;let It=Rt||(e=>e());const Ot=undefined;var Lt={batchUpdates:e=>{It((()=>{let batchEnd=()=>{};try{batchEnd=Nt(),e()}finally{batchEnd()}}))}};function*concatIterables(e){for(const t of e)for(const e of t)yield e}var Pt=concatIterables;const jt="undefined"==typeof Window||"undefined"==typeof window,isWindow=e=>!jt&&(e===window||e instanceof Window),Mt="undefined"!=typeof navigator&&"ReactNative"===navigator.product;var Dt={isSSR:jt,isReactNative:Mt,isWindow:isWindow};function memoizeOneWithArgsHashAndInvalidation(e,t){let n,o;const r=undefined,i=undefined;return[(...r)=>{const i=t(...r);return n===i||(n=i,o=e(...r)),o},()=>{n=null}]}var Bt={memoizeOneWithArgsHashAndInvalidation:memoizeOneWithArgsHashAndInvalidation};const{batchUpdates:zt}=Lt,{initializeNode:Ut,peekNodeInfo:Ft}=et,{graph:Ht}=Ne,{getNextStoreID:Wt}=Me,{DEFAULT_VALUE:$t,recoilValues:Gt,recoilValuesForKeys:Kt}=Se,{AbstractRecoilValue:qt,getRecoilValueAsLoadable:Yt,setRecoilValue:Zt,setUnvalidatedRecoilValue:Xt}=gt,{updateRetainCount:Jt}=Et,{setInvalidateMemoizedSnapshot:Qt}=nt,{getNextTreeStateVersion:en,makeEmptyStoreState:tn}=Ue,{isSSR:nn}=Dt,{memoizeOneWithArgsHashAndInvalidation:on}=Bt,rn="\nRecoil Snapshots only last for the duration of the callback they are provided to. To keep a Snapshot longer, do this:\n\n const release = snapshot.retain();\n try {\n await doSomethingWithSnapshot(snapshot);\n } finally {\n release();\n }\n\nThis is currently a DEV-only warning but will become a thrown exception in the next release of Recoil.\n";class an{constructor(e,t){_defineProperty(this,"_store",void 0),_defineProperty(this,"_refCount",1),_defineProperty(this,"getLoadable",(e=>(this.checkRefCount_INTERNAL(),Yt(this._store,e)))),_defineProperty(this,"getPromise",(e=>(this.checkRefCount_INTERNAL(),this.getLoadable(e).toPromise()))),_defineProperty(this,"getNodes_UNSTABLE",(e=>{if(this.checkRefCount_INTERNAL(),!0===(null==e?void 0:e.isModified)){if(!1===(null==e?void 0:e.isInitialized))return[];const t=this._store.getState().currentTree;return Kt(t.dirtyAtoms)}const t=this._store.getState().knownAtoms,n=this._store.getState().knownSelectors;return null==(null==e?void 0:e.isInitialized)?Gt.values():!0===e.isInitialized?Kt(Pt([t,n])):$e(Gt.values(),(({key:e})=>!t.has(e)&&!n.has(e)))})),_defineProperty(this,"getInfo_UNSTABLE",(({key:e})=>(this.checkRefCount_INTERNAL(),Ft(this._store,this._store.getState().currentTree,e)))),_defineProperty(this,"map",(e=>{this.checkRefCount_INTERNAL();const t=new cn(this,zt);return e(t),t})),_defineProperty(this,"asyncMap",(async e=>{this.checkRefCount_INTERNAL();const t=new cn(this,zt);return t.retain(),await e(t),t.autoRelease_INTERNAL(),t})),this._store={storeID:Wt(),parentStoreID:t,getState:()=>e,replaceState:t=>{e.currentTree=t(e.currentTree)},getGraph:t=>{const n=e.graphsByVersion;if(n.has(t))return T(n.get(t));const o=Ht();return n.set(t,o),o},subscribeToTransactions:()=>({release:()=>{}}),addTransactionMetadata:()=>{throw A("Cannot subscribe to Snapshots")}};for(const e of this._store.getState().knownAtoms)Ut(this._store,e,"get"),Jt(this._store,e,1);this.autoRelease_INTERNAL()}retain(){if(this._refCount<=0){if("production"!==process.env.NODE_ENV)throw A("Snapshot has already been released.");G("Attempt to retain() Snapshot that was already released.")}this._refCount++;let e=!1;return()=>{e||(e=!0,this._release())}}autoRelease_INTERNAL(){nn||window.setTimeout((()=>this._release()),10)}_release(){if(this._refCount--,0===this._refCount){if(this._store.getState().nodeCleanupFunctions.forEach((e=>e())),this._store.getState().nodeCleanupFunctions.clear(),!W("recoil_memory_managament_2020"))return}else this._refCount<0&&"production"!==process.env.NODE_ENV&&G("Snapshot released an extra time.")}isRetained(){return this._refCount>0}checkRefCount_INTERNAL(){W("recoil_memory_managament_2020")&&this._refCount<=0&&"production"!==process.env.NODE_ENV&&G(rn)}getStore_INTERNAL(){return this.checkRefCount_INTERNAL(),this._store}getID(){return this.checkRefCount_INTERNAL(),this._store.getState().currentTree.stateID}getStoreID(){return this.checkRefCount_INTERNAL(),this._store.storeID}}function cloneStoreState(e,t,n=!1){const o=e.getState(),r=n?en():t.version;return{currentTree:{version:n?r:t.version,stateID:n?r:t.stateID,transactionMetadata:{...t.transactionMetadata},dirtyAtoms:new Set(t.dirtyAtoms),atomValues:t.atomValues.clone(),nonvalidatedAtoms:t.nonvalidatedAtoms.clone()},commitDepth:0,nextTree:null,previousTree:null,knownAtoms:new Set(o.knownAtoms),knownSelectors:new Set(o.knownSelectors),transactionSubscriptions:new Map,nodeTransactionSubscriptions:new Map,nodeToComponentSubscriptions:new Map,queuedComponentCallbacks_DEPRECATED:[],suspendedComponentResolvers:new Set,graphsByVersion:(new Map).set(r,e.getGraph(t.version)),retention:{referenceCounts:new Map,nodesRetainedByZone:new Map,retainablesToCheckForRelease:new Set},nodeCleanupFunctions:new Map(fe(o.nodeCleanupFunctions.entries(),(([e])=>[e,()=>{}])))}}function freshSnapshot(e){const t=new an(tn());return null!=e?t.map(e):t}const[sn,ln]=on(((e,t)=>{var n;const o=e.getState(),r="latest"===t?null!==(n=o.nextTree)&&void 0!==n?n:o.currentTree:T(o.previousTree);return new an(cloneStoreState(e,r),e.storeID)}),((e,t)=>{var n,o;return String(t)+String(e.storeID)+String(null===(n=e.getState().nextTree)||void 0===n?void 0:n.version)+String(e.getState().currentTree.version)+String(null===(o=e.getState().previousTree)||void 0===o?void 0:o.version)}));function cloneSnapshot(e,t="latest"){const n=sn(e,t);return n.isRetained()?n:(ln(),sn(e,t))}Qt(ln);class cn extends an{constructor(e,t){super(cloneStoreState(e.getStore_INTERNAL(),e.getStore_INTERNAL().getState().currentTree,!0),e.getStoreID()),_defineProperty(this,"_batch",void 0),_defineProperty(this,"set",((e,t)=>{this.checkRefCount_INTERNAL();const n=this.getStore_INTERNAL();this._batch((()=>{Jt(n,e.key,1),Zt(this.getStore_INTERNAL(),e,t)}))})),_defineProperty(this,"reset",(e=>{this.checkRefCount_INTERNAL();const t=this.getStore_INTERNAL();this._batch((()=>{Jt(t,e.key,1),Zt(this.getStore_INTERNAL(),e,$t)}))})),_defineProperty(this,"setUnvalidatedAtomValues_DEPRECATED",(e=>{this.checkRefCount_INTERNAL();const t=this.getStore_INTERNAL();zt((()=>{for(const[n,o]of e.entries())Jt(t,n,1),Xt(t,new qt(n),o)}))})),this._batch=t}}var un={Snapshot:an,MutableSnapshot:cn,freshSnapshot:freshSnapshot,cloneSnapshot:cloneSnapshot},dn=un.Snapshot,pn=un.MutableSnapshot,fn=un.freshSnapshot,hn=un.cloneSnapshot,mn=Object.freeze({__proto__:null,Snapshot:dn,MutableSnapshot:pn,freshSnapshot:fn,cloneSnapshot:hn});function unionSets(...e){const t=new Set;for(const n of e)for(const e of n)t.add(e);return t}var vn=unionSets;const{useRef:gn}=o;function useRefInitOnce(e){const t=gn(e);return t.current===e&&"function"==typeof e&&(t.current=e()),t}var yn=useRefInitOnce;const{getNextTreeStateVersion:bn,makeEmptyStoreState:Sn}=Ue,{cleanUpNode:xn,getDownstreamNodes:wn,initializeNode:_n,setNodeValue:An,setUnvalidatedAtomValue_DEPRECATED:En}=et,{graph:Tn}=Ne,{cloneGraph:Vn}=Ne,{getNextStoreID:Cn}=Me,{createMutableSource:kn,reactMode:Nn}=ee,{applyAtomValueWrites:Rn}=gt,{releaseScheduledRetainablesNow:In}=Et,{freshSnapshot:On}=mn,{useCallback:Ln,useContext:Pn,useEffect:jn,useMemo:Mn,useRef:Dn,useState:Bn}=o;function notInAContext(){throw A("This component must be used inside a <RecoilRoot> component.")}const zn=Object.freeze({storeID:Cn(),getState:notInAContext,replaceState:notInAContext,getGraph:notInAContext,subscribeToTransactions:notInAContext,addTransactionMetadata:notInAContext});let Un=!1;function startNextTreeIfNeeded(e){if(Un)throw A("An atom update was triggered within the execution of a state updater function. State updater functions provided to Recoil must be pure functions.");const t=e.getState();if(null===t.nextTree){W("recoil_memory_managament_2020")&&W("recoil_release_on_cascading_update_killswitch_2021")&&t.commitDepth>0&&In(e);const n=t.currentTree.version,o=bn();t.nextTree={...t.currentTree,version:o,stateID:o,dirtyAtoms:new Set,transactionMetadata:{}},t.graphsByVersion.set(o,Vn(T(t.graphsByVersion.get(n))))}}const Fn=o.createContext({current:zn}),useStoreRef=()=>Pn(Fn),Hn=o.createContext(null);function useRecoilMutableSource(){const e=Pn(Hn);return null==e&&pe("Attempted to use a Recoil hook outside of a <RecoilRoot>. <RecoilRoot> must be an ancestor of any component that uses Recoil hooks."),e}function notifyComponents(e,t,n){const o=wn(e,n,n.dirtyAtoms);for(const e of o){const o=t.nodeToComponentSubscriptions.get(e);if(o)for(const[e,[t,r]]of o)r(n)}}function sendEndOfBatchNotifications(e){const t=e.getState(),n=t.currentTree,o=n.dirtyAtoms;if(o.size){for(const[n,r]of t.nodeTransactionSubscriptions)if(o.has(n))for(const[t,n]of r)n(e);for(const[n,o]of t.transactionSubscriptions)o(e);(!Nn().early||t.suspendedComponentResolvers.size>0)&&(notifyComponents(e,t,n),t.suspendedComponentResolvers.forEach((e=>e())),t.suspendedComponentResolvers.clear())}t.queuedComponentCallbacks_DEPRECATED.forEach((e=>e(n))),t.queuedComponentCallbacks_DEPRECATED.splice(0,t.queuedComponentCallbacks_DEPRECATED.length)}function endBatch(e){const t=e.getState();t.commitDepth++;try{const{nextTree:n}=t;if(null==n)return;t.previousTree=t.currentTree,t.currentTree=n,t.nextTree=null,sendEndOfBatchNotifications(e),null!=t.previousTree?t.graphsByVersion.delete(t.previousTree.version):G("Ended batch with no previous state, which is unexpected","recoil"),t.previousTree=null,W("recoil_memory_managament_2020")&&null==n&&In(e)}finally{t.commitDepth--}}function Batcher({setNotifyBatcherOfChange:e}){const t=useStoreRef(),[,n]=Bn([]);return e((()=>n({}))),jn((()=>(e((()=>n({}))),()=>{e((()=>{}))})),[e]),jn((()=>{xe.enqueueExecution("Batcher",(()=>{endBatch(t.current)}))})),null}function initialStoreState_DEPRECATED(e,t){const n=Sn();return t({set:(t,o)=>{const r=n.currentTree,i=An(e,r,t.key,o),a=new Set(i.keys()),s=r.nonvalidatedAtoms.clone();for(const e of a)s.delete(e);n.currentTree={...r,dirtyAtoms:vn(r.dirtyAtoms,a),atomValues:Rn(r.atomValues,i),nonvalidatedAtoms:s}},setUnvalidatedAtomValues:e=>{e.forEach(((e,t)=>{n.currentTree=En(n.currentTree,t,e)}))}}),n}function initialStoreState(e){const t=On(e),n=t.getStore_INTERNAL().getState();return t.retain(),n.nodeCleanupFunctions.forEach((e=>e())),n.nodeCleanupFunctions.clear(),n}"production"!==process.env.NODE_ENV&&("undefined"==typeof window||window.$recoilDebugStates||(window.$recoilDebugStates=[]));let Wn=0;function RecoilRoot_INTERNAL({initializeState_DEPRECATED:e,initializeState:t,store_INTERNAL:n,children:r}){let i;const getGraph=e=>{const t=i.current.graphsByVersion;if(t.has(e))return T(t.get(e));const n=Tn();return t.set(e,n),n},subscribeToTransactions=(e,t)=>{if(null==t){const{transactionSubscriptions:t}=l.current.getState(),n=Wn++;return t.set(n,e),{release:()=>{t.delete(n)}}}{const{nodeTransactionSubscriptions:n}=l.current.getState();n.has(t)||n.set(t,new Map);const o=Wn++;return T(n.get(t)).set(o,e),{release:()=>{const e=n.get(t);e&&(e.delete(o),0===e.size&&n.delete(t))}}}},addTransactionMetadata=e=>{startNextTreeIfNeeded(l.current);for(const t of Object.keys(e))T(l.current.getState().nextTree).transactionMetadata[t]=e[t]},replaceState=e=>{startNextTreeIfNeeded(l.current);const t=T(i.current.nextTree);let n;try{Un=!0,n=e(t)}finally{Un=!1}n!==t&&("production"!==process.env.NODE_ENV&&"undefined"!=typeof window&&window.$recoilDebugStates.push(n),i.current.nextTree=n,Nn().early&&notifyComponents(l.current,i.current,n),T(a.current)())},a=Dn(null),s=Ln((e=>{a.current=e}),[a]),l=yn((()=>null!=n?n:{storeID:Cn(),getState:()=>i.current,replaceState:replaceState,getGraph:getGraph,subscribeToTransactions:subscribeToTransactions,addTransactionMetadata:addTransactionMetadata}));null!=n&&(l.current=n),i=yn((()=>null!=e?initialStoreState_DEPRECATED(l.current,e):null!=t?initialStoreState(t):Sn()));const c=Mn((()=>null==kn?void 0:kn(i,(()=>i.current.currentTree.version))),[i]);return jn((()=>{const e=l.current;for(const t of new Set(e.getState().knownAtoms))_n(e,t,"get");return()=>{for(const t of e.getState().knownAtoms)xn(e,t)}}),[l]),o.createElement(Fn.Provider,{value:l},o.createElement(Hn.Provider,{value:c},o.createElement(Batcher,{setNotifyBatcherOfChange:s}),r))}function RecoilRoot(e){const{override:t,...n}=e,r=useStoreRef();return!1===t&&r.current!==zn?e.children:o.createElement(RecoilRoot_INTERNAL,n)}var $n={RecoilRoot:RecoilRoot,useStoreRef:useStoreRef,useRecoilMutableSource:useRecoilMutableSource};function shallowArrayEqual(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0,o=e.length;n<o;n++)if(e[n]!==t[n])return!1;return!0}var Gn=shallowArrayEqual;const{useEffect:Kn,useRef:qn}=o;function usePrevious(e){const t=qn();return Kn((()=>{t.current=e})),t.current}var Yn=usePrevious;const{useStoreRef:Zn}=$n,{SUSPENSE_TIMEOUT_MS:Xn}=Et,{updateRetainCount:Jn}=Et,{RetentionZone:Qn}=He,{useEffect:eo,useRef:to}=o,{isSSR:no}=Dt;function useRetain(e){if(W("recoil_memory_managament_2020"))return useRetain_ACTUAL(e)}function useRetain_ACTUAL(e){const t=undefined,n=(Array.isArray(e)?e:[e]).map((e=>e instanceof Qn?e:e.key)),o=Zn();eo((()=>{if(!W("recoil_memory_managament_2020"))return;const e=o.current;if(r.current&&!no)window.clearTimeout(r.current),r.current=null;else for(const t of n)Jn(e,t,1);return()=>{for(const t of n)Jn(e,t,-1)}}),[o,...n]);const r=to(),i=Yn(n);if(!(no||void 0!==i&&Gn(i,n))){const e=o.current;for(const t of n)Jn(e,t,1);if(i)for(const t of i)Jn(e,t,-1);r.current&&window.clearTimeout(r.current),r.current=window.setTimeout((()=>{r.current=null;for(const t of n)Jn(e,t,-1)}),Xn)}}var oo=useRetain;function useComponentName(){return"<component name not available>"}var ro=useComponentName;const{currentRendererSupportsUseSyncExternalStore:io,reactMode:ao,useMutableSource:so,useSyncExternalStore:lo}=ee,{useRecoilMutableSource:co,useStoreRef:uo}=$n,{isRecoilValue:po}=ce,{getRecoilValueAsLoadable:fo,setRecoilValue:ho,subscribeToRecoilValue:mo}=gt,{useCallback:vo,useEffect:go,useMemo:yo,useRef:bo,useState:So}=o,{isSSR:xo}=Dt;function handleLoadable(e,t,n){if("hasValue"===e.state)return e.contents;if("loading"===e.state){const t=undefined;throw new Promise((t=>{const o=n.current.getState().suspendedComponentResolvers;o.add(t),xo&&E(e.contents)&&e.contents.finally((()=>{o.delete(t)}))}))}throw"hasError"===e.state?e.contents:A(`Invalid value of loadable atom "${t.key}"`)}function validateRecoilValue(e,t){if(!po(e))throw A(`Invalid argument to ${t}: expected an atom or selector but got ${String(e)}`)}function useRecoilValueLoadable_SYNC_EXTERNAL_STORE(e){const t=uo(),n=ro(),o=vo((()=>{var n;process.env.NODE_ENV;const o=t.current,r=o.getState(),i=ao().early&&null!==(n=r.nextTree)&&void 0!==n?n:r.currentTree,a=undefined;return{loadable:fo(o,e,i),key:e.key}}),[t,e]),r=vo((e=>{let t;return()=>{var n,o;const r=e();return null!==(n=t)&&void 0!==n&&n.loadable.is(r.loadable)&&(null===(o=t)||void 0===o?void 0:o.key)===r.key?t:(t=r,r)}}),[]),i=yo((()=>r(o)),[o,r]),a=vo((o=>{const r=t.current,i=undefined;return mo(r,e,o,n).release}),[t,e,n]);return lo(a,i,i).loadable}function useRecoilValueLoadable_MUTABLE_SOURCE(e){const t=uo(),n=vo((()=>{var n;const o=t.current,r=o.getState(),i=ao().early&&null!==(n=r.nextTree)&&void 0!==n?n:r.currentTree;return fo(o,e,i)}),[t,e]),o=vo((()=>(process.env.NODE_ENV,n())),[n]),r=ro(),i=vo(((o,i)=>{const a=t.current,s=undefined;return mo(a,e,(()=>{if(!W("recoil_suppress_rerender_in_callback"))return i();const e=n();l.current.is(e)||i(),l.current=e}),r).release}),[t,e,r,n]),a=co();if(null==a)throw A("Recoil hooks must be used in components contained within a <RecoilRoot> component.");const s=so(a,o,i),l=bo(s);return go((()=>{l.current=s})),s}function useRecoilValueLoadable_TRANSITION_SUPPORT(e){const t=uo(),n=ro(),o=vo((()=>{var n;process.env.NODE_ENV;const o=t.current,r=o.getState(),i=ao().early&&null!==(n=r.nextTree)&&void 0!==n?n:r.currentTree;return fo(o,e,i)}),[t,e]),r=vo((()=>({loadable:o(),key:e.key})),[o,e.key]),i=vo((e=>{const t=r();return e.loadable.is(t.loadable)&&e.key===t.key?e:t}),[r]);go((()=>{const o=mo(t.current,e,(e=>{s(i)}),n);return s(i),o.release}),[n,e,t,i]);const[a,s]=So(r);return a.key!==e.key?r().loadable:a.loadable}function useRecoilValueLoadable_LEGACY(e){const t=uo(),[,n]=So([]),o=ro(),r=vo((()=>{var n;process.env.NODE_ENV;const o=t.current,r=o.getState(),i=ao().early&&null!==(n=r.nextTree)&&void 0!==n?n:r.currentTree;return fo(o,e,i)}),[t,e]),i=r(),a=bo(i);return go((()=>{a.current=i})),go((()=>{const i=t.current,s=i.getState(),l=mo(i,e,(e=>{var t;if(!W("recoil_suppress_rerender_in_callback"))return n([]);const o=r();null!==(t=a.current)&&void 0!==t&&t.is(o)||n(o),a.current=o}),o);if(s.nextTree)i.getState().queuedComponentCallbacks_DEPRECATED.push((()=>{a.current=null,n([])}));else{var c;if(!W("recoil_suppress_rerender_in_callback"))return n([]);const e=r();null!==(c=a.current)&&void 0!==c&&c.is(e)||n(e),a.current=e}return l.release}),[o,r,e,t]),i}function useRecoilValueLoadable(e){return"production"!==process.env.NODE_ENV&&validateRecoilValue(e,"useRecoilValueLoadable"),W("recoil_memory_managament_2020")&&oo(e),{TRANSITION_SUPPORT:useRecoilValueLoadable_TRANSITION_SUPPORT,SYNC_EXTERNAL_STORE:io()?useRecoilValueLoadable_SYNC_EXTERNAL_STORE:useRecoilValueLoadable_TRANSITION_SUPPORT,MUTABLE_SOURCE:useRecoilValueLoadable_MUTABLE_SOURCE,LEGACY:useRecoilValueLoadable_LEGACY}[ao().mode](e)}function useRecoilValue(e){"production"!==process.env.NODE_ENV&&validateRecoilValue(e,"useRecoilValue");const t=uo(),n=undefined;return handleLoadable(useRecoilValueLoadable(e),e,t)}function useSetRecoilState(e){"production"!==process.env.NODE_ENV&&validateRecoilValue(e,"useSetRecoilState");const t=uo();return vo((n=>{ho(t.current,e,n)}),[t,e])}function useRecoilState(e){return"production"!==process.env.NODE_ENV&&validateRecoilValue(e,"useRecoilState"),[useRecoilValue(e),useSetRecoilState(e)]}var wo={useRecoilState:useRecoilState,useRecoilValue:useRecoilValue,useRecoilValueLoadable:useRecoilValueLoadable,useSetRecoilState:useSetRecoilState};const{batchUpdates:_o}=Lt,{DEFAULT_VALUE:Ao,getNode:Eo}=Se,{AbstractRecoilValue:To,setRecoilValueLoadable:Vo}=gt,{cloneSnapshot:Co}=mn,{useCallback:ko,useEffect:No,useRef:Ro,useState:Io}=o;function gotoSnapshot(e,t){var n;const o=e.getState(),r=null!==(n=o.nextTree)&&void 0!==n?n:o.currentTree,i=t.getStore_INTERNAL().getState().currentTree;_o((()=>{const n=new Set;for(const e of[r.atomValues.keys(),i.atomValues.keys()])for(const t of e){var o,a;(null===(o=r.atomValues.get(t))||void 0===o?void 0:o.contents)!==(null===(a=i.atomValues.get(t))||void 0===a?void 0:a.contents)&&Eo(t).shouldRestoreFromSnapshots&&n.add(t)}n.forEach((t=>{Vo(e,new To(t),i.atomValues.has(t)?T(i.atomValues.get(t)):Ao)})),e.replaceState((e=>({...e,stateID:t.getID()})))}))}var Oo={gotoSnapshot:gotoSnapshot};const{useMemo:Lo}=o,{loadableWithValue:Po}=U,{initializeNode:jo}=et,{DEFAULT_VALUE:Mo,getNode:Do}=Se,{copyTreeState:Bo,getRecoilValueAsLoadable:zo,invalidateDownstreams:Uo,writeLoadableToTreeState:Fo}=gt;function isAtom(e){return"atom"===Do(e.key).nodeType}class Ho{constructor(e,t){_defineProperty(this,"_store",void 0),_defineProperty(this,"_treeState",void 0),_defineProperty(this,"_changes",void 0),_defineProperty(this,"get",(e=>{if(this._changes.has(e.key))return this._changes.get(e.key);if(!isAtom(e))throw A("Reading selectors within atomicUpdate is not supported");const t=zo(this._store,e,this._treeState);if("hasValue"===t.state)return t.contents;throw"hasError"===t.state?t.contents:A(`Expected Recoil atom ${e.key} to have a value, but it is in a loading state.`)})),_defineProperty(this,"set",((e,t)=>{if(!isAtom(e))throw A("Setting selectors within atomicUpdate is not supported");if("function"==typeof t){const n=this.get(e);this._changes.set(e.key,t(n))}else jo(this._store,e.key,"set"),this._changes.set(e.key,t)})),_defineProperty(this,"reset",(e=>{this.set(e,Mo)})),this._store=e,this._treeState=t,this._changes=new Map}newTreeState_INTERNAL(){if(0===this._changes.size)return this._treeState;const e=Bo(this._treeState);for(const[t,n]of this._changes)Fo(e,t,Po(n));return Uo(this._store,e),e}}function atomicUpdater(e){return t=>{e.replaceState((n=>{const o=new Ho(e,n);return t(o),o.newTreeState_INTERNAL()}))}}var Wo,$o=atomicUpdater,Go=Object.freeze({__proto__:null,atomicUpdater:$o});function invariant(e,t){if(!e)throw new Error(t)}var Ko,qo=invariant;const{atomicUpdater:Yo}=Go,{batchUpdates:Zo}=Lt,{DEFAULT_VALUE:Xo}=Se,{useStoreRef:Jo}=$n,{refreshRecoilValue:Qo,setRecoilValue:er}=gt,{cloneSnapshot:tr}=mn,{gotoSnapshot:nr}=Oo,{useCallback:or}=o;class rr{}const ir=new rr;function recoilCallback(e,t,n,o){let r=ir,i;var a;(Zo((()=>{const a="useRecoilCallback() expects a function that returns a function: it accepts a function of the type (RecoilInterface) => (Args) => ReturnType and returns a callback function (Args) => ReturnType, where RecoilInterface is an object {snapshot, set, ...} and Args and ReturnType are the argument and return types of the callback you want to create. Please see the docs at recoiljs.org for details.";if("function"!=typeof t)throw A(a);const s=Ge({...null!=o?o:{},set:(t,n)=>er(e,t,n),reset:t=>er(e,t,Xo),refresh:t=>Qo(e,t),gotoSnapshot:t=>nr(e,t),transact_UNSTABLE:t=>Yo(e)(t)},{snapshot:()=>{const t=tr(e);return i=t.retain(),t}}),l=t(s);if("function"!=typeof l)throw A(a);r=l(...n)})),r instanceof rr&&("production"!==process.env.NODE_ENV?qo(!1,"batchUpdates should return immediately"):qo(!1)),E(r))?r=r.finally((()=>{var e;null===(e=i)||void 0===e||e()})):null===(a=i)||void 0===a||a();return r}function useRecoilCallback(e,t){const n=Jo();return or(((...t)=>recoilCallback(n.current,e,t)),null!=t?[...t,n]:void 0)}var ar={recoilCallback:recoilCallback,useRecoilCallback:useRecoilCallback};const{useCallback:sr}=o,{atomicUpdater:lr}=Go,{useMemo:cr}=o;class ur{constructor(e){_defineProperty(this,"value",void 0),this.value=e}}var dr,pr=ur,fr=Object.freeze({__proto__:null,WrappedValue:pr});class hr extends Error{}class mr{constructor(e){var t,n,o;_defineProperty(this,"_name",void 0),_defineProperty(this,"_numLeafs",void 0),_defineProperty(this,"_root",void 0),_defineProperty(this,"_onHit",void 0),_defineProperty(this,"_onSet",void 0),_defineProperty(this,"_mapNodeValue",void 0),this._name=null==e?void 0:e.name,this._numLeafs=0,this._root=null,this._onHit=null!==(t=null==e?void 0:e.onHit)&&void 0!==t?t:()=>{},this._onSet=null!==(n=null==e?void 0:e.onSet)&&void 0!==n?n:()=>{},this._mapNodeValue=null!==(o=null==e?void 0:e.mapNodeValue)&&void 0!==o?o:e=>e}size(){return this._numLeafs}root(){return this._root}get(e,t){var n;return null===(n=this.getLeafNode(e,t))||void 0===n?void 0:n.value}getLeafNode(e,t){if(null==this._root)return;let n=this._root;for(;n;){if(null==t||t.onNodeVisit(n),"leaf"===n.type)return this._onHit(n),n;const o=this._mapNodeValue(e(n.nodeKey));n=n.branches.get(o)}}set(e,t,n){const addLeaf=()=>{var o,r,i,a;let s,l;for(const[t,o]of e){var c,u,d;const e=this._root;if("leaf"===(null==e?void 0:e.type))throw this.invalidCacheError();const r=s;if(s=r?r.branches.get(l):e,s=null!==(c=s)&&void 0!==c?c:{type:"branch",nodeKey:t,parent:r,branches:new Map,branchKey:l},"branch"!==s.type||s.nodeKey!==t)throw this.invalidCacheError();null==r||r.branches.set(l,s),null==n||null===(u=n.onNodeVisit)||void 0===u||u.call(n,s),l=this._mapNodeValue(o),this._root=null!==(d=this._root)&&void 0!==d?d:s}const p=s?null===(o=s)||void 0===o?void 0:o.branches.get(l):this._root;if(null!=p&&("leaf"!==p.type||p.branchKey!==l))throw this.invalidCacheError();const f={type:"leaf",value:t,parent:s,branchKey:l};null===(r=s)||void 0===r||r.branches.set(l,f),this._root=null!==(i=this._root)&&void 0!==i?i:f,this._numLeafs++,this._onSet(f),null==n||null===(a=n.onNodeVisit)||void 0===a||a.call(n,f)};try{addLeaf()}catch(e){if(!(e instanceof hr))throw e;this.clear(),addLeaf()}}delete(e){const t=this.root();if(!t)return!1;if(e===t)return this._root=null,this._numLeafs=0,!0;let n=e.parent,o=e.branchKey;for(;n;){var r;if(n.branches.delete(o),n===t)return 0===n.branches.size?(this._root=null,this._numLeafs=0):this._numLeafs--,!0;if(n.branches.size>0)break;o=null===(r=n)||void 0===r?void 0:r.branchKey,n=n.parent}for(;n!==t;n=n.parent)if(null==n)return!1;return this._numLeafs--,!0}clear(){this._numLeafs=0,this._root=null}invalidCacheError(){const e=undefined;throw G("Invalid cache values. This happens when selectors do not return consistent values for the same input dependency values. That may also be caused when using Fast Refresh to change a selector implementation. Resetting cache."+(null!=this._name?` - ${this._name}`:"")),new hr}}var vr,gr=mr,yr=Object.freeze({__proto__:null,TreeCache:gr});class br{constructor(e){var t;_defineProperty(this,"_maxSize",void 0),_defineProperty(this,"_size",void 0),_defineProperty(this,"_head",void 0),_defineProperty(this,"_tail",void 0),_defineProperty(this,"_map",void 0),_defineProperty(this,"_keyMapper",void 0),this._maxSize=e.maxSize,this._size=0,this._head=null,this._tail=null,this._map=new Map,this._keyMapper=null!==(t=e.mapKey)&&void 0!==t?t:e=>e}head(){return this._head}tail(){return this._tail}size(){return this._size}maxSize(){return this._maxSize}has(e){return this._map.has(this._keyMapper(e))}get(e){const t=this._keyMapper(e),n=this._map.get(t);if(n)return this.set(e,n.value),n.value}set(e,t){const n=this._keyMapper(e),o=undefined;this._map.get(n)&&this.delete(e);const r=this.head(),i={key:e,right:r,left:null,value:t};r?r.left=i:this._tail=i,this._map.set(n,i),this._head=i,this._size++,this._maybeDeleteLRU()}_maybeDeleteLRU(){this.size()>this.maxSize()&&this.deleteLru()}deleteLru(){const e=this.tail();e&&this.delete(e.key)}delete(e){const t=this._keyMapper(e);if(!this._size||!this._map.has(t))return;const n=T(this._map.get(t)),o=n.right,r=n.left;o&&(o.left=n.left),r&&(r.right=n.right),n===this.head()&&(this._head=o),n===this.tail()&&(this._tail=r),this._map.delete(t),this._size--}clear(){this._size=0,this._head=null,this._tail=null,this._map=new Map}}var Sr,xr=br,wr=Object.freeze({__proto__:null,LRUCache:xr});const{LRUCache:_r}=wr,{TreeCache:Ar}=yr;function treeCacheLRU({name:e,maxSize:t,mapNodeValue:n=e=>e}){const o=new _r({maxSize:t}),r=new Ar({name:e,mapNodeValue:n,onHit:e=>{o.set(e,!0)},onSet:e=>{const n=o.tail();o.set(e,!0),n&&r.size()>t&&r.delete(n.key)}});return r}var Er=treeCacheLRU;const Tr=15;function stringify$1(e,t,n){if("string"==typeof e&&!e.includes('"')&&!e.includes("\\"))return`"${e}"`;switch(typeof e){case"undefined":return"";case"boolean":return e?"true":"false";case"number":case"symbol":return String(e);case"string":return JSON.stringify(e);case"function":if(!0!==(null==t?void 0:t.allowFunctions))throw A("Attempt to serialize function in a Recoil cache key");return`__FUNCTION(${e.name})__`}if(null===e)return"null";var o;if("object"!=typeof e)return null!==(o=JSON.stringify(e))&&void 0!==o?o:"";if(E(e))return"__PROMISE__";if(Array.isArray(e))return`[${e.map(((e,n)=>stringify$1(e,t,n.toString())))}]`;if("function"==typeof e.toJSON)return stringify$1(e.toJSON(n),t,n);if(e instanceof Map){const o={};for(const[n,r]of e)o["string"==typeof n?n:stringify$1(n,t)]=r;return stringify$1(o,t,n)}return e instanceof Set?stringify$1(Array.from(e).sort(((e,n)=>stringify$1(e,t).localeCompare(stringify$1(n,t)))),t,n):void 0!==Symbol&&null!=e[Symbol.iterator]&&"function"==typeof e[Symbol.iterator]?stringify$1(Array.from(e),t,n):`{${Object.keys(e).filter((t=>void 0!==e[t])).sort().map((n=>`${stringify$1(n,t)}:${stringify$1(e[n],t,n)}`)).join(",")}}`}function stableStringify(e,t={allowFunctions:!1}){if("production"!==process.env.NODE_ENV&&"undefined"!=typeof window){const n=window.performance?window.performance.now():0,o=stringify$1(e,t),r=window.performance?window.performance.now():0;return r-n>Tr&&(console.groupCollapsed(`Recoil: Spent ${r-n}ms computing a cache key`),console.warn(e,o),console.groupEnd()),o}return stringify$1(e,t)}var Vr=stableStringify;const{TreeCache:Cr}=yr,kr={equality:"reference",eviction:"keep-all",maxSize:1/0};function treeCacheFromPolicy({equality:e=kr.equality,eviction:t=kr.eviction,maxSize:n=kr.maxSize}=kr,o){const r=undefined;return getTreeCache(t,n,getValueMapper(e),o)}function getValueMapper(e){switch(e){case"reference":return e=>e;case"value":return e=>Vr(e)}throw A(`Unrecognized equality policy ${e}`)}function getTreeCache(e,t,n,o){switch(e){case"keep-all":return new Cr({name:o,mapNodeValue:n});case"lru":return Er({name:o,maxSize:T(t),mapNodeValue:n});case"most-recent":return Er({name:o,maxSize:1,mapNodeValue:n})}throw A(`Unrecognized eviction policy ${e}`)}var Nr=treeCacheFromPolicy;function isNode(e){var t,n;if("undefined"==typeof window)return!1;const o=undefined,r=null!==(n=(null!=e?null!==(t=e.ownerDocument)&&void 0!==t?t:e:document).defaultView)&&void 0!==n?n:window;return!(null==e||!("function"==typeof r.Node?e instanceof r.Node:"object"==typeof e&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName))}var Rr=isNode;const{isReactNative:Ir,isWindow:Or}=Dt;function shouldNotBeFrozen(e){if(null===e||"object"!=typeof e)return!0;switch(typeof e.$$typeof){case"symbol":case"number":return!0}return null!=e["@@__IMMUTABLE_ITERABLE__@@"]||null!=e["@@__IMMUTABLE_KEYED__@@"]||null!=e["@@__IMMUTABLE_INDEXED__@@"]||null!=e["@@__IMMUTABLE_ORDERED__@@"]||null!=e["@@__IMMUTABLE_RECORD__@@"]||(!!Rr(e)||(!!E(e)||(e instanceof Error||(!!ArrayBuffer.isView(e)||!(Ir||!Or(e))))))}function deepFreezeValue(e){if("object"==typeof e&&!shouldNotBeFrozen(e)){Object.freeze(e);for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)){const n=e[t];"object"!=typeof n||null==n||Object.isFrozen(n)||deepFreezeValue(n)}Object.seal(e)}}var Lr=deepFreezeValue;const{isLoadable:Pr,loadableWithError:jr,loadableWithPromise:Mr,loadableWithValue:Dr}=U,{WrappedValue:Br}=fr,{getNodeLoadable:zr,peekNodeLoadable:Ur,setNodeValue:Fr}=et,{saveDepsToStore:Hr}=Ne,{DEFAULT_VALUE:Wr,getConfigDeletionHandler:$r,getNode:Gr,registerNode:Kr}=Se,{isRecoilValue:qr}=ce,{markRecoilValueModified:Yr}=gt,{retainedByOptionWithDefault:Zr}=Et,{recoilCallback:Xr}=ar;class Jr{}const Qr=new Jr,ei=[],ti=new Map,ni=(()=>{let e=0;return()=>e++})();function selector(e){let t=null;const{key:n,get:o,cachePolicy_UNSTABLE:r}=e,i=null!=e.set?e.set:void 0;if("production"!==process.env.NODE_ENV){if("string"!=typeof n)throw A("A key option with a unique string value must be provided when creating a selector.");if("function"!=typeof o)throw A("Selectors must specify a get callback option to get the selector value.")}const a=new Set,s=Nr(null!=r?r:{equality:"reference",eviction:"keep-all"},n),l=Zr(e.retainedBy_UNSTABLE),c=new Map;let u=0;function selectorIsLive(){return!W("recoil_memory_managament_2020")||u>0}function selectorInit(e){return e.getState().knownSelectors.add(n),u++,()=>{u--}}function selectorShouldDeleteConfigOnRelease(){return void 0!==$r(n)&&!selectorIsLive()}function resolveAsync(e,t,n,o,r){setCache(t,o,r),notifyStoresOfResolvedAsync(e,n)}function notifyStoresOfResolvedAsync(e,t){isLatestExecution(e,t)&&clearExecutionInfo(e),notifyWaitingStores(t,!0)}function notifyStoresOfNewAsyncDep(e,t){if(isLatestExecution(e,t)){const n=undefined;T(getExecutionInfo(e)).stateVersions.clear(),notifyWaitingStores(t,!1)}}function notifyWaitingStores(e,n){const o=ti.get(e);if(null!=o){for(const e of o)Yr(e,T(t));n&&ti.delete(e)}}function markStoreWaitingForResolvedAsync(e,t){let n=ti.get(t);null==n&&ti.set(t,n=new Set),n.add(e)}function wrapResultPromise(e,t,n,o,r,i){return t.then((t=>{if(!selectorIsLive())throw clearExecutionInfo(e),Qr;const i=Dr(t);return resolveAsync(e,n,r,i,o),t})).catch((t=>{if(!selectorIsLive())throw clearExecutionInfo(e),Qr;if(E(t))return wrapPendingDependencyPromise(e,t,n,o,r,i);const a=jr(t);throw resolveAsync(e,n,r,a,o),t}))}function wrapPendingDependencyPromise(e,t,n,o,r,i){return t.then((o=>{if(!selectorIsLive())throw clearExecutionInfo(e),Qr;null!=i.loadingDepKey&&i.loadingDepPromise===t?n.atomValues.set(i.loadingDepKey,Dr(o)):e.getState().knownSelectors.forEach((e=>{n.atomValues.delete(e)}));const a=getLoadableFromCacheAndUpdateDeps(e,n);if(a&&"loading"!==a.state){if((isLatestExecution(e,r)||null==getExecutionInfo(e))&&notifyStoresOfResolvedAsync(e,r),"hasValue"===a.state)return a.contents;throw a.contents}if(!isLatestExecution(e,r)){const t=getInProgressExecutionInfo(e,n);if(null!=t)return t.loadingLoadable.contents}const[s,l]=evaluateSelectorGetter(e,n,r);if("loading"!==s.state&&resolveAsync(e,n,r,s,l),"hasError"===s.state)throw s.contents;return s.contents})).catch((t=>{if(t instanceof Jr)throw Qr;if(!selectorIsLive())throw clearExecutionInfo(e),Qr;const i=jr(t);throw resolveAsync(e,n,r,i,o),t}))}function updateDeps(e,t,o,r){var i,s,l,c,u,d,p;(isLatestExecution(e,r)||t.version===(null===(i=e.getState())||void 0===i||null===(s=i.currentTree)||void 0===s?void 0:s.version)||t.version===(null===(l=e.getState())||void 0===l||null===(c=l.nextTree)||void 0===c?void 0:c.version))&&Hr(n,o,e,null!==(u=null===(d=e.getState())||void 0===d||null===(p=d.nextTree)||void 0===p?void 0:p.version)&&void 0!==u?u:e.getState().currentTree.version);for(const e of o)a.add(e)}function evaluateSelectorGetter(e,n,r){let i=!0,a=!0;const finishEvaluation=()=>{a=!1};let s,l=!1,c;const u={loadingDepKey:null,loadingDepPromise:null},d=new Map;function getRecoilValue({key:t}){const o=zr(e,n,t);switch(d.set(t,o),i||(updateDeps(e,n,new Set(d.keys()),r),notifyStoresOfNewAsyncDep(e,r)),o.state){case"hasValue":return o.contents;case"hasError":throw o.contents;case"loading":throw u.loadingDepKey=t,u.loadingDepPromise=o.contents,o.contents}throw A("Invalid Loadable state")}const getCallback=n=>(...o)=>{if(a)throw A("Callbacks from getCallback() should only be called asynchronously after the selector is evalutated. It can be used for selectors to return objects with callbacks that can work with Recoil state without a subscription.");return null==t&&("production"!==process.env.NODE_ENV?qo(!1,"Recoil Value can never be null"):qo(!1)),Xr(e,n,o,{node:t})};try{s=o({get:getRecoilValue,getCallback:getCallback}),s=qr(s)?getRecoilValue(s):s,Pr(s)&&("hasError"===s.state&&(l=!0),s=s.contents),E(s)?s=wrapResultPromise(e,s,n,d,r,u).finally(finishEvaluation):finishEvaluation(),s=s instanceof Br?s.value:s}catch(t){s=t,E(s)?s=wrapPendingDependencyPromise(e,s,n,d,r,u).finally(finishEvaluation):(l=!0,finishEvaluation())}return c=l?jr(s):E(s)?Mr(s):Dr(s),i=!1,updateExecutionInfoDepValues(e,r,d),updateDeps(e,n,new Set(d.keys()),r),[c,d]}function getLoadableFromCacheAndUpdateDeps(e,t){let o=t.atomValues.get(n);if(null!=o)return o;const r=new Set;try{o=s.get((n=>("string"!=typeof n&&("production"!==process.env.NODE_ENV?qo(!1,"Cache nodeKey is type string"):qo(!1)),zr(e,t,n).contents)),{onNodeVisit:e=>{"branch"===e.type&&e.nodeKey!==n&&r.add(e.nodeKey)}})}catch(e){throw A(`Problem with cache lookup for selector "${n}": ${e.message}`)}var i;o&&(t.atomValues.set(n,o),updateDeps(e,t,r,null===(i=getExecutionInfo(e))||void 0===i?void 0:i.executionID));return o}function getSelectorLoadableAndUpdateDeps(e,t){const n=getLoadableFromCacheAndUpdateDeps(e,t);if(null!=n)return clearExecutionInfo(e),n;const o=getInProgressExecutionInfo(e,t);var r;if(null!=o)return"loading"===(null===(r=o.loadingLoadable)||void 0===r?void 0:r.state)&&markStoreWaitingForResolvedAsync(e,o.executionID),o.loadingLoadable;const i=ni(),[a,s]=evaluateSelectorGetter(e,t,i);return"loading"===a.state?(setExecutionInfo(e,i,a,s,t),markStoreWaitingForResolvedAsync(e,i)):(clearExecutionInfo(e),setCache(t,a,s)),a}function getInProgressExecutionInfo(e,t){const n=Pt([c.has(e)?[T(c.get(e))]:[],fe($e(c,(([t])=>t!==e)),(([,e])=>e))]);function anyDepChanged(n){for(const[o,r]of n)if(!zr(e,t,o).is(r))return!0;return!1}for(const e of n){if(e.stateVersions.get(t.version)||!anyDepChanged(e.depValuesDiscoveredSoFarDuringAsyncWork))return e.stateVersions.set(t.version,!0),e;e.stateVersions.set(t.version,!1)}}function getExecutionInfo(e){return c.get(e)}function setExecutionInfo(e,t,n,o,r){c.set(e,{depValuesDiscoveredSoFarDuringAsyncWork:o,executionID:t,loadingLoadable:n,stateVersions:new Map([[r.version,!0]])})}function updateExecutionInfoDepValues(e,t,n){if(isLatestExecution(e,t)){const t=getExecutionInfo(e);null!=t&&(t.depValuesDiscoveredSoFarDuringAsyncWork=n)}}function clearExecutionInfo(e){c.delete(e)}function isLatestExecution(e,t){var n;return t===(null===(n=getExecutionInfo(e))||void 0===n?void 0:n.executionID)}function depValuesToDepRoute(e){return Array.from(e.entries()).map((([e,t])=>[e,t.contents]))}function setCache(t,o,r){"production"!==process.env.NODE_ENV&&"loading"!==o.state&&!1===Boolean(e.dangerouslyAllowMutability)&&Lr(o.contents),t.atomValues.set(n,o);try{s.set(depValuesToDepRoute(r),o)}catch(e){throw A(`Problem with setting cache for selector "${n}": ${e.message}`)}}function detectCircularDependencies(e){if(ei.includes(n)){const e=`Recoil selector has circular dependencies: ${ei.slice(ei.indexOf(n)).join(" → ")}`;return jr(A(e))}ei.push(n);try{return e()}finally{ei.pop()}}function selectorPeek(e,t){const o=t.atomValues.get(n);return null!=o?o:s.get((n=>{var o;return"string"!=typeof n&&("production"!==process.env.NODE_ENV?qo(!1,"Cache nodeKey is type string"):qo(!1)),null===(o=Ur(e,t,n))||void 0===o?void 0:o.contents}))}function selectorGet(e,t){return detectCircularDependencies((()=>getSelectorLoadableAndUpdateDeps(e,t)))}function invalidateSelector(e){e.atomValues.delete(n)}function clearSelectorCache(e,n){null==t&&("production"!==process.env.NODE_ENV?qo(!1,"Recoil Value can never be null"):qo(!1));for(const t of a){var o;const r=Gr(t);null===(o=r.clearCache)||void 0===o||o.call(r,e,n)}a.clear(),invalidateSelector(n),s.clear(),Yr(e,t)}if(null!=i){const o=undefined;return t=Kr({key:n,nodeType:"selector",peek:selectorPeek,get:selectorGet,set:(e,t,o)=>{let r=!1;const a=new Map;function getRecoilValue({key:o}){if(r)throw A("Recoil: Async selector sets are not currently supported.");const i=zr(e,t,o);if("hasValue"===i.state)return i.contents;if("loading"===i.state){const e=`Getting value of asynchronous atom or selector "${o}" in a pending state while setting selector "${n}" is not yet supported.`;throw G(e),A(e)}throw i.contents}function setRecoilState(n,o){if(r){const e="Recoil: Async selector sets are not currently supported.";throw G(e),A(e)}const i="function"==typeof o?o(getRecoilValue(n)):o,s=undefined;Fr(e,t,n.key,i).forEach(((e,t)=>a.set(t,e)))}function resetRecoilState(e){setRecoilState(e,Wr)}const s=i({set:setRecoilState,get:getRecoilValue,reset:resetRecoilState},o);if(void 0!==s)throw E(s)?A("Recoil: Async selector sets are not currently supported."):A("Recoil: selector set should be a void function.");return r=!0,a},init:selectorInit,invalidate:invalidateSelector,clearCache:clearSelectorCache,shouldDeleteConfigOnRelease:selectorShouldDeleteConfigOnRelease,dangerouslyAllowMutability:e.dangerouslyAllowMutability,shouldRestoreFromSnapshots:!1,retainedBy:l})}return t=Kr({key:n,nodeType:"selector",peek:selectorPeek,get:selectorGet,init:selectorInit,invalidate:invalidateSelector,clearCache:clearSelectorCache,shouldDeleteConfigOnRelease:selectorShouldDeleteConfigOnRelease,dangerouslyAllowMutability:e.dangerouslyAllowMutability,shouldRestoreFromSnapshots:!1,retainedBy:l})}selector.value=e=>new Br(e);var oi=selector;const{isLoadable:ri,loadableWithError:ii,loadableWithPromise:ai,loadableWithValue:si}=U,{WrappedValue:li}=fr,{peekNodeInfo:ci}=et,{DEFAULT_VALUE:ui,DefaultValue:di,getConfigDeletionHandler:pi,registerNode:fi,setConfigDeletionHandler:hi}=Se,{isRecoilValue:mi}=ce,{getRecoilValueAsLoadable:vi,markRecoilValueModified:gi,setRecoilValue:yi,setRecoilValueLoadable:bi}=gt,{retainedByOptionWithDefault:Si}=Et,unwrap=e=>e instanceof li?e.value:e;function baseAtom(e){const{key:t,persistence_UNSTABLE:n}=e,o=Si(e.retainedBy_UNSTABLE);let r=0;function unwrapPromise(e){return ai(e.then((e=>(i=si(e),e))).catch((e=>{throw i=ii(e),e})))}let i=E(e.default)?unwrapPromise(e.default):ri(e.default)?"loading"===e.default.state?unwrapPromise(e.default.contents):e.default:si(unwrap(e.default)),a;maybeFreezeValueOrPromise(i.contents);const s=new Map;function maybeFreezeValueOrPromise(t){return"production"!==process.env.NODE_ENV&&!0!==e.dangerouslyAllowMutability?E(t)?t.then((e=>(Lr(e),e))):(Lr(t),t):t}function wrapPendingPromise(e,n){const o=n.then((n=>{var r,i;const a=undefined;return(null===(i=(null!==(r=e.getState().nextTree)&&void 0!==r?r:e.getState().currentTree).atomValues.get(t))||void 0===i?void 0:i.contents)===o&&yi(e,l,n),n})).catch((n=>{var r,i;const a=undefined;throw(null===(i=(null!==(r=e.getState().nextTree)&&void 0!==r?r:e.getState().currentTree).atomValues.get(t))||void 0===i?void 0:i.contents)===o&&bi(e,l,ii(n)),n}));return o}function initAtom(n,o,a){var c;r++;const cleanupAtom=()=>{var e;r--,null===(e=s.get(n))||void 0===e||e.forEach((e=>e())),s.delete(n)};if(n.getState().knownAtoms.add(t),"loading"===i.state){const notifyDefaultSubscribers=()=>{var e;const o=undefined;(null!==(e=n.getState().nextTree)&&void 0!==e?e:n.getState().currentTree).atomValues.has(t)||gi(n,l)};i.contents.finally(notifyDefaultSubscribers)}const u=null!==(c=e.effects)&&void 0!==c?c:e.effects_UNSTABLE;if(null!=u){let f=ui,h=!0,m=!1,v=null;function getLoadable(e){if(h&&e.key===t){const e=f;return e instanceof di?peekAtom(n,o):E(e)?ai(e.then((e=>e instanceof di?i.toPromise():e))):si(e)}return vi(n,e)}function getPromise(e){return getLoadable(e).toPromise()}function getInfo_UNSTABLE(e){var o;const r=ci(n,null!==(o=n.getState().nextTree)&&void 0!==o?o:n.getState().currentTree,e.key);return!h||e.key!==t||f instanceof di?r:{...r,isSet:!0,loadable:getLoadable(e)}}const setSelf=e=>t=>{if(h){const n=getLoadable(l),o="hasValue"===n.state?n.contents:ui;f="function"==typeof t?t(o):t,E(f)&&(f=f.then((t=>(v={effect:e,value:t},t))))}else{if(E(t))throw A("Setting atoms to async values is not implemented.");"function"!=typeof t&&(v={effect:e,value:unwrap(t)}),yi(n,l,"function"==typeof t?n=>{const o=unwrap(t(n));return v={effect:e,value:o},o}:unwrap(t))}},resetSelf=e=>()=>setSelf(e)(ui),onSet=e=>o=>{var r;const{release:a}=n.subscribeToTransactions((n=>{var r;let{currentTree:a,previousTree:s}=n.getState();s||(G("Transaction subscribers notified without a next tree being present -- this is a bug in Recoil"),s=a);const l=null!==(r=a.atomValues.get(t))&&void 0!==r?r:i;if("hasValue"===l.state){var c,u,d,p;const n=l.contents,r=null!==(c=s.atomValues.get(t))&&void 0!==c?c:i,f="hasValue"===r.state?r.contents:ui;(null===(u=v)||void 0===u?void 0:u.effect)!==e||(null===(d=v)||void 0===d?void 0:d.value)!==n?o(n,f,!a.atomValues.has(t)):(null===(p=v)||void 0===p?void 0:p.effect)===e&&(v=null)}}),t);s.set(n,[...null!==(r=s.get(n))&&void 0!==r?r:[],a])};for(const g of u)try{const b=g({node:l,storeID:n.storeID,parentStoreID_UNSTABLE:n.parentStoreID,trigger:a,setSelf:setSelf(g),resetSelf:resetSelf(g),onSet:onSet(g),getPromise:getPromise,getLoadable:getLoadable,getInfo_UNSTABLE:getInfo_UNSTABLE});var d;if(null!=b)s.set(n,[...null!==(d=s.get(n))&&void 0!==d?d:[],b])}catch(S){f=S,m=!0}if(h=!1,!(f instanceof di)){var p;const w=m?ii(f):E(f)?ai(wrapPendingPromise(n,f)):si(unwrap(f));maybeFreezeValueOrPromise(w.contents),o.atomValues.set(t,w),null===(p=n.getState().nextTree)||void 0===p||p.atomValues.set(t,w)}}return cleanupAtom}function peekAtom(e,n){var o,r;return null!==(o=null!==(r=n.atomValues.get(t))&&void 0!==r?r:a)&&void 0!==o?o:i}function getAtom(e,o){if(o.atomValues.has(t))return T(o.atomValues.get(t));if(o.nonvalidatedAtoms.has(t)){if(null!=a)return a;if(null==n)return pe(`Tried to restore a persisted value for atom ${t} but it has no persistence settings.`),i;const e=o.nonvalidatedAtoms.get(t),r=n.validator(e,ui),s=r instanceof di?i:si(r);return a=s,a}return i}function invalidateAtom(){a=void 0}function setAtom(e,n,o){if(n.atomValues.has(t)){const e=T(n.atomValues.get(t));if("hasValue"===e.state&&o===e.contents)return new Map}else if(!n.nonvalidatedAtoms.has(t)&&o instanceof di)return new Map;return maybeFreezeValueOrPromise(o),a=void 0,(new Map).set(t,si(o))}function shouldDeleteConfigOnReleaseAtom(){return void 0!==pi(t)&&r<=0}const l=fi({key:t,nodeType:"atom",peek:peekAtom,get:getAtom,set:setAtom,init:initAtom,invalidate:invalidateAtom,shouldDeleteConfigOnRelease:shouldDeleteConfigOnReleaseAtom,dangerouslyAllowMutability:e.dangerouslyAllowMutability,persistence_UNSTABLE:e.persistence_UNSTABLE?{type:e.persistence_UNSTABLE.type,backButton:e.persistence_UNSTABLE.backButton}:void 0,shouldRestoreFromSnapshots:!0,retainedBy:o});return l}function atom(e){if("production"!==process.env.NODE_ENV&&"string"!=typeof e.key)throw A("A key option with a unique string value must be provided when creating an atom.");const{...t}=e,n="default"in e?e.default:new Promise((()=>{}));return mi(n)?atomWithFallback({...t,default:n}):baseAtom({...t,default:n})}function atomWithFallback(e){const t=atom({...e,default:ui,persistence_UNSTABLE:void 0===e.persistence_UNSTABLE?void 0:{...e.persistence_UNSTABLE,validator:t=>t instanceof di?t:T(e.persistence_UNSTABLE).validator(t,ui)},effects:e.effects,effects_UNSTABLE:e.effects_UNSTABLE}),n=oi({key:`${e.key}__withFallback`,get:({get:n})=>{const o=n(t);return o instanceof di?e.default:o},set:({set:e},n)=>e(t,n),cachePolicy_UNSTABLE:{eviction:"most-recent"},dangerouslyAllowMutability:e.dangerouslyAllowMutability});return hi(n.key,pi(e.key)),n}atom.value=e=>new li(e);var xi=atom;class wi{constructor(e){var t;_defineProperty(this,"_map",void 0),_defineProperty(this,"_keyMapper",void 0),this._map=new Map,this._keyMapper=null!==(t=null==e?void 0:e.mapKey)&&void 0!==t?t:e=>e}size(){return this._map.size}has(e){return this._map.has(this._keyMapper(e))}get(e){return this._map.get(this._keyMapper(e))}set(e,t){this._map.set(this._keyMapper(e),t)}delete(e){this._map.delete(this._keyMapper(e))}clear(){this._map.clear()}}var _i,Ai=wi,Ei=Object.freeze({__proto__:null,MapCache:Ai});const{LRUCache:Ti}=wr,{MapCache:Vi}=Ei,Ci={equality:"reference",eviction:"none",maxSize:1/0};function cacheFromPolicy({equality:e=Ci.equality,eviction:t=Ci.eviction,maxSize:n=Ci.maxSize}=Ci){const o=undefined,r=undefined;return getCache(t,n,getValueMapper$1(e))}function getValueMapper$1(e){switch(e){case"reference":return e=>e;case"value":return e=>Vr(e)}throw A(`Unrecognized equality policy ${e}`)}function getCache(e,t,n){switch(e){case"keep-all":return new Vi({mapKey:n});case"lru":return new Ti({mapKey:n,maxSize:T(t)});case"most-recent":return new Ti({mapKey:n,maxSize:1})}throw A(`Unrecognized eviction policy ${e}`)}var ki=cacheFromPolicy;const{setConfigDeletionHandler:Ni}=Se;function atomFamily(e){var t,n;const o=ki({equality:null!==(t=null===(n=e.cachePolicyForParams_UNSTABLE)||void 0===n?void 0:n.equality)&&void 0!==t?t:"value",eviction:"keep-all"});return t=>{var n,r;const i=o.get(t);if(null!=i)return i;const{cachePolicyForParams_UNSTABLE:a,...s}=e,l="default"in e?e.default:new Promise((()=>{})),c=xi({...s,key:`${e.key}__${null!==(n=Vr(t))&&void 0!==n?n:"void"}`,default:"function"==typeof l?l(t):l,retainedBy_UNSTABLE:"function"==typeof e.retainedBy_UNSTABLE?e.retainedBy_UNSTABLE(t):e.retainedBy_UNSTABLE,effects:"function"==typeof e.effects?e.effects(t):"function"==typeof e.effects_UNSTABLE?e.effects_UNSTABLE(t):null!==(r=e.effects)&&void 0!==r?r:e.effects_UNSTABLE});return o.set(t,c),Ni(c.key,(()=>{o.delete(t)})),c}}var Ri=atomFamily;const{setConfigDeletionHandler:Ii}=Se;let Oi=0;function selectorFamily(e){var t,n;const o=ki({equality:null!==(t=null===(n=e.cachePolicyForParams_UNSTABLE)||void 0===n?void 0:n.equality)&&void 0!==t?t:"value",eviction:"keep-all"});return t=>{var n;let r;try{r=o.get(t)}catch(t){throw A(`Problem with cache lookup for selector ${e.key}: ${t.message}`)}if(null!=r)return r;const i=`${e.key}__selectorFamily/${null!==(n=Vr(t,{allowFunctions:!0}))&&void 0!==n?n:"void"}/${Oi++}`,myGet=n=>e.get(t)(n),a=e.cachePolicy_UNSTABLE,s="function"==typeof e.retainedBy_UNSTABLE?e.retainedBy_UNSTABLE(t):e.retainedBy_UNSTABLE;let l;if(null!=e.set){const n=e.set,o=undefined;l=oi({key:i,get:myGet,set:(e,o)=>n(t)(e,o),cachePolicy_UNSTABLE:a,dangerouslyAllowMutability:e.dangerouslyAllowMutability,retainedBy_UNSTABLE:s})}else l=oi({key:i,get:myGet,cachePolicy_UNSTABLE:a,dangerouslyAllowMutability:e.dangerouslyAllowMutability,retainedBy_UNSTABLE:s});return o.set(t,l),Ii(l.key,(()=>{o.delete(t)})),l}}var Li=selectorFamily;Li({key:"__constant",get:e=>()=>e,cachePolicyForParams_UNSTABLE:{equality:"reference"}}),Li({key:"__error",get:e=>()=>{throw A(e)},cachePolicyForParams_UNSTABLE:{equality:"reference"}});const{loadableWithError:Pi,loadableWithPromise:ji,loadableWithValue:Mi}=U;function concurrentRequests(e,t){const n=Array(t.length).fill(void 0),o=Array(t.length).fill(void 0);for(const[r,i]of t.entries())try{n[r]=e(i)}catch(e){o[r]=e}return[n,o]}function isError(e){return null!=e&&!E(e)}function unwrapDependencies(e){return Array.isArray(e)?e:Object.getOwnPropertyNames(e).map((t=>e[t]))}function wrapResults(e,t){return Array.isArray(e)?t:Object.getOwnPropertyNames(e).reduce(((e,n,o)=>({...e,[n]:t[o]})),{})}function wrapLoadables(e,t,n){const o=undefined;return wrapResults(e,n.map(((e,n)=>null==e?Mi(t[n]):E(e)?ji(e):Pi(e))))}function combineAsyncResultsWithSyncResults(e,t){return t.map(((t,n)=>void 0===t?e[n]:t))}Li({key:"__waitForNone",get:e=>({get:t})=>{const n=unwrapDependencies(e),[o,r]=concurrentRequests(t,n);return wrapLoadables(e,o,r)},dangerouslyAllowMutability:!0}),Li({key:"__waitForAny",get:e=>({get:t})=>{const n=unwrapDependencies(e),[o,r]=concurrentRequests(t,n);return r.some((e=>!E(e)))?wrapLoadables(e,o,r):new Promise((t=>{for(const[n,i]of r.entries())E(i)&&i.then((i=>{o[n]=i,r[n]=void 0,t(wrapLoadables(e,o,r))})).catch((i=>{r[n]=i,t(wrapLoadables(e,o,r))}))}))},dangerouslyAllowMutability:!0}),Li({key:"__waitForAll",get:e=>({get:t})=>{const n=unwrapDependencies(e),[o,r]=concurrentRequests(t,n);if(r.every((e=>null==e)))return wrapResults(e,o);const i=r.find(isError);if(null!=i)throw i;return Promise.all(r).then((t=>wrapResults(e,combineAsyncResultsWithSyncResults(o,t))))},dangerouslyAllowMutability:!0}),Li({key:"__waitForAllSettled",get:e=>({get:t})=>{const n=unwrapDependencies(e),[o,r]=concurrentRequests(t,n);return r.every((e=>!E(e)))?wrapLoadables(e,o,r):Promise.all(r.map(((e,t)=>E(e)?e.then((e=>{o[t]=e,r[t]=void 0})).catch((e=>{o[t]=void 0,r[t]=e})):null))).then((()=>wrapLoadables(e,o,r)))},dangerouslyAllowMutability:!0}),Li({key:"__noWait",get:e=>({get:t})=>{try{return oi.value(Mi(t(e)))}catch(e){return oi.value(E(e)?ji(e):Pi(e))}},dangerouslyAllowMutability:!0});const{RecoilLoadable:Di}=U,{RecoilRoot:Bi}=$n,{isRecoilValue:zi}=ce,{freshSnapshot:Ui}=mn,{useRecoilState:Fi,useRecoilValue:Hi,useRecoilValueLoadable:Wi,useSetRecoilState:$i}=wo,{useRecoilCallback:Gi}=ar;var Ki={RecoilRoot:Bi,atom:xi,selector:oi,atomFamily:Ri,useRecoilValue:Hi,useRecoilValueLoadable:Wi,useRecoilState:Fi,useSetRecoilState:$i,useRecoilCallback:Gi},qi=Ki.RecoilRoot,Yi=Ki.atom,Zi=Ki.selector,Xi=Ki.atomFamily,Ji=Ki.useRecoilValue,Qi=Ki.useRecoilValueLoadable,ea=Ki.useRecoilState,ta=Ki.useSetRecoilState,na=Ki.useRecoilCallback;class oa{}function useActionCallback(e,t=[]){const n=undefined;return na((t=>e(Object.assign(Object.assign({},t),{snapshot:Object.defineProperties(t.snapshot,{getPromiseRequired:{configurable:!0,value:createGetPromiseRequiredWrapper(t.snapshot)},tryGetPromise:{configurable:!0,value:createTryGetPromiseWrapper(t.snapshot)}})}))),t instanceof oa?void 0:t)}function retainSnapshot(e){return n=>{var{snapshot:o}=n,r=t.__rest(n,["snapshot"]);return async(...t)=>{const n=o.retain();try{const n=undefined;return await e(Object.assign(Object.assign({},r),{snapshot:o}))(...t)}finally{n()}}}}function createGetPromiseRequiredWrapper(e){return async(t,n)=>{const o=await e.getPromise(t);if(null==o)throw null!=n?n:new Error(`No value present for required value ${t.key}`);return o}}function createTryGetPromiseWrapper(e){return async t=>{try{return{value:await e.getPromise(t)}}catch(e){return logger_debug(`Error encountered retrieving Recoil value. [key={${t.key}}]`,e),{error:e}}}}const ra=Yi({key:"boxSelectionEnabled",default:!1}),ia=Yi({key:"boxSelectionOperationType",default:"clearAndSelect"}),useBoxSelectionActions=()=>({enable:useActionCallback((({set:e})=>()=>{e(ra,!0)})),disable:useActionCallback((({reset:e})=>async()=>{e(ra),e(ia)})),setOperationType:useActionCallback((({set:e})=>t=>{e(ia,t)}))}),isInputElement=e=>{const t=e instanceof HTMLElement&&"VERTEX-AUTO-RESIZE-TEXTAREA"===e.tagName,n=e instanceof HTMLElement&&"VERTEX-TEXTFIELD"===e.tagName,o=e instanceof HTMLElement&&"true"===e.contentEditable,r=e instanceof HTMLElement&&"VERTEX-SCENE-TREE-SEARCH"===e.tagName,i=e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement,a=e instanceof HTMLElement&&"VERTEX-VIEWER-PIN-TOOL"===e.tagName,s=e instanceof HTMLElement&&"VERTEX-VIEWER-TRANSFORM-WIDGET"===e.tagName;return t||n||o||r||i||a||s},useRecoilReducer=({reducer:e,atom:t})=>{const n=undefined,o=undefined;return[Ji(t),useRecoilReducerDispatch({reducer:e,atom:t})]},useRecoilReducerDispatch=({reducer:e,atom:t})=>{const n=na((({set:n})=>async o=>{n(t,(t=>e(t,o)))}),[]);return n};var aa=/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/,sa=/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(.+)\s*\)/,la=/^(#|0x)?([A-Fa-f0-9]{6})$/,create$2=function(e,t,n,o){return void 0===o&&(o=255),{r:e,g:t,b:n,a:o}},fromNumber=function(e){var t=16777215&e;return create$2(t>>16&255,t>>8&255,255&t)},fromHexString=function(e){var t=la.exec(e);if(null!=t)return fromNumber(parseInt(t[2],16))},fromCss=function(e){var t=aa.exec(e);if(null!=t)return create$2(parseInt(t[1]),parseInt(t[2]),parseInt(t[3]));var n=sa.exec(e);return null!=n?create$2(parseInt(n[1]),parseInt(n[2]),parseInt(n[3]),Math.floor(255*parseFloat(n[4]))):la.test(e)?fromHexString(e):void 0},fromArray=function(e){return create$2(e[0],e[1],e[2],e[3])},isInvisible=function(e){return 0===e.a},isOpaque=function(e){return 255===e.a},toHexString=function(e){return"#".concat(componentToHex(e.r)).concat(componentToHex(e.g)).concat(componentToHex(e.b))},componentToHex=function(e){var t=e.toString(16);return 1===t.length?"0"+t:t},ca=Object.freeze({__proto__:null,create:create$2,fromNumber:fromNumber,fromHexString:fromHexString,fromCss:fromCss,fromArray:fromArray,isInvisible:isInvisible,isOpaque:isOpaque,toHexString:toHexString}),ua;!function(e){function MapperValidationError(t){var n=e.call(this,"Validation error mapping object.")||this;return n.errors=t,Object.setPrototypeOf(n,MapperValidationError.prototype),n}t.__extends(MapperValidationError,e)}(Error);var da=new Uint8Array(16);function rng(){if(!ua&&!(ua="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ua(da)}var pa=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function validate(e){return"string"==typeof e&&pa.test(e)}for(var fa=[],ha=0;ha<256;++ha)fa.push((ha+256).toString(16).substr(1));function stringify(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(fa[e[t+0]]+fa[e[t+1]]+fa[e[t+2]]+fa[e[t+3]]+"-"+fa[e[t+4]]+fa[e[t+5]]+"-"+fa[e[t+6]]+fa[e[t+7]]+"-"+fa[e[t+8]]+fa[e[t+9]]+"-"+fa[e[t+10]]+fa[e[t+11]]+fa[e[t+12]]+fa[e[t+13]]+fa[e[t+14]]+fa[e[t+15]]).toLowerCase();if(!validate(n))throw TypeError("Stringified UUID is invalid");return n}function v4(e,t,n){var o=(e=e||{}).random||(e.rng||rng)();return o[6]=15&o[6]|64,o[8]=63&o[8]|128,stringify(o)}function create$1(){return v4()}function fromMsbLsb(e,t){function digits(e,t){var n=BigInt(1)<<t*BigInt(4);return(n|e&n-BigInt(1)).toString(16).substring(1)}var n="string"==typeof e?BigInt(e):e,o="string"==typeof t?BigInt(t):t,r=digits(n>>BigInt(32),BigInt(8)),i=digits(n>>BigInt(16),BigInt(4)),a=digits(n,BigInt(4)),s=digits(o>>BigInt(48),BigInt(4)),l=digits(o,BigInt(12));return"".concat(r,"-").concat(i,"-").concat(a,"-").concat(s,"-").concat(l)}function toMsbLsb(e){var n=t.__read(e.split("-"),5),o=n[0],r=n[1],i=n[2],a=n[3],s=n[4];if(null==o||null==r||null==i||null==a||null==s)throw new Error("Invalid UUID string ".concat(e));var l=BigInt.asIntN(64,BigInt("0x".concat(o+r+i))),c=BigInt.asIntN(64,BigInt("0x".concat(a+s)));return{msb:l.toString(),lsb:c.toString()}}var ma=Object.freeze({__proto__:null,create:create$1,fromMsbLsb:fromMsbLsb,toMsbLsb:toMsbLsb});const va=Yi({key:"keyBindings",default:{applyBindings:[],bindings:{},pressed:{}}});function reducer(e,t){var n,o,r,i;switch(t.type){case"push-key-binding":const a=undefined;return null!=(null===(n=e.bindings[t.binding.keyBind])||void 0===n?void 0:n.find((e=>e.id===t.binding.id)))?e:Object.assign(Object.assign({},e),{bindings:Object.assign(Object.assign({},e.bindings),{[t.binding.keyBind]:[...null!==(o=e.bindings[t.binding.keyBind])&&void 0!==o?o:[],t.binding]})});case"remove-key-binding":const s=undefined;return null==(null===(r=e.bindings[t.binding.keyBind])||void 0===r?void 0:r.find((e=>e.id===t.binding.id)))?e:Object.assign(Object.assign({},e),{bindings:Object.assign(Object.assign({},e.bindings),{[t.binding.keyBind]:(null!==(i=e.bindings[t.binding.keyBind])&&void 0!==i?i:[]).filter((e=>e.id!==t.binding.id))})});case"add-apply-key-binding":return Object.assign(Object.assign({},e),{applyBindings:[...e.applyBindings,t.binding]});case"remove-apply-key-binding":return Object.assign(Object.assign({},e),{applyBindings:e.applyBindings.filter((e=>e.id!==t.id))});case"set-key-pressed":return Object.assign(Object.assign({},e),{applyBindings:e.applyBindings.map((t=>Object.assign(Object.assign({},t),{active:null!=t.keyBind&&allPressed(t.keyBind,e.pressed)}))),pressed:Object.assign(Object.assign({},e.pressed),{[t.key]:t.pressed}),lastPressed:t.pressed?t.key:void 0})}}const useKeyBindingState=()=>useRecoilReducer({reducer:reducer,atom:va});function pressedValue(e,t){return e.includes("!")?!t[e.replace("!","")]&&!t[e.replace("!","").toLowerCase()]:t[e]||t[e.toLowerCase()]}function isPressed(e,t){const n=e.split("||");return n.length>1?n.some((e=>pressedValue(e,t))):pressedValue(n[0],t)}function allPressed(e,t){const n=undefined;return e.split("+").every((e=>isPressed(e,t)))}function matchingSingleFnBindings(e,t,n){return e.filter((e=>!e.repeat)).filter((e=>{var o;return null!=e.keyBind&&null!=n&&(null===(o=e.keyBind)||void 0===o?void 0:o.includes(n))&&allPressed(e.keyBind,t)})).map((e=>e.fn))}function matchingOffBindings(e,t,n){return e.filter((e=>e.off&&e.active&&null!=e.keyBind&&null==n&&!allPressed(e.keyBind,t))).map((e=>e.off))}const useApplyKeyBinding=e=>{const[t,n]=useKeyBindingState();o.useEffect((()=>{const o=ma.create();return n({type:"add-apply-key-binding",binding:Object.assign(Object.assign({},e),{id:o,active:null!=e.keyBind&&allPressed(e.keyBind,t.pressed)})}),()=>{n({type:"remove-apply-key-binding",id:o})}}),[e.fn,e.off,e.keyBind,e.repeat])},useStackKeyBinding=(e,t=[])=>{const[,n]=useKeyBindingState();o.useEffect((()=>{const t=null==e.addPredicate||e.addPredicate(),o=null!=e.cancelPredicate&&e.cancelPredicate();t&&n({type:"push-key-binding",binding:e}),o&&n({type:"remove-key-binding",binding:e})}),t)},useKeyBindings=({keydownRepeatInterval:e=25,keydownIgnorePredicate:t=isInputElement}={})=>{const[n,r]=useKeyBindingState(),i=o.useCallback((e=>{Object.keys(n.bindings).filter((t=>t.includes(e)&&allPressed(t,Object.assign(Object.assign({},n.pressed),{[e]:!0})))).forEach((e=>{const t=n.bindings[e],o=t.length>0?t[t.length-1]:void 0;null!=o&&(o.fn(),r({type:"remove-key-binding",binding:o}))}))}),[n]);o.useEffect((()=>{const handleKeyDown=e=>{if(!e.repeat&&!t(e.target)){r({type:"set-key-pressed",key:e.key,pressed:!0}),i(e.key);const t=Object.assign(Object.assign({},n.pressed),{[e.key]:!0}),o=matchingSingleFnBindings(n.applyBindings,t,e.key),a=matchingOffBindings(n.applyBindings,t,e.key);(o.length>0||a.length>0)&&e.preventDefault()}},handleKeyUp=e=>{r({type:"set-key-pressed",key:e.key,pressed:!1})};return window.addEventListener("keydown",handleKeyDown),window.addEventListener("keyup",handleKeyUp),()=>{window.removeEventListener("keydown",handleKeyDown),window.removeEventListener("keyup",handleKeyUp)}}),[i,n.applyBindings,n.pressed]),o.useEffect((()=>{const e=matchingSingleFnBindings(n.applyBindings,n.pressed,n.lastPressed),t=matchingOffBindings(n.applyBindings,n.pressed,n.lastPressed);e.forEach((e=>e())),t.forEach((e=>e()))}),[n.pressed,n.lastPressed]),o.useEffect((()=>{const t=n.applyBindings.filter((e=>e.repeat&&null!=e.keyBind&&allPressed(e.keyBind,n.pressed))).map((e=>e.fn));if(t.length>0){const n=setInterval((()=>{t.forEach((e=>e()))}),e);return()=>{clearInterval(n)}}return()=>{}}),[n.applyBindings,n.lastPressed])},VertexBoxSelectionButton=()=>{const t=useBoxSelectionActions(),n=Ji(ra);return useStackKeyBinding({id:"ExitBoxSelection",keyBind:"Escape",fn:t.disable,addPredicate:()=>n,cancelPredicate:()=>!n},[n]),e.jsx(i.VertexTooltip,{content:"Box Selection",children:e.jsx(i.VertexIconButton,{iconName:"box-cursor",iconColor:n?"primary":"secondary","data-testid":"viewer-toolbar-enable-box-selection-button",onClick:n?t.disable:t.enable})})};var ga={exports:{}},ya;
2
2
  /*!
3
3
  Copyright (c) 2018 Jed Watson.
4
4
  Licensed under the MIT License (MIT), see
5
5
  http://jedwatson.github.io/classnames
6
- */
7
- f=h,function(){var e={}.hasOwnProperty;function t(){for(var e="",t=0;t<arguments.length;t++){var r=arguments[t];r&&(e=o(e,n(r)))}return e}function n(n){if("string"==typeof n||"number"==typeof n)return n;if("object"!=typeof n)return"";if(Array.isArray(n))return t.apply(null,n);if(n.toString!==Object.prototype.toString&&!n.toString.toString().includes("[native code]"))return n.toString();var r="";for(var i in n)e.call(n,i)&&n[i]&&(r=o(r,i));return r}function o(e,t){return t?e?e+" "+t:e+t:e}f.exports?(t.default=t,f.exports=t):window.classNames=t}();var m=h.exports;const v=o=>{var{className:r,style:i,displayShadow:s,heading:a,id:l,initialScale:c,placement:u="left",children:d,onResize:f}=o,p=e.__rest(o,["className","style","displayShadow","heading","id","initialScale","placement","children","onResize"]);const h="left"===u||"right"===u,v="top"===u;const g=null!=c?c:1;return t.jsx(n.VertexResizable,Object.assign({id:l,"data-testid":`resizable-content-position-${u}`,className:m(r,"pointer-events-auto z-popover md:z-overlay bg-white bg-opacity-95 flex-grow-0 flex-shrink-0 border-neutral-300",{"border-r min-w-75 max-w-half":"left"===u,"sidebar-shadow-right":"left"===u&&s,"border-l min-w-75 max-w-half":"right"===u,"sidebar-shadow-left":"right"===u&&s,"border-t bottom-0 fixed":"top"===u,"min-h-12 sheet":v}),style:Object.assign({maxHeight:"top"===u?window.innerHeight:void 0},i),initialHorizontalScale:h?c:void 0,initialVerticalScale:v?g:void 0,horizontalDirection:function(){switch(u){case"left":return"right";case"right":return"left";default:return"none"}}(),verticalDirection:"top"===u?"top":"none",position:"right"===u||"top"===u?"absolute":"relative",onResizeEnd:()=>null==f?void 0:f()},p,{children:t.jsxs("div",{className:"flex flex-col h-full w-full",children:["top"===u&&t.jsx("div",{className:"flex justify-center w-full",children:t.jsx("div",{className:"block md:hidden w-20 h-0.5 mt-0.5 bg-neutral-600 rounded"})}),a,t.jsx("div",{className:m("w-full flex flex-col h-0 flex-grow",{"right-0":"right"===u}),children:d})]})}))};var g=function(e){const t=new Error(e);if(void 0===t.stack)try{throw t}catch(e){}return t};var y=function(e){return!!e&&"function"==typeof e.then};var b=function(e,t){if(null!=e)return e;throw g(null!=t?t:"Got unexpected null or undefined")};function x(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class w{getValue(){throw g("BaseLoadable")}toPromise(){throw g("BaseLoadable")}valueMaybe(){throw g("BaseLoadable")}valueOrThrow(){throw g(`Loadable expected value, but in "${this.state}" state`)}promiseMaybe(){throw g("BaseLoadable")}promiseOrThrow(){throw g(`Loadable expected promise, but in "${this.state}" state`)}errorMaybe(){throw g("BaseLoadable")}errorOrThrow(){throw g(`Loadable expected error, but in "${this.state}" state`)}is(e){return e.state===this.state&&e.contents===this.contents}map(e){throw g("BaseLoadable")}}class S extends w{constructor(e){super(),x(this,"state","hasValue"),x(this,"contents",void 0),this.contents=e}getValue(){return this.contents}toPromise(){return Promise.resolve(this.contents)}valueMaybe(){return this.contents}valueOrThrow(){return this.contents}promiseMaybe(){}errorMaybe(){}map(e){try{const t=e(this.contents);return y(t)?V(t):C(t)?t:T(t)}catch(t){return y(t)?V(t.next((()=>this.map(e)))):A(t)}}}class _ extends w{constructor(e){super(),x(this,"state","hasError"),x(this,"contents",void 0),this.contents=e}getValue(){throw this.contents}toPromise(){return Promise.reject(this.contents)}valueMaybe(){}promiseMaybe(){}errorMaybe(){return this.contents}errorOrThrow(){return this.contents}map(e){return this}}class E extends w{constructor(e){super(),x(this,"state","loading"),x(this,"contents",void 0),this.contents=e}getValue(){throw this.contents}toPromise(){return this.contents}valueMaybe(){}promiseMaybe(){return this.contents}promiseOrThrow(){return this.contents}errorMaybe(){}map(e){return V(this.contents.then((t=>{const n=e(t);if(C(n)){const e=n;switch(e.state){case"hasValue":case"loading":return e.contents;case"hasError":throw e.contents}}return n})).catch((t=>{if(y(t))return t.then((()=>this.map(e).contents));throw t})))}}function T(e){return Object.freeze(new S(e))}function A(e){return Object.freeze(new _(e))}function V(e){return Object.freeze(new E(e))}function N(){return Object.freeze(new E(new Promise((()=>{}))))}function k(e){const t=(Array.isArray(e)?e:Object.getOwnPropertyNames(e).map((t=>e[t]))).map((e=>C(e)?e:y(e)?V(e):T(e))),n=function(e){return e.every((e=>"hasValue"===e.state))?T(e.map((e=>e.contents))):e.some((e=>"hasError"===e.state))?A(b(e.find((e=>"hasError"===e.state)),"Invalid loadable passed to loadableAll").contents):V(Promise.all(e.map((e=>e.contents))))}(t);return Array.isArray(e)?n:n.map((t=>Object.getOwnPropertyNames(e).reduce(((e,n,o)=>({...e,[n]:t[o]})),{})))}function C(e){return e instanceof w}const j={of:e=>y(e)?V(e):C(e)?e:T(e),error:e=>A(e),loading:()=>N(),all:k,isLoadable:C};var R={loadableWithValue:T,loadableWithError:A,loadableWithPromise:V,loadableLoading:N,loadableAll:k,isLoadable:C,RecoilLoadable:j},I=R.loadableWithValue,O=R.loadableWithError,L=R.loadableWithPromise,M=R.loadableLoading,P=R.loadableAll,D=R.isLoadable,B=R.RecoilLoadable,z=Object.freeze({__proto__:null,loadableWithValue:I,loadableWithError:O,loadableWithPromise:L,loadableLoading:M,loadableAll:P,isLoadable:D,RecoilLoadable:B});const U={RECOIL_DUPLICATE_ATOM_KEY_CHECKING_ENABLED:!0,RECOIL_GKS_ENABLED:new Set(["recoil_hamt_2020","recoil_sync_external_store","recoil_suppress_rerender_in_callback","recoil_memory_managament_2020"])};var H;"undefined"!=typeof process&&null!=(null===(H=process)||void 0===H?void 0:H.env)&&(function(e,t){var n,o;const r=null===(n=process.env[e])||void 0===n||null===(o=n.toLowerCase())||void 0===o?void 0:o.trim();if(null!=r&&""!==r){if(!["true","false"].includes(r))throw g(`process.env.${e} value must be 'true', 'false', or empty: ${r}`);t("true"===r)}}("RECOIL_DUPLICATE_ATOM_KEY_CHECKING_ENABLED",(e=>{U.RECOIL_DUPLICATE_ATOM_KEY_CHECKING_ENABLED=e})),function(e,t){var n;const o=null===(n=process.env[e])||void 0===n?void 0:n.trim();null!=o&&""!==o&&t(o.split(/\s*,\s*|\s+/))}("RECOIL_GKS_ENABLED",(e=>{e.forEach((e=>{U.RECOIL_GKS_ENABLED.add(e)}))})));var F=U;function $(e){return F.RECOIL_GKS_ENABLED.has(e)}$.setPass=e=>{F.RECOIL_GKS_ENABLED.add(e)},$.setFail=e=>{F.RECOIL_GKS_ENABLED.delete(e)},$.clear=()=>{F.RECOIL_GKS_ENABLED.clear()};var K=$;var G,W,q,Y=function(e,t,{error:n}={}){return"production"!==process.env.NODE_ENV&&console.error(e,n),null};const X=null!==(G=o.createMutableSource)&&void 0!==G?G:o.unstable_createMutableSource,Z=null!==(W=o.useMutableSource)&&void 0!==W?W:o.unstable_useMutableSource,J=null!==(q=o.useSyncExternalStore)&&void 0!==q?q:o.unstable_useSyncExternalStore;let Q=!1;var ee={createMutableSource:X,useMutableSource:Z,useSyncExternalStore:J,currentRendererSupportsUseSyncExternalStore:function(){var e;const{ReactCurrentDispatcher:t,ReactCurrentOwner:n}=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,r=null!=(null!==(e=null==t?void 0:t.current)&&void 0!==e?e:n.currentDispatcher).useSyncExternalStore;return!J||r||Q||(Q=!0,Y("A React renderer without React 18+ API support is being used with React 18+.")),r},reactMode:function(){return K("recoil_transition_support")?{mode:"TRANSITION_SUPPORT",early:!0,concurrent:!0}:K("recoil_sync_external_store")&&null!=J?{mode:"SYNC_EXTERNAL_STORE",early:!0,concurrent:!1}:K("recoil_mutable_source")&&null!=Z&&"undefined"!=typeof window&&!window.$disableRecoilValueMutableSource_TEMP_HACK_DO_NOT_USE?K("recoil_suppress_rerender_in_callback")?{mode:"MUTABLE_SOURCE",early:!0,concurrent:!0}:{mode:"MUTABLE_SOURCE",early:!1,concurrent:!1}:K("recoil_suppress_rerender_in_callback")?{mode:"LEGACY",early:!0,concurrent:!1}:{mode:"LEGACY",early:!1,concurrent:!1}}};class te{constructor(e){x(this,"key",void 0),this.key=e}toJSON(){return{key:this.key}}}class ne extends te{}class oe extends te{}var re={AbstractRecoilValue:te,RecoilState:ne,RecoilValueReadOnly:oe,isRecoilValue:function(e){return e instanceof ne||e instanceof oe}},ie=re.AbstractRecoilValue,se=re.RecoilState,ae=re.RecoilValueReadOnly,le=re.isRecoilValue,ce=Object.freeze({__proto__:null,AbstractRecoilValue:ie,RecoilState:se,RecoilValueReadOnly:ae,isRecoilValue:le});var ue=function(e,...t){let n=0;return e.replace(/%s/g,(()=>String(t[n++])))};var de=function(e,...t){if("production"!==process.env.NODE_ENV){const n=ue.call(null,e,...t),o=new Error(n);o.name="Expectation Violation",console.error(o)}},fe=de;var pe=function(e,t){return function*(){let n=0;for(const o of e)yield t(o,n++)}()};class he{}const me=new he,ve=new Map,ge=new Map;class ye extends Error{}const be=new Map;function xe(e){return be.get(e)}var we={recoilValues:ge,registerNode:function(e){F.RECOIL_DUPLICATE_ATOM_KEY_CHECKING_ENABLED&&function(e){if(ve.has(e)){const t=`Duplicate atom key "${e}". This is a FATAL ERROR in\n production. But it is safe to ignore this warning if it occurred because of\n hot module replacement.`;"production"!==process.env.NODE_ENV?fe(t,"recoil"):console.warn(t)}}(e.key),ve.set(e.key,e);const t=null==e.set?new ce.RecoilValueReadOnly(e.key):new ce.RecoilState(e.key);return ge.set(e.key,t),t},getNode:function(e){const t=ve.get(e);if(null==t)throw new ye(`Missing definition for RecoilValue: "${e}""`);return t},getNodeMaybe:function(e){return ve.get(e)},deleteNodeConfigIfPossible:function(e){var t;if(!K("recoil_memory_managament_2020"))return;const n=ve.get(e);var o;null!=n&&null!==(t=n.shouldDeleteConfigOnRelease)&&void 0!==t&&t.call(n)&&(ve.delete(e),null===(o=xe(e))||void 0===o||o(),be.delete(e))},setConfigDeletionHandler:function(e,t){K("recoil_memory_managament_2020")&&(void 0===t?be.delete(e):be.set(e,t))},getConfigDeletionHandler:xe,recoilValuesForKeys:function(e){return pe(e,(e=>b(ge.get(e))))},DefaultValue:he,DEFAULT_VALUE:me};var Se={enqueueExecution:function(e,t){t()}};var _e=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e){var t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n={},o=Math.pow(2,5),r=o-1,i=o/2,s=o/4,a={},l=function(e){return function(){return e}},c=n.hash=function(e){var n=void 0===e?"undefined":t(e);if("number"===n)return e;"string"!==n&&(e+="");for(var o=0,r=0,i=e.length;r<i;++r){o=(o<<5)-o+e.charCodeAt(r)|0}return o},u=function(e,t){return t>>>e&r},d=function(e){return 1<<e},f=function(e,t){return function(e){return e=(e=(858993459&(e-=e>>1&1431655765))+(e>>2&858993459))+(e>>4)&252645135,e+=e>>8,127&e+(e>>16)}(e&t-1)},p=function(e,t,n,o){var r=o;if(!e){var i=o.length;r=new Array(i);for(var s=0;s<i;++s)r[s]=o[s]}return r[t]=n,r},h=function(e,t,n){var o=n.length-1,r=0,i=0,s=n;if(e)r=i=t;else for(s=new Array(o);r<t;)s[i++]=n[r++];for(++r;r<=o;)s[i++]=n[r++];return e&&(s.length=o),s},m={__hamt_isEmpty:!0},v=function(e){return e===m||e&&e.__hamt_isEmpty},g=function(e,t,n,o){return{type:1,edit:e,hash:t,key:n,value:o,_modify:_}},y=function(e,t,n){return{type:2,edit:e,hash:t,children:n,_modify:E}},b=function(e,t,n){return{type:3,edit:e,mask:t,children:n,_modify:T}},x=function(e,t,n){return{type:4,edit:e,size:t,children:n,_modify:A}},w=function e(t,n,o,r,i,s){if(o===i)return y(t,o,[s,r]);var a=u(n,o),l=u(n,i);return b(t,d(a)|d(l),a===l?[e(t,n+5,o,r,i,s)]:a<l?[r,s]:[s,r])},S=function(e,t){return e===t.edit},_=function(e,t,n,o,r,i,s){if(t(i,this.key)){var l=o(this.value);return l===this.value?this:l===a?(--s.value,m):S(e,this)?(this.value=l,this):g(e,r,i,l)}var c=o();return c===a?this:(++s.value,w(e,n,this.hash,this,r,g(e,r,i,c)))},E=function(e,t,n,o,r,i,s){if(r===this.hash){var l=function(e,t,n,o,r,i,s,l){for(var c=r.length,u=0;u<c;++u){var d=r[u];if(n(s,d.key)){var f=d.value,m=i(f);return m===f?r:m===a?(--l.value,h(e,u,r)):p(e,u,g(t,o,s,m),r)}}var v=i();return v===a?r:(++l.value,p(e,c,g(t,o,s,v),r))}(S(e,this),e,t,this.hash,this.children,o,i,s);return l===this.children?this:l.length>1?y(e,this.hash,l):l[0]}var c=o();return c===a?this:(++s.value,w(e,n,this.hash,this,r,g(e,r,i,c)))},T=function(e,t,n,o,r,s,a){var l=this.mask,c=this.children,g=u(n,r),y=d(g),w=f(l,y),_=l&y,E=_?c[w]:m,T=E._modify(e,t,n+5,o,r,s,a);if(E===T)return this;var A,V=S(e,this),N=l,k=void 0;if(_&&v(T)){if(!(N&=~y))return m;if(c.length<=2&&((A=c[1^w])===m||1===A.type||2===A.type))return c[1^w];k=h(V,w,c)}else if(_||v(T))k=p(V,w,T,c);else{if(c.length>=i)return function(e,t,n,o,r){for(var i=[],s=o,a=0,l=0;s;++l)1&s&&(i[l]=r[a++]),s>>>=1;return i[t]=n,x(e,a+1,i)}(e,g,T,l,c);N|=y,k=function(e,t,n,o){var r=o.length;if(e){for(var i=r;i>=t;)o[i--]=o[i];return o[t]=n,o}for(var s=0,a=0,l=new Array(r+1);s<t;)l[a++]=o[s++];for(l[t]=n;s<r;)l[++a]=o[s++];return l}(V,w,T,c)}return V?(this.mask=N,this.children=k,this):b(e,N,k)},A=function(e,t,n,o,r,i,a){var l=this.size,c=this.children,d=u(n,r),f=c[d],h=(f||m)._modify(e,t,n+5,o,r,i,a);if(f===h)return this;var g=S(e,this),y=void 0;if(v(f)&&!v(h))++l,y=p(g,d,h,c);else if(!v(f)&&v(h)){if(--l<=s)return function(e,t,n,o){for(var r=new Array(t-1),i=0,s=0,a=0,l=o.length;a<l;++a)if(a!==n){var c=o[a];c&&!v(c)&&(r[i++]=c,s|=1<<a)}return b(e,s,r)}(e,l,d,c);y=p(g,d,m,c)}else y=p(g,d,h,c);return g?(this.size=l,this.children=y,this):x(e,l,y)};function V(e,t,n,o,r){this._editable=e,this._edit=t,this._config=n,this._root=o,this._size=r}m._modify=function(e,t,n,o,r,i,s){var l=o();return l===a?m:(++s.value,g(e,r,i,l))},V.prototype.setTree=function(e,t){return this._editable?(this._root=e,this._size=t,this):e===this._root?this:new V(this._editable,this._edit,this._config,e,t)};var N=n.tryGetHash=function(e,t,n,o){for(var r=o._root,i=0,s=o._config.keyEq;;)switch(r.type){case 1:return s(n,r.key)?r.value:e;case 2:if(t===r.hash)for(var a=r.children,l=0,c=a.length;l<c;++l){var p=a[l];if(s(n,p.key))return p.value}return e;case 3:var h=u(i,t),m=d(h);if(r.mask&m){r=r.children[f(r.mask,m)],i+=5;break}return e;case 4:if(r=r.children[u(i,t)]){i+=5;break}return e;default:return e}};V.prototype.tryGetHash=function(e,t,n){return N(e,t,n,this)};var k=n.tryGet=function(e,t,n){return N(e,n._config.hash(t),t,n)};V.prototype.tryGet=function(e,t){return k(e,t,this)};var C=n.getHash=function(e,t,n){return N(void 0,e,t,n)};V.prototype.getHash=function(e,t){return C(e,t,this)},n.get=function(e,t){return N(void 0,t._config.hash(e),e,t)},V.prototype.get=function(e,t){return k(t,e,this)};var j=n.has=function(e,t,n){return N(a,e,t,n)!==a};V.prototype.hasHash=function(e,t){return j(e,t,this)};var R=n.has=function(e,t){return j(t._config.hash(e),e,t)};V.prototype.has=function(e){return R(e,this)};var I=function(e,t){return e===t};n.make=function(e){return new V(0,0,{keyEq:e&&e.keyEq||I,hash:e&&e.hash||c},m,0)},n.empty=n.make();var O=n.isEmpty=function(e){return e&&!!v(e._root)};V.prototype.isEmpty=function(){return O(this)};var L=n.modifyHash=function(e,t,n,o){var r={value:o._size},i=o._root._modify(o._editable?o._edit:NaN,o._config.keyEq,0,e,t,n,r);return o.setTree(i,r.value)};V.prototype.modifyHash=function(e,t,n){return L(n,e,t,this)};var M=n.modify=function(e,t,n){return L(e,n._config.hash(t),t,n)};V.prototype.modify=function(e,t){return M(t,e,this)};var P=n.setHash=function(e,t,n,o){return L(l(n),e,t,o)};V.prototype.setHash=function(e,t,n){return P(e,t,n,this)};var D=n.set=function(e,t,n){return P(n._config.hash(e),e,t,n)};V.prototype.set=function(e,t){return D(e,t,this)};var B=l(a),z=n.removeHash=function(e,t,n){return L(B,e,t,n)};V.prototype.removeHash=V.prototype.deleteHash=function(e,t){return z(e,t,this)};var U=n.remove=function(e,t){return z(t._config.hash(e),e,t)};V.prototype.remove=V.prototype.delete=function(e){return U(e,this)};var H=n.beginMutation=function(e){return new V(e._editable+1,e._edit+1,e._config,e._root,e._size)};V.prototype.beginMutation=function(){return H(this)};var F=n.endMutation=function(e){return e._editable=e._editable&&e._editable-1,e};V.prototype.endMutation=function(){return F(this)};var $=n.mutate=function(e,t){var n=H(t);return e(n),F(n)};V.prototype.mutate=function(e){return $(e,this)};var K=function(e){return e&&G(e[0],e[1],e[2],e[3],e[4])},G=function(e,t,n,o,r){for(;n<e;){var i=t[n++];if(i&&!v(i))return W(i,o,[e,t,n,o,r])}return K(r)},W=function(e,t,n){switch(e.type){case 1:return{value:t(e),rest:n};case 2:case 4:case 3:var o=e.children;return G(o.length,o,0,t,n);default:return K(n)}},q={done:!0};function Y(e){this.v=e}Y.prototype.next=function(){if(!this.v)return q;var e=this.v;return this.v=K(e.rest),e},Y.prototype[Symbol.iterator]=function(){return this};var X=function(e,t){return new Y(W(e._root,t))},Z=function(e){return[e.key,e.value]},J=n.entries=function(e){return X(e,Z)};V.prototype.entries=V.prototype[Symbol.iterator]=function(){return J(this)};var Q=function(e){return e.key},ee=n.keys=function(e){return X(e,Q)};V.prototype.keys=function(){return ee(this)};var te=function(e){return e.value},ne=n.values=V.prototype.values=function(e){return X(e,te)};V.prototype.values=function(){return ne(this)};var oe=n.fold=function(e,t,n){var o=n._root;if(1===o.type)return e(t,o.value,o.key);for(var r=[o.children],i=void 0;i=r.pop();)for(var s=0,a=i.length;s<a;){var l=i[s++];l&&l.type&&(1===l.type?t=e(t,l.value,l.key):r.push(l.children))}return t};V.prototype.fold=function(e,t){return oe(e,t,this)};var re=n.forEach=function(e,t){return oe((function(n,o,r){return e(o,r,t)}),null,t)};V.prototype.forEach=function(e){return re(e,this)};var ie=n.count=function(e){return e._size};V.prototype.count=function(){return ie(this)},Object.defineProperty(V.prototype,"size",{get:V.prototype.count}),e.exports?e.exports=n:(void 0).hamt=n}));class Ee{constructor(e){x(this,"_map",void 0),this._map=new Map(null==e?void 0:e.entries())}keys(){return this._map.keys()}entries(){return this._map.entries()}get(e){return this._map.get(e)}has(e){return this._map.has(e)}set(e,t){return this._map.set(e,t),this}delete(e){return this._map.delete(e),this}clone(){return Ae(this)}toMap(){return new Map(this._map)}}class Te{constructor(e){if(x(this,"_hamt",_e.empty.beginMutation()),e instanceof Te){const t=e._hamt.endMutation();e._hamt=t.beginMutation(),this._hamt=t.beginMutation()}else if(e)for(const[t,n]of e.entries())this._hamt.set(t,n)}keys(){return this._hamt.keys()}entries(){return this._hamt.entries()}get(e){return this._hamt.get(e)}has(e){return this._hamt.has(e)}set(e,t){return this._hamt.set(e,t),this}delete(e){return this._hamt.delete(e),this}clone(){return Ae(this)}toMap(){return new Map(this._hamt)}}function Ae(e){return K("recoil_hamt_2020")?new Te(e):new Ee(e)}var Ve=Ae,Ne=Object.freeze({__proto__:null,persistentMap:Ve});var ke=function(e,...t){const n=new Set;e:for(const o of e){for(const e of t)if(e.has(o))continue e;n.add(o)}return n};var Ce=function(e,t){const n=new Map;return e.forEach(((e,o)=>{n.set(o,t(e,o))})),n};function je(e,t,n,o){const{nodeDeps:r,nodeToNodeSubscriptions:i}=n,s=r.get(e);if(s&&o&&s!==o.nodeDeps.get(e))return;r.set(e,t);const a=null==s?t:ke(t,s);for(const t of a){i.has(t)||i.set(t,new Set);b(i.get(t)).add(e)}if(s){const n=ke(s,t);for(const t of n){if(!i.has(t))return;const n=b(i.get(t));n.delete(e),0===n.size&&i.delete(t)}}}var Re={cloneGraph:function(e){return{nodeDeps:Ce(e.nodeDeps,(e=>new Set(e))),nodeToNodeSubscriptions:Ce(e.nodeToNodeSubscriptions,(e=>new Set(e)))}},graph:function(){return{nodeDeps:new Map,nodeToNodeSubscriptions:new Map}},saveDepsToStore:function(e,t,n,o){var r,i,s,a;const l=n.getState();o!==l.currentTree.version&&o!==(null===(r=l.nextTree)||void 0===r?void 0:r.version)&&o!==(null===(i=l.previousTree)||void 0===i?void 0:i.version)&&Y("Tried to save dependencies to a discarded tree");const c=n.getGraph(o);if(je(e,t,c),o===(null===(s=l.previousTree)||void 0===s?void 0:s.version)){je(e,t,n.getGraph(l.currentTree.version),c)}if(o===(null===(a=l.previousTree)||void 0===a?void 0:a.version)||o===l.currentTree.version){var u;const o=null===(u=l.nextTree)||void 0===u?void 0:u.version;if(void 0!==o){je(e,t,n.getGraph(o),c)}}}};let Ie=0;let Oe=0;let Le=0;var Me={getNextTreeStateVersion:()=>Ie++,getNextStoreID:()=>Oe++,getNextComponentID:()=>Le++};const{persistentMap:Pe}=Ne,{graph:De}=Re,{getNextTreeStateVersion:Be}=Me;var ze={makeEmptyStoreState:function(){const e=function(){const e=Be();return{version:e,stateID:e,transactionMetadata:{},dirtyAtoms:new Set,atomValues:Pe(),nonvalidatedAtoms:Pe()}}();return{currentTree:e,nextTree:null,previousTree:null,commitDepth:0,knownAtoms:new Set,knownSelectors:new Set,transactionSubscriptions:new Map,nodeTransactionSubscriptions:new Map,nodeToComponentSubscriptions:new Map,queuedComponentCallbacks_DEPRECATED:[],suspendedComponentResolvers:new Set,graphsByVersion:(new Map).set(e.version,De()),retention:{referenceCounts:new Map,nodesRetainedByZone:new Map,retainablesToCheckForRelease:new Set},nodeCleanupFunctions:new Map}},getNextTreeStateVersion:Be};var Ue={RetentionZone:class{}};var He={setByAddingToSet:function(e,t){const n=new Set(e);return n.add(t),n}};var Fe=function*(e,t){let n=0;for(const o of e)t(o,n++)&&(yield o)};var $e=function(e,t){return new Proxy(e,{get:(e,n)=>(!(n in e)&&n in t&&(e[n]=t[n]()),e[n]),ownKeys:e=>Object.keys(e)})};const{getNode:Ke,getNodeMaybe:Ge,recoilValuesForKeys:We}=we,{RetentionZone:qe}=Ue,{setByAddingToSet:Ye}=He,Xe=Object.freeze(new Set);class Ze extends Error{}function Je(e,t,n,o){const r=e.getState();if(r.nodeCleanupFunctions.has(n))return;const i=Ke(n),s=function(e,t,n){if(!K("recoil_memory_managament_2020"))return()=>{};const{nodesRetainedByZone:o}=e.getState().retention;function r(e){let n=o.get(e);n||o.set(e,n=new Set),n.add(t)}if(n instanceof qe)r(n);else if(Array.isArray(n))for(const e of n)r(e);return()=>{if(!K("recoil_memory_managament_2020"))return;const{retention:o}=e.getState();function r(e){const n=o.nodesRetainedByZone.get(e);null==n||n.delete(t),n&&0===n.size&&o.nodesRetainedByZone.delete(e)}if(n instanceof qe)r(n);else if(Array.isArray(n))for(const e of n)r(e)}}(e,n,i.retainedBy),a=i.init(e,t,o);r.nodeCleanupFunctions.set(n,(()=>{a(),s()}))}function Qe(e,t,n){return Ke(n).peek(e,t)}function et(e,t,n){const o=new Set,r=Array.from(n),i=e.getGraph(t.version);for(let e=r.pop();e;e=r.pop()){var s;o.add(e);const t=null!==(s=i.nodeToNodeSubscriptions.get(e))&&void 0!==s?s:Xe;for(const e of t)o.has(e)||r.push(e)}return o}var tt={getNodeLoadable:function(e,t,n){return Je(e,t,n,"get"),Ke(n).get(e,t)},peekNodeLoadable:Qe,setNodeValue:function(e,t,n,o){const r=Ke(n);if(null==r.set)throw new Ze(`Attempt to set read-only RecoilValue: ${n}`);const i=r.set;return Je(e,t,n,"set"),i(e,t,o)},initializeNode:function(e,t,n){Je(e,e.getState().currentTree,t,n)},cleanUpNode:function(e,t){var n;const o=e.getState();null===(n=o.nodeCleanupFunctions.get(t))||void 0===n||n(),o.nodeCleanupFunctions.delete(t)},setUnvalidatedAtomValue_DEPRECATED:function(e,t,n){var o;const r=Ge(t);return null==r||null===(o=r.invalidate)||void 0===o||o.call(r,e),{...e,atomValues:e.atomValues.clone().delete(t),nonvalidatedAtoms:e.nonvalidatedAtoms.clone().set(t,n),dirtyAtoms:Ye(e.dirtyAtoms,t)}},peekNodeInfo:function(e,t,n){const o=e.getState(),r=e.getGraph(t.version),i=Ke(n).nodeType;return $e({type:i},{loadable:()=>Qe(e,t,n),isActive:()=>o.knownAtoms.has(n)||o.knownSelectors.has(n),isSet:()=>"selector"!==i&&t.atomValues.has(n),isModified:()=>t.dirtyAtoms.has(n),deps:()=>{var e;return We(null!==(e=r.nodeDeps.get(n))&&void 0!==e?e:[])},subscribers:()=>{var r,i;return{nodes:We(Fe(et(e,t,new Set([n])),(e=>e!==n))),components:pe(null!==(r=null===(i=o.nodeToComponentSubscriptions.get(n))||void 0===i?void 0:i.values())&&void 0!==r?r:[],(([e])=>({name:e})))}}})},getDownstreamNodes:et};let nt=null;var ot={setInvalidateMemoizedSnapshot:function(e){nt=e},invalidateMemoizedSnapshot:function(){var e;null===(e=nt)||void 0===e||e()}};const{getDownstreamNodes:rt,getNodeLoadable:it,setNodeValue:st}=tt,{getNextComponentID:at}=Me,{getNode:lt,getNodeMaybe:ct}=we,{DefaultValue:ut}=we,{reactMode:dt}=ee,{AbstractRecoilValue:ft,RecoilState:pt,RecoilValueReadOnly:ht,isRecoilValue:mt}=ce,{invalidateMemoizedSnapshot:vt}=ot;function gt(e,t,n){if("set"===n.type){const{recoilValue:o,valueOrUpdater:r}=n,i=function(e,t,{key:n},o){if("function"==typeof o){const r=it(e,t,n);if("loading"===r.state){const e=`Tried to set atom or selector "${n}" using an updater function while the current state is pending, this is not currently supported.`;throw Y(e),g(e)}if("hasError"===r.state)throw r.contents;return o(r.contents)}return o}(e,t,o,r),s=st(e,t,o.key,i);for(const[e,n]of s.entries())yt(t,e,n)}else if("setLoadable"===n.type){const{recoilValue:{key:e},loadable:o}=n;yt(t,e,o)}else if("markModified"===n.type){const{recoilValue:{key:e}}=n;t.dirtyAtoms.add(e)}else if("setUnvalidated"===n.type){var o;const{recoilValue:{key:e},unvalidatedValue:r}=n,i=ct(e);null==i||null===(o=i.invalidate)||void 0===o||o.call(i,t),t.atomValues.delete(e),t.nonvalidatedAtoms.set(e,r),t.dirtyAtoms.add(e)}else Y(`Unknown action ${n.type}`)}function yt(e,t,n){"hasValue"===n.state&&n.contents instanceof ut?e.atomValues.delete(t):e.atomValues.set(t,n),e.dirtyAtoms.add(t),e.nonvalidatedAtoms.delete(t)}function bt(e,t){e.replaceState((n=>{const o=St(n);for(const n of t)gt(e,o,n);return _t(e,o),vt(),o}))}function xt(e,t){if(wt.length){const n=wt[wt.length-1];let o=n.get(e);o||n.set(e,o=[]),o.push(t)}else bt(e,[t])}const wt=[];function St(e){return{...e,atomValues:e.atomValues.clone(),nonvalidatedAtoms:e.nonvalidatedAtoms.clone(),dirtyAtoms:new Set(e.dirtyAtoms)}}function _t(e,t){const n=rt(e,t,t.dirtyAtoms);for(const e of n){var o,r;null===(o=ct(e))||void 0===o||null===(r=o.invalidate)||void 0===r||r.call(o,t)}}function Et(e,t,n){xt(e,{type:"set",recoilValue:t,valueOrUpdater:n})}var Tt={AbstractRecoilValue:ft,getRecoilValueAsLoadable:function(e,{key:t},n=e.getState().currentTree){var o,r;const i=e.getState();n.version!==i.currentTree.version&&n.version!==(null===(o=i.nextTree)||void 0===o?void 0:o.version)&&n.version!==(null===(r=i.previousTree)||void 0===r?void 0:r.version)&&Y("Tried to read from a discarded tree");const s=it(e,n,t);return"loading"===s.state&&s.contents.catch((()=>{})),s},setRecoilValue:Et,setRecoilValueLoadable:function(e,t,n){if(n instanceof ut)return Et(e,t,n);xt(e,{type:"setLoadable",recoilValue:t,loadable:n})},markRecoilValueModified:function(e,t){xt(e,{type:"markModified",recoilValue:t})},setUnvalidatedRecoilValue:function(e,t,n){xt(e,{type:"setUnvalidated",recoilValue:t,unvalidatedValue:n})},subscribeToRecoilValue:function(e,{key:t},n,o=null){const r=at(),i=e.getState();i.nodeToComponentSubscriptions.has(t)||i.nodeToComponentSubscriptions.set(t,new Map),b(i.nodeToComponentSubscriptions.get(t)).set(r,[null!=o?o:"<not captured>",n]);const s=dt();if(s.early&&("LEGACY"===s.mode||"MUTABLE_SOURCE"===s.mode)){const o=e.getState().nextTree;o&&o.dirtyAtoms.has(t)&&n(o)}return{release:()=>{const n=e.getState(),o=n.nodeToComponentSubscriptions.get(t);void 0!==o&&o.has(r)?(o.delete(r),0===o.size&&n.nodeToComponentSubscriptions.delete(t)):Y(`Subscription missing at release time for atom ${t}. This is a bug in Recoil.`)}}},applyAtomValueWrites:function(e,t){const n=e.clone();return t.forEach(((e,t)=>{"hasValue"===e.state&&e.contents instanceof ut?n.delete(t):n.set(t,e)})),n},batchStart:function(){const e=new Map;return wt.push(e),()=>{for(const[t,n]of e)bt(t,n);wt.pop()!==e&&Y("Incorrect order of batch popping")}},writeLoadableToTreeState:yt,invalidateDownstreams:_t,copyTreeState:St,refreshRecoilValue:function(e,t){var n;const{currentTree:o}=e.getState(),r=lt(t.key);null===(n=r.clearCache)||void 0===n||n.call(r,e,o)}};var At=function(e,t,n){const o=e.entries();let r=o.next();for(;!r.done;){const i=r.value;if(t.call(n,i[1],i[0],e))return!0;r=o.next()}return!1};const{cleanUpNode:Vt}=tt,{deleteNodeConfigIfPossible:Nt,getNode:kt}=we,{RetentionZone:Ct}=Ue,jt=new Set;function Rt(e,t){const n=e.getState(),o=n.currentTree;if(n.nextTree)return void Y("releaseNodesNowOnCurrentTree should only be called at the end of a batch");const r=new Set;for(const e of t)if(e instanceof Ct)for(const t of Ot(n,e))r.add(t);else r.add(e);const i=function(e,t){const n=e.getState(),o=n.currentTree,r=e.getGraph(o.version),i=new Set,s=new Set;return a(t),i;function a(t){const l=new Set,c=function(e,t,n,o,r){const i=e.getGraph(t.version),s=[],a=new Set;for(;n.size>0;)l(b(n.values().next().value));return s;function l(e){if(o.has(e)||r.has(e))return void n.delete(e);if(a.has(e))return;const t=i.nodeToNodeSubscriptions.get(e);if(t)for(const e of t)l(e);a.add(e),n.delete(e),s.push(e)}}(e,o,t,i,s);for(const e of c){var u;if("recoilRoot"===kt(e).retainedBy){s.add(e);continue}if((null!==(u=n.retention.referenceCounts.get(e))&&void 0!==u?u:0)>0){s.add(e);continue}if(Lt(e).some((e=>n.retention.referenceCounts.get(e)))){s.add(e);continue}const t=r.nodeToNodeSubscriptions.get(e);t&&At(t,(e=>s.has(e)))?s.add(e):(i.add(e),l.add(e))}const d=new Set;for(const e of l)for(const t of null!==(f=r.nodeDeps.get(e))&&void 0!==f?f:jt){var f;i.has(t)||d.add(t)}d.size&&a(d)}}(e,r);for(const t of i)It(e,o,t)}function It(e,t,n){if(!K("recoil_memory_managament_2020"))return;Vt(e,n);const o=e.getState();o.knownAtoms.delete(n),o.knownSelectors.delete(n),o.nodeTransactionSubscriptions.delete(n),o.retention.referenceCounts.delete(n);const r=Lt(n);for(const e of r){var i;null===(i=o.retention.nodesRetainedByZone.get(e))||void 0===i||i.delete(n)}t.atomValues.delete(n),t.dirtyAtoms.delete(n),t.nonvalidatedAtoms.delete(n);const s=o.graphsByVersion.get(t.version);if(s){const e=s.nodeDeps.get(n);if(void 0!==e){s.nodeDeps.delete(n);for(const t of e){var a;null===(a=s.nodeToNodeSubscriptions.get(t))||void 0===a||a.delete(n)}}s.nodeToNodeSubscriptions.delete(n)}Nt(n)}function Ot(e,t){var n;return null!==(n=e.retention.nodesRetainedByZone.get(t))&&void 0!==n?n:jt}function Lt(e){const t=kt(e).retainedBy;return void 0===t||"components"===t||"recoilRoot"===t?[]:t instanceof Ct?[t]:t}var Mt={SUSPENSE_TIMEOUT_MS:12e4,updateRetainCount:function(e,t,n){var o;if(!K("recoil_memory_managament_2020"))return;const r=e.getState().retention.referenceCounts,i=(null!==(o=r.get(t))&&void 0!==o?o:0)+n;0===i?function(e,t){if(!K("recoil_memory_managament_2020"))return;const n=e.getState().retention.referenceCounts;n.delete(t),function(e,t){const n=e.getState();n.nextTree?n.retention.retainablesToCheckForRelease.add(t):Rt(e,new Set([t]))}(e,t)}(e,t):r.set(t,i)},releaseScheduledRetainablesNow:function(e){if(!K("recoil_memory_managament_2020"))return;const t=e.getState();Rt(e,t.retention.retainablesToCheckForRelease),t.retention.retainablesToCheckForRelease.clear()},retainedByOptionWithDefault:function(e){return void 0===e?"recoilRoot":e}};const{unstable_batchedUpdates:Pt}=r;var Dt={unstable_batchedUpdates:Pt};const{unstable_batchedUpdates:Bt}=Dt;var zt={unstable_batchedUpdates:Bt};const{batchStart:Ut}=Tt,{unstable_batchedUpdates:Ht}=zt;let Ft=Ht||(e=>e());var $t={batchUpdates:e=>{Ft((()=>{let t=()=>{};try{t=Ut(),e()}finally{t()}}))}};var Kt=function*(e){for(const t of e)for(const e of t)yield e};const Gt="undefined"==typeof Window||"undefined"==typeof window,Wt="undefined"!=typeof navigator&&"ReactNative"===navigator.product;var qt={isSSR:Gt,isReactNative:Wt,isWindow:e=>!Gt&&(e===window||e instanceof Window)};var Yt={memoizeOneWithArgsHashAndInvalidation:function(e,t){let n,o;return[(...r)=>{const i=t(...r);return n===i||(n=i,o=e(...r)),o},()=>{n=null}]}};const{batchUpdates:Xt}=$t,{initializeNode:Zt,peekNodeInfo:Jt}=tt,{graph:Qt}=Re,{getNextStoreID:en}=Me,{DEFAULT_VALUE:tn,recoilValues:nn,recoilValuesForKeys:on}=we,{AbstractRecoilValue:rn,getRecoilValueAsLoadable:sn,setRecoilValue:an,setUnvalidatedRecoilValue:ln}=Tt,{updateRetainCount:cn}=Mt,{setInvalidateMemoizedSnapshot:un}=ot,{getNextTreeStateVersion:dn,makeEmptyStoreState:fn}=ze,{isSSR:pn}=qt,{memoizeOneWithArgsHashAndInvalidation:hn}=Yt;class mn{constructor(e,t){x(this,"_store",void 0),x(this,"_refCount",1),x(this,"getLoadable",(e=>(this.checkRefCount_INTERNAL(),sn(this._store,e)))),x(this,"getPromise",(e=>(this.checkRefCount_INTERNAL(),this.getLoadable(e).toPromise()))),x(this,"getNodes_UNSTABLE",(e=>{if(this.checkRefCount_INTERNAL(),!0===(null==e?void 0:e.isModified)){if(!1===(null==e?void 0:e.isInitialized))return[];const t=this._store.getState().currentTree;return on(t.dirtyAtoms)}const t=this._store.getState().knownAtoms,n=this._store.getState().knownSelectors;return null==(null==e?void 0:e.isInitialized)?nn.values():!0===e.isInitialized?on(Kt([t,n])):Fe(nn.values(),(({key:e})=>!t.has(e)&&!n.has(e)))})),x(this,"getInfo_UNSTABLE",(({key:e})=>(this.checkRefCount_INTERNAL(),Jt(this._store,this._store.getState().currentTree,e)))),x(this,"map",(e=>{this.checkRefCount_INTERNAL();const t=new bn(this,Xt);return e(t),t})),x(this,"asyncMap",(async e=>{this.checkRefCount_INTERNAL();const t=new bn(this,Xt);return t.retain(),await e(t),t.autoRelease_INTERNAL(),t})),this._store={storeID:en(),parentStoreID:t,getState:()=>e,replaceState:t=>{e.currentTree=t(e.currentTree)},getGraph:t=>{const n=e.graphsByVersion;if(n.has(t))return b(n.get(t));const o=Qt();return n.set(t,o),o},subscribeToTransactions:()=>({release:()=>{}}),addTransactionMetadata:()=>{throw g("Cannot subscribe to Snapshots")}};for(const e of this._store.getState().knownAtoms)Zt(this._store,e,"get"),cn(this._store,e,1);this.autoRelease_INTERNAL()}retain(){if(this._refCount<=0){if("production"!==process.env.NODE_ENV)throw g("Snapshot has already been released.");Y("Attempt to retain() Snapshot that was already released.")}this._refCount++;let e=!1;return()=>{e||(e=!0,this._release())}}autoRelease_INTERNAL(){pn||window.setTimeout((()=>this._release()),10)}_release(){if(this._refCount--,0===this._refCount){if(this._store.getState().nodeCleanupFunctions.forEach((e=>e())),this._store.getState().nodeCleanupFunctions.clear(),!K("recoil_memory_managament_2020"))return}else this._refCount<0&&"production"!==process.env.NODE_ENV&&Y("Snapshot released an extra time.")}isRetained(){return this._refCount>0}checkRefCount_INTERNAL(){K("recoil_memory_managament_2020")&&this._refCount<=0&&"production"!==process.env.NODE_ENV&&Y("\nRecoil Snapshots only last for the duration of the callback they are provided to. To keep a Snapshot longer, do this:\n\n const release = snapshot.retain();\n try {\n await doSomethingWithSnapshot(snapshot);\n } finally {\n release();\n }\n\nThis is currently a DEV-only warning but will become a thrown exception in the next release of Recoil.\n")}getStore_INTERNAL(){return this.checkRefCount_INTERNAL(),this._store}getID(){return this.checkRefCount_INTERNAL(),this._store.getState().currentTree.stateID}getStoreID(){return this.checkRefCount_INTERNAL(),this._store.storeID}}function vn(e,t,n=!1){const o=e.getState(),r=n?dn():t.version;return{currentTree:{version:n?r:t.version,stateID:n?r:t.stateID,transactionMetadata:{...t.transactionMetadata},dirtyAtoms:new Set(t.dirtyAtoms),atomValues:t.atomValues.clone(),nonvalidatedAtoms:t.nonvalidatedAtoms.clone()},commitDepth:0,nextTree:null,previousTree:null,knownAtoms:new Set(o.knownAtoms),knownSelectors:new Set(o.knownSelectors),transactionSubscriptions:new Map,nodeTransactionSubscriptions:new Map,nodeToComponentSubscriptions:new Map,queuedComponentCallbacks_DEPRECATED:[],suspendedComponentResolvers:new Set,graphsByVersion:(new Map).set(r,e.getGraph(t.version)),retention:{referenceCounts:new Map,nodesRetainedByZone:new Map,retainablesToCheckForRelease:new Set},nodeCleanupFunctions:new Map(pe(o.nodeCleanupFunctions.entries(),(([e])=>[e,()=>{}])))}}const[gn,yn]=hn(((e,t)=>{var n;const o=e.getState(),r="latest"===t?null!==(n=o.nextTree)&&void 0!==n?n:o.currentTree:b(o.previousTree);return new mn(vn(e,r),e.storeID)}),((e,t)=>{var n,o;return String(t)+String(e.storeID)+String(null===(n=e.getState().nextTree)||void 0===n?void 0:n.version)+String(e.getState().currentTree.version)+String(null===(o=e.getState().previousTree)||void 0===o?void 0:o.version)}));un(yn);class bn extends mn{constructor(e,t){super(vn(e.getStore_INTERNAL(),e.getStore_INTERNAL().getState().currentTree,!0),e.getStoreID()),x(this,"_batch",void 0),x(this,"set",((e,t)=>{this.checkRefCount_INTERNAL();const n=this.getStore_INTERNAL();this._batch((()=>{cn(n,e.key,1),an(this.getStore_INTERNAL(),e,t)}))})),x(this,"reset",(e=>{this.checkRefCount_INTERNAL();const t=this.getStore_INTERNAL();this._batch((()=>{cn(t,e.key,1),an(this.getStore_INTERNAL(),e,tn)}))})),x(this,"setUnvalidatedAtomValues_DEPRECATED",(e=>{this.checkRefCount_INTERNAL();const t=this.getStore_INTERNAL();Xt((()=>{for(const[n,o]of e.entries())cn(t,n,1),ln(t,new rn(n),o)}))})),this._batch=t}}var xn={Snapshot:mn,MutableSnapshot:bn,freshSnapshot:function(e){const t=new mn(fn());return null!=e?t.map(e):t},cloneSnapshot:function(e,t="latest"){const n=gn(e,t);return n.isRetained()?n:(yn(),gn(e,t))}},wn=xn.Snapshot,Sn=xn.MutableSnapshot,_n=xn.freshSnapshot,En=xn.cloneSnapshot,Tn=Object.freeze({__proto__:null,Snapshot:wn,MutableSnapshot:Sn,freshSnapshot:_n,cloneSnapshot:En});var An=function(...e){const t=new Set;for(const n of e)for(const e of n)t.add(e);return t};const{useRef:Vn}=o;var Nn=function(e){const t=Vn(e);return t.current===e&&"function"==typeof e&&(t.current=e()),t};const{getNextTreeStateVersion:kn,makeEmptyStoreState:Cn}=ze,{cleanUpNode:jn,getDownstreamNodes:Rn,initializeNode:In,setNodeValue:On,setUnvalidatedAtomValue_DEPRECATED:Ln}=tt,{graph:Mn}=Re,{cloneGraph:Pn}=Re,{getNextStoreID:Dn}=Me,{createMutableSource:Bn,reactMode:zn}=ee,{applyAtomValueWrites:Un}=Tt,{releaseScheduledRetainablesNow:Hn}=Mt,{freshSnapshot:Fn}=Tn,{useCallback:$n,useContext:Kn,useEffect:Gn,useMemo:Wn,useRef:qn,useState:Yn}=o;function Xn(){throw g("This component must be used inside a <RecoilRoot> component.")}const Zn=Object.freeze({storeID:Dn(),getState:Xn,replaceState:Xn,getGraph:Xn,subscribeToTransactions:Xn,addTransactionMetadata:Xn});let Jn=!1;function Qn(e){if(Jn)throw g("An atom update was triggered within the execution of a state updater function. State updater functions provided to Recoil must be pure functions.");const t=e.getState();if(null===t.nextTree){K("recoil_memory_managament_2020")&&K("recoil_release_on_cascading_update_killswitch_2021")&&t.commitDepth>0&&Hn(e);const n=t.currentTree.version,o=kn();t.nextTree={...t.currentTree,version:o,stateID:o,dirtyAtoms:new Set,transactionMetadata:{}},t.graphsByVersion.set(o,Pn(b(t.graphsByVersion.get(n))))}}const eo=o.createContext({current:Zn}),to=()=>Kn(eo),no=o.createContext(null);function oo(e,t,n){const o=Rn(e,n,n.dirtyAtoms);for(const e of o){const o=t.nodeToComponentSubscriptions.get(e);if(o)for(const[e,[t,r]]of o)r(n)}}function ro(e){const t=e.getState();t.commitDepth++;try{const{nextTree:n}=t;if(null==n)return;t.previousTree=t.currentTree,t.currentTree=n,t.nextTree=null,function(e){const t=e.getState(),n=t.currentTree,o=n.dirtyAtoms;if(o.size){for(const[n,r]of t.nodeTransactionSubscriptions)if(o.has(n))for(const[t,n]of r)n(e);for(const[n,o]of t.transactionSubscriptions)o(e);(!zn().early||t.suspendedComponentResolvers.size>0)&&(oo(e,t,n),t.suspendedComponentResolvers.forEach((e=>e())),t.suspendedComponentResolvers.clear())}t.queuedComponentCallbacks_DEPRECATED.forEach((e=>e(n))),t.queuedComponentCallbacks_DEPRECATED.splice(0,t.queuedComponentCallbacks_DEPRECATED.length)}(e),null!=t.previousTree?t.graphsByVersion.delete(t.previousTree.version):Y("Ended batch with no previous state, which is unexpected","recoil"),t.previousTree=null,K("recoil_memory_managament_2020")&&null==n&&Hn(e)}finally{t.commitDepth--}}function io({setNotifyBatcherOfChange:e}){const t=to(),[,n]=Yn([]);return e((()=>n({}))),Gn((()=>(e((()=>n({}))),()=>{e((()=>{}))})),[e]),Gn((()=>{Se.enqueueExecution("Batcher",(()=>{ro(t.current)}))})),null}"production"!==process.env.NODE_ENV&&("undefined"==typeof window||window.$recoilDebugStates||(window.$recoilDebugStates=[]));let so=0;function ao({initializeState_DEPRECATED:e,initializeState:t,store_INTERNAL:n,children:r}){let i;const s=e=>{const t=i.current.graphsByVersion;if(t.has(e))return b(t.get(e));const n=Mn();return t.set(e,n),n},a=(e,t)=>{if(null==t){const{transactionSubscriptions:t}=f.current.getState(),n=so++;return t.set(n,e),{release:()=>{t.delete(n)}}}{const{nodeTransactionSubscriptions:n}=f.current.getState();n.has(t)||n.set(t,new Map);const o=so++;return b(n.get(t)).set(o,e),{release:()=>{const e=n.get(t);e&&(e.delete(o),0===e.size&&n.delete(t))}}}},l=e=>{Qn(f.current);for(const t of Object.keys(e))b(f.current.getState().nextTree).transactionMetadata[t]=e[t]},c=e=>{Qn(f.current);const t=b(i.current.nextTree);let n;try{Jn=!0,n=e(t)}finally{Jn=!1}n!==t&&("production"!==process.env.NODE_ENV&&"undefined"!=typeof window&&window.$recoilDebugStates.push(n),i.current.nextTree=n,zn().early&&oo(f.current,i.current,n),b(u.current)())},u=qn(null),d=$n((e=>{u.current=e}),[u]),f=Nn((()=>null!=n?n:{storeID:Dn(),getState:()=>i.current,replaceState:c,getGraph:s,subscribeToTransactions:a,addTransactionMetadata:l}));null!=n&&(f.current=n),i=Nn((()=>null!=e?function(e,t){const n=Cn();return t({set:(t,o)=>{const r=n.currentTree,i=On(e,r,t.key,o),s=new Set(i.keys()),a=r.nonvalidatedAtoms.clone();for(const e of s)a.delete(e);n.currentTree={...r,dirtyAtoms:An(r.dirtyAtoms,s),atomValues:Un(r.atomValues,i),nonvalidatedAtoms:a}},setUnvalidatedAtomValues:e=>{e.forEach(((e,t)=>{n.currentTree=Ln(n.currentTree,t,e)}))}}),n}(f.current,e):null!=t?function(e){const t=Fn(e),n=t.getStore_INTERNAL().getState();return t.retain(),n.nodeCleanupFunctions.forEach((e=>e())),n.nodeCleanupFunctions.clear(),n}(t):Cn()));const p=Wn((()=>null==Bn?void 0:Bn(i,(()=>i.current.currentTree.version))),[i]);return Gn((()=>{const e=f.current;for(const t of new Set(e.getState().knownAtoms))In(e,t,"get");return()=>{for(const t of e.getState().knownAtoms)jn(e,t)}}),[f]),o.createElement(eo.Provider,{value:f},o.createElement(no.Provider,{value:p},o.createElement(io,{setNotifyBatcherOfChange:d}),r))}var lo={RecoilRoot:function(e){const{override:t,...n}=e,r=to();return!1===t&&r.current!==Zn?e.children:o.createElement(ao,n)},useStoreRef:to,useRecoilMutableSource:function(){const e=Kn(no);return null==e&&fe("Attempted to use a Recoil hook outside of a <RecoilRoot>. <RecoilRoot> must be an ancestor of any component that uses Recoil hooks."),e}};var co=function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0,o=e.length;n<o;n++)if(e[n]!==t[n])return!1;return!0};const{useEffect:uo,useRef:fo}=o;var po=function(e){const t=fo();return uo((()=>{t.current=e})),t.current};const{useStoreRef:ho}=lo,{SUSPENSE_TIMEOUT_MS:mo}=Mt,{updateRetainCount:vo}=Mt,{RetentionZone:go}=Ue,{useEffect:yo,useRef:bo}=o,{isSSR:xo}=qt;var wo=function(e){if(K("recoil_memory_managament_2020"))return function(e){const t=Array.isArray(e)?e:[e],n=t.map((e=>e instanceof go?e:e.key)),o=ho();yo((()=>{if(!K("recoil_memory_managament_2020"))return;const e=o.current;if(r.current&&!xo)window.clearTimeout(r.current),r.current=null;else for(const t of n)vo(e,t,1);return()=>{for(const t of n)vo(e,t,-1)}}),[o,...n]);const r=bo(),i=po(n);if(!(xo||void 0!==i&&co(i,n))){const e=o.current;for(const t of n)vo(e,t,1);if(i)for(const t of i)vo(e,t,-1);r.current&&window.clearTimeout(r.current),r.current=window.setTimeout((()=>{r.current=null;for(const t of n)vo(e,t,-1)}),mo)}}(e)};var So=function(){return"<component name not available>"};const{currentRendererSupportsUseSyncExternalStore:_o,reactMode:Eo,useMutableSource:To,useSyncExternalStore:Ao}=ee,{useRecoilMutableSource:Vo,useStoreRef:No}=lo,{isRecoilValue:ko}=ce,{getRecoilValueAsLoadable:Co,setRecoilValue:jo,subscribeToRecoilValue:Ro}=Tt,{useCallback:Io,useEffect:Oo,useMemo:Lo,useRef:Mo,useState:Po}=o,{isSSR:Do}=qt;function Bo(e,t){if(!ko(e))throw g(`Invalid argument to ${t}: expected an atom or selector but got ${String(e)}`)}function zo(e){const t=No(),n=So(),o=Io((()=>{var n;process.env.NODE_ENV;const o=t.current,r=o.getState(),i=Eo().early&&null!==(n=r.nextTree)&&void 0!==n?n:r.currentTree;return{loadable:Co(o,e,i),key:e.key}}),[t,e]),r=Io((e=>{let t;return()=>{var n,o;const r=e();return null!==(n=t)&&void 0!==n&&n.loadable.is(r.loadable)&&(null===(o=t)||void 0===o?void 0:o.key)===r.key?t:(t=r,r)}}),[]),i=Lo((()=>r(o)),[o,r]),s=Io((o=>{const r=t.current;return Ro(r,e,o,n).release}),[t,e,n]);return Ao(s,i,i).loadable}function Uo(e){const t=No(),n=Io((()=>{var n;const o=t.current,r=o.getState(),i=Eo().early&&null!==(n=r.nextTree)&&void 0!==n?n:r.currentTree;return Co(o,e,i)}),[t,e]),o=Io((()=>(process.env.NODE_ENV,n())),[n]),r=So(),i=Io(((o,i)=>{const s=t.current;return Ro(s,e,(()=>{if(!K("recoil_suppress_rerender_in_callback"))return i();const e=n();l.current.is(e)||i(),l.current=e}),r).release}),[t,e,r,n]),s=Vo();if(null==s)throw g("Recoil hooks must be used in components contained within a <RecoilRoot> component.");const a=To(s,o,i),l=Mo(a);return Oo((()=>{l.current=a})),a}function Ho(e){const t=No(),n=So(),o=Io((()=>{var n;process.env.NODE_ENV;const o=t.current,r=o.getState(),i=Eo().early&&null!==(n=r.nextTree)&&void 0!==n?n:r.currentTree;return Co(o,e,i)}),[t,e]),r=Io((()=>({loadable:o(),key:e.key})),[o,e.key]),i=Io((e=>{const t=r();return e.loadable.is(t.loadable)&&e.key===t.key?e:t}),[r]);Oo((()=>{const o=Ro(t.current,e,(e=>{a(i)}),n);return a(i),o.release}),[n,e,t,i]);const[s,a]=Po(r);return s.key!==e.key?r().loadable:s.loadable}function Fo(e){const t=No(),[,n]=Po([]),o=So(),r=Io((()=>{var n;process.env.NODE_ENV;const o=t.current,r=o.getState(),i=Eo().early&&null!==(n=r.nextTree)&&void 0!==n?n:r.currentTree;return Co(o,e,i)}),[t,e]),i=r(),s=Mo(i);return Oo((()=>{s.current=i})),Oo((()=>{const i=t.current,a=i.getState(),l=Ro(i,e,(e=>{var t;if(!K("recoil_suppress_rerender_in_callback"))return n([]);const o=r();null!==(t=s.current)&&void 0!==t&&t.is(o)||n(o),s.current=o}),o);if(a.nextTree)i.getState().queuedComponentCallbacks_DEPRECATED.push((()=>{s.current=null,n([])}));else{var c;if(!K("recoil_suppress_rerender_in_callback"))return n([]);const e=r();null!==(c=s.current)&&void 0!==c&&c.is(e)||n(e),s.current=e}return l.release}),[o,r,e,t]),i}function $o(e){return"production"!==process.env.NODE_ENV&&Bo(e,"useRecoilValueLoadable"),K("recoil_memory_managament_2020")&&wo(e),{TRANSITION_SUPPORT:Ho,SYNC_EXTERNAL_STORE:_o()?zo:Ho,MUTABLE_SOURCE:Uo,LEGACY:Fo}[Eo().mode](e)}function Ko(e){"production"!==process.env.NODE_ENV&&Bo(e,"useRecoilValue");const t=No();return function(e,t,n){if("hasValue"===e.state)return e.contents;if("loading"===e.state)throw new Promise((t=>{const o=n.current.getState().suspendedComponentResolvers;o.add(t),Do&&y(e.contents)&&e.contents.finally((()=>{o.delete(t)}))}));throw"hasError"===e.state?e.contents:g(`Invalid value of loadable atom "${t.key}"`)}($o(e),e,t)}function Go(e){"production"!==process.env.NODE_ENV&&Bo(e,"useSetRecoilState");const t=No();return Io((n=>{jo(t.current,e,n)}),[t,e])}var Wo={useRecoilState:function(e){return"production"!==process.env.NODE_ENV&&Bo(e,"useRecoilState"),[Ko(e),Go(e)]},useRecoilValue:Ko,useRecoilValueLoadable:$o,useSetRecoilState:Go};const{batchUpdates:qo}=$t,{DEFAULT_VALUE:Yo,getNode:Xo}=we,{AbstractRecoilValue:Zo,setRecoilValueLoadable:Jo}=Tt,{cloneSnapshot:Qo}=Tn,{useCallback:er,useEffect:tr,useRef:nr,useState:or}=o;var rr={gotoSnapshot:function(e,t){var n;const o=e.getState(),r=null!==(n=o.nextTree)&&void 0!==n?n:o.currentTree,i=t.getStore_INTERNAL().getState().currentTree;qo((()=>{const n=new Set;for(const e of[r.atomValues.keys(),i.atomValues.keys()])for(const t of e){var o,s;(null===(o=r.atomValues.get(t))||void 0===o?void 0:o.contents)!==(null===(s=i.atomValues.get(t))||void 0===s?void 0:s.contents)&&Xo(t).shouldRestoreFromSnapshots&&n.add(t)}n.forEach((t=>{Jo(e,new Zo(t),i.atomValues.has(t)?b(i.atomValues.get(t)):Yo)})),e.replaceState((e=>({...e,stateID:t.getID()})))}))}};const{useMemo:ir}=o,{loadableWithValue:sr}=z,{initializeNode:ar}=tt,{DEFAULT_VALUE:lr,getNode:cr}=we,{copyTreeState:ur,getRecoilValueAsLoadable:dr,invalidateDownstreams:fr,writeLoadableToTreeState:pr}=Tt;function hr(e){return"atom"===cr(e.key).nodeType}class mr{constructor(e,t){x(this,"_store",void 0),x(this,"_treeState",void 0),x(this,"_changes",void 0),x(this,"get",(e=>{if(this._changes.has(e.key))return this._changes.get(e.key);if(!hr(e))throw g("Reading selectors within atomicUpdate is not supported");const t=dr(this._store,e,this._treeState);if("hasValue"===t.state)return t.contents;throw"hasError"===t.state?t.contents:g(`Expected Recoil atom ${e.key} to have a value, but it is in a loading state.`)})),x(this,"set",((e,t)=>{if(!hr(e))throw g("Setting selectors within atomicUpdate is not supported");if("function"==typeof t){const n=this.get(e);this._changes.set(e.key,t(n))}else ar(this._store,e.key,"set"),this._changes.set(e.key,t)})),x(this,"reset",(e=>{this.set(e,lr)})),this._store=e,this._treeState=t,this._changes=new Map}newTreeState_INTERNAL(){if(0===this._changes.size)return this._treeState;const e=ur(this._treeState);for(const[t,n]of this._changes)pr(e,t,sr(n));return fr(this._store,e),e}}var vr=function(e){return t=>{e.replaceState((n=>{const o=new mr(e,n);return t(o),o.newTreeState_INTERNAL()}))}},gr=Object.freeze({__proto__:null,atomicUpdater:vr});var yr=function(e,t){if(!e)throw new Error(t)};const{atomicUpdater:br}=gr,{batchUpdates:xr}=$t,{DEFAULT_VALUE:wr}=we,{useStoreRef:Sr}=lo,{refreshRecoilValue:_r,setRecoilValue:Er}=Tt,{cloneSnapshot:Tr}=Tn,{gotoSnapshot:Ar}=rr,{useCallback:Vr}=o;class Nr{}const kr=new Nr;function Cr(e,t,n,o){let r,i=kr;var s;(xr((()=>{const s="useRecoilCallback() expects a function that returns a function: it accepts a function of the type (RecoilInterface) => (Args) => ReturnType and returns a callback function (Args) => ReturnType, where RecoilInterface is an object {snapshot, set, ...} and Args and ReturnType are the argument and return types of the callback you want to create. Please see the docs at recoiljs.org for details.";if("function"!=typeof t)throw g(s);const a=$e({...null!=o?o:{},set:(t,n)=>Er(e,t,n),reset:t=>Er(e,t,wr),refresh:t=>_r(e,t),gotoSnapshot:t=>Ar(e,t),transact_UNSTABLE:t=>br(e)(t)},{snapshot:()=>{const t=Tr(e);return r=t.retain(),t}}),l=t(a);if("function"!=typeof l)throw g(s);i=l(...n)})),i instanceof Nr&&("production"!==process.env.NODE_ENV?yr(!1,"batchUpdates should return immediately"):yr(!1)),y(i))?i=i.finally((()=>{var e;null===(e=r)||void 0===e||e()})):null===(s=r)||void 0===s||s();return i}var jr={recoilCallback:Cr,useRecoilCallback:function(e,t){const n=Sr();return Vr(((...t)=>Cr(n.current,e,t)),null!=t?[...t,n]:void 0)}};const{useCallback:Rr}=o,{atomicUpdater:Ir}=gr,{useMemo:Or}=o;var Lr=class{constructor(e){x(this,"value",void 0),this.value=e}},Mr=Object.freeze({__proto__:null,WrappedValue:Lr});class Pr extends Error{}var Dr=class{constructor(e){var t,n,o;x(this,"_name",void 0),x(this,"_numLeafs",void 0),x(this,"_root",void 0),x(this,"_onHit",void 0),x(this,"_onSet",void 0),x(this,"_mapNodeValue",void 0),this._name=null==e?void 0:e.name,this._numLeafs=0,this._root=null,this._onHit=null!==(t=null==e?void 0:e.onHit)&&void 0!==t?t:()=>{},this._onSet=null!==(n=null==e?void 0:e.onSet)&&void 0!==n?n:()=>{},this._mapNodeValue=null!==(o=null==e?void 0:e.mapNodeValue)&&void 0!==o?o:e=>e}size(){return this._numLeafs}root(){return this._root}get(e,t){var n;return null===(n=this.getLeafNode(e,t))||void 0===n?void 0:n.value}getLeafNode(e,t){if(null==this._root)return;let n=this._root;for(;n;){if(null==t||t.onNodeVisit(n),"leaf"===n.type)return this._onHit(n),n;const o=this._mapNodeValue(e(n.nodeKey));n=n.branches.get(o)}}set(e,t,n){const o=()=>{var o,r,i,s;let a,l;for(const[t,o]of e){var c,u,d;const e=this._root;if("leaf"===(null==e?void 0:e.type))throw this.invalidCacheError();const r=a;if(a=r?r.branches.get(l):e,a=null!==(c=a)&&void 0!==c?c:{type:"branch",nodeKey:t,parent:r,branches:new Map,branchKey:l},"branch"!==a.type||a.nodeKey!==t)throw this.invalidCacheError();null==r||r.branches.set(l,a),null==n||null===(u=n.onNodeVisit)||void 0===u||u.call(n,a),l=this._mapNodeValue(o),this._root=null!==(d=this._root)&&void 0!==d?d:a}const f=a?null===(o=a)||void 0===o?void 0:o.branches.get(l):this._root;if(null!=f&&("leaf"!==f.type||f.branchKey!==l))throw this.invalidCacheError();const p={type:"leaf",value:t,parent:a,branchKey:l};null===(r=a)||void 0===r||r.branches.set(l,p),this._root=null!==(i=this._root)&&void 0!==i?i:p,this._numLeafs++,this._onSet(p),null==n||null===(s=n.onNodeVisit)||void 0===s||s.call(n,p)};try{o()}catch(e){if(!(e instanceof Pr))throw e;this.clear(),o()}}delete(e){const t=this.root();if(!t)return!1;if(e===t)return this._root=null,this._numLeafs=0,!0;let n=e.parent,o=e.branchKey;for(;n;){var r;if(n.branches.delete(o),n===t)return 0===n.branches.size?(this._root=null,this._numLeafs=0):this._numLeafs--,!0;if(n.branches.size>0)break;o=null===(r=n)||void 0===r?void 0:r.branchKey,n=n.parent}for(;n!==t;n=n.parent)if(null==n)return!1;return this._numLeafs--,!0}clear(){this._numLeafs=0,this._root=null}invalidCacheError(){throw Y("Invalid cache values. This happens when selectors do not return consistent values for the same input dependency values. That may also be caused when using Fast Refresh to change a selector implementation. Resetting cache."+(null!=this._name?` - ${this._name}`:"")),new Pr}},Br=Object.freeze({__proto__:null,TreeCache:Dr});var zr=class{constructor(e){var t;x(this,"_maxSize",void 0),x(this,"_size",void 0),x(this,"_head",void 0),x(this,"_tail",void 0),x(this,"_map",void 0),x(this,"_keyMapper",void 0),this._maxSize=e.maxSize,this._size=0,this._head=null,this._tail=null,this._map=new Map,this._keyMapper=null!==(t=e.mapKey)&&void 0!==t?t:e=>e}head(){return this._head}tail(){return this._tail}size(){return this._size}maxSize(){return this._maxSize}has(e){return this._map.has(this._keyMapper(e))}get(e){const t=this._keyMapper(e),n=this._map.get(t);if(n)return this.set(e,n.value),n.value}set(e,t){const n=this._keyMapper(e);this._map.get(n)&&this.delete(e);const o=this.head(),r={key:e,right:o,left:null,value:t};o?o.left=r:this._tail=r,this._map.set(n,r),this._head=r,this._size++,this._maybeDeleteLRU()}_maybeDeleteLRU(){this.size()>this.maxSize()&&this.deleteLru()}deleteLru(){const e=this.tail();e&&this.delete(e.key)}delete(e){const t=this._keyMapper(e);if(!this._size||!this._map.has(t))return;const n=b(this._map.get(t)),o=n.right,r=n.left;o&&(o.left=n.left),r&&(r.right=n.right),n===this.head()&&(this._head=o),n===this.tail()&&(this._tail=r),this._map.delete(t),this._size--}clear(){this._size=0,this._head=null,this._tail=null,this._map=new Map}},Ur=Object.freeze({__proto__:null,LRUCache:zr});const{LRUCache:Hr}=Ur,{TreeCache:Fr}=Br;var $r=function({name:e,maxSize:t,mapNodeValue:n=e=>e}){const o=new Hr({maxSize:t}),r=new Fr({name:e,mapNodeValue:n,onHit:e=>{o.set(e,!0)},onSet:e=>{const n=o.tail();o.set(e,!0),n&&r.size()>t&&r.delete(n.key)}});return r};function Kr(e,t,n){if("string"==typeof e&&!e.includes('"')&&!e.includes("\\"))return`"${e}"`;switch(typeof e){case"undefined":return"";case"boolean":return e?"true":"false";case"number":case"symbol":return String(e);case"string":return JSON.stringify(e);case"function":if(!0!==(null==t?void 0:t.allowFunctions))throw g("Attempt to serialize function in a Recoil cache key");return`__FUNCTION(${e.name})__`}if(null===e)return"null";var o;if("object"!=typeof e)return null!==(o=JSON.stringify(e))&&void 0!==o?o:"";if(y(e))return"__PROMISE__";if(Array.isArray(e))return`[${e.map(((e,n)=>Kr(e,t,n.toString())))}]`;if("function"==typeof e.toJSON)return Kr(e.toJSON(n),t,n);if(e instanceof Map){const o={};for(const[n,r]of e)o["string"==typeof n?n:Kr(n,t)]=r;return Kr(o,t,n)}return e instanceof Set?Kr(Array.from(e).sort(((e,n)=>Kr(e,t).localeCompare(Kr(n,t)))),t,n):void 0!==Symbol&&null!=e[Symbol.iterator]&&"function"==typeof e[Symbol.iterator]?Kr(Array.from(e),t,n):`{${Object.keys(e).filter((t=>void 0!==e[t])).sort().map((n=>`${Kr(n,t)}:${Kr(e[n],t,n)}`)).join(",")}}`}var Gr=function(e,t={allowFunctions:!1}){if("production"!==process.env.NODE_ENV&&"undefined"!=typeof window){const n=window.performance?window.performance.now():0,o=Kr(e,t),r=window.performance?window.performance.now():0;return r-n>15&&(console.groupCollapsed(`Recoil: Spent ${r-n}ms computing a cache key`),console.warn(e,o),console.groupEnd()),o}return Kr(e,t)};const{TreeCache:Wr}=Br,qr={equality:"reference",eviction:"keep-all",maxSize:1/0};var Yr=function({equality:e=qr.equality,eviction:t=qr.eviction,maxSize:n=qr.maxSize}=qr,o){const r=function(e){switch(e){case"reference":return e=>e;case"value":return e=>Gr(e)}throw g(`Unrecognized equality policy ${e}`)}(e);return function(e,t,n,o){switch(e){case"keep-all":return new Wr({name:o,mapNodeValue:n});case"lru":return $r({name:o,maxSize:b(t),mapNodeValue:n});case"most-recent":return $r({name:o,maxSize:1,mapNodeValue:n})}throw g(`Unrecognized eviction policy ${e}`)}(t,n,r,o)};var Xr=function(e){var t,n;if("undefined"==typeof window)return!1;const o=null!==(n=(null!=e?null!==(t=e.ownerDocument)&&void 0!==t?t:e:document).defaultView)&&void 0!==n?n:window;return!(null==e||!("function"==typeof o.Node?e instanceof o.Node:"object"==typeof e&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName))};const{isReactNative:Zr,isWindow:Jr}=qt;var Qr=function e(t){if("object"==typeof t&&!function(e){if(null===e||"object"!=typeof e)return!0;switch(typeof e.$$typeof){case"symbol":case"number":return!0}return null!=e["@@__IMMUTABLE_ITERABLE__@@"]||null!=e["@@__IMMUTABLE_KEYED__@@"]||null!=e["@@__IMMUTABLE_INDEXED__@@"]||null!=e["@@__IMMUTABLE_ORDERED__@@"]||null!=e["@@__IMMUTABLE_RECORD__@@"]||!!Xr(e)||!!y(e)||e instanceof Error||!!ArrayBuffer.isView(e)||!(Zr||!Jr(e))}(t)){Object.freeze(t);for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)){const o=t[n];"object"!=typeof o||null==o||Object.isFrozen(o)||e(o)}Object.seal(t)}};const{isLoadable:ei,loadableWithError:ti,loadableWithPromise:ni,loadableWithValue:oi}=z,{WrappedValue:ri}=Mr,{getNodeLoadable:ii,peekNodeLoadable:si,setNodeValue:ai}=tt,{saveDepsToStore:li}=Re,{DEFAULT_VALUE:ci,getConfigDeletionHandler:ui,getNode:di,registerNode:fi}=we,{isRecoilValue:pi}=ce,{markRecoilValueModified:hi}=Tt,{retainedByOptionWithDefault:mi}=Mt,{recoilCallback:vi}=jr;class gi{}const yi=new gi,bi=[],xi=new Map,wi=(()=>{let e=0;return()=>e++})();function Si(e){let t=null;const{key:n,get:o,cachePolicy_UNSTABLE:r}=e,i=null!=e.set?e.set:void 0;if("production"!==process.env.NODE_ENV){if("string"!=typeof n)throw g("A key option with a unique string value must be provided when creating a selector.");if("function"!=typeof o)throw g("Selectors must specify a get callback option to get the selector value.")}const s=new Set,a=Yr(null!=r?r:{equality:"reference",eviction:"keep-all"},n),l=mi(e.retainedBy_UNSTABLE),c=new Map;let u=0;function d(){return!K("recoil_memory_managament_2020")||u>0}function f(e){return e.getState().knownSelectors.add(n),u++,()=>{u--}}function p(){return void 0!==ui(n)&&!d()}function h(e,t,n,o,r){C(t,o,r),m(e,n)}function m(e,t){k(e,t)&&N(e),v(t,!0)}function v(e,n){const o=xi.get(e);if(null!=o){for(const e of o)hi(e,b(t));n&&xi.delete(e)}}function x(e,t){let n=xi.get(t);null==n&&xi.set(t,n=new Set),n.add(e)}function w(e,t,n,o,r,i){return t.then((o=>{if(!d())throw N(e),yi;null!=i.loadingDepKey&&i.loadingDepPromise===t?n.atomValues.set(i.loadingDepKey,oi(o)):e.getState().knownSelectors.forEach((e=>{n.atomValues.delete(e)}));const s=E(e,n);if(s&&"loading"!==s.state){if((k(e,r)||null==V(e))&&m(e,r),"hasValue"===s.state)return s.contents;throw s.contents}if(!k(e,r)){const t=A(e,n);if(null!=t)return t.loadingLoadable.contents}const[a,l]=_(e,n,r);if("loading"!==a.state&&h(e,n,r,a,l),"hasError"===a.state)throw a.contents;return a.contents})).catch((t=>{if(t instanceof gi)throw yi;if(!d())throw N(e),yi;const i=ti(t);throw h(e,n,r,i,o),t}))}function S(e,t,o,r){var i,a,l,c,u,d,f;(k(e,r)||t.version===(null===(i=e.getState())||void 0===i||null===(a=i.currentTree)||void 0===a?void 0:a.version)||t.version===(null===(l=e.getState())||void 0===l||null===(c=l.nextTree)||void 0===c?void 0:c.version))&&li(n,o,e,null!==(u=null===(d=e.getState())||void 0===d||null===(f=d.nextTree)||void 0===f?void 0:f.version)&&void 0!==u?u:e.getState().currentTree.version);for(const e of o)s.add(e)}function _(e,n,r){let i=!0,s=!0;const a=()=>{s=!1};let l,c,u=!1;const f={loadingDepKey:null,loadingDepPromise:null},p=new Map;function m({key:t}){const o=ii(e,n,t);switch(p.set(t,o),i||(S(e,n,new Set(p.keys()),r),function(e,t){k(e,t)&&(b(V(e)).stateVersions.clear(),v(t,!1))}(e,r)),o.state){case"hasValue":return o.contents;case"hasError":throw o.contents;case"loading":throw f.loadingDepKey=t,f.loadingDepPromise=o.contents,o.contents}throw g("Invalid Loadable state")}const x=n=>(...o)=>{if(s)throw g("Callbacks from getCallback() should only be called asynchronously after the selector is evalutated. It can be used for selectors to return objects with callbacks that can work with Recoil state without a subscription.");return null==t&&("production"!==process.env.NODE_ENV?yr(!1,"Recoil Value can never be null"):yr(!1)),vi(e,n,o,{node:t})};try{l=o({get:m,getCallback:x}),l=pi(l)?m(l):l,ei(l)&&("hasError"===l.state&&(u=!0),l=l.contents),y(l)?l=function(e,t,n,o,r,i){return t.then((t=>{if(!d())throw N(e),yi;const i=oi(t);return h(e,n,r,i,o),t})).catch((t=>{if(!d())throw N(e),yi;if(y(t))return w(e,t,n,o,r,i);const s=ti(t);throw h(e,n,r,s,o),t}))}(e,l,n,p,r,f).finally(a):a(),l=l instanceof ri?l.value:l}catch(t){l=t,y(l)?l=w(e,l,n,p,r,f).finally(a):(u=!0,a())}return c=u?ti(l):y(l)?ni(l):oi(l),i=!1,function(e,t,n){if(k(e,t)){const t=V(e);null!=t&&(t.depValuesDiscoveredSoFarDuringAsyncWork=n)}}(e,r,p),S(e,n,new Set(p.keys()),r),[c,p]}function E(e,t){let o=t.atomValues.get(n);if(null!=o)return o;const r=new Set;try{o=a.get((n=>("string"!=typeof n&&("production"!==process.env.NODE_ENV?yr(!1,"Cache nodeKey is type string"):yr(!1)),ii(e,t,n).contents)),{onNodeVisit:e=>{"branch"===e.type&&e.nodeKey!==n&&r.add(e.nodeKey)}})}catch(e){throw g(`Problem with cache lookup for selector "${n}": ${e.message}`)}var i;o&&(t.atomValues.set(n,o),S(e,t,r,null===(i=V(e))||void 0===i?void 0:i.executionID));return o}function T(e,t){const n=E(e,t);if(null!=n)return N(e),n;const o=A(e,t);var r;if(null!=o)return"loading"===(null===(r=o.loadingLoadable)||void 0===r?void 0:r.state)&&x(e,o.executionID),o.loadingLoadable;const i=wi(),[s,a]=_(e,t,i);return"loading"===s.state?(!function(e,t,n,o,r){c.set(e,{depValuesDiscoveredSoFarDuringAsyncWork:o,executionID:t,loadingLoadable:n,stateVersions:new Map([[r.version,!0]])})}(e,i,s,a,t),x(e,i)):(N(e),C(t,s,a)),s}function A(e,t){const n=Kt([c.has(e)?[b(c.get(e))]:[],pe(Fe(c,(([t])=>t!==e)),(([,e])=>e))]);function o(n){for(const[o,r]of n)if(!ii(e,t,o).is(r))return!0;return!1}for(const e of n){if(e.stateVersions.get(t.version)||!o(e.depValuesDiscoveredSoFarDuringAsyncWork))return e.stateVersions.set(t.version,!0),e;e.stateVersions.set(t.version,!1)}}function V(e){return c.get(e)}function N(e){c.delete(e)}function k(e,t){var n;return t===(null===(n=V(e))||void 0===n?void 0:n.executionID)}function C(t,o,r){"production"!==process.env.NODE_ENV&&"loading"!==o.state&&!1===Boolean(e.dangerouslyAllowMutability)&&Qr(o.contents),t.atomValues.set(n,o);try{a.set(function(e){return Array.from(e.entries()).map((([e,t])=>[e,t.contents]))}(r),o)}catch(e){throw g(`Problem with setting cache for selector "${n}": ${e.message}`)}}function j(e,t){const o=t.atomValues.get(n);return null!=o?o:a.get((n=>{var o;return"string"!=typeof n&&("production"!==process.env.NODE_ENV?yr(!1,"Cache nodeKey is type string"):yr(!1)),null===(o=si(e,t,n))||void 0===o?void 0:o.contents}))}function R(e,t){return function(e){if(bi.includes(n)){const e=`Recoil selector has circular dependencies: ${bi.slice(bi.indexOf(n)).join(" → ")}`;return ti(g(e))}bi.push(n);try{return e()}finally{bi.pop()}}((()=>T(e,t)))}function I(e){e.atomValues.delete(n)}function O(e,n){null==t&&("production"!==process.env.NODE_ENV?yr(!1,"Recoil Value can never be null"):yr(!1));for(const t of s){var o;const r=di(t);null===(o=r.clearCache)||void 0===o||o.call(r,e,n)}s.clear(),I(n),a.clear(),hi(e,t)}if(null!=i){return t=fi({key:n,nodeType:"selector",peek:j,get:R,set:(e,t,o)=>{let r=!1;const s=new Map;function a({key:o}){if(r)throw g("Recoil: Async selector sets are not currently supported.");const i=ii(e,t,o);if("hasValue"===i.state)return i.contents;if("loading"===i.state){const e=`Getting value of asynchronous atom or selector "${o}" in a pending state while setting selector "${n}" is not yet supported.`;throw Y(e),g(e)}throw i.contents}function l(n,o){if(r){const e="Recoil: Async selector sets are not currently supported.";throw Y(e),g(e)}const i="function"==typeof o?o(a(n)):o;ai(e,t,n.key,i).forEach(((e,t)=>s.set(t,e)))}const c=i({set:l,get:a,reset:function(e){l(e,ci)}},o);if(void 0!==c)throw y(c)?g("Recoil: Async selector sets are not currently supported."):g("Recoil: selector set should be a void function.");return r=!0,s},init:f,invalidate:I,clearCache:O,shouldDeleteConfigOnRelease:p,dangerouslyAllowMutability:e.dangerouslyAllowMutability,shouldRestoreFromSnapshots:!1,retainedBy:l})}return t=fi({key:n,nodeType:"selector",peek:j,get:R,init:f,invalidate:I,clearCache:O,shouldDeleteConfigOnRelease:p,dangerouslyAllowMutability:e.dangerouslyAllowMutability,shouldRestoreFromSnapshots:!1,retainedBy:l})}Si.value=e=>new ri(e);var _i=Si;const{isLoadable:Ei,loadableWithError:Ti,loadableWithPromise:Ai,loadableWithValue:Vi}=z,{WrappedValue:Ni}=Mr,{peekNodeInfo:ki}=tt,{DEFAULT_VALUE:Ci,DefaultValue:ji,getConfigDeletionHandler:Ri,registerNode:Ii,setConfigDeletionHandler:Oi}=we,{isRecoilValue:Li}=ce,{getRecoilValueAsLoadable:Mi,markRecoilValueModified:Pi,setRecoilValue:Di,setRecoilValueLoadable:Bi}=Tt,{retainedByOptionWithDefault:zi}=Mt,Ui=e=>e instanceof Ni?e.value:e;function Hi(e){const{key:t,persistence_UNSTABLE:n}=e,o=zi(e.retainedBy_UNSTABLE);let r=0;function i(e){return Ai(e.then((e=>(a=Vi(e),e))).catch((e=>{throw a=Ti(e),e})))}let s,a=y(e.default)?i(e.default):Ei(e.default)?"loading"===e.default.state?i(e.default.contents):e.default:Vi(Ui(e.default));c(a.contents);const l=new Map;function c(t){return"production"!==process.env.NODE_ENV&&!0!==e.dangerouslyAllowMutability?y(t)?t.then((e=>(Qr(e),e))):(Qr(t),t):t}function u(e,n){var o,r;return null!==(o=null!==(r=n.atomValues.get(t))&&void 0!==r?r:s)&&void 0!==o?o:a}const d=Ii({key:t,nodeType:"atom",peek:u,get:function(e,o){if(o.atomValues.has(t))return b(o.atomValues.get(t));if(o.nonvalidatedAtoms.has(t)){if(null!=s)return s;if(null==n)return fe(`Tried to restore a persisted value for atom ${t} but it has no persistence settings.`),a;const e=o.nonvalidatedAtoms.get(t),r=n.validator(e,Ci),i=r instanceof ji?a:Vi(r);return s=i,s}return a},set:function(e,n,o){if(n.atomValues.has(t)){const e=b(n.atomValues.get(t));if("hasValue"===e.state&&o===e.contents)return new Map}else if(!n.nonvalidatedAtoms.has(t)&&o instanceof ji)return new Map;return c(o),s=void 0,(new Map).set(t,Vi(o))},init:function(n,o,i){var s;if(r++,n.getState().knownAtoms.add(t),"loading"===a.state){const m=()=>{var e;(null!==(e=n.getState().nextTree)&&void 0!==e?e:n.getState().currentTree).atomValues.has(t)||Pi(n,d)};a.contents.finally(m)}const f=null!==(s=e.effects)&&void 0!==s?s:e.effects_UNSTABLE;if(null!=f){let v=Ci,b=!0,x=!1,w=null;function S(e){if(b&&e.key===t){const e=v;return e instanceof ji?u(n,o):y(e)?Ai(e.then((e=>e instanceof ji?a.toPromise():e))):Vi(e)}return Mi(n,e)}function _(e){return S(e).toPromise()}function E(e){var o;const r=ki(n,null!==(o=n.getState().nextTree)&&void 0!==o?o:n.getState().currentTree,e.key);return!b||e.key!==t||v instanceof ji?r:{...r,isSet:!0,loadable:S(e)}}const T=e=>t=>{if(b){const n=S(d),o="hasValue"===n.state?n.contents:Ci;v="function"==typeof t?t(o):t,y(v)&&(v=v.then((t=>(w={effect:e,value:t},t))))}else{if(y(t))throw g("Setting atoms to async values is not implemented.");"function"!=typeof t&&(w={effect:e,value:Ui(t)}),Di(n,d,"function"==typeof t?n=>{const o=Ui(t(n));return w={effect:e,value:o},o}:Ui(t))}},A=e=>()=>T(e)(Ci),V=e=>o=>{var r;const{release:i}=n.subscribeToTransactions((n=>{var r;let{currentTree:i,previousTree:s}=n.getState();s||(Y("Transaction subscribers notified without a next tree being present -- this is a bug in Recoil"),s=i);const l=null!==(r=i.atomValues.get(t))&&void 0!==r?r:a;if("hasValue"===l.state){var c,u,d,f;const n=l.contents,r=null!==(c=s.atomValues.get(t))&&void 0!==c?c:a,p="hasValue"===r.state?r.contents:Ci;(null===(u=w)||void 0===u?void 0:u.effect)!==e||(null===(d=w)||void 0===d?void 0:d.value)!==n?o(n,p,!i.atomValues.has(t)):(null===(f=w)||void 0===f?void 0:f.effect)===e&&(w=null)}}),t);l.set(n,[...null!==(r=l.get(n))&&void 0!==r?r:[],i])};for(const N of f)try{const k=N({node:d,storeID:n.storeID,parentStoreID_UNSTABLE:n.parentStoreID,trigger:i,setSelf:T(N),resetSelf:A(N),onSet:V(N),getPromise:_,getLoadable:S,getInfo_UNSTABLE:E});var p;if(null!=k)l.set(n,[...null!==(p=l.get(n))&&void 0!==p?p:[],k])}catch(C){v=C,x=!0}if(b=!1,!(v instanceof ji)){var h;const j=x?Ti(v):y(v)?Ai(function(e,n){const o=n.then((n=>{var r,i;return(null===(i=(null!==(r=e.getState().nextTree)&&void 0!==r?r:e.getState().currentTree).atomValues.get(t))||void 0===i?void 0:i.contents)===o&&Di(e,d,n),n})).catch((n=>{var r,i;throw(null===(i=(null!==(r=e.getState().nextTree)&&void 0!==r?r:e.getState().currentTree).atomValues.get(t))||void 0===i?void 0:i.contents)===o&&Bi(e,d,Ti(n)),n}));return o}(n,v)):Vi(Ui(v));c(j.contents),o.atomValues.set(t,j),null===(h=n.getState().nextTree)||void 0===h||h.atomValues.set(t,j)}}return()=>{var e;r--,null===(e=l.get(n))||void 0===e||e.forEach((e=>e())),l.delete(n)}},invalidate:function(){s=void 0},shouldDeleteConfigOnRelease:function(){return void 0!==Ri(t)&&r<=0},dangerouslyAllowMutability:e.dangerouslyAllowMutability,persistence_UNSTABLE:e.persistence_UNSTABLE?{type:e.persistence_UNSTABLE.type,backButton:e.persistence_UNSTABLE.backButton}:void 0,shouldRestoreFromSnapshots:!0,retainedBy:o});return d}function Fi(e){if("production"!==process.env.NODE_ENV&&"string"!=typeof e.key)throw g("A key option with a unique string value must be provided when creating an atom.");const{...t}=e,n="default"in e?e.default:new Promise((()=>{}));return Li(n)?function(e){const t=Fi({...e,default:Ci,persistence_UNSTABLE:void 0===e.persistence_UNSTABLE?void 0:{...e.persistence_UNSTABLE,validator:t=>t instanceof ji?t:b(e.persistence_UNSTABLE).validator(t,Ci)},effects:e.effects,effects_UNSTABLE:e.effects_UNSTABLE}),n=_i({key:`${e.key}__withFallback`,get:({get:n})=>{const o=n(t);return o instanceof ji?e.default:o},set:({set:e},n)=>e(t,n),cachePolicy_UNSTABLE:{eviction:"most-recent"},dangerouslyAllowMutability:e.dangerouslyAllowMutability});return Oi(n.key,Ri(e.key)),n}({...t,default:n}):Hi({...t,default:n})}Fi.value=e=>new Ni(e);var $i=Fi;var Ki=class{constructor(e){var t;x(this,"_map",void 0),x(this,"_keyMapper",void 0),this._map=new Map,this._keyMapper=null!==(t=null==e?void 0:e.mapKey)&&void 0!==t?t:e=>e}size(){return this._map.size}has(e){return this._map.has(this._keyMapper(e))}get(e){return this._map.get(this._keyMapper(e))}set(e,t){this._map.set(this._keyMapper(e),t)}delete(e){this._map.delete(this._keyMapper(e))}clear(){this._map.clear()}},Gi=Object.freeze({__proto__:null,MapCache:Ki});const{LRUCache:Wi}=Ur,{MapCache:qi}=Gi,Yi={equality:"reference",eviction:"none",maxSize:1/0};var Xi=function({equality:e=Yi.equality,eviction:t=Yi.eviction,maxSize:n=Yi.maxSize}=Yi){const o=function(e){switch(e){case"reference":return e=>e;case"value":return e=>Gr(e)}throw g(`Unrecognized equality policy ${e}`)}(e);return function(e,t,n){switch(e){case"keep-all":return new qi({mapKey:n});case"lru":return new Wi({mapKey:n,maxSize:b(t)});case"most-recent":return new Wi({mapKey:n,maxSize:1})}throw g(`Unrecognized eviction policy ${e}`)}(t,n,o)};const{setConfigDeletionHandler:Zi}=we;var Ji=function(e){var t,n;const o=Xi({equality:null!==(t=null===(n=e.cachePolicyForParams_UNSTABLE)||void 0===n?void 0:n.equality)&&void 0!==t?t:"value",eviction:"keep-all"});return t=>{var n,r;const i=o.get(t);if(null!=i)return i;const{cachePolicyForParams_UNSTABLE:s,...a}=e,l="default"in e?e.default:new Promise((()=>{})),c=$i({...a,key:`${e.key}__${null!==(n=Gr(t))&&void 0!==n?n:"void"}`,default:"function"==typeof l?l(t):l,retainedBy_UNSTABLE:"function"==typeof e.retainedBy_UNSTABLE?e.retainedBy_UNSTABLE(t):e.retainedBy_UNSTABLE,effects:"function"==typeof e.effects?e.effects(t):"function"==typeof e.effects_UNSTABLE?e.effects_UNSTABLE(t):null!==(r=e.effects)&&void 0!==r?r:e.effects_UNSTABLE});return o.set(t,c),Zi(c.key,(()=>{o.delete(t)})),c}};const{setConfigDeletionHandler:Qi}=we;let es=0;var ts=function(e){var t,n;const o=Xi({equality:null!==(t=null===(n=e.cachePolicyForParams_UNSTABLE)||void 0===n?void 0:n.equality)&&void 0!==t?t:"value",eviction:"keep-all"});return t=>{var n;let r;try{r=o.get(t)}catch(t){throw g(`Problem with cache lookup for selector ${e.key}: ${t.message}`)}if(null!=r)return r;const i=`${e.key}__selectorFamily/${null!==(n=Gr(t,{allowFunctions:!0}))&&void 0!==n?n:"void"}/${es++}`,s=n=>e.get(t)(n),a=e.cachePolicy_UNSTABLE,l="function"==typeof e.retainedBy_UNSTABLE?e.retainedBy_UNSTABLE(t):e.retainedBy_UNSTABLE;let c;if(null!=e.set){const n=e.set;c=_i({key:i,get:s,set:(e,o)=>n(t)(e,o),cachePolicy_UNSTABLE:a,dangerouslyAllowMutability:e.dangerouslyAllowMutability,retainedBy_UNSTABLE:l})}else c=_i({key:i,get:s,cachePolicy_UNSTABLE:a,dangerouslyAllowMutability:e.dangerouslyAllowMutability,retainedBy_UNSTABLE:l});return o.set(t,c),Qi(c.key,(()=>{o.delete(t)})),c}};ts({key:"__constant",get:e=>()=>e,cachePolicyForParams_UNSTABLE:{equality:"reference"}}),ts({key:"__error",get:e=>()=>{throw g(e)},cachePolicyForParams_UNSTABLE:{equality:"reference"}});const{loadableWithError:ns,loadableWithPromise:os,loadableWithValue:rs}=z;function is(e,t){const n=Array(t.length).fill(void 0),o=Array(t.length).fill(void 0);for(const[r,i]of t.entries())try{n[r]=e(i)}catch(e){o[r]=e}return[n,o]}function ss(e){return null!=e&&!y(e)}function as(e){return Array.isArray(e)?e:Object.getOwnPropertyNames(e).map((t=>e[t]))}function ls(e,t){return Array.isArray(e)?t:Object.getOwnPropertyNames(e).reduce(((e,n,o)=>({...e,[n]:t[o]})),{})}function cs(e,t,n){return ls(e,n.map(((e,n)=>null==e?rs(t[n]):y(e)?os(e):ns(e))))}ts({key:"__waitForNone",get:e=>({get:t})=>{const n=as(e),[o,r]=is(t,n);return cs(e,o,r)},dangerouslyAllowMutability:!0}),ts({key:"__waitForAny",get:e=>({get:t})=>{const n=as(e),[o,r]=is(t,n);return r.some((e=>!y(e)))?cs(e,o,r):new Promise((t=>{for(const[n,i]of r.entries())y(i)&&i.then((i=>{o[n]=i,r[n]=void 0,t(cs(e,o,r))})).catch((i=>{r[n]=i,t(cs(e,o,r))}))}))},dangerouslyAllowMutability:!0}),ts({key:"__waitForAll",get:e=>({get:t})=>{const n=as(e),[o,r]=is(t,n);if(r.every((e=>null==e)))return ls(e,o);const i=r.find(ss);if(null!=i)throw i;return Promise.all(r).then((t=>{return ls(e,(n=o,t.map(((e,t)=>void 0===e?n[t]:e))));var n}))},dangerouslyAllowMutability:!0}),ts({key:"__waitForAllSettled",get:e=>({get:t})=>{const n=as(e),[o,r]=is(t,n);return r.every((e=>!y(e)))?cs(e,o,r):Promise.all(r.map(((e,t)=>y(e)?e.then((e=>{o[t]=e,r[t]=void 0})).catch((e=>{o[t]=void 0,r[t]=e})):null))).then((()=>cs(e,o,r)))},dangerouslyAllowMutability:!0}),ts({key:"__noWait",get:e=>({get:t})=>{try{return _i.value(rs(t(e)))}catch(e){return _i.value(y(e)?os(e):ns(e))}},dangerouslyAllowMutability:!0});const{RecoilLoadable:us}=z,{RecoilRoot:ds}=lo,{isRecoilValue:fs}=ce,{freshSnapshot:ps}=Tn,{useRecoilState:hs,useRecoilValue:ms,useRecoilValueLoadable:vs,useSetRecoilState:gs}=Wo,{useRecoilCallback:ys}=jr;var bs={RecoilRoot:ds,atom:$i,selector:_i,atomFamily:Ji,useRecoilValue:ms,useRecoilValueLoadable:vs,useRecoilState:hs,useSetRecoilState:gs,useRecoilCallback:ys},xs=bs.RecoilRoot,ws=bs.atom,Ss=bs.selector,_s=bs.atomFamily,Es=bs.useRecoilValue,Ts=bs.useRecoilValueLoadable,As=bs.useRecoilState,Vs=bs.useSetRecoilState,Ns=bs.useRecoilCallback;function ks(e){var t;return null!=e&&null!=(null===(t=null==e?void 0:e.node)||void 0===t?void 0:t.id)}const Cs=ws({key:"contextMenuActive",default:void 0}),js=ws({key:"contextMenuPosition",default:void 0}),Rs=ws({key:"contextMenuTarget",default:void 0}),Is=ws({key:"contextMenuItem",default:void 0}),Os=ws({key:"contextMenuActions",default:[]}),Ls=Ss({key:"contextMenuActivePosition",get:({get:e})=>null!=e(Cs)?e(js):void 0});var Ms={exports:{}};const Ps=i;Ms.exports=Ks;const Ds=function(){function e(e){return void 0!==e&&e}try{return"undefined"!=typeof globalThis||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch(t){return e(self)||e(window)||e(this)||{}}}().console||{},Bs={mapHttpRequest:Zs,mapHttpResponse:Zs,wrapRequestSerializer:Js,wrapResponseSerializer:Js,wrapErrorSerializer:Js,req:Zs,res:Zs,err:Ys,errWithCause:Ys};function zs(e,t){return"silent"===e?1/0:t.levels.values[e]}const Us=Symbol("pino.logFuncs"),Hs=Symbol("pino.hierarchy"),Fs={error:"log",fatal:"error",warn:"error",info:"log",debug:"log",trace:"log"};function $s(e,t){const n={logger:t,parent:e[Hs]};t[Hs]=n}function Ks(e){(e=e||{}).browser=e.browser||{};const t=e.browser.transmit;if(t&&"function"!=typeof t.send)throw Error("pino: transmit option must have a send function");const n=e.browser.write||Ds;e.browser.write&&(e.browser.asObject=!0);const o=e.serializers||{},r=function(e,t){if(Array.isArray(e))return e.filter((function(e){return"!stdSerializers.err"!==e}));return!0===e&&Object.keys(t)}(e.browser.serialize,o);let i=e.browser.serialize;Array.isArray(e.browser.serialize)&&e.browser.serialize.indexOf("!stdSerializers.err")>-1&&(i=!1);const s=Object.keys(e.customLevels||{}),a=["error","fatal","warn","info","debug","trace"].concat(s);"function"==typeof n&&a.forEach((function(e){n[e]=n})),(!1===e.enabled||e.browser.disabled)&&(e.level="silent");const l=e.level||"info",c=Object.create(n);c.log||(c.log=Qs),function(e,t,n){const o={};t.forEach((e=>{o[e]=n[e]?n[e]:Ds[e]||Ds[Fs[e]||"log"]||Qs})),e[Us]=o}(c,a,n),$s({},c),Object.defineProperty(c,"levelVal",{get:function(){return zs(this.level,this)}}),Object.defineProperty(c,"level",{get:function(){return this._level},set:function(e){if("silent"!==e&&!this.levels.values[e])throw Error("unknown level "+e);this._level=e,Gs(this,u,c,"error"),Gs(this,u,c,"fatal"),Gs(this,u,c,"warn"),Gs(this,u,c,"info"),Gs(this,u,c,"debug"),Gs(this,u,c,"trace"),s.forEach((e=>{Gs(this,u,c,e)}))}});const u={transmit:t,serialize:r,asObject:e.browser.asObject,formatters:e.browser.formatters,levels:a,timestamp:Xs(e),messageKey:e.messageKey||"msg",onChild:e.onChild||Qs};function d(n,i,s){if(!i)throw new Error("missing bindings for child Pino");s=s||{},r&&i.serializers&&(s.serializers=i.serializers);const a=s.serializers;if(r&&a){var l=Object.assign({},o,a),c=!0===e.browser.serialize?Object.keys(l):r;delete i.serializers,Ws([i],c,l,this._stdErrSerialize)}function u(e){this._childLevel=1+(0|e._childLevel),this.bindings=i,l&&(this.serializers=l,this._serialize=c),t&&(this._logEvent=qs([].concat(e._logEvent.bindings,i)))}u.prototype=this;const f=new u(this);return $s(this,f),f.child=function(...e){return d.call(this,n,...e)},f.level=s.level||this.level,n.onChild(f),f}return c.levels=function(e){const t=e.customLevels||{},n=Object.assign({},Ks.levels.values,t),o=Object.assign({},Ks.levels.labels,function(e){const t={};return Object.keys(e).forEach((function(n){t[e[n]]=n})),t}(t));return{values:n,labels:o}}(e),c.level=l,c.setMaxListeners=c.getMaxListeners=c.emit=c.addListener=c.on=c.prependListener=c.once=c.prependOnceListener=c.removeListener=c.removeAllListeners=c.listeners=c.listenerCount=c.eventNames=c.write=c.flush=Qs,c.serializers=o,c._serialize=r,c._stdErrSerialize=i,c.child=function(...e){return d.call(this,u,...e)},t&&(c._logEvent=qs()),c}function Gs(e,t,n,o){if(Object.defineProperty(e,o,{value:zs(e.level,n)>zs(o,n)?Qs:n[Us][o],writable:!0,enumerable:!0,configurable:!0}),e[o]===Qs){if(!t.transmit)return;const r=zs(t.transmit.level||e.level,n);if(zs(o,n)<r)return}e[o]=function(e,t,n,o){return r=e[Us][o],function(){const i=t.timestamp(),s=new Array(arguments.length),a=Object.getPrototypeOf&&Object.getPrototypeOf(this)===Ds?Ds:this;for(var l=0;l<s.length;l++)s[l]=arguments[l];var c=!1;if(t.serialize&&(Ws(s,this._serialize,this.serializers,this._stdErrSerialize),c=!0),t.asObject||t.formatters?r.call(a,function(e,t,n,o,r){const{level:i,log:s=e=>e}=r.formatters||{},a=n.slice();let l=a[0];const c={};if(o&&(c.time=o),i){const n=i(t,e.levels.values[t]);Object.assign(c,n)}else c.level=e.levels.values[t];let u=1+(0|e._childLevel);if(u<1&&(u=1),null!==l&&"object"==typeof l){for(;u--&&"object"==typeof a[0];)Object.assign(c,a.shift());l=a.length?Ps(a.shift(),a):void 0}else"string"==typeof l&&(l=Ps(a.shift(),a));return void 0!==l&&(c[r.messageKey]=l),s(c)}(this,o,s,i,t)):r.apply(a,s),t.transmit){const r=zs(t.transmit.level||e._level,n),a=zs(o,n);if(a<r)return;!function(e,t,n,o=!1){const r=t.send,i=t.ts,s=t.methodLevel,a=t.methodValue,l=t.val,c=e._logEvent.bindings;o||Ws(n,e._serialize||Object.keys(e.serializers),e.serializers,void 0===e._stdErrSerialize||e._stdErrSerialize),e._logEvent.ts=i,e._logEvent.messages=n.filter((function(e){return-1===c.indexOf(e)})),e._logEvent.level.label=s,e._logEvent.level.value=a,r(s,e._logEvent,l),e._logEvent=qs(c)}(this,{ts:i,methodLevel:o,methodValue:a,transmitValue:n.levels.values[t.transmit.level||e._level],send:t.transmit.send,val:zs(e._level,n)},s,c)}};var r}(e,t,n,o);const r=function(e){const t=[];e.bindings&&t.push(e.bindings);let n=e[Hs];for(;n.parent;)n=n.parent,n.logger.bindings&&t.push(n.logger.bindings);return t.reverse()}(e);0!==r.length&&(e[o]=function(e,t){return function(){return t.apply(this,[...e,...arguments])}}(r,e[o]))}function Ws(e,t,n,o){for(const r in e)if(o&&e[r]instanceof Error)e[r]=Ks.stdSerializers.err(e[r]);else if("object"==typeof e[r]&&!Array.isArray(e[r])&&t)for(const o in e[r])t.indexOf(o)>-1&&o in n&&(e[r][o]=n[o](e[r][o]))}function qs(e){return{ts:0,messages:[],bindings:e||[],level:{label:"",value:0}}}function Ys(e){const t={type:e.constructor.name,msg:e.message,stack:e.stack};for(const n in e)void 0===t[n]&&(t[n]=e[n]);return t}function Xs(e){return"function"==typeof e.timestamp?e.timestamp:!1===e.timestamp?ea:ta}function Zs(){return{}}function Js(e){return e}function Qs(){}function ea(){return!1}function ta(){return Date.now()}Ks.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},Ks.stdSerializers=Bs,Ks.stdTimeFunctions=Object.assign({},{nullTime:ea,epochTime:ta,unixTime:function(){return Math.round(Date.now()/1e3)},isoTime:function(){return new Date(Date.now()).toISOString()}}),Ms.exports.default=Ks,Ms.exports.pino=Ks;const na=(0,Ms.exports)({formatters:{level:e=>({level:e})}}),oa=(e,t)=>{null!=t?na.error(t,e):na.error(e)},ra=(e,t)=>{null!=t?na.debug(t,e):na.debug(e)};class ia{}function sa(e,t=[]){return Ns((t=>{return e(Object.assign(Object.assign({},t),{snapshot:Object.defineProperties(t.snapshot,{getPromiseRequired:{configurable:!0,value:(n=t.snapshot,async(e,t)=>{const o=await n.getPromise(e);if(null==o)throw null!=t?t:new Error(`No value present for required value ${e.key}`);return o})},tryGetPromise:{configurable:!0,value:la(t.snapshot)}})}));var n}),t instanceof ia?void 0:t)}function aa(t){return n=>{var{snapshot:o}=n,r=e.__rest(n,["snapshot"]);return async(...e)=>{const n=o.retain();try{return await t(Object.assign(Object.assign({},r),{snapshot:o}))(...e)}finally{n()}}}}function la(e){return async t=>{try{return{value:await e.getPromise(t)}}catch(e){return ra(`Error encountered retrieving Recoil value. [key={${t.key}}]`,e),{error:e}}}}var ca,ua=/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/,da=/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(.+)\s*\)/,fa=/^(#|0x)?([A-Fa-f0-9]{6})$/,pa=function(e,t,n,o){return void 0===o&&(o=255),{r:e,g:t,b:n,a:o}},ha=function(e){var t=16777215&e;return pa(t>>16&255,t>>8&255,255&t)},ma=function(e){var t=fa.exec(e);if(null!=t)return ha(parseInt(t[2],16))},va=function(e){var t=e.toString(16);return 1===t.length?"0"+t:t},ga=Object.freeze({__proto__:null,create:pa,fromNumber:ha,fromHexString:ma,fromCss:function(e){var t=ua.exec(e);if(null!=t)return pa(parseInt(t[1]),parseInt(t[2]),parseInt(t[3]));var n=da.exec(e);return null!=n?pa(parseInt(n[1]),parseInt(n[2]),parseInt(n[3]),Math.floor(255*parseFloat(n[4]))):fa.test(e)?ma(e):void 0},fromArray:function(e){return pa(e[0],e[1],e[2],e[3])},isInvisible:function(e){return 0===e.a},isOpaque:function(e){return 255===e.a},toHexString:function(e){return"#".concat(va(e.r)).concat(va(e.g)).concat(va(e.b))}});!function(t){function n(e){var o=t.call(this,"Validation error mapping object.")||this;return o.errors=e,Object.setPrototypeOf(o,n.prototype),o}e.__extends(n,t)}(Error);var ya=new Uint8Array(16);function ba(){if(!ca&&!(ca="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ca(ya)}var xa=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var wa=[],Sa=0;Sa<256;++Sa)wa.push((Sa+256).toString(16).substr(1));function _a(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(wa[e[t+0]]+wa[e[t+1]]+wa[e[t+2]]+wa[e[t+3]]+"-"+wa[e[t+4]]+wa[e[t+5]]+"-"+wa[e[t+6]]+wa[e[t+7]]+"-"+wa[e[t+8]]+wa[e[t+9]]+"-"+wa[e[t+10]]+wa[e[t+11]]+wa[e[t+12]]+wa[e[t+13]]+wa[e[t+14]]+wa[e[t+15]]).toLowerCase();if(!function(e){return"string"==typeof e&&xa.test(e)}(n))throw TypeError("Stringified UUID is invalid");return n}function Ea(e,t,n){var o=(e=e||{}).random||(e.rng||ba)();return o[6]=15&o[6]|64,o[8]=63&o[8]|128,_a(o)}var Ta=Object.freeze({__proto__:null,create:function(){return Ea()},fromMsbLsb:function(e,t){function n(e,t){var n=BigInt(1)<<t*BigInt(4);return(n|e&n-BigInt(1)).toString(16).substring(1)}var o="string"==typeof e?BigInt(e):e,r="string"==typeof t?BigInt(t):t,i=n(o>>BigInt(32),BigInt(8)),s=n(o>>BigInt(16),BigInt(4)),a=n(o,BigInt(4)),l=n(r>>BigInt(48),BigInt(4)),c=n(r,BigInt(12));return"".concat(i,"-").concat(s,"-").concat(a,"-").concat(l,"-").concat(c)},toMsbLsb:function(t){var n=e.__read(t.split("-"),5),o=n[0],r=n[1],i=n[2],s=n[3],a=n[4];if(null==o||null==r||null==i||null==s||null==a)throw new Error("Invalid UUID string ".concat(t));var l=BigInt.asIntN(64,BigInt("0x".concat(o+r+i))),c=BigInt.asIntN(64,BigInt("0x".concat(s+a)));return{msb:l.toString(),lsb:c.toString()}}});const Aa=ws({key:"viewerToolkitViewerElement",default:void 0,dangerouslyAllowMutability:!0}),Va=ws({key:"viewerInitialSceneReady",default:!1}),Na=ws({key:"viewerBaseInteractionHandlerProvider",default:Promise.resolve(void 0),dangerouslyAllowMutability:!0}),ka=ws({key:"viewerPrimaryInteractionType",default:"rotate"}),Ca=Ss({key:"viewerScene",get:({get:e})=>async()=>{var t;return null===(t=e(Aa))||void 0===t?void 0:t.scene()},dangerouslyAllowMutability:!0}),ja=ws({key:"viewerFrameScene",default:void 0,dangerouslyAllowMutability:!0}),Ra=Ss({key:"viewerSceneVisibleBoundingBox",get:({get:e})=>{var t;return null===(t=e(ja))||void 0===t?void 0:t.boundingBox}});function Ia(){const e=sa((({snapshot:e})=>async(t,n,...o)=>{const r=await e.getPromise(Ca),i=await r();o.length>0&&await(null==i?void 0:i.items((e=>o.map((t=>t(e))))).execute({suppliedCorrelationId:n}))})),t=o.useCallback(((...e)=>t=>t.where((t=>t.withItemIds(e))).select()),[]),n=o.useCallback(((...e)=>t=>t.where((t=>t.withItemIds(e))).deselect()),[]),r=o.useCallback((e=>e.where((e=>e.all())).deselect()),[]);return{executeWithCorrelationId:e,execute:sa((()=>async(t,...n)=>{const o=Ta.create();await e(t,o,...n)})),selectItemsTransform:t,deselectItemsTransform:n,clearSelectionTransform:r,reset:sa((({snapshot:e})=>async t=>{const n=await e.getPromiseRequired(Ca),o=await n(),r=await e.getPromiseRequired(La);null==o||o.reset({includeCamera:!0,suppliedCorrelationId:t,cameraTypeOverride:r})}))}}function Oa(){return{flyToById:sa((({snapshot:e})=>async(t,n)=>{const o=await e.getPromise(Ca),r=await o();await(null==r?void 0:r.camera().flyTo({itemId:t}).render({animation:{milliseconds:null!=n?n:500}}))})),flyToByBoundingBox:sa((({snapshot:e})=>async(t,n)=>{const o=await e.getPromise(Ca),r=await o();await(null==r?void 0:r.camera().flyTo({boundingBox:t}).render({animation:{milliseconds:null!=n?n:500}}))})),updateCameraType:sa((({set:e})=>t=>{e(La,t)}))}}const La=ws({key:"viewerCameraType",default:"perspective"});const Ma=(e,t=0)=>({normal:e,offset:t}),Pa=e=>Ma(s.Vector3.left(),-e),Da=e=>Ma(s.Vector3.down(),-e),Ba=e=>Ma(s.Vector3.forward(),-e),za={x:s.Vector3.left(),y:s.Vector3.down(),z:s.Vector3.forward()},Ua=e=>e.x,Ha=e=>e.y||s.Vector3.create(e.x.z,e.x.x,e.x.y),Fa=e=>e.z||s.Vector3.create(e.x.y,e.x.z,e.x.x),$a=e=>s.Vector3.dot(s.Vector3.create(-1,-1,-1),e.normal)>0,Ka=(e,t)=>((e,t)=>s.Vector3.dot(e,t.normal)<0?Ga(t):t)(e.viewVector,t),Ga=e=>Object.assign(Object.assign({},e),{normal:s.Vector3.multiply(e.normal,s.Vector3.create(-1,-1,-1)),offset:-e.offset}),Wa=(e,t,n,o,r)=>{const i=n.viewAll(),a=((e,t)=>{switch(e){case"x":return Ua(t);case"y":return Ha(t);case"z":return Fa(t)}})(e,t),l=null!=o&&null!=a?Ma(a,s.Vector3.dot(a,r||s.BoundingBox.center(o))):((e,t)=>{switch(e){case"x":return Pa(t);case"y":return Da(t);case"z":return Ba(t)}})(e,i.lookAt[e]);return Ka(n,l)};const qa={default:5,min:0,max:10},Ya=ws({key:"crossSectioningEnabled",default:!1}),Xa=ws({key:"crossSectioningHighlightColor",default:void 0}),Za=ws({key:"crossSectioningBorderWidth",default:void 0}),Ja=ws({key:"crossSectioningPlanes",default:[]}),Qa=ws({key:"crossSectioningAlignment",default:{mode:"global",hitPending:!1}}),el=Ss({key:"crossSectioningTargetBoundingBox",get:async({get:e})=>e(Ra)}),tl=ws({key:"crossSectioningIsInteractive",default:!1}),nl=ws({key:"crossSectioningActiveAxis",default:"x"}),ol=ws({key:"crossSectioningAvailableAxes",default:za}),rl=Ss({key:"crossSectioningOffsetScalar",get:({get:e})=>{const t=e(Ja);return t.length>0&&$a(t[0])?-1:1}}),il=Ss({key:"crossSectioningSliderRange",get:({get:e})=>{const t=e(Ja),n=e(el),o=null!=n?(r=n,[s.Vector3.create(r.min.x,r.min.y,r.min.z),s.Vector3.create(r.min.x,r.min.y,r.max.z),s.Vector3.create(r.min.x,r.max.y,r.min.z),s.Vector3.create(r.min.x,r.max.y,r.max.z),s.Vector3.create(r.max.x,r.max.y,r.max.z),s.Vector3.create(r.max.x,r.max.y,r.min.z),s.Vector3.create(r.max.x,r.min.y,r.max.z),s.Vector3.create(r.max.x,r.min.y,r.min.z)]):[];var r;if(t.length>0){const e=o.map((e=>s.Vector3.dot(e,$a(t[0])?s.Vector3.multiply(t[0].normal,s.Vector3.create(-1,-1,-1)):t[0].normal)));return{default:t[0].offset,min:Math.min(...e)-2,max:Math.max(...e)+2}}return qa}}),sl=Ss({key:"crossSectioningPlaneDisplayOffset",get:({get:e})=>{const t=e(Ja),n=e(rl),o=e(il);return t.length>0?t[0].offset*n:o.default}}),al=ws({key:"crossSectioningAdditionalToolsOpen",default:!1}),ll=ws({key:"crossSectioningAlignmentToolsOpen",default:!1}),cl=ws({key:"crossSectioningAxisToolsOpen",default:!1}),ul=ws({key:"crossSectioningInteractionHandler",default:new class{constructor(){this.interactionStarted=!1}initialize(e,t){this.api=t}dispose(){this.endInteraction()}async beginInteraction(){var e;this.interactionStarted||(await(null===(e=this.api)||void 0===e?void 0:e.beginInteraction()),this.interactionStarted=!0)}async endInteraction(){var e;await(null===(e=this.api)||void 0===e?void 0:e.endInteraction()),this.interactionStarted=!1}},dangerouslyAllowMutability:!0});const dl=ws({key:"hitResultsTapDetails",default:void 0}),fl=ws({key:"hitResultsLongPressDetails",default:void 0}),pl=ws({key:"previousHitResult",default:void 0}),hl=ws({key:"currentHitResult",default:void 0}),ml=Ss({key:"hitResult",get:async({get:e})=>{var t,n,o,r,i,a,l,c;const u=e(dl),d=e(fl),f=null!=u?u:d,p=e(Ca),h=await p(),m=null==h?void 0:h.sceneViewId,v=null==h?void 0:h.raycaster();if(null!=f&&null!=v&&null!=m){const e=await v.hitItems(f.position),u=((null==e?void 0:e.hits)||[])[0];if(null!=u)return{id:null===(t=u.itemId)||void 0===t?void 0:t.hex,normal:s.Vector3.create((null===(n=null==u?void 0:u.hitNormal)||void 0===n?void 0:n.x)||0,(null===(o=null==u?void 0:u.hitNormal)||void 0===o?void 0:o.y)||0,(null===(r=null==u?void 0:u.hitNormal)||void 0===r?void 0:r.z)||0),position:s.Vector3.create((null===(i=null==u?void 0:u.hitPoint)||void 0===i?void 0:i.x)||0,(null===(a=null==u?void 0:u.hitPoint)||void 0===a?void 0:a.y)||0,(null===(l=null==u?void 0:u.hitPoint)||void 0===l?void 0:l.z)||0),meta:f.metaKey||f.ctrlKey||!1,metadata:[],ancestors:(null===(c=null==u?void 0:u.ancestors)||void 0===c?void 0:c.filter((e=>{var t;return null!=(null===(t=e.itemId)||void 0===t?void 0:t.hex)})).map((e=>{var t;return null===(t=e.itemId)||void 0===t?void 0:t.hex})))||[]}}}}),vl=ws({key:"hitResultsSkipNextTap",default:!1});function gl(){const e=sa((({snapshot:e})=>async()=>{const t=await e.getPromise(Za),n=await e.getPromise(Xa),o=await e.getPromise(Ja),r=await e.getPromise(Ca),i=await r();await(null==i?void 0:i.crossSectioning().update({sectionPlanes:o,highlightColor:n?ga.fromHexString(n):void 0,lineWidth:t}))})),t=sa((({set:t,reset:n,snapshot:o})=>async()=>{const r=await o.getPromise(Ca),i=await r();if(null!=i){const o=i.camera().viewAll();n(ol),t(Ja,[Ka(i.camera(),Pa(o.lookAt.x))]),e()}})),n=sa(aa((({snapshot:t,set:n})=>async()=>{const o=await t.tryGetPromise(ml).then((e=>e.value)),r=await t.getPromise(Ca),i=await r();if(null!=o&&null!=i){const t=((e,t)=>{const n=s.Vector3.normalize(e.normal),o=s.Vector3.dot(n,e.position);return Ka(t,Ma(n,o))})(o,i.camera());n(Ja,null!=t?[t]:[]),n(ol,null!=t?{x:t.normal}:za),e()}}))),o=sa((({set:e,snapshot:n})=>async()=>{const o=await n.getPromise(Ja);await n.getPromise(Ya)||(e(Ya,!0),0===o.length&&await t())})),r=sa((({reset:t,snapshot:n})=>async()=>{await n.getPromise(Ya)&&(t(Ya),t(al),t(ll),t(cl),t(Ja),t(Qa),t(nl),await e())}));return{enable:o,disable:r,openAdditionalTools:sa((({set:e,snapshot:t})=>async()=>{await t.getPromise(Ya)||o(),e(al,!0)})),closeAdditionalTools:sa((({reset:e})=>async()=>{e(al)})),openAlignmentTools:sa((({set:e,reset:t})=>async()=>{t(cl),e(ll,!0)})),closeAlignmentTools:sa((({reset:e})=>async()=>{e(ll)})),openAxisTools:sa((({set:e,reset:t})=>async()=>{t(ll),e(cl,!0)})),closeAxisTools:sa((({reset:e})=>async()=>{e(cl)})),beginInteraction:sa((({set:e,snapshot:t})=>async()=>{const n=await t.getPromise(ul);e(tl,!0),await n.beginInteraction()})),endInteraction:sa((({reset:e,snapshot:t})=>async()=>{const n=await t.getPromise(ul);e(tl),await n.endInteraction()})),updatePlanes:sa(aa((({set:t,snapshot:n})=>async o=>{const r=await n.getPromise(Ja);if(r.length>0){const i=await n.getPromise(rl),s=await n.getPromise(il),a=i<0?-1*s.max:s.min,l=i<0?-1*s.min:s.max,c=r.map((e=>Object.assign(Object.assign({},e),{offset:Math.min(Math.max(o*i,a),l)})));t(Ja,c),e()}}))),flipPlanes:sa((({set:t,snapshot:n})=>async()=>{const o=await n.getPromise(Ja);t(Ja,o.map((e=>Ga(e)))),e()})),alignViewToPlane:sa((({snapshot:e})=>async()=>{const t=await e.getPromise(Ja),n=await e.getPromise(Aa),o=await(null==n?void 0:n.scene());t.length>0&&null!=o&&await((e,t,n)=>{if(e.toFrameCamera().isPerspective()){const n=s.Vector3.dot(s.Vector3.normalize(e.up),t),o=Math.abs(n)>.98?s.Vector3.normalize(s.Vector3.scale(-n,e.viewVector)):e.up,r=s.Vector3.add(s.Vector3.scale(s.Vector3.distance(e.position,e.lookAt),s.Vector3.multiply(t,s.Vector3.create(-1,-1,-1))),e.lookAt);return e.update({up:o,position:r})}{const o=s.Vector3.angleTo(s.Vector3.normalize(e.viewVector),t),r=null!=n?s.BoundingBox.center(n):e.lookAt,i=s.Vector3.normalize(s.Vector3.cross(s.Vector3.normalize(e.viewVector),t));return e.rotateAroundAxisAtPoint(o,r,i)}})(o.camera(),t[0].normal,o.boundingBox()).render({animation:{milliseconds:500}})})),updateAxis:sa(aa((({set:t,reset:n,snapshot:o})=>async r=>{const i=await o.getPromise(Ja),a=await o.getPromise(ol),l=await o.getPromise(el),c=await o.getPromise(Qa),u=await o.getPromise(Aa),d=await(null==u?void 0:u.scene()),f=a[r],p=null!=f&&i.length>0&&function(e,t){const n=s.Angle.toDegrees(s.Vector3.angleTo(e,t));return 0===n||180===n}(i[0].normal,f)&&!isNaN(s.Vector3.angleTo(i[0].normal,f));if(null!=d&&!p){const e=await o.tryGetPromise(ml).then((e=>e.value));t(nl,r),t(Ja,[Wa(r,a,d.camera(),l,"global"!==c.mode?null==e?void 0:e.position:void 0)])}n(cl),e()}))),updateAlignment:sa((({set:e,reset:r})=>async(i,s)=>{r(ll),e(Qa,{mode:i,hitPending:"global"!==i&&null==s}),"global"===i?(r(nl),r(ol),t()):"surface"===i&&null!=s&&(await o(),n())})),cancelCurrentHit:sa((({set:e,snapshot:t})=>async()=>{const n=await t.getPromise(Qa);n.hitPending&&e(Qa,Object.assign(Object.assign({},n),{hitPending:!1}))})),sectionCurrentHit:sa((({set:e,snapshot:t})=>async()=>{const o=await t.getPromise(Qa);o.hitPending&&(e(Qa,Object.assign(Object.assign({},o),{hitPending:!1})),"surface"===o.mode&&n())}))}}var yl=Object.freeze({__proto__:null,DEFAULT_ALIGN_TO_PLANE_ANIMATION_DURATION_MS:500,DEFAULT_SLIDER_RANGE:qa,crossSectioningActiveAxis:nl,crossSectioningAdditionalToolsOpen:al,crossSectioningAlignment:Qa,crossSectioningAlignmentToolsOpen:ll,crossSectioningAvailableAxes:ol,crossSectioningAxisToolsOpen:cl,crossSectioningBorderWidth:Za,crossSectioningEnabled:Ya,crossSectioningHighlightColor:Xa,crossSectioningInteractionHandler:ul,crossSectioningIsInteractive:tl,crossSectioningOffsetScalar:rl,crossSectioningPlaneDisplayOffset:sl,crossSectioningPlanes:Ja,crossSectioningSliderRange:il,crossSectioningTargetBoundingBox:el,useCrossSectioning:function(e,t){const n=Es(ul);o.useEffect((()=>{t&&(null==e||e.registerInteractionHandler(n))}),[e,t,n])},useCrossSectioningActions:gl});const bl=()=>{const e=gl(),t=sa(aa((({snapshot:e})=>async()=>{await e.tryGetPromise(ml).then((e=>e.value))}))),n=sa(aa((({snapshot:e})=>async()=>{await e.tryGetPromise(ml).then((e=>e.value))}))),o=sa(aa((({set:e,snapshot:t})=>async()=>{const n=await t.tryGetPromise(ml).then((e=>e.value));e(Is,n)}))),r=sa(aa((({snapshot:e,set:t})=>async()=>{t(hl,await e.tryGetPromise(ml).then((e=>e.value)))})));return{tap:sa(aa((({snapshot:i,set:s})=>async({detail:a},...l)=>{const c=await i.getPromise(Qa),u=2!==(null==a?void 0:a.buttons)&&!(null==a?void 0:a.altKey);a.altKey||a.ctrlKey||a.metaKey||a.shiftKey;const d=u&&!c.hitPending,f=await i.tryGetPromise(ml).then((e=>e.value));s(pl,f),s(dl,a),t(),d&&(l.forEach((e=>e())),n()),o(),e.sectionCurrentHit(),r()}))),longPress:sa(aa((({snapshot:e,set:t,reset:n})=>async i=>{n(dl),t(fl,i.detail),await e.tryGetPromise(ml),o(),r()})))}},xl=Ss({key:"viewerToolkitHitState",get:({get:e})=>({tapDetails:e(dl),longPressDetails:e(fl),previousHitResult:e(pl),currentHitResult:e(hl)})});var wl=Object.freeze({__proto__:null,currentHitResult:hl,hitResult:ml,hitResultsLongPressDetails:fl,hitResultsSkipNextTap:vl,hitResultsTapDetails:dl,hitState:xl,previousHitResult:pl,useHitActions:bl});function Sl(){return{pointerDown:sa((({set:e})=>async t=>{if(2===t.button){const n=t.clientX,o=null==t?void 0:t.clientY;e(js,s.Point.create(n,o)),e(Rs,t.target)}})),pointerUp:sa((({snapshot:e,set:t})=>async(n,o,r,i)=>{const a=await e.getPromise(js),l=await e.getPromise(Cs);if(null!=a&&null==l){const e=n.clientX,l=null==n?void 0:n.clientY,c=s.Point.create(e,l),u=null!=a?s.Point.distance(a,c):0,d=null==r||r(n);u<2&&d&&(null==i||i(n,null!=a?a:c),t(Cs,o))}})),contextMenu:sa((()=>(e,t)=>{(null==t||t(e))&&e.preventDefault()})),longPress:sa((({set:e})=>(t,n,o,r)=>{if(null==o||o(t)){const o=s.Point.create(t.touches[0].clientX,t.touches[0].clientY);e(js,o),e(Rs,t.target),e(Cs,n),null==r||r(t,o)}})),clearActiveContextMenu:sa((({reset:e,set:t})=>n=>{t(vl,!!n),e(Cs),e(Os),e(js)})),clearDismissedState:sa((({reset:e})=>()=>e(vl)))}}function _l(e,t){return null!=t.closest(e)}const El=e=>{const t=e instanceof HTMLElement&&"VERTEX-AUTO-RESIZE-TEXTAREA"===e.tagName,n=e instanceof HTMLElement&&"VERTEX-TEXTFIELD"===e.tagName,o=e instanceof HTMLElement&&"true"===e.contentEditable,r=e instanceof HTMLElement&&"VERTEX-SCENE-TREE-SEARCH"===e.tagName,i=e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement,s=e instanceof HTMLElement&&"VERTEX-VIEWER-PIN-TOOL"===e.tagName,a=e instanceof HTMLElement&&"VERTEX-VIEWER-TRANSFORM-WIDGET"===e.tagName;return t||n||o||r||i||s||a},Tl=({reducer:e,atom:t})=>{const n=Ns((({set:n})=>async o=>{n(t,(t=>e(t,o)))}),[]);return n},Al=ws({key:"keyBindings",default:{applyBindings:[],bindings:{},pressed:{}}});function Vl(e,t){var n,o,r,i;switch(t.type){case"push-key-binding":return null!=(null===(n=e.bindings[t.binding.keyBind])||void 0===n?void 0:n.find((e=>e.id===t.binding.id)))?e:Object.assign(Object.assign({},e),{bindings:Object.assign(Object.assign({},e.bindings),{[t.binding.keyBind]:[...null!==(o=e.bindings[t.binding.keyBind])&&void 0!==o?o:[],t.binding]})});case"remove-key-binding":return null==(null===(r=e.bindings[t.binding.keyBind])||void 0===r?void 0:r.find((e=>e.id===t.binding.id)))?e:Object.assign(Object.assign({},e),{bindings:Object.assign(Object.assign({},e.bindings),{[t.binding.keyBind]:(null!==(i=e.bindings[t.binding.keyBind])&&void 0!==i?i:[]).filter((e=>e.id!==t.binding.id))})});case"add-apply-key-binding":return Object.assign(Object.assign({},e),{applyBindings:[...e.applyBindings,t.binding]});case"remove-apply-key-binding":return Object.assign(Object.assign({},e),{applyBindings:e.applyBindings.filter((e=>e.id!==t.id))});case"set-key-pressed":return Object.assign(Object.assign({},e),{applyBindings:e.applyBindings.map((t=>Object.assign(Object.assign({},t),{active:null!=t.keyBind&&Cl(t.keyBind,e.pressed)}))),pressed:Object.assign(Object.assign({},e.pressed),{[t.key]:t.pressed}),lastPressed:t.pressed?t.key:void 0})}}const Nl=()=>(({reducer:e,atom:t})=>[Es(t),Tl({reducer:e,atom:t})])({reducer:Vl,atom:Al});function kl(e,t){return e.includes("!")?!t[e.replace("!","")]&&!t[e.replace("!","").toLowerCase()]:t[e]||t[e.toLowerCase()]}function Cl(e,t){return e.split("+").every((e=>function(e,t){const n=e.split("||");return n.length>1?n.some((e=>kl(e,t))):kl(n[0],t)}(e,t)))}function jl(e,t,n){return e.filter((e=>!e.repeat)).filter((e=>{var o;return null!=e.keyBind&&null!=n&&(null===(o=e.keyBind)||void 0===o?void 0:o.includes(n))&&Cl(e.keyBind,t)})).map((e=>e.fn))}function Rl(e,t,n){return e.filter((e=>e.off&&e.active&&null!=e.keyBind&&null==n&&!Cl(e.keyBind,t))).map((e=>e.off))}const Il=e=>{const[t,n]=Nl();o.useEffect((()=>{const o=Ta.create();return n({type:"add-apply-key-binding",binding:Object.assign(Object.assign({},e),{id:o,active:null!=e.keyBind&&Cl(e.keyBind,t.pressed)})}),()=>{n({type:"remove-apply-key-binding",id:o})}}),[e.fn,e.off,e.keyBind,e.repeat])},Ol=(e,t=[])=>{const[,n]=Nl();o.useEffect((()=>{const t=null==e.addPredicate||e.addPredicate(),o=null!=e.cancelPredicate&&e.cancelPredicate();t&&n({type:"push-key-binding",binding:e}),o&&n({type:"remove-key-binding",binding:e})}),t)};const Ll=({targetElement:e,menuType:r,disableBackdrop:i,openPredicate:a,onOpen:l,onClose:c,children:u})=>{const d=Sl(),f=Es(Cs),h=Es(Ls),v=o.useMemo((()=>["bottom-end","top-start","top-end","right","left"]),[]),g=f===r;Ol({id:"ContextMenu",keyBind:"Escape",fn:d.clearActiveContextMenu,addPredicate:()=>null!=f&&f===r,cancelPredicate:()=>null==f},[f]);const y=o.useMemo((()=>null!=e?e:null!=a?window:void 0),[e,a]);return function({target:e,callback:t,delay:n=500,onMovement:o}){const[r,i]=p.useState(),[a,l]=p.useState();p.useEffect((()=>{const c=e=>{const o=e;null!=o.touches&&1===o.touches.length&&(null!=r&&clearTimeout(r),l(s.Point.create(o.touches[0].clientX,o.touches[0].clientY)),i(setTimeout((()=>null==t?void 0:t(o)),n)))},u=e=>{const t=e;null!=t.touches&&t.touches.length>0&&null!=r&&null!=a&&s.Point.distance(a,s.Point.create(t.touches[0].clientX,t.touches[0].clientY))>=2&&(clearTimeout(r),null==o||o())},d=()=>{null!=r&&clearTimeout(r)};return null==e||e.addEventListener("touchstart",c),null==e||e.addEventListener("touchmove",u),null==e||e.addEventListener("touchend",d),()=>{null==e||e.removeEventListener("touchstart",c),null==e||e.removeEventListener("touchmove",u),null==e||e.removeEventListener("touchend",d)}}),[e,r,a])}({target:y,callback:e=>d.longPress(e,r,a,l),onMovement:()=>d.clearActiveContextMenu()}),o.useEffect((()=>{const e=e=>{const t=function(e){return e.target instanceof Element&&_l("vertex-menu",e.target)}(e);if(!t&&2!==e.buttons&&f===r){const t=function(e){return e.target instanceof Element&&_l("vertex-viewer",e.target)}(e);d.clearActiveContextMenu(t)}};if(i)return window.addEventListener("pointerdown",e),()=>{window.removeEventListener("pointerdown",e)}}),[i,r,f]),o.useEffect((()=>{const e=e=>{d.pointerDown(e)},t=e=>{d.pointerUp(e,r,a,l)},n=e=>d.contextMenu(e,a);return null==y||y.addEventListener("pointerdown",e),null==y||y.addEventListener("pointerup",t),null==y||y.addEventListener("contextmenu",n),()=>{null==y||y.removeEventListener("pointerdown",e),null==y||y.removeEventListener("pointerup",t),null==y||y.removeEventListener("contextmenu",n)}}),[e,r,a]),t.jsx(n.VertexMenu,{className:m({hidden:!g}),"data-testid":`${r}-context-menu`,open:g,position:h,fallbackPlacements:v,backdrop:!i,onMenuClosed:()=>{d.clearActiveContextMenu(),null==c||c()},children:t.jsx("div",{className:"pt-1",children:u})})};var Ml;!function(e){e.HIDE_ITEM="Hide Item",e.SHOW_ONLY_SELECTED="Show Only Selected",e.HIDE_SELECTED="Hide Selected",e.SHOW_ONLY_ITEM="Show Only Item",e.SHOW_ALL="Show All",e.HIDE_ALL="Hide All",e.SELECT_FILTERED_ITEMS="Select Filtered Items",e.INVERT_SELECTION="Invert Selection",e.CLEAR_ALL_TRANSFORMS="Clear All Transforms",e.CLEAR_SELECTED_TRANSFORMS="Clear Selected Transforms",e.CLEAR_SELECTION="Clear Selection",e.DESELECTING_ITEMS="Deselecting Items",e.SELECTING_ITEMS="Selecting Items",e.SELECTING_ONLY_ITEM="Selecting Only Item",e.SELECTING_ANCESTOR="Selecting Ancestor",e.APPLY_MATERIAL_OVERRIDE_TO_ALL="Apply Material Override To All",e.APPLY_MATERIAL_OVERRIDE_TO_SELECTION="Apply Material Override To Selection",e.CLEAR_ALL_MATERIAL_OVERRIDES="Clear All Material Overrides",e.CLEAR_SELECTED_MATERIAL_OVERRIDES="Clear Selected Material Overrides",e.SET_PHANTOM_ALL="Set Phantom All",e.SET_PHANTOM_SELECTED_ITEMS="Set Phantom Selected Items",e.CLEAR_PHANTOM_ALL="Clear Phantom All",e.CLEAR_PHANTOM_SELECTED_ITEMS="Clear Phantom Selected Items",e.SET_PHANTOM_NON_SELECTED_ITEMS="Set Phantom Non Selected Items",e.RESTORE_PHANTOM_OVERRIDES="Restore Phantom Overrides",e.SET_ITEM_AS_END_ITEM="Set Item as End Item",e.UNSET_ITEM_AS_END_ITEM="Unset Item as End Item",e.SHOW_ANNOTATION="Show Annotation",e.HIDE_ANNOTATION="Hide Annotation"}(Ml||(Ml={}));const Pl=_s({key:"selectionSelectedItems",default:void 0}),Dl=ws({key:"selectionSelectedItemIds",default:[]}),Bl=ws({key:"selectionLastSelected",default:void 0}),zl=ws({key:"selectionLastSelectionFromViewer",default:!1}),Ul=ws({key:"selectionLastSelectWasMultiSelect",default:!1}),Hl=Ss({key:"selectionHighestSelectedAncestor",get:({get:e})=>{var t,n;const o=e(Bl),r=e(Dl);return null!==(n=null===(t=null==o?void 0:o.ancestors)||void 0===t?void 0:t.find((e=>r.includes(e))))&&void 0!==n?n:null==o?void 0:o.id}}),Fl=ws({key:"selectionPreviousVisibleSummary",default:void 0}),$l=ws({key:"selectionVisibleSummary",default:void 0}),Kl=Ss({key:"selectionVisibleCount",get:({get:e})=>{var t,n;return null!==(n=null===(t=e($l))||void 0===t?void 0:t.count)&&void 0!==n?n:0}}),Gl=Ss({key:"selectionIsActive",get:({get:e})=>{const t=e(Dl);return e(Kl)>0||t.length>0}});function Wl(){const e=Ia(),t=sa((({snapshot:e,reset:t})=>async()=>{(await e.getPromise(Dl)).forEach((e=>t(Pl(e))))})),n=sa((({snapshot:t,reset:n,set:o})=>async(r,i)=>{var s,a;const l=await t.getPromise(Pl(r.id)),u=await t.getPromise(Dl),d=null===(a=[...null!==(s=r.ancestors)&&void 0!==s?s:[]])||void 0===a?void 0:a.reverse().find((e=>!u.includes(e)));null!=l&&null!=d?(o(Pl(d),{id:d}),o(Dl,(e=>[...e,d])),e.execute(Ml.SELECTING_ANCESTOR,e.selectItemsTransform(d))):(null==i?void 0:i.clear)?(o(Pl(r.id),r),o(Dl,[r.id]),e.execute(Ml.SELECTING_ONLY_ITEM,e.clearSelectionTransform,e.selectItemsTransform(r.id))):(o(Pl(r.id),r),o(Dl,(e=>[...e,r.id])),e.execute(Ml.SELECTING_ITEMS,e.selectItemsTransform(r.id))),c(r),o(Bl,r),o(zl,!0),n(Ul)})),o=sa((({reset:t,set:n})=>async o=>{t(Pl(o)),t(Ul),n(Dl,(e=>e.filter((e=>e!==o)))),e.execute(Ml.DESELECTING_ITEMS,e.deselectItemsTransform(o))})),r=sa((({snapshot:e})=>async t=>{const r=await e.getPromise(Pl(t.id));null!=r?await o(r.id):await n(t)})),i=sa((({snapshot:e,reset:t,set:o})=>async(r,i={})=>{const s=await e.getPromise(Pl(r.id)),a=await e.getPromise(Dl);if(a.filter((e=>{var t;return e!==r.id&&!(null===(t=r.ancestors)||void 0===t?void 0:t.includes(e))})).forEach((e=>t(Pl(e)))),t(Ul),s)if(i.ignoreAncestorSelection)t(Dl),t(Pl(s.id));else{const e=a.filter((e=>{var t;return e===r.id||(null===(t=r.ancestors)||void 0===t?void 0:t.includes(e))}));o(Dl,e)}else t(Dl);await n(r,{clear:!0})})),s=sa((({reset:e})=>async()=>{await t(),e(Dl),e(Bl),e(zl),e(Ul)})),a=sa((()=>async()=>{await s(),e.execute(Ml.CLEAR_SELECTION,e.clearSelectionTransform)})),l=sa((({set:e})=>async t=>{e(Ul,t)})),c=sa((({reset:e,set:t})=>e=>{}));return{select:n,toggleSelection:r,clearAndSelect:i,selectCurrentHit:sa(aa((({snapshot:e})=>async()=>{const t=await e.tryGetPromise(ml).then((e=>e.value)),n=await e.getPromise(dl),o=(null==n?void 0:n.metaKey)||(null==n?void 0:n.ctrlKey)||(null==n?void 0:n.shiftKey);null==t||o?null!=t&&o?r(t):a():i(t)}))),syncSelection:sa((({set:e,reset:n})=>async(o,r)=>{r.selected?(await t(),e(Pl(o.id),o),r.multiSelect?e(Dl,(e=>[...e.filter((e=>e!==o.id)),o.id])):e(Dl,[o.id]),c(o),e(Bl,o),e(zl,!1),e(Ul,!!r.multiSelect)):(n(Pl(o.id)),n(Ul),e(Dl,(e=>e.filter((e=>e!==o.id)))))})),deselect:o,clearSelection:a,resetSelectionState:s,toggleLastSelectWasMultiSelect:l,selectForModelViewsPanel:c}}const ql=Ss({key:"viewerToolkitSelectionState",get:({get:e})=>({selectedItemIds:e(Dl),lastSelected:e(Bl),highestSelectedAncestorId:e(Hl)})});var Yl=Object.freeze({__proto__:null,selectionHighestSelectedAncestor:Hl,selectionIsActive:Gl,selectionLastSelectWasMultiSelect:Ul,selectionLastSelected:Bl,selectionLastSelectionFromViewer:zl,selectionPreviousVisibleSummary:Fl,selectionSelectedItemIds:Dl,selectionSelectedItems:Pl,selectionState:ql,selectionVisibleCount:Kl,selectionVisibleSummary:$l,useSelectionActions:Wl});const Xl=()=>{const e=Es(Dl),o=Es($l),r=Oa();return t.jsxs(n.VertexMenuItem,{"data-testid":"fit-selected-menu-option",onClick:()=>{null!=(null==o?void 0:o.boundingBox)&&r.flyToByBoundingBox(o.boundingBox)},disabled:0===e.length,children:[t.jsx(n.VertexIcon,{slot:"icon",name:"fit-selected",size:"sm"}),t.jsx("div",{className:"pl-2",children:"Fit Selected"})]})},Zl=()=>{const e=Oa(),o=Es(Is);return t.jsxs(n.VertexMenuItem,{"data-testid":"fly-to-part-menu-option",onClick:()=>{var t;const n=ks(o)?null===(t=null==o?void 0:o.node.id)||void 0===t?void 0:t.hex:null==o?void 0:o.id;null!=n&&e.flyToById(n)},disabled:null==o,children:[t.jsx(n.VertexIcon,{slot:"icon",name:"paper-airplane",size:"sm"}),t.jsx("div",{className:"pl-2",children:"Fly To"})]})};function Jl(){const e=Es(Aa);return{sceneItemsOperation:o.useCallback((async(t,n)=>{const o=await(null==e?void 0:e.scene());null==n?await(null==o?void 0:o.items((e=>t(e.where((e=>e.all()))))).execute()):n.length>0&&await(null==o?void 0:o.items((e=>t(e.where((e=>e.withItemIds(n)))))).execute())}),[e]),showOnlySelected:o.useCallback((async()=>{const t=await(null==e?void 0:e.scene());null==t||t.items((e=>[e.where((e=>e.all())).hide(),e.where((e=>e.withSelected())).show()])).execute()}),[e]),hideSelected:o.useCallback((async()=>{const t=await(null==e?void 0:e.scene());null==t||t.items((e=>[e.where((e=>e.withSelected())).hide()])).execute()}),[e]),showOnlyItem:o.useCallback((async t=>{const n=await(null==e?void 0:e.scene());null==n||n.items((e=>[e.where((e=>e.all())).hide(),e.where((e=>e.withItemIds([t]))).show()])).execute()}),[e]),ghostSelected:o.useCallback((async()=>{const t=await(null==e?void 0:e.scene());null==t||t.items((e=>[e.where((e=>e.withSelected())).setPhantom(!0)])).execute()}),[e]),unGhostSelected:o.useCallback((async()=>{const t=await(null==e?void 0:e.scene());null==t||t.items((e=>[e.where((e=>e.withSelected())).setPhantom(!1)])).execute()}),[e])}}const Ql=()=>{const e=Jl();return t.jsxs(n.VertexMenuItem,{"data-testid":"hide-all-menu-option",onClick:()=>{e.sceneItemsOperation((e=>e.hide()))},children:[t.jsx(n.VertexIcon,{slot:"icon",name:"visibility-hidden",size:"sm"}),t.jsx("div",{className:"pl-2",children:"Hide All Parts"})]})},ec=()=>{const e=Es(Is),o=Jl();return t.jsxs(n.VertexMenuItem,{"data-testid":"hide-menu-option",onClick:()=>{var t;const n=ks(e)?null===(t=null==e?void 0:e.node.id)||void 0===t?void 0:t.hex:e.id;null!=n&&o.sceneItemsOperation((e=>e.hide()),[n])},disabled:null==e,children:[t.jsx(n.VertexIcon,{slot:"icon",name:"visibility-hidden",size:"sm"}),t.jsx("div",{className:"pl-2",children:"Hide Part"})]})},tc=()=>{const e=Es(Dl),o=Jl();return t.jsxs(n.VertexMenuItem,{"data-testid":"hide-selected-menu-option",onClick:()=>o.hideSelected(),disabled:0===e.length,children:[t.jsx(n.VertexIcon,{slot:"icon",name:"visibility-hidden",size:"sm"}),t.jsx("div",{className:"pl-2",children:"Hide Selected"})]})},nc=()=>{const e=Jl();return t.jsxs(n.VertexMenuItem,{"data-testid":"show-all-menu-option",onClick:()=>{e.sceneItemsOperation((e=>e.show()))},children:[t.jsx(n.VertexIcon,{slot:"icon",name:"visibility-visible",size:"sm"}),t.jsx("div",{className:"pl-2",children:"Show All Parts"})]})},oc=()=>{const e=Es(Is),o=Jl();return t.jsxs(n.VertexMenuItem,{"data-testid":"show-only-menu-option",onClick:()=>{var t;const n=ks(e)?null===(t=null==e?void 0:e.node.id)||void 0===t?void 0:t.hex:null==e?void 0:e.id;null!=n&&o.showOnlyItem(n)},disabled:null==e,children:[t.jsx(n.VertexIcon,{slot:"icon",name:"visibility-visible",size:"sm"}),t.jsx("div",{className:"pl-2",children:"Show Only Part"})]})},rc=()=>{const e=Es(Dl),o=Jl();return t.jsxs(n.VertexMenuItem,{"data-testid":"show-only-selected-menu-option",onClick:()=>o.showOnlySelected(),disabled:0===e.length,children:[t.jsx(n.VertexIcon,{slot:"icon",name:"visibility-visible",size:"sm"}),t.jsx("div",{className:"pl-2",children:"Show Only Selected"})]})};ws({key:"sceneTreeLoaderVisible",default:!1});const ic=ws({key:"sceneTreeElement",default:void 0}),sc=ws({key:"sceneTreeWidth",default:void 0});function ac(){const e=Wl(),t=Oa();return{toggleSelection:sa((({snapshot:t})=>async(n,o,r)=>{var i,s;if(!n.defaultPrevented&&0===n.button&&(n.altKey||((n.ctrlKey||n.metaKey)&&o.selected?r.deselectItem(o):o.selected?r.selectItem(o,{recurseParent:!0}):o.selected||r.selectItem(o,{append:n.ctrlKey||n.metaKey,range:n.shiftKey})),null!=o.id)){const r=await t.getPromise(Bl);e.syncSelection({id:null===(i=o.id)||void 0===i?void 0:i.hex,ancestors:null!==(s=null==r?void 0:r.ancestors)&&void 0!==s?s:[]},{selected:!n.metaKey&&!n.ctrlKey||!o.selected,multiSelect:n.shiftKey||n.metaKey||n.ctrlKey})}})),toggleExpansion:sa((()=>(e,t,n)=>{n.toggleExpandItem(t)})),toggleVisibility:sa((()=>(e,t,n)=>{n.toggleItemVisibility(t)})),flyToRow:sa((({snapshot:e})=>async n=>{var o;const r=await e.getPromise(ic),i=await(null==r?void 0:r.getRowAtClientY(n));null!=(null===(o=null==i?void 0:i.node.id)||void 0===o?void 0:o.hex)&&await t.flyToById(i.node.id.hex)})),setContextMenuItem:sa((({set:e,snapshot:t})=>async n=>{const o=await t.getPromise(ic),r=await(null==o?void 0:o.getRowAtClientY(n));e(Is,r)}))}}Ss({key:"sceneTreeController",get:({get:e})=>{var t;return null===(t=e(ic))||void 0===t?void 0:t.controller},dangerouslyAllowMutability:!0});const lc=()=>{const e=Es(Dl),o=Jl();return t.jsxs(n.VertexMenuItem,{"data-testid":"ghost-selected-menu-option",onClick:()=>o.ghostSelected(),disabled:0===e.length,children:[t.jsx(n.VertexIcon,{slot:"icon",name:"visibility-partial",size:"sm"}),t.jsx("div",{className:"pl-2",children:"Ghost Selected"})]})},cc=()=>{const e=Es(Dl),o=Jl();return t.jsxs(n.VertexMenuItem,{"data-testid":"unghost-selected-menu-option",onClick:()=>o.unGhostSelected(),disabled:0===e.length,children:[t.jsx(n.VertexIcon,{slot:"icon",name:"visibility-visible",size:"sm"}),t.jsx("div",{className:"pl-2",children:"Unghost Selected"})]})},uc=()=>t.jsxs("div",{className:"w-56",children:[t.jsx(tc,{}),t.jsx(Ql,{}),t.jsx(oc,{}),t.jsx(rc,{}),t.jsx(nc,{}),t.jsx(lc,{}),t.jsx(cc,{}),t.jsx(n.VertexMenuDivider,{}),t.jsx(Xl,{}),t.jsx(Zl,{})]}),dc=({children:e})=>{const n=ac(),o=Es(ic),r=null!=e&&!1!==e;return t.jsx(Ll,{menuType:"scene-tree",targetElement:o,onOpen:async(e,t)=>{const o=e;await n.setContextMenuItem(o.clientY)},disableBackdrop:!0,children:r?e:t.jsx(uc,{})})},fc=()=>t.jsxs("div",{className:"w-56",children:[t.jsx(ec,{}),t.jsx(tc,{}),t.jsx(Ql,{}),t.jsx(oc,{}),t.jsx(rc,{}),t.jsx(nc,{}),t.jsx(lc,{}),t.jsx(cc,{}),t.jsx(n.VertexMenuDivider,{}),t.jsx(Xl,{}),t.jsx(Zl,{})]}),pc=({children:e})=>{const n=Es(Aa),o=null!=e&&!1!==e;return t.jsx(Ll,{menuType:"viewer",targetElement:n,disableBackdrop:!0,children:o?e:t.jsx(fc,{})})},hc=ws({key:"viewerToolkitSdkConfig",default:void 0});function mc({state:e}){const t=Ns((({set:t})=>n=>{t(e,n)}),[]);return t}var vc;function gc(e){return null!=e?{"--scene-tree-default-font-family":bc(e.fontFace),"--scene-tree-default-font-color":e.color}:{}}function yc(e){const t=null==e?void 0:e.depthColors,n=null!=t?Object.keys(t).reduce(((e,n)=>Object.assign(Object.assign({},e),{[`--scene-tree-row-background-color-depth-${n}`]:t[parseInt(n)]})),{}):{};return null!=e?Object.assign(Object.assign({},n),{"--scene-tree-hovered-row-background-color":e.hovered,"--scene-tree-selected-row-background-color":e.selected,"--scene-tree-row-background-color":e.defaultColor}):{}}function bc(e){return e===vc.ROBOTO_MONO?"var(--vertex-ui-font-family-monospace)":"var(--vertex-ui-font-family)"}!function(e){e.ROBOTO="ROBOTO",e.ROBOTO_MONO="ROBOTO_MONO"}(vc||(vc={}));const xc=()=>{const e=Es(ic);return t.jsx(n.VertexTooltip,{className:"w-auto",content:"Collapse All",placement:"top",children:t.jsx(n.VertexIcon,{size:"sm",className:"h-6 w-6 hover:bg-neutral-300 rounded cursor-pointer","data-testid":"collapse-all-icon",name:"collapse-all",onClick:()=>{null==e||e.collapseAll()}})})},wc=()=>{const e=Es(ic);return t.jsx(n.VertexTooltip,{className:"w-auto",content:"Expand All",placement:"top",children:t.jsx(n.VertexIcon,{size:"sm","data-testid":"expand-all-icon",className:"h-6 w-6 hover:bg-neutral-300 rounded cursor-pointer",name:"expand-all",onClick:()=>{null==e||e.expandAll()}})})};function Sc(){return t.jsx(a.VertexSceneTreeToolbar,{className:"h-10 border-b border-neutral-300 box-border",children:t.jsxs("div",{className:"flex flex-shrink-0 w-full text-neutral-700 items-center gap mx-2",children:[t.jsx(wc,{}),t.jsx(xc,{})]})})}const _c=({children:e})=>{const n=null!=e&&!1!==e;return t.jsx("div",{slot:"header",className:"flex flex-col",children:n?e:t.jsxs(t.Fragment,{children:[t.jsx(a.VertexSceneTreeSearch,{className:"border-b border-neutral-300"}),t.jsx(Sc,{})]})})},Ec={binding:"{{row.node.name}}",label:"Name",metadataKeyName:"VERTEX_SCENE_ITEM_NAME"},Tc=Ss({key:"sceneTreeColumnsActiveColumns",get:({get:e})=>{const t=[],n=e(sc);if(null!=n&&n>0){const e=1/(t.length+1)*n,o=(n-e)/t.length;return{Name:Object.assign(Object.assign({},Ec),{initialWidth:e,minWidth:o})}}return{Name:Ec}}}),Ac=Ss({key:"sceneTreeColumnsActiveColumnNames",get:({get:e})=>Object.keys(e(Tc))}),Vc=e=>{const n=Es(Tc),o=Es(Ac),r=[];return t.jsx(a.VertexSceneTreeTableLayout,Object.assign({"data-testid":"scene-tree-table-layout"},e,{children:o.map(((e,i)=>{var s;const l=n[e],c=null!==(s=r[i])&&void 0!==s?s:l.initialWidth;return t.jsxs(a.VertexSceneTreeTableColumn,{"data-testid":`scene-tree-table-column-${i}`,initialWidth:c,minWidth:l.minWidth,children:[t.jsx("template",{slot:"header",dangerouslySetInnerHTML:{__html:`\n <div class="text-sm text-neutral-800 my-2">\n <div class="${m("truncate",{"pl-2":0===i,"pr-2":i===o.length-1})}">\n ${l.label}\n </div>\n </div>\n `}}),t.jsx("template",{dangerouslySetInnerHTML:{__html:`\n <vertex-scene-tree-table-cell\n prop:value="${l.binding}"\n prop:selection-handler="{{row.data.handleSelection}}"\n prop:expansion-handler="{{row.data.handleExpansion}}"\n prop:visibility-handler="{{row.data.handleVisibility}}"\n ${0===i?"expand-toggle":""}\n ${i===o.length-1?"isolate-button visibility-toggle":""}>\n <div class="flex items-center gap-2">\n <vertex-tooltip \n class="truncate" \n prop:content="${null!=l.binding?l.binding:"--"}" \n placement="${i!==o.length-1?"right":"top"}">\n <div class="flex items-center w-full">\n <div class="truncate">${l.binding}</div>\n </div>\n </vertex-tooltip>\n </div>\n \n\n <div slot="placeholder" class="flex items-center w-full truncate">\n <div> -- </div>\n </div>\n </vertex-scene-tree-table-cell>\n `}})]},l.label)}))}))},Nc=ws({key:"openedPanelActivePrimaryLeft",default:void 0}),kc=ws({key:"openedPanelActivePrimaryRight",default:void 0});const Cc=255,jc=ws({key:"sceneItemAdjustmentsSelectedColor",default:void 0}),Rc=ws({key:"sceneItemAdjustmentsSelectedOpacity",default:void 0}),Ic=_s({key:"appliedItemMaterialOverride",default:void 0}),Oc=ws({key:"appliedItemMaterialOverrideIds",default:[]}),Lc=Ss({key:"sceneItemAdjustmentsLastSelectedOverride",get:({get:e})=>{const t=e(Bl);if(null!=t)return e(Ic(t.id))}}),Mc=ws({key:"applyMaterialToAllUserAction",default:void 0}),Pc=ws({key:"showConfirmDialogWhenApplyingMaterialToAll",default:!0}),Dc=ws({key:"confirmApplyMaterialToAllDialogOpen",default:!1}),Bc=()=>{const e=Ia(),t=sa((({snapshot:e,reset:t})=>async()=>{const n=await e.getPromise(Oc);t(jc),n.forEach((e=>t(Ic(e)))),t(Oc)}));return{updateColor:sa((({set:e})=>t=>{e(jc,t)})),clearCurrentColor:sa((({reset:e})=>()=>{e(jc)})),clearCurrentOpacity:sa((({reset:e})=>()=>{e(Rc)})),clear:sa((({snapshot:t,set:n,reset:o})=>async()=>{const r=await t.getPromise(Dl);o(jc),r.forEach((e=>o(Ic(e)))),n(Oc,(e=>e.filter((e=>!r.includes(e))))),await e.execute(Ml.CLEAR_SELECTED_MATERIAL_OVERRIDES,(e=>e.where((e=>e.withSelected())).clearMaterialOverrides().select()))})),clearAll:sa((()=>async()=>{await t(),await e.execute(Ml.CLEAR_ALL_MATERIAL_OVERRIDES,(e=>e.where((e=>e.all())).clearMaterialOverrides()),(e=>e.where((e=>e.withSelected())).select()))})),clearState:t,updateOpacity:sa((({set:e})=>t=>{e(Rc,t)})),apply:sa((({snapshot:t,set:n})=>async()=>{const o=await t.getPromise(jc),r=await t.getPromise(Rc),i=await t.getPromise(Dl),s=await t.getPromise(Lc),a=null!=o?o:s,l=null!=r?r:null==s?void 0:s.opacity;if(null!=a){const t=Object.assign(Object.assign({},a),{opacity:null!=l?l:a.opacity});await e.execute(Ml.APPLY_MATERIAL_OVERRIDE_TO_SELECTION,(e=>e.where((e=>e.withSelected())).materialOverride(t))),i.forEach((e=>n(Ic(e),t))),n(Oc,(e=>[...e,...i]))}})),confirmApplyAll:sa((({set:e})=>t=>{e(Dc,!0),e(Mc,(()=>t))})),cancelApplyAll:sa((({reset:e})=>()=>{e(Dc),e(Mc)})),applyAll:sa((({snapshot:t,reset:n})=>async()=>{const o=await t.getPromise(jc),r=await t.getPromise(Rc);if(null!=o){const i=await t.getPromise(Oc),s=Object.assign(Object.assign({},o),{opacity:null!=r?r:o.opacity});await e.execute(Ml.APPLY_MATERIAL_OVERRIDE_TO_ALL,(e=>e.where((e=>e.all())).materialOverride(s))),i.forEach((e=>n(Ic(e))));const a=await t.getPromise(Mc);null==a||a(s),n(Dc),n(Mc)}})),hideConfirmApplyAllDialog:sa((({set:e})=>()=>{e(Pc,!1)}))}};function zc({header:e,children:n}){return t.jsxs("div",{className:"py-3 px-4 border-neutral-300 border-b",children:[t.jsx("div",{className:"my-2 text-base text-neutral-700",children:e}),n]})}const Uc=({onApplyAll:e})=>{const o=Bc(),r=Ts(Lc),i=Es(jc),s=Es(Pc),a=p.useMemo((()=>"hasValue"===r.state?null!=i?i:r.contents:i),[r,i]);return t.jsx(n.VertexTooltip,{content:"Apply to All",children:t.jsx(n.VertexIconButton,{iconName:"square-dot-outline",iconSize:"sm",color:"secondary",disabled:null==a,onClick:async()=>{s?o.confirmApplyAll(e):(await o.applyAll(),null==e||e(a))}})})};function Hc(){const e=Bc(),r=Es(Dc),[i,s]=o.useState(!1),a=()=>{e.cancelApplyAll(),s(!1)};return r?t.jsxs(n.VertexDialog,{open:!0,className:"text-sm",onClosed:a,onBackdropClick:a,children:[t.jsx("div",{slot:"heading",children:"Apply to All Parts"}),t.jsx("div",{className:"max-w-lg break-words pr-2",children:"This will apply the same material to all parts in the model. Any previous material changes will be lost."}),t.jsxs("div",{className:"flex mt-8 gap-2 items-center",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx(n.VertexToggle,{"data-testid":"hide-confirmation-dialog-in-future-checkbox",variant:"check",className:"pt-1",checked:i,onValueChanged:e=>{s(e.detail)}}),"Don't show again this session"]}),t.jsxs("div",{className:"flex ml-auto gap-2",children:[t.jsx(n.VertexButton,{"data-testid":"cancel-apply-material-to-all",onClick:a,children:"Cancel"}),t.jsx(n.VertexButton,{color:"primary","data-testid":"confirm-apply-material-to-all",onClick:async()=>{await e.applyAll(),i&&e.hideConfirmApplyAllDialog()},children:"Apply"})]})]})]}):t.jsx(t.Fragment,{})}function Fc(e,t){const[n,r]=o.useState();return o.useEffect((()=>()=>{null!=n&&clearTimeout(n)}),[e,t,n]),o.useCallback((o=>{null!=n&&clearTimeout(n),r(setTimeout((()=>{e(o)}),t))}),[e,t,n])}const $c=({onApply:e})=>{const o=Bc(),r=Ts(Lc),i=Es(jc),s=p.useMemo((()=>"hasValue"===r.state?null!=i?i:r.contents:i),[r,i]),a=Fc((()=>{o.apply()}),500),c=p.useCallback((e=>{const t=e.target;o.updateColor(function(e,t=Ta.create()){return Object.assign({id:t},l.ColorMaterial.fromHex(e))}(t.value)),a(t.value)}),[a,o]);return t.jsx(n.VertexColorPicker,{"data-testid":"selected-item-color-picker",value:null!=s?ga.toHexString(s.diffuse):void 0,onValueChanged:()=>{o.apply(),null==e||e(s)},onInput:c})},Kc=({onApply:e})=>{const o=Bc(),r=Es(Rc),i=Ts(Lc),s=p.useMemo((()=>{var e,t;return"hasValue"===i.state?null!==(t=null!=r?r:null===(e=i.contents)||void 0===e?void 0:e.opacity)&&void 0!==t?t:Cc:null!=r?r:Cc}),[r,i]),a=Fc((()=>{o.apply()}),500),l=p.useCallback((e=>{o.updateOpacity(e.detail.value),a(e.detail.value)}),[a,o]),c=p.useMemo((()=>"hasValue"!==i.state||null==i.contents),[i]);return t.jsx(n.VertexTooltip,{className:"flex w-full",content:c?"Select a part and apply a color to enable opacity":`${Math.floor(s/Cc*100)}%`,placement:"top",children:t.jsxs("div",{className:"flex items-center w-full gap-2",children:[t.jsx("div",{className:"text-xs pr-2 text-center",children:"0%"}),t.jsx(n.VertexSlider,{className:"flex-grow mt-2","data-testid":"scene-item-adjustments-opacity-slider",disabled:c,value:null!=s?s:Cc,step:5,min:0,max:Cc,onValueChange:t=>{o.updateOpacity(t.detail.value),o.apply(),null==e||e(t.detail.value)},onValueInput:l}),t.jsx("div",{className:"text-xs pr-2 text-right cursor-default",children:"100%"})]})})};function Gc({onApplyMaterial:e,onApplyMaterialToAll:n,onApplyOpacity:r}){const i=Bc(),s=Es(Bl);return o.useEffect((()=>{i.clearCurrentColor(),i.clearCurrentOpacity()}),[null==s?void 0:s.id]),t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-col",children:[t.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Color"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx($c,{onApply:e}),t.jsx(Uc,{onApplyAll:n})]})]}),t.jsxs("div",{className:"flex flex-col",children:[t.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Opacity"}),t.jsx("div",{className:"flex items-center",children:t.jsx(Kc,{onApply:r})})]}),t.jsx(Hc,{})]})}const Wc=({id:e,tooltip:r,children:i})=>{const[s,a]=o.useState(!1);return t.jsx("div",{className:"ml-auto",children:t.jsxs(n.VertexDropdownMenu,{className:"flex items-stretch h-full","data-testid":`reset-button-dropdown-menu-${e}`,placement:"bottom-end",onMenuOpened:()=>a(!0),onMenuClosed:()=>a(!1),children:[t.jsx("div",{slot:"anchor",className:"flex items-center h-full",children:t.jsx(n.VertexTooltip,{content:r,disabled:s,placement:"bottom",children:t.jsxs(n.VertexButton,{className:m("p-1.5 rounded-md select-none hover:bg-neutral-300 active:bg-neutral-400 cursor-pointer",{"bg-neutral-300":s}),"data-testid":`reset-button-${e}`,variant:"plaintext",children:[t.jsx(n.VertexIcon,{className:"px-0.5",name:"reset",size:"sm"}),t.jsx(n.VertexIcon,{name:"chevron-down",size:"sm"})]})})}),t.jsx("div",{className:"whitespace-nowrap",children:i})]})})},qc=({canClearSelected:e,onClear:o,onClearAll:r})=>{const i=Bc();return t.jsx("div",{className:"ml-auto",children:t.jsxs(Wc,{id:"materials",tooltip:"Clear Materials",children:[t.jsx("div",{className:"pt-1"}),t.jsx(n.VertexMenuItem,{"data-testid":"clear-selected-materials",onClick:()=>{i.clear(),null==o||o()},disabled:!e,children:"Clear selected materials"}),t.jsx(n.VertexMenuItem,{"data-testid":"clear-all-materials",onClick:()=>{i.clearAll(),null==r||r()},children:"Clear all materials"})]})})};function Yc({onClearMaterial:e,onClearAllMaterials:n,onApplyMaterial:r,onApplyMaterialToAll:i,onApplyOpacity:s}){const a=Bc(),l=Es(Gl),c=Es(Bl);return o.useEffect((()=>{a.clearCurrentColor(),a.clearCurrentOpacity()}),[null==c?void 0:c.id]),t.jsx(zc,{header:t.jsxs("div",{className:"flex items-center text-base",children:["Material",t.jsx(qc,{canClearSelected:l,onClear:e,onClearAll:n})]}),children:t.jsx(Gc,{onApplyMaterial:r,onApplyMaterialToAll:i,onApplyOpacity:s})})}function Xc(){return t.jsx("div",{className:"flex flex-col text-neutral-700 h-full overflow-y-auto",children:t.jsx(Yc,{})})}const Zc="Appearance",Jc=()=>{const e=function(e){if("appearance"===e)return Zc;return"None"}(Es(kc));return t.jsx("div",{className:"flex flex-col w-full items-center z-overlay pointer-events-none md:pointer-events-auto py-3 px-4 border-b border-neutral-300",children:t.jsx("div",{className:"items-center w-full leading-6 text-md align-center font-medium text-neutral-800",children:e})})};function Qc({children:e}){return t.jsx("div",{className:"pointer-events-auto flex flex-col items-center w-full border-neutral-300 py-2",children:e})}function eu({name:e,iconName:r,active:i,responsive:s,disabled:a,content:l,tooltipPlacement:c,children:u,onSelect:d,onDeselect:f}){return t.jsx("div",{className:m({"text-[var(--vertex-ui-blue-700)]":i===e&&!a,"text-neutral-700 hover:text-neutral-800":i!==e&&!a,"cursor-pointer hover:bg-neutral-200":!a,"text-neutral-400":a,"rounded-full md:p-3":s,"p-3":!s&&null==u,"px-3 py-1":null!=u}),"data-testid":`${e}-sidebar-panel`,onClick:()=>{a||(i===e?f():d())},children:t.jsxs(n.VertexTooltip,{placement:null!=c?c:void 0,content:o.isValidElement(l)?void 0:l,children:[t.jsx("div",{slot:"content",children:l}),t.jsxs("div",{className:"flex flex-col",children:[t.jsx(n.VertexIcon,{name:r}),u]})]})})}const tu=(e,t)=>{const n=Vs(e);o.useEffect((()=>{n(t)}),[n,t])},nu=o=>{var{open:r,children:i}=o,s=e.__rest(o,["open","children"]);const a=i.find((e=>e.type===ou)),l=i.filter((e=>e.type!==ou));return null==a?t.jsx(t.Fragment,{}):t.jsxs(n.VertexPopover,Object.assign({className:"flex",placement:"top",backdrop:!1,open:r},s,{children:[a,t.jsx("div",{className:m("flex mb-1.5",{hidden:!r}),"data-testid":"align-plane-popover-menu",children:l})]}))},ou=({tooltipContent:e,children:o})=>t.jsx("div",{slot:"anchor",children:t.jsx(n.VertexTooltip,{className:"cursor-pointer",content:e,children:o})});nu.Anchor=ou;const ru=r=>{var{value:i,defaultValue:s,onChange:a,onValueChange:l,onValueInput:c}=r,u=e.__rest(r,["value","defaultValue","onChange","onValueChange","onValueInput"]);const[d,f]=o.useState(s);return t.jsx(n.VertexSlider,Object.assign({className:"w-52 mx-2 items-center",value:null!=i?i:d,onValueChange:e=>{f(e.detail.value),null==a||a(e.detail.value),null==l||l(e)},onValueInput:e=>{f(e.detail.value),null==a||a(e.detail.value),null==c||c(e)}},u))};function iu(){return t.jsx("div",{"data-testid":"toolbar-divider",className:"h-6 w-px bg-neutral-300 mx-1 items-center mt-1"})}function su(){const e=gl(),o=Es(ll),r=Es(Qa);return Ol({id:"CrossSectionAlignment",keyBind:"Escape",fn:e.cancelCurrentHit,addPredicate:()=>{var e;return null!==(e=null==r?void 0:r.hitPending)&&void 0!==e&&e},cancelPredicate:()=>!(null==r?void 0:r.hitPending)},[null==r?void 0:r.hitPending]),t.jsxs(nu,{"data-testid":"section-alignment-popover",placement:"top",backdrop:!1,open:o,onDismissed:e.closeAlignmentTools,children:[t.jsx(nu.Anchor,{tooltipContent:"Section Alignment",children:t.jsx(n.VertexIconButton,{"data-testid":"section-alignment-icon-button",iconName:`align-to-${null==r?void 0:r.mode}`,iconColor:"secondary",onClick:o?e.closeAlignmentTools:e.openAlignmentTools,children:t.jsx(n.VertexIcon,{"data-testid":"section-alignment-icon-chevron",name:"chevron-up",size:"sm"})})}),t.jsxs(a.VertexViewerToolbarGroup,{direction:"vertical",className:"flex justify-evenly items-center py-1 my-1 ring-1 ring-neutral-200 rounded bg-neutral-100 opacity-95",children:[t.jsx(n.VertexIconButton,{iconColor:"secondary",onClick:()=>e.updateAlignment("global"),className:"w-full text-neutral-800 hover:bg-neutral-300 rounded cursor-pointer mx-0.5 py-1 px-2","data-testid":"section-alignment-align-global",iconName:"align-to-global",variant:"plain",children:t.jsx("div",{className:"text-base ml-2",children:"Align to Global"})}),t.jsx(n.VertexIconButton,{iconColor:"secondary",onClick:()=>e.updateAlignment("surface"),className:"w-full text-neutral-800 hover:bg-neutral-300 rounded cursor-pointer mx-0.5 py-1 px-2","data-testid":"section-alignment-align-surface",iconName:"align-to-surface",variant:"plain",children:t.jsx("div",{className:"text-base ml-2",children:"Align to Surface"})})]})]})}function au(){const e=gl(),r=Es(cl),i=Es(Ja),l=Ts(ol),c=o.useMemo((()=>{const e=i.length>0&&"hasValue"===l.state?((e,t,n,o)=>e&&e.normal&&[["x",t],["y",n],["z",o]].filter((t=>0===s.Vector3.magnitude(s.Vector3.cross(e.normal,t[1])))).map((e=>e[0])).pop())(i[0],Ua(l.contents),Ha(l.contents),Fa(l.contents)):"x";return null!=e?`axis-${e}`:"axis-x"}),[l.state,l.contents,i]);return t.jsxs(nu,{"data-testid":"align-plane-popover",placement:"top",backdrop:!1,open:r,onDismissed:e.closeAxisTools,children:[t.jsx(nu.Anchor,{tooltipContent:"Align Plane",children:t.jsx(n.VertexIconButton,{onClick:r?e.closeAxisTools:e.openAxisTools,iconName:c,"data-testid":"align-plane-icon",iconColor:"secondary",children:t.jsx(n.VertexIcon,{"data-testid":"align-plane-icon-chevron",name:"chevron-up",size:"sm"})})}),t.jsxs(a.VertexViewerToolbarGroup,{direction:"vertical",className:"flex justify-evenly items-center py-1 my-1 ring-1 ring-neutral-200 rounded bg-neutral-100 opacity-95",children:[t.jsx(n.VertexIconButton,{"data-testid":"align-plane-x-axis-button",className:"w-full text-neutral-800 hover:bg-neutral-300 rounded cursor-pointer mx-0.5 py-1 px-2",onClick:()=>e.updateAxis("x"),variant:"plain",iconColor:"secondary",iconName:"axis-x",children:t.jsx("div",{className:"text-base ml-2",children:"X-axis Plane"})}),t.jsx(n.VertexIconButton,{className:"w-full text-neutral-800 hover:bg-neutral-300 rounded cursor-pointer mx-0.5 py-1 px-2",variant:"plain",iconColor:"secondary",iconName:"axis-y","data-testid":"align-plane-y-axis-button",onClick:()=>e.updateAxis("y"),children:t.jsx("div",{className:"text-base ml-2",children:"Y-axis Plane"})}),t.jsx(n.VertexIconButton,{"data-testid":"align-plane-z-axis-button",className:"w-full text-neutral-800 hover:bg-neutral-300 rounded cursor-pointer mx-0.5 py-1 px-2",onClick:()=>e.updateAxis("z"),variant:"plain",iconColor:"secondary",iconName:"axis-z",children:t.jsx("div",{className:"text-base ml-2",children:"Z-axis Plane"})})]})]})}var lu,cu;!function(e){e.mm="millimeters",e.cm="centimeters",e.m="meters",e.in="inches",e.ft="feet"}(lu||(lu={})),function(e){e[e.mm=1]="mm",e[e.cm=.1]="cm",e[e.m=.001]="m",e[e.in=.03937007874015748]="in",e[e.ft=.0032808398950131233]="ft"}(cu||(cu={}));const uu=(e,t)=>e/cu[t],du=(e,t)=>e*cu[t],fu=(e,t)=>n=>((e,t,n)=>((e,t,n)=>`${e.toFixed(n)} ${t}`)(du(e,t),t,n))(n,e,t);function pu({offset:e,measurementUnit:r,decimalPlaces:i,onOffsetChange:s}){const[a,l]=o.useState(du(e,r));o.useEffect((()=>{l(du(e,r))}),[r,e]);const c=fu(r,i),u=e=>{const t=uu(a+e,r);s(t)};return t.jsx(n.VertexTooltip,{content:"Plane Offset",children:t.jsx("form",{"data-testid":"cross-section-stepper-form",onSubmit:e=>{e.preventDefault(),s(uu(a,r))},children:t.jsxs(n.VertexTextfield,{"data-testid":"cross-section-stepper-input",className:"viewer-toolbar-input w-32 border-none ring-0 bg-white",type:"text",value:c(parseFloat(e.toFixed(3))),onInputInput:t=>{l(null!=t.detail.value?parseFloat(t.detail.value):e)},onBlur:()=>{s(uu(a,r))},children:[t.jsx("div",{"data-testid":"cross-section-stepper-decrement",className:"py-1 cursor-pointer",slot:"left",onClick:()=>u(-1),children:t.jsx(n.VertexIcon,{name:"chevron-left",size:"sm"})}),t.jsx("div",{"data-testid":"cross-section-stepper-increment",className:"py-1 cursor-pointer",slot:"right",onClick:()=>u(1),children:t.jsx(n.VertexIcon,{name:"chevron-right",size:"sm"})})]})})})}function hu({decimalPlaces:e,measurementUnit:r}){const i=gl(),s=Es(al),l=Ts(il),c=Ts(sl),u=o.useRef(),d=o.useMemo((()=>"hasValue"===l.state?l.contents:qa),[l.state,l.contents]),f=o.useMemo((()=>"hasValue"===c.state?c.contents:0),[c.state,c.contents]),p=e=>{clearTimeout(u.current),u.current=window.setTimeout((()=>{i.endInteraction()}),400),i.beginInteraction(),i.updatePlanes(e)};return t.jsxs(nu,{"data-testid":"cross-section-popover",placement:"top",backdrop:!1,open:s,onDismissed:i.closeAdditionalTools,children:[t.jsx(nu.Anchor,{tooltipContent:"Section Tools",children:t.jsx("div",{className:"-ml-px py-1.5",children:t.jsx(n.VertexIcon,{"data-testid":"cross-section-popover-icon",name:"chevron-up",size:"sm",onClick:s?i.closeAdditionalTools:i.openAdditionalTools})})}),t.jsxs(a.VertexViewerToolbarGroup,{className:"relative bottom-3 flex justify-evenly items-center p-1 ring-1 ring-neutral-200 rounded bg-neutral-100 opacity-95",children:[t.jsx(su,{}),t.jsx(n.VertexTooltip,{className:"w-auto",content:"Reverse",children:t.jsx(n.VertexIconButton,{iconName:"flip","data-testid":"viewer-toolbar-flip-button",onClick:i.flipPlanes,iconColor:"secondary"})}),t.jsx(n.VertexTooltip,{className:"w-auto",content:"Align View to Plane",children:t.jsx(n.VertexIconButton,{"data-testid":"viewer-toolbar-align-view-to-plane-button",iconName:"align-view-to-plane",onClick:i.alignViewToPlane,iconColor:"secondary"})}),t.jsx(iu,{}),t.jsx(au,{}),t.jsx(ru,{value:f,defaultValue:d.default,disabled:"hasValue"!==l.state,min:d.min,max:d.max,step:.01,onChange:p}),t.jsx("div",{className:"px-4",children:t.jsx(pu,{decimalPlaces:e,measurementUnit:r,offset:"hasValue"===c.state?c.contents:0,onOffsetChange:p})})]})]})}const mu=({decimalPlaces:e,measurementUnit:o,sectionLineWidth:r,sectionColor:i})=>{const s=gl(),a=Es(Ya);return tu(Za,r),tu(Xa,i),t.jsxs(t.Fragment,{children:[t.jsx(n.VertexTooltip,{content:a?"Hide Section":"Show Section",children:t.jsx(n.VertexIconButton,{"data-testid":"viewer-toolbar-cross-section-button",iconName:"cross-section",iconColor:a?"primary":"secondary",onClick:()=>a?s.disable():s.enable()})}),t.jsx(hu,{decimalPlaces:null!=e?e:2,measurementUnit:null!=o?o:"mm"})]})},vu=()=>{const e=Es(Aa);return t.jsx(n.VertexTooltip,{content:"Fit All",children:t.jsx(n.VertexIconButton,{iconName:"fit-all",iconColor:"secondary","data-testid":"viewer-toolbar-fit-all-button",onClick:async()=>{const t=await(null==e?void 0:e.scene());await(null==t?void 0:t.camera().viewAll().render({animation:{milliseconds:500}}))}})})},gu=()=>{const e=Es(Aa),r=Es(Va),[i,s]=As(ka),[a,l]=As(Na);return o.useEffect((()=>{null!=e&&r&&l(e.getBaseInteractionHandler())}),[e,r,l]),t.jsx(n.VertexTooltip,{content:"Pan",children:t.jsx(n.VertexIconButton,{iconName:"pan",iconColor:"pan"===i?"primary":"secondary","data-testid":"viewer-toolbar-pan-button",onClick:async()=>{if(s("pan"),null!=a){const e=await a;null==e||e.setPrimaryInteractionType("pan")}}})})},yu=()=>{const e=Es(Aa),r=Es(Va),[i,s]=As(ka),[a,l]=As(Na);return o.useEffect((()=>{null!=e&&r&&l(e.getBaseInteractionHandler())}),[e,r,l]),t.jsx(n.VertexTooltip,{content:"Rotate",children:t.jsx(n.VertexIconButton,{iconName:"rotate",iconColor:"rotate"===i?"primary":"secondary","data-testid":"viewer-toolbar-rotate-button",onClick:async()=>{if(s("rotate"),null!=a){const e=await a;null==e||e.setPrimaryInteractionType("rotate")}}})})},bu=ws({key:"boxSelectionEnabled",default:!1}),xu=ws({key:"boxSelectionOperationType",default:"clearAndSelect"}),wu=()=>({enable:sa((({set:e})=>()=>{e(bu,!0)})),disable:sa((({reset:e})=>async()=>{e(bu),e(xu)})),setOperationType:sa((({set:e})=>t=>{e(xu,t)}))}),Su=()=>{const e=wu(),o=Es(bu);return Ol({id:"ExitBoxSelection",keyBind:"Escape",fn:e.disable,addPredicate:()=>o,cancelPredicate:()=>!o},[o]),t.jsx(n.VertexTooltip,{content:"Box Selection",children:t.jsx(n.VertexIconButton,{iconName:"box-cursor",iconColor:o?"primary":"secondary","data-testid":"viewer-toolbar-enable-box-selection-button",onClick:o?e.disable:e.enable})})},_u=()=>{const e=Es(Aa),r=Es(Va),[i,s]=As(ka),[a,l]=As(Na);return o.useEffect((()=>{null!=e&&r&&l(e.getBaseInteractionHandler())}),[e,r,l]),t.jsx(n.VertexTooltip,{content:"Zoom",children:t.jsx(n.VertexIconButton,{iconName:"zoom",iconColor:"zoom"===i?"primary":"secondary","data-testid":"viewer-toolbar-zoom-button",onClick:async()=>{if(s("zoom"),null!=a){const e=await a;null==e||e.setPrimaryInteractionType("zoom")}}})})},Eu=()=>t.jsx(a.VertexViewerToolbar,{placement:"bottom-center",children:t.jsxs(a.VertexViewerToolbarGroup,{className:"p-1 border border-neutral-200 rounded bg-neutral-100 opacity-95",children:[t.jsx(yu,{}),t.jsx(gu,{}),t.jsx(_u,{}),t.jsx(vu,{}),t.jsx(iu,{}),t.jsx(Su,{}),t.jsx(iu,{}),t.jsx(mu,{})]})}),Tu=({children:e})=>{const n=null!=e&&!1!==e;return t.jsx(a.VertexViewerToolbar,{placement:"bottom-center",children:n?t.jsx(a.VertexViewerToolbarGroup,{className:"p-1 border border-neutral-200 rounded bg-neutral-100 opacity-95",children:e}):t.jsx(Eu,{})})},Au=({onReset:e})=>{const o=gl(),r=Wl(),i=Ia();return t.jsx(n.VertexTooltip,{content:"Reset View",children:t.jsx(n.VertexIconButton,{iconName:"reset",className:"flex bg-white opacity-70 hover:opacity-100 text-neutral-900 hover:text-neutral-700 hover:bg-neutral-200 rounded p-1 cursor-pointer","data-testid":"viewer-reset-tool-button",onClick:async()=>{await o.disable(),await r.resetSelectionState(),null==e||e(),await i.reset()},variant:"plain"})})};const Vu=()=>{const{callback:e}=function(){const[e,t]=o.useState(null);return{element:e,callback:o.useCallback((e=>t(e)),[])}}(),n=wu(),r=Es(xu);return Il({keyBind:"Shift",fn:p.useCallback((()=>n.setOperationType("select")),[]),off:p.useCallback((()=>n.setOperationType("clearAndSelect")),[])}),t.jsx(a.VertexViewerBoxQueryTool,{ref:e,"data-testid":"viewer-box-query-tool",operationType:r})};function Nu({open:e,onOpen:o,onDismiss:r,onCameraTypeChange:i}){const s=Oa(),a=Es(La);return t.jsxs(n.VertexMenu,{"data-testid":"camera-types-popover",className:"flex",placement:"bottom-end",open:e,onMenuClosed:r,children:[t.jsx("div",{slot:"anchor",children:t.jsx("div",{className:m("flex bg-white hover:opacity-100 hover:text-neutral-700 hover:bg-neutral-200 rounded",{"opacity-70 text-neutral-900":!e,"opacity-100 text-neutral-700 bg-neutral-200":e}),children:t.jsx(n.VertexTooltip,{content:"Change View",children:t.jsx(n.VertexIconButton,{"data-testid":"set-camera-mode-option",className:"p-1 cursor-pointer",variant:"plain",onClick:o,iconName:"orthographic"===a?"cube-orthographic":"cube-perspective",children:t.jsx(n.VertexIcon,{"data-testid":"change-camera-type-icon-button",name:"chevron-down",size:"sm"})})})})}),t.jsxs("div",{className:"w-36",children:[t.jsx("div",{className:"pt-1"}),t.jsxs(n.VertexMenuItem,{"data-testid":"set-perspective-view",onClick:()=>{s.updateCameraType("perspective"),null==i||i("perspective")},children:[t.jsx(n.VertexIcon,{slot:"icon","data-testid":"set-perspective-view-icon",name:"cube-perspective",size:"sm",className:m({"text-[var(--vertex-ui-blue-700)]":"perspective"===a})}),t.jsx("div",{className:m("ml-2 items-center",{"text-[var(--vertex-ui-blue-700)]":"perspective"===a}),children:"Perspective"})]}),t.jsxs(n.VertexMenuItem,{"data-testid":"set-orthographic-view",onClick:()=>{s.updateCameraType("orthographic"),null==i||i("orthographic")},children:[t.jsx(n.VertexIcon,{slot:"icon","data-testid":"set-orthographic-view-icon",name:"cube-orthographic",size:"sm",className:m({"text-[var(--vertex-ui-blue-700)]":"orthographic"===a})}),t.jsx("div",{className:m("ml-2 items-center",{"text-[var(--vertex-ui-blue-700)]":"orthographic"===a}),children:"Orthographic"})]})]})]})}const ku=n=>{var{placement:r,children:i}=n,s=e.__rest(n,["placement","children"]);const l=Array.isArray(i)?i:[i],c=l.filter((e=>!o.isValidElement(e)||e.type!==a.VertexViewerViewCube)).filter((e=>null!=e&&!1!==e)),u=l.find((e=>o.isValidElement(e)&&e.type===a.VertexViewerViewCube)),[d,f]=o.useState(!1);return t.jsxs(a.VertexViewerToolbar,{direction:"vertical","data-testid":"view-cube-toolbar",placement:null!=r?r:"top-right",children:[null!=u?u:t.jsx(a.VertexViewerViewCube,Object.assign({className:"m-7"},s)),0===c.length?t.jsxs("div",{className:"flex items-center justify-center mt-3 gap-1",children:[t.jsx(Au,{}),t.jsx(Nu,{open:d,onDismiss:()=>f(!1),onOpen:()=>f(!0)})]}):t.jsx("div",{className:"mt-3",children:c})]})};const Cu=({onHitStateChange:e,onSelectionStateChange:n})=>{const r=Es(xl),i=Es(ql);return o.useEffect((()=>{null==e||e(r)}),[r,e]),o.useEffect((()=>{null==n||n(i)}),[i,n]),t.jsx(t.Fragment,{})},ju=({config:e,children:n})=>{const r=Vs(hc);return o.useEffect((()=>{const t=null!=e?function(e){return function(e){return null!=e.renderingHost}(e)?{network:e}:e}(e):void 0;r(t)}),[e,r]),t.jsx(t.Fragment,{children:n})};var Ru=Object.freeze({__proto__:null,get AssemblyFontFace(){return vc}});exports.CrossSection=yl,exports.Hits=wl,exports.SceneTree=Ru,exports.Selection=Yl,exports.VertexContextMenu=Ll,exports.VertexFitAllButton=vu,exports.VertexFitSelectedMenuItem=Xl,exports.VertexFlyToMenuItem=Zl,exports.VertexHideAllMenuItem=Ql,exports.VertexHidePartMenuItem=ec,exports.VertexHideSelectedMenuItem=tc,exports.VertexPanButton=gu,exports.VertexResizableContent=v,exports.VertexRotateButton=yu,exports.VertexSceneTree=n=>{var{id:o,font:r,backgroundColors:i,children:s,style:l,onPointerDown:c,onClick:u,onToggleSelection:d,onToggleExpansion:f,onToggleVisibility:p,className:h,rowData:v}=n,g=e.__rest(n,["id","font","backgroundColors","children","style","onPointerDown","onClick","onToggleSelection","onToggleExpansion","onToggleVisibility","className","rowData"]);const y=Es(hc),b=Wl(),x=ac(),w=Es(Aa),S=mc({state:ic}),_=null!=s&&!1!==s,E=(e,t,n)=>{x.toggleExpansion(e,t,n),null==f||f(e,t,n)},T=(e,t,n)=>{x.toggleSelection(e,t,n),null==d||d(e,t,n)},A=(e,t,n)=>{x.toggleVisibility(e,t,n),null==p||p(e,t,n)};return t.jsx("div",{className:m("flex flex-col w-full h-full",h),children:t.jsx("div",{className:"flex group h-full",children:t.jsx(a.VertexSceneTree,Object.assign({id:null!=o?o:"vertex-scene-tree","data-testid":"vertex-scene-tree",config:y,ref:S,className:"flex-1",style:Object.assign(Object.assign(Object.assign({},gc(r)),yc(i)),l),onConnectionError:e=>{oa("Scene Tree Connection Error: ",e.detail)},viewer:w,onPointerDown:e=>{var t,n;t=e.target,n="VERTEX-SCENE-TREE-TABLE-COLUMN",t instanceof Element&&t.tagName===n&&b.clearSelection(),null==c||c(e)},onClick:e=>{e.altKey&&x.flyToRow(e.clientY),null==u||u(e)},rowData:e=>{var t;const n=null!==(t=null==v?void 0:v(e))&&void 0!==t?t:{};return Object.assign({handleExpansion:E,handleSelection:T,handleVisibility:A},n)}},g,{children:_?s:t.jsxs(t.Fragment,{children:[t.jsx(_c,{}),t.jsx(Vc,{}),t.jsx(dc,{})]})}))})})},exports.VertexSceneTreeContextMenu=dc,exports.VertexSceneTreeHeader=_c,exports.VertexSceneTreeTableLayout=Vc,exports.VertexShowAllMenuItem=nc,exports.VertexShowOnlyMenuItem=oc,exports.VertexShowOnlySelectedMenuItem=rc,exports.VertexToolbar=Tu,exports.VertexViewer=n=>{var{id:r,className:i,disableSelection:s,onTap:l,onLongpress:c,onFrameDrawn:u,viewerRefCallback:d,children:f}=n,p=e.__rest(n,["id","className","disableSelection","onTap","onLongpress","onFrameDrawn","viewerRefCallback","children"]);const h=Es(hc),v=mc({state:Aa}),g=Oa(),y=bl(),b=Wl(),x={frameDrawn:sa((({set:e,reset:t,snapshot:n})=>async t=>{const o=await n.getPromise($l);e(ja,t.detail.scene),e($l,t.detail.scene.sceneViewSummary.selectedVisibleSummary),e(Fl,o)}))},[w,S]=As(Va),_=Es(La),E=Es(Qa),T=Es(bu),A=null!=f&&!1!==f;return(({keydownRepeatInterval:e=25,keydownIgnorePredicate:t=El}={})=>{const[n,r]=Nl(),i=o.useCallback((e=>{Object.keys(n.bindings).filter((t=>t.includes(e)&&Cl(t,Object.assign(Object.assign({},n.pressed),{[e]:!0})))).forEach((e=>{const t=n.bindings[e],o=t.length>0?t[t.length-1]:void 0;null!=o&&(o.fn(),r({type:"remove-key-binding",binding:o}))}))}),[n]);o.useEffect((()=>{const e=e=>{if(!e.repeat&&!t(e.target)){r({type:"set-key-pressed",key:e.key,pressed:!0}),i(e.key);const t=Object.assign(Object.assign({},n.pressed),{[e.key]:!0}),o=jl(n.applyBindings,t,e.key),s=Rl(n.applyBindings,t,e.key);(o.length>0||s.length>0)&&e.preventDefault()}},o=e=>{r({type:"set-key-pressed",key:e.key,pressed:!1})};return window.addEventListener("keydown",e),window.addEventListener("keyup",o),()=>{window.removeEventListener("keydown",e),window.removeEventListener("keyup",o)}}),[i,n.applyBindings,n.pressed]),o.useEffect((()=>{const e=jl(n.applyBindings,n.pressed,n.lastPressed),t=Rl(n.applyBindings,n.pressed,n.lastPressed);e.forEach((e=>e())),t.forEach((e=>e()))}),[n.pressed,n.lastPressed]),o.useEffect((()=>{const t=n.applyBindings.filter((e=>e.repeat&&null!=e.keyBind&&Cl(e.keyBind,n.pressed))).map((e=>e.fn));if(t.length>0){const n=setInterval((()=>{t.forEach((e=>e()))}),e);return()=>{clearInterval(n)}}return()=>{}}),[n.applyBindings,n.lastPressed])})(),Il({fn:sa((({snapshot:e})=>async()=>{const t=await e.getPromiseRequired(Ca),n=await t();await(null==n?void 0:n.camera().viewAll().render({animation:{milliseconds:500}}))})),keyBind:"f"}),t.jsxs(a.VertexViewer,Object.assign({id:null!=r?r:"vertex-viewer","data-testid":"vertex-viewer",ref:null!=d?d:v,className:m("flex w-full h-full",i,{"cursor-crosshair":E.hitPending}),config:h,cameraType:w?_:void 0,onCameraTypeChanged:e=>{w&&g.updateCameraType(e.detail)},onTap:e=>{const t=[...s?[]:[b.selectCurrentHit]];y.tap(e,...t),null==l||l(e)},onLongpress:e=>{y.longPress(e),null==c||c(e)},onFrameDrawn:e=>{x.frameDrawn(e),null==u||u(e)}},p,{onSceneReady:()=>{w||S(!0)},children:[T&&t.jsx(Vu,{}),A?f:t.jsxs(t.Fragment,{children:[t.jsx(ku,{}),t.jsx(Tu,{}),t.jsx(pc,{})]})]}))},exports.VertexViewerContextMenu=pc,exports.VertexViewerCrossSectionButton=mu,exports.VertexViewerRightOpenedPanel=function(){const e=Es(kc),n=o.useMemo((()=>["appearance"]),[]);return t.jsx(t.Fragment,{children:null!=e&&n.includes(e)&&t.jsx(v,{displayShadow:!0,heading:t.jsx(Jc,{}),placement:"right",children:"appearance"===e&&t.jsx(Xc,{})})})},exports.VertexViewerRightSidebar=function(){const e={openPrimary:sa((({set:e})=>(t,n)=>{e("left"===n?Nc:kc,t)})),closePrimary:sa((({set:e})=>t=>{e("left"===t?Nc:kc,void 0)}))},n=Es(kc);return t.jsx("div",{className:"flex flex-col flex-shrink-0 items-center relative border-neutral-300 border-l bg-white h-full top-0 min-w-12 w-12",children:t.jsx(Qc,{children:t.jsx(eu,{name:"appearance",active:n,iconName:"adjustments",tooltipPlacement:"right",content:"Appearance",onSelect:()=>{e.openPrimary("appearance","right")},onDeselect:()=>e.closePrimary("right")})})})},exports.VertexViewerSceneReset=Au,exports.VertexViewerToolbarDivider=iu,exports.VertexViewerToolkitRoot=n=>{var{override:r,autoDefineCustomElements:i,children:s,config:a}=n,l=e.__rest(n,["override","autoDefineCustomElements","children","config"]);return o.useEffect((()=>{(null==i||i)&&(u.defineCustomElements(),c.defineCustomElements())}),[i]),t.jsx(xs,{override:r,children:t.jsxs(t.Fragment,{children:[t.jsx(Cu,Object.assign({},l)),t.jsx(ju,{config:a,children:s})]})})},exports.VertexViewerViewCube=ku,exports.VertexZoomButton=_u;
6
+ */ya=ga,function(){var e={}.hasOwnProperty;function classNames(){for(var e="",t=0;t<arguments.length;t++){var n=arguments[t];n&&(e=appendClass(e,parseValue(n)))}return e}function parseValue(t){if("string"==typeof t||"number"==typeof t)return t;if("object"!=typeof t)return"";if(Array.isArray(t))return classNames.apply(null,t);if(t.toString!==Object.prototype.toString&&!t.toString.toString().includes("[native code]"))return t.toString();var n="";for(var o in t)e.call(t,o)&&t[o]&&(n=appendClass(n,o));return n}function appendClass(e,t){return t?e?e+" "+t:e+t:e}ya.exports?(classNames.default=classNames,ya.exports=classNames):window.classNames=classNames}();var ba=ga.exports;const Sa=1,VertexResizableContent=n=>{var{className:o,style:r,displayShadow:a,heading:s,id:l,initialScale:c,placement:u="left",children:d,onResize:p}=n,f=t.__rest(n,["className","style","displayShadow","heading","id","initialScale","placement","children","onResize"]);const h="left"===u||"right"===u,m="top"===u;function getHorizontalResizeDirection(){switch(u){case"left":return"right";case"right":return"left";default:return"none"}}function getVerticalResizeDirection(){return"top"===u?"top":"none"}const v=null!=c?c:1;return e.jsx(i.VertexResizable,Object.assign({id:l,"data-testid":`resizable-content-position-${u}`,className:ba(o,"pointer-events-auto z-popover md:z-overlay bg-white bg-opacity-95 flex-grow-0 flex-shrink-0 border-neutral-300",{"border-r min-w-75 max-w-half":"left"===u,"sidebar-shadow-right":"left"===u&&a,"border-l min-w-75 max-w-half":"right"===u,"sidebar-shadow-left":"right"===u&&a,"border-t bottom-0 fixed":"top"===u,"min-h-12 sheet":m}),style:Object.assign({maxHeight:"top"===u?window.innerHeight:void 0},r),initialHorizontalScale:h?c:void 0,initialVerticalScale:m?v:void 0,horizontalDirection:getHorizontalResizeDirection(),verticalDirection:getVerticalResizeDirection(),position:"right"===u||"top"===u?"absolute":"relative",onResizeEnd:()=>null==p?void 0:p()},f,{children:e.jsxs("div",{className:"flex flex-col h-full w-full",children:["top"===u&&e.jsx("div",{className:"flex justify-center w-full",children:e.jsx("div",{className:"block md:hidden w-20 h-0.5 mt-0.5 bg-neutral-600 rounded"})}),s,e.jsx("div",{className:ba("w-full flex flex-col h-0 flex-grow",{"right-0":"right"===u}),children:d})]})}))};function contextMenuItemIsRow(e){var t;return null!=e&&null!=(null===(t=null==e?void 0:e.node)||void 0===t?void 0:t.id)}const xa=Yi({key:"contextMenuActive",default:void 0}),wa=Yi({key:"contextMenuPosition",default:void 0}),_a=Yi({key:"contextMenuTarget",default:void 0}),Aa=Yi({key:"contextMenuItem",default:void 0}),Ea=Yi({key:"contextMenuActions",default:[]}),Ta=Zi({key:"contextMenuActivePosition",get:({get:e})=>null!=e(xa)?e(wa):void 0}),Va=Yi({key:"viewerToolkitViewerElement",default:void 0,dangerouslyAllowMutability:!0}),Ca=Yi({key:"viewerInitialSceneReady",default:!1}),ka=Yi({key:"viewerBaseInteractionHandlerProvider",default:Promise.resolve(void 0),dangerouslyAllowMutability:!0}),Na=Yi({key:"viewerPrimaryInteractionType",default:"rotate"}),Ra=Zi({key:"viewerScene",get:({get:e})=>async()=>{var t;return null===(t=e(Va))||void 0===t?void 0:t.scene()},dangerouslyAllowMutability:!0}),Ia=Yi({key:"viewerFrameScene",default:void 0,dangerouslyAllowMutability:!0}),Oa=Zi({key:"viewerSceneVisibleBoundingBox",get:({get:e})=>{var t;return null===(t=e(Ia))||void 0===t?void 0:t.boundingBox}});function useViewerSceneActions(){const e=useActionCallback((({snapshot:e})=>async(t,n,...o)=>{const r=await e.getPromise(Ra),i=await r();o.length>0&&await(null==i?void 0:i.items((e=>o.map((t=>t(e))))).execute({suppliedCorrelationId:n}))})),t=o.useCallback(((...e)=>t=>t.where((t=>t.withItemIds(e))).select()),[]),n=o.useCallback(((...e)=>t=>t.where((t=>t.withItemIds(e))).deselect()),[]),r=o.useCallback((e=>e.where((e=>e.all())).deselect()),[]);return{executeWithCorrelationId:e,execute:useActionCallback((()=>async(t,...n)=>{const o=ma.create();await e(t,o,...n)})),selectItemsTransform:t,deselectItemsTransform:n,clearSelectionTransform:r,reset:useActionCallback((({snapshot:e})=>async t=>{const n=await e.getPromiseRequired(Ra),o=await n(),r=await e.getPromiseRequired(Pa);null==o||o.reset({includeCamera:!0,suppliedCorrelationId:t,cameraTypeOverride:r})}))}}const La=500;function useViewerCameraActions(){return{flyToById:useActionCallback((({snapshot:e})=>async(t,n)=>{const o=await e.getPromise(Ra),r=await o();await(null==r?void 0:r.camera().flyTo({itemId:t}).render({animation:{milliseconds:null!=n?n:La}}))})),flyToByBoundingBox:useActionCallback((({snapshot:e})=>async(t,n)=>{const o=await e.getPromise(Ra),r=await o();await(null==r?void 0:r.camera().flyTo({boundingBox:t}).render({animation:{milliseconds:null!=n?n:La}}))})),updateCameraType:useActionCallback((({set:e})=>t=>{e(Pa,t)}))}}const Pa=Yi({key:"viewerCameraType",default:"perspective"});class ja{constructor(){this.interactionStarted=!1}initialize(e,t){this.api=t}dispose(){this.endInteraction()}async beginInteraction(){var e;this.interactionStarted||(await(null===(e=this.api)||void 0===e?void 0:e.beginInteraction()),this.interactionStarted=!0)}async endInteraction(){var e;await(null===(e=this.api)||void 0===e?void 0:e.endInteraction()),this.interactionStarted=!1}}const create=(e,t=0)=>({normal:e,offset:t}),forAxis=(e,t)=>{switch(e){case"x":return x(t);case"y":return y(t);case"z":return z(t)}},x=e=>create(a.Vector3.left(),-e),y=e=>create(a.Vector3.down(),-e),z=e=>create(a.Vector3.forward(),-e),getAxis=(e,t)=>{switch(e){case"x":return xAxis(t);case"y":return yAxis(t);case"z":return zAxis(t)}},Ma={x:a.Vector3.left(),y:a.Vector3.down(),z:a.Vector3.forward()},xAxis=e=>e.x,yAxis=e=>e.y||a.Vector3.create(e.x.z,e.x.x,e.x.y),zAxis=e=>e.z||a.Vector3.create(e.x.y,e.x.z,e.x.x),axis=(e,t,n,o)=>e&&e.normal&&[["x",t],["y",n],["z",o]].filter((t=>0===a.Vector3.magnitude(a.Vector3.cross(e.normal,t[1])))).map((e=>e[0])).pop(),isNegativeNormal=e=>a.Vector3.dot(a.Vector3.create(-1,-1,-1),e.normal)>0,towardsVector=(e,t)=>{const n=undefined;return a.Vector3.dot(e,t.normal)<0?invert(t):t},towardsCamera=(e,t)=>towardsVector(e.viewVector,t),invert=e=>Object.assign(Object.assign({},e),{normal:a.Vector3.multiply(e.normal,a.Vector3.create(-1,-1,-1)),offset:-e.offset}),fromHit=(e,t)=>{const n=a.Vector3.normalize(e.normal),o=a.Vector3.dot(n,e.position);return towardsCamera(t,create(n,o))},toAxis=(e,t,n,o,r)=>{const i=n.viewAll(),s=getAxis(e,t),l=null!=o&&null!=s?create(s,a.Vector3.dot(s,r||a.BoundingBox.center(o))):forAxis(e,i.lookAt[e]);return towardsCamera(n,l)};function corners(e){return[a.Vector3.create(e.min.x,e.min.y,e.min.z),a.Vector3.create(e.min.x,e.min.y,e.max.z),a.Vector3.create(e.min.x,e.max.y,e.min.z),a.Vector3.create(e.min.x,e.max.y,e.max.z),a.Vector3.create(e.max.x,e.max.y,e.max.z),a.Vector3.create(e.max.x,e.max.y,e.min.z),a.Vector3.create(e.max.x,e.min.y,e.max.z),a.Vector3.create(e.max.x,e.min.y,e.min.z)]}const Da={default:5,min:0,max:10},Ba=Yi({key:"crossSectioningEnabled",default:!1}),za=Yi({key:"crossSectioningHighlightColor",default:void 0}),Ua=Yi({key:"crossSectioningBorderWidth",default:void 0}),Fa=Yi({key:"crossSectioningPlanes",default:[]}),Ha=Yi({key:"crossSectioningAlignment",default:{mode:"global",hitPending:!1}}),Wa=Zi({key:"crossSectioningTargetBoundingBox",get:async({get:e})=>{const t=undefined;return e(Oa)}}),$a=Yi({key:"crossSectioningIsInteractive",default:!1}),Ga=Yi({key:"crossSectioningActiveAxis",default:"x"}),Ka=Yi({key:"crossSectioningAvailableAxes",default:Ma}),qa=Zi({key:"crossSectioningOffsetScalar",get:({get:e})=>{const t=e(Fa);return t.length>0&&isNegativeNormal(t[0])?-1:1}}),Ya=Zi({key:"crossSectioningSliderRange",get:({get:e})=>{const t=e(Fa),n=e(Wa),o=null!=n?corners(n):[];if(t.length>0){const e=o.map((e=>a.Vector3.dot(e,isNegativeNormal(t[0])?a.Vector3.multiply(t[0].normal,a.Vector3.create(-1,-1,-1)):t[0].normal)));return{default:t[0].offset,min:Math.min(...e)-2,max:Math.max(...e)+2}}return Da}}),Za=Zi({key:"crossSectioningPlaneDisplayOffset",get:({get:e})=>{const t=e(Fa),n=e(qa),o=e(Ya);return t.length>0?t[0].offset*n:o.default}}),Xa=Yi({key:"crossSectioningAdditionalToolsOpen",default:!1}),Ja=Yi({key:"crossSectioningAlignmentToolsOpen",default:!1}),Qa=Yi({key:"crossSectioningAxisToolsOpen",default:!1}),es=Yi({key:"crossSectioningInteractionHandler",default:new ja,dangerouslyAllowMutability:!0});function useCrossSectioning(e,t){const n=Ji(es);o.useEffect((()=>{t&&(null==e||e.registerInteractionHandler(n))}),[e,t,n])}const ts=Yi({key:"hitResultsTapDetails",default:void 0}),ns=Yi({key:"hitResultsLongPressDetails",default:void 0}),os=Yi({key:"previousHitResult",default:void 0}),rs=Yi({key:"currentHitResult",default:void 0}),is=Zi({key:"hitResult",get:async({get:e})=>{var t,n,o,r,i,s,l,c;const u=e(ts),d=e(ns),p=null!=u?u:d,f=e(Ra),h=await f(),m=null==h?void 0:h.sceneViewId,v=null==h?void 0:h.raycaster();if(null!=p&&null!=v&&null!=m){const e=await v.hitItems(p.position),u=((null==e?void 0:e.hits)||[])[0];if(null!=u)return{id:null===(t=u.itemId)||void 0===t?void 0:t.hex,normal:a.Vector3.create((null===(n=null==u?void 0:u.hitNormal)||void 0===n?void 0:n.x)||0,(null===(o=null==u?void 0:u.hitNormal)||void 0===o?void 0:o.y)||0,(null===(r=null==u?void 0:u.hitNormal)||void 0===r?void 0:r.z)||0),position:a.Vector3.create((null===(i=null==u?void 0:u.hitPoint)||void 0===i?void 0:i.x)||0,(null===(s=null==u?void 0:u.hitPoint)||void 0===s?void 0:s.y)||0,(null===(l=null==u?void 0:u.hitPoint)||void 0===l?void 0:l.z)||0),meta:p.metaKey||p.ctrlKey||!1,metadata:[],ancestors:(null===(c=null==u?void 0:u.ancestors)||void 0===c?void 0:c.filter((e=>{var t;return null!=(null===(t=e.itemId)||void 0===t?void 0:t.hex)})).map((e=>{var t;return null===(t=e.itemId)||void 0===t?void 0:t.hex})))||[]}}}}),as=Yi({key:"hitResultsSkipNextTap",default:!1}),alignToNormal=(e,t,n)=>{if(e.toFrameCamera().isPerspective()){const n=a.Vector3.dot(a.Vector3.normalize(e.up),t),o=Math.abs(n)>.98?a.Vector3.normalize(a.Vector3.scale(-n,e.viewVector)):e.up,r=a.Vector3.add(a.Vector3.scale(a.Vector3.distance(e.position,e.lookAt),a.Vector3.multiply(t,a.Vector3.create(-1,-1,-1))),e.lookAt);return e.update({up:o,position:r})}{const o=a.Vector3.angleTo(a.Vector3.normalize(e.viewVector),t),r=null!=n?a.BoundingBox.center(n):e.lookAt,i=a.Vector3.normalize(a.Vector3.cross(a.Vector3.normalize(e.viewVector),t));return e.rotateAroundAxisAtPoint(o,r,i)}};function isParallelTo(e,t){const n=a.Angle.toDegrees(a.Vector3.angleTo(e,t));return 0===n||180===n}const ss=500;function useCrossSectioningActions(){const e=useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromise(Ua),n=await e.getPromise(za),o=await e.getPromise(Fa),r=await e.getPromise(Ra),i=await r();await(null==i?void 0:i.crossSectioning().update({sectionPlanes:o,highlightColor:n?ca.fromHexString(n):void 0,lineWidth:t}))})),t=useActionCallback((({set:t,reset:n,snapshot:o})=>async()=>{const r=await o.getPromise(Ra),i=await r();if(null!=i){const o=i.camera().viewAll();n(Ka),t(Fa,[towardsCamera(i.camera(),x(o.lookAt.x))]),e()}})),n=useActionCallback(retainSnapshot((({snapshot:t,set:n})=>async()=>{const o=await t.tryGetPromise(is).then((e=>e.value)),r=await t.getPromise(Ra),i=await r();if(null!=o&&null!=i){const t=fromHit(o,i.camera());n(Fa,null!=t?[t]:[]),n(Ka,null!=t?{x:t.normal}:Ma),e()}}))),o=useActionCallback((({set:e,snapshot:n})=>async()=>{const o=await n.getPromise(Fa),r=undefined;await n.getPromise(Ba)||(e(Ba,!0),0===o.length&&await t())})),r=useActionCallback((({reset:t,snapshot:n})=>async()=>{const o=undefined;await n.getPromise(Ba)&&(t(Ba),t(Xa),t(Ja),t(Qa),t(Fa),t(Ha),t(Ga),await e())}));return{enable:o,disable:r,openAdditionalTools:useActionCallback((({set:e,snapshot:t})=>async()=>{const n=undefined;await t.getPromise(Ba)||o(),e(Xa,!0)})),closeAdditionalTools:useActionCallback((({reset:e})=>async()=>{e(Xa)})),openAlignmentTools:useActionCallback((({set:e,reset:t})=>async()=>{t(Qa),e(Ja,!0)})),closeAlignmentTools:useActionCallback((({reset:e})=>async()=>{e(Ja)})),openAxisTools:useActionCallback((({set:e,reset:t})=>async()=>{t(Ja),e(Qa,!0)})),closeAxisTools:useActionCallback((({reset:e})=>async()=>{e(Qa)})),beginInteraction:useActionCallback((({set:e,snapshot:t})=>async()=>{const n=await t.getPromise(es);e($a,!0),await n.beginInteraction()})),endInteraction:useActionCallback((({reset:e,snapshot:t})=>async()=>{const n=await t.getPromise(es);e($a),await n.endInteraction()})),updatePlanes:useActionCallback(retainSnapshot((({set:t,snapshot:n})=>async o=>{const r=await n.getPromise(Fa);if(r.length>0){const i=await n.getPromise(qa),a=await n.getPromise(Ya),s=i<0?-1*a.max:a.min,l=i<0?-1*a.min:a.max,c=r.map((e=>Object.assign(Object.assign({},e),{offset:Math.min(Math.max(o*i,s),l)})));t(Fa,c),e()}}))),flipPlanes:useActionCallback((({set:t,snapshot:n})=>async()=>{const o=await n.getPromise(Fa);t(Fa,o.map((e=>invert(e)))),e()})),alignViewToPlane:useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromise(Fa),n=await e.getPromise(Va),o=await(null==n?void 0:n.scene());t.length>0&&null!=o&&await alignToNormal(o.camera(),t[0].normal,o.boundingBox()).render({animation:{milliseconds:ss}})})),updateAxis:useActionCallback(retainSnapshot((({set:t,reset:n,snapshot:o})=>async r=>{const i=await o.getPromise(Fa),s=await o.getPromise(Ka),l=await o.getPromise(Wa),c=await o.getPromise(Ha),u=await o.getPromise(Va),d=await(null==u?void 0:u.scene()),p=s[r],f=null!=p&&i.length>0&&isParallelTo(i[0].normal,p)&&!isNaN(a.Vector3.angleTo(i[0].normal,p));if(null!=d&&!f){const e=await o.tryGetPromise(is).then((e=>e.value));t(Ga,r),t(Fa,[toAxis(r,s,d.camera(),l,"global"!==c.mode?null==e?void 0:e.position:void 0)])}n(Qa),e()}))),updateAlignment:useActionCallback((({set:e,reset:r})=>async(i,a)=>{r(Ja),e(Ha,{mode:i,hitPending:"global"!==i&&null==a}),"global"===i?(r(Ga),r(Ka),t()):"surface"===i&&null!=a&&(await o(),n())})),cancelCurrentHit:useActionCallback((({set:e,snapshot:t})=>async()=>{const n=await t.getPromise(Ha);n.hitPending&&e(Ha,Object.assign(Object.assign({},n),{hitPending:!1}))})),sectionCurrentHit:useActionCallback((({set:e,snapshot:t})=>async()=>{const o=await t.getPromise(Ha);o.hitPending&&(e(Ha,Object.assign(Object.assign({},o),{hitPending:!1})),"surface"===o.mode&&n())}))}}var ls=Object.freeze({__proto__:null,DEFAULT_ALIGN_TO_PLANE_ANIMATION_DURATION_MS:ss,DEFAULT_SLIDER_RANGE:Da,crossSectioningActiveAxis:Ga,crossSectioningAdditionalToolsOpen:Xa,crossSectioningAlignment:Ha,crossSectioningAlignmentToolsOpen:Ja,crossSectioningAvailableAxes:Ka,crossSectioningAxisToolsOpen:Qa,crossSectioningBorderWidth:Ua,crossSectioningEnabled:Ba,crossSectioningHighlightColor:za,crossSectioningInteractionHandler:es,crossSectioningIsInteractive:$a,crossSectioningOffsetScalar:qa,crossSectioningPlaneDisplayOffset:Za,crossSectioningPlanes:Fa,crossSectioningSliderRange:Ya,crossSectioningTargetBoundingBox:Wa,useCrossSectioning:useCrossSectioning,useCrossSectioningActions:useCrossSectioningActions});const useHitActions=()=>{const e=useCrossSectioningActions(),t=useActionCallback(retainSnapshot((({snapshot:e})=>async()=>{await e.tryGetPromise(is).then((e=>e.value))}))),n=useActionCallback(retainSnapshot((({snapshot:e})=>async()=>{await e.tryGetPromise(is).then((e=>e.value))}))),o=useActionCallback(retainSnapshot((({set:e,snapshot:t})=>async()=>{const n=await t.tryGetPromise(is).then((e=>e.value));e(Aa,n)}))),r=useActionCallback(retainSnapshot((({snapshot:e,set:t})=>async()=>{t(rs,await e.tryGetPromise(is).then((e=>e.value)))})));return{tap:useActionCallback(retainSnapshot((({snapshot:i,set:a})=>async({detail:s},...l)=>{const c=await i.getPromise(Ha),u=2!==(null==s?void 0:s.buttons)&&!(null==s?void 0:s.altKey);s.altKey||s.ctrlKey||s.metaKey||s.shiftKey;const d=u&&!c.hitPending,p=await i.tryGetPromise(is).then((e=>e.value));a(os,p),a(ts,s),t(),d&&(l.forEach((e=>e())),n()),o(),e.sectionCurrentHit(),r()}))),longPress:useActionCallback(retainSnapshot((({snapshot:e,set:t,reset:n})=>async i=>{n(ts),t(ns,i.detail),await e.tryGetPromise(is),o(),r()})))}},cs=Zi({key:"viewerToolkitHitState",get:({get:e})=>{const t=undefined,n=undefined,o=undefined,r=undefined,i=undefined;return{tapDetails:e(ts),longPressDetails:e(ns),previousHitResult:e(os),currentHitResult:e(rs)}}});var us=Object.freeze({__proto__:null,currentHitResult:rs,hitResult:is,hitResultsLongPressDetails:ns,hitResultsSkipNextTap:as,hitResultsTapDetails:ts,hitState:cs,previousHitResult:os,useHitActions:useHitActions});function useContextMenuActions(){return{pointerDown:useActionCallback((({set:e})=>async t=>{if(2===t.button){const n=t.clientX,o=null==t?void 0:t.clientY;e(wa,a.Point.create(n,o)),e(_a,t.target)}})),pointerUp:useActionCallback((({snapshot:e,set:t})=>async(n,o,r,i)=>{const s=await e.getPromise(wa),l=await e.getPromise(xa);if(null!=s&&null==l){const e=n.clientX,l=null==n?void 0:n.clientY,c=a.Point.create(e,l),u=null!=s?a.Point.distance(s,c):0,d=null==r||r(n);u<2&&d&&(null==i||i(n,null!=s?s:c),t(xa,o))}})),contextMenu:useActionCallback((()=>(e,t)=>{(null==t||t(e))&&e.preventDefault()})),longPress:useActionCallback((({set:e})=>(t,n,o,r)=>{if(null==o||o(t)){const o=a.Point.create(t.touches[0].clientX,t.touches[0].clientY);e(wa,o),e(_a,t.target),e(xa,n),null==r||r(t,o)}})),clearActiveContextMenu:useActionCallback((({reset:e,set:t})=>n=>{t(as,!!n),e(xa),e(Ea),e(wa)})),clearDismissedState:useActionCallback((({reset:e})=>()=>e(as)))}}function targetWithinMenu(e){return e.target instanceof Element&&isChildOf("vertex-menu",e.target)}function targetShouldSkipNextHit(e){return e.target instanceof Element&&isChildOf("vertex-viewer",e.target)}function isChildOf(e,t){return null!=t.closest(e)}function useDefaultKeybindings(){useApplyKeyBinding({fn:useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromiseRequired(Ra),n={milliseconds:500},o=await t();await(null==o?void 0:o.camera().viewAll().render({animation:n}))})),keyBind:"f"})}function useLongPress({target:e,callback:t,delay:n=500,onMovement:o}){const[r,i]=d.useState(),[s,l]=d.useState();d.useEffect((()=>{const handleTouchStart=e=>{const o=e;null!=o.touches&&1===o.touches.length&&(null!=r&&clearTimeout(r),l(a.Point.create(o.touches[0].clientX,o.touches[0].clientY)),i(setTimeout((()=>null==t?void 0:t(o)),n)))},handleTouchMove=e=>{const t=e;null!=t.touches&&t.touches.length>0&&null!=r&&null!=s&&a.Point.distance(s,a.Point.create(t.touches[0].clientX,t.touches[0].clientY))>=2&&(clearTimeout(r),null==o||o())},handleTouchEnd=()=>{null!=r&&clearTimeout(r)};return null==e||e.addEventListener("touchstart",handleTouchStart),null==e||e.addEventListener("touchmove",handleTouchMove),null==e||e.addEventListener("touchend",handleTouchEnd),()=>{null==e||e.removeEventListener("touchstart",handleTouchStart),null==e||e.removeEventListener("touchmove",handleTouchMove),null==e||e.removeEventListener("touchend",handleTouchEnd)}}),[e,r,s])}function asBooleanAttribute(e){return!!e||void 0}const VertexContextMenu=({targetElement:t,menuType:n,disableBackdrop:r,openPredicate:a,onOpen:s,onClose:l,children:c})=>{const u=useContextMenuActions(),d=Ji(xa),p=Ji(Ta),f=o.useMemo((()=>["bottom-end","top-start","top-end","right","left"]),[]),h=d===n;useStackKeyBinding({id:"ContextMenu",keyBind:"Escape",fn:u.clearActiveContextMenu,addPredicate:()=>null!=d&&d===n,cancelPredicate:()=>null==d},[d]);const m=o.useMemo((()=>null!=t?t:null!=a?window:void 0),[t,a]);return useLongPress({target:m,callback:e=>u.longPress(e,n,a,s),onMovement:()=>u.clearActiveContextMenu()}),o.useEffect((()=>{const handleWindowPointerDown=e=>{const t=undefined;if(!targetWithinMenu(e)&&2!==e.buttons&&d===n){const t=targetShouldSkipNextHit(e);u.clearActiveContextMenu(t)}};if(r)return window.addEventListener("pointerdown",handleWindowPointerDown),()=>{window.removeEventListener("pointerdown",handleWindowPointerDown)}}),[r,n,d]),o.useEffect((()=>{const handlePointerDown=e=>{u.pointerDown(e)},handlePointerUp=e=>{u.pointerUp(e,n,a,s)},handleContextMenu=e=>u.contextMenu(e,a);return null==m||m.addEventListener("pointerdown",handlePointerDown),null==m||m.addEventListener("pointerup",handlePointerUp),null==m||m.addEventListener("contextmenu",handleContextMenu),()=>{null==m||m.removeEventListener("pointerdown",handlePointerDown),null==m||m.removeEventListener("pointerup",handlePointerUp),null==m||m.removeEventListener("contextmenu",handleContextMenu)}}),[t,n,a]),e.jsx("div",{className:ba({hidden:!h}),children:e.jsx(i.VertexMenu,{"data-testid":`${n}-context-menu`,open:asBooleanAttribute(h),position:p,fallbackPlacements:f,backdrop:!r,onMenuClosed:()=>{u.clearActiveContextMenu(),null==l||l()},children:e.jsx("div",{className:"pt-1",children:c})})})};var ds;!function(e){e.HIDE_ITEM="Hide Item",e.SHOW_ONLY_SELECTED="Show Only Selected",e.HIDE_SELECTED="Hide Selected",e.SHOW_ONLY_ITEM="Show Only Item",e.SHOW_ALL="Show All",e.HIDE_ALL="Hide All",e.SELECT_FILTERED_ITEMS="Select Filtered Items",e.INVERT_SELECTION="Invert Selection",e.CLEAR_ALL_TRANSFORMS="Clear All Transforms",e.CLEAR_SELECTED_TRANSFORMS="Clear Selected Transforms",e.CLEAR_SELECTION="Clear Selection",e.DESELECTING_ITEMS="Deselecting Items",e.SELECTING_ITEMS="Selecting Items",e.SELECTING_ONLY_ITEM="Selecting Only Item",e.SELECTING_ANCESTOR="Selecting Ancestor",e.APPLY_MATERIAL_OVERRIDE_TO_ALL="Apply Material Override To All",e.APPLY_MATERIAL_OVERRIDE_TO_SELECTION="Apply Material Override To Selection",e.CLEAR_ALL_MATERIAL_OVERRIDES="Clear All Material Overrides",e.CLEAR_SELECTED_MATERIAL_OVERRIDES="Clear Selected Material Overrides",e.SET_PHANTOM_ALL="Set Phantom All",e.SET_PHANTOM_SELECTED_ITEMS="Set Phantom Selected Items",e.CLEAR_PHANTOM_ALL="Clear Phantom All",e.CLEAR_PHANTOM_SELECTED_ITEMS="Clear Phantom Selected Items",e.SET_PHANTOM_NON_SELECTED_ITEMS="Set Phantom Non Selected Items",e.RESTORE_PHANTOM_OVERRIDES="Restore Phantom Overrides",e.SET_ITEM_AS_END_ITEM="Set Item as End Item",e.UNSET_ITEM_AS_END_ITEM="Unset Item as End Item",e.SHOW_ANNOTATION="Show Annotation",e.HIDE_ANNOTATION="Hide Annotation"}(ds||(ds={}));const ps=Xi({key:"selectionSelectedItems",default:void 0}),fs=Yi({key:"selectionSelectedItemIds",default:[]}),hs=Yi({key:"selectionLastSelected",default:void 0}),ms=Yi({key:"selectionLastSelectionFromViewer",default:!1}),vs=Yi({key:"selectionLastSelectWasMultiSelect",default:!1}),gs=Zi({key:"selectionHighestSelectedAncestor",get:({get:e})=>{var t,n;const o=e(hs),r=e(fs);return null!==(n=null===(t=null==o?void 0:o.ancestors)||void 0===t?void 0:t.find((e=>r.includes(e))))&&void 0!==n?n:null==o?void 0:o.id}}),ys=Yi({key:"selectionPreviousVisibleSummary",default:void 0}),bs=Yi({key:"selectionVisibleSummary",default:void 0}),Ss=Zi({key:"selectionVisibleCount",get:({get:e})=>{var t,n;return null!==(n=null===(t=e(bs))||void 0===t?void 0:t.count)&&void 0!==n?n:0}}),xs=Zi({key:"selectionIsActive",get:({get:e})=>{const t=e(fs),n=undefined;return e(Ss)>0||t.length>0}});function useSelectionActions(){const e=useViewerSceneActions(),t=useActionCallback((({snapshot:e,reset:t})=>async()=>{const n=undefined;(await e.getPromise(fs)).forEach((e=>t(ps(e))))})),n=useActionCallback((({snapshot:t,reset:n,set:o})=>async(r,i)=>{var a,s;const l=await t.getPromise(ps(r.id)),u=await t.getPromise(fs),d=null===(s=[...null!==(a=r.ancestors)&&void 0!==a?a:[]])||void 0===s?void 0:s.reverse().find((e=>!u.includes(e)));null!=l&&null!=d?(o(ps(d),{id:d}),o(fs,(e=>[...e,d])),e.execute(ds.SELECTING_ANCESTOR,e.selectItemsTransform(d))):(null==i?void 0:i.clear)?(o(ps(r.id),r),o(fs,[r.id]),e.execute(ds.SELECTING_ONLY_ITEM,e.clearSelectionTransform,e.selectItemsTransform(r.id))):(o(ps(r.id),r),o(fs,(e=>[...e,r.id])),e.execute(ds.SELECTING_ITEMS,e.selectItemsTransform(r.id))),c(r),o(hs,r),o(ms,!0),n(vs)})),o=useActionCallback((({reset:t,set:n})=>async o=>{t(ps(o)),t(vs),n(fs,(e=>e.filter((e=>e!==o)))),e.execute(ds.DESELECTING_ITEMS,e.deselectItemsTransform(o))})),r=useActionCallback((({snapshot:e})=>async t=>{const r=await e.getPromise(ps(t.id));null!=r?await o(r.id):await n(t)})),i=useActionCallback((({snapshot:e,reset:t,set:o})=>async(r,i={})=>{const a=await e.getPromise(ps(r.id)),s=await e.getPromise(fs);if(s.filter((e=>{var t;return e!==r.id&&!(null===(t=r.ancestors)||void 0===t?void 0:t.includes(e))})).forEach((e=>t(ps(e)))),t(vs),a)if(i.ignoreAncestorSelection)t(fs),t(ps(a.id));else{const e=s.filter((e=>{var t;return e===r.id||(null===(t=r.ancestors)||void 0===t?void 0:t.includes(e))}));o(fs,e)}else t(fs);await n(r,{clear:!0})})),a=useActionCallback((({reset:e})=>async()=>{await t(),e(fs),e(hs),e(ms),e(vs)})),s=useActionCallback((()=>async()=>{await a(),e.execute(ds.CLEAR_SELECTION,e.clearSelectionTransform)})),l=useActionCallback((({set:e})=>async t=>{e(vs,t)})),c=useActionCallback((({reset:e,set:t})=>e=>{}));return{select:n,toggleSelection:r,clearAndSelect:i,selectCurrentHit:useActionCallback(retainSnapshot((({snapshot:e})=>async()=>{const t=await e.tryGetPromise(is).then((e=>e.value)),n=await e.getPromise(ts),o=(null==n?void 0:n.metaKey)||(null==n?void 0:n.ctrlKey)||(null==n?void 0:n.shiftKey);null==t||o?null!=t&&o?r(t):s():i(t)}))),syncSelection:useActionCallback((({set:e,reset:n})=>async(o,r)=>{r.selected?(await t(),e(ps(o.id),o),r.multiSelect?e(fs,(e=>[...e.filter((e=>e!==o.id)),o.id])):e(fs,[o.id]),c(o),e(hs,o),e(ms,!1),e(vs,!!r.multiSelect)):(n(ps(o.id)),n(vs),e(fs,(e=>e.filter((e=>e!==o.id)))))})),deselect:o,clearSelection:s,resetSelectionState:a,toggleLastSelectWasMultiSelect:l,selectForModelViewsPanel:c}}const ws=Zi({key:"viewerToolkitSelectionState",get:({get:e})=>{const t=undefined,n=undefined,o=undefined,r=undefined;return{selectedItemIds:e(fs),lastSelected:e(hs),highestSelectedAncestorId:e(gs)}}});var _s=Object.freeze({__proto__:null,selectionHighestSelectedAncestor:gs,selectionIsActive:xs,selectionLastSelectWasMultiSelect:vs,selectionLastSelected:hs,selectionLastSelectionFromViewer:ms,selectionPreviousVisibleSummary:ys,selectionSelectedItemIds:fs,selectionSelectedItems:ps,selectionState:ws,selectionVisibleCount:Ss,selectionVisibleSummary:bs,useSelectionActions:useSelectionActions});const VertexFitSelectedMenuItem=()=>{const t=Ji(fs),n=Ji(bs),o=useViewerCameraActions();return e.jsxs(i.VertexMenuItem,{"data-testid":"fit-selected-menu-option",onClick:()=>{null!=(null==n?void 0:n.boundingBox)&&o.flyToByBoundingBox(n.boundingBox)},disabled:asBooleanAttribute(0===t.length),children:[e.jsx(i.VertexIcon,{slot:"icon",name:"fit-selected",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Fit Selected"})]})},VertexFlyToMenuItem=()=>{const t=useViewerCameraActions(),n=Ji(Aa);return e.jsxs(i.VertexMenuItem,{"data-testid":"fly-to-part-menu-option",onClick:()=>{var e;const o=undefined,r=contextMenuItemIsRow(n)?null===(e=null==n?void 0:n.node.id)||void 0===e?void 0:e.hex:null==n?void 0:n.id;null!=r&&t.flyToById(r)},disabled:asBooleanAttribute(null==n),children:[e.jsx(i.VertexIcon,{slot:"icon",name:"paper-airplane",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Fly To"})]})};function useSceneItemsOperations(){const e=Ji(Va),t=undefined,n=undefined,r=undefined,i=undefined,a=undefined,s=undefined;return{sceneItemsOperation:o.useCallback((async(t,n)=>{const o=await(null==e?void 0:e.scene());null==n?await(null==o?void 0:o.items((e=>t(e.where((e=>e.all()))))).execute()):n.length>0&&await(null==o?void 0:o.items((e=>t(e.where((e=>e.withItemIds(n)))))).execute())}),[e]),showOnlySelected:o.useCallback((async()=>{const t=await(null==e?void 0:e.scene());null==t||t.items((e=>[e.where((e=>e.all())).hide(),e.where((e=>e.withSelected())).show()])).execute()}),[e]),hideSelected:o.useCallback((async()=>{const t=await(null==e?void 0:e.scene());null==t||t.items((e=>[e.where((e=>e.withSelected())).hide()])).execute()}),[e]),showOnlyItem:o.useCallback((async t=>{const n=await(null==e?void 0:e.scene());null==n||n.items((e=>[e.where((e=>e.all())).hide(),e.where((e=>e.withItemIds([t]))).show()])).execute()}),[e]),ghostSelected:o.useCallback((async()=>{const t=await(null==e?void 0:e.scene());null==t||t.items((e=>[e.where((e=>e.withSelected())).setPhantom(!0)])).execute()}),[e]),unGhostSelected:o.useCallback((async()=>{const t=await(null==e?void 0:e.scene());null==t||t.items((e=>[e.where((e=>e.withSelected())).setPhantom(!1)])).execute()}),[e])}}const VertexHideAllMenuItem=()=>{const t=useSceneItemsOperations();return e.jsxs(i.VertexMenuItem,{"data-testid":"hide-all-menu-option",onClick:()=>{t.sceneItemsOperation((e=>e.hide()))},children:[e.jsx(i.VertexIcon,{slot:"icon",name:"visibility-hidden",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Hide All Parts"})]})},VertexHidePartMenuItem=()=>{const t=Ji(Aa),n=useSceneItemsOperations();return e.jsxs(i.VertexMenuItem,{"data-testid":"hide-menu-option",onClick:()=>{var e;const o=undefined,r=contextMenuItemIsRow(t)?null===(e=null==t?void 0:t.node.id)||void 0===e?void 0:e.hex:t.id;null!=r&&n.sceneItemsOperation((e=>e.hide()),[r])},disabled:asBooleanAttribute(null==t),children:[e.jsx(i.VertexIcon,{slot:"icon",name:"visibility-hidden",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Hide Part"})]})},VertexHideSelectedMenuItem=()=>{const t=Ji(fs),n=useSceneItemsOperations();return e.jsxs(i.VertexMenuItem,{"data-testid":"hide-selected-menu-option",onClick:()=>n.hideSelected(),disabled:asBooleanAttribute(0===t.length),children:[e.jsx(i.VertexIcon,{slot:"icon",name:"visibility-hidden",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Hide Selected"})]})},VertexShowAllMenuItem=()=>{const t=useSceneItemsOperations();return e.jsxs(i.VertexMenuItem,{"data-testid":"show-all-menu-option",onClick:()=>{t.sceneItemsOperation((e=>e.show()))},children:[e.jsx(i.VertexIcon,{slot:"icon",name:"visibility-visible",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Show All Parts"})]})},VertexShowOnlyMenuItem=()=>{const t=Ji(Aa),n=useSceneItemsOperations();return e.jsxs(i.VertexMenuItem,{"data-testid":"show-only-menu-option",onClick:()=>{var e;const o=undefined,r=contextMenuItemIsRow(t)?null===(e=null==t?void 0:t.node.id)||void 0===e?void 0:e.hex:null==t?void 0:t.id;null!=r&&n.showOnlyItem(r)},disabled:asBooleanAttribute(null==t),children:[e.jsx(i.VertexIcon,{slot:"icon",name:"visibility-visible",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Show Only Part"})]})},VertexShowOnlySelectedMenuItem=()=>{const t=Ji(fs),n=useSceneItemsOperations();return e.jsxs(i.VertexMenuItem,{"data-testid":"show-only-selected-menu-option",onClick:()=>n.showOnlySelected(),disabled:asBooleanAttribute(0===t.length),children:[e.jsx(i.VertexIcon,{slot:"icon",name:"visibility-visible",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Show Only Selected"})]})};Yi({key:"sceneTreeLoaderVisible",default:!1});const As=Yi({key:"sceneTreeElement",default:void 0}),Es=Yi({key:"sceneTreeWidth",default:void 0});function useSceneTreeActions(){const e=useSelectionActions(),t=useViewerCameraActions();return{toggleSelection:useActionCallback((({snapshot:t})=>async(n,o,r)=>{var i,a;if(!n.defaultPrevented&&0===n.button&&(n.altKey||((n.ctrlKey||n.metaKey)&&o.selected?r.deselectItem(o):o.selected?r.selectItem(o,{recurseParent:!0}):o.selected||r.selectItem(o,{append:n.ctrlKey||n.metaKey,range:n.shiftKey})),null!=o.id)){const r=await t.getPromise(hs);e.syncSelection({id:null===(i=o.id)||void 0===i?void 0:i.hex,ancestors:null!==(a=null==r?void 0:r.ancestors)&&void 0!==a?a:[]},{selected:!n.metaKey&&!n.ctrlKey||!o.selected,multiSelect:n.shiftKey||n.metaKey||n.ctrlKey})}})),toggleExpansion:useActionCallback((()=>(e,t,n)=>{n.toggleExpandItem(t)})),toggleVisibility:useActionCallback((()=>(e,t,n)=>{n.toggleItemVisibility(t)})),flyToRow:useActionCallback((({snapshot:e})=>async n=>{var o;const r=await e.getPromise(As),i=await(null==r?void 0:r.getRowAtClientY(n));null!=(null===(o=null==i?void 0:i.node.id)||void 0===o?void 0:o.hex)&&await t.flyToById(i.node.id.hex)})),setContextMenuItem:useActionCallback((({set:e,snapshot:t})=>async n=>{const o=await t.getPromise(As),r=await(null==o?void 0:o.getRowAtClientY(n));e(Aa,r)}))}}Zi({key:"sceneTreeController",get:({get:e})=>{var t;return null===(t=e(As))||void 0===t?void 0:t.controller},dangerouslyAllowMutability:!0});const VertexGhostSelectedMenuItem=()=>{const t=Ji(fs),n=useSceneItemsOperations();return e.jsxs(i.VertexMenuItem,{"data-testid":"ghost-selected-menu-option",onClick:()=>n.ghostSelected(),disabled:asBooleanAttribute(0===t.length),children:[e.jsx(i.VertexIcon,{slot:"icon",name:"visibility-partial",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Ghost Selected"})]})},VertexUnghostSelectedMenuItem=()=>{const t=Ji(fs),n=useSceneItemsOperations();return e.jsxs(i.VertexMenuItem,{"data-testid":"unghost-selected-menu-option",onClick:()=>n.unGhostSelected(),disabled:asBooleanAttribute(0===t.length),children:[e.jsx(i.VertexIcon,{slot:"icon",name:"visibility-visible",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Unghost Selected"})]})},DefaultSceneTreeContextMenu=()=>e.jsxs("div",{className:"w-56",children:[e.jsx(VertexHideSelectedMenuItem,{}),e.jsx(VertexHideAllMenuItem,{}),e.jsx(VertexShowOnlyMenuItem,{}),e.jsx(VertexShowOnlySelectedMenuItem,{}),e.jsx(VertexShowAllMenuItem,{}),e.jsx(VertexGhostSelectedMenuItem,{}),e.jsx(VertexUnghostSelectedMenuItem,{}),e.jsx(i.VertexMenuDivider,{}),e.jsx(VertexFitSelectedMenuItem,{}),e.jsx(VertexFlyToMenuItem,{})]}),VertexSceneTreeContextMenu=({children:t})=>{const n=useSceneTreeActions(),o=Ji(As),r=null!=t&&!1!==t;return e.jsx(VertexContextMenu,{menuType:"scene-tree",targetElement:o,onOpen:async(e,t)=>{const o=e;await n.setContextMenuItem(o.clientY)},disableBackdrop:!0,children:r?t:e.jsx(DefaultSceneTreeContextMenu,{})})},DefaultViewerContextMenu=()=>e.jsxs("div",{className:"w-56",children:[e.jsx(VertexHidePartMenuItem,{}),e.jsx(VertexHideSelectedMenuItem,{}),e.jsx(VertexHideAllMenuItem,{}),e.jsx(VertexShowOnlyMenuItem,{}),e.jsx(VertexShowOnlySelectedMenuItem,{}),e.jsx(VertexShowAllMenuItem,{}),e.jsx(VertexGhostSelectedMenuItem,{}),e.jsx(VertexUnghostSelectedMenuItem,{}),e.jsx(i.VertexMenuDivider,{}),e.jsx(VertexFitSelectedMenuItem,{}),e.jsx(VertexFlyToMenuItem,{})]}),VertexViewerContextMenu=({children:t})=>{const n=Ji(Va),o=null!=t&&!1!==t;return e.jsx(VertexContextMenu,{menuType:"viewer",targetElement:n,disableBackdrop:!0,children:o?t:e.jsx(DefaultViewerContextMenu,{})})},Ts=Yi({key:"viewerToolkitSdkConfig",default:void 0}),targetIsElement=(e,t)=>e instanceof Element&&e.tagName===t;function useRecoilRef({state:e}){const t=na((({set:t})=>n=>{t(e,n)}),[]);return t}var Vs;function styleFromOptionalFont(e){return null!=e?{"--scene-tree-default-font-family":styleFromFontFace(e.fontFace),"--scene-tree-default-font-color":e.color}:{}}function styleFromOptionalBackgroundColors(e){const t=null==e?void 0:e.depthColors,n=null!=t?Object.keys(t).reduce(((e,n)=>Object.assign(Object.assign({},e),{[`--scene-tree-row-background-color-depth-${n}`]:t[parseInt(n)]})),{}):{};return null!=e?Object.assign(Object.assign({},n),{"--scene-tree-hovered-row-background-color":e.hovered,"--scene-tree-selected-row-background-color":e.selected,"--scene-tree-row-background-color":e.defaultColor}):{}}function styleFromFontFace(e){return e===Vs.ROBOTO_MONO?"var(--vertex-ui-font-family-monospace)":"var(--vertex-ui-font-family)"}!function(e){e.ROBOTO="ROBOTO",e.ROBOTO_MONO="ROBOTO_MONO"}(Vs||(Vs={}));const VertexSceneTreeCollapseAll=()=>{const t=Ji(As);return e.jsx(i.VertexTooltip,{className:"w-auto",content:"Collapse All",placement:"top",children:e.jsx(i.VertexIcon,{size:"sm",className:"h-6 w-6 hover:bg-neutral-300 rounded cursor-pointer","data-testid":"collapse-all-icon",name:"collapse-all",onClick:()=>{null==t||t.collapseAll()}})})},VertexSceneTreeExpandAll=()=>{const t=Ji(As);return e.jsx(i.VertexTooltip,{className:"w-auto",content:"Expand All",placement:"top",children:e.jsx(i.VertexIcon,{size:"sm","data-testid":"expand-all-icon",className:"h-6 w-6 hover:bg-neutral-300 rounded cursor-pointer",name:"expand-all",onClick:()=>{null==t||t.expandAll()}})})};function VertexSceneTreeToolbar(){return e.jsx(s.VertexSceneTreeToolbar,{className:"h-10 border-b border-neutral-300 box-border",children:e.jsxs("div",{className:"flex flex-shrink-0 w-full text-neutral-700 items-center gap mx-2",children:[e.jsx(VertexSceneTreeExpandAll,{}),e.jsx(VertexSceneTreeCollapseAll,{})]})})}const VertexSceneTreeHeader=({children:t})=>{const n=null!=t&&!1!==t;return e.jsx("div",{slot:"header",className:"flex flex-col",children:n?t:e.jsxs(e.Fragment,{children:[e.jsx(s.VertexSceneTreeSearch,{className:"border-b border-neutral-300"}),e.jsx(VertexSceneTreeToolbar,{})]})})},Cs={binding:"{{row.node.name}}",label:"Name",metadataKeyName:"VERTEX_SCENE_ITEM_NAME"},ks=Zi({key:"sceneTreeColumnsActiveColumns",get:({get:e})=>{const t=[],n=e(Es);if(null!=n&&n>0){const e=1/(t.length+1)*n,o=(n-e)/t.length;return{Name:Object.assign(Object.assign({},Cs),{initialWidth:e,minWidth:o})}}return{Name:Cs}}}),Ns=Zi({key:"sceneTreeColumnsActiveColumnNames",get:({get:e})=>Object.keys(e(ks))}),VertexSceneTreeTableLayout=t=>{const n=Ji(ks),o=Ji(Ns),r=[];return e.jsx(s.VertexSceneTreeTableLayout,Object.assign({"data-testid":"scene-tree-table-layout"},t,{children:o.map(((t,i)=>{var a;const l=n[t],c=null!==(a=r[i])&&void 0!==a?a:l.initialWidth;return e.jsxs(s.VertexSceneTreeTableColumn,{"data-testid":`scene-tree-table-column-${i}`,initialWidth:c,minWidth:l.minWidth,children:[e.jsx("template",{slot:"header",dangerouslySetInnerHTML:{__html:`\n <div class="text-sm text-neutral-800 my-2">\n <div class="${ba("truncate",{"pl-2":0===i,"pr-2":i===o.length-1})}">\n ${l.label}\n </div>\n </div>\n `}}),e.jsx("template",{dangerouslySetInnerHTML:{__html:`\n <vertex-scene-tree-table-cell\n prop:value="${l.binding}"\n prop:selection-handler="{{row.data.handleSelection}}"\n prop:expansion-handler="{{row.data.handleExpansion}}"\n prop:visibility-handler="{{row.data.handleVisibility}}"\n ${0===i?"expand-toggle":""}\n ${i===o.length-1?"isolate-button visibility-toggle":""}>\n <div class="flex items-center gap-2">\n <vertex-tooltip \n class="truncate" \n prop:content="${null!=l.binding?l.binding:"--"}" \n placement="${i!==o.length-1?"right":"top"}">\n <div class="flex items-center w-full">\n <div class="truncate">${l.binding}</div>\n </div>\n </vertex-tooltip>\n </div>\n \n\n <div slot="placeholder" class="flex items-center w-full truncate">\n <div> -- </div>\n </div>\n </vertex-scene-tree-table-cell>\n `}})]},l.label)}))}))},VertexSceneTree=n=>{var{id:o,font:r,backgroundColors:i,children:a,style:l,onPointerDown:c,onClick:u,onToggleSelection:d,onToggleExpansion:p,onToggleVisibility:f,className:h,rowData:m}=n,v=t.__rest(n,["id","font","backgroundColors","children","style","onPointerDown","onClick","onToggleSelection","onToggleExpansion","onToggleVisibility","className","rowData"]);const g=Ji(Ts),b=useSelectionActions(),S=useSceneTreeActions(),w=Ji(Va),_=useRecoilRef({state:As}),A=null!=a&&!1!==a,wrappedExpansionHandler=(e,t,n)=>{S.toggleExpansion(e,t,n),null==p||p(e,t,n)},wrappedSelectionHandler=(e,t,n)=>{S.toggleSelection(e,t,n),null==d||d(e,t,n)},wrappedVisibilityHandler=(e,t,n)=>{S.toggleVisibility(e,t,n),null==f||f(e,t,n)},handleClick=e=>{e.altKey&&S.flyToRow(e.clientY),null==u||u(e)},handlePointerDown=e=>{targetIsElement(e.target,"VERTEX-SCENE-TREE-TABLE-COLUMN")&&b.clearSelection(),null==c||c(e)};return e.jsx("div",{className:ba("flex flex-col w-full h-full",h),children:e.jsx("div",{className:"flex group h-full",children:e.jsx(s.VertexSceneTree,Object.assign({id:null!=o?o:"vertex-scene-tree","data-testid":"vertex-scene-tree",config:g,ref:_,className:"flex-1",style:Object.assign(Object.assign(Object.assign({},styleFromOptionalFont(r)),styleFromOptionalBackgroundColors(i)),l),onConnectionError:e=>{logger_error("Scene Tree Connection Error: ",e.detail)},viewer:w,onPointerDown:handlePointerDown,onClick:handleClick,rowData:e=>{var t;const n=null!==(t=null==m?void 0:m(e))&&void 0!==t?t:{};return Object.assign({handleExpansion:wrappedExpansionHandler,handleSelection:wrappedSelectionHandler,handleVisibility:wrappedVisibilityHandler},n)}},v,{children:A?a:e.jsxs(e.Fragment,{children:[e.jsx(VertexSceneTreeHeader,{}),e.jsx(VertexSceneTreeTableLayout,{}),e.jsx(VertexSceneTreeContextMenu,{})]})}))})})},Rs=Yi({key:"openedPanelActivePrimaryLeft",default:void 0}),Is=Yi({key:"openedPanelActivePrimaryRight",default:void 0});function usePanelActions(){return{openPrimary:useActionCallback((({set:e})=>(t,n)=>{e("left"===n?Rs:Is,t)})),closePrimary:useActionCallback((({set:e})=>t=>{e("left"===t?Rs:Is,void 0)}))}}const Os=255,Ls=Yi({key:"sceneItemAdjustmentsSelectedColor",default:void 0}),Ps=Yi({key:"sceneItemAdjustmentsSelectedOpacity",default:void 0}),js=Xi({key:"appliedItemMaterialOverride",default:void 0}),Ms=Yi({key:"appliedItemMaterialOverrideIds",default:[]}),Ds=Zi({key:"sceneItemAdjustmentsLastSelectedOverride",get:({get:e})=>{const t=e(hs);if(null!=t)return e(js(t.id))}}),Bs=Yi({key:"applyMaterialToAllUserAction",default:void 0}),zs=Yi({key:"showConfirmDialogWhenApplyingMaterialToAll",default:!0}),Us=Yi({key:"confirmApplyMaterialToAllDialogOpen",default:!1}),useSceneItemMaterialActions=()=>{const e=useViewerSceneActions(),t=useActionCallback((({snapshot:e,reset:t})=>async()=>{const n=await e.getPromise(Ms);t(Ls),n.forEach((e=>t(js(e)))),t(Ms)}));return{updateColor:useActionCallback((({set:e})=>t=>{e(Ls,t)})),clearCurrentColor:useActionCallback((({reset:e})=>()=>{e(Ls)})),clearCurrentOpacity:useActionCallback((({reset:e})=>()=>{e(Ps)})),clear:useActionCallback((({snapshot:t,set:n,reset:o})=>async()=>{const r=await t.getPromise(fs);o(Ls),r.forEach((e=>o(js(e)))),n(Ms,(e=>e.filter((e=>!r.includes(e))))),await e.execute(ds.CLEAR_SELECTED_MATERIAL_OVERRIDES,(e=>e.where((e=>e.withSelected())).clearMaterialOverrides().select()))})),clearAll:useActionCallback((()=>async()=>{await t(),await e.execute(ds.CLEAR_ALL_MATERIAL_OVERRIDES,(e=>e.where((e=>e.all())).clearMaterialOverrides()),(e=>e.where((e=>e.withSelected())).select()))})),clearState:t,updateOpacity:useActionCallback((({set:e})=>t=>{e(Ps,t)})),apply:useActionCallback((({snapshot:t,set:n})=>async()=>{const o=await t.getPromise(Ls),r=await t.getPromise(Ps),i=await t.getPromise(fs),a=await t.getPromise(Ds),s=null!=o?o:a,l=null!=r?r:null==a?void 0:a.opacity;if(null!=s){const t=Object.assign(Object.assign({},s),{opacity:null!=l?l:s.opacity});await e.execute(ds.APPLY_MATERIAL_OVERRIDE_TO_SELECTION,(e=>e.where((e=>e.withSelected())).materialOverride(t))),i.forEach((e=>n(js(e),t))),n(Ms,(e=>[...e,...i]))}})),confirmApplyAll:useActionCallback((({set:e})=>t=>{e(Us,!0),e(Bs,(()=>t))})),cancelApplyAll:useActionCallback((({reset:e})=>()=>{e(Us),e(Bs)})),applyAll:useActionCallback((({snapshot:t,reset:n})=>async()=>{const o=await t.getPromise(Ls),r=await t.getPromise(Ps);if(null!=o){const i=await t.getPromise(Ms),a=Object.assign(Object.assign({},o),{opacity:null!=r?r:o.opacity});await e.execute(ds.APPLY_MATERIAL_OVERRIDE_TO_ALL,(e=>e.where((e=>e.all())).materialOverride(a))),i.forEach((e=>n(js(e))));const s=await t.getPromise(Bs);null==s||s(a),n(Us),n(Bs)}})),hideConfirmApplyAllDialog:useActionCallback((({set:e})=>()=>{e(zs,!1)}))}};function PanelSection({header:t,children:n}){return e.jsxs("div",{className:"py-3 px-4 border-neutral-300 border-b",children:[e.jsx("div",{className:"my-2 text-base text-neutral-700",children:t}),n]})}const VertexSceneItemMaterialApplyAll=({onApplyAll:t})=>{const n=useSceneItemMaterialActions(),o=Qi(Ds),r=Ji(Ls),a=Ji(zs),s=d.useMemo((()=>"hasValue"===o.state?null!=r?r:o.contents:r),[o,r]);return e.jsx(i.VertexTooltip,{content:"Apply to All",children:e.jsx(i.VertexIconButton,{iconName:"square-dot-outline",iconSize:"sm",color:"secondary",disabled:null==s,onClick:async()=>{a?n.confirmApplyAll(t):(await n.applyAll(),null==t||t(s))}})})};function SceneItemMaterialApplyAllConfirmationDialog(){const t=useSceneItemMaterialActions(),n=Ji(Us),[r,a]=o.useState(!1),onCloseDialog=()=>{t.cancelApplyAll(),a(!1)};return n?e.jsxs(i.VertexDialog,{open:!0,className:"text-sm",onClosed:onCloseDialog,onBackdropClick:onCloseDialog,children:[e.jsx("div",{slot:"heading",children:"Apply to All Parts"}),e.jsx("div",{className:"max-w-lg break-words pr-2",children:"This will apply the same material to all parts in the model. Any previous material changes will be lost."}),e.jsxs("div",{className:"flex mt-8 gap-2 items-center",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(i.VertexToggle,{"data-testid":"hide-confirmation-dialog-in-future-checkbox",variant:"check",className:"pt-1",checked:r,onValueChanged:e=>{a(e.detail)}}),"Don't show again this session"]}),e.jsxs("div",{className:"flex ml-auto gap-2",children:[e.jsx(i.VertexButton,{"data-testid":"cancel-apply-material-to-all",onClick:onCloseDialog,children:"Cancel"}),e.jsx(i.VertexButton,{color:"primary","data-testid":"confirm-apply-material-to-all",onClick:async()=>{await t.applyAll(),r&&t.hideConfirmApplyAllDialog()},children:"Apply"})]})]})]}):e.jsx(e.Fragment,{})}function createColorMaterialWithId(e,t=ma.create()){return Object.assign({id:t},l.ColorMaterial.fromHex(e))}function useDebouncedCallback(e,t){const[n,r]=o.useState();return o.useEffect((()=>()=>{null!=n&&clearTimeout(n)}),[e,t,n]),o.useCallback((o=>{const handler=()=>{e(o)};null!=n&&clearTimeout(n),r(setTimeout(handler,t))}),[e,t,n])}const VertexSceneItemMaterialColorPicker=({onApply:t})=>{const n=useSceneItemMaterialActions(),o=Qi(Ds),r=Ji(Ls),a=d.useMemo((()=>"hasValue"===o.state?null!=r?r:o.contents:r),[o,r]),s=useDebouncedCallback((()=>{n.apply()}),500),l=d.useCallback((e=>{const t=e.target;n.updateColor(createColorMaterialWithId(t.value)),s(t.value)}),[s,n]);return e.jsx(i.VertexColorPicker,{"data-testid":"selected-item-color-picker",value:null!=a?ca.toHexString(a.diffuse):void 0,onValueChanged:()=>{n.apply(),null==t||t(a)},onInput:l})},VertexSceneItemMaterialOpacitySlider=({onApply:t})=>{const n=useSceneItemMaterialActions(),o=Ji(Ps),r=Qi(Ds),a=d.useMemo((()=>{var e,t;return"hasValue"===r.state?null!==(t=null!=o?o:null===(e=r.contents)||void 0===e?void 0:e.opacity)&&void 0!==t?t:Os:null!=o?o:Os}),[o,r]),s=useDebouncedCallback((()=>{n.apply()}),500),l=d.useCallback((e=>{n.updateOpacity(e.detail.value),s(e.detail.value)}),[s,n]),c=d.useMemo((()=>"hasValue"!==r.state||null==r.contents),[r]);return e.jsx(i.VertexTooltip,{className:"flex w-full",content:c?"Select a part and apply a color to enable opacity":`${Math.floor(a/Os*100)}%`,placement:"top",children:e.jsxs("div",{className:"flex items-center w-full gap-2",children:[e.jsx("div",{className:"text-xs pr-2 text-center",children:"0%"}),e.jsx(i.VertexSlider,{className:"flex-grow mt-2","data-testid":"scene-item-adjustments-opacity-slider",disabled:c,value:null!=a?a:Os,step:5,min:0,max:Os,onValueChange:e=>{n.updateOpacity(e.detail.value),n.apply(),null==t||t(e.detail.value)},onValueInput:l}),e.jsx("div",{className:"text-xs pr-2 text-right cursor-default",children:"100%"})]})})};function VertexMaterialControls({onApplyMaterial:t,onApplyMaterialToAll:n,onApplyOpacity:r}){const i=useSceneItemMaterialActions(),a=Ji(hs);return o.useEffect((()=>{i.clearCurrentColor(),i.clearCurrentOpacity()}),[null==a?void 0:a.id]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Color"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(VertexSceneItemMaterialColorPicker,{onApply:t}),e.jsx(VertexSceneItemMaterialApplyAll,{onApplyAll:n})]})]}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Opacity"}),e.jsx("div",{className:"flex items-center",children:e.jsx(VertexSceneItemMaterialOpacitySlider,{onApply:r})})]}),e.jsx(SceneItemMaterialApplyAllConfirmationDialog,{})]})}const ResetButton=({id:t,tooltip:n,children:r})=>{const[a,s]=o.useState(!1);return e.jsx("div",{className:"ml-auto",children:e.jsxs(i.VertexDropdownMenu,{className:"flex items-stretch h-full","data-testid":`reset-button-dropdown-menu-${t}`,placement:"bottom-end",onMenuOpened:()=>s(!0),onMenuClosed:()=>s(!1),children:[e.jsx("div",{slot:"anchor",className:"flex items-center h-full",children:e.jsx(i.VertexTooltip,{content:n,disabled:a,placement:"bottom",children:e.jsxs(i.VertexButton,{className:ba("p-1.5 rounded-md select-none hover:bg-neutral-300 active:bg-neutral-400 cursor-pointer",{"bg-neutral-300":a}),"data-testid":`reset-button-${t}`,variant:"plaintext",children:[e.jsx(i.VertexIcon,{className:"px-0.5",name:"reset",size:"sm"}),e.jsx(i.VertexIcon,{name:"chevron-down",size:"sm"})]})})}),e.jsx("div",{className:"whitespace-nowrap",children:r})]})})},VertexSceneItemMaterialClear=({canClearSelected:t,onClear:n,onClearAll:o})=>{const r=useSceneItemMaterialActions();return e.jsx("div",{className:"ml-auto",children:e.jsxs(ResetButton,{id:"materials",tooltip:"Clear Materials",children:[e.jsx("div",{className:"pt-1"}),e.jsx(i.VertexMenuItem,{"data-testid":"clear-selected-materials",onClick:()=>{r.clear(),null==n||n()},disabled:!t,children:"Clear selected materials"}),e.jsx(i.VertexMenuItem,{"data-testid":"clear-all-materials",onClick:()=>{r.clearAll(),null==o||o()},children:"Clear all materials"})]})})};function VertexMaterialPanelSection({onClearMaterial:t,onClearAllMaterials:n,onApplyMaterial:r,onApplyMaterialToAll:i,onApplyOpacity:a}){const s=useSceneItemMaterialActions(),l=Ji(xs),c=Ji(hs);return o.useEffect((()=>{s.clearCurrentColor(),s.clearCurrentOpacity()}),[null==c?void 0:c.id]),e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Material",e.jsx(VertexSceneItemMaterialClear,{canClearSelected:l,onClear:t,onClearAll:n})]}),children:e.jsx(VertexMaterialControls,{onApplyMaterial:r,onApplyMaterialToAll:i,onApplyOpacity:a})})}function DefaultAppearancePanel(){return e.jsx("div",{className:"flex flex-col text-neutral-700 h-full overflow-y-auto",children:e.jsx(VertexMaterialPanelSection,{})})}const Fs="Appearance",ViewerRightPanelHeader=()=>{const t=undefined,n=getHeading(Ji(Is));return e.jsx("div",{className:"flex flex-col w-full items-center z-overlay pointer-events-none md:pointer-events-auto py-3 px-4 border-b border-neutral-300",children:e.jsx("div",{className:"items-center w-full leading-6 text-md align-center font-medium text-neutral-800",children:n})})};function getHeading(e){return"appearance"===e?Fs:"None"}function VertexViewerRightOpenedPanel(){const t=Ji(Is),n=o.useMemo((()=>["appearance"]),[]);return e.jsx(e.Fragment,{children:null!=t&&n.includes(t)&&e.jsx(VertexResizableContent,{displayShadow:!0,heading:e.jsx(ViewerRightPanelHeader,{}),placement:"right",children:"appearance"===t&&e.jsx(DefaultAppearancePanel,{})})})}function Sidebar({children:t}){return e.jsx("div",{className:"pointer-events-auto flex flex-col items-center w-full border-neutral-300 py-2",children:t})}function SidebarIcon({name:t,iconName:n,active:r,responsive:a,disabled:s,content:l,tooltipPlacement:c,children:u,onSelect:d,onDeselect:p}){return e.jsx("div",{className:ba({"text-[var(--vertex-ui-blue-700)]":r===t&&!s,"text-neutral-700 hover:text-neutral-800":r!==t&&!s,"cursor-pointer hover:bg-neutral-200":!s,"text-neutral-400":s,"rounded-full md:p-3":a,"p-3":!a&&null==u,"px-3 py-1":null!=u}),"data-testid":`${t}-sidebar-panel`,onClick:()=>{s||(r===t?p():d())},children:e.jsxs(i.VertexTooltip,{placement:null!=c?c:void 0,content:o.isValidElement(l)?void 0:l,children:[e.jsx("div",{slot:"content",children:l}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx(i.VertexIcon,{name:n}),u]})]})})}function VertexViewerRightSidebar(){const t=usePanelActions(),n=Ji(Is);return e.jsx("div",{className:"flex flex-col flex-shrink-0 items-center relative border-neutral-300 border-l bg-white h-full top-0 min-w-12 w-12",children:e.jsx(Sidebar,{children:e.jsx(SidebarIcon,{name:"appearance",active:n,iconName:"adjustments",tooltipPlacement:"right",content:"Appearance",onSelect:()=>{t.openPrimary("appearance","right")},onDeselect:()=>t.closePrimary("right")})})})}const useSynchronizedProp=(e,t)=>{const n=ta(e);o.useEffect((()=>{n(t)}),[n,t])},VertexPopupButton=n=>{var{open:o,children:r}=n,a=t.__rest(n,["open","children"]);const s=r.find((e=>e.type===Anchor)),l=r.filter((e=>e.type!==Anchor));return null==s?e.jsx(e.Fragment,{}):e.jsxs(i.VertexPopover,Object.assign({className:"flex",placement:"top",backdrop:!1,open:asBooleanAttribute(o)},a,{children:[s,e.jsx("div",{className:ba("flex mb-1.5",{hidden:!o}),"data-testid":"align-plane-popover-menu",children:l})]}))},Anchor=({tooltipContent:t,children:n})=>e.jsx("div",{slot:"anchor",children:e.jsx(i.VertexTooltip,{className:"cursor-pointer",content:t,children:n})});VertexPopupButton.Anchor=Anchor;const VertexSlider=n=>{var{value:r,defaultValue:a,onChange:s,onValueChange:l,onValueInput:c}=n,u=t.__rest(n,["value","defaultValue","onChange","onValueChange","onValueInput"]);const[d,p]=o.useState(a);return e.jsx(i.VertexSlider,Object.assign({className:"w-52 mx-2 items-center",value:null!=r?r:d,onValueChange:e=>{p(e.detail.value),null==s||s(e.detail.value),null==l||l(e)},onValueInput:e=>{p(e.detail.value),null==s||s(e.detail.value),null==c||c(e)}},u))};function VertexViewerToolbarDivider(){return e.jsx("div",{"data-testid":"toolbar-divider",className:"h-6 w-px bg-neutral-300 mx-1 items-center mt-1"})}function VertexViewerCrossSectionAlignmentPopoverMenu(){const t=useCrossSectioningActions(),n=Ji(Ja),o=Ji(Ha),getBaseIcon=()=>`align-to-${null==o?void 0:o.mode}`;return useStackKeyBinding({id:"CrossSectionAlignment",keyBind:"Escape",fn:t.cancelCurrentHit,addPredicate:()=>{var e;return null!==(e=null==o?void 0:o.hitPending)&&void 0!==e&&e},cancelPredicate:()=>!(null==o?void 0:o.hitPending)},[null==o?void 0:o.hitPending]),e.jsxs(VertexPopupButton,{"data-testid":"section-alignment-popover",placement:"top",backdrop:!1,open:asBooleanAttribute(n),onDismissed:t.closeAlignmentTools,children:[e.jsx(VertexPopupButton.Anchor,{tooltipContent:"Section Alignment",children:e.jsx(i.VertexIconButton,{"data-testid":"section-alignment-icon-button",iconName:getBaseIcon(),iconColor:"secondary",onClick:n?t.closeAlignmentTools:t.openAlignmentTools,children:e.jsx(i.VertexIcon,{"data-testid":"section-alignment-icon-chevron",name:"chevron-up",size:"sm"})})}),e.jsxs(s.VertexViewerToolbarGroup,{direction:"vertical",className:"flex justify-evenly items-center py-1 my-1 ring-1 ring-neutral-200 rounded bg-neutral-100 opacity-95",children:[e.jsx(i.VertexIconButton,{iconColor:"secondary",onClick:()=>t.updateAlignment("global"),className:"w-full text-neutral-800 hover:bg-neutral-300 rounded cursor-pointer mx-0.5 py-1 px-2","data-testid":"section-alignment-align-global",iconName:"align-to-global",variant:"plain",children:e.jsx("div",{className:"text-base ml-2",children:"Align to Global"})}),e.jsx(i.VertexIconButton,{iconColor:"secondary",onClick:()=>t.updateAlignment("surface"),className:"w-full text-neutral-800 hover:bg-neutral-300 rounded cursor-pointer mx-0.5 py-1 px-2","data-testid":"section-alignment-align-surface",iconName:"align-to-surface",variant:"plain",children:e.jsx("div",{className:"text-base ml-2",children:"Align to Surface"})})]})]})}function VertexViewerCrossSectionAxisPopoverMenu(){const t=useCrossSectioningActions(),n=Ji(Qa),r=Ji(Fa),a=Qi(Ka),l=o.useMemo((()=>{const e=r.length>0&&"hasValue"===a.state?axis(r[0],xAxis(a.contents),yAxis(a.contents),zAxis(a.contents)):"x";return null!=e?`axis-${e}`:"axis-x"}),[a.state,a.contents,r]);return e.jsxs(VertexPopupButton,{"data-testid":"align-plane-popover",placement:"top",backdrop:!1,open:asBooleanAttribute(n),onDismissed:t.closeAxisTools,children:[e.jsx(VertexPopupButton.Anchor,{tooltipContent:"Align Plane",children:e.jsx(i.VertexIconButton,{onClick:n?t.closeAxisTools:t.openAxisTools,iconName:l,"data-testid":"align-plane-icon",iconColor:"secondary",children:e.jsx(i.VertexIcon,{"data-testid":"align-plane-icon-chevron",name:"chevron-up",size:"sm"})})}),e.jsxs(s.VertexViewerToolbarGroup,{direction:"vertical",className:"flex justify-evenly items-center py-1 my-1 ring-1 ring-neutral-200 rounded bg-neutral-100 opacity-95",children:[e.jsx(i.VertexIconButton,{"data-testid":"align-plane-x-axis-button",className:"w-full text-neutral-800 hover:bg-neutral-300 rounded cursor-pointer mx-0.5 py-1 px-2",onClick:()=>t.updateAxis("x"),variant:"plain",iconColor:"secondary",iconName:"axis-x",children:e.jsx("div",{className:"text-base ml-2",children:"X-axis Plane"})}),e.jsx(i.VertexIconButton,{className:"w-full text-neutral-800 hover:bg-neutral-300 rounded cursor-pointer mx-0.5 py-1 px-2",variant:"plain",iconColor:"secondary",iconName:"axis-y","data-testid":"align-plane-y-axis-button",onClick:()=>t.updateAxis("y"),children:e.jsx("div",{className:"text-base ml-2",children:"Y-axis Plane"})}),e.jsx(i.VertexIconButton,{"data-testid":"align-plane-z-axis-button",className:"w-full text-neutral-800 hover:bg-neutral-300 rounded cursor-pointer mx-0.5 py-1 px-2",onClick:()=>t.updateAxis("z"),variant:"plain",iconColor:"secondary",iconName:"axis-z",children:e.jsx("div",{className:"text-base ml-2",children:"Z-axis Plane"})})]})]})}var Hs,Ws;!function(e){e.mm="millimeters",e.cm="centimeters",e.m="meters",e.in="inches",e.ft="feet"}(Hs||(Hs={})),function(e){e[e.mm=1]="mm",e[e.cm=.1]="cm",e[e.m=.001]="m",e[e.in=.03937007874015748]="in",e[e.ft=.0032808398950131233]="ft"}(Ws||(Ws={}));const convertFrom=(e,t)=>{const n=undefined;return e/Ws[t]},convertTo=(e,t)=>{const n=undefined;return e*Ws[t]},formatWithUnit=(e,t,n)=>`${e.toFixed(n)} ${t}`,formatDistance=(e,t,n)=>formatWithUnit(convertTo(e,t),t,n),createDistanceFormatter=(e,t)=>n=>formatDistance(n,e,t);function VertexViewerCrossSectionOffsetStepper({offset:t,measurementUnit:n,decimalPlaces:r,onOffsetChange:a}){const[s,l]=o.useState(convertTo(t,n));o.useEffect((()=>{l(convertTo(t,n))}),[n,t]);const c=createDistanceFormatter(n,r),handleIncrementalUpdate=e=>{const t=convertFrom(s+e,n);a(t)},handleSubmit=e=>{e.preventDefault(),a(convertFrom(s,n))},handleBlur=()=>{a(convertFrom(s,n))};return e.jsx(i.VertexTooltip,{content:"Plane Offset",children:e.jsx("form",{"data-testid":"cross-section-stepper-form",onSubmit:handleSubmit,children:e.jsxs(i.VertexTextfield,{"data-testid":"cross-section-stepper-input",className:"viewer-toolbar-input w-32 border-none ring-0 bg-white",type:"text",value:c(parseFloat(t.toFixed(3))),onInputInput:e=>{l(null!=e.detail.value?parseFloat(e.detail.value):t)},onBlur:handleBlur,children:[e.jsx("div",{"data-testid":"cross-section-stepper-decrement",className:"py-1 cursor-pointer",slot:"left",onClick:()=>handleIncrementalUpdate(-1),children:e.jsx(i.VertexIcon,{name:"chevron-left",size:"sm"})}),e.jsx("div",{"data-testid":"cross-section-stepper-increment",className:"py-1 cursor-pointer",slot:"right",onClick:()=>handleIncrementalUpdate(1),children:e.jsx(i.VertexIcon,{name:"chevron-right",size:"sm"})})]})})})}const $s=400;function VertexViewerCrossSectionPopupMenu({decimalPlaces:t,measurementUnit:n}){const r=useCrossSectioningActions(),a=Ji(Xa),l=Qi(Ya),c=Qi(Za),u=o.useRef(),d=o.useMemo((()=>"hasValue"===l.state?l.contents:Da),[l.state,l.contents]),p=o.useMemo((()=>"hasValue"===c.state?c.contents:0),[c.state,c.contents]),handleCrossSectionValueChange=e=>{clearTimeout(u.current),u.current=window.setTimeout((()=>{r.endInteraction()}),$s),r.beginInteraction(),r.updatePlanes(e)};return e.jsxs(VertexPopupButton,{"data-testid":"cross-section-popover",placement:"top",backdrop:!1,open:asBooleanAttribute(a),onDismissed:r.closeAdditionalTools,children:[e.jsx(VertexPopupButton.Anchor,{tooltipContent:"Section Tools",children:e.jsx("div",{className:"-ml-px py-1.5",children:e.jsx(i.VertexIcon,{"data-testid":"cross-section-popover-icon",name:"chevron-up",size:"sm",onClick:a?r.closeAdditionalTools:r.openAdditionalTools})})}),e.jsxs(s.VertexViewerToolbarGroup,{className:"relative bottom-3 flex justify-evenly items-center p-1 ring-1 ring-neutral-200 rounded bg-neutral-100 opacity-95",children:[e.jsx(VertexViewerCrossSectionAlignmentPopoverMenu,{}),e.jsx(i.VertexTooltip,{className:"w-auto",content:"Reverse",children:e.jsx(i.VertexIconButton,{iconName:"flip","data-testid":"viewer-toolbar-flip-button",onClick:r.flipPlanes,iconColor:"secondary"})}),e.jsx(i.VertexTooltip,{className:"w-auto",content:"Align View to Plane",children:e.jsx(i.VertexIconButton,{"data-testid":"viewer-toolbar-align-view-to-plane-button",iconName:"align-view-to-plane",onClick:r.alignViewToPlane,iconColor:"secondary"})}),e.jsx(VertexViewerToolbarDivider,{}),e.jsx(VertexViewerCrossSectionAxisPopoverMenu,{}),e.jsx(VertexSlider,{value:p,defaultValue:d.default,disabled:asBooleanAttribute("hasValue"!==l.state),min:d.min,max:d.max,step:.01,onChange:handleCrossSectionValueChange}),e.jsx("div",{className:"px-4",children:e.jsx(VertexViewerCrossSectionOffsetStepper,{decimalPlaces:t,measurementUnit:n,offset:"hasValue"===c.state?c.contents:0,onOffsetChange:handleCrossSectionValueChange})})]})]})}const VertexViewerCrossSectionButton=({decimalPlaces:t,measurementUnit:n,sectionLineWidth:o,sectionColor:r})=>{const a=useCrossSectioningActions(),s=Ji(Ba);return useSynchronizedProp(Ua,o),useSynchronizedProp(za,r),e.jsxs(e.Fragment,{children:[e.jsx(i.VertexTooltip,{content:s?"Hide Section":"Show Section",children:e.jsx(i.VertexIconButton,{"data-testid":"viewer-toolbar-cross-section-button",iconName:"cross-section",iconColor:s?"primary":"secondary",onClick:()=>s?a.disable():a.enable()})}),e.jsx(VertexViewerCrossSectionPopupMenu,{decimalPlaces:null!=t?t:2,measurementUnit:null!=n?n:"mm"})]})},VertexFitAllButton=()=>{const t=Ji(Va);return e.jsx(i.VertexTooltip,{content:"Fit All",children:e.jsx(i.VertexIconButton,{iconName:"fit-all",iconColor:"secondary","data-testid":"viewer-toolbar-fit-all-button",onClick:async()=>{const e=await(null==t?void 0:t.scene());await(null==e?void 0:e.camera().viewAll().render({animation:{milliseconds:500}}))}})})},VertexPanButton=()=>{const t=Ji(Va),n=Ji(Ca),[r,a]=ea(Na),[s,l]=ea(ka);return o.useEffect((()=>{null!=t&&n&&l(t.getBaseInteractionHandler())}),[t,n,l]),e.jsx(i.VertexTooltip,{content:"Pan",children:e.jsx(i.VertexIconButton,{iconName:"pan",iconColor:"pan"===r?"primary":"secondary","data-testid":"viewer-toolbar-pan-button",onClick:async()=>{if(a("pan"),null!=s){const e=await s;null==e||e.setPrimaryInteractionType("pan")}}})})},VertexRotateButton=()=>{const t=Ji(Va),n=Ji(Ca),[r,a]=ea(Na),[s,l]=ea(ka);return o.useEffect((()=>{null!=t&&n&&l(t.getBaseInteractionHandler())}),[t,n,l]),e.jsx(i.VertexTooltip,{content:"Rotate",children:e.jsx(i.VertexIconButton,{iconName:"rotate",iconColor:"rotate"===r?"primary":"secondary","data-testid":"viewer-toolbar-rotate-button",onClick:async()=>{if(a("rotate"),null!=s){const e=await s;null==e||e.setPrimaryInteractionType("rotate")}}})})},VertexZoomButton=()=>{const t=Ji(Va),n=Ji(Ca),[r,a]=ea(Na),[s,l]=ea(ka);return o.useEffect((()=>{null!=t&&n&&l(t.getBaseInteractionHandler())}),[t,n,l]),e.jsx(i.VertexTooltip,{content:"Zoom",children:e.jsx(i.VertexIconButton,{iconName:"zoom",iconColor:"zoom"===r?"primary":"secondary","data-testid":"viewer-toolbar-zoom-button",onClick:async()=>{if(a("zoom"),null!=s){const e=await s;null==e||e.setPrimaryInteractionType("zoom")}}})})},DefaultToolbar=()=>e.jsx(s.VertexViewerToolbar,{placement:"bottom-center",children:e.jsxs(s.VertexViewerToolbarGroup,{className:"p-1 border border-neutral-200 rounded bg-neutral-100 opacity-95",children:[e.jsx(VertexRotateButton,{}),e.jsx(VertexPanButton,{}),e.jsx(VertexZoomButton,{}),e.jsx(VertexFitAllButton,{}),e.jsx(VertexViewerToolbarDivider,{}),e.jsx(VertexBoxSelectionButton,{}),e.jsx(VertexViewerToolbarDivider,{}),e.jsx(VertexViewerCrossSectionButton,{})]})}),VertexToolbar=({children:t})=>{const n=null!=t&&!1!==t;return e.jsx(s.VertexViewerToolbar,{placement:"bottom-center",children:n?e.jsx(s.VertexViewerToolbarGroup,{className:"p-1 border border-neutral-200 rounded bg-neutral-100 opacity-95",children:t}):e.jsx(DefaultToolbar,{})})},VertexViewerSceneReset=({onReset:t})=>{const n=useCrossSectioningActions(),o=useSelectionActions(),r=useViewerSceneActions(),handleReset=async()=>{await n.disable(),await o.resetSelectionState(),null==t||t(),await r.reset()};return e.jsx(i.VertexTooltip,{content:"Reset View",children:e.jsx(i.VertexIconButton,{iconName:"reset",className:"flex bg-white opacity-70 hover:opacity-100 text-neutral-900 hover:text-neutral-700 hover:bg-neutral-200 rounded p-1 cursor-pointer","data-testid":"viewer-reset-tool-button",onClick:handleReset,variant:"plain"})})};function useViewerFrameActions(){return{frameDrawn:useActionCallback((({set:e,reset:t,snapshot:n})=>async t=>{const o=await n.getPromise(bs);e(Ia,t.detail.scene),e(bs,t.detail.scene.sceneViewSummary.selectedVisibleSummary),e(ys,o)}))}}function useCallbackRef(e){var t;const[n,r]=o.useState((t=void 0,null)),i=undefined;return{element:n,callback:o.useCallback((e=>r(e)),[])}}const VertexBoxSelectionTool=()=>{const{callback:t}=useCallbackRef(),n=useBoxSelectionActions(),o=Ji(ia);return useApplyKeyBinding({keyBind:"Shift",fn:d.useCallback((()=>n.setOperationType("select")),[]),off:d.useCallback((()=>n.setOperationType("clearAndSelect")),[])}),e.jsx(s.VertexViewerBoxQueryTool,{ref:t,"data-testid":"viewer-box-query-tool",operationType:o})};function VertexViewerCameraTypeMenu({open:t,onOpen:n,onDismiss:o,onCameraTypeChange:r}){const a=useViewerCameraActions(),s=Ji(Pa);return e.jsxs(i.VertexMenu,{"data-testid":"camera-types-popover",className:"flex",placement:"bottom-end",open:asBooleanAttribute(t),onMenuClosed:o,children:[e.jsx("div",{slot:"anchor",children:e.jsx("div",{className:ba("flex bg-white hover:opacity-100 hover:text-neutral-700 hover:bg-neutral-200 rounded",{"opacity-70 text-neutral-900":!t,"opacity-100 text-neutral-700 bg-neutral-200":t}),children:e.jsx(i.VertexTooltip,{content:"Change View",children:e.jsx(i.VertexIconButton,{"data-testid":"set-camera-mode-option",className:"p-1 cursor-pointer",variant:"plain",onClick:n,iconName:"orthographic"===s?"cube-orthographic":"cube-perspective",children:e.jsx(i.VertexIcon,{"data-testid":"change-camera-type-icon-button",name:"chevron-down",size:"sm"})})})})}),e.jsxs("div",{className:"w-36",children:[e.jsx("div",{className:"pt-1"}),e.jsxs(i.VertexMenuItem,{"data-testid":"set-perspective-view",onClick:()=>{a.updateCameraType("perspective"),null==r||r("perspective")},children:[e.jsx(i.VertexIcon,{slot:"icon","data-testid":"set-perspective-view-icon",name:"cube-perspective",size:"sm",className:ba({"text-[var(--vertex-ui-blue-700)]":"perspective"===s})}),e.jsx("div",{className:ba("ml-2 items-center",{"text-[var(--vertex-ui-blue-700)]":"perspective"===s}),children:"Perspective"})]}),e.jsxs(i.VertexMenuItem,{"data-testid":"set-orthographic-view",onClick:()=>{a.updateCameraType("orthographic"),null==r||r("orthographic")},children:[e.jsx(i.VertexIcon,{slot:"icon","data-testid":"set-orthographic-view-icon",name:"cube-orthographic",size:"sm",className:ba({"text-[var(--vertex-ui-blue-700)]":"orthographic"===s})}),e.jsx("div",{className:ba("ml-2 items-center",{"text-[var(--vertex-ui-blue-700)]":"orthographic"===s}),children:"Orthographic"})]})]})]})}const VertexViewerViewCube=n=>{var{placement:r,children:i}=n,a=t.__rest(n,["placement","children"]);const l=Array.isArray(i)?i:[i],c=l.filter((e=>!o.isValidElement(e)||e.type!==s.VertexViewerViewCube)).filter((e=>null!=e&&!1!==e)),u=l.find((e=>o.isValidElement(e)&&e.type===s.VertexViewerViewCube)),[d,p]=o.useState(!1);return e.jsxs(s.VertexViewerToolbar,{direction:"vertical","data-testid":"view-cube-toolbar",placement:null!=r?r:"top-right",children:[null!=u?u:e.jsx(s.VertexViewerViewCube,Object.assign({className:"m-7"},a)),0===c.length?e.jsxs("div",{className:"flex items-center justify-center mt-3 gap-1",children:[e.jsx(VertexViewerSceneReset,{}),e.jsx(VertexViewerCameraTypeMenu,{open:d,onDismiss:()=>p(!1),onOpen:()=>p(!0)})]}):e.jsx("div",{className:"mt-3",children:c})]})},VertexViewer=n=>{var{id:o,className:r,disableSelection:i,onTap:a,onLongpress:l,onFrameDrawn:c,onSceneReady:u,viewerRefCallback:d,children:p}=n,f=t.__rest(n,["id","className","disableSelection","onTap","onLongpress","onFrameDrawn","onSceneReady","viewerRefCallback","children"]);const h=Ji(Ts),m=useRecoilRef({state:Va}),v=useViewerCameraActions(),g=useHitActions(),b=useSelectionActions(),S=useViewerFrameActions(),[w,_]=ea(Ca),A=Ji(Pa),E=Ji(Ha),T=Ji(ra),V=null!=p&&!1!==p;return useKeyBindings(),useDefaultKeybindings(),e.jsxs(s.VertexViewer,Object.assign({id:null!=o?o:"vertex-viewer","data-testid":"vertex-viewer",ref:null!=d?d:m,className:ba("flex w-full h-full",r,{"cursor-crosshair":E.hitPending}),config:h,cameraType:w?A:void 0,onCameraTypeChanged:e=>{w&&v.updateCameraType(e.detail)},onTap:e=>{const t=[...i?[]:[b.selectCurrentHit]];g.tap(e,...t),null==a||a(e)},onLongpress:e=>{g.longPress(e),null==l||l(e)},onFrameDrawn:e=>{S.frameDrawn(e),null==c||c(e)},onSceneReady:e=>{w||_(!0),null==u||u(e)}},f,{children:[T&&e.jsx(VertexBoxSelectionTool,{}),V?p:e.jsxs(e.Fragment,{children:[e.jsx(VertexViewerViewCube,{}),e.jsx(VertexToolbar,{}),e.jsx(VertexViewerContextMenu,{})]})]}))};function toSdkConfig(e){return isOnlyNetworkConfig(e)?{network:e}:e}function isOnlyNetworkConfig(e){const t=undefined;return null!=e.renderingHost}const VertexViewerToolkitEventListener=({onHitStateChange:t,onSelectionStateChange:n})=>{const r=Ji(cs),i=Ji(ws);return o.useEffect((()=>{null==t||t(r)}),[r,t]),o.useEffect((()=>{null==n||n(i)}),[i,n]),e.jsx(e.Fragment,{})},VertexViewerToolkitRoot=n=>{var{override:r,autoDefineCustomElements:i,children:a,config:s}=n,l=t.__rest(n,["override","autoDefineCustomElements","children","config"]);return o.useEffect((()=>{(null==i||i)&&(u.defineCustomElements(),c.defineCustomElements())}),[i]),e.jsx(qi,{override:r,children:e.jsxs(e.Fragment,{children:[e.jsx(VertexViewerToolkitEventListener,Object.assign({},l)),e.jsx(VertexViewerToolkitRootConfig,{config:s,children:a})]})})},VertexViewerToolkitRootConfig=({config:t,children:n})=>{const r=ta(Ts);return o.useEffect((()=>{const e=null!=t?toSdkConfig(t):void 0;r(e)}),[t,r]),e.jsx(e.Fragment,{children:n})};var Gs=Object.freeze({__proto__:null,get AssemblyFontFace(){return Vs}});exports.CrossSection=ls,exports.Hits=us,exports.SceneTree=Gs,exports.Selection=_s,exports.VertexBoxSelectionButton=VertexBoxSelectionButton,exports.VertexContextMenu=VertexContextMenu,exports.VertexFitAllButton=VertexFitAllButton,exports.VertexFitSelectedMenuItem=VertexFitSelectedMenuItem,exports.VertexFlyToMenuItem=VertexFlyToMenuItem,exports.VertexHideAllMenuItem=VertexHideAllMenuItem,exports.VertexHidePartMenuItem=VertexHidePartMenuItem,exports.VertexHideSelectedMenuItem=VertexHideSelectedMenuItem,exports.VertexPanButton=VertexPanButton,exports.VertexResizableContent=VertexResizableContent,exports.VertexRotateButton=VertexRotateButton,exports.VertexSceneTree=VertexSceneTree,exports.VertexSceneTreeContextMenu=VertexSceneTreeContextMenu,exports.VertexSceneTreeHeader=VertexSceneTreeHeader,exports.VertexSceneTreeTableLayout=VertexSceneTreeTableLayout,exports.VertexShowAllMenuItem=VertexShowAllMenuItem,exports.VertexShowOnlyMenuItem=VertexShowOnlyMenuItem,exports.VertexShowOnlySelectedMenuItem=VertexShowOnlySelectedMenuItem,exports.VertexToolbar=VertexToolbar,exports.VertexViewer=VertexViewer,exports.VertexViewerContextMenu=VertexViewerContextMenu,exports.VertexViewerCrossSectionButton=VertexViewerCrossSectionButton,exports.VertexViewerRightOpenedPanel=VertexViewerRightOpenedPanel,exports.VertexViewerRightSidebar=VertexViewerRightSidebar,exports.VertexViewerSceneReset=VertexViewerSceneReset,exports.VertexViewerToolbarDivider=VertexViewerToolbarDivider,exports.VertexViewerToolkitRoot=VertexViewerToolkitRoot,exports.VertexViewerViewCube=VertexViewerViewCube,exports.VertexZoomButton=VertexZoomButton;
8
7
  //# sourceMappingURL=bundle.cjs.js.map