@vertexvis/viewer-toolkit-react 0.0.5-canary.4 → 0.0.5-canary.6

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,4 +1,4 @@
1
- "use strict";var e=require("react/jsx-runtime"),t=require("quick-format-unescaped"),n=require("recoil"),a=require("react"),s=require("@vertexvis/geometry"),o=require("@vertexvis/ui-react"),l=require("@vertexvis/viewer"),i=require("@vertexvis/viewer-react"),r=require("@vertexvis/ui/loader"),c=require("@vertexvis/viewer/loader");function _interopNamespaceDefault(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,a.get?a:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var u=_interopNamespaceDefault(a),extendStatics=function(e,t){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},extendStatics(e,t)};function __extends(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function __(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}var __assign=function(){return __assign=Object.assign||function __assign(e){for(var t,n=1,a=arguments.length;n<a;n++)for(var s in t=arguments[n])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},__assign.apply(this,arguments)};function __rest(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var s=0,a=Object.getOwnPropertySymbols(e);s<a.length;s++)t.indexOf(a[s])<0&&Object.prototype.propertyIsEnumerable.call(e,a[s])&&(n[a[s]]=e[a[s]]);return n}function __read(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var a=n.call(e),s,o=[],l;try{for(;(void 0===t||t-- >0)&&!(s=a.next()).done;)o.push(s.value)}catch(e){l={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(l)throw l.error}}return o}"function"==typeof SuppressedError&&SuppressedError;var d={exports:{}};const m=t;d.exports=pino;const p=pfGlobalThisOrFallback().console||{},h={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 g=Symbol("pino.logFuncs"),f=Symbol("pino.hierarchy"),v={error:"log",fatal:"error",warn:"error",info:"log",debug:"log",trace:"log"};function appendChildLogger(e,t){const n={logger:t,parent:e[f]};t[f]=n}function setupBaseLogFunctions(e,t,n){const a={};t.forEach((e=>{a[e]=n[e]?n[e]:p[e]||p[v[e]||"log"]||noop})),e[g]=a}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||p;e.browser.write&&(e.browser.asObject=!0);const a=e.serializers||{},s=shouldSerialize(e.browser.serialize,a);let o=e.browser.serialize;Array.isArray(e.browser.serialize)&&e.browser.serialize.indexOf("!stdSerializers.err")>-1&&(o=!1);const l=Object.keys(e.customLevels||{}),i=["error","fatal","warn","info","debug","trace"].concat(l);"function"==typeof n&&i.forEach((function(e){n[e]=n})),(!1===e.enabled||e.browser.disabled)&&(e.level="silent");const r=e.level||"info",c=Object.create(n);c.log||(c.log=noop),setupBaseLogFunctions(c,i,n),appendChildLogger({},c),Object.defineProperty(c,"levelVal",{get:getLevelVal}),Object.defineProperty(c,"level",{get:getLevel,set:setLevel});const u={transmit:t,serialize:s,asObject:e.browser.asObject,asObjectBindingsOnly:e.browser.asObjectBindingsOnly,formatters:e.browser.formatters,levels:i,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"),l.forEach((e=>{set(this,u,c,e)}))}function child(n,o,l){if(!o)throw new Error("missing bindings for child Pino");l=l||{},s&&o.serializers&&(l.serializers=o.serializers);const i=l.serializers;if(s&&i){var r=Object.assign({},a,i),c=!0===e.browser.serialize?Object.keys(r):s;delete o.serializers,applySerializers([o],c,r,this._stdErrSerialize)}function Child(e){this._childLevel=1+(0|e._childLevel),this.bindings=o,r&&(this.serializers=r,this._serialize=c),t&&(this._logEvent=createLogEventShape([].concat(e._logEvent.bindings,o)))}Child.prototype=this;const u=new Child(this);return appendChildLogger(this,u),u.child=function(...e){return child.call(this,n,...e)},u.level=l.level||this.level,n.onChild(u),u}return c.levels=getLevels(e),c.level=r,c.isLevelEnabled=function(e){return!!this.levels.values[e]&&this.levels.values[e]>=this.levels.values[this.level]},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=a,c._serialize=s,c._stdErrSerialize=o,c.child=function(...e){return child.call(this,u,...e)},t&&(c._logEvent=createLogEventShape()),c}function getLevels(e){const t=e.customLevels||{},n=undefined,a=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[f];for(;n.parent;)n=n.parent,n.logger.bindings&&t.push(n.logger.bindings);return t.reverse()}function set(e,t,n,a){if(Object.defineProperty(e,a,{value:levelToValue(e.level,n)>levelToValue(a,n)?noop:n[g][a],writable:!0,enumerable:!0,configurable:!0}),e[a]===noop){if(!t.transmit)return;const s=undefined,o=levelToValue(t.transmit.level||e.level,n),l=undefined;if(levelToValue(a,n)<o)return}e[a]=createWrap(e,t,n,a);const s=getBindingChain(e);0!==s.length&&(e[a]=prependBindingsInArguments(s,e[a]))}function prependBindingsInArguments(e,t){return function(){return t.apply(this,[...e,...arguments])}}function createWrap(e,t,n,a){return s=e[g][a],function LOG(){const o=t.timestamp(),l=new Array(arguments.length),i=Object.getPrototypeOf&&Object.getPrototypeOf(this)===p?p:this;for(var r=0;r<l.length;r++)l[r]=arguments[r];var c=!1;if(t.serialize&&(applySerializers(l,this._serialize,this.serializers,this._stdErrSerialize),c=!0),t.asObject||t.formatters?s.call(i,...asObject(this,a,l,o,t)):s.apply(i,l),t.transmit){const s=void 0,i=levelToValue(t.transmit.level||e._level,n),r=levelToValue(a,n);if(r<i)return;transmit(this,{ts:o,methodLevel:a,methodValue:r,transmitValue:n.levels.values[t.transmit.level||e._level],send:t.transmit.send,val:levelToValue(e._level,n)},l,c)}};var s}function asObject(e,t,n,a,s){const{level:o,log:l=e=>e}=s.formatters||{},i=n.slice();let r=i[0];const c={};let u=1+(0|e._childLevel);if(u<1&&(u=1),a&&(c.time=a),o){const n=o(t,e.levels.values[t]);Object.assign(c,n)}else c.level=e.levels.values[t];if(s.asObjectBindingsOnly){if(null!==r&&"object"==typeof r)for(;u--&&"object"==typeof i[0];)Object.assign(c,i.shift());const e=undefined;return[l(c),...i]}{if(null!==r&&"object"==typeof r){for(;u--&&"object"==typeof i[0];)Object.assign(c,i.shift());r=i.length?m(i.shift(),i):void 0}else"string"==typeof r&&(r=m(i.shift(),i));void 0!==r&&(c[s.messageKey]=r);const e=undefined;return[l(c)]}}function applySerializers(e,t,n,a){for(const s in e)if(a&&e[s]instanceof Error)e[s]=pino.stdSerializers.err(e[s]);else if("object"==typeof e[s]&&!Array.isArray(e[s])&&t)for(const a in e[s])t.indexOf(a)>-1&&a in n&&(e[s][a]=n[a](e[s][a]))}function transmit(e,t,n,a=!1){const s=t.send,o=t.ts,l=t.methodLevel,i=t.methodValue,r=t.val,c=e._logEvent.bindings;a||applySerializers(n,e._serialize||Object.keys(e.serializers),e.serializers,void 0===e._stdErrSerialize||e._stdErrSerialize),e._logEvent.ts=o,e._logEvent.messages=n.filter((function(e){return-1===c.indexOf(e)})),e._logEvent.level.label=l,e._logEvent.level.value=i,s(l,e._logEvent,r),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 b;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=h,pino.stdTimeFunctions=Object.assign({},{nullTime:nullTime,epochTime:epochTime,unixTime:unixTime,isoTime:isoTime}),d.exports.default=pino,d.exports.pino=pino;const S=(0,d.exports)({formatters:{level:e=>({level:e})}}),logger_error=(e,t)=>{null!=t?S.error(t,e):S.error(e)},logger_info=(e,t)=>{null!=t?S.info(t,e):S.info(e)},logger_warn=(e,t)=>{null!=t?S.warn(t,e):S.warn(e)},logger_debug=(e,t)=>{null!=t?S.debug(t,e):S.debug(e)};class w{}function useActionCallback(e,t=[]){const a=t instanceof w?void 0:t;return n.useRecoilCallback((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)}})}))),a)}function retainSnapshot(e){return t=>{var{snapshot:n}=t,a=__rest(t,["snapshot"]);return async(...t)=>{const s=n.retain();try{const s=undefined;return await e(Object.assign(Object.assign({},a),{snapshot:n}))(...t)}finally{s()}}}}function createGetPromiseRequiredWrapper(e){return async(t,n)=>{const a=await e.getPromise(t);if(null==a)throw null!=n?n:new Error(`No value present for required value ${t.key}`);return a}}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}}}}var C=/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/,V=/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(.+)\s*\)/,j=/^(#|0x)?([A-Fa-f0-9]{6})$/,create$2=function(e,t,n,a){return void 0===a&&(a=255),{r:e,g:t,b:n,a:a}},fromNumber=function(e){var t=16777215&e;return create$2(t>>16&255,t>>8&255,255&t)},fromHexString=function(e){var t=j.exec(e);if(null!=t)return fromNumber(parseInt(t[2],16))},fromCss=function(e){var t=C.exec(e);if(null!=t)return create$2(parseInt(t[1]),parseInt(t[2]),parseInt(t[3]));var n=V.exec(e);return null!=n?create$2(parseInt(n[1]),parseInt(n[2]),parseInt(n[3]),Math.floor(255*parseFloat(n[4]))):j.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},T=Object.freeze({__proto__:null,create:create$2,fromNumber:fromNumber,fromHexString:fromHexString,fromCss:fromCss,fromArray:fromArray,isInvisible:isInvisible,isOpaque:isOpaque,toHexString:toHexString});!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}__extends(MapperValidationError,e)}(Error);var k=function equal(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){if(e.constructor!==t.constructor)return!1;var n,a,s;if(Array.isArray(e)){if((n=e.length)!=t.length)return!1;for(a=n;0!=a--;)if(!equal(e[a],t[a]))return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if((n=(s=Object.keys(e)).length)!==Object.keys(t).length)return!1;for(a=n;0!=a--;)if(!Object.prototype.hasOwnProperty.call(t,s[a]))return!1;for(a=n;0!=a--;){var o=s[a];if(!equal(e[o],t[o]))return!1}return!0}return e!=e&&t!=t};
1
+ "use strict";var e=require("react/jsx-runtime"),t=require("quick-format-unescaped"),n=require("recoil"),a=require("react"),s=require("@vertexvis/geometry"),o=require("@vertexvis/ui-react"),l=require("@vertexvis/viewer"),i=require("@vertexvis/viewer-react"),r=require("@vertexvis/ui/loader"),c=require("@vertexvis/viewer/loader");function _interopNamespaceDefault(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,a.get?a:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var u=_interopNamespaceDefault(a),extendStatics=function(e,t){return extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},extendStatics(e,t)};function __extends(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function __(){this.constructor=e}extendStatics(e,t),e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}var __assign=function(){return __assign=Object.assign||function __assign(e){for(var t,n=1,a=arguments.length;n<a;n++)for(var s in t=arguments[n])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},__assign.apply(this,arguments)};function __rest(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var s=0,a=Object.getOwnPropertySymbols(e);s<a.length;s++)t.indexOf(a[s])<0&&Object.prototype.propertyIsEnumerable.call(e,a[s])&&(n[a[s]]=e[a[s]]);return n}function __read(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var a=n.call(e),s,o=[],l;try{for(;(void 0===t||t-- >0)&&!(s=a.next()).done;)o.push(s.value)}catch(e){l={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(l)throw l.error}}return o}"function"==typeof SuppressedError&&SuppressedError;var d={exports:{}};const m=t;d.exports=pino;const p=pfGlobalThisOrFallback().console||{},h={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 g=Symbol("pino.logFuncs"),f=Symbol("pino.hierarchy"),v={error:"log",fatal:"error",warn:"error",info:"log",debug:"log",trace:"log"};function appendChildLogger(e,t){const n={logger:t,parent:e[f]};t[f]=n}function setupBaseLogFunctions(e,t,n){const a={};t.forEach((e=>{a[e]=n[e]?n[e]:p[e]||p[v[e]||"log"]||noop})),e[g]=a}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||p;e.browser.write&&(e.browser.asObject=!0);const a=e.serializers||{},s=shouldSerialize(e.browser.serialize,a);let o=e.browser.serialize;Array.isArray(e.browser.serialize)&&e.browser.serialize.indexOf("!stdSerializers.err")>-1&&(o=!1);const l=Object.keys(e.customLevels||{}),i=["error","fatal","warn","info","debug","trace"].concat(l);"function"==typeof n&&i.forEach((function(e){n[e]=n})),(!1===e.enabled||e.browser.disabled)&&(e.level="silent");const r=e.level||"info",c=Object.create(n);c.log||(c.log=noop),setupBaseLogFunctions(c,i,n),appendChildLogger({},c),Object.defineProperty(c,"levelVal",{get:getLevelVal}),Object.defineProperty(c,"level",{get:getLevel,set:setLevel});const u={transmit:t,serialize:s,asObject:e.browser.asObject,asObjectBindingsOnly:e.browser.asObjectBindingsOnly,formatters:e.browser.formatters,levels:i,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"),l.forEach((e=>{set(this,u,c,e)}))}function child(n,o,l){if(!o)throw new Error("missing bindings for child Pino");l=l||{},s&&o.serializers&&(l.serializers=o.serializers);const i=l.serializers;if(s&&i){var r=Object.assign({},a,i),c=!0===e.browser.serialize?Object.keys(r):s;delete o.serializers,applySerializers([o],c,r,this._stdErrSerialize)}function Child(e){this._childLevel=1+(0|e._childLevel),this.bindings=o,r&&(this.serializers=r,this._serialize=c),t&&(this._logEvent=createLogEventShape([].concat(e._logEvent.bindings,o)))}Child.prototype=this;const u=new Child(this);return appendChildLogger(this,u),u.child=function(...e){return child.call(this,n,...e)},u.level=l.level||this.level,n.onChild(u),u}return c.levels=getLevels(e),c.level=r,c.isLevelEnabled=function(e){return!!this.levels.values[e]&&this.levels.values[e]>=this.levels.values[this.level]},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=a,c._serialize=s,c._stdErrSerialize=o,c.child=function(...e){return child.call(this,u,...e)},t&&(c._logEvent=createLogEventShape()),c}function getLevels(e){const t=e.customLevels||{},n=undefined,a=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[f];for(;n.parent;)n=n.parent,n.logger.bindings&&t.push(n.logger.bindings);return t.reverse()}function set(e,t,n,a){if(Object.defineProperty(e,a,{value:levelToValue(e.level,n)>levelToValue(a,n)?noop:n[g][a],writable:!0,enumerable:!0,configurable:!0}),e[a]===noop){if(!t.transmit)return;const s=undefined,o=levelToValue(t.transmit.level||e.level,n),l=undefined;if(levelToValue(a,n)<o)return}e[a]=createWrap(e,t,n,a);const s=getBindingChain(e);0!==s.length&&(e[a]=prependBindingsInArguments(s,e[a]))}function prependBindingsInArguments(e,t){return function(){return t.apply(this,[...e,...arguments])}}function createWrap(e,t,n,a){return s=e[g][a],function LOG(){const o=t.timestamp(),l=new Array(arguments.length),i=Object.getPrototypeOf&&Object.getPrototypeOf(this)===p?p:this;for(var r=0;r<l.length;r++)l[r]=arguments[r];var c=!1;if(t.serialize&&(applySerializers(l,this._serialize,this.serializers,this._stdErrSerialize),c=!0),t.asObject||t.formatters?s.call(i,...asObject(this,a,l,o,t)):s.apply(i,l),t.transmit){const s=void 0,i=levelToValue(t.transmit.level||e._level,n),r=levelToValue(a,n);if(r<i)return;transmit(this,{ts:o,methodLevel:a,methodValue:r,transmitValue:n.levels.values[t.transmit.level||e._level],send:t.transmit.send,val:levelToValue(e._level,n)},l,c)}};var s}function asObject(e,t,n,a,s){const{level:o,log:l=e=>e}=s.formatters||{},i=n.slice();let r=i[0];const c={};let u=1+(0|e._childLevel);if(u<1&&(u=1),a&&(c.time=a),o){const n=o(t,e.levels.values[t]);Object.assign(c,n)}else c.level=e.levels.values[t];if(s.asObjectBindingsOnly){if(null!==r&&"object"==typeof r)for(;u--&&"object"==typeof i[0];)Object.assign(c,i.shift());const e=undefined;return[l(c),...i]}{if(null!==r&&"object"==typeof r){for(;u--&&"object"==typeof i[0];)Object.assign(c,i.shift());r=i.length?m(i.shift(),i):void 0}else"string"==typeof r&&(r=m(i.shift(),i));void 0!==r&&(c[s.messageKey]=r);const e=undefined;return[l(c)]}}function applySerializers(e,t,n,a){for(const s in e)if(a&&e[s]instanceof Error)e[s]=pino.stdSerializers.err(e[s]);else if("object"==typeof e[s]&&!Array.isArray(e[s])&&t)for(const a in e[s])t.indexOf(a)>-1&&a in n&&(e[s][a]=n[a](e[s][a]))}function transmit(e,t,n,a=!1){const s=t.send,o=t.ts,l=t.methodLevel,i=t.methodValue,r=t.val,c=e._logEvent.bindings;a||applySerializers(n,e._serialize||Object.keys(e.serializers),e.serializers,void 0===e._stdErrSerialize||e._stdErrSerialize),e._logEvent.ts=o,e._logEvent.messages=n.filter((function(e){return-1===c.indexOf(e)})),e._logEvent.level.label=l,e._logEvent.level.value=i,s(l,e._logEvent,r),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 b;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=h,pino.stdTimeFunctions=Object.assign({},{nullTime:nullTime,epochTime:epochTime,unixTime:unixTime,isoTime:isoTime}),d.exports.default=pino,d.exports.pino=pino;const S=(0,d.exports)({formatters:{level:e=>({level:e})}}),logger_error=(e,t)=>{null!=t?S.error(t,e):S.error(e)},logger_info=(e,t)=>{null!=t?S.info(t,e):S.info(e)},logger_warn=(e,t)=>{null!=t?S.warn(t,e):S.warn(e)},logger_debug=(e,t)=>{null!=t?S.debug(t,e):S.debug(e)};class w{}function useActionCallback(e,t=[]){const a=t instanceof w?void 0:t;return n.useRecoilCallback((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)}})}))),a)}function retainSnapshot(e){return t=>{var{snapshot:n}=t,a=__rest(t,["snapshot"]);return async(...t)=>{const s=n.retain();try{const s=undefined;return await e(Object.assign(Object.assign({},a),{snapshot:n}))(...t)}finally{s()}}}}function createGetPromiseRequiredWrapper(e){return async(t,n)=>{const a=await e.getPromise(t);if(null==a)throw null!=n?n:new Error(`No value present for required value ${t.key}`);return a}}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}}}}var V=/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/,C=/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(.+)\s*\)/,j=/^(#|0x)?([A-Fa-f0-9]{6})$/,create$2=function(e,t,n,a){return void 0===a&&(a=255),{r:e,g:t,b:n,a:a}},fromNumber=function(e){var t=16777215&e;return create$2(t>>16&255,t>>8&255,255&t)},fromHexString=function(e){var t=j.exec(e);if(null!=t)return fromNumber(parseInt(t[2],16))},fromCss=function(e){var t=V.exec(e);if(null!=t)return create$2(parseInt(t[1]),parseInt(t[2]),parseInt(t[3]));var n=C.exec(e);return null!=n?create$2(parseInt(n[1]),parseInt(n[2]),parseInt(n[3]),Math.floor(255*parseFloat(n[4]))):j.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},T=Object.freeze({__proto__:null,create:create$2,fromNumber:fromNumber,fromHexString:fromHexString,fromCss:fromCss,fromArray:fromArray,isInvisible:isInvisible,isOpaque:isOpaque,toHexString:toHexString});!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}__extends(MapperValidationError,e)}(Error);var k=function equal(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){if(e.constructor!==t.constructor)return!1;var n,a,s;if(Array.isArray(e)){if((n=e.length)!=t.length)return!1;for(a=n;0!=a--;)if(!equal(e[a],t[a]))return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if((n=(s=Object.keys(e)).length)!==Object.keys(t).length)return!1;for(a=n;0!=a--;)if(!Object.prototype.hasOwnProperty.call(t,s[a]))return!1;for(a=n;0!=a--;){var o=s[a];if(!equal(e[o],t[o]))return!1}return!0}return e!=e&&t!=t};
2
2
  /*!
3
3
  * isobject <https://github.com/jonschlinkert/isobject>
4
4
  *
@@ -10,10 +10,10 @@
10
10
  *
11
11
  * Copyright (c) 2014-2017, Jon Schlinkert.
12
12
  * Released under the MIT License.
13
- */function isObjectObject(e){return!0===isObject(e)&&"[object Object]"===Object.prototype.toString.call(e)}function isPlainObject$1(e){var t,n;return!1!==isObjectObject(e)&&("function"==typeof(t=e.constructor)&&(!1!==isObjectObject(n=t.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf")))}function defaults(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=__read(e),a=n[0],s=n.slice(1),o=__assign({},a);if(0===s.length)return o;if(1===s.length){var l=s[0];for(var i in l)null==o[i]?o[i]=l[i]:isPlainObject(o[i])&&(o[i]=defaults(o[i],l[i]));return o}return s.reduce((function(e,t){return defaults(e,t)}),a)}function isPlainObject(e){return isPlainObject$1(e)}function isEqual$1(e,t){return k(e,t)}function toPairs(e){return null!=e?Object.keys(e).map((function(t){return[t,e[t]]})):[]}function fromPairs(e){return Array.isArray(e)?e.reduce((function(e,t){var n;return null!=t?__assign(__assign({},e),((n={})[t[0]]=t[1],n)):e}),{}):{}}var A=Object.freeze({__proto__:null,defaults:defaults,isPlainObject:isPlainObject,isEqual:isEqual$1,toPairs:toPairs,fromPairs:fromPairs}),P,E=new Uint8Array(16);function rng(){if(!P&&!(P="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 P(E)}var I=/^(?:[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&&I.test(e)}for(var R=[],N=0;N<256;++N)R.push((N+256).toString(16).substr(1));function stringify(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(R[e[t+0]]+R[e[t+1]]+R[e[t+2]]+R[e[t+3]]+"-"+R[e[t+4]]+R[e[t+5]]+"-"+R[e[t+6]]+R[e[t+7]]+"-"+R[e[t+8]]+R[e[t+9]]+"-"+R[e[t+10]]+R[e[t+11]]+R[e[t+12]]+R[e[t+13]]+R[e[t+14]]+R[e[t+15]]).toLowerCase();if(!validate(n))throw TypeError("Stringified UUID is invalid");return n}function v4(e,t,n){var a=(e=e||{}).random||(e.rng||rng)();return a[6]=15&a[6]|64,a[8]=63&a[8]|128,stringify(a)}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,a="string"==typeof t?BigInt(t):t,s=digits(n>>BigInt(32),BigInt(8)),o=digits(n>>BigInt(16),BigInt(4)),l=digits(n,BigInt(4)),i=digits(a>>BigInt(48),BigInt(4)),r=digits(a,BigInt(12));return"".concat(s,"-").concat(o,"-").concat(l,"-").concat(i,"-").concat(r)}function toMsbLsb(e){var t=__read(e.split("-"),5),n=t[0],a=t[1],s=t[2],o=t[3],l=t[4];if(null==n||null==a||null==s||null==o||null==l)throw new Error("Invalid UUID string ".concat(e));var i=BigInt.asIntN(64,BigInt("0x".concat(n+a+s))),r=BigInt.asIntN(64,BigInt("0x".concat(o+l)));return{msb:i.toString(),lsb:r.toString()}}var O=Object.freeze({__proto__:null,create:create$1,fromMsbLsb:fromMsbLsb,toMsbLsb:toMsbLsb});const M=n.atom({key:"viewerToolkitViewerElement",default:void 0,dangerouslyAllowMutability:!0}),L=n.atom({key:"viewerElementId",default:"vertex-viewer"}),B=n.atom({key:"viewerInitialSceneReady",default:!1}),_=n.atom({key:"viewerBaseInteractionHandlerProvider",default:Promise.resolve(void 0),dangerouslyAllowMutability:!0}),D=n.atom({key:"viewerPrimaryInteractionType",default:"rotate"}),F=n.atom({key:"viewerSceneViewId",default:void 0}),H=n.selector({key:"viewerScene",get:({get:e})=>async()=>{var t;return null===(t=e(M))||void 0===t?void 0:t.scene()},dangerouslyAllowMutability:!0}),U=n.atom({key:"viewerFrameScene",default:void 0,dangerouslyAllowMutability:!0}),W=n.selector({key:"viewerSceneVisibleBoundingBox",get:({get:e})=>{var t;return null===(t=e(U))||void 0===t?void 0:t.boundingBox}});function useViewerSceneActions(){const e=useActionCallback((({snapshot:e})=>async(t,n,...a)=>{const s=await e.getPromise(H),o=await s();a.length>0&&await(null==o?void 0:o.items((e=>a.map((t=>t(e))))).execute({suppliedCorrelationId:n}))})),t=a.useCallback(((...e)=>t=>t.where((t=>t.withItemIds(e))).select()),[]),n=a.useCallback(((...e)=>t=>t.where((t=>t.withItemIds(e))).deselect()),[]),s=a.useCallback((e=>e.where((e=>e.all())).deselect()),[]);return{executeWithCorrelationId:e,execute:useActionCallback((()=>async(t,...n)=>{const a=O.create();await e(t,a,...n)})),selectItemsTransform:t,deselectItemsTransform:n,clearSelectionTransform:s,reset:useActionCallback((({snapshot:e})=>async t=>{const n=await e.getPromiseRequired(H),a=await n(),s=await e.getPromiseRequired(K);null==a||a.reset({includeCamera:!0,suppliedCorrelationId:t,cameraTypeOverride:s})}))}}const G=500;function useViewerCameraActions(){return{flyToById:useActionCallback((({snapshot:e})=>async(t,n)=>{const a=await e.getPromise(H),s=await a();await(null==s?void 0:s.camera().flyTo({itemId:t}).render({animation:{milliseconds:null!=n?n:G}}))})),flyToByBoundingBox:useActionCallback((({snapshot:e})=>async(t,n)=>{const a=await e.getPromise(H),s=await a();await(null==s?void 0:s.camera().flyTo({boundingBox:t}).render({animation:{milliseconds:null!=n?n:G}}))})),updateCameraType:useActionCallback((({set:e})=>t=>{e(K,t)}))}}const K=n.atom({key:"viewerCameraType",default:"perspective"});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}}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(s.Vector3.left(),-e),y=e=>create(s.Vector3.down(),-e),z=e=>create(s.Vector3.forward(),-e),getAxis=(e,t)=>{switch(e){case"x":return xAxis(t);case"y":return yAxis(t);case"z":return zAxis(t)}},q={x:s.Vector3.left(),y:s.Vector3.down(),z:s.Vector3.forward()},xAxis=e=>e.x,yAxis=e=>e.y||s.Vector3.create(e.x.z,e.x.x,e.x.y),zAxis=e=>e.z||s.Vector3.create(e.x.y,e.x.z,e.x.x),axis=(e,t,n,a)=>e&&e.normal&&[["x",t],["y",n],["z",a]].filter((t=>0===s.Vector3.magnitude(s.Vector3.cross(e.normal,t[1])))).map((e=>e[0])).pop(),isNegativeNormal=e=>s.Vector3.dot(s.Vector3.create(-1,-1,-1),e.normal)>0,towardsVector=(e,t)=>{const n=undefined;return s.Vector3.dot(e,t.normal)<0?invert(t):t},towardsCamera=(e,t)=>towardsVector(e.viewVector,t),invert=e=>Object.assign(Object.assign({},e),{normal:s.Vector3.multiply(e.normal,s.Vector3.create(-1,-1,-1)),offset:-e.offset}),fromHit=(e,t)=>{const n=s.Vector3.normalize(e.normal),a=s.Vector3.dot(n,e.position);return towardsCamera(t,create(n,a))},toAxis=(e,t,n,a,o)=>{const l=n.viewAll(),i=getAxis(e,t),r=null!=a&&null!=i?create(i,s.Vector3.dot(i,o||s.BoundingBox.center(a))):forAxis(e,l.lookAt[e]);return towardsCamera(n,r)};function corners(e){return[s.Vector3.create(e.min.x,e.min.y,e.min.z),s.Vector3.create(e.min.x,e.min.y,e.max.z),s.Vector3.create(e.min.x,e.max.y,e.min.z),s.Vector3.create(e.min.x,e.max.y,e.max.z),s.Vector3.create(e.max.x,e.max.y,e.max.z),s.Vector3.create(e.max.x,e.max.y,e.min.z),s.Vector3.create(e.max.x,e.min.y,e.max.z),s.Vector3.create(e.max.x,e.min.y,e.min.z)]}function equals(e,t){return e.min.x===t.min.x&&e.min.y===t.min.y&&e.min.z===t.min.z&&e.max.x===t.max.x&&e.max.y===t.max.y&&e.max.z===t.max.z}const Y="#999999",X=1,Z={default:5,min:0,max:10},J=n.atom({key:"crossSectioningEnabled",default:!1}),Q=n.atom({key:"crossSectioningHighlightColor",default:Y}),ee=n.atom({key:"crossSectioningBorderWidth",default:1}),te=n.atom({key:"crossSectioningPlanes",default:[]}),ne=n.atom({key:"crossSectioningAlignment",default:{mode:"global",hitPending:!1}}),ae=n.selector({key:"crossSectioningTargetBoundingBox",get:async({get:e})=>{const t=undefined;return e(W)}}),se=n.atom({key:"crossSectioningIsInteractive",default:!1}),oe=n.atom({key:"crossSectioningActiveAxis",default:"x"}),le=n.atom({key:"crossSectioningAvailableAxes",default:q}),ie=n.selector({key:"crossSectioningOffsetScalar",get:({get:e})=>{const t=e(te);return t.length>0&&isNegativeNormal(t[0])?-1:1}}),re=n.selector({key:"crossSectioningSliderRange",get:({get:e})=>{const t=e(te),n=e(ae),a=null!=n?corners(n):[];if(t.length>0){const e=a.map((e=>s.Vector3.dot(e,isNegativeNormal(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 Z}}),ce=n.selector({key:"crossSectioningPlaneDisplayOffset",get:({get:e})=>{const t=e(te),n=e(ie),a=e(re);return t.length>0?t[0].offset*n:a.default}}),ue=n.atom({key:"crossSectioningAdditionalToolsOpen",default:!1}),de=n.atom({key:"crossSectioningAlignmentToolsOpen",default:!1}),me=n.atom({key:"crossSectioningAxisToolsOpen",default:!1}),pe=n.atom({key:"crossSectioningInteractionHandler",default:new $,dangerouslyAllowMutability:!0});function useCrossSectioning(e,t){const s=n.useRecoilValue(pe);a.useEffect((()=>{t&&(null==e||e.registerInteractionHandler(s))}),[e,t,s])}const xe=n.atom({key:"hitResultsTapDetails",default:void 0}),he=n.atom({key:"hitResultsLongPressDetails",default:void 0}),ge=n.atom({key:"previousHitResult",default:void 0}),fe=n.atom({key:"currentHitResult",default:void 0}),ve=n.selector({key:"hitResult",get:async({get:e})=>{var t,n,a,o,l,i,r,c;const u=e(xe),d=e(he),m=null!=u?u:d,p=e(H),h=await p(),g=null==h?void 0:h.sceneViewId,f=null==h?void 0:h.raycaster();if(null!=m&&null!=f&&null!=g){const e=await f.hitItems(m.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===(a=null==u?void 0:u.hitNormal)||void 0===a?void 0:a.y)||0,(null===(o=null==u?void 0:u.hitNormal)||void 0===o?void 0:o.z)||0),position:s.Vector3.create((null===(l=null==u?void 0:u.hitPoint)||void 0===l?void 0:l.x)||0,(null===(i=null==u?void 0:u.hitPoint)||void 0===i?void 0:i.y)||0,(null===(r=null==u?void 0:u.hitPoint)||void 0===r?void 0:r.z)||0),meta:m.metaKey||m.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})))||[]}}}}),ye=n.atom({key:"hitResultsSkipNextTap",default:!1}),alignToNormal=(e,t,n)=>{if(e.toFrameCamera().isPerspective()){const n=s.Vector3.dot(s.Vector3.normalize(e.up),t),a=Math.abs(n)>.98?s.Vector3.normalize(s.Vector3.scale(-n,e.viewVector)):e.up,o=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:a,position:o})}{const a=s.Vector3.angleTo(s.Vector3.normalize(e.viewVector),t),o=null!=n?s.BoundingBox.center(n):e.lookAt,l=s.Vector3.normalize(s.Vector3.cross(s.Vector3.normalize(e.viewVector),t));return e.rotateAroundAxisAtPoint(a,o,l)}};function isParallelTo(e,t){const n=s.Angle.toDegrees(s.Vector3.angleTo(e,t));return 0===n||180===n}const be=500;function useCrossSectioningActions(){const e=useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromise(ee),n=await e.getPromise(Q),a=await e.getPromise(te),s=await e.getPromise(H),o=await s();await(null==o?void 0:o.crossSectioning().update({sectionPlanes:a,highlightColor:n?T.fromHexString(n):void 0,lineWidth:t}))})),t=useActionCallback((({set:t,reset:n,snapshot:a})=>async()=>{const s=await a.getPromise(H),o=await s();if(null!=o){const a=o.camera().viewAll();n(le),t(te,[towardsCamera(o.camera(),x(a.lookAt.x))]),await e()}})),n=useActionCallback(retainSnapshot((({snapshot:t,set:n})=>async()=>{const a=await t.tryGetPromise(ve).then((e=>e.value)),s=await t.getPromise(H),o=await s();if(null!=a&&null!=o){const t=fromHit(a,o.camera());n(te,null!=t?[t]:[]),n(le,null!=t?{x:t.normal}:q),await e()}}))),a=useActionCallback((({set:e,snapshot:n})=>async()=>{const a=await n.getPromise(te),s=undefined;await n.getPromise(J)||(e(J,!0),0===a.length&&await t())})),o=useActionCallback((({reset:t,snapshot:n})=>async()=>{const a=undefined;await n.getPromise(J)&&(t(J),t(ue),t(de),t(me),t(te),t(ne),t(oe),await e())}));return{enable:a,disable:o,reapply:useActionCallback((({snapshot:t})=>async()=>{const n=undefined;await t.getPromise(J)&&await e()})),openAdditionalTools:useActionCallback((({set:e,snapshot:t})=>async()=>{const n=undefined;await t.getPromise(J)||await a(),e(ue,!0)})),closeAdditionalTools:useActionCallback((({reset:e})=>()=>{e(ue)})),openAlignmentTools:useActionCallback((({set:e,reset:t})=>()=>{t(me),e(de,!0)})),closeAlignmentTools:useActionCallback((({reset:e})=>()=>{e(de)})),openAxisTools:useActionCallback((({set:e,reset:t})=>()=>{t(de),e(me,!0)})),closeAxisTools:useActionCallback((({reset:e})=>()=>{e(me)})),beginInteraction:useActionCallback((({set:e,snapshot:t})=>async()=>{const n=await t.getPromise(pe);e(se,!0),await n.beginInteraction()})),endInteraction:useActionCallback((({reset:e,snapshot:t})=>async()=>{const n=await t.getPromise(pe);e(se),await n.endInteraction()})),updatePlanes:useActionCallback(retainSnapshot((({set:t,snapshot:n})=>async a=>{const s=await n.getPromise(te);if(s.length>0){const o=await n.getPromise(ie),l=await n.getPromise(re),i=o<0?-1*l.max:l.min,r=o<0?-1*l.min:l.max,c=s.map((e=>Object.assign(Object.assign({},e),{offset:Math.min(Math.max(a*o,i),r)})));t(te,c),await e()}}))),flipPlanes:useActionCallback((({set:t,snapshot:n})=>async()=>{const a=await n.getPromise(te);t(te,a.map((e=>invert(e)))),await e()})),alignViewToPlane:useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromise(te),n=await e.getPromise(M),a=await(null==n?void 0:n.scene());t.length>0&&null!=a&&await alignToNormal(a.camera(),t[0].normal,a.boundingBox()).render({animation:{milliseconds:be}})})),updateAxis:useActionCallback(retainSnapshot((({set:t,reset:n,snapshot:a})=>async o=>{const l=await a.getPromise(te),i=await a.getPromise(le),r=await a.getPromise(ae),c=await a.getPromise(ne),u=await a.getPromise(M),d=await(null==u?void 0:u.scene()),m=i[o],p=null!=m&&l.length>0&&isParallelTo(l[0].normal,m)&&!isNaN(s.Vector3.angleTo(l[0].normal,m));if(null!=d&&!p){const e=await a.tryGetPromise(ve).then((e=>e.value));t(oe,o),t(te,[toAxis(o,i,d.camera(),r,"global"!==c.mode?null==e?void 0:e.position:void 0)])}n(me),await e()}))),updateAlignment:useActionCallback((({set:e,reset:s})=>async(o,l)=>{s(de),e(ne,{mode:o,hitPending:"global"!==o&&null==l}),"global"===o?(s(oe),s(le),await t()):"surface"===o&&null!=l&&(await a(),await n())})),sectionCurrentHit:useActionCallback((({set:e,snapshot:t})=>async()=>{const a=await t.getPromise(ne);a.hitPending&&(e(ne,Object.assign(Object.assign({},a),{hitPending:!1})),"surface"===a.mode&&await n())})),cancelCurrentHit:useActionCallback((({set:e,snapshot:t})=>async()=>{const n=await t.getPromise(ne);n.hitPending&&e(ne,Object.assign(Object.assign({},n),{hitPending:!1}))}))}}var Se=Object.freeze({__proto__:null,DEFAULT_ALIGN_TO_PLANE_ANIMATION_DURATION_MS:be,DEFAULT_CROSS_SECTION_HIGHLIGHT_COLOR:Y,DEFAULT_CROSS_SECTION_LINE_THICKNESS_VALUE:1,DEFAULT_SLIDER_RANGE:Z,crossSectioningActiveAxis:oe,crossSectioningAdditionalToolsOpen:ue,crossSectioningAlignment:ne,crossSectioningAlignmentToolsOpen:de,crossSectioningAvailableAxes:le,crossSectioningAxisToolsOpen:me,crossSectioningBorderWidth:ee,crossSectioningEnabled:J,crossSectioningHighlightColor:Q,crossSectioningInteractionHandler:pe,crossSectioningIsInteractive:se,crossSectioningOffsetScalar:ie,crossSectioningPlaneDisplayOffset:ce,crossSectioningPlanes:te,crossSectioningSliderRange:re,crossSectioningTargetBoundingBox:ae,useCrossSectioning:useCrossSectioning,useCrossSectioningActions:useCrossSectioningActions});function useDebouncedCallback(e,t){const[n,s]=a.useState();return a.useEffect((()=>()=>{null!=n&&clearTimeout(n)}),[e,t,n]),a.useCallback((a=>{const handler=()=>{e(a)};null!=n&&clearTimeout(n),s(setTimeout(handler,t))}),[e,t,n])}const VertexColorPicker=t=>{var{onInput:n}=t,s=__rest(t,["onInput"]);const l=useDebouncedCallback((e=>{null==n||n(e)}),500),i=a.useCallback((e=>{const t=e.target;l(t.value)}),[l]);return e.jsx(o.VertexColorPicker,Object.assign({onInput:i},s))},VertexCrossSectionAppearanceColorPicker=({onUpdate:t})=>{const a=useCrossSectioningActions(),[s,o]=n.useRecoilState(Q);return e.jsx(VertexColorPicker,{"data-testid":"cross-section-highlight-color-picker",value:s,onValueChanged:e=>{null==t||t(e.detail)},onInput:async e=>{o(e),await a.reapply()}})};var we={exports:{}},Ce;
13
+ */function isObjectObject(e){return!0===isObject(e)&&"[object Object]"===Object.prototype.toString.call(e)}function isPlainObject$1(e){var t,n;return!1!==isObjectObject(e)&&("function"==typeof(t=e.constructor)&&(!1!==isObjectObject(n=t.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf")))}function defaults(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=__read(e),a=n[0],s=n.slice(1),o=__assign({},a);if(0===s.length)return o;if(1===s.length){var l=s[0];for(var i in l)null==o[i]?o[i]=l[i]:isPlainObject(o[i])&&(o[i]=defaults(o[i],l[i]));return o}return s.reduce((function(e,t){return defaults(e,t)}),a)}function isPlainObject(e){return isPlainObject$1(e)}function isEqual$1(e,t){return k(e,t)}function toPairs(e){return null!=e?Object.keys(e).map((function(t){return[t,e[t]]})):[]}function fromPairs(e){return Array.isArray(e)?e.reduce((function(e,t){var n;return null!=t?__assign(__assign({},e),((n={})[t[0]]=t[1],n)):e}),{}):{}}var A=Object.freeze({__proto__:null,defaults:defaults,isPlainObject:isPlainObject,isEqual:isEqual$1,toPairs:toPairs,fromPairs:fromPairs}),P,E=new Uint8Array(16);function rng(){if(!P&&!(P="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 P(E)}var I=/^(?:[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&&I.test(e)}for(var R=[],N=0;N<256;++N)R.push((N+256).toString(16).substr(1));function stringify(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(R[e[t+0]]+R[e[t+1]]+R[e[t+2]]+R[e[t+3]]+"-"+R[e[t+4]]+R[e[t+5]]+"-"+R[e[t+6]]+R[e[t+7]]+"-"+R[e[t+8]]+R[e[t+9]]+"-"+R[e[t+10]]+R[e[t+11]]+R[e[t+12]]+R[e[t+13]]+R[e[t+14]]+R[e[t+15]]).toLowerCase();if(!validate(n))throw TypeError("Stringified UUID is invalid");return n}function v4(e,t,n){var a=(e=e||{}).random||(e.rng||rng)();return a[6]=15&a[6]|64,a[8]=63&a[8]|128,stringify(a)}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,a="string"==typeof t?BigInt(t):t,s=digits(n>>BigInt(32),BigInt(8)),o=digits(n>>BigInt(16),BigInt(4)),l=digits(n,BigInt(4)),i=digits(a>>BigInt(48),BigInt(4)),r=digits(a,BigInt(12));return"".concat(s,"-").concat(o,"-").concat(l,"-").concat(i,"-").concat(r)}function toMsbLsb(e){var t=__read(e.split("-"),5),n=t[0],a=t[1],s=t[2],o=t[3],l=t[4];if(null==n||null==a||null==s||null==o||null==l)throw new Error("Invalid UUID string ".concat(e));var i=BigInt.asIntN(64,BigInt("0x".concat(n+a+s))),r=BigInt.asIntN(64,BigInt("0x".concat(o+l)));return{msb:i.toString(),lsb:r.toString()}}var O=Object.freeze({__proto__:null,create:create$1,fromMsbLsb:fromMsbLsb,toMsbLsb:toMsbLsb});const M=n.atom({key:"viewerToolkitViewerElement",default:void 0,dangerouslyAllowMutability:!0}),L=n.atom({key:"viewerElementId",default:"vertex-viewer"}),B=n.atom({key:"viewerInitialSceneReady",default:!1}),_=n.atom({key:"viewerBaseInteractionHandlerProvider",default:Promise.resolve(void 0),dangerouslyAllowMutability:!0}),D=n.atom({key:"viewerPrimaryInteractionType",default:"rotate"}),F=n.atom({key:"viewerSceneViewId",default:void 0}),H=n.selector({key:"viewerScene",get:({get:e})=>async()=>{var t;return null===(t=e(M))||void 0===t?void 0:t.scene()},dangerouslyAllowMutability:!0}),U=n.atom({key:"viewerFrameScene",default:void 0,dangerouslyAllowMutability:!0}),W=n.selector({key:"viewerSceneVisibleBoundingBox",get:({get:e})=>{var t;return null===(t=e(U))||void 0===t?void 0:t.boundingBox}});function useViewerSceneActions(){const e=useActionCallback((({snapshot:e})=>async(t,n,...a)=>{const s=await e.getPromise(H),o=await s();a.length>0&&await(null==o?void 0:o.items((e=>a.map((t=>t(e))))).execute({suppliedCorrelationId:n}))})),t=a.useCallback(((...e)=>t=>t.where((t=>t.withItemIds(e))).select()),[]),n=a.useCallback(((...e)=>t=>t.where((t=>t.withItemIds(e))).deselect()),[]),s=a.useCallback((e=>e.where((e=>e.all())).deselect()),[]);return{executeWithCorrelationId:e,execute:useActionCallback((()=>async(t,...n)=>{const a=O.create();await e(t,a,...n)})),selectItemsTransform:t,deselectItemsTransform:n,clearSelectionTransform:s,reset:useActionCallback((({snapshot:e})=>async t=>{const n=await e.getPromiseRequired(H),a=await n(),s=await e.getPromiseRequired(K);null==a||a.reset({includeCamera:!0,suppliedCorrelationId:t,cameraTypeOverride:s})}))}}const G=500;function useViewerCameraActions(){return{flyToById:useActionCallback((({snapshot:e})=>async(t,n)=>{const a=await e.getPromise(H),s=await a();await(null==s?void 0:s.camera().flyTo({itemId:t}).render({animation:{milliseconds:null!=n?n:G}}))})),flyToByBoundingBox:useActionCallback((({snapshot:e})=>async(t,n)=>{const a=await e.getPromise(H),s=await a();await(null==s?void 0:s.camera().flyTo({boundingBox:t}).render({animation:{milliseconds:null!=n?n:G}}))})),updateCameraType:useActionCallback((({set:e})=>t=>{e(K,t)}))}}const K=n.atom({key:"viewerCameraType",default:"perspective"});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}}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(s.Vector3.left(),-e),y=e=>create(s.Vector3.down(),-e),z=e=>create(s.Vector3.forward(),-e),getAxis=(e,t)=>{switch(e){case"x":return xAxis(t);case"y":return yAxis(t);case"z":return zAxis(t)}},q={x:s.Vector3.left(),y:s.Vector3.down(),z:s.Vector3.forward()},xAxis=e=>e.x,yAxis=e=>e.y||s.Vector3.create(e.x.z,e.x.x,e.x.y),zAxis=e=>e.z||s.Vector3.create(e.x.y,e.x.z,e.x.x),axis=(e,t,n,a)=>e&&e.normal&&[["x",t],["y",n],["z",a]].filter((t=>0===s.Vector3.magnitude(s.Vector3.cross(e.normal,t[1])))).map((e=>e[0])).pop(),isNegativeNormal=e=>s.Vector3.dot(s.Vector3.create(-1,-1,-1),e.normal)>0,towardsVector=(e,t)=>{const n=undefined;return s.Vector3.dot(e,t.normal)<0?invert(t):t},towardsCamera=(e,t)=>towardsVector(e.viewVector,t),invert=e=>Object.assign(Object.assign({},e),{normal:s.Vector3.multiply(e.normal,s.Vector3.create(-1,-1,-1)),offset:-e.offset}),fromHit=(e,t)=>{const n=s.Vector3.normalize(e.normal),a=s.Vector3.dot(n,e.position);return towardsCamera(t,create(n,a))},toAxis=(e,t,n,a,o)=>{const l=n.viewAll(),i=getAxis(e,t),r=null!=a&&null!=i?create(i,s.Vector3.dot(i,o||s.BoundingBox.center(a))):forAxis(e,l.lookAt[e]);return towardsCamera(n,r)};function corners(e){return[s.Vector3.create(e.min.x,e.min.y,e.min.z),s.Vector3.create(e.min.x,e.min.y,e.max.z),s.Vector3.create(e.min.x,e.max.y,e.min.z),s.Vector3.create(e.min.x,e.max.y,e.max.z),s.Vector3.create(e.max.x,e.max.y,e.max.z),s.Vector3.create(e.max.x,e.max.y,e.min.z),s.Vector3.create(e.max.x,e.min.y,e.max.z),s.Vector3.create(e.max.x,e.min.y,e.min.z)]}function equals(e,t){return e.min.x===t.min.x&&e.min.y===t.min.y&&e.min.z===t.min.z&&e.max.x===t.max.x&&e.max.y===t.max.y&&e.max.z===t.max.z}const Y="#999999",X=1,Z={default:5,min:0,max:10},J=n.atom({key:"crossSectioningEnabled",default:!1}),Q=n.atom({key:"crossSectioningHighlightColor",default:Y}),ee=n.atom({key:"crossSectioningBorderWidth",default:1}),te=n.atom({key:"crossSectioningPlanes",default:[]}),ne=n.atom({key:"crossSectioningAlignment",default:{mode:"global",hitPending:!1}}),ae=n.selector({key:"crossSectioningTargetBoundingBox",get:async({get:e})=>{const t=undefined;return e(W)}}),se=n.atom({key:"crossSectioningIsInteractive",default:!1}),oe=n.atom({key:"crossSectioningActiveAxis",default:"x"}),le=n.atom({key:"crossSectioningAvailableAxes",default:q}),ie=n.selector({key:"crossSectioningOffsetScalar",get:({get:e})=>{const t=e(te);return t.length>0&&isNegativeNormal(t[0])?-1:1}}),re=n.selector({key:"crossSectioningSliderRange",get:({get:e})=>{const t=e(te),n=e(ae),a=null!=n?corners(n):[];if(t.length>0){const e=a.map((e=>s.Vector3.dot(e,isNegativeNormal(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 Z}}),ce=n.selector({key:"crossSectioningPlaneDisplayOffset",get:({get:e})=>{const t=e(te),n=e(ie),a=e(re);return t.length>0?t[0].offset*n:a.default}}),ue=n.atom({key:"crossSectioningAdditionalToolsOpen",default:!1}),de=n.atom({key:"crossSectioningAlignmentToolsOpen",default:!1}),me=n.atom({key:"crossSectioningAxisToolsOpen",default:!1}),pe=n.atom({key:"crossSectioningInteractionHandler",default:new $,dangerouslyAllowMutability:!0});function useCrossSectioning(e,t){const s=n.useRecoilValue(pe);a.useEffect((()=>{t&&(null==e||e.registerInteractionHandler(s))}),[e,t,s])}const xe=n.atom({key:"hitResultsTapDetails",default:void 0}),he=n.atom({key:"hitResultsLongPressDetails",default:void 0}),ge=n.atom({key:"previousHitResult",default:void 0}),fe=n.atom({key:"currentHitResult",default:void 0}),ve=n.selector({key:"hitResult",get:async({get:e})=>{var t,n,a,o,l,i,r,c;const u=e(xe),d=e(he),m=null!=u?u:d,p=e(H),h=await p(),g=null==h?void 0:h.sceneViewId,f=null==h?void 0:h.raycaster();if(null!=m&&null!=f&&null!=g){const e=await f.hitItems(m.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===(a=null==u?void 0:u.hitNormal)||void 0===a?void 0:a.y)||0,(null===(o=null==u?void 0:u.hitNormal)||void 0===o?void 0:o.z)||0),position:s.Vector3.create((null===(l=null==u?void 0:u.hitPoint)||void 0===l?void 0:l.x)||0,(null===(i=null==u?void 0:u.hitPoint)||void 0===i?void 0:i.y)||0,(null===(r=null==u?void 0:u.hitPoint)||void 0===r?void 0:r.z)||0),meta:m.metaKey||m.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})))||[]}}}}),ye=n.atom({key:"hitResultsSkipNextTap",default:!1}),alignToNormal=(e,t,n)=>{if(e.toFrameCamera().isPerspective()){const n=s.Vector3.dot(s.Vector3.normalize(e.up),t),a=Math.abs(n)>.98?s.Vector3.normalize(s.Vector3.scale(-n,e.viewVector)):e.up,o=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:a,position:o})}{const a=s.Vector3.angleTo(s.Vector3.normalize(e.viewVector),t),o=null!=n?s.BoundingBox.center(n):e.lookAt,l=s.Vector3.normalize(s.Vector3.cross(s.Vector3.normalize(e.viewVector),t));return e.rotateAroundAxisAtPoint(a,o,l)}};function isParallelTo(e,t){const n=s.Angle.toDegrees(s.Vector3.angleTo(e,t));return 0===n||180===n}const be=500;function useCrossSectioningActions(){const e=useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromise(ee),n=await e.getPromise(Q),a=await e.getPromise(te),s=await e.getPromise(H),o=await s();await(null==o?void 0:o.crossSectioning().update({sectionPlanes:a,highlightColor:n?T.fromHexString(n):void 0,lineWidth:t}))})),t=useActionCallback((({set:t,reset:n,snapshot:a})=>async()=>{const s=await a.getPromise(H),o=await s();if(null!=o){const a=o.camera().viewAll();n(le),t(te,[towardsCamera(o.camera(),x(a.lookAt.x))]),await e()}})),n=useActionCallback(retainSnapshot((({snapshot:t,set:n})=>async()=>{const a=await t.tryGetPromise(ve).then((e=>e.value)),s=await t.getPromise(H),o=await s();if(null!=a&&null!=o){const t=fromHit(a,o.camera());n(te,null!=t?[t]:[]),n(le,null!=t?{x:t.normal}:q),await e()}}))),a=useActionCallback((({set:e,snapshot:n})=>async()=>{const a=await n.getPromise(te),s=undefined;await n.getPromise(J)||(e(J,!0),0===a.length&&await t())})),o=useActionCallback((({reset:t,snapshot:n})=>async()=>{const a=undefined;await n.getPromise(J)&&(t(J),t(ue),t(de),t(me),t(te),t(ne),t(oe),await e())}));return{enable:a,disable:o,reapply:useActionCallback((({snapshot:t})=>async()=>{const n=undefined;await t.getPromise(J)&&await e()})),openAdditionalTools:useActionCallback((({set:e,snapshot:t})=>async()=>{const n=undefined;await t.getPromise(J)||await a(),e(ue,!0)})),closeAdditionalTools:useActionCallback((({reset:e})=>()=>{e(ue)})),openAlignmentTools:useActionCallback((({set:e,reset:t})=>()=>{t(me),e(de,!0)})),closeAlignmentTools:useActionCallback((({reset:e})=>()=>{e(de)})),openAxisTools:useActionCallback((({set:e,reset:t})=>()=>{t(de),e(me,!0)})),closeAxisTools:useActionCallback((({reset:e})=>()=>{e(me)})),beginInteraction:useActionCallback((({set:e,snapshot:t})=>async()=>{const n=await t.getPromise(pe);e(se,!0),await n.beginInteraction()})),endInteraction:useActionCallback((({reset:e,snapshot:t})=>async()=>{const n=await t.getPromise(pe);e(se),await n.endInteraction()})),updatePlanes:useActionCallback(retainSnapshot((({set:t,snapshot:n})=>async a=>{const s=await n.getPromise(te);if(s.length>0){const o=await n.getPromise(ie),l=await n.getPromise(re),i=o<0?-1*l.max:l.min,r=o<0?-1*l.min:l.max,c=s.map((e=>Object.assign(Object.assign({},e),{offset:Math.min(Math.max(a*o,i),r)})));t(te,c),await e()}}))),flipPlanes:useActionCallback((({set:t,snapshot:n})=>async()=>{const a=await n.getPromise(te);t(te,a.map((e=>invert(e)))),await e()})),alignViewToPlane:useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromise(te),n=await e.getPromise(M),a=await(null==n?void 0:n.scene());t.length>0&&null!=a&&await alignToNormal(a.camera(),t[0].normal,a.boundingBox()).render({animation:{milliseconds:be}})})),updateAxis:useActionCallback(retainSnapshot((({set:t,reset:n,snapshot:a})=>async o=>{const l=await a.getPromise(te),i=await a.getPromise(le),r=await a.getPromise(ae),c=await a.getPromise(ne),u=await a.getPromise(M),d=await(null==u?void 0:u.scene()),m=i[o],p=null!=m&&l.length>0&&isParallelTo(l[0].normal,m)&&!isNaN(s.Vector3.angleTo(l[0].normal,m));if(null!=d&&!p){const e=await a.tryGetPromise(ve).then((e=>e.value));t(oe,o),t(te,[toAxis(o,i,d.camera(),r,"global"!==c.mode?null==e?void 0:e.position:void 0)])}n(me),await e()}))),updateAlignment:useActionCallback((({set:e,reset:s})=>async(o,l)=>{s(de),e(ne,{mode:o,hitPending:"global"!==o&&null==l}),"global"===o?(s(oe),s(le),await t()):"surface"===o&&null!=l&&(await a(),await n())})),sectionCurrentHit:useActionCallback((({set:e,snapshot:t})=>async()=>{const a=await t.getPromise(ne);a.hitPending&&(e(ne,Object.assign(Object.assign({},a),{hitPending:!1})),"surface"===a.mode&&await n())})),cancelCurrentHit:useActionCallback((({set:e,snapshot:t})=>async()=>{const n=await t.getPromise(ne);n.hitPending&&e(ne,Object.assign(Object.assign({},n),{hitPending:!1}))}))}}var Se=Object.freeze({__proto__:null,DEFAULT_ALIGN_TO_PLANE_ANIMATION_DURATION_MS:be,DEFAULT_CROSS_SECTION_HIGHLIGHT_COLOR:Y,DEFAULT_CROSS_SECTION_LINE_THICKNESS_VALUE:1,DEFAULT_SLIDER_RANGE:Z,crossSectioningActiveAxis:oe,crossSectioningAdditionalToolsOpen:ue,crossSectioningAlignment:ne,crossSectioningAlignmentToolsOpen:de,crossSectioningAvailableAxes:le,crossSectioningAxisToolsOpen:me,crossSectioningBorderWidth:ee,crossSectioningEnabled:J,crossSectioningHighlightColor:Q,crossSectioningInteractionHandler:pe,crossSectioningIsInteractive:se,crossSectioningOffsetScalar:ie,crossSectioningPlaneDisplayOffset:ce,crossSectioningPlanes:te,crossSectioningSliderRange:re,crossSectioningTargetBoundingBox:ae,useCrossSectioning:useCrossSectioning,useCrossSectioningActions:useCrossSectioningActions});function useDebouncedCallback(e,t){const[n,s]=a.useState();return a.useEffect((()=>()=>{null!=n&&clearTimeout(n)}),[e,t,n]),a.useCallback((a=>{const handler=()=>{e(a)};null!=n&&clearTimeout(n),s(setTimeout(handler,t))}),[e,t,n])}const VertexColorPicker=t=>{var{onInput:n}=t,s=__rest(t,["onInput"]);const l=useDebouncedCallback((e=>{null==n||n(e)}),500),i=a.useCallback((e=>{const t=e.target;l(t.value)}),[l]);return e.jsx(o.VertexColorPicker,Object.assign({onInput:i},s))},VertexCrossSectionAppearanceColorPicker=({onUpdate:t})=>{const a=useCrossSectioningActions(),[s,o]=n.useRecoilState(Q);return e.jsx(VertexColorPicker,{"data-testid":"cross-section-highlight-color-picker",value:s,onValueChanged:e=>{null==t||t(e.detail)},onInput:async e=>{o(e),await a.reapply()}})};var we={exports:{}},Ve;
14
14
  /*!
15
15
  Copyright (c) 2018 Jed Watson.
16
16
  Licensed under the MIT License (MIT), see
17
17
  http://jedwatson.github.io/classnames
18
- */Ce=we,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 a in t)e.call(t,a)&&t[a]&&(n=appendClass(n,a));return n}function appendClass(e,t){return t?e?e+" "+t:e+t:e}Ce.exports?(classNames.default=classNames,Ce.exports=classNames):window.classNames=classNames}();var Ve=we.exports;const VertexSlider=t=>{var{value:n,defaultValue:s,leftLabel:l,rightLabel:i,onChange:r,onValueChange:c,onValueInput:u}=t,d=__rest(t,["value","defaultValue","leftLabel","rightLabel","onChange","onValueChange","onValueInput"]);const[m,p]=a.useState(s);return e.jsxs("div",{className:"flex w-full items-center gap-2",children:[l&&e.jsx("div",{className:"pl-0.5 text-xs text-center",children:l}),e.jsx(o.VertexSlider,Object.assign({className:Ve("w-full",{"mt-0.5":null!=l||null!=i}),value:null!=n?n:m,onValueChange:e=>{p(e.detail.value),null==r||r(e.detail.value),null==c||c(e)},onValueInput:e=>{p(e.detail.value),null==r||r(e.detail.value),null==u||u(e)}},d)),i&&e.jsx("div",{className:"text-xs pr-2 flex-shrink-0 text-right",children:i})]})},VertexCrossSectionAppearanceLineThicknessSlider=({onUpdate:t})=>{const a=useCrossSectioningActions(),[s,o]=n.useRecoilState(ee);return e.jsx(VertexSlider,{id:"cross-section-line-thickness","data-testid":"cross-section-line-thickness-slider",leftLabel:"Off",rightLabel:"Thick",min:0,max:3,step:.5,value:s,valueLabelDisplay:"auto",onValueInput:async e=>{o(e.detail.value),await a.reapply()},onValueChange:e=>{null==t||t(e.detail.value)}})};function VertexCrossSectionAppearanceControls({onUpdateCrossSectionColor:t,onUpdateCrossSectionLineThickness:n}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Color"}),e.jsx(VertexCrossSectionAppearanceColorPicker,{onUpdate:t}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Line Thickness"}),e.jsx(VertexCrossSectionAppearanceLineThicknessSlider,{onUpdate:n})]})}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 VertexCrossSectionAppearanceReset=({onReset:t})=>{const a=useCrossSectioningActions(),[s,l]=n.useRecoilState(Q),[i,r]=n.useRecoilState(ee),c=s!==Y||1!==i;return e.jsx("div",{className:"ml-auto",children:e.jsx(o.VertexTooltip,{content:"Reset Cross Sectioning Appearance",children:e.jsx(o.VertexIconButton,{"data-testid":"cross-section-appearance-reset",iconName:"reset",iconSize:"sm",onClick:async()=>{l(Y),r(1),null==t||t(),await a.reapply()},disabled:!c})})})};function VertexCrossSectionAppearancePanelSection({onResetCrossSectionAppearance:t,onUpdateCrossSectionColor:n,onUpdateCrossSectionLineThickness:a}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Cross Sectioning",e.jsx(VertexCrossSectionAppearanceReset,{onReset:t})]}),children:e.jsx(VertexCrossSectionAppearanceControls,{onUpdateCrossSectionColor:n,onUpdateCrossSectionLineThickness:a})})}const je=.5,Te="#444444",ke=n.atom({key:"featureEdgesSelectedColor",default:Te}),Ae=n.atom({key:"featureEdgesLineThickness",default:je}),VertexFeatureEdgesColorPicker=({onUpdate:t})=>{const[a,s]=n.useRecoilState(ke);return e.jsx(VertexColorPicker,{"data-testid":"feature-edges-color-picker",value:a,onValueChanged:e=>{null==t||t(e.detail)},onInput:e=>s(e)})},VertexFeatureEdgesThicknessSlider=({onUpdate:t})=>{const[a,s]=n.useRecoilState(Ae);return e.jsx(VertexSlider,{id:"feature-edges-thickness","data-testid":"feature-edges-thickness-slider",leftLabel:"Off",rightLabel:"Thick",min:0,max:3,step:.5,value:a,valueLabelDisplay:"auto",onValueInput:e=>{s(e.detail.value)},onValueChange:e=>{null==t||t(e.detail.value)}})};function VertexFeatureEdgesControls({onUpdateFeatureEdgesColor:t,onUpdateFeatureEdgesThickness:n}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Color"}),e.jsx(VertexFeatureEdgesColorPicker,{onUpdate:t}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Line Thickness"}),e.jsx(VertexFeatureEdgesThicknessSlider,{onUpdate:n})]})}const VertexFeatureEdgesReset=({onReset:t})=>{const[a,s]=n.useRecoilState(ke),[l,i]=n.useRecoilState(Ae),r=l!==je||a!==Te;return e.jsx("div",{className:"ml-auto",children:e.jsx(o.VertexTooltip,{content:"Reset Feature Edges",children:e.jsx(o.VertexIconButton,{"data-testid":"feature-edges-reset",iconName:"reset",iconSize:"sm",onClick:()=>{s(Te),i(je),null==t||t()},disabled:!r})})})};function VertexFeatureEdgesPanelSection({onResetFeatureEdges:t,onUpdateFeatureEdgesColor:n,onUpdateFeatureEdgesThickness:a}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Feature Edges",e.jsx(VertexFeatureEdgesReset,{onReset:t})]}),children:e.jsx(VertexFeatureEdgesControls,{onUpdateFeatureEdgesColor:n,onUpdateFeatureEdgesThickness:a})})}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 Pe=n.atom({key:"contextMenuActive",default:void 0}),Ee=n.atom({key:"contextMenuPosition",default:void 0}),Ie=n.atom({key:"contextMenuTarget",default:void 0}),Re=n.atom({key:"contextMenuItem",default:void 0}),Ne=n.atom({key:"contextMenuActions",default:[]}),Oe=n.selector({key:"contextMenuActivePosition",get:({get:e})=>null!=e(Pe)?e(Ee):void 0});function useContextMenuActions(){return{pointerDown:useActionCallback((({set:e})=>async t=>{if(2===t.button){const n=t.clientX,a=null==t?void 0:t.clientY;e(Ee,s.Point.create(n,a)),e(Ie,t.target)}})),pointerUp:useActionCallback((({snapshot:e,set:t})=>async(n,a,o,l)=>{const i=await e.getPromise(Ee),r=await e.getPromise(Pe);if(null!=i&&null==r){const e=n.clientX,r=null==n?void 0:n.clientY,c=s.Point.create(e,r),u=null!=i?s.Point.distance(i,c):0,d=null==o||o(n);u<2&&d&&(null==l||l(n,null!=i?i:c),t(Pe,a))}})),contextMenu:useActionCallback((()=>(e,t)=>{(null==t||t(e))&&e.preventDefault()})),longPress:useActionCallback((({set:e})=>(t,n,a,o)=>{if(null==a||a(t)){const a=s.Point.create(t.touches[0].clientX,t.touches[0].clientY);e(Ee,a),e(Ie,t.target),e(Pe,n),null==o||o(t,a)}})),clearActiveContextMenu:useActionCallback((({reset:e,set:t})=>n=>{t(ye,!!n),e(Pe),e(Ne),e(Ee)})),clearDismissedState:useActionCallback((({reset:e})=>()=>e(ye)))}}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)}const Me=n.atom({key:"boxSelectionEnabled",default:!1}),Le=n.atom({key:"boxSelectionOperationType",default:"clearAndSelect"}),useBoxSelectionActions=()=>({enable:useActionCallback((({set:e})=>()=>{e(Me,!0)})),disable:useActionCallback((({reset:e})=>async()=>{e(Me),e(Le)})),setOperationType:useActionCallback((({set:e})=>t=>{e(Le,t)}))});async function whenComponentReady(e,t){return null!=e&&null!=e.nodeName&&await customElements.whenDefined(e.nodeName.toLowerCase()),"function"==typeof(null==e?void 0:e.componentOnReady)?(await(null==e?void 0:e.componentOnReady()),t()):void 0}const Be=n.atom({key:"isEditingPointToPointMeasurement",default:!1}),_e=n.atom({key:"pointToPointMeasurementOutcome",default:void 0}),De=n.atom({key:"editedPointToPointMeasurement",default:void 0});function usePointToPointMeasurement(e){const t=n.useSetRecoilState(_e);a.useEffect((()=>{let n;return whenComponentReady(e,(()=>{n=null==e?void 0:e.measurementModel.onOutcomeChanged(t)})),()=>null==n?void 0:n.dispose()}),[e,t])}const Fe=2,ze=n.atom({key:"isEditingPreciseMeasurement",default:!1}),He=n.atom({key:"preciseMeasurementOutcome",default:void 0}),Ue=n.atom({key:"preciseMeasurementController",dangerouslyAllowMutability:!0,default:void 0}),We=n.atom({key:"preciseMeasurementOverlays",dangerouslyAllowMutability:!0,default:void 0}),Ge=n.atom({key:"preciseMeasurementEntities",dangerouslyAllowMutability:!0,default:[]}),Ke=n.selector({key:"preciseMeasurementMessage",get:({get:e})=>{const t=undefined;return 0===e(Ge).length?"Select a surface":void 0}});function usePreciseMeasurementModel(e,t,s){const o=n.useSetRecoilState(Ge),l=n.useSetRecoilState(He),i=n.useSetRecoilState(Ue),r=n.useSetRecoilState(We),c=n.useRecoilValue(Ue);a.useEffect((()=>{let n;return whenComponentReady(e,(()=>{n=null==e?void 0:e.measurementModel.onEntitiesChanged((e=>{o(e),null==t||t(e)}))})),()=>null==n?void 0:n.dispose()}),[e,o]),a.useEffect((()=>{let t;return whenComponentReady(e,(()=>{t=null==e?void 0:e.measurementModel.onOutcomeChanged((e=>{l(e),null==s||s(e)}))})),()=>null==t?void 0:t.dispose()}),[e,l]),a.useEffect((()=>{let t;return whenComponentReady(e,(()=>{t=null==e?void 0:e.measurementModel.onEntitiesChanged((e=>{if(e.length>2){const t=e[2];null==c||c.setEntities(new Set([t]))}}))})),()=>null==t?void 0:t.dispose()}),[e,c]),a.useEffect((()=>{whenComponentReady(e,(()=>{i(null==e?void 0:e.measurementController)}))}),[e,i]),a.useEffect((()=>{whenComponentReady(e,(()=>{r(null==e?void 0:e.measurementOverlays)}))}),[e,r])}function useMeasurementActions(){const e=useBoxSelectionActions(),t=useEnablePointToPointMeasurement(),n=useDisablePointToPointMeasurement(),a=useDisablePreciseMeasurement(),s=useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromise(Ue);null==t||t.clearEntities()})),o=useActionCallback((()=>async(e={})=>{await s(),n(e),a()})),l=useActionCallback((({set:e,reset:n})=>async a=>{await o(),"point-to-point"===a?t():(n(He),n(Ge),e(ze,!0))}));return{disableEditMeasurement:useActionCallback((()=>async e=>{await o(e)})),enableEditMeasurement:useActionCallback((()=>async e=>{await l(e)})),resetMeasurement:useActionCallback((({snapshot:e,reset:t})=>async()=>{const n=await e.getPromise(ze),a=await e.getPromise(Be);n?await s():a&&(t(_e),t(De))})),clearEditedPointToPointMeasurement:useActionCallback((({reset:e})=>()=>{e(De)})),setEditedPointToPointMeasurement:useActionCallback((({set:e})=>t=>{e(De,t)})),toggleEditPointToPointMeasurement:useActionCallback((({snapshot:t})=>async()=>{const n=undefined;await t.getPromise(Be)?await o():await l("point-to-point"),e.disable()})),toggleEditPreciseMeasurement:useActionCallback((({snapshot:t})=>async()=>{const n=undefined;await t.getPromise(ze)?await o():await l("precise"),e.disable()}))}}function useEnablePointToPointMeasurement(){return useActionCallback((({reset:e,set:t})=>(n={})=>{t(Be,!0),n.keepExistingMeasurement||e(_e)}))}function useDisablePointToPointMeasurement(){return useActionCallback((({reset:e})=>(t={})=>{e(Be),t.keepExistingMeasurement||(e(De),e(_e))}))}function useDisablePreciseMeasurement(){return useActionCallback((({reset:e})=>async()=>{e(ze),e(He),e(Ge)}))}const $e=n.selector({key:"isEditingMeasurement",get:({get:e})=>e(Be)||e(ze)}),qe=n.selector({key:"measurementPanelModel",get:({get:e})=>e(_e)||e(He)}),Ye=n.selector({key:"measurementPanelOverlays",dangerouslyAllowMutability:!0,get:({get:e})=>e(We)}),Xe=n.selector({key:"measurementPanelMessage",get:({get:e})=>{const t=undefined;return e(ze)?e(Ke):void 0}}),Ze=n.selector({key:"measurementPanelIsResettable",get:({get:e})=>e($e)&&null!=e(qe)}),Je=3e3,Qe=n.atom({key:"applicationMessageToast",default:void 0}),et=n.atom({key:"applicationMessageBanner",default:void 0}),useApplicationMessageActions=()=>({setBannerMessage:useActionCallback((({set:e})=>t=>{e(et,null!=t?Object.assign(Object.assign({},t),{id:O.create()}):void 0)})),setToastMessage:useActionCallback((({set:e})=>t=>{e(Qe,null!=t?Object.assign(Object.assign({},t),{id:O.create()}):void 0)}))});var tt;!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"}(tt||(tt={}));const nt=n.atom({key:"fetchedItemInvalidator",default:0}),at=n.selectorFamily({key:"fetchedItems",get:e=>async({get:t})=>{var n;const a=t(M),s=t(F);if(t(nt),t(Lt),null!=s)try{return await(null===(n=null==a?void 0:a.sceneItems)||void 0===n?void 0:n.getSceneViewItem(e,s,{includeOverride:!0,includeWorldTransform:!0}))}catch(t){return void logger_debug(`Error encountered get scene view item. [itemId={${e}}]`,t)}}}),st=n.atomFamily({key:"selectionSelectedItems",default:void 0}),ot=n.atom({key:"selectionSelectedItemIds",default:[]}),lt=n.atom({key:"selectionLastSelected",default:void 0}),it=n.atom({key:"selectionLastSelectionFromViewer",default:!1}),rt=n.atom({key:"selectionLastSelectWasMultiSelect",default:!1}),ct=n.selector({key:"selectionHasMultipleSelected",get:({get:e})=>{const t=e(lt),n=undefined;return e(ot).filter((e=>{var n;return e!==(null==t?void 0:t.id)&&!(null===(n=null==t?void 0:t.ancestors)||void 0===n?void 0:n.includes(e))})).length>0}}),ut=n.atom({key:"selectionFirstSelectedItemInTreeId",default:void 0}),dt=n.selector({key:"selectionHighestSelectedAncestor",get:({get:e})=>{var t,n;const a=e(lt),s=e(ot);return null!==(n=null===(t=null==a?void 0:a.ancestors)||void 0===t?void 0:t.find((e=>s.includes(e))))&&void 0!==n?n:null==a?void 0:a.id}}),mt=n.atom({key:"selectionPreviousVisibleSummary",default:void 0}),pt=n.atom({key:"selectionVisibleSummary",default:void 0}),xt=n.selector({key:"selectionVisibleCount",get:({get:e})=>{var t,n;return null!==(n=null===(t=e(pt))||void 0===t?void 0:t.count)&&void 0!==n?n:0}}),ht=n.selector({key:"selectionBoundingBoxCenter",get:({get:e})=>{const t=e(pt);return null!=(null==t?void 0:t.boundingBox)?s.BoundingBox.center(t.boundingBox):s.Vector3.origin()}}),gt=n.selector({key:"selectionIsActive",get:({get:e})=>{const t=e(ot),n=undefined;return e(xt)>0||t.length>0}}),ft=n.selector({key:"fetchedAndSelectedItems",get:async({get:e})=>{const t=e(ot),n=undefined;return null!=e(F)?t.map((t=>e(at(t)))):[]}});function useSceneViewItemActions(){return{invalidateCachedItems:useActionCallback((({set:e})=>()=>{e(nt,(e=>e+1))}))}}const vt=n.atom({key:"lengthUnit",default:"cm"}),yt=n.atom({key:"decimalPlace",default:"2"});var bt,St;!function(e){e.mm="millimeters",e.cm="centimeters",e.m="meters",e.in="inches",e.ft="feet"}(bt||(bt={})),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"}(St||(St={}));const convertFrom=(e,t)=>{const n=undefined;return e/St[t]},convertTo=(e,t)=>{const n=undefined;return e*St[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 toUnitType(e){switch(e){case"cm":return"centimeters";case"m":return"meters";case"in":return"inches";case"ft":return"feet";default:return"millimeters"}}function pickLocalOrWorldTransform(e,t){return"local"===t?e.local:e.world}function mapItemTransforms(e,t){return{local:t(e.local),world:t(e.world)}}function makeItemTransforms(e,t,n){return"local"===n?{local:e,world:l.toWorldTransform(e,t)}:{world:e,local:l.toLocalTransform(e,t)}}function convertTransformToUnits(e,t){const{position:n,rotation:a,scale:o}=e;return{position:s.Vector3.create(convertTo(n.x,t),convertTo(n.y,t),convertTo(n.z,t)),rotation:a,scale:o}}function convertTransformFromUnits(e,t){const{position:n,rotation:a,scale:o}=e;return{position:s.Vector3.create(convertFrom(n.x,t),convertFrom(n.y,t),convertFrom(n.z,t)),rotation:a,scale:o}}function toValidTransform(e){const{position:t,rotation:n,scale:a}=e;return{position:{x:t.x||0,y:t.y||0,z:t.z||0},rotation:{x:n.x||0,y:n.y||0,z:n.z||0},scale:a||1}}function scale(e){const t=parseFloat(Math.sqrt(e[0]**2+e[4]**2+e[8]**2).toFixed(2)),n=parseFloat(Math.sqrt(e[1]**2+e[5]**2+e[9]**2).toFixed(2)),a=parseFloat(Math.sqrt(e[2]**2+e[6]**2+e[10]**2).toFixed(2));return t===n&&n===a?t:NaN}function translation(e){return{x:e[12],y:e[13],z:e[14]}}function rotation(e){const t=e.map((t=>t*(1/scale(e))));return t[8]<1?t[8]>-1?{x:Math.atan2(-t[9],t[10])*(180/Math.PI),y:Math.asin(t[8])*(180/Math.PI),z:Math.atan2(-t[4],t[0])*(180/Math.PI)}:{x:-Math.atan2(-t[1],t[5])*(180/Math.PI),y:-90,z:0}:{x:Math.atan2(t[1],t[5])*(180/Math.PI),y:90,z:0}}function toTransformFromApiMatrix(e){return null!=e?{position:translation(e),rotation:rotation(e),scale:scale(e)}:void 0}const wt={position:s.Vector3.create(0,0,0),rotation:s.Vector3.create(0,0,0),scale:1},Ct=n.atom({key:"transformWidgetEnabled",default:!1}),Vt=n.atom({key:"transformWidgetPosition",default:void 0}),jt=n.atom({key:"transformWidgetOrientationOverride",default:void 0}),Tt=n.selector({key:"transformWidgetOrientation",get:({get:e})=>{const t=e(jt),n=e(lt);if(null!=t)return t;if(null!=n){const t=e(Mt(n.id));return s.Euler.fromDegrees({x:null==t?void 0:t.world.rotation.x,y:null==t?void 0:t.world.rotation.y,z:null==t?void 0:t.world.rotation.z})}}}),kt=n.atom({key:"transformWidgetCachedOrientation",default:void 0}),At=n.atom({key:"transformWidgetSyncToSelection",default:!1}),Pt=n.atom({key:"transformWidgetIsInteracting",default:!1}),Et=n.atomFamily({key:"appliedItemTransform",default:void 0}),It=n.atom({key:"appliedItemTransformIds",default:[]}),Rt=n.atom({key:"selectedCoordinateSpace",default:"world"}),Nt=n.atomFamily({key:"editedItemTransform",default:void 0}),Ot=n.selectorFamily({key:"displayedItemTransform",get:e=>({get:t})=>{const n=t(Rt),a=t(vt),s=t(Mt(e)),o=t(Nt(e));return null!=o?o.transform:null!=s?pickLocalOrWorldTransform(mapItemTransforms(s,(e=>convertTransformToUnits(e,a))),n):void 0},set:e=>({get:t,set:a},s)=>{const o=t(Rt),l=t(Bt(e)),i=t(Mt(e)),r=t(vt);if(null!=i&&!(s instanceof n.DefaultValue)&&null!=s&&null!=l){a(Nt(e),{coordinateSpace:o,units:r,transform:s});const n=makeItemTransforms(convertTransformFromUnits(toValidTransform(s),r),l,o),i=t(It);a(Et(e),n),a(It,[...i,e])}}}),Mt=n.selectorFamily({key:"fetchedItemTransforms",get:e=>({get:t})=>{var n,a;const s=t(at(e));if(null!=s){const e=(null===(n=s.override)||void 0===n?void 0:n.transform)?toTransformFromApiMatrix(null===(a=s.override)||void 0===a?void 0:a.transform):void 0,t=s.worldTransform?toTransformFromApiMatrix(s.worldTransform):void 0;return{local:null!=e?e:wt,world:null!=t?t:wt}}}}),Lt=n.atom({key:"transformInvalidator",default:0}),Bt=n.selectorFamily({key:"parentItemWorldMatrix",get:e=>({get:t})=>{const n=undefined;if(null!=t(F)){const n=t(at(e));if(null!=(null==n?void 0:n.parentId)){const e=t(Mt(n.parentId)),a=t(Et(n.parentId));if(null==e)throw new Error("Invalid state. Parent item state should be populated, but is undefined.");return null!=a?l.toMatrix(l.toRadiansTransform(a.world)):l.toMatrix(l.toRadiansTransform(e.world))}}return logger_debug(`Unable to find the world matrix for the parent of ${e}. Returning the identity matrix.`),s.Matrix4.makeIdentity()}});function useUpdateEditedTransformWhenSettingsChange(e){const t=n.useRecoilValue(vt),s=n.useRecoilValue(Rt),o=n.useRecoilValue(Et(null!=e?e:"")),[l,i]=n.useRecoilState(Nt(null!=e?e:""));a.useEffect((()=>{if(null!=o&&((null==l?void 0:l.coordinateSpace)!==s||(null==l?void 0:l.units)!==t)){const e=undefined,n=convertTransformToUnits(pickLocalOrWorldTransform(o,s),t);i({units:t,coordinateSpace:s,transform:n})}}),[t,s])}function useEditItemTransform(e){const t=useTransformActions();useUpdateEditedTransformWhenSettingsChange(e);const a=n.useRecoilValueLoadable(Bt(null!=e?e:"")),[s,o]=n.useRecoilStateLoadable(Ot(null!=e?e:""));return{transform:"hasValue"===s.state?s.contents:void 0,loading:"loading"===s.state||"loading"===a.state,error:"hasError"===s.state?s.contents:void 0,async update(n){o(n),null!=e&&await t.applyTransformToItem(e)}}}const useTransformActions=()=>{const e=useApplicationMessageActions(),t=useViewerSceneActions(),n=useActionCallback((({set:e,snapshot:t})=>async()=>{const n=await t.getPromise(ht);e(Vt,n)})),a=useActionCallback((({set:e,snapshot:t})=>async()=>{const a=await t.getPromise(Vt),s=await t.getPromise(rt),o=await t.getPromise(ot),l=await t.getPromise(xt);null==a&&(o.length>0||s||l>0)&&await n(),e(At,!0)})),o=useActionCallback((({set:e})=>async t=>{e(Vt,null!=t?t:void 0)})),i=useActionCallback(retainSnapshot((({snapshot:e,set:t,reset:n})=>async()=>{const a=await e.getPromise(Tt),s=undefined;(await e.getPromise(It)).forEach((e=>{n(Et(e)),n(Nt(e))})),n(It),null!=a&&t(kt,a),t(Lt,(e=>e+1))}))),r=useActionCallback((({set:e,reset:t})=>n=>{t(kt),e(jt,n)})),c=useActionCallback((({set:e})=>()=>{e(Vt,void 0),e(Ct,!1)}));return{enableTransformWidget:useActionCallback((({set:t})=>async(s,l)=>{e.setToastMessage({message:"Transform manipulator enabled! Select parts to interact.",duration:Je}),t(Ct,!0),l?await n():null==s?await a():await o(s)})),disableTransformWidget:useActionCallback((({reset:e})=>()=>{e(Ct),e(jt)})),setTransformWidgetOrientation:r,clearTransformWidgetOrientation:useActionCallback((({reset:e})=>()=>{e(kt),e(jt)})),setTransformWidgetPosition:o,clearTransformWidgetPosition:useActionCallback((({reset:e})=>()=>e(Vt))),invalidateTransforms:i,setIsInteractivelyTransforming:useActionCallback((({set:e})=>t=>{e(Pt,t)})),setDefaultWidgetPosition:a,setDefaultWidgetPositionToSelection:n,enableSelectionSync:useActionCallback((({set:e})=>()=>e(At,!0))),disableSelectionSync:useActionCallback((({reset:e})=>()=>e(At))),syncToSelection:useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromise(mt),n=await e.getPromise(pt),a=undefined;if(await e.getPromise(At)){const e=null==n?void 0:n.boundingBox,a=null!=e&&null!=(null==t?void 0:t.boundingBox)&&equals(e,t.boundingBox);null==e||a||await o(s.BoundingBox.center(e))}})),orientToHitResult:useActionCallback((({reset:e})=>async t=>{e(At),null!=t?(await o(null==t?void 0:t.position),r(s.Vector3.eulerTo(s.Vector3.up(),t.normal))):(e(Vt),r(void 0))})),clearSelectedTransforms:useActionCallback((()=>async()=>{await t.execute(tt.CLEAR_SELECTED_TRANSFORMS,(e=>e.where((e=>e.withSelected())).clearTransforms())),await i(),c()})),clearAllTransforms:useActionCallback((()=>async()=>{await t.execute(tt.CLEAR_SELECTED_TRANSFORMS,(e=>e.where((e=>e.all())).clearTransforms())),await i(),c()})),applyTransformToItem:useActionCallback((({snapshot:e})=>async t=>{const n=await e.getPromise(M),a=await(null==n?void 0:n.scene()),o=await e.getPromise(Et(t));if(null==o)return void logger_warn(`There is no transform to apply to item ${t}.`);const i=s.Matrix4.transpose(l.toMatrix(l.toRadiansTransform(null==o?void 0:o.local)));return null==a?void 0:a.items((e=>e.where((e=>e.withItemId(t))).transform(i))).execute()}))}},useHitActions=()=>{const e=useCrossSectioningActions(),t=useMeasurementActions(),n=useTransformActions(),a=useActionCallback(retainSnapshot((({snapshot:e})=>async()=>{const n=await e.tryGetPromise(ve).then((e=>e.value)),a=await e.getPromise(De);null==n&&null!=(null==a?void 0:a.start)&&null!=a.end&&await t.resetMeasurement()}))),s=useActionCallback(retainSnapshot((({snapshot:e})=>async()=>{const t=await e.tryGetPromise(ve).then((e=>e.value));await n.orientToHitResult(t)}))),o=useActionCallback(retainSnapshot((({set:e,snapshot:t})=>async()=>{const n=await t.tryGetPromise(ve).then((e=>e.value));e(Re,n)}))),l=useActionCallback(retainSnapshot((({snapshot:e,set:t})=>async()=>{t(fe,await e.tryGetPromise(ve).then((e=>e.value)))})));return{tap:useActionCallback(retainSnapshot((({snapshot:t,set:n})=>async({detail:i},...r)=>{const c=await t.getPromise($e),u=await t.getPromise(ne),d=2!==(null==i?void 0:i.buttons)&&!(null==i?void 0:i.altKey);i.altKey||i.ctrlKey||i.metaKey||i.shiftKey;const m=d&&!u.hitPending&&!c,p=await t.tryGetPromise(ve).then((e=>e.value));n(ge,p),n(xe,i),await a(),m&&(r.forEach((e=>e())),await s()),await o(),await e.sectionCurrentHit(),await l()}))),longPress:useActionCallback(retainSnapshot((({snapshot:e,set:t,reset:n})=>async a=>{n(xe),t(he,a.detail),await e.tryGetPromise(ve),await o(),await l()})))}},_t=n.selector({key:"viewerToolkitHitState",get:({get:e})=>{const t=undefined,n=undefined,a=undefined,s=undefined,o=undefined;return{tapDetails:e(xe),longPressDetails:e(he),previousHitResult:e(ge),currentHitResult:e(fe)}}});var Dt=Object.freeze({__proto__:null,currentHitResult:fe,hitResult:ve,hitResultsLongPressDetails:he,hitResultsSkipNextTap:ye,hitResultsTapDetails:xe,hitState:_t,previousHitResult:ge,useHitActions:useHitActions});function useSelectionActions(){const e=useSceneViewItemActions(),t=useTransformActions(),n=useViewerSceneActions(),a=useActionCallback((({snapshot:e,reset:t})=>async()=>{const n=undefined;(await e.getPromise(ot)).forEach((e=>t(st(e))))})),s=useActionCallback((({snapshot:e,reset:t,set:a})=>async(s,o)=>{var l,i;const r=await e.getPromise(st(s.id)),c=await e.getPromise(ot),u=null===(i=[...null!==(l=s.ancestors)&&void 0!==l?l:[]])||void 0===i?void 0:i.reverse().find((e=>!c.includes(e)));null!=r&&null!=u?(a(st(u),{id:u}),a(ot,(e=>[...e,u])),n.execute(tt.SELECTING_ANCESTOR,n.selectItemsTransform(u))):(null==o?void 0:o.clear)?(a(st(s.id),s),a(ot,[s.id]),n.execute(tt.SELECTING_ONLY_ITEM,n.clearSelectionTransform,n.selectItemsTransform(s.id))):(a(st(s.id),s),a(ot,(e=>[...e,s.id])),n.execute(tt.SELECTING_ITEMS,n.selectItemsTransform(s.id))),d(s),a(lt,s),a(it,!0),t(rt)})),o=useActionCallback((({reset:e,set:t})=>async a=>{e(st(a)),e(rt),t(ot,(e=>e.filter((e=>e!==a)))),n.execute(tt.DESELECTING_ITEMS,n.deselectItemsTransform(a))})),l=useActionCallback((({snapshot:e})=>async t=>{const n=await e.getPromise(st(t.id));null!=n?await o(n.id):await s(t)})),i=useActionCallback((({snapshot:n,reset:a,set:o})=>async(l,i={})=>{const r=await n.getPromise(st(l.id)),c=await n.getPromise(ot);if(c.filter((e=>{var t;return e!==l.id&&!(null===(t=l.ancestors)||void 0===t?void 0:t.includes(e))})).forEach((e=>a(st(e)))),a(rt),r)if(i.ignoreAncestorSelection)a(ot),a(st(r.id));else{const e=c.filter((e=>{var t;return e===l.id||(null===(t=l.ancestors)||void 0===t?void 0:t.includes(e))}));o(ot,e)}else a(ot);e.invalidateCachedItems(),t.clearTransformWidgetOrientation(),await s(l,{clear:!0})})),r=useActionCallback((({reset:e})=>async()=>{await a(),e(ot),e(lt),e(it),e(rt),t.clearTransformWidgetPosition(),t.clearTransformWidgetOrientation()})),c=useActionCallback((()=>async()=>{await r(),n.execute(tt.CLEAR_SELECTION,n.clearSelectionTransform)})),u=useActionCallback((({set:e})=>async t=>{e(rt,t)})),d=useActionCallback((({reset:e,set:t})=>e=>{}));return{select:s,toggleSelection:l,clearAndSelect:i,selectCurrentHit:useActionCallback(retainSnapshot((({snapshot:e})=>async()=>{const t=await e.tryGetPromise(ve).then((e=>e.value)),n=await e.getPromise(xe),a=(null==n?void 0:n.metaKey)||(null==n?void 0:n.ctrlKey)||(null==n?void 0:n.shiftKey);null==t||a?null!=t&&a?await l(t):await c():await i(t)}))),syncSelection:useActionCallback((({set:e,reset:t})=>async(n,s)=>{s.selected?(await a(),e(st(n.id),n),s.multiSelect?e(ot,(e=>[...e.filter((e=>e!==n.id)),n.id])):e(ot,[n.id]),d(n),e(lt,n),e(it,!1),e(rt,!!s.multiSelect)):(t(st(n.id)),t(rt),e(ot,(e=>e.filter((e=>e!==n.id)))))})),deselect:o,clearSelection:c,resetSelectionState:r,toggleLastSelectWasMultiSelect:u,selectForModelViewsPanel:d}}const Ft=n.selector({key:"viewerToolkitSelectionState",get:({get:e})=>{const t=undefined,n=undefined,a=undefined,s=undefined;return{selectedItemIds:e(ot),lastSelected:e(lt),highestSelectedAncestorId:e(dt)}}});var zt=Object.freeze({__proto__:null,fetchedAndSelectedItems:ft,selectionBoundingBoxCenter:ht,selectionFirstSelectedItemInTreeId:ut,selectionHasMultipleSelected:ct,selectionHighestSelectedAncestor:dt,selectionIsActive:gt,selectionLastSelectWasMultiSelect:rt,selectionLastSelected:lt,selectionLastSelectionFromViewer:it,selectionPreviousVisibleSummary:mt,selectionSelectedItemIds:ot,selectionSelectedItems:st,selectionState:Ft,selectionVisibleCount:xt,selectionVisibleSummary:pt,useSelectionActions:useSelectionActions});const Ht=255,Ut=n.atom({key:"sceneItemAdjustmentsSelectedColor",default:void 0}),Wt=n.atom({key:"sceneItemAdjustmentsSelectedOpacity",default:void 0}),Gt=n.atomFamily({key:"appliedItemMaterialOverride",default:void 0}),Kt=n.atom({key:"appliedItemMaterialOverrideIds",default:[]}),$t=n.selector({key:"sceneItemAdjustmentsLastSelectedOverride",get:({get:e})=>{const t=e(lt);if(null!=t)return e(Gt(t.id))}}),qt=n.atom({key:"applyMaterialToAllUserAction",default:void 0}),Yt=n.atom({key:"showConfirmDialogWhenApplyingMaterialToAll",default:!0}),Xt=n.atom({key:"confirmApplyMaterialToAllDialogOpen",default:!1}),useSceneItemMaterialActions=()=>{const e=useViewerSceneActions(),t=useActionCallback((({snapshot:e,reset:t})=>async()=>{const n=await e.getPromise(Kt);t(Ut),n.forEach((e=>t(Gt(e)))),t(Kt)}));return{updateColor:useActionCallback((({set:e})=>t=>{e(Ut,t)})),clearCurrentColor:useActionCallback((({reset:e})=>()=>{e(Ut)})),clearCurrentOpacity:useActionCallback((({reset:e})=>()=>{e(Wt)})),clear:useActionCallback((({snapshot:t,set:n,reset:a})=>async()=>{const s=await t.getPromise(ot);a(Ut),s.forEach((e=>a(Gt(e)))),n(Kt,(e=>e.filter((e=>!s.includes(e))))),await e.execute(tt.CLEAR_SELECTED_MATERIAL_OVERRIDES,(e=>e.where((e=>e.withSelected())).clearMaterialOverrides().select()))})),clearAll:useActionCallback((()=>async()=>{await t(),await e.execute(tt.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(Wt,t)})),apply:useActionCallback((({snapshot:t,set:n})=>async()=>{const a=await t.getPromise(Ut),s=await t.getPromise(Wt),o=await t.getPromise(ot),l=await t.getPromise($t),i=null!=a?a:l,r=null!=s?s:null==l?void 0:l.opacity;if(null!=i){const t=Object.assign(Object.assign({},i),{opacity:null!=r?r:i.opacity});await e.execute(tt.APPLY_MATERIAL_OVERRIDE_TO_SELECTION,(e=>e.where((e=>e.withSelected())).materialOverride(t))),o.forEach((e=>n(Gt(e),t))),n(Kt,(e=>[...e,...o]))}})),confirmApplyAll:useActionCallback((({set:e})=>t=>{e(Xt,!0),e(qt,(()=>t))})),cancelApplyAll:useActionCallback((({reset:e})=>()=>{e(Xt),e(qt)})),applyAll:useActionCallback((({snapshot:t,reset:n})=>async()=>{const a=await t.getPromise(Ut),s=await t.getPromise(Wt);if(null!=a){const o=await t.getPromise(Kt),l=Object.assign(Object.assign({},a),{opacity:null!=s?s:a.opacity});await e.execute(tt.APPLY_MATERIAL_OVERRIDE_TO_ALL,(e=>e.where((e=>e.all())).materialOverride(l))),o.forEach((e=>n(Gt(e))));const i=await t.getPromise(qt);null==i||i(l),n(Xt),n(qt)}})),hideConfirmApplyAllDialog:useActionCallback((({set:e})=>()=>{e(Yt,!1)}))}},Zt="#FFFFFF",Jt=n.atom({key:"viewerBackgroundSelectedColor",default:Zt}),VertexSceneItemMaterialApplyAll=({onApplyAll:t})=>{const a=useSceneItemMaterialActions(),s=n.useRecoilValueLoadable($t),l=n.useRecoilValue(Ut),i=n.useRecoilValue(Yt),r=u.useMemo((()=>"hasValue"===s.state?null!=l?l:s.contents:l),[s,l]);return e.jsx(o.VertexTooltip,{content:"Apply to All",children:e.jsx(o.VertexIconButton,{iconName:"square-dot-outline",iconSize:"sm",color:"secondary",disabled:null==r,onClick:async()=>{i?a.confirmApplyAll(t):(await a.applyAll(),null==t||t(r))}})})};function SceneItemMaterialApplyAllConfirmationDialog(){const t=useSceneItemMaterialActions(),s=n.useRecoilValue(Xt),[l,i]=a.useState(!1),onCloseDialog=()=>{t.cancelApplyAll(),i(!1)};return s?e.jsxs(o.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(o.VertexToggle,{"data-testid":"hide-confirmation-dialog-in-future-checkbox",variant:"check",className:"pt-0.5",checked:l,onValueChanged:e=>{i(e.detail)}}),"Don't show again this session"]}),e.jsxs("div",{className:"flex ml-auto gap-2",children:[e.jsx(o.VertexButton,{"data-testid":"cancel-apply-material-to-all",onClick:onCloseDialog,children:"Cancel"}),e.jsx(o.VertexButton,{color:"primary","data-testid":"confirm-apply-material-to-all",onClick:async()=>{await t.applyAll(),l&&t.hideConfirmApplyAllDialog()},children:"Apply"})]})]})]}):e.jsx(e.Fragment,{})}function createColorMaterialWithId(e,t=O.create()){return Object.assign({id:t},l.ColorMaterial.fromHex(e))}const VertexSceneItemMaterialColorPicker=({onApply:t})=>{const a=useSceneItemMaterialActions(),s=n.useRecoilValueLoadable($t),o=n.useRecoilValue(Ut),l=u.useMemo((()=>"hasValue"===s.state?null!=o?o:s.contents:o),[s,o]);return e.jsx(VertexColorPicker,{"data-testid":"selected-item-color-picker",value:null!=l?T.toHexString(l.diffuse):void 0,onValueChanged:()=>{a.apply(),null==t||t(l)},onInput:async e=>{a.updateColor(createColorMaterialWithId(e)),await a.apply()}})},VertexSceneItemMaterialOpacitySlider=({onApply:t})=>{const a=useSceneItemMaterialActions(),s=n.useRecoilValue(Wt),l=n.useRecoilValueLoadable($t),i=u.useMemo((()=>{var e,t;return"hasValue"===l.state?null!==(t=null!=s?s:null===(e=l.contents)||void 0===e?void 0:e.opacity)&&void 0!==t?t:Ht:null!=s?s:Ht}),[s,l]),r=useDebouncedCallback((()=>{a.apply()}),500),c=u.useCallback((e=>{a.updateOpacity(e.detail.value),r(e.detail.value)}),[r,a]),d=u.useMemo((()=>"hasValue"!==l.state||null==l.contents),[l]);return e.jsx(o.VertexTooltip,{className:"flex w-full",content:d?"Select a part and apply a color to enable opacity":`${Math.floor(i/Ht*100)}%`,placement:"top",children:e.jsx(VertexSlider,{"data-testid":"scene-item-adjustments-opacity-slider",leftLabel:"0%",rightLabel:"100%",disabled:d,value:null!=i?i:Ht,step:5,min:0,max:Ht,onValueChange:e=>{a.updateOpacity(e.detail.value),a.apply(),null==t||t(e.detail.value)},onValueInput:c})})};function VertexMaterialControls({onApplyMaterial:t,onApplyMaterialToAll:s,onApplyOpacity:o}){const l=useSceneItemMaterialActions(),i=n.useRecoilValue(lt);return a.useEffect((()=>{l.clearCurrentColor(),l.clearCurrentOpacity()}),[null==i?void 0:i.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:s})]})]}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Opacity"}),e.jsx(VertexSceneItemMaterialOpacitySlider,{onApply:o}),e.jsx(SceneItemMaterialApplyAllConfirmationDialog,{})]})}const ResetButton=({id:t,tooltip:n,children:s})=>{const[l,i]=a.useState(!1);return e.jsx("div",{className:"ml-auto",children:e.jsxs(o.VertexDropdownMenu,{className:"flex items-stretch h-full","data-testid":`reset-button-dropdown-menu-${t}`,placement:"bottom-end",onMenuOpened:()=>i(!0),onMenuClosed:()=>i(!1),children:[e.jsx("div",{slot:"anchor",className:"flex items-center h-full",children:e.jsx(o.VertexTooltip,{content:n,disabled:l,placement:"bottom",children:e.jsxs(o.VertexButton,{className:Ve("p-1.5 rounded-md select-none hover:bg-neutral-300 active:bg-neutral-400 cursor-pointer",{"bg-neutral-300":l}),"data-testid":`reset-button-${t}`,variant:"plaintext",children:[e.jsx(o.VertexIcon,{className:"px-0.5",name:"reset",size:"sm"}),e.jsx(o.VertexIcon,{name:"chevron-down",size:"sm"})]})})}),e.jsx("div",{className:"whitespace-nowrap",children:s})]})})},VertexSceneItemMaterialClear=({onClear:t,onClearAll:a})=>{const s=useSceneItemMaterialActions(),l=n.useRecoilValue(gt);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(o.VertexMenuItem,{"data-testid":"clear-selected-materials",onClick:()=>{s.clear(),null==t||t()},disabled:!l,children:"Clear selected materials"}),e.jsx(o.VertexMenuItem,{"data-testid":"clear-all-materials",onClick:()=>{s.clearAll(),null==a||a()},children:"Clear all materials"})]})})};function VertexMaterialPanelSection({onClearMaterial:t,onClearAllMaterials:n,onApplyMaterial:a,onApplyMaterialToAll:s,onApplyOpacity:o}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Material",e.jsx(VertexSceneItemMaterialClear,{onClear:t,onClearAll:n})]}),children:e.jsx(VertexMaterialControls,{onApplyMaterial:a,onApplyMaterialToAll:s,onApplyOpacity:o})})}const Qt="#ffff00",en=35,tn=1,nn=n.atom({key:"selectionHighlightingSelectedColor",default:Qt}),an=n.atom({key:"selectionHighlightingSelectedOpacity",default:en}),sn=n.atom({key:"selectionHighlightingSelectedLineThickness",default:1}),VertexSelectionHighlightingColorPicker=({onUpdate:t})=>{const[a,s]=n.useRecoilState(nn);return e.jsx(VertexColorPicker,{"data-testid":"selection-highlighting-color-picker",value:a,onValueChanged:e=>{null==t||t(e.detail)},onInput:e=>s(e)})},VertexSelectionHighlightingLineThicknessSlider=({onUpdate:t})=>{const[a,s]=n.useRecoilState(sn);return e.jsx(VertexSlider,{id:"selection-highlighting-line-thickness","data-testid":"selection-highlighting-line-thickness-slider",leftLabel:"Off",rightLabel:"Thick",min:0,max:3,step:.5,value:a,valueLabelDisplay:"auto",onValueInput:e=>{s(e.detail.value)},onValueChange:e=>{null==t||t(e.detail.value)}})},VertexSelectionHighlightingOpacitySlider=({onUpdate:t})=>{const[a,s]=n.useRecoilState(an);return e.jsx(VertexSlider,{id:"selection-highlighting-opacity","data-testid":"selection-highlighting-opacity-slider",leftLabel:"0%",rightLabel:"100%",min:0,max:100,step:5,value:a,valueLabelDisplay:"auto",onValueInput:e=>{s(e.detail.value)},onValueChange:e=>{null==t||t(e.detail.value)}})};function VertexSelectionHighlightingControls({onUpdateSelectionHighlightColor:t,onUpdateSelectionHighlightOpacity:n,onUpdateSelectionHighlightLineThickness:a}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Color"}),e.jsx(VertexSelectionHighlightingColorPicker,{onUpdate:t}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Opacity"}),e.jsx(VertexSelectionHighlightingOpacitySlider,{onUpdate:n}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Line Thickness"}),e.jsx(VertexSelectionHighlightingLineThicknessSlider,{onUpdate:a})]})}const VertexSelectionHighlightingReset=({onReset:t})=>{const[a,s]=n.useRecoilState(nn),[l,i]=n.useRecoilState(an),[r,c]=n.useRecoilState(sn),u=a!==Qt||l!==en||1!==r;return e.jsx("div",{className:"ml-auto",children:e.jsx(o.VertexTooltip,{content:"Reset Selection Highlighting",children:e.jsx(o.VertexIconButton,{"data-testid":"selection-highlighting-reset",iconName:"reset",iconSize:"sm",onClick:()=>{s(Qt),i(en),c(1),null==t||t()},disabled:!u})})})};function VertexSelectionHighlightingPanelSection({onResetSelectionHighlighting:t,onUpdateSelectionHighlightColor:n,onUpdateSelectionHighlightOpacity:a,onUpdateSelectionHighlightLineThickness:s}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Selection Highlighting",e.jsx(VertexSelectionHighlightingReset,{onReset:t})]}),children:e.jsx(VertexSelectionHighlightingControls,{onUpdateSelectionHighlightColor:n,onUpdateSelectionHighlightOpacity:a,onUpdateSelectionHighlightLineThickness:s})})}const VertexViewerBackgroundColorPicker=({onUpdate:t})=>{const[a,s]=n.useRecoilState(Jt);return e.jsx(VertexColorPicker,{"data-testid":"viewer-background-color-picker",value:a,onValueChanged:e=>{null==t||t(e.detail)},onInput:e=>s(e)})};function VertexViewerBackgroundControls({onUpdateViewerBackgroundColor:t}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Color"}),e.jsx(VertexViewerBackgroundColorPicker,{onUpdate:t})]})}const VertexViewerBackgroundReset=({onReset:t})=>{const[a,s]=n.useRecoilState(Jt),l=a!==Zt;return e.jsx("div",{className:"ml-auto",children:e.jsx(o.VertexTooltip,{content:"Reset Background Color",children:e.jsx(o.VertexIconButton,{"data-testid":"viewer-background-reset",iconName:"reset",iconSize:"sm",onClick:()=>{s(Zt),null==t||t()},disabled:!l})})})};function VertexViewerBackgroundPanelSection({onResetViewerBackgroundColor:t,onUpdateViewerBackgroundColor:n}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Viewer Background",e.jsx(VertexViewerBackgroundReset,{onReset:t})]}),children:e.jsx(VertexViewerBackgroundControls,{onUpdateViewerBackgroundColor:n})})}const isInputElement=e=>{const t=e instanceof HTMLElement&&"VERTEX-AUTO-RESIZE-TEXTAREA"===e.tagName,n=e instanceof HTMLElement&&"VERTEX-TEXTFIELD"===e.tagName,a=e instanceof HTMLElement&&"true"===e.contentEditable,s=e instanceof HTMLElement&&"VERTEX-SCENE-TREE-SEARCH"===e.tagName,o=e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement,l=e instanceof HTMLElement&&"VERTEX-VIEWER-PIN-TOOL"===e.tagName,i=e instanceof HTMLElement&&"VERTEX-VIEWER-TRANSFORM-WIDGET"===e.tagName;return t||n||a||s||o||l||i},useRecoilReducer=({reducer:e,atom:t})=>{const a=undefined,s=undefined;return[n.useRecoilValue(t),useRecoilReducerDispatch({reducer:e,atom:t})]},useRecoilReducerDispatch=({reducer:e,atom:t})=>{const a=n.useRecoilCallback((({set:n})=>async a=>{n(t,(t=>e(t,a)))}),[]);return a},on=n.atom({key:"keyBindings",default:{applyBindings:[],bindings:{},pressed:{}}});function reducer(e,t){var n,a,s,o;switch(t.type){case"push-key-binding":const l=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!==(a=e.bindings[t.binding.keyBind])&&void 0!==a?a:[],t.binding]})});case"remove-key-binding":const i=undefined;return null==(null===(s=e.bindings[t.binding.keyBind])||void 0===s?void 0:s.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:[]).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:on});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 a;return null!=e.keyBind&&null!=n&&(null===(a=e.keyBind)||void 0===a?void 0:a.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();a.useEffect((()=>{const a=O.create();return n({type:"add-apply-key-binding",binding:Object.assign(Object.assign({},e),{id:a,active:null!=e.keyBind&&allPressed(e.keyBind,t.pressed)})}),()=>{n({type:"remove-apply-key-binding",id:a})}}),[e.fn,e.off,e.keyBind,e.repeat])},useStackKeyBinding=(e,t=[])=>{const[,n]=useKeyBindingState();a.useEffect((()=>{const t=null==e.addPredicate||e.addPredicate(),a=null!=e.cancelPredicate&&e.cancelPredicate();t&&n({type:"push-key-binding",binding:e}),a&&n({type:"remove-key-binding",binding:e})}),t)},useKeyBindings=({keydownRepeatInterval:e=25,keydownIgnorePredicate:t=isInputElement}={})=>{const[n,s]=useKeyBindingState(),o=a.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],a=t.length>0?t[t.length-1]:void 0;null!=a&&(a.fn(),s({type:"remove-key-binding",binding:a}))}))}),[n]);a.useEffect((()=>{const handleKeyDown=e=>{if(!e.repeat&&!t(e.target)){s({type:"set-key-pressed",key:e.key,pressed:!0}),o(e.key);const t=Object.assign(Object.assign({},n.pressed),{[e.key]:!0}),a=matchingSingleFnBindings(n.applyBindings,t,e.key),l=matchingOffBindings(n.applyBindings,t,e.key);(a.length>0||l.length>0)&&e.preventDefault()}},handleKeyUp=e=>{s({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)}}),[o,n.applyBindings,n.pressed]),a.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]),a.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(),a=n.useRecoilValue(Me);return useStackKeyBinding({id:"ExitBoxSelection",keyBind:"Escape",fn:t.disable,addPredicate:()=>a,cancelPredicate:()=>!a},[a]),e.jsx(o.VertexTooltip,{content:"Box Selection",children:e.jsx(o.VertexIconButton,{iconName:"box-cursor",iconColor:a?"primary":"secondary","data-testid":"viewer-toolbar-enable-box-selection-button",onClick:a?t.disable:t.enable})})},ln=1,VertexResizableContent=t=>{var{className:n,style:a,displayShadow:s,heading:l,id:i,initialScale:r,placement:c="left",children:u,onResize:d}=t,m=__rest(t,["className","style","displayShadow","heading","id","initialScale","placement","children","onResize"]);const p="left"===c||"right"===c,h="top"===c;function getHorizontalResizeDirection(){switch(c){case"left":return"right";case"right":return"left";default:return"none"}}function getVerticalResizeDirection(){return"top"===c?"top":"none"}const g=null!=r?r:1;return e.jsx(o.VertexResizable,Object.assign({id:i,"data-testid":`resizable-content-position-${c}`,className:Ve(n,"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"===c,"sidebar-shadow-right":"left"===c&&s,"border-l min-w-75 max-w-half":"right"===c,"sidebar-shadow-left":"right"===c&&s,"border-t bottom-0 fixed":"top"===c,"min-h-12 sheet":h}),style:Object.assign({maxHeight:"top"===c?window.innerHeight:void 0},a),initialHorizontalScale:p?r:void 0,initialVerticalScale:h?g:void 0,horizontalDirection:getHorizontalResizeDirection(),verticalDirection:getVerticalResizeDirection(),position:"right"===c||"top"===c?"absolute":"relative",onResizeEnd:()=>null==d?void 0:d()},m,{children:e.jsxs("div",{className:"flex flex-col h-full w-full",children:["top"===c&&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"})}),l,e.jsx("div",{className:Ve("w-full flex flex-col h-0 flex-grow",{"right-0":"right"===c}),children:u})]})}))};function useDefaultKeybindings(){useApplyKeyBinding({fn:useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromiseRequired(H),n={milliseconds:500},a=await t();await(null==a?void 0:a.camera().viewAll().render({animation:n}))})),keyBind:"f"})}function useLongPress({target:e,callback:t,delay:n=500,onMovement:a}){const[o,l]=u.useState(),[i,r]=u.useState();u.useEffect((()=>{const handleTouchStart=e=>{const a=e;null!=a.touches&&1===a.touches.length&&(null!=o&&clearTimeout(o),r(s.Point.create(a.touches[0].clientX,a.touches[0].clientY)),l(setTimeout((()=>null==t?void 0:t(a)),n)))},handleTouchMove=e=>{const t=e;null!=t.touches&&t.touches.length>0&&null!=o&&null!=i&&s.Point.distance(i,s.Point.create(t.touches[0].clientX,t.touches[0].clientY))>=2&&(clearTimeout(o),null==a||a())},handleTouchEnd=()=>{null!=o&&clearTimeout(o)};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,o,i])}function asBooleanAttribute(e){return!!e||void 0}const VertexContextMenu=({targetElement:t,menuType:s,disableBackdrop:l,openPredicate:i,onOpen:r,onClose:c,children:u})=>{const d=useContextMenuActions(),m=n.useRecoilValue(Pe),p=n.useRecoilValue(Oe),h=a.useMemo((()=>["bottom-end","top-start","top-end","right","left"]),[]),g=m===s;useStackKeyBinding({id:"ContextMenu",keyBind:"Escape",fn:d.clearActiveContextMenu,addPredicate:()=>null!=m&&m===s,cancelPredicate:()=>null==m},[m]);const f=a.useMemo((()=>null!=t?t:null!=i?window:void 0),[t,i]);return useLongPress({target:f,callback:e=>d.longPress(e,s,i,r),onMovement:()=>d.clearActiveContextMenu()}),a.useEffect((()=>{const handleWindowPointerDown=e=>{const t=undefined;if(!targetWithinMenu(e)&&2!==e.buttons&&m===s){const t=targetShouldSkipNextHit(e);d.clearActiveContextMenu(t)}};if(l)return window.addEventListener("pointerdown",handleWindowPointerDown),()=>{window.removeEventListener("pointerdown",handleWindowPointerDown)}}),[l,s,m]),a.useEffect((()=>{const handlePointerDown=e=>{d.pointerDown(e)},handlePointerUp=e=>{d.pointerUp(e,s,i,r)},handleContextMenu=e=>d.contextMenu(e,i);return null==f||f.addEventListener("pointerdown",handlePointerDown),null==f||f.addEventListener("pointerup",handlePointerUp),null==f||f.addEventListener("contextmenu",handleContextMenu),()=>{null==f||f.removeEventListener("pointerdown",handlePointerDown),null==f||f.removeEventListener("pointerup",handlePointerUp),null==f||f.removeEventListener("contextmenu",handleContextMenu)}}),[t,s,i]),e.jsx("div",{className:Ve({hidden:!g}),children:e.jsx(o.VertexMenu,{"data-testid":`${s}-context-menu`,open:asBooleanAttribute(g),position:p,fallbackPlacements:h,backdrop:!l,onMenuClosed:()=>{d.clearActiveContextMenu(),null==c||c()},children:e.jsx("div",{className:"pt-1",children:u})})})},VertexFitSelectedMenuItem=()=>{const t=n.useRecoilValue(ot),a=n.useRecoilValue(pt),s=useViewerCameraActions();return e.jsxs(o.VertexMenuItem,{"data-testid":"fit-selected-menu-option",onClick:()=>{null!=(null==a?void 0:a.boundingBox)&&s.flyToByBoundingBox(a.boundingBox)},disabled:asBooleanAttribute(0===t.length),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"fit-selected",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Fit Selected"})]})},VertexFlyToMenuItem=()=>{const t=useViewerCameraActions(),a=n.useRecoilValue(Re);return e.jsxs(o.VertexMenuItem,{"data-testid":"fly-to-part-menu-option",onClick:()=>{var e;const n=undefined,s=contextMenuItemIsRow(a)?null===(e=null==a?void 0:a.node.id)||void 0===e?void 0:e.hex:null==a?void 0:a.id;null!=s&&t.flyToById(s)},disabled:asBooleanAttribute(null==a),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"paper-airplane",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Fly To"})]})};function useSceneItemsOperations(){const e=n.useRecoilValue(M),t=undefined,s=undefined,o=undefined,l=undefined,i=undefined,r=undefined;return{sceneItemsOperation:a.useCallback((async(t,n)=>{const a=await(null==e?void 0:e.scene());null==n?await(null==a?void 0:a.items((e=>t(e.where((e=>e.all()))))).execute()):n.length>0&&await(null==a?void 0:a.items((e=>t(e.where((e=>e.withItemIds(n)))))).execute())}),[e]),showOnlySelected:a.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:a.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:a.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:a.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:a.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(o.VertexMenuItem,{"data-testid":"hide-all-menu-option",onClick:()=>{t.sceneItemsOperation((e=>e.hide()))},children:[e.jsx(o.VertexIcon,{slot:"icon",name:"visibility-hidden",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Hide All Parts"})]})},VertexHidePartMenuItem=()=>{const t=n.useRecoilValue(Re),a=useSceneItemsOperations();return e.jsxs(o.VertexMenuItem,{"data-testid":"hide-menu-option",onClick:()=>{var e;const n=undefined,s=contextMenuItemIsRow(t)?null===(e=null==t?void 0:t.node.id)||void 0===e?void 0:e.hex:t.id;null!=s&&a.sceneItemsOperation((e=>e.hide()),[s])},disabled:asBooleanAttribute(null==t),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"visibility-hidden",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Hide Part"})]})},VertexHideSelectedMenuItem=()=>{const t=n.useRecoilValue(ot),a=useSceneItemsOperations();return e.jsxs(o.VertexMenuItem,{"data-testid":"hide-selected-menu-option",onClick:()=>a.hideSelected(),disabled:asBooleanAttribute(0===t.length),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"visibility-hidden",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Hide Selected"})]})},VertexShowAllMenuItem=()=>{const t=useSceneItemsOperations();return e.jsxs(o.VertexMenuItem,{"data-testid":"show-all-menu-option",onClick:()=>{t.sceneItemsOperation((e=>e.show()))},children:[e.jsx(o.VertexIcon,{slot:"icon",name:"visibility-visible",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Show All Parts"})]})},VertexShowOnlyMenuItem=()=>{const t=n.useRecoilValue(Re),a=useSceneItemsOperations();return e.jsxs(o.VertexMenuItem,{"data-testid":"show-only-menu-option",onClick:()=>{var e;const n=undefined,s=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!=s&&a.showOnlyItem(s)},disabled:asBooleanAttribute(null==t),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"visibility-visible",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Show Only Part"})]})},VertexShowOnlySelectedMenuItem=()=>{const t=n.useRecoilValue(ot),a=useSceneItemsOperations();return e.jsxs(o.VertexMenuItem,{"data-testid":"show-only-selected-menu-option",onClick:()=>a.showOnlySelected(),disabled:asBooleanAttribute(0===t.length),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"visibility-visible",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Show Only Selected"})]})};n.atom({key:"sceneTreeLoaderVisible",default:!1});const rn=n.atom({key:"sceneTreeElement",default:void 0}),cn=n.atom({key:"sceneTreeController",default:void 0,dangerouslyAllowMutability:!0});function useSceneTreeActions(){const e=useSelectionActions(),t=useViewerCameraActions();return{toggleSelection:useActionCallback((({snapshot:t})=>async(n,a,s)=>{var o,l;if(!n.defaultPrevented&&0===n.button&&(n.altKey||((n.ctrlKey||n.metaKey)&&a.selected?await s.deselectItem(a):a.selected?await s.selectItem(a,{recurseParent:!0}):a.selected||await s.selectItem(a,{append:n.ctrlKey||n.metaKey,range:n.shiftKey})),null!=a.id)){const s=await t.getPromise(lt);e.syncSelection({id:null===(o=a.id)||void 0===o?void 0:o.hex,ancestors:null!==(l=null==s?void 0:s.ancestors)&&void 0!==l?l:[]},{selected:!n.metaKey&&!n.ctrlKey||!a.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 a;const s=await e.getPromise(rn),o=await(null==s?void 0:s.getRowAtClientY(n));null!=(null===(a=null==o?void 0:o.node.id)||void 0===a?void 0:a.hex)&&await t.flyToById(o.node.id.hex)})),flyToFirstSelectedItem:useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromise(rn),n=await e.getPromise(ut);null!=n&&(null==t||t.scrollToItem(n))})),setContextMenuItem:useActionCallback((({set:e,snapshot:t})=>async n=>{const a=await t.getPromise(rn),s=await(null==a?void 0:a.getRowAtClientY(n));e(Re,s)}))}}const VertexGhostSelectedMenuItem=()=>{const t=n.useRecoilValue(ot),a=useSceneItemsOperations();return e.jsxs(o.VertexMenuItem,{"data-testid":"ghost-selected-menu-option",onClick:()=>a.ghostSelected(),disabled:asBooleanAttribute(0===t.length),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"visibility-partial",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Ghost Selected"})]})},VertexUnghostSelectedMenuItem=()=>{const t=n.useRecoilValue(ot),a=useSceneItemsOperations();return e.jsxs(o.VertexMenuItem,{"data-testid":"unghost-selected-menu-option",onClick:()=>a.unGhostSelected(),disabled:asBooleanAttribute(0===t.length),children:[e.jsx(o.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(o.VertexMenuDivider,{}),e.jsx(VertexFitSelectedMenuItem,{}),e.jsx(VertexFlyToMenuItem,{})]}),VertexSceneTreeContextMenu=({children:t})=>{const a=useSceneTreeActions(),s=n.useRecoilValue(rn),o=null!=t&&!1!==t;return e.jsx(VertexContextMenu,{menuType:"scene-tree",targetElement:s,onOpen:async(e,t)=>{const n=e;await a.setContextMenuItem(n.clientY)},disableBackdrop:!0,children:o?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(o.VertexMenuDivider,{}),e.jsx(VertexFitSelectedMenuItem,{}),e.jsx(VertexFlyToMenuItem,{})]}),VertexViewerContextMenu=({children:t})=>{const n=null!=t&&!1!==t,s=a.useCallback((e=>e.target instanceof HTMLElement&&"vertex-viewer"===e.target.id),[]);return e.jsx(VertexContextMenu,{menuType:"viewer",disableBackdrop:!0,openPredicate:s,children:n?t:e.jsx(DefaultViewerContextMenu,{})})},un=35,dn=n.atom({key:"sceneItemGhostingSelectedOpacity",default:un}),mn=n.atomFamily({key:"appliedItemPhantomState",default:void 0}),pn=n.atom({key:"appliedItemPhantomStateIds",default:[]}),xn=n.selector({key:"sceneItemGhostingLastSelectedPhantom",get:({get:e})=>{var t;const n=e(lt);return null!=n&&(null!==(t=e(mn(n.id)))&&void 0!==t&&t)}}),VertexSceneItemGhostingOpacitySlider=({onApply:t})=>{const[a,s]=n.useRecoilState(dn);return e.jsx(VertexSlider,{id:"phantom-opacity","data-testid":"phantom-opacity-slider",leftLabel:"0%",rightLabel:"100%",min:0,max:100,step:5,value:a,valueLabelDisplay:"auto",onValueInput:e=>{s(e.detail.value)},onValueChange:e=>{null==t||t(e.detail.value)}})},useSceneItemPhantomActions=()=>{const e=useViewerSceneActions(),t=useActionCallback((({snapshot:e,reset:t})=>async()=>{const n=undefined;(await e.getPromise(pn)).forEach((e=>t(mn(e)))),t(pn)}));return{setPhantomState:useActionCallback((({snapshot:t,set:n})=>async a=>{const s=await t.getPromise(ot);s.forEach((e=>n(mn(e),a))),n(pn,(e=>[...e,...s])),await e.execute(tt.SET_PHANTOM_SELECTED_ITEMS,(e=>e.where((e=>e.withSelected())).setPhantom(a)))})),clearPhantomState:useActionCallback((({snapshot:t,set:n,reset:a})=>async()=>{const s=await t.getPromise(ot);s.forEach((e=>a(mn(e)))),n(pn,(e=>e.filter((e=>!s.includes(e))))),await e.execute(tt.CLEAR_PHANTOM_SELECTED_ITEMS,(e=>e.where((e=>e.withSelected())).clearPhantom()),(e=>e.where((e=>e.withSelected())).select()))})),clearAllPhantomState:useActionCallback((()=>async()=>{await t(),await e.execute(tt.CLEAR_PHANTOM_ALL,(e=>e.where((e=>e.all())).clearPhantom()),(e=>e.where((e=>e.withSelected())).select()))})),resetAllPhantomState:t}},VertexSceneItemGhostingToggle=({onApply:t})=>{const a=useSceneItemPhantomActions(),s=n.useRecoilValue(gt),l=n.useRecoilValueLoadable(xn);return e.jsx(o.VertexTooltip,{content:"Select a part to display as ghost",disabled:s,children:e.jsx(o.VertexToggle,{className:"flex items-center","data-testid":"phantom-state-toggle",variant:"switch",disabled:!s,checked:"hasValue"===l.state&&l.contents,onValueChanged:async e=>{await a.setPhantomState(e.detail),null==t||t(e.detail)}})})};function VertexGhostingControls({onApplyGhostingChange:t,onApplyOpacity:n}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center py-3",children:[e.jsx(VertexSceneItemGhostingToggle,{onApply:t}),e.jsx("span",{className:"pl-4 text-sm text-neutral-700",children:"Display as Ghost"})]}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Global Ghost Opacity"}),e.jsx(VertexSceneItemGhostingOpacitySlider,{onApply:n})]})}const VertexSceneItemGhostingClear=({onClear:t,onClearAll:a})=>{const s=useSceneItemPhantomActions(),l=n.useRecoilValue(xn);return e.jsx("div",{className:"ml-auto",children:e.jsxs(ResetButton,{id:"phantom",tooltip:"Clear Ghosting",children:[e.jsx("div",{className:"pt-1"}),e.jsx(o.VertexMenuItem,{"data-testid":"reset-selected-phantom",onClick:async()=>{await s.clearPhantomState(),null==t||t()},disabled:!l,children:"Clear ghosting for selected"}),e.jsx(o.VertexMenuItem,{"data-testid":"reset-all-phantom",onClick:async()=>{await s.clearAllPhantomState(),null==a||a()},children:"Clear ghosting for all"})]})})};function VertexGhostingPanelSection({onClearGhostState:t,onClearAllGhostState:n,onApplyGhostingChange:a,onApplyOpacity:s}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Ghosting",e.jsx(VertexSceneItemGhostingClear,{onClear:t,onClearAll:n})]}),children:e.jsx(VertexGhostingControls,{onApplyGhostingChange:a,onApplyOpacity:s})})}function VertexMeasurementContextMenu({onDelete:t}){const a=n.useRecoilValue(Ie);return e.jsx(VertexContextMenu,{menuType:"measurement",openPredicate:e=>e.target instanceof HTMLElement&&"VERTEX-VIEWER-MEASUREMENT-DISTANCE"===e.target.tagName,children:e.jsxs(o.VertexMenuItem,{"data-testid":"measurement-delete",onClick:()=>null!=a&&t(a.id),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"delete",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Delete"})]})})}function useDockedPlacement(e,t){const[n,a]=u.useState(s.Point.create(0,0));return u.useLayoutEffect((()=>{if(null!=e){const n=e.getBoundingClientRect(),o=s.Point.create(n.left,n.bottom),l=s.Point.create(n.right,n.bottom);a("left"===t?o:l)}}),[e,t]),n}function VertexMeasurementDetails({placement:t}){const a=useMeasurementActions(),s=n.useRecoilValue(M),l=n.useRecoilValue(L),r=useDockedPlacement(null!=s?s:null,t),c=n.useRecoilValue(qe),u=n.useRecoilValue(Ye),d=n.useRecoilValue(Xe),m=n.useRecoilValue(Ze),p=n.useRecoilValue(vt),h=n.useRecoilValue(yt);return e.jsx(o.VertexDraggablePopover,{className:"z-popover",boundaryPadding:16,boundarySelector:`#${l}`,position:r,children:e.jsxs("div",{className:"flex flex-col leading-4 min-w-40",children:[e.jsxs("div",{className:"pb-2 flex justify-between",children:[e.jsx("div",{className:"w-full",children:"Measurement"}),e.jsx("div",{className:Ve("-mt-1 relative",{hidden:!m}),children:e.jsx(o.VertexTooltip,{content:"Reset",placement:"left-start",children:e.jsx(o.VertexIconButton,{"data-testid":"measurement-details-reset",iconName:"reset",iconSize:"sm",onClick:a.resetMeasurement})})})]}),e.jsx(i.VertexViewerMeasurementDetails,{"data-testid":"measurement-details-viewer-measurement-details",className:Ve("gap-y-1.5 text-xs",{hidden:null==c}),measurementOutcome:c,measurementOverlays:u,distanceUnits:toUnitType(p),fractionalDigits:parseInt(h,10)}),e.jsx("div",{"data-testid":"measurement-details-message",className:Ve("text-xs",{hidden:null==d}),children:d})]})})}function useCallbackRef(e){var t;const[n,s]=a.useState((t=void 0,null)),o=undefined;return{element:n,callback:a.useCallback((e=>s(e)),[])}}function VertexPointToPointMeasurement({detailsPlacement:t,onPointToPointMeasurementChange:s}){const o=useMeasurementActions(),l=n.useRecoilValue(M),r=n.useRecoilValue(Be),c=n.useRecoilValue(De),u=n.useRecoilValue(vt),d=n.useRecoilValue(yt),{callback:m,element:p}=useCallbackRef();usePointToPointMeasurement(p);const h=a.useCallback((e=>{const t={start:e.detail.start,end:e.detail.end,invalid:!e.detail.valid};o.setEditedPointToPointMeasurement(t),null==s||s(t)}),[o]);return r?e.jsxs(e.Fragment,{children:[e.jsx(i.VertexViewerMeasurementDistance,{"data-testid":"point-to-point-measurement",ref:m,viewer:null!=l?l:void 0,mode:"replace",start:null==c?void 0:c.start,end:null==c?void 0:c.end,invalid:null==c?void 0:c.invalid,units:toUnitType(u),fractionalDigits:parseInt(d,10),showAxisReferenceLines:!0,onEditEnd:h}),e.jsx(VertexMeasurementDetails,{placement:t}),e.jsx(VertexMeasurementContextMenu,{onDelete:o.resetMeasurement})]}):e.jsx(e.Fragment,{})}function VertexPointToPointMeasurementTool(){const t=useMeasurementActions(),a=n.useRecoilValue(Be);return useStackKeyBinding({id:"ExitMeasurement",keyBind:"Escape",fn:t.disableEditMeasurement,addPredicate:()=>a,cancelPredicate:()=>!a},[a,t]),e.jsx(o.VertexTooltip,{content:"Point to Point Measurement",children:e.jsx(o.VertexIconButton,{iconName:"tape-measure","data-testid":"viewer-toolbar-point-to-point-measurement-button",iconColor:a?"primary":"secondary",onClick:t.toggleEditPointToPointMeasurement})})}const hn=n.atom({key:"viewerToolkitSdkConfig",default:void 0}),VertexPreciseMeasurement=({detailsPlacement:t,onEntitiesChanged:a,onOutcomeChanged:s})=>{var o,l,r,c;const u=n.useRecoilValue(M),d=n.useRecoilValue(hn),m=n.useRecoilValue(ze),{callback:p,element:h}=useCallbackRef();return usePreciseMeasurementModel(h,a,s),m?e.jsxs(e.Fragment,{children:[e.jsx(i.VertexViewerMeasurementPrecise,{"data-testid":"precise-measurement-viewer-tool",ref:p,viewer:null!=u?u:void 0,config:JSON.stringify({network:{apiHost:null===(o=null==d?void 0:d.network)||void 0===o?void 0:o.apiHost,renderingHost:null===(l=null==d?void 0:d.network)||void 0===l?void 0:l.renderingHost,sceneTreeHost:null===(r=null==d?void 0:d.network)||void 0===r?void 0:r.sceneTreeHost,sceneViewHost:null===(c=null==d?void 0:d.network)||void 0===c?void 0:c.sceneViewHost}})}),e.jsx(VertexMeasurementDetails,{placement:t})]}):e.jsx(e.Fragment,{})};function VertexPreciseMeasurementTool(){const t=useMeasurementActions(),a=n.useRecoilValue(ze);return e.jsx(o.VertexTooltip,{content:"Precise Measurement",children:e.jsx(o.VertexIconButton,{iconName:"ruler","data-testid":"viewer-toolbar-precise-measurement-button",iconColor:a?"primary":"secondary",onClick:t.toggleEditPreciseMeasurement})})}function VertexApplicationMessages(){const t=n.useRecoilValue(et),a=n.useRecoilValue(Qe);return e.jsxs(e.Fragment,{children:[null!=t&&e.jsx(o.VertexBanner,{className:"z-[16000]",duration:t.duration,open:!0,content:t.message,type:t.type},t.id),null!=a&&e.jsx(o.VertexToast,{placement:"bottom-left",className:"z-[16000]",duration:a.duration,open:!0,content:a.message,type:a.type},a.id)]})}const gn={binding:"{{row.node.name}}",label:"Name",metadataKeyName:"VERTEX_SCENE_ITEM_NAME"};function mapToColumn(e,t){return{label:"name"===e.toLowerCase()?"Name (Property)":e,binding:`{{row.metadata.${e}}}`,initialWidth:t,minWidth:t/2}}const fn=n.atom({key:"sceneTreeColumnsRefreshTrigger",default:0}),vn=n.selector({key:"sceneTreeColumnsAvailableColumns",get:async({get:e})=>{const t=e(cn);return e(fn),null!=t?await t.fetchMetadataKeys():[]}}),yn=n.selector({key:"sceneTreeColumnsAvailableSortedColumns",get:({get:e})=>e(vn).filter((e=>e!==gn.metadataKeyName)).sort(((e,t)=>e.localeCompare(t)))}),bn=n.atom({key:"sceneTreeColumnsVisibleMetadataColumnNames",default:[]}),Sn=n.selector({key:"sceneTreeColumnsActiveColumns",get:({get:e})=>{const t=e(bn),n=e(rn),a=null==n?void 0:n.clientWidth;if(null!=a&&a>0){const e=1/(t.length+1)*a,n=(a-e)/t.length;return t.reduce(((e,t)=>{const a=mapToColumn(t,n);return Object.assign(Object.assign({},e),{[a.label]:a})}),{Name:Object.assign(Object.assign({},gn),{initialWidth:e,minWidth:n})})}return{Name:gn}}}),wn=n.selector({key:"sceneTreeColumnsActiveColumnNames",get:({get:e})=>Object.keys(e(Sn))});function useSceneTreeColumnActions(){return{setActive:useActionCallback((({set:e,snapshot:t})=>async n=>{e(bn,n);const a=await t.getPromise(cn);null==a||a.setMetadataKeys(n)})),refreshKeyList:useActionCallback((({set:e})=>()=>{e(fn,(e=>e+1))}))}}const Cn=16,Vn=-8;var jn;function useOpenColumnPopover({buttonElement:e,horizontalOffset:t,verticalOffset:n}){const[a,s]=u.useState(!1),[o,l]=u.useState(),[i,r]=u.useState(),c=u.useCallback((()=>{if(a)s(!1);else{const a=null==e?void 0:e.getBoundingClientRect();if(null!=a){const e=null!=t?t:Cn,o=null!=n?n:Vn,i=a.x>window.innerWidth/2?jn.LEFT:jn.RIGHT;l({x:i===jn.LEFT?a.left-e:a.right+e,y:a.top+o}),r(i),s(!0)}}}),[a,e]),d=u.useCallback((()=>{s(!1)}),[]);return{open:a,position:o,direction:i,handleOpen:c,handleClose:d}}!function(e){e.LEFT="left",e.RIGHT="right"}(jn||(jn={}));const Tn=n.atom({key:"sceneTreeSearchActive",default:!1}),kn=n.atom({key:"sceneTreeColumnsPartial",default:!1}),An=n.atom({key:"sceneTreeSearchValue",default:void 0}),Pn=n.atom({key:"sceneTreeSearchExactMatch",default:!1}),En=n.atom({key:"sceneTreeSearchResultCount",default:0}),In=n.atom({key:"sceneTreeSearchActiveColumns",default:[]}),Rn=n.selector({key:"sceneTreeSearchNameColumnActive",get:({get:e})=>{const t=e(In);return 0===t.length||t.includes(gn.metadataKeyName)}});function useSceneTreeSearch({sceneTreeElement:e}){const t=useSceneTreeActions(),s=n.useRecoilValue(Tn),o=n.useSetRecoilState(En),l=n.useSetRecoilState(ut);a.useEffect((()=>{let t;return whenComponentReady(e,(()=>{var n;t=null===(n=null==e?void 0:e.controller)||void 0===n?void 0:n.stateChanged((e=>{void 0!==(null==e?void 0:e.totalFilteredRows)&&o(null==e?void 0:e.totalFilteredRows)}))})),()=>{null==t||t.dispose()}}),[e]),a.useEffect((()=>{if(null!=e){let n;return whenComponentReady(e,(()=>{var a;n=null===(a=null==e?void 0:e.controller)||void 0===a?void 0:a.stateChanged((e=>{var n;if(null!=(null==e?void 0:e.filterTerm)){const t=null==e?void 0:e.rows.find((e=>{var t;return null===(t=null==e?void 0:e.node)||void 0===t?void 0:t.selected}));l(null===(n=null==t?void 0:t.node.id)||void 0===n?void 0:n.hex)}else s&&t.flyToFirstSelectedItem()}))})),()=>{null==n||n.dispose()}}}),[e,null==e?void 0:e.controller,open])}function useSceneTreePartialResults({sceneTreeElement:e}){const t=n.useSetRecoilState(kn);a.useEffect((()=>{let n;return whenComponentReady(e,(()=>{var a;n=null===(a=null==e?void 0:e.controller)||void 0===a?void 0:a.stateChanged((e=>{t(!!(null==e?void 0:e.isPartialKeysResponse))}))})),()=>{null==n||n.dispose()}}),[e])}const useSceneTreeSearchActions=()=>{const e=useActionCallback((({set:e})=>t=>{e(In,t)})),t=useActionCallback((({snapshot:e})=>async t=>{const n=await e.getPromise(rn),a=await e.getPromise(Pn),s=await e.getPromise(In),o=a?[gn.metadataKeyName]:[],l=s.length>0?s:o;null==n||n.filterItems(t,{columns:l,exactMatch:a})})),n=useActionCallback((({snapshot:t})=>async(n,a)=>{const s=await t.getPromise(In);if(a)e(0===s.length?[gn.metadataKeyName,n]:[...s,n]);else{const t=s.filter((e=>e!==n));e(t.every((e=>e===gn.metadataKeyName))?[]:t)}})),a=useActionCallback((({set:e})=>t=>{e(Pn,t)}));return{setMetadataSearchKeys:e,updateSearchForActiveColumns:t,updateMetadataSearchAfterSearchKeysChange:n,setMetadataSearchExactMatch:a}};function useCacheableLoadable(e,t){const s=a.useRef(),[o,l]=a.useState(0),i=n.useRecoilValueLoadable(e);a.useEffect((()=>{"hasValue"===i.state&&(s.current=i.contents)}),[t,i]);const[r,c]=a.useMemo((()=>"hasValue"!==i.state&&null!=s.current?[s.current,!0]:"hasValue"===i.state?[i.contents,!1]:[void 0,!1]),[i.state,i.contents,o]),u=a.useCallback((()=>{s.current=void 0,l(o+1)}),[o]),d=undefined;return a.useMemo((()=>({data:r,state:i.state,cached:c,invalidate:u})),[u,r,c,i.state])}const VertexSceneTreeMetadataCheck=({checked:t,disabled:n,onChange:a,children:s})=>{const l="string"==typeof s?s.replace(" ","-"):"";return e.jsxs("div",{className:"flex items-center",children:[e.jsx(o.VertexToggle,{"data-testid":`scene-tree-metadata-check-${l}`,variant:"check",checked:t,disabled:n,onValueChanged:e=>null==a?void 0:a(e.detail)}),e.jsx("div",{className:"pl-2 py-1 text-[0.875rem] w-full","data-testid":`scene-tree-metadata-name-${l}`,onClick:()=>{n||null==a||a(!t)},children:s})]})},VertexSceneTreeColumnPopover=({onVisibleSceneTreeColumnsChange:t})=>{const a=useSceneTreeColumnActions(),s=useSceneTreeSearchActions(),l=n.useRecoilValue(rn);useSceneTreePartialResults({sceneTreeElement:null!=l?l:null});const r=n.useRecoilValue(An),c=useCacheableLoadable(yn),d=n.useRecoilValue(bn),m=n.useRecoilValue(kn),p=n.useRecoilValue(In),[h,g]=u.useState(d),[f,v]=u.useState(""),{element:b,callback:S}=useCallbackRef(),{open:w,position:C,direction:V,handleOpen:j,handleClose:T}=useOpenColumnPopover({buttonElement:b}),k=V===jn.LEFT?"left-end":"right-start",A=u.useMemo((()=>{if(null!=c.data){const e=c.data.filter((e=>h.indexOf(e)<0)),t=undefined;return[...[...h].sort(((e,t)=>e.localeCompare(t))),...e]}return[]}),[h,c.data]),P=u.useMemo((()=>A),[w,c.data]);return e.jsxs(e.Fragment,{children:[e.jsx(o.VertexTooltip,{content:"Configure Columns",placement:"top",children:e.jsx(o.VertexIconButton,{"data-testid":"scene-tree-column-popover-button",ref:S,iconName:"columns-add",iconSize:"sm",onClick:()=>{j()}})}),w&&e.jsx(o.VertexPopover,{"data-testid":"scene-tree-column-popover",open:w,backdrop:!1,position:C,resizeBehavior:"fixed",placement:k,className:"z-popover",children:e.jsxs("div",{className:Ve("flex flex-col bg-white border border-neutral-300 rounded",{hidden:!w}),children:[e.jsxs("div",{className:"flex items-center text-[0.875rem] p-3",children:[e.jsxs("div",{className:"pr-2",children:[e.jsx("div",{className:"text-[0.875rem]",children:"Assembly Properties"}),e.jsx("div",{className:"text-[0.75rem] text-neutral-700 mt-1.5",children:"Select up to six properties to appear in the Assembly panel."})]}),e.jsx(o.VertexIconButton,{"data-testid":"scene-tree-columns-popover-close-button",className:"ml-auto",iconName:"close",iconSize:"sm",onClick:()=>{v(""),T()}})]}),e.jsx(o.VertexTextfield,{className:"flex w-full px-2 overflow-hidden border-b border-neutral-300 pb-2",id:"scene-tree-available-columns-search-bar","data-testid":"scene-tree-available-columns-search-bar",multiline:!1,placeholder:"Filter properties",type:"text",onInputInput:e=>{const t=e.detail.value;null!=t&&v(t.toLowerCase())}}),m&&e.jsx(i.VertexSceneTreeNotificationBanner,{"data-testid":"partial-key-list-notification-banner",message:"loading"===c.state?"Refreshing results...":"Data loading, refresh for more.",actionLabel:"Refresh",onAction:()=>a.refreshKeyList()}),e.jsxs("div",{className:"max-h-64 p-3 overflow-y-auto",children:[e.jsx(VertexSceneTreeMetadataCheck,{checked:!0,disabled:!0,children:gn.label}),P.filter((e=>""===f||e.toLowerCase().includes(f))).map((t=>e.jsx(VertexSceneTreeMetadataCheck,{checked:h.includes(t),disabled:h.length>=6&&!h.includes(t),onChange:e=>{g(e?[...h,t]:h.filter((e=>e!==t)))},children:t},t)))]}),e.jsxs("div",{className:"flex items-center p-3 border-t border-neutral-300 space-x-4",children:[e.jsx("div",{className:"text-[0.75rem] text-[var(--vertex-ui-blue-700)] cursor-pointer","data-testid":"scene-tree-column-clear-selection",onClick:()=>g([]),children:"Clear selection"}),e.jsx("div",{className:"flex-grow"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(o.VertexButton,{"data-testid":"scene-tree-column-popover-cancel",color:"secondary",onClick:()=>{v(""),T()},children:"Cancel"}),e.jsx(o.VertexButton,{"data-testid":"scene-tree-column-popover-apply",color:"primary",onClick:async()=>{await a.setActive(h),null==t||t(h),v(""),T();const e=[gn.metadataKeyName,...h],n=p.filter((t=>!e.includes(t)));n.length>0&&(await Promise.all(n.map((e=>s.updateMetadataSearchAfterSearchKeysChange(e,!1)))),null!=r&&await s.updateSearchForActiveColumns(r))},children:"Apply"})]})]})]})})]})},VertexSceneTreeSearchOptionsPopover=({onSearchedSceneTreeColumnsChange:t,onSearchForExactMatchChange:a})=>{const s=useSceneTreeSearchActions(),l=n.useRecoilValue(Rn),i=n.useRecoilValue(In),r=n.useRecoilValue(An),c=n.useRecoilValue(Pn),u=n.useRecoilValue(bn),{element:d,callback:m}=useCallbackRef(),{open:p,position:h,direction:g,handleOpen:f,handleClose:v}=useOpenColumnPopover({buttonElement:d,horizontalOffset:40}),b=g===jn.LEFT?"left-end":"right-start";return e.jsxs(e.Fragment,{children:[e.jsx(o.VertexTooltip,{content:"Search Options",placement:"top",children:e.jsx(o.VertexIconButton,{"data-testid":"scene-tree-search-options-popover-button",ref:m,iconName:"gear",iconSize:"sm",onClick:()=>{f()}})}),e.jsx(o.VertexPopover,{"data-testid":"scene-tree-search-options-popover",open:p,backdrop:!1,position:h,resizeBehavior:"fixed",placement:b,className:"z-popover",children:e.jsxs("div",{className:Ve("flex flex-col bg-white border border-neutral-300 rounded",{hidden:!p}),children:[e.jsxs("div",{className:"flex items-center text-[0.875rem] p-3 border-b border-neutral-300 pb-2",children:[e.jsx("div",{className:"pr-2 text-[0.875rem] whitespace-nowrap",children:"Column Properties Search"}),e.jsx(o.VertexIconButton,{className:"ml-auto",iconName:"close",iconSize:"sm",onClick:()=>{v()}})]}),e.jsxs("div",{className:"max-h-64 p-3 overflow-y-auto",children:[e.jsx("div",{className:"text-[0.875rem] pb-2 pr-2",children:"Select properties to perform the search on:"}),e.jsx(VertexSceneTreeMetadataCheck,{checked:l,disabled:0===i.length||i.every((e=>e===gn.metadataKeyName)),onChange:async e=>{await s.updateMetadataSearchAfterSearchKeysChange(gn.metadataKeyName,e),null==t||t(),null!=r&&await s.updateSearchForActiveColumns(r)},children:gn.label},gn.metadataKeyName),u.map((n=>e.jsx(VertexSceneTreeMetadataCheck,{checked:i.includes(n),disabled:i.length>0&&i.every((e=>e===n)),onChange:async e=>{await s.updateMetadataSearchAfterSearchKeysChange(n,e),null==t||t(),null!=r&&await s.updateSearchForActiveColumns(r)},children:n},n)))]}),e.jsxs("div",{className:"flex p-3 border-t border-neutral-300",children:[e.jsx(o.VertexToggle,{className:"flex items-center","data-testid":"filter-exact-match-toggle",variant:"switch",checked:c,onValueChanged:async e=>{s.setMetadataSearchExactMatch(e.detail),null==a||a(),null!=r&&await s.updateSearchForActiveColumns(r)}}),e.jsx("span",{className:"pl-4 text-[0.875rem] text-neutral-800",children:"Return only exact matches"})]})]})})]})},VertexSceneTreeSearchBar=({onSearch:t,onClearSearch:a,onExitSearchMode:s,onSearchedSceneTreeColumnsChange:l,onSearchForExactMatchChange:r,children:c})=>{const d=useSceneTreeActions(),m=n.useRecoilValue(rn),[p,h]=n.useRecoilState(Tn),[g,f]=n.useRecoilState(An);useSceneTreeSearch({sceneTreeElement:null!=m?m:null});const{element:v,callback:b}=useCallbackRef(),S=null==g||""===g,w=S?"Exit Search":"Clear Search";return u.useEffect((()=>{p&&(null==v||v.setFocus())}),[v,p]),e.jsxs("div",{className:"flex w-full py-3 px-2",children:[e.jsx(i.VertexSceneTreeSearch,{"data-testid":"scene-tree-search-bar",ref:b,controller:null==m?void 0:m.controller,onBlur:()=>{S&&(h(!1),null==s||s())},onSearch:()=>{f(null==v?void 0:v.value),null==t||t(null==v?void 0:v.value)},children:c}),e.jsx("div",{className:"self-center px-1",onPointerDown:e=>{e.preventDefault()},children:e.jsx(VertexSceneTreeSearchOptionsPopover,{onSearchedSceneTreeColumnsChange:l,onSearchForExactMatchChange:r})}),e.jsx(o.VertexTooltip,{className:"self-center pr-1",content:w,children:e.jsx(o.VertexIconButton,{"data-testid":"scene-tree-search-close-button",iconName:"close-circle-fill",iconSize:"sm",variant:"plain",onPointerDown:e=>{e.preventDefault()},onClick:async()=>{S?(h(!1),await d.flyToFirstSelectedItem(),null==s||s()):(await(null==v?void 0:v.clear()),await(null==v?void 0:v.setFocus()),f(void 0),null==a||a())}})})]})};function VertexToolbarDivider(){return e.jsx("div",{"data-testid":"toolbar-divider",className:"h-6 w-px bg-neutral-300 mx-1"})}const VertexSceneTreeSearchInformationForToolbar=()=>{const t=useSelectionActions(),a=n.useRecoilValue(rn),s=n.useRecoilValue(An),l=n.useRecoilValue(En),i=undefined,r=undefined,c=`${l>=1e3?`${l}+`:`${l}`} ${1===l?"result":"results"}`;return e.jsxs(e.Fragment,{children:[e.jsx(VertexToolbarDivider,{}),e.jsxs("div",{className:"flex flex-row items-center overflow-hidden",children:[e.jsx("div",{className:"px-2 text-[0.8125rem] leading-4 text-neutral-900 truncate","data-testid":"search-result-info",children:`${c}`}),e.jsx(o.VertexTooltip,{className:"w-auto",content:"Select Results",placement:"top",children:e.jsx(o.VertexButton,{className:"h-6 rounded cursor-pointer","data-testid":"select-search-results-button",color:"secondary",variant:"text",size:"sm",onClick:async()=>{null!=a&&null!=s&&(await a.selectFilteredItems(s),t.toggleLastSelectWasMultiSelect(!0))},children:e.jsxs("div",{className:"flex h-6 items-center gap-1",children:[e.jsx(o.VertexIcon,{size:"sm",name:"check-circle"}),e.jsx("span",{className:"whitespace-nowrap",children:"Select Results"})]})})})]})]})},targetIsElement=(e,t)=>e instanceof Element&&e.tagName===t;function useRecoilRef({state:e}){const t=n.useRecoilCallback((({set:t})=>n=>{t(e,n)}),[]);return t}var Nn;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===Nn.ROBOTO_MONO?"var(--vertex-ui-font-family-monospace)":"var(--vertex-ui-font-family)"}!function(e){e.ROBOTO="ROBOTO",e.ROBOTO_MONO="ROBOTO_MONO"}(Nn||(Nn={}));const VertexEnterSceneTreeSearchModeButton=({onEnterSearchMode:t})=>{const a=n.useSetRecoilState(Tn);return e.jsx(o.VertexTooltip,{className:"flex ml-auto",content:"Scene Tree Search",children:e.jsx(o.VertexIconButton,{"data-testid":"enter-scene-tree-search-mode-button",iconName:"search",iconSize:"sm",onPointerDown:e=>{e.preventDefault()},onClick:()=>{a(!0),null==t||t()}})})},VertexSceneTreeSearch=({onEnterSearchMode:t,onExitSearchMode:a,onSearch:s,onClearSearch:o,onSearchedSceneTreeColumnsChange:l,onSearchForExactMatchChange:r,children:c})=>{const u=n.useRecoilValue(Tn);return e.jsxs(i.VertexSceneTreeToolbar,{className:"h-11 p-0 border-b border-neutral-300 box-content",slot:"header",children:[u&&e.jsx(VertexSceneTreeSearchBar,{onSearch:s,onClearSearch:o,onExitSearchMode:a,onSearchedSceneTreeColumnsChange:l,onSearchForExactMatchChange:r,children:c}),!u&&e.jsx("div",{className:"ml-auto mr-2",children:e.jsx(VertexEnterSceneTreeSearchModeButton,{onEnterSearchMode:t})})]})},VertexSceneTreeCollapseAll=()=>{const t=n.useRecoilValue(rn);return e.jsx(o.VertexTooltip,{className:"w-auto",content:"Collapse All",placement:"top",children:e.jsx(o.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=n.useRecoilValue(rn);return e.jsx(o.VertexTooltip,{className:"w-auto",content:"Expand All",placement:"top",children:e.jsx(o.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()}})})},VertexSceneTreeToolbar=({onVisibleSceneTreeColumnsChange:t})=>{const a=n.useRecoilValue(An),s=null==a||""===a;return e.jsx(i.VertexSceneTreeToolbar,{className:"h-10 border-b border-neutral-300 box-border",children:e.jsxs("div",{className:"flex w-full text-neutral-700 items-center gap mx-2",children:[e.jsx(VertexSceneTreeExpandAll,{}),e.jsx(VertexSceneTreeCollapseAll,{}),!s&&e.jsx(VertexSceneTreeSearchInformationForToolbar,{}),e.jsx("div",{className:"ml-auto",children:e.jsx(VertexSceneTreeColumnPopover,{onVisibleSceneTreeColumnsChange:t})})]})})},VertexSceneTreeHeader=({onEnterSearchMode:t,onExitSearchMode:n,onSearch:a,onClearSearch:s,onVisibleSceneTreeColumnsChange:o,children:l})=>{const i=null!=l&&!1!==l;return e.jsx("div",{slot:"header",className:"flex flex-col",children:i?l:e.jsxs(e.Fragment,{children:[e.jsx(VertexSceneTreeSearch,{onEnterSearchMode:t,onExitSearchMode:n,onSearch:a,onClearSearch:s,children:e.jsx("div",{slot:"clear-icon"})}),e.jsx(VertexSceneTreeToolbar,{onVisibleSceneTreeColumnsChange:o})]})})},VertexSceneTreeTableLayout=t=>{const a=n.useRecoilValue(Sn),s=n.useRecoilValue(wn),o=[];return e.jsx(i.VertexSceneTreeTableLayout,Object.assign({"data-testid":"scene-tree-table-layout"},t,{children:s.map(((t,n)=>{var l;const r=a[t],c=null!==(l=o[n])&&void 0!==l?l:r.initialWidth;return e.jsxs(i.VertexSceneTreeTableColumn,{"data-testid":`scene-tree-table-column-${n}`,initialWidth:c,minWidth:r.minWidth,children:[e.jsx("template",{slot:"header",dangerouslySetInnerHTML:{__html:`\n <div class="text-sm text-neutral-800 my-2">\n <div class="${Ve("truncate",{"pl-2":0===n,"pr-2":n===s.length-1})}">\n ${r.label}\n </div>\n </div>\n `}}),e.jsx("template",{dangerouslySetInnerHTML:{__html:`\n <vertex-scene-tree-table-cell\n prop:value="${r.binding}"\n prop:selection-handler="{{row.data.handleSelection}}"\n prop:expansion-handler="{{row.data.handleExpansion}}"\n prop:visibility-handler="{{row.data.handleVisibility}}"\n ${0===n?"expand-toggle":""}\n ${n===s.length-1?"isolate-button visibility-toggle":""}>\n <div class="flex items-center gap-2">\n <vertex-tooltip \n class="truncate" \n prop:content="${null!=r.binding?r.binding:"--"}" \n placement="${n!==s.length-1?"right":"top"}">\n <div class="flex items-center w-full">\n <div class="truncate">${r.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 `}})]},r.label)}))}))},VertexSceneTree=t=>{var{id:s,font:o,backgroundColors:l,children:r,style:c,onPointerDown:u,onClick:d,onToggleSelection:m,onToggleExpansion:p,onToggleVisibility:h,className:g,rowData:f}=t,v=__rest(t,["id","font","backgroundColors","children","style","onPointerDown","onClick","onToggleSelection","onToggleExpansion","onToggleVisibility","className","rowData"]);const b=useSceneTreeActions(),S=useSelectionActions(),w=n.useRecoilValue(hn),C=n.useRecoilValue(M),V=n.useRecoilValue(In),j=n.useRecoilValue(Pn),T=n.useRecoilValue(An),k=null==T||""===T,A=useRecoilRef({state:rn}),P=null!=r&&!1!==r,wrappedExpansionHandler=(e,t,n)=>{b.toggleExpansion(e,t,n),null==p||p(e,t,n)},wrappedSelectionHandler=(e,t,n)=>{b.toggleSelection(e,t,n),null==m||m(e,t,n)},wrappedVisibilityHandler=(e,t,n)=>{b.toggleVisibility(e,t,n),null==h||h(e,t,n)},handleClick=e=>{e.altKey&&b.flyToRow(e.clientY),null==d||d(e)},handlePointerDown=e=>{targetIsElement(e.target,"VERTEX-SCENE-TREE-TABLE-COLUMN")&&S.clearSelection(),null==u||u(e)},E=n.useSetRecoilState(cn),handleFirstRowRendered=e=>{var t;E(e.target.controller),null===(t=null==v?void 0:v.onFirstRowRendered)||void 0===t||t.call(v,e)},I=a.useMemo((()=>({metadataSearchKeys:V,exactMatch:j})),[V,j]);return e.jsx("div",{className:Ve("flex flex-col w-full h-full",g),children:e.jsx("div",{className:"flex group h-full",children:e.jsx(i.VertexSceneTree,Object.assign({id:null!=s?s:"vertex-scene-tree","data-testid":"vertex-scene-tree",config:w,ref:A,className:Ve("flex-1",{filtered:!k}),style:Object.assign(Object.assign(Object.assign({},styleFromOptionalFont(o)),styleFromOptionalBackgroundColors(l)),c),onConnectionError:e=>{logger_error("Scene Tree Connection Error: ",e.detail)},viewer:C,onPointerDown:handlePointerDown,onClick:handleClick,rowData:e=>{var t;const n=null!==(t=null==f?void 0:f(e))&&void 0!==t?t:{};return Object.assign({handleExpansion:wrappedExpansionHandler,handleSelection:wrappedSelectionHandler,handleVisibility:wrappedVisibilityHandler},n)},searchOptions:I},v,{onFirstRowRendered:handleFirstRowRendered,children:P?r:e.jsxs(e.Fragment,{children:[e.jsx(VertexSceneTreeHeader,{}),e.jsx(VertexSceneTreeTableLayout,{}),e.jsx(VertexSceneTreeContextMenu,{})]})}))})})},VertexDecimalPlaceSelector=({onApply:t})=>{const[a,s]=n.useRecoilState(yt);return e.jsxs(o.VertexSelect,{"data-testid":"decimal-place-select",className:"w-24",value:a,onOptionChanged:e=>{s(e.detail),null==t||t(e.detail)},children:[e.jsx("div",{className:"py-1.5 px-3",children:"0"}),e.jsx("div",{className:"py-1.5 px-3",children:"1"}),e.jsx("div",{className:"py-1.5 px-3",children:"2"}),e.jsx("div",{className:"py-1.5 px-3",children:"3"})]})},VertexLengthUnitSelector=({onApply:t})=>{const[a,s]=n.useRecoilState(vt);return e.jsxs(o.VertexSelect,{"data-testid":"length-unit-select",className:"w-40",value:a,onOptionChanged:e=>{s(e.detail),null==t||t(e.detail)},children:[e.jsx("div",{"data-value":"cm",className:"py-1.5 px-3",children:"centimeters"}),e.jsx("div",{"data-value":"mm",className:"py-1.5 px-3",children:"millimeters"}),e.jsx("div",{"data-value":"m",className:"py-1.5 px-3",children:"meters"}),e.jsx("div",{"data-value":"in",className:"py-1.5 px-3",children:"inches"}),e.jsx("div",{"data-value":"ft",className:"py-1.5 px-3",children:"feet"})]})};function VertexUnitsControls({onUnitChange:t,onDecimalPlaceChange:n}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Length Unit"}),e.jsx(VertexLengthUnitSelector,{onApply:t})]}),e.jsxs("div",{children:[e.jsx("div",{className:"pt-2 pb-2 text-sm text-neutral-700",children:"Decimals"}),e.jsx(VertexDecimalPlaceSelector,{onApply:n})]})]})}function VertexUnitsPanelSection({onUnitChange:t,onDecimalPlaceChange:n}){return e.jsx(PanelSection,{header:e.jsx("div",{className:"flex items-center text-base",children:"Units"}),children:e.jsx(VertexUnitsControls,{onUnitChange:t,onDecimalPlaceChange:n})})}const On=n.atom({key:"openedPanelActivePrimaryLeft",default:void 0}),Mn=n.atom({key:"openedPanelActivePrimaryRight",default:void 0});function usePanelActions(){return{openPrimary:useActionCallback((({set:e})=>(t,n)=>{e("left"===n?On:Mn,t)})),closePrimary:useActionCallback((({set:e})=>t=>{e("left"===t?On:Mn,void 0)}))}}function childrenAsArray(e){return Array.isArray(e)?e:[e]}function filterChildElements(e,t){return childrenAsArray(e).filter((e=>a.isValidElement(e)&&e.type===t))}function DefaultAppearancePanel(){return e.jsxs("div",{className:"flex flex-col text-neutral-700 h-full overflow-y-auto",children:[e.jsx(VertexMaterialPanelSection,{}),e.jsx(VertexGhostingPanelSection,{}),e.jsx(VertexFeatureEdgesPanelSection,{}),e.jsx(VertexViewerBackgroundPanelSection,{}),e.jsx(VertexSelectionHighlightingPanelSection,{}),e.jsx(VertexCrossSectionAppearancePanelSection,{})]})}function DefaultSettingsPanel(){return e.jsx("div",{className:"flex flex-col text-neutral-700 h-full overflow-y-auto",children:e.jsx(VertexUnitsPanelSection,{})})}const VertexTransformClear=({onClear:t,onClearAll:s})=>{const l=useTransformActions(),i=useCacheableLoadable(ft),r=n.useRecoilValue(dt),c=useCacheableLoadable(Et(null!=r?r:"")),u=a.useMemo((()=>{var e;const t=null===(e=i.data)||void 0===e?void 0:e.some((e=>{var t;return null!=(null===(t=null==e?void 0:e.override)||void 0===t?void 0:t.transform)})),n=null!=c.data;return t||n}),[i,c]);return e.jsx("div",{className:"ml-auto",children:e.jsxs(ResetButton,{id:"transforms",tooltip:"Clear Transforms",children:[e.jsx("div",{className:"pt-1"}),e.jsx(o.VertexMenuItem,{"data-testid":"clear-selected-transforms",onClick:async()=>{await l.clearSelectedTransforms(),null==t||t()},disabled:!u,children:"Clear selected transforms"}),e.jsx(o.VertexMenuItem,{"data-testid":"clear-all-transforms",onClick:async()=>{await l.clearAllTransforms(),null==s||s()},children:"Clear all transforms"})]})})},VertexTransformNumericField=({bottomLabel:t,value:s,step:o,min:l,max:i,disabled:r,testId:c,onBlur:u,onInput:d,onChange:m})=>{const p=a.useRef(null),h=n.useRecoilValue(yt),[g,f]=a.useState(!0);a.useEffect((()=>{var e;const t=null!=p.current&&Number.isNaN(p.current.valueAsNumber),n=g||t;null!=p.current&&n?p.current.value=null!==(e=null==s?void 0:s.toFixed(Number(h)))&&void 0!==e?e:"":f(!0)}),[s]);const v=a.useCallback((e=>{f(!1),null==m||m(e)}),[f,m]),b=a.useCallback((e=>{f(!0),null==u||u(e),null!=p.current&&null!=s&&(p.current.value=s.toFixed(Number(h)))}),[u,s,f]);return e.jsxs("div",{children:[e.jsx("div",{className:"truncate rounded-md w-full",children:e.jsx("input",{ref:p,className:"w-full truncate border border-neutral-400 rounded-md px-2 py-1.5 hover:border-neutral-500 focus:border-neutral-500 focus:outline-none",type:"number",step:o,min:l,max:i,"data-testid":c,disabled:r,defaultValue:Number.isNaN(s)?"":null==s?void 0:s.toFixed(Number(h)),onBlur:b,onInput:d,onChange:v})}),null!=t&&e.jsx("div",{className:"flex justify-center items-center pointer-events-none text-neutral-500",children:e.jsx("span",{children:t})})]})},VertexTransformInputs=({onUpdateTransform:t})=>{const a=n.useRecoilValue(vt),s=n.useRecoilValue(ct),o=n.useRecoilValue(rt),l=s||o,i=n.useRecoilValue(dt),{transform:r,error:c,update:u}=useEditItemTransform(i),d=l?void 0:r,m=useDebouncedCallback((async e=>{await u(e),null==t||t(e)}),50);function updateTransform(e){return t=>{if(null!=d){const n=parseFloat(t.currentTarget.value);Number.isNaN(n)||null==m||m(Object.assign(Object.assign({},d),e(n,d)))}}}function updatePosition(e){return updateTransform(((t,n)=>({position:Object.assign(Object.assign({},n.position),e(t))})))}function updateRotation(e){return updateTransform(((t,n)=>({rotation:Object.assign(Object.assign({},n.rotation),e(t))})))}function updateScale(){return updateTransform((e=>e>0?{scale:e}:{}))}function updateToDefaultValueIfInvalid(e,t){return n=>{const a=parseFloat(n.currentTarget.value),s=undefined;(isNaN(a)||!!(null==t?void 0:t(a)))&&null!=d&&m(A.defaults(e,d))}}return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 text-[0.8125rem]",children:[e.jsx("span",{className:"flex w-full items-center mt-3 mb-1",children:"Position"}),e.jsxs("div",{className:"flex flex-wrap w-full gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"X"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"position-x",value:null!=d?d.position.x:void 0,bottomLabel:a,disabled:null==d,onChange:updatePosition((e=>({x:e}))),onBlur:updateToDefaultValueIfInvalid({position:{x:0}})})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"Y"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"position-y",value:null==d?void 0:d.position.y,bottomLabel:a,disabled:null==d,onChange:updatePosition((e=>({y:e}))),onBlur:updateToDefaultValueIfInvalid({position:{y:0}})})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"Z"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"position-z",value:null==d?void 0:d.position.z,bottomLabel:a,disabled:null==d,onChange:updatePosition((e=>({z:e}))),onBlur:updateToDefaultValueIfInvalid({position:{z:0}})})})]})]})]}),e.jsxs("div",{className:"mb-2 text-[0.8125rem]",children:[e.jsx("span",{className:"flex w-full items-center mt-3 mb-1",children:"Rotation"}),e.jsxs("div",{className:"flex flex-wrap w-full gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"X"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"rotation-x",value:null==d?void 0:d.rotation.x,bottomLabel:"deg",disabled:null==d,onChange:updateRotation((e=>({x:e}))),onBlur:updateToDefaultValueIfInvalid({rotation:{x:0}})})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"Y"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"rotation-y",value:null==d?void 0:d.rotation.y,bottomLabel:"deg",disabled:null==d,onChange:updateRotation((e=>({y:e}))),onBlur:updateToDefaultValueIfInvalid({rotation:{y:0}})})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"Z"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"rotation-z",value:null==d?void 0:d.rotation.z,bottomLabel:"deg",disabled:null==d,onChange:updateRotation((e=>({z:e}))),onBlur:updateToDefaultValueIfInvalid({rotation:{z:0}})})})]})]})]}),e.jsxs("div",{className:"mb-2 text-[0.8125rem]",children:[e.jsx("span",{className:"flex w-full items-center mt-3 mb-1",children:"Scale"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"scale",value:null==d?void 0:d.scale,step:.1,min:.1,disabled:null==d,onChange:updateScale(),onBlur:updateToDefaultValueIfInvalid({scale:1},(e=>e<=0))})}),l&&e.jsx("div",{className:"bg-orange-100 rounded px-3 py-2 mt-6 mb-2",children:"Input based part transformation is not yet supported for multiple parts."}),null!=c&&e.jsx("div",{className:"bg-red-100 rounded px-3 py-2 mt-6 mb-2",children:"There was a problem retrieving data. Try selecting a different part."})]})]})},VertexTransformManipulatorToggle=({onToggleTransformsManipulator:t})=>{const a=useTransformActions(),s=n.useRecoilValue(Ct),l=n.useSetRecoilState(Rt);return e.jsx(o.VertexToggle,{className:"flex items-center","data-testid":"transform-widget-toggle",variant:"switch",checked:s,onValueChanged:async()=>{s?(a.disableTransformWidget(),null==t||t(!1)):(l("world"),await a.enableTransformWidget(),null==t||t(!0))}})};function VertexTransformControls({onToggleTransformsManipulator:t,onUpdateTransform:n}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center py-3",children:[e.jsx(VertexTransformManipulatorToggle,{onToggleTransformsManipulator:t}),e.jsx("span",{className:"pl-4 text-[0.8125rem] text-neutral-700",children:"Enable manipulator"})]}),e.jsx(VertexTransformInputs,{onUpdateTransform:n})]})}function VertexTransformPanelSection({onClearTransforms:t,onClearAllTransforms:n,onToggleTransformsManipulator:a,onUpdateTransform:s}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Manual Part Transforms",e.jsx(VertexTransformClear,{onClear:t,onClearAll:n})]}),children:e.jsx(VertexTransformControls,{onToggleTransformsManipulator:a,onUpdateTransform:s})})}function DefaultTransformsPanel(){return e.jsx("div",{className:"flex flex-col text-neutral-700 h-full overflow-y-auto",children:e.jsx(VertexTransformPanelSection,{})})}const Ln="Appearance",Bn="Settings",_n="Transforms",ViewerRightPanelHeader=({additionalHeaderMap:t})=>{const a=undefined,s=getHeading(n.useRecoilValue(Mn),t);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:s})})};function getHeading(e,t={}){switch(e){case"appearance":return Ln;case"settings":return Bn;case"transforms":return _n;default:const n=null!=e?t[e]:void 0;return null!=n?n:"None"}}function VertexViewerRightOpenedPanel({children:t}){const s=n.useRecoilValue(Mn),o=a.useMemo((()=>filterChildElements(t,CustomPanelContent)),[t]),l=a.useMemo((()=>o.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.props.panelName]:t.props.panelTitle})),{})),[o]),i=a.useMemo((()=>["appearance","settings","transforms",...o.map((e=>e.props.panelName))]),[o]);return e.jsx(e.Fragment,{children:null!=s&&i.includes(s)&&e.jsxs(VertexResizableContent,{displayShadow:!0,heading:e.jsx(ViewerRightPanelHeader,{additionalHeaderMap:l}),placement:"right",children:["appearance"===s&&e.jsx(DefaultAppearancePanel,{}),"transforms"===s&&e.jsx(DefaultTransformsPanel,{}),"settings"===s&&e.jsx(DefaultSettingsPanel,{}),t]})})}function CustomPanelContent({panelName:t,children:a}){const s=n.useRecoilValue(Mn);return e.jsx(e.Fragment,{children:s===t&&a})}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:s,responsive:l,disabled:i,content:r,tooltipPlacement:c,children:u,onSelect:d,onDeselect:m}){return e.jsx("div",{className:Ve({"text-[var(--vertex-ui-blue-700)]":s===t&&!i,"text-neutral-700 hover:text-neutral-800":s!==t&&!i,"cursor-pointer hover:bg-neutral-200":!i,"text-neutral-400":i,"rounded-full md:p-3":l,"p-3":!l&&null==u,"px-3 py-1":null!=u}),"data-testid":`${t}-sidebar-panel`,onClick:()=>{i||(s===t?m():d())},children:e.jsxs(o.VertexTooltip,{placement:null!=c?c:void 0,content:a.isValidElement(r)?void 0:r,children:[e.jsx("div",{slot:"content",children:r}),e.jsx("div",{className:"flex flex-col",children:null!=u?u:e.jsx(o.VertexIcon,{name:n})})]})})}function VertexViewerRightSidebar({children:t}){const a=usePanelActions(),s=n.useRecoilValue(Mn);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.jsxs(Sidebar,{children:[t,e.jsx(SidebarIcon,{name:"appearance",active:s,iconName:"adjustments",tooltipPlacement:"right",content:"Appearance",onSelect:()=>{a.openPrimary("appearance","right")},onDeselect:()=>a.closePrimary("right")}),e.jsx(SidebarIcon,{name:"transforms",active:s,iconName:"show-only-nearby",tooltipPlacement:"right",content:"Transforms",onSelect:()=>{a.openPrimary("transforms","right")},onDeselect:()=>a.closePrimary("right")}),e.jsx(SidebarIcon,{name:"settings",active:s,iconName:"gear",tooltipPlacement:"right",content:"Settings",onSelect:()=>{a.openPrimary("settings","right")},onDeselect:()=>a.closePrimary("right")})]})})}function CustomPanelIcon(t){const a=usePanelActions(),s=n.useRecoilValue(Mn),{panelName:o,tooltipContent:l,iconName:i}=t,r=__rest(t,["panelName","tooltipContent","iconName"]);if(null==i&&null==r.children)throw new Error('CustomPanelIcon must contain either a Vertex "iconName" or custom "children"');return e.jsx(SidebarIcon,Object.assign({},r,{name:o,iconName:null!=i?i:"help",active:s,content:l,onSelect:()=>{a.openPrimary(t.panelName,"right")},onDeselect:()=>{a.closePrimary("right")}}))}VertexViewerRightOpenedPanel.CustomPanelContent=CustomPanelContent,VertexViewerRightSidebar.CustomPanelIcon=CustomPanelIcon;const VertexPopupButton=t=>{var{open:n,children:a}=t,s=__rest(t,["open","children"]);const l=a.find((e=>e.type===Anchor)),i=a.filter((e=>e.type!==Anchor));return null==l?e.jsx(e.Fragment,{}):e.jsxs(o.VertexPopover,Object.assign({className:"flex",placement:"top",backdrop:!1,open:asBooleanAttribute(n)},s,{children:[l,e.jsx("div",{className:Ve("flex mb-1.5",{hidden:!n}),"data-testid":"align-plane-popover-menu",children:i})]}))},Anchor=({tooltipContent:t,children:n})=>e.jsx("div",{slot:"anchor",children:e.jsx(o.VertexTooltip,{className:"cursor-pointer",content:t,children:n})});function VertexViewerCrossSectionAlignmentPopoverMenu(){const t=useCrossSectioningActions(),a=n.useRecoilValue(de),s=n.useRecoilValue(ne),getBaseIcon=()=>`align-to-${null==s?void 0:s.mode}`;return useStackKeyBinding({id:"CrossSectionAlignment",keyBind:"Escape",fn:t.cancelCurrentHit,addPredicate:()=>{var e;return null!==(e=null==s?void 0:s.hitPending)&&void 0!==e&&e},cancelPredicate:()=>!(null==s?void 0:s.hitPending)},[null==s?void 0:s.hitPending]),e.jsxs(VertexPopupButton,{"data-testid":"section-alignment-popover",placement:"top",backdrop:!1,open:asBooleanAttribute(a),onDismissed:t.closeAlignmentTools,children:[e.jsx(VertexPopupButton.Anchor,{tooltipContent:"Section Alignment",children:e.jsx(o.VertexIconButton,{"data-testid":"section-alignment-icon-button",iconName:getBaseIcon(),iconColor:"secondary",onClick:a?t.closeAlignmentTools:t.openAlignmentTools,children:e.jsx(o.VertexIcon,{"data-testid":"section-alignment-icon-chevron",name:"chevron-up",size:"sm"})})}),e.jsxs(i.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(o.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(o.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(),s=n.useRecoilValue(me),l=n.useRecoilValue(te),r=n.useRecoilValueLoadable(le),c=a.useMemo((()=>{const e=l.length>0&&"hasValue"===r.state?axis(l[0],xAxis(r.contents),yAxis(r.contents),zAxis(r.contents)):"x";return null!=e?`axis-${e}`:"axis-x"}),[r.state,r.contents,l]);return e.jsxs(VertexPopupButton,{"data-testid":"align-plane-popover",placement:"top",backdrop:!1,open:asBooleanAttribute(s),onDismissed:t.closeAxisTools,children:[e.jsx(VertexPopupButton.Anchor,{tooltipContent:"Align Plane",children:e.jsx(o.VertexIconButton,{onClick:s?t.closeAxisTools:t.openAxisTools,iconName:c,"data-testid":"align-plane-icon",iconColor:"secondary",children:e.jsx(o.VertexIcon,{"data-testid":"align-plane-icon-chevron",name:"chevron-up",size:"sm"})})}),e.jsxs(i.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(o.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(o.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(o.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"})})]})]})}function VertexViewerCrossSectionOffsetStepper({offset:t,onOffsetChange:s}){const l=n.useRecoilValue(vt),i=n.useRecoilValue(yt),[r,c]=a.useState(convertTo(t,l));a.useEffect((()=>{c(convertTo(t,l))}),[l,t]);const u=createDistanceFormatter(l,parseInt(i,10)),handleIncrementalUpdate=e=>{const t=convertFrom(r+e,l);s(t)},handleSubmit=e=>{e.preventDefault(),s(convertFrom(r,l))},handleBlur=()=>{s(convertFrom(r,l))};return e.jsx(o.VertexTooltip,{content:"Plane Offset",children:e.jsx("form",{"data-testid":"cross-section-stepper-form",onSubmit:handleSubmit,children:e.jsxs(o.VertexTextfield,{"data-testid":"cross-section-stepper-input",className:"viewer-toolbar-input w-32 border-none ring-0 bg-white",type:"text",value:u(parseFloat(t.toFixed(3))),onInputInput:e=>{c(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(o.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(o.VertexIcon,{name:"chevron-right",size:"sm"})})]})})})}VertexPopupButton.Anchor=Anchor;const Dn=400;function VertexViewerCrossSectionPopupMenu(){const t=useCrossSectioningActions(),s=n.useRecoilValue(ue),l=n.useRecoilValueLoadable(re),r=n.useRecoilValueLoadable(ce),c=a.useRef(),u=a.useMemo((()=>"hasValue"===l.state?l.contents:Z),[l.state,l.contents]),d=a.useMemo((()=>"hasValue"===r.state?r.contents:0),[r.state,r.contents]),handleCrossSectionValueChange=e=>{clearTimeout(c.current),c.current=window.setTimeout((()=>{t.endInteraction()}),Dn),t.beginInteraction(),t.updatePlanes(e)};return e.jsxs(VertexPopupButton,{"data-testid":"cross-section-popover",placement:"top",backdrop:!1,open:asBooleanAttribute(s),onDismissed:t.closeAdditionalTools,children:[e.jsx(VertexPopupButton.Anchor,{tooltipContent:"Section Tools",children:e.jsx("div",{className:"-ml-px py-1.5",children:e.jsx(o.VertexIcon,{"data-testid":"cross-section-popover-icon",name:"chevron-up",size:"sm",onClick:s?t.closeAdditionalTools:t.openAdditionalTools})})}),e.jsxs(i.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(o.VertexTooltip,{className:"w-auto",content:"Reverse",children:e.jsx(o.VertexIconButton,{iconName:"flip","data-testid":"viewer-toolbar-flip-button",onClick:t.flipPlanes,iconColor:"secondary"})}),e.jsx(o.VertexTooltip,{className:"w-auto",content:"Align View to Plane",children:e.jsx(o.VertexIconButton,{"data-testid":"viewer-toolbar-align-view-to-plane-button",iconName:"align-view-to-plane",onClick:t.alignViewToPlane,iconColor:"secondary"})}),e.jsx(VertexToolbarDivider,{}),e.jsx(VertexViewerCrossSectionAxisPopoverMenu,{}),e.jsx("div",{className:"w-52 mx-2",children:e.jsx(VertexSlider,{value:d,defaultValue:u.default,disabled:asBooleanAttribute("hasValue"!==l.state),min:u.min,max:u.max,step:.01,onChange:handleCrossSectionValueChange})}),e.jsx("div",{className:"px-4",children:e.jsx(VertexViewerCrossSectionOffsetStepper,{offset:"hasValue"===r.state?r.contents:0,onOffsetChange:handleCrossSectionValueChange})})]})]})}const VertexViewerCrossSectionButton=()=>{const t=useCrossSectioningActions(),a=n.useRecoilValue(J);return e.jsxs(e.Fragment,{children:[e.jsx(o.VertexTooltip,{content:a?"Hide Section":"Show Section",children:e.jsx(o.VertexIconButton,{"data-testid":"viewer-toolbar-cross-section-button",iconName:"cross-section",iconColor:a?"primary":"secondary",onClick:()=>a?t.disable():t.enable()})}),e.jsx(VertexViewerCrossSectionPopupMenu,{})]})},VertexFitAllButton=()=>{const t=n.useRecoilValue(M);return e.jsx(o.VertexTooltip,{content:"Fit All",children:e.jsx(o.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=n.useRecoilValue(M),s=n.useRecoilValue(B),[l,i]=n.useRecoilState(D),[r,c]=n.useRecoilState(_);return a.useEffect((()=>{null!=t&&s&&c(t.getBaseInteractionHandler())}),[t,s,c]),e.jsx(o.VertexTooltip,{content:"Pan",children:e.jsx(o.VertexIconButton,{iconName:"pan",iconColor:"pan"===l?"primary":"secondary","data-testid":"viewer-toolbar-pan-button",onClick:async()=>{if(i("pan"),null!=r){const e=await r;null==e||e.setPrimaryInteractionType("pan")}}})})},VertexRotateButton=()=>{const t=n.useRecoilValue(M),s=n.useRecoilValue(B),[l,i]=n.useRecoilState(D),[r,c]=n.useRecoilState(_);return a.useEffect((()=>{null!=t&&s&&c(t.getBaseInteractionHandler())}),[t,s,c]),e.jsx(o.VertexTooltip,{content:"Rotate",children:e.jsx(o.VertexIconButton,{iconName:"rotate",iconColor:"rotate"===l?"primary":"secondary","data-testid":"viewer-toolbar-rotate-button",onClick:async()=>{if(i("rotate"),null!=r){const e=await r;null==e||e.setPrimaryInteractionType("rotate")}}})})},VertexZoomButton=()=>{const t=n.useRecoilValue(M),s=n.useRecoilValue(B),[l,i]=n.useRecoilState(D),[r,c]=n.useRecoilState(_);return a.useEffect((()=>{null!=t&&s&&c(t.getBaseInteractionHandler())}),[t,s,c]),e.jsx(o.VertexTooltip,{content:"Zoom",children:e.jsx(o.VertexIconButton,{iconName:"zoom",iconColor:"zoom"===l?"primary":"secondary","data-testid":"viewer-toolbar-zoom-button",onClick:async()=>{if(i("zoom"),null!=r){const e=await r;null==e||e.setPrimaryInteractionType("zoom")}}})})},DefaultToolbar=()=>e.jsx(i.VertexViewerToolbar,{placement:"bottom-center",children:e.jsxs(i.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(VertexToolbarDivider,{}),e.jsx(VertexBoxSelectionButton,{}),e.jsx(VertexToolbarDivider,{}),e.jsx(VertexViewerCrossSectionButton,{}),e.jsx(VertexToolbarDivider,{}),e.jsx(VertexPointToPointMeasurementTool,{}),e.jsx(VertexPreciseMeasurementTool,{})]})}),VertexToolbar=({children:t})=>{const n=null!=t&&!1!==t;return e.jsx(i.VertexViewerToolbar,{placement:"bottom-center",children:n?e.jsx(i.VertexViewerToolbarGroup,{className:"p-1 border border-neutral-200 rounded bg-neutral-100 opacity-95",children:t}):e.jsx(DefaultToolbar,{})})};function VertexTransformWidget({transformWidgetElement:t,supportUndo:s,onPositionChange:o,onRotationChange:l}){const r=useTransformActions(),c=n.useRecoilValue(At),u=n.useRecoilValue(Ct),d=n.useRecoilValue(Vt),m=n.useRecoilValue(kt),p=n.useRecoilValueLoadable(Tt),h=n.useRecoilValue(vt),g=n.useRecoilValue(yt),f=a.useMemo((()=>"hasValue"===p.state?p.contents:m),[p,m]),v=a.useMemo((()=>{const e=undefined;return u&&(null!=f||c)}),[u,f,c]);return e.jsx(e.Fragment,{children:v&&e.jsx(i.VertexViewerTransformWidget,{id:"transform-widget","data-testid":"viewer-transform-widget",ref:t,position:d,rotation:null!=d?f:void 0,decimalPlaces:parseInt(g,10),distanceUnit:toUnitType(h),EXPERIMENTAL_undoKeybindings:null==s||s,onInteractionStarted:()=>{r.disableSelectionSync(),r.setIsInteractivelyTransforming(!0)},onInteractionEnded:()=>{r.invalidateTransforms(),r.setIsInteractivelyTransforming(!1)},onPositionChanged:async e=>{await r.setTransformWidgetPosition(e.detail),null==o||o(e.detail)},onRotationChanged:e=>{r.setTransformWidgetOrientation(e.detail),null==l||l(e.detail)}})})}const VertexViewerSceneReset=({onReset:t})=>{const n=useCrossSectioningActions(),a=useSelectionActions(),s=useTransformActions(),l=useViewerSceneActions(),handleReset=async()=>{await n.disable(),await a.resetSelectionState(),s.clearTransformWidgetPosition(),await s.invalidateTransforms(),null==t||t(),await l.reset()};return e.jsx(o.VertexTooltip,{content:"Reset View",children:e.jsx(o.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(){const e=useTransformActions();return{frameDrawn:useActionCallback((({set:t,snapshot:n})=>async a=>{const s=await n.getPromise(pt);t(U,a.detail.scene),t(pt,a.detail.scene.sceneViewSummary.selectedVisibleSummary),t(mt,s);const o=undefined;await n.getPromise(Ct)&&await e.syncToSelection()}))}}const VertexBoxSelectionTool=()=>{const{element:t,callback:a}=useCallbackRef(),s=useBoxSelectionActions(),o=useTransformActions(),l=n.useRecoilValue(Le);return u.useEffect((()=>{const e=whenComponentReady(t,(()=>{var e;return[null===(e=null==t?void 0:t.model)||void 0===e?void 0:e.onDragComplete((()=>{"clearAndSelect"===l&&(o.clearTransformWidgetOrientation(),o.clearTransformWidgetPosition(),o.enableSelectionSync())}))]}));return()=>{null==e||e.then((e=>{null==e||e.forEach((e=>null==e?void 0:e.dispose()))}))}}),[t,l]),useApplyKeyBinding({keyBind:"Shift",fn:u.useCallback((()=>s.setOperationType("select")),[]),off:u.useCallback((()=>s.setOperationType("clearAndSelect")),[])}),e.jsx(i.VertexViewerBoxQueryTool,{ref:a,"data-testid":"viewer-box-query-tool",operationType:l})};function VertexViewerCameraTypeMenu({open:t,onOpen:a,onDismiss:s,onCameraTypeChange:l}){const i=useViewerCameraActions(),r=n.useRecoilValue(K);return e.jsxs(o.VertexMenu,{"data-testid":"camera-types-popover",className:"flex",placement:"bottom-end",open:asBooleanAttribute(t),onMenuClosed:s,children:[e.jsx("div",{slot:"anchor",children:e.jsx("div",{className:Ve("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(o.VertexTooltip,{content:"Change View",children:e.jsx(o.VertexIconButton,{"data-testid":"set-camera-mode-option",className:"p-1 cursor-pointer",variant:"plain",onClick:a,iconName:"orthographic"===r?"cube-orthographic":"cube-perspective",children:e.jsx(o.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(o.VertexMenuItem,{"data-testid":"set-perspective-view",onClick:()=>{i.updateCameraType("perspective"),null==l||l("perspective")},children:[e.jsx(o.VertexIcon,{slot:"icon","data-testid":"set-perspective-view-icon",name:"cube-perspective",size:"sm",className:Ve({"text-[var(--vertex-ui-blue-700)]":"perspective"===r})}),e.jsx("div",{className:Ve("ml-2 items-center",{"text-[var(--vertex-ui-blue-700)]":"perspective"===r}),children:"Perspective"})]}),e.jsxs(o.VertexMenuItem,{"data-testid":"set-orthographic-view",onClick:()=>{i.updateCameraType("orthographic"),null==l||l("orthographic")},children:[e.jsx(o.VertexIcon,{slot:"icon","data-testid":"set-orthographic-view-icon",name:"cube-orthographic",size:"sm",className:Ve({"text-[var(--vertex-ui-blue-700)]":"orthographic"===r})}),e.jsx("div",{className:Ve("ml-2 items-center",{"text-[var(--vertex-ui-blue-700)]":"orthographic"===r}),children:"Orthographic"})]})]})]})}const VertexViewerViewCube=t=>{var{placement:n,children:s}=t,o=__rest(t,["placement","children"]);const l=Array.isArray(s)?s:[s],r=l.filter((e=>!a.isValidElement(e)||e.type!==i.VertexViewerViewCube)).filter((e=>null!=e&&!1!==e)),c=l.find((e=>a.isValidElement(e)&&e.type===i.VertexViewerViewCube)),[u,d]=a.useState(!1);return e.jsxs(i.VertexViewerToolbar,{direction:"vertical","data-testid":"view-cube-toolbar",placement:null!=n?n:"top-right",children:[null!=c?c:e.jsx(i.VertexViewerViewCube,Object.assign({className:"m-7"},o)),0===r.length?e.jsxs("div",{className:"flex items-center justify-center mt-3 gap-1",children:[e.jsx(VertexViewerSceneReset,{}),e.jsx(VertexViewerCameraTypeMenu,{open:u,onDismiss:()=>d(!1),onOpen:()=>d(!0)})]}):e.jsx("div",{className:"mt-3",children:r})]})},VertexViewer=t=>{var{id:s,className:o,disableSelection:l,onTap:r,onLongpress:c,onFrameDrawn:u,onSceneReady:d,viewerRefCallback:m,children:p}=t,h=__rest(t,["id","className","disableSelection","onTap","onLongpress","onFrameDrawn","onSceneReady","viewerRefCallback","children"]);const g=n.useRecoilValue(hn),f=useRecoilRef({state:M}),v=useViewerCameraActions(),b=useHitActions(),S=useSelectionActions(),w=useViewerFrameActions(),[C,V]=n.useRecoilState(B),j=n.useRecoilValue(K),T=n.useRecoilValue(ne),k=n.useRecoilValue(Me),A=n.useSetRecoilState(F),[P,E]=n.useRecoilState(L);a.useEffect((()=>{null!=s&&E(s)}),[s]);const I=n.useRecoilValue(dn),R=a.useMemo((()=>({opacity:I/100})),[I]),N=n.useRecoilValue(ke),O=n.useRecoilValue(Ae),_=a.useMemo((()=>({color:N,width:O})),[N,O]),D=n.useRecoilValue(Jt),H=n.useRecoilValue(nn),U=n.useRecoilValue(an),W=n.useRecoilValue(sn),G=a.useMemo((()=>({color:H,opacity:U/100,lineWidth:W})),[H,U,W]),$=n.useRecoilValue(ze),q=null!=p&&!1!==p;return useKeyBindings(),useDefaultKeybindings(),e.jsxs(i.VertexViewer,Object.assign({id:P,"data-testid":"vertex-viewer",ref:null!=m?m:f,className:Ve("flex w-full h-full",o,{"cursor-crosshair":T.hitPending}),style:{"--viewer-background":D},config:g,cameraType:C?j:void 0,onCameraTypeChanged:e=>{C&&v.updateCameraType(e.detail)},phantom:R,featureLines:_,selectionHighlighting:G,featureMaps:$?"final":void 0,onTap:e=>{const t=[...l?[]:[S.selectCurrentHit]];b.tap(e,...t),null==r||r(e)},onLongpress:e=>{b.longPress(e),null==c||c(e)},onFrameDrawn:e=>{w.frameDrawn(e),null==u||u(e)},onSceneReady:async e=>{var t;if(!C){V(!0);const n=await(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.scene());A(null==n?void 0:n.sceneViewId)}null==d||d(e)}},h,{children:[k&&e.jsx(VertexBoxSelectionTool,{}),q?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:s})=>{const o=n.useRecoilValue(_t),l=n.useRecoilValue(Ft);return a.useEffect((()=>{null==t||t(o)}),[o,t]),a.useEffect((()=>{null==s||s(l)}),[l,s]),e.jsx(e.Fragment,{})},VertexViewerToolkitRoot=t=>{var{override:s,autoDefineCustomElements:o,children:l,config:i}=t,u=__rest(t,["override","autoDefineCustomElements","children","config"]);return a.useEffect((()=>{(null==o||o)&&(c.defineCustomElements(),r.defineCustomElements())}),[o]),e.jsx(n.RecoilRoot,{override:s,children:e.jsxs(e.Fragment,{children:[e.jsx(VertexViewerToolkitEventListener,Object.assign({},u)),e.jsx(VertexViewerToolkitRootConfig,{config:i,children:l})]})})},VertexViewerToolkitRootConfig=({config:t,children:s})=>{const o=n.useSetRecoilState(hn);return a.useEffect((()=>{const e=null!=t?toSdkConfig(t):void 0;o(e)}),[t,o]),e.jsx(e.Fragment,{children:s})};var Fn=Object.freeze({__proto__:null,get AssemblyFontFace(){return Nn}});exports.CrossSection=Se,exports.Hits=Dt,exports.SceneTree=Fn,exports.Selection=zt,exports.VertexApplicationMessages=VertexApplicationMessages,exports.VertexBoxSelectionButton=VertexBoxSelectionButton,exports.VertexContextMenu=VertexContextMenu,exports.VertexCrossSectionAppearanceColorPicker=VertexCrossSectionAppearanceColorPicker,exports.VertexCrossSectionAppearanceControls=VertexCrossSectionAppearanceControls,exports.VertexCrossSectionAppearanceLineThicknessSlider=VertexCrossSectionAppearanceLineThicknessSlider,exports.VertexCrossSectionAppearancePanelSection=VertexCrossSectionAppearancePanelSection,exports.VertexCrossSectionAppearanceReset=VertexCrossSectionAppearanceReset,exports.VertexDecimalPlaceSelector=VertexDecimalPlaceSelector,exports.VertexFeatureEdgesColorPicker=VertexFeatureEdgesColorPicker,exports.VertexFeatureEdgesControls=VertexFeatureEdgesControls,exports.VertexFeatureEdgesPanelSection=VertexFeatureEdgesPanelSection,exports.VertexFeatureEdgesReset=VertexFeatureEdgesReset,exports.VertexFeatureEdgesThicknessSlider=VertexFeatureEdgesThicknessSlider,exports.VertexFitAllButton=VertexFitAllButton,exports.VertexFitSelectedMenuItem=VertexFitSelectedMenuItem,exports.VertexFlyToMenuItem=VertexFlyToMenuItem,exports.VertexGhostingControls=VertexGhostingControls,exports.VertexGhostingPanelSection=VertexGhostingPanelSection,exports.VertexHideAllMenuItem=VertexHideAllMenuItem,exports.VertexHidePartMenuItem=VertexHidePartMenuItem,exports.VertexHideSelectedMenuItem=VertexHideSelectedMenuItem,exports.VertexLengthUnitSelector=VertexLengthUnitSelector,exports.VertexMaterialControls=VertexMaterialControls,exports.VertexMaterialPanelSection=VertexMaterialPanelSection,exports.VertexMeasurementContextMenu=VertexMeasurementContextMenu,exports.VertexMeasurementDetails=VertexMeasurementDetails,exports.VertexPanButton=VertexPanButton,exports.VertexPointToPointMeasurement=VertexPointToPointMeasurement,exports.VertexPointToPointMeasurementTool=VertexPointToPointMeasurementTool,exports.VertexPreciseMeasurement=VertexPreciseMeasurement,exports.VertexPreciseMeasurementTool=VertexPreciseMeasurementTool,exports.VertexResizableContent=VertexResizableContent,exports.VertexRotateButton=VertexRotateButton,exports.VertexSceneItemGhostingClear=VertexSceneItemGhostingClear,exports.VertexSceneItemGhostingOpacitySlider=VertexSceneItemGhostingOpacitySlider,exports.VertexSceneItemGhostingToggle=VertexSceneItemGhostingToggle,exports.VertexSceneItemMaterialClear=VertexSceneItemMaterialClear,exports.VertexSceneItemMaterialColorPicker=VertexSceneItemMaterialColorPicker,exports.VertexSceneItemMaterialOpacitySlider=VertexSceneItemMaterialOpacitySlider,exports.VertexSceneTree=VertexSceneTree,exports.VertexSceneTreeColumnPopover=VertexSceneTreeColumnPopover,exports.VertexSceneTreeContextMenu=VertexSceneTreeContextMenu,exports.VertexSceneTreeHeader=VertexSceneTreeHeader,exports.VertexSceneTreeSearchBar=VertexSceneTreeSearchBar,exports.VertexSceneTreeSearchInformationForToolbar=VertexSceneTreeSearchInformationForToolbar,exports.VertexSceneTreeSearchOptionsPopover=VertexSceneTreeSearchOptionsPopover,exports.VertexSceneTreeTableLayout=VertexSceneTreeTableLayout,exports.VertexSelectionHighlightingColorPicker=VertexSelectionHighlightingColorPicker,exports.VertexSelectionHighlightingControls=VertexSelectionHighlightingControls,exports.VertexSelectionHighlightingLineThicknessSlider=VertexSelectionHighlightingLineThicknessSlider,exports.VertexSelectionHighlightingOpacitySlider=VertexSelectionHighlightingOpacitySlider,exports.VertexSelectionHighlightingPanelSection=VertexSelectionHighlightingPanelSection,exports.VertexSelectionHighlightingReset=VertexSelectionHighlightingReset,exports.VertexShowAllMenuItem=VertexShowAllMenuItem,exports.VertexShowOnlyMenuItem=VertexShowOnlyMenuItem,exports.VertexShowOnlySelectedMenuItem=VertexShowOnlySelectedMenuItem,exports.VertexToolbar=VertexToolbar,exports.VertexToolbarDivider=VertexToolbarDivider,exports.VertexTransformClear=VertexTransformClear,exports.VertexTransformControls=VertexTransformControls,exports.VertexTransformInputs=VertexTransformInputs,exports.VertexTransformManipulatorToggle=VertexTransformManipulatorToggle,exports.VertexTransformPanelSection=VertexTransformPanelSection,exports.VertexTransformWidget=VertexTransformWidget,exports.VertexUnitsControls=VertexUnitsControls,exports.VertexUnitsPanelSection=VertexUnitsPanelSection,exports.VertexViewer=VertexViewer,exports.VertexViewerBackgroundColorPicker=VertexViewerBackgroundColorPicker,exports.VertexViewerBackgroundControls=VertexViewerBackgroundControls,exports.VertexViewerBackgroundPanelSection=VertexViewerBackgroundPanelSection,exports.VertexViewerBackgroundReset=VertexViewerBackgroundReset,exports.VertexViewerContextMenu=VertexViewerContextMenu,exports.VertexViewerCrossSectionButton=VertexViewerCrossSectionButton,exports.VertexViewerRightOpenedPanel=VertexViewerRightOpenedPanel,exports.VertexViewerRightSidebar=VertexViewerRightSidebar,exports.VertexViewerSceneReset=VertexViewerSceneReset,exports.VertexViewerToolkitRoot=VertexViewerToolkitRoot,exports.VertexViewerViewCube=VertexViewerViewCube,exports.VertexZoomButton=VertexZoomButton;
18
+ */Ve=we,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 a in t)e.call(t,a)&&t[a]&&(n=appendClass(n,a));return n}function appendClass(e,t){return t?e?e+" "+t:e+t:e}Ve.exports?(classNames.default=classNames,Ve.exports=classNames):window.classNames=classNames}();var Ce=we.exports;const VertexSlider=t=>{var{value:n,defaultValue:s,leftLabel:l,rightLabel:i,onChange:r,onValueChange:c,onValueInput:u}=t,d=__rest(t,["value","defaultValue","leftLabel","rightLabel","onChange","onValueChange","onValueInput"]);const[m,p]=a.useState(s);return e.jsxs("div",{className:"flex w-full items-center gap-2",children:[l&&e.jsx("div",{className:"pl-0.5 text-xs text-center",children:l}),e.jsx(o.VertexSlider,Object.assign({className:Ce("w-full",{"mt-0.5":null!=l||null!=i}),value:null!=n?n:m,onValueChange:e=>{p(e.detail.value),null==r||r(e.detail.value),null==c||c(e)},onValueInput:e=>{p(e.detail.value),null==r||r(e.detail.value),null==u||u(e)}},d)),i&&e.jsx("div",{className:"text-xs pr-2 flex-shrink-0 text-right",children:i})]})},VertexCrossSectionAppearanceLineThicknessSlider=({onUpdate:t})=>{const a=useCrossSectioningActions(),[s,o]=n.useRecoilState(ee);return e.jsx(VertexSlider,{id:"cross-section-line-thickness","data-testid":"cross-section-line-thickness-slider",leftLabel:"Off",rightLabel:"Thick",min:0,max:3,step:.5,value:s,valueLabelDisplay:"auto",onValueInput:async e=>{o(e.detail.value),await a.reapply()},onValueChange:e=>{null==t||t(e.detail.value)}})};function VertexCrossSectionAppearanceControls({onUpdateCrossSectionColor:t,onUpdateCrossSectionLineThickness:n}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Color"}),e.jsx(VertexCrossSectionAppearanceColorPicker,{onUpdate:t}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Line Thickness"}),e.jsx(VertexCrossSectionAppearanceLineThicknessSlider,{onUpdate:n})]})}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 VertexCrossSectionAppearanceReset=({onReset:t})=>{const a=useCrossSectioningActions(),[s,l]=n.useRecoilState(Q),[i,r]=n.useRecoilState(ee),c=s!==Y||1!==i;return e.jsx("div",{className:"ml-auto",children:e.jsx(o.VertexTooltip,{content:"Reset Cross Sectioning Appearance",children:e.jsx(o.VertexIconButton,{"data-testid":"cross-section-appearance-reset",iconName:"reset",iconSize:"sm",onClick:async()=>{l(Y),r(1),null==t||t(),await a.reapply()},disabled:!c})})})};function VertexCrossSectionAppearancePanelSection({onResetCrossSectionAppearance:t,onUpdateCrossSectionColor:n,onUpdateCrossSectionLineThickness:a}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Cross Sectioning",e.jsx(VertexCrossSectionAppearanceReset,{onReset:t})]}),children:e.jsx(VertexCrossSectionAppearanceControls,{onUpdateCrossSectionColor:n,onUpdateCrossSectionLineThickness:a})})}const je=.5,Te="#444444",ke=n.atom({key:"featureEdgesSelectedColor",default:Te}),Ae=n.atom({key:"featureEdgesLineThickness",default:je}),VertexFeatureEdgesColorPicker=({onUpdate:t})=>{const[a,s]=n.useRecoilState(ke);return e.jsx(VertexColorPicker,{"data-testid":"feature-edges-color-picker",value:a,onValueChanged:e=>{null==t||t(e.detail)},onInput:e=>s(e)})},VertexFeatureEdgesThicknessSlider=({onUpdate:t})=>{const[a,s]=n.useRecoilState(Ae);return e.jsx(VertexSlider,{id:"feature-edges-thickness","data-testid":"feature-edges-thickness-slider",leftLabel:"Off",rightLabel:"Thick",min:0,max:3,step:.5,value:a,valueLabelDisplay:"auto",onValueInput:e=>{s(e.detail.value)},onValueChange:e=>{null==t||t(e.detail.value)}})};function VertexFeatureEdgesControls({onUpdateFeatureEdgesColor:t,onUpdateFeatureEdgesThickness:n}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Color"}),e.jsx(VertexFeatureEdgesColorPicker,{onUpdate:t}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Line Thickness"}),e.jsx(VertexFeatureEdgesThicknessSlider,{onUpdate:n})]})}const VertexFeatureEdgesReset=({onReset:t})=>{const[a,s]=n.useRecoilState(ke),[l,i]=n.useRecoilState(Ae),r=l!==je||a!==Te;return e.jsx("div",{className:"ml-auto",children:e.jsx(o.VertexTooltip,{content:"Reset Feature Edges",children:e.jsx(o.VertexIconButton,{"data-testid":"feature-edges-reset",iconName:"reset",iconSize:"sm",onClick:()=>{s(Te),i(je),null==t||t()},disabled:!r})})})};function VertexFeatureEdgesPanelSection({onResetFeatureEdges:t,onUpdateFeatureEdgesColor:n,onUpdateFeatureEdgesThickness:a}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Feature Edges",e.jsx(VertexFeatureEdgesReset,{onReset:t})]}),children:e.jsx(VertexFeatureEdgesControls,{onUpdateFeatureEdgesColor:n,onUpdateFeatureEdgesThickness:a})})}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 Pe=n.atom({key:"contextMenuActive",default:void 0}),Ee=n.atom({key:"contextMenuPosition",default:void 0}),Ie=n.atom({key:"contextMenuTarget",default:void 0}),Re=n.atom({key:"contextMenuItem",default:void 0}),Ne=n.atom({key:"contextMenuActions",default:[]}),Oe=n.selector({key:"contextMenuActivePosition",get:({get:e})=>null!=e(Pe)?e(Ee):void 0});function useContextMenuActions(){return{pointerDown:useActionCallback((({set:e})=>async t=>{if(2===t.button){const n=t.clientX,a=null==t?void 0:t.clientY;e(Ee,s.Point.create(n,a)),e(Ie,t.target)}})),pointerUp:useActionCallback((({snapshot:e,set:t})=>async(n,a,o,l)=>{const i=await e.getPromise(Ee),r=await e.getPromise(Pe);if(null!=i&&null==r){const e=n.clientX,r=null==n?void 0:n.clientY,c=s.Point.create(e,r),u=null!=i?s.Point.distance(i,c):0,d=null==o||o(n);u<2&&d&&(null==l||l(n,null!=i?i:c),t(Pe,a))}})),contextMenu:useActionCallback((()=>(e,t)=>{(null==t||t(e))&&e.preventDefault()})),longPress:useActionCallback((({set:e})=>(t,n,a,o)=>{if(null==a||a(t)){const a=s.Point.create(t.touches[0].clientX,t.touches[0].clientY);e(Ee,a),e(Ie,t.target),e(Pe,n),null==o||o(t,a)}})),clearActiveContextMenu:useActionCallback((({reset:e,set:t})=>n=>{t(ye,!!n),e(Pe),e(Ne),e(Ee)})),clearDismissedState:useActionCallback((({reset:e})=>()=>e(ye)))}}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)}const Me=n.atom({key:"boxSelectionEnabled",default:!1}),Le=n.atom({key:"boxSelectionOperationType",default:"clearAndSelect"}),useBoxSelectionActions=()=>({enable:useActionCallback((({set:e})=>()=>{e(Me,!0)})),disable:useActionCallback((({reset:e})=>async()=>{e(Me),e(Le)})),setOperationType:useActionCallback((({set:e})=>t=>{e(Le,t)}))});async function whenComponentReady(e,t,n=customElements,a=requestAnimationFrame,s=setTimeout){return null!=e&&null!=e.nodeName&&await n.whenDefined(e.nodeName.toLowerCase()),"function"==typeof(null==e?void 0:e.componentOnReady)?(await(null==e?void 0:e.componentOnReady()),t()):(await new Promise((e=>"function"==typeof a?a(e):s(e))),t())}const Be=n.atom({key:"isEditingPointToPointMeasurement",default:!1}),_e=n.atom({key:"pointToPointMeasurementOutcome",default:void 0}),De=n.atom({key:"editedPointToPointMeasurement",default:void 0});function usePointToPointMeasurement(e){const t=n.useSetRecoilState(_e);a.useEffect((()=>{let n;return whenComponentReady(e,(()=>{n=null==e?void 0:e.measurementModel.onOutcomeChanged(t)})),()=>null==n?void 0:n.dispose()}),[e,t])}const ze=2,Fe=n.atom({key:"isEditingPreciseMeasurement",default:!1}),He=n.atom({key:"preciseMeasurementOutcome",default:void 0}),Ue=n.atom({key:"preciseMeasurementController",dangerouslyAllowMutability:!0,default:void 0}),We=n.atom({key:"preciseMeasurementOverlays",dangerouslyAllowMutability:!0,default:void 0}),Ge=n.atom({key:"preciseMeasurementEntities",dangerouslyAllowMutability:!0,default:[]}),Ke=n.selector({key:"preciseMeasurementMessage",get:({get:e})=>{const t=undefined;return 0===e(Ge).length?"Select a surface":void 0}});function usePreciseMeasurementModel(e,t,s){const o=n.useSetRecoilState(Ge),l=n.useSetRecoilState(He),i=n.useSetRecoilState(Ue),r=n.useSetRecoilState(We),c=n.useRecoilValue(Ue);a.useEffect((()=>{let n;return whenComponentReady(e,(()=>{n=null==e?void 0:e.measurementModel.onEntitiesChanged((e=>{o(e),null==t||t(e)}))})),()=>null==n?void 0:n.dispose()}),[e,o]),a.useEffect((()=>{let t;return whenComponentReady(e,(()=>{t=null==e?void 0:e.measurementModel.onOutcomeChanged((e=>{l(e),null==s||s(e)}))})),()=>null==t?void 0:t.dispose()}),[e,l]),a.useEffect((()=>{let t;return whenComponentReady(e,(()=>{t=null==e?void 0:e.measurementModel.onEntitiesChanged((e=>{if(e.length>2){const t=e[2];null==c||c.setEntities(new Set([t]))}}))})),()=>null==t?void 0:t.dispose()}),[e,c]),a.useEffect((()=>{whenComponentReady(e,(()=>{i(null==e?void 0:e.measurementController)}))}),[e,i]),a.useEffect((()=>{whenComponentReady(e,(()=>{r(null==e?void 0:e.measurementOverlays)}))}),[e,r])}function useMeasurementActions(){const e=useBoxSelectionActions(),t=useEnablePointToPointMeasurement(),n=useDisablePointToPointMeasurement(),a=useDisablePreciseMeasurement(),s=useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromise(Ue);null==t||t.clearEntities()})),o=useActionCallback((()=>async(e={})=>{await s(),n(e),a()})),l=useActionCallback((({set:e,reset:n})=>async a=>{await o(),"point-to-point"===a?t():(n(He),n(Ge),e(Fe,!0))}));return{disableEditMeasurement:useActionCallback((()=>async e=>{await o(e)})),enableEditMeasurement:useActionCallback((()=>async e=>{await l(e)})),resetMeasurement:useActionCallback((({snapshot:e,reset:t})=>async()=>{const n=await e.getPromise(Fe),a=await e.getPromise(Be);n?await s():a&&(t(_e),t(De))})),clearEditedPointToPointMeasurement:useActionCallback((({reset:e})=>()=>{e(De)})),setEditedPointToPointMeasurement:useActionCallback((({set:e})=>t=>{e(De,t)})),toggleEditPointToPointMeasurement:useActionCallback((({snapshot:t})=>async()=>{const n=undefined;await t.getPromise(Be)?await o():await l("point-to-point"),e.disable()})),toggleEditPreciseMeasurement:useActionCallback((({snapshot:t})=>async()=>{const n=undefined;await t.getPromise(Fe)?await o():await l("precise"),e.disable()}))}}function useEnablePointToPointMeasurement(){return useActionCallback((({reset:e,set:t})=>(n={})=>{t(Be,!0),n.keepExistingMeasurement||e(_e)}))}function useDisablePointToPointMeasurement(){return useActionCallback((({reset:e})=>(t={})=>{e(Be),t.keepExistingMeasurement||(e(De),e(_e))}))}function useDisablePreciseMeasurement(){return useActionCallback((({reset:e})=>async()=>{e(Fe),e(He),e(Ge)}))}const $e=n.selector({key:"isEditingMeasurement",get:({get:e})=>e(Be)||e(Fe)}),qe=n.selector({key:"measurementPanelModel",get:({get:e})=>e(_e)||e(He)}),Ye=n.selector({key:"measurementPanelOverlays",dangerouslyAllowMutability:!0,get:({get:e})=>e(We)}),Xe=n.selector({key:"measurementPanelMessage",get:({get:e})=>{const t=undefined;return e(Fe)?e(Ke):void 0}}),Ze=n.selector({key:"measurementPanelIsResettable",get:({get:e})=>e($e)&&null!=e(qe)}),Je=3e3,Qe=n.atom({key:"applicationMessageToast",default:void 0}),et=n.atom({key:"applicationMessageBanner",default:void 0}),useApplicationMessageActions=()=>({setBannerMessage:useActionCallback((({set:e})=>t=>{e(et,null!=t?Object.assign(Object.assign({},t),{id:O.create()}):void 0)})),setToastMessage:useActionCallback((({set:e})=>t=>{e(Qe,null!=t?Object.assign(Object.assign({},t),{id:O.create()}):void 0)}))});var tt;!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"}(tt||(tt={}));const nt=n.atom({key:"fetchedItemInvalidator",default:0}),at=n.selectorFamily({key:"fetchedItems",get:e=>async({get:t})=>{var n;const a=t(M),s=t(F);if(t(nt),t(Lt),null!=s)try{return await(null===(n=null==a?void 0:a.sceneItems)||void 0===n?void 0:n.getSceneViewItem(e,s,{includeOverride:!0,includeWorldTransform:!0}))}catch(t){return void logger_debug(`Error encountered get scene view item. [itemId={${e}}]`,t)}}}),st=n.atomFamily({key:"selectionSelectedItems",default:void 0}),ot=n.atom({key:"selectionSelectedItemIds",default:[]}),lt=n.atom({key:"selectionLastSelected",default:void 0}),it=n.atom({key:"selectionLastSelectionFromViewer",default:!1}),rt=n.atom({key:"selectionLastSelectWasMultiSelect",default:!1}),ct=n.selector({key:"selectionHasMultipleSelected",get:({get:e})=>{const t=e(lt),n=undefined;return e(ot).filter((e=>{var n;return e!==(null==t?void 0:t.id)&&!(null===(n=null==t?void 0:t.ancestors)||void 0===n?void 0:n.includes(e))})).length>0}}),ut=n.atom({key:"selectionFirstSelectedItemInTreeId",default:void 0}),dt=n.selector({key:"selectionHighestSelectedAncestor",get:({get:e})=>{var t,n;const a=e(lt),s=e(ot);return null!==(n=null===(t=null==a?void 0:a.ancestors)||void 0===t?void 0:t.find((e=>s.includes(e))))&&void 0!==n?n:null==a?void 0:a.id}}),mt=n.atom({key:"selectionPreviousVisibleSummary",default:void 0}),pt=n.atom({key:"selectionVisibleSummary",default:void 0}),xt=n.selector({key:"selectionVisibleCount",get:({get:e})=>{var t,n;return null!==(n=null===(t=e(pt))||void 0===t?void 0:t.count)&&void 0!==n?n:0}}),ht=n.selector({key:"selectionBoundingBoxCenter",get:({get:e})=>{const t=e(pt);return null!=(null==t?void 0:t.boundingBox)?s.BoundingBox.center(t.boundingBox):s.Vector3.origin()}}),gt=n.selector({key:"selectionIsActive",get:({get:e})=>{const t=e(ot),n=undefined;return e(xt)>0||t.length>0}}),ft=n.selector({key:"fetchedAndSelectedItems",get:async({get:e})=>{const t=e(ot),n=undefined;return null!=e(F)?t.map((t=>e(at(t)))):[]}});function useSceneViewItemActions(){return{invalidateCachedItems:useActionCallback((({set:e})=>()=>{e(nt,(e=>e+1))}))}}const vt=n.atom({key:"lengthUnit",default:"cm"}),yt=n.atom({key:"decimalPlace",default:"2"});var bt,St;!function(e){e.mm="millimeters",e.cm="centimeters",e.m="meters",e.in="inches",e.ft="feet"}(bt||(bt={})),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"}(St||(St={}));const convertFrom=(e,t)=>{const n=undefined;return e/St[t]},convertTo=(e,t)=>{const n=undefined;return e*St[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 toUnitType(e){switch(e){case"cm":return"centimeters";case"m":return"meters";case"in":return"inches";case"ft":return"feet";default:return"millimeters"}}function pickLocalOrWorldTransform(e,t){return"local"===t?e.local:e.world}function mapItemTransforms(e,t){return{local:t(e.local),world:t(e.world)}}function makeItemTransforms(e,t,n){return"local"===n?{local:e,world:l.toWorldTransform(e,t)}:{world:e,local:l.toLocalTransform(e,t)}}function convertTransformToUnits(e,t){const{position:n,rotation:a,scale:o}=e;return{position:s.Vector3.create(convertTo(n.x,t),convertTo(n.y,t),convertTo(n.z,t)),rotation:a,scale:o}}function convertTransformFromUnits(e,t){const{position:n,rotation:a,scale:o}=e;return{position:s.Vector3.create(convertFrom(n.x,t),convertFrom(n.y,t),convertFrom(n.z,t)),rotation:a,scale:o}}function toValidTransform(e){const{position:t,rotation:n,scale:a}=e;return{position:{x:t.x||0,y:t.y||0,z:t.z||0},rotation:{x:n.x||0,y:n.y||0,z:n.z||0},scale:a||1}}function scale(e){const t=parseFloat(Math.sqrt(e[0]**2+e[4]**2+e[8]**2).toFixed(2)),n=parseFloat(Math.sqrt(e[1]**2+e[5]**2+e[9]**2).toFixed(2)),a=parseFloat(Math.sqrt(e[2]**2+e[6]**2+e[10]**2).toFixed(2));return t===n&&n===a?t:NaN}function translation(e){return{x:e[12],y:e[13],z:e[14]}}function rotation(e){const t=e.map((t=>t*(1/scale(e))));return t[8]<1?t[8]>-1?{x:Math.atan2(-t[9],t[10])*(180/Math.PI),y:Math.asin(t[8])*(180/Math.PI),z:Math.atan2(-t[4],t[0])*(180/Math.PI)}:{x:-Math.atan2(-t[1],t[5])*(180/Math.PI),y:-90,z:0}:{x:Math.atan2(t[1],t[5])*(180/Math.PI),y:90,z:0}}function toTransformFromApiMatrix(e){return null!=e?{position:translation(e),rotation:rotation(e),scale:scale(e)}:void 0}const wt={position:s.Vector3.create(0,0,0),rotation:s.Vector3.create(0,0,0),scale:1},Vt=n.atom({key:"transformWidgetEnabled",default:!1}),Ct=n.atom({key:"transformWidgetPosition",default:void 0}),jt=n.atom({key:"transformWidgetOrientationOverride",default:void 0}),Tt=n.selector({key:"transformWidgetOrientation",get:({get:e})=>{const t=e(jt),n=e(lt);if(null!=t)return t;if(null!=n){const t=e(Mt(n.id));return s.Euler.fromDegrees({x:null==t?void 0:t.world.rotation.x,y:null==t?void 0:t.world.rotation.y,z:null==t?void 0:t.world.rotation.z})}}}),kt=n.atom({key:"transformWidgetCachedOrientation",default:void 0}),At=n.atom({key:"transformWidgetSyncToSelection",default:!1}),Pt=n.atom({key:"transformWidgetIsInteracting",default:!1}),Et=n.atomFamily({key:"appliedItemTransform",default:void 0}),It=n.atom({key:"appliedItemTransformIds",default:[]}),Rt=n.atom({key:"selectedCoordinateSpace",default:"world"}),Nt=n.atomFamily({key:"editedItemTransform",default:void 0}),Ot=n.selectorFamily({key:"displayedItemTransform",get:e=>({get:t})=>{const n=t(Rt),a=t(vt),s=t(Mt(e)),o=t(Nt(e));return null!=o?o.transform:null!=s?pickLocalOrWorldTransform(mapItemTransforms(s,(e=>convertTransformToUnits(e,a))),n):void 0},set:e=>({get:t,set:a},s)=>{const o=t(Rt),l=t(Bt(e)),i=t(Mt(e)),r=t(vt);if(null!=i&&!(s instanceof n.DefaultValue)&&null!=s&&null!=l){a(Nt(e),{coordinateSpace:o,units:r,transform:s});const n=makeItemTransforms(convertTransformFromUnits(toValidTransform(s),r),l,o),i=t(It);a(Et(e),n),a(It,[...i,e])}}}),Mt=n.selectorFamily({key:"fetchedItemTransforms",get:e=>({get:t})=>{var n,a;const s=t(at(e));if(null!=s){const e=(null===(n=s.override)||void 0===n?void 0:n.transform)?toTransformFromApiMatrix(null===(a=s.override)||void 0===a?void 0:a.transform):void 0,t=s.worldTransform?toTransformFromApiMatrix(s.worldTransform):void 0;return{local:null!=e?e:wt,world:null!=t?t:wt}}}}),Lt=n.atom({key:"transformInvalidator",default:0}),Bt=n.selectorFamily({key:"parentItemWorldMatrix",get:e=>({get:t})=>{const n=undefined;if(null!=t(F)){const n=t(at(e));if(null!=(null==n?void 0:n.parentId)){const e=t(Mt(n.parentId)),a=t(Et(n.parentId));if(null==e)throw new Error("Invalid state. Parent item state should be populated, but is undefined.");return null!=a?l.toMatrix(l.toRadiansTransform(a.world)):l.toMatrix(l.toRadiansTransform(e.world))}}return logger_debug(`Unable to find the world matrix for the parent of ${e}. Returning the identity matrix.`),s.Matrix4.makeIdentity()}});function useUpdateEditedTransformWhenSettingsChange(e){const t=n.useRecoilValue(vt),s=n.useRecoilValue(Rt),o=n.useRecoilValue(Et(null!=e?e:"")),[l,i]=n.useRecoilState(Nt(null!=e?e:""));a.useEffect((()=>{if(null!=o&&((null==l?void 0:l.coordinateSpace)!==s||(null==l?void 0:l.units)!==t)){const e=undefined,n=convertTransformToUnits(pickLocalOrWorldTransform(o,s),t);i({units:t,coordinateSpace:s,transform:n})}}),[t,s])}function useEditItemTransform(e){const t=useTransformActions();useUpdateEditedTransformWhenSettingsChange(e);const a=n.useRecoilValueLoadable(Bt(null!=e?e:"")),[s,o]=n.useRecoilStateLoadable(Ot(null!=e?e:""));return{transform:"hasValue"===s.state?s.contents:void 0,loading:"loading"===s.state||"loading"===a.state,error:"hasError"===s.state?s.contents:void 0,async update(n){o(n),null!=e&&await t.applyTransformToItem(e)}}}const useTransformActions=()=>{const e=useApplicationMessageActions(),t=useViewerSceneActions(),n=useActionCallback((({set:e,snapshot:t})=>async()=>{const n=await t.getPromise(ht);e(Ct,n)})),a=useActionCallback((({set:e,snapshot:t})=>async()=>{const a=await t.getPromise(Ct),s=await t.getPromise(rt),o=await t.getPromise(ot),l=await t.getPromise(xt);null==a&&(o.length>0||s||l>0)&&await n(),e(At,!0)})),o=useActionCallback((({set:e})=>async t=>{e(Ct,null!=t?t:void 0)})),i=useActionCallback(retainSnapshot((({snapshot:e,set:t,reset:n})=>async()=>{const a=await e.getPromise(Tt),s=undefined;(await e.getPromise(It)).forEach((e=>{n(Et(e)),n(Nt(e))})),n(It),null!=a&&t(kt,a),t(Lt,(e=>e+1))}))),r=useActionCallback((({set:e,reset:t})=>n=>{t(kt),e(jt,n)})),c=useActionCallback((({set:e})=>()=>{e(Ct,void 0),e(Vt,!1)}));return{enableTransformWidget:useActionCallback((({set:t})=>async(s,l)=>{e.setToastMessage({message:"Transform manipulator enabled! Select parts to interact.",duration:Je}),t(Vt,!0),l?await n():null==s?await a():await o(s)})),disableTransformWidget:useActionCallback((({reset:e})=>()=>{e(Vt),e(jt)})),setTransformWidgetOrientation:r,clearTransformWidgetOrientation:useActionCallback((({reset:e})=>()=>{e(kt),e(jt)})),setTransformWidgetPosition:o,clearTransformWidgetPosition:useActionCallback((({reset:e})=>()=>e(Ct))),invalidateTransforms:i,setIsInteractivelyTransforming:useActionCallback((({set:e})=>t=>{e(Pt,t)})),setDefaultWidgetPosition:a,setDefaultWidgetPositionToSelection:n,enableSelectionSync:useActionCallback((({set:e})=>()=>e(At,!0))),disableSelectionSync:useActionCallback((({reset:e})=>()=>e(At))),syncToSelection:useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromise(mt),n=await e.getPromise(pt),a=undefined;if(await e.getPromise(At)){const e=null==n?void 0:n.boundingBox,a=null!=e&&null!=(null==t?void 0:t.boundingBox)&&equals(e,t.boundingBox);null==e||a||await o(s.BoundingBox.center(e))}})),orientToHitResult:useActionCallback((({reset:e})=>async t=>{e(At),null!=t?(await o(null==t?void 0:t.position),r(s.Vector3.eulerTo(s.Vector3.up(),t.normal))):(e(Ct),r(void 0))})),clearSelectedTransforms:useActionCallback((()=>async()=>{await t.execute(tt.CLEAR_SELECTED_TRANSFORMS,(e=>e.where((e=>e.withSelected())).clearTransforms())),await i(),c()})),clearAllTransforms:useActionCallback((()=>async()=>{await t.execute(tt.CLEAR_SELECTED_TRANSFORMS,(e=>e.where((e=>e.all())).clearTransforms())),await i(),c()})),applyTransformToItem:useActionCallback((({snapshot:e})=>async t=>{const n=await e.getPromise(M),a=await(null==n?void 0:n.scene()),o=await e.getPromise(Et(t));if(null==o)return void logger_warn(`There is no transform to apply to item ${t}.`);const i=s.Matrix4.transpose(l.toMatrix(l.toRadiansTransform(null==o?void 0:o.local)));return null==a?void 0:a.items((e=>e.where((e=>e.withItemId(t))).transform(i))).execute()}))}},useHitActions=()=>{const e=useCrossSectioningActions(),t=useMeasurementActions(),n=useTransformActions(),a=useActionCallback(retainSnapshot((({snapshot:e})=>async()=>{const n=await e.tryGetPromise(ve).then((e=>e.value)),a=await e.getPromise(De);null==n&&null!=(null==a?void 0:a.start)&&null!=a.end&&await t.resetMeasurement()}))),s=useActionCallback(retainSnapshot((({snapshot:e})=>async()=>{const t=await e.tryGetPromise(ve).then((e=>e.value));await n.orientToHitResult(t)}))),o=useActionCallback(retainSnapshot((({set:e,snapshot:t})=>async()=>{const n=await t.tryGetPromise(ve).then((e=>e.value));e(Re,n)}))),l=useActionCallback(retainSnapshot((({snapshot:e,set:t})=>async()=>{t(fe,await e.tryGetPromise(ve).then((e=>e.value)))})));return{tap:useActionCallback(retainSnapshot((({snapshot:t,set:n})=>async({detail:i},...r)=>{const c=await t.getPromise($e),u=await t.getPromise(ne),d=2!==(null==i?void 0:i.buttons)&&!(null==i?void 0:i.altKey);i.altKey||i.ctrlKey||i.metaKey||i.shiftKey;const m=d&&!u.hitPending&&!c,p=await t.tryGetPromise(ve).then((e=>e.value));n(ge,p),n(xe,i),await a(),m&&(r.forEach((e=>e())),await s()),await o(),await e.sectionCurrentHit(),await l()}))),longPress:useActionCallback(retainSnapshot((({snapshot:e,set:t,reset:n})=>async a=>{n(xe),t(he,a.detail),await e.tryGetPromise(ve),await o(),await l()})))}},_t=n.selector({key:"viewerToolkitHitState",get:({get:e})=>{const t=undefined,n=undefined,a=undefined,s=undefined,o=undefined;return{tapDetails:e(xe),longPressDetails:e(he),previousHitResult:e(ge),currentHitResult:e(fe)}}});var Dt=Object.freeze({__proto__:null,currentHitResult:fe,hitResult:ve,hitResultsLongPressDetails:he,hitResultsSkipNextTap:ye,hitResultsTapDetails:xe,hitState:_t,previousHitResult:ge,useHitActions:useHitActions});function useSelectionActions(){const e=useSceneViewItemActions(),t=useTransformActions(),n=useViewerSceneActions(),a=useActionCallback((({snapshot:e,reset:t})=>async()=>{const n=undefined;(await e.getPromise(ot)).forEach((e=>t(st(e))))})),s=useActionCallback((({snapshot:e,reset:t,set:a})=>async(s,o)=>{var l,i;const r=await e.getPromise(st(s.id)),c=await e.getPromise(ot),u=null===(i=[...null!==(l=s.ancestors)&&void 0!==l?l:[]])||void 0===i?void 0:i.reverse().find((e=>!c.includes(e)));null!=r&&null!=u?(a(st(u),{id:u}),a(ot,(e=>[...e,u])),n.execute(tt.SELECTING_ANCESTOR,n.selectItemsTransform(u))):(null==o?void 0:o.clear)?(a(st(s.id),s),a(ot,[s.id]),n.execute(tt.SELECTING_ONLY_ITEM,n.clearSelectionTransform,n.selectItemsTransform(s.id))):(a(st(s.id),s),a(ot,(e=>[...e,s.id])),n.execute(tt.SELECTING_ITEMS,n.selectItemsTransform(s.id))),d(s),a(lt,s),a(it,!0),t(rt)})),o=useActionCallback((({reset:e,set:t})=>async a=>{e(st(a)),e(rt),t(ot,(e=>e.filter((e=>e!==a)))),n.execute(tt.DESELECTING_ITEMS,n.deselectItemsTransform(a))})),l=useActionCallback((({snapshot:e})=>async t=>{const n=await e.getPromise(st(t.id));null!=n?await o(n.id):await s(t)})),i=useActionCallback((({snapshot:n,reset:a,set:o})=>async(l,i={})=>{const r=await n.getPromise(st(l.id)),c=await n.getPromise(ot);if(c.filter((e=>{var t;return e!==l.id&&!(null===(t=l.ancestors)||void 0===t?void 0:t.includes(e))})).forEach((e=>a(st(e)))),a(rt),r)if(i.ignoreAncestorSelection)a(ot),a(st(r.id));else{const e=c.filter((e=>{var t;return e===l.id||(null===(t=l.ancestors)||void 0===t?void 0:t.includes(e))}));o(ot,e)}else a(ot);e.invalidateCachedItems(),t.clearTransformWidgetOrientation(),await s(l,{clear:!0})})),r=useActionCallback((({reset:e})=>async()=>{await a(),e(ot),e(lt),e(it),e(rt),t.clearTransformWidgetPosition(),t.clearTransformWidgetOrientation()})),c=useActionCallback((()=>async()=>{await r(),n.execute(tt.CLEAR_SELECTION,n.clearSelectionTransform)})),u=useActionCallback((({set:e})=>async t=>{e(rt,t)})),d=useActionCallback((({reset:e,set:t})=>e=>{}));return{select:s,toggleSelection:l,clearAndSelect:i,selectCurrentHit:useActionCallback(retainSnapshot((({snapshot:e})=>async()=>{const t=await e.tryGetPromise(ve).then((e=>e.value)),n=await e.getPromise(xe),a=(null==n?void 0:n.metaKey)||(null==n?void 0:n.ctrlKey)||(null==n?void 0:n.shiftKey);null==t||a?null!=t&&a?await l(t):await c():await i(t)}))),syncSelection:useActionCallback((({set:e,reset:t})=>async(n,s)=>{s.selected?(await a(),e(st(n.id),n),s.multiSelect?e(ot,(e=>[...e.filter((e=>e!==n.id)),n.id])):e(ot,[n.id]),d(n),e(lt,n),e(it,!1),e(rt,!!s.multiSelect)):(t(st(n.id)),t(rt),e(ot,(e=>e.filter((e=>e!==n.id)))))})),deselect:o,clearSelection:c,resetSelectionState:r,toggleLastSelectWasMultiSelect:u,selectForModelViewsPanel:d}}const zt=n.selector({key:"viewerToolkitSelectionState",get:({get:e})=>{const t=undefined,n=undefined,a=undefined,s=undefined;return{selectedItemIds:e(ot),lastSelected:e(lt),highestSelectedAncestorId:e(dt)}}});var Ft=Object.freeze({__proto__:null,fetchedAndSelectedItems:ft,selectionBoundingBoxCenter:ht,selectionFirstSelectedItemInTreeId:ut,selectionHasMultipleSelected:ct,selectionHighestSelectedAncestor:dt,selectionIsActive:gt,selectionLastSelectWasMultiSelect:rt,selectionLastSelected:lt,selectionLastSelectionFromViewer:it,selectionPreviousVisibleSummary:mt,selectionSelectedItemIds:ot,selectionSelectedItems:st,selectionState:zt,selectionVisibleCount:xt,selectionVisibleSummary:pt,useSelectionActions:useSelectionActions});const Ht=255,Ut=n.atom({key:"sceneItemAdjustmentsSelectedColor",default:void 0}),Wt=n.atom({key:"sceneItemAdjustmentsSelectedOpacity",default:void 0}),Gt=n.atomFamily({key:"appliedItemMaterialOverride",default:void 0}),Kt=n.atom({key:"appliedItemMaterialOverrideIds",default:[]}),$t=n.selector({key:"sceneItemAdjustmentsLastSelectedOverride",get:({get:e})=>{const t=e(lt);if(null!=t)return e(Gt(t.id))}}),qt=n.atom({key:"applyMaterialToAllUserAction",default:void 0}),Yt=n.atom({key:"showConfirmDialogWhenApplyingMaterialToAll",default:!0}),Xt=n.atom({key:"confirmApplyMaterialToAllDialogOpen",default:!1}),useSceneItemMaterialActions=()=>{const e=useViewerSceneActions(),t=useActionCallback((({snapshot:e,reset:t})=>async()=>{const n=await e.getPromise(Kt);t(Ut),n.forEach((e=>t(Gt(e)))),t(Kt)}));return{updateColor:useActionCallback((({set:e})=>t=>{e(Ut,t)})),clearCurrentColor:useActionCallback((({reset:e})=>()=>{e(Ut)})),clearCurrentOpacity:useActionCallback((({reset:e})=>()=>{e(Wt)})),clear:useActionCallback((({snapshot:t,set:n,reset:a})=>async()=>{const s=await t.getPromise(ot);a(Ut),s.forEach((e=>a(Gt(e)))),n(Kt,(e=>e.filter((e=>!s.includes(e))))),await e.execute(tt.CLEAR_SELECTED_MATERIAL_OVERRIDES,(e=>e.where((e=>e.withSelected())).clearMaterialOverrides().select()))})),clearAll:useActionCallback((()=>async()=>{await t(),await e.execute(tt.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(Wt,t)})),apply:useActionCallback((({snapshot:t,set:n})=>async()=>{const a=await t.getPromise(Ut),s=await t.getPromise(Wt),o=await t.getPromise(ot),l=await t.getPromise($t),i=null!=a?a:l,r=null!=s?s:null==l?void 0:l.opacity;if(null!=i){const t=Object.assign(Object.assign({},i),{opacity:null!=r?r:i.opacity});await e.execute(tt.APPLY_MATERIAL_OVERRIDE_TO_SELECTION,(e=>e.where((e=>e.withSelected())).materialOverride(t))),o.forEach((e=>n(Gt(e),t))),n(Kt,(e=>[...e,...o]))}})),confirmApplyAll:useActionCallback((({set:e})=>t=>{e(Xt,!0),e(qt,(()=>t))})),cancelApplyAll:useActionCallback((({reset:e})=>()=>{e(Xt),e(qt)})),applyAll:useActionCallback((({snapshot:t,reset:n})=>async()=>{const a=await t.getPromise(Ut),s=await t.getPromise(Wt);if(null!=a){const o=await t.getPromise(Kt),l=Object.assign(Object.assign({},a),{opacity:null!=s?s:a.opacity});await e.execute(tt.APPLY_MATERIAL_OVERRIDE_TO_ALL,(e=>e.where((e=>e.all())).materialOverride(l))),o.forEach((e=>n(Gt(e))));const i=await t.getPromise(qt);null==i||i(l),n(Xt),n(qt)}})),hideConfirmApplyAllDialog:useActionCallback((({set:e})=>()=>{e(Yt,!1)}))}},Zt="#FFFFFF",Jt=n.atom({key:"viewerBackgroundSelectedColor",default:Zt}),VertexSceneItemMaterialApplyAll=({onApplyAll:t})=>{const a=useSceneItemMaterialActions(),s=n.useRecoilValueLoadable($t),l=n.useRecoilValue(Ut),i=n.useRecoilValue(Yt),r=u.useMemo((()=>"hasValue"===s.state?null!=l?l:s.contents:l),[s,l]);return e.jsx(o.VertexTooltip,{content:"Apply to All",children:e.jsx(o.VertexIconButton,{iconName:"square-dot-outline",iconSize:"sm",color:"secondary",disabled:null==r,onClick:async()=>{i?a.confirmApplyAll(t):(await a.applyAll(),null==t||t(r))}})})};function SceneItemMaterialApplyAllConfirmationDialog(){const t=useSceneItemMaterialActions(),s=n.useRecoilValue(Xt),[l,i]=a.useState(!1),onCloseDialog=()=>{t.cancelApplyAll(),i(!1)};return s?e.jsxs(o.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(o.VertexToggle,{"data-testid":"hide-confirmation-dialog-in-future-checkbox",variant:"check",className:"pt-0.5",checked:l,onValueChanged:e=>{i(e.detail)}}),"Don't show again this session"]}),e.jsxs("div",{className:"flex ml-auto gap-2",children:[e.jsx(o.VertexButton,{"data-testid":"cancel-apply-material-to-all",onClick:onCloseDialog,children:"Cancel"}),e.jsx(o.VertexButton,{color:"primary","data-testid":"confirm-apply-material-to-all",onClick:async()=>{await t.applyAll(),l&&t.hideConfirmApplyAllDialog()},children:"Apply"})]})]})]}):e.jsx(e.Fragment,{})}function createColorMaterialWithId(e,t=O.create()){return Object.assign({id:t},l.ColorMaterial.fromHex(e))}const VertexSceneItemMaterialColorPicker=({onApply:t})=>{const a=useSceneItemMaterialActions(),s=n.useRecoilValueLoadable($t),o=n.useRecoilValue(Ut),l=u.useMemo((()=>"hasValue"===s.state?null!=o?o:s.contents:o),[s,o]);return e.jsx(VertexColorPicker,{"data-testid":"selected-item-color-picker",value:null!=l?T.toHexString(l.diffuse):void 0,onValueChanged:()=>{a.apply(),null==t||t(l)},onInput:async e=>{a.updateColor(createColorMaterialWithId(e)),await a.apply()}})},VertexSceneItemMaterialOpacitySlider=({onApply:t})=>{const a=useSceneItemMaterialActions(),s=n.useRecoilValue(Wt),l=n.useRecoilValueLoadable($t),i=u.useMemo((()=>{var e,t;return"hasValue"===l.state?null!==(t=null!=s?s:null===(e=l.contents)||void 0===e?void 0:e.opacity)&&void 0!==t?t:Ht:null!=s?s:Ht}),[s,l]),r=useDebouncedCallback((()=>{a.apply()}),500),c=u.useCallback((e=>{a.updateOpacity(e.detail.value),r(e.detail.value)}),[r,a]),d=u.useMemo((()=>"hasValue"!==l.state||null==l.contents),[l]);return e.jsx(o.VertexTooltip,{className:"flex w-full",content:d?"Select a part and apply a color to enable opacity":`${Math.floor(i/Ht*100)}%`,placement:"top",children:e.jsx(VertexSlider,{"data-testid":"scene-item-adjustments-opacity-slider",leftLabel:"0%",rightLabel:"100%",disabled:d,value:null!=i?i:Ht,step:5,min:0,max:Ht,onValueChange:e=>{a.updateOpacity(e.detail.value),a.apply(),null==t||t(e.detail.value)},onValueInput:c})})};function VertexMaterialControls({onApplyMaterial:t,onApplyMaterialToAll:s,onApplyOpacity:o}){const l=useSceneItemMaterialActions(),i=n.useRecoilValue(lt);return a.useEffect((()=>{l.clearCurrentColor(),l.clearCurrentOpacity()}),[null==i?void 0:i.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:s})]})]}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Opacity"}),e.jsx(VertexSceneItemMaterialOpacitySlider,{onApply:o}),e.jsx(SceneItemMaterialApplyAllConfirmationDialog,{})]})}const ResetButton=({id:t,tooltip:n,children:s})=>{const[l,i]=a.useState(!1);return e.jsx("div",{className:"ml-auto",children:e.jsxs(o.VertexDropdownMenu,{className:"flex items-stretch h-full","data-testid":`reset-button-dropdown-menu-${t}`,placement:"bottom-end",onMenuOpened:()=>i(!0),onMenuClosed:()=>i(!1),children:[e.jsx("div",{slot:"anchor",className:"flex items-center h-full",children:e.jsx(o.VertexTooltip,{content:n,disabled:l,placement:"bottom",children:e.jsxs(o.VertexButton,{className:Ce("p-1.5 rounded-md select-none hover:bg-neutral-300 active:bg-neutral-400 cursor-pointer",{"bg-neutral-300":l}),"data-testid":`reset-button-${t}`,variant:"plaintext",children:[e.jsx(o.VertexIcon,{className:"px-0.5",name:"reset",size:"sm"}),e.jsx(o.VertexIcon,{name:"chevron-down",size:"sm"})]})})}),e.jsx("div",{className:"whitespace-nowrap",children:s})]})})},VertexSceneItemMaterialClear=({onClear:t,onClearAll:a})=>{const s=useSceneItemMaterialActions(),l=n.useRecoilValue(gt);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(o.VertexMenuItem,{"data-testid":"clear-selected-materials",onClick:()=>{s.clear(),null==t||t()},disabled:!l,children:"Clear selected materials"}),e.jsx(o.VertexMenuItem,{"data-testid":"clear-all-materials",onClick:()=>{s.clearAll(),null==a||a()},children:"Clear all materials"})]})})};function VertexMaterialPanelSection({onClearMaterial:t,onClearAllMaterials:n,onApplyMaterial:a,onApplyMaterialToAll:s,onApplyOpacity:o}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Material",e.jsx(VertexSceneItemMaterialClear,{onClear:t,onClearAll:n})]}),children:e.jsx(VertexMaterialControls,{onApplyMaterial:a,onApplyMaterialToAll:s,onApplyOpacity:o})})}const Qt="#ffff00",en=35,tn=1,nn=n.atom({key:"selectionHighlightingSelectedColor",default:Qt}),an=n.atom({key:"selectionHighlightingSelectedOpacity",default:en}),sn=n.atom({key:"selectionHighlightingSelectedLineThickness",default:1}),VertexSelectionHighlightingColorPicker=({onUpdate:t})=>{const[a,s]=n.useRecoilState(nn);return e.jsx(VertexColorPicker,{"data-testid":"selection-highlighting-color-picker",value:a,onValueChanged:e=>{null==t||t(e.detail)},onInput:e=>s(e)})},VertexSelectionHighlightingLineThicknessSlider=({onUpdate:t})=>{const[a,s]=n.useRecoilState(sn);return e.jsx(VertexSlider,{id:"selection-highlighting-line-thickness","data-testid":"selection-highlighting-line-thickness-slider",leftLabel:"Off",rightLabel:"Thick",min:0,max:3,step:.5,value:a,valueLabelDisplay:"auto",onValueInput:e=>{s(e.detail.value)},onValueChange:e=>{null==t||t(e.detail.value)}})},VertexSelectionHighlightingOpacitySlider=({onUpdate:t})=>{const[a,s]=n.useRecoilState(an);return e.jsx(VertexSlider,{id:"selection-highlighting-opacity","data-testid":"selection-highlighting-opacity-slider",leftLabel:"0%",rightLabel:"100%",min:0,max:100,step:5,value:a,valueLabelDisplay:"auto",onValueInput:e=>{s(e.detail.value)},onValueChange:e=>{null==t||t(e.detail.value)}})};function VertexSelectionHighlightingControls({onUpdateSelectionHighlightColor:t,onUpdateSelectionHighlightOpacity:n,onUpdateSelectionHighlightLineThickness:a}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Color"}),e.jsx(VertexSelectionHighlightingColorPicker,{onUpdate:t}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Opacity"}),e.jsx(VertexSelectionHighlightingOpacitySlider,{onUpdate:n}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Line Thickness"}),e.jsx(VertexSelectionHighlightingLineThicknessSlider,{onUpdate:a})]})}const VertexSelectionHighlightingReset=({onReset:t})=>{const[a,s]=n.useRecoilState(nn),[l,i]=n.useRecoilState(an),[r,c]=n.useRecoilState(sn),u=a!==Qt||l!==en||1!==r;return e.jsx("div",{className:"ml-auto",children:e.jsx(o.VertexTooltip,{content:"Reset Selection Highlighting",children:e.jsx(o.VertexIconButton,{"data-testid":"selection-highlighting-reset",iconName:"reset",iconSize:"sm",onClick:()=>{s(Qt),i(en),c(1),null==t||t()},disabled:!u})})})};function VertexSelectionHighlightingPanelSection({onResetSelectionHighlighting:t,onUpdateSelectionHighlightColor:n,onUpdateSelectionHighlightOpacity:a,onUpdateSelectionHighlightLineThickness:s}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Selection Highlighting",e.jsx(VertexSelectionHighlightingReset,{onReset:t})]}),children:e.jsx(VertexSelectionHighlightingControls,{onUpdateSelectionHighlightColor:n,onUpdateSelectionHighlightOpacity:a,onUpdateSelectionHighlightLineThickness:s})})}const VertexViewerBackgroundColorPicker=({onUpdate:t})=>{const[a,s]=n.useRecoilState(Jt);return e.jsx(VertexColorPicker,{"data-testid":"viewer-background-color-picker",value:a,onValueChanged:e=>{null==t||t(e.detail)},onInput:e=>s(e)})};function VertexViewerBackgroundControls({onUpdateViewerBackgroundColor:t}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Color"}),e.jsx(VertexViewerBackgroundColorPicker,{onUpdate:t})]})}const VertexViewerBackgroundReset=({onReset:t})=>{const[a,s]=n.useRecoilState(Jt),l=a!==Zt;return e.jsx("div",{className:"ml-auto",children:e.jsx(o.VertexTooltip,{content:"Reset Background Color",children:e.jsx(o.VertexIconButton,{"data-testid":"viewer-background-reset",iconName:"reset",iconSize:"sm",onClick:()=>{s(Zt),null==t||t()},disabled:!l})})})};function VertexViewerBackgroundPanelSection({onResetViewerBackgroundColor:t,onUpdateViewerBackgroundColor:n}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Viewer Background",e.jsx(VertexViewerBackgroundReset,{onReset:t})]}),children:e.jsx(VertexViewerBackgroundControls,{onUpdateViewerBackgroundColor:n})})}const isInputElement=e=>{const t=e instanceof HTMLElement&&"VERTEX-AUTO-RESIZE-TEXTAREA"===e.tagName,n=e instanceof HTMLElement&&"VERTEX-TEXTFIELD"===e.tagName,a=e instanceof HTMLElement&&"true"===e.contentEditable,s=e instanceof HTMLElement&&"VERTEX-SCENE-TREE-SEARCH"===e.tagName,o=e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement,l=e instanceof HTMLElement&&"VERTEX-VIEWER-PIN-TOOL"===e.tagName,i=e instanceof HTMLElement&&"VERTEX-VIEWER-TRANSFORM-WIDGET"===e.tagName;return t||n||a||s||o||l||i},useRecoilReducer=({reducer:e,atom:t})=>{const a=undefined,s=undefined;return[n.useRecoilValue(t),useRecoilReducerDispatch({reducer:e,atom:t})]},useRecoilReducerDispatch=({reducer:e,atom:t})=>{const a=n.useRecoilCallback((({set:n})=>async a=>{n(t,(t=>e(t,a)))}),[]);return a},on=n.atom({key:"keyBindings",default:{applyBindings:[],bindings:{},pressed:{}}});function reducer(e,t){var n,a,s,o;switch(t.type){case"push-key-binding":const l=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!==(a=e.bindings[t.binding.keyBind])&&void 0!==a?a:[],t.binding]})});case"remove-key-binding":const i=undefined;return null==(null===(s=e.bindings[t.binding.keyBind])||void 0===s?void 0:s.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:[]).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:on});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 a;return null!=e.keyBind&&null!=n&&(null===(a=e.keyBind)||void 0===a?void 0:a.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();a.useEffect((()=>{const a=O.create();return n({type:"add-apply-key-binding",binding:Object.assign(Object.assign({},e),{id:a,active:null!=e.keyBind&&allPressed(e.keyBind,t.pressed)})}),()=>{n({type:"remove-apply-key-binding",id:a})}}),[e.fn,e.off,e.keyBind,e.repeat])},useStackKeyBinding=(e,t=[])=>{const[,n]=useKeyBindingState();a.useEffect((()=>{const t=null==e.addPredicate||e.addPredicate(),a=null!=e.cancelPredicate&&e.cancelPredicate();t&&n({type:"push-key-binding",binding:e}),a&&n({type:"remove-key-binding",binding:e})}),t)},useKeyBindings=({keydownRepeatInterval:e=25,keydownIgnorePredicate:t=isInputElement}={})=>{const[n,s]=useKeyBindingState(),o=a.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],a=t.length>0?t[t.length-1]:void 0;null!=a&&(a.fn(),s({type:"remove-key-binding",binding:a}))}))}),[n]);a.useEffect((()=>{const handleKeyDown=e=>{if(!e.repeat&&!t(e.target)){s({type:"set-key-pressed",key:e.key,pressed:!0}),o(e.key);const t=Object.assign(Object.assign({},n.pressed),{[e.key]:!0}),a=matchingSingleFnBindings(n.applyBindings,t,e.key),l=matchingOffBindings(n.applyBindings,t,e.key);(a.length>0||l.length>0)&&e.preventDefault()}},handleKeyUp=e=>{s({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)}}),[o,n.applyBindings,n.pressed]),a.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]),a.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(),a=n.useRecoilValue(Me);return useStackKeyBinding({id:"ExitBoxSelection",keyBind:"Escape",fn:t.disable,addPredicate:()=>a,cancelPredicate:()=>!a},[a]),e.jsx(o.VertexTooltip,{content:"Box Selection",children:e.jsx(o.VertexIconButton,{iconName:"box-cursor",iconColor:a?"primary":"secondary","data-testid":"viewer-toolbar-enable-box-selection-button",onClick:a?t.disable:t.enable})})},ln=1,VertexResizableContent=t=>{var{className:n,style:a,displayShadow:s,heading:l,id:i,initialScale:r,placement:c="left",children:u,onResize:d}=t,m=__rest(t,["className","style","displayShadow","heading","id","initialScale","placement","children","onResize"]);const p="left"===c||"right"===c,h="top"===c;function getHorizontalResizeDirection(){switch(c){case"left":return"right";case"right":return"left";default:return"none"}}function getVerticalResizeDirection(){return"top"===c?"top":"none"}const g=null!=r?r:1;return e.jsx(o.VertexResizable,Object.assign({id:i,"data-testid":`resizable-content-position-${c}`,className:Ce(n,"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"===c,"sidebar-shadow-right":"left"===c&&s,"border-l min-w-75 max-w-half":"right"===c,"sidebar-shadow-left":"right"===c&&s,"border-t bottom-0 fixed":"top"===c,"min-h-12 sheet":h}),style:Object.assign({maxHeight:"top"===c?window.innerHeight:void 0},a),initialHorizontalScale:p?r:void 0,initialVerticalScale:h?g:void 0,horizontalDirection:getHorizontalResizeDirection(),verticalDirection:getVerticalResizeDirection(),position:"right"===c||"top"===c?"absolute":"relative",onResizeEnd:()=>null==d?void 0:d()},m,{children:e.jsxs("div",{className:"flex flex-col h-full w-full",children:["top"===c&&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"})}),l,e.jsx("div",{className:Ce("w-full flex flex-col h-0 flex-grow",{"right-0":"right"===c}),children:u})]})}))};function useDefaultKeybindings(){useApplyKeyBinding({fn:useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromiseRequired(H),n={milliseconds:500},a=await t();await(null==a?void 0:a.camera().viewAll().render({animation:n}))})),keyBind:"f"})}function useLongPress({target:e,callback:t,delay:n=500,onMovement:a}){const[o,l]=u.useState(),[i,r]=u.useState();u.useEffect((()=>{const handleTouchStart=e=>{const a=e;null!=a.touches&&1===a.touches.length&&(null!=o&&clearTimeout(o),r(s.Point.create(a.touches[0].clientX,a.touches[0].clientY)),l(setTimeout((()=>null==t?void 0:t(a)),n)))},handleTouchMove=e=>{const t=e;null!=t.touches&&t.touches.length>0&&null!=o&&null!=i&&s.Point.distance(i,s.Point.create(t.touches[0].clientX,t.touches[0].clientY))>=2&&(clearTimeout(o),null==a||a())},handleTouchEnd=()=>{null!=o&&clearTimeout(o)};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,o,i])}function asBooleanAttribute(e){return!!e||void 0}const VertexContextMenu=({targetElement:t,menuType:s,disableBackdrop:l,openPredicate:i,onOpen:r,onClose:c,children:u})=>{const d=useContextMenuActions(),m=n.useRecoilValue(Pe),p=n.useRecoilValue(Oe),h=a.useMemo((()=>["bottom-end","top-start","top-end","right","left"]),[]),g=m===s;useStackKeyBinding({id:"ContextMenu",keyBind:"Escape",fn:d.clearActiveContextMenu,addPredicate:()=>null!=m&&m===s,cancelPredicate:()=>null==m},[m]);const f=a.useMemo((()=>null!=t?t:null!=i?window:void 0),[t,i]);return useLongPress({target:f,callback:e=>d.longPress(e,s,i,r),onMovement:()=>d.clearActiveContextMenu()}),a.useEffect((()=>{const handleWindowPointerDown=e=>{const t=undefined;if(!targetWithinMenu(e)&&2!==e.buttons&&m===s){const t=targetShouldSkipNextHit(e);d.clearActiveContextMenu(t)}};if(l)return window.addEventListener("pointerdown",handleWindowPointerDown),()=>{window.removeEventListener("pointerdown",handleWindowPointerDown)}}),[l,s,m]),a.useEffect((()=>{const handlePointerDown=e=>{d.pointerDown(e)},handlePointerUp=e=>{d.pointerUp(e,s,i,r)},handleContextMenu=e=>d.contextMenu(e,i);return null==f||f.addEventListener("pointerdown",handlePointerDown),null==f||f.addEventListener("pointerup",handlePointerUp),null==f||f.addEventListener("contextmenu",handleContextMenu),()=>{null==f||f.removeEventListener("pointerdown",handlePointerDown),null==f||f.removeEventListener("pointerup",handlePointerUp),null==f||f.removeEventListener("contextmenu",handleContextMenu)}}),[t,s,i]),e.jsx("div",{className:Ce({hidden:!g}),children:e.jsx(o.VertexMenu,{"data-testid":`${s}-context-menu`,open:asBooleanAttribute(g),position:p,fallbackPlacements:h,backdrop:!l,onMenuClosed:()=>{d.clearActiveContextMenu(),null==c||c()},children:e.jsx("div",{className:"pt-1",children:u})})})},VertexFitSelectedMenuItem=()=>{const t=n.useRecoilValue(ot),a=n.useRecoilValue(pt),s=useViewerCameraActions();return e.jsxs(o.VertexMenuItem,{"data-testid":"fit-selected-menu-option",onClick:()=>{null!=(null==a?void 0:a.boundingBox)&&s.flyToByBoundingBox(a.boundingBox)},disabled:asBooleanAttribute(0===t.length),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"fit-selected",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Fit Selected"})]})},VertexFlyToMenuItem=()=>{const t=useViewerCameraActions(),a=n.useRecoilValue(Re);return e.jsxs(o.VertexMenuItem,{"data-testid":"fly-to-part-menu-option",onClick:()=>{var e;const n=undefined,s=contextMenuItemIsRow(a)?null===(e=null==a?void 0:a.node.id)||void 0===e?void 0:e.hex:null==a?void 0:a.id;null!=s&&t.flyToById(s)},disabled:asBooleanAttribute(null==a),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"paper-airplane",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Fly To"})]})};function useSceneItemsOperations(){const e=n.useRecoilValue(M),t=undefined,s=undefined,o=undefined,l=undefined,i=undefined,r=undefined;return{sceneItemsOperation:a.useCallback((async(t,n)=>{const a=await(null==e?void 0:e.scene());null==n?await(null==a?void 0:a.items((e=>t(e.where((e=>e.all()))))).execute()):n.length>0&&await(null==a?void 0:a.items((e=>t(e.where((e=>e.withItemIds(n)))))).execute())}),[e]),showOnlySelected:a.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:a.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:a.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:a.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:a.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(o.VertexMenuItem,{"data-testid":"hide-all-menu-option",onClick:()=>{t.sceneItemsOperation((e=>e.hide()))},children:[e.jsx(o.VertexIcon,{slot:"icon",name:"visibility-hidden",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Hide All Parts"})]})},VertexHidePartMenuItem=()=>{const t=n.useRecoilValue(Re),a=useSceneItemsOperations();return e.jsxs(o.VertexMenuItem,{"data-testid":"hide-menu-option",onClick:()=>{var e;const n=undefined,s=contextMenuItemIsRow(t)?null===(e=null==t?void 0:t.node.id)||void 0===e?void 0:e.hex:t.id;null!=s&&a.sceneItemsOperation((e=>e.hide()),[s])},disabled:asBooleanAttribute(null==t),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"visibility-hidden",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Hide Part"})]})},VertexHideSelectedMenuItem=()=>{const t=n.useRecoilValue(ot),a=useSceneItemsOperations();return e.jsxs(o.VertexMenuItem,{"data-testid":"hide-selected-menu-option",onClick:()=>a.hideSelected(),disabled:asBooleanAttribute(0===t.length),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"visibility-hidden",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Hide Selected"})]})},VertexShowAllMenuItem=()=>{const t=useSceneItemsOperations();return e.jsxs(o.VertexMenuItem,{"data-testid":"show-all-menu-option",onClick:()=>{t.sceneItemsOperation((e=>e.show()))},children:[e.jsx(o.VertexIcon,{slot:"icon",name:"visibility-visible",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Show All Parts"})]})},VertexShowOnlyMenuItem=()=>{const t=n.useRecoilValue(Re),a=useSceneItemsOperations();return e.jsxs(o.VertexMenuItem,{"data-testid":"show-only-menu-option",onClick:()=>{var e;const n=undefined,s=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!=s&&a.showOnlyItem(s)},disabled:asBooleanAttribute(null==t),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"visibility-visible",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Show Only Part"})]})},VertexShowOnlySelectedMenuItem=()=>{const t=n.useRecoilValue(ot),a=useSceneItemsOperations();return e.jsxs(o.VertexMenuItem,{"data-testid":"show-only-selected-menu-option",onClick:()=>a.showOnlySelected(),disabled:asBooleanAttribute(0===t.length),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"visibility-visible",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Show Only Selected"})]})};n.atom({key:"sceneTreeLoaderVisible",default:!1});const rn=n.atom({key:"sceneTreeElement",default:void 0}),cn=n.atom({key:"sceneTreeController",default:void 0,dangerouslyAllowMutability:!0});function useSceneTreeActions(){const e=useSelectionActions(),t=useViewerCameraActions();return{toggleSelection:useActionCallback((({snapshot:t})=>async(n,a,s)=>{var o,l;if(!n.defaultPrevented&&0===n.button&&(n.altKey||((n.ctrlKey||n.metaKey)&&a.selected?await s.deselectItem(a):a.selected?await s.selectItem(a,{recurseParent:!0}):a.selected||await s.selectItem(a,{append:n.ctrlKey||n.metaKey,range:n.shiftKey})),null!=a.id)){const s=await t.getPromise(lt);e.syncSelection({id:null===(o=a.id)||void 0===o?void 0:o.hex,ancestors:null!==(l=null==s?void 0:s.ancestors)&&void 0!==l?l:[]},{selected:!n.metaKey&&!n.ctrlKey||!a.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 a;const s=await e.getPromise(rn),o=await(null==s?void 0:s.getRowAtClientY(n));null!=(null===(a=null==o?void 0:o.node.id)||void 0===a?void 0:a.hex)&&await t.flyToById(o.node.id.hex)})),flyToFirstSelectedItem:useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromise(rn),n=await e.getPromise(ut);null!=n&&(null==t||t.scrollToItem(n))})),setContextMenuItem:useActionCallback((({set:e,snapshot:t})=>async n=>{const a=await t.getPromise(rn),s=await(null==a?void 0:a.getRowAtClientY(n));e(Re,s)}))}}const VertexGhostSelectedMenuItem=()=>{const t=n.useRecoilValue(ot),a=useSceneItemsOperations();return e.jsxs(o.VertexMenuItem,{"data-testid":"ghost-selected-menu-option",onClick:()=>a.ghostSelected(),disabled:asBooleanAttribute(0===t.length),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"visibility-partial",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Ghost Selected"})]})},VertexUnghostSelectedMenuItem=()=>{const t=n.useRecoilValue(ot),a=useSceneItemsOperations();return e.jsxs(o.VertexMenuItem,{"data-testid":"unghost-selected-menu-option",onClick:()=>a.unGhostSelected(),disabled:asBooleanAttribute(0===t.length),children:[e.jsx(o.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(o.VertexMenuDivider,{}),e.jsx(VertexFitSelectedMenuItem,{}),e.jsx(VertexFlyToMenuItem,{})]}),VertexSceneTreeContextMenu=({children:t})=>{const a=useSceneTreeActions(),s=n.useRecoilValue(rn),o=null!=t&&!1!==t;return e.jsx(VertexContextMenu,{menuType:"scene-tree",targetElement:s,onOpen:async(e,t)=>{const n=e;await a.setContextMenuItem(n.clientY)},disableBackdrop:!0,children:o?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(o.VertexMenuDivider,{}),e.jsx(VertexFitSelectedMenuItem,{}),e.jsx(VertexFlyToMenuItem,{})]}),VertexViewerContextMenu=({children:t})=>{const n=null!=t&&!1!==t,s=a.useCallback((e=>e.target instanceof HTMLElement&&"vertex-viewer"===e.target.id),[]);return e.jsx(VertexContextMenu,{menuType:"viewer",disableBackdrop:!0,openPredicate:s,children:n?t:e.jsx(DefaultViewerContextMenu,{})})},un=35,dn=n.atom({key:"sceneItemGhostingSelectedOpacity",default:un}),mn=n.atomFamily({key:"appliedItemPhantomState",default:void 0}),pn=n.atom({key:"appliedItemPhantomStateIds",default:[]}),xn=n.selector({key:"sceneItemGhostingLastSelectedPhantom",get:({get:e})=>{var t;const n=e(lt);return null!=n&&(null!==(t=e(mn(n.id)))&&void 0!==t&&t)}}),VertexSceneItemGhostingOpacitySlider=({onApply:t})=>{const[a,s]=n.useRecoilState(dn);return e.jsx(VertexSlider,{id:"phantom-opacity","data-testid":"phantom-opacity-slider",leftLabel:"0%",rightLabel:"100%",min:0,max:100,step:5,value:a,valueLabelDisplay:"auto",onValueInput:e=>{s(e.detail.value)},onValueChange:e=>{null==t||t(e.detail.value)}})},useSceneItemPhantomActions=()=>{const e=useViewerSceneActions(),t=useActionCallback((({snapshot:e,reset:t})=>async()=>{const n=undefined;(await e.getPromise(pn)).forEach((e=>t(mn(e)))),t(pn)}));return{setPhantomState:useActionCallback((({snapshot:t,set:n})=>async a=>{const s=await t.getPromise(ot);s.forEach((e=>n(mn(e),a))),n(pn,(e=>[...e,...s])),await e.execute(tt.SET_PHANTOM_SELECTED_ITEMS,(e=>e.where((e=>e.withSelected())).setPhantom(a)))})),clearPhantomState:useActionCallback((({snapshot:t,set:n,reset:a})=>async()=>{const s=await t.getPromise(ot);s.forEach((e=>a(mn(e)))),n(pn,(e=>e.filter((e=>!s.includes(e))))),await e.execute(tt.CLEAR_PHANTOM_SELECTED_ITEMS,(e=>e.where((e=>e.withSelected())).clearPhantom()),(e=>e.where((e=>e.withSelected())).select()))})),clearAllPhantomState:useActionCallback((()=>async()=>{await t(),await e.execute(tt.CLEAR_PHANTOM_ALL,(e=>e.where((e=>e.all())).clearPhantom()),(e=>e.where((e=>e.withSelected())).select()))})),resetAllPhantomState:t}},VertexSceneItemGhostingToggle=({onApply:t})=>{const a=useSceneItemPhantomActions(),s=n.useRecoilValue(gt),l=n.useRecoilValueLoadable(xn);return e.jsx(o.VertexTooltip,{content:"Select a part to display as ghost",disabled:s,children:e.jsx(o.VertexToggle,{className:"flex items-center","data-testid":"phantom-state-toggle",variant:"switch",disabled:!s,checked:"hasValue"===l.state&&l.contents,onValueChanged:async e=>{await a.setPhantomState(e.detail),null==t||t(e.detail)}})})};function VertexGhostingControls({onApplyGhostingChange:t,onApplyOpacity:n}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center py-3",children:[e.jsx(VertexSceneItemGhostingToggle,{onApply:t}),e.jsx("span",{className:"pl-4 text-sm text-neutral-700",children:"Display as Ghost"})]}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Global Ghost Opacity"}),e.jsx(VertexSceneItemGhostingOpacitySlider,{onApply:n})]})}const VertexSceneItemGhostingClear=({onClear:t,onClearAll:a})=>{const s=useSceneItemPhantomActions(),l=n.useRecoilValue(xn);return e.jsx("div",{className:"ml-auto",children:e.jsxs(ResetButton,{id:"phantom",tooltip:"Clear Ghosting",children:[e.jsx("div",{className:"pt-1"}),e.jsx(o.VertexMenuItem,{"data-testid":"reset-selected-phantom",onClick:async()=>{await s.clearPhantomState(),null==t||t()},disabled:!l,children:"Clear ghosting for selected"}),e.jsx(o.VertexMenuItem,{"data-testid":"reset-all-phantom",onClick:async()=>{await s.clearAllPhantomState(),null==a||a()},children:"Clear ghosting for all"})]})})};function VertexGhostingPanelSection({onClearGhostState:t,onClearAllGhostState:n,onApplyGhostingChange:a,onApplyOpacity:s}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Ghosting",e.jsx(VertexSceneItemGhostingClear,{onClear:t,onClearAll:n})]}),children:e.jsx(VertexGhostingControls,{onApplyGhostingChange:a,onApplyOpacity:s})})}function VertexMeasurementContextMenu({onDelete:t}){const a=n.useRecoilValue(Ie);return e.jsx(VertexContextMenu,{menuType:"measurement",openPredicate:e=>e.target instanceof HTMLElement&&"VERTEX-VIEWER-MEASUREMENT-DISTANCE"===e.target.tagName,children:e.jsxs(o.VertexMenuItem,{"data-testid":"measurement-delete",onClick:()=>null!=a&&t(a.id),children:[e.jsx(o.VertexIcon,{slot:"icon",name:"delete",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Delete"})]})})}function useDockedPlacement(e,t){const[n,a]=u.useState(s.Point.create(0,0));return u.useLayoutEffect((()=>{if(null!=e){const n=e.getBoundingClientRect(),o=s.Point.create(n.left,n.bottom),l=s.Point.create(n.right,n.bottom);a("left"===t?o:l)}}),[e,t]),n}function VertexMeasurementDetails({placement:t}){const a=useMeasurementActions(),s=n.useRecoilValue(M),l=n.useRecoilValue(L),r=useDockedPlacement(null!=s?s:null,t),c=n.useRecoilValue(qe),u=n.useRecoilValue(Ye),d=n.useRecoilValue(Xe),m=n.useRecoilValue(Ze),p=n.useRecoilValue(vt),h=n.useRecoilValue(yt);return e.jsx(o.VertexDraggablePopover,{className:"z-popover",boundaryPadding:16,boundarySelector:`#${l}`,position:r,children:e.jsxs("div",{className:"flex flex-col leading-4 min-w-40",children:[e.jsxs("div",{className:"pb-2 flex justify-between",children:[e.jsx("div",{className:"w-full",children:"Measurement"}),e.jsx("div",{className:Ce("-mt-1 relative",{hidden:!m}),children:e.jsx(o.VertexTooltip,{content:"Reset",placement:"left-start",children:e.jsx(o.VertexIconButton,{"data-testid":"measurement-details-reset",iconName:"reset",iconSize:"sm",onClick:a.resetMeasurement})})})]}),e.jsx(i.VertexViewerMeasurementDetails,{"data-testid":"measurement-details-viewer-measurement-details",className:Ce("gap-y-1.5 text-xs",{hidden:null==c}),measurementOutcome:c,measurementOverlays:u,distanceUnits:toUnitType(p),fractionalDigits:parseInt(h,10)}),e.jsx("div",{"data-testid":"measurement-details-message",className:Ce("text-xs",{hidden:null==d}),children:d})]})})}function useCallbackRef(e){var t;const[n,s]=a.useState((t=void 0,null)),o=undefined;return{element:n,callback:a.useCallback((e=>s(e)),[])}}function VertexPointToPointMeasurement({detailsPlacement:t,onPointToPointMeasurementChange:s}){const o=useMeasurementActions(),l=n.useRecoilValue(M),r=n.useRecoilValue(Be),c=n.useRecoilValue(De),u=n.useRecoilValue(vt),d=n.useRecoilValue(yt),{callback:m,element:p}=useCallbackRef();usePointToPointMeasurement(p);const h=a.useCallback((e=>{const t={start:e.detail.start,end:e.detail.end,invalid:!e.detail.valid};o.setEditedPointToPointMeasurement(t),null==s||s(t)}),[o]);return r?e.jsxs(e.Fragment,{children:[e.jsx(i.VertexViewerMeasurementDistance,{"data-testid":"point-to-point-measurement",ref:m,viewer:null!=l?l:void 0,mode:"replace",start:null==c?void 0:c.start,end:null==c?void 0:c.end,invalid:null==c?void 0:c.invalid,units:toUnitType(u),fractionalDigits:parseInt(d,10),showAxisReferenceLines:!0,onEditEnd:h}),e.jsx(VertexMeasurementDetails,{placement:t}),e.jsx(VertexMeasurementContextMenu,{onDelete:o.resetMeasurement})]}):e.jsx(e.Fragment,{})}function VertexPointToPointMeasurementTool(){const t=useMeasurementActions(),a=n.useRecoilValue(Be);return useStackKeyBinding({id:"ExitMeasurement",keyBind:"Escape",fn:t.disableEditMeasurement,addPredicate:()=>a,cancelPredicate:()=>!a},[a,t]),e.jsx(o.VertexTooltip,{content:"Point to Point Measurement",children:e.jsx(o.VertexIconButton,{iconName:"tape-measure","data-testid":"viewer-toolbar-point-to-point-measurement-button",iconColor:a?"primary":"secondary",onClick:t.toggleEditPointToPointMeasurement})})}const hn=n.atom({key:"viewerToolkitSdkConfig",default:void 0}),VertexPreciseMeasurement=({detailsPlacement:t,onEntitiesChanged:a,onOutcomeChanged:s})=>{var o,l,r,c;const u=n.useRecoilValue(M),d=n.useRecoilValue(hn),m=n.useRecoilValue(Fe),{callback:p,element:h}=useCallbackRef();return usePreciseMeasurementModel(h,a,s),m?e.jsxs(e.Fragment,{children:[e.jsx(i.VertexViewerMeasurementPrecise,{"data-testid":"precise-measurement-viewer-tool",ref:p,viewer:null!=u?u:void 0,config:JSON.stringify({network:{apiHost:null===(o=null==d?void 0:d.network)||void 0===o?void 0:o.apiHost,renderingHost:null===(l=null==d?void 0:d.network)||void 0===l?void 0:l.renderingHost,sceneTreeHost:null===(r=null==d?void 0:d.network)||void 0===r?void 0:r.sceneTreeHost,sceneViewHost:null===(c=null==d?void 0:d.network)||void 0===c?void 0:c.sceneViewHost}})}),e.jsx(VertexMeasurementDetails,{placement:t})]}):e.jsx(e.Fragment,{})};function VertexPreciseMeasurementTool(){const t=useMeasurementActions(),a=n.useRecoilValue(Fe);return e.jsx(o.VertexTooltip,{content:"Precise Measurement",children:e.jsx(o.VertexIconButton,{iconName:"ruler","data-testid":"viewer-toolbar-precise-measurement-button",iconColor:a?"primary":"secondary",onClick:t.toggleEditPreciseMeasurement})})}function VertexApplicationMessages(){const t=n.useRecoilValue(et),a=n.useRecoilValue(Qe);return e.jsxs(e.Fragment,{children:[null!=t&&e.jsx(o.VertexBanner,{className:"z-[16000]",duration:t.duration,open:!0,content:t.message,type:t.type},t.id),null!=a&&e.jsx(o.VertexToast,{placement:"bottom-left",className:"z-[16000]",duration:a.duration,open:!0,content:a.message,type:a.type},a.id)]})}const gn={binding:"{{row.node.name}}",label:"Name",metadataKeyName:"VERTEX_SCENE_ITEM_NAME"};function mapToColumn(e,t){return{label:"name"===e.toLowerCase()?"Name (Property)":e,binding:`{{row.metadata.${e}}}`,initialWidth:t,minWidth:t/2}}const fn=n.atom({key:"sceneTreeColumnsRefreshTrigger",default:0}),vn=n.selector({key:"sceneTreeColumnsAvailableColumns",get:async({get:e})=>{const t=e(cn);return e(fn),null!=t?await t.fetchMetadataKeys():[]}}),yn=n.selector({key:"sceneTreeColumnsAvailableSortedColumns",get:({get:e})=>e(vn).filter((e=>e!==gn.metadataKeyName)).sort(((e,t)=>e.localeCompare(t)))}),bn=n.atom({key:"sceneTreeColumnsVisibleMetadataColumnNames",default:[]}),Sn=n.selector({key:"sceneTreeColumnsActiveColumns",get:({get:e})=>{const t=e(bn),n=e(rn),a=null==n?void 0:n.clientWidth;if(null!=a&&a>0){const e=1/(t.length+1)*a,n=(a-e)/t.length;return t.reduce(((e,t)=>{const a=mapToColumn(t,n);return Object.assign(Object.assign({},e),{[a.label]:a})}),{Name:Object.assign(Object.assign({},gn),{initialWidth:e,minWidth:n})})}return{Name:gn}}}),wn=n.selector({key:"sceneTreeColumnsActiveColumnNames",get:({get:e})=>Object.keys(e(Sn))});function useSceneTreeColumnActions(){return{setActive:useActionCallback((({set:e,snapshot:t})=>async n=>{e(bn,n);const a=await t.getPromise(cn);null==a||a.setMetadataKeys(n)})),refreshKeyList:useActionCallback((({set:e})=>()=>{e(fn,(e=>e+1))}))}}const Vn=16,Cn=-8;var jn;function useOpenColumnPopover({buttonElement:e,horizontalOffset:t,verticalOffset:n}){const[a,s]=u.useState(!1),[o,l]=u.useState(),[i,r]=u.useState(),c=u.useCallback((()=>{if(a)s(!1);else{const a=null==e?void 0:e.getBoundingClientRect();if(null!=a){const e=null!=t?t:Vn,o=null!=n?n:Cn,i=a.x>window.innerWidth/2?jn.LEFT:jn.RIGHT;l({x:i===jn.LEFT?a.left-e:a.right+e,y:a.top+o}),r(i),s(!0)}}}),[a,e]),d=u.useCallback((()=>{s(!1)}),[]);return{open:a,position:o,direction:i,handleOpen:c,handleClose:d}}!function(e){e.LEFT="left",e.RIGHT="right"}(jn||(jn={}));const Tn=n.atom({key:"sceneTreeSearchActive",default:!1}),kn=n.atom({key:"sceneTreeColumnsPartial",default:!1}),An=n.atom({key:"sceneTreeSearchValue",default:void 0}),Pn=n.atom({key:"sceneTreeSearchExactMatch",default:!1}),En=n.atom({key:"sceneTreeSearchResultCount",default:0}),In=n.atom({key:"sceneTreeSearchActiveColumns",default:[]}),Rn=n.selector({key:"sceneTreeSearchNameColumnActive",get:({get:e})=>{const t=e(In);return 0===t.length||t.includes(gn.metadataKeyName)}});function useSceneTreeSearch({sceneTreeElement:e}){const t=useSceneTreeActions(),s=n.useRecoilValue(Tn),o=n.useSetRecoilState(En),l=n.useSetRecoilState(ut);a.useEffect((()=>{let t;return whenComponentReady(e,(()=>{var n;t=null===(n=null==e?void 0:e.controller)||void 0===n?void 0:n.stateChanged((e=>{void 0!==(null==e?void 0:e.totalFilteredRows)&&o(null==e?void 0:e.totalFilteredRows)}))})),()=>{null==t||t.dispose()}}),[e]),a.useEffect((()=>{if(null!=e){let n;return whenComponentReady(e,(()=>{var a;n=null===(a=null==e?void 0:e.controller)||void 0===a?void 0:a.stateChanged((e=>{var n;if(null!=(null==e?void 0:e.filterTerm)){const t=null==e?void 0:e.rows.find((e=>{var t;return null===(t=null==e?void 0:e.node)||void 0===t?void 0:t.selected}));l(null===(n=null==t?void 0:t.node.id)||void 0===n?void 0:n.hex)}else s&&t.flyToFirstSelectedItem()}))})),()=>{null==n||n.dispose()}}}),[e,null==e?void 0:e.controller,open])}function useSceneTreePartialResults({sceneTreeElement:e}){const t=n.useSetRecoilState(kn);a.useEffect((()=>{let n;return whenComponentReady(e,(()=>{var a;n=null===(a=null==e?void 0:e.controller)||void 0===a?void 0:a.stateChanged((e=>{t(!!(null==e?void 0:e.isPartialKeysResponse))}))})),()=>{null==n||n.dispose()}}),[e])}const useSceneTreeSearchActions=()=>{const e=useActionCallback((({set:e})=>t=>{e(In,t)})),t=useActionCallback((({snapshot:t})=>async(n,a,s,o)=>{const l=await t.getPromise(rn),i=await t.getPromise(Pn),r=await t.getPromise(In),c=r.length>0?a?[...r,n]:r.filter((e=>e!==n)):[...s,gn.metadataKeyName].filter((e=>e!==n));e(c),o&&(null==l||l.filterItems(o,{columns:c,exactMatch:i}))})),n=useActionCallback((({snapshot:e,set:t})=>async(n,a,s)=>{const o=await e.getPromise(rn),l=await e.getPromise(Pn),i=await e.getPromise(In),r=n.filter((e=>!a.includes(e))),c=a.filter((e=>!n.includes(e))),u=i.length>0?[...i.filter((e=>!r.includes(e))),...c]:[...a,gn.metadataKeyName],d=u.length>0?u:[...a,gn.metadataKeyName];t(In,d),s&&(null==o||o.filterItems(s,{columns:d,exactMatch:l}))})),a=useActionCallback((({set:e})=>t=>{e(Pn,t)}));return{setMetadataSearchKeys:e,updateMetadataSearchAfterSearchKeysChange:t,updateMetadataSearchAfterColumnVisibilityChange:n,setMetadataSearchExactMatch:a}};function useCacheableLoadable(e,t){const s=a.useRef(),[o,l]=a.useState(0),i=n.useRecoilValueLoadable(e);a.useEffect((()=>{"hasValue"===i.state&&(s.current=i.contents)}),[t,i]);const[r,c]=a.useMemo((()=>"hasValue"!==i.state&&null!=s.current?[s.current,!0]:"hasValue"===i.state?[i.contents,!1]:[void 0,!1]),[i.state,i.contents,o]),u=a.useCallback((()=>{s.current=void 0,l(o+1)}),[o]),d=undefined;return a.useMemo((()=>({data:r,state:i.state,cached:c,invalidate:u})),[u,r,c,i.state])}const VertexSceneTreeMetadataCheck=({checked:t,disabled:n,onChange:a,children:s})=>{const l="string"==typeof s?s.replace(" ","-"):"";return e.jsxs("div",{className:"flex items-center",children:[e.jsx(o.VertexToggle,{"data-testid":`scene-tree-metadata-check-${l}`,variant:"check",checked:t,disabled:n,onValueChanged:e=>null==a?void 0:a(e.detail)}),e.jsx("div",{className:"pl-2 py-1 text-[0.875rem] w-full","data-testid":`scene-tree-metadata-name-${l}`,onClick:()=>{n||null==a||a(!t)},children:s})]})},VertexSceneTreeColumnPopover=({onVisibleSceneTreeColumnsChange:t})=>{const a=useSceneTreeColumnActions(),s=useSceneTreeSearchActions(),l=n.useRecoilValue(rn);useSceneTreePartialResults({sceneTreeElement:null!=l?l:null});const r=n.useRecoilValue(An),c=useCacheableLoadable(yn),d=n.useRecoilValue(bn),m=n.useRecoilValue(kn),[p,h]=u.useState(d),[g,f]=u.useState(""),{element:v,callback:b}=useCallbackRef(),{open:S,position:w,direction:V,handleOpen:C,handleClose:j}=useOpenColumnPopover({buttonElement:v}),T=V===jn.LEFT?"left-end":"right-start",k=u.useMemo((()=>{if(null!=c.data){const e=c.data.filter((e=>p.indexOf(e)<0)),t=undefined;return[...[...p].sort(((e,t)=>e.localeCompare(t))),...e]}return[]}),[p,c.data]),A=u.useMemo((()=>k),[S,c.data]);return e.jsxs(e.Fragment,{children:[e.jsx(o.VertexTooltip,{content:"Configure Columns",placement:"top",children:e.jsx(o.VertexIconButton,{"data-testid":"scene-tree-column-popover-button",ref:b,iconName:"columns-add",iconSize:"sm",onClick:()=>{C()}})}),S&&e.jsx(o.VertexPopover,{"data-testid":"scene-tree-column-popover",open:S,backdrop:!1,position:w,resizeBehavior:"fixed",placement:T,className:"z-popover",children:e.jsxs("div",{className:Ce("flex flex-col bg-white border border-neutral-300 rounded",{hidden:!S}),children:[e.jsxs("div",{className:"flex items-center text-[0.875rem] p-3",children:[e.jsxs("div",{className:"pr-2",children:[e.jsx("div",{className:"text-[0.875rem]",children:"Assembly Properties"}),e.jsx("div",{className:"text-[0.75rem] text-neutral-700 mt-1.5",children:"Select up to six properties to appear in the Assembly panel."})]}),e.jsx(o.VertexIconButton,{"data-testid":"scene-tree-columns-popover-close-button",className:"ml-auto",iconName:"close",iconSize:"sm",onClick:()=>{f(""),j()}})]}),e.jsx(o.VertexTextfield,{className:"flex w-full px-2 overflow-hidden border-b border-neutral-300 pb-2",id:"scene-tree-available-columns-search-bar","data-testid":"scene-tree-available-columns-search-bar",multiline:!1,placeholder:"Filter properties",type:"text",onInputInput:e=>{const t=e.detail.value;null!=t&&f(t.toLowerCase())}}),m&&e.jsx(i.VertexSceneTreeNotificationBanner,{"data-testid":"partial-key-list-notification-banner",message:"loading"===c.state?"Refreshing results...":"Data loading, refresh for more.",actionLabel:"Refresh",onAction:()=>a.refreshKeyList()}),e.jsxs("div",{className:"max-h-64 p-3 overflow-y-auto",children:[e.jsx(VertexSceneTreeMetadataCheck,{checked:!0,disabled:!0,children:gn.label}),A.filter((e=>""===g||e.toLowerCase().includes(g))).map((t=>e.jsx(VertexSceneTreeMetadataCheck,{checked:p.includes(t),disabled:p.length>=6&&!p.includes(t),onChange:e=>{h(e?[...p,t]:p.filter((e=>e!==t)))},children:t},t)))]}),e.jsxs("div",{className:"flex items-center p-3 border-t border-neutral-300 space-x-4",children:[e.jsx("div",{className:"text-[0.75rem] text-[var(--vertex-ui-blue-700)] cursor-pointer","data-testid":"scene-tree-column-clear-selection",onClick:()=>h([]),children:"Clear selection"}),e.jsx("div",{className:"flex-grow"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(o.VertexButton,{"data-testid":"scene-tree-column-popover-cancel",color:"secondary",onClick:()=>{f(""),j()},children:"Cancel"}),e.jsx(o.VertexButton,{"data-testid":"scene-tree-column-popover-apply",color:"primary",onClick:async()=>{await s.updateMetadataSearchAfterColumnVisibilityChange(d,p,r),await a.setActive(p),null==t||t(p),f(""),j()},children:"Apply"})]})]})]})})]})},VertexSceneTreeSearchOptionsPopover=({onSearchedSceneTreeColumnsChange:t,onSearchForExactMatchChange:a})=>{const s=useSceneTreeSearchActions(),l=n.useRecoilValue(rn),i=n.useRecoilValue(Rn),r=n.useRecoilValue(In),c=n.useRecoilValue(An),u=n.useRecoilValue(Pn),d=n.useRecoilValue(bn),{element:m,callback:p}=useCallbackRef(),{open:h,position:g,direction:f,handleOpen:v,handleClose:b}=useOpenColumnPopover({buttonElement:m,horizontalOffset:40}),S=f===jn.LEFT?"left-end":"right-start",updateSearch=e=>{if(c){const t=r.length>0?r:[...d,gn.metadataKeyName];null==l||l.filterItems(c,{columns:t,exactMatch:e})}};return e.jsxs(e.Fragment,{children:[e.jsx(o.VertexTooltip,{content:"Search Options",placement:"top",children:e.jsx(o.VertexIconButton,{"data-testid":"scene-tree-search-options-popover-button",ref:p,iconName:"gear",iconSize:"sm",onClick:()=>{v()}})}),e.jsx(o.VertexPopover,{"data-testid":"scene-tree-search-options-popover",open:h,backdrop:!1,position:g,resizeBehavior:"fixed",placement:S,className:"z-popover",children:e.jsxs("div",{className:Ce("flex flex-col bg-white border border-neutral-300 rounded",{hidden:!h}),children:[e.jsxs("div",{className:"flex items-center text-[0.875rem] p-3 border-b border-neutral-300 pb-2",children:[e.jsx("div",{className:"pr-2 text-[0.875rem] whitespace-nowrap",children:"Column Properties Search"}),e.jsx(o.VertexIconButton,{className:"ml-auto",iconName:"close",iconSize:"sm",onClick:()=>{b()}})]}),e.jsxs("div",{className:"max-h-64 p-3 overflow-y-auto",children:[e.jsx("div",{className:"text-[0.875rem] pb-2 pr-2",children:"Select properties to perform the search on:"}),e.jsx(VertexSceneTreeMetadataCheck,{checked:i,disabled:0===r.length||r.every((e=>e===gn.metadataKeyName)),onChange:async e=>{await s.updateMetadataSearchAfterSearchKeysChange(gn.metadataKeyName,e,d,c),null==t||t()},children:gn.label},gn.metadataKeyName),d.map((n=>e.jsx(VertexSceneTreeMetadataCheck,{checked:r.includes(n),disabled:r.length>0&&r.every((e=>e===n)),onChange:async e=>{await s.updateMetadataSearchAfterSearchKeysChange(n,e,d,c),null==t||t()},children:n},n)))]}),e.jsxs("div",{className:"flex p-3 border-t border-neutral-300",children:[e.jsx(o.VertexToggle,{className:"flex items-center","data-testid":"filter-exact-match-toggle",variant:"switch",checked:u,onValueChanged:async e=>{s.setMetadataSearchExactMatch(e.detail),null==a||a(),updateSearch(e.detail)}}),e.jsx("span",{className:"pl-4 text-[0.875rem] text-neutral-800",children:"Return only exact matches"})]})]})})]})},VertexSceneTreeSearchBar=({onSearch:t,onClearSearch:a,onExitSearchMode:s,onSearchedSceneTreeColumnsChange:l,onSearchForExactMatchChange:r,children:c})=>{const d=useSceneTreeActions(),m=n.useRecoilValue(rn),[p,h]=n.useRecoilState(Tn),[g,f]=n.useRecoilState(An);useSceneTreeSearch({sceneTreeElement:null!=m?m:null});const{element:v,callback:b}=useCallbackRef(),S=null==g||""===g,w=S?"Exit Search":"Clear Search";return u.useEffect((()=>{p&&(null==v||v.setFocus())}),[v,p]),e.jsxs("div",{className:"flex w-full py-3 px-2",children:[e.jsx(i.VertexSceneTreeSearch,{"data-testid":"scene-tree-search-bar",ref:b,controller:null==m?void 0:m.controller,onBlur:()=>{S&&(h(!1),null==s||s())},onSearch:()=>{f(null==v?void 0:v.value),null==t||t(null==v?void 0:v.value)},children:c}),e.jsx("div",{className:"self-center px-1",onPointerDown:e=>{e.preventDefault()},children:e.jsx(VertexSceneTreeSearchOptionsPopover,{onSearchedSceneTreeColumnsChange:l,onSearchForExactMatchChange:r})}),e.jsx(o.VertexTooltip,{className:"self-center pr-1",content:w,children:e.jsx(o.VertexIconButton,{"data-testid":"scene-tree-search-close-button",iconName:"close-circle-fill",iconSize:"sm",variant:"plain",onPointerDown:e=>{e.preventDefault()},onClick:async()=>{S?(h(!1),await d.flyToFirstSelectedItem(),null==s||s()):(await(null==v?void 0:v.clear()),await(null==v?void 0:v.setFocus()),f(void 0),null==a||a())}})})]})};function VertexToolbarDivider(){return e.jsx("div",{"data-testid":"toolbar-divider",className:"h-6 w-px bg-neutral-300 mx-1"})}const VertexSceneTreeSearchInformationForToolbar=()=>{const t=useSelectionActions(),a=n.useRecoilValue(rn),s=n.useRecoilValue(An),l=n.useRecoilValue(En),i=undefined,r=undefined,c=`${l>=1e3?`${l}+`:`${l}`} ${1===l?"result":"results"}`;return e.jsxs(e.Fragment,{children:[e.jsx(VertexToolbarDivider,{}),e.jsxs("div",{className:"flex flex-row items-center overflow-hidden",children:[e.jsx("div",{className:"px-2 text-[0.8125rem] leading-4 text-neutral-900 truncate","data-testid":"search-result-info",children:`${c}`}),e.jsx(o.VertexTooltip,{className:"w-auto",content:"Select Results",placement:"top",children:e.jsx(o.VertexButton,{className:"h-6 rounded cursor-pointer","data-testid":"select-search-results-button",color:"secondary",variant:"text",size:"sm",onClick:async()=>{null!=a&&null!=s&&(await a.selectFilteredItems(s),t.toggleLastSelectWasMultiSelect(!0))},children:e.jsxs("div",{className:"flex h-6 items-center gap-1",children:[e.jsx(o.VertexIcon,{size:"sm",name:"check-circle"}),e.jsx("span",{className:"whitespace-nowrap",children:"Select Results"})]})})})]})]})},targetIsElement=(e,t)=>e instanceof Element&&e.tagName===t;function useRecoilRef({state:e}){const t=n.useRecoilCallback((({set:t})=>n=>{t(e,n)}),[]);return t}var Nn;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===Nn.ROBOTO_MONO?"var(--vertex-ui-font-family-monospace)":"var(--vertex-ui-font-family)"}!function(e){e.ROBOTO="ROBOTO",e.ROBOTO_MONO="ROBOTO_MONO"}(Nn||(Nn={}));const VertexEnterSceneTreeSearchModeButton=({onEnterSearchMode:t})=>{const a=n.useSetRecoilState(Tn);return e.jsx(o.VertexTooltip,{className:"flex ml-auto",content:"Scene Tree Search",children:e.jsx(o.VertexIconButton,{"data-testid":"enter-scene-tree-search-mode-button",iconName:"search",iconSize:"sm",onPointerDown:e=>{e.preventDefault()},onClick:()=>{a(!0),null==t||t()}})})},VertexSceneTreeSearch=({onEnterSearchMode:t,onExitSearchMode:a,onSearch:s,onClearSearch:o,onSearchedSceneTreeColumnsChange:l,onSearchForExactMatchChange:r,children:c})=>{const u=n.useRecoilValue(Tn);return e.jsxs(i.VertexSceneTreeToolbar,{className:"h-11 p-0 border-b border-neutral-300 box-content",slot:"header",children:[u&&e.jsx(VertexSceneTreeSearchBar,{onSearch:s,onClearSearch:o,onExitSearchMode:a,onSearchedSceneTreeColumnsChange:l,onSearchForExactMatchChange:r,children:c}),!u&&e.jsx("div",{className:"ml-auto mr-2",children:e.jsx(VertexEnterSceneTreeSearchModeButton,{onEnterSearchMode:t})})]})},VertexSceneTreeCollapseAll=()=>{const t=n.useRecoilValue(rn);return e.jsx(o.VertexTooltip,{className:"w-auto",content:"Collapse All",placement:"top",children:e.jsx(o.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=n.useRecoilValue(rn);return e.jsx(o.VertexTooltip,{className:"w-auto",content:"Expand All",placement:"top",children:e.jsx(o.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()}})})},VertexSceneTreeToolbar=({onVisibleSceneTreeColumnsChange:t})=>{const a=n.useRecoilValue(An),s=null==a||""===a;return e.jsx(i.VertexSceneTreeToolbar,{className:"h-10 border-b border-neutral-300 box-border",children:e.jsxs("div",{className:"flex w-full text-neutral-700 items-center gap mx-2",children:[e.jsx(VertexSceneTreeExpandAll,{}),e.jsx(VertexSceneTreeCollapseAll,{}),!s&&e.jsx(VertexSceneTreeSearchInformationForToolbar,{}),e.jsx("div",{className:"ml-auto",children:e.jsx(VertexSceneTreeColumnPopover,{onVisibleSceneTreeColumnsChange:t})})]})})},VertexSceneTreeHeader=({onEnterSearchMode:t,onExitSearchMode:n,onSearch:a,onClearSearch:s,onVisibleSceneTreeColumnsChange:o,children:l})=>{const i=null!=l&&!1!==l;return e.jsx("div",{slot:"header",className:"flex flex-col",children:i?l:e.jsxs(e.Fragment,{children:[e.jsx(VertexSceneTreeSearch,{onEnterSearchMode:t,onExitSearchMode:n,onSearch:a,onClearSearch:s,children:e.jsx("div",{slot:"clear-icon"})}),e.jsx(VertexSceneTreeToolbar,{onVisibleSceneTreeColumnsChange:o})]})})},VertexSceneTreeTableLayout=t=>{const a=n.useRecoilValue(Sn),s=n.useRecoilValue(wn),o=[];return e.jsx(i.VertexSceneTreeTableLayout,Object.assign({"data-testid":"scene-tree-table-layout"},t,{children:s.map(((t,n)=>{var l;const r=a[t],c=null!==(l=o[n])&&void 0!==l?l:r.initialWidth;return e.jsxs(i.VertexSceneTreeTableColumn,{"data-testid":`scene-tree-table-column-${n}`,initialWidth:c,minWidth:r.minWidth,children:[e.jsx("template",{slot:"header",dangerouslySetInnerHTML:{__html:`\n <div class="text-sm text-neutral-800 my-2">\n <div class="${Ce("truncate",{"pl-2":0===n,"pr-2":n===s.length-1})}">\n ${r.label}\n </div>\n </div>\n `}}),e.jsx("template",{dangerouslySetInnerHTML:{__html:`\n <vertex-scene-tree-table-cell\n prop:value="${r.binding}"\n prop:selection-handler="{{row.data.handleSelection}}"\n prop:expansion-handler="{{row.data.handleExpansion}}"\n prop:visibility-handler="{{row.data.handleVisibility}}"\n ${0===n?"expand-toggle":""}\n ${n===s.length-1?"isolate-button visibility-toggle":""}>\n <div class="flex items-center gap-2">\n <vertex-tooltip \n class="truncate" \n prop:content="${null!=r.binding?r.binding:"--"}" \n placement="${n!==s.length-1?"right":"top"}">\n <div class="flex items-center w-full">\n <div class="truncate">${r.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 `}})]},r.label)}))}))},VertexSceneTree=t=>{var{id:s,font:o,backgroundColors:l,children:r,style:c,onPointerDown:u,onClick:d,onToggleSelection:m,onToggleExpansion:p,onToggleVisibility:h,className:g,rowData:f}=t,v=__rest(t,["id","font","backgroundColors","children","style","onPointerDown","onClick","onToggleSelection","onToggleExpansion","onToggleVisibility","className","rowData"]);const b=useSceneTreeActions(),S=useSelectionActions(),w=n.useRecoilValue(hn),V=n.useRecoilValue(M),C=n.useRecoilValue(In),j=n.useRecoilValue(Pn),T=n.useRecoilValue(An),k=null==T||""===T,A=useRecoilRef({state:rn}),P=null!=r&&!1!==r,wrappedExpansionHandler=(e,t,n)=>{b.toggleExpansion(e,t,n),null==p||p(e,t,n)},wrappedSelectionHandler=(e,t,n)=>{b.toggleSelection(e,t,n),null==m||m(e,t,n)},wrappedVisibilityHandler=(e,t,n)=>{b.toggleVisibility(e,t,n),null==h||h(e,t,n)},handleClick=e=>{e.altKey&&b.flyToRow(e.clientY),null==d||d(e)},handlePointerDown=e=>{targetIsElement(e.target,"VERTEX-SCENE-TREE-TABLE-COLUMN")&&S.clearSelection(),null==u||u(e)},E=n.useSetRecoilState(cn),handleFirstRowRendered=e=>{var t;E(e.target.controller),null===(t=null==v?void 0:v.onFirstRowRendered)||void 0===t||t.call(v,e)},I=a.useMemo((()=>({metadataSearchKeys:C,exactMatch:j})),[C,j]);return e.jsx("div",{className:Ce("flex flex-col w-full h-full",g),children:e.jsx("div",{className:"flex group h-full",children:e.jsx(i.VertexSceneTree,Object.assign({id:null!=s?s:"vertex-scene-tree","data-testid":"vertex-scene-tree",config:w,ref:A,className:Ce("flex-1",{filtered:!k}),style:Object.assign(Object.assign(Object.assign({},styleFromOptionalFont(o)),styleFromOptionalBackgroundColors(l)),c),onConnectionError:e=>{logger_error("Scene Tree Connection Error: ",e.detail)},viewer:V,onPointerDown:handlePointerDown,onClick:handleClick,rowData:e=>{var t;const n=null!==(t=null==f?void 0:f(e))&&void 0!==t?t:{};return Object.assign({handleExpansion:wrappedExpansionHandler,handleSelection:wrappedSelectionHandler,handleVisibility:wrappedVisibilityHandler},n)},searchOptions:I},v,{onFirstRowRendered:handleFirstRowRendered,children:P?r:e.jsxs(e.Fragment,{children:[e.jsx(VertexSceneTreeHeader,{}),e.jsx(VertexSceneTreeTableLayout,{}),e.jsx(VertexSceneTreeContextMenu,{})]})}))})})},VertexDecimalPlaceSelector=({onApply:t})=>{const[a,s]=n.useRecoilState(yt);return e.jsxs(o.VertexSelect,{"data-testid":"decimal-place-select",className:"w-24",value:a,onOptionChanged:e=>{s(e.detail),null==t||t(e.detail)},children:[e.jsx("div",{className:"py-1.5 px-3",children:"0"}),e.jsx("div",{className:"py-1.5 px-3",children:"1"}),e.jsx("div",{className:"py-1.5 px-3",children:"2"}),e.jsx("div",{className:"py-1.5 px-3",children:"3"})]})},VertexLengthUnitSelector=({onApply:t})=>{const[a,s]=n.useRecoilState(vt);return e.jsxs(o.VertexSelect,{"data-testid":"length-unit-select",className:"w-40",value:a,onOptionChanged:e=>{s(e.detail),null==t||t(e.detail)},children:[e.jsx("div",{"data-value":"cm",className:"py-1.5 px-3",children:"centimeters"}),e.jsx("div",{"data-value":"mm",className:"py-1.5 px-3",children:"millimeters"}),e.jsx("div",{"data-value":"m",className:"py-1.5 px-3",children:"meters"}),e.jsx("div",{"data-value":"in",className:"py-1.5 px-3",children:"inches"}),e.jsx("div",{"data-value":"ft",className:"py-1.5 px-3",children:"feet"})]})};function VertexUnitsControls({onUnitChange:t,onDecimalPlaceChange:n}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Length Unit"}),e.jsx(VertexLengthUnitSelector,{onApply:t})]}),e.jsxs("div",{children:[e.jsx("div",{className:"pt-2 pb-2 text-sm text-neutral-700",children:"Decimals"}),e.jsx(VertexDecimalPlaceSelector,{onApply:n})]})]})}function VertexUnitsPanelSection({onUnitChange:t,onDecimalPlaceChange:n}){return e.jsx(PanelSection,{header:e.jsx("div",{className:"flex items-center text-base",children:"Units"}),children:e.jsx(VertexUnitsControls,{onUnitChange:t,onDecimalPlaceChange:n})})}const On=n.atom({key:"openedPanelActivePrimaryLeft",default:void 0}),Mn=n.atom({key:"openedPanelActivePrimaryRight",default:void 0});function usePanelActions(){return{openPrimary:useActionCallback((({set:e})=>(t,n)=>{e("left"===n?On:Mn,t)})),closePrimary:useActionCallback((({set:e})=>t=>{e("left"===t?On:Mn,void 0)}))}}function childrenAsArray(e){return Array.isArray(e)?e:[e]}function filterChildElements(e,t){return childrenAsArray(e).filter((e=>a.isValidElement(e)&&e.type===t))}function DefaultAppearancePanel(){return e.jsxs("div",{className:"flex flex-col text-neutral-700 h-full overflow-y-auto",children:[e.jsx(VertexMaterialPanelSection,{}),e.jsx(VertexGhostingPanelSection,{}),e.jsx(VertexFeatureEdgesPanelSection,{}),e.jsx(VertexViewerBackgroundPanelSection,{}),e.jsx(VertexSelectionHighlightingPanelSection,{}),e.jsx(VertexCrossSectionAppearancePanelSection,{})]})}function DefaultSettingsPanel(){return e.jsx("div",{className:"flex flex-col text-neutral-700 h-full overflow-y-auto",children:e.jsx(VertexUnitsPanelSection,{})})}const VertexTransformClear=({onClear:t,onClearAll:s})=>{const l=useTransformActions(),i=useCacheableLoadable(ft),r=n.useRecoilValue(dt),c=useCacheableLoadable(Et(null!=r?r:"")),u=a.useMemo((()=>{var e;const t=null===(e=i.data)||void 0===e?void 0:e.some((e=>{var t;return null!=(null===(t=null==e?void 0:e.override)||void 0===t?void 0:t.transform)})),n=null!=c.data;return t||n}),[i,c]);return e.jsx("div",{className:"ml-auto",children:e.jsxs(ResetButton,{id:"transforms",tooltip:"Clear Transforms",children:[e.jsx("div",{className:"pt-1"}),e.jsx(o.VertexMenuItem,{"data-testid":"clear-selected-transforms",onClick:async()=>{await l.clearSelectedTransforms(),null==t||t()},disabled:!u,children:"Clear selected transforms"}),e.jsx(o.VertexMenuItem,{"data-testid":"clear-all-transforms",onClick:async()=>{await l.clearAllTransforms(),null==s||s()},children:"Clear all transforms"})]})})},VertexTransformNumericField=({bottomLabel:t,value:s,step:o,min:l,max:i,disabled:r,testId:c,onBlur:u,onInput:d,onChange:m})=>{const p=a.useRef(null),h=n.useRecoilValue(yt),[g,f]=a.useState(!0);a.useEffect((()=>{var e;const t=null!=p.current&&Number.isNaN(p.current.valueAsNumber),n=g||t;null!=p.current&&n?p.current.value=null!==(e=null==s?void 0:s.toFixed(Number(h)))&&void 0!==e?e:"":f(!0)}),[s]);const v=a.useCallback((e=>{f(!1),null==m||m(e)}),[f,m]),b=a.useCallback((e=>{f(!0),null==u||u(e),null!=p.current&&null!=s&&(p.current.value=s.toFixed(Number(h)))}),[u,s,f]);return e.jsxs("div",{children:[e.jsx("div",{className:"truncate rounded-md w-full",children:e.jsx("input",{ref:p,className:"w-full truncate border border-neutral-400 rounded-md px-2 py-1.5 hover:border-neutral-500 focus:border-neutral-500 focus:outline-none",type:"number",step:o,min:l,max:i,"data-testid":c,disabled:r,defaultValue:Number.isNaN(s)?"":null==s?void 0:s.toFixed(Number(h)),onBlur:b,onInput:d,onChange:v})}),null!=t&&e.jsx("div",{className:"flex justify-center items-center pointer-events-none text-neutral-500",children:e.jsx("span",{children:t})})]})},VertexTransformInputs=({onUpdateTransform:t})=>{const a=n.useRecoilValue(vt),s=n.useRecoilValue(ct),o=n.useRecoilValue(rt),l=s||o,i=n.useRecoilValue(dt),{transform:r,error:c,update:u}=useEditItemTransform(i),d=l?void 0:r,m=useDebouncedCallback((async e=>{await u(e),null==t||t(e)}),50);function updateTransform(e){return t=>{if(null!=d){const n=parseFloat(t.currentTarget.value);Number.isNaN(n)||null==m||m(Object.assign(Object.assign({},d),e(n,d)))}}}function updatePosition(e){return updateTransform(((t,n)=>({position:Object.assign(Object.assign({},n.position),e(t))})))}function updateRotation(e){return updateTransform(((t,n)=>({rotation:Object.assign(Object.assign({},n.rotation),e(t))})))}function updateScale(){return updateTransform((e=>e>0?{scale:e}:{}))}function updateToDefaultValueIfInvalid(e,t){return n=>{const a=parseFloat(n.currentTarget.value),s=undefined;(isNaN(a)||!!(null==t?void 0:t(a)))&&null!=d&&m(A.defaults(e,d))}}return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 text-[0.8125rem]",children:[e.jsx("span",{className:"flex w-full items-center mt-3 mb-1",children:"Position"}),e.jsxs("div",{className:"flex flex-wrap w-full gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"X"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"position-x",value:null!=d?d.position.x:void 0,bottomLabel:a,disabled:null==d,onChange:updatePosition((e=>({x:e}))),onBlur:updateToDefaultValueIfInvalid({position:{x:0}})})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"Y"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"position-y",value:null==d?void 0:d.position.y,bottomLabel:a,disabled:null==d,onChange:updatePosition((e=>({y:e}))),onBlur:updateToDefaultValueIfInvalid({position:{y:0}})})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"Z"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"position-z",value:null==d?void 0:d.position.z,bottomLabel:a,disabled:null==d,onChange:updatePosition((e=>({z:e}))),onBlur:updateToDefaultValueIfInvalid({position:{z:0}})})})]})]})]}),e.jsxs("div",{className:"mb-2 text-[0.8125rem]",children:[e.jsx("span",{className:"flex w-full items-center mt-3 mb-1",children:"Rotation"}),e.jsxs("div",{className:"flex flex-wrap w-full gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"X"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"rotation-x",value:null==d?void 0:d.rotation.x,bottomLabel:"deg",disabled:null==d,onChange:updateRotation((e=>({x:e}))),onBlur:updateToDefaultValueIfInvalid({rotation:{x:0}})})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"Y"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"rotation-y",value:null==d?void 0:d.rotation.y,bottomLabel:"deg",disabled:null==d,onChange:updateRotation((e=>({y:e}))),onBlur:updateToDefaultValueIfInvalid({rotation:{y:0}})})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"Z"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"rotation-z",value:null==d?void 0:d.rotation.z,bottomLabel:"deg",disabled:null==d,onChange:updateRotation((e=>({z:e}))),onBlur:updateToDefaultValueIfInvalid({rotation:{z:0}})})})]})]})]}),e.jsxs("div",{className:"mb-2 text-[0.8125rem]",children:[e.jsx("span",{className:"flex w-full items-center mt-3 mb-1",children:"Scale"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"scale",value:null==d?void 0:d.scale,step:.1,min:.1,disabled:null==d,onChange:updateScale(),onBlur:updateToDefaultValueIfInvalid({scale:1},(e=>e<=0))})}),l&&e.jsx("div",{className:"bg-orange-100 rounded px-3 py-2 mt-6 mb-2",children:"Input based part transformation is not yet supported for multiple parts."}),null!=c&&e.jsx("div",{className:"bg-red-100 rounded px-3 py-2 mt-6 mb-2",children:"There was a problem retrieving data. Try selecting a different part."})]})]})},VertexTransformManipulatorToggle=({onToggleTransformsManipulator:t})=>{const a=useTransformActions(),s=n.useRecoilValue(Vt),l=n.useSetRecoilState(Rt);return e.jsx(o.VertexToggle,{className:"flex items-center","data-testid":"transform-widget-toggle",variant:"switch",checked:s,onValueChanged:async()=>{s?(a.disableTransformWidget(),null==t||t(!1)):(l("world"),await a.enableTransformWidget(),null==t||t(!0))}})};function VertexTransformControls({onToggleTransformsManipulator:t,onUpdateTransform:n}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center py-3",children:[e.jsx(VertexTransformManipulatorToggle,{onToggleTransformsManipulator:t}),e.jsx("span",{className:"pl-4 text-[0.8125rem] text-neutral-700",children:"Enable manipulator"})]}),e.jsx(VertexTransformInputs,{onUpdateTransform:n})]})}function VertexTransformPanelSection({onClearTransforms:t,onClearAllTransforms:n,onToggleTransformsManipulator:a,onUpdateTransform:s}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Manual Part Transforms",e.jsx(VertexTransformClear,{onClear:t,onClearAll:n})]}),children:e.jsx(VertexTransformControls,{onToggleTransformsManipulator:a,onUpdateTransform:s})})}function DefaultTransformsPanel(){return e.jsx("div",{className:"flex flex-col text-neutral-700 h-full overflow-y-auto",children:e.jsx(VertexTransformPanelSection,{})})}const Ln="Appearance",Bn="Settings",_n="Transforms",ViewerRightPanelHeader=({additionalHeaderMap:t})=>{const a=undefined,s=getHeading(n.useRecoilValue(Mn),t);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:s})})};function getHeading(e,t={}){switch(e){case"appearance":return Ln;case"settings":return Bn;case"transforms":return _n;default:const n=null!=e?t[e]:void 0;return null!=n?n:"None"}}function VertexViewerRightOpenedPanel({children:t}){const s=n.useRecoilValue(Mn),o=a.useMemo((()=>filterChildElements(t,CustomPanelContent)),[t]),l=a.useMemo((()=>o.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t.props.panelName]:t.props.panelTitle})),{})),[o]),i=a.useMemo((()=>["appearance","settings","transforms",...o.map((e=>e.props.panelName))]),[o]);return e.jsx(e.Fragment,{children:null!=s&&i.includes(s)&&e.jsxs(VertexResizableContent,{displayShadow:!0,heading:e.jsx(ViewerRightPanelHeader,{additionalHeaderMap:l}),placement:"right",children:["appearance"===s&&e.jsx(DefaultAppearancePanel,{}),"transforms"===s&&e.jsx(DefaultTransformsPanel,{}),"settings"===s&&e.jsx(DefaultSettingsPanel,{}),t]})})}function CustomPanelContent({panelName:t,children:a}){const s=n.useRecoilValue(Mn);return e.jsx(e.Fragment,{children:s===t&&a})}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:s,responsive:l,disabled:i,content:r,tooltipPlacement:c,children:u,onSelect:d,onDeselect:m}){return e.jsx("div",{className:Ce({"text-[var(--vertex-ui-blue-700)]":s===t&&!i,"text-neutral-700 hover:text-neutral-800":s!==t&&!i,"cursor-pointer hover:bg-neutral-200":!i,"text-neutral-400":i,"rounded-full md:p-3":l,"p-3":!l&&null==u,"px-3 py-1":null!=u}),"data-testid":`${t}-sidebar-panel`,onClick:()=>{i||(s===t?m():d())},children:e.jsxs(o.VertexTooltip,{placement:null!=c?c:void 0,content:a.isValidElement(r)?void 0:r,children:[e.jsx("div",{slot:"content",children:r}),e.jsx("div",{className:"flex flex-col",children:null!=u?u:e.jsx(o.VertexIcon,{name:n})})]})})}function VertexViewerRightSidebar({children:t}){const a=usePanelActions(),s=n.useRecoilValue(Mn);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.jsxs(Sidebar,{children:[t,e.jsx(SidebarIcon,{name:"appearance",active:s,iconName:"adjustments",tooltipPlacement:"right",content:"Appearance",onSelect:()=>{a.openPrimary("appearance","right")},onDeselect:()=>a.closePrimary("right")}),e.jsx(SidebarIcon,{name:"transforms",active:s,iconName:"show-only-nearby",tooltipPlacement:"right",content:"Transforms",onSelect:()=>{a.openPrimary("transforms","right")},onDeselect:()=>a.closePrimary("right")}),e.jsx(SidebarIcon,{name:"settings",active:s,iconName:"gear",tooltipPlacement:"right",content:"Settings",onSelect:()=>{a.openPrimary("settings","right")},onDeselect:()=>a.closePrimary("right")})]})})}function CustomPanelIcon(t){const a=usePanelActions(),s=n.useRecoilValue(Mn),{panelName:o,tooltipContent:l,iconName:i}=t,r=__rest(t,["panelName","tooltipContent","iconName"]);if(null==i&&null==r.children)throw new Error('CustomPanelIcon must contain either a Vertex "iconName" or custom "children"');return e.jsx(SidebarIcon,Object.assign({},r,{name:o,iconName:null!=i?i:"help",active:s,content:l,onSelect:()=>{a.openPrimary(t.panelName,"right")},onDeselect:()=>{a.closePrimary("right")}}))}VertexViewerRightOpenedPanel.CustomPanelContent=CustomPanelContent,VertexViewerRightSidebar.CustomPanelIcon=CustomPanelIcon;const VertexPopupButton=t=>{var{open:n,children:a}=t,s=__rest(t,["open","children"]);const l=a.find((e=>e.type===Anchor)),i=a.filter((e=>e.type!==Anchor));return null==l?e.jsx(e.Fragment,{}):e.jsxs(o.VertexPopover,Object.assign({className:"flex",placement:"top",backdrop:!1,open:asBooleanAttribute(n)},s,{children:[l,e.jsx("div",{className:Ce("flex mb-1.5",{hidden:!n}),"data-testid":"align-plane-popover-menu",children:i})]}))},Anchor=({tooltipContent:t,children:n})=>e.jsx("div",{slot:"anchor",children:e.jsx(o.VertexTooltip,{className:"cursor-pointer",content:t,children:n})});function VertexViewerCrossSectionAlignmentPopoverMenu(){const t=useCrossSectioningActions(),a=n.useRecoilValue(de),s=n.useRecoilValue(ne),getBaseIcon=()=>`align-to-${null==s?void 0:s.mode}`;return useStackKeyBinding({id:"CrossSectionAlignment",keyBind:"Escape",fn:t.cancelCurrentHit,addPredicate:()=>{var e;return null!==(e=null==s?void 0:s.hitPending)&&void 0!==e&&e},cancelPredicate:()=>!(null==s?void 0:s.hitPending)},[null==s?void 0:s.hitPending]),e.jsxs(VertexPopupButton,{"data-testid":"section-alignment-popover",placement:"top",backdrop:!1,open:asBooleanAttribute(a),onDismissed:t.closeAlignmentTools,children:[e.jsx(VertexPopupButton.Anchor,{tooltipContent:"Section Alignment",children:e.jsx(o.VertexIconButton,{"data-testid":"section-alignment-icon-button",iconName:getBaseIcon(),iconColor:"secondary",onClick:a?t.closeAlignmentTools:t.openAlignmentTools,children:e.jsx(o.VertexIcon,{"data-testid":"section-alignment-icon-chevron",name:"chevron-up",size:"sm"})})}),e.jsxs(i.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(o.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(o.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(),s=n.useRecoilValue(me),l=n.useRecoilValue(te),r=n.useRecoilValueLoadable(le),c=a.useMemo((()=>{const e=l.length>0&&"hasValue"===r.state?axis(l[0],xAxis(r.contents),yAxis(r.contents),zAxis(r.contents)):"x";return null!=e?`axis-${e}`:"axis-x"}),[r.state,r.contents,l]);return e.jsxs(VertexPopupButton,{"data-testid":"align-plane-popover",placement:"top",backdrop:!1,open:asBooleanAttribute(s),onDismissed:t.closeAxisTools,children:[e.jsx(VertexPopupButton.Anchor,{tooltipContent:"Align Plane",children:e.jsx(o.VertexIconButton,{onClick:s?t.closeAxisTools:t.openAxisTools,iconName:c,"data-testid":"align-plane-icon",iconColor:"secondary",children:e.jsx(o.VertexIcon,{"data-testid":"align-plane-icon-chevron",name:"chevron-up",size:"sm"})})}),e.jsxs(i.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(o.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(o.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(o.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"})})]})]})}function VertexViewerCrossSectionOffsetStepper({offset:t,onOffsetChange:s}){const l=n.useRecoilValue(vt),i=n.useRecoilValue(yt),[r,c]=a.useState(convertTo(t,l));a.useEffect((()=>{c(convertTo(t,l))}),[l,t]);const u=createDistanceFormatter(l,parseInt(i,10)),handleIncrementalUpdate=e=>{const t=convertFrom(r+e,l);s(t)},handleSubmit=e=>{e.preventDefault(),s(convertFrom(r,l))},handleBlur=()=>{s(convertFrom(r,l))};return e.jsx(o.VertexTooltip,{content:"Plane Offset",children:e.jsx("form",{"data-testid":"cross-section-stepper-form",onSubmit:handleSubmit,children:e.jsxs(o.VertexTextfield,{"data-testid":"cross-section-stepper-input",className:"viewer-toolbar-input w-32 border-none ring-0 bg-white",type:"text",value:u(parseFloat(t.toFixed(3))),onInputInput:e=>{c(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(o.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(o.VertexIcon,{name:"chevron-right",size:"sm"})})]})})})}VertexPopupButton.Anchor=Anchor;const Dn=400;function VertexViewerCrossSectionPopupMenu(){const t=useCrossSectioningActions(),s=n.useRecoilValue(ue),l=n.useRecoilValueLoadable(re),r=n.useRecoilValueLoadable(ce),c=a.useRef(),u=a.useMemo((()=>"hasValue"===l.state?l.contents:Z),[l.state,l.contents]),d=a.useMemo((()=>"hasValue"===r.state?r.contents:0),[r.state,r.contents]),handleCrossSectionValueChange=e=>{clearTimeout(c.current),c.current=window.setTimeout((()=>{t.endInteraction()}),Dn),t.beginInteraction(),t.updatePlanes(e)};return e.jsxs(VertexPopupButton,{"data-testid":"cross-section-popover",placement:"top",backdrop:!1,open:asBooleanAttribute(s),onDismissed:t.closeAdditionalTools,children:[e.jsx(VertexPopupButton.Anchor,{tooltipContent:"Section Tools",children:e.jsx("div",{className:"-ml-px py-1.5",children:e.jsx(o.VertexIcon,{"data-testid":"cross-section-popover-icon",name:"chevron-up",size:"sm",onClick:s?t.closeAdditionalTools:t.openAdditionalTools})})}),e.jsxs(i.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(o.VertexTooltip,{className:"w-auto",content:"Reverse",children:e.jsx(o.VertexIconButton,{iconName:"flip","data-testid":"viewer-toolbar-flip-button",onClick:t.flipPlanes,iconColor:"secondary"})}),e.jsx(o.VertexTooltip,{className:"w-auto",content:"Align View to Plane",children:e.jsx(o.VertexIconButton,{"data-testid":"viewer-toolbar-align-view-to-plane-button",iconName:"align-view-to-plane",onClick:t.alignViewToPlane,iconColor:"secondary"})}),e.jsx(VertexToolbarDivider,{}),e.jsx(VertexViewerCrossSectionAxisPopoverMenu,{}),e.jsx("div",{className:"w-52 mx-2",children:e.jsx(VertexSlider,{value:d,defaultValue:u.default,disabled:asBooleanAttribute("hasValue"!==l.state),min:u.min,max:u.max,step:.01,onChange:handleCrossSectionValueChange})}),e.jsx("div",{className:"px-4",children:e.jsx(VertexViewerCrossSectionOffsetStepper,{offset:"hasValue"===r.state?r.contents:0,onOffsetChange:handleCrossSectionValueChange})})]})]})}const VertexViewerCrossSectionButton=()=>{const t=useCrossSectioningActions(),a=n.useRecoilValue(J);return e.jsxs(e.Fragment,{children:[e.jsx(o.VertexTooltip,{content:a?"Hide Section":"Show Section",children:e.jsx(o.VertexIconButton,{"data-testid":"viewer-toolbar-cross-section-button",iconName:"cross-section",iconColor:a?"primary":"secondary",onClick:()=>a?t.disable():t.enable()})}),e.jsx(VertexViewerCrossSectionPopupMenu,{})]})},VertexFitAllButton=()=>{const t=n.useRecoilValue(M);return e.jsx(o.VertexTooltip,{content:"Fit All",children:e.jsx(o.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=n.useRecoilValue(M),s=n.useRecoilValue(B),[l,i]=n.useRecoilState(D),[r,c]=n.useRecoilState(_);return a.useEffect((()=>{null!=t&&s&&c(t.getBaseInteractionHandler())}),[t,s,c]),e.jsx(o.VertexTooltip,{content:"Pan",children:e.jsx(o.VertexIconButton,{iconName:"pan",iconColor:"pan"===l?"primary":"secondary","data-testid":"viewer-toolbar-pan-button",onClick:async()=>{if(i("pan"),null!=r){const e=await r;null==e||e.setPrimaryInteractionType("pan")}}})})},VertexRotateButton=()=>{const t=n.useRecoilValue(M),s=n.useRecoilValue(B),[l,i]=n.useRecoilState(D),[r,c]=n.useRecoilState(_);return a.useEffect((()=>{null!=t&&s&&c(t.getBaseInteractionHandler())}),[t,s,c]),e.jsx(o.VertexTooltip,{content:"Rotate",children:e.jsx(o.VertexIconButton,{iconName:"rotate",iconColor:"rotate"===l?"primary":"secondary","data-testid":"viewer-toolbar-rotate-button",onClick:async()=>{if(i("rotate"),null!=r){const e=await r;null==e||e.setPrimaryInteractionType("rotate")}}})})},VertexZoomButton=()=>{const t=n.useRecoilValue(M),s=n.useRecoilValue(B),[l,i]=n.useRecoilState(D),[r,c]=n.useRecoilState(_);return a.useEffect((()=>{null!=t&&s&&c(t.getBaseInteractionHandler())}),[t,s,c]),e.jsx(o.VertexTooltip,{content:"Zoom",children:e.jsx(o.VertexIconButton,{iconName:"zoom",iconColor:"zoom"===l?"primary":"secondary","data-testid":"viewer-toolbar-zoom-button",onClick:async()=>{if(i("zoom"),null!=r){const e=await r;null==e||e.setPrimaryInteractionType("zoom")}}})})},DefaultToolbar=()=>e.jsx(i.VertexViewerToolbar,{placement:"bottom-center",children:e.jsxs(i.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(VertexToolbarDivider,{}),e.jsx(VertexBoxSelectionButton,{}),e.jsx(VertexToolbarDivider,{}),e.jsx(VertexViewerCrossSectionButton,{}),e.jsx(VertexToolbarDivider,{}),e.jsx(VertexPointToPointMeasurementTool,{}),e.jsx(VertexPreciseMeasurementTool,{})]})}),VertexToolbar=({children:t})=>{const n=null!=t&&!1!==t;return e.jsx(i.VertexViewerToolbar,{placement:"bottom-center",children:n?e.jsx(i.VertexViewerToolbarGroup,{className:"p-1 border border-neutral-200 rounded bg-neutral-100 opacity-95",children:t}):e.jsx(DefaultToolbar,{})})};function VertexTransformWidget({transformWidgetElement:t,supportUndo:s,onPositionChange:o,onRotationChange:l}){const r=useTransformActions(),c=n.useRecoilValue(At),u=n.useRecoilValue(Vt),d=n.useRecoilValue(Ct),m=n.useRecoilValue(kt),p=n.useRecoilValueLoadable(Tt),h=n.useRecoilValue(vt),g=n.useRecoilValue(yt),f=a.useMemo((()=>"hasValue"===p.state?p.contents:m),[p,m]),v=a.useMemo((()=>{const e=undefined;return u&&(null!=f||c)}),[u,f,c]);return e.jsx(e.Fragment,{children:v&&e.jsx(i.VertexViewerTransformWidget,{id:"transform-widget","data-testid":"viewer-transform-widget",ref:t,position:d,rotation:null!=d?f:void 0,decimalPlaces:parseInt(g,10),distanceUnit:toUnitType(h),EXPERIMENTAL_undoKeybindings:null==s||s,onInteractionStarted:()=>{r.disableSelectionSync(),r.setIsInteractivelyTransforming(!0)},onInteractionEnded:()=>{r.invalidateTransforms(),r.setIsInteractivelyTransforming(!1)},onPositionChanged:async e=>{await r.setTransformWidgetPosition(e.detail),null==o||o(e.detail)},onRotationChanged:e=>{r.setTransformWidgetOrientation(e.detail),null==l||l(e.detail)}})})}const VertexViewerSceneReset=({onReset:t})=>{const n=useCrossSectioningActions(),a=useSelectionActions(),s=useTransformActions(),l=useViewerSceneActions(),handleReset=async()=>{await n.disable(),await a.resetSelectionState(),s.clearTransformWidgetPosition(),await s.invalidateTransforms(),null==t||t(),await l.reset()};return e.jsx(o.VertexTooltip,{content:"Reset View",children:e.jsx(o.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(){const e=useTransformActions();return{frameDrawn:useActionCallback((({set:t,snapshot:n})=>async a=>{const s=await n.getPromise(pt);t(U,a.detail.scene),t(pt,a.detail.scene.sceneViewSummary.selectedVisibleSummary),t(mt,s);const o=undefined;await n.getPromise(Vt)&&await e.syncToSelection()}))}}const VertexBoxSelectionTool=()=>{const{element:t,callback:a}=useCallbackRef(),s=useBoxSelectionActions(),o=useTransformActions(),l=n.useRecoilValue(Le);return u.useEffect((()=>{const e=whenComponentReady(t,(()=>{var e;return[null===(e=null==t?void 0:t.model)||void 0===e?void 0:e.onDragComplete((()=>{"clearAndSelect"===l&&(o.clearTransformWidgetOrientation(),o.clearTransformWidgetPosition(),o.enableSelectionSync())}))]}));return()=>{null==e||e.then((e=>{null==e||e.forEach((e=>null==e?void 0:e.dispose()))}))}}),[t,l]),useApplyKeyBinding({keyBind:"Shift",fn:u.useCallback((()=>s.setOperationType("select")),[]),off:u.useCallback((()=>s.setOperationType("clearAndSelect")),[])}),e.jsx(i.VertexViewerBoxQueryTool,{ref:a,"data-testid":"viewer-box-query-tool",operationType:l})};function VertexViewerCameraTypeMenu({open:t,onOpen:a,onDismiss:s,onCameraTypeChange:l}){const i=useViewerCameraActions(),r=n.useRecoilValue(K);return e.jsxs(o.VertexMenu,{"data-testid":"camera-types-popover",className:"flex",placement:"bottom-end",open:asBooleanAttribute(t),onMenuClosed:s,children:[e.jsx("div",{slot:"anchor",children:e.jsx("div",{className:Ce("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(o.VertexTooltip,{content:"Change View",children:e.jsx(o.VertexIconButton,{"data-testid":"set-camera-mode-option",className:"p-1 cursor-pointer",variant:"plain",onClick:a,iconName:"orthographic"===r?"cube-orthographic":"cube-perspective",children:e.jsx(o.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(o.VertexMenuItem,{"data-testid":"set-perspective-view",onClick:()=>{i.updateCameraType("perspective"),null==l||l("perspective")},children:[e.jsx(o.VertexIcon,{slot:"icon","data-testid":"set-perspective-view-icon",name:"cube-perspective",size:"sm",className:Ce({"text-[var(--vertex-ui-blue-700)]":"perspective"===r})}),e.jsx("div",{className:Ce("ml-2 items-center",{"text-[var(--vertex-ui-blue-700)]":"perspective"===r}),children:"Perspective"})]}),e.jsxs(o.VertexMenuItem,{"data-testid":"set-orthographic-view",onClick:()=>{i.updateCameraType("orthographic"),null==l||l("orthographic")},children:[e.jsx(o.VertexIcon,{slot:"icon","data-testid":"set-orthographic-view-icon",name:"cube-orthographic",size:"sm",className:Ce({"text-[var(--vertex-ui-blue-700)]":"orthographic"===r})}),e.jsx("div",{className:Ce("ml-2 items-center",{"text-[var(--vertex-ui-blue-700)]":"orthographic"===r}),children:"Orthographic"})]})]})]})}const VertexViewerViewCube=t=>{var{placement:n,children:s}=t,o=__rest(t,["placement","children"]);const l=Array.isArray(s)?s:[s],r=l.filter((e=>!a.isValidElement(e)||e.type!==i.VertexViewerViewCube)).filter((e=>null!=e&&!1!==e)),c=l.find((e=>a.isValidElement(e)&&e.type===i.VertexViewerViewCube)),[u,d]=a.useState(!1);return e.jsxs(i.VertexViewerToolbar,{direction:"vertical","data-testid":"view-cube-toolbar",placement:null!=n?n:"top-right",children:[null!=c?c:e.jsx(i.VertexViewerViewCube,Object.assign({className:"m-7"},o)),0===r.length?e.jsxs("div",{className:"flex items-center justify-center mt-3 gap-1",children:[e.jsx(VertexViewerSceneReset,{}),e.jsx(VertexViewerCameraTypeMenu,{open:u,onDismiss:()=>d(!1),onOpen:()=>d(!0)})]}):e.jsx("div",{className:"mt-3",children:r})]})},VertexViewer=t=>{var{id:s,className:o,disableSelection:l,onTap:r,onLongpress:c,onFrameDrawn:u,onSceneReady:d,viewerRefCallback:m,children:p}=t,h=__rest(t,["id","className","disableSelection","onTap","onLongpress","onFrameDrawn","onSceneReady","viewerRefCallback","children"]);const g=n.useRecoilValue(hn),f=useRecoilRef({state:M}),v=useViewerCameraActions(),b=useHitActions(),S=useSelectionActions(),w=useViewerFrameActions(),[V,C]=n.useRecoilState(B),j=n.useRecoilValue(K),T=n.useRecoilValue(ne),k=n.useRecoilValue(Me),A=n.useSetRecoilState(F),[P,E]=n.useRecoilState(L);a.useEffect((()=>{null!=s&&E(s)}),[s]);const I=n.useRecoilValue(dn),R=a.useMemo((()=>({opacity:I/100})),[I]),N=n.useRecoilValue(ke),O=n.useRecoilValue(Ae),_=a.useMemo((()=>({color:N,width:O})),[N,O]),D=n.useRecoilValue(Jt),H=n.useRecoilValue(nn),U=n.useRecoilValue(an),W=n.useRecoilValue(sn),G=a.useMemo((()=>({color:H,opacity:U/100,lineWidth:W})),[H,U,W]),$=n.useRecoilValue(Fe),q=null!=p&&!1!==p;return useKeyBindings(),useDefaultKeybindings(),e.jsxs(i.VertexViewer,Object.assign({id:P,"data-testid":"vertex-viewer",ref:null!=m?m:f,className:Ce("flex w-full h-full",o,{"cursor-crosshair":T.hitPending}),style:{"--viewer-background":D},config:g,cameraType:V?j:void 0,onCameraTypeChanged:e=>{V&&v.updateCameraType(e.detail)},phantom:R,featureLines:_,selectionHighlighting:G,featureMaps:$?"final":void 0,onTap:e=>{const t=[...l?[]:[S.selectCurrentHit]];b.tap(e,...t),null==r||r(e)},onLongpress:e=>{b.longPress(e),null==c||c(e)},onFrameDrawn:e=>{w.frameDrawn(e),null==u||u(e)},onSceneReady:async e=>{var t;if(!V){C(!0);const n=await(null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.scene());A(null==n?void 0:n.sceneViewId)}null==d||d(e)}},h,{children:[k&&e.jsx(VertexBoxSelectionTool,{}),q?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:s})=>{const o=n.useRecoilValue(_t),l=n.useRecoilValue(zt);return a.useEffect((()=>{null==t||t(o)}),[o,t]),a.useEffect((()=>{null==s||s(l)}),[l,s]),e.jsx(e.Fragment,{})},VertexViewerToolkitRoot=t=>{var{override:s,autoDefineCustomElements:o,children:l,config:i}=t,u=__rest(t,["override","autoDefineCustomElements","children","config"]);return a.useEffect((()=>{(null==o||o)&&(c.defineCustomElements(),r.defineCustomElements())}),[o]),e.jsx(n.RecoilRoot,{override:s,children:e.jsxs(e.Fragment,{children:[e.jsx(VertexViewerToolkitEventListener,Object.assign({},u)),e.jsx(VertexViewerToolkitRootConfig,{config:i,children:l})]})})},VertexViewerToolkitRootConfig=({config:t,children:s})=>{const o=n.useSetRecoilState(hn);return a.useEffect((()=>{const e=null!=t?toSdkConfig(t):void 0;o(e)}),[t,o]),e.jsx(e.Fragment,{children:s})};var zn=Object.freeze({__proto__:null,get AssemblyFontFace(){return Nn}});exports.CrossSection=Se,exports.Hits=Dt,exports.SceneTree=zn,exports.Selection=Ft,exports.VertexApplicationMessages=VertexApplicationMessages,exports.VertexBoxSelectionButton=VertexBoxSelectionButton,exports.VertexContextMenu=VertexContextMenu,exports.VertexCrossSectionAppearanceColorPicker=VertexCrossSectionAppearanceColorPicker,exports.VertexCrossSectionAppearanceControls=VertexCrossSectionAppearanceControls,exports.VertexCrossSectionAppearanceLineThicknessSlider=VertexCrossSectionAppearanceLineThicknessSlider,exports.VertexCrossSectionAppearancePanelSection=VertexCrossSectionAppearancePanelSection,exports.VertexCrossSectionAppearanceReset=VertexCrossSectionAppearanceReset,exports.VertexDecimalPlaceSelector=VertexDecimalPlaceSelector,exports.VertexFeatureEdgesColorPicker=VertexFeatureEdgesColorPicker,exports.VertexFeatureEdgesControls=VertexFeatureEdgesControls,exports.VertexFeatureEdgesPanelSection=VertexFeatureEdgesPanelSection,exports.VertexFeatureEdgesReset=VertexFeatureEdgesReset,exports.VertexFeatureEdgesThicknessSlider=VertexFeatureEdgesThicknessSlider,exports.VertexFitAllButton=VertexFitAllButton,exports.VertexFitSelectedMenuItem=VertexFitSelectedMenuItem,exports.VertexFlyToMenuItem=VertexFlyToMenuItem,exports.VertexGhostingControls=VertexGhostingControls,exports.VertexGhostingPanelSection=VertexGhostingPanelSection,exports.VertexHideAllMenuItem=VertexHideAllMenuItem,exports.VertexHidePartMenuItem=VertexHidePartMenuItem,exports.VertexHideSelectedMenuItem=VertexHideSelectedMenuItem,exports.VertexLengthUnitSelector=VertexLengthUnitSelector,exports.VertexMaterialControls=VertexMaterialControls,exports.VertexMaterialPanelSection=VertexMaterialPanelSection,exports.VertexMeasurementContextMenu=VertexMeasurementContextMenu,exports.VertexMeasurementDetails=VertexMeasurementDetails,exports.VertexPanButton=VertexPanButton,exports.VertexPointToPointMeasurement=VertexPointToPointMeasurement,exports.VertexPointToPointMeasurementTool=VertexPointToPointMeasurementTool,exports.VertexPreciseMeasurement=VertexPreciseMeasurement,exports.VertexPreciseMeasurementTool=VertexPreciseMeasurementTool,exports.VertexResizableContent=VertexResizableContent,exports.VertexRotateButton=VertexRotateButton,exports.VertexSceneItemGhostingClear=VertexSceneItemGhostingClear,exports.VertexSceneItemGhostingOpacitySlider=VertexSceneItemGhostingOpacitySlider,exports.VertexSceneItemGhostingToggle=VertexSceneItemGhostingToggle,exports.VertexSceneItemMaterialClear=VertexSceneItemMaterialClear,exports.VertexSceneItemMaterialColorPicker=VertexSceneItemMaterialColorPicker,exports.VertexSceneItemMaterialOpacitySlider=VertexSceneItemMaterialOpacitySlider,exports.VertexSceneTree=VertexSceneTree,exports.VertexSceneTreeColumnPopover=VertexSceneTreeColumnPopover,exports.VertexSceneTreeContextMenu=VertexSceneTreeContextMenu,exports.VertexSceneTreeHeader=VertexSceneTreeHeader,exports.VertexSceneTreeSearchBar=VertexSceneTreeSearchBar,exports.VertexSceneTreeSearchInformationForToolbar=VertexSceneTreeSearchInformationForToolbar,exports.VertexSceneTreeSearchOptionsPopover=VertexSceneTreeSearchOptionsPopover,exports.VertexSceneTreeTableLayout=VertexSceneTreeTableLayout,exports.VertexSelectionHighlightingColorPicker=VertexSelectionHighlightingColorPicker,exports.VertexSelectionHighlightingControls=VertexSelectionHighlightingControls,exports.VertexSelectionHighlightingLineThicknessSlider=VertexSelectionHighlightingLineThicknessSlider,exports.VertexSelectionHighlightingOpacitySlider=VertexSelectionHighlightingOpacitySlider,exports.VertexSelectionHighlightingPanelSection=VertexSelectionHighlightingPanelSection,exports.VertexSelectionHighlightingReset=VertexSelectionHighlightingReset,exports.VertexShowAllMenuItem=VertexShowAllMenuItem,exports.VertexShowOnlyMenuItem=VertexShowOnlyMenuItem,exports.VertexShowOnlySelectedMenuItem=VertexShowOnlySelectedMenuItem,exports.VertexToolbar=VertexToolbar,exports.VertexToolbarDivider=VertexToolbarDivider,exports.VertexTransformClear=VertexTransformClear,exports.VertexTransformControls=VertexTransformControls,exports.VertexTransformInputs=VertexTransformInputs,exports.VertexTransformManipulatorToggle=VertexTransformManipulatorToggle,exports.VertexTransformPanelSection=VertexTransformPanelSection,exports.VertexTransformWidget=VertexTransformWidget,exports.VertexUnitsControls=VertexUnitsControls,exports.VertexUnitsPanelSection=VertexUnitsPanelSection,exports.VertexViewer=VertexViewer,exports.VertexViewerBackgroundColorPicker=VertexViewerBackgroundColorPicker,exports.VertexViewerBackgroundControls=VertexViewerBackgroundControls,exports.VertexViewerBackgroundPanelSection=VertexViewerBackgroundPanelSection,exports.VertexViewerBackgroundReset=VertexViewerBackgroundReset,exports.VertexViewerContextMenu=VertexViewerContextMenu,exports.VertexViewerCrossSectionButton=VertexViewerCrossSectionButton,exports.VertexViewerRightOpenedPanel=VertexViewerRightOpenedPanel,exports.VertexViewerRightSidebar=VertexViewerRightSidebar,exports.VertexViewerSceneReset=VertexViewerSceneReset,exports.VertexViewerToolkitRoot=VertexViewerToolkitRoot,exports.VertexViewerViewCube=VertexViewerViewCube,exports.VertexZoomButton=VertexZoomButton;
19
19
  //# sourceMappingURL=bundle.cjs.js.map