@vertexvis/viewer-toolkit-react 0.0.6-canary.10 → 0.0.6-canary.11
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.
package/dist/bundle.cjs.js
CHANGED
|
@@ -15,5 +15,5 @@
|
|
|
15
15
|
Copyright (c) 2018 Jed Watson.
|
|
16
16
|
Licensed under the MIT License (MIT), see
|
|
17
17
|
http://jedwatson.github.io/classnames
|
|
18
|
-
*/Le=Oe,function(){var e={}.hasOwnProperty;function classNames(){for(var e="",t=0;t<arguments.length;t++){var n=arguments[t];n&&(e=appendClass(e,parseValue(n)))}return e}function parseValue(t){if("string"==typeof t||"number"==typeof t)return t;if("object"!=typeof t)return"";if(Array.isArray(t))return classNames.apply(null,t);if(t.toString!==Object.prototype.toString&&!t.toString.toString().includes("[native code]"))return t.toString();var n="";for(var a in t)e.call(t,a)&&t[a]&&(n=appendClass(n,a));return n}function appendClass(e,t){return t?e?e+" "+t:e+t:e}Le.exports?(classNames.default=classNames,Le.exports=classNames):window.classNames=classNames}();var _e=Oe.exports;const VertexSlider=({value:t,defaultValue:n,leftLabel:a,rightLabel:i,onChange:r,onValueChange:l,onValueInput:c,...d})=>{const[u,m]=o.useState(n);return e.jsxs("div",{className:"flex w-full items-center gap-2",children:[a&&e.jsx("div",{className:"pl-0.5 text-xs text-center",children:a}),e.jsx(s.VertexSlider,{className:_e("w-full",{"mt-0.5":null!=a||null!=i}),value:t??u,onValueChange:e=>{m(e.detail.value),r?.(e.detail.value),l?.(e)},onValueInput:e=>{m(e.detail.value),r?.(e.detail.value),c?.(e)},...d}),i&&e.jsx("div",{className:"text-xs pr-2 flex-shrink-0 text-right",children:i})]})},VertexCrossSectionAppearanceLineThicknessSlider=({onUpdate:t})=>{const a=useCrossSectioningActions(),[o,s]=n.useRecoilState(ce);return e.jsx(VertexSlider,{id:"cross-section-line-thickness","data-testid":"cross-section-line-thickness-slider",leftLabel:"Off",rightLabel:"Thick",min:0,max:3,step:.5,value:o,valueLabelDisplay:"auto",onValueInput:async e=>{s(e.detail.value),await a.reapply()},onValueChange:e=>{t?.(e.detail.value)}})},VertexEndCapColorOptions=({onUpdateColorType:t})=>{const[a,o]=n.useRecoilState(me);return e.jsx("div",{className:"pl-2 text-sm text-neutral-700",children:e.jsxs(s.VertexRadioGroup,{value:a,"data-testid":"end-capping-color-type-radio-group",name:"end-capping-color-type",onValueChanged:e=>{o(e.detail.toUpperCase()===ne.PART?ne.PART:ne.SINGLE),t?.(e.detail)},children:[e.jsx(s.VertexRadio,{"data-testid":"end-capping-color-part-color",label:"Part Color",value:ne.PART}),e.jsx(s.VertexRadio,{"data-testid":"end-capping-color-single-color",label:"Single Color",value:ne.SINGLE})]})})},VertexEndCapColorPicker=({onUpdateCustomColor:t})=>{const[a,o]=n.useRecoilState(pe);return e.jsx(VertexColorPicker,{"data-testid":"end-capping-color-picker",value:a,onValueChanged:e=>{t?.(e.detail)},onInput:e=>o(e)})},VertexEndCapToggle=({onEnabledChange:t})=>{const[a,o]=n.useRecoilState(ue);return e.jsx(s.VertexToggle,{className:"flex items-center","data-testid":"end-item-enabled-toggle",variant:"switch",checked:a,onValueChanged:async e=>{o(e.detail),t?.(e.detail)}})};function VertexCrossSectionAppearanceControls({onUpdateCrossSectionColor:t,onUpdateCrossSectionLineThickness:a,showEndCapSettings:o,onEndCapEnabledChange:s,onUpdateEndCapColorType:i,onUpdateEndCapCustomColor:r}){const l=n.useRecoilValue(me);return e.jsxs(e.Fragment,{children:[o&&e.jsxs("div",{className:"flex items-center pt-2 pb-2",children:[e.jsx(VertexEndCapToggle,{onEnabledChange:s}),e.jsx("span",{className:"pl-4 text-sm text-neutral-700",children:"Show End Cap"})]}),e.jsx("div",{className:"pt-2 pb-2 text-sm text-neutral-700",children:"Line Color"}),e.jsx(VertexCrossSectionAppearanceColorPicker,{onUpdate:t}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Line Thickness"}),e.jsx(VertexCrossSectionAppearanceLineThicknessSlider,{onUpdate:a}),o&&e.jsxs("div",{children:[e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Cap Color"}),e.jsx(VertexEndCapColorOptions,{onUpdateColorType:i}),l===ne.SINGLE&&e.jsx("div",{className:"mt-2",children:e.jsx(VertexEndCapColorPicker,{onUpdateCustomColor:r})})]})]})}function PanelSection({header:t,children:n}){return e.jsxs("div",{className:"py-3 px-4 border-neutral-300 border-b",children:[e.jsx("div",{className:"my-2 text-base text-neutral-700",children:t}),n]})}const VertexCrossSectionAppearanceReset=({onReset:t})=>{const a=useCrossSectioningActions(),[o,i]=n.useRecoilState(le),[r,l]=n.useRecoilState(ce),c=n.useRecoilValue(de),[d,u]=n.useRecoilState(ue),[m,p]=n.useRecoilState(me),[h,f]=n.useRecoilState(pe),g=o!==ae||1!==r||d!==c||m!==ne.PART||h!==se;return e.jsx("div",{className:"ml-auto",children:e.jsx(s.VertexTooltip,{content:"Reset Cross Sectioning Appearance",children:e.jsx(s.VertexIconButton,{"data-testid":"cross-section-appearance-reset",iconName:"reset",iconSize:"sm",onClick:async()=>{i(ae),l(1),u(c),p(ne.PART),f(se),t?.(),await a.reapply()},disabled:!g})})})};function VertexCrossSectionAppearancePanelSection({onResetCrossSectionAppearance:t,onUpdateCrossSectionColor:n,onUpdateCrossSectionLineThickness:a,onEndCapEnabledChange:o,onUpdateEndCapColorType:s,onUpdateEndCapCustomColor:i}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Cross Sectioning",e.jsx(VertexCrossSectionAppearanceReset,{onReset:t})]}),children:e.jsx(VertexCrossSectionAppearanceControls,{onUpdateCrossSectionColor:n,onUpdateCrossSectionLineThickness:a,onEndCapEnabledChange:o,onUpdateEndCapColorType:s,onUpdateEndCapCustomColor:i})})}const Be=.5,De="#444444",ze=n.atom({key:"featureEdgesSelectedColor",default:De}),Fe=n.atom({key:"featureEdgesLineThickness",default:Be}),VertexFeatureEdgesColorPicker=({onUpdate:t})=>{const[a,o]=n.useRecoilState(ze);return e.jsx(VertexColorPicker,{"data-testid":"feature-edges-color-picker",value:a,onValueChanged:e=>{t?.(e.detail)},onInput:e=>o(e)})},VertexFeatureEdgesThicknessSlider=({onUpdate:t})=>{const[a,o]=n.useRecoilState(Fe);return e.jsx(VertexSlider,{id:"feature-edges-thickness","data-testid":"feature-edges-thickness-slider",leftLabel:"Off",rightLabel:"Thick",min:0,max:3,step:.5,value:a,valueLabelDisplay:"auto",onValueInput:e=>{o(e.detail.value)},onValueChange:e=>{t?.(e.detail.value)}})};function VertexFeatureEdgesControls({onUpdateFeatureEdgesColor:t,onUpdateFeatureEdgesThickness:n}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Color"}),e.jsx(VertexFeatureEdgesColorPicker,{onUpdate:t}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Line Thickness"}),e.jsx(VertexFeatureEdgesThicknessSlider,{onUpdate:n})]})}const VertexFeatureEdgesReset=({onReset:t})=>{const[a,o]=n.useRecoilState(ze),[i,r]=n.useRecoilState(Fe),l=i!==Be||a!==De;return e.jsx("div",{className:"ml-auto",children:e.jsx(s.VertexTooltip,{content:"Reset Feature Edges",children:e.jsx(s.VertexIconButton,{"data-testid":"feature-edges-reset",iconName:"reset",iconSize:"sm",onClick:()=>{o(De),r(Be),t?.()},disabled:!l})})})};function VertexFeatureEdgesPanelSection({onResetFeatureEdges:t,onUpdateFeatureEdgesColor:n,onUpdateFeatureEdgesThickness:a}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Feature Edges",e.jsx(VertexFeatureEdgesReset,{onReset:t})]}),children:e.jsx(VertexFeatureEdgesControls,{onUpdateFeatureEdgesColor:n,onUpdateFeatureEdgesThickness:a})})}function contextMenuItemIsRow(e){return null!=e&&null!=e?.node?.id}function contextMenuItemIsElement(e){return null!=e&&e instanceof HTMLElement}const He=n.atom({key:"contextMenuActive",default:void 0}),Ue=n.atom({key:"contextMenuPosition",default:void 0}),We=n.atom({key:"contextMenuTarget",default:void 0}),Ge=n.atom({key:"contextMenuItem",default:void 0}),Ke=n.atom({key:"contextMenuActions",default:[]}),$e=n.selector({key:"contextMenuActivePosition",get:({get:e})=>null!=e(He)?e(Ue):void 0});function useContextMenuActions(){return{pointerDown:useActionCallback((({set:e})=>async t=>{if(2===t.button){const n=t.clientX,o=t?.clientY;e(Ue,a.Point.create(n,o)),e(We,t.target)}})),pointerUp:useActionCallback((({snapshot:e,set:t})=>async(n,o,s,i)=>{const r=await e.getPromise(Ue),l=await e.getPromise(He);if(null!=r&&null==l){const e=n.clientX,l=n?.clientY,c=a.Point.create(e,l),d=null!=r?a.Point.distance(r,c):0,u=null==s||s(n);d<2&&u&&(i?.(n,r??c),t(He,o))}})),contextMenu:useActionCallback((()=>(e,t)=>{(null==t||t(e))&&e.preventDefault()})),longPress:useActionCallback((({set:e})=>(t,n,o,s)=>{if(null==o||o(t)){const o=a.Point.create(t.touches[0].clientX,t.touches[0].clientY);e(Ue,o),e(We,t.target),e(He,n),s?.(t,o)}})),setContextMenuItem:useActionCallback((({snapshot:e,set:t,reset:n})=>async a=>{const o=await e.getPromise(Ke);t(Ge,a),o.forEach((e=>e(a))),n(Ke)})),clearActiveContextMenu:useActionCallback((({reset:e,set:t})=>n=>{t(Ee,!!n),e(He),e(Ke),e(Ue)})),clearDismissedState:useActionCallback((({reset:e})=>()=>e(Ee)))}}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)}var qe=Object.freeze({__proto__:null,contextMenuActions:Ke,contextMenuActive:He,contextMenuActivePosition:$e,contextMenuItem:Ge,contextMenuItemIsElement:contextMenuItemIsElement,contextMenuItemIsRow:contextMenuItemIsRow,contextMenuPosition:Ue,contextMenuTarget:We,targetShouldSkipNextHit:targetShouldSkipNextHit,targetWithinMenu:targetWithinMenu,useContextMenuActions:useContextMenuActions});const Ye=n.atom({key:"boxSelectionEnabled",default:!1}),Xe=n.atom({key:"boxSelectionOperationType",default:"clearAndSelect"}),useBoxSelectionActions=()=>({enable:useActionCallback((({set:e})=>()=>{e(Ye,!0)})),disable:useActionCallback((({reset:e})=>async()=>{e(Ye),e(Xe)})),setOperationType:useActionCallback((({set:e})=>t=>{e(Xe,t)}))});var Ze=Object.freeze({__proto__:null,boxSelectionEnabled:Ye,boxSelectionOperationType:Xe,useBoxSelectionActions:useBoxSelectionActions});async function whenComponentReady(e,t,n=customElements,a=requestAnimationFrame,o=setTimeout){return null!=e&&null!=e.nodeName&&await n.whenDefined(e.nodeName.toLowerCase()),"function"==typeof e?.componentOnReady?(await(e?.componentOnReady()),t()):(await new Promise((e=>"function"==typeof a?a(e):o(e))),t())}const Je=n.atom({key:"isEditingPointToPointMeasurement",default:!1}),Qe=n.atom({key:"pointToPointMeasurementOutcome",default:void 0}),et=n.atom({key:"editedPointToPointMeasurement",default:void 0});function usePointToPointMeasurement(e){const t=n.useSetRecoilState(Qe);o.useEffect((()=>{let n;return whenComponentReady(e,(()=>{n=e?.measurementModel.onOutcomeChanged(t)})),()=>n?.dispose()}),[e,t])}const tt=2,nt=n.atom({key:"isEditingPreciseMeasurement",default:!1}),at=n.atom({key:"preciseMeasurementOutcome",default:void 0}),ot=n.atom({key:"preciseMeasurementController",dangerouslyAllowMutability:!0,default:void 0}),st=n.atom({key:"preciseMeasurementOverlays",dangerouslyAllowMutability:!0,default:void 0}),it=n.atom({key:"preciseMeasurementEntities",dangerouslyAllowMutability:!0,default:[]}),rt=n.selector({key:"preciseMeasurementMessage",get:({get:e})=>{const t=undefined;return 0===e(it).length?"Select a surface":void 0}});function usePreciseMeasurementModel(e,t,a){const s=n.useSetRecoilState(it),i=n.useSetRecoilState(at),r=n.useSetRecoilState(ot),l=n.useSetRecoilState(st),c=n.useRecoilValue(ot);o.useEffect((()=>{let n;return whenComponentReady(e,(()=>{n=e?.measurementModel.onEntitiesChanged((e=>{s(e),t?.(e)}))})),()=>n?.dispose()}),[e,s]),o.useEffect((()=>{let t;return whenComponentReady(e,(()=>{t=e?.measurementModel.onOutcomeChanged((e=>{i(e),a?.(e)}))})),()=>t?.dispose()}),[e,i]),o.useEffect((()=>{let t;return whenComponentReady(e,(()=>{t=e?.measurementModel.onEntitiesChanged((e=>{if(e.length>2){const t=e[2];c?.setEntities(new Set([t]))}}))})),()=>t?.dispose()}),[e,c]),o.useEffect((()=>{whenComponentReady(e,(()=>{r(e?.measurementController)}))}),[e,r]),o.useEffect((()=>{whenComponentReady(e,(()=>{l(e?.measurementOverlays)}))}),[e,l])}function useMeasurementActions(){const e=useBoxSelectionActions(),t=useEnablePointToPointMeasurement(),n=useDisablePointToPointMeasurement(),a=useDisablePreciseMeasurement(),o=useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromise(ot);t?.clearEntities()})),s=useActionCallback((()=>async(e={})=>{await o(),n(e),a()})),i=useActionCallback((({set:e,reset:n})=>async a=>{await s(),"point-to-point"===a?t():(n(at),n(it),e(nt,!0))}));return{disableEditMeasurement:useActionCallback((()=>async e=>{await s(e)})),enableEditMeasurement:useActionCallback((()=>async e=>{await i(e)})),resetMeasurement:useActionCallback((({snapshot:e,reset:t})=>async()=>{const n=await e.getPromise(nt),a=await e.getPromise(Je);n?await o():a&&(t(Qe),t(et))})),clearEditedPointToPointMeasurement:useActionCallback((({reset:e})=>()=>{e(et)})),setEditedPointToPointMeasurement:useActionCallback((({set:e})=>t=>{e(et,t)})),toggleEditPointToPointMeasurement:useActionCallback((({snapshot:t})=>async()=>{const n=undefined;await t.getPromise(Je)?await s():await i("point-to-point"),e.disable()})),toggleEditPreciseMeasurement:useActionCallback((({snapshot:t})=>async()=>{const n=undefined;await t.getPromise(nt)?await s():await i("precise"),e.disable()}))}}function useEnablePointToPointMeasurement(){return useActionCallback((({reset:e,set:t})=>(n={})=>{t(Je,!0),n.keepExistingMeasurement||e(Qe)}))}function useDisablePointToPointMeasurement(){return useActionCallback((({reset:e})=>(t={})=>{e(Je),t.keepExistingMeasurement||(e(et),e(Qe))}))}function useDisablePreciseMeasurement(){return useActionCallback((({reset:e})=>async()=>{e(nt),e(at),e(it)}))}const lt=n.selector({key:"isEditingMeasurement",get:({get:e})=>e(Je)||e(nt)}),ct=n.selector({key:"measurementPanelModel",get:({get:e})=>e(Qe)||e(at)}),dt=n.selector({key:"measurementPanelOverlays",dangerouslyAllowMutability:!0,get:({get:e})=>e(st)}),ut=n.selector({key:"measurementPanelMessage",get:({get:e})=>{const t=undefined;return e(nt)?e(rt):void 0}}),mt=n.selector({key:"measurementPanelIsResettable",get:({get:e})=>e(lt)&&null!=e(ct)});var pt=Object.freeze({__proto__:null,editedPointToPointMeasurement:et,isEditingMeasurement:lt,isEditingPointToPointMeasurement:Je,isEditingPreciseMeasurement:nt,measurementPanelIsResettable:mt,measurementPanelMessage:ut,measurementPanelOutcome:ct,measurementPanelOverlays:dt,pointToPointMeasurementOutcome:Qe,preciseMeasurementController:ot,preciseMeasurementEntities:it,preciseMeasurementMessage:rt,preciseMeasurementOutcome:at,preciseMeasurementOverlays:st,useDisablePointToPointMeasurement:useDisablePointToPointMeasurement,useDisablePreciseMeasurement:useDisablePreciseMeasurement,useEnablePointToPointMeasurement:useEnablePointToPointMeasurement,useMeasurementActions:useMeasurementActions,usePointToPointMeasurement:usePointToPointMeasurement,usePreciseMeasurementModel:usePreciseMeasurementModel});const ht="Scene Alteration Performance";var xt;!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"}(xt||(xt={}));var ft=Object.freeze({__proto__:null,SCENE_ALTERATION_PERFORMANCE:ht,get SceneAlterationPerformanceType(){return xt}});const gt=n.atom({key:"fetchedItemInvalidator",default:0}),yt=n.selectorFamily({key:"fetchedItems",get:e=>async({get:t})=>{const n=t(G),a=t(X);if(t(gt),t(tn),null!=a)try{return await(n?.sceneItems?.getSceneViewItem(e,a,{includeOverride:!0,includeWorldTransform:!0}))}catch(t){return void logger_debug(`Error encountered get scene view item. [itemId={${e}}]`,t)}}}),vt=n.atomFamily({key:"selectionSelectedItems",default:void 0}),bt=n.atom({key:"selectionSelectedItemIds",default:[]}),wt=n.atom({key:"selectionLastSelected",default:void 0}),Ct=n.atom({key:"selectionLastSelectionFromViewer",default:!1}),St=n.atom({key:"selectionLastSelectWasMultiSelect",default:!1}),Vt=n.selector({key:"selectionHasMultipleSelected",get:({get:e})=>{const t=e(wt),n=undefined;return e(bt).filter((e=>e!==t?.id&&!t?.ancestors?.includes(e))).length>0}}),jt=n.atom({key:"selectionIsAncestorSelection",default:!1}),kt=n.atom({key:"selectionFirstSelectedItemInTreeId",default:void 0}),Tt=n.selector({key:"selectionHighestSelectedAncestor",get:({get:e})=>{const t=e(wt),n=e(bt);return t?.ancestors?.find((e=>n.includes(e)))??t?.id}}),At=n.atom({key:"selectionPreviousVisibleSummary",default:void 0}),Pt=n.atom({key:"selectionVisibleSummary",default:void 0}),It=n.selector({key:"selectionVisibleCount",get:({get:e})=>e(Pt)?.count??0}),Mt=n.selector({key:"selectionBoundingBoxCenter",get:({get:e})=>{const t=e(Pt);return null!=t?.boundingBox?a.BoundingBox.center(t.boundingBox):a.Vector3.origin()}}),Et=n.selector({key:"selectionIsActive",get:({get:e})=>{const t=e(bt),n=undefined;return e(It)>0||t.length>0}}),Rt=n.selector({key:"fetchedAndSelectedItems",get:async({get:e})=>{const t=e(bt),n=undefined;return null!=e(X)?t.map((t=>e(yt(t)))):[]}}),Nt=n.atom({key:"selectionModelViewsSelected",default:void 0});function useSceneViewItemActions(){return{invalidateCachedItems:useActionCallback((({set:e})=>()=>{e(gt,(e=>e+1))}))}}var Ot=Object.freeze({__proto__:null,fetchedItem:yt,fetchedItemInvalidator:gt,useSceneViewItemActions:useSceneViewItemActions});const Lt=n.atom({key:"lengthUnit",default:"cm"}),_t=n.atom({key:"decimalPlace",default:"2"});var Bt=Object.freeze({__proto__:null,decimalPlace:_t,lengthUnit:Lt}),Dt,zt;!function(e){e.mm="millimeters",e.cm="centimeters",e.m="meters",e.in="inches",e.ft="feet"}(Dt||(Dt={})),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"}(zt||(zt={}));const convertFrom=(e,t)=>{const n=undefined;return e/zt[t]},convertTo=(e,t)=>{const n=undefined;return e*zt[t]},formatWithUnit=(e,t,n)=>`${e.toFixed(n)} ${t}`,formatDistance=(e,t,n)=>formatWithUnit(convertTo(e,t),t,n),createDistanceFormatter=(e,t)=>n=>formatDistance(n,e,t);function toUnitType(e){switch(e){case"cm":return"centimeters";case"m":return"meters";case"in":return"inches";case"ft":return"feet";default:return"millimeters"}}function pickLocalOrWorldTransform(e,t){return"local"===t?e.local:e.world}function mapItemTransforms(e,t){return{local:t(e.local),world:t(e.world)}}function makeItemTransforms(e,t,n){return"local"===n?{local:e,world:i.toWorldTransform(e,t)}:{world:e,local:i.toLocalTransform(e,t)}}function convertTransformToUnits(e,t){const{position:n,rotation:o,scale:s}=e;return{position:a.Vector3.create(convertTo(n.x,t),convertTo(n.y,t),convertTo(n.z,t)),rotation:o,scale:s}}function convertTransformFromUnits(e,t){const{position:n,rotation:o,scale:s}=e;return{position:a.Vector3.create(convertFrom(n.x,t),convertFrom(n.y,t),convertFrom(n.z,t)),rotation:o,scale:s}}function toValidTransform(e){const{position:t,rotation:n,scale:a}=e;return{position:{x:t.x||0,y:t.y||0,z:t.z||0},rotation:{x:n.x||0,y:n.y||0,z:n.z||0},scale:a||1}}function scale(e){const t=parseFloat(Math.sqrt(e[0]**2+e[4]**2+e[8]**2).toFixed(2)),n=parseFloat(Math.sqrt(e[1]**2+e[5]**2+e[9]**2).toFixed(2)),a=parseFloat(Math.sqrt(e[2]**2+e[6]**2+e[10]**2).toFixed(2));return t===n&&n===a?t:NaN}function translation(e){return{x:e[12],y:e[13],z:e[14]}}function rotation(e){const t=e.map((t=>t*(1/scale(e))));return t[8]<1?t[8]>-1?{x:Math.atan2(-t[9],t[10])*(180/Math.PI),y:Math.asin(t[8])*(180/Math.PI),z:Math.atan2(-t[4],t[0])*(180/Math.PI)}:{x:-Math.atan2(-t[1],t[5])*(180/Math.PI),y:-90,z:0}:{x:Math.atan2(t[1],t[5])*(180/Math.PI),y:90,z:0}}function toTransformFromApiMatrix(e){return null!=e?{position:translation(e),rotation:rotation(e),scale:scale(e)}:void 0}const Ft={position:a.Vector3.create(0,0,0),rotation:a.Vector3.create(0,0,0),scale:1},Ht=n.atom({key:"transformWidgetEnabled",default:!1}),Ut=n.atom({key:"transformWidgetPosition",default:void 0}),Wt=n.atom({key:"transformWidgetOrientationOverride",default:void 0}),Gt=n.selector({key:"transformWidgetOrientation",get:({get:e})=>{const t=e(Wt),n=e(wt);if(null!=t)return t;if(null!=n){const t=e(en(n.id));return a.Euler.fromDegrees({x:t?.world.rotation.x,y:t?.world.rotation.y,z:t?.world.rotation.z})}}}),Kt=n.atom({key:"transformWidgetCachedOrientation",default:void 0}),$t=n.atom({key:"transformWidgetSyncToSelection",default:!1}),qt=n.atom({key:"transformWidgetIsInteracting",default:!1}),Yt=n.atomFamily({key:"appliedItemTransform",default:void 0}),Xt=n.atom({key:"appliedItemTransformIds",default:[]}),Zt=n.atom({key:"selectedCoordinateSpace",default:"world"}),Jt=n.atomFamily({key:"editedItemTransform",default:void 0}),Qt=n.selectorFamily({key:"displayedItemTransform",get:e=>({get:t})=>{if(null!=e){const n=t(Zt),a=t(Lt),o=t(en(e)),s=t(Jt(e));if(null!=s)return s.transform;if(null!=o)return pickLocalOrWorldTransform(mapItemTransforms(o,(e=>convertTransformToUnits(e,a))),n)}},set:e=>({get:t,set:a},o)=>{if(null!=e){const s=t(Zt),i=t(nn(e)),r=t(en(e)),l=t(Lt);if(null!=r&&!(o instanceof n.DefaultValue)&&null!=o&&null!=i){a(Jt(e),{coordinateSpace:s,units:l,transform:o});const n=makeItemTransforms(convertTransformFromUnits(toValidTransform(o),l),i,s),r=t(Xt);a(Yt(e),n),a(Xt,[...r,e])}}}}),en=n.selectorFamily({key:"fetchedItemTransforms",get:e=>({get:t})=>{const n=t(yt(e));if(null!=n){const e=n.override?.transform?toTransformFromApiMatrix(n.override?.transform):void 0,t=n.worldTransform?toTransformFromApiMatrix(n.worldTransform):void 0;return{local:e??Ft,world:t??Ft}}}}),tn=n.atom({key:"transformInvalidator",default:0}),nn=n.selectorFamily({key:"parentItemWorldMatrix",get:e=>({get:t})=>{const n=t(X);if(null!=e&&null!=n){const n=t(yt(e));if(null!=n?.parentId){const e=t(en(n.parentId)),a=t(Yt(n.parentId));if(null==e)throw new Error("Invalid state. Parent item state should be populated, but is undefined.");return null!=a?i.toMatrix(i.toRadiansTransform(a.world)):i.toMatrix(i.toRadiansTransform(e.world))}}return logger_debug(`Unable to find the world matrix for the parent of ${e}. Returning the identity matrix.`),a.Matrix4.makeIdentity()}});function useUpdateEditedTransformWhenSettingsChange(e){const t=n.useRecoilValue(Lt),a=n.useRecoilValue(Zt),s=n.useRecoilValue(Yt(e??"")),[i,r]=n.useRecoilState(Jt(e??""));o.useEffect((()=>{if(null!=s&&(i?.coordinateSpace!==a||i?.units!==t)){const e=undefined,n=convertTransformToUnits(pickLocalOrWorldTransform(s,a),t);r({units:t,coordinateSpace:a,transform:n})}}),[t,a])}function useEditItemTransform(e){const t=useTransformActions();useUpdateEditedTransformWhenSettingsChange(e);const a=n.useRecoilValueLoadable(nn(e)),[o,s]=n.useRecoilStateLoadable(Qt(e));return{transform:"hasValue"===o.state?o.contents:void 0,loading:"loading"===o.state||"loading"===a.state,error:"hasError"===o.state?o.contents:void 0,async update(n){t.enableSelectionSync(),s(n),null!=e&&await t.applyTransformToItem(e)}}}const useTransformActions=()=>{const e=useApplicationMessageActions(),t=useViewerSceneActions(),n=useActionCallback((({set:e,snapshot:t})=>async()=>{const n=await t.getPromise(Mt);e(Ut,n)})),o=useActionCallback((({set:e,snapshot:t})=>async()=>{const a=await t.getPromise(Ut),o=await t.getPromise(St),s=await t.getPromise(bt),i=await t.getPromise(It);null==a&&(s.length>0||o||i>0)&&await n(),e($t,!0)})),s=useActionCallback((({set:e})=>async t=>{e(Ut,t??void 0)})),r=useActionCallback(retainSnapshot((({snapshot:e,set:t,reset:n})=>async()=>{const a=await e.getPromise(Gt),o=undefined;(await e.getPromise(Xt)).forEach((e=>{n(Yt(e)),n(Jt(e))})),n(Xt),null!=a&&t(Kt,a),t(tn,(e=>e+1))}))),l=useActionCallback((({set:e,reset:t})=>n=>{t(Kt),e(Wt,n)})),c=useActionCallback((({set:e})=>()=>{e(Ut,void 0),e(Ht,!1)}));return{enableTransformWidget:useActionCallback((({set:t})=>async(a,i)=>{e.setToastMessage({message:"Transform manipulator enabled! Select parts to interact.",duration:L}),t(Ht,!0),i?await n():null==a?await o():await s(a)})),disableTransformWidget:useActionCallback((({reset:e})=>()=>{e(Ht),e(Wt)})),setTransformWidgetOrientation:l,clearTransformWidgetOrientation:useActionCallback((({reset:e})=>()=>{e(Kt),e(Wt)})),setTransformWidgetPosition:s,clearTransformWidgetPosition:useActionCallback((({reset:e})=>()=>e(Ut))),invalidateTransforms:r,setIsInteractivelyTransforming:useActionCallback((({set:e})=>t=>{e(qt,t)})),setDefaultWidgetPosition:o,setDefaultWidgetPositionToSelection:n,enableSelectionSync:useActionCallback((({set:e})=>()=>e($t,!0))),disableSelectionSync:useActionCallback((({reset:e})=>()=>e($t))),syncToSelection:useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromise(At),n=await e.getPromise(Pt),o=undefined;if(await e.getPromise($t)){const e=n?.boundingBox,o=null!=e&&null!=t?.boundingBox&&equals(e,t.boundingBox);null==e||o||await s(a.BoundingBox.center(e))}})),orientToHitResult:useActionCallback((({reset:e})=>async t=>{e($t),null==t?.annotationId&&(null!=t?await s(t?.position):(e(Ut),l(void 0)))})),clearSelectedTransforms:useActionCallback((()=>async()=>{await t.execute(xt.CLEAR_SELECTED_TRANSFORMS,(e=>e.where((e=>e.withSelected())).clearTransforms())),await r(),c()})),clearAllTransforms:useActionCallback((()=>async()=>{await t.execute(xt.CLEAR_SELECTED_TRANSFORMS,(e=>e.where((e=>e.all())).clearTransforms())),await r(),c()})),applyTransformToItem:useActionCallback((({snapshot:e})=>async t=>{const n=await e.getPromise(G),o=await(n?.scene()),s=await e.getPromise(Yt(t));if(null==s)return void logger_warn(`There is no transform to apply to item ${t}.`);const r=a.Matrix4.transpose(i.toMatrix(i.toRadiansTransform(s?.local)));return o?.items((e=>e.where((e=>e.withItemId(t))).transform(r))).execute()}))}};var an=Object.freeze({__proto__:null,appliedItemTransformIds:Xt,appliedItemTransforms:Yt,convertTransformFromUnits:convertTransformFromUnits,convertTransformToUnits:convertTransformToUnits,displayedItemTransform:Qt,editedItemTransform:Jt,fetchedItemTransforms:en,identityTransform:Ft,makeItemTransforms:makeItemTransforms,mapItemTransforms:mapItemTransforms,parentItemWorldMatrix:nn,pickLocalOrWorldTransform:pickLocalOrWorldTransform,selectedCoordinateSpace:Zt,toValidTransform:toValidTransform,transformInvalidator:tn,transformWidgetCachedOrientation:Kt,transformWidgetEnabled:Ht,transformWidgetIsInteracting:qt,transformWidgetOrientation:Gt,transformWidgetOrientationOverride:Wt,transformWidgetPosition:Ut,transformWidgetSyncToSelection:$t,useEditItemTransform:useEditItemTransform,useTransformActions:useTransformActions});const useHitActions=()=>{const e=useCrossSectioningActions(),t=useMeasurementActions(),n=useTransformActions(),a=useActionCallback(retainSnapshot((({snapshot:e})=>async()=>{const n=await e.tryGetPromise(Me).then((e=>e.value)),a=await e.getPromise(et);null==n&&null!=a?.start&&null!=a.end&&await t.resetMeasurement()}))),o=useActionCallback(retainSnapshot((({snapshot:e})=>async()=>{const t=await e.tryGetPromise(Me).then((e=>e.value));await n.orientToHitResult(t)}))),s=useActionCallback(retainSnapshot((({set:e,snapshot:t})=>async()=>{const n=await t.tryGetPromise(Me).then((e=>e.value));e(Ge,n)}))),i=useActionCallback(retainSnapshot((({snapshot:e,set:t})=>async()=>{t(Ie,await e.tryGetPromise(Me).then((e=>e.value)))})));return{tap:useActionCallback(retainSnapshot((({snapshot:t,set:n})=>async({detail:r},...l)=>{const c=await t.getPromise(lt),d=await t.getPromise(xe),u=2!==r?.buttons&&!r?.altKey;r.altKey||r.ctrlKey||r.metaKey||r.shiftKey;const m=u&&!d.hitPending&&!c,p=await t.tryGetPromise(Me).then((e=>e.value));n(Pe,p),n(Te,r),await a(),m&&(l.forEach((e=>e())),await o()),await s(),await e.sectionCurrentHit(),await i()}))),longPress:useActionCallback(retainSnapshot((({snapshot:e,set:t,reset:n})=>async a=>{n(Te),t(Ae,a.detail),await e.tryGetPromise(Me),await s(),await i()})))}},on=n.selector({key:"viewerToolkitHitState",get:({get:e})=>{const t=undefined,n=undefined,a=undefined,o=undefined,s=undefined;return{tapDetails:e(Te),longPressDetails:e(Ae),previousHitResult:e(Pe),currentHitResult:e(Ie)}}});var sn=Object.freeze({__proto__:null,currentHitResult:Ie,hitResult:Me,hitResultsLongPressDetails:Ae,hitResultsSkipNextTap:Ee,hitResultsTapDetails:Te,hitState:on,previousHitResult:Pe,useHitActions:useHitActions});const rn=n.atomFamily({key:"modelViewsCursor",default:void 0}),ln=n.atomFamily({key:"pmiAnnotationsCursor",default:void 0}),cn=n.atomFamily({key:"loadedModelViews",default:[]}),dn=n.atomFamily({key:"loadedPmiAnnotations",default:[]}),un=n.atomFamily({key:"visiblePmiAnnotations",default:[]}),mn=n.selector({key:"modelViewsSceneItemName",get:async({get:e})=>{const t=e(Nt);if(null!=t){const n=e(yt(t.id));return n?.name??void 0}}}),pn=n.atom({key:"loadedItemModelView",default:void 0}),hn=n.selectorFamily({key:"nextModelViews",get:e=>async({get:t})=>{const n=t(G),a=t(rn(e));return await(n?.modelViews?.listByItem(e,{cursor:a,size:100,hasAnnotations:!0}))}}),xn=n.selectorFamily({key:"modelViews",get:e=>({get:t})=>{const n=t(cn(e)),a=t(hn(e));return n.flatMap((e=>e.modelViews)).concat(a?.modelViews??[])}}),fn=n.selectorFamily({key:"hasMoreModelViews",get:e=>({get:t})=>{const n=t(hn(e));return null!=n?.paging.next}}),gn=n.selectorFamily({key:"nextPmiAnnotations",get:e=>async({get:t})=>{const n=t(G),a=t(ln(e));return n?.pmi?.listAnnotations({modelViewId:e,cursor:a,size:100})}}),yn=n.selectorFamily({key:"pmiAnnotations",get:e=>({get:t})=>{const n=undefined;return t(dn(e)).flatMap((e=>e.annotations))}}),vn=n.selectorFamily({key:"hasMorePmiAnnotations",get:e=>({get:t})=>{const n=undefined;return null!=t(ln(e))}}),bn=n.atom({key:"selectedPmiAnnotationId",default:void 0});function useSceneAnnotationsOperations(){const e=o.useCallback((async(e,t,n)=>{const a=await(t?.scene());null==n?await(a?.elements((t=>e(t.annotations.where((e=>e.all()))))).execute()):n.length>0&&await(a?.elements((t=>e(t.annotations.where((e=>e.withAnnotationIds(n)))))).execute())}),[]),t=o.useCallback((async(e,t)=>{const n=await(e?.scene());n?.elements((e=>[e.annotations.where((e=>e.all())).deselect(),e.annotations.where((e=>e.withAnnotationIds([t]))).select()])).execute()}),[]),n=o.useCallback((async e=>{const t=await(e?.scene());t?.elements((e=>[e.annotations.where((e=>e.all())).deselect()])).execute()}),[]);return{sceneAnnotationsOperation:e,selectOnlyAnnotation:t,clearAnnotationSelection:n}}function usePmiAnnotationActions(){const e=useSceneAnnotationsOperations(),t=useActionCallback((({snapshot:e,set:t})=>async n=>{const a=await e.getPromise(gn(n));if(null!=a){t(dn(n),(e=>[...e,a])),t(un(n),(e=>[...e,...a.annotations]));const e=a?.paging?.next;t(ln(n),null!=e?()=>e:()=>{})}})),n=useActionCallback((({snapshot:e})=>async a=>{const o=document.getElementById(`annotation-entry-${a}`);if(null!=o)o.scrollIntoView();else{const o=await e.getPromise(pn),s=o?.modelView.id;if(null==s)return;const i=undefined;await e.getPromise(vn(s))&&(await t(s),await n(a))}}));return{fetchInitialPmiAnnotations:useActionCallback((({snapshot:e})=>async n=>{const a=undefined;0===(await e.getPromise(yn(n))).length&&await t(n)})),fetchNextPmiAnnotations:useActionCallback((()=>async e=>{await t(e)})),selectPmiAnnotation:useActionCallback((({set:t,snapshot:a})=>async(o,s)=>{t(bn,o);const i=await a.getPromise(G);null!=i&&await(e?.selectOnlyAnnotation(i,o)),s&&await n(o)})),clearPmiAnnotationSelection:useActionCallback((({reset:t,snapshot:n})=>async()=>{const a=await n.getPromise(bn),o=await n.getPromise(G);null!=a&&null!=o&&(t(bn),await(e?.clearAnnotationSelection(o)))})),scrollToSelectedPmiAnnotation:n}}const wn=n.atom({key:"sceneTreeLoaderVisible",default:!1}),Cn=n.atom({key:"sceneTreeElement",default:void 0}),Sn=n.atom({key:"sceneTreeController",default:void 0,dangerouslyAllowMutability:!0}),Vn=n.atom({key:"sceneTreeOpenPopover",default:void 0}),jn=n.selectorFamily({key:"sceneTreePopoverIsOpen",get:e=>({get:t})=>t(Vn)===e});function useSceneTreeActions(){const e=useSelectionActions(),t=useViewerCameraActions();return{toggleSelection:useActionCallback((({snapshot:t})=>async(n,a,o)=>{if(!n.defaultPrevented&&0===n.button&&(n.altKey||((n.ctrlKey||n.metaKey)&&a.selected?await o.deselectItem(a):a.selected?await o.selectItem(a,{recurseParent:!0}):a.selected||await o.selectItem(a,{append:n.ctrlKey||n.metaKey,range:n.shiftKey})),null!=a.id)){const o=await t.getPromise(wt);e.syncSelection({id:a.id?.hex,ancestors:o?.ancestors??[]},{selected:!n.metaKey&&!n.ctrlKey||!a.selected,multiSelect:n.shiftKey||n.metaKey||n.ctrlKey})}})),toggleExpansion:useActionCallback((()=>(e,t,n)=>{n.toggleExpandItem(t)})),toggleVisibility:useActionCallback((()=>(e,t,n)=>{n.toggleItemVisibility(t)})),flyToRow:useActionCallback((({snapshot:e})=>async n=>{const a=await e.getPromise(Cn),o=await(a?.getRowAtClientY(n));null!=o?.node.id?.hex&&await t.flyToById(o.node.id.hex)})),flyToFirstSelectedItem:useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromise(Cn),n=await e.getPromise(kt);null!=n&&t?.scrollToItem(n)})),setContextMenuItem:useActionCallback((({set:e,snapshot:t})=>async n=>{const a=await t.getPromise(Cn),o=await(a?.getRowAtClientY(n));e(Ge,o)})),openSceneTreePopover:useActionCallback((({set:e})=>t=>{e(Vn,t)})),closeSceneTreePopover:useActionCallback((({set:e})=>()=>{e(Vn,void 0)}))}}var kn=Object.freeze({__proto__:null,sceneTreeController:Sn,sceneTreeElement:Cn,sceneTreeLoaderVisible:wn,sceneTreeOpenPopover:Vn,sceneTreePopoverIsOpen:jn,useSceneTreeActions:useSceneTreeActions});function useSelectionActions(){const e=usePmiAnnotationActions(),t=useSceneViewItemActions(),n=useTransformActions(),a=useViewerSceneActions(),o=useActionCallback((({snapshot:e,reset:t})=>async()=>{const n=undefined;(await e.getPromise(bt)).forEach((e=>t(vt(e))))})),s=useActionCallback((({snapshot:e,reset:t,set:n})=>async(o,s)=>{const i=await e.getPromise(vt(o.id)),r=await e.getPromise(bt),l=[...o.ancestors??[]]?.reverse().find((e=>!r.includes(e)));null!=i&&null!=l?(n(vt(l),{id:l}),n(bt,(e=>[...e,l])),n(jt,!0),await a.execute(xt.SELECTING_ANCESTOR,a.selectItemsTransform(l)),await m({id:l})):s?.clear?(n(vt(o.id),o),n(bt,[o.id]),await a.execute(xt.SELECTING_ONLY_ITEM,a.clearSelectionTransform,a.selectItemsTransform(o.id)),await m(o)):(n(vt(o.id),o),n(bt,(e=>[...e,o.id])),await a.execute(xt.SELECTING_ITEMS,a.selectItemsTransform(o.id)),await m(o)),n(wt,o),n(Ct,!0),t(St);try{const t=await e.getPromise(Cn);await(t?.scrollToItem(o.id))}catch(e){logger_debug(`The scene item was not found in the tree. [itemId={${o.id}}]`)}})),i=useActionCallback((({reset:e,set:t})=>async n=>{e(vt(n)),e(St),e(jt),t(bt,(e=>e.filter((e=>e!==n)))),await a.execute(xt.DESELECTING_ITEMS,a.deselectItemsTransform(n))})),r=useActionCallback((({snapshot:e})=>async t=>{const n=await e.getPromise(vt(t.id));null!=n?await i(n.id):await s(t)})),l=useActionCallback((({snapshot:a,reset:o,set:i})=>async(r,l={})=>{const c=await a.getPromise(vt(r.id)),d=await a.getPromise(bt);if(d.filter((e=>e!==r.id&&!r.ancestors?.includes(e))).forEach((e=>o(vt(e)))),o(St),o(jt),c)if(l.ignoreAncestorSelection)o(bt),o(vt(c.id));else{const e=d.filter((e=>e===r.id||r.ancestors?.includes(e)));i(bt,e)}else o(bt);t.invalidateCachedItems(),n.clearTransformWidgetOrientation(),await e.clearPmiAnnotationSelection(),await s(r,{clear:!0})})),c=useActionCallback((({reset:t})=>async()=>{await o(),t(bt),t(wt),t(Ct),t(St),t(jt),n.clearTransformWidgetPosition(),n.clearTransformWidgetOrientation(),await e.clearPmiAnnotationSelection()})),d=useActionCallback((()=>async()=>{await c(),await a.execute(xt.CLEAR_SELECTION,a.clearSelectionTransform)})),u=useActionCallback((({set:e})=>async t=>{e(St,t)})),m=useActionCallback((({set:e,snapshot:t})=>async n=>{const a=await t.getPromise(Nt);a?.id!==n?.id&&e(Nt,n)}));return{select:s,toggleSelection:r,clearAndSelect:l,selectCurrentHit:useActionCallback(retainSnapshot((({snapshot:t})=>async()=>{const n=await t.tryGetPromise(Me).then((e=>e.value)),a=await t.getPromise(Te),o=a?.metaKey||a?.ctrlKey||a?.shiftKey;null!=n?.annotationId?await e.selectPmiAnnotation(n.annotationId,!0):null==n||o?null!=n&&o?await r(n):await d():await l(n)}))),syncSelection:useActionCallback((({set:e,snapshot:t,reset:n})=>async(a,s)=>{if(s.selected){const n=await t.getPromise(vt(a.id)),i=await t.getPromise(Sn);if(null!=n&&null!=i){const n=undefined,o=(await(i?.fetchNodeAncestors(a.id))).map((e=>e.id?.hex)).filter((e=>null!=e)),r=await t.getPromise(bt),l=[...o??[]]?.findLastIndex((e=>r.includes(e)));if(o.length>0&&l<o.length-1){const t=o[l+1];return e(jt,!0),e(wt,{id:t}),e(vt(t),{id:t}),e(bt,(e=>[...e.filter((e=>e!==t)),t])),e(Ct,!1),e(St,!!s.multiSelect),void await m({id:t})}}await o(),e(vt(a.id),a),s.multiSelect?e(bt,(e=>[...e.filter((e=>e!==a.id)),a.id])):e(bt,[a.id]),await m(a),e(wt,a),e(Ct,!1),e(St,!!s.multiSelect)}else n(vt(a.id)),n(St),e(bt,(e=>e.filter((e=>e!==a.id))))})),deselect:i,clearSelection:d,resetSelectionState:c,toggleLastSelectWasMultiSelect:u,selectForModelViewsPanel:m}}const Tn=n.selector({key:"viewerToolkitSelectionState",get:({get:e})=>{const t=undefined,n=undefined,a=undefined,o=undefined;return{selectedItemIds:e(bt),lastSelected:e(wt),highestSelectedAncestorId:e(Tt)}}});var An=Object.freeze({__proto__:null,fetchedAndSelectedItems:Rt,selectionBoundingBoxCenter:Mt,selectionFirstSelectedItemInTreeId:kt,selectionHasMultipleSelected:Vt,selectionHighestSelectedAncestor:Tt,selectionIsActive:Et,selectionIsAncestorSelection:jt,selectionLastSelectWasMultiSelect:St,selectionLastSelected:wt,selectionLastSelectionFromViewer:Ct,selectionModelViewsSelected:Nt,selectionPreviousVisibleSummary:At,selectionSelectedItemIds:bt,selectionSelectedItems:vt,selectionState:Tn,selectionVisibleCount:It,selectionVisibleSummary:Pt,useSelectionActions:useSelectionActions});function createColorMaterialWithId(e,t=j.create()){return{id:t,...i.ColorMaterial.fromHex(e)}}const Pn=255,In=18,Mn=n.atom({key:"sceneItemAdjustmentsSelectedColor",default:void 0}),En=n.atom({key:"sceneItemAdjustmentsRecentColors",default:[]}),Rn=n.atom({key:"sceneItemAdjustmentsCustomColors",default:[createColorMaterialWithId("#ffffff"),createColorMaterialWithId("#616161")]}),Nn=n.atom({key:"sceneItemAdjustmentsSelectedOpacity",default:void 0}),On=n.atomFamily({key:"appliedItemMaterialOverride",default:void 0}),Ln=n.atom({key:"appliedItemMaterialOverrideIds",default:[]}),_n=n.selector({key:"sceneItemAdjustmentsLastSelectedOverride",get:({get:e})=>{const t=e(wt);if(null!=t)return e(On(t.id))}}),Bn=n.atom({key:"applyMaterialToAllUserAction",default:void 0}),Dn=n.atom({key:"showConfirmDialogWhenApplyingMaterialToAll",default:!0}),zn=n.atom({key:"confirmApplyMaterialToAllDialogOpen",default:!1}),useSceneItemMaterialActions=()=>{const e=useViewerSceneActions(),t=useActionCallback((({snapshot:e,reset:t})=>async()=>{const n=await e.getPromise(Ln);t(Mn),n.forEach((e=>t(On(e)))),t(Ln)}));return{updateColor:useActionCallback((({set:e})=>t=>{e(Mn,t)})),saveRecentColor:useActionCallback((({set:e,snapshot:t})=>async n=>{const a=await t.getPromise(En),o=[n,...a.filter((e=>e!==n))],s=o.length>In?o.slice(0,-(o.length-In)):o;e(Mn,n),e(En,s)})),removeRecentColor:useActionCallback((({set:e,snapshot:t})=>async n=>{const a=undefined,o=(await t.getPromise(En)).filter((e=>e.id!==n));e(En,o)})),setCustomColors:useActionCallback((({set:e})=>async t=>{e(Rn,t)})),saveCustomColor:useActionCallback((({set:e,snapshot:t})=>async n=>{const a=undefined,o=[...await t.getPromise(Rn),n],s=o.length>In?o.slice(o.length-In):o;e(Mn,n),e(Rn,s)})),removeCustomColor:useActionCallback((({set:e,snapshot:t})=>async n=>{const a=undefined,o=(await t.getPromise(Rn)).filter((e=>e.id!==n));e(Rn,o)})),clearCurrentColor:useActionCallback((({reset:e})=>()=>{e(Mn)})),clearCurrentOpacity:useActionCallback((({reset:e})=>()=>{e(Nn)})),clear:useActionCallback((({snapshot:t,set:n,reset:a})=>async()=>{const o=await t.getPromise(bt);a(Mn),o.forEach((e=>a(On(e)))),n(Ln,(e=>e.filter((e=>!o.includes(e))))),await e.execute(xt.CLEAR_SELECTED_MATERIAL_OVERRIDES,(e=>e.where((e=>e.withSelected())).clearMaterialOverrides().select()))})),clearAll:useActionCallback((()=>async()=>{await t(),await e.execute(xt.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(Nn,t)})),apply:useActionCallback((({snapshot:t,set:n})=>async()=>{const a=await t.getPromise(Mn),o=await t.getPromise(Nn),s=await t.getPromise(bt),i=await t.getPromise(_n),r=a??i,l=o??i?.opacity;if(null!=r){const t={...r,opacity:l??r.opacity};await e.execute(xt.APPLY_MATERIAL_OVERRIDE_TO_SELECTION,(e=>e.where((e=>e.withSelected())).materialOverride(t))),s.forEach((e=>n(On(e),t))),n(Ln,(e=>[...e,...s]))}})),confirmApplyAll:useActionCallback((({set:e})=>t=>{e(zn,!0),e(Bn,(()=>t))})),cancelApplyAll:useActionCallback((({reset:e})=>()=>{e(zn),e(Bn)})),applyAll:useActionCallback((({snapshot:t,reset:n})=>async()=>{const a=await t.getPromise(Mn),o=await t.getPromise(Nn);if(null!=a){const s=await t.getPromise(Ln),i={...a,opacity:o??a.opacity};await e.execute(xt.APPLY_MATERIAL_OVERRIDE_TO_ALL,(e=>e.where((e=>e.all())).materialOverride(i))),s.forEach((e=>n(On(e))));const r=await t.getPromise(Bn);r?.(i),n(zn),n(Bn)}})),hideConfirmApplyAllDialog:useActionCallback((({set:e})=>()=>{e(Dn,!1)}))}},Fn="#ffff00",Hn=35,Un=1,Wn=n.atom({key:"selectionHighlightingSelectedColor",default:Fn}),Gn=n.atom({key:"selectionHighlightingSelectedOpacity",default:Hn}),Kn=n.atom({key:"selectionHighlightingSelectedLineThickness",default:1});function elementIsColorSwatch(e){return e instanceof Element&&"VERTEX-COLOR-SWATCH"===e.nodeName}function elementHasColorAttribute(e){return"true"===e.getAttribute("data-custom-color")||"true"===e.getAttribute("data-recent-color")}const $n="#FFFFFF",qn=n.atom({key:"viewerBackgroundSelectedColor",default:$n});var Yn=Object.freeze({__proto__:null,DEFAULT_FEATURE_EDGE_COLOR:De,DEFAULT_FEATURE_EDGE_THICKNESS_VALUE:Be,DEFAULT_SELECTION_HIGHLIGHTING_COLOR:Fn,DEFAULT_SELECTION_HIGHLIGHTING_LINE_THICKNESS:1,DEFAULT_SELECTION_HIGHLIGHTING_OPACITY:Hn,DEFAULT_VIEWER_BACKGROUND_COLOR:$n,MAXIMUM_MATERIAL_OVERRIDE_OPACITY:Pn,MAX_STORED_COLOR_ARRAY_LENGTH:In,appliedItemMaterialOverride:On,appliedItemMaterialOverrideIds:Ln,applyMaterialToAllUserAction:Bn,confirmApplyMaterialToAllDialogOpen:zn,elementHasColorAttribute:elementHasColorAttribute,elementIsColorSwatch:elementIsColorSwatch,featureEdgesLineThickness:Fe,featureEdgesSelectedColor:ze,sceneItemAdjustmentsCustomColors:Rn,sceneItemAdjustmentsLastSelectedOverride:_n,sceneItemAdjustmentsRecentColors:En,sceneItemAdjustmentsSelectedColor:Mn,sceneItemAdjustmentsSelectedOpacity:Nn,selectionHighlightingSelectedColor:Wn,selectionHighlightingSelectedLineThickness:Kn,selectionHighlightingSelectedOpacity:Gn,showConfirmDialogWhenApplyingMaterialToAll:Dn,useSceneItemMaterialActions:useSceneItemMaterialActions,viewerBackgroundSelectedColor:qn});const VertexSceneItemMaterialApplyAll=({onApplyAll:t})=>{const a=useSceneItemMaterialActions(),o=n.useRecoilValueLoadable(_n),i=n.useRecoilValue(Mn),r=n.useRecoilValue(Dn),l=u.useMemo((()=>"hasValue"===o.state?i??o.contents:i),[o,i]);return e.jsx(s.VertexTooltip,{content:"Apply to All",children:e.jsx(s.VertexIconButton,{iconName:"square-dot-outline",iconSize:"sm",color:"secondary",disabled:null==l,onClick:async()=>{r?a.confirmApplyAll(t):(await a.applyAll(),t?.(l))}})})};function SceneItemMaterialApplyAllConfirmationDialog(){const t=useSceneItemMaterialActions(),a=n.useRecoilValue(zn),[i,r]=o.useState(!1),onCloseDialog=()=>{t.cancelApplyAll(),r(!1)};return a?e.jsxs(s.VertexDialog,{open:!0,className:"text-sm",onClosed:onCloseDialog,onBackdropClick:onCloseDialog,children:[e.jsx("div",{slot:"heading",children:"Apply to All Parts"}),e.jsx("div",{className:"max-w-lg break-words pr-2",children:"This will apply the same material to all parts in the model. Any previous material changes will be lost."}),e.jsxs("div",{className:"flex mt-8 gap-2 items-center",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(s.VertexToggle,{"data-testid":"hide-confirmation-dialog-in-future-checkbox",variant:"check",className:"pt-0.5",checked:i,onValueChanged:e=>{r(e.detail)}}),"Don't show again this session"]}),e.jsxs("div",{className:"flex ml-auto gap-2",children:[e.jsx(s.VertexButton,{"data-testid":"cancel-apply-material-to-all",onClick:onCloseDialog,children:"Cancel"}),e.jsx(s.VertexButton,{color:"primary","data-testid":"confirm-apply-material-to-all",onClick:async()=>{await t.applyAll(),i&&t.hideConfirmApplyAllDialog()},children:"Apply"})]})]})]}):e.jsx(e.Fragment,{})}const VertexSceneItemMaterialColorPicker=({onApply:t})=>{const a=useSceneItemMaterialActions(),o=n.useRecoilValueLoadable(_n),s=n.useRecoilValue(Mn),i=u.useMemo((()=>"hasValue"===o.state?s??o.contents:s),[o,s]);return e.jsx(VertexColorPicker,{"data-testid":"selected-item-color-picker",value:null!=i?f.toHexString(i.diffuse):void 0,onValueChanged:async()=>{null!=i&&(await a.apply(),t?.(i),await a.saveRecentColor(createColorMaterialWithId(f.toHexString(i.diffuse))))},onInput:async e=>{a.updateColor(createColorMaterialWithId(e)),await a.apply()}})},ColorSwatch=({color:t,hideTooltip:n,onClick:a,...o})=>{const i="string"==typeof t?t:f.toHexString(t.diffuse);return e.jsx(s.VertexTooltip,{className:"flex-grow-0",content:i,disabled:!!n,children:e.jsx("button",{onClick:()=>a?.(t),children:e.jsx(s.VertexColorSwatch,{"data-testid":`color-swatch-${i}`,variant:"square",color:i,...o})})})},VertexSceneItemMaterialColorSwatches=({onAddCustomColor:t,onApplyCustomColor:a,onApplyRecentColor:o})=>{const i=useSceneItemMaterialActions(),r=n.useRecoilValue(Rn),l=n.useRecoilValue(En),c=r.length===In;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{"data-testid":"appearance-custom-colors",className:"flex flex-wrap gap-2 mt-1 mb-4",children:[r.map((t=>e.jsx(ColorSwatch,{color:t,onClick:async()=>{i.updateColor(t),await i.apply(),a?.(t)},"data-custom-color":!0,"data-color-id":t.id},t.id))),!c&&e.jsx(s.VertexColorPicker,{"data-testid":"appearance-custom-colors-add",variant:"swatch",size:"md",onValueChanged:async e=>{const n=createColorMaterialWithId(e.detail);await i.saveCustomColor(n),await i.apply(),t?.(n)},children:e.jsx("div",{slot:"overlay",className:"flex items-center justify-center w-full h-full",children:e.jsx(s.VertexIcon,{className:"bg-white p-2",name:"plus",size:"sm"})})})]}),!!l.length&&e.jsx("div",{"data-testid":"appearance-recent-colors",className:"flex flex-wrap gap-2",children:l.map((t=>e.jsx(ColorSwatch,{color:t,onClick:async()=>{i.updateColor(t),await i.apply(),o?.(t)},"data-recent-color":!0,"data-color-id":t.id},t.id)))})]})},VertexSceneItemMaterialOpacitySlider=({onApply:t})=>{const a=useSceneItemMaterialActions(),o=n.useRecoilValue(Nn),i=n.useRecoilValueLoadable(_n),r=u.useMemo((()=>"hasValue"===i.state?o??i.contents?.opacity??Pn:o??Pn),[o,i]),l=useDebouncedCallback((()=>{a.apply()}),500),c=u.useCallback((e=>{a.updateOpacity(e.detail.value),l(e.detail.value)}),[l,a]),d=u.useMemo((()=>"hasValue"!==i.state||null==i.contents),[i]);return e.jsx(s.VertexTooltip,{className:"flex w-full",content:d?"Select a part and apply a color to enable opacity":`${Math.floor(r/Pn*100)}%`,placement:"top",children:e.jsx(VertexSlider,{"data-testid":"scene-item-adjustments-opacity-slider",leftLabel:"0%",rightLabel:"100%",disabled:d,value:r??Pn,step:5,min:0,max:Pn,onValueChange:e=>{a.updateOpacity(e.detail.value),a.apply(),t?.(e.detail.value)},onValueInput:c})})};function VertexMaterialControls({customColors:t,onApplyMaterial:a,onApplyMaterialToAll:s,onAddCustomColor:i,onApplyCustomColor:r,onApplyRecentColor:l,onApplyOpacity:c}){const d=useSceneItemMaterialActions(),u=n.useRecoilValue(wt);return o.useEffect((()=>{d.clearCurrentColor(),d.clearCurrentOpacity()}),[u?.id]),o.useEffect((()=>{if(null!=t){const e=t.map((e=>({...e,id:j.create()})));d.setCustomColors(e)}}),[t]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Color"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(VertexSceneItemMaterialColorPicker,{onApply:a}),e.jsx(VertexSceneItemMaterialApplyAll,{onApplyAll:s})]})]}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Color Swatches"}),e.jsx(VertexSceneItemMaterialColorSwatches,{onAddCustomColor:i,onApplyCustomColor:r,onApplyRecentColor:l}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Opacity"}),e.jsx(VertexSceneItemMaterialOpacitySlider,{onApply:c}),e.jsx(SceneItemMaterialApplyAllConfirmationDialog,{})]})}const ResetButton=({id:t,tooltip:n,children:a})=>{const[i,r]=o.useState(!1);return e.jsx("div",{className:"ml-auto",children:e.jsxs(s.VertexDropdownMenu,{className:"flex items-stretch h-full","data-testid":`reset-button-dropdown-menu-${t}`,placement:"bottom-end",onMenuOpened:()=>r(!0),onMenuClosed:()=>r(!1),children:[e.jsx("div",{slot:"anchor",className:"flex items-center h-full",children:e.jsx(s.VertexTooltip,{content:n,disabled:i,placement:"bottom",children:e.jsxs(s.VertexButton,{className:_e("p-1.5 rounded-md select-none hover:bg-neutral-300 active:bg-neutral-400 cursor-pointer",{"bg-neutral-300":i}),"data-testid":`reset-button-${t}`,variant:"plaintext",children:[e.jsx(s.VertexIcon,{className:"px-0.5",name:"reset",size:"sm"}),e.jsx(s.VertexIcon,{name:"chevron-down",size:"sm"})]})})}),e.jsx("div",{className:"whitespace-nowrap",children:a})]})})},VertexSceneItemMaterialClear=({onClear:t,onClearAll:a})=>{const o=useSceneItemMaterialActions(),i=n.useRecoilValue(Et);return e.jsx("div",{className:"ml-auto",children:e.jsxs(ResetButton,{id:"materials",tooltip:"Clear Materials",children:[e.jsx("div",{className:"pt-1"}),e.jsx(s.VertexMenuItem,{"data-testid":"clear-selected-materials",onClick:()=>{o.clear(),t?.()},disabled:!i,children:"Clear selected materials"}),e.jsx(s.VertexMenuItem,{"data-testid":"clear-all-materials",onClick:()=>{o.clearAll(),a?.()},children:"Clear all materials"})]})})};function VertexMaterialPanelSection({customColors:t,onClearMaterial:n,onClearAllMaterials:a,onApplyMaterial:o,onApplyMaterialToAll:s,onAddCustomColor:i,onApplyCustomColor:r,onApplyRecentColor:l,onApplyOpacity:c}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Material",e.jsx(VertexSceneItemMaterialClear,{onClear:n,onClearAll:a})]}),children:e.jsx(VertexMaterialControls,{customColors:t,onApplyMaterial:o,onApplyMaterialToAll:s,onAddCustomColor:i,onApplyCustomColor:r,onApplyRecentColor:l,onApplyOpacity:c})})}const VertexSelectionHighlightingColorPicker=({onUpdate:t})=>{const[a,o]=n.useRecoilState(Wn);return e.jsx(VertexColorPicker,{"data-testid":"selection-highlighting-color-picker",value:a,onValueChanged:e=>{t?.(e.detail)},onInput:e=>o(e)})},VertexSelectionHighlightingLineThicknessSlider=({onUpdate:t})=>{const[a,o]=n.useRecoilState(Kn);return e.jsx(VertexSlider,{id:"selection-highlighting-line-thickness","data-testid":"selection-highlighting-line-thickness-slider",leftLabel:"Off",rightLabel:"Thick",min:0,max:3,step:.5,value:a,valueLabelDisplay:"auto",onValueInput:e=>{o(e.detail.value)},onValueChange:e=>{t?.(e.detail.value)}})},VertexSelectionHighlightingOpacitySlider=({onUpdate:t})=>{const[a,o]=n.useRecoilState(Gn);return e.jsx(VertexSlider,{id:"selection-highlighting-opacity","data-testid":"selection-highlighting-opacity-slider",leftLabel:"0%",rightLabel:"100%",min:0,max:100,step:5,value:a,valueLabelDisplay:"auto",onValueInput:e=>{o(e.detail.value)},onValueChange:e=>{t?.(e.detail.value)}})};function VertexSelectionHighlightingControls({onUpdateSelectionHighlightColor:t,onUpdateSelectionHighlightOpacity:n,onUpdateSelectionHighlightLineThickness:a}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Color"}),e.jsx(VertexSelectionHighlightingColorPicker,{onUpdate:t}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Opacity"}),e.jsx(VertexSelectionHighlightingOpacitySlider,{onUpdate:n}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Line Thickness"}),e.jsx(VertexSelectionHighlightingLineThicknessSlider,{onUpdate:a})]})}const VertexSelectionHighlightingReset=({onReset:t})=>{const[a,o]=n.useRecoilState(Wn),[i,r]=n.useRecoilState(Gn),[l,c]=n.useRecoilState(Kn),d=a!==Fn||i!==Hn||1!==l;return e.jsx("div",{className:"ml-auto",children:e.jsx(s.VertexTooltip,{content:"Reset Selection Highlighting",children:e.jsx(s.VertexIconButton,{"data-testid":"selection-highlighting-reset",iconName:"reset",iconSize:"sm",onClick:()=>{o(Fn),r(Hn),c(1),t?.()},disabled:!d})})})};function VertexSelectionHighlightingPanelSection({onResetSelectionHighlighting:t,onUpdateSelectionHighlightColor:n,onUpdateSelectionHighlightOpacity:a,onUpdateSelectionHighlightLineThickness:o}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Selection Highlighting",e.jsx(VertexSelectionHighlightingReset,{onReset:t})]}),children:e.jsx(VertexSelectionHighlightingControls,{onUpdateSelectionHighlightColor:n,onUpdateSelectionHighlightOpacity:a,onUpdateSelectionHighlightLineThickness:o})})}const VertexViewerBackgroundColorPicker=({onUpdate:t})=>{const[a,o]=n.useRecoilState(qn);return e.jsx(VertexColorPicker,{"data-testid":"viewer-background-color-picker",value:a,onValueChanged:e=>{t?.(e.detail)},onInput:e=>o(e)})};function VertexViewerBackgroundControls({onUpdateViewerBackgroundColor:t}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Color"}),e.jsx(VertexViewerBackgroundColorPicker,{onUpdate:t})]})}const VertexViewerBackgroundReset=({onReset:t})=>{const[a,o]=n.useRecoilState(qn),i=a!==$n;return e.jsx("div",{className:"ml-auto",children:e.jsx(s.VertexTooltip,{content:"Reset Background Color",children:e.jsx(s.VertexIconButton,{"data-testid":"viewer-background-reset",iconName:"reset",iconSize:"sm",onClick:()=>{o($n),t?.()},disabled:!i})})})};function VertexViewerBackgroundPanelSection({onResetViewerBackgroundColor:t,onUpdateViewerBackgroundColor:n}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Viewer Background",e.jsx(VertexViewerBackgroundReset,{onReset:t})]}),children:e.jsx(VertexViewerBackgroundControls,{onUpdateViewerBackgroundColor:n})})}const isInputElement=e=>{const t=e instanceof HTMLElement&&"VERTEX-AUTO-RESIZE-TEXTAREA"===e.tagName,n=e instanceof HTMLElement&&"VERTEX-TEXTFIELD"===e.tagName,a=e instanceof HTMLElement&&"true"===e.contentEditable,o=e instanceof HTMLElement&&"VERTEX-SCENE-TREE-SEARCH"===e.tagName,s=e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement,i=e instanceof HTMLElement&&"VERTEX-VIEWER-PIN-TOOL"===e.tagName,r=e instanceof HTMLElement&&"VERTEX-VIEWER-TRANSFORM-WIDGET"===e.tagName;return t||n||a||o||s||i||r},useRecoilReducer=({reducer:e,atom:t})=>{const a=undefined,o=undefined;return[n.useRecoilValue(t),useRecoilReducerDispatch({reducer:e,atom:t})]},useRecoilReducerDispatch=({reducer:e,atom:t})=>{const a=n.useRecoilCallback((({set:n})=>async a=>{n(t,(t=>e(t,a)))}),[]);return a},Xn=n.atom({key:"keyBindings",default:{applyBindings:[],bindings:{},pressed:{}}});function reducer(e,t){switch(t.type){case"push-key-binding":const n=e.bindings[t.binding.keyBind]?.find((e=>e.id===t.binding.id));return null!=n?e:{...e,bindings:{...e.bindings,[t.binding.keyBind]:[...e.bindings[t.binding.keyBind]??[],t.binding]}};case"remove-key-binding":const a=e.bindings[t.binding.keyBind]?.find((e=>e.id===t.binding.id));return null==a?e:{...e,bindings:{...e.bindings,[t.binding.keyBind]:(e.bindings[t.binding.keyBind]??[]).filter((e=>e.id!==t.binding.id))}};case"add-apply-key-binding":return{...e,applyBindings:[...e.applyBindings,t.binding]};case"remove-apply-key-binding":return{...e,applyBindings:e.applyBindings.filter((e=>e.id!==t.id))};case"set-key-pressed":return{...e,applyBindings:e.applyBindings.map((t=>({...t,active:null!=t.keyBind&&allPressed(t.keyBind,e.pressed)}))),pressed:{...e.pressed,[t.key]:t.pressed},lastPressed:t.pressed?t.key:void 0}}}const useKeyBindingState=()=>useRecoilReducer({reducer:reducer,atom:Xn}),useKeyBindingReadonlyState=()=>n.useRecoilValue(Xn);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=>null!=e.keyBind&&null!=n&&e.keyBind?.includes(n)&&allPressed(e.keyBind,t))).map((e=>e.fn))}function matchingOffBindings(e,t,n){return e.filter((e=>e.off&&e.active&&null!=e.keyBind&&null==n&&!allPressed(e.keyBind,t))).map((e=>e.off))}const useApplyKeyBinding=e=>{const[t,n]=useKeyBindingState();o.useEffect((()=>{const a=j.create();return n({type:"add-apply-key-binding",binding:{...e,id:a,active:null!=e.keyBind&&allPressed(e.keyBind,t.pressed)}}),()=>{n({type:"remove-apply-key-binding",id:a})}}),[e.fn,e.off,e.keyBind,e.repeat])},useStackKeyBinding=(e,t=[])=>{const[,n]=useKeyBindingState();o.useEffect((()=>{const t=null==e.addPredicate||e.addPredicate(),a=null!=e.cancelPredicate&&e.cancelPredicate();t&&n({type:"push-key-binding",binding:e}),a&&n({type:"remove-key-binding",binding:e})}),t)},useKeyBindings=({keydownRepeatInterval:e=25,keydownIgnorePredicate:t=isInputElement}={})=>{const[n,a]=useKeyBindingState(),s=o.useCallback((e=>{Object.keys(n.bindings).filter((t=>t.includes(e)&&allPressed(t,{...n.pressed,[e]:!0}))).forEach((e=>{const t=n.bindings[e],o=t.length>0?t[t.length-1]:void 0;null!=o&&(o.fn(),a({type:"remove-key-binding",binding:o}))}))}),[n]);o.useEffect((()=>{const handleKeyDown=e=>{if(!e.repeat&&!t(e.target)){a({type:"set-key-pressed",key:e.key,pressed:!0}),s(e.key);const t={...n.pressed,[e.key]:!0},o=matchingSingleFnBindings(n.applyBindings,t,e.key),i=matchingOffBindings(n.applyBindings,t,e.key);(o.length>0||i.length>0)&&e.preventDefault()}},handleKeyUp=e=>{a({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)}}),[s,n.applyBindings,n.pressed]),o.useEffect((()=>{const e=matchingSingleFnBindings(n.applyBindings,n.pressed,n.lastPressed),t=matchingOffBindings(n.applyBindings,n.pressed,n.lastPressed);e.forEach((e=>e())),t.forEach((e=>e()))}),[n.pressed,n.lastPressed]),o.useEffect((()=>{const t=n.applyBindings.filter((e=>e.repeat&&null!=e.keyBind&&allPressed(e.keyBind,n.pressed))).map((e=>e.fn));if(t.length>0){const n=setInterval((()=>{t.forEach((e=>e()))}),e);return()=>{clearInterval(n)}}return()=>{}}),[n.applyBindings,n.lastPressed])},VertexBoxSelectionButton=()=>{const t=useBoxSelectionActions(),a=n.useRecoilValue(Ye);return useStackKeyBinding({id:"ExitBoxSelection",keyBind:"Escape",fn:t.disable,addPredicate:()=>a,cancelPredicate:()=>!a},[a]),e.jsx(s.VertexTooltip,{content:"Box Selection",children:e.jsx(s.VertexIconButton,{iconName:"box-cursor",iconColor:a?"primary":"secondary","data-testid":"viewer-toolbar-enable-box-selection-button",onClick:a?t.disable:t.enable})})},Zn=1,VertexResizableContent=({className:t,style:n,displayShadow:a,heading:o,id:i,initialScale:r,placement:l="left",children:c,onResize:d,...u})=>{const m="left"===l||"right"===l,p="top"===l;function getHorizontalResizeDirection(){switch(l){case"left":return"right";case"right":return"left";default:return"none"}}function getVerticalResizeDirection(){return"top"===l?"top":"none"}const h=null!=r?r:1;return e.jsx(s.VertexResizable,{id:i,"data-testid":`resizable-content-position-${l}`,className:_e(t,"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"===l,"sidebar-shadow-right":"left"===l&&a,"border-l min-w-75 max-w-half":"right"===l,"sidebar-shadow-left":"right"===l&&a,"border-t bottom-0 fixed":"top"===l,"min-h-12 sheet":p}),style:{maxHeight:"top"===l?window.innerHeight:void 0,...n},initialHorizontalScale:m?r:void 0,initialVerticalScale:p?h:void 0,horizontalDirection:getHorizontalResizeDirection(),verticalDirection:getVerticalResizeDirection(),position:"right"===l||"top"===l?"absolute":"relative",onResizeEnd:()=>d?.(),...u,children:e.jsxs("div",{className:"flex flex-col h-full w-full",children:["top"===l&&e.jsx("div",{className:"flex justify-center w-full",children:e.jsx("div",{className:"block md:hidden w-20 h-0.5 mt-0.5 bg-neutral-600 rounded"})}),o,e.jsx("div",{className:_e("w-full flex flex-col h-0 flex-grow",{"right-0":"right"===l}),children:c})]})})};function useDefaultKeybindings(){useApplyKeyBinding({fn:useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromise(G),n=await(t?.scene()),a={milliseconds:500};await(n?.camera().viewAll().render({animation:a}))})),keyBind:"f"})}function useLongPress({target:e,callback:t,delay:n=500,onMovement:o}){const[s,i]=u.useState(),[r,l]=u.useState();u.useEffect((()=>{const handleTouchStart=e=>{const o=e;null!=o.touches&&1===o.touches.length&&(null!=s&&clearTimeout(s),l(a.Point.create(o.touches[0].clientX,o.touches[0].clientY)),i(setTimeout((()=>t?.(o)),n)))},handleTouchMove=e=>{const t=e;null!=t.touches&&t.touches.length>0&&null!=s&&null!=r&&a.Point.distance(r,a.Point.create(t.touches[0].clientX,t.touches[0].clientY))>=2&&(clearTimeout(s),o?.())},handleTouchEnd=()=>{null!=s&&clearTimeout(s)};return e?.addEventListener("touchstart",handleTouchStart),e?.addEventListener("touchmove",handleTouchMove),e?.addEventListener("touchend",handleTouchEnd),()=>{e?.removeEventListener("touchstart",handleTouchStart),e?.removeEventListener("touchmove",handleTouchMove),e?.removeEventListener("touchend",handleTouchEnd)}}),[e,s,r])}var Jn=Object.freeze({__proto__:null,isInputElement:isInputElement,keyBindings:Xn,reducer:reducer,useApplyKeyBinding:useApplyKeyBinding,useDefaultKeybindings:useDefaultKeybindings,useKeyBindingReadonlyState:useKeyBindingReadonlyState,useKeyBindings:useKeyBindings,useLongPress:useLongPress,useStackKeyBinding:useStackKeyBinding});function asBooleanAttribute(e){return!!e||void 0}const VertexContextMenu=({targetElement:t,menuType:a,disableBackdrop:i,openPredicate:r,onOpen:l,onClose:c,children:d})=>{const u=useContextMenuActions(),m=n.useRecoilValue(He),p=n.useRecoilValue($e),h=o.useMemo((()=>["bottom-end","top-start","top-end","right","left"]),[]),f=m===a;useStackKeyBinding({id:"ContextMenu",keyBind:"Escape",fn:u.clearActiveContextMenu,addPredicate:()=>null!=m&&m===a,cancelPredicate:()=>null==m},[m]);const g=o.useMemo((()=>null!=t?t:null!=r?window:void 0),[t,r]);return useLongPress({target:g,callback:e=>u.longPress(e,a,r,l),onMovement:()=>u.clearActiveContextMenu()}),o.useEffect((()=>{const handleWindowPointerDown=e=>{const t=undefined;if(!targetWithinMenu(e)&&2!==e.buttons&&m===a){const t=targetShouldSkipNextHit(e);u.clearActiveContextMenu(t)}};if(i)return window.addEventListener("pointerdown",handleWindowPointerDown),()=>{window.removeEventListener("pointerdown",handleWindowPointerDown)}}),[i,a,m]),o.useEffect((()=>{const handlePointerDown=e=>{u.pointerDown(e)},handlePointerUp=e=>{u.pointerUp(e,a,r,l)},handleContextMenu=e=>u.contextMenu(e,r);return g?.addEventListener("pointerdown",handlePointerDown),g?.addEventListener("pointerup",handlePointerUp),g?.addEventListener("contextmenu",handleContextMenu),()=>{g?.removeEventListener("pointerdown",handlePointerDown),g?.removeEventListener("pointerup",handlePointerUp),g?.removeEventListener("contextmenu",handleContextMenu)}}),[t,a,r]),e.jsx("div",{className:_e({hidden:!f}),children:e.jsx(s.VertexMenu,{"data-testid":`${a}-context-menu`,open:asBooleanAttribute(f),position:p,fallbackPlacements:h,backdrop:!i,onMenuClosed:()=>{u.clearActiveContextMenu(),c?.()},children:e.jsx("div",{className:"pt-1",children:d})})})},VertexFitSelectedMenuItem=()=>{const t=n.useRecoilValue(bt),a=n.useRecoilValue(Pt),o=useViewerCameraActions();return e.jsx(s.VertexMenuItem,{"data-testid":"fit-selected-menu-option",onClick:async()=>{null!=a?.boundingBox&&await o.flyToByBoundingBox(a.boundingBox)},disabled:asBooleanAttribute(0===t.length),children:e.jsxs("div",{className:"flex align-middle gap-2.5",children:[e.jsx(s.VertexIcon,{slot:"icon",name:"fit-selected",size:"sm"}),"Fit Selected"]})})},VertexFlyToMenuItem=()=>{const t=useViewerCameraActions(),a=n.useRecoilValue(Ge);return e.jsx(s.VertexMenuItem,{"data-testid":"fly-to-part-menu-option",onClick:async()=>{const e=undefined,n=contextMenuItemIsRow(a)?a?.node.id?.hex:a?.id;null!=n&&await t.flyToById(n)},disabled:asBooleanAttribute(null==a),children:e.jsxs("div",{className:"flex align-middle gap-2.5",children:[e.jsx(s.VertexIcon,{slot:"icon",name:"paper-airplane",size:"sm"}),"Fly To"]})})};function useSceneItemsOperations(){const e=n.useRecoilValue(G),t=undefined,a=undefined,s=undefined,i=undefined,r=undefined,l=undefined;return{sceneItemsOperation:o.useCallback((async(t,n)=>{const a=await(e?.scene());null==n?await(a?.items((e=>t(e.where((e=>e.all()))))).execute()):n.length>0&&await(a?.items((e=>t(e.where((e=>e.withItemIds(n)))))).execute())}),[e]),showOnlySelected:o.useCallback((async()=>{const t=await(e?.scene());t?.items((e=>[e.where((e=>e.all())).hide(),e.where((e=>e.withSelected())).show()])).execute()}),[e]),hideSelected:o.useCallback((async()=>{const t=await(e?.scene());t?.items((e=>[e.where((e=>e.withSelected())).hide()])).execute()}),[e]),showOnlyItem:o.useCallback((async t=>{const n=await(e?.scene());n?.items((e=>[e.where((e=>e.all())).hide(),e.where((e=>e.withItemIds([t]))).show()])).execute()}),[e]),ghostSelected:o.useCallback((async()=>{const t=await(e?.scene());t?.items((e=>[e.where((e=>e.withSelected())).setPhantom(!0)])).execute()}),[e]),unGhostSelected:o.useCallback((async()=>{const t=await(e?.scene());t?.items((e=>[e.where((e=>e.withSelected())).setPhantom(!1)])).execute()}),[e])}}const VertexHideAllMenuItem=()=>{const t=useSceneItemsOperations();return e.jsx(s.VertexMenuItem,{"data-testid":"hide-all-menu-option",onClick:async()=>{await t.sceneItemsOperation((e=>e.hide()))},children:e.jsxs("div",{className:"flex align-middle gap-2.5",children:[e.jsx(s.VertexIcon,{slot:"icon",name:"visibility-hidden",size:"sm"}),"Hide All Parts"]})})},VertexHidePartMenuItem=()=>{const t=n.useRecoilValue(Ge),a=useSceneItemsOperations();return e.jsx(s.VertexMenuItem,{"data-testid":"hide-menu-option",onClick:async()=>{const e=undefined,n=contextMenuItemIsRow(t)?t?.node.id?.hex:t.id;null!=n&&await a.sceneItemsOperation((e=>e.hide()),[n])},disabled:asBooleanAttribute(null==t),children:e.jsxs("div",{className:"flex align-middle gap-2.5",children:[e.jsx(s.VertexIcon,{slot:"icon",name:"visibility-hidden",size:"sm"}),"Hide Part"]})})},VertexHideSelectedMenuItem=()=>{const t=n.useRecoilValue(bt),a=useSceneItemsOperations();return e.jsx(s.VertexMenuItem,{"data-testid":"hide-selected-menu-option",onClick:()=>a.hideSelected(),disabled:asBooleanAttribute(0===t.length),children:e.jsxs("div",{className:"flex align-middle gap-2.5",children:[e.jsx(s.VertexIcon,{slot:"icon",name:"visibility-hidden",size:"sm"}),"Hide Selected"]})})},VertexShowAllMenuItem=()=>{const t=useSceneItemsOperations();return e.jsx(s.VertexMenuItem,{"data-testid":"show-all-menu-option",onClick:async()=>{await t.sceneItemsOperation((e=>e.show()))},children:e.jsxs("div",{className:"flex align-middle gap-2.5",children:[e.jsx(s.VertexIcon,{slot:"icon",name:"visibility-visible",size:"sm"}),"Show All Parts"]})})},VertexShowOnlyMenuItem=()=>{const t=n.useRecoilValue(Ge),a=useSceneItemsOperations();return e.jsx(s.VertexMenuItem,{"data-testid":"show-only-menu-option",onClick:async()=>{const e=undefined,n=contextMenuItemIsRow(t)?t?.node.id?.hex:t?.id;null!=n&&await a.showOnlyItem(n)},disabled:asBooleanAttribute(null==t),children:e.jsxs("div",{className:"flex align-middle gap-2.5",children:[e.jsx(s.VertexIcon,{slot:"icon",name:"visibility-visible",size:"sm"}),"Show Only Part"]})})},VertexShowOnlySelectedMenuItem=()=>{const t=n.useRecoilValue(bt),a=useSceneItemsOperations();return e.jsx(s.VertexMenuItem,{"data-testid":"show-only-selected-menu-option",onClick:()=>a.showOnlySelected(),disabled:asBooleanAttribute(0===t.length),children:e.jsxs("div",{className:"flex align-middle gap-2.5",children:[e.jsx(s.VertexIcon,{slot:"icon",name:"visibility-visible",size:"sm"}),"Show Only Selected"]})})},Qn=n.atom({key:"openedPanelActivePrimaryLeft",default:void 0}),ea=n.atom({key:"openedPanelActivePrimaryRight",default:void 0}),ta=n.atom({key:"openedPanelActiveSceneTreeSecondary",default:void 0});function usePanelActions(){return{openPrimary:useActionCallback((({set:e})=>(t,n)=>{e("left"===n?Qn:ea,t)})),closePrimary:useActionCallback((({set:e})=>t=>{e("left"===t?Qn:ea,void 0)})),openSecondary:useActionCallback((({set:e})=>t=>e(ta,t))),closeSecondary:useActionCallback((({reset:e})=>()=>e(ta)))}}var na=Object.freeze({__proto__:null,openedPanelActivePrimaryLeft:Qn,openedPanelActivePrimaryRight:ea,openedPanelActiveSceneTreeSecondary:ta,usePanelActions:usePanelActions});const VertexShowPropertiesMenuItem=()=>{const t=usePanelActions(),a=useSelectionActions(),o=n.useRecoilValue(Ge);return e.jsx(s.VertexMenuItem,{"data-testid":"show-properties-menu-option",disabled:asBooleanAttribute(null==o),onClick:()=>{const e=undefined,n=contextMenuItemIsRow(o)?o?.node.id?.hex:o?.id;null!=n&&(a.clearAndSelect({id:n}),t.openSecondary("Properties"))},children:e.jsxs("div",{className:"flex align-middle gap-2.5",children:[e.jsx(s.VertexIcon,{slot:"icon",name:"info",size:"sm"}),"Show Properties"]})})};function fromApiProperty(e){return{key:e.key?.name??"",value:apiMetadataPropertyDisplayValue(e.value)}}function apiMetadataPropertyDisplayValue(e){let t="";switch(e?.type){case"string":t=e.value??t;break;case"long":case"double":t=e.value.toString()??t;break;case"timestamp":t=e.value.seconds.toLocaleString()??t}return t}const aa=n.atom({key:"showMetadataSceneItemProperties",default:!0}),oa=n.selectorFamily({key:"nextMetadataSceneItemProperties",get:e=>async({get:t})=>{const n=t(G),a=t(ia(e));try{const t=await(n?.sceneItems?.listSceneItemMetadata(e,{cursor:a,size:20})),o=t?.entries?.map((e=>fromApiProperty(e))),s=undefined;return{metadata:null!=o?[...o]?.sort(((e,t)=>e.key>t.key?1:-1)):void 0,cursor:t?.paging.next}}catch(t){return void logger_debug(`Error encountered get metadata for scene item. [itemId={${e}}]`,t)}}}),sa=n.atomFamily({key:"loadedMetadataSceneItemProperties",default:[]}),ia=n.atomFamily({key:"metadataSceneItemPropertiesCursor",default:void 0}),ra=n.selectorFamily({key:"hasMoreMetadataSceneItemProperties",get:e=>({get:t})=>{const n=undefined;return null!=t(ia(e))}}),la=n.atomFamily({key:"isFetchingMetadataSceneItemProperties",default:!1}),ca=n.selector({key:"metadataSceneItemName",get:async({get:e})=>{const t=e(wt);if(null!=t){const n=e(yt(t.id));return n?.name??void 0}}});var da=Object.freeze({__proto__:null,apiMetadataPropertyDisplayValue:apiMetadataPropertyDisplayValue,fromApiProperty:fromApiProperty,hasMoreMetadataSceneItemProperties:ra,isFetchingMetadataSceneItemProperties:la,loadedMetadataSceneItemProperties:sa,metadataSceneItemName:ca,metadataSceneItemPropertiesCursor:ia,nextMetadataSceneItemProperties:oa,showMetadataSceneItemProperties:aa});const VertexGhostSelectedMenuItem=()=>{const t=n.useRecoilValue(bt),a=useSceneItemsOperations();return e.jsx(s.VertexMenuItem,{"data-testid":"ghost-selected-menu-option",onClick:()=>a.ghostSelected(),disabled:asBooleanAttribute(0===t.length),children:e.jsxs("div",{className:"flex align-middle gap-2.5",children:[e.jsx(s.VertexIcon,{slot:"icon",name:"visibility-partial",size:"sm"}),"Ghost Selected"]})})};function BetaLabel({children:t,label:n="Beta",placement:a="end",borderColor:o="border-purple-400",textColor:s="text-purple-500"}){return e.jsxs("div",{className:"flex items-center",children:[t,e.jsx("div",{className:_e(`flex border ${o} rounded-md px-1.5 text-xs ${s} uppercase items-center justify-center ml-2 select-none max-h-5`,{"ml-auto":"end"===a}),style:{height:"fit-content"},children:n})]})}const VertexShowModelViewsMenuItem=()=>{const t=usePanelActions(),a=useSelectionActions(),o=n.useRecoilValue(Ge);return e.jsx(s.VertexMenuItem,{"data-testid":"viewer-show-model-views",disabled:asBooleanAttribute(null==o),onClick:async()=>{const e=undefined,n=contextMenuItemIsRow(o)?o?.node.id?.hex:o?.id;null!=n&&(t.openPrimary("model-views","right"),a.selectForModelViewsPanel({id:n}))},children:e.jsxs("div",{className:"flex align-middle gap-2.5",children:[e.jsx(s.VertexIcon,{slot:"icon",name:"views",size:"sm"}),e.jsxs("div",{className:"flex gap-2",children:["Show Model Views ",e.jsx(BetaLabel,{})]})]})})},VertexUnghostSelectedMenuItem=()=>{const t=n.useRecoilValue(bt),a=useSceneItemsOperations();return e.jsx(s.VertexMenuItem,{"data-testid":"unghost-selected-menu-option",onClick:()=>a.unGhostSelected(),disabled:asBooleanAttribute(0===t.length),children:e.jsxs("div",{className:"flex align-middle gap-2.5",children:[e.jsx(s.VertexIcon,{slot:"icon",name:"visibility-visible",size:"sm"}),"Unghost Selected"]})})},DefaultSceneTreeContextMenu=()=>{const t=n.useRecoilValue(aa);return e.jsxs("div",{className:"w-56",children:[e.jsx(VertexHideSelectedMenuItem,{}),e.jsx(VertexHideAllMenuItem,{}),e.jsx(VertexShowOnlyMenuItem,{}),e.jsx(VertexShowOnlySelectedMenuItem,{}),e.jsx(VertexShowAllMenuItem,{}),e.jsx(VertexGhostSelectedMenuItem,{}),e.jsx(VertexUnghostSelectedMenuItem,{}),e.jsx(s.VertexMenuDivider,{}),e.jsx(VertexFitSelectedMenuItem,{}),e.jsx(VertexFlyToMenuItem,{}),e.jsx(s.VertexMenuDivider,{}),t&&e.jsx(VertexShowPropertiesMenuItem,{}),e.jsx(VertexShowModelViewsMenuItem,{})]})},VertexSceneTreeContextMenu=({children:t})=>{const a=useSceneTreeActions(),o=n.useRecoilValue(Cn),s=null!=t&&!1!==t;return e.jsx(VertexContextMenu,{menuType:"scene-tree",targetElement:o,onOpen:async(e,t)=>{const n=e;await a.setContextMenuItem(n.clientY)},disableBackdrop:!0,children:s?t:e.jsx(DefaultSceneTreeContextMenu,{})})},DefaultViewerContextMenu=()=>{const t=n.useRecoilValue(aa);return e.jsxs("div",{className:"w-56",children:[e.jsx(VertexHidePartMenuItem,{}),e.jsx(VertexHideSelectedMenuItem,{}),e.jsx(VertexHideAllMenuItem,{}),e.jsx(VertexShowOnlyMenuItem,{}),e.jsx(VertexShowOnlySelectedMenuItem,{}),e.jsx(VertexShowAllMenuItem,{}),e.jsx(VertexGhostSelectedMenuItem,{}),e.jsx(VertexUnghostSelectedMenuItem,{}),e.jsx(s.VertexMenuDivider,{}),e.jsx(VertexFitSelectedMenuItem,{}),e.jsx(VertexFlyToMenuItem,{}),e.jsx(s.VertexMenuDivider,{}),t&&e.jsx(VertexShowPropertiesMenuItem,{}),e.jsx(VertexShowModelViewsMenuItem,{})]})},VertexViewerContextMenu=({children:t})=>{const n=null!=t&&!1!==t,a=o.useCallback((e=>e.target instanceof HTMLElement&&"vertex-viewer"===e.target.id),[]);return e.jsx(VertexContextMenu,{menuType:"viewer",disableBackdrop:!0,openPredicate:a,children:n?t:e.jsx(DefaultViewerContextMenu,{})})},ua=35,ma=n.atom({key:"sceneItemGhostingSelectedOpacity",default:ua}),pa=n.atomFamily({key:"appliedItemPhantomState",default:void 0}),ha=n.atom({key:"appliedItemPhantomStateIds",default:[]}),xa=n.selector({key:"sceneItemGhostingLastSelectedPhantom",get:({get:e})=>{const t=e(wt);return null!=t&&(e(pa(t.id))??!1)}}),VertexSceneItemGhostingOpacitySlider=({onApply:t})=>{const[a,o]=n.useRecoilState(ma);return e.jsx(VertexSlider,{id:"phantom-opacity","data-testid":"phantom-opacity-slider",leftLabel:"0%",rightLabel:"100%",min:0,max:100,step:5,value:a,valueLabelDisplay:"auto",onValueInput:e=>{o(e.detail.value)},onValueChange:e=>{t?.(e.detail.value)}})},useSceneItemPhantomActions=()=>{const e=useViewerSceneActions(),t=useActionCallback((({snapshot:e,reset:t})=>async()=>{const n=undefined;(await e.getPromise(ha)).forEach((e=>t(pa(e)))),t(ha)}));return{setPhantomState:useActionCallback((({snapshot:t,set:n})=>async a=>{const o=await t.getPromise(bt);o.forEach((e=>n(pa(e),a))),n(ha,(e=>[...e,...o])),await e.execute(xt.SET_PHANTOM_SELECTED_ITEMS,(e=>e.where((e=>e.withSelected())).setPhantom(a)))})),clearPhantomState:useActionCallback((({snapshot:t,set:n,reset:a})=>async()=>{const o=await t.getPromise(bt);o.forEach((e=>a(pa(e)))),n(ha,(e=>e.filter((e=>!o.includes(e))))),await e.execute(xt.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(xt.CLEAR_PHANTOM_ALL,(e=>e.where((e=>e.all())).clearPhantom()),(e=>e.where((e=>e.withSelected())).select()))})),resetAllPhantomState:t}};var fa=Object.freeze({__proto__:null,DEFAULT_GHOSTING_OPACITY:ua,appliedItemPhantomState:pa,appliedItemPhantomStateIds:ha,sceneItemGhostingLastSelectedPhantom:xa,sceneItemGhostingSelectedOpacity:ma,useSceneItemPhantomActions:useSceneItemPhantomActions});const VertexSceneItemGhostingToggle=({onApply:t})=>{const a=useSceneItemPhantomActions(),o=n.useRecoilValue(Et),i=n.useRecoilValueLoadable(xa);return e.jsx(s.VertexTooltip,{content:"Select a part to display as ghost",disabled:o,children:e.jsx(s.VertexToggle,{className:"flex items-center","data-testid":"phantom-state-toggle",variant:"switch",disabled:!o,checked:"hasValue"===i.state&&i.contents,onValueChanged:async e=>{await a.setPhantomState(e.detail),t?.(e.detail)}})})};function VertexGhostingControls({onApplyGhostingChange:t,onApplyOpacity:n}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center py-3",children:[e.jsx(VertexSceneItemGhostingToggle,{onApply:t}),e.jsx("span",{className:"pl-4 text-sm text-neutral-700",children:"Display as Ghost"})]}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Global Ghost Opacity"}),e.jsx(VertexSceneItemGhostingOpacitySlider,{onApply:n})]})}const VertexSceneItemGhostingClear=({onClear:t,onClearAll:a})=>{const o=useSceneItemPhantomActions(),i=n.useRecoilValue(xa);return e.jsx("div",{className:"ml-auto",children:e.jsxs(ResetButton,{id:"phantom",tooltip:"Clear Ghosting",children:[e.jsx("div",{className:"pt-1"}),e.jsx(s.VertexMenuItem,{"data-testid":"reset-selected-phantom",onClick:async()=>{await o.clearPhantomState(),t?.()},disabled:!i,children:"Clear ghosting for selected"}),e.jsx(s.VertexMenuItem,{"data-testid":"reset-all-phantom",onClick:async()=>{await o.clearAllPhantomState(),a?.()},children:"Clear ghosting for all"})]})})};function VertexGhostingPanelSection({onClearGhostState:t,onClearAllGhostState:n,onApplyGhostingChange:a,onApplyOpacity:o}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Ghosting",e.jsx(VertexSceneItemGhostingClear,{onClear:t,onClearAll:n})]}),children:e.jsx(VertexGhostingControls,{onApplyGhostingChange:a,onApplyOpacity:o})})}function VertexMeasurementContextMenu({onDelete:t}){const a=n.useRecoilValue(We);return e.jsx(VertexContextMenu,{menuType:"measurement",openPredicate:e=>e.target instanceof HTMLElement&&"VERTEX-VIEWER-MEASUREMENT-DISTANCE"===e.target.tagName,children:e.jsxs(s.VertexMenuItem,{"data-testid":"measurement-delete",onClick:()=>null!=a&&t(a.id),children:[e.jsx(s.VertexIcon,{slot:"icon",name:"delete",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Delete"})]})})}function useDockedPlacement(e,t){const[n,o]=u.useState(a.Point.create(0,0));return u.useLayoutEffect((()=>{if(null!=e){const n=e.getBoundingClientRect(),s=a.Point.create(n.left,n.bottom),i=a.Point.create(n.right,n.bottom);o("left"===t?s:i)}}),[e,t]),n}function VertexMeasurementDetails({placement:t,size:a}){const o=useMeasurementActions(),i=n.useRecoilValue(G),l=n.useRecoilValue(K),c=useDockedPlacement(i??null,t),d=n.useRecoilValue(ct),u=n.useRecoilValue(dt),m=n.useRecoilValue(ut),p=n.useRecoilValue(mt),h=n.useRecoilValue(Lt),f=n.useRecoilValue(_t);return e.jsx(s.VertexDraggablePopover,{className:"z-popover",boundaryPadding:16,boundarySelector:`#${l}`,position:c,children:e.jsxs("div",{className:_e("flex flex-col min-w-40",{"text-xs leading-2":"sm"===a,"text-sm leading-4":"md"===a,"text-base leading-5":"lg"===a,"text-lg leading-5":"xl"===a}),children:[e.jsxs("div",{className:"pb-2 flex justify-between items-center",children:[e.jsx("div",{className:_e("w-full",{"text-sm leading-5":"sm"===a,"text-base leading-5":"md"===a,"text-lg leading-6":"lg"===a,"text-xl leading-7 mr-6":"xl"===a}),children:"Measurement"}),e.jsx("div",{className:_e("mr-0.5",{hidden:!p}),children:e.jsx(s.VertexTooltip,{content:"Reset",placement:"left-start",children:e.jsx(s.VertexIconButton,{"data-testid":"measurement-details-reset",iconName:"reset",iconSize:"sm",onClick:o.resetMeasurement})})})]}),e.jsx(r.VertexViewerMeasurementDetails,{"data-testid":"measurement-details-viewer-measurement-details",className:_e("gap-y-1.5",{hidden:null==d}),measurementOutcome:d,measurementOverlays:u,distanceUnits:toUnitType(h),fractionalDigits:parseInt(f,10)}),e.jsx("div",{"data-testid":"measurement-details-message",className:_e({hidden:null==m}),children:m})]})})}function useCallbackRef(e){const[t,n]=o.useState(e?.override??null),a=undefined;return{element:t,callback:o.useCallback((t=>n(e?.override??t)),[])}}function VertexPointToPointMeasurement({detailsPlacement:t,detailsSize:a,onPointToPointMeasurementChange:s}){const i=useMeasurementActions(),l=n.useRecoilValue(G),c=n.useRecoilValue(Je),d=n.useRecoilValue(et),u=n.useRecoilValue(Lt),m=n.useRecoilValue(_t),{callback:p,element:h}=useCallbackRef();usePointToPointMeasurement(h);const f=o.useCallback((e=>{const t={start:e.detail.start,end:e.detail.end,invalid:!e.detail.valid};i.setEditedPointToPointMeasurement(t),s?.(t)}),[i]);return c?e.jsxs(e.Fragment,{children:[e.jsx(r.VertexViewerMeasurementDistance,{"data-testid":"point-to-point-measurement",ref:p,viewer:l??void 0,mode:"replace",start:d?.start,end:d?.end,invalid:d?.invalid,units:toUnitType(u),fractionalDigits:parseInt(m,10),showAxisReferenceLines:!0,onEditEnd:f}),e.jsx(VertexMeasurementDetails,{placement:t,size:a}),e.jsx(VertexMeasurementContextMenu,{onDelete:i.resetMeasurement})]}):e.jsx(e.Fragment,{})}function VertexPointToPointMeasurementTool(){const t=useMeasurementActions(),a=n.useRecoilValue(Je);return useStackKeyBinding({id:"ExitMeasurement",keyBind:"Escape",fn:t.disableEditMeasurement,addPredicate:()=>a,cancelPredicate:()=>!a},[a,t]),e.jsx(s.VertexTooltip,{content:"Point to Point Measurement",children:e.jsx(s.VertexIconButton,{iconName:"tape-measure","data-testid":"viewer-toolbar-point-to-point-measurement-button",iconColor:a?"primary":"secondary",onClick:t.toggleEditPointToPointMeasurement})})}const ga=n.atom({key:"viewerToolkitSdkConfig",default:void 0});var ya=Object.freeze({__proto__:null,sdkConfig:ga});const VertexPreciseMeasurement=({detailsPlacement:t,detailsSize:a,onEntitiesChanged:o,onOutcomeChanged:s})=>{const i=n.useRecoilValue(G),l=n.useRecoilValue(ga),c=n.useRecoilValue(nt),{callback:d,element:u}=useCallbackRef();return usePreciseMeasurementModel(u,o,s),c?e.jsxs(e.Fragment,{children:[e.jsx(r.VertexViewerMeasurementPrecise,{"data-testid":"precise-measurement-viewer-tool",ref:d,viewer:i??void 0,config:JSON.stringify({network:{apiHost:l?.network?.apiHost,renderingHost:l?.network?.renderingHost,sceneTreeHost:l?.network?.sceneTreeHost,sceneViewHost:l?.network?.sceneViewHost}})}),e.jsx(VertexMeasurementDetails,{placement:t,size:a})]}):e.jsx(e.Fragment,{})};function VertexPreciseMeasurementTool(){const t=useMeasurementActions(),a=n.useRecoilValue(nt);return e.jsx(s.VertexTooltip,{content:"Precise Measurement",children:e.jsx(s.VertexIconButton,{iconName:"ruler","data-testid":"viewer-toolbar-precise-measurement-button",iconColor:a?"primary":"secondary",onClick:t.toggleEditPreciseMeasurement})})}function VertexApplicationMessages(){const t=n.useRecoilValue(F),a=n.useRecoilValue(D);return e.jsxs(e.Fragment,{children:[null!=t&&e.jsx(s.VertexBanner,{className:"z-[16000]",duration:t.duration,open:!0,content:t.message,type:t.type},t.id),null!=a&&e.jsx(s.VertexToast,{placement:"bottom-left",className:"z-[16000]",duration:a.duration,open:!0,content:a.message,type:a.type},a.id)]})}const va={binding:"{{row.node.name}}",label:"Name",metadataKeyName:"VERTEX_SCENE_ITEM_NAME"};function mapToColumn(e,t){return{label:"name"===e.toLowerCase()?"Name (Property)":e,binding:`{{row.metadata.${e}}}`,initialWidth:t,minWidth:t/2}}const ba=n.atom({key:"sceneTreeColumnsRefreshTrigger",default:0}),wa=n.atom({key:"sceneTreeColumnsWhitelistedColumns",default:[]}),Ca=n.selector({key:"sceneTreeColumnsAvailableColumns",get:async({get:e})=>{const t=e(Sn);return e(ba),null!=t?await t.fetchMetadataKeys():[]}}),Sa=n.selector({key:"sceneTreeColumnsAvailableSortedColumns",get:({get:e})=>e(Ca).filter((e=>e!==va.metadataKeyName)).sort(((e,t)=>e.localeCompare(t)))}),Va=n.atom({key:"sceneTreeColumnsVisibleMetadataColumnNames",default:[]}),ja=n.selector({key:"sceneTreeColumnsActiveColumns",get:({get:e})=>{const t=e(Va),n=e(Cn),a=n?.clientWidth;if(null!=a&&a>0){const e=1/(t.length+1)*a,n=(a-e)/t.length;return t.reduce(((e,t)=>{const a=mapToColumn(t,n);return{...e,[a.label]:a}}),{Name:{...va,initialWidth:e,minWidth:n}})}return{Name:va}}}),ka=n.selector({key:"sceneTreeColumnsActiveColumnNames",get:({get:e})=>Object.keys(e(ja))});function useSceneTreeColumnActions(){return{setActive:useActionCallback((({set:e})=>async t=>{e(Va,t)})),refreshKeyList:useActionCallback((({set:e})=>()=>{e(ba,(e=>e+1))}))}}const Ta=16,Aa=-8;var Pa;function useOpenPositionedPopover({open:e,buttonElement:t,horizontalOffset:n,verticalOffset:a}){const[o,s]=u.useState(),[i,r]=u.useState(),l=undefined;return{position:o,direction:i,handleOpen:u.useCallback((()=>{if(!e){const e=t?.getBoundingClientRect();if(null!=e){const t=n??Ta,o=a??Aa,i=e.x>window.innerWidth/2?Pa.LEFT:Pa.RIGHT;s({x:i===Pa.LEFT?e.left-t:e.right+t,y:e.top+o}),r(i)}}}),[e,t])}}!function(e){e.LEFT="left",e.RIGHT="right"}(Pa||(Pa={}));var Ia=Object.freeze({__proto__:null,DEFAULT_HORIZONTAL_POSITION_OFFSET:Ta,DEFAULT_NAME_COLUMN:va,DEFAULT_VERTICAL_POSITION_OFFSET:Aa,get PlacementDirection(){return Pa},mapToColumn:mapToColumn,sceneTreeColumnsActiveColumnNames:ka,sceneTreeColumnsActiveColumns:ja,sceneTreeColumnsAvailableColumns:Ca,sceneTreeColumnsAvailableSortedColumns:Sa,sceneTreeColumnsRefreshTrigger:ba,sceneTreeColumnsVisibleMetadataColumnNames:Va,sceneTreeColumnsWhitelistedColumns:wa,useOpenPositionedPopover:useOpenPositionedPopover,useSceneTreeColumnActions:useSceneTreeColumnActions});const Ma=n.atom({key:"sceneTreeSearchActive",default:!1}),Ea=n.atom({key:"sceneTreeColumnsPartial",default:!1}),Ra=n.atom({key:"sceneTreeSearchValue",default:void 0}),Na=n.atom({key:"sceneTreeSearchExactMatch",default:!1}),Oa=n.atom({key:"sceneTreeSearchRemoveHiddenItems",default:!1}),La=n.atom({key:"sceneTreeSearchResultCount",default:0}),_a=n.atom({key:"sceneTreeSearchActiveColumns",default:[]}),Ba=n.selector({key:"sceneTreeSearchNameColumnActive",get:({get:e})=>{const t=e(_a);return 0===t.length||t.includes(va.metadataKeyName)}});function useSceneTreeSearch({sceneTreeElement:e}){const t=useSceneTreeActions(),a=n.useRecoilValue(Ma),s=n.useSetRecoilState(La),i=n.useSetRecoilState(kt);o.useEffect((()=>{let t;return whenComponentReady(e,(()=>{t=e?.controller?.stateChanged((e=>{void 0!==e?.totalFilteredRows&&s(e?.totalFilteredRows)}))})),()=>{t?.dispose()}}),[e]),o.useEffect((()=>{if(null!=e){let n;return whenComponentReady(e,(()=>{n=e?.controller?.stateChanged((e=>{if(null!=e?.filterTerm){const t=e?.rows.find((e=>e?.node?.selected));i(t?.node.id?.hex)}else a&&t.flyToFirstSelectedItem()}))})),()=>{n?.dispose()}}}),[e,e?.controller,open])}function useSceneTreePartialResults({sceneTreeElement:e}){const t=n.useSetRecoilState(Ea);o.useEffect((()=>{let n;return whenComponentReady(e,(()=>{n=e?.controller?.stateChanged((e=>{t(!!e?.isPartialKeysResponse)}))})),()=>{n?.dispose()}}),[e])}const useSceneTreeSearchActions=()=>{const e=useActionCallback((({set:e})=>t=>{e(_a,t)})),t=useActionCallback((({snapshot:t})=>async(n,a,o,s)=>{const i=await t.getPromise(Cn),r=await t.getPromise(Na),l=await t.getPromise(Oa),c=await t.getPromise(_a),d=c.length>0?a?[...c,n]:c.filter((e=>e!==n)):[...o,va.metadataKeyName].filter((e=>e!==n));e(d),s&&i?.filterItems(s,{columns:d,exactMatch:r,removeHiddenItems:l})})),n=useActionCallback((({snapshot:e,set:t})=>async(n,a,o)=>{const s=await e.getPromise(Cn),i=await e.getPromise(Na),r=await e.getPromise(Oa),l=await e.getPromise(_a),c=n.filter((e=>!a.includes(e))),d=a.filter((e=>!n.includes(e))),u=l.length>0?[...l.filter((e=>!c.includes(e))),...d]:[...a,va.metadataKeyName],m=u.length>0?u:[...a,va.metadataKeyName];t(_a,m),o&&s?.filterItems(o,{columns:m,exactMatch:i,removeHiddenItems:r})})),a=useActionCallback((({set:e})=>t=>{e(Na,t)})),o=useActionCallback((({set:e})=>t=>{e(Oa,t)}));return{setMetadataSearchKeys:e,updateMetadataSearchAfterSearchKeysChange:t,updateMetadataSearchAfterColumnVisibilityChange:n,setMetadataSearchExactMatch:a,setMetadataSearchRemoveHiddenItems:o}};var Da=Object.freeze({__proto__:null,sceneTreeColumnsPartial:Ea,sceneTreeSearchActive:Ma,sceneTreeSearchActiveColumns:_a,sceneTreeSearchExactMatch:Na,sceneTreeSearchNameColumnActive:Ba,sceneTreeSearchRemoveHiddenItems:Oa,sceneTreeSearchResultCount:La,sceneTreeSearchValue:Ra,useSceneTreePartialResults:useSceneTreePartialResults,useSceneTreeSearch:useSceneTreeSearch,useSceneTreeSearchActions:useSceneTreeSearchActions});const targetIsElement=(e,t)=>e instanceof Element&&e.tagName===t;function useRecoilRef({state:e}){const t=n.useRecoilCallback((({set:t})=>n=>{t(e,n)}),[]);return t}var za;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=e?.depthColors,n=null!=t?Object.keys(t).reduce(((e,n)=>({...e,[`--scene-tree-row-background-color-depth-${n}`]:t[parseInt(n)]})),{}):{};return null!=e?{...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===za.ROBOTO_MONO?"var(--vertex-ui-font-family-monospace)":"var(--vertex-ui-font-family)"}!function(e){e.ROBOTO="ROBOTO",e.ROBOTO_MONO="ROBOTO_MONO"}(za||(za={}));const Fa=n.atom({key:"sceneTreeAdditionalMetadataKeys",default:[]}),Ha=n.selector({key:"sceneTreeActiveMetadataKeys",get:({get:e})=>{const t=e(Fa),n=e(Va),a=e(wa),o=new Set([...t,...n]),s=new Set(a);return 0===a.length?Array.from(o):Array.from(o.intersection(s))}});var Ua=Object.freeze({__proto__:null,sceneTreeActiveMetadataKeys:Ha,sceneTreeAdditionalMetadataKeys:Fa});function childrenAsArray(e){return Array.isArray(e)?e:[e]}function filterChildElements(e,t){return childrenAsArray(e).filter((e=>o.isValidElement(e)&&e.type===t))}function findChildElement(e,t){return filterChildElements(e,t)[0]}function cloneChildNodeOrFunction(e,t){return"object"==typeof e?o.cloneElement(e,t):e(t)}function useStateSyncedValue(e,t,{transform:a}={}){const[s,i]=n.useRecoilState(e);return o.useEffect((()=>{null!=t&&i(null!=a?a(t):t)}),[t]),s}const VertexEnterSceneTreeSearchModeButton=({onEnterSearchMode:t})=>{const a=n.useSetRecoilState(Ma);return e.jsx(s.VertexTooltip,{className:"flex ml-auto",content:"Scene Tree Search",children:e.jsx(s.VertexIconButton,{"data-testid":"enter-scene-tree-search-mode-button",iconName:"search",iconSize:"sm",onPointerDown:e=>{e.preventDefault()},onClick:()=>{a(!0),t?.()}})})},VertexSceneTreeMetadataCheck=({checked:t,disabled:n,onChange:a,children:o})=>{const i="string"==typeof o?o.replace(" ","-"):"";return e.jsxs("div",{className:"flex items-center",children:[e.jsx(s.VertexToggle,{"data-testid":`scene-tree-metadata-check-${i}`,variant:"check",checked:t,disabled:n,onValueChanged:e=>a?.(e.detail)}),e.jsx("div",{className:"pl-2 py-1 text-[0.875rem] w-full","data-testid":`scene-tree-metadata-name-${i}`,onClick:()=>{n||a?.(!t)},children:o})]})},VertexSceneTreeSearchOptionsPopover=({onSearchedSceneTreeColumnsChange:t,onSearchForExactMatchChange:a})=>{const o=useSceneTreeActions(),i=useSceneTreeSearchActions(),r=n.useRecoilValue(Cn),l=n.useRecoilValue(Ba),c=n.useRecoilValue(_a),d=n.useRecoilValue(Ra),m=n.useRecoilValue(Na),p=n.useRecoilValue(Oa),h=n.useRecoilValue(Va),{element:f,callback:g}=useCallbackRef(),v="scene-tree-search",b=n.useRecoilValue(jn(v)),{position:w,direction:C,handleOpen:S}=useOpenPositionedPopover({open:b,buttonElement:f,horizontalOffset:20}),V=u.useCallback((()=>{o.closeSceneTreePopover()}),[]),j=C===Pa.LEFT?"left-end":"right-start",updateSearch=async(e,t)=>{if(d){const n=c.length>0?c:[...h,va.metadataKeyName];await(r?.filterItems(d,{columns:n,exactMatch:e,removeHiddenItems:t}))}};return e.jsxs(e.Fragment,{children:[e.jsx(s.VertexTooltip,{content:"Search Options",placement:"top",children:e.jsx(s.VertexIconButton,{"data-testid":"scene-tree-search-options-popover-button",className:"text-neutral-700",ref:g,iconName:"gear",iconSize:"sm",onClick:()=>{b?V():(S(),o.openSceneTreePopover(v))}})}),b&&e.jsx(s.VertexPopover,{"data-testid":"scene-tree-search-options-popover",open:b,backdrop:!1,position:w,resizeBehavior:"fixed",placement:j,className:"z-popover",children:e.jsxs("div",{className:_e("flex flex-col bg-white border border-neutral-300 rounded",{hidden:!b}),children:[e.jsxs("div",{className:"flex items-center text-[0.875rem] p-3 border-b border-neutral-300 pb-2",children:[e.jsx("div",{className:"pr-2 text-[0.875rem] whitespace-nowrap",children:"Column Properties Search"}),e.jsx(s.VertexIconButton,{className:"ml-auto",iconName:"close",iconSize:"sm",onClick:()=>{V()}})]}),e.jsxs("div",{className:"max-h-64 p-3 overflow-y-auto",children:[e.jsx("div",{className:"text-[0.875rem] pb-2 pr-2",children:"Select properties to perform the search on:"}),e.jsx(VertexSceneTreeMetadataCheck,{checked:l,disabled:0===c.length||c.every((e=>e===va.metadataKeyName)),onChange:async e=>{await i.updateMetadataSearchAfterSearchKeysChange(va.metadataKeyName,e,h,d),t?.()},children:va.label},va.metadataKeyName),h.map((n=>e.jsx(VertexSceneTreeMetadataCheck,{checked:c.includes(n),disabled:c.length>0&&c.every((e=>e===n)),onChange:async e=>{await i.updateMetadataSearchAfterSearchKeysChange(n,e,h,d),t?.()},children:n},n)))]}),e.jsxs("div",{className:"flex p-3 border-t border-neutral-300",children:[e.jsx(s.VertexToggle,{className:"flex items-center","data-testid":"filter-exact-match-toggle",variant:"switch",checked:m,onValueChanged:async e=>{i.setMetadataSearchExactMatch(e.detail),a?.(),await updateSearch(e.detail,p)}}),e.jsx("span",{className:"pl-4 text-[0.875rem] text-neutral-800",children:"Return only exact matches"})]}),e.jsxs("div",{className:"flex px-3 pb-3",children:[e.jsx(s.VertexToggle,{className:"flex items-center","data-testid":"filter-remove-hidden-items-toggle",variant:"switch",checked:p,onValueChanged:async e=>{i.setMetadataSearchRemoveHiddenItems(e.detail),await updateSearch(m,e.detail)}}),e.jsx("span",{className:"pl-4 text-[0.875rem] text-neutral-800",children:"Search only visible items"})]})]})})]})},VertexSceneTreeSearchBar=({onSearch:t,onClearSearch:a,onExitSearchMode:o,onSearchedSceneTreeColumnsChange:i,onSearchForExactMatchChange:l,sceneTreeSearchElement:c,children:d})=>{const m=useSceneTreeActions(),p=n.useRecoilValue(Cn),[h,f]=n.useRecoilState(Ma),[g,v]=n.useRecoilState(Ra),b=n.useRecoilValue(jn("scene-tree-search"));useSceneTreeSearch({sceneTreeElement:p??null});const{element:w,callback:C}=useCallbackRef({override:c}),S=null==g||""===g;return u.useEffect((()=>{h&&w?.setFocus()}),[w,h]),e.jsxs("div",{className:"flex w-full py-3 px-2",children:[e.jsx(s.VertexTooltip,{className:"self-center mr-1",content:"Exit Search",children:e.jsx(s.VertexIconButton,{"data-testid":"scene-tree-search-close-button",iconName:"caret-left",iconSize:"sm",onPointerDown:e=>{e.preventDefault()},onClick:async()=>{f(!1),v(void 0),await(w?.clear()),await(p?.filterItems("")),b&&m.closeSceneTreePopover(),await m.flyToFirstSelectedItem(),o?.()}})}),e.jsxs(r.VertexSceneTreeSearch,{"data-testid":"scene-tree-search-bar",ref:C,controller:p?.controller,onBlur:()=>{S&&(f(!1),o?.(),b&&m.closeSceneTreePopover())},onSearch:()=>{v(w?.value),t?.(w?.value)},children:[d,e.jsx(s.VertexIcon,{slot:"clear-icon",name:"close-circle-fill",size:"sm",onPointerDown:async()=>{await m.flyToFirstSelectedItem(),a?.()}})]}),e.jsx("div",{className:"self-center pl-1",onPointerDown:e=>{e.preventDefault()},children:e.jsx(VertexSceneTreeSearchOptionsPopover,{onSearchedSceneTreeColumnsChange:i,onSearchForExactMatchChange:l})})]})},VertexSceneTreeSearch=({onEnterSearchMode:t,onExitSearchMode:a,onSearch:o,onClearSearch:s,onSearchedSceneTreeColumnsChange:i,onSearchForExactMatchChange:l,children:c})=>{const d=n.useRecoilValue(Ma);return e.jsxs(r.VertexSceneTreeToolbar,{className:"h-11 p-0 border-b border-neutral-300 box-content",slot:"header",children:[d&&e.jsx(VertexSceneTreeSearchBar,{onSearch:o,onClearSearch:s,onExitSearchMode:a,onSearchedSceneTreeColumnsChange:i,onSearchForExactMatchChange:l,children:c}),!d&&e.jsx("div",{className:"ml-auto mr-2",children:e.jsx(VertexEnterSceneTreeSearchModeButton,{onEnterSearchMode:t})})]})};function useCacheableLoadable(e,t){const a=o.useRef(),[s,i]=o.useState(0),r=n.useRecoilValueLoadable(e);o.useEffect((()=>{"hasValue"===r.state&&(a.current=r.contents)}),[t,r]);const[l,c]=o.useMemo((()=>"hasValue"!==r.state&&null!=a.current?[a.current,!0]:"hasValue"===r.state?[r.contents,!1]:[void 0,!1]),[r.state,r.contents,s]),d=o.useCallback((()=>{a.current=void 0,i(s+1)}),[s]),u=undefined;return o.useMemo((()=>({data:l,state:r.state,cached:c,invalidate:d})),[d,l,c,r.state])}const VertexSceneTreeColumnPopover=({onVisibleSceneTreeColumnsChange:t})=>{const a=useSceneTreeActions(),o=useSceneTreeColumnActions(),i=useSceneTreeSearchActions(),l=undefined;useSceneTreePartialResults({sceneTreeElement:n.useRecoilValue(Cn)??null});const c=n.useRecoilValue(Ra),d=n.useRecoilValue(wa),m=useCacheableLoadable(Sa),p=d.length>0?d:m.data,h=n.useRecoilValue(Va),f=n.useRecoilValue(Ea),[g,v]=u.useState(h),[b,w]=u.useState(""),{element:C,callback:S}=useCallbackRef(),V="scene-tree-columns",j=n.useRecoilValue(jn(V)),{position:k,direction:T,handleOpen:A}=useOpenPositionedPopover({open:j,buttonElement:C}),P=u.useCallback((()=>{a.closeSceneTreePopover()}),[]),I=T===Pa.LEFT?"left-end":"right-start",M=u.useMemo((()=>{if(null!=p){const e=p.filter((e=>g.indexOf(e)<0)),t=undefined;return[...[...g].sort(((e,t)=>e.localeCompare(t))),...e]}return[]}),[g,p]),E=u.useMemo((()=>M),[j,p]);return e.jsxs(e.Fragment,{children:[e.jsx(s.VertexTooltip,{content:"Configure Columns",placement:"top",children:e.jsx(s.VertexIconButton,{"data-testid":"scene-tree-column-popover-button",ref:S,iconName:"columns-add",iconSize:"sm",onClick:()=>{j?P():(A(),a.openSceneTreePopover(V))}})}),j&&e.jsx(s.VertexPopover,{"data-testid":"scene-tree-column-popover",open:j,backdrop:!1,position:k,resizeBehavior:"fixed",placement:I,className:"z-popover",children:e.jsxs("div",{className:_e("flex flex-col bg-white border border-neutral-300 rounded",{hidden:!j}),children:[e.jsxs("div",{className:"flex items-center text-[0.875rem] p-3",children:[e.jsxs("div",{className:"pr-2",children:[e.jsx("div",{className:"text-[0.875rem]",children:"Assembly Properties"}),e.jsx("div",{className:"text-[0.75rem] text-neutral-700 mt-1.5",children:"Select up to six properties to appear in the Assembly panel."})]}),e.jsx(s.VertexIconButton,{"data-testid":"scene-tree-columns-popover-close-button",className:"ml-auto",iconName:"close",iconSize:"sm",onClick:()=>{w(""),P()}})]}),e.jsx(s.VertexTextfield,{className:"flex w-full px-2 overflow-hidden border-b border-neutral-300 pb-2",id:"scene-tree-available-columns-search-bar","data-testid":"scene-tree-available-columns-search-bar",multiline:!1,placeholder:"Filter properties",type:"text",onInputInput:e=>{const t=e.detail.value;null!=t&&w(t.toLowerCase())}}),f&&e.jsx(r.VertexSceneTreeNotificationBanner,{"data-testid":"partial-key-list-notification-banner",message:"loading"===m.state?"Refreshing results...":"Data loading, refresh for more.",actionLabel:"Refresh",onAction:()=>o.refreshKeyList()}),e.jsxs("div",{className:"max-h-64 p-3 overflow-y-auto",children:[e.jsx(VertexSceneTreeMetadataCheck,{checked:!0,disabled:!0,children:va.label}),E.filter((e=>""===b||e.toLowerCase().includes(b))).map((t=>e.jsx(VertexSceneTreeMetadataCheck,{checked:g.includes(t),disabled:g.length>=6&&!g.includes(t),onChange:e=>{v(e?[...g,t]:g.filter((e=>e!==t)))},children:t},t)))]}),e.jsxs("div",{className:"flex items-center p-3 border-t border-neutral-300 space-x-4",children:[e.jsx("div",{className:"text-[0.75rem] text-[var(--vertex-ui-blue-700)] cursor-pointer","data-testid":"scene-tree-column-clear-selection",onClick:()=>v([]),children:"Clear selection"}),e.jsx("div",{className:"flex-grow"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(s.VertexButton,{"data-testid":"scene-tree-column-popover-cancel",color:"secondary",onClick:()=>{w(""),P()},children:"Cancel"}),e.jsx(s.VertexButton,{"data-testid":"scene-tree-column-popover-apply",color:"primary",onClick:async()=>{await i.updateMetadataSearchAfterColumnVisibilityChange(h,g,c),await o.setActive(g),t?.(g),w(""),P()},children:"Apply"})]})]})]})})]})};function VertexToolbarDivider(){return e.jsx("div",{"data-testid":"toolbar-divider",className:"h-6 w-px bg-neutral-300 mx-1"})}const VertexSceneTreeSearchInformationForToolbar=()=>{const t=useSelectionActions(),a=n.useRecoilValue(Cn),o=n.useRecoilValue(Ra),i=n.useRecoilValue(La),r=undefined,l=`${i} ${1===i?"result":"results"}`;return e.jsxs(e.Fragment,{children:[e.jsx(VertexToolbarDivider,{}),e.jsxs("div",{className:"flex flex-row items-center overflow-hidden",children:[e.jsx("div",{className:"px-2 text-[0.8125rem] leading-4 text-neutral-900 truncate","data-testid":"search-result-info",children:`${l}`}),e.jsx(s.VertexTooltip,{className:"w-auto",content:"Select Results",placement:"top",children:e.jsx(s.VertexButton,{className:"h-6 rounded cursor-pointer","data-testid":"select-search-results-button",color:"secondary",variant:"text",size:"sm",onClick:async()=>{null!=a&&null!=o&&(await a.selectFilteredItems(o),t.toggleLastSelectWasMultiSelect(!0))},children:e.jsxs("div",{className:"flex h-6 items-center gap-1",children:[e.jsx(s.VertexIcon,{size:"sm",name:"check-circle"}),e.jsx("span",{className:"whitespace-nowrap",children:"Select Results"})]})})})]})]})},VertexSceneTreeCollapseAll=()=>{const t=n.useRecoilValue(Cn);return e.jsx(s.VertexTooltip,{className:"w-auto",content:"Collapse All",placement:"top",children:e.jsx(s.VertexIcon,{size:"sm",className:"h-6 w-6 hover:bg-neutral-300 rounded cursor-pointer","data-testid":"collapse-all-icon",name:"collapse-all",onClick:()=>{t?.collapseAll()}})})},VertexSceneTreeExpandAll=()=>{const t=n.useRecoilValue(Cn);return e.jsx(s.VertexTooltip,{className:"w-auto",content:"Expand All",placement:"top",children:e.jsx(s.VertexIcon,{size:"sm","data-testid":"expand-all-icon",className:"h-6 w-6 hover:bg-neutral-300 rounded cursor-pointer",name:"expand-all",onClick:()=>{t?.expandAll()}})})},VertexSceneTreeToolbar=({onVisibleSceneTreeColumnsChange:t})=>{const a=n.useRecoilValue(Ra),o=null==a||""===a;return e.jsx(r.VertexSceneTreeToolbar,{className:"h-10 border-b border-neutral-300 box-border",children:e.jsxs("div",{className:"flex w-full text-neutral-700 items-center gap mx-2",children:[e.jsx(VertexSceneTreeExpandAll,{}),e.jsx(VertexSceneTreeCollapseAll,{}),!o&&e.jsx(VertexSceneTreeSearchInformationForToolbar,{}),e.jsx("div",{className:"ml-auto",children:e.jsx(VertexSceneTreeColumnPopover,{onVisibleSceneTreeColumnsChange:t})})]})})},VertexSceneTreeHeader=({onEnterSearchMode:t,onExitSearchMode:n,onSearch:a,onClearSearch:o,onVisibleSceneTreeColumnsChange:s,children:i})=>{const r=null!=i&&!1!==i;return e.jsx("div",{slot:"header",className:"flex flex-col",children:r?i:e.jsxs(e.Fragment,{children:[e.jsx(VertexSceneTreeSearch,{onEnterSearchMode:t,onExitSearchMode:n,onSearch:a,onClearSearch:o,children:e.jsx("div",{slot:"clear-icon"})}),e.jsx(VertexSceneTreeToolbar,{onVisibleSceneTreeColumnsChange:s})]})})};function useMetadataActions(){const e=useActionCallback((({snapshot:e,set:t})=>async n=>{const a=undefined;if(await e.getPromise(la(n)))return;t(la(n),!0);const o=await e.getPromise(oa(n));if(null!=o?.metadata){const e=[...o.metadata];t(sa(n),(t=>[...t,...e]))}const s=o?.cursor;t(ia(n),s),t(la(n),!1)}));return{fetchInitialMetadata:useActionCallback((({snapshot:t})=>async n=>{const a=undefined;0===(await t.getPromise(sa(n))).length&&await e(n)})),fetchNextMetadata:useActionCallback((()=>async t=>{await e(t)}))}}var Wa={exports:{}};!function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function defineProperties(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(e,t,n){return t&&defineProperties(e.prototype,t),n&&defineProperties(e,n),e}}(),a=o,s=_interopRequireDefault(a),i,r=_interopRequireDefault(l);function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _objectWithoutProperties(e,t){var n={};for(var a in e)t.indexOf(a)>=0||Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=e[a]);return n}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var c=function(e){function InfiniteScroll(e){_classCallCheck(this,InfiniteScroll);var t=_possibleConstructorReturn(this,(InfiniteScroll.__proto__||Object.getPrototypeOf(InfiniteScroll)).call(this,e));return t.scrollListener=t.scrollListener.bind(t),t.eventListenerOptions=t.eventListenerOptions.bind(t),t.mousewheelListener=t.mousewheelListener.bind(t),t}return _inherits(InfiniteScroll,e),n(InfiniteScroll,[{key:"componentDidMount",value:function componentDidMount(){this.pageLoaded=this.props.pageStart,this.options=this.eventListenerOptions(),this.attachScrollListener()}},{key:"componentDidUpdate",value:function componentDidUpdate(){if(this.props.isReverse&&this.loadMore){var e=this.getParentElement(this.scrollComponent);e.scrollTop=e.scrollHeight-this.beforeScrollHeight+this.beforeScrollTop,this.loadMore=!1}this.attachScrollListener()}},{key:"componentWillUnmount",value:function componentWillUnmount(){this.detachScrollListener(),this.detachMousewheelListener()}},{key:"isPassiveSupported",value:function isPassiveSupported(){var e=!1,t={get passive(){e=!0}};try{document.addEventListener("test",null,t),document.removeEventListener("test",null,t)}catch(e){}return e}},{key:"eventListenerOptions",value:function eventListenerOptions(){var e=this.props.useCapture;return e=this.isPassiveSupported()?{useCapture:this.props.useCapture,passive:!0}:{passive:!1}}},{key:"setDefaultLoader",value:function setDefaultLoader(e){this.defaultLoader=e}},{key:"detachMousewheelListener",value:function detachMousewheelListener(){var e=window;!1===this.props.useWindow&&(e=this.scrollComponent.parentNode),e.removeEventListener("mousewheel",this.mousewheelListener,this.options?this.options:this.props.useCapture)}},{key:"detachScrollListener",value:function detachScrollListener(){var e=window;!1===this.props.useWindow&&(e=this.getParentElement(this.scrollComponent)),e.removeEventListener("scroll",this.scrollListener,this.options?this.options:this.props.useCapture),e.removeEventListener("resize",this.scrollListener,this.options?this.options:this.props.useCapture)}},{key:"getParentElement",value:function getParentElement(e){var t=this.props.getScrollParent&&this.props.getScrollParent();return null!=t?t:e&&e.parentNode}},{key:"filterProps",value:function filterProps(e){return e}},{key:"attachScrollListener",value:function attachScrollListener(){var e=this.getParentElement(this.scrollComponent);if(this.props.hasMore&&e){var t=window;!1===this.props.useWindow&&(t=e),t.addEventListener("mousewheel",this.mousewheelListener,this.options?this.options:this.props.useCapture),t.addEventListener("scroll",this.scrollListener,this.options?this.options:this.props.useCapture),t.addEventListener("resize",this.scrollListener,this.options?this.options:this.props.useCapture),this.props.initialLoad&&this.scrollListener()}}},{key:"mousewheelListener",value:function mousewheelListener(e){1!==e.deltaY||this.isPassiveSupported()||e.preventDefault()}},{key:"scrollListener",value:function scrollListener(){var e=this.scrollComponent,t=window,n=this.getParentElement(e),a=void 0;if(this.props.useWindow){var o=document.documentElement||document.body.parentNode||document.body,s=void 0!==t.pageYOffset?t.pageYOffset:o.scrollTop;a=this.props.isReverse?s:this.calculateOffset(e,s)}else a=this.props.isReverse?n.scrollTop:e.scrollHeight-n.scrollTop-n.clientHeight;a<Number(this.props.threshold)&&e&&null!==e.offsetParent&&(this.detachScrollListener(),this.beforeScrollHeight=n.scrollHeight,this.beforeScrollTop=n.scrollTop,"function"==typeof this.props.loadMore&&(this.props.loadMore(this.pageLoaded+=1),this.loadMore=!0))}},{key:"calculateOffset",value:function calculateOffset(e,t){return e?this.calculateTopPosition(e)+(e.offsetHeight-t-window.innerHeight):0}},{key:"calculateTopPosition",value:function calculateTopPosition(e){return e?e.offsetTop+this.calculateTopPosition(e.offsetParent):0}},{key:"render",value:function render(){var e=this,t=this.filterProps(this.props),n=t.children,a=t.element,o=t.hasMore;t.initialLoad;var i=t.isReverse,r=t.loader;t.loadMore,t.pageStart;var l=t.ref;t.threshold,t.useCapture,t.useWindow,t.getScrollParent;var c=_objectWithoutProperties(t,["children","element","hasMore","initialLoad","isReverse","loader","loadMore","pageStart","ref","threshold","useCapture","useWindow","getScrollParent"]);c.ref=function(t){e.scrollComponent=t,l&&l(t)};var d=[n];return o&&(r?i?d.unshift(r):d.push(r):this.defaultLoader&&(i?d.unshift(this.defaultLoader):d.push(this.defaultLoader))),s.default.createElement(a,c,d)}}]),InfiniteScroll}(a.Component);c.propTypes={children:r.default.node.isRequired,element:r.default.node,hasMore:r.default.bool,initialLoad:r.default.bool,isReverse:r.default.bool,loader:r.default.node,loadMore:r.default.func.isRequired,pageStart:r.default.number,ref:r.default.func,getScrollParent:r.default.func,threshold:r.default.number,useCapture:r.default.bool,useWindow:r.default.bool},c.defaultProps={element:"div",hasMore:!1,initialLoad:!0,pageStart:0,ref:null,threshold:250,useWindow:!0,isReverse:!1,useCapture:!1,loader:null,getScrollParent:null},t.default=c,e.exports=t.default}(Wa,Wa.exports);var Ga=Wa.exports;const CopyButton=({id:t,textToCopy:n,iconSize:a,disableTooltip:i,onCopyValue:r})=>{const[l,c]=o.useState(!1),d=undefined,u=useDebouncedCallback((()=>{c(!1)}),2e3);return e.jsx(s.VertexTooltip,{className:"h-fit self-center z-[16000]",content:l?"Copied to Clipboard":"Copy",placement:"bottom",disabled:i,children:e.jsx("div",{className:_e({"text-green-700":l}),children:e.jsx(s.VertexIconButton,{className:"ml-auto","data-testid":`${t}-copy-button`,iconName:l?"check":"copy",iconSize:a??"xs",onClick:e=>{e.stopPropagation(),e.preventDefault(),null!=n&&(navigator.clipboard.writeText(n),r?.(n)),c(!0),u(!0)},style:{"--hover-box-shadow":"none"}})})})};function MetadataPropertyValue({value:t,onCopyMetadataValue:n}){const[a,i]=o.useState(!1),r=""!==t.replace(/^\s*$/,"").trim();return r?e.jsxs("div",{className:"flex w-full border-b border-neutral-300 pl-1 pr-3","data-testid":`${t}-metadata-property`,onMouseEnter:()=>{i(!0)},onMouseLeave:()=>i(!1),children:[e.jsx(s.VertexTooltip,{className:"w-full shrink truncate pr-2 py-1.5",content:t,placement:"bottom-start",children:e.jsx("div",{className:"truncate",children:t})}),a&&e.jsx(CopyButton,{id:t,textToCopy:t,onCopyValue:n})]}):e.jsx("div",{className:_e("overflow-visible border-b border-neutral-300 pl-1 pr-4 py-1.5",{"text-neutral-500":!r}),children:"--"})}const MetadataPanelContents=({sceneItemId:t,onCopyMetadataValue:a})=>{const i=useMetadataActions(),r=n.useRecoilValueLoadable(ca),l=n.useRecoilValue(sa(t)),c=n.useRecoilValue(ra(t)),d=n.useRecoilValue(la(t)),u=l?.length>0;function getMessage(){if(!d&&0===l?.length&&"hasValue"===r.state)return"This part does not contain properties"}return o.useEffect((()=>{null!=t&&i.fetchInitialMetadata(t)}),[t]),e.jsxs(e.Fragment,{children:[e.jsx(Ga,{initialLoad:!1,hasMore:c,loadMore:async()=>{c&&await i.fetchNextMetadata(t)},useWindow:!1,children:e.jsxs("div",{className:"flex w-full text-xs leading-5 grow-0",children:[e.jsx(s.VertexResizable,{className:"w-1/2 min-w-24 max-w-full shrink-0",horizontalDirection:"right",verticalDirection:"none",initialHorizontalScale:.5,parentSelector:"#metadata-panel-wrapper",horizontalSiblingSelector:"#metadata-value-column",children:e.jsx("div",{className:"flex flex-col w-full overflow-hidden whitespace-nowrap",children:l.map(((t,n)=>e.jsx(s.VertexTooltip,{className:"border-b border-neutral-300 pl-4 pr-1 py-1.5",content:t.key,placement:"bottom-start",children:e.jsx("div",{className:"truncate",children:t.key})},n)))})}),e.jsx("div",{id:"metadata-value-column",className:"flex flex-col w-full min-w-24",children:l.map(((t,n)=>e.jsx(MetadataPropertyValue,{value:t.value,onCopyMetadataValue:a},n)))})]})}),!u&&e.jsx("div",{className:"w-full h-full flex items-center justify-center px-4 text-center text-sm",children:getMessage()})]})},MetadataPanel=({onCopyMetadataValue:t})=>{const a=usePanelActions(),o=n.useRecoilValue(wt),i=n.useRecoilValueLoadable(ca);return e.jsxs("div",{id:"metadata-panel-wrapper","data-testid":"metadata-panel-wrapper",className:"w-full h-full flex flex-col mt-auto text-neutral-800",children:[e.jsxs("div",{className:"flex h-10 border-b border-neutral-300 p-3 pl-4 text-[0.875rem] items-center",children:["hasValue"===i.state&&e.jsx("span",{className:"flex flex-col w-full",children:e.jsx(s.VertexTooltip,{content:i.contents,children:e.jsx("div",{className:"truncate",children:i.contents||""})})}),"loading"===i.state&&e.jsx("div",{className:"flex items-center w-full h-full",children:e.jsx("div",{className:"w-1/2 h-1/2 bg-neutral-300 animate-pulse rounded"})}),e.jsx(s.VertexIcon,{className:"ml-auto cursor-pointer",onClick:a.closeSecondary,name:"close",size:"sm"})]}),e.jsxs("div",{className:"w-full h-full overflow-y-auto overflow-x-hidden",children:[null!=o&&e.jsx(MetadataPanelContents,{sceneItemId:o.id,onCopyMetadataValue:t}),null==o&&e.jsx("div",{className:"w-full h-full flex items-center justify-center px-4 text-center text-sm",children:"Please select a single part or assembly to view its metadata"})]})]})},SceneTreeSecondaryPanel=({panelId:t,onCopyMetadataValue:n})=>e.jsx(s.VertexResizable,{"data-testid":"scene-tree-secondary-panel",className:"min-h-20 max-h-full flex-shrink-0 border-t border-neutral-300",horizontalDirection:"none",verticalDirection:"top",initializeWithOffset:!0,initialVerticalScale:.6,parentSelector:`#${t}`,verticalSiblingSelector:"#scene-tree-container",children:e.jsx(MetadataPanel,{onCopyMetadataValue:n})}),VertexSceneTreeCustomColumn=({label:t,rowDataBinding:a,expandToggle:s,visibilityToggle:i,isolateButton:l,modelViewsButton:c,initialWidth:d,minWidth:u})=>{const m=n.useRecoilValue(Cn);return o.useEffect((()=>{m?.invalidateRows()}),[a]),e.jsxs(r.VertexSceneTreeTableColumn,{"data-testid":`scene-tree-table-column-${t}`,initialWidth:d,minWidth:u,children:[e.jsx("template",{slot:"header",dangerouslySetInnerHTML:{__html:`\n <div class="text-sm text-neutral-800 my-2">\n <div class="${_e("truncate",{"pl-2":s,"pr-2":i})}">\n ${t}\n </div>\n </div>\n `}}),e.jsx("template",{dangerouslySetInnerHTML:{__html:`\n <vertex-scene-tree-table-cell\n prop:value="${a}"\n prop:selection-handler="{{row.data.handleSelection}}"\n prop:expansion-handler="{{row.data.handleExpansion}}"\n prop:visibility-handler="{{row.data.handleVisibility}}"\n ${s?"expand-toggle":""}\n ${i?"visibility-toggle":""}\n ${l?"isolate-button":""}\n >\n <div class="flex items-center gap-2">\n <vertex-tooltip \n class="truncate" \n prop:content="${null!=a?a:"--"}" \n placement="${i?"right":"top"}">\n <div class="flex items-center w-full">\n <div class="truncate">${a}</div>\n </div>\n </vertex-tooltip>\n\n ${c?'<div attr:style={{row.data.modelViewIndicatorStyle}}> \n <vertex-tooltip class="block w-full truncate" content="Listing Model Views" placement="bottom">\n <vertex-icon-button\n class="ml-auto mr-0.5 text-neutral-800"\n event:pointerup="{{row.data.handleShowModelViews}}"\n icon-name="views"\n icon-size="sm"\n variant="plain"\n >\n </vertex-icon-button>\n </vertex-tooltip>\n </div>':""}\n </div>\n\n <div slot="placeholder" class="flex items-center w-full truncate">\n <div> -- </div>\n </div>\n </vertex-scene-tree-table-cell>\n `}})]},t)},VertexSceneTreeMetadataColumns=({children:t})=>{const a=n.useRecoilValue(ja),o=n.useRecoilValue(ka),s=[],i=o.filter((e=>e!==va.label)).map((e=>a[e]));return null!=t?e.jsx(e.Fragment,{children:t({columns:i.map((e=>({key:e.label,initialWidth:e.initialWidth,minWidth:e.minWidth})))})}):e.jsx(e.Fragment,{children:i.map(((t,n)=>{const a=s[n]??t.initialWidth;return e.jsx(VertexSceneTreeCustomColumn,{label:t.label,visibilityToggle:n===i.length-1,isolateButton:n===i.length-1,rowDataBinding:t.binding,initialWidth:a,minWidth:t.minWidth},t.label)}))})},VertexSceneTreeTableLayout=t=>{const{children:a,...s}=t,i=n.useRecoilValue(ja),l=n.useRecoilValue(ka),c=o.useMemo((()=>findChildElement(a,NameColumn)),[a]),d=o.useMemo((()=>findChildElement(a,MetadataColumns)),[a]),u=i[va.label]??va,m=l.filter((e=>e!==va.label)).map((e=>i[e]));return e.jsxs(r.VertexSceneTreeTableLayout,{"data-testid":"scene-tree-table-layout",...s,children:[c?cloneChildNodeOrFunction(c.props.children,{columnCount:l.length,initialWidth:u.initialWidth,minWidth:u.minWidth}):e.jsx(VertexSceneTreeCustomColumn,{expandToggle:!0,visibilityToggle:1===l.length,isolateButton:1===l.length,rowDataBinding:u.binding,label:u.label,initialWidth:u.initialWidth,minWidth:u.minWidth}),null!=d?cloneChildNodeOrFunction(d.props.children,{columns:m.map((e=>({key:e.label,initialWidth:e.initialWidth,minWidth:e.minWidth})))}):e.jsx(VertexSceneTreeMetadataColumns,{})]})},NameColumn=({children:t})=>e.jsx(e.Fragment,{children:t}),MetadataColumns=({children:t})=>e.jsx(e.Fragment,{children:t});VertexSceneTreeTableLayout.NameColumn=NameColumn,VertexSceneTreeTableLayout.MetadataColumns=MetadataColumns;const VertexSceneTree=({id:t,font:a,backgroundColors:s,additionalLoadedMetadataProperties:i,whitelistedMetadataProperties:l,allowViewingMetadataPropertiesPanel:c,children:d,style:u,onPointerDown:m,onClick:p,onToggleSelection:h,onToggleExpansion:f,onToggleVisibility:g,onCopyMetadataValue:v,className:b,rowData:w,...C})=>{const S=usePanelActions(),V=useSceneTreeActions(),j=useSelectionActions(),k=n.useRecoilValue(ga),T=n.useRecoilValue(G),A=n.useRecoilValue(ta),P=n.useRecoilValue(Ha),I=n.useRecoilValue(_a),M=n.useRecoilValue(Na),E=n.useRecoilValue(Oa),R=n.useRecoilValue(Ra),N=null==R||""===R,O=useRecoilRef({state:Cn}),L=o.useMemo((()=>findChildElement(d,Header)),[d]),_=o.useMemo((()=>findChildElement(d,TableLayout)),[d]),B=o.useMemo((()=>findChildElement(d,ContextMenu)),[d]),wrappedExpansionHandler=(e,t,n)=>{V.toggleExpansion(e,t,n),f?.(e,t,n)},wrappedSelectionHandler=(e,t,n)=>{V.toggleSelection(e,t,n),h?.(e,t,n)},wrappedVisibilityHandler=(e,t,n)=>{V.toggleVisibility(e,t,n),g?.(e,t,n)},handleClick=async e=>{e.altKey&&await V.flyToRow(e.clientY),p?.(e)},handlePointerDown=async e=>{targetIsElement(e.target,"VERTEX-SCENE-TREE-TABLE-COLUMN")&&await j.clearSelection(),m?.(e)},D=n.useSetRecoilState(Sn),handleFirstRowRendered=e=>{D(e.target.controller),C?.onFirstRowRendered?.(e)},F=o.useMemo((()=>({metadataSearchKeys:I,exactMatch:M,removeHiddenItems:E})),[I,M,E]);useStateSyncedValue(wa,l,{transform:e=>e.sort(((e,t)=>e.localeCompare(t)))}),useStateSyncedValue(aa,c),useStateSyncedValue(Fa,i);const H=n.useRecoilValue(Nt),U=o.useCallback((e=>{e.preventDefault(),e.stopPropagation(),S.openPrimary("model-views","right")}),[S]);return e.jsxs("div",{id:"scene-tree-panel",className:"flex flex-col w-full h-full grow-0",children:[e.jsx("div",{id:"scene-tree-container",className:"flex group h-full min-h-32 overflow-auto",children:e.jsxs(r.VertexSceneTree,{id:t??"vertex-scene-tree","data-testid":"vertex-scene-tree",config:k,ref:O,className:_e("flex-1",{filtered:!N}),style:{...styleFromOptionalFont(a),...styleFromOptionalBackgroundColors(s),...u},onConnectionError:e=>{logger_error("Scene Tree Connection Error: ",e.detail)},viewer:T,onPointerDown:handlePointerDown,onClick:handleClick,rowData:e=>{const t=w?.(e)??{};return{handleExpansion:wrappedExpansionHandler,handleSelection:wrappedSelectionHandler,handleVisibility:wrappedVisibilityHandler,handleShowModelViews:U,modelViewIndicatorStyle:e?.node.id?.hex===H?.id?"display: flex;":"display: none;",...t}},searchOptions:F,metadataKeys:P,...C,onFirstRowRendered:handleFirstRowRendered,children:[L??e.jsx(VertexSceneTreeHeader,{}),_??e.jsx(VertexSceneTreeTableLayout,{}),B??e.jsx(VertexSceneTreeContextMenu,{})]})}),void 0!==A&&e.jsx(SceneTreeSecondaryPanel,{panelId:"scene-tree-panel",onCopyMetadataValue:v})]})},Header=({children:t})=>e.jsx(e.Fragment,{children:t}),TableLayout=({children:t})=>e.jsx(e.Fragment,{children:t}),ContextMenu=({children:t})=>e.jsx(e.Fragment,{children:t});VertexSceneTree.Header=Header,VertexSceneTree.TableLayout=TableLayout,VertexSceneTree.ContextMenu=ContextMenu;const VertexDecimalPlaceSelector=({onApply:t})=>{const[a,o]=n.useRecoilState(_t);return e.jsxs(s.VertexSelect,{"data-testid":"decimal-place-select",className:"w-24",value:a,onOptionChanged:e=>{o(e.detail),t?.(e.detail)},children:[e.jsx("div",{className:"py-1.5 px-3",children:"0"}),e.jsx("div",{className:"py-1.5 px-3",children:"1"}),e.jsx("div",{className:"py-1.5 px-3",children:"2"}),e.jsx("div",{className:"py-1.5 px-3",children:"3"})]})},VertexLengthUnitSelector=({onApply:t})=>{const[a,o]=n.useRecoilState(Lt);return e.jsxs(s.VertexSelect,{"data-testid":"length-unit-select",className:"w-40",value:a,onOptionChanged:e=>{o(e.detail),t?.(e.detail)},children:[e.jsx("div",{"data-value":"cm",className:"py-1.5 px-3",children:"centimeters"}),e.jsx("div",{"data-value":"mm",className:"py-1.5 px-3",children:"millimeters"}),e.jsx("div",{"data-value":"m",className:"py-1.5 px-3",children:"meters"}),e.jsx("div",{"data-value":"in",className:"py-1.5 px-3",children:"inches"}),e.jsx("div",{"data-value":"ft",className:"py-1.5 px-3",children:"feet"})]})};function VertexUnitsControls({onUnitChange:t,onDecimalPlaceChange:n}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Length Unit"}),e.jsx(VertexLengthUnitSelector,{onApply:t})]}),e.jsxs("div",{children:[e.jsx("div",{className:"pt-2 pb-2 text-sm text-neutral-700",children:"Decimals"}),e.jsx(VertexDecimalPlaceSelector,{onApply:n})]})]})}function VertexUnitsPanelSection({onUnitChange:t,onDecimalPlaceChange:n}){return e.jsx(PanelSection,{header:e.jsx("div",{className:"flex items-center text-base",children:"Units"}),children:e.jsx(VertexUnitsControls,{onUnitChange:t,onDecimalPlaceChange:n})})}function useModelViewActions(){const e=usePmiAnnotationActions(),t=useSelectionActions();return{fetchNextModelViews:useActionCallback((({snapshot:e,set:t})=>async n=>{const a=await e.getPromise(hn(n));if(null!=a){const e=a?.paging?.next;null!=e&&(t(cn(n),(e=>[...e,a])),t(rn(n),(()=>e)))}})),loadModelView:useActionCallback((({set:n,snapshot:a})=>async(o,s)=>{const i=await a.getPromiseRequired(G),r=await a.getPromiseRequired(bt);try{await(i?.modelViews?.load(o,s.id)),n(pn,{itemId:o,modelView:s}),await e.clearPmiAnnotationSelection(),0!==r.length&&await t.clearSelection(),await e.fetchInitialPmiAnnotations(s.id)}catch(e){logger_error("Failed to load model view",e)}})),clearModelView:useActionCallback((({reset:t,snapshot:n})=>async()=>{const a=undefined;if(null!=await n.getPromise(pn)){const a=await n.getPromiseRequired(G);try{await(a?.modelViews?.unload()),t(pn),await e.clearPmiAnnotationSelection()}catch(e){logger_error("Failed to remove model view",e)}}}))}}var Ka=Object.freeze({__proto__:null,hasMoreModelViews:fn,hasMorePmiAnnotations:vn,loadedItemModelView:pn,loadedModelViews:cn,loadedPmiAnnotations:dn,modelViews:xn,modelViewsCursor:rn,modelViewsSceneItemName:mn,nextModelViews:hn,nextPmiAnnotations:gn,pmiAnnotations:yn,pmiAnnotationsCursor:ln,selectedPmiAnnotationId:bn,useModelViewActions:useModelViewActions,visiblePmiAnnotations:un});function FileWithMagnifyingGlassImage(){return e.jsx("div",{children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"160",height:"160",viewBox:"0 0 220 220",children:[e.jsx("path",{fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":".75",d:"M38.84 186.31h143.29m-155.07 5.14h176.49M1 196.58h218m-205.11 5.14h185.22m-162.74 5.13h141.84"}),e.jsx("path",{fill:"#f7fcfd",d:"m150.94 50.25 20.43 19.51a3.42 3.42 0 0 1 1 2.46v121.2a5.23 5.23 0 0 1-5.23 5.23H52.78a5.23 5.23 0 0 1-5.23-5.23V54.56a5.24 5.24 0 0 1 5.23-5.24h95.81a3.44 3.44 0 0 1 2.35.93"}),e.jsx("path",{fill:"none",stroke:"#006bad","stroke-dasharray":"3 3","stroke-linecap":"round","stroke-linejoin":"round",d:"m150.94 50.25 20.43 19.51a3.42 3.42 0 0 1 1 2.46v121.2a5.23 5.23 0 0 1-5.23 5.23H52.78a5.23 5.23 0 0 1-5.23-5.23V54.56a5.24 5.24 0 0 1 5.23-5.24h95.81a3.44 3.44 0 0 1 2.35.93"}),e.jsx("path",{d:"M79.12 123.99H110v30.88H79.12z",fill:"#e0f3f9"}),e.jsx("path",{d:"M110 153.37v1.5h-1.5",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{d:"M105.4 154.87H82.17",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round","stroke-dasharray":"3.1 3.1"}),e.jsx("path",{d:"M80.62 154.87h-1.5v-1.5",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{d:"M79.12 150.27v-23.23",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round","stroke-dasharray":"3.1 3.1"}),e.jsx("path",{d:"M79.12 125.49v-1.5h1.5",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{d:"M83.72 123.99h23.23",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round","stroke-dasharray":"3.1 3.1"}),e.jsx("path",{d:"M108.5 123.99h1.5v1.5",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{d:"M110 128.59v23.23",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round","stroke-dasharray":"3.1 3.1"}),e.jsx("path",{d:"M110 123.99h30.88v30.88H110z",fill:"#e0f3f9"}),e.jsx("path",{d:"M140.88 153.37v1.5h-1.5",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{d:"M136.28 154.87h-23.23",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round","stroke-dasharray":"3.1 3.1"}),e.jsx("path",{d:"M111.5 154.87H110v-1.5",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{d:"M110 150.27v-23.23",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round","stroke-dasharray":"3.1 3.1"}),e.jsx("path",{d:"M110 125.49v-1.5h1.5",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{d:"M114.6 123.99h23.23",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round","stroke-dasharray":"3.1 3.1"}),e.jsx("path",{d:"M139.38 123.99h1.5v1.5",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{d:"M140.88 128.59v23.23",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round","stroke-dasharray":"3.1 3.1"}),e.jsx("path",{d:"M110 93.11h30.88v30.88H110z",fill:"#e0f3f9"}),e.jsx("path",{d:"M140.88 122.49v1.5h-1.5",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{d:"M136.28 123.99h-23.23",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round","stroke-dasharray":"3.1 3.1"}),e.jsx("path",{d:"M111.5 123.99H110v-1.5",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{d:"M110 119.39V96.15",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round","stroke-dasharray":"3.1 3.1"}),e.jsx("path",{d:"M110 94.61v-1.5h1.5",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{d:"M114.6 93.11h23.23",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round","stroke-dasharray":"3.1 3.1"}),e.jsx("path",{d:"M139.38 93.11h1.5v1.5",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{d:"M140.88 97.7v23.24",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round","stroke-dasharray":"3.1 3.1"}),e.jsx("path",{d:"M150.91 50.28a3.6 3.6 0 0 1 .86 1.22",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{fill:"none",stroke:"#006bad","stroke-dasharray":"2.87 2.87","stroke-linecap":"round","stroke-linejoin":"round",d:"M152.05 54.34v9.14a5.24 5.24 0 0 0 5.24 5.23h9.94"}),e.jsx("path",{d:"M168.67 68.71h.2a3.5 3.5 0 0 1 1.27.23M19.8 78.25l1.93 14.68-14.67 1.93",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{d:"M21.73 92.93S-2.15 82.45 4.05 54.82",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{fill:"none",stroke:"#b43296","stroke-linecap":"round","stroke-linejoin":"round",d:"M14.89 132.63h5.88v5.88h-5.88z"}),e.jsx("path",{fill:"none",stroke:"#f90","stroke-linecap":"round","stroke-linejoin":"round",d:"M174.49 36v5.88m-2.94-2.94h5.88"}),e.jsx("circle",{cx:"199.1",cy:"164.76",r:"2.45",fill:"none",stroke:"#0c0","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{d:"M109.68 25.74V11.9M87.12 29.74l-6.02-9.4m53.21 9.4 6.01-9.4",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{fill:"#eff9fc",stroke:"#006bad","stroke-linejoin":"round",d:"m140.43 139.69 7.22 5.8-8.28 10.31-7.22-5.8"}),e.jsx("circle",{cx:"110.2",cy:"124.35",r:"27.74",fill:"#e0f3f9",opacity:".7"}),e.jsx("path",{fill:"#fff",stroke:"#006bad","stroke-linejoin":"round",d:"M131.2 98.19a33.55 33.55 0 1 0 5.16 47.16 33.56 33.56 0 0 0-5.16-47.16Zm.63 43.52a27.73 27.73 0 1 1-4.26-39 27.73 27.73 0 0 1 4.26 39ZM187 173.84a29.8 29.8 0 0 1-4.19 7.52 29.3 29.3 0 0 1-7.24 6.71l-37.77-30.31a29.3 29.3 0 0 1 5-8.56 29.6 29.6 0 0 1 6.4-5.67Z"}),e.jsx("path",{fill:"none",stroke:"#fff","stroke-linecap":"round","stroke-miterlimit":"10",d:"m118.82 138.09 12.51-15.58m-38.56-3.68 6.94-8.65m-5.32 1.9 6.95-8.66m16.23 42.44 12.5-15.58"}),e.jsx("path",{fill:"#fff",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round",d:"M139.92 153.31a28.4 28.4 0 0 0-2.12 4.45m7.07-.49a38 38 0 0 0-2.35 4.28m7.3-.32c-.93 1.34-1.79 2.72-2.58 4.11m7.53-.15q-1.47 2-2.81 3.94m7.75.01-3 3.78m7.95.18c-1.07 1.24-2.16 2.45-3.26 3.61m8.21.35a54 54 0 0 1-3.49 3.44m8.44.5a37 37 0 0 1-3.72 3.26m8.67.74a29 29 0 0 1-3.95 3.09"}),e.jsx("path",{d:"m196.69 115.8-2.18 14.64 14.64 2.18",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{d:"M194.51 130.44s23.76-12 21.9-35.66",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"})]})})}function ModelViewsEmptyState({itemSelected:t}){const n=t?"There are no model views associated with this part.":"Select a part to access model views.";return e.jsxs("div",{"data-testid":"pmi-views-empty-state",className:"h-full w-full px-4 flex flex-col gap-2 justify-center items-center overflow-y-auto",children:[e.jsx(FileWithMagnifyingGlassImage,{}),e.jsx("div",{className:"text-base text-neutral-700 text-center px-3 pt-2.5 pb-1.5",children:"No Model Views"}),e.jsx("div",{className:"text-[0.8125rem] text-neutral-600 text-center px-3 pb-2.5",children:n})]})}const VertexModelViewsViewRow=({view:t,currentlyViewing:n,itemId:a,onLoadModelView:o,onClearModelView:i})=>{const r=useModelViewActions();return e.jsx("div",{"data-testid":`model-view-${t.id}`,onClick:async()=>{n?(await r.clearModelView(),i?.()):(await r.loadModelView(a,t),o?.(a,t.id))},className:_e("flex flex-col w-full h-8 p-1 pl-4 cursor-pointer text-neutral-700 text-[0.8125rem] hover:text-[var(--vertex-ui-blue-600)]",{"bg-[var(--vertex-ui-blue-200)]":n,"hover:bg-[var(--vertex-ui-blue-100)]":!n}),children:e.jsxs("div",{className:_e("flex w-full h-full items-center",{"text-neutral-900 font-extrabold":n}),children:[e.jsxs(s.VertexTooltip,{className:"flex w-20 grow","data-testid":`model-view-${t.id}-tooltip`,placement:"bottom-start",content:t.displayName,children:[e.jsx(s.VertexIcon,{name:"views",size:"sm"}),e.jsx("div",{className:"truncate mx-2",children:t.displayName}),e.jsx("span",{className:"font-normal text-neutral-700 ml-auto pr-1",children:n&&"(Viewing)"})]}),n&&e.jsx("div",{className:"ml-auto pr-1",children:e.jsx(s.VertexIconButton,{"data-testid":"model-views-clear-selection",iconSize:"sm",iconName:"close",onClick:async()=>await r.clearModelView()})})]})},t.id)};function VertexModelViewsList({itemId:t,onLoadModelView:a,onClearModelView:o}){const i=useModelViewActions(),r=n.useRecoilValue(pn),l=n.useRecoilValue(xn(t)),c=n.useRecoilValue(fn(t)),d=n.useRecoilValueLoadable(mn),u=0===l.length;return e.jsxs("div",{className:"w-full h-full flex flex-col",children:[("hasValue"!==d.state||null!=d.contents)&&e.jsxs("div",{className:"flex flex-row h-11 w-full border-b border-neutral-300 p-3 pl-4 mr-2 text-sm items-center",children:["hasValue"===d.state&&e.jsx("div",{className:"truncate items-center",children:e.jsx(s.VertexTooltip,{content:d.contents,children:e.jsx("div",{className:"truncate",children:d.contents||""})})}),"loading"===d.state&&e.jsx("div",{className:"flex items-center h-11 w-full",children:e.jsx("div",{className:"w-3/4 h-3 bg-neutral-300 animate-pulse rounded"})})]}),u&&e.jsx(ModelViewsEmptyState,{itemSelected:!0}),!u&&e.jsx("div",{className:"h-full overflow-y-auto",children:e.jsx(Ga,{hasMore:c,loadMore:()=>{i.fetchNextModelViews(t)},useWindow:!1,children:l.map((n=>{const s=r?.modelView?.id.toString(),i=s===n?.id;return e.jsx(VertexModelViewsViewRow,{view:n,currentlyViewing:i,itemId:t,onLoadModelView:a,onClearModelView:o},n.id)}))})})]})}const VertexPMIAnnotationRow=({annotation:t,checked:n,onCheckedChange:a,selected:o,onSelectedChange:i})=>e.jsxs("div",{id:`annotation-entry-${t.id}`,"data-testid":`annotation-entry-${t.displayName}`,className:_e("flex items-center w-full h-7 gap-2.5 pl-4 pr-2 cursor-default hover:text-[var(--vertex-ui-blue-600)]",{"bg-[var(--vertex-ui-blue-200)]":o,"hover:bg-[var(--vertex-ui-blue-100)]":!o}),onClick:()=>i(!o),children:[e.jsx(s.VertexToggle,{"data-testid":`annotation-entry-${t.displayName}-check`,variant:"check",checked:n,onClick:e=>e.stopPropagation(),onValueChanged:e=>{a(e.detail)}}),e.jsx("div",{className:"w-1/2 flex-grow",children:e.jsx(s.VertexTooltip,{content:t.displayName,placement:"bottom-start",children:e.jsx("div",{className:"truncate",children:t.displayName})})})]}),VertexPMIAnnotationsSecondaryPanel=({modelViewId:t,parentPanelId:a,verticalSiblingId:o,sceneAnnotationOperations:i,onToggleSelectionOfPMIAnnotation:r,onToggleVisibilityOfPMIAnnotation:l})=>{const c=usePmiAnnotationActions(),d=n.useRecoilValue(G),m=n.useRecoilValue(yn(t)),p=n.useRecoilValue(vn(t)),h=n.useRecoilValue(bn),[f,g]=n.useRecoilState(un(t)),[v,b]=u.useState("");u.useEffect((()=>{t!==v&&(g(m),b(t))}),[m,v,t,g,b]);const toggleVisibilityOfAllAnnotations=e=>{e?(g(m),i?.sceneAnnotationsOperation((e=>e.show()),d)):(g([]),i?.sceneAnnotationsOperation((e=>e.hide()),d))};return e.jsx(s.VertexResizable,{"data-testid":"pmi-annotation-secondary-panel",className:"min-h-28 max-h-3/4 flex-shrink-0 border-t text-sm text-neutral-700",horizontalDirection:"none",verticalDirection:"top",initializeWithOffset:!0,initialVerticalScale:.6,parentSelector:`#${a}`,verticalSiblingSelector:`#${o}`,children:e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsx("div",{className:"flex items-center w-full h-9 border-b border-[var(--vertex-ui-neutral-300)] px-4 shrink-0",children:"3D PMI"}),e.jsxs("div",{"data-testid":"display-all-annotations",className:"flex items-center w-full h-8 gap-2.5 px-4 py-1.5 cursor-default border-b border-[var(--vertex-ui-neutral-300)]",onClick:()=>{const e=m.length!==f.length;toggleVisibilityOfAllAnnotations(e)},children:[e.jsx(s.VertexToggle,{"data-testid":"display-all-annotations-check",variant:"check",checked:m.length===f.length,onClick:e=>e.stopPropagation(),onValueChanged:e=>{toggleVisibilityOfAllAnnotations(e.detail)}}),"Display All"]}),e.jsx("div",{className:"h-full overflow-y-auto text-[0.8125rem] py-1",children:e.jsx(Ga,{hasMore:p,loadMore:async()=>{p&&await c.fetchNextPmiAnnotations(t)},useWindow:!1,children:m.map(((n,a)=>e.jsx(VertexPMIAnnotationRow,{annotation:n,checked:f.includes(n),onCheckedChange:e=>{e?(g([...f,n]),i?.sceneAnnotationsOperation((e=>e.show()),d,[n.id])):(g(f.filter((e=>e!==n))),i?.sceneAnnotationsOperation((e=>e.hide()),d,[n.id])),l?.(t,n.id,e)},selected:n.id===h,onSelectedChange:async e=>{e?await c.selectPmiAnnotation(n.id,!1):await c.clearPmiAnnotationSelection(),r?.(t,n.id,e)}},a)))})})]})})},VertexModelViewsPanelSection=({onLoadModelView:t,onClearModelView:a,onToggleSelectionOfPMIAnnotation:o,onToggleVisibilityOfPMIAnnotation:s})=>{const i=useSceneAnnotationsOperations(),r=n.useRecoilValue(Nt),l=null!=r?.id,c=n.useRecoilValue(pn),d=c?.itemId===r?.id;return e.jsxs("div",{id:"model-views-panel-wrapper",className:"w-full h-full flex flex-col text-neutral-800",children:[e.jsxs("div",{"data-testid":"model-views-container",className:"group h-full flex overflow-auto min-h-29 relative",children:[l&&e.jsx(u.Suspense,{fallback:e.jsx(ModelViewsItemListLoading,{}),children:e.jsx(VertexModelViewsList,{itemId:r.id,onLoadModelView:t,onClearModelView:a})}),!l&&e.jsx(ModelViewsEmptyState,{itemSelected:!1})]}),null!=c&&d&&e.jsx(u.Suspense,{fallback:e.jsx(ModelViewsItemListLoading,{}),children:e.jsx(VertexPMIAnnotationsSecondaryPanel,{modelViewId:c.modelView.id,parentPanelId:"model-views-panel-wrapper",verticalSiblingId:"model-views-container",sceneAnnotationOperations:i,onToggleSelectionOfPMIAnnotation:o,onToggleVisibilityOfPMIAnnotation:s})})]})};function ModelViewsItemListLoading(){return e.jsxs("div",{className:"flex flex-col w-full h-full items-center justify-center text-[0.8125rem] overflow-y-auto",children:[e.jsx(s.VertexSpinner,{"data-testid":"model-views-panel-spinner",size:"lg",color:"grey"}),e.jsx("div",{className:"pt-3 px-10 text-center",children:"Loading model views for the selected part..."})]})}function VertexModelViewsPanel(){return e.jsx("div",{className:"flex flex-col text-neutral-700 h-full overflow-y-auto",children:e.jsx(VertexModelViewsPanelSection,{})})}function ColorSwatchContextMenu({onRemoveCustomColor:t}){const a=useContextMenuActions(),o=useSceneItemMaterialActions(),i=n.useRecoilValue(Ge);return e.jsx(VertexContextMenu,{menuType:"color-swatch",onOpen:e=>{elementIsColorSwatch(e.target)&&a.setContextMenuItem(e.target)},openPredicate:e=>elementIsColorSwatch(e.target)&&elementHasColorAttribute(e.target),disableBackdrop:!0,children:e.jsx(s.VertexMenuItem,{"data-testid":"color-swatch-delete",onClick:async()=>{if(contextMenuItemIsElement(i)&&elementIsColorSwatch(i)){const e=i?.getAttribute("data-color-id");null!=e&&"true"===i.getAttribute("data-custom-color")?(await o.removeCustomColor(e),t?.(e)):null!=e&&"true"===i.getAttribute("data-recent-color")&&await o.removeRecentColor(e)}},children:e.jsxs("div",{className:"flex align-middle gap-2.5",children:[e.jsx(s.VertexIcon,{slot:"icon",name:"delete",size:"sm"}),"Delete"]})})})}function DefaultAppearancePanel(){return e.jsxs("div",{className:"flex flex-col text-neutral-700 h-full overflow-y-auto",children:[e.jsx(VertexMaterialPanelSection,{}),e.jsx(VertexGhostingPanelSection,{}),e.jsx(VertexFeatureEdgesPanelSection,{}),e.jsx(VertexViewerBackgroundPanelSection,{}),e.jsx(VertexSelectionHighlightingPanelSection,{}),e.jsx(VertexCrossSectionAppearancePanelSection,{}),e.jsx(ColorSwatchContextMenu,{})]})}function DefaultSettingsPanel(){return e.jsx("div",{className:"flex flex-col text-neutral-700 h-full overflow-y-auto",children:e.jsx(VertexUnitsPanelSection,{})})}const VertexTransformClear=({onClear:t,onClearAll:a})=>{const i=useTransformActions(),r=useCacheableLoadable(Rt),l=n.useRecoilValue(Tt),c=useCacheableLoadable(Yt(l??"")),d=o.useMemo((()=>{const e=r.data?.some((e=>null!=e?.override?.transform)),t=null!=c.data;return e||t}),[r,c]);return e.jsx("div",{className:"ml-auto",children:e.jsxs(ResetButton,{id:"transforms",tooltip:"Clear Transforms",children:[e.jsx("div",{className:"pt-1"}),e.jsx(s.VertexMenuItem,{"data-testid":"clear-selected-transforms",onClick:async()=>{await i.clearSelectedTransforms(),t?.()},disabled:!d,children:"Clear selected transforms"}),e.jsx(s.VertexMenuItem,{"data-testid":"clear-all-transforms",onClick:async()=>{await i.clearAllTransforms(),a?.()},children:"Clear all transforms"})]})})},VertexTransformNumericField=({bottomLabel:t,value:a,step:s,min:i,max:r,disabled:l,testId:c,onBlur:d,onInput:u,onChange:m})=>{const p=o.useRef(null),h=n.useRecoilValue(_t),[f,g]=o.useState(!0);o.useEffect((()=>{const e=null!=p.current&&Number.isNaN(p.current.valueAsNumber),t=f||e;null!=p.current&&t?p.current.value=a?.toFixed(Number(h))??"":g(!0)}),[a]);const v=o.useCallback((e=>{g(!1),m?.(e)}),[g,m]),b=o.useCallback((e=>{g(!0),d?.(e),null!=p.current&&null!=a&&(p.current.value=a.toFixed(Number(h)))}),[d,a,g]);return e.jsxs("div",{children:[e.jsx("div",{className:"truncate rounded-md w-full",children:e.jsx("input",{ref:p,className:"w-full truncate border border-neutral-400 rounded-md px-2 py-1.5 hover:border-neutral-500 focus:border-neutral-500 focus:outline-none",type:"number",step:s,min:i,max:r,"data-testid":c,disabled:l,defaultValue:Number.isNaN(a)?"":a?.toFixed(Number(h)),onBlur:b,onInput:u,onChange:v})}),null!=t&&e.jsx("div",{className:"flex justify-center items-center pointer-events-none text-neutral-500",children:e.jsx("span",{children:t})})]})},VertexTransformInputs=({onUpdateTransform:t})=>{const a=n.useRecoilValue(Lt),o=n.useRecoilValue(Vt),s=n.useRecoilValue(St),i=o||s,r=n.useRecoilValue(Tt),{transform:l,error:c,update:d}=useEditItemTransform(r),u=i?void 0:l,m=useDebouncedCallback((async e=>{await d(e),t?.(e)}),50);function updateTransform(e){return t=>{if(null!=u){const n=parseFloat(t.currentTarget.value);Number.isNaN(n)||m?.({...u,...e(n,u)})}}}function updatePosition(e){return updateTransform(((t,n)=>({position:{...n.position,...e(t)}})))}function updateRotation(e){return updateTransform(((t,n)=>({rotation:{...n.rotation,...e(t)}})))}function updateScale(){return updateTransform((e=>e>0?{scale:e}:{}))}function updateToDefaultValueIfInvalid(e,t){return n=>{const a=parseFloat(n.currentTarget.value),o=undefined;(isNaN(a)||!!t?.(a))&&null!=u&&m(v.defaults(e,u))}}return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 text-[0.8125rem]",children:[e.jsx("span",{className:"flex w-full items-center mt-3 mb-1",children:"Position"}),e.jsxs("div",{className:"flex flex-wrap w-full gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"X"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"position-x",value:null!=u?u.position.x:void 0,bottomLabel:a,disabled:null==u,onChange:updatePosition((e=>({x:e}))),onBlur:updateToDefaultValueIfInvalid({position:{x:0}})})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"Y"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"position-y",value:u?.position.y,bottomLabel:a,disabled:null==u,onChange:updatePosition((e=>({y:e}))),onBlur:updateToDefaultValueIfInvalid({position:{y:0}})})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"Z"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"position-z",value:u?.position.z,bottomLabel:a,disabled:null==u,onChange:updatePosition((e=>({z:e}))),onBlur:updateToDefaultValueIfInvalid({position:{z:0}})})})]})]})]}),e.jsxs("div",{className:"mb-2 text-[0.8125rem]",children:[e.jsx("span",{className:"flex w-full items-center mt-3 mb-1",children:"Rotation"}),e.jsxs("div",{className:"flex flex-wrap w-full gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"X"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"rotation-x",value:u?.rotation.x,bottomLabel:"deg",disabled:null==u,onChange:updateRotation((e=>({x:e}))),onBlur:updateToDefaultValueIfInvalid({rotation:{x:0}})})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"Y"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"rotation-y",value:u?.rotation.y,bottomLabel:"deg",disabled:null==u,onChange:updateRotation((e=>({y:e}))),onBlur:updateToDefaultValueIfInvalid({rotation:{y:0}})})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"Z"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"rotation-z",value:u?.rotation.z,bottomLabel:"deg",disabled:null==u,onChange:updateRotation((e=>({z:e}))),onBlur:updateToDefaultValueIfInvalid({rotation:{z:0}})})})]})]})]}),e.jsxs("div",{className:"mb-2 text-[0.8125rem]",children:[e.jsx("span",{className:"flex w-full items-center mt-3 mb-1",children:"Scale"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"scale",value:u?.scale,step:.1,min:.1,disabled:null==u,onChange:updateScale(),onBlur:updateToDefaultValueIfInvalid({scale:1},(e=>e<=0))})}),i&&e.jsx("div",{className:"bg-orange-100 rounded px-3 py-2 mt-6 mb-2",children:"Input based part transformation is not yet supported for multiple parts."}),null!=c&&e.jsx("div",{className:"bg-red-100 rounded px-3 py-2 mt-6 mb-2",children:"There was a problem retrieving data. Try selecting a different part."})]})]})},VertexTransformManipulatorToggle=({onToggleTransformsManipulator:t})=>{const a=useTransformActions(),o=n.useRecoilValue(Ht),i=n.useSetRecoilState(Zt);return e.jsx(s.VertexToggle,{className:"flex items-center","data-testid":"transform-widget-toggle",variant:"switch",checked:o,onValueChanged:async()=>{o?(a.disableTransformWidget(),t?.(!1)):(i("world"),await a.enableTransformWidget(),t?.(!0))}})};function VertexTransformControls({onToggleTransformsManipulator:t,onUpdateTransform:n}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center py-3",children:[e.jsx(VertexTransformManipulatorToggle,{onToggleTransformsManipulator:t}),e.jsx("span",{className:"pl-4 text-[0.8125rem] text-neutral-700",children:"Enable manipulator"})]}),e.jsx(VertexTransformInputs,{onUpdateTransform:n})]})}function VertexTransformPanelSection({onClearTransforms:t,onClearAllTransforms:n,onToggleTransformsManipulator:a,onUpdateTransform:o}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Manual Part Transforms",e.jsx(VertexTransformClear,{onClear:t,onClearAll:n})]}),children:e.jsx(VertexTransformControls,{onToggleTransformsManipulator:a,onUpdateTransform:o})})}function DefaultTransformsPanel(){return e.jsx("div",{className:"flex flex-col text-neutral-700 h-full overflow-y-auto",children:e.jsx(VertexTransformPanelSection,{})})}const $a="Appearance",qa="Model Views",Ya="Settings",Xa="Transforms",ViewerRightPanelHeader=({additionalHeaderMap:t})=>{const a=n.useRecoilValue(ea),o=getHeading(a,t),s="model-views"===a;return e.jsx("div",{className:"flex flex-col w-full items-center z-overlay pointer-events-none md:pointer-events-auto py-3 px-4 border-b border-neutral-300",children:e.jsxs("div",{className:"flex items-center w-full leading-6 text-md align-center font-medium text-neutral-800 gap-2",children:[o,s&&e.jsx(BetaLabel,{})]})})};function getHeading(e,t={}){switch(e){case"appearance":return $a;case"model-views":return qa;case"settings":return Ya;case"transforms":return Xa;default:const n=undefined;return(null!=e?t[e]:void 0)??"None"}}function VertexViewerRightOpenedPanel({children:t}){const a=n.useRecoilValue(ea),s=o.useMemo((()=>filterChildElements(t,CustomPanelContent)),[t]),i=o.useMemo((()=>s.reduce(((e,t)=>({...e,[t.props.panelName]:t.props.panelTitle})),{})),[s]),r=o.useMemo((()=>["appearance","model-views","settings","transforms",...s.map((e=>e.props.panelName))]),[s]);return e.jsx(e.Fragment,{children:null!=a&&r.includes(a)&&e.jsxs(VertexResizableContent,{displayShadow:!0,heading:e.jsx(ViewerRightPanelHeader,{additionalHeaderMap:i}),placement:"right",children:["appearance"===a&&e.jsx(DefaultAppearancePanel,{}),"transforms"===a&&e.jsx(DefaultTransformsPanel,{}),"settings"===a&&e.jsx(DefaultSettingsPanel,{}),"model-views"===a&&e.jsx(VertexModelViewsPanel,{}),t]})})}function CustomPanelContent({panelName:t,children:a}){const o=n.useRecoilValue(ea);return e.jsx(e.Fragment,{children:o===t&&a})}function Sidebar({children:t}){return e.jsx("div",{className:"pointer-events-auto flex flex-col items-center w-full border-neutral-300 py-2",children:t})}function SidebarIcon({name:t,iconName:n,active:a,responsive:i,disabled:r,content:l,tooltipPlacement:c,children:d,onSelect:u,onDeselect:m}){return e.jsx("div",{className:_e({"text-[var(--vertex-ui-blue-700)]":a===t&&!r,"text-neutral-700 hover:text-neutral-800":a!==t&&!r,"cursor-pointer hover:bg-neutral-200":!r,"text-neutral-400":r,"rounded-full md:p-3":i,"p-3":!i&&null==d,"px-3 py-1":null!=d}),"data-testid":`${t}-sidebar-panel`,onClick:()=>{r||(a===t?m():u())},children:e.jsxs(s.VertexTooltip,{placement:c??void 0,content:o.isValidElement(l)?void 0:l,children:[e.jsx("div",{slot:"content",children:l}),e.jsx("div",{className:"flex flex-col",children:d??e.jsx(s.VertexIcon,{name:n})})]})})}function VertexViewerRightSidebar({children:t}){const a=usePanelActions(),o=useTransformActions(),s=n.useRecoilValue(ea);return e.jsx("div",{className:"flex flex-col flex-shrink-0 items-center relative border-neutral-300 border-l bg-white h-full top-0 min-w-12 w-12",children:e.jsxs(Sidebar,{children:[t,e.jsx(SidebarIcon,{name:"appearance",active:s,iconName:"adjustments",tooltipPlacement:"right",content:"Appearance",onSelect:()=>{a.openPrimary("appearance","right")},onDeselect:()=>a.closePrimary("right")}),e.jsx(SidebarIcon,{name:"transforms",active:s,iconName:"show-only-nearby",tooltipPlacement:"right",content:"Transforms",onSelect:async()=>{a.openPrimary("transforms","right"),await o.enableTransformWidget(void 0,!0)},onDeselect:()=>a.closePrimary("right")}),e.jsx(SidebarIcon,{name:"model-views",active:s,iconName:"views",tooltipPlacement:"right",content:"Model Views",onSelect:async()=>{a.openPrimary("model-views","right")},onDeselect:()=>a.closePrimary("right")}),e.jsx(SidebarIcon,{name:"settings",active:s,iconName:"gear",tooltipPlacement:"right",content:"Settings",onSelect:()=>{a.openPrimary("settings","right")},onDeselect:()=>a.closePrimary("right")})]})})}function CustomPanelIcon(t){const a=usePanelActions(),o=n.useRecoilValue(ea),{panelName:s,tooltipContent:i,iconName:r,...l}=t;if(null==r&&null==l.children)throw new Error('CustomPanelIcon must contain either a Vertex "iconName" or custom "children"');return e.jsx(SidebarIcon,{...l,name:s,iconName:r??"help",active:o,content:i,onSelect:()=>{a.openPrimary(t.panelName,"right")},onDeselect:()=>{a.closePrimary("right")}})}VertexViewerRightOpenedPanel.CustomPanelContent=CustomPanelContent,VertexViewerRightSidebar.CustomPanelIcon=CustomPanelIcon;const VertexPopupButton=({open:t,children:n,...a})=>{const o=n.find((e=>e.type===Anchor)),i=n.filter((e=>e.type!==Anchor));return null==o?e.jsx(e.Fragment,{}):e.jsxs(s.VertexPopover,{className:"flex",placement:"top",backdrop:!1,open:asBooleanAttribute(t),...a,children:[o,e.jsx("div",{className:_e("flex mb-1.5",{hidden:!t}),"data-testid":"align-plane-popover-menu",children:i})]})},Anchor=({tooltipContent:t,children:n})=>e.jsx("div",{slot:"anchor",children:e.jsx(s.VertexTooltip,{className:"cursor-pointer",content:t,children:n})});function VertexViewerCrossSectionAlignmentPopoverMenu({disabled:t}){const a=useCrossSectioningActions(),o=n.useRecoilValue(Ve),i=n.useRecoilValue(xe),getBaseIcon=()=>`align-to-${i?.mode}`;return useStackKeyBinding({id:"CrossSectionAlignment",keyBind:"Escape",fn:a.cancelCurrentHit,addPredicate:()=>i?.hitPending??!1,cancelPredicate:()=>!i?.hitPending},[i?.hitPending]),e.jsxs(VertexPopupButton,{"data-testid":"section-alignment-popover",placement:"top",backdrop:!1,open:asBooleanAttribute(o),onDismissed:a.closeAlignmentTools,children:[e.jsx(VertexPopupButton.Anchor,{tooltipContent:"Section Alignment",children:e.jsx(s.VertexIconButton,{"data-testid":"section-alignment-icon-button",iconName:getBaseIcon(),iconColor:"secondary",onClick:o?a.closeAlignmentTools:a.openAlignmentTools,disabled:t,children:e.jsx(s.VertexIcon,{"data-testid":"section-alignment-icon-chevron",name:"chevron-up",size:"sm"})})}),e.jsxs(r.VertexViewerToolbarGroup,{direction:"vertical",className:"flex justify-evenly items-center py-1 my-1 ring-1 ring-neutral-200 rounded bg-neutral-100 opacity-95",children:[e.jsx(s.VertexIconButton,{iconColor:"secondary",onClick:()=>a.updateAlignment("global"),className:"w-full text-neutral-800 hover:bg-neutral-300 rounded cursor-pointer mx-0.5 py-1 px-2","data-testid":"section-alignment-align-global",iconName:"align-to-global",variant:"plain",children:e.jsx("div",{className:"text-base ml-2",children:"Align to Global"})}),e.jsx(s.VertexIconButton,{iconColor:"secondary",onClick:()=>a.updateAlignment("surface"),className:"w-full text-neutral-800 hover:bg-neutral-300 rounded cursor-pointer mx-0.5 py-1 px-2","data-testid":"section-alignment-align-surface",iconName:"align-to-surface",variant:"plain",children:e.jsx("div",{className:"text-base ml-2",children:"Align to Surface"})})]})]})}function VertexViewerCrossSectionAxisPopoverMenu({disabled:t}){const a=useCrossSectioningActions(),i=n.useRecoilValue(je),l=n.useRecoilValue(he),c=n.useRecoilValueLoadable(ve),d=o.useMemo((()=>{const e=l.length>0&&"hasValue"===c.state?axis(l[0],xAxis(c.contents),yAxis(c.contents),zAxis(c.contents)):"x";return null!=e?`axis-${e}`:"axis-x"}),[c.state,c.contents,l]);return e.jsxs(VertexPopupButton,{"data-testid":"align-plane-popover",placement:"top",backdrop:!1,open:asBooleanAttribute(i),onDismissed:a.closeAxisTools,children:[e.jsx(VertexPopupButton.Anchor,{tooltipContent:"Align Plane",children:e.jsx(s.VertexIconButton,{onClick:i?a.closeAxisTools:a.openAxisTools,iconName:d,"data-testid":"align-plane-icon",iconColor:"secondary",disabled:t,children:e.jsx(s.VertexIcon,{"data-testid":"align-plane-icon-chevron",name:"chevron-up",size:"sm"})})}),e.jsxs(r.VertexViewerToolbarGroup,{direction:"vertical",className:"flex justify-evenly items-center py-1 my-1 ring-1 ring-neutral-200 rounded bg-neutral-100 opacity-95",children:[e.jsx(s.VertexIconButton,{"data-testid":"align-plane-x-axis-button",className:"w-full text-neutral-800 hover:bg-neutral-300 rounded cursor-pointer mx-0.5 py-1 px-2",onClick:()=>a.updateAxis("x"),variant:"plain",iconColor:"secondary",iconName:"axis-x",children:e.jsx("div",{className:"text-base ml-2",children:"X-axis Plane"})}),e.jsx(s.VertexIconButton,{className:"w-full text-neutral-800 hover:bg-neutral-300 rounded cursor-pointer mx-0.5 py-1 px-2",variant:"plain",iconColor:"secondary",iconName:"axis-y","data-testid":"align-plane-y-axis-button",onClick:()=>a.updateAxis("y"),children:e.jsx("div",{className:"text-base ml-2",children:"Y-axis Plane"})}),e.jsx(s.VertexIconButton,{"data-testid":"align-plane-z-axis-button",className:"w-full text-neutral-800 hover:bg-neutral-300 rounded cursor-pointer mx-0.5 py-1 px-2",onClick:()=>a.updateAxis("z"),variant:"plain",iconColor:"secondary",iconName:"axis-z",children:e.jsx("div",{className:"text-base ml-2",children:"Z-axis Plane"})})]})]})}function VertexViewerCrossSectionOffsetStepper({offset:t,disabled:a,onOffsetChange:i}){const r=n.useRecoilValue(Lt),l=n.useRecoilValue(_t),[c,d]=o.useState(convertTo(t,r));o.useEffect((()=>{d(convertTo(t,r))}),[r,t]);const u=createDistanceFormatter(r,parseInt(l,10)),handleIncrementalUpdate=e=>{const t=convertFrom(c+e,r);i(t)},handleSubmit=e=>{e.preventDefault(),i(convertFrom(c,r))},handleBlur=()=>{i(convertFrom(c,r))};return e.jsx(s.VertexTooltip,{content:"Plane Offset",children:e.jsx("form",{"data-testid":"cross-section-stepper-form",onSubmit:handleSubmit,children:e.jsxs(s.VertexTextfield,{"data-testid":"cross-section-stepper-input",className:"viewer-toolbar-input w-32 border-none ring-0 bg-white",type:"text",value:u(parseFloat(t.toFixed(3))),onInputInput:e=>{d(null!=e.detail.value?parseFloat(e.detail.value):t)},onBlur:handleBlur,disabled:a,children:[e.jsx("div",{"data-testid":"cross-section-stepper-decrement",className:"py-1 cursor-pointer",slot:"left",onClick:()=>{a||handleIncrementalUpdate(-1)},children:e.jsx(s.VertexIcon,{name:"chevron-left",size:"sm"})}),e.jsx("div",{"data-testid":"cross-section-stepper-increment",className:"py-1 cursor-pointer",slot:"right",onClick:()=>{a||handleIncrementalUpdate(1)},children:e.jsx(s.VertexIcon,{name:"chevron-right",size:"sm"})})]})})})}VertexPopupButton.Anchor=Anchor;const Za=400;function VertexViewerCrossSectionPopupMenu(){const t=useCrossSectioningActions(),a=n.useRecoilValue(Se),i=n.useRecoilValueLoadable(we),l=n.useRecoilValueLoadable(Ce),c=o.useRef(),d=o.useMemo((()=>"hasValue"===i.state&&Number.isFinite(i.contents.max)&&Number.isFinite(i.contents.min)),[i.state,i.contents]),u=o.useMemo((()=>"hasValue"===i.state?i.contents:ie),[i.state,i.contents]),m=o.useMemo((()=>"hasValue"===l.state&&Number.isFinite(l.contents)?l.contents:0),[l.state,l.contents]),handleCrossSectionValueChange=e=>{clearTimeout(c.current),c.current=window.setTimeout((()=>{t.endInteraction()}),Za),t.beginInteraction(),t.updatePlanes(e)};return e.jsxs(VertexPopupButton,{"data-testid":"cross-section-popover",placement:"top",backdrop:!1,open:asBooleanAttribute(a),onDismissed:t.closeAdditionalTools,children:[e.jsx(VertexPopupButton.Anchor,{tooltipContent:"Section Tools",children:e.jsx("div",{className:"-ml-px py-1.5",children:e.jsx(s.VertexIcon,{"data-testid":"cross-section-popover-icon",name:"chevron-up",size:"sm",onClick:a?t.closeAdditionalTools:t.openAdditionalTools})})}),e.jsxs(r.VertexViewerToolbarGroup,{className:"relative bottom-3 flex justify-evenly items-center p-1 ring-1 ring-neutral-200 rounded bg-neutral-100 opacity-95",children:[e.jsx(VertexViewerCrossSectionAlignmentPopoverMenu,{disabled:!d}),e.jsx(s.VertexTooltip,{className:"w-auto",content:"Reverse",children:e.jsx(s.VertexIconButton,{iconName:"flip","data-testid":"viewer-toolbar-flip-button",onClick:t.flipPlanes,iconColor:"secondary",disabled:!d})}),e.jsx(s.VertexTooltip,{className:"w-auto",content:"Align View to Plane",children:e.jsx(s.VertexIconButton,{"data-testid":"viewer-toolbar-align-view-to-plane-button",iconName:"align-view-to-plane",onClick:t.alignViewToPlane,iconColor:"secondary",disabled:!d})}),e.jsx(VertexToolbarDivider,{}),e.jsx(VertexViewerCrossSectionAxisPopoverMenu,{disabled:!d}),e.jsx("div",{className:"w-52 mx-2",children:e.jsx(VertexSlider,{value:m,defaultValue:u.default,disabled:asBooleanAttribute("hasValue"!==i.state)||!d,min:u.min,max:u.max,step:.01,onChange:handleCrossSectionValueChange})}),e.jsx("div",{className:"px-4",children:e.jsx(VertexViewerCrossSectionOffsetStepper,{offset:"hasValue"===l.state&&d?l.contents:0,disabled:!d,onOffsetChange:handleCrossSectionValueChange})})]})]})}const VertexViewerCrossSectionButton=()=>{const t=useCrossSectioningActions(),a=n.useRecoilValue(re);return e.jsxs(e.Fragment,{children:[e.jsx(s.VertexTooltip,{content:a?"Hide Section":"Show Section",children:e.jsx(s.VertexIconButton,{"data-testid":"viewer-toolbar-cross-section-button",iconName:"cross-section",iconColor:a?"primary":"secondary",onClick:()=>a?t.disable():t.enable()})}),e.jsx(VertexViewerCrossSectionPopupMenu,{})]})},VertexFitAllButton=()=>{const t=n.useRecoilValue(G);return e.jsx(s.VertexTooltip,{content:"Fit All",children:e.jsx(s.VertexIconButton,{iconName:"fit-all",iconColor:"secondary","data-testid":"viewer-toolbar-fit-all-button",onClick:async()=>{const e=await(t?.scene());await(e?.camera().viewAll().render({animation:{milliseconds:500}}))}})})},VertexPanButton=()=>{const t=n.useRecoilValue(G),a=n.useRecoilValue($),[i,r]=n.useRecoilState(Y),[l,c]=n.useRecoilState(q);return o.useEffect((()=>{null!=t&&a&&c(t.getBaseInteractionHandler())}),[t,a,c]),e.jsx(s.VertexTooltip,{content:"Pan",children:e.jsx(s.VertexIconButton,{iconName:"pan",iconColor:"pan"===i?"primary":"secondary","data-testid":"viewer-toolbar-pan-button",onClick:async()=>{if(r("pan"),null!=l){const e=await l;e?.setPrimaryInteractionType("pan")}}})})},VertexRotateButton=()=>{const t=n.useRecoilValue(G),a=n.useRecoilValue($),[i,r]=n.useRecoilState(Y),[l,c]=n.useRecoilState(q);return o.useEffect((()=>{null!=t&&a&&c(t.getBaseInteractionHandler())}),[t,a,c]),e.jsx(s.VertexTooltip,{content:"Rotate",children:e.jsx(s.VertexIconButton,{iconName:"rotate",iconColor:"rotate"===i?"primary":"secondary","data-testid":"viewer-toolbar-rotate-button",onClick:async()=>{if(r("rotate"),null!=l){const e=await l;e?.setPrimaryInteractionType("rotate")}}})})},VertexZoomButton=()=>{const t=n.useRecoilValue(G),a=n.useRecoilValue($),[i,r]=n.useRecoilState(Y),[l,c]=n.useRecoilState(q);return o.useEffect((()=>{null!=t&&a&&c(t.getBaseInteractionHandler())}),[t,a,c]),e.jsx(s.VertexTooltip,{content:"Zoom",children:e.jsx(s.VertexIconButton,{iconName:"zoom",iconColor:"zoom"===i?"primary":"secondary","data-testid":"viewer-toolbar-zoom-button",onClick:async()=>{if(r("zoom"),null!=l){const e=await l;e?.setPrimaryInteractionType("zoom")}}})})},DefaultToolbar=()=>e.jsx(r.VertexViewerToolbar,{placement:"bottom-center",children:e.jsxs(r.VertexViewerToolbarGroup,{className:"p-1 border border-neutral-200 rounded bg-neutral-100 opacity-95",children:[e.jsx(VertexRotateButton,{}),e.jsx(VertexPanButton,{}),e.jsx(VertexZoomButton,{}),e.jsx(VertexFitAllButton,{}),e.jsx(VertexToolbarDivider,{}),e.jsx(VertexBoxSelectionButton,{}),e.jsx(VertexToolbarDivider,{}),e.jsx(VertexViewerCrossSectionButton,{}),e.jsx(VertexToolbarDivider,{}),e.jsx(VertexPointToPointMeasurementTool,{}),e.jsx(VertexPreciseMeasurementTool,{})]})}),VertexToolbar=({endCapEnabledByDefault:t,children:a})=>{const s=n.useSetRecoilState(ue),i=n.useSetRecoilState(de);o.useEffect((()=>{null!=t&&(s(t),i(t))}),[t]);const l=null!=a&&!1!==a;return e.jsx(r.VertexViewerToolbar,{placement:"bottom-center",children:l?e.jsx(r.VertexViewerToolbarGroup,{className:"p-1 border border-neutral-200 rounded bg-neutral-100 opacity-95",children:a}):e.jsx(DefaultToolbar,{})})};function VertexTransformWidget({transformWidgetElement:t,supportUndo:a,onPositionChange:s,onRotationChange:i}){const l=useTransformActions(),c=n.useRecoilValue($t),d=n.useRecoilValue(Ht),u=n.useRecoilValue(Ut),m=n.useRecoilValue(Kt),p=n.useRecoilValueLoadable(Gt),h=n.useRecoilValue(Lt),f=n.useRecoilValue(_t),g=o.useMemo((()=>"hasValue"===p.state?p.contents:m),[p,m]),v=o.useMemo((()=>{const e=undefined;return d&&(null!=g||c)}),[d,g,c]);return e.jsx(e.Fragment,{children:v&&e.jsx(r.VertexViewerTransformWidget,{id:"transform-widget","data-testid":"viewer-transform-widget",ref:t,position:u,rotation:null!=u?g:void 0,decimalPlaces:parseInt(f,10),distanceUnit:toUnitType(h),EXPERIMENTAL_undoKeybindings:a??!0,onInteractionStarted:()=>{l.disableSelectionSync(),l.setIsInteractivelyTransforming(!0)},onInteractionEnded:()=>{l.invalidateTransforms(),l.setIsInteractivelyTransforming(!1)},onPositionChanged:async e=>{await l.setTransformWidgetPosition(e.detail),s?.(e.detail)},onRotationChanged:e=>{l.setTransformWidgetOrientation(e.detail),i?.(e.detail)}})})}const VertexViewerSceneReset=({onReset:t})=>{const a=useCrossSectioningActions(),o=useModelViewActions(),i=useSelectionActions(),r=useTransformActions(),l=useViewerSceneActions(),c=n.useSetRecoilState(Nt),handleReset=async()=>{await a.disable(),await i.resetSelectionState(),r.clearTransformWidgetPosition(),await r.invalidateTransforms(),c(void 0),await o.clearModelView(),t?.(),await l.reset()};return e.jsx(s.VertexTooltip,{content:"Reset View",children:e.jsx(s.VertexIconButton,{iconName:"reset",className:"flex bg-white opacity-70 hover:opacity-100 text-neutral-900 hover:text-neutral-700 hover:bg-neutral-200 rounded p-1 cursor-pointer","data-testid":"viewer-reset-tool-button",onClick:handleReset,variant:"plain"})})};function useViewerFrameActions(){const e=useTransformActions();return{frameDrawn:useActionCallback((({set:t,snapshot:n})=>async a=>{const o=await n.getPromise(Pt);t(Z,a.detail.scene),t(Pt,a.detail.scene.sceneViewSummary.selectedVisibleSummary),t(At,o);const s=undefined;await n.getPromise(Ht)&&await e.syncToSelection()}))}}const VertexBoxSelectionTool=()=>{const{element:t,callback:a}=useCallbackRef(),o=useBoxSelectionActions(),s=useTransformActions(),i=n.useRecoilValue(Xe);return u.useEffect((()=>{const e=whenComponentReady(t,(()=>[t?.model?.onDragComplete((()=>{"clearAndSelect"===i&&(s.clearTransformWidgetOrientation(),s.clearTransformWidgetPosition(),s.enableSelectionSync())}))]));return()=>{e?.then((e=>{e?.forEach((e=>e?.dispose()))}))}}),[t,i]),useApplyKeyBinding({keyBind:"Shift",fn:u.useCallback((()=>o.setOperationType("select")),[]),off:u.useCallback((()=>o.setOperationType("clearAndSelect")),[])}),e.jsx(r.VertexViewerBoxQueryTool,{ref:a,"data-testid":"viewer-box-query-tool",operationType:i})};function VertexViewerCameraTypeMenu({open:t,onOpen:a,onDismiss:o,onCameraTypeChange:i}){const r=useViewerCameraActions(),l=n.useRecoilValue(W);return e.jsxs(s.VertexMenu,{"data-testid":"camera-types-popover",className:"flex",placement:"bottom-end",open:asBooleanAttribute(t),onMenuClosed:o,children:[e.jsx("div",{slot:"anchor",children:e.jsx("div",{className:_e("flex bg-white hover:opacity-100 hover:text-neutral-700 hover:bg-neutral-200 rounded",{"opacity-70 text-neutral-900":!t,"opacity-100 text-neutral-700 bg-neutral-200":t}),children:e.jsx(s.VertexTooltip,{content:"Change View",children:e.jsx(s.VertexIconButton,{"data-testid":"set-camera-mode-option",className:"p-1 cursor-pointer",variant:"plain",onClick:a,iconName:"orthographic"===l?"cube-orthographic":"cube-perspective",children:e.jsx(s.VertexIcon,{"data-testid":"change-camera-type-icon-button",name:"chevron-down",size:"sm"})})})})}),e.jsxs("div",{className:"w-36",children:[e.jsx("div",{className:"pt-1"}),e.jsxs(s.VertexMenuItem,{"data-testid":"set-perspective-view",onClick:()=>{r.updateCameraType("perspective",!0),i?.("perspective")},children:[e.jsx(s.VertexIcon,{slot:"icon","data-testid":"set-perspective-view-icon",name:"cube-perspective",size:"sm",className:_e({"text-[var(--vertex-ui-blue-700)]":"perspective"===l})}),e.jsx("div",{className:_e("ml-2 items-center",{"text-[var(--vertex-ui-blue-700)]":"perspective"===l}),children:"Perspective"})]}),e.jsxs(s.VertexMenuItem,{"data-testid":"set-orthographic-view",onClick:()=>{r.updateCameraType("orthographic",!0),i?.("orthographic")},children:[e.jsx(s.VertexIcon,{slot:"icon","data-testid":"set-orthographic-view-icon",name:"cube-orthographic",size:"sm",className:_e({"text-[var(--vertex-ui-blue-700)]":"orthographic"===l})}),e.jsx("div",{className:_e("ml-2 items-center",{"text-[var(--vertex-ui-blue-700)]":"orthographic"===l}),children:"Orthographic"})]})]})]})}const VertexViewerViewCube=({placement:t,children:n,...a})=>{const s=Array.isArray(n)?n:[n],i=s.filter((e=>!o.isValidElement(e)||e.type!==r.VertexViewerViewCube)).filter((e=>null!=e&&!1!==e)),l=s.find((e=>o.isValidElement(e)&&e.type===r.VertexViewerViewCube)),[c,d]=o.useState(!1);return e.jsxs(r.VertexViewerToolbar,{direction:"vertical","data-testid":"view-cube-toolbar",placement:t??"top-right",children:[l??e.jsx(r.VertexViewerViewCube,{className:"m-7",...a}),0===i.length?e.jsxs("div",{className:"flex items-center justify-center mt-3 gap-1",children:[e.jsx(VertexViewerSceneReset,{}),e.jsx(VertexViewerCameraTypeMenu,{open:c,onDismiss:()=>d(!1),onOpen:()=>d(!0)})]}):e.jsx("div",{className:"mt-3",children:i})]})},VertexViewer=({id:t,src:a,className:s,disableSelection:i,onTap:l,onLongpress:c,onFrameDrawn:d,onSceneReady:u,viewerRefCallback:m,children:p,...h})=>{const f=n.useRecoilValue(ga),g=useRecoilRef({state:G}),v=useViewerCameraActions(),b=useCrossSectioningActions(),w=useHitActions(),C=useSelectionActions(),S=useViewerFrameActions(),V=n.useRecoilValue(W),j=n.useRecoilValue(xe),k=n.useRecoilValue(Ye),T=n.useSetRecoilState(X),[A,P]=n.useRecoilState($);o.useEffect((()=>{A&&(P(!1),b.disable())}),[a]);const[I,M]=n.useRecoilState(K);o.useEffect((()=>{null!=t&&M(t)}),[t]);const E=n.useRecoilValue(ma),R=o.useMemo((()=>({opacity:E/100})),[E]),N=n.useRecoilValue(ze),O=n.useRecoilValue(Fe),L=o.useMemo((()=>({color:N,width:O})),[N,O]),_=n.useRecoilValue(ue),B=n.useRecoilValue(me),D=n.useRecoilValue(pe),F=o.useMemo((()=>({endCapEnabled:_,endCapUsePartColor:B===ne.PART,..._&&B===ne.SINGLE&&{endCapColor:D}})),[_,B,D]),H=n.useRecoilValue(qn),U=n.useRecoilValue(Wn),q=n.useRecoilValue(Gn),Y=n.useRecoilValue(Kn),Z=o.useMemo((()=>({color:U,opacity:q/100,lineWidth:Y})),[U,q,Y]),J=n.useRecoilValue(nt),Q=null!=p&&!1!==p;return useKeyBindings(),useDefaultKeybindings(),e.jsxs(r.VertexViewer,{id:I,"data-testid":"vertex-viewer",src:a,ref:e=>{m?.(e),g(e)},className:_e("flex w-full h-full",s,{"cursor-crosshair":j.hitPending}),style:{"--viewer-background":H},config:f,cameraType:A?V:void 0,onCameraTypeChanged:e=>{A&&v.updateCameraType(e.detail,!1)},phantom:R,featureLines:L,selectionHighlighting:Z,crossSectioning:F,featureMaps:J?"final":void 0,onTap:e=>{const t=[...i?[]:[C.selectCurrentHit]];w.tap(e,...t),l?.(e)},onLongpress:e=>{w.longPress(e),c?.(e)},onFrameDrawn:e=>{S.frameDrawn(e),d?.(e)},onSceneReady:async e=>{if(!A){P(!0);const t=await(e?.target?.scene());T(t?.sceneViewId)}u?.(e)},...h,children:[k&&e.jsx(VertexBoxSelectionTool,{}),Q?p:e.jsxs(e.Fragment,{children:[e.jsx(VertexViewerViewCube,{}),e.jsx(VertexToolbar,{}),e.jsx(VertexViewerContextMenu,{})]})]})};function toSdkConfig(e){return isOnlyNetworkConfig(e)?{network:e}:e}function isOnlyNetworkConfig(e){const t=undefined;return null!=e.renderingHost}const VertexViewerToolkitEventListener=({onHitStateChange:t,onSelectionStateChange:a})=>{const s=n.useRecoilValue(on),i=n.useRecoilValue(Tn);return o.useEffect((()=>{t?.(s)}),[s,t]),o.useEffect((()=>{a?.(i)}),[i,a]),e.jsx(e.Fragment,{})},VertexViewerToolkitRoot=({override:t,autoDefineCustomElements:a,children:s,config:i,...r})=>(o.useEffect((()=>{(null==a||a)&&(d.defineCustomElements(),c.defineCustomElements())}),[a]),e.jsx(n.RecoilRoot,{override:t,children:e.jsxs(e.Fragment,{children:[e.jsx(VertexViewerToolkitEventListener,{...r}),e.jsx(VertexViewerToolkitRootConfig,{config:i,children:s})]})})),VertexViewerToolkitRootConfig=({config:t,children:a})=>{const s=n.useSetRecoilState(ga);return o.useEffect((()=>{const e=null!=t?toSdkConfig(t):void 0;s(e)}),[t,s]),e.jsx(e.Fragment,{children:a})};var Ja=Object.freeze({__proto__:null,get AssemblyFontFace(){return za},Columns:Ia,Core:kn,Metadata:Ua,Search:Da});exports.Appearance=Yn,exports.BoxSelection=Ze,exports.Config=ya,exports.ContextMenu=qe,exports.CrossSection=Ne,exports.Ghosting=fa,exports.Hits=sn,exports.Keybinding=Jn,exports.Measurement=pt,exports.Messages=H,exports.Metadata=da,exports.ModelViews=Ka,exports.Panel=na,exports.Performance=ft,exports.SceneTree=Ja,exports.SceneViewItem=Ot,exports.Selection=An,exports.Settings=Bt,exports.Transforms=an,exports.VertexApplicationMessages=VertexApplicationMessages,exports.VertexBoxSelectionButton=VertexBoxSelectionButton,exports.VertexContextMenu=VertexContextMenu,exports.VertexCrossSectionAppearanceColorPicker=VertexCrossSectionAppearanceColorPicker,exports.VertexCrossSectionAppearanceControls=VertexCrossSectionAppearanceControls,exports.VertexCrossSectionAppearanceLineThicknessSlider=VertexCrossSectionAppearanceLineThicknessSlider,exports.VertexCrossSectionAppearancePanelSection=VertexCrossSectionAppearancePanelSection,exports.VertexCrossSectionAppearanceReset=VertexCrossSectionAppearanceReset,exports.VertexDecimalPlaceSelector=VertexDecimalPlaceSelector,exports.VertexFeatureEdgesColorPicker=VertexFeatureEdgesColorPicker,exports.VertexFeatureEdgesControls=VertexFeatureEdgesControls,exports.VertexFeatureEdgesPanelSection=VertexFeatureEdgesPanelSection,exports.VertexFeatureEdgesReset=VertexFeatureEdgesReset,exports.VertexFeatureEdgesThicknessSlider=VertexFeatureEdgesThicknessSlider,exports.VertexFitAllButton=VertexFitAllButton,exports.VertexFitSelectedMenuItem=VertexFitSelectedMenuItem,exports.VertexFlyToMenuItem=VertexFlyToMenuItem,exports.VertexGhostingControls=VertexGhostingControls,exports.VertexGhostingPanelSection=VertexGhostingPanelSection,exports.VertexHideAllMenuItem=VertexHideAllMenuItem,exports.VertexHidePartMenuItem=VertexHidePartMenuItem,exports.VertexHideSelectedMenuItem=VertexHideSelectedMenuItem,exports.VertexLengthUnitSelector=VertexLengthUnitSelector,exports.VertexMaterialControls=VertexMaterialControls,exports.VertexMaterialPanelSection=VertexMaterialPanelSection,exports.VertexMeasurementContextMenu=VertexMeasurementContextMenu,exports.VertexMeasurementDetails=VertexMeasurementDetails,exports.VertexModelViewsPanel=VertexModelViewsPanel,exports.VertexPanButton=VertexPanButton,exports.VertexPointToPointMeasurement=VertexPointToPointMeasurement,exports.VertexPointToPointMeasurementTool=VertexPointToPointMeasurementTool,exports.VertexPreciseMeasurement=VertexPreciseMeasurement,exports.VertexPreciseMeasurementTool=VertexPreciseMeasurementTool,exports.VertexResizableContent=VertexResizableContent,exports.VertexRotateButton=VertexRotateButton,exports.VertexSceneItemGhostingClear=VertexSceneItemGhostingClear,exports.VertexSceneItemGhostingOpacitySlider=VertexSceneItemGhostingOpacitySlider,exports.VertexSceneItemGhostingToggle=VertexSceneItemGhostingToggle,exports.VertexSceneItemMaterialClear=VertexSceneItemMaterialClear,exports.VertexSceneItemMaterialColorPicker=VertexSceneItemMaterialColorPicker,exports.VertexSceneItemMaterialColorSwatches=VertexSceneItemMaterialColorSwatches,exports.VertexSceneItemMaterialOpacitySlider=VertexSceneItemMaterialOpacitySlider,exports.VertexSceneTree=VertexSceneTree,exports.VertexSceneTreeColumnPopover=VertexSceneTreeColumnPopover,exports.VertexSceneTreeContextMenu=VertexSceneTreeContextMenu,exports.VertexSceneTreeCustomColumn=VertexSceneTreeCustomColumn,exports.VertexSceneTreeHeader=VertexSceneTreeHeader,exports.VertexSceneTreeMetadataColumns=VertexSceneTreeMetadataColumns,exports.VertexSceneTreeSearchBar=VertexSceneTreeSearchBar,exports.VertexSceneTreeSearchInformationForToolbar=VertexSceneTreeSearchInformationForToolbar,exports.VertexSceneTreeSearchOptionsPopover=VertexSceneTreeSearchOptionsPopover,exports.VertexSceneTreeTableLayout=VertexSceneTreeTableLayout,exports.VertexSelectionHighlightingColorPicker=VertexSelectionHighlightingColorPicker,exports.VertexSelectionHighlightingControls=VertexSelectionHighlightingControls,exports.VertexSelectionHighlightingLineThicknessSlider=VertexSelectionHighlightingLineThicknessSlider,exports.VertexSelectionHighlightingOpacitySlider=VertexSelectionHighlightingOpacitySlider,exports.VertexSelectionHighlightingPanelSection=VertexSelectionHighlightingPanelSection,exports.VertexSelectionHighlightingReset=VertexSelectionHighlightingReset,exports.VertexShowAllMenuItem=VertexShowAllMenuItem,exports.VertexShowOnlyMenuItem=VertexShowOnlyMenuItem,exports.VertexShowOnlySelectedMenuItem=VertexShowOnlySelectedMenuItem,exports.VertexShowPropertiesMenuItem=VertexShowPropertiesMenuItem,exports.VertexToolbar=VertexToolbar,exports.VertexToolbarDivider=VertexToolbarDivider,exports.VertexTransformClear=VertexTransformClear,exports.VertexTransformControls=VertexTransformControls,exports.VertexTransformInputs=VertexTransformInputs,exports.VertexTransformManipulatorToggle=VertexTransformManipulatorToggle,exports.VertexTransformPanelSection=VertexTransformPanelSection,exports.VertexTransformWidget=VertexTransformWidget,exports.VertexUnitsControls=VertexUnitsControls,exports.VertexUnitsPanelSection=VertexUnitsPanelSection,exports.VertexViewer=VertexViewer,exports.VertexViewerBackgroundColorPicker=VertexViewerBackgroundColorPicker,exports.VertexViewerBackgroundControls=VertexViewerBackgroundControls,exports.VertexViewerBackgroundPanelSection=VertexViewerBackgroundPanelSection,exports.VertexViewerBackgroundReset=VertexViewerBackgroundReset,exports.VertexViewerContextMenu=VertexViewerContextMenu,exports.VertexViewerCrossSectionButton=VertexViewerCrossSectionButton,exports.VertexViewerRightOpenedPanel=VertexViewerRightOpenedPanel,exports.VertexViewerRightSidebar=VertexViewerRightSidebar,exports.VertexViewerSceneReset=VertexViewerSceneReset,exports.VertexViewerToolkitRoot=VertexViewerToolkitRoot,exports.VertexViewerViewCube=VertexViewerViewCube,exports.VertexZoomButton=VertexZoomButton,exports.Viewer=Q;
|
|
18
|
+
*/Le=Oe,function(){var e={}.hasOwnProperty;function classNames(){for(var e="",t=0;t<arguments.length;t++){var n=arguments[t];n&&(e=appendClass(e,parseValue(n)))}return e}function parseValue(t){if("string"==typeof t||"number"==typeof t)return t;if("object"!=typeof t)return"";if(Array.isArray(t))return classNames.apply(null,t);if(t.toString!==Object.prototype.toString&&!t.toString.toString().includes("[native code]"))return t.toString();var n="";for(var a in t)e.call(t,a)&&t[a]&&(n=appendClass(n,a));return n}function appendClass(e,t){return t?e?e+" "+t:e+t:e}Le.exports?(classNames.default=classNames,Le.exports=classNames):window.classNames=classNames}();var _e=Oe.exports;const VertexSlider=({value:t,defaultValue:n,leftLabel:a,rightLabel:i,onChange:r,onValueChange:l,onValueInput:c,...d})=>{const[u,m]=o.useState(n);return e.jsxs("div",{className:"flex w-full items-center gap-2",children:[a&&e.jsx("div",{className:"pl-0.5 text-xs text-center",children:a}),e.jsx(s.VertexSlider,{className:_e("w-full",{"mt-0.5":null!=a||null!=i}),value:t??u,onValueChange:e=>{m(e.detail.value),r?.(e.detail.value),l?.(e)},onValueInput:e=>{m(e.detail.value),r?.(e.detail.value),c?.(e)},...d}),i&&e.jsx("div",{className:"text-xs pr-2 flex-shrink-0 text-right",children:i})]})},VertexCrossSectionAppearanceLineThicknessSlider=({onUpdate:t})=>{const a=useCrossSectioningActions(),[o,s]=n.useRecoilState(ce);return e.jsx(VertexSlider,{id:"cross-section-line-thickness","data-testid":"cross-section-line-thickness-slider",leftLabel:"Off",rightLabel:"Thick",min:0,max:3,step:.5,value:o,valueLabelDisplay:"auto",onValueInput:async e=>{s(e.detail.value),await a.reapply()},onValueChange:e=>{t?.(e.detail.value)}})},VertexEndCapColorOptions=({onUpdateColorType:t})=>{const[a,o]=n.useRecoilState(me);return e.jsx("div",{className:"pl-2 text-sm text-neutral-700",children:e.jsxs(s.VertexRadioGroup,{value:a,"data-testid":"end-capping-color-type-radio-group",name:"end-capping-color-type",onValueChanged:e=>{o(e.detail.toUpperCase()===ne.PART?ne.PART:ne.SINGLE),t?.(e.detail)},children:[e.jsx(s.VertexRadio,{"data-testid":"end-capping-color-part-color",label:"Part Color",value:ne.PART}),e.jsx(s.VertexRadio,{"data-testid":"end-capping-color-single-color",label:"Single Color",value:ne.SINGLE})]})})},VertexEndCapColorPicker=({onUpdateCustomColor:t})=>{const[a,o]=n.useRecoilState(pe);return e.jsx(VertexColorPicker,{"data-testid":"end-capping-color-picker",value:a,onValueChanged:e=>{t?.(e.detail)},onInput:e=>o(e)})},VertexEndCapToggle=({onEnabledChange:t})=>{const[a,o]=n.useRecoilState(ue);return e.jsx(s.VertexToggle,{className:"flex items-center","data-testid":"end-capping-enabled-toggle",variant:"switch",checked:a,onValueChanged:async e=>{o(e.detail),t?.(e.detail)}})};function VertexCrossSectionAppearanceControls({onUpdateCrossSectionColor:t,onUpdateCrossSectionLineThickness:a,onEndCapEnabledChange:o,onUpdateEndCapColorType:s,onUpdateEndCapCustomColor:i}){const r=n.useRecoilValue(me);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center pt-2 pb-2",children:[e.jsx(VertexEndCapToggle,{onEnabledChange:o}),e.jsx("span",{className:"pl-4 text-sm text-neutral-700",children:"Show End Cap"})]}),e.jsx("div",{className:"pt-2 pb-2 text-sm text-neutral-700",children:"Line Color"}),e.jsx(VertexCrossSectionAppearanceColorPicker,{onUpdate:t}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Line Thickness"}),e.jsx(VertexCrossSectionAppearanceLineThicknessSlider,{onUpdate:a}),e.jsxs("div",{children:[e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Cap Color"}),e.jsx(VertexEndCapColorOptions,{onUpdateColorType:s}),r===ne.SINGLE&&e.jsx("div",{className:"mt-2",children:e.jsx(VertexEndCapColorPicker,{onUpdateCustomColor:i})})]})]})}function PanelSection({header:t,children:n}){return e.jsxs("div",{className:"py-3 px-4 border-neutral-300 border-b",children:[e.jsx("div",{className:"my-2 text-base text-neutral-700",children:t}),n]})}const VertexCrossSectionAppearanceReset=({onReset:t})=>{const a=useCrossSectioningActions(),[o,i]=n.useRecoilState(le),[r,l]=n.useRecoilState(ce),c=n.useRecoilValue(de),[d,u]=n.useRecoilState(ue),[m,p]=n.useRecoilState(me),[h,f]=n.useRecoilState(pe),g=o!==ae||1!==r||d!==c||m!==ne.PART||h!==se;return e.jsx("div",{className:"ml-auto",children:e.jsx(s.VertexTooltip,{content:"Reset Cross Sectioning Appearance",children:e.jsx(s.VertexIconButton,{"data-testid":"cross-section-appearance-reset",iconName:"reset",iconSize:"sm",onClick:async()=>{i(ae),l(1),u(c),p(ne.PART),f(se),t?.(),await a.reapply()},disabled:!g})})})};function VertexCrossSectionAppearancePanelSection({onResetCrossSectionAppearance:t,onUpdateCrossSectionColor:n,onUpdateCrossSectionLineThickness:a,onEndCapEnabledChange:o,onUpdateEndCapColorType:s,onUpdateEndCapCustomColor:i}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Cross Sectioning",e.jsx(VertexCrossSectionAppearanceReset,{onReset:t})]}),children:e.jsx(VertexCrossSectionAppearanceControls,{onUpdateCrossSectionColor:n,onUpdateCrossSectionLineThickness:a,onEndCapEnabledChange:o,onUpdateEndCapColorType:s,onUpdateEndCapCustomColor:i})})}const Be=.5,De="#444444",ze=n.atom({key:"featureEdgesSelectedColor",default:De}),Fe=n.atom({key:"featureEdgesLineThickness",default:Be}),VertexFeatureEdgesColorPicker=({onUpdate:t})=>{const[a,o]=n.useRecoilState(ze);return e.jsx(VertexColorPicker,{"data-testid":"feature-edges-color-picker",value:a,onValueChanged:e=>{t?.(e.detail)},onInput:e=>o(e)})},VertexFeatureEdgesThicknessSlider=({onUpdate:t})=>{const[a,o]=n.useRecoilState(Fe);return e.jsx(VertexSlider,{id:"feature-edges-thickness","data-testid":"feature-edges-thickness-slider",leftLabel:"Off",rightLabel:"Thick",min:0,max:3,step:.5,value:a,valueLabelDisplay:"auto",onValueInput:e=>{o(e.detail.value)},onValueChange:e=>{t?.(e.detail.value)}})};function VertexFeatureEdgesControls({onUpdateFeatureEdgesColor:t,onUpdateFeatureEdgesThickness:n}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Color"}),e.jsx(VertexFeatureEdgesColorPicker,{onUpdate:t}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Line Thickness"}),e.jsx(VertexFeatureEdgesThicknessSlider,{onUpdate:n})]})}const VertexFeatureEdgesReset=({onReset:t})=>{const[a,o]=n.useRecoilState(ze),[i,r]=n.useRecoilState(Fe),l=i!==Be||a!==De;return e.jsx("div",{className:"ml-auto",children:e.jsx(s.VertexTooltip,{content:"Reset Feature Edges",children:e.jsx(s.VertexIconButton,{"data-testid":"feature-edges-reset",iconName:"reset",iconSize:"sm",onClick:()=>{o(De),r(Be),t?.()},disabled:!l})})})};function VertexFeatureEdgesPanelSection({onResetFeatureEdges:t,onUpdateFeatureEdgesColor:n,onUpdateFeatureEdgesThickness:a}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Feature Edges",e.jsx(VertexFeatureEdgesReset,{onReset:t})]}),children:e.jsx(VertexFeatureEdgesControls,{onUpdateFeatureEdgesColor:n,onUpdateFeatureEdgesThickness:a})})}function contextMenuItemIsRow(e){return null!=e&&null!=e?.node?.id}function contextMenuItemIsElement(e){return null!=e&&e instanceof HTMLElement}const He=n.atom({key:"contextMenuActive",default:void 0}),Ue=n.atom({key:"contextMenuPosition",default:void 0}),We=n.atom({key:"contextMenuTarget",default:void 0}),Ge=n.atom({key:"contextMenuItem",default:void 0}),Ke=n.atom({key:"contextMenuActions",default:[]}),$e=n.selector({key:"contextMenuActivePosition",get:({get:e})=>null!=e(He)?e(Ue):void 0});function useContextMenuActions(){return{pointerDown:useActionCallback((({set:e})=>async t=>{if(2===t.button){const n=t.clientX,o=t?.clientY;e(Ue,a.Point.create(n,o)),e(We,t.target)}})),pointerUp:useActionCallback((({snapshot:e,set:t})=>async(n,o,s,i)=>{const r=await e.getPromise(Ue),l=await e.getPromise(He);if(null!=r&&null==l){const e=n.clientX,l=n?.clientY,c=a.Point.create(e,l),d=null!=r?a.Point.distance(r,c):0,u=null==s||s(n);d<2&&u&&(i?.(n,r??c),t(He,o))}})),contextMenu:useActionCallback((()=>(e,t)=>{(null==t||t(e))&&e.preventDefault()})),longPress:useActionCallback((({set:e})=>(t,n,o,s)=>{if(null==o||o(t)){const o=a.Point.create(t.touches[0].clientX,t.touches[0].clientY);e(Ue,o),e(We,t.target),e(He,n),s?.(t,o)}})),setContextMenuItem:useActionCallback((({snapshot:e,set:t,reset:n})=>async a=>{const o=await e.getPromise(Ke);t(Ge,a),o.forEach((e=>e(a))),n(Ke)})),clearActiveContextMenu:useActionCallback((({reset:e,set:t})=>n=>{t(Ee,!!n),e(He),e(Ke),e(Ue)})),clearDismissedState:useActionCallback((({reset:e})=>()=>e(Ee)))}}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)}var qe=Object.freeze({__proto__:null,contextMenuActions:Ke,contextMenuActive:He,contextMenuActivePosition:$e,contextMenuItem:Ge,contextMenuItemIsElement:contextMenuItemIsElement,contextMenuItemIsRow:contextMenuItemIsRow,contextMenuPosition:Ue,contextMenuTarget:We,targetShouldSkipNextHit:targetShouldSkipNextHit,targetWithinMenu:targetWithinMenu,useContextMenuActions:useContextMenuActions});const Ye=n.atom({key:"boxSelectionEnabled",default:!1}),Xe=n.atom({key:"boxSelectionOperationType",default:"clearAndSelect"}),useBoxSelectionActions=()=>({enable:useActionCallback((({set:e})=>()=>{e(Ye,!0)})),disable:useActionCallback((({reset:e})=>async()=>{e(Ye),e(Xe)})),setOperationType:useActionCallback((({set:e})=>t=>{e(Xe,t)}))});var Ze=Object.freeze({__proto__:null,boxSelectionEnabled:Ye,boxSelectionOperationType:Xe,useBoxSelectionActions:useBoxSelectionActions});async function whenComponentReady(e,t,n=customElements,a=requestAnimationFrame,o=setTimeout){return null!=e&&null!=e.nodeName&&await n.whenDefined(e.nodeName.toLowerCase()),"function"==typeof e?.componentOnReady?(await(e?.componentOnReady()),t()):(await new Promise((e=>"function"==typeof a?a(e):o(e))),t())}const Je=n.atom({key:"isEditingPointToPointMeasurement",default:!1}),Qe=n.atom({key:"pointToPointMeasurementOutcome",default:void 0}),et=n.atom({key:"editedPointToPointMeasurement",default:void 0});function usePointToPointMeasurement(e){const t=n.useSetRecoilState(Qe);o.useEffect((()=>{let n;return whenComponentReady(e,(()=>{n=e?.measurementModel.onOutcomeChanged(t)})),()=>n?.dispose()}),[e,t])}const tt=2,nt=n.atom({key:"isEditingPreciseMeasurement",default:!1}),at=n.atom({key:"preciseMeasurementOutcome",default:void 0}),ot=n.atom({key:"preciseMeasurementController",dangerouslyAllowMutability:!0,default:void 0}),st=n.atom({key:"preciseMeasurementOverlays",dangerouslyAllowMutability:!0,default:void 0}),it=n.atom({key:"preciseMeasurementEntities",dangerouslyAllowMutability:!0,default:[]}),rt=n.selector({key:"preciseMeasurementMessage",get:({get:e})=>{const t=undefined;return 0===e(it).length?"Select a surface":void 0}});function usePreciseMeasurementModel(e,t,a){const s=n.useSetRecoilState(it),i=n.useSetRecoilState(at),r=n.useSetRecoilState(ot),l=n.useSetRecoilState(st),c=n.useRecoilValue(ot);o.useEffect((()=>{let n;return whenComponentReady(e,(()=>{n=e?.measurementModel.onEntitiesChanged((e=>{s(e),t?.(e)}))})),()=>n?.dispose()}),[e,s]),o.useEffect((()=>{let t;return whenComponentReady(e,(()=>{t=e?.measurementModel.onOutcomeChanged((e=>{i(e),a?.(e)}))})),()=>t?.dispose()}),[e,i]),o.useEffect((()=>{let t;return whenComponentReady(e,(()=>{t=e?.measurementModel.onEntitiesChanged((e=>{if(e.length>2){const t=e[2];c?.setEntities(new Set([t]))}}))})),()=>t?.dispose()}),[e,c]),o.useEffect((()=>{whenComponentReady(e,(()=>{r(e?.measurementController)}))}),[e,r]),o.useEffect((()=>{whenComponentReady(e,(()=>{l(e?.measurementOverlays)}))}),[e,l])}function useMeasurementActions(){const e=useBoxSelectionActions(),t=useEnablePointToPointMeasurement(),n=useDisablePointToPointMeasurement(),a=useDisablePreciseMeasurement(),o=useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromise(ot);t?.clearEntities()})),s=useActionCallback((()=>async(e={})=>{await o(),n(e),a()})),i=useActionCallback((({set:e,reset:n})=>async a=>{await s(),"point-to-point"===a?t():(n(at),n(it),e(nt,!0))}));return{disableEditMeasurement:useActionCallback((()=>async e=>{await s(e)})),enableEditMeasurement:useActionCallback((()=>async e=>{await i(e)})),resetMeasurement:useActionCallback((({snapshot:e,reset:t})=>async()=>{const n=await e.getPromise(nt),a=await e.getPromise(Je);n?await o():a&&(t(Qe),t(et))})),clearEditedPointToPointMeasurement:useActionCallback((({reset:e})=>()=>{e(et)})),setEditedPointToPointMeasurement:useActionCallback((({set:e})=>t=>{e(et,t)})),toggleEditPointToPointMeasurement:useActionCallback((({snapshot:t})=>async()=>{const n=undefined;await t.getPromise(Je)?await s():await i("point-to-point"),e.disable()})),toggleEditPreciseMeasurement:useActionCallback((({snapshot:t})=>async()=>{const n=undefined;await t.getPromise(nt)?await s():await i("precise"),e.disable()}))}}function useEnablePointToPointMeasurement(){return useActionCallback((({reset:e,set:t})=>(n={})=>{t(Je,!0),n.keepExistingMeasurement||e(Qe)}))}function useDisablePointToPointMeasurement(){return useActionCallback((({reset:e})=>(t={})=>{e(Je),t.keepExistingMeasurement||(e(et),e(Qe))}))}function useDisablePreciseMeasurement(){return useActionCallback((({reset:e})=>async()=>{e(nt),e(at),e(it)}))}const lt=n.selector({key:"isEditingMeasurement",get:({get:e})=>e(Je)||e(nt)}),ct=n.selector({key:"measurementPanelModel",get:({get:e})=>e(Qe)||e(at)}),dt=n.selector({key:"measurementPanelOverlays",dangerouslyAllowMutability:!0,get:({get:e})=>e(st)}),ut=n.selector({key:"measurementPanelMessage",get:({get:e})=>{const t=undefined;return e(nt)?e(rt):void 0}}),mt=n.selector({key:"measurementPanelIsResettable",get:({get:e})=>e(lt)&&null!=e(ct)});var pt=Object.freeze({__proto__:null,editedPointToPointMeasurement:et,isEditingMeasurement:lt,isEditingPointToPointMeasurement:Je,isEditingPreciseMeasurement:nt,measurementPanelIsResettable:mt,measurementPanelMessage:ut,measurementPanelOutcome:ct,measurementPanelOverlays:dt,pointToPointMeasurementOutcome:Qe,preciseMeasurementController:ot,preciseMeasurementEntities:it,preciseMeasurementMessage:rt,preciseMeasurementOutcome:at,preciseMeasurementOverlays:st,useDisablePointToPointMeasurement:useDisablePointToPointMeasurement,useDisablePreciseMeasurement:useDisablePreciseMeasurement,useEnablePointToPointMeasurement:useEnablePointToPointMeasurement,useMeasurementActions:useMeasurementActions,usePointToPointMeasurement:usePointToPointMeasurement,usePreciseMeasurementModel:usePreciseMeasurementModel});const ht="Scene Alteration Performance";var xt;!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"}(xt||(xt={}));var ft=Object.freeze({__proto__:null,SCENE_ALTERATION_PERFORMANCE:ht,get SceneAlterationPerformanceType(){return xt}});const gt=n.atom({key:"fetchedItemInvalidator",default:0}),yt=n.selectorFamily({key:"fetchedItems",get:e=>async({get:t})=>{const n=t(G),a=t(X);if(t(gt),t(tn),null!=a)try{return await(n?.sceneItems?.getSceneViewItem(e,a,{includeOverride:!0,includeWorldTransform:!0}))}catch(t){return void logger_debug(`Error encountered get scene view item. [itemId={${e}}]`,t)}}}),vt=n.atomFamily({key:"selectionSelectedItems",default:void 0}),bt=n.atom({key:"selectionSelectedItemIds",default:[]}),wt=n.atom({key:"selectionLastSelected",default:void 0}),Ct=n.atom({key:"selectionLastSelectionFromViewer",default:!1}),St=n.atom({key:"selectionLastSelectWasMultiSelect",default:!1}),Vt=n.selector({key:"selectionHasMultipleSelected",get:({get:e})=>{const t=e(wt),n=undefined;return e(bt).filter((e=>e!==t?.id&&!t?.ancestors?.includes(e))).length>0}}),jt=n.atom({key:"selectionIsAncestorSelection",default:!1}),kt=n.atom({key:"selectionFirstSelectedItemInTreeId",default:void 0}),Tt=n.selector({key:"selectionHighestSelectedAncestor",get:({get:e})=>{const t=e(wt),n=e(bt);return t?.ancestors?.find((e=>n.includes(e)))??t?.id}}),At=n.atom({key:"selectionPreviousVisibleSummary",default:void 0}),Pt=n.atom({key:"selectionVisibleSummary",default:void 0}),It=n.selector({key:"selectionVisibleCount",get:({get:e})=>e(Pt)?.count??0}),Mt=n.selector({key:"selectionBoundingBoxCenter",get:({get:e})=>{const t=e(Pt);return null!=t?.boundingBox?a.BoundingBox.center(t.boundingBox):a.Vector3.origin()}}),Et=n.selector({key:"selectionIsActive",get:({get:e})=>{const t=e(bt),n=undefined;return e(It)>0||t.length>0}}),Rt=n.selector({key:"fetchedAndSelectedItems",get:async({get:e})=>{const t=e(bt),n=undefined;return null!=e(X)?t.map((t=>e(yt(t)))):[]}}),Nt=n.atom({key:"selectionModelViewsSelected",default:void 0});function useSceneViewItemActions(){return{invalidateCachedItems:useActionCallback((({set:e})=>()=>{e(gt,(e=>e+1))}))}}var Ot=Object.freeze({__proto__:null,fetchedItem:yt,fetchedItemInvalidator:gt,useSceneViewItemActions:useSceneViewItemActions});const Lt=n.atom({key:"lengthUnit",default:"cm"}),_t=n.atom({key:"decimalPlace",default:"2"});var Bt=Object.freeze({__proto__:null,decimalPlace:_t,lengthUnit:Lt}),Dt,zt;!function(e){e.mm="millimeters",e.cm="centimeters",e.m="meters",e.in="inches",e.ft="feet"}(Dt||(Dt={})),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"}(zt||(zt={}));const convertFrom=(e,t)=>{const n=undefined;return e/zt[t]},convertTo=(e,t)=>{const n=undefined;return e*zt[t]},formatWithUnit=(e,t,n)=>`${e.toFixed(n)} ${t}`,formatDistance=(e,t,n)=>formatWithUnit(convertTo(e,t),t,n),createDistanceFormatter=(e,t)=>n=>formatDistance(n,e,t);function toUnitType(e){switch(e){case"cm":return"centimeters";case"m":return"meters";case"in":return"inches";case"ft":return"feet";default:return"millimeters"}}function pickLocalOrWorldTransform(e,t){return"local"===t?e.local:e.world}function mapItemTransforms(e,t){return{local:t(e.local),world:t(e.world)}}function makeItemTransforms(e,t,n){return"local"===n?{local:e,world:i.toWorldTransform(e,t)}:{world:e,local:i.toLocalTransform(e,t)}}function convertTransformToUnits(e,t){const{position:n,rotation:o,scale:s}=e;return{position:a.Vector3.create(convertTo(n.x,t),convertTo(n.y,t),convertTo(n.z,t)),rotation:o,scale:s}}function convertTransformFromUnits(e,t){const{position:n,rotation:o,scale:s}=e;return{position:a.Vector3.create(convertFrom(n.x,t),convertFrom(n.y,t),convertFrom(n.z,t)),rotation:o,scale:s}}function toValidTransform(e){const{position:t,rotation:n,scale:a}=e;return{position:{x:t.x||0,y:t.y||0,z:t.z||0},rotation:{x:n.x||0,y:n.y||0,z:n.z||0},scale:a||1}}function scale(e){const t=parseFloat(Math.sqrt(e[0]**2+e[4]**2+e[8]**2).toFixed(2)),n=parseFloat(Math.sqrt(e[1]**2+e[5]**2+e[9]**2).toFixed(2)),a=parseFloat(Math.sqrt(e[2]**2+e[6]**2+e[10]**2).toFixed(2));return t===n&&n===a?t:NaN}function translation(e){return{x:e[12],y:e[13],z:e[14]}}function rotation(e){const t=e.map((t=>t*(1/scale(e))));return t[8]<1?t[8]>-1?{x:Math.atan2(-t[9],t[10])*(180/Math.PI),y:Math.asin(t[8])*(180/Math.PI),z:Math.atan2(-t[4],t[0])*(180/Math.PI)}:{x:-Math.atan2(-t[1],t[5])*(180/Math.PI),y:-90,z:0}:{x:Math.atan2(t[1],t[5])*(180/Math.PI),y:90,z:0}}function toTransformFromApiMatrix(e){return null!=e?{position:translation(e),rotation:rotation(e),scale:scale(e)}:void 0}const Ft={position:a.Vector3.create(0,0,0),rotation:a.Vector3.create(0,0,0),scale:1},Ht=n.atom({key:"transformWidgetEnabled",default:!1}),Ut=n.atom({key:"transformWidgetPosition",default:void 0}),Wt=n.atom({key:"transformWidgetOrientationOverride",default:void 0}),Gt=n.selector({key:"transformWidgetOrientation",get:({get:e})=>{const t=e(Wt),n=e(wt);if(null!=t)return t;if(null!=n){const t=e(en(n.id));return a.Euler.fromDegrees({x:t?.world.rotation.x,y:t?.world.rotation.y,z:t?.world.rotation.z})}}}),Kt=n.atom({key:"transformWidgetCachedOrientation",default:void 0}),$t=n.atom({key:"transformWidgetSyncToSelection",default:!1}),qt=n.atom({key:"transformWidgetIsInteracting",default:!1}),Yt=n.atomFamily({key:"appliedItemTransform",default:void 0}),Xt=n.atom({key:"appliedItemTransformIds",default:[]}),Zt=n.atom({key:"selectedCoordinateSpace",default:"world"}),Jt=n.atomFamily({key:"editedItemTransform",default:void 0}),Qt=n.selectorFamily({key:"displayedItemTransform",get:e=>({get:t})=>{if(null!=e){const n=t(Zt),a=t(Lt),o=t(en(e)),s=t(Jt(e));if(null!=s)return s.transform;if(null!=o)return pickLocalOrWorldTransform(mapItemTransforms(o,(e=>convertTransformToUnits(e,a))),n)}},set:e=>({get:t,set:a},o)=>{if(null!=e){const s=t(Zt),i=t(nn(e)),r=t(en(e)),l=t(Lt);if(null!=r&&!(o instanceof n.DefaultValue)&&null!=o&&null!=i){a(Jt(e),{coordinateSpace:s,units:l,transform:o});const n=makeItemTransforms(convertTransformFromUnits(toValidTransform(o),l),i,s),r=t(Xt);a(Yt(e),n),a(Xt,[...r,e])}}}}),en=n.selectorFamily({key:"fetchedItemTransforms",get:e=>({get:t})=>{const n=t(yt(e));if(null!=n){const e=n.override?.transform?toTransformFromApiMatrix(n.override?.transform):void 0,t=n.worldTransform?toTransformFromApiMatrix(n.worldTransform):void 0;return{local:e??Ft,world:t??Ft}}}}),tn=n.atom({key:"transformInvalidator",default:0}),nn=n.selectorFamily({key:"parentItemWorldMatrix",get:e=>({get:t})=>{const n=t(X);if(null!=e&&null!=n){const n=t(yt(e));if(null!=n?.parentId){const e=t(en(n.parentId)),a=t(Yt(n.parentId));if(null==e)throw new Error("Invalid state. Parent item state should be populated, but is undefined.");return null!=a?i.toMatrix(i.toRadiansTransform(a.world)):i.toMatrix(i.toRadiansTransform(e.world))}}return logger_debug(`Unable to find the world matrix for the parent of ${e}. Returning the identity matrix.`),a.Matrix4.makeIdentity()}});function useUpdateEditedTransformWhenSettingsChange(e){const t=n.useRecoilValue(Lt),a=n.useRecoilValue(Zt),s=n.useRecoilValue(Yt(e??"")),[i,r]=n.useRecoilState(Jt(e??""));o.useEffect((()=>{if(null!=s&&(i?.coordinateSpace!==a||i?.units!==t)){const e=undefined,n=convertTransformToUnits(pickLocalOrWorldTransform(s,a),t);r({units:t,coordinateSpace:a,transform:n})}}),[t,a])}function useEditItemTransform(e){const t=useTransformActions();useUpdateEditedTransformWhenSettingsChange(e);const a=n.useRecoilValueLoadable(nn(e)),[o,s]=n.useRecoilStateLoadable(Qt(e));return{transform:"hasValue"===o.state?o.contents:void 0,loading:"loading"===o.state||"loading"===a.state,error:"hasError"===o.state?o.contents:void 0,async update(n){t.enableSelectionSync(),s(n),null!=e&&await t.applyTransformToItem(e)}}}const useTransformActions=()=>{const e=useApplicationMessageActions(),t=useViewerSceneActions(),n=useActionCallback((({set:e,snapshot:t})=>async()=>{const n=await t.getPromise(Mt);e(Ut,n)})),o=useActionCallback((({set:e,snapshot:t})=>async()=>{const a=await t.getPromise(Ut),o=await t.getPromise(St),s=await t.getPromise(bt),i=await t.getPromise(It);null==a&&(s.length>0||o||i>0)&&await n(),e($t,!0)})),s=useActionCallback((({set:e})=>async t=>{e(Ut,t??void 0)})),r=useActionCallback(retainSnapshot((({snapshot:e,set:t,reset:n})=>async()=>{const a=await e.getPromise(Gt),o=undefined;(await e.getPromise(Xt)).forEach((e=>{n(Yt(e)),n(Jt(e))})),n(Xt),null!=a&&t(Kt,a),t(tn,(e=>e+1))}))),l=useActionCallback((({set:e,reset:t})=>n=>{t(Kt),e(Wt,n)})),c=useActionCallback((({set:e})=>()=>{e(Ut,void 0),e(Ht,!1)}));return{enableTransformWidget:useActionCallback((({set:t})=>async(a,i)=>{e.setToastMessage({message:"Transform manipulator enabled! Select parts to interact.",duration:L}),t(Ht,!0),i?await n():null==a?await o():await s(a)})),disableTransformWidget:useActionCallback((({reset:e})=>()=>{e(Ht),e(Wt)})),setTransformWidgetOrientation:l,clearTransformWidgetOrientation:useActionCallback((({reset:e})=>()=>{e(Kt),e(Wt)})),setTransformWidgetPosition:s,clearTransformWidgetPosition:useActionCallback((({reset:e})=>()=>e(Ut))),invalidateTransforms:r,setIsInteractivelyTransforming:useActionCallback((({set:e})=>t=>{e(qt,t)})),setDefaultWidgetPosition:o,setDefaultWidgetPositionToSelection:n,enableSelectionSync:useActionCallback((({set:e})=>()=>e($t,!0))),disableSelectionSync:useActionCallback((({reset:e})=>()=>e($t))),syncToSelection:useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromise(At),n=await e.getPromise(Pt),o=undefined;if(await e.getPromise($t)){const e=n?.boundingBox,o=null!=e&&null!=t?.boundingBox&&equals(e,t.boundingBox);null==e||o||await s(a.BoundingBox.center(e))}})),orientToHitResult:useActionCallback((({reset:e})=>async t=>{e($t),null==t?.annotationId&&(null!=t?await s(t?.position):(e(Ut),l(void 0)))})),clearSelectedTransforms:useActionCallback((()=>async()=>{await t.execute(xt.CLEAR_SELECTED_TRANSFORMS,(e=>e.where((e=>e.withSelected())).clearTransforms())),await r(),c()})),clearAllTransforms:useActionCallback((()=>async()=>{await t.execute(xt.CLEAR_SELECTED_TRANSFORMS,(e=>e.where((e=>e.all())).clearTransforms())),await r(),c()})),applyTransformToItem:useActionCallback((({snapshot:e})=>async t=>{const n=await e.getPromise(G),o=await(n?.scene()),s=await e.getPromise(Yt(t));if(null==s)return void logger_warn(`There is no transform to apply to item ${t}.`);const r=a.Matrix4.transpose(i.toMatrix(i.toRadiansTransform(s?.local)));return o?.items((e=>e.where((e=>e.withItemId(t))).transform(r))).execute()}))}};var an=Object.freeze({__proto__:null,appliedItemTransformIds:Xt,appliedItemTransforms:Yt,convertTransformFromUnits:convertTransformFromUnits,convertTransformToUnits:convertTransformToUnits,displayedItemTransform:Qt,editedItemTransform:Jt,fetchedItemTransforms:en,identityTransform:Ft,makeItemTransforms:makeItemTransforms,mapItemTransforms:mapItemTransforms,parentItemWorldMatrix:nn,pickLocalOrWorldTransform:pickLocalOrWorldTransform,selectedCoordinateSpace:Zt,toValidTransform:toValidTransform,transformInvalidator:tn,transformWidgetCachedOrientation:Kt,transformWidgetEnabled:Ht,transformWidgetIsInteracting:qt,transformWidgetOrientation:Gt,transformWidgetOrientationOverride:Wt,transformWidgetPosition:Ut,transformWidgetSyncToSelection:$t,useEditItemTransform:useEditItemTransform,useTransformActions:useTransformActions});const useHitActions=()=>{const e=useCrossSectioningActions(),t=useMeasurementActions(),n=useTransformActions(),a=useActionCallback(retainSnapshot((({snapshot:e})=>async()=>{const n=await e.tryGetPromise(Me).then((e=>e.value)),a=await e.getPromise(et);null==n&&null!=a?.start&&null!=a.end&&await t.resetMeasurement()}))),o=useActionCallback(retainSnapshot((({snapshot:e})=>async()=>{const t=await e.tryGetPromise(Me).then((e=>e.value));await n.orientToHitResult(t)}))),s=useActionCallback(retainSnapshot((({set:e,snapshot:t})=>async()=>{const n=await t.tryGetPromise(Me).then((e=>e.value));e(Ge,n)}))),i=useActionCallback(retainSnapshot((({snapshot:e,set:t})=>async()=>{t(Ie,await e.tryGetPromise(Me).then((e=>e.value)))})));return{tap:useActionCallback(retainSnapshot((({snapshot:t,set:n})=>async({detail:r},...l)=>{const c=await t.getPromise(lt),d=await t.getPromise(xe),u=2!==r?.buttons&&!r?.altKey;r.altKey||r.ctrlKey||r.metaKey||r.shiftKey;const m=u&&!d.hitPending&&!c,p=await t.tryGetPromise(Me).then((e=>e.value));n(Pe,p),n(Te,r),await a(),m&&(l.forEach((e=>e())),await o()),await s(),await e.sectionCurrentHit(),await i()}))),longPress:useActionCallback(retainSnapshot((({snapshot:e,set:t,reset:n})=>async a=>{n(Te),t(Ae,a.detail),await e.tryGetPromise(Me),await s(),await i()})))}},on=n.selector({key:"viewerToolkitHitState",get:({get:e})=>{const t=undefined,n=undefined,a=undefined,o=undefined,s=undefined;return{tapDetails:e(Te),longPressDetails:e(Ae),previousHitResult:e(Pe),currentHitResult:e(Ie)}}});var sn=Object.freeze({__proto__:null,currentHitResult:Ie,hitResult:Me,hitResultsLongPressDetails:Ae,hitResultsSkipNextTap:Ee,hitResultsTapDetails:Te,hitState:on,previousHitResult:Pe,useHitActions:useHitActions});const rn=n.atomFamily({key:"modelViewsCursor",default:void 0}),ln=n.atomFamily({key:"pmiAnnotationsCursor",default:void 0}),cn=n.atomFamily({key:"loadedModelViews",default:[]}),dn=n.atomFamily({key:"loadedPmiAnnotations",default:[]}),un=n.atomFamily({key:"visiblePmiAnnotations",default:[]}),mn=n.selector({key:"modelViewsSceneItemName",get:async({get:e})=>{const t=e(Nt);if(null!=t){const n=e(yt(t.id));return n?.name??void 0}}}),pn=n.atom({key:"loadedItemModelView",default:void 0}),hn=n.selectorFamily({key:"nextModelViews",get:e=>async({get:t})=>{const n=t(G),a=t(rn(e));return await(n?.modelViews?.listByItem(e,{cursor:a,size:100,hasAnnotations:!0}))}}),xn=n.selectorFamily({key:"modelViews",get:e=>({get:t})=>{const n=t(cn(e)),a=t(hn(e));return n.flatMap((e=>e.modelViews)).concat(a?.modelViews??[])}}),fn=n.selectorFamily({key:"hasMoreModelViews",get:e=>({get:t})=>{const n=t(hn(e));return null!=n?.paging.next}}),gn=n.selectorFamily({key:"nextPmiAnnotations",get:e=>async({get:t})=>{const n=t(G),a=t(ln(e));return n?.pmi?.listAnnotations({modelViewId:e,cursor:a,size:100})}}),yn=n.selectorFamily({key:"pmiAnnotations",get:e=>({get:t})=>{const n=undefined;return t(dn(e)).flatMap((e=>e.annotations))}}),vn=n.selectorFamily({key:"hasMorePmiAnnotations",get:e=>({get:t})=>{const n=undefined;return null!=t(ln(e))}}),bn=n.atom({key:"selectedPmiAnnotationId",default:void 0});function useSceneAnnotationsOperations(){const e=o.useCallback((async(e,t,n)=>{const a=await(t?.scene());null==n?await(a?.elements((t=>e(t.annotations.where((e=>e.all()))))).execute()):n.length>0&&await(a?.elements((t=>e(t.annotations.where((e=>e.withAnnotationIds(n)))))).execute())}),[]),t=o.useCallback((async(e,t)=>{const n=await(e?.scene());n?.elements((e=>[e.annotations.where((e=>e.all())).deselect(),e.annotations.where((e=>e.withAnnotationIds([t]))).select()])).execute()}),[]),n=o.useCallback((async e=>{const t=await(e?.scene());t?.elements((e=>[e.annotations.where((e=>e.all())).deselect()])).execute()}),[]);return{sceneAnnotationsOperation:e,selectOnlyAnnotation:t,clearAnnotationSelection:n}}function usePmiAnnotationActions(){const e=useSceneAnnotationsOperations(),t=useActionCallback((({snapshot:e,set:t})=>async n=>{const a=await e.getPromise(gn(n));if(null!=a){t(dn(n),(e=>[...e,a])),t(un(n),(e=>[...e,...a.annotations]));const e=a?.paging?.next;t(ln(n),null!=e?()=>e:()=>{})}})),n=useActionCallback((({snapshot:e})=>async a=>{const o=document.getElementById(`annotation-entry-${a}`);if(null!=o)o.scrollIntoView();else{const o=await e.getPromise(pn),s=o?.modelView.id;if(null==s)return;const i=undefined;await e.getPromise(vn(s))&&(await t(s),await n(a))}}));return{fetchInitialPmiAnnotations:useActionCallback((({snapshot:e})=>async n=>{const a=undefined;0===(await e.getPromise(yn(n))).length&&await t(n)})),fetchNextPmiAnnotations:useActionCallback((()=>async e=>{await t(e)})),selectPmiAnnotation:useActionCallback((({set:t,snapshot:a})=>async(o,s)=>{t(bn,o);const i=await a.getPromise(G);null!=i&&await(e?.selectOnlyAnnotation(i,o)),s&&await n(o)})),clearPmiAnnotationSelection:useActionCallback((({reset:t,snapshot:n})=>async()=>{const a=await n.getPromise(bn),o=await n.getPromise(G);null!=a&&null!=o&&(t(bn),await(e?.clearAnnotationSelection(o)))})),scrollToSelectedPmiAnnotation:n}}const wn=n.atom({key:"sceneTreeLoaderVisible",default:!1}),Cn=n.atom({key:"sceneTreeElement",default:void 0}),Sn=n.atom({key:"sceneTreeController",default:void 0,dangerouslyAllowMutability:!0}),Vn=n.atom({key:"sceneTreeOpenPopover",default:void 0}),jn=n.selectorFamily({key:"sceneTreePopoverIsOpen",get:e=>({get:t})=>t(Vn)===e});function useSceneTreeActions(){const e=useSelectionActions(),t=useViewerCameraActions();return{toggleSelection:useActionCallback((({snapshot:t})=>async(n,a,o)=>{if(!n.defaultPrevented&&0===n.button&&(n.altKey||((n.ctrlKey||n.metaKey)&&a.selected?await o.deselectItem(a):a.selected?await o.selectItem(a,{recurseParent:!0}):a.selected||await o.selectItem(a,{append:n.ctrlKey||n.metaKey,range:n.shiftKey})),null!=a.id)){const o=await t.getPromise(wt);e.syncSelection({id:a.id?.hex,ancestors:o?.ancestors??[]},{selected:!n.metaKey&&!n.ctrlKey||!a.selected,multiSelect:n.shiftKey||n.metaKey||n.ctrlKey})}})),toggleExpansion:useActionCallback((()=>(e,t,n)=>{n.toggleExpandItem(t)})),toggleVisibility:useActionCallback((()=>(e,t,n)=>{n.toggleItemVisibility(t)})),flyToRow:useActionCallback((({snapshot:e})=>async n=>{const a=await e.getPromise(Cn),o=await(a?.getRowAtClientY(n));null!=o?.node.id?.hex&&await t.flyToById(o.node.id.hex)})),flyToFirstSelectedItem:useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromise(Cn),n=await e.getPromise(kt);null!=n&&t?.scrollToItem(n)})),setContextMenuItem:useActionCallback((({set:e,snapshot:t})=>async n=>{const a=await t.getPromise(Cn),o=await(a?.getRowAtClientY(n));e(Ge,o)})),openSceneTreePopover:useActionCallback((({set:e})=>t=>{e(Vn,t)})),closeSceneTreePopover:useActionCallback((({set:e})=>()=>{e(Vn,void 0)}))}}var kn=Object.freeze({__proto__:null,sceneTreeController:Sn,sceneTreeElement:Cn,sceneTreeLoaderVisible:wn,sceneTreeOpenPopover:Vn,sceneTreePopoverIsOpen:jn,useSceneTreeActions:useSceneTreeActions});function useSelectionActions(){const e=usePmiAnnotationActions(),t=useSceneViewItemActions(),n=useTransformActions(),a=useViewerSceneActions(),o=useActionCallback((({snapshot:e,reset:t})=>async()=>{const n=undefined;(await e.getPromise(bt)).forEach((e=>t(vt(e))))})),s=useActionCallback((({snapshot:e,reset:t,set:n})=>async(o,s)=>{const i=await e.getPromise(vt(o.id)),r=await e.getPromise(bt),l=[...o.ancestors??[]]?.reverse().find((e=>!r.includes(e)));null!=i&&null!=l?(n(vt(l),{id:l}),n(bt,(e=>[...e,l])),n(jt,!0),await a.execute(xt.SELECTING_ANCESTOR,a.selectItemsTransform(l)),await m({id:l})):s?.clear?(n(vt(o.id),o),n(bt,[o.id]),await a.execute(xt.SELECTING_ONLY_ITEM,a.clearSelectionTransform,a.selectItemsTransform(o.id)),await m(o)):(n(vt(o.id),o),n(bt,(e=>[...e,o.id])),await a.execute(xt.SELECTING_ITEMS,a.selectItemsTransform(o.id)),await m(o)),n(wt,o),n(Ct,!0),t(St);try{const t=await e.getPromise(Cn);await(t?.scrollToItem(o.id))}catch(e){logger_debug(`The scene item was not found in the tree. [itemId={${o.id}}]`)}})),i=useActionCallback((({reset:e,set:t})=>async n=>{e(vt(n)),e(St),e(jt),t(bt,(e=>e.filter((e=>e!==n)))),await a.execute(xt.DESELECTING_ITEMS,a.deselectItemsTransform(n))})),r=useActionCallback((({snapshot:e})=>async t=>{const n=await e.getPromise(vt(t.id));null!=n?await i(n.id):await s(t)})),l=useActionCallback((({snapshot:a,reset:o,set:i})=>async(r,l={})=>{const c=await a.getPromise(vt(r.id)),d=await a.getPromise(bt);if(d.filter((e=>e!==r.id&&!r.ancestors?.includes(e))).forEach((e=>o(vt(e)))),o(St),o(jt),c)if(l.ignoreAncestorSelection)o(bt),o(vt(c.id));else{const e=d.filter((e=>e===r.id||r.ancestors?.includes(e)));i(bt,e)}else o(bt);t.invalidateCachedItems(),n.clearTransformWidgetOrientation(),await e.clearPmiAnnotationSelection(),await s(r,{clear:!0})})),c=useActionCallback((({reset:t})=>async()=>{await o(),t(bt),t(wt),t(Ct),t(St),t(jt),n.clearTransformWidgetPosition(),n.clearTransformWidgetOrientation(),await e.clearPmiAnnotationSelection()})),d=useActionCallback((()=>async()=>{await c(),await a.execute(xt.CLEAR_SELECTION,a.clearSelectionTransform)})),u=useActionCallback((({set:e})=>async t=>{e(St,t)})),m=useActionCallback((({set:e,snapshot:t})=>async n=>{const a=await t.getPromise(Nt);a?.id!==n?.id&&e(Nt,n)}));return{select:s,toggleSelection:r,clearAndSelect:l,selectCurrentHit:useActionCallback(retainSnapshot((({snapshot:t})=>async()=>{const n=await t.tryGetPromise(Me).then((e=>e.value)),a=await t.getPromise(Te),o=a?.metaKey||a?.ctrlKey||a?.shiftKey;null!=n?.annotationId?await e.selectPmiAnnotation(n.annotationId,!0):null==n||o?null!=n&&o?await r(n):await d():await l(n)}))),syncSelection:useActionCallback((({set:e,snapshot:t,reset:n})=>async(a,s)=>{if(s.selected){const n=await t.getPromise(vt(a.id)),i=await t.getPromise(Sn);if(null!=n&&null!=i){const n=undefined,o=(await(i?.fetchNodeAncestors(a.id))).map((e=>e.id?.hex)).filter((e=>null!=e)),r=await t.getPromise(bt),l=[...o??[]]?.findLastIndex((e=>r.includes(e)));if(o.length>0&&l<o.length-1){const t=o[l+1];return e(jt,!0),e(wt,{id:t}),e(vt(t),{id:t}),e(bt,(e=>[...e.filter((e=>e!==t)),t])),e(Ct,!1),e(St,!!s.multiSelect),void await m({id:t})}}await o(),e(vt(a.id),a),s.multiSelect?e(bt,(e=>[...e.filter((e=>e!==a.id)),a.id])):e(bt,[a.id]),await m(a),e(wt,a),e(Ct,!1),e(St,!!s.multiSelect)}else n(vt(a.id)),n(St),e(bt,(e=>e.filter((e=>e!==a.id))))})),deselect:i,clearSelection:d,resetSelectionState:c,toggleLastSelectWasMultiSelect:u,selectForModelViewsPanel:m}}const Tn=n.selector({key:"viewerToolkitSelectionState",get:({get:e})=>{const t=undefined,n=undefined,a=undefined,o=undefined;return{selectedItemIds:e(bt),lastSelected:e(wt),highestSelectedAncestorId:e(Tt)}}});var An=Object.freeze({__proto__:null,fetchedAndSelectedItems:Rt,selectionBoundingBoxCenter:Mt,selectionFirstSelectedItemInTreeId:kt,selectionHasMultipleSelected:Vt,selectionHighestSelectedAncestor:Tt,selectionIsActive:Et,selectionIsAncestorSelection:jt,selectionLastSelectWasMultiSelect:St,selectionLastSelected:wt,selectionLastSelectionFromViewer:Ct,selectionModelViewsSelected:Nt,selectionPreviousVisibleSummary:At,selectionSelectedItemIds:bt,selectionSelectedItems:vt,selectionState:Tn,selectionVisibleCount:It,selectionVisibleSummary:Pt,useSelectionActions:useSelectionActions});function createColorMaterialWithId(e,t=j.create()){return{id:t,...i.ColorMaterial.fromHex(e)}}const Pn=255,In=18,Mn=n.atom({key:"sceneItemAdjustmentsSelectedColor",default:void 0}),En=n.atom({key:"sceneItemAdjustmentsRecentColors",default:[]}),Rn=n.atom({key:"sceneItemAdjustmentsCustomColors",default:[createColorMaterialWithId("#ffffff"),createColorMaterialWithId("#616161")]}),Nn=n.atom({key:"sceneItemAdjustmentsSelectedOpacity",default:void 0}),On=n.atomFamily({key:"appliedItemMaterialOverride",default:void 0}),Ln=n.atom({key:"appliedItemMaterialOverrideIds",default:[]}),_n=n.selector({key:"sceneItemAdjustmentsLastSelectedOverride",get:({get:e})=>{const t=e(wt);if(null!=t)return e(On(t.id))}}),Bn=n.atom({key:"applyMaterialToAllUserAction",default:void 0}),Dn=n.atom({key:"showConfirmDialogWhenApplyingMaterialToAll",default:!0}),zn=n.atom({key:"confirmApplyMaterialToAllDialogOpen",default:!1}),useSceneItemMaterialActions=()=>{const e=useViewerSceneActions(),t=useActionCallback((({snapshot:e,reset:t})=>async()=>{const n=await e.getPromise(Ln);t(Mn),n.forEach((e=>t(On(e)))),t(Ln)}));return{updateColor:useActionCallback((({set:e})=>t=>{e(Mn,t)})),saveRecentColor:useActionCallback((({set:e,snapshot:t})=>async n=>{const a=await t.getPromise(En),o=[n,...a.filter((e=>e!==n))],s=o.length>In?o.slice(0,-(o.length-In)):o;e(Mn,n),e(En,s)})),removeRecentColor:useActionCallback((({set:e,snapshot:t})=>async n=>{const a=undefined,o=(await t.getPromise(En)).filter((e=>e.id!==n));e(En,o)})),setCustomColors:useActionCallback((({set:e})=>async t=>{e(Rn,t)})),saveCustomColor:useActionCallback((({set:e,snapshot:t})=>async n=>{const a=undefined,o=[...await t.getPromise(Rn),n],s=o.length>In?o.slice(o.length-In):o;e(Mn,n),e(Rn,s)})),removeCustomColor:useActionCallback((({set:e,snapshot:t})=>async n=>{const a=undefined,o=(await t.getPromise(Rn)).filter((e=>e.id!==n));e(Rn,o)})),clearCurrentColor:useActionCallback((({reset:e})=>()=>{e(Mn)})),clearCurrentOpacity:useActionCallback((({reset:e})=>()=>{e(Nn)})),clear:useActionCallback((({snapshot:t,set:n,reset:a})=>async()=>{const o=await t.getPromise(bt);a(Mn),o.forEach((e=>a(On(e)))),n(Ln,(e=>e.filter((e=>!o.includes(e))))),await e.execute(xt.CLEAR_SELECTED_MATERIAL_OVERRIDES,(e=>e.where((e=>e.withSelected())).clearMaterialOverrides().select()))})),clearAll:useActionCallback((()=>async()=>{await t(),await e.execute(xt.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(Nn,t)})),apply:useActionCallback((({snapshot:t,set:n})=>async()=>{const a=await t.getPromise(Mn),o=await t.getPromise(Nn),s=await t.getPromise(bt),i=await t.getPromise(_n),r=a??i,l=o??i?.opacity;if(null!=r){const t={...r,opacity:l??r.opacity};await e.execute(xt.APPLY_MATERIAL_OVERRIDE_TO_SELECTION,(e=>e.where((e=>e.withSelected())).materialOverride(t))),s.forEach((e=>n(On(e),t))),n(Ln,(e=>[...e,...s]))}})),confirmApplyAll:useActionCallback((({set:e})=>t=>{e(zn,!0),e(Bn,(()=>t))})),cancelApplyAll:useActionCallback((({reset:e})=>()=>{e(zn),e(Bn)})),applyAll:useActionCallback((({snapshot:t,reset:n})=>async()=>{const a=await t.getPromise(Mn),o=await t.getPromise(Nn);if(null!=a){const s=await t.getPromise(Ln),i={...a,opacity:o??a.opacity};await e.execute(xt.APPLY_MATERIAL_OVERRIDE_TO_ALL,(e=>e.where((e=>e.all())).materialOverride(i))),s.forEach((e=>n(On(e))));const r=await t.getPromise(Bn);r?.(i),n(zn),n(Bn)}})),hideConfirmApplyAllDialog:useActionCallback((({set:e})=>()=>{e(Dn,!1)}))}},Fn="#ffff00",Hn=35,Un=1,Wn=n.atom({key:"selectionHighlightingSelectedColor",default:Fn}),Gn=n.atom({key:"selectionHighlightingSelectedOpacity",default:Hn}),Kn=n.atom({key:"selectionHighlightingSelectedLineThickness",default:1});function elementIsColorSwatch(e){return e instanceof Element&&"VERTEX-COLOR-SWATCH"===e.nodeName}function elementHasColorAttribute(e){return"true"===e.getAttribute("data-custom-color")||"true"===e.getAttribute("data-recent-color")}const $n="#FFFFFF",qn=n.atom({key:"viewerBackgroundSelectedColor",default:$n});var Yn=Object.freeze({__proto__:null,DEFAULT_FEATURE_EDGE_COLOR:De,DEFAULT_FEATURE_EDGE_THICKNESS_VALUE:Be,DEFAULT_SELECTION_HIGHLIGHTING_COLOR:Fn,DEFAULT_SELECTION_HIGHLIGHTING_LINE_THICKNESS:1,DEFAULT_SELECTION_HIGHLIGHTING_OPACITY:Hn,DEFAULT_VIEWER_BACKGROUND_COLOR:$n,MAXIMUM_MATERIAL_OVERRIDE_OPACITY:Pn,MAX_STORED_COLOR_ARRAY_LENGTH:In,appliedItemMaterialOverride:On,appliedItemMaterialOverrideIds:Ln,applyMaterialToAllUserAction:Bn,confirmApplyMaterialToAllDialogOpen:zn,elementHasColorAttribute:elementHasColorAttribute,elementIsColorSwatch:elementIsColorSwatch,featureEdgesLineThickness:Fe,featureEdgesSelectedColor:ze,sceneItemAdjustmentsCustomColors:Rn,sceneItemAdjustmentsLastSelectedOverride:_n,sceneItemAdjustmentsRecentColors:En,sceneItemAdjustmentsSelectedColor:Mn,sceneItemAdjustmentsSelectedOpacity:Nn,selectionHighlightingSelectedColor:Wn,selectionHighlightingSelectedLineThickness:Kn,selectionHighlightingSelectedOpacity:Gn,showConfirmDialogWhenApplyingMaterialToAll:Dn,useSceneItemMaterialActions:useSceneItemMaterialActions,viewerBackgroundSelectedColor:qn});const VertexSceneItemMaterialApplyAll=({onApplyAll:t})=>{const a=useSceneItemMaterialActions(),o=n.useRecoilValueLoadable(_n),i=n.useRecoilValue(Mn),r=n.useRecoilValue(Dn),l=u.useMemo((()=>"hasValue"===o.state?i??o.contents:i),[o,i]);return e.jsx(s.VertexTooltip,{content:"Apply to All",children:e.jsx(s.VertexIconButton,{iconName:"square-dot-outline",iconSize:"sm",color:"secondary",disabled:null==l,onClick:async()=>{r?a.confirmApplyAll(t):(await a.applyAll(),t?.(l))}})})};function SceneItemMaterialApplyAllConfirmationDialog(){const t=useSceneItemMaterialActions(),a=n.useRecoilValue(zn),[i,r]=o.useState(!1),onCloseDialog=()=>{t.cancelApplyAll(),r(!1)};return a?e.jsxs(s.VertexDialog,{open:!0,className:"text-sm",onClosed:onCloseDialog,onBackdropClick:onCloseDialog,children:[e.jsx("div",{slot:"heading",children:"Apply to All Parts"}),e.jsx("div",{className:"max-w-lg break-words pr-2",children:"This will apply the same material to all parts in the model. Any previous material changes will be lost."}),e.jsxs("div",{className:"flex mt-8 gap-2 items-center",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx(s.VertexToggle,{"data-testid":"hide-confirmation-dialog-in-future-checkbox",variant:"check",className:"pt-0.5",checked:i,onValueChanged:e=>{r(e.detail)}}),"Don't show again this session"]}),e.jsxs("div",{className:"flex ml-auto gap-2",children:[e.jsx(s.VertexButton,{"data-testid":"cancel-apply-material-to-all",onClick:onCloseDialog,children:"Cancel"}),e.jsx(s.VertexButton,{color:"primary","data-testid":"confirm-apply-material-to-all",onClick:async()=>{await t.applyAll(),i&&t.hideConfirmApplyAllDialog()},children:"Apply"})]})]})]}):e.jsx(e.Fragment,{})}const VertexSceneItemMaterialColorPicker=({onApply:t})=>{const a=useSceneItemMaterialActions(),o=n.useRecoilValueLoadable(_n),s=n.useRecoilValue(Mn),i=u.useMemo((()=>"hasValue"===o.state?s??o.contents:s),[o,s]);return e.jsx(VertexColorPicker,{"data-testid":"selected-item-color-picker",value:null!=i?f.toHexString(i.diffuse):void 0,onValueChanged:async()=>{null!=i&&(await a.apply(),t?.(i),await a.saveRecentColor(createColorMaterialWithId(f.toHexString(i.diffuse))))},onInput:async e=>{a.updateColor(createColorMaterialWithId(e)),await a.apply()}})},ColorSwatch=({color:t,hideTooltip:n,onClick:a,...o})=>{const i="string"==typeof t?t:f.toHexString(t.diffuse);return e.jsx(s.VertexTooltip,{className:"flex-grow-0",content:i,disabled:!!n,children:e.jsx("button",{onClick:()=>a?.(t),children:e.jsx(s.VertexColorSwatch,{"data-testid":`color-swatch-${i}`,variant:"square",color:i,...o})})})},VertexSceneItemMaterialColorSwatches=({onAddCustomColor:t,onApplyCustomColor:a,onApplyRecentColor:o})=>{const i=useSceneItemMaterialActions(),r=n.useRecoilValue(Rn),l=n.useRecoilValue(En),c=r.length===In;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{"data-testid":"appearance-custom-colors",className:"flex flex-wrap gap-2 mt-1 mb-4",children:[r.map((t=>e.jsx(ColorSwatch,{color:t,onClick:async()=>{i.updateColor(t),await i.apply(),a?.(t)},"data-custom-color":!0,"data-color-id":t.id},t.id))),!c&&e.jsx(s.VertexColorPicker,{"data-testid":"appearance-custom-colors-add",variant:"swatch",size:"md",onValueChanged:async e=>{const n=createColorMaterialWithId(e.detail);await i.saveCustomColor(n),await i.apply(),t?.(n)},children:e.jsx("div",{slot:"overlay",className:"flex items-center justify-center w-full h-full",children:e.jsx(s.VertexIcon,{className:"bg-white p-2",name:"plus",size:"sm"})})})]}),!!l.length&&e.jsx("div",{"data-testid":"appearance-recent-colors",className:"flex flex-wrap gap-2",children:l.map((t=>e.jsx(ColorSwatch,{color:t,onClick:async()=>{i.updateColor(t),await i.apply(),o?.(t)},"data-recent-color":!0,"data-color-id":t.id},t.id)))})]})},VertexSceneItemMaterialOpacitySlider=({onApply:t})=>{const a=useSceneItemMaterialActions(),o=n.useRecoilValue(Nn),i=n.useRecoilValueLoadable(_n),r=u.useMemo((()=>"hasValue"===i.state?o??i.contents?.opacity??Pn:o??Pn),[o,i]),l=useDebouncedCallback((()=>{a.apply()}),500),c=u.useCallback((e=>{a.updateOpacity(e.detail.value),l(e.detail.value)}),[l,a]),d=u.useMemo((()=>"hasValue"!==i.state||null==i.contents),[i]);return e.jsx(s.VertexTooltip,{className:"flex w-full",content:d?"Select a part and apply a color to enable opacity":`${Math.floor(r/Pn*100)}%`,placement:"top",children:e.jsx(VertexSlider,{"data-testid":"scene-item-adjustments-opacity-slider",leftLabel:"0%",rightLabel:"100%",disabled:d,value:r??Pn,step:5,min:0,max:Pn,onValueChange:e=>{a.updateOpacity(e.detail.value),a.apply(),t?.(e.detail.value)},onValueInput:c})})};function VertexMaterialControls({customColors:t,onApplyMaterial:a,onApplyMaterialToAll:s,onAddCustomColor:i,onApplyCustomColor:r,onApplyRecentColor:l,onApplyOpacity:c}){const d=useSceneItemMaterialActions(),u=n.useRecoilValue(wt);return o.useEffect((()=>{d.clearCurrentColor(),d.clearCurrentOpacity()}),[u?.id]),o.useEffect((()=>{if(null!=t){const e=t.map((e=>({...e,id:j.create()})));d.setCustomColors(e)}}),[t]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Color"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(VertexSceneItemMaterialColorPicker,{onApply:a}),e.jsx(VertexSceneItemMaterialApplyAll,{onApplyAll:s})]})]}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Color Swatches"}),e.jsx(VertexSceneItemMaterialColorSwatches,{onAddCustomColor:i,onApplyCustomColor:r,onApplyRecentColor:l}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Opacity"}),e.jsx(VertexSceneItemMaterialOpacitySlider,{onApply:c}),e.jsx(SceneItemMaterialApplyAllConfirmationDialog,{})]})}const ResetButton=({id:t,tooltip:n,children:a})=>{const[i,r]=o.useState(!1);return e.jsx("div",{className:"ml-auto",children:e.jsxs(s.VertexDropdownMenu,{className:"flex items-stretch h-full","data-testid":`reset-button-dropdown-menu-${t}`,placement:"bottom-end",onMenuOpened:()=>r(!0),onMenuClosed:()=>r(!1),children:[e.jsx("div",{slot:"anchor",className:"flex items-center h-full",children:e.jsx(s.VertexTooltip,{content:n,disabled:i,placement:"bottom",children:e.jsxs(s.VertexButton,{className:_e("p-1.5 rounded-md select-none hover:bg-neutral-300 active:bg-neutral-400 cursor-pointer",{"bg-neutral-300":i}),"data-testid":`reset-button-${t}`,variant:"plaintext",children:[e.jsx(s.VertexIcon,{className:"px-0.5",name:"reset",size:"sm"}),e.jsx(s.VertexIcon,{name:"chevron-down",size:"sm"})]})})}),e.jsx("div",{className:"whitespace-nowrap",children:a})]})})},VertexSceneItemMaterialClear=({onClear:t,onClearAll:a})=>{const o=useSceneItemMaterialActions(),i=n.useRecoilValue(Et);return e.jsx("div",{className:"ml-auto",children:e.jsxs(ResetButton,{id:"materials",tooltip:"Clear Materials",children:[e.jsx("div",{className:"pt-1"}),e.jsx(s.VertexMenuItem,{"data-testid":"clear-selected-materials",onClick:()=>{o.clear(),t?.()},disabled:!i,children:"Clear selected materials"}),e.jsx(s.VertexMenuItem,{"data-testid":"clear-all-materials",onClick:()=>{o.clearAll(),a?.()},children:"Clear all materials"})]})})};function VertexMaterialPanelSection({customColors:t,onClearMaterial:n,onClearAllMaterials:a,onApplyMaterial:o,onApplyMaterialToAll:s,onAddCustomColor:i,onApplyCustomColor:r,onApplyRecentColor:l,onApplyOpacity:c}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Material",e.jsx(VertexSceneItemMaterialClear,{onClear:n,onClearAll:a})]}),children:e.jsx(VertexMaterialControls,{customColors:t,onApplyMaterial:o,onApplyMaterialToAll:s,onAddCustomColor:i,onApplyCustomColor:r,onApplyRecentColor:l,onApplyOpacity:c})})}const VertexSelectionHighlightingColorPicker=({onUpdate:t})=>{const[a,o]=n.useRecoilState(Wn);return e.jsx(VertexColorPicker,{"data-testid":"selection-highlighting-color-picker",value:a,onValueChanged:e=>{t?.(e.detail)},onInput:e=>o(e)})},VertexSelectionHighlightingLineThicknessSlider=({onUpdate:t})=>{const[a,o]=n.useRecoilState(Kn);return e.jsx(VertexSlider,{id:"selection-highlighting-line-thickness","data-testid":"selection-highlighting-line-thickness-slider",leftLabel:"Off",rightLabel:"Thick",min:0,max:3,step:.5,value:a,valueLabelDisplay:"auto",onValueInput:e=>{o(e.detail.value)},onValueChange:e=>{t?.(e.detail.value)}})},VertexSelectionHighlightingOpacitySlider=({onUpdate:t})=>{const[a,o]=n.useRecoilState(Gn);return e.jsx(VertexSlider,{id:"selection-highlighting-opacity","data-testid":"selection-highlighting-opacity-slider",leftLabel:"0%",rightLabel:"100%",min:0,max:100,step:5,value:a,valueLabelDisplay:"auto",onValueInput:e=>{o(e.detail.value)},onValueChange:e=>{t?.(e.detail.value)}})};function VertexSelectionHighlightingControls({onUpdateSelectionHighlightColor:t,onUpdateSelectionHighlightOpacity:n,onUpdateSelectionHighlightLineThickness:a}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Color"}),e.jsx(VertexSelectionHighlightingColorPicker,{onUpdate:t}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Opacity"}),e.jsx(VertexSelectionHighlightingOpacitySlider,{onUpdate:n}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Line Thickness"}),e.jsx(VertexSelectionHighlightingLineThicknessSlider,{onUpdate:a})]})}const VertexSelectionHighlightingReset=({onReset:t})=>{const[a,o]=n.useRecoilState(Wn),[i,r]=n.useRecoilState(Gn),[l,c]=n.useRecoilState(Kn),d=a!==Fn||i!==Hn||1!==l;return e.jsx("div",{className:"ml-auto",children:e.jsx(s.VertexTooltip,{content:"Reset Selection Highlighting",children:e.jsx(s.VertexIconButton,{"data-testid":"selection-highlighting-reset",iconName:"reset",iconSize:"sm",onClick:()=>{o(Fn),r(Hn),c(1),t?.()},disabled:!d})})})};function VertexSelectionHighlightingPanelSection({onResetSelectionHighlighting:t,onUpdateSelectionHighlightColor:n,onUpdateSelectionHighlightOpacity:a,onUpdateSelectionHighlightLineThickness:o}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Selection Highlighting",e.jsx(VertexSelectionHighlightingReset,{onReset:t})]}),children:e.jsx(VertexSelectionHighlightingControls,{onUpdateSelectionHighlightColor:n,onUpdateSelectionHighlightOpacity:a,onUpdateSelectionHighlightLineThickness:o})})}const VertexViewerBackgroundColorPicker=({onUpdate:t})=>{const[a,o]=n.useRecoilState(qn);return e.jsx(VertexColorPicker,{"data-testid":"viewer-background-color-picker",value:a,onValueChanged:e=>{t?.(e.detail)},onInput:e=>o(e)})};function VertexViewerBackgroundControls({onUpdateViewerBackgroundColor:t}){return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Color"}),e.jsx(VertexViewerBackgroundColorPicker,{onUpdate:t})]})}const VertexViewerBackgroundReset=({onReset:t})=>{const[a,o]=n.useRecoilState(qn),i=a!==$n;return e.jsx("div",{className:"ml-auto",children:e.jsx(s.VertexTooltip,{content:"Reset Background Color",children:e.jsx(s.VertexIconButton,{"data-testid":"viewer-background-reset",iconName:"reset",iconSize:"sm",onClick:()=>{o($n),t?.()},disabled:!i})})})};function VertexViewerBackgroundPanelSection({onResetViewerBackgroundColor:t,onUpdateViewerBackgroundColor:n}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Viewer Background",e.jsx(VertexViewerBackgroundReset,{onReset:t})]}),children:e.jsx(VertexViewerBackgroundControls,{onUpdateViewerBackgroundColor:n})})}const isInputElement=e=>{const t=e instanceof HTMLElement&&"VERTEX-AUTO-RESIZE-TEXTAREA"===e.tagName,n=e instanceof HTMLElement&&"VERTEX-TEXTFIELD"===e.tagName,a=e instanceof HTMLElement&&"true"===e.contentEditable,o=e instanceof HTMLElement&&"VERTEX-SCENE-TREE-SEARCH"===e.tagName,s=e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement,i=e instanceof HTMLElement&&"VERTEX-VIEWER-PIN-TOOL"===e.tagName,r=e instanceof HTMLElement&&"VERTEX-VIEWER-TRANSFORM-WIDGET"===e.tagName;return t||n||a||o||s||i||r},useRecoilReducer=({reducer:e,atom:t})=>{const a=undefined,o=undefined;return[n.useRecoilValue(t),useRecoilReducerDispatch({reducer:e,atom:t})]},useRecoilReducerDispatch=({reducer:e,atom:t})=>{const a=n.useRecoilCallback((({set:n})=>async a=>{n(t,(t=>e(t,a)))}),[]);return a},Xn=n.atom({key:"keyBindings",default:{applyBindings:[],bindings:{},pressed:{}}});function reducer(e,t){switch(t.type){case"push-key-binding":const n=e.bindings[t.binding.keyBind]?.find((e=>e.id===t.binding.id));return null!=n?e:{...e,bindings:{...e.bindings,[t.binding.keyBind]:[...e.bindings[t.binding.keyBind]??[],t.binding]}};case"remove-key-binding":const a=e.bindings[t.binding.keyBind]?.find((e=>e.id===t.binding.id));return null==a?e:{...e,bindings:{...e.bindings,[t.binding.keyBind]:(e.bindings[t.binding.keyBind]??[]).filter((e=>e.id!==t.binding.id))}};case"add-apply-key-binding":return{...e,applyBindings:[...e.applyBindings,t.binding]};case"remove-apply-key-binding":return{...e,applyBindings:e.applyBindings.filter((e=>e.id!==t.id))};case"set-key-pressed":return{...e,applyBindings:e.applyBindings.map((t=>({...t,active:null!=t.keyBind&&allPressed(t.keyBind,e.pressed)}))),pressed:{...e.pressed,[t.key]:t.pressed},lastPressed:t.pressed?t.key:void 0}}}const useKeyBindingState=()=>useRecoilReducer({reducer:reducer,atom:Xn}),useKeyBindingReadonlyState=()=>n.useRecoilValue(Xn);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=>null!=e.keyBind&&null!=n&&e.keyBind?.includes(n)&&allPressed(e.keyBind,t))).map((e=>e.fn))}function matchingOffBindings(e,t,n){return e.filter((e=>e.off&&e.active&&null!=e.keyBind&&null==n&&!allPressed(e.keyBind,t))).map((e=>e.off))}const useApplyKeyBinding=e=>{const[t,n]=useKeyBindingState();o.useEffect((()=>{const a=j.create();return n({type:"add-apply-key-binding",binding:{...e,id:a,active:null!=e.keyBind&&allPressed(e.keyBind,t.pressed)}}),()=>{n({type:"remove-apply-key-binding",id:a})}}),[e.fn,e.off,e.keyBind,e.repeat])},useStackKeyBinding=(e,t=[])=>{const[,n]=useKeyBindingState();o.useEffect((()=>{const t=null==e.addPredicate||e.addPredicate(),a=null!=e.cancelPredicate&&e.cancelPredicate();t&&n({type:"push-key-binding",binding:e}),a&&n({type:"remove-key-binding",binding:e})}),t)},useKeyBindings=({keydownRepeatInterval:e=25,keydownIgnorePredicate:t=isInputElement}={})=>{const[n,a]=useKeyBindingState(),s=o.useCallback((e=>{Object.keys(n.bindings).filter((t=>t.includes(e)&&allPressed(t,{...n.pressed,[e]:!0}))).forEach((e=>{const t=n.bindings[e],o=t.length>0?t[t.length-1]:void 0;null!=o&&(o.fn(),a({type:"remove-key-binding",binding:o}))}))}),[n]);o.useEffect((()=>{const handleKeyDown=e=>{if(!e.repeat&&!t(e.target)){a({type:"set-key-pressed",key:e.key,pressed:!0}),s(e.key);const t={...n.pressed,[e.key]:!0},o=matchingSingleFnBindings(n.applyBindings,t,e.key),i=matchingOffBindings(n.applyBindings,t,e.key);(o.length>0||i.length>0)&&e.preventDefault()}},handleKeyUp=e=>{a({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)}}),[s,n.applyBindings,n.pressed]),o.useEffect((()=>{const e=matchingSingleFnBindings(n.applyBindings,n.pressed,n.lastPressed),t=matchingOffBindings(n.applyBindings,n.pressed,n.lastPressed);e.forEach((e=>e())),t.forEach((e=>e()))}),[n.pressed,n.lastPressed]),o.useEffect((()=>{const t=n.applyBindings.filter((e=>e.repeat&&null!=e.keyBind&&allPressed(e.keyBind,n.pressed))).map((e=>e.fn));if(t.length>0){const n=setInterval((()=>{t.forEach((e=>e()))}),e);return()=>{clearInterval(n)}}return()=>{}}),[n.applyBindings,n.lastPressed])},VertexBoxSelectionButton=()=>{const t=useBoxSelectionActions(),a=n.useRecoilValue(Ye);return useStackKeyBinding({id:"ExitBoxSelection",keyBind:"Escape",fn:t.disable,addPredicate:()=>a,cancelPredicate:()=>!a},[a]),e.jsx(s.VertexTooltip,{content:"Box Selection",children:e.jsx(s.VertexIconButton,{iconName:"box-cursor",iconColor:a?"primary":"secondary","data-testid":"viewer-toolbar-enable-box-selection-button",onClick:a?t.disable:t.enable})})},Zn=1,VertexResizableContent=({className:t,style:n,displayShadow:a,heading:o,id:i,initialScale:r,placement:l="left",children:c,onResize:d,...u})=>{const m="left"===l||"right"===l,p="top"===l;function getHorizontalResizeDirection(){switch(l){case"left":return"right";case"right":return"left";default:return"none"}}function getVerticalResizeDirection(){return"top"===l?"top":"none"}const h=null!=r?r:1;return e.jsx(s.VertexResizable,{id:i,"data-testid":`resizable-content-position-${l}`,className:_e(t,"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"===l,"sidebar-shadow-right":"left"===l&&a,"border-l min-w-75 max-w-half":"right"===l,"sidebar-shadow-left":"right"===l&&a,"border-t bottom-0 fixed":"top"===l,"min-h-12 sheet":p}),style:{maxHeight:"top"===l?window.innerHeight:void 0,...n},initialHorizontalScale:m?r:void 0,initialVerticalScale:p?h:void 0,horizontalDirection:getHorizontalResizeDirection(),verticalDirection:getVerticalResizeDirection(),position:"right"===l||"top"===l?"absolute":"relative",onResizeEnd:()=>d?.(),...u,children:e.jsxs("div",{className:"flex flex-col h-full w-full",children:["top"===l&&e.jsx("div",{className:"flex justify-center w-full",children:e.jsx("div",{className:"block md:hidden w-20 h-0.5 mt-0.5 bg-neutral-600 rounded"})}),o,e.jsx("div",{className:_e("w-full flex flex-col h-0 flex-grow",{"right-0":"right"===l}),children:c})]})})};function useDefaultKeybindings(){useApplyKeyBinding({fn:useActionCallback((({snapshot:e})=>async()=>{const t=await e.getPromise(G),n=await(t?.scene()),a={milliseconds:500};await(n?.camera().viewAll().render({animation:a}))})),keyBind:"f"})}function useLongPress({target:e,callback:t,delay:n=500,onMovement:o}){const[s,i]=u.useState(),[r,l]=u.useState();u.useEffect((()=>{const handleTouchStart=e=>{const o=e;null!=o.touches&&1===o.touches.length&&(null!=s&&clearTimeout(s),l(a.Point.create(o.touches[0].clientX,o.touches[0].clientY)),i(setTimeout((()=>t?.(o)),n)))},handleTouchMove=e=>{const t=e;null!=t.touches&&t.touches.length>0&&null!=s&&null!=r&&a.Point.distance(r,a.Point.create(t.touches[0].clientX,t.touches[0].clientY))>=2&&(clearTimeout(s),o?.())},handleTouchEnd=()=>{null!=s&&clearTimeout(s)};return e?.addEventListener("touchstart",handleTouchStart),e?.addEventListener("touchmove",handleTouchMove),e?.addEventListener("touchend",handleTouchEnd),()=>{e?.removeEventListener("touchstart",handleTouchStart),e?.removeEventListener("touchmove",handleTouchMove),e?.removeEventListener("touchend",handleTouchEnd)}}),[e,s,r])}var Jn=Object.freeze({__proto__:null,isInputElement:isInputElement,keyBindings:Xn,reducer:reducer,useApplyKeyBinding:useApplyKeyBinding,useDefaultKeybindings:useDefaultKeybindings,useKeyBindingReadonlyState:useKeyBindingReadonlyState,useKeyBindings:useKeyBindings,useLongPress:useLongPress,useStackKeyBinding:useStackKeyBinding});function asBooleanAttribute(e){return!!e||void 0}const VertexContextMenu=({targetElement:t,menuType:a,disableBackdrop:i,openPredicate:r,onOpen:l,onClose:c,children:d})=>{const u=useContextMenuActions(),m=n.useRecoilValue(He),p=n.useRecoilValue($e),h=o.useMemo((()=>["bottom-end","top-start","top-end","right","left"]),[]),f=m===a;useStackKeyBinding({id:"ContextMenu",keyBind:"Escape",fn:u.clearActiveContextMenu,addPredicate:()=>null!=m&&m===a,cancelPredicate:()=>null==m},[m]);const g=o.useMemo((()=>null!=t?t:null!=r?window:void 0),[t,r]);return useLongPress({target:g,callback:e=>u.longPress(e,a,r,l),onMovement:()=>u.clearActiveContextMenu()}),o.useEffect((()=>{const handleWindowPointerDown=e=>{const t=undefined;if(!targetWithinMenu(e)&&2!==e.buttons&&m===a){const t=targetShouldSkipNextHit(e);u.clearActiveContextMenu(t)}};if(i)return window.addEventListener("pointerdown",handleWindowPointerDown),()=>{window.removeEventListener("pointerdown",handleWindowPointerDown)}}),[i,a,m]),o.useEffect((()=>{const handlePointerDown=e=>{u.pointerDown(e)},handlePointerUp=e=>{u.pointerUp(e,a,r,l)},handleContextMenu=e=>u.contextMenu(e,r);return g?.addEventListener("pointerdown",handlePointerDown),g?.addEventListener("pointerup",handlePointerUp),g?.addEventListener("contextmenu",handleContextMenu),()=>{g?.removeEventListener("pointerdown",handlePointerDown),g?.removeEventListener("pointerup",handlePointerUp),g?.removeEventListener("contextmenu",handleContextMenu)}}),[t,a,r]),e.jsx("div",{className:_e({hidden:!f}),children:e.jsx(s.VertexMenu,{"data-testid":`${a}-context-menu`,open:asBooleanAttribute(f),position:p,fallbackPlacements:h,backdrop:!i,onMenuClosed:()=>{u.clearActiveContextMenu(),c?.()},children:e.jsx("div",{className:"pt-1",children:d})})})},VertexFitSelectedMenuItem=()=>{const t=n.useRecoilValue(bt),a=n.useRecoilValue(Pt),o=useViewerCameraActions();return e.jsx(s.VertexMenuItem,{"data-testid":"fit-selected-menu-option",onClick:async()=>{null!=a?.boundingBox&&await o.flyToByBoundingBox(a.boundingBox)},disabled:asBooleanAttribute(0===t.length),children:e.jsxs("div",{className:"flex align-middle gap-2.5",children:[e.jsx(s.VertexIcon,{slot:"icon",name:"fit-selected",size:"sm"}),"Fit Selected"]})})},VertexFlyToMenuItem=()=>{const t=useViewerCameraActions(),a=n.useRecoilValue(Ge);return e.jsx(s.VertexMenuItem,{"data-testid":"fly-to-part-menu-option",onClick:async()=>{const e=undefined,n=contextMenuItemIsRow(a)?a?.node.id?.hex:a?.id;null!=n&&await t.flyToById(n)},disabled:asBooleanAttribute(null==a),children:e.jsxs("div",{className:"flex align-middle gap-2.5",children:[e.jsx(s.VertexIcon,{slot:"icon",name:"paper-airplane",size:"sm"}),"Fly To"]})})};function useSceneItemsOperations(){const e=n.useRecoilValue(G),t=undefined,a=undefined,s=undefined,i=undefined,r=undefined,l=undefined;return{sceneItemsOperation:o.useCallback((async(t,n)=>{const a=await(e?.scene());null==n?await(a?.items((e=>t(e.where((e=>e.all()))))).execute()):n.length>0&&await(a?.items((e=>t(e.where((e=>e.withItemIds(n)))))).execute())}),[e]),showOnlySelected:o.useCallback((async()=>{const t=await(e?.scene());t?.items((e=>[e.where((e=>e.all())).hide(),e.where((e=>e.withSelected())).show()])).execute()}),[e]),hideSelected:o.useCallback((async()=>{const t=await(e?.scene());t?.items((e=>[e.where((e=>e.withSelected())).hide()])).execute()}),[e]),showOnlyItem:o.useCallback((async t=>{const n=await(e?.scene());n?.items((e=>[e.where((e=>e.all())).hide(),e.where((e=>e.withItemIds([t]))).show()])).execute()}),[e]),ghostSelected:o.useCallback((async()=>{const t=await(e?.scene());t?.items((e=>[e.where((e=>e.withSelected())).setPhantom(!0)])).execute()}),[e]),unGhostSelected:o.useCallback((async()=>{const t=await(e?.scene());t?.items((e=>[e.where((e=>e.withSelected())).setPhantom(!1)])).execute()}),[e])}}const VertexHideAllMenuItem=()=>{const t=useSceneItemsOperations();return e.jsx(s.VertexMenuItem,{"data-testid":"hide-all-menu-option",onClick:async()=>{await t.sceneItemsOperation((e=>e.hide()))},children:e.jsxs("div",{className:"flex align-middle gap-2.5",children:[e.jsx(s.VertexIcon,{slot:"icon",name:"visibility-hidden",size:"sm"}),"Hide All Parts"]})})},VertexHidePartMenuItem=()=>{const t=n.useRecoilValue(Ge),a=useSceneItemsOperations();return e.jsx(s.VertexMenuItem,{"data-testid":"hide-menu-option",onClick:async()=>{const e=undefined,n=contextMenuItemIsRow(t)?t?.node.id?.hex:t.id;null!=n&&await a.sceneItemsOperation((e=>e.hide()),[n])},disabled:asBooleanAttribute(null==t),children:e.jsxs("div",{className:"flex align-middle gap-2.5",children:[e.jsx(s.VertexIcon,{slot:"icon",name:"visibility-hidden",size:"sm"}),"Hide Part"]})})},VertexHideSelectedMenuItem=()=>{const t=n.useRecoilValue(bt),a=useSceneItemsOperations();return e.jsx(s.VertexMenuItem,{"data-testid":"hide-selected-menu-option",onClick:()=>a.hideSelected(),disabled:asBooleanAttribute(0===t.length),children:e.jsxs("div",{className:"flex align-middle gap-2.5",children:[e.jsx(s.VertexIcon,{slot:"icon",name:"visibility-hidden",size:"sm"}),"Hide Selected"]})})},VertexShowAllMenuItem=()=>{const t=useSceneItemsOperations();return e.jsx(s.VertexMenuItem,{"data-testid":"show-all-menu-option",onClick:async()=>{await t.sceneItemsOperation((e=>e.show()))},children:e.jsxs("div",{className:"flex align-middle gap-2.5",children:[e.jsx(s.VertexIcon,{slot:"icon",name:"visibility-visible",size:"sm"}),"Show All Parts"]})})},VertexShowOnlyMenuItem=()=>{const t=n.useRecoilValue(Ge),a=useSceneItemsOperations();return e.jsx(s.VertexMenuItem,{"data-testid":"show-only-menu-option",onClick:async()=>{const e=undefined,n=contextMenuItemIsRow(t)?t?.node.id?.hex:t?.id;null!=n&&await a.showOnlyItem(n)},disabled:asBooleanAttribute(null==t),children:e.jsxs("div",{className:"flex align-middle gap-2.5",children:[e.jsx(s.VertexIcon,{slot:"icon",name:"visibility-visible",size:"sm"}),"Show Only Part"]})})},VertexShowOnlySelectedMenuItem=()=>{const t=n.useRecoilValue(bt),a=useSceneItemsOperations();return e.jsx(s.VertexMenuItem,{"data-testid":"show-only-selected-menu-option",onClick:()=>a.showOnlySelected(),disabled:asBooleanAttribute(0===t.length),children:e.jsxs("div",{className:"flex align-middle gap-2.5",children:[e.jsx(s.VertexIcon,{slot:"icon",name:"visibility-visible",size:"sm"}),"Show Only Selected"]})})},Qn=n.atom({key:"openedPanelActivePrimaryLeft",default:void 0}),ea=n.atom({key:"openedPanelActivePrimaryRight",default:void 0}),ta=n.atom({key:"openedPanelActiveSceneTreeSecondary",default:void 0});function usePanelActions(){return{openPrimary:useActionCallback((({set:e})=>(t,n)=>{e("left"===n?Qn:ea,t)})),closePrimary:useActionCallback((({set:e})=>t=>{e("left"===t?Qn:ea,void 0)})),openSecondary:useActionCallback((({set:e})=>t=>e(ta,t))),closeSecondary:useActionCallback((({reset:e})=>()=>e(ta)))}}var na=Object.freeze({__proto__:null,openedPanelActivePrimaryLeft:Qn,openedPanelActivePrimaryRight:ea,openedPanelActiveSceneTreeSecondary:ta,usePanelActions:usePanelActions});const VertexShowPropertiesMenuItem=()=>{const t=usePanelActions(),a=useSelectionActions(),o=n.useRecoilValue(Ge);return e.jsx(s.VertexMenuItem,{"data-testid":"show-properties-menu-option",disabled:asBooleanAttribute(null==o),onClick:()=>{const e=undefined,n=contextMenuItemIsRow(o)?o?.node.id?.hex:o?.id;null!=n&&(a.clearAndSelect({id:n}),t.openSecondary("Properties"))},children:e.jsxs("div",{className:"flex align-middle gap-2.5",children:[e.jsx(s.VertexIcon,{slot:"icon",name:"info",size:"sm"}),"Show Properties"]})})};function fromApiProperty(e){return{key:e.key?.name??"",value:apiMetadataPropertyDisplayValue(e.value)}}function apiMetadataPropertyDisplayValue(e){let t="";switch(e?.type){case"string":t=e.value??t;break;case"long":case"double":t=e.value.toString()??t;break;case"timestamp":t=e.value.seconds.toLocaleString()??t}return t}const aa=n.atom({key:"showMetadataSceneItemProperties",default:!0}),oa=n.selectorFamily({key:"nextMetadataSceneItemProperties",get:e=>async({get:t})=>{const n=t(G),a=t(ia(e));try{const t=await(n?.sceneItems?.listSceneItemMetadata(e,{cursor:a,size:20})),o=t?.entries?.map((e=>fromApiProperty(e))),s=undefined;return{metadata:null!=o?[...o]?.sort(((e,t)=>e.key>t.key?1:-1)):void 0,cursor:t?.paging.next}}catch(t){return void logger_debug(`Error encountered get metadata for scene item. [itemId={${e}}]`,t)}}}),sa=n.atomFamily({key:"loadedMetadataSceneItemProperties",default:[]}),ia=n.atomFamily({key:"metadataSceneItemPropertiesCursor",default:void 0}),ra=n.selectorFamily({key:"hasMoreMetadataSceneItemProperties",get:e=>({get:t})=>{const n=undefined;return null!=t(ia(e))}}),la=n.atomFamily({key:"isFetchingMetadataSceneItemProperties",default:!1}),ca=n.selector({key:"metadataSceneItemName",get:async({get:e})=>{const t=e(wt);if(null!=t){const n=e(yt(t.id));return n?.name??void 0}}});var da=Object.freeze({__proto__:null,apiMetadataPropertyDisplayValue:apiMetadataPropertyDisplayValue,fromApiProperty:fromApiProperty,hasMoreMetadataSceneItemProperties:ra,isFetchingMetadataSceneItemProperties:la,loadedMetadataSceneItemProperties:sa,metadataSceneItemName:ca,metadataSceneItemPropertiesCursor:ia,nextMetadataSceneItemProperties:oa,showMetadataSceneItemProperties:aa});const VertexGhostSelectedMenuItem=()=>{const t=n.useRecoilValue(bt),a=useSceneItemsOperations();return e.jsx(s.VertexMenuItem,{"data-testid":"ghost-selected-menu-option",onClick:()=>a.ghostSelected(),disabled:asBooleanAttribute(0===t.length),children:e.jsxs("div",{className:"flex align-middle gap-2.5",children:[e.jsx(s.VertexIcon,{slot:"icon",name:"visibility-partial",size:"sm"}),"Ghost Selected"]})})};function BetaLabel({children:t,label:n="Beta",placement:a="end",borderColor:o="border-purple-400",textColor:s="text-purple-500"}){return e.jsxs("div",{className:"flex items-center",children:[t,e.jsx("div",{className:_e(`flex border ${o} rounded-md px-1.5 text-xs ${s} uppercase items-center justify-center ml-2 select-none max-h-5`,{"ml-auto":"end"===a}),style:{height:"fit-content"},children:n})]})}const VertexShowModelViewsMenuItem=()=>{const t=usePanelActions(),a=useSelectionActions(),o=n.useRecoilValue(Ge);return e.jsx(s.VertexMenuItem,{"data-testid":"viewer-show-model-views",disabled:asBooleanAttribute(null==o),onClick:async()=>{const e=undefined,n=contextMenuItemIsRow(o)?o?.node.id?.hex:o?.id;null!=n&&(t.openPrimary("model-views","right"),a.selectForModelViewsPanel({id:n}))},children:e.jsxs("div",{className:"flex align-middle gap-2.5",children:[e.jsx(s.VertexIcon,{slot:"icon",name:"views",size:"sm"}),e.jsxs("div",{className:"flex gap-2",children:["Show Model Views ",e.jsx(BetaLabel,{})]})]})})},VertexUnghostSelectedMenuItem=()=>{const t=n.useRecoilValue(bt),a=useSceneItemsOperations();return e.jsx(s.VertexMenuItem,{"data-testid":"unghost-selected-menu-option",onClick:()=>a.unGhostSelected(),disabled:asBooleanAttribute(0===t.length),children:e.jsxs("div",{className:"flex align-middle gap-2.5",children:[e.jsx(s.VertexIcon,{slot:"icon",name:"visibility-visible",size:"sm"}),"Unghost Selected"]})})},DefaultSceneTreeContextMenu=()=>{const t=n.useRecoilValue(aa);return e.jsxs("div",{className:"w-56",children:[e.jsx(VertexHideSelectedMenuItem,{}),e.jsx(VertexHideAllMenuItem,{}),e.jsx(VertexShowOnlyMenuItem,{}),e.jsx(VertexShowOnlySelectedMenuItem,{}),e.jsx(VertexShowAllMenuItem,{}),e.jsx(VertexGhostSelectedMenuItem,{}),e.jsx(VertexUnghostSelectedMenuItem,{}),e.jsx(s.VertexMenuDivider,{}),e.jsx(VertexFitSelectedMenuItem,{}),e.jsx(VertexFlyToMenuItem,{}),e.jsx(s.VertexMenuDivider,{}),t&&e.jsx(VertexShowPropertiesMenuItem,{}),e.jsx(VertexShowModelViewsMenuItem,{})]})},VertexSceneTreeContextMenu=({children:t})=>{const a=useSceneTreeActions(),o=n.useRecoilValue(Cn),s=null!=t&&!1!==t;return e.jsx(VertexContextMenu,{menuType:"scene-tree",targetElement:o,onOpen:async(e,t)=>{const n=e;await a.setContextMenuItem(n.clientY)},disableBackdrop:!0,children:s?t:e.jsx(DefaultSceneTreeContextMenu,{})})},DefaultViewerContextMenu=()=>{const t=n.useRecoilValue(aa);return e.jsxs("div",{className:"w-56",children:[e.jsx(VertexHidePartMenuItem,{}),e.jsx(VertexHideSelectedMenuItem,{}),e.jsx(VertexHideAllMenuItem,{}),e.jsx(VertexShowOnlyMenuItem,{}),e.jsx(VertexShowOnlySelectedMenuItem,{}),e.jsx(VertexShowAllMenuItem,{}),e.jsx(VertexGhostSelectedMenuItem,{}),e.jsx(VertexUnghostSelectedMenuItem,{}),e.jsx(s.VertexMenuDivider,{}),e.jsx(VertexFitSelectedMenuItem,{}),e.jsx(VertexFlyToMenuItem,{}),e.jsx(s.VertexMenuDivider,{}),t&&e.jsx(VertexShowPropertiesMenuItem,{}),e.jsx(VertexShowModelViewsMenuItem,{})]})},VertexViewerContextMenu=({children:t})=>{const n=null!=t&&!1!==t,a=o.useCallback((e=>e.target instanceof HTMLElement&&"vertex-viewer"===e.target.id),[]);return e.jsx(VertexContextMenu,{menuType:"viewer",disableBackdrop:!0,openPredicate:a,children:n?t:e.jsx(DefaultViewerContextMenu,{})})},ua=35,ma=n.atom({key:"sceneItemGhostingSelectedOpacity",default:ua}),pa=n.atomFamily({key:"appliedItemPhantomState",default:void 0}),ha=n.atom({key:"appliedItemPhantomStateIds",default:[]}),xa=n.selector({key:"sceneItemGhostingLastSelectedPhantom",get:({get:e})=>{const t=e(wt);return null!=t&&(e(pa(t.id))??!1)}}),VertexSceneItemGhostingOpacitySlider=({onApply:t})=>{const[a,o]=n.useRecoilState(ma);return e.jsx(VertexSlider,{id:"phantom-opacity","data-testid":"phantom-opacity-slider",leftLabel:"0%",rightLabel:"100%",min:0,max:100,step:5,value:a,valueLabelDisplay:"auto",onValueInput:e=>{o(e.detail.value)},onValueChange:e=>{t?.(e.detail.value)}})},useSceneItemPhantomActions=()=>{const e=useViewerSceneActions(),t=useActionCallback((({snapshot:e,reset:t})=>async()=>{const n=undefined;(await e.getPromise(ha)).forEach((e=>t(pa(e)))),t(ha)}));return{setPhantomState:useActionCallback((({snapshot:t,set:n})=>async a=>{const o=await t.getPromise(bt);o.forEach((e=>n(pa(e),a))),n(ha,(e=>[...e,...o])),await e.execute(xt.SET_PHANTOM_SELECTED_ITEMS,(e=>e.where((e=>e.withSelected())).setPhantom(a)))})),clearPhantomState:useActionCallback((({snapshot:t,set:n,reset:a})=>async()=>{const o=await t.getPromise(bt);o.forEach((e=>a(pa(e)))),n(ha,(e=>e.filter((e=>!o.includes(e))))),await e.execute(xt.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(xt.CLEAR_PHANTOM_ALL,(e=>e.where((e=>e.all())).clearPhantom()),(e=>e.where((e=>e.withSelected())).select()))})),resetAllPhantomState:t}};var fa=Object.freeze({__proto__:null,DEFAULT_GHOSTING_OPACITY:ua,appliedItemPhantomState:pa,appliedItemPhantomStateIds:ha,sceneItemGhostingLastSelectedPhantom:xa,sceneItemGhostingSelectedOpacity:ma,useSceneItemPhantomActions:useSceneItemPhantomActions});const VertexSceneItemGhostingToggle=({onApply:t})=>{const a=useSceneItemPhantomActions(),o=n.useRecoilValue(Et),i=n.useRecoilValueLoadable(xa);return e.jsx(s.VertexTooltip,{content:"Select a part to display as ghost",disabled:o,children:e.jsx(s.VertexToggle,{className:"flex items-center","data-testid":"phantom-state-toggle",variant:"switch",disabled:!o,checked:"hasValue"===i.state&&i.contents,onValueChanged:async e=>{await a.setPhantomState(e.detail),t?.(e.detail)}})})};function VertexGhostingControls({onApplyGhostingChange:t,onApplyOpacity:n}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center py-3",children:[e.jsx(VertexSceneItemGhostingToggle,{onApply:t}),e.jsx("span",{className:"pl-4 text-sm text-neutral-700",children:"Display as Ghost"})]}),e.jsx("div",{className:"pt-4 pb-2 text-sm text-neutral-700",children:"Global Ghost Opacity"}),e.jsx(VertexSceneItemGhostingOpacitySlider,{onApply:n})]})}const VertexSceneItemGhostingClear=({onClear:t,onClearAll:a})=>{const o=useSceneItemPhantomActions(),i=n.useRecoilValue(xa);return e.jsx("div",{className:"ml-auto",children:e.jsxs(ResetButton,{id:"phantom",tooltip:"Clear Ghosting",children:[e.jsx("div",{className:"pt-1"}),e.jsx(s.VertexMenuItem,{"data-testid":"reset-selected-phantom",onClick:async()=>{await o.clearPhantomState(),t?.()},disabled:!i,children:"Clear ghosting for selected"}),e.jsx(s.VertexMenuItem,{"data-testid":"reset-all-phantom",onClick:async()=>{await o.clearAllPhantomState(),a?.()},children:"Clear ghosting for all"})]})})};function VertexGhostingPanelSection({onClearGhostState:t,onClearAllGhostState:n,onApplyGhostingChange:a,onApplyOpacity:o}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Ghosting",e.jsx(VertexSceneItemGhostingClear,{onClear:t,onClearAll:n})]}),children:e.jsx(VertexGhostingControls,{onApplyGhostingChange:a,onApplyOpacity:o})})}function VertexMeasurementContextMenu({onDelete:t}){const a=n.useRecoilValue(We);return e.jsx(VertexContextMenu,{menuType:"measurement",openPredicate:e=>e.target instanceof HTMLElement&&"VERTEX-VIEWER-MEASUREMENT-DISTANCE"===e.target.tagName,children:e.jsxs(s.VertexMenuItem,{"data-testid":"measurement-delete",onClick:()=>null!=a&&t(a.id),children:[e.jsx(s.VertexIcon,{slot:"icon",name:"delete",size:"sm"}),e.jsx("div",{className:"pl-2",children:"Delete"})]})})}function useDockedPlacement(e,t){const[n,o]=u.useState(a.Point.create(0,0));return u.useLayoutEffect((()=>{if(null!=e){const n=e.getBoundingClientRect(),s=a.Point.create(n.left,n.bottom),i=a.Point.create(n.right,n.bottom);o("left"===t?s:i)}}),[e,t]),n}function VertexMeasurementDetails({placement:t,size:a}){const o=useMeasurementActions(),i=n.useRecoilValue(G),l=n.useRecoilValue(K),c=useDockedPlacement(i??null,t),d=n.useRecoilValue(ct),u=n.useRecoilValue(dt),m=n.useRecoilValue(ut),p=n.useRecoilValue(mt),h=n.useRecoilValue(Lt),f=n.useRecoilValue(_t);return e.jsx(s.VertexDraggablePopover,{className:"z-popover",boundaryPadding:16,boundarySelector:`#${l}`,position:c,children:e.jsxs("div",{className:_e("flex flex-col min-w-40",{"text-xs leading-2":"sm"===a,"text-sm leading-4":"md"===a,"text-base leading-5":"lg"===a,"text-lg leading-5":"xl"===a}),children:[e.jsxs("div",{className:"pb-2 flex justify-between items-center",children:[e.jsx("div",{className:_e("w-full",{"text-sm leading-5":"sm"===a,"text-base leading-5":"md"===a,"text-lg leading-6":"lg"===a,"text-xl leading-7 mr-6":"xl"===a}),children:"Measurement"}),e.jsx("div",{className:_e("mr-0.5",{hidden:!p}),children:e.jsx(s.VertexTooltip,{content:"Reset",placement:"left-start",children:e.jsx(s.VertexIconButton,{"data-testid":"measurement-details-reset",iconName:"reset",iconSize:"sm",onClick:o.resetMeasurement})})})]}),e.jsx(r.VertexViewerMeasurementDetails,{"data-testid":"measurement-details-viewer-measurement-details",className:_e("gap-y-1.5",{hidden:null==d}),measurementOutcome:d,measurementOverlays:u,distanceUnits:toUnitType(h),fractionalDigits:parseInt(f,10)}),e.jsx("div",{"data-testid":"measurement-details-message",className:_e({hidden:null==m}),children:m})]})})}function useCallbackRef(e){const[t,n]=o.useState(e?.override??null),a=undefined;return{element:t,callback:o.useCallback((t=>n(e?.override??t)),[])}}function VertexPointToPointMeasurement({detailsPlacement:t,detailsSize:a,onPointToPointMeasurementChange:s}){const i=useMeasurementActions(),l=n.useRecoilValue(G),c=n.useRecoilValue(Je),d=n.useRecoilValue(et),u=n.useRecoilValue(Lt),m=n.useRecoilValue(_t),{callback:p,element:h}=useCallbackRef();usePointToPointMeasurement(h);const f=o.useCallback((e=>{const t={start:e.detail.start,end:e.detail.end,invalid:!e.detail.valid};i.setEditedPointToPointMeasurement(t),s?.(t)}),[i]);return c?e.jsxs(e.Fragment,{children:[e.jsx(r.VertexViewerMeasurementDistance,{"data-testid":"point-to-point-measurement",ref:p,viewer:l??void 0,mode:"replace",start:d?.start,end:d?.end,invalid:d?.invalid,units:toUnitType(u),fractionalDigits:parseInt(m,10),showAxisReferenceLines:!0,onEditEnd:f}),e.jsx(VertexMeasurementDetails,{placement:t,size:a}),e.jsx(VertexMeasurementContextMenu,{onDelete:i.resetMeasurement})]}):e.jsx(e.Fragment,{})}function VertexPointToPointMeasurementTool(){const t=useMeasurementActions(),a=n.useRecoilValue(Je);return useStackKeyBinding({id:"ExitMeasurement",keyBind:"Escape",fn:t.disableEditMeasurement,addPredicate:()=>a,cancelPredicate:()=>!a},[a,t]),e.jsx(s.VertexTooltip,{content:"Point to Point Measurement",children:e.jsx(s.VertexIconButton,{iconName:"tape-measure","data-testid":"viewer-toolbar-point-to-point-measurement-button",iconColor:a?"primary":"secondary",onClick:t.toggleEditPointToPointMeasurement})})}const ga=n.atom({key:"viewerToolkitSdkConfig",default:void 0});var ya=Object.freeze({__proto__:null,sdkConfig:ga});const VertexPreciseMeasurement=({detailsPlacement:t,detailsSize:a,onEntitiesChanged:o,onOutcomeChanged:s})=>{const i=n.useRecoilValue(G),l=n.useRecoilValue(ga),c=n.useRecoilValue(nt),{callback:d,element:u}=useCallbackRef();return usePreciseMeasurementModel(u,o,s),c?e.jsxs(e.Fragment,{children:[e.jsx(r.VertexViewerMeasurementPrecise,{"data-testid":"precise-measurement-viewer-tool",ref:d,viewer:i??void 0,config:JSON.stringify({network:{apiHost:l?.network?.apiHost,renderingHost:l?.network?.renderingHost,sceneTreeHost:l?.network?.sceneTreeHost,sceneViewHost:l?.network?.sceneViewHost}})}),e.jsx(VertexMeasurementDetails,{placement:t,size:a})]}):e.jsx(e.Fragment,{})};function VertexPreciseMeasurementTool(){const t=useMeasurementActions(),a=n.useRecoilValue(nt);return e.jsx(s.VertexTooltip,{content:"Precise Measurement",children:e.jsx(s.VertexIconButton,{iconName:"ruler","data-testid":"viewer-toolbar-precise-measurement-button",iconColor:a?"primary":"secondary",onClick:t.toggleEditPreciseMeasurement})})}function VertexApplicationMessages(){const t=n.useRecoilValue(F),a=n.useRecoilValue(D);return e.jsxs(e.Fragment,{children:[null!=t&&e.jsx(s.VertexBanner,{className:"z-[16000]",duration:t.duration,open:!0,content:t.message,type:t.type},t.id),null!=a&&e.jsx(s.VertexToast,{placement:"bottom-left",className:"z-[16000]",duration:a.duration,open:!0,content:a.message,type:a.type},a.id)]})}const va={binding:"{{row.node.name}}",label:"Name",metadataKeyName:"VERTEX_SCENE_ITEM_NAME"};function mapToColumn(e,t){return{label:"name"===e.toLowerCase()?"Name (Property)":e,binding:`{{row.metadata.${e}}}`,initialWidth:t,minWidth:t/2}}const ba=n.atom({key:"sceneTreeColumnsRefreshTrigger",default:0}),wa=n.atom({key:"sceneTreeColumnsWhitelistedColumns",default:[]}),Ca=n.selector({key:"sceneTreeColumnsAvailableColumns",get:async({get:e})=>{const t=e(Sn);return e(ba),null!=t?await t.fetchMetadataKeys():[]}}),Sa=n.selector({key:"sceneTreeColumnsAvailableSortedColumns",get:({get:e})=>e(Ca).filter((e=>e!==va.metadataKeyName)).sort(((e,t)=>e.localeCompare(t)))}),Va=n.atom({key:"sceneTreeColumnsVisibleMetadataColumnNames",default:[]}),ja=n.selector({key:"sceneTreeColumnsActiveColumns",get:({get:e})=>{const t=e(Va),n=e(Cn),a=n?.clientWidth;if(null!=a&&a>0){const e=1/(t.length+1)*a,n=(a-e)/t.length;return t.reduce(((e,t)=>{const a=mapToColumn(t,n);return{...e,[a.label]:a}}),{Name:{...va,initialWidth:e,minWidth:n}})}return{Name:va}}}),ka=n.selector({key:"sceneTreeColumnsActiveColumnNames",get:({get:e})=>Object.keys(e(ja))});function useSceneTreeColumnActions(){return{setActive:useActionCallback((({set:e})=>async t=>{e(Va,t)})),refreshKeyList:useActionCallback((({set:e})=>()=>{e(ba,(e=>e+1))}))}}const Ta=16,Aa=-8;var Pa;function useOpenPositionedPopover({open:e,buttonElement:t,horizontalOffset:n,verticalOffset:a}){const[o,s]=u.useState(),[i,r]=u.useState(),l=undefined;return{position:o,direction:i,handleOpen:u.useCallback((()=>{if(!e){const e=t?.getBoundingClientRect();if(null!=e){const t=n??Ta,o=a??Aa,i=e.x>window.innerWidth/2?Pa.LEFT:Pa.RIGHT;s({x:i===Pa.LEFT?e.left-t:e.right+t,y:e.top+o}),r(i)}}}),[e,t])}}!function(e){e.LEFT="left",e.RIGHT="right"}(Pa||(Pa={}));var Ia=Object.freeze({__proto__:null,DEFAULT_HORIZONTAL_POSITION_OFFSET:Ta,DEFAULT_NAME_COLUMN:va,DEFAULT_VERTICAL_POSITION_OFFSET:Aa,get PlacementDirection(){return Pa},mapToColumn:mapToColumn,sceneTreeColumnsActiveColumnNames:ka,sceneTreeColumnsActiveColumns:ja,sceneTreeColumnsAvailableColumns:Ca,sceneTreeColumnsAvailableSortedColumns:Sa,sceneTreeColumnsRefreshTrigger:ba,sceneTreeColumnsVisibleMetadataColumnNames:Va,sceneTreeColumnsWhitelistedColumns:wa,useOpenPositionedPopover:useOpenPositionedPopover,useSceneTreeColumnActions:useSceneTreeColumnActions});const Ma=n.atom({key:"sceneTreeSearchActive",default:!1}),Ea=n.atom({key:"sceneTreeColumnsPartial",default:!1}),Ra=n.atom({key:"sceneTreeSearchValue",default:void 0}),Na=n.atom({key:"sceneTreeSearchExactMatch",default:!1}),Oa=n.atom({key:"sceneTreeSearchRemoveHiddenItems",default:!1}),La=n.atom({key:"sceneTreeSearchResultCount",default:0}),_a=n.atom({key:"sceneTreeSearchActiveColumns",default:[]}),Ba=n.selector({key:"sceneTreeSearchNameColumnActive",get:({get:e})=>{const t=e(_a);return 0===t.length||t.includes(va.metadataKeyName)}});function useSceneTreeSearch({sceneTreeElement:e}){const t=useSceneTreeActions(),a=n.useRecoilValue(Ma),s=n.useSetRecoilState(La),i=n.useSetRecoilState(kt);o.useEffect((()=>{let t;return whenComponentReady(e,(()=>{t=e?.controller?.stateChanged((e=>{void 0!==e?.totalFilteredRows&&s(e?.totalFilteredRows)}))})),()=>{t?.dispose()}}),[e]),o.useEffect((()=>{if(null!=e){let n;return whenComponentReady(e,(()=>{n=e?.controller?.stateChanged((e=>{if(null!=e?.filterTerm){const t=e?.rows.find((e=>e?.node?.selected));i(t?.node.id?.hex)}else a&&t.flyToFirstSelectedItem()}))})),()=>{n?.dispose()}}}),[e,e?.controller,open])}function useSceneTreePartialResults({sceneTreeElement:e}){const t=n.useSetRecoilState(Ea);o.useEffect((()=>{let n;return whenComponentReady(e,(()=>{n=e?.controller?.stateChanged((e=>{t(!!e?.isPartialKeysResponse)}))})),()=>{n?.dispose()}}),[e])}const useSceneTreeSearchActions=()=>{const e=useActionCallback((({set:e})=>t=>{e(_a,t)})),t=useActionCallback((({snapshot:t})=>async(n,a,o,s)=>{const i=await t.getPromise(Cn),r=await t.getPromise(Na),l=await t.getPromise(Oa),c=await t.getPromise(_a),d=c.length>0?a?[...c,n]:c.filter((e=>e!==n)):[...o,va.metadataKeyName].filter((e=>e!==n));e(d),s&&i?.filterItems(s,{columns:d,exactMatch:r,removeHiddenItems:l})})),n=useActionCallback((({snapshot:e,set:t})=>async(n,a,o)=>{const s=await e.getPromise(Cn),i=await e.getPromise(Na),r=await e.getPromise(Oa),l=await e.getPromise(_a),c=n.filter((e=>!a.includes(e))),d=a.filter((e=>!n.includes(e))),u=l.length>0?[...l.filter((e=>!c.includes(e))),...d]:[...a,va.metadataKeyName],m=u.length>0?u:[...a,va.metadataKeyName];t(_a,m),o&&s?.filterItems(o,{columns:m,exactMatch:i,removeHiddenItems:r})})),a=useActionCallback((({set:e})=>t=>{e(Na,t)})),o=useActionCallback((({set:e})=>t=>{e(Oa,t)}));return{setMetadataSearchKeys:e,updateMetadataSearchAfterSearchKeysChange:t,updateMetadataSearchAfterColumnVisibilityChange:n,setMetadataSearchExactMatch:a,setMetadataSearchRemoveHiddenItems:o}};var Da=Object.freeze({__proto__:null,sceneTreeColumnsPartial:Ea,sceneTreeSearchActive:Ma,sceneTreeSearchActiveColumns:_a,sceneTreeSearchExactMatch:Na,sceneTreeSearchNameColumnActive:Ba,sceneTreeSearchRemoveHiddenItems:Oa,sceneTreeSearchResultCount:La,sceneTreeSearchValue:Ra,useSceneTreePartialResults:useSceneTreePartialResults,useSceneTreeSearch:useSceneTreeSearch,useSceneTreeSearchActions:useSceneTreeSearchActions});const targetIsElement=(e,t)=>e instanceof Element&&e.tagName===t;function useRecoilRef({state:e}){const t=n.useRecoilCallback((({set:t})=>n=>{t(e,n)}),[]);return t}var za;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=e?.depthColors,n=null!=t?Object.keys(t).reduce(((e,n)=>({...e,[`--scene-tree-row-background-color-depth-${n}`]:t[parseInt(n)]})),{}):{};return null!=e?{...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===za.ROBOTO_MONO?"var(--vertex-ui-font-family-monospace)":"var(--vertex-ui-font-family)"}!function(e){e.ROBOTO="ROBOTO",e.ROBOTO_MONO="ROBOTO_MONO"}(za||(za={}));const Fa=n.atom({key:"sceneTreeAdditionalMetadataKeys",default:[]}),Ha=n.selector({key:"sceneTreeActiveMetadataKeys",get:({get:e})=>{const t=e(Fa),n=e(Va),a=e(wa),o=new Set([...t,...n]),s=new Set(a);return 0===a.length?Array.from(o):Array.from(o.intersection(s))}});var Ua=Object.freeze({__proto__:null,sceneTreeActiveMetadataKeys:Ha,sceneTreeAdditionalMetadataKeys:Fa});function childrenAsArray(e){return Array.isArray(e)?e:[e]}function filterChildElements(e,t){return childrenAsArray(e).filter((e=>o.isValidElement(e)&&e.type===t))}function findChildElement(e,t){return filterChildElements(e,t)[0]}function cloneChildNodeOrFunction(e,t){return"object"==typeof e?o.cloneElement(e,t):e(t)}function useStateSyncedValue(e,t,{transform:a}={}){const[s,i]=n.useRecoilState(e);return o.useEffect((()=>{null!=t&&i(null!=a?a(t):t)}),[t]),s}const VertexEnterSceneTreeSearchModeButton=({onEnterSearchMode:t})=>{const a=n.useSetRecoilState(Ma);return e.jsx(s.VertexTooltip,{className:"flex ml-auto",content:"Scene Tree Search",children:e.jsx(s.VertexIconButton,{"data-testid":"enter-scene-tree-search-mode-button",iconName:"search",iconSize:"sm",onPointerDown:e=>{e.preventDefault()},onClick:()=>{a(!0),t?.()}})})},VertexSceneTreeMetadataCheck=({checked:t,disabled:n,onChange:a,children:o})=>{const i="string"==typeof o?o.replace(" ","-"):"";return e.jsxs("div",{className:"flex items-center",children:[e.jsx(s.VertexToggle,{"data-testid":`scene-tree-metadata-check-${i}`,variant:"check",checked:t,disabled:n,onValueChanged:e=>a?.(e.detail)}),e.jsx("div",{className:"pl-2 py-1 text-[0.875rem] w-full","data-testid":`scene-tree-metadata-name-${i}`,onClick:()=>{n||a?.(!t)},children:o})]})},VertexSceneTreeSearchOptionsPopover=({onSearchedSceneTreeColumnsChange:t,onSearchForExactMatchChange:a})=>{const o=useSceneTreeActions(),i=useSceneTreeSearchActions(),r=n.useRecoilValue(Cn),l=n.useRecoilValue(Ba),c=n.useRecoilValue(_a),d=n.useRecoilValue(Ra),m=n.useRecoilValue(Na),p=n.useRecoilValue(Oa),h=n.useRecoilValue(Va),{element:f,callback:g}=useCallbackRef(),v="scene-tree-search",b=n.useRecoilValue(jn(v)),{position:w,direction:C,handleOpen:S}=useOpenPositionedPopover({open:b,buttonElement:f,horizontalOffset:20}),V=u.useCallback((()=>{o.closeSceneTreePopover()}),[]),j=C===Pa.LEFT?"left-end":"right-start",updateSearch=async(e,t)=>{if(d){const n=c.length>0?c:[...h,va.metadataKeyName];await(r?.filterItems(d,{columns:n,exactMatch:e,removeHiddenItems:t}))}};return e.jsxs(e.Fragment,{children:[e.jsx(s.VertexTooltip,{content:"Search Options",placement:"top",children:e.jsx(s.VertexIconButton,{"data-testid":"scene-tree-search-options-popover-button",className:"text-neutral-700",ref:g,iconName:"gear",iconSize:"sm",onClick:()=>{b?V():(S(),o.openSceneTreePopover(v))}})}),b&&e.jsx(s.VertexPopover,{"data-testid":"scene-tree-search-options-popover",open:b,backdrop:!1,position:w,resizeBehavior:"fixed",placement:j,className:"z-popover",children:e.jsxs("div",{className:_e("flex flex-col bg-white border border-neutral-300 rounded",{hidden:!b}),children:[e.jsxs("div",{className:"flex items-center text-[0.875rem] p-3 border-b border-neutral-300 pb-2",children:[e.jsx("div",{className:"pr-2 text-[0.875rem] whitespace-nowrap",children:"Column Properties Search"}),e.jsx(s.VertexIconButton,{className:"ml-auto",iconName:"close",iconSize:"sm",onClick:()=>{V()}})]}),e.jsxs("div",{className:"max-h-64 p-3 overflow-y-auto",children:[e.jsx("div",{className:"text-[0.875rem] pb-2 pr-2",children:"Select properties to perform the search on:"}),e.jsx(VertexSceneTreeMetadataCheck,{checked:l,disabled:0===c.length||c.every((e=>e===va.metadataKeyName)),onChange:async e=>{await i.updateMetadataSearchAfterSearchKeysChange(va.metadataKeyName,e,h,d),t?.()},children:va.label},va.metadataKeyName),h.map((n=>e.jsx(VertexSceneTreeMetadataCheck,{checked:c.includes(n),disabled:c.length>0&&c.every((e=>e===n)),onChange:async e=>{await i.updateMetadataSearchAfterSearchKeysChange(n,e,h,d),t?.()},children:n},n)))]}),e.jsxs("div",{className:"flex p-3 border-t border-neutral-300",children:[e.jsx(s.VertexToggle,{className:"flex items-center","data-testid":"filter-exact-match-toggle",variant:"switch",checked:m,onValueChanged:async e=>{i.setMetadataSearchExactMatch(e.detail),a?.(),await updateSearch(e.detail,p)}}),e.jsx("span",{className:"pl-4 text-[0.875rem] text-neutral-800",children:"Return only exact matches"})]}),e.jsxs("div",{className:"flex px-3 pb-3",children:[e.jsx(s.VertexToggle,{className:"flex items-center","data-testid":"filter-remove-hidden-items-toggle",variant:"switch",checked:p,onValueChanged:async e=>{i.setMetadataSearchRemoveHiddenItems(e.detail),await updateSearch(m,e.detail)}}),e.jsx("span",{className:"pl-4 text-[0.875rem] text-neutral-800",children:"Search only visible items"})]})]})})]})},VertexSceneTreeSearchBar=({onSearch:t,onClearSearch:a,onExitSearchMode:o,onSearchedSceneTreeColumnsChange:i,onSearchForExactMatchChange:l,sceneTreeSearchElement:c,children:d})=>{const m=useSceneTreeActions(),p=n.useRecoilValue(Cn),[h,f]=n.useRecoilState(Ma),[g,v]=n.useRecoilState(Ra),b=n.useRecoilValue(jn("scene-tree-search"));useSceneTreeSearch({sceneTreeElement:p??null});const{element:w,callback:C}=useCallbackRef({override:c}),S=null==g||""===g;return u.useEffect((()=>{h&&w?.setFocus()}),[w,h]),e.jsxs("div",{className:"flex w-full py-3 px-2",children:[e.jsx(s.VertexTooltip,{className:"self-center mr-1",content:"Exit Search",children:e.jsx(s.VertexIconButton,{"data-testid":"scene-tree-search-close-button",iconName:"caret-left",iconSize:"sm",onPointerDown:e=>{e.preventDefault()},onClick:async()=>{f(!1),v(void 0),await(w?.clear()),await(p?.filterItems("")),b&&m.closeSceneTreePopover(),await m.flyToFirstSelectedItem(),o?.()}})}),e.jsxs(r.VertexSceneTreeSearch,{"data-testid":"scene-tree-search-bar",ref:C,controller:p?.controller,onBlur:()=>{S&&(f(!1),o?.(),b&&m.closeSceneTreePopover())},onSearch:()=>{v(w?.value),t?.(w?.value)},children:[d,e.jsx(s.VertexIcon,{slot:"clear-icon",name:"close-circle-fill",size:"sm",onPointerDown:async()=>{await m.flyToFirstSelectedItem(),a?.()}})]}),e.jsx("div",{className:"self-center pl-1",onPointerDown:e=>{e.preventDefault()},children:e.jsx(VertexSceneTreeSearchOptionsPopover,{onSearchedSceneTreeColumnsChange:i,onSearchForExactMatchChange:l})})]})},VertexSceneTreeSearch=({onEnterSearchMode:t,onExitSearchMode:a,onSearch:o,onClearSearch:s,onSearchedSceneTreeColumnsChange:i,onSearchForExactMatchChange:l,children:c})=>{const d=n.useRecoilValue(Ma);return e.jsxs(r.VertexSceneTreeToolbar,{className:"h-11 p-0 border-b border-neutral-300 box-content",slot:"header",children:[d&&e.jsx(VertexSceneTreeSearchBar,{onSearch:o,onClearSearch:s,onExitSearchMode:a,onSearchedSceneTreeColumnsChange:i,onSearchForExactMatchChange:l,children:c}),!d&&e.jsx("div",{className:"ml-auto mr-2",children:e.jsx(VertexEnterSceneTreeSearchModeButton,{onEnterSearchMode:t})})]})};function useCacheableLoadable(e,t){const a=o.useRef(),[s,i]=o.useState(0),r=n.useRecoilValueLoadable(e);o.useEffect((()=>{"hasValue"===r.state&&(a.current=r.contents)}),[t,r]);const[l,c]=o.useMemo((()=>"hasValue"!==r.state&&null!=a.current?[a.current,!0]:"hasValue"===r.state?[r.contents,!1]:[void 0,!1]),[r.state,r.contents,s]),d=o.useCallback((()=>{a.current=void 0,i(s+1)}),[s]),u=undefined;return o.useMemo((()=>({data:l,state:r.state,cached:c,invalidate:d})),[d,l,c,r.state])}const VertexSceneTreeColumnPopover=({onVisibleSceneTreeColumnsChange:t})=>{const a=useSceneTreeActions(),o=useSceneTreeColumnActions(),i=useSceneTreeSearchActions(),l=undefined;useSceneTreePartialResults({sceneTreeElement:n.useRecoilValue(Cn)??null});const c=n.useRecoilValue(Ra),d=n.useRecoilValue(wa),m=useCacheableLoadable(Sa),p=d.length>0?d:m.data,h=n.useRecoilValue(Va),f=n.useRecoilValue(Ea),[g,v]=u.useState(h),[b,w]=u.useState(""),{element:C,callback:S}=useCallbackRef(),V="scene-tree-columns",j=n.useRecoilValue(jn(V)),{position:k,direction:T,handleOpen:A}=useOpenPositionedPopover({open:j,buttonElement:C}),P=u.useCallback((()=>{a.closeSceneTreePopover()}),[]),I=T===Pa.LEFT?"left-end":"right-start",M=u.useMemo((()=>{if(null!=p){const e=p.filter((e=>g.indexOf(e)<0)),t=undefined;return[...[...g].sort(((e,t)=>e.localeCompare(t))),...e]}return[]}),[g,p]),E=u.useMemo((()=>M),[j,p]);return e.jsxs(e.Fragment,{children:[e.jsx(s.VertexTooltip,{content:"Configure Columns",placement:"top",children:e.jsx(s.VertexIconButton,{"data-testid":"scene-tree-column-popover-button",ref:S,iconName:"columns-add",iconSize:"sm",onClick:()=>{j?P():(A(),a.openSceneTreePopover(V))}})}),j&&e.jsx(s.VertexPopover,{"data-testid":"scene-tree-column-popover",open:j,backdrop:!1,position:k,resizeBehavior:"fixed",placement:I,className:"z-popover",children:e.jsxs("div",{className:_e("flex flex-col bg-white border border-neutral-300 rounded",{hidden:!j}),children:[e.jsxs("div",{className:"flex items-center text-[0.875rem] p-3",children:[e.jsxs("div",{className:"pr-2",children:[e.jsx("div",{className:"text-[0.875rem]",children:"Assembly Properties"}),e.jsx("div",{className:"text-[0.75rem] text-neutral-700 mt-1.5",children:"Select up to six properties to appear in the Assembly panel."})]}),e.jsx(s.VertexIconButton,{"data-testid":"scene-tree-columns-popover-close-button",className:"ml-auto",iconName:"close",iconSize:"sm",onClick:()=>{w(""),P()}})]}),e.jsx(s.VertexTextfield,{className:"flex w-full px-2 overflow-hidden border-b border-neutral-300 pb-2",id:"scene-tree-available-columns-search-bar","data-testid":"scene-tree-available-columns-search-bar",multiline:!1,placeholder:"Filter properties",type:"text",onInputInput:e=>{const t=e.detail.value;null!=t&&w(t.toLowerCase())}}),f&&e.jsx(r.VertexSceneTreeNotificationBanner,{"data-testid":"partial-key-list-notification-banner",message:"loading"===m.state?"Refreshing results...":"Data loading, refresh for more.",actionLabel:"Refresh",onAction:()=>o.refreshKeyList()}),e.jsxs("div",{className:"max-h-64 p-3 overflow-y-auto",children:[e.jsx(VertexSceneTreeMetadataCheck,{checked:!0,disabled:!0,children:va.label}),E.filter((e=>""===b||e.toLowerCase().includes(b))).map((t=>e.jsx(VertexSceneTreeMetadataCheck,{checked:g.includes(t),disabled:g.length>=6&&!g.includes(t),onChange:e=>{v(e?[...g,t]:g.filter((e=>e!==t)))},children:t},t)))]}),e.jsxs("div",{className:"flex items-center p-3 border-t border-neutral-300 space-x-4",children:[e.jsx("div",{className:"text-[0.75rem] text-[var(--vertex-ui-blue-700)] cursor-pointer","data-testid":"scene-tree-column-clear-selection",onClick:()=>v([]),children:"Clear selection"}),e.jsx("div",{className:"flex-grow"}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(s.VertexButton,{"data-testid":"scene-tree-column-popover-cancel",color:"secondary",onClick:()=>{w(""),P()},children:"Cancel"}),e.jsx(s.VertexButton,{"data-testid":"scene-tree-column-popover-apply",color:"primary",onClick:async()=>{await i.updateMetadataSearchAfterColumnVisibilityChange(h,g,c),await o.setActive(g),t?.(g),w(""),P()},children:"Apply"})]})]})]})})]})};function VertexToolbarDivider(){return e.jsx("div",{"data-testid":"toolbar-divider",className:"h-6 w-px bg-neutral-300 mx-1"})}const VertexSceneTreeSearchInformationForToolbar=()=>{const t=useSelectionActions(),a=n.useRecoilValue(Cn),o=n.useRecoilValue(Ra),i=n.useRecoilValue(La),r=undefined,l=`${i} ${1===i?"result":"results"}`;return e.jsxs(e.Fragment,{children:[e.jsx(VertexToolbarDivider,{}),e.jsxs("div",{className:"flex flex-row items-center overflow-hidden",children:[e.jsx("div",{className:"px-2 text-[0.8125rem] leading-4 text-neutral-900 truncate","data-testid":"search-result-info",children:`${l}`}),e.jsx(s.VertexTooltip,{className:"w-auto",content:"Select Results",placement:"top",children:e.jsx(s.VertexButton,{className:"h-6 rounded cursor-pointer","data-testid":"select-search-results-button",color:"secondary",variant:"text",size:"sm",onClick:async()=>{null!=a&&null!=o&&(await a.selectFilteredItems(o),t.toggleLastSelectWasMultiSelect(!0))},children:e.jsxs("div",{className:"flex h-6 items-center gap-1",children:[e.jsx(s.VertexIcon,{size:"sm",name:"check-circle"}),e.jsx("span",{className:"whitespace-nowrap",children:"Select Results"})]})})})]})]})},VertexSceneTreeCollapseAll=()=>{const t=n.useRecoilValue(Cn);return e.jsx(s.VertexTooltip,{className:"w-auto",content:"Collapse All",placement:"top",children:e.jsx(s.VertexIcon,{size:"sm",className:"h-6 w-6 hover:bg-neutral-300 rounded cursor-pointer","data-testid":"collapse-all-icon",name:"collapse-all",onClick:()=>{t?.collapseAll()}})})},VertexSceneTreeExpandAll=()=>{const t=n.useRecoilValue(Cn);return e.jsx(s.VertexTooltip,{className:"w-auto",content:"Expand All",placement:"top",children:e.jsx(s.VertexIcon,{size:"sm","data-testid":"expand-all-icon",className:"h-6 w-6 hover:bg-neutral-300 rounded cursor-pointer",name:"expand-all",onClick:()=>{t?.expandAll()}})})},VertexSceneTreeToolbar=({onVisibleSceneTreeColumnsChange:t})=>{const a=n.useRecoilValue(Ra),o=null==a||""===a;return e.jsx(r.VertexSceneTreeToolbar,{className:"h-10 border-b border-neutral-300 box-border",children:e.jsxs("div",{className:"flex w-full text-neutral-700 items-center gap mx-2",children:[e.jsx(VertexSceneTreeExpandAll,{}),e.jsx(VertexSceneTreeCollapseAll,{}),!o&&e.jsx(VertexSceneTreeSearchInformationForToolbar,{}),e.jsx("div",{className:"ml-auto",children:e.jsx(VertexSceneTreeColumnPopover,{onVisibleSceneTreeColumnsChange:t})})]})})},VertexSceneTreeHeader=({onEnterSearchMode:t,onExitSearchMode:n,onSearch:a,onClearSearch:o,onVisibleSceneTreeColumnsChange:s,children:i})=>{const r=null!=i&&!1!==i;return e.jsx("div",{slot:"header",className:"flex flex-col",children:r?i:e.jsxs(e.Fragment,{children:[e.jsx(VertexSceneTreeSearch,{onEnterSearchMode:t,onExitSearchMode:n,onSearch:a,onClearSearch:o,children:e.jsx("div",{slot:"clear-icon"})}),e.jsx(VertexSceneTreeToolbar,{onVisibleSceneTreeColumnsChange:s})]})})};function useMetadataActions(){const e=useActionCallback((({snapshot:e,set:t})=>async n=>{const a=undefined;if(await e.getPromise(la(n)))return;t(la(n),!0);const o=await e.getPromise(oa(n));if(null!=o?.metadata){const e=[...o.metadata];t(sa(n),(t=>[...t,...e]))}const s=o?.cursor;t(ia(n),s),t(la(n),!1)}));return{fetchInitialMetadata:useActionCallback((({snapshot:t})=>async n=>{const a=undefined;0===(await t.getPromise(sa(n))).length&&await e(n)})),fetchNextMetadata:useActionCallback((()=>async t=>{await e(t)}))}}var Wa={exports:{}};!function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function defineProperties(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(e,t,n){return t&&defineProperties(e.prototype,t),n&&defineProperties(e,n),e}}(),a=o,s=_interopRequireDefault(a),i,r=_interopRequireDefault(l);function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _objectWithoutProperties(e,t){var n={};for(var a in e)t.indexOf(a)>=0||Object.prototype.hasOwnProperty.call(e,a)&&(n[a]=e[a]);return n}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var c=function(e){function InfiniteScroll(e){_classCallCheck(this,InfiniteScroll);var t=_possibleConstructorReturn(this,(InfiniteScroll.__proto__||Object.getPrototypeOf(InfiniteScroll)).call(this,e));return t.scrollListener=t.scrollListener.bind(t),t.eventListenerOptions=t.eventListenerOptions.bind(t),t.mousewheelListener=t.mousewheelListener.bind(t),t}return _inherits(InfiniteScroll,e),n(InfiniteScroll,[{key:"componentDidMount",value:function componentDidMount(){this.pageLoaded=this.props.pageStart,this.options=this.eventListenerOptions(),this.attachScrollListener()}},{key:"componentDidUpdate",value:function componentDidUpdate(){if(this.props.isReverse&&this.loadMore){var e=this.getParentElement(this.scrollComponent);e.scrollTop=e.scrollHeight-this.beforeScrollHeight+this.beforeScrollTop,this.loadMore=!1}this.attachScrollListener()}},{key:"componentWillUnmount",value:function componentWillUnmount(){this.detachScrollListener(),this.detachMousewheelListener()}},{key:"isPassiveSupported",value:function isPassiveSupported(){var e=!1,t={get passive(){e=!0}};try{document.addEventListener("test",null,t),document.removeEventListener("test",null,t)}catch(e){}return e}},{key:"eventListenerOptions",value:function eventListenerOptions(){var e=this.props.useCapture;return e=this.isPassiveSupported()?{useCapture:this.props.useCapture,passive:!0}:{passive:!1}}},{key:"setDefaultLoader",value:function setDefaultLoader(e){this.defaultLoader=e}},{key:"detachMousewheelListener",value:function detachMousewheelListener(){var e=window;!1===this.props.useWindow&&(e=this.scrollComponent.parentNode),e.removeEventListener("mousewheel",this.mousewheelListener,this.options?this.options:this.props.useCapture)}},{key:"detachScrollListener",value:function detachScrollListener(){var e=window;!1===this.props.useWindow&&(e=this.getParentElement(this.scrollComponent)),e.removeEventListener("scroll",this.scrollListener,this.options?this.options:this.props.useCapture),e.removeEventListener("resize",this.scrollListener,this.options?this.options:this.props.useCapture)}},{key:"getParentElement",value:function getParentElement(e){var t=this.props.getScrollParent&&this.props.getScrollParent();return null!=t?t:e&&e.parentNode}},{key:"filterProps",value:function filterProps(e){return e}},{key:"attachScrollListener",value:function attachScrollListener(){var e=this.getParentElement(this.scrollComponent);if(this.props.hasMore&&e){var t=window;!1===this.props.useWindow&&(t=e),t.addEventListener("mousewheel",this.mousewheelListener,this.options?this.options:this.props.useCapture),t.addEventListener("scroll",this.scrollListener,this.options?this.options:this.props.useCapture),t.addEventListener("resize",this.scrollListener,this.options?this.options:this.props.useCapture),this.props.initialLoad&&this.scrollListener()}}},{key:"mousewheelListener",value:function mousewheelListener(e){1!==e.deltaY||this.isPassiveSupported()||e.preventDefault()}},{key:"scrollListener",value:function scrollListener(){var e=this.scrollComponent,t=window,n=this.getParentElement(e),a=void 0;if(this.props.useWindow){var o=document.documentElement||document.body.parentNode||document.body,s=void 0!==t.pageYOffset?t.pageYOffset:o.scrollTop;a=this.props.isReverse?s:this.calculateOffset(e,s)}else a=this.props.isReverse?n.scrollTop:e.scrollHeight-n.scrollTop-n.clientHeight;a<Number(this.props.threshold)&&e&&null!==e.offsetParent&&(this.detachScrollListener(),this.beforeScrollHeight=n.scrollHeight,this.beforeScrollTop=n.scrollTop,"function"==typeof this.props.loadMore&&(this.props.loadMore(this.pageLoaded+=1),this.loadMore=!0))}},{key:"calculateOffset",value:function calculateOffset(e,t){return e?this.calculateTopPosition(e)+(e.offsetHeight-t-window.innerHeight):0}},{key:"calculateTopPosition",value:function calculateTopPosition(e){return e?e.offsetTop+this.calculateTopPosition(e.offsetParent):0}},{key:"render",value:function render(){var e=this,t=this.filterProps(this.props),n=t.children,a=t.element,o=t.hasMore;t.initialLoad;var i=t.isReverse,r=t.loader;t.loadMore,t.pageStart;var l=t.ref;t.threshold,t.useCapture,t.useWindow,t.getScrollParent;var c=_objectWithoutProperties(t,["children","element","hasMore","initialLoad","isReverse","loader","loadMore","pageStart","ref","threshold","useCapture","useWindow","getScrollParent"]);c.ref=function(t){e.scrollComponent=t,l&&l(t)};var d=[n];return o&&(r?i?d.unshift(r):d.push(r):this.defaultLoader&&(i?d.unshift(this.defaultLoader):d.push(this.defaultLoader))),s.default.createElement(a,c,d)}}]),InfiniteScroll}(a.Component);c.propTypes={children:r.default.node.isRequired,element:r.default.node,hasMore:r.default.bool,initialLoad:r.default.bool,isReverse:r.default.bool,loader:r.default.node,loadMore:r.default.func.isRequired,pageStart:r.default.number,ref:r.default.func,getScrollParent:r.default.func,threshold:r.default.number,useCapture:r.default.bool,useWindow:r.default.bool},c.defaultProps={element:"div",hasMore:!1,initialLoad:!0,pageStart:0,ref:null,threshold:250,useWindow:!0,isReverse:!1,useCapture:!1,loader:null,getScrollParent:null},t.default=c,e.exports=t.default}(Wa,Wa.exports);var Ga=Wa.exports;const CopyButton=({id:t,textToCopy:n,iconSize:a,disableTooltip:i,onCopyValue:r})=>{const[l,c]=o.useState(!1),d=undefined,u=useDebouncedCallback((()=>{c(!1)}),2e3);return e.jsx(s.VertexTooltip,{className:"h-fit self-center z-[16000]",content:l?"Copied to Clipboard":"Copy",placement:"bottom",disabled:i,children:e.jsx("div",{className:_e({"text-green-700":l}),children:e.jsx(s.VertexIconButton,{className:"ml-auto","data-testid":`${t}-copy-button`,iconName:l?"check":"copy",iconSize:a??"xs",onClick:e=>{e.stopPropagation(),e.preventDefault(),null!=n&&(navigator.clipboard.writeText(n),r?.(n)),c(!0),u(!0)},style:{"--hover-box-shadow":"none"}})})})};function MetadataPropertyValue({value:t,onCopyMetadataValue:n}){const[a,i]=o.useState(!1),r=""!==t.replace(/^\s*$/,"").trim();return r?e.jsxs("div",{className:"flex w-full border-b border-neutral-300 pl-1 pr-3","data-testid":`${t}-metadata-property`,onMouseEnter:()=>{i(!0)},onMouseLeave:()=>i(!1),children:[e.jsx(s.VertexTooltip,{className:"w-full shrink truncate pr-2 py-1.5",content:t,placement:"bottom-start",children:e.jsx("div",{className:"truncate",children:t})}),a&&e.jsx(CopyButton,{id:t,textToCopy:t,onCopyValue:n})]}):e.jsx("div",{className:_e("overflow-visible border-b border-neutral-300 pl-1 pr-4 py-1.5",{"text-neutral-500":!r}),children:"--"})}const MetadataPanelContents=({sceneItemId:t,onCopyMetadataValue:a})=>{const i=useMetadataActions(),r=n.useRecoilValueLoadable(ca),l=n.useRecoilValue(sa(t)),c=n.useRecoilValue(ra(t)),d=n.useRecoilValue(la(t)),u=l?.length>0;function getMessage(){if(!d&&0===l?.length&&"hasValue"===r.state)return"This part does not contain properties"}return o.useEffect((()=>{null!=t&&i.fetchInitialMetadata(t)}),[t]),e.jsxs(e.Fragment,{children:[e.jsx(Ga,{initialLoad:!1,hasMore:c,loadMore:async()=>{c&&await i.fetchNextMetadata(t)},useWindow:!1,children:e.jsxs("div",{className:"flex w-full text-xs leading-5 grow-0",children:[e.jsx(s.VertexResizable,{className:"w-1/2 min-w-24 max-w-full shrink-0",horizontalDirection:"right",verticalDirection:"none",initialHorizontalScale:.5,parentSelector:"#metadata-panel-wrapper",horizontalSiblingSelector:"#metadata-value-column",children:e.jsx("div",{className:"flex flex-col w-full overflow-hidden whitespace-nowrap",children:l.map(((t,n)=>e.jsx(s.VertexTooltip,{className:"border-b border-neutral-300 pl-4 pr-1 py-1.5",content:t.key,placement:"bottom-start",children:e.jsx("div",{className:"truncate",children:t.key})},n)))})}),e.jsx("div",{id:"metadata-value-column",className:"flex flex-col w-full min-w-24",children:l.map(((t,n)=>e.jsx(MetadataPropertyValue,{value:t.value,onCopyMetadataValue:a},n)))})]})}),!u&&e.jsx("div",{className:"w-full h-full flex items-center justify-center px-4 text-center text-sm",children:getMessage()})]})},MetadataPanel=({onCopyMetadataValue:t})=>{const a=usePanelActions(),o=n.useRecoilValue(wt),i=n.useRecoilValueLoadable(ca);return e.jsxs("div",{id:"metadata-panel-wrapper","data-testid":"metadata-panel-wrapper",className:"w-full h-full flex flex-col mt-auto text-neutral-800",children:[e.jsxs("div",{className:"flex h-10 border-b border-neutral-300 p-3 pl-4 text-[0.875rem] items-center",children:["hasValue"===i.state&&e.jsx("span",{className:"flex flex-col w-full",children:e.jsx(s.VertexTooltip,{content:i.contents,children:e.jsx("div",{className:"truncate",children:i.contents||""})})}),"loading"===i.state&&e.jsx("div",{className:"flex items-center w-full h-full",children:e.jsx("div",{className:"w-1/2 h-1/2 bg-neutral-300 animate-pulse rounded"})}),e.jsx(s.VertexIcon,{className:"ml-auto cursor-pointer",onClick:a.closeSecondary,name:"close",size:"sm"})]}),e.jsxs("div",{className:"w-full h-full overflow-y-auto overflow-x-hidden",children:[null!=o&&e.jsx(MetadataPanelContents,{sceneItemId:o.id,onCopyMetadataValue:t}),null==o&&e.jsx("div",{className:"w-full h-full flex items-center justify-center px-4 text-center text-sm",children:"Please select a single part or assembly to view its metadata"})]})]})},SceneTreeSecondaryPanel=({panelId:t,onCopyMetadataValue:n})=>e.jsx(s.VertexResizable,{"data-testid":"scene-tree-secondary-panel",className:"min-h-20 max-h-full flex-shrink-0 border-t border-neutral-300",horizontalDirection:"none",verticalDirection:"top",initializeWithOffset:!0,initialVerticalScale:.6,parentSelector:`#${t}`,verticalSiblingSelector:"#scene-tree-container",children:e.jsx(MetadataPanel,{onCopyMetadataValue:n})}),VertexSceneTreeCustomColumn=({label:t,rowDataBinding:a,expandToggle:s,visibilityToggle:i,isolateButton:l,modelViewsButton:c,initialWidth:d,minWidth:u})=>{const m=n.useRecoilValue(Cn);return o.useEffect((()=>{m?.invalidateRows()}),[a]),e.jsxs(r.VertexSceneTreeTableColumn,{"data-testid":`scene-tree-table-column-${t}`,initialWidth:d,minWidth:u,children:[e.jsx("template",{slot:"header",dangerouslySetInnerHTML:{__html:`\n <div class="text-sm text-neutral-800 my-2">\n <div class="${_e("truncate",{"pl-2":s,"pr-2":i})}">\n ${t}\n </div>\n </div>\n `}}),e.jsx("template",{dangerouslySetInnerHTML:{__html:`\n <vertex-scene-tree-table-cell\n prop:value="${a}"\n prop:selection-handler="{{row.data.handleSelection}}"\n prop:expansion-handler="{{row.data.handleExpansion}}"\n prop:visibility-handler="{{row.data.handleVisibility}}"\n ${s?"expand-toggle":""}\n ${i?"visibility-toggle":""}\n ${l?"isolate-button":""}\n >\n <div class="flex items-center gap-2">\n <vertex-tooltip \n class="truncate" \n prop:content="${null!=a?a:"--"}" \n placement="${i?"right":"top"}">\n <div class="flex items-center w-full">\n <div class="truncate">${a}</div>\n </div>\n </vertex-tooltip>\n\n ${c?'<div attr:style={{row.data.modelViewIndicatorStyle}}> \n <vertex-tooltip class="block w-full truncate" content="Listing Model Views" placement="bottom">\n <vertex-icon-button\n class="ml-auto mr-0.5 text-neutral-800"\n event:pointerup="{{row.data.handleShowModelViews}}"\n icon-name="views"\n icon-size="sm"\n variant="plain"\n >\n </vertex-icon-button>\n </vertex-tooltip>\n </div>':""}\n </div>\n\n <div slot="placeholder" class="flex items-center w-full truncate">\n <div> -- </div>\n </div>\n </vertex-scene-tree-table-cell>\n `}})]},t)},VertexSceneTreeMetadataColumns=({children:t})=>{const a=n.useRecoilValue(ja),o=n.useRecoilValue(ka),s=[],i=o.filter((e=>e!==va.label)).map((e=>a[e]));return null!=t?e.jsx(e.Fragment,{children:t({columns:i.map((e=>({key:e.label,initialWidth:e.initialWidth,minWidth:e.minWidth})))})}):e.jsx(e.Fragment,{children:i.map(((t,n)=>{const a=s[n]??t.initialWidth;return e.jsx(VertexSceneTreeCustomColumn,{label:t.label,visibilityToggle:n===i.length-1,isolateButton:n===i.length-1,rowDataBinding:t.binding,initialWidth:a,minWidth:t.minWidth},t.label)}))})},VertexSceneTreeTableLayout=t=>{const{children:a,...s}=t,i=n.useRecoilValue(ja),l=n.useRecoilValue(ka),c=o.useMemo((()=>findChildElement(a,NameColumn)),[a]),d=o.useMemo((()=>findChildElement(a,MetadataColumns)),[a]),u=i[va.label]??va,m=l.filter((e=>e!==va.label)).map((e=>i[e]));return e.jsxs(r.VertexSceneTreeTableLayout,{"data-testid":"scene-tree-table-layout",...s,children:[c?cloneChildNodeOrFunction(c.props.children,{columnCount:l.length,initialWidth:u.initialWidth,minWidth:u.minWidth}):e.jsx(VertexSceneTreeCustomColumn,{expandToggle:!0,visibilityToggle:1===l.length,isolateButton:1===l.length,rowDataBinding:u.binding,label:u.label,initialWidth:u.initialWidth,minWidth:u.minWidth}),null!=d?cloneChildNodeOrFunction(d.props.children,{columns:m.map((e=>({key:e.label,initialWidth:e.initialWidth,minWidth:e.minWidth})))}):e.jsx(VertexSceneTreeMetadataColumns,{})]})},NameColumn=({children:t})=>e.jsx(e.Fragment,{children:t}),MetadataColumns=({children:t})=>e.jsx(e.Fragment,{children:t});VertexSceneTreeTableLayout.NameColumn=NameColumn,VertexSceneTreeTableLayout.MetadataColumns=MetadataColumns;const VertexSceneTree=({id:t,font:a,backgroundColors:s,additionalLoadedMetadataProperties:i,whitelistedMetadataProperties:l,allowViewingMetadataPropertiesPanel:c,children:d,style:u,onPointerDown:m,onClick:p,onToggleSelection:h,onToggleExpansion:f,onToggleVisibility:g,onCopyMetadataValue:v,className:b,rowData:w,...C})=>{const S=usePanelActions(),V=useSceneTreeActions(),j=useSelectionActions(),k=n.useRecoilValue(ga),T=n.useRecoilValue(G),A=n.useRecoilValue(ta),P=n.useRecoilValue(Ha),I=n.useRecoilValue(_a),M=n.useRecoilValue(Na),E=n.useRecoilValue(Oa),R=n.useRecoilValue(Ra),N=null==R||""===R,O=useRecoilRef({state:Cn}),L=o.useMemo((()=>findChildElement(d,Header)),[d]),_=o.useMemo((()=>findChildElement(d,TableLayout)),[d]),B=o.useMemo((()=>findChildElement(d,ContextMenu)),[d]),wrappedExpansionHandler=(e,t,n)=>{V.toggleExpansion(e,t,n),f?.(e,t,n)},wrappedSelectionHandler=(e,t,n)=>{V.toggleSelection(e,t,n),h?.(e,t,n)},wrappedVisibilityHandler=(e,t,n)=>{V.toggleVisibility(e,t,n),g?.(e,t,n)},handleClick=async e=>{e.altKey&&await V.flyToRow(e.clientY),p?.(e)},handlePointerDown=async e=>{targetIsElement(e.target,"VERTEX-SCENE-TREE-TABLE-COLUMN")&&await j.clearSelection(),m?.(e)},D=n.useSetRecoilState(Sn),handleFirstRowRendered=e=>{D(e.target.controller),C?.onFirstRowRendered?.(e)},F=o.useMemo((()=>({metadataSearchKeys:I,exactMatch:M,removeHiddenItems:E})),[I,M,E]);useStateSyncedValue(wa,l,{transform:e=>e.sort(((e,t)=>e.localeCompare(t)))}),useStateSyncedValue(aa,c),useStateSyncedValue(Fa,i);const H=n.useRecoilValue(Nt),U=o.useCallback((e=>{e.preventDefault(),e.stopPropagation(),S.openPrimary("model-views","right")}),[S]);return e.jsxs("div",{id:"scene-tree-panel",className:"flex flex-col w-full h-full grow-0",children:[e.jsx("div",{id:"scene-tree-container",className:"flex group h-full min-h-32 overflow-auto",children:e.jsxs(r.VertexSceneTree,{id:t??"vertex-scene-tree","data-testid":"vertex-scene-tree",config:k,ref:O,className:_e("flex-1",{filtered:!N}),style:{...styleFromOptionalFont(a),...styleFromOptionalBackgroundColors(s),...u},onConnectionError:e=>{logger_error("Scene Tree Connection Error: ",e.detail)},viewer:T,onPointerDown:handlePointerDown,onClick:handleClick,rowData:e=>{const t=w?.(e)??{};return{handleExpansion:wrappedExpansionHandler,handleSelection:wrappedSelectionHandler,handleVisibility:wrappedVisibilityHandler,handleShowModelViews:U,modelViewIndicatorStyle:e?.node.id?.hex===H?.id?"display: flex;":"display: none;",...t}},searchOptions:F,metadataKeys:P,...C,onFirstRowRendered:handleFirstRowRendered,children:[L??e.jsx(VertexSceneTreeHeader,{}),_??e.jsx(VertexSceneTreeTableLayout,{}),B??e.jsx(VertexSceneTreeContextMenu,{})]})}),void 0!==A&&e.jsx(SceneTreeSecondaryPanel,{panelId:"scene-tree-panel",onCopyMetadataValue:v})]})},Header=({children:t})=>e.jsx(e.Fragment,{children:t}),TableLayout=({children:t})=>e.jsx(e.Fragment,{children:t}),ContextMenu=({children:t})=>e.jsx(e.Fragment,{children:t});VertexSceneTree.Header=Header,VertexSceneTree.TableLayout=TableLayout,VertexSceneTree.ContextMenu=ContextMenu;const VertexDecimalPlaceSelector=({onApply:t})=>{const[a,o]=n.useRecoilState(_t);return e.jsxs(s.VertexSelect,{"data-testid":"decimal-place-select",className:"w-24",value:a,onOptionChanged:e=>{o(e.detail),t?.(e.detail)},children:[e.jsx("div",{className:"py-1.5 px-3",children:"0"}),e.jsx("div",{className:"py-1.5 px-3",children:"1"}),e.jsx("div",{className:"py-1.5 px-3",children:"2"}),e.jsx("div",{className:"py-1.5 px-3",children:"3"})]})},VertexLengthUnitSelector=({onApply:t})=>{const[a,o]=n.useRecoilState(Lt);return e.jsxs(s.VertexSelect,{"data-testid":"length-unit-select",className:"w-40",value:a,onOptionChanged:e=>{o(e.detail),t?.(e.detail)},children:[e.jsx("div",{"data-value":"cm",className:"py-1.5 px-3",children:"centimeters"}),e.jsx("div",{"data-value":"mm",className:"py-1.5 px-3",children:"millimeters"}),e.jsx("div",{"data-value":"m",className:"py-1.5 px-3",children:"meters"}),e.jsx("div",{"data-value":"in",className:"py-1.5 px-3",children:"inches"}),e.jsx("div",{"data-value":"ft",className:"py-1.5 px-3",children:"feet"})]})};function VertexUnitsControls({onUnitChange:t,onDecimalPlaceChange:n}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("div",{className:"pt-1 pb-2 text-sm text-neutral-700",children:"Length Unit"}),e.jsx(VertexLengthUnitSelector,{onApply:t})]}),e.jsxs("div",{children:[e.jsx("div",{className:"pt-2 pb-2 text-sm text-neutral-700",children:"Decimals"}),e.jsx(VertexDecimalPlaceSelector,{onApply:n})]})]})}function VertexUnitsPanelSection({onUnitChange:t,onDecimalPlaceChange:n}){return e.jsx(PanelSection,{header:e.jsx("div",{className:"flex items-center text-base",children:"Units"}),children:e.jsx(VertexUnitsControls,{onUnitChange:t,onDecimalPlaceChange:n})})}function useModelViewActions(){const e=usePmiAnnotationActions(),t=useSelectionActions();return{fetchNextModelViews:useActionCallback((({snapshot:e,set:t})=>async n=>{const a=await e.getPromise(hn(n));if(null!=a){const e=a?.paging?.next;null!=e&&(t(cn(n),(e=>[...e,a])),t(rn(n),(()=>e)))}})),loadModelView:useActionCallback((({set:n,snapshot:a})=>async(o,s)=>{const i=await a.getPromiseRequired(G),r=await a.getPromiseRequired(bt);try{await(i?.modelViews?.load(o,s.id)),n(pn,{itemId:o,modelView:s}),await e.clearPmiAnnotationSelection(),0!==r.length&&await t.clearSelection(),await e.fetchInitialPmiAnnotations(s.id)}catch(e){logger_error("Failed to load model view",e)}})),clearModelView:useActionCallback((({reset:t,snapshot:n})=>async()=>{const a=undefined;if(null!=await n.getPromise(pn)){const a=await n.getPromiseRequired(G);try{await(a?.modelViews?.unload()),t(pn),await e.clearPmiAnnotationSelection()}catch(e){logger_error("Failed to remove model view",e)}}}))}}var Ka=Object.freeze({__proto__:null,hasMoreModelViews:fn,hasMorePmiAnnotations:vn,loadedItemModelView:pn,loadedModelViews:cn,loadedPmiAnnotations:dn,modelViews:xn,modelViewsCursor:rn,modelViewsSceneItemName:mn,nextModelViews:hn,nextPmiAnnotations:gn,pmiAnnotations:yn,pmiAnnotationsCursor:ln,selectedPmiAnnotationId:bn,useModelViewActions:useModelViewActions,visiblePmiAnnotations:un});function FileWithMagnifyingGlassImage(){return e.jsx("div",{children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"160",height:"160",viewBox:"0 0 220 220",children:[e.jsx("path",{fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":".75",d:"M38.84 186.31h143.29m-155.07 5.14h176.49M1 196.58h218m-205.11 5.14h185.22m-162.74 5.13h141.84"}),e.jsx("path",{fill:"#f7fcfd",d:"m150.94 50.25 20.43 19.51a3.42 3.42 0 0 1 1 2.46v121.2a5.23 5.23 0 0 1-5.23 5.23H52.78a5.23 5.23 0 0 1-5.23-5.23V54.56a5.24 5.24 0 0 1 5.23-5.24h95.81a3.44 3.44 0 0 1 2.35.93"}),e.jsx("path",{fill:"none",stroke:"#006bad","stroke-dasharray":"3 3","stroke-linecap":"round","stroke-linejoin":"round",d:"m150.94 50.25 20.43 19.51a3.42 3.42 0 0 1 1 2.46v121.2a5.23 5.23 0 0 1-5.23 5.23H52.78a5.23 5.23 0 0 1-5.23-5.23V54.56a5.24 5.24 0 0 1 5.23-5.24h95.81a3.44 3.44 0 0 1 2.35.93"}),e.jsx("path",{d:"M79.12 123.99H110v30.88H79.12z",fill:"#e0f3f9"}),e.jsx("path",{d:"M110 153.37v1.5h-1.5",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{d:"M105.4 154.87H82.17",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round","stroke-dasharray":"3.1 3.1"}),e.jsx("path",{d:"M80.62 154.87h-1.5v-1.5",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{d:"M79.12 150.27v-23.23",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round","stroke-dasharray":"3.1 3.1"}),e.jsx("path",{d:"M79.12 125.49v-1.5h1.5",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{d:"M83.72 123.99h23.23",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round","stroke-dasharray":"3.1 3.1"}),e.jsx("path",{d:"M108.5 123.99h1.5v1.5",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{d:"M110 128.59v23.23",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round","stroke-dasharray":"3.1 3.1"}),e.jsx("path",{d:"M110 123.99h30.88v30.88H110z",fill:"#e0f3f9"}),e.jsx("path",{d:"M140.88 153.37v1.5h-1.5",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{d:"M136.28 154.87h-23.23",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round","stroke-dasharray":"3.1 3.1"}),e.jsx("path",{d:"M111.5 154.87H110v-1.5",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{d:"M110 150.27v-23.23",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round","stroke-dasharray":"3.1 3.1"}),e.jsx("path",{d:"M110 125.49v-1.5h1.5",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{d:"M114.6 123.99h23.23",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round","stroke-dasharray":"3.1 3.1"}),e.jsx("path",{d:"M139.38 123.99h1.5v1.5",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{d:"M140.88 128.59v23.23",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round","stroke-dasharray":"3.1 3.1"}),e.jsx("path",{d:"M110 93.11h30.88v30.88H110z",fill:"#e0f3f9"}),e.jsx("path",{d:"M140.88 122.49v1.5h-1.5",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{d:"M136.28 123.99h-23.23",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round","stroke-dasharray":"3.1 3.1"}),e.jsx("path",{d:"M111.5 123.99H110v-1.5",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{d:"M110 119.39V96.15",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round","stroke-dasharray":"3.1 3.1"}),e.jsx("path",{d:"M110 94.61v-1.5h1.5",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{d:"M114.6 93.11h23.23",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round","stroke-dasharray":"3.1 3.1"}),e.jsx("path",{d:"M139.38 93.11h1.5v1.5",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{d:"M140.88 97.7v23.24",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round","stroke-dasharray":"3.1 3.1"}),e.jsx("path",{d:"M150.91 50.28a3.6 3.6 0 0 1 .86 1.22",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{fill:"none",stroke:"#006bad","stroke-dasharray":"2.87 2.87","stroke-linecap":"round","stroke-linejoin":"round",d:"M152.05 54.34v9.14a5.24 5.24 0 0 0 5.24 5.23h9.94"}),e.jsx("path",{d:"M168.67 68.71h.2a3.5 3.5 0 0 1 1.27.23M19.8 78.25l1.93 14.68-14.67 1.93",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{d:"M21.73 92.93S-2.15 82.45 4.05 54.82",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{fill:"none",stroke:"#b43296","stroke-linecap":"round","stroke-linejoin":"round",d:"M14.89 132.63h5.88v5.88h-5.88z"}),e.jsx("path",{fill:"none",stroke:"#f90","stroke-linecap":"round","stroke-linejoin":"round",d:"M174.49 36v5.88m-2.94-2.94h5.88"}),e.jsx("circle",{cx:"199.1",cy:"164.76",r:"2.45",fill:"none",stroke:"#0c0","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{d:"M109.68 25.74V11.9M87.12 29.74l-6.02-9.4m53.21 9.4 6.01-9.4",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{fill:"#eff9fc",stroke:"#006bad","stroke-linejoin":"round",d:"m140.43 139.69 7.22 5.8-8.28 10.31-7.22-5.8"}),e.jsx("circle",{cx:"110.2",cy:"124.35",r:"27.74",fill:"#e0f3f9",opacity:".7"}),e.jsx("path",{fill:"#fff",stroke:"#006bad","stroke-linejoin":"round",d:"M131.2 98.19a33.55 33.55 0 1 0 5.16 47.16 33.56 33.56 0 0 0-5.16-47.16Zm.63 43.52a27.73 27.73 0 1 1-4.26-39 27.73 27.73 0 0 1 4.26 39ZM187 173.84a29.8 29.8 0 0 1-4.19 7.52 29.3 29.3 0 0 1-7.24 6.71l-37.77-30.31a29.3 29.3 0 0 1 5-8.56 29.6 29.6 0 0 1 6.4-5.67Z"}),e.jsx("path",{fill:"none",stroke:"#fff","stroke-linecap":"round","stroke-miterlimit":"10",d:"m118.82 138.09 12.51-15.58m-38.56-3.68 6.94-8.65m-5.32 1.9 6.95-8.66m16.23 42.44 12.5-15.58"}),e.jsx("path",{fill:"#fff",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round",d:"M139.92 153.31a28.4 28.4 0 0 0-2.12 4.45m7.07-.49a38 38 0 0 0-2.35 4.28m7.3-.32c-.93 1.34-1.79 2.72-2.58 4.11m7.53-.15q-1.47 2-2.81 3.94m7.75.01-3 3.78m7.95.18c-1.07 1.24-2.16 2.45-3.26 3.61m8.21.35a54 54 0 0 1-3.49 3.44m8.44.5a37 37 0 0 1-3.72 3.26m8.67.74a29 29 0 0 1-3.95 3.09"}),e.jsx("path",{d:"m196.69 115.8-2.18 14.64 14.64 2.18",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"}),e.jsx("path",{d:"M194.51 130.44s23.76-12 21.9-35.66",fill:"none",stroke:"#006bad","stroke-linecap":"round","stroke-linejoin":"round"})]})})}function ModelViewsEmptyState({itemSelected:t}){const n=t?"There are no model views associated with this part.":"Select a part to access model views.";return e.jsxs("div",{"data-testid":"pmi-views-empty-state",className:"h-full w-full px-4 flex flex-col gap-2 justify-center items-center overflow-y-auto",children:[e.jsx(FileWithMagnifyingGlassImage,{}),e.jsx("div",{className:"text-base text-neutral-700 text-center px-3 pt-2.5 pb-1.5",children:"No Model Views"}),e.jsx("div",{className:"text-[0.8125rem] text-neutral-600 text-center px-3 pb-2.5",children:n})]})}const VertexModelViewsViewRow=({view:t,currentlyViewing:n,itemId:a,onLoadModelView:o,onClearModelView:i})=>{const r=useModelViewActions();return e.jsx("div",{"data-testid":`model-view-${t.id}`,onClick:async()=>{n?(await r.clearModelView(),i?.()):(await r.loadModelView(a,t),o?.(a,t.id))},className:_e("flex flex-col w-full h-8 p-1 pl-4 cursor-pointer text-neutral-700 text-[0.8125rem] hover:text-[var(--vertex-ui-blue-600)]",{"bg-[var(--vertex-ui-blue-200)]":n,"hover:bg-[var(--vertex-ui-blue-100)]":!n}),children:e.jsxs("div",{className:_e("flex w-full h-full items-center",{"text-neutral-900 font-extrabold":n}),children:[e.jsxs(s.VertexTooltip,{className:"flex w-20 grow","data-testid":`model-view-${t.id}-tooltip`,placement:"bottom-start",content:t.displayName,children:[e.jsx(s.VertexIcon,{name:"views",size:"sm"}),e.jsx("div",{className:"truncate mx-2",children:t.displayName}),e.jsx("span",{className:"font-normal text-neutral-700 ml-auto pr-1",children:n&&"(Viewing)"})]}),n&&e.jsx("div",{className:"ml-auto pr-1",children:e.jsx(s.VertexIconButton,{"data-testid":"model-views-clear-selection",iconSize:"sm",iconName:"close",onClick:async()=>await r.clearModelView()})})]})},t.id)};function VertexModelViewsList({itemId:t,onLoadModelView:a,onClearModelView:o}){const i=useModelViewActions(),r=n.useRecoilValue(pn),l=n.useRecoilValue(xn(t)),c=n.useRecoilValue(fn(t)),d=n.useRecoilValueLoadable(mn),u=0===l.length;return e.jsxs("div",{className:"w-full h-full flex flex-col",children:[("hasValue"!==d.state||null!=d.contents)&&e.jsxs("div",{className:"flex flex-row h-11 w-full border-b border-neutral-300 p-3 pl-4 mr-2 text-sm items-center",children:["hasValue"===d.state&&e.jsx("div",{className:"truncate items-center",children:e.jsx(s.VertexTooltip,{content:d.contents,children:e.jsx("div",{className:"truncate",children:d.contents||""})})}),"loading"===d.state&&e.jsx("div",{className:"flex items-center h-11 w-full",children:e.jsx("div",{className:"w-3/4 h-3 bg-neutral-300 animate-pulse rounded"})})]}),u&&e.jsx(ModelViewsEmptyState,{itemSelected:!0}),!u&&e.jsx("div",{className:"h-full overflow-y-auto",children:e.jsx(Ga,{hasMore:c,loadMore:()=>{i.fetchNextModelViews(t)},useWindow:!1,children:l.map((n=>{const s=r?.modelView?.id.toString(),i=s===n?.id;return e.jsx(VertexModelViewsViewRow,{view:n,currentlyViewing:i,itemId:t,onLoadModelView:a,onClearModelView:o},n.id)}))})})]})}const VertexPMIAnnotationRow=({annotation:t,checked:n,onCheckedChange:a,selected:o,onSelectedChange:i})=>e.jsxs("div",{id:`annotation-entry-${t.id}`,"data-testid":`annotation-entry-${t.displayName}`,className:_e("flex items-center w-full h-7 gap-2.5 pl-4 pr-2 cursor-default hover:text-[var(--vertex-ui-blue-600)]",{"bg-[var(--vertex-ui-blue-200)]":o,"hover:bg-[var(--vertex-ui-blue-100)]":!o}),onClick:()=>i(!o),children:[e.jsx(s.VertexToggle,{"data-testid":`annotation-entry-${t.displayName}-check`,variant:"check",checked:n,onClick:e=>e.stopPropagation(),onValueChanged:e=>{a(e.detail)}}),e.jsx("div",{className:"w-1/2 flex-grow",children:e.jsx(s.VertexTooltip,{content:t.displayName,placement:"bottom-start",children:e.jsx("div",{className:"truncate",children:t.displayName})})})]}),VertexPMIAnnotationsSecondaryPanel=({modelViewId:t,parentPanelId:a,verticalSiblingId:o,sceneAnnotationOperations:i,onToggleSelectionOfPMIAnnotation:r,onToggleVisibilityOfPMIAnnotation:l})=>{const c=usePmiAnnotationActions(),d=n.useRecoilValue(G),m=n.useRecoilValue(yn(t)),p=n.useRecoilValue(vn(t)),h=n.useRecoilValue(bn),[f,g]=n.useRecoilState(un(t)),[v,b]=u.useState("");u.useEffect((()=>{t!==v&&(g(m),b(t))}),[m,v,t,g,b]);const toggleVisibilityOfAllAnnotations=e=>{e?(g(m),i?.sceneAnnotationsOperation((e=>e.show()),d)):(g([]),i?.sceneAnnotationsOperation((e=>e.hide()),d))};return e.jsx(s.VertexResizable,{"data-testid":"pmi-annotation-secondary-panel",className:"min-h-28 max-h-3/4 flex-shrink-0 border-t text-sm text-neutral-700",horizontalDirection:"none",verticalDirection:"top",initializeWithOffset:!0,initialVerticalScale:.6,parentSelector:`#${a}`,verticalSiblingSelector:`#${o}`,children:e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsx("div",{className:"flex items-center w-full h-9 border-b border-[var(--vertex-ui-neutral-300)] px-4 shrink-0",children:"3D PMI"}),e.jsxs("div",{"data-testid":"display-all-annotations",className:"flex items-center w-full h-8 gap-2.5 px-4 py-1.5 cursor-default border-b border-[var(--vertex-ui-neutral-300)]",onClick:()=>{const e=m.length!==f.length;toggleVisibilityOfAllAnnotations(e)},children:[e.jsx(s.VertexToggle,{"data-testid":"display-all-annotations-check",variant:"check",checked:m.length===f.length,onClick:e=>e.stopPropagation(),onValueChanged:e=>{toggleVisibilityOfAllAnnotations(e.detail)}}),"Display All"]}),e.jsx("div",{className:"h-full overflow-y-auto text-[0.8125rem] py-1",children:e.jsx(Ga,{hasMore:p,loadMore:async()=>{p&&await c.fetchNextPmiAnnotations(t)},useWindow:!1,children:m.map(((n,a)=>e.jsx(VertexPMIAnnotationRow,{annotation:n,checked:f.includes(n),onCheckedChange:e=>{e?(g([...f,n]),i?.sceneAnnotationsOperation((e=>e.show()),d,[n.id])):(g(f.filter((e=>e!==n))),i?.sceneAnnotationsOperation((e=>e.hide()),d,[n.id])),l?.(t,n.id,e)},selected:n.id===h,onSelectedChange:async e=>{e?await c.selectPmiAnnotation(n.id,!1):await c.clearPmiAnnotationSelection(),r?.(t,n.id,e)}},a)))})})]})})},VertexModelViewsPanelSection=({onLoadModelView:t,onClearModelView:a,onToggleSelectionOfPMIAnnotation:o,onToggleVisibilityOfPMIAnnotation:s})=>{const i=useSceneAnnotationsOperations(),r=n.useRecoilValue(Nt),l=null!=r?.id,c=n.useRecoilValue(pn),d=c?.itemId===r?.id;return e.jsxs("div",{id:"model-views-panel-wrapper",className:"w-full h-full flex flex-col text-neutral-800",children:[e.jsxs("div",{"data-testid":"model-views-container",className:"group h-full flex overflow-auto min-h-29 relative",children:[l&&e.jsx(u.Suspense,{fallback:e.jsx(ModelViewsItemListLoading,{}),children:e.jsx(VertexModelViewsList,{itemId:r.id,onLoadModelView:t,onClearModelView:a})}),!l&&e.jsx(ModelViewsEmptyState,{itemSelected:!1})]}),null!=c&&d&&e.jsx(u.Suspense,{fallback:e.jsx(ModelViewsItemListLoading,{}),children:e.jsx(VertexPMIAnnotationsSecondaryPanel,{modelViewId:c.modelView.id,parentPanelId:"model-views-panel-wrapper",verticalSiblingId:"model-views-container",sceneAnnotationOperations:i,onToggleSelectionOfPMIAnnotation:o,onToggleVisibilityOfPMIAnnotation:s})})]})};function ModelViewsItemListLoading(){return e.jsxs("div",{className:"flex flex-col w-full h-full items-center justify-center text-[0.8125rem] overflow-y-auto",children:[e.jsx(s.VertexSpinner,{"data-testid":"model-views-panel-spinner",size:"lg",color:"grey"}),e.jsx("div",{className:"pt-3 px-10 text-center",children:"Loading model views for the selected part..."})]})}function VertexModelViewsPanel(){return e.jsx("div",{className:"flex flex-col text-neutral-700 h-full overflow-y-auto",children:e.jsx(VertexModelViewsPanelSection,{})})}function ColorSwatchContextMenu({onRemoveCustomColor:t}){const a=useContextMenuActions(),o=useSceneItemMaterialActions(),i=n.useRecoilValue(Ge);return e.jsx(VertexContextMenu,{menuType:"color-swatch",onOpen:e=>{elementIsColorSwatch(e.target)&&a.setContextMenuItem(e.target)},openPredicate:e=>elementIsColorSwatch(e.target)&&elementHasColorAttribute(e.target),disableBackdrop:!0,children:e.jsx(s.VertexMenuItem,{"data-testid":"color-swatch-delete",onClick:async()=>{if(contextMenuItemIsElement(i)&&elementIsColorSwatch(i)){const e=i?.getAttribute("data-color-id");null!=e&&"true"===i.getAttribute("data-custom-color")?(await o.removeCustomColor(e),t?.(e)):null!=e&&"true"===i.getAttribute("data-recent-color")&&await o.removeRecentColor(e)}},children:e.jsxs("div",{className:"flex align-middle gap-2.5",children:[e.jsx(s.VertexIcon,{slot:"icon",name:"delete",size:"sm"}),"Delete"]})})})}function DefaultAppearancePanel(){return e.jsxs("div",{className:"flex flex-col text-neutral-700 h-full overflow-y-auto",children:[e.jsx(VertexMaterialPanelSection,{}),e.jsx(VertexGhostingPanelSection,{}),e.jsx(VertexFeatureEdgesPanelSection,{}),e.jsx(VertexViewerBackgroundPanelSection,{}),e.jsx(VertexSelectionHighlightingPanelSection,{}),e.jsx(VertexCrossSectionAppearancePanelSection,{}),e.jsx(ColorSwatchContextMenu,{})]})}function DefaultSettingsPanel(){return e.jsx("div",{className:"flex flex-col text-neutral-700 h-full overflow-y-auto",children:e.jsx(VertexUnitsPanelSection,{})})}const VertexTransformClear=({onClear:t,onClearAll:a})=>{const i=useTransformActions(),r=useCacheableLoadable(Rt),l=n.useRecoilValue(Tt),c=useCacheableLoadable(Yt(l??"")),d=o.useMemo((()=>{const e=r.data?.some((e=>null!=e?.override?.transform)),t=null!=c.data;return e||t}),[r,c]);return e.jsx("div",{className:"ml-auto",children:e.jsxs(ResetButton,{id:"transforms",tooltip:"Clear Transforms",children:[e.jsx("div",{className:"pt-1"}),e.jsx(s.VertexMenuItem,{"data-testid":"clear-selected-transforms",onClick:async()=>{await i.clearSelectedTransforms(),t?.()},disabled:!d,children:"Clear selected transforms"}),e.jsx(s.VertexMenuItem,{"data-testid":"clear-all-transforms",onClick:async()=>{await i.clearAllTransforms(),a?.()},children:"Clear all transforms"})]})})},VertexTransformNumericField=({bottomLabel:t,value:a,step:s,min:i,max:r,disabled:l,testId:c,onBlur:d,onInput:u,onChange:m})=>{const p=o.useRef(null),h=n.useRecoilValue(_t),[f,g]=o.useState(!0);o.useEffect((()=>{const e=null!=p.current&&Number.isNaN(p.current.valueAsNumber),t=f||e;null!=p.current&&t?p.current.value=a?.toFixed(Number(h))??"":g(!0)}),[a]);const v=o.useCallback((e=>{g(!1),m?.(e)}),[g,m]),b=o.useCallback((e=>{g(!0),d?.(e),null!=p.current&&null!=a&&(p.current.value=a.toFixed(Number(h)))}),[d,a,g]);return e.jsxs("div",{children:[e.jsx("div",{className:"truncate rounded-md w-full",children:e.jsx("input",{ref:p,className:"w-full truncate border border-neutral-400 rounded-md px-2 py-1.5 hover:border-neutral-500 focus:border-neutral-500 focus:outline-none",type:"number",step:s,min:i,max:r,"data-testid":c,disabled:l,defaultValue:Number.isNaN(a)?"":a?.toFixed(Number(h)),onBlur:b,onInput:u,onChange:v})}),null!=t&&e.jsx("div",{className:"flex justify-center items-center pointer-events-none text-neutral-500",children:e.jsx("span",{children:t})})]})},VertexTransformInputs=({onUpdateTransform:t})=>{const a=n.useRecoilValue(Lt),o=n.useRecoilValue(Vt),s=n.useRecoilValue(St),i=o||s,r=n.useRecoilValue(Tt),{transform:l,error:c,update:d}=useEditItemTransform(r),u=i?void 0:l,m=useDebouncedCallback((async e=>{await d(e),t?.(e)}),50);function updateTransform(e){return t=>{if(null!=u){const n=parseFloat(t.currentTarget.value);Number.isNaN(n)||m?.({...u,...e(n,u)})}}}function updatePosition(e){return updateTransform(((t,n)=>({position:{...n.position,...e(t)}})))}function updateRotation(e){return updateTransform(((t,n)=>({rotation:{...n.rotation,...e(t)}})))}function updateScale(){return updateTransform((e=>e>0?{scale:e}:{}))}function updateToDefaultValueIfInvalid(e,t){return n=>{const a=parseFloat(n.currentTarget.value),o=undefined;(isNaN(a)||!!t?.(a))&&null!=u&&m(v.defaults(e,u))}}return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 text-[0.8125rem]",children:[e.jsx("span",{className:"flex w-full items-center mt-3 mb-1",children:"Position"}),e.jsxs("div",{className:"flex flex-wrap w-full gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"X"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"position-x",value:null!=u?u.position.x:void 0,bottomLabel:a,disabled:null==u,onChange:updatePosition((e=>({x:e}))),onBlur:updateToDefaultValueIfInvalid({position:{x:0}})})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"Y"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"position-y",value:u?.position.y,bottomLabel:a,disabled:null==u,onChange:updatePosition((e=>({y:e}))),onBlur:updateToDefaultValueIfInvalid({position:{y:0}})})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"Z"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"position-z",value:u?.position.z,bottomLabel:a,disabled:null==u,onChange:updatePosition((e=>({z:e}))),onBlur:updateToDefaultValueIfInvalid({position:{z:0}})})})]})]})]}),e.jsxs("div",{className:"mb-2 text-[0.8125rem]",children:[e.jsx("span",{className:"flex w-full items-center mt-3 mb-1",children:"Rotation"}),e.jsxs("div",{className:"flex flex-wrap w-full gap-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"X"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"rotation-x",value:u?.rotation.x,bottomLabel:"deg",disabled:null==u,onChange:updateRotation((e=>({x:e}))),onBlur:updateToDefaultValueIfInvalid({rotation:{x:0}})})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"Y"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"rotation-y",value:u?.rotation.y,bottomLabel:"deg",disabled:null==u,onChange:updateRotation((e=>({y:e}))),onBlur:updateToDefaultValueIfInvalid({rotation:{y:0}})})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("span",{className:"pt-2",children:"Z"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"rotation-z",value:u?.rotation.z,bottomLabel:"deg",disabled:null==u,onChange:updateRotation((e=>({z:e}))),onBlur:updateToDefaultValueIfInvalid({rotation:{z:0}})})})]})]})]}),e.jsxs("div",{className:"mb-2 text-[0.8125rem]",children:[e.jsx("span",{className:"flex w-full items-center mt-3 mb-1",children:"Scale"}),e.jsx("div",{className:"w-26",children:e.jsx(VertexTransformNumericField,{testId:"scale",value:u?.scale,step:.1,min:.1,disabled:null==u,onChange:updateScale(),onBlur:updateToDefaultValueIfInvalid({scale:1},(e=>e<=0))})}),i&&e.jsx("div",{className:"bg-orange-100 rounded px-3 py-2 mt-6 mb-2",children:"Input based part transformation is not yet supported for multiple parts."}),null!=c&&e.jsx("div",{className:"bg-red-100 rounded px-3 py-2 mt-6 mb-2",children:"There was a problem retrieving data. Try selecting a different part."})]})]})},VertexTransformManipulatorToggle=({onToggleTransformsManipulator:t})=>{const a=useTransformActions(),o=n.useRecoilValue(Ht),i=n.useSetRecoilState(Zt);return e.jsx(s.VertexToggle,{className:"flex items-center","data-testid":"transform-widget-toggle",variant:"switch",checked:o,onValueChanged:async()=>{o?(a.disableTransformWidget(),t?.(!1)):(i("world"),await a.enableTransformWidget(),t?.(!0))}})};function VertexTransformControls({onToggleTransformsManipulator:t,onUpdateTransform:n}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center py-3",children:[e.jsx(VertexTransformManipulatorToggle,{onToggleTransformsManipulator:t}),e.jsx("span",{className:"pl-4 text-[0.8125rem] text-neutral-700",children:"Enable manipulator"})]}),e.jsx(VertexTransformInputs,{onUpdateTransform:n})]})}function VertexTransformPanelSection({onClearTransforms:t,onClearAllTransforms:n,onToggleTransformsManipulator:a,onUpdateTransform:o}){return e.jsx(PanelSection,{header:e.jsxs("div",{className:"flex items-center text-base",children:["Manual Part Transforms",e.jsx(VertexTransformClear,{onClear:t,onClearAll:n})]}),children:e.jsx(VertexTransformControls,{onToggleTransformsManipulator:a,onUpdateTransform:o})})}function DefaultTransformsPanel(){return e.jsx("div",{className:"flex flex-col text-neutral-700 h-full overflow-y-auto",children:e.jsx(VertexTransformPanelSection,{})})}const $a="Appearance",qa="Model Views",Ya="Settings",Xa="Transforms",ViewerRightPanelHeader=({additionalHeaderMap:t})=>{const a=n.useRecoilValue(ea),o=getHeading(a,t),s="model-views"===a;return e.jsx("div",{className:"flex flex-col w-full items-center z-overlay pointer-events-none md:pointer-events-auto py-3 px-4 border-b border-neutral-300",children:e.jsxs("div",{className:"flex items-center w-full leading-6 text-md align-center font-medium text-neutral-800 gap-2",children:[o,s&&e.jsx(BetaLabel,{})]})})};function getHeading(e,t={}){switch(e){case"appearance":return $a;case"model-views":return qa;case"settings":return Ya;case"transforms":return Xa;default:const n=undefined;return(null!=e?t[e]:void 0)??"None"}}function VertexViewerRightOpenedPanel({children:t}){const a=n.useRecoilValue(ea),s=o.useMemo((()=>filterChildElements(t,CustomPanelContent)),[t]),i=o.useMemo((()=>s.reduce(((e,t)=>({...e,[t.props.panelName]:t.props.panelTitle})),{})),[s]),r=o.useMemo((()=>["appearance","model-views","settings","transforms",...s.map((e=>e.props.panelName))]),[s]);return e.jsx(e.Fragment,{children:null!=a&&r.includes(a)&&e.jsxs(VertexResizableContent,{displayShadow:!0,heading:e.jsx(ViewerRightPanelHeader,{additionalHeaderMap:i}),placement:"right",children:["appearance"===a&&e.jsx(DefaultAppearancePanel,{}),"transforms"===a&&e.jsx(DefaultTransformsPanel,{}),"settings"===a&&e.jsx(DefaultSettingsPanel,{}),"model-views"===a&&e.jsx(VertexModelViewsPanel,{}),t]})})}function CustomPanelContent({panelName:t,children:a}){const o=n.useRecoilValue(ea);return e.jsx(e.Fragment,{children:o===t&&a})}function Sidebar({children:t}){return e.jsx("div",{className:"pointer-events-auto flex flex-col items-center w-full border-neutral-300 py-2",children:t})}function SidebarIcon({name:t,iconName:n,active:a,responsive:i,disabled:r,content:l,tooltipPlacement:c,children:d,onSelect:u,onDeselect:m}){return e.jsx("div",{className:_e({"text-[var(--vertex-ui-blue-700)]":a===t&&!r,"text-neutral-700 hover:text-neutral-800":a!==t&&!r,"cursor-pointer hover:bg-neutral-200":!r,"text-neutral-400":r,"rounded-full md:p-3":i,"p-3":!i&&null==d,"px-3 py-1":null!=d}),"data-testid":`${t}-sidebar-panel`,onClick:()=>{r||(a===t?m():u())},children:e.jsxs(s.VertexTooltip,{placement:c??void 0,content:o.isValidElement(l)?void 0:l,children:[e.jsx("div",{slot:"content",children:l}),e.jsx("div",{className:"flex flex-col",children:d??e.jsx(s.VertexIcon,{name:n})})]})})}function VertexViewerRightSidebar({children:t}){const a=usePanelActions(),o=useTransformActions(),s=n.useRecoilValue(ea);return e.jsx("div",{className:"flex flex-col flex-shrink-0 items-center relative border-neutral-300 border-l bg-white h-full top-0 min-w-12 w-12",children:e.jsxs(Sidebar,{children:[t,e.jsx(SidebarIcon,{name:"appearance",active:s,iconName:"adjustments",tooltipPlacement:"right",content:"Appearance",onSelect:()=>{a.openPrimary("appearance","right")},onDeselect:()=>a.closePrimary("right")}),e.jsx(SidebarIcon,{name:"transforms",active:s,iconName:"show-only-nearby",tooltipPlacement:"right",content:"Transforms",onSelect:async()=>{a.openPrimary("transforms","right"),await o.enableTransformWidget(void 0,!0)},onDeselect:()=>a.closePrimary("right")}),e.jsx(SidebarIcon,{name:"model-views",active:s,iconName:"views",tooltipPlacement:"right",content:"Model Views",onSelect:async()=>{a.openPrimary("model-views","right")},onDeselect:()=>a.closePrimary("right")}),e.jsx(SidebarIcon,{name:"settings",active:s,iconName:"gear",tooltipPlacement:"right",content:"Settings",onSelect:()=>{a.openPrimary("settings","right")},onDeselect:()=>a.closePrimary("right")})]})})}function CustomPanelIcon(t){const a=usePanelActions(),o=n.useRecoilValue(ea),{panelName:s,tooltipContent:i,iconName:r,...l}=t;if(null==r&&null==l.children)throw new Error('CustomPanelIcon must contain either a Vertex "iconName" or custom "children"');return e.jsx(SidebarIcon,{...l,name:s,iconName:r??"help",active:o,content:i,onSelect:()=>{a.openPrimary(t.panelName,"right")},onDeselect:()=>{a.closePrimary("right")}})}VertexViewerRightOpenedPanel.CustomPanelContent=CustomPanelContent,VertexViewerRightSidebar.CustomPanelIcon=CustomPanelIcon;const VertexPopupButton=({open:t,children:n,...a})=>{const o=n.find((e=>e.type===Anchor)),i=n.filter((e=>e.type!==Anchor));return null==o?e.jsx(e.Fragment,{}):e.jsxs(s.VertexPopover,{className:"flex",placement:"top",backdrop:!1,open:asBooleanAttribute(t),...a,children:[o,e.jsx("div",{className:_e("flex mb-1.5",{hidden:!t}),"data-testid":"align-plane-popover-menu",children:i})]})},Anchor=({tooltipContent:t,children:n})=>e.jsx("div",{slot:"anchor",children:e.jsx(s.VertexTooltip,{className:"cursor-pointer",content:t,children:n})});function VertexViewerCrossSectionAlignmentPopoverMenu({disabled:t}){const a=useCrossSectioningActions(),o=n.useRecoilValue(Ve),i=n.useRecoilValue(xe),getBaseIcon=()=>`align-to-${i?.mode}`;return useStackKeyBinding({id:"CrossSectionAlignment",keyBind:"Escape",fn:a.cancelCurrentHit,addPredicate:()=>i?.hitPending??!1,cancelPredicate:()=>!i?.hitPending},[i?.hitPending]),e.jsxs(VertexPopupButton,{"data-testid":"section-alignment-popover",placement:"top",backdrop:!1,open:asBooleanAttribute(o),onDismissed:a.closeAlignmentTools,children:[e.jsx(VertexPopupButton.Anchor,{tooltipContent:"Section Alignment",children:e.jsx(s.VertexIconButton,{"data-testid":"section-alignment-icon-button",iconName:getBaseIcon(),iconColor:"secondary",onClick:o?a.closeAlignmentTools:a.openAlignmentTools,disabled:t,children:e.jsx(s.VertexIcon,{"data-testid":"section-alignment-icon-chevron",name:"chevron-up",size:"sm"})})}),e.jsxs(r.VertexViewerToolbarGroup,{direction:"vertical",className:"flex justify-evenly items-center py-1 my-1 ring-1 ring-neutral-200 rounded bg-neutral-100 opacity-95",children:[e.jsx(s.VertexIconButton,{iconColor:"secondary",onClick:()=>a.updateAlignment("global"),className:"w-full text-neutral-800 hover:bg-neutral-300 rounded cursor-pointer mx-0.5 py-1 px-2","data-testid":"section-alignment-align-global",iconName:"align-to-global",variant:"plain",children:e.jsx("div",{className:"text-base ml-2",children:"Align to Global"})}),e.jsx(s.VertexIconButton,{iconColor:"secondary",onClick:()=>a.updateAlignment("surface"),className:"w-full text-neutral-800 hover:bg-neutral-300 rounded cursor-pointer mx-0.5 py-1 px-2","data-testid":"section-alignment-align-surface",iconName:"align-to-surface",variant:"plain",children:e.jsx("div",{className:"text-base ml-2",children:"Align to Surface"})})]})]})}function VertexViewerCrossSectionAxisPopoverMenu({disabled:t}){const a=useCrossSectioningActions(),i=n.useRecoilValue(je),l=n.useRecoilValue(he),c=n.useRecoilValueLoadable(ve),d=o.useMemo((()=>{const e=l.length>0&&"hasValue"===c.state?axis(l[0],xAxis(c.contents),yAxis(c.contents),zAxis(c.contents)):"x";return null!=e?`axis-${e}`:"axis-x"}),[c.state,c.contents,l]);return e.jsxs(VertexPopupButton,{"data-testid":"align-plane-popover",placement:"top",backdrop:!1,open:asBooleanAttribute(i),onDismissed:a.closeAxisTools,children:[e.jsx(VertexPopupButton.Anchor,{tooltipContent:"Align Plane",children:e.jsx(s.VertexIconButton,{onClick:i?a.closeAxisTools:a.openAxisTools,iconName:d,"data-testid":"align-plane-icon",iconColor:"secondary",disabled:t,children:e.jsx(s.VertexIcon,{"data-testid":"align-plane-icon-chevron",name:"chevron-up",size:"sm"})})}),e.jsxs(r.VertexViewerToolbarGroup,{direction:"vertical",className:"flex justify-evenly items-center py-1 my-1 ring-1 ring-neutral-200 rounded bg-neutral-100 opacity-95",children:[e.jsx(s.VertexIconButton,{"data-testid":"align-plane-x-axis-button",className:"w-full text-neutral-800 hover:bg-neutral-300 rounded cursor-pointer mx-0.5 py-1 px-2",onClick:()=>a.updateAxis("x"),variant:"plain",iconColor:"secondary",iconName:"axis-x",children:e.jsx("div",{className:"text-base ml-2",children:"X-axis Plane"})}),e.jsx(s.VertexIconButton,{className:"w-full text-neutral-800 hover:bg-neutral-300 rounded cursor-pointer mx-0.5 py-1 px-2",variant:"plain",iconColor:"secondary",iconName:"axis-y","data-testid":"align-plane-y-axis-button",onClick:()=>a.updateAxis("y"),children:e.jsx("div",{className:"text-base ml-2",children:"Y-axis Plane"})}),e.jsx(s.VertexIconButton,{"data-testid":"align-plane-z-axis-button",className:"w-full text-neutral-800 hover:bg-neutral-300 rounded cursor-pointer mx-0.5 py-1 px-2",onClick:()=>a.updateAxis("z"),variant:"plain",iconColor:"secondary",iconName:"axis-z",children:e.jsx("div",{className:"text-base ml-2",children:"Z-axis Plane"})})]})]})}function VertexViewerCrossSectionOffsetStepper({offset:t,disabled:a,onOffsetChange:i}){const r=n.useRecoilValue(Lt),l=n.useRecoilValue(_t),[c,d]=o.useState(convertTo(t,r));o.useEffect((()=>{d(convertTo(t,r))}),[r,t]);const u=createDistanceFormatter(r,parseInt(l,10)),handleIncrementalUpdate=e=>{const t=convertFrom(c+e,r);i(t)},handleSubmit=e=>{e.preventDefault(),i(convertFrom(c,r))},handleBlur=()=>{i(convertFrom(c,r))};return e.jsx(s.VertexTooltip,{content:"Plane Offset",children:e.jsx("form",{"data-testid":"cross-section-stepper-form",onSubmit:handleSubmit,children:e.jsxs(s.VertexTextfield,{"data-testid":"cross-section-stepper-input",className:"viewer-toolbar-input w-32 border-none ring-0 bg-white",type:"text",value:u(parseFloat(t.toFixed(3))),onInputInput:e=>{d(null!=e.detail.value?parseFloat(e.detail.value):t)},onBlur:handleBlur,disabled:a,children:[e.jsx("div",{"data-testid":"cross-section-stepper-decrement",className:"py-1 cursor-pointer",slot:"left",onClick:()=>{a||handleIncrementalUpdate(-1)},children:e.jsx(s.VertexIcon,{name:"chevron-left",size:"sm"})}),e.jsx("div",{"data-testid":"cross-section-stepper-increment",className:"py-1 cursor-pointer",slot:"right",onClick:()=>{a||handleIncrementalUpdate(1)},children:e.jsx(s.VertexIcon,{name:"chevron-right",size:"sm"})})]})})})}VertexPopupButton.Anchor=Anchor;const Za=400;function VertexViewerCrossSectionPopupMenu(){const t=useCrossSectioningActions(),a=n.useRecoilValue(Se),i=n.useRecoilValueLoadable(we),l=n.useRecoilValueLoadable(Ce),c=o.useRef(),d=o.useMemo((()=>"hasValue"===i.state&&Number.isFinite(i.contents.max)&&Number.isFinite(i.contents.min)),[i.state,i.contents]),u=o.useMemo((()=>"hasValue"===i.state?i.contents:ie),[i.state,i.contents]),m=o.useMemo((()=>"hasValue"===l.state&&Number.isFinite(l.contents)?l.contents:0),[l.state,l.contents]),handleCrossSectionValueChange=e=>{clearTimeout(c.current),c.current=window.setTimeout((()=>{t.endInteraction()}),Za),t.beginInteraction(),t.updatePlanes(e)};return e.jsxs(VertexPopupButton,{"data-testid":"cross-section-popover",placement:"top",backdrop:!1,open:asBooleanAttribute(a),onDismissed:t.closeAdditionalTools,children:[e.jsx(VertexPopupButton.Anchor,{tooltipContent:"Section Tools",children:e.jsx("div",{className:"-ml-px py-1.5",children:e.jsx(s.VertexIcon,{"data-testid":"cross-section-popover-icon",name:"chevron-up",size:"sm",onClick:a?t.closeAdditionalTools:t.openAdditionalTools})})}),e.jsxs(r.VertexViewerToolbarGroup,{className:"relative bottom-3 flex justify-evenly items-center p-1 ring-1 ring-neutral-200 rounded bg-neutral-100 opacity-95",children:[e.jsx(VertexViewerCrossSectionAlignmentPopoverMenu,{disabled:!d}),e.jsx(s.VertexTooltip,{className:"w-auto",content:"Reverse",children:e.jsx(s.VertexIconButton,{iconName:"flip","data-testid":"viewer-toolbar-flip-button",onClick:t.flipPlanes,iconColor:"secondary",disabled:!d})}),e.jsx(s.VertexTooltip,{className:"w-auto",content:"Align View to Plane",children:e.jsx(s.VertexIconButton,{"data-testid":"viewer-toolbar-align-view-to-plane-button",iconName:"align-view-to-plane",onClick:t.alignViewToPlane,iconColor:"secondary",disabled:!d})}),e.jsx(VertexToolbarDivider,{}),e.jsx(VertexViewerCrossSectionAxisPopoverMenu,{disabled:!d}),e.jsx("div",{className:"w-52 mx-2",children:e.jsx(VertexSlider,{value:m,defaultValue:u.default,disabled:asBooleanAttribute("hasValue"!==i.state)||!d,min:u.min,max:u.max,step:.01,onChange:handleCrossSectionValueChange})}),e.jsx("div",{className:"px-4",children:e.jsx(VertexViewerCrossSectionOffsetStepper,{offset:"hasValue"===l.state&&d?l.contents:0,disabled:!d,onOffsetChange:handleCrossSectionValueChange})})]})]})}const VertexViewerCrossSectionButton=()=>{const t=useCrossSectioningActions(),a=n.useRecoilValue(re);return e.jsxs(e.Fragment,{children:[e.jsx(s.VertexTooltip,{content:a?"Hide Section":"Show Section",children:e.jsx(s.VertexIconButton,{"data-testid":"viewer-toolbar-cross-section-button",iconName:"cross-section",iconColor:a?"primary":"secondary",onClick:()=>a?t.disable():t.enable()})}),e.jsx(VertexViewerCrossSectionPopupMenu,{})]})},VertexFitAllButton=()=>{const t=n.useRecoilValue(G);return e.jsx(s.VertexTooltip,{content:"Fit All",children:e.jsx(s.VertexIconButton,{iconName:"fit-all",iconColor:"secondary","data-testid":"viewer-toolbar-fit-all-button",onClick:async()=>{const e=await(t?.scene());await(e?.camera().viewAll().render({animation:{milliseconds:500}}))}})})},VertexPanButton=()=>{const t=n.useRecoilValue(G),a=n.useRecoilValue($),[i,r]=n.useRecoilState(Y),[l,c]=n.useRecoilState(q);return o.useEffect((()=>{null!=t&&a&&c(t.getBaseInteractionHandler())}),[t,a,c]),e.jsx(s.VertexTooltip,{content:"Pan",children:e.jsx(s.VertexIconButton,{iconName:"pan",iconColor:"pan"===i?"primary":"secondary","data-testid":"viewer-toolbar-pan-button",onClick:async()=>{if(r("pan"),null!=l){const e=await l;e?.setPrimaryInteractionType("pan")}}})})},VertexRotateButton=()=>{const t=n.useRecoilValue(G),a=n.useRecoilValue($),[i,r]=n.useRecoilState(Y),[l,c]=n.useRecoilState(q);return o.useEffect((()=>{null!=t&&a&&c(t.getBaseInteractionHandler())}),[t,a,c]),e.jsx(s.VertexTooltip,{content:"Rotate",children:e.jsx(s.VertexIconButton,{iconName:"rotate",iconColor:"rotate"===i?"primary":"secondary","data-testid":"viewer-toolbar-rotate-button",onClick:async()=>{if(r("rotate"),null!=l){const e=await l;e?.setPrimaryInteractionType("rotate")}}})})},VertexZoomButton=()=>{const t=n.useRecoilValue(G),a=n.useRecoilValue($),[i,r]=n.useRecoilState(Y),[l,c]=n.useRecoilState(q);return o.useEffect((()=>{null!=t&&a&&c(t.getBaseInteractionHandler())}),[t,a,c]),e.jsx(s.VertexTooltip,{content:"Zoom",children:e.jsx(s.VertexIconButton,{iconName:"zoom",iconColor:"zoom"===i?"primary":"secondary","data-testid":"viewer-toolbar-zoom-button",onClick:async()=>{if(r("zoom"),null!=l){const e=await l;e?.setPrimaryInteractionType("zoom")}}})})},DefaultToolbar=()=>e.jsx(r.VertexViewerToolbar,{placement:"bottom-center",children:e.jsxs(r.VertexViewerToolbarGroup,{className:"p-1 border border-neutral-200 rounded bg-neutral-100 opacity-95",children:[e.jsx(VertexRotateButton,{}),e.jsx(VertexPanButton,{}),e.jsx(VertexZoomButton,{}),e.jsx(VertexFitAllButton,{}),e.jsx(VertexToolbarDivider,{}),e.jsx(VertexBoxSelectionButton,{}),e.jsx(VertexToolbarDivider,{}),e.jsx(VertexViewerCrossSectionButton,{}),e.jsx(VertexToolbarDivider,{}),e.jsx(VertexPointToPointMeasurementTool,{}),e.jsx(VertexPreciseMeasurementTool,{})]})}),VertexToolbar=({endCapEnabledByDefault:t,children:a})=>{const s=n.useSetRecoilState(ue),i=n.useSetRecoilState(de);o.useEffect((()=>{null!=t&&(s(t),i(t))}),[t]);const l=null!=a&&!1!==a;return e.jsx(r.VertexViewerToolbar,{placement:"bottom-center",children:l?e.jsx(r.VertexViewerToolbarGroup,{className:"p-1 border border-neutral-200 rounded bg-neutral-100 opacity-95",children:a}):e.jsx(DefaultToolbar,{})})};function VertexTransformWidget({transformWidgetElement:t,supportUndo:a,onPositionChange:s,onRotationChange:i}){const l=useTransformActions(),c=n.useRecoilValue($t),d=n.useRecoilValue(Ht),u=n.useRecoilValue(Ut),m=n.useRecoilValue(Kt),p=n.useRecoilValueLoadable(Gt),h=n.useRecoilValue(Lt),f=n.useRecoilValue(_t),g=o.useMemo((()=>"hasValue"===p.state?p.contents:m),[p,m]),v=o.useMemo((()=>{const e=undefined;return d&&(null!=g||c)}),[d,g,c]);return e.jsx(e.Fragment,{children:v&&e.jsx(r.VertexViewerTransformWidget,{id:"transform-widget","data-testid":"viewer-transform-widget",ref:t,position:u,rotation:null!=u?g:void 0,decimalPlaces:parseInt(f,10),distanceUnit:toUnitType(h),EXPERIMENTAL_undoKeybindings:a??!0,onInteractionStarted:()=>{l.disableSelectionSync(),l.setIsInteractivelyTransforming(!0)},onInteractionEnded:()=>{l.invalidateTransforms(),l.setIsInteractivelyTransforming(!1)},onPositionChanged:async e=>{await l.setTransformWidgetPosition(e.detail),s?.(e.detail)},onRotationChanged:e=>{l.setTransformWidgetOrientation(e.detail),i?.(e.detail)}})})}const VertexViewerSceneReset=({onReset:t})=>{const a=useCrossSectioningActions(),o=useModelViewActions(),i=useSelectionActions(),r=useTransformActions(),l=useViewerSceneActions(),c=n.useSetRecoilState(Nt),handleReset=async()=>{await a.disable(),await i.resetSelectionState(),r.clearTransformWidgetPosition(),await r.invalidateTransforms(),c(void 0),await o.clearModelView(),t?.(),await l.reset()};return e.jsx(s.VertexTooltip,{content:"Reset View",children:e.jsx(s.VertexIconButton,{iconName:"reset",className:"flex bg-white opacity-70 hover:opacity-100 text-neutral-900 hover:text-neutral-700 hover:bg-neutral-200 rounded p-1 cursor-pointer","data-testid":"viewer-reset-tool-button",onClick:handleReset,variant:"plain"})})};function useViewerFrameActions(){const e=useTransformActions();return{frameDrawn:useActionCallback((({set:t,snapshot:n})=>async a=>{const o=await n.getPromise(Pt);t(Z,a.detail.scene),t(Pt,a.detail.scene.sceneViewSummary.selectedVisibleSummary),t(At,o);const s=undefined;await n.getPromise(Ht)&&await e.syncToSelection()}))}}const VertexBoxSelectionTool=()=>{const{element:t,callback:a}=useCallbackRef(),o=useBoxSelectionActions(),s=useTransformActions(),i=n.useRecoilValue(Xe);return u.useEffect((()=>{const e=whenComponentReady(t,(()=>[t?.model?.onDragComplete((()=>{"clearAndSelect"===i&&(s.clearTransformWidgetOrientation(),s.clearTransformWidgetPosition(),s.enableSelectionSync())}))]));return()=>{e?.then((e=>{e?.forEach((e=>e?.dispose()))}))}}),[t,i]),useApplyKeyBinding({keyBind:"Shift",fn:u.useCallback((()=>o.setOperationType("select")),[]),off:u.useCallback((()=>o.setOperationType("clearAndSelect")),[])}),e.jsx(r.VertexViewerBoxQueryTool,{ref:a,"data-testid":"viewer-box-query-tool",operationType:i})};function VertexViewerCameraTypeMenu({open:t,onOpen:a,onDismiss:o,onCameraTypeChange:i}){const r=useViewerCameraActions(),l=n.useRecoilValue(W);return e.jsxs(s.VertexMenu,{"data-testid":"camera-types-popover",className:"flex",placement:"bottom-end",open:asBooleanAttribute(t),onMenuClosed:o,children:[e.jsx("div",{slot:"anchor",children:e.jsx("div",{className:_e("flex bg-white hover:opacity-100 hover:text-neutral-700 hover:bg-neutral-200 rounded",{"opacity-70 text-neutral-900":!t,"opacity-100 text-neutral-700 bg-neutral-200":t}),children:e.jsx(s.VertexTooltip,{content:"Change View",children:e.jsx(s.VertexIconButton,{"data-testid":"set-camera-mode-option",className:"p-1 cursor-pointer",variant:"plain",onClick:a,iconName:"orthographic"===l?"cube-orthographic":"cube-perspective",children:e.jsx(s.VertexIcon,{"data-testid":"change-camera-type-icon-button",name:"chevron-down",size:"sm"})})})})}),e.jsxs("div",{className:"w-36",children:[e.jsx("div",{className:"pt-1"}),e.jsxs(s.VertexMenuItem,{"data-testid":"set-perspective-view",onClick:()=>{r.updateCameraType("perspective",!0),i?.("perspective")},children:[e.jsx(s.VertexIcon,{slot:"icon","data-testid":"set-perspective-view-icon",name:"cube-perspective",size:"sm",className:_e({"text-[var(--vertex-ui-blue-700)]":"perspective"===l})}),e.jsx("div",{className:_e("ml-2 items-center",{"text-[var(--vertex-ui-blue-700)]":"perspective"===l}),children:"Perspective"})]}),e.jsxs(s.VertexMenuItem,{"data-testid":"set-orthographic-view",onClick:()=>{r.updateCameraType("orthographic",!0),i?.("orthographic")},children:[e.jsx(s.VertexIcon,{slot:"icon","data-testid":"set-orthographic-view-icon",name:"cube-orthographic",size:"sm",className:_e({"text-[var(--vertex-ui-blue-700)]":"orthographic"===l})}),e.jsx("div",{className:_e("ml-2 items-center",{"text-[var(--vertex-ui-blue-700)]":"orthographic"===l}),children:"Orthographic"})]})]})]})}const VertexViewerViewCube=({placement:t,children:n,...a})=>{const s=Array.isArray(n)?n:[n],i=s.filter((e=>!o.isValidElement(e)||e.type!==r.VertexViewerViewCube)).filter((e=>null!=e&&!1!==e)),l=s.find((e=>o.isValidElement(e)&&e.type===r.VertexViewerViewCube)),[c,d]=o.useState(!1);return e.jsxs(r.VertexViewerToolbar,{direction:"vertical","data-testid":"view-cube-toolbar",placement:t??"top-right",children:[l??e.jsx(r.VertexViewerViewCube,{className:"m-7",...a}),0===i.length?e.jsxs("div",{className:"flex items-center justify-center mt-3 gap-1",children:[e.jsx(VertexViewerSceneReset,{}),e.jsx(VertexViewerCameraTypeMenu,{open:c,onDismiss:()=>d(!1),onOpen:()=>d(!0)})]}):e.jsx("div",{className:"mt-3",children:i})]})},VertexViewer=({id:t,src:a,className:s,disableSelection:i,onTap:l,onLongpress:c,onFrameDrawn:d,onSceneReady:u,viewerRefCallback:m,children:p,...h})=>{const f=n.useRecoilValue(ga),g=useRecoilRef({state:G}),v=useViewerCameraActions(),b=useCrossSectioningActions(),w=useHitActions(),C=useSelectionActions(),S=useViewerFrameActions(),V=n.useRecoilValue(W),j=n.useRecoilValue(xe),k=n.useRecoilValue(Ye),T=n.useSetRecoilState(X),[A,P]=n.useRecoilState($);o.useEffect((()=>{A&&(P(!1),b.disable())}),[a]);const[I,M]=n.useRecoilState(K);o.useEffect((()=>{null!=t&&M(t)}),[t]);const E=n.useRecoilValue(ma),R=o.useMemo((()=>({opacity:E/100})),[E]),N=n.useRecoilValue(ze),O=n.useRecoilValue(Fe),L=o.useMemo((()=>({color:N,width:O})),[N,O]),_=n.useRecoilValue(ue),B=n.useRecoilValue(me),D=n.useRecoilValue(pe),F=o.useMemo((()=>({endCapEnabled:_,endCapUsePartColor:B===ne.PART,..._&&B===ne.SINGLE&&{endCapColor:D}})),[_,B,D]),H=n.useRecoilValue(qn),U=n.useRecoilValue(Wn),q=n.useRecoilValue(Gn),Y=n.useRecoilValue(Kn),Z=o.useMemo((()=>({color:U,opacity:q/100,lineWidth:Y})),[U,q,Y]),J=n.useRecoilValue(nt),Q=null!=p&&!1!==p;return useKeyBindings(),useDefaultKeybindings(),e.jsxs(r.VertexViewer,{id:I,"data-testid":"vertex-viewer",src:a,ref:e=>{m?.(e),g(e)},className:_e("flex w-full h-full",s,{"cursor-crosshair":j.hitPending}),style:{"--viewer-background":H},config:f,cameraType:A?V:void 0,onCameraTypeChanged:e=>{A&&v.updateCameraType(e.detail,!1)},phantom:R,featureLines:L,selectionHighlighting:Z,crossSectioning:F,featureMaps:J?"final":void 0,onTap:e=>{const t=[...i?[]:[C.selectCurrentHit]];w.tap(e,...t),l?.(e)},onLongpress:e=>{w.longPress(e),c?.(e)},onFrameDrawn:e=>{S.frameDrawn(e),d?.(e)},onSceneReady:async e=>{if(!A){P(!0);const t=await(e?.target?.scene());T(t?.sceneViewId)}u?.(e)},...h,children:[k&&e.jsx(VertexBoxSelectionTool,{}),Q?p:e.jsxs(e.Fragment,{children:[e.jsx(VertexViewerViewCube,{}),e.jsx(VertexToolbar,{}),e.jsx(VertexViewerContextMenu,{})]})]})};function toSdkConfig(e){return isOnlyNetworkConfig(e)?{network:e}:e}function isOnlyNetworkConfig(e){const t=undefined;return null!=e.renderingHost}const VertexViewerToolkitEventListener=({onHitStateChange:t,onSelectionStateChange:a})=>{const s=n.useRecoilValue(on),i=n.useRecoilValue(Tn);return o.useEffect((()=>{t?.(s)}),[s,t]),o.useEffect((()=>{a?.(i)}),[i,a]),e.jsx(e.Fragment,{})},VertexViewerToolkitRoot=({override:t,autoDefineCustomElements:a,children:s,config:i,...r})=>(o.useEffect((()=>{(null==a||a)&&(d.defineCustomElements(),c.defineCustomElements())}),[a]),e.jsx(n.RecoilRoot,{override:t,children:e.jsxs(e.Fragment,{children:[e.jsx(VertexViewerToolkitEventListener,{...r}),e.jsx(VertexViewerToolkitRootConfig,{config:i,children:s})]})})),VertexViewerToolkitRootConfig=({config:t,children:a})=>{const s=n.useSetRecoilState(ga);return o.useEffect((()=>{const e=null!=t?toSdkConfig(t):void 0;s(e)}),[t,s]),e.jsx(e.Fragment,{children:a})};var Ja=Object.freeze({__proto__:null,get AssemblyFontFace(){return za},Columns:Ia,Core:kn,Metadata:Ua,Search:Da});exports.Appearance=Yn,exports.BoxSelection=Ze,exports.Config=ya,exports.ContextMenu=qe,exports.CrossSection=Ne,exports.Ghosting=fa,exports.Hits=sn,exports.Keybinding=Jn,exports.Measurement=pt,exports.Messages=H,exports.Metadata=da,exports.ModelViews=Ka,exports.Panel=na,exports.Performance=ft,exports.SceneTree=Ja,exports.SceneViewItem=Ot,exports.Selection=An,exports.Settings=Bt,exports.Transforms=an,exports.VertexApplicationMessages=VertexApplicationMessages,exports.VertexBoxSelectionButton=VertexBoxSelectionButton,exports.VertexContextMenu=VertexContextMenu,exports.VertexCrossSectionAppearanceColorPicker=VertexCrossSectionAppearanceColorPicker,exports.VertexCrossSectionAppearanceControls=VertexCrossSectionAppearanceControls,exports.VertexCrossSectionAppearanceLineThicknessSlider=VertexCrossSectionAppearanceLineThicknessSlider,exports.VertexCrossSectionAppearancePanelSection=VertexCrossSectionAppearancePanelSection,exports.VertexCrossSectionAppearanceReset=VertexCrossSectionAppearanceReset,exports.VertexDecimalPlaceSelector=VertexDecimalPlaceSelector,exports.VertexFeatureEdgesColorPicker=VertexFeatureEdgesColorPicker,exports.VertexFeatureEdgesControls=VertexFeatureEdgesControls,exports.VertexFeatureEdgesPanelSection=VertexFeatureEdgesPanelSection,exports.VertexFeatureEdgesReset=VertexFeatureEdgesReset,exports.VertexFeatureEdgesThicknessSlider=VertexFeatureEdgesThicknessSlider,exports.VertexFitAllButton=VertexFitAllButton,exports.VertexFitSelectedMenuItem=VertexFitSelectedMenuItem,exports.VertexFlyToMenuItem=VertexFlyToMenuItem,exports.VertexGhostingControls=VertexGhostingControls,exports.VertexGhostingPanelSection=VertexGhostingPanelSection,exports.VertexHideAllMenuItem=VertexHideAllMenuItem,exports.VertexHidePartMenuItem=VertexHidePartMenuItem,exports.VertexHideSelectedMenuItem=VertexHideSelectedMenuItem,exports.VertexLengthUnitSelector=VertexLengthUnitSelector,exports.VertexMaterialControls=VertexMaterialControls,exports.VertexMaterialPanelSection=VertexMaterialPanelSection,exports.VertexMeasurementContextMenu=VertexMeasurementContextMenu,exports.VertexMeasurementDetails=VertexMeasurementDetails,exports.VertexModelViewsPanel=VertexModelViewsPanel,exports.VertexPanButton=VertexPanButton,exports.VertexPointToPointMeasurement=VertexPointToPointMeasurement,exports.VertexPointToPointMeasurementTool=VertexPointToPointMeasurementTool,exports.VertexPreciseMeasurement=VertexPreciseMeasurement,exports.VertexPreciseMeasurementTool=VertexPreciseMeasurementTool,exports.VertexResizableContent=VertexResizableContent,exports.VertexRotateButton=VertexRotateButton,exports.VertexSceneItemGhostingClear=VertexSceneItemGhostingClear,exports.VertexSceneItemGhostingOpacitySlider=VertexSceneItemGhostingOpacitySlider,exports.VertexSceneItemGhostingToggle=VertexSceneItemGhostingToggle,exports.VertexSceneItemMaterialClear=VertexSceneItemMaterialClear,exports.VertexSceneItemMaterialColorPicker=VertexSceneItemMaterialColorPicker,exports.VertexSceneItemMaterialColorSwatches=VertexSceneItemMaterialColorSwatches,exports.VertexSceneItemMaterialOpacitySlider=VertexSceneItemMaterialOpacitySlider,exports.VertexSceneTree=VertexSceneTree,exports.VertexSceneTreeColumnPopover=VertexSceneTreeColumnPopover,exports.VertexSceneTreeContextMenu=VertexSceneTreeContextMenu,exports.VertexSceneTreeCustomColumn=VertexSceneTreeCustomColumn,exports.VertexSceneTreeHeader=VertexSceneTreeHeader,exports.VertexSceneTreeMetadataColumns=VertexSceneTreeMetadataColumns,exports.VertexSceneTreeSearchBar=VertexSceneTreeSearchBar,exports.VertexSceneTreeSearchInformationForToolbar=VertexSceneTreeSearchInformationForToolbar,exports.VertexSceneTreeSearchOptionsPopover=VertexSceneTreeSearchOptionsPopover,exports.VertexSceneTreeTableLayout=VertexSceneTreeTableLayout,exports.VertexSelectionHighlightingColorPicker=VertexSelectionHighlightingColorPicker,exports.VertexSelectionHighlightingControls=VertexSelectionHighlightingControls,exports.VertexSelectionHighlightingLineThicknessSlider=VertexSelectionHighlightingLineThicknessSlider,exports.VertexSelectionHighlightingOpacitySlider=VertexSelectionHighlightingOpacitySlider,exports.VertexSelectionHighlightingPanelSection=VertexSelectionHighlightingPanelSection,exports.VertexSelectionHighlightingReset=VertexSelectionHighlightingReset,exports.VertexShowAllMenuItem=VertexShowAllMenuItem,exports.VertexShowOnlyMenuItem=VertexShowOnlyMenuItem,exports.VertexShowOnlySelectedMenuItem=VertexShowOnlySelectedMenuItem,exports.VertexShowPropertiesMenuItem=VertexShowPropertiesMenuItem,exports.VertexToolbar=VertexToolbar,exports.VertexToolbarDivider=VertexToolbarDivider,exports.VertexTransformClear=VertexTransformClear,exports.VertexTransformControls=VertexTransformControls,exports.VertexTransformInputs=VertexTransformInputs,exports.VertexTransformManipulatorToggle=VertexTransformManipulatorToggle,exports.VertexTransformPanelSection=VertexTransformPanelSection,exports.VertexTransformWidget=VertexTransformWidget,exports.VertexUnitsControls=VertexUnitsControls,exports.VertexUnitsPanelSection=VertexUnitsPanelSection,exports.VertexViewer=VertexViewer,exports.VertexViewerBackgroundColorPicker=VertexViewerBackgroundColorPicker,exports.VertexViewerBackgroundControls=VertexViewerBackgroundControls,exports.VertexViewerBackgroundPanelSection=VertexViewerBackgroundPanelSection,exports.VertexViewerBackgroundReset=VertexViewerBackgroundReset,exports.VertexViewerContextMenu=VertexViewerContextMenu,exports.VertexViewerCrossSectionButton=VertexViewerCrossSectionButton,exports.VertexViewerRightOpenedPanel=VertexViewerRightOpenedPanel,exports.VertexViewerRightSidebar=VertexViewerRightSidebar,exports.VertexViewerSceneReset=VertexViewerSceneReset,exports.VertexViewerToolkitRoot=VertexViewerToolkitRoot,exports.VertexViewerViewCube=VertexViewerViewCube,exports.VertexZoomButton=VertexZoomButton,exports.Viewer=Q;
|
|
19
19
|
//# sourceMappingURL=bundle.cjs.js.map
|