@vertexvis/viewer-toolkit-react 0.0.3-canary.12 → 0.0.3-canary.13

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,2 +1,2 @@
1
- export{i as CrossSection,d as Hits,e as SceneTree,f as Selection,V as VertexApplicationMessages,g as VertexBoxSelectionButton,h as VertexContextMenu,j as VertexCrossSectionAppearanceColorPicker,k as VertexCrossSectionAppearanceControls,l as VertexCrossSectionAppearanceLineThicknessSlider,m as VertexCrossSectionAppearancePanelSection,n as VertexCrossSectionAppearanceReset,o as VertexDecimalPlaceSelector,p as VertexFeatureEdgesColorPicker,q as VertexFeatureEdgesControls,r as VertexFeatureEdgesPanelSection,s as VertexFeatureEdgesReset,t as VertexFeatureEdgesThicknessSlider,u as VertexFitAllButton,v as VertexFitSelectedMenuItem,w as VertexFlyToMenuItem,x as VertexGhostingControls,y as VertexGhostingPanelSection,z as VertexHideAllMenuItem,A as VertexHidePartMenuItem,B as VertexHideSelectedMenuItem,C as VertexLengthUnitSelector,D as VertexMaterialControls,E as VertexMaterialPanelSection,F as VertexMeasurementContextMenu,G as VertexMeasurementDetails,H as VertexPanButton,I as VertexPointToPointMeasurement,J as VertexPointToPointMeasurementTool,K as VertexPreciseMeasurement,L as VertexPreciseMeasurementTool,M as VertexResizableContent,N as VertexRotateButton,O as VertexSceneItemGhostingClear,P as VertexSceneItemGhostingOpacitySlider,Q as VertexSceneItemGhostingToggle,R as VertexSceneItemMaterialClear,S as VertexSceneItemMaterialColorPicker,T as VertexSceneItemMaterialOpacitySlider,U as VertexSceneTree,W as VertexSceneTreeContextMenu,X as VertexSceneTreeHeader,Y as VertexSceneTreeTableLayout,Z as VertexSelectionHighlightingColorPicker,$ as VertexSelectionHighlightingControls,a0 as VertexSelectionHighlightingLineThicknessSlider,a1 as VertexSelectionHighlightingOpacitySlider,a2 as VertexSelectionHighlightingPanelSection,a3 as VertexSelectionHighlightingReset,a4 as VertexShowAllMenuItem,a5 as VertexShowOnlyMenuItem,a6 as VertexShowOnlySelectedMenuItem,a7 as VertexToolbar,a8 as VertexTransformClear,a9 as VertexTransformControls,aa as VertexTransformManipulatorToggle,ab as VertexTransformPanelSection,ac as VertexTransformWidget,ad as VertexUnitsControls,ae as VertexUnitsPanelSection,af as VertexViewer,ag as VertexViewerBackgroundColorPicker,ah as VertexViewerBackgroundControls,ai as VertexViewerBackgroundPanelSection,aj as VertexViewerBackgroundReset,ak as VertexViewerContextMenu,al as VertexViewerCrossSectionButton,am as VertexViewerRightOpenedPanel,an as VertexViewerRightSidebar,ao as VertexViewerSceneReset,ap as VertexViewerToolbarDivider,aq as VertexViewerToolkitRoot,ar as VertexViewerViewCube,as as VertexZoomButton}from"./index-BkmxazkT.js";import"react/jsx-runtime";import"recoil";import"react";import"@vertexvis/ui-react";import"@vertexvis/viewer-react";
1
+ import{jsx as e,jsxs as t,Fragment as n}from"react/jsx-runtime";import{logger as i}from"@vertexwebtoolkit/logging";import{useRecoilCallback as a,atom as l,selector as o,useRecoilValue as s,useRecoilState as r,useSetRecoilState as c,atomFamily as d,useRecoilValueLoadable as u,RecoilRoot as m}from"recoil";import{UUID as p,Color as g}from"@vertexvis/utils";import*as h from"react";import f,{useEffect as v,useCallback as b}from"react";import{Vector3 as w,BoundingBox as C,Angle as S,Point as A}from"@vertexvis/geometry";import{VertexColorPicker as k,VertexSlider as T,VertexTooltip as P,VertexIconButton as E,VertexDialog as N,VertexToggle as O,VertexButton as M,VertexDropdownMenu as I,VertexIcon as V,VertexMenuItem as R,VertexResizable as L,VertexMenu as _,VertexMenuDivider as D,VertexDraggablePopover as B,VertexBanner as H,VertexToast as j,VertexSelect as U,VertexPopover as F,VertexTextfield as W}from"@vertexvis/ui-react";import G from"classnames";import{ColorMaterial as K}from"@vertexvis/viewer";import{VertexViewerMeasurementDetails as $,VertexViewerMeasurementDistance as Y,VertexViewerMeasurementPrecise as X,VertexSceneTreeToolbar as q,VertexSceneTreeSearch as Z,VertexSceneTreeTableLayout as J,VertexSceneTreeTableColumn as Q,VertexSceneTree as ee,VertexViewerToolbarGroup as te,VertexViewerToolbar as ne,VertexViewerTransformWidget as ie,VertexViewerBoxQueryTool as ae,VertexViewerViewCube as le,VertexViewer as oe}from"@vertexvis/viewer-react";import{defineCustomElements as se}from"@vertexvis/ui/loader";import{defineCustomElements as re}from"@vertexvis/viewer/loader";function __rest(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var a=0,i=Object.getOwnPropertySymbols(e);a<i.length;a++)t.indexOf(i[a])<0&&Object.prototype.propertyIsEnumerable.call(e,i[a])&&(n[i[a]]=e[i[a]]);return n}"function"==typeof SuppressedError&&SuppressedError;class ce{}function useActionCallback(e,t=[]){const n=undefined;return a((t=>e(Object.assign(Object.assign({},t),{snapshot:Object.defineProperties(t.snapshot,{getPromiseRequired:{configurable:!0,value:createGetPromiseRequiredWrapper(t.snapshot)},tryGetPromise:{configurable:!0,value:createTryGetPromiseWrapper(t.snapshot)}})}))),t instanceof ce?void 0:t)}function retainSnapshot(e){return t=>{var{snapshot:n}=t,i=__rest(t,["snapshot"]);return async(...t)=>{const a=n.retain();try{const a=undefined;return await e(Object.assign(Object.assign({},i),{snapshot:n}))(...t)}finally{a()}}}}function createGetPromiseRequiredWrapper(e){return async(t,n)=>{const i=await e.getPromise(t);if(null==i)throw null!=n?n:new Error(`No value present for required value ${t.key}`);return i}}function createTryGetPromiseWrapper(e){return async t=>{try{return{value:await e.getPromise(t)}}catch(e){return i.debug(`Error encountered retrieving Recoil value. [key={${t.key}}]`,e),{error:e}}}}const de=l({key:"viewerToolkitViewerElement",default:void 0,dangerouslyAllowMutability:!0}),ue=l({key:"viewerElementId",default:"vertex-viewer"}),me=l({key:"viewerInitialSceneReady",default:!1}),pe=l({key:"viewerBaseInteractionHandlerProvider",default:Promise.resolve(void 0),dangerouslyAllowMutability:!0}),ge=l({key:"viewerPrimaryInteractionType",default:"rotate"}),he=o({key:"viewerScene",get:({get:e})=>async()=>{var t;return null===(t=e(de))||void 0===t?void 0:t.scene()},dangerouslyAllowMutability:!0}),fe=l({key:"viewerFrameScene",default:void 0,dangerouslyAllowMutability:!0}),ve=o({key:"viewerSceneVisibleBoundingBox",get:({get:e})=>{var t;return null===(t=e(fe))||void 0===t?void 0:t.boundingBox}});function useViewerSceneActions(){const e=useActionCallback((({snapshot:e})=>async(t,n,...i)=>{const a=await e.getPromise(he),l=await a();i.length>0&&await(null==l?void 0:l.items((e=>i.map((t=>t(e))))).execute({suppliedCorrelationId:n}))})),t=f.useCallback(((...e)=>t=>t.where((t=>t.withItemIds(e))).select()),[]),n=f.useCallback(((...e)=>t=>t.where((t=>t.withItemIds(e))).deselect()),[]),i=f.useCallback((e=>e.where((e=>e.all())).deselect()),[]);return{executeWithCorrelationId:e,execute:useActionCallback((()=>async(t,...n)=>{const i=p.create();await e(t,i,...n)})),selectItemsTransform:t,deselectItemsTransform:n,clearSelectionTransform:i,reset:useActionCallback((({snapshot:e})=>async t=>{const n=await e.getPromiseRequired(he),i=await n(),a=await e.getPromiseRequired(be);null==i||i.reset({includeCamera:!0,suppliedCorrelationId:t,cameraTypeOverride:a})}))}}const ye=500;function useViewerCameraActions(){return{flyToById:useActionCallback((({snapshot:e})=>async(t,n)=>{const i=await e.getPromise(he),a=await i();await(null==a?void 0:a.camera().flyTo({itemId:t}).render({animation:{milliseconds:null!=n?n:ye}}))})),flyToByBoundingBox:useActionCallback((({snapshot:e})=>async(t,n)=>{const i=await e.getPromise(he),a=await i();await(null==a?void 0:a.camera().flyTo({boundingBox:t}).render({animation:{milliseconds:null!=n?n:ye}}))})),updateCameraType:useActionCallback((({set:e})=>t=>{e(be,t)}))}}const be=l({key:"viewerCameraType",default:"perspective"});class we{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(w.left(),-e),y=e=>create(w.down(),-e),z=e=>create(w.forward(),-e),getAxis=(e,t)=>{switch(e){case"x":return xAxis(t);case"y":return yAxis(t);case"z":return zAxis(t)}},Ce={x:w.left(),y:w.down(),z:w.forward()},xAxis=e=>e.x,yAxis=e=>e.y||w.create(e.x.z,e.x.x,e.x.y),zAxis=e=>e.z||w.create(e.x.y,e.x.z,e.x.x),axis=(e,t,n,i)=>e&&e.normal&&[["x",t],["y",n],["z",i]].filter((t=>0===w.magnitude(w.cross(e.normal,t[1])))).map((e=>e[0])).pop(),isNegativeNormal=e=>w.dot(w.create(-1,-1,-1),e.normal)>0,towardsVector=(e,t)=>{const n=undefined;return w.dot(e,t.normal)<0?invert(t):t},towardsCamera=(e,t)=>towardsVector(e.viewVector,t),invert=e=>Object.assign(Object.assign({},e),{normal:w.multiply(e.normal,w.create(-1,-1,-1)),offset:-e.offset}),fromHit=(e,t)=>{const n=w.normalize(e.normal),i=w.dot(n,e.position);return towardsCamera(t,create(n,i))},toAxis=(e,t,n,i,a)=>{const l=n.viewAll(),o=getAxis(e,t),s=null!=i&&null!=o?create(o,w.dot(o,a||C.center(i))):forAxis(e,l.lookAt[e]);return towardsCamera(n,s)};function corners(e){return[w.create(e.min.x,e.min.y,e.min.z),w.create(e.min.x,e.min.y,e.max.z),w.create(e.min.x,e.max.y,e.min.z),w.create(e.min.x,e.max.y,e.max.z),w.create(e.max.x,e.max.y,e.max.z),w.create(e.max.x,e.max.y,e.min.z),w.create(e.max.x,e.min.y,e.max.z),w.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 xe="#999999",Se=1,Ae={default:5,min:0,max:10},ke=l({key:"crossSectioningEnabled",default:!1}),Te=l({key:"crossSectioningHighlightColor",default:xe}),Pe=l({key:"crossSectioningBorderWidth",default:1}),Ee=l({key:"crossSectioningPlanes",default:[]}),Ne=l({key:"crossSectioningAlignment",default:{mode:"global",hitPending:!1}}),Oe=o({key:"crossSectioningTargetBoundingBox",get:async({get:e})=>{const t=undefined;return e(ve)}}),Me=l({key:"crossSectioningIsInteractive",default:!1}),Ie=l({key:"crossSectioningActiveAxis",default:"x"}),Ve=l({key:"crossSectioningAvailableAxes",default:Ce}),Re=o({key:"crossSectioningOffsetScalar",get:({get:e})=>{const t=e(Ee);return t.length>0&&isNegativeNormal(t[0])?-1:1}}),Le=o({key:"crossSectioningSliderRange",get:({get:e})=>{const t=e(Ee),n=e(Oe),i=null!=n?corners(n):[];if(t.length>0){const e=i.map((e=>w.dot(e,isNegativeNormal(t[0])?w.multiply(t[0].normal,w.create(-1,-1,-1)):t[0].normal)));return{default:t[0].offset,min:Math.min(...e)-2,max:Math.max(...e)+2}}return Ae}}),_e=o({key:"crossSectioningPlaneDisplayOffset",get:({get:e})=>{const t=e(Ee),n=e(Re),i=e(Le);return t.length>0?t[0].offset*n:i.default}}),De=l({key:"crossSectioningAdditionalToolsOpen",default:!1}),Be=l({key:"crossSectioningAlignmentToolsOpen",default:!1}),He=l({key:"crossSectioningAxisToolsOpen",default:!1}),je=l({key:"crossSectioningInteractionHandler",default:new we,dangerouslyAllowMutability:!0});function useCrossSectioning(e,t){const n=s(je);f.useEffect((()=>{t&&(null==e||e.registerInteractionHandler(n))}),[e,t,n])}const ze=l({key:"hitResultsTapDetails",default:void 0}),Ue=l({key:"hitResultsLongPressDetails",default:void 0}),Fe=l({key:"previousHitResult",default:void 0}),We=l({key:"currentHitResult",default:void 0}),Ge=o({key:"hitResult",get:async({get:e})=>{var t,n,i,a,l,o,s,r;const c=e(ze),d=e(Ue),u=null!=c?c:d,m=e(he),p=await m(),g=null==p?void 0:p.sceneViewId,h=null==p?void 0:p.raycaster();if(null!=u&&null!=h&&null!=g){const e=await h.hitItems(u.position),c=((null==e?void 0:e.hits)||[])[0];if(null!=c)return{id:null===(t=c.itemId)||void 0===t?void 0:t.hex,normal:w.create((null===(n=null==c?void 0:c.hitNormal)||void 0===n?void 0:n.x)||0,(null===(i=null==c?void 0:c.hitNormal)||void 0===i?void 0:i.y)||0,(null===(a=null==c?void 0:c.hitNormal)||void 0===a?void 0:a.z)||0),position:w.create((null===(l=null==c?void 0:c.hitPoint)||void 0===l?void 0:l.x)||0,(null===(o=null==c?void 0:c.hitPoint)||void 0===o?void 0:o.y)||0,(null===(s=null==c?void 0:c.hitPoint)||void 0===s?void 0:s.z)||0),meta:u.metaKey||u.ctrlKey||!1,metadata:[],ancestors:(null===(r=null==c?void 0:c.ancestors)||void 0===r?void 0:r.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})))||[]}}}}),Ke=l({key:"hitResultsSkipNextTap",default:!1}),alignToNormal=(e,t,n)=>{if(e.toFrameCamera().isPerspective()){const n=w.dot(w.normalize(e.up),t),i=Math.abs(n)>.98?w.normalize(w.scale(-n,e.viewVector)):e.up,a=w.add(w.scale(w.distance(e.position,e.lookAt),w.multiply(t,w.create(-1,-1,-1))),e.lookAt);return e.update({up:i,position:a})}{const i=w.angleTo(w.normalize(e.viewVector),t),a=null!=n?C.center(n):e.lookAt,l=w.normalize(w.cross(w.normalize(e.viewVector),t));return e.rotateAroundAxisAtPoint(i,a,l)}};function isParallelTo(e,t){const n=S.toDegrees(w.angleTo(e,t));return 0===n||180===n}const $e=500;function useCrossSectioningActions(){const e=useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromise(Pe),n=await e.getPromise(Te),i=await e.getPromise(Ee),a=await e.getPromise(he),l=await a();await(null==l?void 0:l.crossSectioning().update({sectionPlanes:i,highlightColor:n?g.fromHexString(n):void 0,lineWidth:t}))})),t=useActionCallback((({set:t,reset:n,snapshot:i})=>async()=>{const a=await i.getPromise(he),l=await a();if(null!=l){const i=l.camera().viewAll();n(Ve),t(Ee,[towardsCamera(l.camera(),x(i.lookAt.x))]),await e()}})),n=useActionCallback(retainSnapshot((({snapshot:t,set:n})=>async()=>{const i=await t.tryGetPromise(Ge).then((e=>e.value)),a=await t.getPromise(he),l=await a();if(null!=i&&null!=l){const t=fromHit(i,l.camera());n(Ee,null!=t?[t]:[]),n(Ve,null!=t?{x:t.normal}:Ce),await e()}}))),i=useActionCallback((({set:e,snapshot:n})=>async()=>{const i=await n.getPromise(Ee),a=undefined;await n.getPromise(ke)||(e(ke,!0),0===i.length&&await t())})),a=useActionCallback((({reset:t,snapshot:n})=>async()=>{const i=undefined;await n.getPromise(ke)&&(t(ke),t(De),t(Be),t(He),t(Ee),t(Ne),t(Ie),await e())}));return{enable:i,disable:a,reapply:useActionCallback((({snapshot:t})=>async()=>{const n=undefined;await t.getPromise(ke)&&await e()})),openAdditionalTools:useActionCallback((({set:e,snapshot:t})=>async()=>{const n=undefined;await t.getPromise(ke)||await i(),e(De,!0)})),closeAdditionalTools:useActionCallback((({reset:e})=>()=>{e(De)})),openAlignmentTools:useActionCallback((({set:e,reset:t})=>()=>{t(He),e(Be,!0)})),closeAlignmentTools:useActionCallback((({reset:e})=>()=>{e(Be)})),openAxisTools:useActionCallback((({set:e,reset:t})=>()=>{t(Be),e(He,!0)})),closeAxisTools:useActionCallback((({reset:e})=>()=>{e(He)})),beginInteraction:useActionCallback((({set:e,snapshot:t})=>async()=>{const n=await t.getPromise(je);e(Me,!0),await n.beginInteraction()})),endInteraction:useActionCallback((({reset:e,snapshot:t})=>async()=>{const n=await t.getPromise(je);e(Me),await n.endInteraction()})),updatePlanes:useActionCallback(retainSnapshot((({set:t,snapshot:n})=>async i=>{const a=await n.getPromise(Ee);if(a.length>0){const l=await n.getPromise(Re),o=await n.getPromise(Le),s=l<0?-1*o.max:o.min,r=l<0?-1*o.min:o.max,c=a.map((e=>Object.assign(Object.assign({},e),{offset:Math.min(Math.max(i*l,s),r)})));t(Ee,c),await e()}}))),flipPlanes:useActionCallback((({set:t,snapshot:n})=>async()=>{const i=await n.getPromise(Ee);t(Ee,i.map((e=>invert(e)))),await e()})),alignViewToPlane:useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromise(Ee),n=await e.getPromise(de),i=await(null==n?void 0:n.scene());t.length>0&&null!=i&&await alignToNormal(i.camera(),t[0].normal,i.boundingBox()).render({animation:{milliseconds:$e}})})),updateAxis:useActionCallback(retainSnapshot((({set:t,reset:n,snapshot:i})=>async a=>{const l=await i.getPromise(Ee),o=await i.getPromise(Ve),s=await i.getPromise(Oe),r=await i.getPromise(Ne),c=await i.getPromise(de),d=await(null==c?void 0:c.scene()),u=o[a],m=null!=u&&l.length>0&&isParallelTo(l[0].normal,u)&&!isNaN(w.angleTo(l[0].normal,u));if(null!=d&&!m){const e=await i.tryGetPromise(Ge).then((e=>e.value));t(Ie,a),t(Ee,[toAxis(a,o,d.camera(),s,"global"!==r.mode?null==e?void 0:e.position:void 0)])}n(He),await e()}))),updateAlignment:useActionCallback((({set:e,reset:a})=>async(l,o)=>{a(Be),e(Ne,{mode:l,hitPending:"global"!==l&&null==o}),"global"===l?(a(Ie),a(Ve),await t()):"surface"===l&&null!=o&&(await i(),await n())})),sectionCurrentHit:useActionCallback((({set:e,snapshot:t})=>async()=>{const i=await t.getPromise(Ne);i.hitPending&&(e(Ne,Object.assign(Object.assign({},i),{hitPending:!1})),"surface"===i.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 Ye=Object.freeze({__proto__:null,DEFAULT_ALIGN_TO_PLANE_ANIMATION_DURATION_MS:$e,DEFAULT_CROSS_SECTION_HIGHLIGHT_COLOR:xe,DEFAULT_CROSS_SECTION_LINE_THICKNESS_VALUE:1,DEFAULT_SLIDER_RANGE:Ae,crossSectioningActiveAxis:Ie,crossSectioningAdditionalToolsOpen:De,crossSectioningAlignment:Ne,crossSectioningAlignmentToolsOpen:Be,crossSectioningAvailableAxes:Ve,crossSectioningAxisToolsOpen:He,crossSectioningBorderWidth:Pe,crossSectioningEnabled:ke,crossSectioningHighlightColor:Te,crossSectioningInteractionHandler:je,crossSectioningIsInteractive:Me,crossSectioningOffsetScalar:Re,crossSectioningPlaneDisplayOffset:_e,crossSectioningPlanes:Ee,crossSectioningSliderRange:Le,crossSectioningTargetBoundingBox:Oe,useCrossSectioning:useCrossSectioning,useCrossSectioningActions:useCrossSectioningActions});function useDebouncedCallback(e,t){const[n,i]=f.useState();return f.useEffect((()=>()=>{null!=n&&clearTimeout(n)}),[e,t,n]),f.useCallback((a=>{const handler=()=>{e(a)};null!=n&&clearTimeout(n),i(setTimeout(handler,t))}),[e,t,n])}const VertexColorPicker=t=>{var{onInput:n}=t,i=__rest(t,["onInput"]);const a=useDebouncedCallback((e=>{null==n||n(e)}),500),l=f.useCallback((e=>{const t=e.target;a(t.value)}),[a]);return e(k,Object.assign({onInput:l},i))},VertexCrossSectionAppearanceColorPicker=({onUpdate:t})=>{const n=useCrossSectioningActions(),[i,a]=r(Te);return e(VertexColorPicker,{"data-testid":"cross-section-highlight-color-picker",value:i,onValueChanged:e=>{null==t||t(e.detail)},onInput:async e=>{a(e),await n.reapply()}})},VertexSlider=n=>{var{value:i,defaultValue:a,leftLabel:l,rightLabel:o,onChange:s,onValueChange:r,onValueInput:c}=n,d=__rest(n,["value","defaultValue","leftLabel","rightLabel","onChange","onValueChange","onValueInput"]);const[u,m]=f.useState(a);return t("div",{className:"flex w-full items-center gap-2",children:[l&&e("div",{className:"pl-0.5 text-xs text-center",children:l}),e(T,Object.assign({className:G("w-full",{"mt-0.5":null!=l||null!=o}),value:null!=i?i:u,onValueChange:e=>{m(e.detail.value),null==s||s(e.detail.value),null==r||r(e)},onValueInput:e=>{m(e.detail.value),null==s||s(e.detail.value),null==c||c(e)}},d)),o&&e("div",{className:"text-xs pr-2 flex-shrink-0 text-right",children:o})]})},VertexCrossSectionAppearanceLineThicknessSlider=({onUpdate:t})=>{const n=useCrossSectioningActions(),[i,a]=r(Pe);return e(VertexSlider,{id:"cross-section-line-thickness","data-testid":"cross-section-line-thickness-slider",leftLabel:"Off",rightLabel:"Thick",min:0,max:3,step:.5,value:i,valueLabelDisplay:"auto",onValueInput:async e=>{a(e.detail.value),await n.reapply()},onValueChange:e=>{null==t||t(e.detail.value)}})};function VertexCrossSectionAppearanceControls({onUpdateCrossSectionColor:i,onUpdateCrossSectionLineThickness:a}){return t(n,{children:[e("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Color"}),e(VertexCrossSectionAppearanceColorPicker,{onUpdate:i}),e("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Line Thickness"}),e(VertexCrossSectionAppearanceLineThicknessSlider,{onUpdate:a})]})}function PanelSection({header:n,children:i}){return t("div",{className:"py-3 px-4 border-neutral-300 border-b",children:[e("div",{className:"my-2 text-base text-neutral-700",children:n}),i]})}const VertexCrossSectionAppearanceReset=({onReset:t})=>{const n=useCrossSectioningActions(),[i,a]=r(Te),[l,o]=r(Pe),s=undefined;return e("div",{className:"ml-auto",children:e(P,{content:"Reset Cross Sectioning Appearance",children:e(E,{"data-testid":"cross-section-appearance-reset",iconName:"reset",iconSize:"sm",onClick:async()=>{a(xe),o(1),null==t||t(),await n.reapply()},disabled:!(i!==xe||1!==l)})})})};function VertexCrossSectionAppearancePanelSection({onResetCrossSectionAppearance:n,onUpdateCrossSectionColor:i,onUpdateCrossSectionLineThickness:a}){return e(PanelSection,{header:t("div",{className:"flex items-center text-base",children:["Cross Sectioning",e(VertexCrossSectionAppearanceReset,{onReset:n})]}),children:e(VertexCrossSectionAppearanceControls,{onUpdateCrossSectionColor:i,onUpdateCrossSectionLineThickness:a})})}const Xe=.5,qe="#444444",Ze=l({key:"featureEdgesSelectedColor",default:qe}),Je=l({key:"featureEdgesLineThickness",default:Xe}),VertexFeatureEdgesColorPicker=({onUpdate:t})=>{const[n,i]=r(Ze);return e(VertexColorPicker,{"data-testid":"feature-edges-color-picker",value:n,onValueChanged:e=>{null==t||t(e.detail)},onInput:e=>i(e)})},VertexFeatureEdgesThicknessSlider=({onUpdate:t})=>{const[n,i]=r(Je);return e(VertexSlider,{id:"feature-edges-thickness","data-testid":"feature-edges-thickness-slider",leftLabel:"Off",rightLabel:"Thick",min:0,max:3,step:.5,value:n,valueLabelDisplay:"auto",onValueInput:e=>{i(e.detail.value)},onValueChange:e=>{null==t||t(e.detail.value)}})};function VertexFeatureEdgesControls({onUpdateFeatureEdgesColor:i,onUpdateFeatureEdgesThickness:a}){return t(n,{children:[e("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Color"}),e(VertexFeatureEdgesColorPicker,{onUpdate:i}),e("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Line Thickness"}),e(VertexFeatureEdgesThicknessSlider,{onUpdate:a})]})}const VertexFeatureEdgesReset=({onReset:t})=>{const[n,i]=r(Ze),[a,l]=r(Je),o=undefined;return e("div",{className:"ml-auto",children:e(P,{content:"Reset Feature Edges",children:e(E,{"data-testid":"feature-edges-reset",iconName:"reset",iconSize:"sm",onClick:()=>{i(qe),l(Xe),null==t||t()},disabled:!(a!==Xe||n!==qe)})})})};function VertexFeatureEdgesPanelSection({onResetFeatureEdges:n,onUpdateFeatureEdgesColor:i,onUpdateFeatureEdgesThickness:a}){return e(PanelSection,{header:t("div",{className:"flex items-center text-base",children:["Feature Edges",e(VertexFeatureEdgesReset,{onReset:n})]}),children:e(VertexFeatureEdgesControls,{onUpdateFeatureEdgesColor:i,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 Qe=l({key:"contextMenuActive",default:void 0}),et=l({key:"contextMenuPosition",default:void 0}),tt=l({key:"contextMenuTarget",default:void 0}),nt=l({key:"contextMenuItem",default:void 0}),it=l({key:"contextMenuActions",default:[]}),at=o({key:"contextMenuActivePosition",get:({get:e})=>null!=e(Qe)?e(et):void 0});function useContextMenuActions(){return{pointerDown:useActionCallback((({set:e})=>async t=>{if(2===t.button){const n=t.clientX,i=null==t?void 0:t.clientY;e(et,A.create(n,i)),e(tt,t.target)}})),pointerUp:useActionCallback((({snapshot:e,set:t})=>async(n,i,a,l)=>{const o=await e.getPromise(et),s=await e.getPromise(Qe);if(null!=o&&null==s){const e=n.clientX,s=null==n?void 0:n.clientY,r=A.create(e,s),c=null!=o?A.distance(o,r):0,d=null==a||a(n);c<2&&d&&(null==l||l(n,null!=o?o:r),t(Qe,i))}})),contextMenu:useActionCallback((()=>(e,t)=>{(null==t||t(e))&&e.preventDefault()})),longPress:useActionCallback((({set:e})=>(t,n,i,a)=>{if(null==i||i(t)){const i=A.create(t.touches[0].clientX,t.touches[0].clientY);e(et,i),e(tt,t.target),e(Qe,n),null==a||a(t,i)}})),clearActiveContextMenu:useActionCallback((({reset:e,set:t})=>n=>{t(Ke,!!n),e(Qe),e(it),e(et)})),clearDismissedState:useActionCallback((({reset:e})=>()=>e(Ke)))}}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 lt=l({key:"boxSelectionEnabled",default:!1}),ot=l({key:"boxSelectionOperationType",default:"clearAndSelect"}),useBoxSelectionActions=()=>({enable:useActionCallback((({set:e})=>()=>{e(lt,!0)})),disable:useActionCallback((({reset:e})=>async()=>{e(lt),e(ot)})),setOperationType:useActionCallback((({set:e})=>t=>{e(ot,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 st=l({key:"isEditingPointToPointMeasurement",default:!1}),rt=l({key:"pointToPointMeasurementOutcome",default:void 0}),ct=l({key:"editedPointToPointMeasurement",default:void 0});function usePointToPointMeasurement(e){const t=c(rt);v((()=>{let n;return whenComponentReady(e,(()=>{n=null==e?void 0:e.measurementModel.onOutcomeChanged(t)})),()=>null==n?void 0:n.dispose()}),[e,t])}const dt=2,ut=l({key:"isEditingPreciseMeasurement",default:!1}),mt=l({key:"preciseMeasurementOutcome",default:void 0}),pt=l({key:"preciseMeasurementController",dangerouslyAllowMutability:!0,default:void 0}),gt=l({key:"preciseMeasurementOverlays",dangerouslyAllowMutability:!0,default:void 0}),ht=l({key:"preciseMeasurementEntities",dangerouslyAllowMutability:!0,default:[]}),ft=o({key:"preciseMeasurementMessage",get:({get:e})=>{const t=undefined;return 0===e(ht).length?"Select a surface":void 0}});function usePreciseMeasurementModel(e,t,n){const i=c(ht),a=c(mt),l=c(pt),o=c(gt),r=s(pt);v((()=>{let n;return whenComponentReady(e,(()=>{n=null==e?void 0:e.measurementModel.onEntitiesChanged((e=>{i(e),null==t||t(e)}))})),()=>null==n?void 0:n.dispose()}),[e,i]),v((()=>{let t;return whenComponentReady(e,(()=>{t=null==e?void 0:e.measurementModel.onOutcomeChanged((e=>{a(e),null==n||n(e)}))})),()=>null==t?void 0:t.dispose()}),[e,a]),v((()=>{let t;return whenComponentReady(e,(()=>{t=null==e?void 0:e.measurementModel.onEntitiesChanged((e=>{if(e.length>2){const t=e[2];null==r||r.setEntities(new Set([t]))}}))})),()=>null==t?void 0:t.dispose()}),[e,r]),v((()=>{whenComponentReady(e,(()=>{l(null==e?void 0:e.measurementController)}))}),[e,l]),v((()=>{whenComponentReady(e,(()=>{o(null==e?void 0:e.measurementOverlays)}))}),[e,o])}function useMeasurementActions(){const e=useBoxSelectionActions(),t=useEnablePointToPointMeasurement(),n=useDisablePointToPointMeasurement(),i=useDisablePreciseMeasurement(),a=useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromise(pt);null==t||t.clearEntities()})),l=useActionCallback((()=>async(e={})=>{await a(),n(e),i()})),o=useActionCallback((({set:e,reset:n})=>async i=>{await l(),"point-to-point"===i?t():(n(mt),n(ht),e(ut,!0))}));return{disableEditMeasurement:useActionCallback((()=>async e=>{await l(e)})),enableEditMeasurement:useActionCallback((()=>async e=>{await o(e)})),resetMeasurement:useActionCallback((({snapshot:e,reset:t})=>async()=>{const n=await e.getPromise(ut),i=await e.getPromise(st);n?await a():i&&(t(rt),t(ct))})),clearEditedPointToPointMeasurement:useActionCallback((({reset:e})=>()=>{e(ct)})),setEditedPointToPointMeasurement:useActionCallback((({set:e})=>t=>{e(ct,t)})),toggleEditPointToPointMeasurement:useActionCallback((({snapshot:t})=>async()=>{const n=undefined;await t.getPromise(st)?await l():await o("point-to-point"),e.disable()})),toggleEditPreciseMeasurement:useActionCallback((({snapshot:t})=>async()=>{const n=undefined;await t.getPromise(ut)?await l():await o("precise"),e.disable()}))}}function useEnablePointToPointMeasurement(){return useActionCallback((({reset:e,set:t})=>(n={})=>{t(st,!0),n.keepExistingMeasurement||e(rt)}))}function useDisablePointToPointMeasurement(){return useActionCallback((({reset:e})=>(t={})=>{e(st),t.keepExistingMeasurement||(e(ct),e(rt))}))}function useDisablePreciseMeasurement(){return useActionCallback((({reset:e})=>async()=>{e(ut),e(mt),e(ht)}))}const vt=o({key:"isEditingMeasurement",get:({get:e})=>e(st)||e(ut)}),yt=o({key:"measurementPanelModel",get:({get:e})=>e(rt)||e(mt)}),bt=o({key:"measurementPanelOverlays",dangerouslyAllowMutability:!0,get:({get:e})=>e(gt)}),wt=o({key:"measurementPanelMessage",get:({get:e})=>{const t=undefined;return e(ut)?e(ft):void 0}}),Ct=o({key:"measurementPanelIsResettable",get:({get:e})=>e(vt)&&null!=e(yt)}),xt=3e3,St=l({key:"applicationMessageToast",default:void 0}),At=l({key:"applicationMessageBanner",default:void 0}),useApplicationMessageActions=()=>({setBannerMessage:useActionCallback((({set:e})=>t=>{e(At,null!=t?Object.assign(Object.assign({},t),{id:p.create()}):void 0)})),setToastMessage:useActionCallback((({set:e})=>t=>{e(St,null!=t?Object.assign(Object.assign({},t),{id:p.create()}):void 0)}))});var kt;!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"}(kt||(kt={}));const Tt=d({key:"selectionSelectedItems",default:void 0}),Pt=l({key:"selectionSelectedItemIds",default:[]}),Et=l({key:"selectionLastSelected",default:void 0}),Nt=l({key:"selectionLastSelectionFromViewer",default:!1}),Ot=l({key:"selectionLastSelectWasMultiSelect",default:!1}),Mt=o({key:"selectionHighestSelectedAncestor",get:({get:e})=>{var t,n;const i=e(Et),a=e(Pt);return null!==(n=null===(t=null==i?void 0:i.ancestors)||void 0===t?void 0:t.find((e=>a.includes(e))))&&void 0!==n?n:null==i?void 0:i.id}}),It=l({key:"selectionPreviousVisibleSummary",default:void 0}),Vt=l({key:"selectionVisibleSummary",default:void 0}),Rt=o({key:"selectionVisibleCount",get:({get:e})=>{var t,n;return null!==(n=null===(t=e(Vt))||void 0===t?void 0:t.count)&&void 0!==n?n:0}}),Lt=o({key:"selectionBoundingBoxCenter",get:({get:e})=>{const t=e(Vt);return null!=(null==t?void 0:t.boundingBox)?C.center(t.boundingBox):w.origin()}}),_t=o({key:"selectionIsActive",get:({get:e})=>{const t=e(Pt),n=undefined;return e(Rt)>0||t.length>0}}),Dt=l({key:"transformWidgetEnabled",default:!1}),Bt=l({key:"transformWidgetPosition",default:void 0}),Ht=l({key:"transformWidgetOrientationOverride",default:void 0}),jt=o({key:"transformWidgetOrientation",get:({get:e})=>{const t=e(Ht);if(null!=t)return t}}),zt=l({key:"transformWidgetCachedOrientation",default:void 0}),Ut=l({key:"transformWidgetSyncToSelection",default:!1}),Ft=l({key:"transformWidgetIsInteracting",default:!1}),Wt=d({key:"appliedItemTransform",default:void 0}),Gt=l({key:"appliedItemTransformIds",default:[]}),Kt=l({key:"selectedCoordinateSpace",default:"world"}),useTransformActions=()=>{const e=useApplicationMessageActions(),t=useViewerSceneActions(),n=useActionCallback((({set:e,snapshot:t})=>async()=>{const n=await t.getPromise(Lt);e(Bt,n)})),i=useActionCallback((({set:e,snapshot:t})=>async()=>{const i=await t.getPromise(Bt),a=await t.getPromise(Ot),l=await t.getPromise(Pt),o=await t.getPromise(Rt);null==i&&(l.length>0||a||o>0)&&await n(),e(Ut,!0)})),a=useActionCallback((({set:e})=>async t=>{e(Bt,null!=t?t:void 0)})),l=useActionCallback(retainSnapshot((({snapshot:e,set:t,reset:n})=>async()=>{const i=await e.getPromise(jt),a=undefined;(await e.getPromise(Gt)).forEach((e=>{n(Wt(e))})),null!=i&&t(zt,i)}))),o=useActionCallback((({set:e,reset:t})=>n=>{t(zt),e(Ht,n)}));return{enableTransformWidget:useActionCallback((({set:t})=>async(l,o)=>{e.setToastMessage({message:"Transform manipulator enabled! Select parts to interact.",duration:xt}),t(Dt,!0),o?await n():null==l?await i():await a(l)})),disableTransformWidget:useActionCallback((({reset:e})=>()=>{e(Dt),e(Ht)})),setTransformWidgetOrientation:o,clearTransformWidgetOrientation:useActionCallback((({reset:e})=>()=>{e(zt),e(Ht)})),setTransformWidgetPosition:a,clearTransformWidgetPosition:useActionCallback((({reset:e})=>()=>e(Bt))),invalidateTransforms:l,setIsInteractivelyTransforming:useActionCallback((({set:e})=>t=>{e(Ft,t)})),setDefaultWidgetPosition:i,setDefaultWidgetPositionToSelection:n,enableSelectionSync:useActionCallback((({set:e})=>()=>e(Ut,!0))),disableSelectionSync:useActionCallback((({reset:e})=>()=>e(Ut))),syncToSelection:useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromise(It),n=await e.getPromise(Vt),i=undefined;if(await e.getPromise(Ut)){const e=null==n?void 0:n.boundingBox,i=null!=e&&null!=(null==t?void 0:t.boundingBox)&&equals(e,t.boundingBox);null==e||i||await a(C.center(e))}})),orientToHitResult:useActionCallback((({reset:e})=>async t=>{e(Ut),null!=t?(await a(null==t?void 0:t.position),o(w.eulerTo(w.up(),t.normal))):(e(Bt),o(void 0))})),clearSelectedTransforms:useActionCallback((({set:e})=>async()=>{await t.execute(kt.CLEAR_SELECTED_TRANSFORMS,(e=>e.where((e=>e.withSelected())).clearTransforms())),e(Bt,void 0),e(Dt,!1)})),clearAllTransforms:useActionCallback((({set:e})=>async()=>{await t.execute(kt.CLEAR_SELECTED_TRANSFORMS,(e=>e.where((e=>e.all())).clearTransforms())),e(Bt,void 0),e(Dt,!1)}))}},useHitActions=()=>{const e=useCrossSectioningActions(),t=useMeasurementActions(),n=useTransformActions(),i=useActionCallback(retainSnapshot((({snapshot:e})=>async()=>{const n=await e.tryGetPromise(Ge).then((e=>e.value)),i=await e.getPromise(ct);null==n&&null!=(null==i?void 0:i.start)&&null!=i.end&&await t.resetMeasurement()}))),a=useActionCallback(retainSnapshot((({snapshot:e})=>async()=>{const t=await e.tryGetPromise(Ge).then((e=>e.value));await n.orientToHitResult(t)}))),l=useActionCallback(retainSnapshot((({set:e,snapshot:t})=>async()=>{const n=await t.tryGetPromise(Ge).then((e=>e.value));e(nt,n)}))),o=useActionCallback(retainSnapshot((({snapshot:e,set:t})=>async()=>{t(We,await e.tryGetPromise(Ge).then((e=>e.value)))})));return{tap:useActionCallback(retainSnapshot((({snapshot:t,set:n})=>async({detail:s},...r)=>{const c=await t.getPromise(vt),d=await t.getPromise(Ne),u=2!==(null==s?void 0:s.buttons)&&!(null==s?void 0:s.altKey);s.altKey||s.ctrlKey||s.metaKey||s.shiftKey;const m=u&&!d.hitPending&&!c,p=await t.tryGetPromise(Ge).then((e=>e.value));n(Fe,p),n(ze,s),await i(),m&&(r.forEach((e=>e())),await a()),await l(),await e.sectionCurrentHit(),await o()}))),longPress:useActionCallback(retainSnapshot((({snapshot:e,set:t,reset:n})=>async i=>{n(ze),t(Ue,i.detail),await e.tryGetPromise(Ge),await l(),await o()})))}},$t=o({key:"viewerToolkitHitState",get:({get:e})=>{const t=undefined,n=undefined,i=undefined,a=undefined,l=undefined;return{tapDetails:e(ze),longPressDetails:e(Ue),previousHitResult:e(Fe),currentHitResult:e(We)}}});var Yt=Object.freeze({__proto__:null,currentHitResult:We,hitResult:Ge,hitResultsLongPressDetails:Ue,hitResultsSkipNextTap:Ke,hitResultsTapDetails:ze,hitState:$t,previousHitResult:Fe,useHitActions:useHitActions});function useSelectionActions(){const e=useTransformActions(),t=useViewerSceneActions(),n=useActionCallback((({snapshot:e,reset:t})=>async()=>{const n=undefined;(await e.getPromise(Pt)).forEach((e=>t(Tt(e))))})),i=useActionCallback((({snapshot:e,reset:n,set:i})=>async(a,l)=>{var o,s;const r=await e.getPromise(Tt(a.id)),c=await e.getPromise(Pt),u=null===(s=[...null!==(o=a.ancestors)&&void 0!==o?o:[]])||void 0===s?void 0:s.reverse().find((e=>!c.includes(e)));null!=r&&null!=u?(i(Tt(u),{id:u}),i(Pt,(e=>[...e,u])),t.execute(kt.SELECTING_ANCESTOR,t.selectItemsTransform(u))):(null==l?void 0:l.clear)?(i(Tt(a.id),a),i(Pt,[a.id]),t.execute(kt.SELECTING_ONLY_ITEM,t.clearSelectionTransform,t.selectItemsTransform(a.id))):(i(Tt(a.id),a),i(Pt,(e=>[...e,a.id])),t.execute(kt.SELECTING_ITEMS,t.selectItemsTransform(a.id))),d(a),i(Et,a),i(Nt,!0),n(Ot)})),a=useActionCallback((({reset:e,set:n})=>async i=>{e(Tt(i)),e(Ot),n(Pt,(e=>e.filter((e=>e!==i)))),t.execute(kt.DESELECTING_ITEMS,t.deselectItemsTransform(i))})),l=useActionCallback((({snapshot:e})=>async t=>{const n=await e.getPromise(Tt(t.id));null!=n?await a(n.id):await i(t)})),o=useActionCallback((({snapshot:t,reset:n,set:a})=>async(l,o={})=>{const s=await t.getPromise(Tt(l.id)),r=await t.getPromise(Pt);if(r.filter((e=>{var t;return e!==l.id&&!(null===(t=l.ancestors)||void 0===t?void 0:t.includes(e))})).forEach((e=>n(Tt(e)))),n(Ot),s)if(o.ignoreAncestorSelection)n(Pt),n(Tt(s.id));else{const e=r.filter((e=>{var t;return e===l.id||(null===(t=l.ancestors)||void 0===t?void 0:t.includes(e))}));a(Pt,e)}else n(Pt);e.clearTransformWidgetOrientation(),await i(l,{clear:!0})})),s=useActionCallback((({reset:t})=>async()=>{await n(),t(Pt),t(Et),t(Nt),t(Ot),e.clearTransformWidgetPosition(),e.clearTransformWidgetOrientation()})),r=useActionCallback((()=>async()=>{await s(),t.execute(kt.CLEAR_SELECTION,t.clearSelectionTransform)})),c=useActionCallback((({set:e})=>async t=>{e(Ot,t)})),d=useActionCallback((({reset:e,set:t})=>e=>{}));return{select:i,toggleSelection:l,clearAndSelect:o,selectCurrentHit:useActionCallback(retainSnapshot((({snapshot:e})=>async()=>{const t=await e.tryGetPromise(Ge).then((e=>e.value)),n=await e.getPromise(ze),i=(null==n?void 0:n.metaKey)||(null==n?void 0:n.ctrlKey)||(null==n?void 0:n.shiftKey);null==t||i?null!=t&&i?await l(t):await r():await o(t)}))),syncSelection:useActionCallback((({set:e,reset:t})=>async(i,a)=>{a.selected?(await n(),e(Tt(i.id),i),a.multiSelect?e(Pt,(e=>[...e.filter((e=>e!==i.id)),i.id])):e(Pt,[i.id]),d(i),e(Et,i),e(Nt,!1),e(Ot,!!a.multiSelect)):(t(Tt(i.id)),t(Ot),e(Pt,(e=>e.filter((e=>e!==i.id)))))})),deselect:a,clearSelection:r,resetSelectionState:s,toggleLastSelectWasMultiSelect:c,selectForModelViewsPanel:d}}const Xt=o({key:"viewerToolkitSelectionState",get:({get:e})=>{const t=undefined,n=undefined,i=undefined,a=undefined;return{selectedItemIds:e(Pt),lastSelected:e(Et),highestSelectedAncestorId:e(Mt)}}});var qt=Object.freeze({__proto__:null,selectionBoundingBoxCenter:Lt,selectionHighestSelectedAncestor:Mt,selectionIsActive:_t,selectionLastSelectWasMultiSelect:Ot,selectionLastSelected:Et,selectionLastSelectionFromViewer:Nt,selectionPreviousVisibleSummary:It,selectionSelectedItemIds:Pt,selectionSelectedItems:Tt,selectionState:Xt,selectionVisibleCount:Rt,selectionVisibleSummary:Vt,useSelectionActions:useSelectionActions});const Zt=255,Jt=l({key:"sceneItemAdjustmentsSelectedColor",default:void 0}),Qt=l({key:"sceneItemAdjustmentsSelectedOpacity",default:void 0}),en=d({key:"appliedItemMaterialOverride",default:void 0}),tn=l({key:"appliedItemMaterialOverrideIds",default:[]}),nn=o({key:"sceneItemAdjustmentsLastSelectedOverride",get:({get:e})=>{const t=e(Et);if(null!=t)return e(en(t.id))}}),an=l({key:"applyMaterialToAllUserAction",default:void 0}),ln=l({key:"showConfirmDialogWhenApplyingMaterialToAll",default:!0}),on=l({key:"confirmApplyMaterialToAllDialogOpen",default:!1}),useSceneItemMaterialActions=()=>{const e=useViewerSceneActions(),t=useActionCallback((({snapshot:e,reset:t})=>async()=>{const n=await e.getPromise(tn);t(Jt),n.forEach((e=>t(en(e)))),t(tn)}));return{updateColor:useActionCallback((({set:e})=>t=>{e(Jt,t)})),clearCurrentColor:useActionCallback((({reset:e})=>()=>{e(Jt)})),clearCurrentOpacity:useActionCallback((({reset:e})=>()=>{e(Qt)})),clear:useActionCallback((({snapshot:t,set:n,reset:i})=>async()=>{const a=await t.getPromise(Pt);i(Jt),a.forEach((e=>i(en(e)))),n(tn,(e=>e.filter((e=>!a.includes(e))))),await e.execute(kt.CLEAR_SELECTED_MATERIAL_OVERRIDES,(e=>e.where((e=>e.withSelected())).clearMaterialOverrides().select()))})),clearAll:useActionCallback((()=>async()=>{await t(),await e.execute(kt.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(Qt,t)})),apply:useActionCallback((({snapshot:t,set:n})=>async()=>{const i=await t.getPromise(Jt),a=await t.getPromise(Qt),l=await t.getPromise(Pt),o=await t.getPromise(nn),s=null!=i?i:o,r=null!=a?a:null==o?void 0:o.opacity;if(null!=s){const t=Object.assign(Object.assign({},s),{opacity:null!=r?r:s.opacity});await e.execute(kt.APPLY_MATERIAL_OVERRIDE_TO_SELECTION,(e=>e.where((e=>e.withSelected())).materialOverride(t))),l.forEach((e=>n(en(e),t))),n(tn,(e=>[...e,...l]))}})),confirmApplyAll:useActionCallback((({set:e})=>t=>{e(on,!0),e(an,(()=>t))})),cancelApplyAll:useActionCallback((({reset:e})=>()=>{e(on),e(an)})),applyAll:useActionCallback((({snapshot:t,reset:n})=>async()=>{const i=await t.getPromise(Jt),a=await t.getPromise(Qt);if(null!=i){const l=await t.getPromise(tn),o=Object.assign(Object.assign({},i),{opacity:null!=a?a:i.opacity});await e.execute(kt.APPLY_MATERIAL_OVERRIDE_TO_ALL,(e=>e.where((e=>e.all())).materialOverride(o))),l.forEach((e=>n(en(e))));const s=await t.getPromise(an);null==s||s(o),n(on),n(an)}})),hideConfirmApplyAllDialog:useActionCallback((({set:e})=>()=>{e(ln,!1)}))}},sn="#FFFFFF",rn=l({key:"viewerBackgroundSelectedColor",default:sn}),VertexSceneItemMaterialApplyAll=({onApplyAll:t})=>{const n=useSceneItemMaterialActions(),i=u(nn),a=s(Jt),l=s(ln),o=h.useMemo((()=>"hasValue"===i.state?null!=a?a:i.contents:a),[i,a]);return e(P,{content:"Apply to All",children:e(E,{iconName:"square-dot-outline",iconSize:"sm",color:"secondary",disabled:null==o,onClick:async()=>{l?n.confirmApplyAll(t):(await n.applyAll(),null==t||t(o))}})})};function SceneItemMaterialApplyAllConfirmationDialog(){const i=useSceneItemMaterialActions(),a=s(on),[l,o]=f.useState(!1),onCloseDialog=()=>{i.cancelApplyAll(),o(!1)};return a?t(N,{open:!0,className:"text-sm",onClosed:onCloseDialog,onBackdropClick:onCloseDialog,children:[e("div",{slot:"heading",children:"Apply to All Parts"}),e("div",{className:"max-w-lg break-words pr-2",children:"This will apply the same material to all parts in the model. Any previous material changes will be lost."}),t("div",{className:"flex mt-8 gap-2 items-center",children:[t("div",{className:"flex gap-2",children:[e(O,{"data-testid":"hide-confirmation-dialog-in-future-checkbox",variant:"check",className:"pt-0.5",checked:l,onValueChanged:e=>{o(e.detail)}}),"Don't show again this session"]}),t("div",{className:"flex ml-auto gap-2",children:[e(M,{"data-testid":"cancel-apply-material-to-all",onClick:onCloseDialog,children:"Cancel"}),e(M,{color:"primary","data-testid":"confirm-apply-material-to-all",onClick:async()=>{await i.applyAll(),l&&i.hideConfirmApplyAllDialog()},children:"Apply"})]})]})]}):e(n,{})}function createColorMaterialWithId(e,t=p.create()){return Object.assign({id:t},K.fromHex(e))}const VertexSceneItemMaterialColorPicker=({onApply:t})=>{const n=useSceneItemMaterialActions(),i=u(nn),a=s(Jt),l=h.useMemo((()=>"hasValue"===i.state?null!=a?a:i.contents:a),[i,a]);return e(VertexColorPicker,{"data-testid":"selected-item-color-picker",value:null!=l?g.toHexString(l.diffuse):void 0,onValueChanged:()=>{n.apply(),null==t||t(l)},onInput:async e=>{n.updateColor(createColorMaterialWithId(e)),await n.apply()}})},VertexSceneItemMaterialOpacitySlider=({onApply:t})=>{const n=useSceneItemMaterialActions(),i=s(Qt),a=u(nn),l=h.useMemo((()=>{var e,t;return"hasValue"===a.state?null!==(t=null!=i?i:null===(e=a.contents)||void 0===e?void 0:e.opacity)&&void 0!==t?t:Zt:null!=i?i:Zt}),[i,a]),o=useDebouncedCallback((()=>{n.apply()}),500),r=h.useCallback((e=>{n.updateOpacity(e.detail.value),o(e.detail.value)}),[o,n]),c=h.useMemo((()=>"hasValue"!==a.state||null==a.contents),[a]);return e(P,{className:"flex w-full",content:c?"Select a part and apply a color to enable opacity":`${Math.floor(l/Zt*100)}%`,placement:"top",children:e(VertexSlider,{"data-testid":"scene-item-adjustments-opacity-slider",leftLabel:"0%",rightLabel:"100%",disabled:c,value:null!=l?l:Zt,step:5,min:0,max:Zt,onValueChange:e=>{n.updateOpacity(e.detail.value),n.apply(),null==t||t(e.detail.value)},onValueInput:r})})};function VertexMaterialControls({onApplyMaterial:i,onApplyMaterialToAll:a,onApplyOpacity:l}){const o=useSceneItemMaterialActions(),r=s(Et);return f.useEffect((()=>{o.clearCurrentColor(),o.clearCurrentOpacity()}),[null==r?void 0:r.id]),t(n,{children:[t("div",{className:"flex flex-col",children:[e("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Color"}),t("div",{className:"flex items-center gap-2",children:[e(VertexSceneItemMaterialColorPicker,{onApply:i}),e(VertexSceneItemMaterialApplyAll,{onApplyAll:a})]})]}),e("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Opacity"}),e(VertexSceneItemMaterialOpacitySlider,{onApply:l}),e(SceneItemMaterialApplyAllConfirmationDialog,{})]})}const ResetButton=({id:n,tooltip:i,children:a})=>{const[l,o]=f.useState(!1);return e("div",{className:"ml-auto",children:t(I,{className:"flex items-stretch h-full","data-testid":`reset-button-dropdown-menu-${n}`,placement:"bottom-end",onMenuOpened:()=>o(!0),onMenuClosed:()=>o(!1),children:[e("div",{slot:"anchor",className:"flex items-center h-full",children:e(P,{content:i,disabled:l,placement:"bottom",children:t(M,{className:G("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-${n}`,variant:"plaintext",children:[e(V,{className:"px-0.5",name:"reset",size:"sm"}),e(V,{name:"chevron-down",size:"sm"})]})})}),e("div",{className:"whitespace-nowrap",children:a})]})})},VertexSceneItemMaterialClear=({onClear:n,onClearAll:i})=>{const a=useSceneItemMaterialActions(),l=s(_t);return e("div",{className:"ml-auto",children:t(ResetButton,{id:"materials",tooltip:"Clear Materials",children:[e("div",{className:"pt-1"}),e(R,{"data-testid":"clear-selected-materials",onClick:()=>{a.clear(),null==n||n()},disabled:!l,children:"Clear selected materials"}),e(R,{"data-testid":"clear-all-materials",onClick:()=>{a.clearAll(),null==i||i()},children:"Clear all materials"})]})})};function VertexMaterialPanelSection({onClearMaterial:n,onClearAllMaterials:i,onApplyMaterial:a,onApplyMaterialToAll:l,onApplyOpacity:o}){return e(PanelSection,{header:t("div",{className:"flex items-center text-base",children:["Material",e(VertexSceneItemMaterialClear,{onClear:n,onClearAll:i})]}),children:e(VertexMaterialControls,{onApplyMaterial:a,onApplyMaterialToAll:l,onApplyOpacity:o})})}const cn="#ffff00",dn=35,un=1,mn=l({key:"selectionHighlightingSelectedColor",default:cn}),pn=l({key:"selectionHighlightingSelectedOpacity",default:dn}),gn=l({key:"selectionHighlightingSelectedLineThickness",default:1}),VertexSelectionHighlightingColorPicker=({onUpdate:t})=>{const[n,i]=r(mn);return e(VertexColorPicker,{"data-testid":"selection-highlighting-color-picker",value:n,onValueChanged:e=>{null==t||t(e.detail)},onInput:e=>i(e)})},VertexSelectionHighlightingLineThicknessSlider=({onUpdate:t})=>{const[n,i]=r(gn);return e(VertexSlider,{id:"selection-highlighting-line-thickness","data-testid":"selection-highlighting-line-thickness-slider",leftLabel:"Off",rightLabel:"Thick",min:0,max:3,step:.5,value:n,valueLabelDisplay:"auto",onValueInput:e=>{i(e.detail.value)},onValueChange:e=>{null==t||t(e.detail.value)}})},VertexSelectionHighlightingOpacitySlider=({onUpdate:t})=>{const[n,i]=r(pn);return e(VertexSlider,{id:"selection-highlighting-opacity","data-testid":"selection-highlighting-opacity-slider",leftLabel:"0%",rightLabel:"100%",min:0,max:100,step:5,value:n,valueLabelDisplay:"auto",onValueInput:e=>{i(e.detail.value)},onValueChange:e=>{null==t||t(e.detail.value)}})};function VertexSelectionHighlightingControls({onUpdateSelectionHighlightColor:i,onUpdateSelectionHighlightOpacity:a,onUpdateSelectionHighlightLineThickness:l}){return t(n,{children:[e("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Color"}),e(VertexSelectionHighlightingColorPicker,{onUpdate:i}),e("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Opacity"}),e(VertexSelectionHighlightingOpacitySlider,{onUpdate:a}),e("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Line Thickness"}),e(VertexSelectionHighlightingLineThicknessSlider,{onUpdate:l})]})}const VertexSelectionHighlightingReset=({onReset:t})=>{const[n,i]=r(mn),[a,l]=r(pn),[o,s]=r(gn),c=undefined;return e("div",{className:"ml-auto",children:e(P,{content:"Reset Selection Highlighting",children:e(E,{"data-testid":"selection-highlighting-reset",iconName:"reset",iconSize:"sm",onClick:()=>{i(cn),l(dn),s(1),null==t||t()},disabled:!(n!==cn||a!==dn||1!==o)})})})};function VertexSelectionHighlightingPanelSection({onResetSelectionHighlighting:n,onUpdateSelectionHighlightColor:i,onUpdateSelectionHighlightOpacity:a,onUpdateSelectionHighlightLineThickness:l}){return e(PanelSection,{header:t("div",{className:"flex items-center text-base",children:["Selection Highlighting",e(VertexSelectionHighlightingReset,{onReset:n})]}),children:e(VertexSelectionHighlightingControls,{onUpdateSelectionHighlightColor:i,onUpdateSelectionHighlightOpacity:a,onUpdateSelectionHighlightLineThickness:l})})}const VertexViewerBackgroundColorPicker=({onUpdate:t})=>{const[n,i]=r(rn);return e(VertexColorPicker,{"data-testid":"viewer-background-color-picker",value:n,onValueChanged:e=>{null==t||t(e.detail)},onInput:e=>i(e)})};function VertexViewerBackgroundControls({onUpdateViewerBackgroundColor:i}){return t(n,{children:[e("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Color"}),e(VertexViewerBackgroundColorPicker,{onUpdate:i})]})}const VertexViewerBackgroundReset=({onReset:t})=>{const[n,i]=r(rn),a=undefined;return e("div",{className:"ml-auto",children:e(P,{content:"Reset Background Color",children:e(E,{"data-testid":"viewer-background-reset",iconName:"reset",iconSize:"sm",onClick:()=>{i(sn),null==t||t()},disabled:!(n!==sn)})})})};function VertexViewerBackgroundPanelSection({onResetViewerBackgroundColor:n,onUpdateViewerBackgroundColor:i}){return e(PanelSection,{header:t("div",{className:"flex items-center text-base",children:["Viewer Background",e(VertexViewerBackgroundReset,{onReset:n})]}),children:e(VertexViewerBackgroundControls,{onUpdateViewerBackgroundColor:i})})}const isInputElement=e=>{const t=e instanceof HTMLElement&&"VERTEX-AUTO-RESIZE-TEXTAREA"===e.tagName,n=e instanceof HTMLElement&&"VERTEX-TEXTFIELD"===e.tagName,i=e instanceof HTMLElement&&"true"===e.contentEditable,a=e instanceof HTMLElement&&"VERTEX-SCENE-TREE-SEARCH"===e.tagName,l=e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement,o=e instanceof HTMLElement&&"VERTEX-VIEWER-PIN-TOOL"===e.tagName,s=e instanceof HTMLElement&&"VERTEX-VIEWER-TRANSFORM-WIDGET"===e.tagName;return t||n||i||a||l||o||s},useRecoilReducer=({reducer:e,atom:t})=>{const n=undefined,i=undefined;return[s(t),useRecoilReducerDispatch({reducer:e,atom:t})]},useRecoilReducerDispatch=({reducer:e,atom:t})=>{const n=undefined;return a((({set:n})=>async i=>{n(t,(t=>e(t,i)))}),[])},hn=l({key:"keyBindings",default:{applyBindings:[],bindings:{},pressed:{}}});function reducer(e,t){var n,i,a,l;switch(t.type){case"push-key-binding":const o=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!==(i=e.bindings[t.binding.keyBind])&&void 0!==i?i:[],t.binding]})});case"remove-key-binding":const s=undefined;return null==(null===(a=e.bindings[t.binding.keyBind])||void 0===a?void 0:a.find((e=>e.id===t.binding.id)))?e:Object.assign(Object.assign({},e),{bindings:Object.assign(Object.assign({},e.bindings),{[t.binding.keyBind]:(null!==(l=e.bindings[t.binding.keyBind])&&void 0!==l?l:[]).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:hn});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 i;return null!=e.keyBind&&null!=n&&(null===(i=e.keyBind)||void 0===i?void 0:i.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();f.useEffect((()=>{const i=p.create();return n({type:"add-apply-key-binding",binding:Object.assign(Object.assign({},e),{id:i,active:null!=e.keyBind&&allPressed(e.keyBind,t.pressed)})}),()=>{n({type:"remove-apply-key-binding",id:i})}}),[e.fn,e.off,e.keyBind,e.repeat])},useStackKeyBinding=(e,t=[])=>{const[,n]=useKeyBindingState();f.useEffect((()=>{const t=null==e.addPredicate||e.addPredicate(),i=null!=e.cancelPredicate&&e.cancelPredicate();t&&n({type:"push-key-binding",binding:e}),i&&n({type:"remove-key-binding",binding:e})}),t)},useKeyBindings=({keydownRepeatInterval:e=25,keydownIgnorePredicate:t=isInputElement}={})=>{const[n,i]=useKeyBindingState(),a=f.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(),i({type:"remove-key-binding",binding:a}))}))}),[n]);f.useEffect((()=>{const handleKeyDown=e=>{if(!e.repeat&&!t(e.target)){i({type:"set-key-pressed",key:e.key,pressed:!0}),a(e.key);const t=Object.assign(Object.assign({},n.pressed),{[e.key]:!0}),l=matchingSingleFnBindings(n.applyBindings,t,e.key),o=matchingOffBindings(n.applyBindings,t,e.key);(l.length>0||o.length>0)&&e.preventDefault()}},handleKeyUp=e=>{i({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)}}),[a,n.applyBindings,n.pressed]),f.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]),f.useEffect((()=>{const t=n.applyBindings.filter((e=>e.repeat&&null!=e.keyBind&&allPressed(e.keyBind,n.pressed))).map((e=>e.fn));if(t.length>0){const n=setInterval((()=>{t.forEach((e=>e()))}),e);return()=>{clearInterval(n)}}return()=>{}}),[n.applyBindings,n.lastPressed])},VertexBoxSelectionButton=()=>{const t=useBoxSelectionActions(),n=s(lt);return useStackKeyBinding({id:"ExitBoxSelection",keyBind:"Escape",fn:t.disable,addPredicate:()=>n,cancelPredicate:()=>!n},[n]),e(P,{content:"Box Selection",children:e(E,{iconName:"box-cursor",iconColor:n?"primary":"secondary","data-testid":"viewer-toolbar-enable-box-selection-button",onClick:n?t.disable:t.enable})})},fn=1,VertexResizableContent=n=>{var{className:i,style:a,displayShadow:l,heading:o,id:s,initialScale:r,placement:c="left",children:d,onResize:u}=n,m=__rest(n,["className","style","displayShadow","heading","id","initialScale","placement","children","onResize"]);const p="left"===c||"right"===c,g="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 h=null!=r?r:1;return e(L,Object.assign({id:s,"data-testid":`resizable-content-position-${c}`,className:G(i,"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&&l,"border-l min-w-75 max-w-half":"right"===c,"sidebar-shadow-left":"right"===c&&l,"border-t bottom-0 fixed":"top"===c,"min-h-12 sheet":g}),style:Object.assign({maxHeight:"top"===c?window.innerHeight:void 0},a),initialHorizontalScale:p?r:void 0,initialVerticalScale:g?h:void 0,horizontalDirection:getHorizontalResizeDirection(),verticalDirection:getVerticalResizeDirection(),position:"right"===c||"top"===c?"absolute":"relative",onResizeEnd:()=>null==u?void 0:u()},m,{children:t("div",{className:"flex flex-col h-full w-full",children:["top"===c&&e("div",{className:"flex justify-center w-full",children:e("div",{className:"block md:hidden w-20 h-0.5 mt-0.5 bg-neutral-600 rounded"})}),o,e("div",{className:G("w-full flex flex-col h-0 flex-grow",{"right-0":"right"===c}),children:d})]})}))};function useDefaultKeybindings(){useApplyKeyBinding({fn:useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromiseRequired(he),n={milliseconds:500},i=await t();await(null==i?void 0:i.camera().viewAll().render({animation:n}))})),keyBind:"f"})}function useLongPress({target:e,callback:t,delay:n=500,onMovement:i}){const[a,l]=h.useState(),[o,s]=h.useState();h.useEffect((()=>{const handleTouchStart=e=>{const i=e;null!=i.touches&&1===i.touches.length&&(null!=a&&clearTimeout(a),s(A.create(i.touches[0].clientX,i.touches[0].clientY)),l(setTimeout((()=>null==t?void 0:t(i)),n)))},handleTouchMove=e=>{const t=e;null!=t.touches&&t.touches.length>0&&null!=a&&null!=o&&A.distance(o,A.create(t.touches[0].clientX,t.touches[0].clientY))>=2&&(clearTimeout(a),null==i||i())},handleTouchEnd=()=>{null!=a&&clearTimeout(a)};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,a,o])}function asBooleanAttribute(e){return!!e||void 0}const VertexContextMenu=({targetElement:t,menuType:n,disableBackdrop:i,openPredicate:a,onOpen:l,onClose:o,children:r})=>{const c=useContextMenuActions(),d=s(Qe),u=s(at),m=f.useMemo((()=>["bottom-end","top-start","top-end","right","left"]),[]),p=d===n;useStackKeyBinding({id:"ContextMenu",keyBind:"Escape",fn:c.clearActiveContextMenu,addPredicate:()=>null!=d&&d===n,cancelPredicate:()=>null==d},[d]);const g=f.useMemo((()=>null!=t?t:null!=a?window:void 0),[t,a]);return useLongPress({target:g,callback:e=>c.longPress(e,n,a,l),onMovement:()=>c.clearActiveContextMenu()}),f.useEffect((()=>{const handleWindowPointerDown=e=>{const t=undefined;if(!targetWithinMenu(e)&&2!==e.buttons&&d===n){const t=targetShouldSkipNextHit(e);c.clearActiveContextMenu(t)}};if(i)return window.addEventListener("pointerdown",handleWindowPointerDown),()=>{window.removeEventListener("pointerdown",handleWindowPointerDown)}}),[i,n,d]),f.useEffect((()=>{const handlePointerDown=e=>{c.pointerDown(e)},handlePointerUp=e=>{c.pointerUp(e,n,a,l)},handleContextMenu=e=>c.contextMenu(e,a);return null==g||g.addEventListener("pointerdown",handlePointerDown),null==g||g.addEventListener("pointerup",handlePointerUp),null==g||g.addEventListener("contextmenu",handleContextMenu),()=>{null==g||g.removeEventListener("pointerdown",handlePointerDown),null==g||g.removeEventListener("pointerup",handlePointerUp),null==g||g.removeEventListener("contextmenu",handleContextMenu)}}),[t,n,a]),e("div",{className:G({hidden:!p}),children:e(_,{"data-testid":`${n}-context-menu`,open:asBooleanAttribute(p),position:u,fallbackPlacements:m,backdrop:!i,onMenuClosed:()=>{c.clearActiveContextMenu(),null==o||o()},children:e("div",{className:"pt-1",children:r})})})},VertexFitSelectedMenuItem=()=>{const n=s(Pt),i=s(Vt),a=useViewerCameraActions();return t(R,{"data-testid":"fit-selected-menu-option",onClick:()=>{null!=(null==i?void 0:i.boundingBox)&&a.flyToByBoundingBox(i.boundingBox)},disabled:asBooleanAttribute(0===n.length),children:[e(V,{slot:"icon",name:"fit-selected",size:"sm"}),e("div",{className:"pl-2",children:"Fit Selected"})]})},VertexFlyToMenuItem=()=>{const n=useViewerCameraActions(),i=s(nt);return t(R,{"data-testid":"fly-to-part-menu-option",onClick:()=>{var e;const t=undefined,a=contextMenuItemIsRow(i)?null===(e=null==i?void 0:i.node.id)||void 0===e?void 0:e.hex:null==i?void 0:i.id;null!=a&&n.flyToById(a)},disabled:asBooleanAttribute(null==i),children:[e(V,{slot:"icon",name:"paper-airplane",size:"sm"}),e("div",{className:"pl-2",children:"Fly To"})]})};function useSceneItemsOperations(){const e=s(de),t=undefined,n=undefined,i=undefined,a=undefined,l=undefined,o=undefined;return{sceneItemsOperation:f.useCallback((async(t,n)=>{const i=await(null==e?void 0:e.scene());null==n?await(null==i?void 0:i.items((e=>t(e.where((e=>e.all()))))).execute()):n.length>0&&await(null==i?void 0:i.items((e=>t(e.where((e=>e.withItemIds(n)))))).execute())}),[e]),showOnlySelected:f.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:f.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:f.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:f.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:f.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 n=useSceneItemsOperations();return t(R,{"data-testid":"hide-all-menu-option",onClick:()=>{n.sceneItemsOperation((e=>e.hide()))},children:[e(V,{slot:"icon",name:"visibility-hidden",size:"sm"}),e("div",{className:"pl-2",children:"Hide All Parts"})]})},VertexHidePartMenuItem=()=>{const n=s(nt),i=useSceneItemsOperations();return t(R,{"data-testid":"hide-menu-option",onClick:()=>{var e;const t=undefined,a=contextMenuItemIsRow(n)?null===(e=null==n?void 0:n.node.id)||void 0===e?void 0:e.hex:n.id;null!=a&&i.sceneItemsOperation((e=>e.hide()),[a])},disabled:asBooleanAttribute(null==n),children:[e(V,{slot:"icon",name:"visibility-hidden",size:"sm"}),e("div",{className:"pl-2",children:"Hide Part"})]})},VertexHideSelectedMenuItem=()=>{const n=s(Pt),i=useSceneItemsOperations();return t(R,{"data-testid":"hide-selected-menu-option",onClick:()=>i.hideSelected(),disabled:asBooleanAttribute(0===n.length),children:[e(V,{slot:"icon",name:"visibility-hidden",size:"sm"}),e("div",{className:"pl-2",children:"Hide Selected"})]})},VertexShowAllMenuItem=()=>{const n=useSceneItemsOperations();return t(R,{"data-testid":"show-all-menu-option",onClick:()=>{n.sceneItemsOperation((e=>e.show()))},children:[e(V,{slot:"icon",name:"visibility-visible",size:"sm"}),e("div",{className:"pl-2",children:"Show All Parts"})]})},VertexShowOnlyMenuItem=()=>{const n=s(nt),i=useSceneItemsOperations();return t(R,{"data-testid":"show-only-menu-option",onClick:()=>{var e;const t=undefined,a=contextMenuItemIsRow(n)?null===(e=null==n?void 0:n.node.id)||void 0===e?void 0:e.hex:null==n?void 0:n.id;null!=a&&i.showOnlyItem(a)},disabled:asBooleanAttribute(null==n),children:[e(V,{slot:"icon",name:"visibility-visible",size:"sm"}),e("div",{className:"pl-2",children:"Show Only Part"})]})},VertexShowOnlySelectedMenuItem=()=>{const n=s(Pt),i=useSceneItemsOperations();return t(R,{"data-testid":"show-only-selected-menu-option",onClick:()=>i.showOnlySelected(),disabled:asBooleanAttribute(0===n.length),children:[e(V,{slot:"icon",name:"visibility-visible",size:"sm"}),e("div",{className:"pl-2",children:"Show Only Selected"})]})};l({key:"sceneTreeLoaderVisible",default:!1});const vn=l({key:"sceneTreeElement",default:void 0}),yn=l({key:"sceneTreeWidth",default:void 0});function useSceneTreeActions(){const e=useSelectionActions(),t=useViewerCameraActions();return{toggleSelection:useActionCallback((({snapshot:t})=>async(n,i,a)=>{var l,o;if(!n.defaultPrevented&&0===n.button&&(n.altKey||((n.ctrlKey||n.metaKey)&&i.selected?a.deselectItem(i):i.selected?a.selectItem(i,{recurseParent:!0}):i.selected||a.selectItem(i,{append:n.ctrlKey||n.metaKey,range:n.shiftKey})),null!=i.id)){const a=await t.getPromise(Et);e.syncSelection({id:null===(l=i.id)||void 0===l?void 0:l.hex,ancestors:null!==(o=null==a?void 0:a.ancestors)&&void 0!==o?o:[]},{selected:!n.metaKey&&!n.ctrlKey||!i.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 i;const a=await e.getPromise(vn),l=await(null==a?void 0:a.getRowAtClientY(n));null!=(null===(i=null==l?void 0:l.node.id)||void 0===i?void 0:i.hex)&&await t.flyToById(l.node.id.hex)})),setContextMenuItem:useActionCallback((({set:e,snapshot:t})=>async n=>{const i=await t.getPromise(vn),a=await(null==i?void 0:i.getRowAtClientY(n));e(nt,a)}))}}o({key:"sceneTreeController",get:({get:e})=>{var t;return null===(t=e(vn))||void 0===t?void 0:t.controller},dangerouslyAllowMutability:!0});const VertexGhostSelectedMenuItem=()=>{const n=s(Pt),i=useSceneItemsOperations();return t(R,{"data-testid":"ghost-selected-menu-option",onClick:()=>i.ghostSelected(),disabled:asBooleanAttribute(0===n.length),children:[e(V,{slot:"icon",name:"visibility-partial",size:"sm"}),e("div",{className:"pl-2",children:"Ghost Selected"})]})},VertexUnghostSelectedMenuItem=()=>{const n=s(Pt),i=useSceneItemsOperations();return t(R,{"data-testid":"unghost-selected-menu-option",onClick:()=>i.unGhostSelected(),disabled:asBooleanAttribute(0===n.length),children:[e(V,{slot:"icon",name:"visibility-visible",size:"sm"}),e("div",{className:"pl-2",children:"Unghost Selected"})]})},DefaultSceneTreeContextMenu=()=>t("div",{className:"w-56",children:[e(VertexHideSelectedMenuItem,{}),e(VertexHideAllMenuItem,{}),e(VertexShowOnlyMenuItem,{}),e(VertexShowOnlySelectedMenuItem,{}),e(VertexShowAllMenuItem,{}),e(VertexGhostSelectedMenuItem,{}),e(VertexUnghostSelectedMenuItem,{}),e(D,{}),e(VertexFitSelectedMenuItem,{}),e(VertexFlyToMenuItem,{})]}),VertexSceneTreeContextMenu=({children:t})=>{const n=useSceneTreeActions(),i=s(vn),a=undefined;return e(VertexContextMenu,{menuType:"scene-tree",targetElement:i,onOpen:async(e,t)=>{const i=e;await n.setContextMenuItem(i.clientY)},disableBackdrop:!0,children:null!=t&&!1!==t?t:e(DefaultSceneTreeContextMenu,{})})},DefaultViewerContextMenu=()=>t("div",{className:"w-56",children:[e(VertexHidePartMenuItem,{}),e(VertexHideSelectedMenuItem,{}),e(VertexHideAllMenuItem,{}),e(VertexShowOnlyMenuItem,{}),e(VertexShowOnlySelectedMenuItem,{}),e(VertexShowAllMenuItem,{}),e(VertexGhostSelectedMenuItem,{}),e(VertexUnghostSelectedMenuItem,{}),e(D,{}),e(VertexFitSelectedMenuItem,{}),e(VertexFlyToMenuItem,{})]}),VertexViewerContextMenu=({children:t})=>{const n=null!=t&&!1!==t,i=f.useCallback((e=>e.target instanceof HTMLElement&&"vertex-viewer"===e.target.id),[]);return e(VertexContextMenu,{menuType:"viewer",disableBackdrop:!0,openPredicate:i,children:n?t:e(DefaultViewerContextMenu,{})})},bn=undefined,wn=l({key:"sceneItemGhostingSelectedOpacity",default:35}),Cn=d({key:"appliedItemPhantomState",default:void 0}),xn=l({key:"appliedItemPhantomStateIds",default:[]}),Sn=o({key:"sceneItemGhostingLastSelectedPhantom",get:({get:e})=>{var t;const n=e(Et);return null!=n&&(null!==(t=e(Cn(n.id)))&&void 0!==t&&t)}}),VertexSceneItemGhostingOpacitySlider=({onApply:t})=>{const[n,i]=r(wn);return e(VertexSlider,{id:"phantom-opacity","data-testid":"phantom-opacity-slider",leftLabel:"0%",rightLabel:"100%",min:0,max:100,step:5,value:n,valueLabelDisplay:"auto",onValueInput:e=>{i(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(xn)).forEach((e=>t(Cn(e)))),t(xn)}));return{setPhantomState:useActionCallback((({snapshot:t,set:n})=>async i=>{const a=await t.getPromise(Pt);a.forEach((e=>n(Cn(e),i))),n(xn,(e=>[...e,...a])),await e.execute(kt.SET_PHANTOM_SELECTED_ITEMS,(e=>e.where((e=>e.withSelected())).setPhantom(i)))})),clearPhantomState:useActionCallback((({snapshot:t,set:n,reset:i})=>async()=>{const a=await t.getPromise(Pt);a.forEach((e=>i(Cn(e)))),n(xn,(e=>e.filter((e=>!a.includes(e))))),await e.execute(kt.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(kt.CLEAR_PHANTOM_ALL,(e=>e.where((e=>e.all())).clearPhantom()),(e=>e.where((e=>e.withSelected())).select()))})),resetAllPhantomState:t}},VertexSceneItemGhostingToggle=({onApply:t})=>{const n=useSceneItemPhantomActions(),i=s(_t),a=u(Sn);return e(P,{content:"Select a part to display as ghost",disabled:i,children:e(O,{className:"flex items-center","data-testid":"phantom-state-toggle",variant:"switch",disabled:!i,checked:"hasValue"===a.state&&a.contents,onValueChanged:async e=>{await n.setPhantomState(e.detail),null==t||t(e.detail)}})})};function VertexGhostingControls({onApplyGhostingChange:i,onApplyOpacity:a}){return t(n,{children:[t("div",{className:"flex items-center py-3",children:[e(VertexSceneItemGhostingToggle,{onApply:i}),e("span",{className:"pl-4 text-sm text-neutral-700",children:"Display as Ghost"})]}),e("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Global Ghost Opacity"}),e(VertexSceneItemGhostingOpacitySlider,{onApply:a})]})}const VertexSceneItemGhostingClear=({onClear:n,onClearAll:i})=>{const a=useSceneItemPhantomActions(),l=s(Sn);return e("div",{className:"ml-auto",children:t(ResetButton,{id:"phantom",tooltip:"Clear Ghosting",children:[e("div",{className:"pt-1"}),e(R,{"data-testid":"reset-selected-phantom",onClick:async()=>{await a.clearPhantomState(),null==n||n()},disabled:!l,children:"Clear ghosting for selected"}),e(R,{"data-testid":"reset-all-phantom",onClick:async()=>{await a.clearAllPhantomState(),null==i||i()},children:"Clear ghosting for all"})]})})};function VertexGhostingPanelSection({onClearGhostState:n,onClearAllGhostState:i,onApplyGhostingChange:a,onApplyOpacity:l}){return e(PanelSection,{header:t("div",{className:"flex items-center text-base",children:["Ghosting",e(VertexSceneItemGhostingClear,{onClear:n,onClearAll:i})]}),children:e(VertexGhostingControls,{onApplyGhostingChange:a,onApplyOpacity:l})})}function VertexMeasurementContextMenu({onDelete:n}){const i=s(tt);return e(VertexContextMenu,{menuType:"measurement",openPredicate:e=>e.target instanceof HTMLElement&&"VERTEX-VIEWER-MEASUREMENT-DISTANCE"===e.target.tagName,children:t(R,{"data-testid":"measurement-delete",onClick:()=>null!=i&&n(i.id),children:[e(V,{slot:"icon",name:"delete",size:"sm"}),e("div",{className:"pl-2",children:"Delete"})]})})}const An=l({key:"lengthUnit",default:"cm"}),kn=l({key:"decimalPlace",default:"2"});var Tn,Pn;!function(e){e.mm="millimeters",e.cm="centimeters",e.m="meters",e.in="inches",e.ft="feet"}(Tn||(Tn={})),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"}(Pn||(Pn={}));const convertFrom=(e,t)=>{const n=undefined;return e/Pn[t]},convertTo=(e,t)=>{const n=undefined;return e*Pn[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 useDockedPlacement(e,t){const[n,i]=h.useState(A.create(0,0));return h.useLayoutEffect((()=>{if(null!=e){const n=e.getBoundingClientRect(),a=A.create(n.left,n.bottom),l=A.create(n.right,n.bottom);i("left"===t?a:l)}}),[e,t]),n}function VertexMeasurementDetails({placement:n}){const i=useMeasurementActions(),a=s(de),l=s(ue),o=useDockedPlacement(null!=a?a:null,n),r=s(yt),c=s(bt),d=s(wt),u=s(Ct),m=s(An),p=s(kn);return e(B,{className:"z-popover",boundaryPadding:16,boundarySelector:`#${l}`,position:o,children:t("div",{className:"flex flex-col leading-4 min-w-40",children:[t("div",{className:"pb-2 flex justify-between",children:[e("div",{className:"w-full",children:"Measurement"}),e("div",{className:G("-mt-1 relative",{hidden:!u}),children:e(P,{content:"Reset",placement:"left-start",children:e(E,{"data-testid":"measurement-details-reset",iconName:"reset",iconSize:"sm",onClick:i.resetMeasurement})})})]}),e($,{"data-testid":"measurement-details-viewer-measurement-details",className:G("gap-y-1.5 text-xs",{hidden:null==r}),measurementOutcome:r,measurementOverlays:c,distanceUnits:toUnitType(m),fractionalDigits:parseInt(p,10)}),e("div",{"data-testid":"measurement-details-message",className:G("text-xs",{hidden:null==d}),children:d})]})})}function useCallbackRef(e){var t;const[n,i]=f.useState((t=void 0,null)),a=undefined;return{element:n,callback:f.useCallback((e=>i(e)),[])}}function VertexPointToPointMeasurement({detailsPlacement:i,onPointToPointMeasurementChange:a}){const l=useMeasurementActions(),o=s(de),r=s(st),c=s(ct),d=s(An),u=s(kn),{callback:m,element:p}=useCallbackRef();usePointToPointMeasurement(p);const g=b((e=>{const t={start:e.detail.start,end:e.detail.end,invalid:!e.detail.valid};l.setEditedPointToPointMeasurement(t),null==a||a(t)}),[l]);return r?t(n,{children:[e(Y,{"data-testid":"point-to-point-measurement",ref:m,viewer:null!=o?o: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(d),fractionalDigits:parseInt(u,10),showAxisReferenceLines:!0,onEditEnd:g}),e(VertexMeasurementDetails,{placement:i}),e(VertexMeasurementContextMenu,{onDelete:l.resetMeasurement})]}):e(n,{})}function VertexPointToPointMeasurementTool(){const t=useMeasurementActions(),n=s(st);return useStackKeyBinding({id:"ExitMeasurement",keyBind:"Escape",fn:t.disableEditMeasurement,addPredicate:()=>n,cancelPredicate:()=>!n},[n,t]),e(P,{content:"Point to Point Measurement",children:e(E,{iconName:"tape-measure","data-testid":"viewer-toolbar-point-to-point-measurement-button",iconColor:n?"primary":"secondary",onClick:t.toggleEditPointToPointMeasurement})})}const En=l({key:"viewerToolkitSdkConfig",default:void 0}),VertexPreciseMeasurement=({detailsPlacement:i,onEntitiesChanged:a,onOutcomeChanged:l})=>{var o,r,c,d;const u=s(de),m=s(En),p=s(ut),{callback:g,element:h}=useCallbackRef();return usePreciseMeasurementModel(h,a,l),p?t(n,{children:[e(X,{"data-testid":"precise-measurement-viewer-tool",ref:g,viewer:null!=u?u:void 0,config:JSON.stringify({network:{apiHost:null===(o=null==m?void 0:m.network)||void 0===o?void 0:o.apiHost,renderingHost:null===(r=null==m?void 0:m.network)||void 0===r?void 0:r.renderingHost,sceneTreeHost:null===(c=null==m?void 0:m.network)||void 0===c?void 0:c.sceneTreeHost,sceneViewHost:null===(d=null==m?void 0:m.network)||void 0===d?void 0:d.sceneViewHost}})}),e(VertexMeasurementDetails,{placement:i})]}):e(n,{})};function VertexPreciseMeasurementTool(){const t=useMeasurementActions(),n=s(ut);return e(P,{content:"Precise Measurement",children:e(E,{iconName:"ruler","data-testid":"viewer-toolbar-precise-measurement-button",iconColor:n?"primary":"secondary",onClick:t.toggleEditPreciseMeasurement})})}function VertexApplicationMessages(){const i=s(At),a=s(St);return t(n,{children:[null!=i&&e(H,{className:"z-[16000]",duration:i.duration,open:!0,content:i.message,type:i.type},i.id),null!=a&&e(j,{placement:"bottom-left",className:"z-[16000]",duration:a.duration,open:!0,content:a.message,type:a.type},a.id)]})}const targetIsElement=(e,t)=>e instanceof Element&&e.tagName===t;function useRecoilRef({state:e}){const t=undefined;return a((({set:t})=>n=>{t(e,n)}),[])}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 VertexSceneTreeCollapseAll=()=>{const t=s(vn);return e(P,{className:"w-auto",content:"Collapse All",placement:"top",children:e(V,{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=s(vn);return e(P,{className:"w-auto",content:"Expand All",placement:"top",children:e(V,{size:"sm","data-testid":"expand-all-icon",className:"h-6 w-6 hover:bg-neutral-300 rounded cursor-pointer",name:"expand-all",onClick:()=>{null==t||t.expandAll()}})})};function VertexSceneTreeToolbar(){return e(q,{className:"h-10 border-b border-neutral-300 box-border",children:t("div",{className:"flex flex-shrink-0 w-full text-neutral-700 items-center gap mx-2",children:[e(VertexSceneTreeExpandAll,{}),e(VertexSceneTreeCollapseAll,{})]})})}const VertexSceneTreeHeader=({children:i})=>{const a=undefined;return e("div",{slot:"header",className:"flex flex-col",children:null!=i&&!1!==i?i:t(n,{children:[e(Z,{className:"border-b border-neutral-300"}),e(VertexSceneTreeToolbar,{})]})})},On={binding:"{{row.node.name}}",label:"Name",metadataKeyName:"VERTEX_SCENE_ITEM_NAME"},Mn=o({key:"sceneTreeColumnsActiveColumns",get:({get:e})=>{const t=[],n=e(yn);if(null!=n&&n>0){const e=1/(t.length+1)*n,i=(n-e)/t.length;return{Name:Object.assign(Object.assign({},On),{initialWidth:e,minWidth:i})}}return{Name:On}}}),In=o({key:"sceneTreeColumnsActiveColumnNames",get:({get:e})=>Object.keys(e(Mn))}),VertexSceneTreeTableLayout=n=>{const i=s(Mn),a=s(In),l=[];return e(J,Object.assign({"data-testid":"scene-tree-table-layout"},n,{children:a.map(((n,o)=>{var s;const r=i[n],c=null!==(s=l[o])&&void 0!==s?s:r.initialWidth;return t(Q,{"data-testid":`scene-tree-table-column-${o}`,initialWidth:c,minWidth:r.minWidth,children:[e("template",{slot:"header",dangerouslySetInnerHTML:{__html:`\n <div class="text-sm text-neutral-800 my-2">\n <div class="${G("truncate",{"pl-2":0===o,"pr-2":o===a.length-1})}">\n ${r.label}\n </div>\n </div>\n `}}),e("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===o?"expand-toggle":""}\n ${o===a.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="${o!==a.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=a=>{var{id:l,font:o,backgroundColors:r,children:c,style:d,onPointerDown:u,onClick:m,onToggleSelection:p,onToggleExpansion:g,onToggleVisibility:h,className:f,rowData:v}=a,b=__rest(a,["id","font","backgroundColors","children","style","onPointerDown","onClick","onToggleSelection","onToggleExpansion","onToggleVisibility","className","rowData"]);const w=s(En),C=useSelectionActions(),S=useSceneTreeActions(),A=s(de),k=useRecoilRef({state:vn}),T=null!=c&&!1!==c,wrappedExpansionHandler=(e,t,n)=>{S.toggleExpansion(e,t,n),null==g||g(e,t,n)},wrappedSelectionHandler=(e,t,n)=>{S.toggleSelection(e,t,n),null==p||p(e,t,n)},wrappedVisibilityHandler=(e,t,n)=>{S.toggleVisibility(e,t,n),null==h||h(e,t,n)},handleClick=e=>{e.altKey&&S.flyToRow(e.clientY),null==m||m(e)},handlePointerDown=e=>{targetIsElement(e.target,"VERTEX-SCENE-TREE-TABLE-COLUMN")&&C.clearSelection(),null==u||u(e)};return e("div",{className:G("flex flex-col w-full h-full",f),children:e("div",{className:"flex group h-full",children:e(ee,Object.assign({id:null!=l?l:"vertex-scene-tree","data-testid":"vertex-scene-tree",config:w,ref:k,className:"flex-1",style:Object.assign(Object.assign(Object.assign({},styleFromOptionalFont(o)),styleFromOptionalBackgroundColors(r)),d),onConnectionError:e=>{i.error("Scene Tree Connection Error: ",e.detail)},viewer:A,onPointerDown:handlePointerDown,onClick:handleClick,rowData:e=>{var t;const n=null!==(t=null==v?void 0:v(e))&&void 0!==t?t:{};return Object.assign({handleExpansion:wrappedExpansionHandler,handleSelection:wrappedSelectionHandler,handleVisibility:wrappedVisibilityHandler},n)}},b,{children:T?c:t(n,{children:[e(VertexSceneTreeHeader,{}),e(VertexSceneTreeTableLayout,{}),e(VertexSceneTreeContextMenu,{})]})}))})})},VertexDecimalPlaceSelector=({onApply:n})=>{const[i,a]=r(kn);return t(U,{"data-testid":"decimal-place-select",className:"w-24",value:i,onOptionChanged:e=>{a(e.detail),null==n||n(e.detail)},children:[e("div",{className:"py-1.5 px-3",children:"0"}),e("div",{className:"py-1.5 px-3",children:"1"}),e("div",{className:"py-1.5 px-3",children:"2"}),e("div",{className:"py-1.5 px-3",children:"3"})]})},VertexLengthUnitSelector=({onApply:n})=>{const[i,a]=r(An);return t(U,{"data-testid":"length-unit-select",className:"w-40",value:i,onOptionChanged:e=>{a(e.detail),null==n||n(e.detail)},children:[e("div",{"data-value":"cm",className:"py-1.5 px-3",children:"centimeters"}),e("div",{"data-value":"mm",className:"py-1.5 px-3",children:"millimeters"}),e("div",{"data-value":"m",className:"py-1.5 px-3",children:"meters"}),e("div",{"data-value":"in",className:"py-1.5 px-3",children:"inches"}),e("div",{"data-value":"ft",className:"py-1.5 px-3",children:"feet"})]})};function VertexUnitsControls({onUnitChange:i,onDecimalPlaceChange:a}){return t(n,{children:[t("div",{children:[e("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Length Unit"}),e(VertexLengthUnitSelector,{onApply:i})]}),t("div",{children:[e("div",{className:"pt-2 pb-2 text-sm text-neutral-700",children:"Decimals"}),e(VertexDecimalPlaceSelector,{onApply:a})]})]})}function VertexUnitsPanelSection({onUnitChange:t,onDecimalPlaceChange:n}){return e(PanelSection,{header:e("div",{className:"flex items-center text-base",children:"Units"}),children:e(VertexUnitsControls,{onUnitChange:t,onDecimalPlaceChange:n})})}const Vn=l({key:"openedPanelActivePrimaryLeft",default:void 0}),Rn=l({key:"openedPanelActivePrimaryRight",default:void 0});function usePanelActions(){return{openPrimary:useActionCallback((({set:e})=>(t,n)=>{e("left"===n?Vn:Rn,t)})),closePrimary:useActionCallback((({set:e})=>t=>{e("left"===t?Vn:Rn,void 0)}))}}function DefaultAppearancePanel(){return t("div",{className:"flex flex-col text-neutral-700 h-full overflow-y-auto",children:[e(VertexMaterialPanelSection,{}),e(VertexGhostingPanelSection,{}),e(VertexFeatureEdgesPanelSection,{}),e(VertexViewerBackgroundPanelSection,{}),e(VertexSelectionHighlightingPanelSection,{}),e(VertexCrossSectionAppearancePanelSection,{})]})}function DefaultSettingsPanel(){return e("div",{className:"flex flex-col text-neutral-700 h-full overflow-y-auto",children:e(VertexUnitsPanelSection,{})})}const VertexTransformClear=({onClear:n,onClearAll:i})=>{const a=useTransformActions(),l=s(_t);return e("div",{className:"ml-auto",children:t(ResetButton,{id:"transforms",tooltip:"Clear Transforms",children:[e("div",{className:"pt-1"}),e(R,{"data-testid":"reset-selected-transforms",onClick:async()=>{await a.clearSelectedTransforms(),null==n||n()},disabled:!l,children:"Clear selected transforms"}),e(R,{"data-testid":"reset-all-transforms",onClick:async()=>{await a.clearAllTransforms(),null==i||i()},children:"Clear all transforms"})]})})},VertexTransformManipulatorToggle=({onToggleTransformsManipulator:t})=>{const n=useTransformActions(),i=s(Dt),a=c(Kt);return e(O,{className:"flex items-center","data-testid":"transform-widget-toggle",variant:"switch",checked:i,onValueChanged:async()=>{i?(n.disableTransformWidget(),null==t||t(!1)):(a("world"),await n.enableTransformWidget(),null==t||t(!0))}})};function VertexTransformControls({onToggleTransformsManipulator:i}){return e(n,{children:t("div",{className:"flex items-center py-3",children:[e(VertexTransformManipulatorToggle,{onToggleTransformsManipulator:i}),e("span",{className:"pl-4 text-sm text-neutral-700",children:"Enable manipulator"})]})})}function VertexTransformPanelSection({onClearTransforms:n,onClearAllTransforms:i,onToggleTransformsManipulator:a}){return e(PanelSection,{header:t("div",{className:"flex items-center text-base",children:["Manual Part Transforms",e(VertexTransformClear,{onClear:n,onClearAll:i})]}),children:e(VertexTransformControls,{onToggleTransformsManipulator:a})})}function DefaultTransformsPanel(){return e("div",{className:"flex flex-col text-neutral-700 h-full overflow-y-auto",children:e(VertexTransformPanelSection,{})})}const Ln="Appearance",_n="Settings",Dn="Transforms",ViewerRightPanelHeader=()=>{const t=undefined,n=getHeading(s(Rn));return e("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("div",{className:"items-center w-full leading-6 text-md align-center font-medium text-neutral-800",children:n})})};function getHeading(e){switch(e){case"appearance":return Ln;case"settings":return _n;case"transforms":return Dn;default:return"None"}}function VertexViewerRightOpenedPanel(){const i=s(Rn),a=f.useMemo((()=>["appearance","settings","transforms"]),[]);return e(n,{children:null!=i&&a.includes(i)&&t(VertexResizableContent,{displayShadow:!0,heading:e(ViewerRightPanelHeader,{}),placement:"right",children:["appearance"===i&&e(DefaultAppearancePanel,{}),"transforms"===i&&e(DefaultTransformsPanel,{}),"settings"===i&&e(DefaultSettingsPanel,{})]})})}function Sidebar({children:t}){return e("div",{className:"pointer-events-auto flex flex-col items-center w-full border-neutral-300 py-2",children:t})}function SidebarIcon({name:n,iconName:i,active:a,responsive:l,disabled:o,content:s,tooltipPlacement:r,children:c,onSelect:d,onDeselect:u}){return e("div",{className:G({"text-[var(--vertex-ui-blue-700)]":a===n&&!o,"text-neutral-700 hover:text-neutral-800":a!==n&&!o,"cursor-pointer hover:bg-neutral-200":!o,"text-neutral-400":o,"rounded-full md:p-3":l,"p-3":!l&&null==c,"px-3 py-1":null!=c}),"data-testid":`${n}-sidebar-panel`,onClick:()=>{o||(a===n?u():d())},children:t(P,{placement:null!=r?r:void 0,content:f.isValidElement(s)?void 0:s,children:[e("div",{slot:"content",children:s}),t("div",{className:"flex flex-col",children:[e(V,{name:i}),c]})]})})}function VertexViewerRightSidebar(){const n=usePanelActions(),i=s(Rn);return e("div",{className:"flex flex-col flex-shrink-0 items-center relative border-neutral-300 border-l bg-white h-full top-0 min-w-12 w-12",children:t(Sidebar,{children:[e(SidebarIcon,{name:"appearance",active:i,iconName:"adjustments",tooltipPlacement:"right",content:"Appearance",onSelect:()=>{n.openPrimary("appearance","right")},onDeselect:()=>n.closePrimary("right")}),e(SidebarIcon,{name:"transforms",active:i,iconName:"show-only-nearby",tooltipPlacement:"right",content:"Transforms",onSelect:()=>{n.openPrimary("transforms","right")},onDeselect:()=>n.closePrimary("right")}),e(SidebarIcon,{name:"settings",active:i,iconName:"gear",tooltipPlacement:"right",content:"Settings",onSelect:()=>{n.openPrimary("settings","right")},onDeselect:()=>n.closePrimary("right")})]})})}const VertexPopupButton=i=>{var{open:a,children:l}=i,o=__rest(i,["open","children"]);const s=l.find((e=>e.type===Anchor)),r=l.filter((e=>e.type!==Anchor));return null==s?e(n,{}):t(F,Object.assign({className:"flex",placement:"top",backdrop:!1,open:asBooleanAttribute(a)},o,{children:[s,e("div",{className:G("flex mb-1.5",{hidden:!a}),"data-testid":"align-plane-popover-menu",children:r})]}))},Anchor=({tooltipContent:t,children:n})=>e("div",{slot:"anchor",children:e(P,{className:"cursor-pointer",content:t,children:n})});function VertexViewerToolbarDivider(){return e("div",{"data-testid":"toolbar-divider",className:"h-6 w-px bg-neutral-300 mx-1 items-center mt-1"})}function VertexViewerCrossSectionAlignmentPopoverMenu(){const n=useCrossSectioningActions(),i=s(Be),a=s(Ne),getBaseIcon=()=>`align-to-${null==a?void 0:a.mode}`;return useStackKeyBinding({id:"CrossSectionAlignment",keyBind:"Escape",fn:n.cancelCurrentHit,addPredicate:()=>{var e;return null!==(e=null==a?void 0:a.hitPending)&&void 0!==e&&e},cancelPredicate:()=>!(null==a?void 0:a.hitPending)},[null==a?void 0:a.hitPending]),t(VertexPopupButton,{"data-testid":"section-alignment-popover",placement:"top",backdrop:!1,open:asBooleanAttribute(i),onDismissed:n.closeAlignmentTools,children:[e(VertexPopupButton.Anchor,{tooltipContent:"Section Alignment",children:e(E,{"data-testid":"section-alignment-icon-button",iconName:getBaseIcon(),iconColor:"secondary",onClick:i?n.closeAlignmentTools:n.openAlignmentTools,children:e(V,{"data-testid":"section-alignment-icon-chevron",name:"chevron-up",size:"sm"})})}),t(te,{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(E,{iconColor:"secondary",onClick:()=>n.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("div",{className:"text-base ml-2",children:"Align to Global"})}),e(E,{iconColor:"secondary",onClick:()=>n.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("div",{className:"text-base ml-2",children:"Align to Surface"})})]})]})}function VertexViewerCrossSectionAxisPopoverMenu(){const n=useCrossSectioningActions(),i=s(He),a=s(Ee),l=u(Ve),o=f.useMemo((()=>{const e=a.length>0&&"hasValue"===l.state?axis(a[0],xAxis(l.contents),yAxis(l.contents),zAxis(l.contents)):"x";return null!=e?`axis-${e}`:"axis-x"}),[l.state,l.contents,a]);return t(VertexPopupButton,{"data-testid":"align-plane-popover",placement:"top",backdrop:!1,open:asBooleanAttribute(i),onDismissed:n.closeAxisTools,children:[e(VertexPopupButton.Anchor,{tooltipContent:"Align Plane",children:e(E,{onClick:i?n.closeAxisTools:n.openAxisTools,iconName:o,"data-testid":"align-plane-icon",iconColor:"secondary",children:e(V,{"data-testid":"align-plane-icon-chevron",name:"chevron-up",size:"sm"})})}),t(te,{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(E,{"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:()=>n.updateAxis("x"),variant:"plain",iconColor:"secondary",iconName:"axis-x",children:e("div",{className:"text-base ml-2",children:"X-axis Plane"})}),e(E,{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:()=>n.updateAxis("y"),children:e("div",{className:"text-base ml-2",children:"Y-axis Plane"})}),e(E,{"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:()=>n.updateAxis("z"),variant:"plain",iconColor:"secondary",iconName:"axis-z",children:e("div",{className:"text-base ml-2",children:"Z-axis Plane"})})]})]})}function VertexViewerCrossSectionOffsetStepper({offset:n,onOffsetChange:i}){const a=s(An),l=s(kn),[o,r]=f.useState(convertTo(n,a));f.useEffect((()=>{r(convertTo(n,a))}),[a,n]);const c=createDistanceFormatter(a,parseInt(l,10)),handleIncrementalUpdate=e=>{const t=convertFrom(o+e,a);i(t)},d=undefined,handleBlur=()=>{i(convertFrom(o,a))};return e(P,{content:"Plane Offset",children:e("form",{"data-testid":"cross-section-stepper-form",onSubmit:e=>{e.preventDefault(),i(convertFrom(o,a))},children:t(W,{"data-testid":"cross-section-stepper-input",className:"viewer-toolbar-input w-32 border-none ring-0 bg-white",type:"text",value:c(parseFloat(n.toFixed(3))),onInputInput:e=>{r(null!=e.detail.value?parseFloat(e.detail.value):n)},onBlur:handleBlur,children:[e("div",{"data-testid":"cross-section-stepper-decrement",className:"py-1 cursor-pointer",slot:"left",onClick:()=>handleIncrementalUpdate(-1),children:e(V,{name:"chevron-left",size:"sm"})}),e("div",{"data-testid":"cross-section-stepper-increment",className:"py-1 cursor-pointer",slot:"right",onClick:()=>handleIncrementalUpdate(1),children:e(V,{name:"chevron-right",size:"sm"})})]})})})}VertexPopupButton.Anchor=Anchor;const Bn=400;function VertexViewerCrossSectionPopupMenu(){const n=useCrossSectioningActions(),i=s(De),a=u(Le),l=u(_e),o=f.useRef(),r=f.useMemo((()=>"hasValue"===a.state?a.contents:Ae),[a.state,a.contents]),c=f.useMemo((()=>"hasValue"===l.state?l.contents:0),[l.state,l.contents]),handleCrossSectionValueChange=e=>{clearTimeout(o.current),o.current=window.setTimeout((()=>{n.endInteraction()}),Bn),n.beginInteraction(),n.updatePlanes(e)};return t(VertexPopupButton,{"data-testid":"cross-section-popover",placement:"top",backdrop:!1,open:asBooleanAttribute(i),onDismissed:n.closeAdditionalTools,children:[e(VertexPopupButton.Anchor,{tooltipContent:"Section Tools",children:e("div",{className:"-ml-px py-1.5",children:e(V,{"data-testid":"cross-section-popover-icon",name:"chevron-up",size:"sm",onClick:i?n.closeAdditionalTools:n.openAdditionalTools})})}),t(te,{className:"relative bottom-3 flex justify-evenly items-center p-1 ring-1 ring-neutral-200 rounded bg-neutral-100 opacity-95",children:[e(VertexViewerCrossSectionAlignmentPopoverMenu,{}),e(P,{className:"w-auto",content:"Reverse",children:e(E,{iconName:"flip","data-testid":"viewer-toolbar-flip-button",onClick:n.flipPlanes,iconColor:"secondary"})}),e(P,{className:"w-auto",content:"Align View to Plane",children:e(E,{"data-testid":"viewer-toolbar-align-view-to-plane-button",iconName:"align-view-to-plane",onClick:n.alignViewToPlane,iconColor:"secondary"})}),e(VertexViewerToolbarDivider,{}),e(VertexViewerCrossSectionAxisPopoverMenu,{}),e("div",{className:"w-52 mx-2",children:e(VertexSlider,{value:c,defaultValue:r.default,disabled:asBooleanAttribute("hasValue"!==a.state),min:r.min,max:r.max,step:.01,onChange:handleCrossSectionValueChange})}),e("div",{className:"px-4",children:e(VertexViewerCrossSectionOffsetStepper,{offset:"hasValue"===l.state?l.contents:0,onOffsetChange:handleCrossSectionValueChange})})]})]})}const VertexViewerCrossSectionButton=()=>{const i=useCrossSectioningActions(),a=s(ke);return t(n,{children:[e(P,{content:a?"Hide Section":"Show Section",children:e(E,{"data-testid":"viewer-toolbar-cross-section-button",iconName:"cross-section",iconColor:a?"primary":"secondary",onClick:()=>a?i.disable():i.enable()})}),e(VertexViewerCrossSectionPopupMenu,{})]})},VertexFitAllButton=()=>{const t=s(de);return e(P,{content:"Fit All",children:e(E,{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=s(de),n=s(me),[i,a]=r(ge),[l,o]=r(pe);return f.useEffect((()=>{null!=t&&n&&o(t.getBaseInteractionHandler())}),[t,n,o]),e(P,{content:"Pan",children:e(E,{iconName:"pan",iconColor:"pan"===i?"primary":"secondary","data-testid":"viewer-toolbar-pan-button",onClick:async()=>{if(a("pan"),null!=l){const e=await l;null==e||e.setPrimaryInteractionType("pan")}}})})},VertexRotateButton=()=>{const t=s(de),n=s(me),[i,a]=r(ge),[l,o]=r(pe);return f.useEffect((()=>{null!=t&&n&&o(t.getBaseInteractionHandler())}),[t,n,o]),e(P,{content:"Rotate",children:e(E,{iconName:"rotate",iconColor:"rotate"===i?"primary":"secondary","data-testid":"viewer-toolbar-rotate-button",onClick:async()=>{if(a("rotate"),null!=l){const e=await l;null==e||e.setPrimaryInteractionType("rotate")}}})})},VertexZoomButton=()=>{const t=s(de),n=s(me),[i,a]=r(ge),[l,o]=r(pe);return f.useEffect((()=>{null!=t&&n&&o(t.getBaseInteractionHandler())}),[t,n,o]),e(P,{content:"Zoom",children:e(E,{iconName:"zoom",iconColor:"zoom"===i?"primary":"secondary","data-testid":"viewer-toolbar-zoom-button",onClick:async()=>{if(a("zoom"),null!=l){const e=await l;null==e||e.setPrimaryInteractionType("zoom")}}})})},DefaultToolbar=()=>e(ne,{placement:"bottom-center",children:t(te,{className:"p-1 border border-neutral-200 rounded bg-neutral-100 opacity-95",children:[e(VertexRotateButton,{}),e(VertexPanButton,{}),e(VertexZoomButton,{}),e(VertexFitAllButton,{}),e(VertexViewerToolbarDivider,{}),e(VertexBoxSelectionButton,{}),e(VertexViewerToolbarDivider,{}),e(VertexViewerCrossSectionButton,{}),e(VertexViewerToolbarDivider,{}),e(VertexPointToPointMeasurementTool,{}),e(VertexPreciseMeasurementTool,{})]})}),VertexToolbar=({children:t})=>{const n=undefined;return e(ne,{placement:"bottom-center",children:null!=t&&!1!==t?e(te,{className:"p-1 border border-neutral-200 rounded bg-neutral-100 opacity-95",children:t}):e(DefaultToolbar,{})})};function VertexTransformWidget({transformWidgetElement:t,supportUndo:i,onPositionChange:a,onRotationChange:l}){const o=useTransformActions(),r=s(Ut),c=s(Dt),d=s(Bt),m=s(zt),p=u(jt),g=s(An),h=s(kn),v=f.useMemo((()=>"hasValue"===p.state?p.contents:m),[p,m]),b=f.useMemo((()=>{const e=undefined;return c&&(null!=v||r)}),[c,v,r]);return e(n,{children:b&&e(ie,{id:"transform-widget","data-testid":"viewer-transform-widget",ref:t,position:d,rotation:null!=d?v:void 0,decimalPlaces:parseInt(h,10),distanceUnit:toUnitType(g),EXPERIMENTAL_undoKeybindings:null==i||i,onInteractionStarted:()=>{o.disableSelectionSync(),o.setIsInteractivelyTransforming(!0)},onInteractionEnded:()=>{o.invalidateTransforms(),o.setIsInteractivelyTransforming(!1)},onPositionChanged:async e=>{await o.setTransformWidgetPosition(e.detail),null==a||a(e.detail)},onRotationChanged:e=>{o.setTransformWidgetOrientation(e.detail),null==l||l(e.detail)}})})}const VertexViewerSceneReset=({onReset:t})=>{const n=useCrossSectioningActions(),i=useSelectionActions(),a=useTransformActions(),l=useViewerSceneActions(),o=undefined;return e(P,{content:"Reset View",children:e(E,{iconName:"reset",className:"flex bg-white opacity-70 hover:opacity-100 text-neutral-900 hover:text-neutral-700 hover:bg-neutral-200 rounded p-1 cursor-pointer","data-testid":"viewer-reset-tool-button",onClick:async()=>{await n.disable(),await i.resetSelectionState(),a.clearTransformWidgetPosition(),null==t||t(),await l.reset()},variant:"plain"})})};function useViewerFrameActions(){const e=useTransformActions();return{frameDrawn:useActionCallback((({set:t,snapshot:n})=>async i=>{const a=await n.getPromise(Vt);t(fe,i.detail.scene),t(Vt,i.detail.scene.sceneViewSummary.selectedVisibleSummary),t(It,a);const l=undefined;await n.getPromise(Dt)&&await e.syncToSelection()}))}}const VertexBoxSelectionTool=()=>{const{element:t,callback:n}=useCallbackRef(),i=useBoxSelectionActions(),a=useTransformActions(),l=s(ot);return h.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&&(a.clearTransformWidgetOrientation(),a.clearTransformWidgetPosition(),a.enableSelectionSync())}))]}));return()=>{null==e||e.then((e=>{null==e||e.forEach((e=>null==e?void 0:e.dispose()))}))}}),[t,l]),useApplyKeyBinding({keyBind:"Shift",fn:h.useCallback((()=>i.setOperationType("select")),[]),off:h.useCallback((()=>i.setOperationType("clearAndSelect")),[])}),e(ae,{ref:n,"data-testid":"viewer-box-query-tool",operationType:l})};function VertexViewerCameraTypeMenu({open:n,onOpen:i,onDismiss:a,onCameraTypeChange:l}){const o=useViewerCameraActions(),r=s(be);return t(_,{"data-testid":"camera-types-popover",className:"flex",placement:"bottom-end",open:asBooleanAttribute(n),onMenuClosed:a,children:[e("div",{slot:"anchor",children:e("div",{className:G("flex bg-white hover:opacity-100 hover:text-neutral-700 hover:bg-neutral-200 rounded",{"opacity-70 text-neutral-900":!n,"opacity-100 text-neutral-700 bg-neutral-200":n}),children:e(P,{content:"Change View",children:e(E,{"data-testid":"set-camera-mode-option",className:"p-1 cursor-pointer",variant:"plain",onClick:i,iconName:"orthographic"===r?"cube-orthographic":"cube-perspective",children:e(V,{"data-testid":"change-camera-type-icon-button",name:"chevron-down",size:"sm"})})})})}),t("div",{className:"w-36",children:[e("div",{className:"pt-1"}),t(R,{"data-testid":"set-perspective-view",onClick:()=>{o.updateCameraType("perspective"),null==l||l("perspective")},children:[e(V,{slot:"icon","data-testid":"set-perspective-view-icon",name:"cube-perspective",size:"sm",className:G({"text-[var(--vertex-ui-blue-700)]":"perspective"===r})}),e("div",{className:G("ml-2 items-center",{"text-[var(--vertex-ui-blue-700)]":"perspective"===r}),children:"Perspective"})]}),t(R,{"data-testid":"set-orthographic-view",onClick:()=>{o.updateCameraType("orthographic"),null==l||l("orthographic")},children:[e(V,{slot:"icon","data-testid":"set-orthographic-view-icon",name:"cube-orthographic",size:"sm",className:G({"text-[var(--vertex-ui-blue-700)]":"orthographic"===r})}),e("div",{className:G("ml-2 items-center",{"text-[var(--vertex-ui-blue-700)]":"orthographic"===r}),children:"Orthographic"})]})]})]})}const VertexViewerViewCube=n=>{var{placement:i,children:a}=n,l=__rest(n,["placement","children"]);const o=Array.isArray(a)?a:[a],s=o.filter((e=>!f.isValidElement(e)||e.type!==le)).filter((e=>null!=e&&!1!==e)),r=o.find((e=>f.isValidElement(e)&&e.type===le)),[c,d]=f.useState(!1);return t(ne,{direction:"vertical","data-testid":"view-cube-toolbar",placement:null!=i?i:"top-right",children:[null!=r?r:e(le,Object.assign({className:"m-7"},l)),0===s.length?t("div",{className:"flex items-center justify-center mt-3 gap-1",children:[e(VertexViewerSceneReset,{}),e(VertexViewerCameraTypeMenu,{open:c,onDismiss:()=>d(!1),onOpen:()=>d(!0)})]}):e("div",{className:"mt-3",children:s})]})},VertexViewer=i=>{var{id:a,className:l,disableSelection:o,onTap:c,onLongpress:d,onFrameDrawn:u,onSceneReady:m,viewerRefCallback:p,children:g}=i,h=__rest(i,["id","className","disableSelection","onTap","onLongpress","onFrameDrawn","onSceneReady","viewerRefCallback","children"]);const v=s(En),b=useRecoilRef({state:de}),w=useViewerCameraActions(),C=useHitActions(),S=useSelectionActions(),A=useViewerFrameActions(),[k,T]=r(me),P=s(be),E=s(Ne),N=s(lt),[O,M]=r(ue);f.useEffect((()=>{null!=a&&M(a)}),[a]);const I=s(wn),V=f.useMemo((()=>({opacity:I/100})),[I]),R=s(Ze),L=s(Je),_=f.useMemo((()=>({color:R,width:L})),[R,L]),D=s(rn),B=s(mn),H=s(pn),j=s(gn),U=f.useMemo((()=>({color:B,opacity:H/100,lineWidth:j})),[B,H,j]),F=s(ut),W=null!=g&&!1!==g;return useKeyBindings(),useDefaultKeybindings(),t(oe,Object.assign({id:O,"data-testid":"vertex-viewer",ref:null!=p?p:b,className:G("flex w-full h-full",l,{"cursor-crosshair":E.hitPending}),style:{"--viewer-background":D},config:v,cameraType:k?P:void 0,onCameraTypeChanged:e=>{k&&w.updateCameraType(e.detail)},phantom:V,featureLines:_,selectionHighlighting:U,featureMaps:F?"final":void 0,onTap:e=>{const t=[...o?[]:[S.selectCurrentHit]];C.tap(e,...t),null==c||c(e)},onLongpress:e=>{C.longPress(e),null==d||d(e)},onFrameDrawn:e=>{A.frameDrawn(e),null==u||u(e)},onSceneReady:e=>{k||T(!0),null==m||m(e)}},h,{children:[N&&e(VertexBoxSelectionTool,{}),W?g:t(n,{children:[e(VertexViewerViewCube,{}),e(VertexToolbar,{}),e(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:i})=>{const a=s($t),l=s(Xt);return f.useEffect((()=>{null==t||t(a)}),[a,t]),f.useEffect((()=>{null==i||i(l)}),[l,i]),e(n,{})},VertexViewerToolkitRoot=i=>{var{override:a,autoDefineCustomElements:l,children:o,config:s}=i,r=__rest(i,["override","autoDefineCustomElements","children","config"]);return f.useEffect((()=>{(null==l||l)&&(re(),se())}),[l]),e(m,{override:a,children:t(n,{children:[e(VertexViewerToolkitEventListener,Object.assign({},r)),e(VertexViewerToolkitRootConfig,{config:s,children:o})]})})},VertexViewerToolkitRootConfig=({config:t,children:i})=>{const a=c(En);return f.useEffect((()=>{const e=null!=t?toSdkConfig(t):void 0;a(e)}),[t,a]),e(n,{children:i})};var Hn=Object.freeze({__proto__:null,get AssemblyFontFace(){return Nn}});export{Ye as CrossSection,Yt as Hits,Hn as SceneTree,qt as Selection,VertexApplicationMessages,VertexBoxSelectionButton,VertexContextMenu,VertexCrossSectionAppearanceColorPicker,VertexCrossSectionAppearanceControls,VertexCrossSectionAppearanceLineThicknessSlider,VertexCrossSectionAppearancePanelSection,VertexCrossSectionAppearanceReset,VertexDecimalPlaceSelector,VertexFeatureEdgesColorPicker,VertexFeatureEdgesControls,VertexFeatureEdgesPanelSection,VertexFeatureEdgesReset,VertexFeatureEdgesThicknessSlider,VertexFitAllButton,VertexFitSelectedMenuItem,VertexFlyToMenuItem,VertexGhostingControls,VertexGhostingPanelSection,VertexHideAllMenuItem,VertexHidePartMenuItem,VertexHideSelectedMenuItem,VertexLengthUnitSelector,VertexMaterialControls,VertexMaterialPanelSection,VertexMeasurementContextMenu,VertexMeasurementDetails,VertexPanButton,VertexPointToPointMeasurement,VertexPointToPointMeasurementTool,VertexPreciseMeasurement,VertexPreciseMeasurementTool,VertexResizableContent,VertexRotateButton,VertexSceneItemGhostingClear,VertexSceneItemGhostingOpacitySlider,VertexSceneItemGhostingToggle,VertexSceneItemMaterialClear,VertexSceneItemMaterialColorPicker,VertexSceneItemMaterialOpacitySlider,VertexSceneTree,VertexSceneTreeContextMenu,VertexSceneTreeHeader,VertexSceneTreeTableLayout,VertexSelectionHighlightingColorPicker,VertexSelectionHighlightingControls,VertexSelectionHighlightingLineThicknessSlider,VertexSelectionHighlightingOpacitySlider,VertexSelectionHighlightingPanelSection,VertexSelectionHighlightingReset,VertexShowAllMenuItem,VertexShowOnlyMenuItem,VertexShowOnlySelectedMenuItem,VertexToolbar,VertexTransformClear,VertexTransformControls,VertexTransformManipulatorToggle,VertexTransformPanelSection,VertexTransformWidget,VertexUnitsControls,VertexUnitsPanelSection,VertexViewer,VertexViewerBackgroundColorPicker,VertexViewerBackgroundControls,VertexViewerBackgroundPanelSection,VertexViewerBackgroundReset,VertexViewerContextMenu,VertexViewerCrossSectionButton,VertexViewerRightOpenedPanel,VertexViewerRightSidebar,VertexViewerSceneReset,VertexViewerToolbarDivider,VertexViewerToolkitRoot,VertexViewerViewCube,VertexZoomButton};
2
2
  //# sourceMappingURL=bundle.esm.js.map