architwin 1.0.9
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/README.md +530 -0
- package/bundle/LICENSE.md +17 -0
- package/bundle/css/core.css +21 -0
- package/bundle/css/late.css +22 -0
- package/bundle/css/showcase.css +406 -0
- package/bundle/css/unsupported_browser.css +1 -0
- package/bundle/cursors/grab.png +0 -0
- package/bundle/cursors/grabbing.png +0 -0
- package/bundle/cursors/rbe-default.png +0 -0
- package/bundle/cursors/rbe-finish-room.png +0 -0
- package/bundle/cursors/rbe-moving.png +0 -0
- package/bundle/cursors/rbe-place-door.png +0 -0
- package/bundle/cursors/rbe-place-node.png +0 -0
- package/bundle/cursors/rbe-place-opening.png +0 -0
- package/bundle/cursors/zoom-in.png +0 -0
- package/bundle/cursors/zoom-out.png +0 -0
- package/bundle/fonts/ibm-plex-sans-100.woff +0 -0
- package/bundle/fonts/ibm-plex-sans-100.woff2 +0 -0
- package/bundle/fonts/ibm-plex-sans-100italic.woff +0 -0
- package/bundle/fonts/ibm-plex-sans-100italic.woff2 +0 -0
- package/bundle/fonts/ibm-plex-sans-200.woff +0 -0
- package/bundle/fonts/ibm-plex-sans-200.woff2 +0 -0
- package/bundle/fonts/ibm-plex-sans-200italic.woff +0 -0
- package/bundle/fonts/ibm-plex-sans-200italic.woff2 +0 -0
- package/bundle/fonts/ibm-plex-sans-300.woff +0 -0
- package/bundle/fonts/ibm-plex-sans-300.woff2 +0 -0
- package/bundle/fonts/ibm-plex-sans-300italic.woff +0 -0
- package/bundle/fonts/ibm-plex-sans-300italic.woff2 +0 -0
- package/bundle/fonts/ibm-plex-sans-500.woff +0 -0
- package/bundle/fonts/ibm-plex-sans-500.woff2 +0 -0
- package/bundle/fonts/ibm-plex-sans-500italic.woff +0 -0
- package/bundle/fonts/ibm-plex-sans-500italic.woff2 +0 -0
- package/bundle/fonts/ibm-plex-sans-600.woff +0 -0
- package/bundle/fonts/ibm-plex-sans-600.woff2 +0 -0
- package/bundle/fonts/ibm-plex-sans-600italic.woff +0 -0
- package/bundle/fonts/ibm-plex-sans-600italic.woff2 +0 -0
- package/bundle/fonts/ibm-plex-sans-700.woff +0 -0
- package/bundle/fonts/ibm-plex-sans-700.woff2 +0 -0
- package/bundle/fonts/ibm-plex-sans-700italic.woff +0 -0
- package/bundle/fonts/ibm-plex-sans-700italic.woff2 +0 -0
- package/bundle/fonts/ibm-plex-sans-italic.woff +0 -0
- package/bundle/fonts/ibm-plex-sans-italic.woff2 +0 -0
- package/bundle/fonts/ibm-plex-sans-regular.woff +0 -0
- package/bundle/fonts/ibm-plex-sans-regular.woff2 +0 -0
- package/bundle/fonts/mp-font.svg +2079 -0
- package/bundle/fonts/mp-font.woff +0 -0
- package/bundle/fonts/mp-font.woff2 +0 -0
- package/bundle/fonts/roboto-100.woff +0 -0
- package/bundle/fonts/roboto-100.woff2 +0 -0
- package/bundle/fonts/roboto-100italic.woff +0 -0
- package/bundle/fonts/roboto-100italic.woff2 +0 -0
- package/bundle/fonts/roboto-300.woff +0 -0
- package/bundle/fonts/roboto-300.woff2 +0 -0
- package/bundle/fonts/roboto-300italic.woff +0 -0
- package/bundle/fonts/roboto-300italic.woff2 +0 -0
- package/bundle/fonts/roboto-500.woff +0 -0
- package/bundle/fonts/roboto-500.woff2 +0 -0
- package/bundle/fonts/roboto-500italic.woff +0 -0
- package/bundle/fonts/roboto-500italic.woff2 +0 -0
- package/bundle/fonts/roboto-700.woff +0 -0
- package/bundle/fonts/roboto-700.woff2 +0 -0
- package/bundle/fonts/roboto-700italic.woff +0 -0
- package/bundle/fonts/roboto-700italic.woff2 +0 -0
- package/bundle/fonts/roboto-900.woff +0 -0
- package/bundle/fonts/roboto-900.woff2 +0 -0
- package/bundle/fonts/roboto-900italic.woff +0 -0
- package/bundle/fonts/roboto-900italic.woff2 +0 -0
- package/bundle/fonts/roboto-italic.woff +0 -0
- package/bundle/fonts/roboto-italic.woff2 +0 -0
- package/bundle/fonts/roboto-regular.woff +0 -0
- package/bundle/fonts/roboto-regular.woff2 +0 -0
- package/bundle/images/360_placement_pin_mask.png +0 -0
- package/bundle/images/Desktop-help-play-button.svg +1 -0
- package/bundle/images/Desktop-help-spacebar.png +0 -0
- package/bundle/images/MP-logo_H_lock-RGB_color-black.svg +24 -0
- package/bundle/images/NoteColor.png +0 -0
- package/bundle/images/chrome.png +0 -0
- package/bundle/images/edge.png +0 -0
- package/bundle/images/escape.png +0 -0
- package/bundle/images/exterior.png +0 -0
- package/bundle/images/exterior_hover.png +0 -0
- package/bundle/images/firefox.png +0 -0
- package/bundle/images/headset-quest-2.png +0 -0
- package/bundle/images/interior.png +0 -0
- package/bundle/images/interior_hover.png +0 -0
- package/bundle/images/login-screen-background.jpg +0 -0
- package/bundle/images/matterport-app-icon.svg +9 -0
- package/bundle/images/matterport-logo-light.svg +1 -0
- package/bundle/images/mattertag-disc-128-free.v1.png +0 -0
- package/bundle/images/mobile-help-play-button.svg +1 -0
- package/bundle/images/nav_help_360.png +0 -0
- package/bundle/images/nav_help_click_inside.png +0 -0
- package/bundle/images/nav_help_gesture_drag.png +0 -0
- package/bundle/images/nav_help_gesture_drag_two_finger.png +0 -0
- package/bundle/images/nav_help_gesture_pinch.png +0 -0
- package/bundle/images/nav_help_gesture_position.png +0 -0
- package/bundle/images/nav_help_gesture_position_two_finger.png +0 -0
- package/bundle/images/nav_help_gesture_tap.png +0 -0
- package/bundle/images/nav_help_inside_key.png +0 -0
- package/bundle/images/nav_help_keyboard_all.png +0 -0
- package/bundle/images/nav_help_keyboard_left_right.png +0 -0
- package/bundle/images/nav_help_keyboard_up_down.png +0 -0
- package/bundle/images/nav_help_mouse_click.png +0 -0
- package/bundle/images/nav_help_mouse_drag_left.png +0 -0
- package/bundle/images/nav_help_mouse_drag_right.png +0 -0
- package/bundle/images/nav_help_mouse_position_left.png +0 -0
- package/bundle/images/nav_help_mouse_position_right.png +0 -0
- package/bundle/images/nav_help_mouse_zoom.png +0 -0
- package/bundle/images/nav_help_tap_inside.png +0 -0
- package/bundle/images/nav_help_zoom_keys.png +0 -0
- package/bundle/images/objectColor.png +0 -0
- package/bundle/images/outlineBasic1024.png +0 -0
- package/bundle/images/outlineBasic2048.png +0 -0
- package/bundle/images/outlineBasic4096.png +0 -0
- package/bundle/images/outlineBasic512.png +0 -0
- package/bundle/images/outlineEnhanced1024.png +0 -0
- package/bundle/images/outlineEnhanced2048.png +0 -0
- package/bundle/images/outlineEnhanced4096.png +0 -0
- package/bundle/images/outlineEnhanced512.png +0 -0
- package/bundle/images/pinAnchor.png +0 -0
- package/bundle/images/pinIconDefault.png +0 -0
- package/bundle/images/safari.png +0 -0
- package/bundle/images/scope.svg +3 -0
- package/bundle/images/selected_sweep_glow.png +0 -0
- package/bundle/images/showcase-password-background.jpg +0 -0
- package/bundle/images/surface_grid_planar_256.png +0 -0
- package/bundle/images/tagColor.png +0 -0
- package/bundle/images/unsupported-browser.jpg +0 -0
- package/bundle/images/uv_grid_opengl.jpg +0 -0
- package/bundle/images/vert_arrows.png +0 -0
- package/bundle/js/136.js +18 -0
- package/bundle/js/136.js.LICENSE.txt +20 -0
- package/bundle/js/143.js +2 -0
- package/bundle/js/143.js.LICENSE.txt +20 -0
- package/bundle/js/145.js +2 -0
- package/bundle/js/145.js.LICENSE.txt +20 -0
- package/bundle/js/189.js +2 -0
- package/bundle/js/189.js.LICENSE.txt +20 -0
- package/bundle/js/217.js +2 -0
- package/bundle/js/217.js.LICENSE.txt +20 -0
- package/bundle/js/313.js +2 -0
- package/bundle/js/313.js.LICENSE.txt +20 -0
- package/bundle/js/316.js +2 -0
- package/bundle/js/316.js.LICENSE.txt +27 -0
- package/bundle/js/321.js +2 -0
- package/bundle/js/321.js.LICENSE.txt +20 -0
- package/bundle/js/324.js +2 -0
- package/bundle/js/324.js.LICENSE.txt +20 -0
- package/bundle/js/325.js +2 -0
- package/bundle/js/325.js.LICENSE.txt +20 -0
- package/bundle/js/330.js +2 -0
- package/bundle/js/330.js.LICENSE.txt +20 -0
- package/bundle/js/335.js +2 -0
- package/bundle/js/335.js.LICENSE.txt +20 -0
- package/bundle/js/376.js +2 -0
- package/bundle/js/376.js.LICENSE.txt +20 -0
- package/bundle/js/422.js +2 -0
- package/bundle/js/422.js.LICENSE.txt +22 -0
- package/bundle/js/493.js +2 -0
- package/bundle/js/493.js.LICENSE.txt +27 -0
- package/bundle/js/512.js +2 -0
- package/bundle/js/512.js.LICENSE.txt +20 -0
- package/bundle/js/519.js +2 -0
- package/bundle/js/519.js.LICENSE.txt +20 -0
- package/bundle/js/521.js +2 -0
- package/bundle/js/521.js.LICENSE.txt +20 -0
- package/bundle/js/525.js +2 -0
- package/bundle/js/525.js.LICENSE.txt +20 -0
- package/bundle/js/607.js +2 -0
- package/bundle/js/607.js.LICENSE.txt +27 -0
- package/bundle/js/644.js +2 -0
- package/bundle/js/644.js.LICENSE.txt +63 -0
- package/bundle/js/648.js +2 -0
- package/bundle/js/648.js.LICENSE.txt +20 -0
- package/bundle/js/66.js +2 -0
- package/bundle/js/66.js.LICENSE.txt +20 -0
- package/bundle/js/662.js +2 -0
- package/bundle/js/662.js.LICENSE.txt +20 -0
- package/bundle/js/668.js +2 -0
- package/bundle/js/668.js.LICENSE.txt +20 -0
- package/bundle/js/718.js +2 -0
- package/bundle/js/718.js.LICENSE.txt +20 -0
- package/bundle/js/764.js +2 -0
- package/bundle/js/764.js.LICENSE.txt +29 -0
- package/bundle/js/833.js +20 -0
- package/bundle/js/833.js.LICENSE.txt +20 -0
- package/bundle/js/858.js +2 -0
- package/bundle/js/858.js.LICENSE.txt +20 -0
- package/bundle/js/916.js +2 -0
- package/bundle/js/916.js.LICENSE.txt +20 -0
- package/bundle/js/924.js +2 -0
- package/bundle/js/924.js.LICENSE.txt +20 -0
- package/bundle/js/932.js +2 -0
- package/bundle/js/932.js.LICENSE.txt +20 -0
- package/bundle/js/948.js +2 -0
- package/bundle/js/948.js.LICENSE.txt +20 -0
- package/bundle/js/958.js +2 -0
- package/bundle/js/958.js.LICENSE.txt +20 -0
- package/bundle/js/JPEGDecoder.worker.worker.js.LICENSE.txt +29 -0
- package/bundle/js/JPEGEncoder.worker.worker.js.LICENSE.txt +29 -0
- package/bundle/js/PNGDecoder.worker.worker.js.LICENSE.txt +20 -0
- package/bundle/js/PNGEncoder.worker.worker.js.LICENSE.txt +20 -0
- package/bundle/js/browser-check.js +2 -0
- package/bundle/js/browser-check.js.LICENSE.txt +18 -0
- package/bundle/js/showcase.js +6 -0
- package/bundle/js/showcase.js.LICENSE.txt +144 -0
- package/bundle/locale/messages/strings_de.json +1 -0
- package/bundle/locale/messages/strings_es.json +1 -0
- package/bundle/locale/messages/strings_fr.json +1 -0
- package/bundle/locale/messages/strings_it.json +1 -0
- package/bundle/locale/messages/strings_ja.json +1 -0
- package/bundle/locale/messages/strings_ko.json +1 -0
- package/bundle/locale/messages/strings_nl.json +1 -0
- package/bundle/locale/messages/strings_pt.json +1 -0
- package/bundle/locale/messages/strings_ru.json +1 -0
- package/bundle/locale/messages/strings_zh-CN.json +1 -0
- package/bundle/locale/messages/strings_zh-TW.json +1 -0
- package/bundle/locale/strings.json +1 -0
- package/bundle/sdk/cursors/grab.png +0 -0
- package/bundle/sdk/cursors/grabbing.png +0 -0
- package/bundle/sdk/cursors/rbe-default.png +0 -0
- package/bundle/sdk/cursors/rbe-finish-room.png +0 -0
- package/bundle/sdk/cursors/rbe-moving.png +0 -0
- package/bundle/sdk/cursors/rbe-place-door.png +0 -0
- package/bundle/sdk/cursors/rbe-place-node.png +0 -0
- package/bundle/sdk/cursors/rbe-place-opening.png +0 -0
- package/bundle/sdk/cursors/zoom-in.png +0 -0
- package/bundle/sdk/cursors/zoom-out.png +0 -0
- package/bundle/sdk/sandbox.html +1 -0
- package/bundle/sdk/sdk-client.js +1 -0
- package/bundle/sdk/sdk-interface.js +1 -0
- package/bundle/sdk.d.ts +5312 -0
- package/bundle/showcase.html +114 -0
- package/bundle/terms/terms-de-DE.html +69 -0
- package/bundle/terms/terms-en-GB.html +62 -0
- package/bundle/terms/terms-en-US.html +62 -0
- package/bundle/terms/terms-es-MX.html +66 -0
- package/bundle/terms/terms-fr-FR.html +65 -0
- package/bundle/terms/terms-it-IT.html +65 -0
- package/bundle/terms/terms-ja-JP.html +64 -0
- package/bundle/terms/terms-ko-KR.html +65 -0
- package/bundle/terms/terms-nl-NL.html +65 -0
- package/bundle/terms/terms-pt-BR.html +75 -0
- package/bundle/terms/terms-ru-RU.html +72 -0
- package/bundle/terms/terms-zh-CN.html +65 -0
- package/bundle/terms/terms-zh-TW.html +84 -0
- package/bundle/vendors/three/0.146.0/libs/basis/README.md +32 -0
- package/bundle/vendors/three/0.146.0/libs/basis/basis_transcoder.js +1 -0
- package/bundle/vendors/three/0.146.0/libs/basis/basis_transcoder.wasm +0 -0
- package/bundle/vendors/three/0.146.0/libs/basis/no-dynamic-execution.patch +11 -0
- package/bundle/vendors/three/0.146.0/libs/draco/README.md +32 -0
- package/bundle/vendors/three/0.146.0/libs/draco/draco_decoder.js +1 -0
- package/bundle/vendors/three/0.146.0/libs/draco/draco_decoder.wasm +0 -0
- package/bundle/vendors/three/0.146.0/libs/draco/draco_encoder.js +1 -0
- package/bundle/vendors/three/0.146.0/libs/draco/draco_wasm_wrapper.js +1 -0
- package/bundle/vendors/three/0.146.0/libs/draco/gltf/draco_decoder.js +1 -0
- package/bundle/vendors/three/0.146.0/libs/draco/gltf/draco_decoder.wasm +0 -0
- package/bundle/vendors/three/0.146.0/libs/draco/gltf/draco_encoder.js +1 -0
- package/bundle/vendors/three/0.146.0/libs/draco/gltf/draco_wasm_wrapper.js +1 -0
- package/bundle/vendors/three/0.146.0/three.cjs +2 -0
- package/bundle/vendors/three/0.146.0/three.cjs.LICENSE.txt +5 -0
- package/bundle/vendors/three/0.146.0/three.js +2 -0
- package/bundle/vendors/three/0.146.0/three.js.LICENSE.txt +5 -0
- package/bundle/vendors/three/0.146.0/three.min.js +2 -0
- package/bundle/vendors/three/0.146.0/three.min.js.LICENSE.txt +5 -0
- package/bundle/vendors/three/0.146.0/three.module.js +2 -0
- package/bundle/vendors/three/0.146.0/three.module.js.LICENSE.txt +5 -0
- package/bundle/version.txt +1 -0
- package/lib/architwin.d.ts +24 -0
- package/lib/architwin.min.js +1 -0
- package/lib/types.d.ts +123 -0
- package/lib/types.js +2 -0
- package/package.json +26 -0
- package/tsconfig.json +11 -0
package/bundle/js/833.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*! For license information please see 833.js.LICENSE.txt */
|
|
2
|
+
(self.webpackChunkmp_webgl=self.webpackChunkmp_webgl||[]).push([[833],{48603:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>r});var s=i(97542),n=i(69170),o=i(51524);class r extends s.Y{constructor(){super(...arguments),this.name="automation-support"}async init(e,t){const i=window;if(i.MP_AUTOMATION)this.addAutomationHooks(t,i.MP_AUTOMATION);else{const e=performance.now(),s=setInterval((()=>{i.MP_AUTOMATION?(this.addAutomationHooks(t,i.MP_AUTOMATION),clearInterval(s)):performance.now()-e>5e3&&clearInterval(s)}),100)}}async addAutomationHooks(e,t){const i=await e.getModuleBySymbol(n.y.WEBGL_RENDERER);t.estimatedGPUMemoryAllocated=()=>i.estimatedGPUMemoryAllocated(),t.maxLOD=()=>o.t.maxLOD}}},38319:(e,t,i)=>{"use strict";i.d(t,{hf:()=>o,lb:()=>n});var s=i(50575);const n=(e=200)=>({resizeDimensions:[{property:s.P.width,setDimension:e=>e.width,duration:e},{property:s.P.height,setDimension:e=>e.height,duration:e},{property:s.P.top,setDimension:()=>0,duration:e},{property:s.P.left,setDimension:()=>0,duration:e}]}),o=(e,t,i,n=200)=>{const o=[];return void 0!==e&&o.push({property:s.P.width,setDimension:t=>t.width+e,duration:n}),void 0!==t&&o.push({property:s.P.height,setDimension:e=>e.height+t,duration:n}),void 0!==i&&o.push({property:s.P.left,setDimension:()=>i,duration:n}),{resizeDimensions:o}}},13310:(e,t,i)=>{"use strict";i.d(t,{Y:()=>o});var s=i(89557),n=i(67992);class o extends n.V{constructor(){super(),this.name="cursor",this.opacity=new s.z(0),this.texture=null}}},85042:(e,t,i)=>{"use strict";var s;i.d(t,{L:()=>s}),function(e){e[e.Reticle=0]="Reticle",e[e.GridPlane=1]="GridPlane"}(s||(s={}))},65792:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>w});var s=i(97542),n=i(69170),o=i(9037),r=i(54244),a=i(23254),h=i(95882),d=i(95912),l=i(80361),c=i(9133),u=i(2569),p=i(59296);function g(e){const t=(0,p.J5)(u.ep.toVisionQuaternion(e.rotation));return{position:(0,p.m)(u.ep.toVisionVector(e.position)),rotation:t,aspect:e.aspect(),isOrtho:e.isOrtho(),fovX:e.fovX(),fovY:e.fovY()}}function m(e){return(0,c.U)(new Date(e))}class w extends s.Y{constructor(){super(...arguments),this.name="dwell-analytics",this.pendingDwellEvents=[],this.onCameraChange=(0,d.P)((e=>{this.checkForDwellEvent(),e.clone(this.currentEvent.pose),this.currentEvent.startTimeMs=Date.now(),this.scheduleDwellTimeOutEvent()}),1e3),this.checkForDwellEvent=(e=!1)=>{const{startTimeMs:t,viewmode:i}=this.currentEvent;if(!t||this.appData.phase!==r.nh.PLAYING)return;const s=Date.now(),n=s-t,o={pose:g(this.currentEvent.pose),durationMs:n,startTime:m(t),endTime:m(s),timedOut:e,viewmode:i};this.trackDwellEvent(o)},this.onViewmodeUpdate=e=>{e.value!==h.Ey.Transition&&(this.currentEvent.viewmode=(0,h.Ae)(e.value))},this.trackDwellEvent=e=>{this.pendingDwellEvents.push(e),this.trackPendingDwellEvents()},this.trackPendingDwellEvents=(0,d.P)((()=>{const e={events:JSON.stringify(this.pendingDwellEvents)};this.pendingDwellEvents=[],this.analytics.track("dwell_events",e)}),5e3),this.onBlur=()=>this.stopTrackingDwellTime(!1),this.stopTrackingDwellTime=(e=!1)=>{this.checkForDwellEvent(e),delete this.currentEvent.startTimeMs},this.resumeTrackingDwellTime=()=>{this.currentEvent.startTimeMs||(this.currentEvent.startTimeMs=Date.now()),this.scheduleDwellTimeOutEvent()},this.throttledResumeTrackingDwellTime=(0,d.P)(this.resumeTrackingDwellTime,100),this.scheduleDwellTimeOutEvent=(0,l.D)((()=>this.stopTrackingDwellTime(!0)),15e3)}async init(e,t){[this.analytics,this.cameraData,this.appData,this.viewmodeData]=await Promise.all([t.getModuleBySymbol(n.y.ANALYTICS),t.market.waitForData(o.M),t.market.waitForData(r.pu),t.market.waitForData(a.O)]),this.currentEvent={pose:this.cameraData.pose.clone(),viewmode:(0,h.Ae)(null)},this.bindings.push(this.cameraData.pose.onChanged(this.onCameraChange)),this.bindings.push(this.viewmodeData.onPropertyChanged("currentModeObservable",this.onViewmodeUpdate)),window.addEventListener("blur",this.onBlur),window.addEventListener("focus",this.resumeTrackingDwellTime),window.addEventListener("keydown",this.resumeTrackingDwellTime,{capture:!0}),window.addEventListener("touchcancel",this.resumeTrackingDwellTime),window.addEventListener("touchstart",this.resumeTrackingDwellTime),window.addEventListener("touchend",this.resumeTrackingDwellTime),window.addEventListener("touchmove",this.throttledResumeTrackingDwellTime),window.addEventListener("mousemove",this.throttledResumeTrackingDwellTime)}dispose(e){super.dispose(e),window.removeEventListener("blur",this.onBlur),window.removeEventListener("focus",this.resumeTrackingDwellTime),window.removeEventListener("keydown",this.resumeTrackingDwellTime,{capture:!0}),window.removeEventListener("touchcancel",this.resumeTrackingDwellTime),window.removeEventListener("touchstart",this.resumeTrackingDwellTime),window.removeEventListener("touchend",this.resumeTrackingDwellTime),window.removeEventListener("touchmove",this.throttledResumeTrackingDwellTime),window.removeEventListener("mousemove",this.throttledResumeTrackingDwellTime)}}},86034:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>G});var s=i(97542),n=i(69170),o=i(79728),r=i(45905),a=i(90632),h=i(635),d=i(85979),l=i(64567),c=i(71954),u=i(2541),p=i(34361),g=i(17788),m=i(97998),w=i(75287),y=i(81396);class f extends w.T{constructor(){super(...arguments),this.position=new y.Vector3,this.floorId="",this.sid="",this.layerId="",this.text="",this.visible=!1,this.roomId=void 0,this.created=new Date,this.modified=new Date,this.version="3.1"}copy(e){return this.floorId=e.floorId,this.sid=e.sid,this.text=e.text,this.visible=e.visible,this.roomId=e.roomId,this.created=e.created,this.modified=e.modified,this.position.copy(e.position),this.version=e.version,this.commit(),this}}var v=i(40731),b=i(2569);const T=new m.Z("mds-label-serialize");class D{constructor(){this.validate=e=>{if(!e)return!1;const t=["enabled","floorId","label","position"].filter((t=>!(t in e))),i=0===t.length,s=!!e.floorId&&"string"==typeof e.floorId,n=!!e.position&&(0,v.u)(e.position),o=i&&s&&n;return o||T.debug("Label invalid:",{missingFields:t,validPosition:n}),o}}serialize(e,t){const i=P(e,t);return this.validate(i)?i:null}}class S{constructor(){this.validate=e=>{if(!e)return!1;const t=["enabled","label","position","floorId","roomId","layerId"];return Object.keys(e).every((e=>t.includes(e)))}}serialize(e,t){const i=P(e,t);return i&&this.validate(i)?i:null}}const P=(e,t)=>{const i={};return void 0!==e.visible&&(i.enabled=e.visible),void 0!==e.text&&(i.label=e.text),void 0!==e.position&&(0,v.u)(e.position)&&(i.position=b.ep.toVisionVector(e.position)),void 0!==e.floorId&&""!==e.floorId&&(i.floorId=e.floorId),void 0!==e.roomId&&""!==e.roomId&&(i.roomId=e.roomId),t&&void 0!==e.layerId&&""!==e.layerId&&(i.layerId=e.layerId),Object.keys(i).length>0?i:null};var I=i(9133);const M=new m.Z("mds-label-deserializer");class x{constructor(){this.validate=e=>{if(!e)return!1;const t=["id","created","modified","enabled","floor","label","position"].filter((t=>!(t in e))),i=0===t.length,s=!(!e.floor||!e.floor.id),n=!!e.position&&(0,v.u)(e.position);return i&&s&&n||M.debug("Label invalid:",{missingFields:t,validFloor:s,validPosition:n}),i&&s&&n}}deserialize(e){var t;if(!e||!this.validate(e))return M.debug("Deserialized invalid Label data from MDS",e),null;const i=new f;return i.sid=e.id,i.layerId=(null===(t=e.layer)||void 0===t?void 0:t.id)||"",i.floorId=e.floor.id,i.text=e.label,i.visible=!!e.enabled,i.created=(0,I.p)(e.created),i.modified=(0,I.p)(e.modified),i.position=b.ep.fromVisionVector(e.position),e.room&&e.room.id&&(i.roomId=e.room.id),i}}var R=i(61341),E=i(41999),C=i(39011),A=i(5823);const L=new m.Z("MdsLabelStore");class O extends g.u{constructor(e){super(e),this.prefetchKey="data.model.labels",this.layeredType=A.SF.LABEL,this.deserializer=new x,this.updateSerializer=new S,this.createSerializer=new D}async read(e){const{includeDisabled:t=!1}=this.config,i={modelId:this.getViewId(),includeDisabled:t,includeLayers:this.readLayerId()};return this.query(R.GetLabels,i,e).then((e=>{var t,i;const s=null===(i=null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.model)||void 0===i?void 0:i.labels;if(!s||!Array.isArray(s))return null;const n=[];for(const e of s){const t=this.deserializer.deserialize(e);t&&n.push(t)}return n.reduce(((e,t)=>(e[t.sid]=t,e)),{})}))}async create(e){const t=this.getViewId(),i=[];for(const s of e){const e=this.createSerializer.serialize(s,this.writeLayerId(s.layerId));if(!e)throw L.error("Failure saving label:",s.sid,s),new Error("Could not save Label");const n={modelId:t,labelId:s.sid,data:e,includeLayers:this.readLayerId()};await this.mutate(R.AddLabel,n).then((e=>{var t;const n=null===(t=e.data)||void 0===t?void 0:t.addLabel;if(!n)throw new Error("Could not save label: empty response");const o=(new f).copy(s);o.sid=n.id,o.commit(),L.debug(Object.assign({type:"addLabel"},e)),i.push(o)}))}return i}async update(e){if(!e||0===e.length)return;const t=this.getViewId();let i="";const s={};s.modelId=t,s.includeLayers=this.readLayerId();let n="";for(const t of e){const e=t.sid,o=this.updateSerializer.serialize(t,!1);if(!o)throw L.error("Failure updating label:",e,t),new Error("Could not update Label");i+=`, $patch${e}: LabelPatch!`,s[`patch${e}`]=o,n+=`patch${e}:\n patchLabel(modelId: $modelId, labelId: "${e}", patch: $patch${e}) {\n ...LabelDetails\n }\n `}const o=E.gql`
|
|
3
|
+
mutation labelUpdate($modelId: ID! ${i}, $includeLayers: Boolean!) {
|
|
4
|
+
${n}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
${(0,C.S)(R.LabelDetails)}
|
|
8
|
+
`;return this.mutate(o,s).then((e=>{L.debug(Object.assign({type:"patchLabel"},e))}))}async delete(e){if(!e||0===e.length)return;const t=this.getViewId();let i="";for(const t of e){if(!t||t&&!t.sid)throw L.error("Failure deleting label:",t),new Error("Could not update Label");i+=`delete${t.sid}: deleteLabel(modelId: $modelId, labelId: "${t.sid}") `}const s=E.gql`
|
|
9
|
+
mutation batchDeleteLabel($modelId: ID!) {
|
|
10
|
+
${i}
|
|
11
|
+
}
|
|
12
|
+
`;return this.mutate(s,{modelId:t}).then((()=>{}))}}var F=i(59279),k=i(79232),N=i(33824),B=i(80742);class G extends s.Y{constructor(){super(...arguments),this.name="label-data",this.monitor=null}async init(e,t){const{readonly:i}=e;this.config=e,this.engine=t,this.market=t.market,this.layersData=await t.market.waitForData(B.R),this.store=new O({context:this.layersData.mdsContext,readonly:e.readonly,includeDisabled:!e.readonly,baseUrl:e.baseUrl});const s=await this.store.read()||{},h=await t.getModuleBySymbol(n.y.STORAGE),d=await t.getModuleBySymbol(n.y.MESH_QUERY);for(const e of Object.values(s))d.inferMeshIdsFromPoint(e,e.position);if(this.labelData=t.market.tryGetData(p.D)||new p.D(s),this.store.onNewData((async e=>{var t;this.labelData.atomic((()=>{this.layersData.replaceBackendLayers(this.labelData.getCollection(),{})})),e&&this.labelData.atomic((()=>{this.layersData.replaceBackendLayers(this.labelData.getCollection(),e)})),null===(t=this.monitor)||void 0===t||t.clearDiffRecord()})),await this.store.refresh(),this.market.register(this,p.D,this.labelData),!i){this.monitor=new l.c(this.labelData.getCollection(),{aggregationType:u.E.Manual,shallow:!0},this.engine),this.bindings.push(h.onSave((()=>this.saveDiff()),{dataType:o.g.LABELS}),h.onPublish((()=>this.onAfterPublish()),{dataType:o.g.LABELS,phase:r.Q.AFTER}));const e=await t.market.waitForData(a.Q);e.setRevertableType(o.g.LABELS),e.setPublishableType(o.g.LABELS),this.configureTrash()}}dispose(e){this.store.dispose(),super.dispose(e)}async save(){return this.engine.commandBinder.issueCommand(new h.VQ({dataTypes:[o.g.LABELS]}))}getDiffRecord(){var e;return(null===(e=this.monitor)||void 0===e?void 0:e.getDiffRecord())||[]}async saveDiff(){if(!this.store||!this.monitor)return void this.log.warn("Labels changes will NOT be saved");this.monitor.commitChanges();const e=this.monitor.getDiffRecord();this.monitor.clearDiffRecord();const t=e.map((e=>{var t;const i=e.diff.layerId||(null===(t=this.labelData.getLabel(e.index))||void 0===t?void 0:t.layerId);return Object.assign(Object.assign({},e),{layerId:i})})).filter((e=>!this.layersData.isInMemoryLayer(e.layerId))),i=t.filter((e=>e.action===c.KI.removed)).map((e=>({sid:e.index,layerId:e.layerId}))),s=t.filter((e=>e.action===c.KI.added)).map((e=>this.labelData.getLabel(e.index))),n=t.filter((e=>e.action===c.KI.updated)).map((e=>Object.assign(Object.assign({sid:e.index},e.diff),{layerId:e.layerId})));return Promise.all([this.store.delete(i),this.store.create(s),this.store.update(n)]).then((()=>{}))}onUpdate(e){}async onAfterPublish(){this.verifyDataIntegrity()}async verifyDataIntegrity(){const e="data-integrity"===(0,F.eY)("error",""),t=this.labelData.getCount(),i=await this.store.read().catch((e=>{this.log.debug("Label integrity check failed",e)}))||{},s=Object.keys(i).length;(s!==t||e)&&this.engine.broadcast(new d.Qq(`Unexpected label count after publish (${s}/${t})`,o.g.LABELS,e))}async configureTrash(){const{readonly:e}=this.config;if(e)return;const{commandBinder:t}=this.engine,i=o.g.LABELS,s=new x,n={objectType:i,create:e=>new k.F({label:e.label||"Label",objectId:e.id,objectType:i,created:new Date,value:e}),restore:e=>{const t=s.deserialize(e.value);t&&this.labelData.add(t)}},r=await t.issueCommandWhenBound(new N.B(n));this.bindings.push(r)}}},92543:(e,t,i)=>{"use strict";i.r(t),i.d(t,{USER_LABELS:()=>I,default:()=>we});var s=i(97542),n=i(69170),o=i(34361),r=i(9037),a=i(79727),h=i(91380),d=i(76532),l=i(53954),c=i(28269),u=i(34029),p=i(12529),g=i(78449),m=i(81396);const w={ColorDefault:16777215,ColorHovered:i(15462).I.MP_BRAND.getHex(),ColorInvalid:16750933};class y extends g.$7{use(e){this.userData.sid=e.data.sid,this.collider.data=e.data,this.collider.name=e.data.text,this.collider.labelMesh=e}}class f extends m.Mesh{constructor(){super(...arguments),this.hitTest=(()=>{const e=new m.Matrix4,t=new m.Ray,i=new m.Plane(new m.Vector3(0,0,-1)),s=new m.Vector3;return(n,o)=>{if(e.copy(this.matrixWorld).invert(),t.copy(n.ray).applyMatrix4(e),t.intersectPlane(i,s)){const e=this.scale.x/this.scale.y;let t=.5;e<1.5&&(t=1/e),Math.abs(s.x)<=t&&Math.abs(s.y)<=.75&&(s.applyMatrix4(this.matrixWorld),o.push({distance:n.ray.origin.distanceTo(s),point:s.clone(),object:this}))}}})()}labelVisible(){return!(!this.labelMesh||!this.labelMesh.labelVisible())}getId(){if(!this.data)throw new Error("LabelInputCollider used before configure");return this.data.sid}raycast(e,t){if(!this.labelVisible())return;if(this.material.depthTest)return void this.hitTest(e,t);const i=this.material.depthTest?t:[];this.hitTest(e,i),i.length>0&&(i[0].distance/=1e4,t.push(i[0]))}}class v{constructor(e,t=""){this.makeLabel=()=>{const e=new y(Object.assign({},this.textStyle));return e.scaleType=g.N3.WORLD,e.setRenderOrder(p.z.labels),e.setRenderLayer(this.layer),e.opacity=0,e},this.textStyle=g.uc.makeConfig({assetBasePath:t,color:"white",background:!e,backgroundAsCollider:!0,backgroundColliderType:f,backgroundColor:"#222",backgroundOpacity:1,outline:e,outlineWidth:8,backgroundBorderHeight:26,backgroundBorderWidth:20,wordWrapWidth:void 0,disableDepth:!0})}setRenderLayer(e){this.layer=e}}var b=i(19663);class T extends b.m{constructor(e){super(),this.payload={ids:e}}}class D extends b.m{constructor(e){super(),this.payload={enabled:e}}}var S=i(15637),P=i(89557);const I={LABEL_SIZE:0,FADE_DURATION:200};var M=i(39880);class x extends m.Object3D{constructor(e){super(),this.text=e,this.maxOpacity=1,this.labelAnim=new P.z(0),this.filtered=!1,this.hidden=!1,this.selectState={active:!1,on:()=>{},off:()=>{}},this.validState={active:!0,on:()=>{const e=this.hoverState.active?w.ColorHovered:w.ColorDefault;this.text.setColorHex(e)},off:()=>{this.text.setColorHex(w.ColorInvalid)}},this.hoverState={active:!1,on:()=>{this.validState.active&&this.text.setColorHex(w.ColorHovered)},off:()=>{this.validState.active&&this.text.setColorHex(w.ColorDefault)}},this.add(e)}use(e){this.data=e,this.userData.sid=e.sid,this.userData.data=e,this.text.use(this),this.labelUpdate(e.position,new m.Quaternion,"")}getId(){return this.data.sid}labelVisible(){return!this.filtered&&!this.hidden}updatePose(e,t){return this.labelUpdate(e,t,this.data.text),this}setMaxOpacity(e){this.maxOpacity=e,this.toggleLabel(this.labelVisible())}async free(){this.labelAnim.value>0&&(this.toggleLabel(!1),await(0,M.gw)(I.FADE_DURATION))}tickAnimations(e){return this.animateLabelOpacity(.5*e),this}toggleLabel(e){this.hidden=!e,this.updateOpacity()}isHidden(){return this.hidden}toggleFiltered(e){e!==this.filtered&&(this.filtered=e,this.updateOpacity())}updateOpacity(){const e=this.labelVisible()?this.maxOpacity:0;this.labelAnim.endValue!==e&&this.labelAnim.modifyAnimation(this.labelAnim.value,e,I.FADE_DURATION)}animateLabelOpacity(e){const t=this.labelAnim.tick(e);Math.min(t,this.maxOpacity)!==this.text.opacity&&(this.text.opacity=t)}labelUpdate(e,t,i){this.text.position.copy(e),this.text.quaternion.copy(t),this.text.text=i}billboard(e,t,i,s,n,o,r){this.text.scaleBillboard(e,t,i,s,n,o,r)}}var R=i(97998);const E=new R.Z("label-spawner");class C{constructor(e,t){this.map=e,this.maker=t,this.container=new m.Object3D,this.pool=[],this.bindings=[],this.meshesMap=(0,S.q)(),this.container.name="RoomLabels";const i=e.keys;for(const t of i){const i=e.get(t);this.add(i,t)}this.bindings.push(e.onElementChanged({onAdded:(e,t)=>{this.add(e,t),E.debug("LabelMesh: added:",t)},onRemoved:(e,t)=>{E.debug("LabelMesh: removing:",t);const i=this.meshesMap.get(t);i&&this.free(i)}}))}subscribe(e){return this.meshesMap.onElementChanged(e)}get(e){return this.meshesMap.get(e)}free(e){const t=e.getId(),i=this.meshesMap.get(t);return i.free().then((()=>{this.meshesMap.delete(t),this.container.remove(i),this.pool.push(i),E.debug("LabelMesh: removed:",i)}))}add(e,t){const i=this.get(t);if(i)return i;const s=this.pool.shift();if(void 0!==s)return s.use(e),this.container.add(s),this.meshesMap.set(t,s),s;{const i=new x(this.maker.makeLabel());return i.use(e),this.container.add(i),this.meshesMap.set(t,i),i}}dispose(){for(const e of this.meshesMap.values)this.free(e),e.text.dispose();this.meshesMap.clear();for(const e of this.pool)e.text.dispose();this.pool.length=0,this.bindings.forEach((e=>e.cancel()))}}var A=i(2569);class L{constructor(e,t,i,s){this.meshes=e,this.cameraData=i,this.screenFilter=s,this.dirty=!0,this.bindings=[],this.pendingMesh=null,this.setDirty=()=>{this.dirty=!0},this.bindings.push(i.onChanged(this.setDirty),t.onChanged(this.setDirty));for(const e of this.meshes.values)e.text.onGeomUpdate(this.setDirty);this.meshes.onElementChanged({onAdded:e=>e.text.onGeomUpdate(this.setDirty)})}dispose(){this.bindings.forEach((e=>e.cancel())),this.bindings.length=0}setPendingMeshId(e){if((!this.pendingMesh||this.pendingMesh.getId()!==e)&&(this.pendingMesh&&(this.pendingMesh.data.removeOnChanged(this.setDirty),this.pendingMesh=null),e)){const t=this.meshes.get(e);t.data.onChanged(this.setDirty),this.pendingMesh=t}}beforeRender(){if(!this.dirty)return;this.dirty=!1;const{position:e,rotation:t,projection:i}=this.cameraData.pose,{height:s}=this.cameraData,n=this.cameraData.zoom(),o=this.cameraData.aspect(),r=(0,A.dS)(64-I.LABEL_SIZE,0,64,.02,.1);for(const a of this.meshes.values)a.isHidden()||(a.updatePose(a.data.position,t),a.billboard(e,t,i,n,s,o,r));this.screenFilter.update();for(const e of this.meshes.values)e.isHidden()||e.toggleFiltered(!this.screenFilter.visible(e.data.sid))}render(e){for(const t of this.meshes)t.tickAnimations(e)}deactivate(){}init(){}activate(){}}var O=i(82582),F=i.n(O),k=i(59370);class N{constructor(e,t,i){this.meshes=e,this.cameraData=t,this.enabled=i,this.tree=new(F()),this.visibleMap={},this._screenPosition=new m.Vector2,this._ndcPosition=new m.Vector3,this._cornerWorldPosition=new m.Vector3,this._cornerScreenPosition=new m.Vector2,this._selectedId=null,this.update=()=>{this.enabled()?(this.visibleMap={},this.updatePositions()):Object.keys(this.visibleMap).length&&(this.visibleMap={})}}visible(e){if(!(e in this.visibleMap))return!1;return e in this.visibleMap}setSelectedMeshId(e){this._selectedId=e}updatePositions(){this.tree.clear(),this.meshes().filter((e=>!e.isHidden())).map((e=>{(0,k.q9)(this.cameraData,e.text.position,this._screenPosition,this._ndcPosition);const{width:t,height:i}=e.text.textGeometry.layout;this._cornerWorldPosition.set(.5*t,-.5*i,0),e.text.updateMatrixWorld(),this._cornerWorldPosition.applyMatrix4(e.text.matrixWorld),(0,k.q9)(this.cameraData,this._cornerWorldPosition,this._cornerScreenPosition);const s=e.getId()!==this._selectedId?this._ndcPosition.z:-999;return this.describeBbox(e.text,this._screenPosition,this._cornerScreenPosition,s)})).sort(((e,t)=>e.depth-t.depth)).forEach((e=>{this.tree.collides(e)||(this.tree.insert(e),this.visibleMap[e.id]=e)}))}describeBbox(e,t,i,s){i.sub(t);const n=i.x,o=i.y;return{id:e.userData.sid,depth:s,minX:t.x-n,minY:t.y-o,maxX:t.x+n,maxY:t.y+o}}}var B=i(54244),G=i(59625),z=i(39642),V=i(23037),U=i(76631),Q=i(23254),_=i(80742);class H{constructor(e){this.meshes=e,this.initialized=!1,this.pendingMeshId=null,this.selectedMeshId=null,this.dirty=!0,this.bindings=[],this.labelIdVisibility={},this.visibilityFilterEnabled=!1,this.featureEnabled=()=>{if(!this.initialized)return!1;const e=this.appData.phase===B.nh.PLAYING,t=this.settingsData.tryGetProperty(z.Q,!1),i=this.settingsData.tryGetProperty(V.Nj,!1),s=this.appData.application===B.Mx.WORKSHOP,n=this.settingsData.tryGetProperty(G.gx.Labels,!1)||s,o=e&&i&&n&&(t||s);return this.settingsData.setProperty(V.Cu,o),o},this.visibleByTool=()=>{if(!this.initialized)return!1;const{activeToolName:e}=this.toolsData;return null===e||e===U.w1.LABELS||e===U.w1.PHOTOS||e===U.w1.SEARCH||e===U.w1.LAYERS},this.visibleByViewmode=()=>{const e=this.settingsData.tryGetProperty(z.Q,!1),t=this.settingsData.tryGetProperty(G.gx.LabelsDollhouse,!1)||e&&this.toolsData.activeToolName===U.w1.LABELS,i=this.viewmodeData.isDollhouse()&&t&&e;return this.viewmodeData.isFloorplan()&&(this.appData.application===B.Mx.WORKSHOP&&this.visibleByTool()||e&&this.settingsData.tryGetProperty(G.gx.Labels,!1))||i},this.hiddenByTransition=()=>this.viewmodeData.transitionActive()||this.floorsViewData.transitionActive,this.visibleByFloor=e=>{const t=this.settingsData.tryGetProperty(z.Q,!1),i=this.toolsData.activeToolName===U.w1.LABELS;if(t&&!i){const{roomSelectModeActive:e,floorSelectModeActive:t}=this.floorsViewData;if(!e)return!1;if(t)return!1}return this.viewmodeData.isFloorplan()?this.floorsViewData.currentFloor?this.floorsViewData.isCurrentOrAllFloors(e):this.floorsViewData.topFloorId===e:this.floorsViewData.isCurrentOrAllFloors(e)},this.setDirty=()=>{this.dirty=!0}}async init(e){[this.viewmodeData,this.floorsViewData,this.settingsData,this.toolsData,this.appData,this.layersData]=await Promise.all([e.waitForData(Q.O),e.waitForData(a.c),e.waitForData(u.e),e.waitForData(h.t),e.waitForData(B.pu),e.waitForData(_.R)]);const t=await e.waitForData(o.D);[this.viewmodeData,this.floorsViewData,this.settingsData,this.toolsData,this.appData,t].forEach((e=>this.bindings.push(e.onChanged(this.setDirty)))),this.bindings.push(this.layersData.onCurrentLayersChanged(this.setDirty)),this.meshes.onChanged(this.setDirty),this.initialized=!0}dispose(){this.bindings.forEach((e=>e.cancel())),this.bindings.length=0}setVisibilityFilterEnabled(e){this.visibilityFilterEnabled=e,this.setDirty()}updateLabelVisibility(e){this.labelIdVisibility=e.reduce(((e,t)=>(e[t]=!0,e)),{}),this.setDirty()}onUpdate(){if(!this.initialized||!this.dirty)return;this.dirty=!1;const e=this.featureEnabled()&&!this.hiddenByTransition()&&this.visibleByTool()&&this.visibleByViewmode(),t=e=>e.visible&&this.visibleByFloor(e.floorId)&&this.visibleById(e.sid)&&this.layerToggledOn(e.layerId)&&this.layersData.layerVisible(e.layerId);for(const i of this.meshes.values){const s=i.data.sid===this.pendingMeshId||i.data.sid===this.selectedMeshId,n=e&&(s||t(i.data));i.toggleLabel(n)}this.dirtyCb&&this.dirtyCb()}setPendingMeshId(e){this.pendingMeshId=e,this.setDirty()}setSelectedMeshId(e){this.selectedMeshId=e,this.setDirty()}setDirtyCallback(e){this.dirtyCb=e}visibleById(e){return!this.visibilityFilterEnabled||!!this.labelIdVisibility[e]}layerToggledOn(e){return this.appData.application===B.Mx.WORKSHOP||this.layersData.layerToggled(e)}}var j=i(41326),Z=i(64918),W=i(72996),q=i(86819),Y=i(23612),X=i(35895),$=i(89570),K=i(38987),J=i(34956),ee=i(31362),te=i(12039);class ie{constructor(e,t,i,s,n,o){this.labelRenderer=e,this.issueCommand=t,this.input=i,this.floorsViewData=s,this.toolsData=n,this.roomNavigationPose=o,this.inputBindings=[],this.appStateBindings=[],this.raycasterRegistrationBindings=[],this.active=!0,this.enabled=!0,this.refresh=()=>{this.shouldBeInteractive!==this.active&&(this.inputBindings.forEach((e=>this.shouldBeInteractive?e.renew():e.cancel())),this.raycasterRegistrationBindings.forEach((e=>this.shouldBeInteractive?e.renew():e.cancel())),this.active=this.shouldBeInteractive)},this.refreshColliders=()=>{for(const e of this.labelRenderer.labelMeshIterator())this.shouldBeInteractive?this.input.registerMesh(e.text.collider,!1):this.input.unregisterMesh(e.text.collider)},this.clearColliders=()=>{for(const e of this.labelRenderer.labelMeshIterator())this.input.unregisterMesh(e.text.collider)},this.inputBindings.push(...this.setupInputBindings()),this.raycasterRegistrationBindings.push(...this.setupRaycasterBindings());const r=this.toolsData.onToolChanged(this.refresh),a=this.floorsViewData.makeFloorChangeSubscription(this.refresh),h=this.floorsViewData.onRoomSelectModeChange(this.refresh);this.appStateBindings.push(r,a,h),this.refresh()}toggleInput(e){this.enabled!==e&&(this.enabled=e,this.appStateBindings.forEach((t=>e?t.renew():t.cancel())),this.refresh())}get shouldBeInteractive(){return this.enabled&&null===this.toolsData.activeToolName&&this.floorsViewData.roomSelectModeActive}setupRaycasterBindings(){return[(0,X.k1)((()=>this.refreshColliders()),(()=>this.clearColliders()),!0,"toggleLabelMeshInput"),this.labelRenderer.subscribe({onAdded:e=>this.input.registerMesh(e.text.collider,!1),onRemoved:e=>this.input.unregisterMesh(e.text.collider)})]}setupInputBindings(){const e=W.s.is((e=>e instanceof f&&e.labelVisible())),t=this.input.registerMeshHandler(q.R,e,((e,t)=>{const i=this.labelRenderer.getLabelMesh(t.getId());if(i){const e=i.data.roomId;if(e){const t=this.roomNavigationPose.getPoseForRoom(e,i.data.position);t&&this.issueCommand(new j._i(j.BD.INSIDE,Z.n.Interpolate,t))}else this.issueCommand(new te.zs({focusPosition:i.data.position,transition:Z.n.Interpolate}))}}));if((0,ee.Jm)())return[t];let i=null;return[new $.V(this.input.registerMeshHandler(Y.z,e,((e,t)=>{const s=this.labelRenderer.getLabelMesh(t.getId());s&&(s.hoverState.active=!0,s.hoverState.on(),i=s,this.issueCommand(new K.u(J.C.FINGER)))})),this.input.registerMeshHandler(Y.A,W.s.isType(f),((e,t)=>{i&&this.issueCommand(new K.u(J.C.DEFAULT));const s=this.labelRenderer.getLabelMesh(t.getId());s&&(s.hoverState.active=!1,s.hoverState.off()),i=null})),(0,X.k1)((()=>{}),(()=>{i&&(i.hoverState.active=!1,i.hoverState.off(),this.issueCommand(new K.u(J.C.DEFAULT)),i=null)}),!0,"labelHoverClear")),t]}}var se=i(90304),ne=i(95882);const oe=new R.Z("room-with-a-view");class re{constructor(e,t,i){this.sweepData=e,this.roomData=t,this.meshData=i}getPoseForRoom(e,t){const i=this.bestViewForRoom(e,t);if(i){return{rotation:i.rotation,sweepID:i.sweepID,viewmode:ne.Ey.Panorama}}return null}bestViewForRoom(e,t){const i=this.sweepData.filter((t=>t.roomId===e&&t.enabled));if(0===i.length)return oe.debug("no sweeps in selected room",{roomId:e,scansInRoom:i}),null;let s=1;const n=this.roomData.get(e),o=this.meshData.meshGroups.rooms.get(n.meshSubgroup),r=(null==o?void 0:o.boundingBox.getSize(new m.Vector3).length())||1/0;t&&r>10&&(s=.1);const a=i.sort(((i,n)=>{let o=0,r=0;t&&(o=i.position.distanceTo(t),r=n.position.distanceTo(t));const a=i.neighbours.map((e=>this.sweepData.getSweep(e))).filter((t=>t.roomId===e)).length,h=n.neighbours.map((e=>this.sweepData.getSweep(e))).filter((t=>t.roomId===e)).length;return 1*s*(h-a)-3*(r-o)})),h=a[0];if(!h)return oe.debug("no start sweep",{roomId:e,scansInRoom:i,connectedness:a}),null;const d=h.neighbours.map((e=>this.sweepData.getSweep(e))).sort(((t,i)=>{let s=h.position.distanceTo(t.position),n=h.position.distanceTo(i.position);return t.roomId===e&&(s*=1e3),i.roomId===e&&(n*=1e3),n-s})).map((e=>({sweep:e,dist:h.position.distanceTo(e.position),rm:e.roomId}))),l=d[0];oe.warn({roomId:e,roomSize:r,scoring:a,byDistance:d,scansInRoom:i});const c=new m.Quaternion;if(1===i.length&&void 0!==l){const e=(new m.Matrix4).setPosition(h.position);e.lookAt(l.sweep.position,h.position,se.f.UP),c.setFromRotationMatrix(e)}else{const e=(new m.Matrix4).setPosition(h.position);e.lookAt(h.position,l.sweep.position,se.f.UP),c.setFromRotationMatrix(e)}return{sweepID:h.id,rotation:c}}}var ae=i(5586),he=i(5823),de=i(56163),le=i(35221);class ce extends de.K{constructor(e,t,i,s,n){super(e,t,i),this.editMode=s,this.label=n,this.id=this.label.sid,this.title=this.label.text,this.icon="icon-toolbar-labels",this.typeId=he.SF.LABEL,this.floorId=this.label.floorId,this.layerId=this.label.layerId,this.dateBucket=(0,le.f)(this.label.created),this.enabled=this.label.visible,this.onSelect=()=>{super.onSelect(),this.editMode||this.commandBinder.issueCommand(new te.Cs(this.label))}}supportsLayeredCopyMove(){return!0}supportsBatchDelete(){return!0}}var ue=i(71166),pe=i(38399);const{LABELS:ge}=pe.Z.SHOWCASE;class me extends s.Y{constructor(){super(...arguments),this.name="user-labels",this.labelMeshIterator=()=>this.spawner.meshesMap.values,this.checkForRTL=(()=>{const e=/[\u0591-\u07FF]/;let t;return(i,s)=>{if(!s.tryGetProperty(z.Q,!1))return;const n=i=>{s.tryGetProperty(z.Q,!1)&&e.test(i.text)&&(this.broadcast(new ae.V),s.setProperty(z.Q,!1),t&&t.cancel())};i.getCollection().entries().forEach((e=>n(e[1]))),s.tryGetProperty(z.Q,!1)&&(t=i.getCollection().onElementChanged({onAdded:n,onUpdated:n}),this.bindings.push(t))}})(),this.filterVisibleLabels=async e=>{this.visibilityRules.updateLabelVisibility(e.ids)},this.changeVisibilityFilterEnabled=async e=>{this.visibilityRules.setVisibilityFilterEnabled(e.enabled)}}async init(e,t){const[i,s,p,g,m,w,y,f,b,S]=await Promise.all([t.market.waitForData(o.D),t.market.waitForData(r.M),t.market.waitForData(a.c),t.market.waitForData(h.t),t.market.waitForData(l.Z),t.market.waitForData(c.Z),t.market.waitForData(d._),t.getModuleBySymbol(n.y.WEBGL_RENDERER),t.getModuleBySymbol(n.y.INPUT),t.market.waitForData(u.e)]),P=f.getScene();this.broadcast=t.broadcast,this.checkForRTL(i,S);const I=new v(S.tryGetProperty(z.Q,!1),S.tryGetProperty("assetBasePath",""));I.setRenderLayer(t.claimRenderLayer("labels")),this.spawner=new C(i.getCollection(),I),P.add(this.spawner.container),this.visibilityRules=new H(this.spawner.meshesMap),this.visibilityRules.init(t.market),this.bindings.push(t.commandBinder.addBinding(T,this.filterVisibleLabels),t.commandBinder.addBinding(D,this.changeVisibilityFilterEnabled));this.labelFilter=new N(this.labelMeshIterator,s,(()=>this.visibilityRules.featureEnabled()&&this.visibilityRules.visibleByTool())),this.labelRenderer=new L(this.spawner.meshesMap,i.getCollection(),s,this.labelFilter),t.addComponent(this,this.labelRenderer),this.visibilityRules.setDirtyCallback(this.labelRenderer.setDirty);const M=new re(m,w,y);this.labelNavInput=new ie(this,t.commandBinder.issueCommand,b,p,g,M),this.toggleInput(!0),async function(e,t,i){const[s,n]=await Promise.all([e.market.waitForData(B.pu),e.market.waitForData(_.R)]);let o=s.application===B.Mx.WORKSHOP;const r=(i,s,r,a=[])=>{const h=[];return 0===a.length&&t.iterate((t=>{(o||t.visible&&n.layerToggled(t.layerId))&&i(t.text)&&h.push(new ce(e.commandBinder,n,s,o,t))})),e.commandBinder.issueCommand(new T(h.map((e=>e.id)))),h.sort(((e,t)=>e.title.localeCompare(t.title)))},a=t=>{e.commandBinder.issueCommand(new D(!!t))},h=e=>new $.V(t.onChanged(e)),d={renew:()=>{e.commandBinder.issueCommandWhenBound(new ue.c6({id:he.SF.LABEL,groupPhraseKey:ge.SEARCH_GROUP_HEADER,getSimpleMatches:r,registerChangeObserver:h,onSearchActivatedChanged:a,groupOrder:30,groupIcon:"toolbar-labels"}))},cancel:()=>{e.commandBinder.issueCommandWhenBound(new ue.Pe(he.SF.LABEL))}},l=()=>{o=s.application===B.Mx.WORKSHOP,i.tryGetProperty(G.gx.Labels,!1)||o?d.renew():d.cancel()},c=s.onPropertyChanged("application",l),u=i.onPropertyChanged(G.gx.Labels,l);return l(),new $.V(d,c,u)}(t,i,S).then((e=>this.bindings.push(e)))}dispose(e){super.dispose(e),this.visibilityRules.dispose(),this.spawner.dispose()}getLabelMesh(e){return e&&this.spawner.get(e)||null}addLabelMesh(e,t){return this.spawner.add(e,t)}freeLabelMesh(e){e&&this.spawner.free(e)}setPendingMeshId(e){this.visibilityRules.setPendingMeshId(e),this.labelRenderer.setPendingMeshId(e)}setSelectedMeshId(e){this.labelFilter.setSelectedMeshId(e),this.visibilityRules.setSelectedMeshId(e)}toggleInput(e){this.labelNavInput.toggleInput(e)}subscribe(e){return this.spawner.subscribe(e)}onUpdate(){this.visibilityRules&&this.visibilityRules.onUpdate()}}const we=me},98128:(e,t,i)=>{"use strict";i.r(t),i.d(t,{Group:()=>De,Grouper:()=>Te,MeasurementLabelBackgroundMesh:()=>Be,MeasurementLabelRenderer:()=>Ge,MeasurementLineRenderer:()=>Le,MeasurementModeData:()=>ee.X,MeasuringPhase:()=>J.au,default:()=>Ci,labelVisible:()=>J.Ph});var s,n=i(97542),o=i(69170),r=i(78449),a=i(29537),h=i(34956),d=i(64918),l=i(38987),c=i(33324),u=i(9037),p=i(79727),g=i(23254),m=i(95882),w=i(97998),y=i(81396),f=i(89557);!function(e){e[e.FloorplanOnly=0]="FloorplanOnly",e[e.ThreeD=1]="ThreeD"}(s||(s={}));var v=i(69505),b=i(46391),T=i(59370),D=i(78283);const S=new y.Vector2,P=new y.Vector3,I=new y.Vector2,M=new y.Vector2,x=(e,t,i)=>{const s=((e,t,i)=>((0,T.q9)(i,e,I),(0,T.q9)(i,t,M),{pixelDistance:I.distanceTo(M),startScreenPosition:I,endScreenPosition:M}))(e,t,i);return{screenPosition:((e,t,i)=>(P.copy(e).add(t).multiplyScalar(.5),(0,T.q9)(i,P,S),S))(e,t,i),rotation:R(I,M),pixelDistance:s.pixelDistance,startScreenPosition:s.startScreenPosition,endScreenPosition:s.endScreenPosition}},R=(e,t)=>{const i=e.y-t.y,s=e.x-t.x;let n=Math.atan2(i,s)*v.MN;return n=n>=90||n<=-90?n+180:n,n},E=(e,t=b.M.IMPERIAL)=>{let i='0"';switch(t){case b.M.IMPERIAL:const{feet:t,inches:s}=(0,D.XJ)(e);i=t>0?`${t}' ${s}"`:`${s}"`;break;case b.M.METRIC:i=`${e.toFixed(2)}m`}return i};var C=i(66990);const A=new w.Z("line-data"),L=()=>({lineVisibleByFeatureType:!0,labelVisibleByFeatureType:!0});class O{constructor(e,t,i,n,o,r,a=L){this.cameraData=e,this.viewmodeData=t,this.floorsViewData=i,this.isCurrentSweepAligned=n,this.getUnits=o,this.isFeatureEnabled=r,this.visibleFilter=a,this.derivedDataCache={},this.dollhouseLineStyle=s.ThreeD,this.setVisibilityFilter=e=>{this.visibleFilter=e},this.resetVisibilityFilter=()=>{this.visibleFilter=L},this.make=(e,t,i)=>{const s=t(),{start_position:n,end_position:o,visible:r,floorId:a,type:h,text:d}=s,l=r&&this.isFeatureEnabled(),c=l&&this.visibleByFloorAndModes(a,h),u=void 0!==i?i.opacity.value:0,p=0===u||u===C.iV.LABEL_HIDDEN_OPACITY&&c;if(i&&p&&(!l||!c))return i;let g=c,m=c;if(c){const t=this.visibleFilter(e);g=g&&t.lineVisibleByFeatureType,m=m&&t.labelVisibleByFeatureType}let w=0;const y=n.distanceTo(o),v=E(y,this.getUnits());if(m||!p){const{width:e,height:t}=((e,t=10,i=40)=>({width:Math.max(9*Math.max(e,2)+t,i),height:18+t}))(d.length+v.length),i=x(n,o,this.cameraData);this.tmpVec.copy(i.startScreenPosition).sub(i.endScreenPosition);let s=Math.abs(this.tmpVec.y)<Math.abs(this.tmpVec.x)?t:e;C.iV.ALIGN_LABELS&&(s=e,w=i.rotation),m=m&&i.pixelDistance>s}let b;const T=g&&m?1:g&&!m?C.iV.LABEL_HIDDEN_OPACITY:0;i?(b=i.opacity,b.endValue===T&&g===i.visible&&m===i.labelVisible||b.modifyAnimation(b.value,T,C.iV.FADE_DURATION)):b=new f.z(0,T,C.iV.FADE_DURATION);const D={sid:e,rotation:w,labelVisible:m,visible:g,length:y,displayLength:v,labelContents:d.length>0?`${v} ${d}`:v,opacity:b};return this.derivedDataCache[e]={getLineData:t,previousDerivedData:D},D},this.update=e=>{if(this.derivedDataCache[e]){const{getLineData:t,previousDerivedData:i}=this.derivedDataCache[e];return this.make(e,t,i)}A.warn(`data not found for ${e}`)},this.get=e=>{if(this.derivedDataCache[e])return this.derivedDataCache[e].previousDerivedData},this.remove=e=>{this.derivedDataCache[e]&&delete this.derivedDataCache[e]},this.clear=()=>{this.derivedDataCache={}},this.visibleByFloorAndModes=(e,t)=>{if(this.floorsViewData.transition.progress.active)return!1;const i=this.viewmodeData.isInside(),n=this.viewmodeData.isFloorplan(),o=this.viewmodeData.isDollhouse(),r=this.floorsViewData.currentFloorId,a=!r,h=!(!r||r!==e),d=e===this.floorsViewData.topFloorId,l=t===s.FloorplanOnly&&n&&(h||d&&a),c=t===this.dollhouseLineStyle&&o&&(h||a);return t===s.ThreeD&&i&&this.isCurrentSweepAligned()||c||l},this.tmpVec=new y.Vector2}setDollhouseLineStyle(e){this.dollhouseLineStyle=e}}var F=i(34029),k=i(59625),N=i(26158),B=i(53954),G=i(54244),z=i(62436),V=i(57989),U=i(62292),Q=i(51205),_=i(35870),H=i(19663);class j extends H.m{constructor(e,...t){super(),this.id="MEASUREMENTS_SET_VISIBILITY",this.payload={sids:t,visible:e}}}class Z extends H.m{constructor(e,t=""){super(),this.id="RENAME_MEASUREMENT",this.payload={sid:e,text:t}}}class W extends H.m{constructor(e){super(),this.payload=e}}class q extends H.m{constructor(e){super(),this.id="FILTER_MEAUREMENT_VISIBILITY",this.payload={sids:e}}}class Y extends H.m{constructor(e){super(),this.id="MEASUREMENT_VISIBILITY_FILTER_ENABLED",this.payload={enabled:e}}}class X extends H.m{constructor(e){super(),this.payload={groupId:e}}}var $=i(75810),K=i(40964),J=i(20341),ee=i(92294),te=i(90304);var ie;!function(e){e[e.Axes=1]="Axes",e[e.PlanarAxes=2]="PlanarAxes",e[e.EdgesAndPlanarAxes=3]="EdgesAndPlanarAxes",e[e.Edges=4]="Edges",e[e.Free=5]="Free",e[e.Locked=6]="Locked"}(ie||(ie={}));const se={[te.e.UP]:{dir:Object.freeze(te.f.UP.clone())},[te.e.DOWN]:{dir:Object.freeze(te.f.DOWN.clone())},[te.e.BACK]:{dir:Object.freeze(te.f.BACK.clone())},[te.e.LEFT]:{dir:Object.freeze(te.f.LEFT.clone())},[te.e.RIGHT]:{dir:Object.freeze(te.f.RIGHT.clone())},[te.e.FORWARD]:{dir:Object.freeze(te.f.FORWARD.clone())}},ne={[te.e.HORIZONTAL_PLANE]:{dir:Object.freeze(te.f.HORIZONTAL_PLANE.clone())}},oe=(()=>{let e=0;const t=new y.Vector3,i=new y.Vector3,s=new y.Vector3,n=new y.Vector3,o=999,r=Object.freeze(te.f.ZERO.clone()),a=Object.keys(se).map((e=>Object.assign(Object.assign({},se[e]),{name:e,angleTo:o}))),h=Object.keys(ne).map((e=>Object.assign(Object.assign({},ne[e]),{name:e,angleTo:o}))),d=e=>(e+3)%2;let l=a[0];return(c,u,p=ie.Axes)=>{if(p===ie.Free)return{position:u.clone(),constrainedAxis:r,axisName:te.e.NONE};if(a.forEach((e=>e.angleTo=o)),h.forEach((e=>e.angleTo=o)),s.copy(u).sub(c),e=s.length(),e<.05)return{position:u.clone(),constrainedAxis:r,axisName:te.e.NONE};n.copy(s).normalize();const g=.05*Math.min(e,1);if(p!==ie.Locked){for(const e of a){const t=(0,v.ZY)(n.angleTo(e.dir));t<l.angleTo&&(l=e),e.angleTo=t}if(l.angleTo>20){const e=Math.abs(s.y);e*e<g&&(l=h[0])}}t.set(c.x*d(l.dir.x),c.y*d(l.dir.y),c.z*d(l.dir.z)),i.set(u.x*Math.abs(l.dir.x),u.y*Math.abs(l.dir.y),u.z*Math.abs(l.dir.z)).add(t);return p===ie.Locked||i.distanceToSquared(u)<g?{position:i.clone(),constrainedAxis:l.dir,axisName:l.name}:{position:u.clone(),constrainedAxis:r,axisName:te.e.NONE}}})(),re=1081,ae=192,he=320,de=128,le={smoothness:.4,perspective:{fov:40,thresholdClose:1,thresholdFar:8,offsetClose:.25,offsetFar:.5,scale:1},ortho:{fov:5,thresholdClose:5,thresholdFar:20,offsetClose:15,offsetFar:30,scale:4}},ce={desktop:ie.Edges,floorplan:ie.Axes,mobile:ie.Edges,alt:ie.Free,shift:ie.PlanarAxes,shiftAlt:ie.EdgesAndPlanarAxes,disabled:ie.Free},ue=.15,pe=.1,ge=.1,me=.5,we=.035,ye=.025,fe="measurements";var ve=i(37262),be=i(92558);class Te{constructor(e){this.contents=e,this.groupInfo=[],this.groupIndices=[],this.groupInfoMap={},this.groupIndicesMap={}}startGroup(e){const t=0===this.groupCount,i=this.contents.length!==this.groupIndices[this.groupCount-1];if(t||i){let t=e.sid;if(!t)for(t=(0,be.fV)();this.groupInfoMap.hasOwnProperty(t);)t=(0,be.fV)();const i=Object.assign(Object.assign({},e),{sid:t});this.groupInfo.push(i),this.groupInfoMap[t]=i,this.groupIndices.push(this.contents.length),this.groupIndicesMap[this.contents.length]=!0}return this.groupIndices.length-1}reset(){this.contents.atomic((()=>{for(let e=this.contents.length-1;e>=0;--e)this.removeFromIdx(e);this.groupIndices=[],this.groupInfo=[],this.groupIndicesMap={}}))}isStartIndex(e){return!!this.groupIndicesMap[e]}*groups(){for(let e=0;e<this.groupCount;++e)yield this.getGroup(e)}*[Symbol.iterator](){for(const e of this.contents)yield e}getGroupStartIndex(e){return this.groupIndices[e]}getGroup(e){const t=this.groupIndices[e],i=this.groupIndices[e+1],s=isNaN(i)?this.contents.length-1:i-1;return new De(e,this.contents,t,s,Object.assign({},this.groupInfo[e]))}getGroupById(e){for(let t=0;t<this.groupInfo.length;t++)if(e===this.groupInfo[t].sid)return this.getGroup(t)}indexOfGroup(e){for(let t=0;t<this.groupInfo.length;t++)if(e(this.groupInfo[t]))return t;return-1}updateGroupInfo(e,t){const i=this.groupInfo[e].sid;delete this.groupInfoMap[i];const s=Object.assign({sid:i},t);this.groupInfo.splice(e,1,s),this.groupInfoMap[i]=s}get groupCount(){return this.groupIndices.length}get length(){return this.contents.length}get(e){return this.contents.get(e)}push(e){if(0===this.groupCount)throw Error("Grouper: Error pushing points when we have no groups!");return this.contents.push(e.clone()),this.contents.length}pop(){return this.removeFromIdx(this.contents.length-1)}removeFromIdx(e){if(e<this.contents.length&&e>=0&&this.contents.length>=0){const t=this.contents.get(e);return this.contents.remove(e),this.removeEmptyGroups(),t}}removeEmptyGroups(){this.contents.length<=this.groupIndices[this.groupCount-1]&&this.removeGroup(this.groupCount-1)}groupFromPointIndex(e){if(0>e||e>=this.length)return-1;let t=this.groupCount-1;for(;e<this.groupIndices[t];)--t;return t}removeGroup(e){if(e>this.groupCount||e<0)return;const t=this.getGroup(e);if(0===t.count)return;const i=this.groupIndices[e];this.groupIndices.splice(e,1),this.groupInfo.splice(e,1),delete this.groupInfoMap[t.info.sid],delete this.groupIndicesMap[i];for(let i=e;i<this.groupCount;++i){const e=this.groupIndices[i],s=e-t.count;this.groupIndices[i]=s,delete this.groupIndicesMap[e],this.groupIndicesMap[s]=!0}this.contents.splice(t.startIndex,t.count)}update(e,t){this.contents.update(e,t.clone())}copy(e,t=!0){return t&&this.reset(),this.contents.atomic((()=>{for(const t of e){this.startGroup(t.info);for(const e of t)this.push(e)}})),this}toString(){return`Grouper: { groupCount: ${this.groupCount}, length: ${this.length}, groups: [${[...this.groups()].map((e=>`${e}`))}]}`}}class De{constructor(e,t,i,s,n){this.index=e,this.grouper=t,this.startIndex=i,this.endIndex=s,this.data=n}*[Symbol.iterator](){for(let e=0;e<this.count;++e)yield this.get(e)}get(e){if(!this.has(e))throw RangeError(`Out of range error ${e} / ${this.count-1}`);return this.grouper.get(this.startIndex+e)}has(e){return e>=0&&this.startIndex+e<=this.endIndex}get count(){return this.endIndex-this.startIndex+1}get info(){return this.data}get isClosed(){const e=this.grouper.get(this.startIndex),t=this.grouper.get(this.endIndex);return this.count>2&&e.distanceTo(t)<=.001}get length(){let e=0,t=null;for(let i=0;i<this.count;i++)t&&(e+=this.get(i).distanceTo(t)),t=this.get(i);return e}get segmentLengths(){const e=[];let t=null;for(let i=0;i<this.count;i++)t&&e.push(this.get(i).distanceTo(t)),t=this.get(i);return e}hasLength(){const e=this.grouper.get(this.startIndex),t=this.grouper.get(this.endIndex);return e&&t&&(this.isClosed||e.distanceTo(t)>.001)}clone(){const e=[],t={get:t=>e[t],contents:e};for(let e=0;e<this.count;e++)t.contents.push(this.get(e));return new De(this.index,t,0,t.contents.length-1,Object.assign({},this.data))}describe(e=this.endIndex){return`GroupSegment${this.index}/${this.startIndex}/${e}}`}equals(e){if(this.count!==e.count||this.index!==e.index)return!1;if((0,ve.NK)(this.info,e.info))return!1;for(let t=0;t<this.count;++t)if(!this.get(t).equals(e.get(t)))return!1;return!0}}var Se,Pe,Ie=i(31546),Me=i(54702),xe=i(35895);!function(e){e[e.ADDED=0]="ADDED",e[e.REMOVED=1]="REMOVED",e[e.UPDATED=2]="UPDATED",e[e.COUNT=3]="COUNT"}(Se||(Se={})),function(e){e[e.ADDED=1]="ADDED",e[e.REMOVED=2]="REMOVED",e[e.UPDATED=4]="UPDATED",e[e.ALL=7]="ALL"}(Pe||(Pe={}));const Re=(e,t)=>{const i=t&Pe.ADDED,s=t&Pe.REMOVED,n=t&Pe.UPDATED,o={};let r;return new xe.gm((()=>e),(t=>r=e.onElementChanged((e=>(o.onAdded=i?e:void 0,o.onRemoved=s?e:void 0,o.onUpdated=n?e:void 0,o))(t))),(e=>{r&&r.cancel()}))};var Ee;!function(e){e[e.x=16711680]="x",e[e.y=32768]="y",e[e.z=255]="z",e[e.free=16777215]="free",e[e.xz=16711935]="xz",e[e.laser=16724312]="laser",e[e.yellow=16776960]="yellow",e[e.white=16777215]="white"}(Ee||(Ee={}));var Ce=i(67944),Ae=i(56512);class Le{constructor(e,t,i,s,n,o,r=(()=>-1),a,h=16777215){this.points=e,this.createPointSubscription=t,this.cameraData=i,this.lineModule=s,this.mainLayer=n,this.lineLayer=o,this.selectedGroup=r,this.getLineDetails=a,this.lineColor=h,this.endpointGeometry=(0,Ae.fc)(),this.linePool=[],this.groupToLines={},this.pointToLines={},this.activeLines=[],this.cameraQuaternion=new y.Quaternion,this.cameraPosition=new y.Vector3,this.cameraProjection=new Ie.M,this.getLinesForPoint=e=>{const t=[];if(this.pointToLines[e])for(const i of this.pointToLines[e]){const e=i.getMesh(Me.B.line),{startIndex:s,endIndex:n,group:o}=e.userData;t.push({endIndex:n,startIndex:s,line:i,group:o})}return t},this.updateMaterialColors(this.lineColor),this.dataSubs=[this.createPointSubscription(Pe.REMOVED,((e,t)=>{this.resetLines()}))]}updateMaterialColors(e){const t=C.V9.lineDefault;this.lineMaterial=this.lineModule.makeLineMaterial(e,!0,{linewidth:t}),this.setStencilState(this.lineMaterial),this.endpointMaterial=this.lineModule.makeEndpointMaterial(e);const i={dashed:!0,dashSize:.025,gapSize:.05,linewidth:C.V9.dottedLineDefault};this.dottedLineMaterial=this.lineModule.makeLineMaterial(e,!1,i),this.setStencilState(this.dottedLineMaterial),this.xLineMaterial=this.lineModule.makeLineMaterial(Ee.x,!1,i),this.yLineMaterial=this.lineModule.makeLineMaterial(Ee.y,!1,i),this.zLineMaterial=this.lineModule.makeLineMaterial(Ee.z,!1,i),this.xzLineMaterial=this.lineModule.makeLineMaterial(Ee.xz,!1,i)}setStencilState(e){e.stencilRef=1,e.stencilFail=y.KeepStencilOp,e.stencilZFail=y.KeepStencilOp,e.stencilZPass=y.KeepStencilOp,e.stencilFunc=y.GreaterStencilFunc,e.stencilWrite=!0}setLineOpacityByGroup(e,t){const i=this.groupToLines[e];if(i)for(const e of i)e.opacity(t)}setLineOpacityByPoint(e,t){const i=this.getLinesForPoint(e);if(i)for(const e of i)e.line.opacity(t)}resetLines(){for(const e of this.lines)e.opacity(0),e.hide();this.groupToLines={},this.pointToLines={},this.lines.length=0}updateAllLines(){if(!(this.points.length<1)){for(let e=0;e<this.points.length;e++)this.updateLine(e);for(const e in this.groupToLines){const t=Number(e),i=this.groupToLines[t];for(const e of i)e.updateSelected(this.selectedGroup()===t)}}}init(){}dispose(){this.deactivate();for(const e of this.linePool)e.dispose();this.endpointGeometry.dispose(),this.dottedLineMaterial.dispose(),this.lineMaterial.dispose(),this.endpointMaterial.dispose(),this.xLineMaterial.dispose(),this.yLineMaterial.dispose(),this.zLineMaterial.dispose()}activate(){for(const e of this.dataSubs)e.renew()}deactivate(){for(const e of this.dataSubs)e.cancel();this.resetLines()}get lines(){return this.activeLines}get dottedMaterial(){return this.dottedLineMaterial}beforeRender(){this.cameraQuaternion.copy(this.cameraData.pose.rotation),this.cameraPosition.copy(this.cameraData.pose.position),this.cameraProjection.copy(this.cameraData.pose.projection)}get xMaterial(){return this.xLineMaterial}get yMaterial(){return this.yLineMaterial}get zMaterial(){return this.zLineMaterial}get xzMaterial(){return this.xzLineMaterial}render(){this.updateAllLines()}updateLine(e){const t=this.points.get(e),i=this.points.get(e+1),s=this.points.groupFromPointIndex(e)===this.points.groupFromPointIndex(e+1);t&&i&&s&&this.setLinePosition(e,t,i)}setLinePosition(e,t,i){let s=this.linePool[e];if(!s){const n=this.points.groupFromPointIndex(e);if(!this.getLineDetails(n,e,e+1).visible)return;const o=C.V9.endpointDefault>.01?this.endpointMaterial.clone():void 0;s=this.lineModule.makeLine(t,i,this.lineMaterial.clone(),o,(()=>!(0,Ce.Pp)(this.cameraProjection))),this.setupLine(s,e),s.setRenderLayer(this.mainLayer)}s.visible||this.setupLine(s,e),this.linePool[e]=s,s.updateResolution(this.cameraData.width,this.cameraData.height),s.updatePositions(t,i),s.updateBillboard({rotation:this.cameraQuaternion,position:this.cameraPosition,projection:this.cameraProjection})}setupLine(e,t){const i=this.points.groupFromPointIndex(t);e.children.forEach((e=>{e.userData.startIndex=t,e.userData.endIndex=t+1,e.userData.group=i,e.layers.mask=this.mainLayer.mask})),e.getMesh(Me.B.line).layers.mask=this.lineLayer.mask,this.activeLines.push(e),this.addLineToGroup(i,e),this.addLineToPoint(t,e),this.addLineToPoint(t+1,e),e.show(),e.opacity(0)}addLineToGroup(e,t){this.groupToLines[e]||(this.groupToLines[e]=[]),this.groupToLines[e].push(t)}addLineToPoint(e,t){this.pointToLines[e]||(this.pointToLines[e]=[]),this.pointToLines[e].push(t)}}var Oe=i(49827),Fe=i(86819),ke=i(23612),Ne=i(72996);class Be extends y.Mesh{}class Ge{constructor(e,t,i,s,n,o,r,a,h,d,l){this.points=e,this.input=t,this.mobile=i,this.cameraData=s,this.renderLayer=n,this.renderOrder=o,this.textRenderer=r,this.getLineDetails=a,this.changeCursor=h,this.getPhase=d,this.setSelectedLine=l,this.meshPool=[],this.textContainer=new y.Object3D,this.textGeometry=new y.PlaneGeometry(1,1),this.tmpMidpoint=new y.Vector3,this.tmpCamPos=new y.Vector3,this.cameraRotation=new y.Quaternion,this.cameraProjection=new Ie.M,this.cameraPosition=new y.Vector3;this.inputSubs=[this.input.registerMeshHandler(Fe.R,Ne.s.isType(Be),((e,t)=>{var i,s;if(this.getPhase()===J.au.IDLE)return this.setSelectedLine(null===(s=null===(i=null==t?void 0:t.parent)||void 0===i?void 0:i.userData)||void 0===s?void 0:s.groupIndex),!0}))],this.mobile||this.inputSubs.push(...this.registerHoverHandlers()),this.deactivate(),this.deactivateInteraction()}registerHoverHandlers(){return[this.input.registerMeshHandler(ke.z,Ne.s.isType(Be),(()=>{this.getPhase()===J.au.IDLE&&this.changeCursor(h.C.FINGER)})),this.input.registerMeshHandler(ke.A,Ne.s.isType(Be),(()=>{this.changeCursor(h.C.DEFAULT)}))]}reset(){for(const e of this.meshPool)e&&(this.input.unregisterMesh(e.collider),this.textContainer.remove(e));this.meshPool=[]}init(){}dispose(){this.textGeometry.dispose()}activate(){}deactivate(){this.reset()}activateInteraction(){for(const e of this.inputSubs)e.renew()}deactivateInteraction(){for(const e of this.inputSubs)e.cancel()}get container(){return this.textContainer}beforeRender(){const e=this.cameraData.pose;this.cameraRotation.copy(e.rotation),this.cameraPosition.copy(e.position),this.cameraProjection.copy(e.projection);const t=(0,Ce.s1)(this.cameraProjection),i=(0,Ce.Pp)(this.cameraProjection),s=this.cameraData.height,n=this.cameraData.zoom(),o=this.cameraData.aspect();for(let e=1;e<this.points.length;++e){const r=e-1,a=this.points.groupFromPointIndex(e),h=this.getLineDetails(a,r,e);if(!h||a!==this.points.groupFromPointIndex(r)){this.removeLabelMesh(e);continue}const d=this.points.get(r),l=this.points.get(e),c=this.setMeshVisible(e,h.labelVisible);if(!c)continue;c.text!==h.labelContents&&(c.text=h.labelContents);const u=this.cameraPosition.distanceTo(c.position);if(this.updateMeshPose(c,d,l,this.cameraRotation,this.cameraPosition,u,h.rotation,i),i||t)c.scaleFactor=ye*n;else{const e=(0,T.D_)(c.position,this.cameraPosition,this.cameraRotation,this.cameraProjection.asThreeMatrix4()),t=Math.abs(e.x);if(t<1){const e=(0,Ce.mY)(this.cameraProjection,this.cameraPosition,c.position,s,ge),i=((0,Oe.uZ)(o,1,2.5)+n)*we,r=1+me-t*me-i;c.scaleFactor=Math.max(Math.min(1/e*r,3),.001)}else c.scaleFactor=.001}}for(let e=this.points.length;e<this.meshPool.length;e++)this.removeLabelMesh(e);this.meshPool=this.meshPool.slice(0,this.points.length)}setTextOpacityByPoint(e,t){const i=this.meshPool[e];i&&(i.opacity=t)}updateMeshPose(e,t,i,s,n,o,r,a){this.tmpMidpoint.copy(t).add(i).multiplyScalar(.5);const h=a?e=>this.tmpCamPos.copy(e).addScaledVector(te.f.UP,.15):e=>this.tmpCamPos.copy(n).sub(e).setLength(.15*o).add(e);e.setPosition(this.tmpMidpoint,h),e.setOrientation(s,r)}render(){}setMeshVisible(e,t){let i=this.meshPool[e];if(!i&&t){i=this.textRenderer.createLabel(),i.setRenderLayer(this.renderLayer),i.renderOrder=this.renderOrder,i.opacity=1,i.visible=!1;const t=this.points.groupFromPointIndex(e);i.userData.groupIndex=t,this.textContainer.add(i),this.input.registerMesh(i.collider,!1),this.meshPool[e]=i}if(i){const e=t?.001:C.iV.LABEL_HIDDEN_OPACITY;if(i.visible=i.opacity>e,!i.visible)return null}return i}removeLabelMesh(e){const t=this.meshPool[e];t&&(this.textContainer.remove(t),t.dispose(),this.input.unregisterMesh(t.collider),this.meshPool[e]=null)}}var ze=i(17878);const Ve=i.p+"images/scope.svg";var Ue=i(87926),Qe=i(13310),_e=i(85992),He=i(85042);const je=i.p+"images/vert_arrows.png",Ze=i.p+"images/surface_grid_planar_256.png";var We=i(12529);class qe{constructor(e,t=ze.o.ALL){this.scene=e,this.layer=t,this.supportsMobile=!0,this.style=He.L.GridPlane,this.alignToNormal=!0,this.xzTex=(0,Ue.p)(je),this.zyTex=(0,Ue.p)(Ze),this.bindings=[],this.onOpacityUpdate=e=>{this.container.children.forEach((t=>{t.isMesh&&(t.material.opacity=Math.max(0,e.opacity.value))}))},this.onPositionUpdate=(e,t)=>{this.container.position.copy(e).addScaledVector(t,.005),this.alignToNormal&&(0,Ce.J2)(this.container,e,t)},this.scale=e=>{this.container.scale.set(e,e,e)},this.onRaycasterUpdate=e=>{e.hit&&e.hit.face&&this.onPositionUpdate(e.hit.point.clone(),e.hit.face.normal)},this.container=new y.Group;const i=new y.PlaneGeometry(.4,.4),s={color:16777215,side:y.DoubleSide,transparent:!0,depthTest:!0,depthWrite:!1};this.xzTex.generateMipmaps=!1,this.xzTex.minFilter=y.LinearFilter,this.xzMaterial=new y.MeshBasicMaterial(Object.assign(Object.assign({},s),{color:65280,map:this.xzTex})),this.xzMaterial.premultipliedAlpha=!1;const n=new y.Mesh(i,this.xzMaterial);n.rotateOnAxis(te.f.LEFT,Math.PI/2),this.zyTex.generateMipmaps=!1,this.zyTex.minFilter=y.NearestFilter,this.zyMaterial=new y.MeshBasicMaterial(Object.assign(Object.assign({},s),{map:this.zyTex})),this.zyMaterial.premultipliedAlpha=!1;const o=new y.Mesh(i,this.zyMaterial);this.container.add(n,o),this.container.children.forEach((e=>{e.renderOrder=We.z.reticule,e.layers.mask=this.layer.mask}))}init(){}render(){}dispose(){this.container.children.forEach((e=>{if(e.isMesh){e.geometry.dispose();const t=e.material;t.dispose(),t.map&&t.map.dispose()}}))}async activate(e){const t=await e.market.waitForData(Qe.Y),i=await e.market.waitForData(_e.P);this.bindings.push(t.onChanged(this.onOpacityUpdate),i.onChanged(this.onRaycasterUpdate)),this.scene.add(this.container)}deactivate(e){for(const e of this.bindings)e.cancel();this.bindings.length=0,this.scene.remove(this.container)}setVisible(e){this.container.visible=e}}var Ye=i(2569),Xe=i(14564);class $e{constructor(e,t,i,s,n,o,r){this.mobile=e,this.pointer=t,this.sceneInfo=i,this.renderToTexture=s,this.getLayer=n,this.issueCommand=o,this.editing=!1,this.editingStateChange=!1,this.setOverlay=e=>{this.issueCommand(new Xe.u({color:e?Xe.u.COLOR_DIM:null}))},this.setupCursorRenderCamera=()=>{const e=new y.PerspectiveCamera(le.perspective.fov,1,.1,100);e.name="Cursor Peek Camera";const t=ze.o.ALL,i=["measurement-mode","measurement3d"];for(const e of i)t.removeLayers(this.getLayer(e));e.layers.mask=t.mask,e.updateProjectionMatrix();return{camera:e,update:(t,i,s)=>{e.fov=t,e.near=i,e.far=s,e.updateProjectionMatrix()}}};const a=(0,Ue.p)(Ve),h=new y.Vector2,d=e=>{const t=this.rttView.height,i=this.rttView.width,s=this.sceneInfo.cameraData;let n=t/2;const o=-i/2;n=e.y<t/2+n?t+n:-n;const r=e.x+o,a=s.height-e.y-n;return h.set(r,a)};this.cursorMesh=new qe(this.sceneInfo.scene,this.getLayer("cursor-mesh")),this.cursorMesh.setVisible(!1);const l=new y.Vector3,c=new y.Quaternion,u=new y.Vector2;let p,g,m=r(),w=le.perspective;this.renderIntersection=(e,t,n)=>{p||(g=this.setupCursorRenderCamera(),p=g.camera,g.update(le.perspective.fov,.1,100)),m!==r()&&(w=r()?le.ortho:le.perspective,this.cursorMesh.scale(w.scale),g.update(w.fov,.1,100),m=r());const o=this.editingStateChange?1:le.smoothness;if(t){if(i.playerCamera.getWorldPosition(l),i.playerCamera.getWorldQuaternion(c),r()){const e=i.cameraData.zoom(),s=(0,Ye.dS)(e,w.thresholdClose,w.thresholdFar,w.offsetClose,w.offsetFar);p.position.copy(t.point).addScaledVector(te.f.UP,s),p.quaternion.copy(c)}else{const e=(0,Ye.dS)(t.distance,w.thresholdClose,w.thresholdFar,w.offsetClose,w.offsetFar),i=l.sub(t.point).setLength(e).add(t.point);p.position.lerp(i,o),p.lookAt(t.point)}p.updateMatrixWorld(),this.setOverlay(!1),s.render(e,i.scene.scene,p),this.setOverlay(!0),u.lerp(d(n),o),s.renderToScreen(e,!1,u,a)}this.editingStateChange=!1}}init(){}dispose(){}activate(){this.sceneInfo.scene.addChild(a.a.Root,this.cursorMesh.container);const e=this.mobile?de:this.sceneInfo.cameraData.height>re?he:ae;this.rttView=this.renderToTexture.createRenderTarget2D(e,e,{format:y.RGBAFormat},!1)}setMeasuringPhase(e){const t=this.mobile?!!J.Pj.mobile[e]:!!J.Pj.desktop[e];t!==this.editing&&(this.editingStateChange=!0,this.editing=t,this.cursorMesh.setVisible(this.editing))}deactivate(){this.sceneInfo.scene.removeChild(a.a.Root,this.cursorMesh.container),this.renderToTexture.disposeRenderTarget2D(this.rttView),this.editing=!1}beforeRender(){this.editing&&(this.hit=this.mobile?this.pointer.lastIntersection:this.pointer.getIntersection(),this.hit&&this.cursorMesh.onPositionUpdate(this.hit.point,this.hit.normal))}render(){if(this.editing&&this.hit){const{screenPosition:e}=(0,T.q9)(this.sceneInfo.cameraData,this.hit.point);this.renderIntersection(this.rttView,this.hit,e)}}}var Ke,Je=i(26269),et=i(82814),tt=i(3968);!function(e){e[e.SnapPoint=1]="SnapPoint",e[e.SnapLine=2]="SnapLine",e[e.AxisAny=3]="AxisAny",e[e.AxisX=4]="AxisX",e[e.AxisY=5]="AxisY",e[e.AxisZ=6]="AxisZ",e[e.Mesh=7]="Mesh",e[e.RoomMesh=8]="RoomMesh",e[e.LinePoint=9]="LinePoint",e[e.LineSegment=10]="LineSegment"}(Ke||(Ke={}));class it extends tt.FM{constructor(e,t,i){super(e,t),this.featureType=i}}class st extends tt.FM{constructor(e,t,i){super(e,t),this.featureType=i}}const nt={[te.e.UP]:Ke.AxisY,[te.e.DOWN]:Ke.AxisY,[te.e.FORWARD]:Ke.AxisZ,[te.e.BACK]:Ke.AxisZ,[te.e.LEFT]:Ke.AxisX,[te.e.RIGHT]:Ke.AxisX,[te.e.HORIZONTAL_PLANE]:Ke.AxisY,NONE:void 0};var ot;!function(e){e[e.UserAxis=1]="UserAxis",e[e.UserPoint=2]="UserPoint",e[e.UserLine=3]="UserLine",e[e.ModelFeature=4]="ModelFeature"}(ot||(ot={}));const rt={[Ke.LinePoint]:ot.UserPoint,[Ke.LineSegment]:ot.UserLine,[Ke.AxisAny]:ot.UserAxis,[Ke.AxisX]:ot.UserAxis,[Ke.AxisY]:ot.UserAxis,[Ke.AxisZ]:ot.UserAxis,[Ke.Mesh]:ot.ModelFeature,[Ke.RoomMesh]:ot.ModelFeature,[Ke.SnapLine]:ot.ModelFeature,[Ke.SnapPoint]:ot.ModelFeature};class at{constructor(e,t,i,s){this.constraint=t,this.meshQuery=i,this.point=new y.Vector3,this.normal=new y.Vector3,ht(e,i)?this.updateFromIntersection(e,t):dt(e,i)&&s&&this.updateFromSnapIntersection(e,t,s),this.source=e}updatePoint(e){return this.point.copy(e),this.source.point.copy(e),this}updateFromIntersection(e,t){return this.source=e,this.updateContents(t,e.point,e.face.normal,e.distance,e.object),this}updateFromSnapIntersection(e,t,i){return this.source=e,this.updateContents(t,e.point,i,e.distance,e.object),this}copy({constraint:e,point:t,normal:i,distance:s,object:n}){this.updateContents(e,t,i,s,n)}clone(){return new at(this.source,this.constraint,this.meshQuery)}updateContents(e,t,i,s,n){this.constraint=e,this.point.copy(t),this.normal.copy(i),this.distance=s,this.object=n;const o=this.meshQuery.roomIdFloorIdFromObject(n);o&&(this.roomId=o.roomId||null,this.floorId=o.floorId),this.featureType=(e=>{if(e)return"featureType"in e&&void 0!==e.featureType?e.featureType:e instanceof y.Vector3||e instanceof tt.UQ?Ke.SnapPoint:Je.$4.isRoomMesh(e)?Ke.RoomMesh:e instanceof et.S?Ke.Mesh:e instanceof y.Line3||e instanceof tt.FM?Ke.SnapLine:void 0})(n)}}const ht=(e,t)=>e&&"face"in e&&void 0!==e.face&&(t.floorIdFromObject(e.object)||e.object.floorId),dt=(e,t)=>e&&"isLineOctreeIntersection"in e&&t.floorIdFromObject(e.object),lt=(()=>{class e extends y.Object3D{constructor(e,t,i,s){super(),this.floorId=e,this.roomId=t,this.meshGroup=i,this.meshSubGroup=s}}return(t,i,s,n,o,r,a)=>({point:t,object:new e(n,o,r,a),face:{a:0,b:1,c:2,normal:i,materialIndex:0},distance:s})})();var ct=i(38042),ut=i(16769),pt=i(80592),gt=i(16782);const mt=e=>e instanceof Fe.R?e.button===gt.M.PRIMARY:e.buttons===gt.r.PRIMARY;class wt extends y.Mesh{constructor(e,t,i,s,n,o,r,a,h,d,l,c){super(),this.pointGroups=e,this.input=t,this.cameraData=i,this.mobile=s,this.changeCursor=n,this.getPhase=o,this.changePhase=r,this.restorePreviousPhase=a,this.setSelectedLine=h,this.getSelected=d,this.onDragStart=l,this.onDragEnd=c,this.inputSubscriptions=[],this.groupVisible=[],this.raycast=(()=>{const e=new y.Vector3,t=new y.Vector3,i=new y.Vector3,s=(e,t,i)=>{if(e.isOrtho())return i.copy(t);{const s=C.iV.OFFSET_TOWARDS_CAMERA;return i.copy(e.position).sub(t).setLength(s).add(t)}};return(n,o)=>{const{pose:r,width:a}=this.cameraData,h=this.mobile?3:-2,d=C.V9.lineDefault+h,l=r.projection.asThreeMatrix4(),c=r.position;let u,p=0,g=0;for(let o=0;o<this.pointGroups.groupCount;++o){const h=this.pointGroups.getGroup(o);if(!(void 0!==this.editingGroup&&this.editingGroup!==o)&&this.groupVisible[o]){for(let m=0;m<h.count-1;++m){const w=s(r,h.get(m),t),y=s(r,h.get(m+1),i);if(w&&y){const t=n.ray.distanceSqToSegment(w,y,void 0,e),i=c.distanceTo(e);let s=(0,Ce._U)(i,l,a)*d;if(s*=s,t<s){let i,r=e;this.editingPointIndex?i=this.editingPointIndex:w.distanceToSquared(e)<2*s?(i=g,r=w):y.distanceToSquared(e)<2*s&&(i=g+1,r=y),(!u||t<p)&&(u={distance:n.ray.origin.distanceTo(r),point:r,object:this,instanceId:o,index:i},p=t)}}g++}g++}else g+=h.count}u&&o.push(u)}})(),this.inputSubscriptions.push(...this.registerCommonInput()),s||this.inputSubscriptions.push(...this.registerHoverInput()),this.deactivate()}activate(){this.input.registerMesh(this,!1),this.inputSubscriptions.forEach((e=>e.renew()))}deactivate(){this.input.unregisterMesh(this),this.inputSubscriptions.forEach((e=>e.cancel()))}dispose(){this.deactivate()}setEditingGroup(e){this.editingGroup=e}setGroupVisible(e,t){this.groupVisible[e]=t}validJoint(e){return!!e&&void 0!==e.index}registerHoverInput(){return[this.input.registerMeshHandler(ke.z,Ne.s.isType(wt),((e,t,i)=>{this.getPhase()===J.au.IDLE&&this.changeCursor(i&&void 0!==i.index?h.C.GRAB:h.C.FINGER)})),this.input.registerMeshHandler(ke.A,Ne.s.isType(wt),((e,t,i)=>{this.getPhase()===J.au.IDLE&&this.changeCursor(h.C.DEFAULT)}))]}registerCommonInput(){return[this.input.registerMeshHandler(Fe.R,Ne.s.isType(wt),((e,t,i)=>{if(!mt(e))return!1;if(this.getPhase()!==J.au.IDLE)return!1;const s=i&&void 0!==i.instanceId?i.instanceId:-1,n=this.getSelected()===s?-1:s;return this.setSelectedLine(n),!0})),this.input.registerMeshHandler(pt._t,Ne.s.isType(wt),((e,t,i)=>!!mt(e)&&(!!J.WN[this.getPhase()]&&(!this.validJoint(i)||(!i||void 0===i.instanceId||(this.getPhase()===J.au.EDITING||(this.editingPointIndex=i.index,this.onDragStart(i.instanceId),this.setSelectedLine(i.instanceId),this.changePhase(J.au.EDITING),this.mobile||this.changeCursor(h.C.GRABBING)),!0)))))),this.input.registerMeshHandler(pt._R,Ne.s.isType(wt),((e,t,i)=>this.getPhase()===J.au.EDITING&&(this.editingPointIndex=void 0,this.restorePreviousPhase(),this.onDragEnd(),this.mobile||this.changeCursor(h.C.DEFAULT),!0)))]}}const yt=new w.Z("snapping");class ft{constructor(e,t,i,s,n,o){this.raycaster=e,this.getConstraintStyle=t,this.floorsViewData=s,this.viewmodeData=n,this.meshQuery=o,this.origin=null,this.planeNormal=new y.Vector3,this.plane=new y.Plane,this.ray=new y.Ray,this.originChangedListeners=[],this.registeredSnapFeatures={[ot.UserAxis]:[],[ot.UserLine]:[],[ot.UserPoint]:[],[ot.ModelFeature]:[]},this.clearOrigin=()=>{this.origin=null,this.originChangedListeners.forEach((e=>e(null)))},this.setOrigin=(e,t=!1)=>{this.origin&&!t||(this.origin=e,this.plane.setFromNormalAndCoplanarPoint(this.origin.normal,this.origin.point),this.originChangedListeners.forEach((e=>e(this.origin))),yt.debug("Updating origin",this.origin,{forceUpdate:t}))},this.setOriginFromPointer=e=>{if(this.origin)return;const t=this.getMeshIntersection();if(!t)return;const i=new at(t,this.getConstraintStyle(),this.meshQuery);e&&i.updatePoint(e),this.setOrigin(i,!0)},this.snapFeatures=e=>this.registeredSnapFeatures[e].reduce(((e,t)=>e.concat(t.features)),[]),this.addSnapFeatures=(e,t,i)=>{const s=rt[t];this.registeredSnapFeatures[s].push({owner:e,features:i}),yt.debug(`Adding ${i.length} snap feature groups`,Ke[t],t)},this.removeSnapFeatures=(e,t)=>{const i=rt[t],s=this.registeredSnapFeatures[i].findIndex((t=>t.owner===e));if(-1!==s){const e=this.registeredSnapFeatures[i].splice(s,1);yt.debug(`Removing ${e.length} snap feature groups`,Ke[t],t)}else yt.debug(`removeTemporarySnapFeature: ${t} ${Ke[t]} not found from`,e,this.registeredSnapFeatures)},this.filters={nop:e=>!0,isNotMeasurementInput:e=>!(e instanceof wt),meshVisible:e=>!!(0,ut.Pv)(e)&&(!this.viewmodeData.isDollhouse()||this.floorsViewData.isCurrentMeshGroupOrAllFloors(e.meshGroup)),visibleFloor:e=>{const t=e.object;return!t||!t.meta||null==t.meta.meshGroup||this.floorsViewData.isCurrentMeshGroupOrAllFloors(t.meta.meshGroup)},userPoints:e=>{if(void 0===e.object)return!1;if((t=e.object)&&t instanceof y.Vector3)for(const t of this.snapFeatures(ot.UserPoint))if(t.equals(e.object))return!0;var t;return!1},userLines:e=>{if(void 0===e.object)return!1;if((t=e.object)&&"isSnapAxisLine3"in t||"isSnapUserLine3"in t||"isSnapLine3"in t||"start"in t&&"end"in t&&"closestPointToPoint"in t){for(const t of this.snapFeatures(ot.UserLine))if(t.equals(e.object))return!0;for(const t of this.snapFeatures(ot.UserAxis))if(t.equals(e.object))return!0}var t;return!1},userFeatures:e=>this.filters.userPoints(e)||this.filters.userLines(e)},this.meshSnapRadius=i?ue:pe}preload(){this.raycaster.snapping.preloadMeshSnapping()}getMeshIntersection(e){let t=[];const i=this.viewmodeData.isFloorplan();if(e&&e.origin&&e.normal)t=this.raycaster.picking.cast(e.origin,e.normal,this.filters.meshVisible);else if(i){const e=this.floorsViewData.getHighestVisibleFloor(),i=new y.Vector3(0,1,0),s=(new y.Plane).setFromNormalAndCoplanarPoint(i,new y.Vector3(0,e.boundingBox.max.y,0)),n=new y.Vector3;if(this.raycaster.pointer.pointerRay.intersectPlane(s,n)){const s=this.raycaster.pointer.pointerRay.origin.distanceTo(n);t=[lt(n,i,s,e.id,null,e.meshGroup,null)]}}else t=this.raycaster.pointer.cast(this.filters.meshVisible);const s=t[0];return ht(s,this.meshQuery)?s:null}getIntersection(e){const t=this.getMeshIntersection(e);if(!t)return null;this.cachedHit||(this.cachedHit=new at(t,this.getConstraintStyle(),this.meshQuery));const i=this.cachedHit.updateFromIntersection(t,this.getConstraintStyle()),s=this.raycaster.pointer.pointerRay;this.ray.set(s.origin,s.direction),this.planeNormal.copy(i.normal);switch(this.getConstraintStyle()){case ie.Free:return i;case ie.Axes:return this.lockToWorldAxes(i);case ie.PlanarAxes:const e=[...this.snapFeatures(ot.UserAxis),...this.snapFeatures(ot.UserLine),...this.snapFeatures(ot.UserPoint)];return this.softSnapToEdges(i,e,this.filters.userFeatures);case ie.Edges:const t=[...this.snapFeatures(ot.UserLine),...this.snapFeatures(ot.UserPoint)];return this.softSnapToEdges(i,t,this.filters.visibleFloor);case ie.EdgesAndPlanarAxes:const s=[...this.snapFeatures(ot.UserAxis),...this.snapFeatures(ot.UserLine),...this.snapFeatures(ot.UserPoint)];return this.softSnapToEdges(i,s,this.filters.visibleFloor)}return i}get lastIntersection(){return this.cachedHit}onOriginChanged(e,t=!1){const i={renew:()=>{this.originChangedListeners.push(e)},cancel:()=>{(0,ct.bX)(this.originChangedListeners,e)}};return t&&i.renew(),i}lockToWorldAxes(e){if(this.origin){const t=oe(this.origin.point,e.point,ie.Axes);return this.cachedHit.copy(e),this.cachedHit.point.copy(t.position),this.cachedHit.constraint="NONE"!==t.axisName?ie.Axes:ie.Free,this.cachedHit.featureType=nt[t.axisName],this.cachedHit}return e}softSnapToEdges(e,t,i){const s=this.origin?this.origin.point:e.point,n=this.origin?this.origin.normal:e.normal;this.raycaster.snapping.add(...t);const o=this.raycaster.snapping.cast(this.ray,this.meshSnapRadius,s,n).filter(i),r=this.findClosestVisible(o);return this.raycaster.snapping.remove(...t),r?(this.cachedHit.updateFromSnapIntersection(r,this.getConstraintStyle(),n),this.cachedHit):e}findClosestVisible(e){let t=null;const i=new y.Vector3;for(const s of e){i.copy(s.point).sub(this.ray.origin).normalize();const e=this.raycaster.picking.pick(this.ray.origin,i,this.filters.meshVisible);if(!e||e.distance>s.distance-.05){t=s;break}}return t?{isLineOctreeIntersection:!0,distance:t.distance,distanceToRay:t.distanceToRay,point:t.point,object:t.object}:null}}var vt=i(80361);class bt{constructor(e,t,i,s){this.points=e,this.createPointSubscription=t,this.pointer=i,this.mobileCreateHackJob=s,this.subscriptions=[],this.lineSegments=[],this.updateSnapping=e=>{this.lineSegments.length>0&&(this.pointer.removeSnapFeatures(this,Ke.LineSegment),this.lineSegments.length=0);for(let t=0;t<this.points.length;t++)if(t!==e&&t!==e-1&&t!==e+1&&!this.points.isStartIndex(t)){const e=this.points.get(t),i=this.points.get(t-1);this.lineSegments.push(new st(i,e,Ke.LineSegment))}this.lineSegments.length>0&&this.pointer.addSnapFeatures(this,Ke.LineSegment,this.lineSegments)}}init(){}dispose(){}activate(e){let t=-1,i=-1;const s=(0,vt.D)((()=>this.updateSnapping(this.points.length)),16);this.subscriptions.push(this.createPointSubscription(Pe.ADDED,s,!0),this.createPointSubscription(Pe.REMOVED,s,!0),this.createPointSubscription(Pe.UPDATED,((e,s)=>{s===t||this.mobileCreateHackJob()&&s===i||(this.updateSnapping(s),i=t,t=s)}),!0))}deactivate(){this.subscriptions.forEach((e=>e.cancel())),this.subscriptions.length=0,this.pointer.removeSnapFeatures(this,Ke.LinePoint),this.pointer.removeSnapFeatures(this,Ke.LineSegment)}beforeRender(){}render(){}}class Tt{constructor(e,t,i,s,n,o){this.points=e,this.pointer=i,this.getPhase=s,this.onDrag=n,this.onDragEnd=o,this.inputSubscriptions=[],this.onDragBegin=(e,t,i)=>{if(!J.q8[this.getPhase()])return!1;if(!i||void 0===i.index)return!1;const s=this.points.isStartIndex(i.index)?i.index+1:i.index-1,n=this.points.get(s);return this.pointer.clearOrigin(),this.pointer.setOriginFromPointer(n),!0},this.onDragEndEvent=()=>!!J.q8[this.getPhase()]&&(this.onDragEnd(),this.pointer.clearOrigin(),!0),this.onDragEvent=(e,t,i)=>{if(e.buttons!==gt.r.PRIMARY)return!1;if(!J.q8[this.getPhase()])return!1;if(!i||void 0===i.index||void 0===i.instanceId)return!1;const s=this.pointer.getIntersection();return s&&this.points.update(i.index,s.point),this.onDrag(i.instanceId),!0},this.inputSubscriptions.push(t.registerMeshHandler(pt.E0,Ne.s.isType(wt),this.onDragBegin),t.registerMeshHandler(pt._t,Ne.s.isType(wt),this.onDragEvent),t.registerMeshHandler(pt._R,Ne.s.isType(wt),this.onDragEndEvent)),this.deactivate()}activate(){for(const e of this.inputSubscriptions)e.renew()}deactivate(){for(const e of this.inputSubscriptions)e.cancel()}}var Dt=i(67678);class St{constructor(e,t,i,s,n,o,r){this.lines=e,this.getLinesForPoint=t,this.editingMaterial=i,this.createPointSubscription=s,this.getPhase=o,this.getSelected=r,this.bindings=[],this.onDragEnd=e=>{for(const e of this.lines)e.restoreLineMaterial()},this.onClick=(e,t,i)=>{if(this.getPhase()!==J.au.IDLE)return!1;for(const e of this.lines)e.restoreLineMaterial();if(!i||void 0===i.index)return!1;if(e.down){const e=i.index;void 0!==e&&this.styleLines(e)}return!1},this.styleLines=e=>{const t=this.getLinesForPoint(e);for(const e of t)e.group===this.getSelected()&&e.line.overrideLineMaterial(this.editingMaterial)},this.bindings.push(n.registerMeshHandler(Dt.er,Ne.s.isType(wt),this.onClick),n.registerUnfilteredHandler(pt._R,this.onDragEnd),...this.setupLineStyler(this.createPointSubscription)),this.deactivate()}activate(){for(const e of this.bindings)e.renew()}deactivate(){for(const e of this.bindings)e.cancel()}setupLineStyler(e){return[e(Pe.ADDED,(()=>{const e=this.lines[this.lines.length-1];e&&e.restoreLineMaterial()}),!0),e(Pe.UPDATED,((e,t)=>{this.styleLines(t)}),!0)]}}var Pt=i(62017),It=i(67238);class Mt{constructor(e,t,i,n,o,r,a,h,d,l){this.points=e,this.setSelected=t,this.pointer=i,this.changePhase=n,this.getPhase=o,this.isFloorplan=r,this.currentFloorId=a,this.currentRoomId=h,this.currentLayerId=d,this.inferRoomAssociation=l,this.id=Mt,this.onGroupCreated=e=>null,this.onGroupAddPoint=()=>null,this.onDone=()=>null,this.onEdit=e=>null,this.previousPhase=J.au.IDLE,this.currentLinePoints=0,this.previousPoint=new y.Vector3,this.inputSubscriptions=[],this.log=new w.Z("measurement-creator"),this.isReadonly=!1,this.createNewLine=e=>{const t=this.inferRoomAssociation(e),i=e.roomId||t.roomId||this.currentRoomId()||void 0,n=e.floorId||t.floorId||this.currentFloorId();if(this.log.debug(`Starting measurement: floorId="${n}" roomId="${i}"`),!n)throw new It.H(`Cannot create new line on invalid floor '${n}'`);const o={visible:!0,roomId:i,floorId:n,type:this.isFloorplan()?s.FloorplanOnly:s.ThreeD,text:"",created:new Date,modified:new Date,temporary:this.isReadonly,layerId:this.currentLayerId()},r=this.points.startGroup(o);this.currentGroup=r,this.points.push(e.point),this.currentLinePoints=1,this.setSelected(r);const a=this.points.getGroup(r);this.onGroupCreated(a.info.sid),this.pointer.setOrigin(e,!0)},this.addPointToLine=e=>{this.previousPoint.copy(e.point),this.points.push(e.point),++this.currentLinePoints,this.onGroupAddPoint(),this.pointer.setOrigin(e,!0)},this.updateLastPoint=e=>{this.points.update(this.points.length-1,e.point)},this.getIntersection=e=>this.pointer.getIntersection(e),this.setPhase=e=>{const t=this.getPhase();e!==t&&(this.previousPhase=t,this.changePhase(e))},this.restorePreviousPhase=()=>{this.setPhase(this.previousPhase)}}start(){if(this.getPhase()===J.au.IDLE){this.previousPoint.set(1e3,1e3,1e3),this.setPhase(J.au.CREATING),this.setSelected(-1);for(const e of this.inputSubscriptions)e.renew()}}cancelSubs(){for(const e of this.inputSubscriptions)e.cancel()}stop(){this.cancelSubs(),this.currentLinePoints=0,this.setSelected(-1),this.setPhase(J.au.IDLE),this.pointer.clearOrigin(),this.onDone()}syncReadonly(e){this.isReadonly=e}}class xt extends Mt{constructor(e,t,i,s,n,o,r,a,h,d,l,c,u,p,g){super(e,t,s,n,h,l,c,u,p,g),this.setCreatePointProgress=o,this.updateCreatePointHit=r,this.toggleCameraMovement=a,this.continuous=d,this.onLongPressSuccess=e=>{this.log.debug("onLongPressSuccess while in phase:",J.au[this.getPhase()]),this.getPhase()===J.au.CREATING?(this.createNewLine(e),this.addPointToLine(e)):this.getPhase()===J.au.CREATING_NEXT_POINT&&(this.continuous()?(this.updateLastPoint(e),this.addPointToLine(e)):this.updateLastPoint(e)),this.setPhase(J.au.POINT_PLACED)},this.onLongPressStart=e=>{if(e.buttons===gt.r.PRIMARY&&(this.getPhase()===J.au.CREATING||this.getPhase()===J.au.CREATING_NEXT_POINT)){const e=this.getIntersection();e&&(this.previousPoint.equals(e.point)||(this.setPhase(J.au.CONFIRMING_POINT),this.toggleCameraMovement(!1),this.setCreatePointProgress(Date.now(),xt.longPressCreateThreshold),this.updateCreatePointHit(e),this.previousPhase===J.au.CREATING_NEXT_POINT&&(this.updateLastPoint(e),this.toggleLastPointDraggable(!1)),this.creatingPointTimeout=window.setTimeout((()=>{this.restorePreviousPhase(),this.onLongPressSuccess(e),this.toggleLastPointDraggable(!0)}),xt.longPressCreateThreshold)))}},this.onLongPressEnd=()=>{this.getPhase()===J.au.CONFIRMING_POINT&&(this.log.debug("onLongPressEnd, cancelling confirmation"),this.setCreatePointProgress(0,xt.longPressCreateThreshold),window.clearTimeout(this.creatingPointTimeout),this.toggleCameraMovement(!0),this.restorePreviousPhase()),this.getPhase()===J.au.CREATING_NEXT_POINT&&this.points.update(this.points.length-1,this.points.get(this.points.length-2)),this.setPlacedtoCreatePhase()},this.onDrag=()=>{const e=this.getIntersection();e&&(this.setPlacedtoCreatePhase(),this.setPhase(J.au.EDITING),this.previousPhase===J.au.CREATING_NEXT_POINT?this.updateLastTwoPoints(e):this.previousPhase===J.au.CREATING&&this.updateLastPoint(e))},this.onDragEnd=()=>{this.getPhase()===J.au.EDITING&&this.restorePreviousPhase(),this.getPhase()!==J.au.CREATING&&this.getPhase()!==J.au.CREATING_NEXT_POINT||(this.toggleLastPointDraggable(!1),this.toggleCameraMovement(!0))},this.toggleLastPointDraggable=e=>{e?(this.dragSub.renew(),this.dragEndSub.renew()):(this.dragSub.cancel(),this.dragEndSub.cancel())},this.updateLastTwoPoints=e=>{this.points.update(this.points.length-1,e.point),this.points.update(this.points.length-2,e.point)},this.dragSub=i(pt._t,this.onDrag),this.dragEndSub=i(pt._R,this.onDragEnd),this.inputSubscriptions.push(i(Pt.Vh,this.onLongPressStart),i(Pt.pt,this.onLongPressEnd)),this.dragSub.cancel(),this.dragEndSub.cancel(),this.cancelSubs()}start(){super.start()}stop(){if(this.getPhase()===J.au.CREATING_NEXT_POINT)if(this.continuous())this.points.pop();else{const e=this.points.getGroup(this.currentGroup);this.points.removeFromIdx(e.startIndex)}super.stop()}setPlacedtoCreatePhase(){this.getPhase()===J.au.POINT_PLACED&&(this.continuous()?(this.previousPhase===J.au.CREATING||this.previousPhase===J.au.CREATING_NEXT_POINT)&&this.setPhase(J.au.CREATING_NEXT_POINT):this.previousPhase===J.au.CREATING?this.setPhase(J.au.CREATING_NEXT_POINT):this.previousPhase===J.au.CREATING_NEXT_POINT&&this.setPhase(J.au.CREATING))}}xt.longPressCreateThreshold=500;class Rt extends Mt{constructor(e,t,i,s,n,o,r,a,h,d,l,c,u){super(e,t,s,n,o,r,a,h,d,c),this.continuous=l,this.meshQuery=u,this.onCreate=e=>{const t=this.previousPoint.distanceTo(e.point)>.01;if(t||2!==this.currentLinePoints){if(this.getPhase()===J.au.CREATING)return this.createNewLine(e),this.addPointToLine(e),void this.setPhase(J.au.CREATING_NEXT_POINT);t&&this.getPhase()===J.au.CREATING_NEXT_POINT&&(this.continuous()?(this.updateLastPoint(e),this.addPointToLine(e)):this.finishLine(e))}else{const t={origin:e.point.addScaledVector(e.normal,.05),normal:e.normal},i=this.pointer.getMeshIntersection(t);if(i)if(this.continuous()){this.points.pop();const e=new at(i,ie.Free,this.meshQuery);this.addPointToLine(e),this.addPointToLine(e),this.setPhase(J.au.CREATING_NEXT_POINT)}else this.finishLine(new at(i,ie.Free,this.meshQuery))}},this.onMouseMove=()=>{if(this.getPhase()===J.au.CREATING_NEXT_POINT){const e=this.getIntersection();e&&this.updateLastPoint(e)}},this.onMouseClick=e=>{if(e.button!==gt.M.PRIMARY||this.getPhase()===J.au.IDLE)return;const t=this.getIntersection();t&&this.onCreate(t)},this.inputSubscriptions.push(i(Dt.mE,this.onMouseMove),i(Fe.R,this.onMouseClick)),this.cancelSubs()}start(){super.start()}stop(){this.getPhase()===J.au.CREATING_NEXT_POINT&&(this.points.pop(),this.currentLinePoints<3&&this.points.pop()),super.stop()}finishLine(e){this.points.pop(),this.addPointToLine(e),this.setPhase(J.au.CREATING),this.onDone()}}var Et=i(10385),Ct=i(94046),At=i(89553),Lt=i(89570),Ot=i(6667),Ft=i(32597),kt=i(31362),Nt=i(51180);class Bt{constructor(e,t,i,s,n){this.pointer=e,this.mobile=t,this.getPhase=i,this.scene=s,this.getLayer=n,this.subscriptions=[],this.editing=!1,this.axisLines=[],this.axisAlignmentHelper=new y.Object3D,this.updateSnapping=e=>{if(this.axisLines.length>0&&(this.pointer.removeSnapFeatures(this,Ke.AxisAny),this.axisLines.length=0),e){this.axisAlignmentHelper.position.copy(e.point);const t=(0,Ce.J2)(this.axisAlignmentHelper,e.point,e.normal);this.axisAlignmentHelper.updateMatrixWorld(!0);const i=this.axisAlignmentHelper.matrixWorld,s=100,n=(e,t,i,n)=>{const o=new it(e.clone().multiplyScalar(s),t.clone().multiplyScalar(s),n);return o.applyMatrix4(i),o},o=(new y.Matrix4).copyPosition(i);this.axisLines.push(n(te.f.UP,te.f.DOWN,o,Ke.AxisY)),t||this.axisLines.push(n(te.f.FORWARD,te.f.BACK,i,Ke.AxisY),n(te.f.UP,te.f.DOWN,i,Ke.AxisX),n(te.f.LEFT,te.f.RIGHT,i,Ke.AxisZ)),this.axisLines.length>0&&this.pointer.addSnapFeatures(this,Ke.AxisAny,this.axisLines)}}}init(){}dispose(){}activate(){this.subscriptions.push(this.pointer.onOriginChanged(this.updateSnapping,!0)),this.axisLineRenderer=new Gt(this.scene,this.getLayer("cursor-mesh"))}deactivate(){this.subscriptions.forEach((e=>e.cancel())),this.subscriptions.length=0,this.pointer.removeSnapFeatures(this,Ke.AxisAny),this.axisLineRenderer.dispose(),this.axisLineRenderer=null}beforeRender(){const e=this.getPhase(),t=this.mobile?!!J.Pj.mobile[e]:!!J.Pj.desktop[e];t!==this.editing&&(this.editing=t,this.axisLineRenderer.clearLines())}render(){this.editing&&this.axisLineRenderer.render(this.pointer.lastIntersection,this.axisLines)}}class Gt{constructor(e,t){this.scene=e,this.layer=t,this.offsetFromMesh=.0075,this.featureColors={[Ke.AxisX]:Ee.x,[Ke.AxisZ]:Ee.z,[Ke.AxisY]:Ee.y},this.axesVisibleInConstraints={[ie.EdgesAndPlanarAxes]:!0,[ie.Axes]:!0,[ie.PlanarAxes]:!0},this.linesActive=[],this.linesFree=[],this.axesVisible=[],this.axisMat=new y.LineBasicMaterial({color:4095,linewidth:1,opacity:.75,transparent:!0,depthWrite:!1,depthTest:!0}),this.render=(e,t)=>{if(e&&this.axesVisibleInConstraints[e.constraint]&&t.length>0){if(t.length!==this.axesVisible.length)this.clearLines();else{this.axesVisible.every(((e,i)=>e.equals(t[i])))||this.clearLines()}if(this.container.parent!==this.scene.scene){for(const e of t){const t=this.getMesh(e);t.material.color.setHex(this.featureColors[e.featureType]),this.container.add(t),this.linesActive.push(t)}this.axesVisible=t.map((e=>e)),this.scene.addChild(a.a.Root,this.container),this.container.position.copy(e.normal).multiplyScalar(this.offsetFromMesh),this.container.updateMatrixWorld(!0)}}else this.clearLines()},this.clearLines=()=>{if(0!==this.linesActive.length){for(;this.linesActive.length>0;){const e=this.linesActive.pop();e&&(this.container.remove(e),this.linesFree.push(e))}this.scene.removeChild(a.a.Root,this.container)}},this.container=new y.Object3D}getMesh(e){let t=this.linesFree.pop();return t?t.geometry.setFromPoints([e.start,e.end]):(t=new zt(e,this.axisMat.clone()),t.layers.mask=this.layer.mask),t}dispose(){for(this.clearLines();this.linesFree.length>0;){const e=this.linesFree.pop();e&&(this.container.remove(e),e.geometry.dispose(),e.material.dispose())}this.linesActive=[],this.linesFree=[],this.container=null}}class zt extends y.Line{constructor(e,t){super(void 0,t),this.material=t,this.geometry=(new y.BufferGeometry).setFromPoints([e.start,e.end])}}var Vt=i(79728),Ut=i(90632),Qt=i(635),_t=i(80742),Ht=i(63319),jt=i(41999),Zt=i(17788),Wt=i(27553),qt=i(95548),Yt=i(77285),Xt=i(5823);const $t={[s.FloorplanOnly]:Xt.eR.LINETYPE_2D,[s.ThreeD]:Xt.eR.LINETYPE_3D},Kt={[Xt.eR.LINETYPE_2D]:s.FloorplanOnly,[Xt.eR.LINETYPE_3D]:s.ThreeD};class Jt{serialize(e,t){if(!e)return null;const i=[],{text:s,visible:n,type:o,floorId:r,roomId:a,layerId:h}=e.info;for(const t of e){const e={position:Ye.ep.toVisionVector(t)};r&&(e.floorId=r),a&&(e.roomId=a),i.push(e)}const d={enabled:n,label:s,version:"3.2",lineType:$t[o]||Xt.eR.LINETYPE_3D,points:i};return t&&(d.layerId=h),this.validate(d)?d:null}validate(e){return!!e&&!(e.points.length<2)}}var ei=i(9133);const ti=new w.Z("mds-measurement-serializer");class ii{constructor(){this.points=(0,Et.C)([]),this.grouper=new Te(this.points)}deserialize(e){var t;if(!e||!Array.isArray(e))return ti.debug("No contents",e),null;this.grouper.reset();for(const i of e)if(this.validate(i)){const e=i.lineType||Xt.eR.LINETYPE_3D,s=Kt[e],n=this.getModelContextFromPoint(i.points[0]),o=Object.assign(Object.assign({layerId:(null===(t=i.layer)||void 0===t?void 0:t.id)||"",sid:i.id,text:i.label||"",visible:i.enabled,type:s},n),{created:(0,ei.p)(i.created),modified:(0,ei.p)(i.modified),temporary:!1});this.grouper.startGroup(o),i.points.forEach((e=>this.grouper.push(Ye.ep.fromVisionVector(e.position))))}else ti.debug("Deserialized invalid Measurement data from MDS",i);return 0===this.grouper.length?null:this.grouper}validate(e){if(!e||"object"!=typeof e)return!1;const t=["id","points"].every((t=>t in e)),i=e.points&&Array.isArray(e.points)&&e.points.length>0,s=t&&i;return s||ti.debug("Invalid MDS.MeasurementPath:",{hasRequiredFields:t,hasPoints:i,data:e}),s}getModelContextFromPoint(e){return{floorId:e.floor&&e.floor.id?e.floor.id:"",roomId:e.room&&e.room.id?e.room.id:""}}}class si extends Zt.u{constructor(){super(...arguments),this.serializer=new Jt,this.deserializer=new ii,this.prefetchKey="data.model.measurementPaths",this.layeredType=Xt.SF.MEASUREMENTPATH}async read(e){const{readonly:t}=this.config,i={modelId:this.getViewId(),includeDisabled:!t,includeLayers:this.readLayerId()};return this.query(Yt.GetMeasurements,i,e).then((e=>{var t,i;if(!Wt.w.isOk(e,"model.measurementPaths"))throw new qt.Zb("MdsMeasurementModeStore.read failed");return this.deserializer.deserialize(null===(i=null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.model)||void 0===i?void 0:i.measurementPaths)}))}async create(e){const t=this.getViewId(),i=this.serializer.serialize(e,this.writeLayerId(e.info.layerId));if(!i)throw new Error("Could not create Measurement");return this.mutate(Yt.AddMeasurement,{modelId:t,data:i}).then((e=>{var t,i;const s=null===(i=null===(t=e.data)||void 0===t?void 0:t.addMeasurementPath)||void 0===i?void 0:i.id;if(!s)throw new Error("Unable to add measurement!");return s}))}async update(e){if(!e||0===e.length)return Promise.resolve();const t=this.getViewId();let i="";const s={};s.modelId=t;let n="";for(const t of e){const e=t.info.sid,o=this.serializer.serialize(t,!1);if(!o)throw new Error("Could not update Measurement");s[`data${e}`]=o,i+=`, $data${e}: MeasurementPathPatch!`,n+=`patch${e}: patchMeasurementPath(modelId: $modelId, pathId: "${e}", patch: $data${e}) {\n id\n }`}const o=jt.gql`
|
|
13
|
+
mutation PatchMeasurements($modelId: ID! ${i}) {
|
|
14
|
+
${n}
|
|
15
|
+
}
|
|
16
|
+
`;return this.mutate(o,s).then((()=>{}))}async delete(...e){if(!e||0===e.length)return;const t=this.getViewId();let i="";for(const t of e){const{pathId:e}=t;i+=`delete${e}: deleteMeasurementPath(modelId: $modelId, pathId: "${e}")`}const s=jt.gql`
|
|
17
|
+
mutation DeleteMeasurements($modelId: ID!) {
|
|
18
|
+
${i}
|
|
19
|
+
}
|
|
20
|
+
`;return this.mutate(s,{modelId:t}).then((()=>{}))}}var ni=i(28269),oi=i(71954),ri=i(89549),ai=i(76631),hi=i(79232),di=i(33824),li=i(56163),ci=i(35221);class ui extends li.K{constructor(e,t,i,s,n,o){super(e,t,i),this.group=s,this.units=n,this.id=this.group.info.sid,this.title=ui.getTitle(this.group,this.units,this.textParser),this.description=ui.getDescription(this.group,this.units),this.label=ui.getLabel(this.group,this.textParser),this.icon="icon-tape-measure",this.enabled=this.group.info.visible,this.typeId=Xt.SF.MEASUREMENTPATH,this.floorId=this.group.info.floorId,this.layerId=this.group.info.layerId,this.dateBucket=(0,ci.f)(this.group.info.created),this.onSelect=async()=>{super.onSelect(),this.commandBinder.issueCommand(new X(this.id))},this.textParser=o}supportsLayeredCopyMove(){return!0}supportsBatchDelete(){return!0}static getTitle(e,t,i){const s=E(e.length,t),n=ui.getLabel(e,i);return n?`${s} ${n}`:s}static getLabel(e,t){return t.getPlainText(e.info.text)}static getDescription(e,t){if(e.count>2){return e.segmentLengths.map((e=>E(e,t))).join(" – ")}return""}}var pi=i(52528),gi=i(71166),mi=i(85893),wi=i(67294),yi=i(33558),fi=i(36893),vi=i(96377),bi=i(77230),Ti=i(16589),Di=i(78116),Si=i(6608),Pi=i(44472);const Ii=({item:e})=>{const{analytics:t}=(0,wi.useContext)(yi.I),i=(0,fi.l)(e.id),n=(0,bi.A)(),o=(0,vi.m)();if(!i)return null;const{id:r,textParser:a,title:h,description:d,icon:l}=e,c=r===o,u=i.info.type===s.FloorplanOnly?"floorplan":"dollhouse",p=n?(0,Ti.vr)(h,n):h,g=n?(0,Ti.vr)(d,n):d,m=(0,mi.jsxs)("div",Object.assign({className:"item-details"},{children:[(0,mi.jsxs)("div",Object.assign({className:"item-header"},{children:[(0,mi.jsx)(Pi.S,{text:p||"",textParser:a,markers:Ti.PP}),(0,mi.jsx)("div",Object.assign({className:"list-item-decal"},{children:(0,mi.jsx)(Di.JO,{name:u})}))]})),d&&(0,mi.jsx)("div",Object.assign({className:"item-description"},{children:(0,mi.jsx)(Pi.S,{text:g,textParser:a,markers:Ti.PP})}))]}));return(0,mi.jsx)(Di.HC,{id:r,className:"search-result-item",title:m,active:c,disabled:!e.enabled,onClick:async()=>{t.trackToolGuiEvent("search","search_item_measurement_click"),e.onSelect()},badge:(0,mi.jsx)(Si.C,{iconClass:l})},r)};var Mi=i(38399);const{MEASUREMENTS:xi}=Mi.Z.SHOWCASE,Ri=new pi.v({});class Ei extends n.Y{constructor(){super(),this.name="measurement-mode",this.mutationRecord={[oi.KI.added]:new Set,[oi.KI.updated]:new Set,[oi.KI.removed]:new Set},this.removedLayerMap=new Map,this.store=null,this.newDataBinding=null,this.longPressStart=Date.now(),this.threshold=800,this.lineSidToPointMap={},this.mobile=!1,this.cameraAndDragBlocked=!1,this.blockNavigation=()=>!1,this.visibilityFilterEnabled=!1,this.trashEnabled=!1,this.editable=!0,this.changeCursor=e=>{this.engine.commandBinder.issueCommand(new l.u(e))},this.onEdit=e=>{const t=this.data.getGroupInfo(e),i=t&&t.info.sid||null;this.data.editingGroupId!==i&&(this.data.editingGroupId=i,this.colliders.setEditingGroup(e))},this.onEditEnd=()=>{if(this.data.editingGroupId){const e=this.pointGroups.getGroupById(this.data.editingGroupId);e&&(this.mutationRecord.updated.add(e.info.sid),this.save(),this.engine.broadcast(new Nt.av(this.buildAnalyticsMessageFromGroup(e))))}this.data.editingGroupId=null,this.colliders.setEditingGroup(void 0)},this.onCreatorAddNewLine=e=>{this.log.debug("onCreatorAddNewLine",e),this.data.creatingGroupId=e},this.onCreatorAddPoint=()=>{if(this.data.creatingGroupId){this.log.debug("onCreatorAddNewSegment",this.data.creatingGroupId);const e=this.pointGroups.getGroupById(this.data.creatingGroupId);if(e&&e.count>1&&e.length>0){const t=this.buildAnalyticsMessageFromGroup(e);this.engine.broadcast(new Nt.rf(Object.assign(Object.assign({},t),{startPosition:this.pointGroups.get(e.startIndex),endPosition:this.pointGroups.get(e.endIndex)})))}}},this.onCreatorStop=()=>{if(this.data.creatingGroupId){const e=this.pointGroups.getGroupById(this.data.creatingGroupId);e&&(e.count>1&&e.hasLength()?(this.engine.broadcast(new Nt.u6(Object.assign({},this.buildAnalyticsMessageFromGroup(e)))),this.mutationRecord.added.add(e.info.sid),this.save()):this.engine.broadcast(new Nt.ff))}this.data.creatingGroupId=null},this.onToggleMeasurementMode=async(e,t,i)=>{this.toggleMeasuringMode(e,i),await this.engine.commandBinder.issueCommand(new $.I(e&&t))},this.onViewmodeChange=()=>{this.getPhase()!==J.au.CLOSED&&this.stopMeasuring()},this.onSweepChange=()=>{const e=this.getPhase();e!==J.au.CREATING&&e!==J.au.CREATING_NEXT_POINT&&this.setSelected(-1)},this.initStorageOnApplicationChange=async()=>{var e;const t=this.loadSavedMeasurements();this.data.modeActive()&&this.engine.commandBinder.issueCommand(new z.O(!1)),this.store&&t&&!this.newDataBinding?this.newDataBinding=this.store.onNewData((async e=>{this.getPhase()!==J.au.CLOSED&&this.stopMeasuring(),this.loadSavedMeasurements()?this.replaceContents(null==e?void 0:e.groups()):this.replaceContents(),this.clearMutationRecord(),this.configureTrash()})):this.newDataBinding&&!t&&(this.newDataBinding.cancel(),this.newDataBinding=null),t&&await(null===(e=this.store)||void 0===e?void 0:e.refresh())},this.getPhase=()=>this.data.phase,this.toggleCameraMovement=e=>{e||this.cameraAndDragBlocked?e&&this.cameraAndDragBlocked&&(this.dragInterceptor.cancel(),this.navigation.removeNavigationRule(this.blockNavigation),this.cameraAndDragBlocked=!1):(this.dragInterceptor.renew(),this.navigation.addNavigationRule(this.blockNavigation),this.cameraAndDragBlocked=!0)},this.getConstraint=()=>this.settings.tryGetProperty(N.F.MeasurementSnapping,!1)?this.viewmodeData.isFloorplan()?ce.floorplan:this.constraint:ce.disabled,this.getSelected=()=>this.data.selectedGroupIndex,this.setSelected=e=>{this.data.selectedGroupIndex!==e&&this.data.setSelectedGroupIndex(e)},this.setSelectedById=e=>{if(null===e)this.setSelected(-1);else{const t=this.pointGroups.getGroupById(e);t&&this.setSelected(t.index)}},this.deleteSelectedMeasurement=()=>{-1!==this.data.selectedGroupIndex&&(this.deleteMeasurement(this.data.selectedGroupIndex),this.setSelected(-1),this.changePhase(J.au.IDLE),this.mobile||(this.navigation.removeNavigationRule(this.blockNavigation),this.engine.commandBinder.issueCommand(new l.u(h.C.DEFAULT))))},this.deleteMeasurementBySids=async e=>{const t=e.sids;for(const i of t){const t=this.pointGroups.getGroupById(i);if(!t)throw this.log.error("Measurement delete failed",Object.assign({},e)),Error("Measurement delete failed, not found");this.deleteMeasurement(t.index,!0)}this.save()},this.onToggleContinuous=()=>{this.stopMeasuring()},this.changePhase=e=>{this.getPhase()!==e&&(this.log.debug(`Phase Change: ${J.au[this.getPhase()]} -> ${J.au[e]}`),this.previousPhase=this.getPhase(),this.data.setPhase(e))},this.restorePreviousPhase=()=>{this.changePhase(this.previousPhase)},this.onPhaseChange=e=>{if(this.intersectionVisualizer.setMeasuringPhase(e),this.previousPhase!==e)switch(e){case J.au.CLOSED:case J.au.IDLE:this.engine.broadcast(new K.ps(!0));break;case J.au.EDITING:case J.au.CREATING:case J.au.POINT_PLACED:case J.au.CREATING_NEXT_POINT:case J.au.CONFIRMING_POINT:this.engine.broadcast(new K.ps(!1))}},this.buildAnalyticsMessage=e=>{const t=this.pointGroups.getGroup(e);return t&&t.hasLength()?this.buildAnalyticsMessageFromGroup(t):null},this.buildAnalyticsMessageFromGroup=e=>{const t=this.viewmodeData.isFloorplan()?s[s.FloorplanOnly]:s[s.ThreeD];return Object.assign(Object.assign({sid:e.info&&e.info.sid?e.info.sid:e.describe(),totalLength:e?e.length:0,segments:e?e.count:0,temporary:!!e.info.temporary,viewmode:this.viewmodeData.currentMode,floorId:e.info.floorId,continuous:this.settings.tryGetProperty(N.F.MeasurementContinuousLines,!1)},this.getAnalyticsForConstraints()),{type:t})},this.getAnalyticsForConstraints=()=>{const e=this.pointer.lastIntersection;if(e){const t=e.featureType,i=e.constraint;return{featureType:void 0!==t?Ke[t]:"None",constraint:ie[i]}}return null},this.toggleMeasuringMode=(e,t)=>{this.log.debug("toggleMeasuringMode",e);e!==(this.getPhase()!==J.au.CLOSED)&&(e?(this.editable=t,this.engine.toggleRendering(this,!0),this.changePhase(J.au.IDLE),this.lineStyler.activate(),this.renderer.activate(),this.textRenderer.activate(),this.editable&&(this.editor.activate(),this.colliders.activate(),this.textRenderer.activateInteraction()),this.scene.addChild(a.a.Root,this.textRenderer.container),this.engine.broadcast(new Nt.$n(!0,this.viewmodeData.currentMode,this.pointGroups.groupCount))):(this.engine.toggleRendering(this,!1),this.stopMeasuring(),this.changePhase(J.au.CLOSED),this.toggleCameraMovement(!0),this.editable&&(this.editor.deactivate(),this.colliders.deactivate(),this.textRenderer.deactivateInteraction()),this.lineStyler.deactivate(),this.renderer.deactivate(),this.textRenderer.deactivate(),this.scene.removeChild(a.a.Root,this.textRenderer.container),this.engine.broadcast(new Nt.$n(!1,this.viewmodeData.currentMode,this.pointGroups.groupCount))))},this.startMeasuring=()=>{this.settings.tryGetProperty(N.F.MeasurementSnapping,!1)&&this.pointer.preload(),this.mobile||(this.navigation.addNavigationRule(this.blockNavigation),this.engine.commandBinder.issueCommand(new l.u(h.C.XHAIR))),this.creator.start()},this.stopMeasuring=()=>{const e=this.isMeasurementComplete(this.data.selectedGroupIndex);this.isCreating()&&!e&&this.deleteSelectedMeasurement(),this.creator.stop(),this.mobile||(this.navigation.removeNavigationRule(this.blockNavigation),this.engine.commandBinder.issueCommand(new l.u(h.C.DEFAULT)))},this.setupIntersectionVisuals=(e,t,i,s,n,o,r,a)=>{t.addVisibilityRule((()=>{const e=this.getPhase();return!(!o&&e===J.au.CREATING||e===J.au.CONFIRMING_POINT||e===J.au.CREATING_NEXT_POINT||e===J.au.EDITING)}));const h={cameraData:s,playerCamera:i.camera,scene:i};return new $e(o,n,h,e,r,this.engine.commandBinder.issueCommand,a.isFloorplan)},this.renameMeasurement=async e=>{const t=this.pointGroups.getGroupById(e.sid);if(!t)throw this.log.error("Measurement rename failed",Object.assign({},e)),Error("Measurement rename failed, not found");const i=void 0!==e.text&&e.text.length<=24;if(!t||!i)throw this.log.error("Measurement text invalid, text must be between 0 and 24 charachters in length.",Object.assign({},e)),new Error("Measurement text invalid");{const i=""===t.info.text&&e.text.length>0,s=!i&&t.info.text!==e.text;this.pointGroups.updateGroupInfo(t.index,Object.assign(Object.assign({},t.info),{text:e.text})),this.mutationRecord.updated.add(t.info.sid),this.save(),i&&this.engine.broadcast(new Nt.ty(e.sid,e.text)),s&&this.engine.broadcast(new Nt.mM(e.sid,t.info.text,e.text))}},this.onChangeVisibility=async e=>{const{sids:t,visible:i}=e;for(const s of t){const t=this.pointGroups.getGroupById(s);if(!t)throw this.log.error("Measurement visibility toggle failed",Object.assign(Object.assign({},e),{group:t})),new Error("Measurement visibility toggle failed, not found");{this.pointGroups.updateGroupInfo(t.index,Object.assign(Object.assign({},t.info),{visible:i})),this.mutationRecord.updated.add(t.info.sid);const e=this.buildAnalyticsMessage(t.index);e&&this.engine.broadcast(new Nt.av(e)),i||t.index!==this.getSelected()||this.setSelected(-1)}}this.save()},this.filterVisibility=async e=>{this.data.idVisibility=new Set(e.sids)},this.changeVisibilityFilterEnabled=async e=>{this.data.idVisibility=new Set,this.visibilityFilterEnabled=e.enabled},this.clearMutationRecord=this.clearMutationRecord.bind(this),this.deleteMeasurement=this.deleteMeasurement.bind(this),this.replaceContents=this.replaceContents.bind(this),this.navigateToMeasurement=this.navigateToMeasurement.bind(this)}async init(e,t){var i;const{readonly:s,baseUrl:n}=e;this.config=e,this.mobile=(0,kt.tq)(),this.engine=t;const[a,h,d,l,c,m,w,y,f,v,T]=await Promise.all([t.getModuleBySymbol(o.y.WEBGL_RENDERER),t.getModuleBySymbol(o.y.RENDER_TO_TEXTURE),t.getModuleBySymbol(o.y.INPUT),t.getModuleBySymbol(o.y.LINES),t.getModuleBySymbol(o.y.RAYCASTER),t.market.waitForData(p.c),t.market.waitForData(u.M),t.market.waitForData(g.O),t.market.waitForData(B.Z),t.market.waitForData(ni.Z),t.market.waitForData(F.e)]);this.settings=await t.market.waitForData(F.e),this.playerOptions=await t.market.waitForData(k.af),this.layersData=await t.market.waitForData(_t.R),this.scene=a.getScene(),this.viewmodeData=y,this.floorsViewData=m,this.roomData=v,this.input=d,this.navigation=await t.getModuleBySymbol(o.y.NAVIGATION),this.meshQueryModule=await t.getModuleBySymbol(o.y.MESH_QUERY);const D=await t.getModuleBySymbol(o.y.STORAGE);this.applicationData=await t.market.waitForData(G.pu),this.lineDerivedDataFactory=new O(w,y,m,(()=>!!f.currentSweep&&f.isSweepAligned(f.currentSweep)),(()=>this.settings.tryGetProperty(N.F.UnitType,b.M.IMPERIAL)),(()=>!0));const S=t.claimRenderLayer(this.name);this.data=new ee.X,t.market.register(this,ee.X,this.data);const P=(0,Et.C)([]);this.pointGroups=new Te(P);const I=(e,t,i=!1)=>Re(P,e).createSubscription(t,i);this.dataSubscription=P.onChanged((()=>{this.data.repopulate(this.pointGroups.groups()),this.data.commit()})),this.store=new si({context:this.layersData.mdsContext,readonly:s,baseUrl:n});const M=await t.market.waitForData(Ut.Q);s||(M.setRevertableType(Vt.g.MEASUREMENTS),M.setPublishableType(Vt.g.MEASUREMENTS)),this.constraint=this.mobile?ce.mobile:ce.desktop,this.pointer=new ft(c,this.getConstraint,this.mobile,this.floorsViewData,this.viewmodeData,this.meshQueryModule);const x=new bt(this.pointGroups,I,this.pointer,(()=>{const e=this.settings.tryGetProperty(N.F.MeasurementContinuousLines,!1),t=this.getPhase()===J.au.CREATING||this.getPhase()===J.au.CREATING_NEXT_POINT||this.previousPhase===J.au.CREATING_NEXT_POINT&&this.getPhase()===J.au.EDITING;return e&&this.mobile&&t}));t.addComponent(this,x);const R=new Bt(this.pointer,this.mobile,this.getPhase,this.scene,t.getRenderLayer);t.addComponent(this,R),this.creator=this.instantiateCreator(w),this.initStorageOnApplicationChange();const E=(e,t,i)=>{const s=this.pointGroups.getGroup(e),n=s.describe(i);this.lineSidToPointMap[n]=i;const o=this.lineDerivedDataFactory.get(n);return this.lineDerivedDataFactory.make(n,(()=>({start_position:this.pointGroups.get(t),end_position:this.pointGroups.get(i),visible:this.getMeasurementVisibility(s.info.sid,s.info.layerId,s.info.visible),floorId:s.info.floorId,roomId:s.info.roomId,type:s.info.type,text:this.pointGroups.isStartIndex(t)?s.info.text:""})),o)};this.renderer=new Le(this.pointGroups,I,w,l,S,t.claimRenderLayer("measure-lines"),this.getSelected,E),await t.addComponent(this,this.renderer);const C=new r.uc({assetBasePath:null!==(i=T.getProperty("assetBasePath"))&&void 0!==i?i:"",color:"black",background:!0,backgroundColor:"#ffffff",backgroundColliderType:Be});this.textRenderer=new Ge(this.pointGroups,d,this.mobile,w,S,We.z.labels,C,E,this.changeCursor,this.getPhase,this.setSelected),await t.addComponent(this,this.textRenderer),this.editor=new Tt(this.pointGroups,d,this.pointer,this.getPhase,this.onEdit,this.onEditEnd),this.colliders=new wt(this.pointGroups,this.input,w,this.mobile,this.changeCursor,this.getPhase,this.changePhase,this.restorePreviousPhase,this.setSelected,this.getSelected,this.onEdit,this.onEditEnd),this.lineStyler=new St(this.renderer.lines,this.renderer.getLinesForPoint,this.renderer.dottedMaterial,I,this.input,this.getPhase,this.getSelected);const[A]=await Promise.all([t.getModuleBySymbol(o.y.CURSOR_CONTROLLER)]);this.intersectionVisualizer=this.setupIntersectionVisuals(h,A,this.scene,w,this.pointer,this.mobile,t.getRenderLayer,this.viewmodeData),t.addComponent(this,this.intersectionVisualizer),this.dragInterceptor=new Lt.V(this.input.registerPriorityHandler(pt._t,et.S,(()=>!0)),this.input.registerPriorityHandler(pt._t,Ct.i,(()=>!0))),this.dragInterceptor.cancel(),this.mobile||this.bindings.push(...this.hotkeys()),this.bindings.push(this.applicationData.onPropertyChanged("application",this.initStorageOnApplicationChange),y.makeModeChangeSubscription(this.onViewmodeChange),f.makeSweepChangeSubscription(this.onSweepChange),t.commandBinder.addBinding(z.O,(async e=>{this.onToggleMeasurementMode(e.on,e.dimWhileActive,e.editable)})),t.commandBinder.addBinding(V.c,(async()=>this.startMeasuring())),t.commandBinder.addBinding(U.Q,(async e=>this.setSelected(e.index))),t.commandBinder.addBinding(Q.B,(async()=>this.stopMeasuring())),t.commandBinder.addBinding(_.Ev,(async()=>this.deleteSelectedMeasurement())),t.commandBinder.addBinding(_.Tn,(async e=>this.deleteMeasurement(e.index))),t.commandBinder.addBinding(j,this.onChangeVisibility),t.commandBinder.addBinding(Z,this.renameMeasurement),t.commandBinder.addBinding(_.JM,this.deleteMeasurementBySids),t.commandBinder.addBinding(W,(async e=>{var t;return this.replaceContents(null===(t=e.points)||void 0===t?void 0:t.groups())})),t.commandBinder.addBinding(q,this.filterVisibility),t.commandBinder.addBinding(Y,this.changeVisibilityFilterEnabled),t.commandBinder.addBinding(X,this.navigateToMeasurement),this.dataSubscription,this.settings.onPropertyChanged(N.F.MeasurementContinuousLines,(()=>this.onToggleContinuous())),D.onSave((()=>this.saveDiff()),{dataType:Vt.g.MEASUREMENTS}),this.layersData.onPropertyChanged("currentViewId",(()=>this.updateSettings())),this.layersData.onPropertyChanged("activeLayerId",(()=>this.updatePendingMeasurement())),this.data.onPropertyChanged("phase",this.onPhaseChange)),t.toggleRendering(this,!1),this.updateSettings(),this.registerDebugSettings(),async function(e,t,i,s){const n=await e.market.waitForData(G.pu);let o=n.application===G.Mx.WORKSHOP;const r=(n,r,a,h=[])=>{const d=s.tryGetProperty(N.F.UnitType,b.M.METRIC),l=[],c=t.groups();if(0===h.length)for(const t of c)(o||t.info.visible&&i.layerToggled(t.info.layerId))&&n(ui.getTitle(t,d,Ri),ui.getDescription(t,d))&&l.push(new ui(e.commandBinder,i,r,t,d,Ri));return e.commandBinder.issueCommand(new q(l.map((e=>e.id)))),l},a=t=>{t===Xt.SF.MEASUREMENTPATH||e.commandBinder.issueCommand(new z.O(!!t,!1,!1)),e.commandBinder.issueCommand(new Y(!!t))},h=e=>new Lt.V(t.onDataChanged(e),s.onPropertyChanged(N.F.UnitType,e)),d={renew:()=>{e.commandBinder.issueCommandWhenBound(new gi.c6({id:Xt.SF.MEASUREMENTPATH,groupPhraseKey:xi.SEARCH_GROUP_HEADER,getSimpleMatches:r,registerChangeObserver:h,onSearchActivatedChanged:a,groupOrder:40,groupIcon:"tape-measure",itemFC:Ii}))},cancel:()=>{e.commandBinder.issueCommandWhenBound(new gi.Pe(Xt.SF.MEASUREMENTPATH))}},l=()=>{o=n.application===G.Mx.WORKSHOP,s.tryGetProperty(k.gx.Measurements,!0)||o?d.renew():d.cancel()},c=n.onPropertyChanged("application",l),u=s.onPropertyChanged(k.gx.Measurements,l);return l(),new Lt.V(d,c,u)}(t,this.data,this.layersData,this.settings).then((e=>this.bindings.push(e)))}replaceContents(e){this.lineDerivedDataFactory.clear();for(let e=this.pointGroups.groupCount;e>=0;e--){const t=this.pointGroups.getGroup(e);this.layersData.isInMemoryLayer(t.info.layerId)||this.pointGroups.removeGroup(e)}e&&this.pointGroups.copy(e,!1)}loadSavedMeasurements(){return this.config.readonly=this.applicationData.application!==G.Mx.WORKSHOP,this.creator.syncReadonly(this.config.readonly),!this.config.readonly||this.playerOptions.options.measurements_saved}isCreating(){const e=this.getPhase();return e===J.au.CREATING||e===J.au.CREATING_NEXT_POINT}setConstraintStyle(e){this.log.debug("setConstraintStyle:",ie[e]),this.constraint=e}deleteMeasurement(e,t=!1){const i=this.buildAnalyticsMessage(e);i&&this.engine.broadcast(new Nt.$Z(Object.assign(Object.assign({},i),{count:this.pointGroups.groupCount-1})));const s=this.pointGroups.getGroup(e);if(s){const{sid:i,layerId:n}=s.info;this.pointGroups.removeGroup(e),i!==this.data.creatingGroupId&&(this.layersData.isInMemoryLayer(n)||(this.mutationRecord.removed.add(i),this.removedLayerMap.set(i,n),t||this.save()))}}isMeasurementComplete(e){if(-1===e||!this.isCreating())return!0;const t=this.getPhase(),i=this.pointGroups.getGroup(e);return this.settings.tryGetProperty(N.F.MeasurementContinuousLines,!1)?i.count>2&&t===J.au.CREATING_NEXT_POINT:i.count>=2&&t===J.au.CREATING}hotkeys(){return[this.input.registerHandler(At.e,(e=>{if(e.state===Ot.M.PRESSED)switch(e.key){case Ft.R.ESCAPE:this.getPhase()===J.au.CONFIRMING_POINT?(this.creator.stop(),this.creator.start(),this.changePhase(J.au.CREATING)):this.isCreating()?this.stopMeasuring():this.applicationData.application!==G.Mx.WORKSHOP&&this.getPhase()!==J.au.CLOSED&&this.engine.commandBinder.issueCommand(new ri.tT(ai.w1.MEASUREMENTS,!1));break;case Ft.R.BACKSPACE:case Ft.R.DELETE:this.getPhase()!==J.au.CLOSED&&this.getPhase()!==J.au.EDITING&&this.deleteSelectedMeasurement();break;case Ft.R.RETURN:const e=this.pointGroups.groupCount-1;this.isMeasurementComplete(e)&&this.stopMeasuring()}})),this.input.registerHandler(At.e,(e=>{if(e.key===Ft.R.SHIFT||e.key===Ft.R.ALT){const{altKey:t,shiftKey:i}=e.modifiers,s=i&&t?ce.shiftAlt:t?ce.alt:i?ce.shift:ce.desktop;this.setConstraintStyle(s)}}))]}onUpdate(e){if(this.getPhase()===J.au.CLOSED)return;const t=this.data.selectedGroupIndex,i=this.mobile?J.Ph.mobile[this.getPhase()]:J.Ph.desktop[this.getPhase()];for(const s in this.lineSidToPointMap){const n=this.lineDerivedDataFactory.get(s);if(n){n.opacity.tick(e);const o=this.lineSidToPointMap[s],r=this.pointGroups.groupFromPointIndex(o),a=r===t&&n.visible?1:n.opacity.value,h=i&&!n.labelVisible?0:a;this.textRenderer.setTextOpacityByPoint(o,h),this.renderer.setLineOpacityByPoint(o,a),-1!==r&&this.colliders.setGroupVisible(r,a>0)}}if(this.mobile)if(this.getPhase()===J.au.CONFIRMING_POINT){const e=(Date.now()-this.longPressStart)/this.threshold;e<=1&&(this.data.pressProgress=e,this.data.commit())}else this.getPhase()===J.au.CREATING&&0!==this.data.pressProgress&&(this.data.pressProgress=0,this.data.commit())}dispose(){var e,t;this.data.modeActive()&&(this.stopMeasuring(),this.engine.commandBinder.issueCommand(new z.O(!1))),this.colliders.dispose(),this.textRenderer.dispose(),this.renderer.dispose(),this.engine.disposeRenderLayer(this.name),null===(e=this.store)||void 0===e||e.dispose(),this.store=null,null===(t=this.newDataBinding)||void 0===t||t.cancel(),this.newDataBinding=null,super.dispose(this.engine)}clearMutationRecord(){for(const e of Object.values(this.mutationRecord))e.clear()}async save(){if(!this.config.readonly)return this.engine.commandBinder.issueCommand(new Qt.VQ({dataTypes:[Vt.g.MEASUREMENTS]}));this.clearMutationRecord()}async saveDiff(){var e,t;if(this.data.repopulate(this.pointGroups.groups()),this.data.commit(),this.data.notifyDataChanged(),this.config.readonly||!this.store)return void this.clearMutationRecord();const i=this.mutationRecord,s=[];this.log.debug("MDS mutation ops:",`{\n added: '${[...i.added.keys()]}',\n updated: '${[...i.updated.keys()]}',\n removed: '${[...i.removed.keys()]}',\n }`);const n=[];for(const e of i[oi.KI.removed]){if(i[oi.KI.added].has(e))i[oi.KI.added].delete(e);else{const t=this.removedLayerMap.get(e);n.push({pathId:e,layerId:t})}i[oi.KI.updated].delete(e)}this.removedLayerMap.clear();const o=this.store.delete(...n);s.push(o);for(const t of i[oi.KI.added]){if(this.layersData.isInMemoryLayer(null===(e=this.data.getGroupInfoBySid(t))||void 0===e?void 0:e.info.layerId))continue;const n=this.pointGroups.getGroupById(t);if(n){const e=this.store.create(n).then((e=>{e&&(this.log.debug(`Updating group id for new path: ${n.info.sid} -> ${e}`),this.pointGroups.updateGroupInfo(n.index,Object.assign(Object.assign({},n.info),{sid:e}))),this.data.repopulate(this.pointGroups.groups()),this.data.commit(),this.data.notifyDataChanged()}));s.push(e)}i[oi.KI.updated].delete(t)}const r=[];for(const e of i[oi.KI.updated]){if(this.layersData.isInMemoryLayer(null===(t=this.data.getGroupInfoBySid(e))||void 0===t?void 0:t.info.layerId))continue;const i=this.pointGroups.getGroupById(e);i&&r.push(i)}const a=this.store.update(r);return s.push(a),this.clearMutationRecord(),Promise.all(s)}updatePendingMeasurement(){const e=this.data.creatingGroupId;if(e){const t=this.pointGroups.getGroupById(e);if(!t)return void this.log.error("Missing pending measurement group");if(!this.layersData.isInMemoryLayer(t.info.layerId)){const i=this.layersData.activeLayerId;this.pointGroups.updateGroupInfo(t.index,Object.assign(Object.assign({},t.info),{layerId:i}));const s=this.data.getGroupInfoBySid(e);s&&(s.info.layerId=i,this.data.commit(),this.data.notifyDataChanged())}}}getMeasurementVisibility(e,t,i){if(!this.data.modeActive())return!1;const{selectedGroupSid:s,creatingGroupId:n,editingGroupId:o,idVisibility:r}=this.data,a=this.applicationData.application===G.Mx.WORKSHOP||this.layersData.layerToggled(t),h=this.layersData.layerVisible(t),d=[s,n,o].includes(e),l=!this.visibilityFilterEnabled||r.has(e);return a&&(d||i&&l&&h)}async registerDebugSettings(){const e=await this.engine.getModuleBySymbol(o.y.SETTINGS);e.registerMenuEntry({header:"Measurement Debug",setting:"measure/fp_in_dh",initialValue:()=>!1,onChange:t=>(this.lineDerivedDataFactory.setDollhouseLineStyle(t?s.FloorplanOnly:s.ThreeD),e.updateSetting("measure/fp_in_dh",t))})}updateSettings(){const e=this.layersData.getCurrentView(),t=(null==e?void 0:e.viewType)===Ht.XZ.TRUEPLAN,i=this.settings.tryGetProperty(fe,!0),s=t||i;this.settings.setProperty(fe,s)}instantiateCreator(e){let t;const i=e=>{const t={floorId:e.floorId||"",roomId:e.roomId||""};return this.meshQueryModule.inferMeshIdsFromPoint(t,e.point),t};if(this.mobile){const s=(e,t)=>{this.longPressStart=e,this.threshold=t},n=t=>{const i=(0,T.q9)(e,t.point);this.data.setPointPosition(i.screenPosition)};t=new xt(this.pointGroups,this.setSelected,this.input.registerUnfilteredHandler,this.pointer,this.changePhase,s,n,this.toggleCameraMovement,this.getPhase,(()=>this.settings.tryGetProperty(N.F.MeasurementContinuousLines,!1)),this.viewmodeData.isFloorplan,(()=>this.floorsViewData.getHighestVisibleFloorId()),(()=>this.roomData.selected.value),(()=>this.layersData.activeLayerId),i)}else t=new Rt(this.pointGroups,this.setSelected,this.input.registerUnfilteredHandler,this.pointer,this.changePhase,this.getPhase,this.viewmodeData.isFloorplan,(()=>this.floorsViewData.getHighestVisibleFloorId()),(()=>this.roomData.selected.value),(()=>this.layersData.activeLayerId),(()=>this.settings.tryGetProperty(N.F.MeasurementContinuousLines,!1)),i,this.meshQueryModule);return t.onGroupCreated=this.onCreatorAddNewLine,t.onGroupAddPoint=this.onCreatorAddPoint,t.onEdit=this.onEdit,t.onDone=this.onCreatorStop,t.syncReadonly(this.config.readonly),t}async configureTrash(){const{readonly:e}=this.config;if(this.trashEnabled||e)return;const{commandBinder:t}=this.engine,i=Vt.g.MEASUREMENTS,s={objectType:i,create:e=>new hi.F({label:e.label||"Measurement",objectId:e.id,objectType:i,created:new Date,value:e}),restore:e=>{}};this.trashEnabled=!0;const n=await t.issueCommandWhenBound(new di.B(s));this.bindings.push(n)}async navigateToMeasurement({groupId:e}){const{commandBinder:t}=this.engine,i=this.data.getGroupInfoBySid(e);if(!i)return;const n=[];for(const e of i)n.push(e);const o=this.floorsViewData.isCurrentOrAllFloors(i.info.floorId),r=(new y.Box3).setFromPoints(n),a={mode:i.info.type===s.FloorplanOnly?m.Ey.Floorplan:m.Ey.Dollhouse,transition:d.n.Interpolate};try{o||await t.issueCommand(new c.Vw(i.info.floorId)),await this.navigation.focus(r,a),this.setSelectedById(e)}catch(e){this.log.info("Unable to navigateToMeasurement:",e)}}}const Ci=Ei},7402:(e,t,i)=>{"use strict";i.d(t,{g:()=>d});var s=i(81396),n=i(17878),o=i(56512),r=i(82814),a=i(12529),h=i(53203);class d extends r.S{constructor(e,t,i=n.o.ALL){super(),this._opacity=1,this._chunks=[],this.size=new s.Vector3,this.center=new s.Vector3,this.built=!1,this.layers.mask=i.mask,this.name=`RoomMesh:${e}-${t}`,this.meshGroup=e,this.meshSubgroup=t,this.renderOrder=a.z.default,this.onBeforeRender=(e,t,i,s,n,o)=>{this.updateUniforms(n,o)}}dispose(){this.reset()}reset(){this._chunks.length=0,this.geometry.dispose(),delete this.onBuild,delete this.onOpacityUpdate,this.built=!1}addChunk(e){-1===this._chunks.indexOf(e)&&this._chunks.push(e)}getChunk(e){return this._chunks[e]}build(){if(this.built)throw new Error("build() should only be called once");if(!this._chunks.length)return;const e=(0,o.qf)(this._chunks.map((e=>e.geometry)));e.clearGroups();let t=0;this.material=[],this._chunks.forEach(((i,s)=>{i.geometry&&i.geometry.index&&(e.addGroup(t,i.geometry.index.count,s),t+=i.geometry.index.count,i.geometry.dispose(),i.geometry=e,i.notifyOnMaterialUpdated((e=>{Array.isArray(this.material)&&(this.material[s]=e),this.onMaterialUpdate&&this.onMaterialUpdate()})),i.onOpacityUpdate=e=>{this.opacity=e})})),this.geometry=e,this.geometry.computeBoundingBox(),this.geometry.computeBoundingSphere(),this.material=this._chunks.map((e=>e.material)),this.size=this.boundingBox.getSize(this.size),this.center=this.boundingBox.getCenter(this.center),this.built=!0,this.onBuild&&this.onBuild()}buildWithTileChunk(e){if(this.built)return;const{meshGroup:t,meshSubgroup:i,lod:s}=e;this.name=`RoomMesh:${s}-${t}-${i}-${e.chunkIndex}`,this.meshGroup=t,this.meshSubgroup=i,this._chunks.push(e),e.notifyOnMaterialUpdated((e=>{this.material=e,this.onMaterialUpdate&&this.onMaterialUpdate()})),e.onOpacityUpdate=e=>{this.opacity=e},this.size=this.boundingBox.getSize(this.size),this.center=this.boundingBox.getCenter(this.center),this.built=!0,this.onBuild&&this.onBuild()}updateUniforms(e,t){e instanceof s.RawShaderMaterial&&(t?this.chunks[t.materialIndex].onBeforeDraw(e):this.chunks.length&&this.chunks[0].onBeforeDraw(e))}get boundingBox(){return(0,o.A5)(this.geometry)}set opacity(e){e!==this.opacity&&(this._opacity=e,this.raycastEnabled=e>h.xx.FADE_CLICKABLE_THRESHOLD,this.renderOrder=e<h.xx.FADE_OPAQUE?a.z.ghostFloor:a.z.default,this.onOpacityUpdate&&this.onOpacityUpdate(e))}get opacity(){return this._opacity}get chunks(){return this._chunks}getSortKey(){return this.chunks.length?this._chunks[0].getSortKey():0}}},14564:(e,t,i)=>{"use strict";i.d(t,{u:()=>r});var s,n,o=i(19663);!function(e){e.all="all",e.byMeshGroup="byMeshGroup",e.byMeshSubGroup="byMeshSubGroup"}(s||(s={})),function(e){e.explicit="explicit",e.random="random"}(n||(n={}));class r extends o.m{constructor(e,t){super(),this.id="SET_MESH_OVERLAY_COLOR",this.payload={selectBy:(null==t?void 0:t.style)||s.all,colorStyle:(null==e?void 0:e.style)||n.explicit,color:(null==e?void 0:e.color)||null,alpha:(null==e?void 0:e.alpha)||.5,index:null==t?void 0:t.index}}}r.selectBy=s,r.colorBy=n,r.COLOR_DIM={x:0,y:0,z:0,w:.3}},75810:(e,t,i)=>{"use strict";i.d(t,{I:()=>n});var s=i(19663);class n extends s.m{constructor(e){super(),this.id="TOGGLE_MESH_OVERLAY_COLOR",this.payload={enabled:e}}}},26269:(e,t,i)=>{"use strict";i.d(t,{$4:()=>o,oR:()=>n});var s=i(7402);const n=e=>!!e&&e instanceof s.g,o={hasMeshGroup:e=>"object"==typeof e&&!!e&&"meshGroup"in e,hasMeshSubgroup:e=>"object"==typeof e&&!!e&&"meshSubgroup"in e,isRoomMesh:n,isVisibleRoomMesh:e=>n(e)&&e.raycastEnabled&&e.visible}},76325:(e,t,i)=>{"use strict";i.r(t),i.d(t,{ModelRatedMessage:()=>r.E,SubmitModelRatingCommand:()=>a.M,ToggleModelRatingDialogCommand:()=>a.m,default:()=>S});var s=i(70173),n=i(97542),o=i(7446),r=i(75783),a=i(99660),h=i(92211),d=i(73536),l=i(3907);const c=new(i(97998).Z)("model-rating-data-store"),u=e=>e,p=e=>e;class g extends l.MU{constructor(e,t,i){super({queue:e,deserialize:u,serialize:p,path:`${t}/api/v1/jsonstore/model/model-rating/${i}`}),this.queue=e,this.baseUrl=t,this.modelId=i}async canPromptRating(){let e;try{e=await this.read()}catch(e){return c.error("Failed to read existing rating data from JSONStore"),!1}const t=!!e.rated_at;return!!!e.prompt_dismissed_at&&!t}async recordRatingSubmitted(){this.update({rated_at:(new Date).toISOString()})}async recordAutomaticPromptDismissed(){this.update({prompt_dismissed_at:(new Date).toISOString()})}async reset(){var e;const t=`${this.baseUrl}/api/v1/jsonstore/model/model-rating/${this.modelId}`;if(!(null===(e=this.modelId)||void 0===e?void 0:e.length))throw new Error(`Refusing to DELETE ${t}`);if(window.confirm("Are you sure you want to reset the Model Rated value for this space? This cannot be undone."))return this.queue.delete(t,this.options).then((()=>{window.location.reload()}))}}var m=i(26158),w=i(34029),y=i(26568),f=i(69170);const v=e=>864e5*e,b=v(1),T=v(7);class D extends n.Y{constructor(){super(...arguments),this.name="model-rating",this.promptEnabled=!1,this.totalActiveTime=0,this.wasLastOpeningAutomatic=!1,this.canPrompt=async()=>{const e=Date.now(),t=+this.settings.tryGetProperty(m.F.LastRatingPromptTime,null),i=!t||isNaN(t)||+new Date(e)-+new Date(t)>=b,s=await this.store.canPromptRating();return this.log.debug(`canPromptUser: ${i}, canPromptModel: ${s}`),i&&s},this.handleActivityPingMessage=async e=>{if(this.totalActiveTime+=e.durationDollhouse+e.durationFloorplan+e.durationInside,this.log.debug(`prompt timing update: totalActiveTime:${this.totalActiveTime}, threshHold: 74500`),this.totalActiveTime<74500||!this.promptEnabled)return;this.engine.unsubscribe(s.i,this.handleActivityPingMessage);if(await this.canPrompt()&&!this.viewData.getIsDialogVisible()){this.log.debug("automatically prompting user for Model Rating");const e=(new Date).toISOString();this.settings.setLocalStorageProperty(m.F.LastRatingPromptTime,e),this.engine.commandBinder.issueCommand(new a.m(!0)),this.wasLastOpeningAutomatic=!0}},this.handleSubmitModelRatingCommand=async({rating:e,didFinish:t})=>{this.log.info(e),this.engine.broadcast(new r.E(e)),this.store.recordRatingSubmitted(),t&&(this.engine.commandBinder.issueCommand(new a.m(!1)),this.engine.commandBinder.issueCommand(new h.Bz(d.P.RATING_THANK_YOU,!0)))},this.handleToggleDialogCommand=async({toVisible:e})=>{this.viewData.setDialogVisible(e);!this.viewData.getIsDialogVisible()&&this.wasLastOpeningAutomatic&&(this.store.recordAutomaticPromptDismissed(),this.wasLastOpeningAutomatic=!1)}}async init(e,t){this.engine=t,this.config=e,this.viewData=new o.P,this.store=new g(e.queue,e.baseUrl,e.baseModelId),this.promptEnabled=e.promptEnabled,this.settings=await t.market.waitForData(w.e),this.modelData=await t.market.waitForData(y.T),this.bindings.push(t.commandBinder.addBinding(a.m,this.handleToggleDialogCommand),t.commandBinder.addBinding(a.M,this.handleSubmitModelRatingCommand));const i=this.modelData.model.created;let n=!!i&&Date.now()-+new Date(i)<T;this.promptEnabled&&e.debug&&(this.log.info("Debug Mode Enabled: Ignoring max model age requirement for rating prompt."),n=!0),this.log.debug(`promptEnabled: ${e.promptEnabled}, isModelEligible: ${n}`),this.promptEnabled&&n&&this.bindings.push(t.subscribe(s.i,this.handleActivityPingMessage)),t.market.register(this,o.P,this.viewData),this.registerSettings()}async registerSettings(){const e=await this.engine.getModuleBySymbol(f.y.SETTINGS),{debug:t}=this.config;t&&e.registerMenuButton({header:"Model Rating",buttonName:"Reset Model Rated value",callback:()=>{this.settings.setLocalStorageProperty(m.F.LastRatingPromptTime,null),this.store.reset()}})}dispose(e){this.bindings.forEach((e=>{e.cancel()})),this.bindings=[],super.dispose(e)}}const S=D},38987:(e,t,i)=>{"use strict";i.d(t,{u:()=>n});var s=i(19663);class n extends s.m{constructor(e=null){super(),this.id="SET_MOUSE_CURSOR",this.payload={cursor:e}}}},34956:(e,t,i)=>{"use strict";var s;i.d(t,{C:()=>s}),function(e){e.NONE="none",e.DEFAULT="default",e.MOVE="move",e.MOVE_LF="col-resize",e.MOVE_UD="row-resize",e.XHAIR="crosshair",e.PLUS="cell",e.QUESTION="help",e.NOPE="not-allowed",e.FINGER="pointer",e.TEXT="text",e.TEXT_VERT="vertical-text",e.ZOOM_IN="zoom-in",e.ZOOM_OUT="zoom-in",e.GRAB="grab",e.GRABBING="grabbing",e.ARROW_R="e-resize",e.ARROW_L="w-resize",e.ARROW_U="n-resize",e.ARROW_D="s-resize",e.ARROW_UR="ne-resize",e.ARROW_UL="nw-resize",e.ARROW_DR="se-resize",e.ARROW_DL="sw-resize",e.ARROW_LR="ew-resize",e.ARROW_UD="ns-resize",e.ARROW_URDL="nesw-resize",e.ARROW_ULDR="nwse-resize",e.ROOMBOUNDS_DEFAULT="rbe-default",e.ROOMBOUNDS_MOVING="rbe-moving",e.ROOMBOUNDS_PLACE_NODE="rbe-place-node",e.ROOMBOUNDS_FINISH_ROOM="rbe-finish-room",e.ROOMBOUNDS_PLACE_OPENING="rbe-place-opening",e.ROOMBOUNDS_PLACE_DOOR="rbe-place-door"}(s||(s={}))},73992:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>m});var s=i(97542),n=i(97998),o=i(75287);class r extends o.T{equals(e){return this.id===e.id}copy(e){return this.id=e.id,this.name=e.name,this.vendor=e.vendor,this.model=e.model,this.captureMode=e.captureMode,this.depthCameraType=e.depthCameraType,this.cameraTypes=e.cameraTypes.slice(),this.sensorSerialNumbers=e.sensorSerialNumbers.slice(),this.serialNumber=e.serialNumber,this.mountCalibrationVersion=e.mountCalibrationVersion,this.softwareVersion=e.softwareVersion,this}}class a extends o.T{constructor(e){super(),e&&(e.id&&(this.id=e.id),void 0!==e.index&&(this.index=e.index),this.name=e.name||"",this.created=e.created||"",this.alignment=e.alignment||"",this.options=e.options||[],this.camera=e.camera||new r)}equals(e){return this.id===e.id}copy(e){return this.id=e.id,this.index=e.index,this.name=e.name,this.created=e.created,this.alignment=e.alignment,this.options=e.options.slice(),this.camera=(new r).copy(e.camera),this}}const h=new n.Z("mds-scaninfo-serializer");class d{deserialize(e){if(!e||!this.validate(e))return h.debug("Deserialized invalid ScanInfo data from MDS",e),null;const t=e,i=new a;i.id=t.id,i.anchorId=t.anchor&&t.anchor.id||"",i.index=t.index||-1,i.name=t.name||"",i.created=t.created||"",i.alignment=t.alignment||"",i.url=t.url||"",i.timeOfDay=t.timeOfDay||"",i.options=t.options||[];const s=t.camera;return i.camera=new r,i.camera.id=s&&s.id||"",i.camera.name=s&&s.name||"",i.camera.vendor=s&&s.vendor||"",i.camera.model=s&&s.model||"",i.camera.captureMode=s&&s.captureMode||"",i.camera.depthCameraType=s&&s.depthCameraType||"",i.camera.cameraTypes=((null==s?void 0:s.cameraTypes)||[]).filter((e=>e)),i.camera.sensorSerialNumbers=((null==s?void 0:s.sensorSerialNumbers)||[]).filter((e=>e)),i.camera.serialNumber=s&&s.serialNumber||"",i.camera.mountCalibrationVersion=(null==s?void 0:s.mountCalibrationVersion)?s.mountCalibrationVersion:void 0,i.camera.softwareVersion=s&&s.softwareVersion||"",i}validate(e){if(!e)return!1;return["id"].every((t=>t in e))}}var l=i(17788),c=i(68512);class u{}class p extends l.u{constructor(){super(...arguments),this.deserializer=new d}async fetch(){const e=this.getViewId();return this.query(c.GetScans,{modelId:e},{fetchPolicy:"no-cache"}).then((e=>{var t,i,s;const n=(null===(s=null===(i=null===(t=e.data)||void 0===t?void 0:t.model)||void 0===i?void 0:i.assets)||void 0===s?void 0:s.scans)||[],o={},r={};for(const e of n){const t=this.deserializer.deserialize(e);t&&(o[t.id]=t,t.anchorId&&(r[t.anchorId]=t))}const a=new u;return a.scansById=o,a.scansByAnchor=r,a}))}async read(){return this.scans||(this.scans=this.fetch()),this.scans}async refresh(){return this.scans=this.fetch(),this.scans}}var g=i(80742);class m extends s.Y{constructor(){super(...arguments),this.name="scaninfo-data",this.getScanInfo=e=>this.store.read().then((t=>t?t.scansByAnchor[e]:void 0)),this.getScanDownloadURL=e=>this.store.refresh().then((t=>{if(t){const i=t.scansByAnchor[e];return i?i.url:void 0}}))}async init(e,t){const i=await t.market.waitForData(g.R);this.store=new p({context:i.mdsContext,readonly:!0})}}},56163:(e,t,i)=>{"use strict";i.d(t,{K:()=>a});var s=i(52528),n=i(71166),o=i(63319);const r=new s.v({});class a{constructor(e,t,i){this.commandBinder=e,this.layersData=t,this.dataTypeGroup=i,this.textParser=r,this.enabled=!0,this.bindings=[]}getGroupingId(e){switch(e){case o.HH.TYPE:return this.getTypeId();case o.HH.FLOOR:return this.getFloorId();case o.HH.LAYER:return this.getLayerGroupId();case o.HH.DATE:return this.dateBucket}}getFloorId(){return this.floorId}getDateBucket(){return this.dateBucket}getTypeId(){return this.typeId}supportsBatchDelete(){return!1}supportsLayeredCopyMove(){return!1}getLayerGroupId(){var e,t;const i=null===(e=this.layersData)||void 0===e?void 0:e.getBaseLayerId(),s=null===(t=this.layersData)||void 0===t?void 0:t.getViewLayerId();return this.layerId&&s&&this.layerId===i?s:this.layerId}isLayerVisible(){return!this.layersData||!this.layerId||this.layersData.layerVisible(this.layerId)}onSelect(e,t,i){this.commandBinder.issueCommand(new n.IL(this.id,this.typeId))}registerBindings(){}cancelBindings(){this.bindings.forEach((e=>e.cancel()))}}},3907:(e,t,i)=>{"use strict";i.d(t,{MU:()=>a});var s,n=i(39880),o=i(44584);!function(e){e.GET="GET",e.POST="POST",e.PATCH="PATCH",e.PUT="PUT",e.DELETE="DELETE",e.OPTIONS="OPTIONS"}(s||(s={}));class r extends class{constructor(){this._options={responseType:"json"}}get options(){const e=this._options;return e.headers=(0,o.m)(this.url,this._options.headers||{}),e}}{constructor(e){super(),this.config=e,this.url=e.path}async read(){const{deserialize:e}=this.config;let t=null;return this.config.cachedData&&this.config.cachedData.data?t=this.config.cachedData.data:(t=await this.config.queue.get(this.config.path,this.options),this.config.cachedData&&(this.config.cachedData.data=t)),e(t)}clearCache(){this.config.cachedData&&(this.config.cachedData.data=null)}}class a extends r{constructor(e){super(e),this.config=e,this.acceptsPartial=!1,this.config.batchUpdate="batchUpdate"in this.config&&this.config.batchUpdate}async create(e){throw Error("Not implemented")}updateBatch(e,t){const{serialize:i}=this.config,n=[],o=[...new Set([...Object.keys(e),...Object.keys(t)])];for(const i of o){e[i]||t[i]||n.push(this.config.queue.delete(`${this.config.path}/${i}`,this.options))}const r=i(e,t),a=Object.assign(Object.assign({},this.options),{body:r});return n.push(this.config.queue.request(this.config.httpMethod||s.POST,this.config.path,a)),Promise.all(n)}updateInternal(e,t){const{serialize:i}=this.config,o=[],r=Object.assign({},this.options),a=Object.keys(e),h=Object.keys(t),d=(0,n.XN)(a.concat(h));for(const n in d){const a=d[n],h=e[a]||t[a];if(h){const e={};e[a]=h;const n={},d=t[a];d&&(n[a]=d);const l=i(e,n);r.body=l,o.push(this.config.queue.request(this.config.httpMethod||s.POST,this.config.path,r))}else o.push(this.config.queue.delete(`${this.config.path}/${a}`,this.options))}return Promise.all(o)}async update(e,t){this.clearCache(),await(this.config.batchUpdate?this.updateBatch(e,t||{}):this.updateInternal(e,t||{}))}async delete(e){throw Error("Not implemented")}}},84366:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(98010);class n extends s.v{constructor(e,t,i){super(),this.size=e,this.sweepId=t,this.renderTarget=i}}},10777:(e,t,i)=>{"use strict";i.d(t,{D:()=>n,F:()=>o});var s=i(19663);class n extends s.m{constructor(e){super(),this.id="ALLOW_HIGH_RES",this.payload={ignoreWindowSize:e}}}class o extends s.m{constructor(e){super(),this.id="SET_NAV_PANO_SIZE",this.payload={navSize:e}}}},99685:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>re});var s=i(69170),n=i(71239),o=i(56692),r=i(2224);class a extends r.y{constructor(e){super(e),this.name="PanoTilingError"}}var h=i(97998),d=i(81396),l=i(70903),c=i(90304);var u;!function(e){e[e.PreOrder=0]="PreOrder",e[e.PostOrder=1]="PostOrder"}(u||(u={}));class p{constructor(e,t){this.tree=e,this.parent=t,this.children=[],this.id=++p._id,this.extra={},this.level=-1}}p._id=0;class g{constructor(e,t){this.levels=t,this.tileSize=e,this.root=null,this.allNodes=[],y(this)}getSizeForLevel(e,t){return Math.pow(2,t)*e}getSubNode(e,t,i){(!t||e<this.tileSize)&&(t=0),(!i||e<this.tileSize)&&(i=0),e<this.tileSize&&(e=this.tileSize);const s=m(this.tileSize,e);return v(this.root,0,s,t,i)}deleteAllNodes(){this.depthFirst(function(e,t,i,s,n){for(let t=0;t<e.children.length;t++){const i=e.children[t];i&&(i.parent=null,i.tree=null),e.children[t]=null}e.children.length=0}.bind(this),null,u.PostOrder);for(let e=0;e<this.allNodes.length;e++){const t=this.allNodes[e];t&&(t.parent=null,t.tree=null),this.allNodes[e]=null}this.allNodes.length=0,this.root=null}breadthFirst(e){const t=!!(e=e||{}).nullLevelEnd,i=e.maxLevel,s=e.minLevel,n=e.callback,o=e.saveVisited,r=[],a=new p(this,null);let h=0;if(this.root)for(r.push(this.root),r.push(a);r.length>0&&!(i&&h>i);){const e=r.shift();if(e)if(e===a)(!s||h>=s)&&(n&&t&&n(),o&&t&&o.push(null)),r.length>0&&r.push(a),h++;else{if(e.children)for(const t of e.children)t&&r.push(t);const t=this.getFaceIndexFromNode(e);(!s||h>=s)&&(n&&n(e,h,t),o&&o.push(e))}}}getFaceIndexFromNode(e){if(!e)return-1;let t=1,i=e,s=0,n=0;for(;;){const e=i.parent;if(!e)break;let o=-1;for(let t=0;t<e.children.length;t++)e.children[t]===i&&(o=t);s=o%2*t+s,n=Math.floor(o/2)*t+n,t*=2,i=e}return n*t+s}depthFirst(e,t,i){w(this.root,0,0,0,e,t,i,this.tileSize)}}const m=function(e,t){let i=0;for(t<e&&(t=e);!((t/=2)<e);)i++;return i},w=function(e,t,i,s,n,o,r,a){if(!e)return;const h=2*s+i;if((r=r||u.PreOrder)===u.PreOrder&&(n&&n(e,t,h,i,s),o&&o.push(e)),!e.children||0===e.children.length)return;const d=2*s,l=2*i;for(let i=0;i<2;i++)for(let s=0;s<2;s++)w(e.children[2*s+i],t+1,l+i,d+s,n,o,r,a);r===u.PostOrder&&(n&&n(e,t,h,i,s),o&&o.push(e))},y=e=>{e.root=f(e,null,0)},f=(e,t,i)=>{if(i>e.levels)return null;const s=new p(e,t);s.level=i,e.allNodes.push(s);for(let t=0;t<4;t++){const n=f(e,s,i+1);n&&(s.children[t]=n)}return s},v=(e,t,i,s,n)=>{if(!e)return null;if(0===i)return e;{if(!e.children||0===e.children.length)return null;const o=Math.pow(2,i)/2,r=s%o,a=n%o,h=2*Math.floor(n/o)+Math.floor(s/o),d=e.children[h];return v(d,t+1,i-1,r,a)}};var b,T=i(55084),D=i(25215),S=i(27646),P=i(14766),I=i(76609),M=i(54730);!function(e){e[e.Base=0]="Base",e[e.Remaining=1]="Remaining"}(b||(b={}));class x{constructor(e){this.tilePrioritizer=e,this.forceQueue=[],this.uploadQueues={},this.panoLODDescriptors={}}addToForceQueue(e){this.forceQueue.push(e)}addToPanoQueue(e,t){this.getUploadQueueForPano(e).push(t)}insertSortedIntoPanoQueue(e,t,i){const s=this.getUploadQueueForPano(t.id);this.tilePrioritizer.insertSortedPanoTile(s,e,t,i)}sortQueue(e,t){const i=this.getUploadQueueForPano(e.id);this.tilePrioritizer.sortTiles(i,e,t)}getUploadQueueForPano(e){let t=this.uploadQueues[e];return t||(t=[],this.uploadQueues[e]=t),t}hasQueuedTiles(){if(this.forceQueue.length>0)return!0;for(const e in this.uploadQueues){const t=this.getUploadQueueForSweep(e);if(t&&t.length>0)return!0}return!1}getUploadQueueForSweep(e){let t=this.uploadQueues[e];return t||(t=[],this.uploadQueues[e]=t),t}getTopUploadQueue(e){let t=null;for(let i=b.Base;i<=b.Remaining;i++)for(const s of e)if(t=this.getUploadQueueForSweep(s.id),t.length>0)switch(i){case b.Base:if(0===t[0].level)return t;break;case b.Remaining:return t}return null}processNextQueueItem(e){const t=e.shift();return t?(t.uploadQueued=!1,t):null}getNextFromUploadQueue(e){if(this.forceQueue.length>0)return this.processNextQueueItem(this.forceQueue);const t=this.getTopUploadQueue(e);return t&&t.length>0?this.processNextQueueItem(t):null}peekNextFromUploadQueue(e){if(this.forceQueue.length>0)return this.forceQueue[0];const t=this.getTopUploadQueue(e);return t&&t.length>0?t[0]:null}clearAllQueuedUploads(){this.clearAllUploadQueues(null,0)}clearAllUploadQueues(e,t=0){if(e)this.clearUploadQueue(this.getUploadQueueForSweep(e),t),this.clearUploadQueue(this.forceQueue,t,e);else{for(const e in this.uploadQueues)this.clearUploadQueue(this.getUploadQueueForSweep(e),t);this.clearUploadQueue(this.forceQueue,t)}}clearUploadQueue(e,t=0,i){let s=0;for(;s<e.length;){const n=e[s];(!i||i&&i===n.sweepId)&&n.level>=t?(n.uploadQueued=!1,e.splice(s,1)):s++}}resetPanoLODDescriptors(e){const t=this.getPanoLODDescriptors(e);for(const e in t)if(t.hasOwnProperty(e)){const i=t[e];i.uploadCount=0,i.uploadAttempts=0}}getPanoLODDescriptor(e,t){const i=this.getPanoLODDescriptors(e);let s=i[t];return s||(s={uploadCount:0,uploadAttempts:0},i[t]=s),s}getPanoLODDescriptors(e){let t=this.panoLODDescriptors[e];return t||(t={},this.panoLODDescriptors[e]=t),t}}var R=i(84366),E=i(39880),C=i(60047),A=i(40505),L=i(947);const O=new h.Z("tiles"),F=n.Xd.uploadIntervalDelay;class k extends D.Z{constructor(e,t,i,s,n,o,r,a){super(n.getSweepList()),this.cwfRenderer=e,this.panoQualityManager=t,this.tileDownloader=i,this.tilePrioritizer=s,this.sweepData=n,this.cameraData=o,this.tilingSettings=r,this.broadcast=a,this.persistentStorage=new M.a,this.activeSweeps=[],this.sweepLoadHistory=[],this.activeRenderTargetDescriptors={},this.panoLoadPromises={},this.panoLoadResolvers={},this.panoLoadTimers={},this.tileTrees={},this.tileDirectory={},this.zoomSweepRenderingDisabled=!1,this.zoomingActive=!1,this.zoomSweepId=null,this.usingTileOverlay=!1,this.overlayTilesLoaded=!1,this.overlayTilesBasic={},this.overlayTilesEnhanced={},this.tileUploadQueue=new x(this.tilePrioritizer),this.currentState={direction:new d.Vector3,position:new d.Vector3,rotation:new d.Quaternion},this.renderTargetPool=new l.L(this.rtCompare),this.tileDownloader.setModel(this.sweepListMap),this.tileDownloader.setLoadCallbacks(this.onTileDownLoaded.bind(this))}activate(e){this.engine=e}rtCompare(e,t){return e.object.height===t.size&&e.object.width===t.size}getActivePanos(){const e=[];for(const t of Object.keys(this.activeRenderTargetDescriptors)){this.activeRenderTargetDescriptors[t]&&e.push(t)}return e}init(){super.init(),this.loadOverlayTiles()}highResRenderTarget(e,t){if(e){if(!t)throw new a("Cannot activate zooming without sweepId!");this.zoomingActive=!0,this.zoomSweepId=t,this.copyTargetToZoom(t)}else this.zoomingActive=!1,this.zoomSweepId=null;if(t){const e=this.getRenderTargetDescriptorForSweep(t);if(!e)throw new a("Zooming at a null render target!");const i=this.zoomingActive?this.zoomRenderTarget:e.object,s=i.width;this.broadcast(new R.Z(s,t,i))}}getCurrentPanoResolution(){const e=this.zoomingActive?this.panoQualityManager.getZoomPanoSize():this.panoQualityManager.getNavPanoSize();return S.Z.getPanoSizeClass(e)}beforeRender(){const e=this.sweepData.currentSweep,t=this.sweepData.transition.to;this.updateState(this.cameraData.pose.position,this.cameraData.pose.rotation,e,t),this.updateUploadQueueProcessing()}activateSweep(e){const t=this.sweepListMap.get(e);if(!t)throw O.error(e,t),new a("Invalid sweepId passed to TiledPanoRenderer.activate()");let i=this.panoLoadPromises[e];return i||(this.panoLoadTimers[e]=window.setTimeout((()=>{this.engine.broadcast(new A.Z_(!0))}),n.Xd.loadIndicatorDelay),i=new Promise(((i,s)=>{this.panoLoadResolvers[e]=i,this.updateSweepState(e),this.activatePano(t),this.queueUploadForAllTiles(e,!0),this.tileDownloader.forceQueueTiles(t,S.Z.getPanoSize(I.SL.BASE),this.currentState.direction,!0)})),this.panoLoadPromises[e]=i),super._activateSweep(e),i}useTexture(e){const t=this.getRenderTargetDescriptorForSweep(e);if(!t)throw O.error(e),new a("Texture for sweep not activated before using");const i=t.object.texture;return super._useTexture(e),this.freeUnusedTextures(),this.zoomingActive?this.zoomRenderTarget.texture:i}freeTexture(e,t=!1){super.freeTexture(e,t),0===this.textureUsageCounter[e]&&(this.panoLoadPromises[e]=null,this.deactivatePano(e))}freeAllTextures(e=[]){const t=(0,E.ow)(e),i=this.getActivePanos();for(const e of i)t[e]||this.freeTexture(e,!0)}enableUltraHighQualityMode(e){this.setupZoomRenderTarget(),this.zoomSweepId&&this.broadcast(new R.Z(this.zoomRenderTarget.width,this.zoomSweepId,this.zoomRenderTarget))}resetRenderStatus(e,t,i,s){let n;s&&(n=m(T.I_,s)+1);const o=(e,s,n,o)=>{i&&(s.extra.tile.zoomUploaded=!1),t&&(s.extra.tile.uploaded=!1)};for(let t=0;t<T.Hq;t++){this.getTileTree(e,t).breadthFirst({callback:o.bind(this,t),minLevel:n})}}copyBaseRenderStatusToZoomed(e){const t=m(T.I_,this.panoQualityManager.getNavPanoSize()),i=(e,t,i,s)=>{t.extra.tile.zoomUploaded=t.extra.tile.uploaded,t.extra.zoomCovered=t.extra.covered};for(let s=0;s<T.Hq;s++){this.getTileTree(e,s).breadthFirst({callback:i.bind(this,s),maxLevel:t})}}renderPanoTiles(e,t,i,s){const n=[];this.zoomRenderTarget&&this.zoomRenderTarget.width===this.panoQualityManager.getZoomPanoSize()||this.zoomSweepRenderingDisabled||this.setupZoomRenderTarget(),t=t||this.currentState.direction||c.f.FORWARD;const o=this.getRenderTargetDescriptorForSweep(e);if(!this.isRenderTargetDescriptorValid(o))throw new a("PanoRenderer.renderPanoTiles() -> Cannot render to a pano that is not activated.");for(let t=0;t<T.Hq;t++){const o=this.getTileTree(e,t);n.length=0,o.breadthFirst({saveVisited:n});for(let e=0;e<n.length;e++){const t=n[e];this.queueUploadForTile(t.extra.tile,!1,s||0===e&&i)}}}renderAllActivePanos(){for(const e of this.getActivePanos())this.resetUploadState(e,!0,!0),this.clearAllQueuedUploadsForPano(e),this.renderPanoTiles(e,null,!0,!0)}clearAllQueuedUploads(){this.tileUploadQueue.clearAllUploadQueues(null,0)}clearAllQueuedUploadsForPano(e){this.tileUploadQueue.clearAllUploadQueues(e,0)}updateState(e,t,i,s){const n=s||i||this.currentState.sweepId,o=n?this.sweepListMap.get(n):null;this.updatePositionState(e),this.updateRotationState(t),n&&this.updateSweepState(n),o&&this.tileDownloader.tilePrioritizer&&this.tileDownloader.tilePrioritizer.updateCriteria(o,e,this.currentState.direction,this.currentState.rotation)}updatePositionState(e){this.currentState.position.copy(e)}updateRotationState(e){if(this.currentState.rotation.copy(e),this.currentState.direction.copy(c.f.FORWARD).applyQuaternion(e),this.tileUploadQueue.hasQueuedTiles())for(const e of this.activeSweeps)this.tileUploadQueue.sortQueue(e,this.currentState.direction)}updateSweepState(e){this.currentState.sweepId=e}activatePano(e){this.tileUploadQueue.clearAllQueuedUploads();const t=this.panoQualityManager.getMaxPossiblePanoSize();for(let i=0;i<T.Hq;i++)this.initTileTree(e.id,i,t);this.linkAllTilesAndNodes(e);let i=this.getRenderTargetDescriptorForSweep(e.id);if(!i){const t=this.panoQualityManager.getNavPanoSize();if(i=this.renderTargetPool.get({size:t}),!i){const e=this.cwfRenderer.initRenderTargetCube(t);i=this.renderTargetPool.add(e),i.extra={},i.extra.size=e.width}i.extra.sweep=e,i.extra.sweepindex=e.index,this.setRenderTargetDescriptorForSweep(e.id,i),this.tileUploadQueue.resetPanoLODDescriptors(e.id),this.resetUploadState(e.id,!0,!0)}return this.updateActiveSweeps(e),i.object}deactivatePano(e){const t=this.getRenderTargetDescriptorForSweep(e);t&&this.isRenderTargetDescriptorValid(t)&&(this.renderTargetPool.free(t.object),this.setRenderTargetDescriptorForSweep(e,null),this.updateActiveSweeps(),this.tileUploadQueue.clearAllUploadQueues(e),this.tileUploadQueue.resetPanoLODDescriptors(e),this.clearCachedTileData())}clearCachedTileData(){for(let e=this.sweepLoadHistory.length-1;e>=0;e--){let t=!1;const i=this.sweepLoadHistory[e];if(i){for(const e of this.activeSweeps)if(i===e.id){t=!0;break}t||(this.checkTileTreeInitialized(i)&&(this.clearTileState(i,!0,!0),this.deleteTileTrees(i)),this.deleteTileDirectoryEntries(i),this.tileDownloader.deleteAllTileDownloadDescriptors(i),this.sweepLoadHistory[e]=null)}}this.updateSweepLoadHistory()}updateActiveSweeps(e){const t=this.persistentStorage.getArray("updateActiveSweeps:tempSweeps");t.length=0;for(const i of this.activeSweeps){const s=this.getRenderTargetDescriptorForSweep(i.id);e&&i.id===e.id||!this.isRenderTargetDescriptorValid(s)||t.push(i)}e&&t.unshift(e),this.activeSweeps.length=0,this.activeSweeps.push(...t)}queueUploadForAllTiles(e,t=!0){this.zoomRenderTarget&&this.zoomRenderTarget.width===this.panoQualityManager.getZoomPanoSize()||this.zoomSweepRenderingDisabled||this.setupZoomRenderTarget();const i=this.getRenderTargetDescriptorForSweep(e);if(!this.isRenderTargetDescriptorValid(i))throw new a("queueUploadForAllTiles() -> Cannot render to a pano that is not activated.");const s=this.persistentStorage.getArray("queueUploadForAllTiles:nodeList");for(let i=0;i<T.Hq;i++){const n=this.getTileTree(e,i);s.length=0,n.breadthFirst({saveVisited:s});for(const e of s)this.queueUploadForTile(e.extra.tile,!1,0===e.level&&t)}}onTileDownLoaded(e){if(!e.sweep)return;const t=m(T.I_,e.panoSize),i=this.getTileDirectoryEntry(e.sweep.id,e.face,t,e.faceTileIndex);this.updateUploadDescriptorFromDownloadDescriptor(i,e),this.updateSweepLoadHistory(i.sweepId);const s=this.getRenderTargetDescriptorForSweep(i.sweepId);if(this.isRenderTargetDescriptorValid(s)){const e=this.getTileTree(i.sweepId,i.face).getSubNode(i.panoSize,i.tileX,i.tileY);e&&(this.linkTileAndNode(i,e),this.queueUploadForTile(i,!0))}}updateUploadDescriptorFromDownloadDescriptor(e,t){e.downloaded=!0,e.image=t.image,e.panoSize=t.panoSize,e.tileX=t.tileX,e.tileY=t.tileY,e.totalTiles=t.totalTiles,e.tileIndex=t.tileIndex,e.faceTileIndex=t.faceTileIndex,e.face=t.face,e.cubeFace=P.m(t.face),t.sweep&&(e.sweepId=t.sweep.id),e.tileSize=t.tileSize,e.direction.copy(t.direction),e.node=null,e.level=m(T.I_,e.panoSize)}updateSweepLoadHistory(e){const t=this.persistentStorage.getArray("updateSweepLoadHistory:tempHistory");t.length=0;for(const i of this.sweepLoadHistory)i&&(!e||e&&e!==i)&&t.push(i);this.sweepLoadHistory.length=0,e&&this.sweepLoadHistory.push(e),this.sweepLoadHistory.push(...t)}onPanoRendered(e,t,i,s){clearTimeout(this.panoLoadTimers[e]),this.engine.broadcast(new A.Z_(!1));const n=this.panoLoadResolvers[e],o=this.activeRenderTargetDescriptors[e];o&&o.object&&n(o.object.texture)}getRenderTargetDescriptorForSweep(e){return this.activeRenderTargetDescriptors[e]}setRenderTargetDescriptorForSweep(e,t){this.activeRenderTargetDescriptors[e]=t}isRenderTargetDescriptorValid(e){return!!e&&!!e.object}isSweepZoomed(e){return this.zoomingActive&&this.zoomSweepId===e}initTileTree(e,t,i){let s=this.tileTrees[e];s||(s=[],this.tileTrees[e]=s);let n=s[t];if(!n){const e=m(T.I_,i);n=new g(T.I_,e),s[t]=n}}getTileTrees(e){const t=this.tileTrees[e];if(!t)throw new a("TiledPanoRenderer.getTileTrees() -> Tree array not yet initialized!");return t}checkTileTreeInitialized(e){return!!this.tileTrees[e]}getTileTree(e,t){const i=this.getTileTrees(e)[t];if(!i)throw new a("TiledPanoRenderer.getTileTree() -> Tree not yet initialized!");return i}deleteTileTrees(e){const t=this.getTileTrees(e);for(let e=0;e<T.Hq;e++){const i=t[e];i&&i.deleteAllNodes()}this.tileTrees[e]=null,delete this.tileTrees[e]}clearTileState(e,t=!1,i=!1){const s=(e,s,n,o)=>{var r,a;i&&(null===(a=null===(r=s.extra.tile.image)||void 0===r?void 0:r.close)||void 0===a||a.call(r),s.extra.tile.image=null),t&&(s.extra.tile.uploaded=!1,s.extra.tile.downloaded=!1,s.extra.tile.zoomUploaded=!1,s.extra.tile.uploadAttempted=!1)};for(let t=0;t<T.Hq;t++){const i=this.getTileTree(e,t);i&&i.breadthFirst({callback:s.bind(this,t),maxLevel:m(T.I_,this.panoQualityManager.getZoomPanoSize())})}}resetUploadState(e,t,i){const s=(e,s,n,o)=>{s.extra.tile.zoomUploaded=!i&&s.extra.tile.zoomUploaded,s.extra.tile.uploaded=!t&&s.extra.tile.uploaded};for(let t=0;t<T.Hq;t++){this.getTileTree(e,t).breadthFirst({callback:s.bind(this,t),minLevel:0})}}anyUploaded(e){if(!e)return!1;if(e.extra.tile&&this.isTileUploaded(e.extra.tile))return!0;if(e.children)for(const t of e.children)if(this.anyUploaded(t))return!0;return!1}linkTileAndNode(e,t){t.extra.tile=e,e.node=t}linkAllTilesAndNodes(e){const t=(t,i,s,n,o)=>{const r=this.getTileDirectoryEntry(e.id,i,n,o);this.linkTileAndNode(r,s)};for(let i=0;i<T.Hq;i++){const s=this.getTileTree(e.id,i);s.breadthFirst({callback:t.bind(this,s,i)})}}getTileDirectoryEntry(e,t,i,s){let n=this.tileDirectory[e];n||(n={},this.tileDirectory[e]=n);const o=16384*t+1024*i+s;let r=n[o];return r||(r={downloaded:!1,uploaded:!1,uploadAttempted:!1,zoomUploaded:!1,uploadQueued:!1,image:null,panoSize:-1,tileX:-1,tileY:-1,totalTiles:-1,tileIndex:s,faceTileIndex:-1,face:t,cubeFace:-1,sweepId:e,tileSize:-1,direction:new d.Vector3,node:null,level:i},n[o]=r),r._tileKey=o,r}deleteTileDirectoryEntries(e){var t,i;const s=this.tileDirectory[e];if(s)for(const e of Object.values(s))e.image&&(null===(i=(t=e.image).close)||void 0===i||i.call(t),e.image=null);delete this.tileDirectory[e]}isTileUploaded(e){return this.isSweepZoomed(e.sweepId)?e.zoomUploaded:e.uploaded}setUploaded(e,t){this.isSweepZoomed(e.sweepId)?e.zoomUploaded=t:e.uploaded=t}queueUploadForTile(e,t,i){const s=!e.downloaded||e.uploadQueued&&!i||this.isTileUploaded(e)||e.panoSize>this.panoQualityManager.getNavPanoSize()&&!this.zoomingActive,n=this.getRenderTargetDescriptorForSweep(e.sweepId);!s&&n&&this.isRenderTargetDescriptorValid(n)&&(i?this.uploadTile(e):(0===m(T.I_,e.panoSize)?this.tileUploadQueue.addToForceQueue(e):t&&this.currentState.direction?this.tileUploadQueue.insertSortedIntoPanoQueue(e,n.extra.sweep,this.currentState.direction):this.tileUploadQueue.addToPanoQueue(e.sweepId,e),e.uploadQueued=!0))}uploadTile(e){const t=this.persistentStorage.get("uploadTile:tempTileTexture",(()=>({}))),i=this.tileUploadQueue.getPanoLODDescriptor(e.sweepId,e.panoSize),s=this.getRenderTargetDescriptorForSweep(e.sweepId);if(!s||!e.image||!this.isRenderTargetDescriptorValid(s))return;let o=s.object,r=s.extra.size;if(this.isSweepZoomed(e.sweepId)&&(o=this.zoomRenderTarget,r=this.panoQualityManager.getZoomPanoSize()),this.isTileUploaded(e)||this.anyUploaded(e.node))this.setUploaded(e,!1);else{const s=e.tileX*e.tileSize,a=e.tileY*e.tileSize,h=e.tileSize/e.panoSize*r,l=s/e.panoSize*r,c=a/e.panoSize*r;let u=t[e.tileSize];if(t[e.tileSize]||(u=this.cwfRenderer.initSizedTexture2D(e.tileSize,{generateMipmaps:!1,minFilter:d.LinearFilter,flipY:!1}),t[e.tileSize]=u),this.cwfRenderer.uploadTexture2D(e.image,u,0,0),this.cwfRenderer.renderToCubeMap(u,o,e.tileSize,e.tileSize,0,0,e.tileSize,e.tileSize,l,c,h,h,e.cubeFace),n.Xd.overlayStyle>0){const t=1===n.Xd.overlayStyle?this.overlayTilesBasic:this.overlayTilesEnhanced;this.cwfRenderer.renderToCubeMap(t[e.panoSize],o,e.tileSize,e.tileSize,0,0,e.tileSize,e.tileSize,l,c,h,h,e.cubeFace,d.NormalBlending,!0,.5)}i.uploadCount++,this.setUploaded(e,!0)}e.uploadAttempted||i.uploadAttempts++,e.uploadAttempted=!0,i.uploadAttempts===e.totalTiles&&this.onPanoRendered(e.sweepId,e.panoSize,e.totalTiles)}updateUploadQueueProcessing(){if(!this.currentUploadPromise&&(this.overlayTilesLoaded||!this.usingTileOverlay)){const e=new C._("pano/tiling/upload",(()=>this.engine.after(L.A.End).then((()=>this.processUploadQueue(this.tilingSettings.highResUploadsPerFrame,this.tilingSettings.uploadsPerFrame)))),F);this.currentUploadPromise=this.engine.commandBinder.issueCommand(e).then((async e=>{await e.promise,this.currentUploadPromise=null}))}}processUploadQueue(e=1,t){let i=0,s=0,n=null;for(;n=this.tileUploadQueue.getNextFromUploadQueue(this.activeSweeps);){const o=this.getRenderTargetDescriptorForSweep(n.sweepId);if(!(n.panoSize>this.panoQualityManager.getNavPanoSize()&&!this.zoomingActive||!this.isRenderTargetDescriptorValid(o))&&(this.uploadTile(n),i+=0!==n.level?1:0,s+=0===n.level?1:0,s>=t||i>=e))break}}loadOverlayTiles(){if(0!==n.Xd.overlayStyle){let e=0;const t=[],s=(i,s,n)=>{const o=i[s]=this.cwfRenderer.initSizedTexture2D(T.I_,{generateMipmaps:!1,minFilter:d.LinearFilter,flipY:!1});this.cwfRenderer.uploadTexture2D(n,o,0,0),e++,e>=t.length&&(this.overlayTilesLoaded=!0)};switch(n.Xd.overlayStyle){case 1:t.push([i(95405),this.overlayTilesBasic,256]),t.push([i(95405),this.overlayTilesBasic,512]),t.push([i(43890),this.overlayTilesBasic,1024]),t.push([i(75183),this.overlayTilesBasic,2048]),t.push([i(94326),this.overlayTilesBasic,4096]);break;case 2:t.push([i(21742),this.overlayTilesEnhanced,256]),t.push([i(21742),this.overlayTilesEnhanced,512]),t.push([i(20699),this.overlayTilesEnhanced,1024]),t.push([i(5793),this.overlayTilesEnhanced,2048]),t.push([i(94991),this.overlayTilesEnhanced,4096])}t.forEach((e=>{const t=document.createElement("img");t.crossOrigin="anonymous",t.src=e[0],t.onload=()=>{s.call(this,e[1],e[2],t)}})),this.usingTileOverlay=!0}else this.usingTileOverlay=!1}copyTargetToZoom(e){if(!this.zoomingActive)return;const t=this.getRenderTargetDescriptorForSweep(e);if(!t)throw new a("Error in copying a null render target to a zoomed target");const i=t.object;this.cwfRenderer.copyCubemap(i.texture,this.zoomRenderTarget),this.copyBaseRenderStatusToZoomed(e)}setupZoomRenderTarget(){if(this.panoQualityManager.getZoomPanoSize()>=this.panoQualityManager.getNavPanoSize()){if(this.zoomRenderTarget&&this.zoomRenderTarget.width===this.panoQualityManager.getZoomPanoSize())return;const e=this.zoomRenderTarget;this.zoomRenderTarget=this.cwfRenderer.initRenderTargetCube(this.panoQualityManager.getZoomPanoSize()),e&&(this.cwfRenderer.copyCubemap(e.texture,this.zoomRenderTarget),e.texture.dispose(),e.texture.version=0,e.texture=null),this.zoomSweepRenderingDisabled=!1}else this.zoomSweepRenderingDisabled=!0}}var N=i(48176),B=i(77382),G=i(55721),z=i(53261),V=i(74789);const U=new h.Z("tile-downloader");class Q{constructor(e,t,i,s){this.urls=e,this.panoQualityManager=t,this.tilePrioritizer=i,this.settings=s,this.persistentStorage=new M.a,this.downloadDescriptors={},this.priorityQueue=[],this.forceQueue=[],this.activeDownloads=[],this.lastPrioritizedTime=Date.now(),this.processPriorityQueue=!0}init(){}render(){this.update()}update(){this.processQueue(this.forceQueue,!1),this.processPriorityQueue&&(!this.processQueuePromise&&this.sweepListMap&&this.activeDownloads.length<this.settings.concurrentDownloads&&Date.now()-this.lastPrioritizedTime>200&&(this.processQueuePromise=this.engine.commandBinder.issueCommand(new C._("pano/tiling/queue-download",(()=>{this.queuePrioritizedTiles(this.sweepListMap),this.lastPrioritizedTime=Date.now()}),100)).then((async e=>{await e.promise,this.processQueuePromise=null}))),this.processQueue(this.priorityQueue,!1))}dispose(){}activate(e){this.engine=e}deactivate(e){}setModel(e){this.setSweeps(e)}setRestrictedSweeps(e){if(this.sweepListMap&&this.tilePrioritizer){const t=[];for(const i of e)t.push(this.sweepListMap.get(i));this.tilePrioritizer.setUpcomingSweeps(t),this.clearFromAllQueuesBySweep(e)}}clearRestrictedSweeps(){this.tilePrioritizer&&this.tilePrioritizer.clearUpcomingSweeps()}setLoadCallbacks(e,t){this.onTileDownloaded=e,this.onPanoDownloaded=t}setSweeps(e){this.sweepListMap=e}getNonDownloadedTiles(e,t,i){i.length=0;const s=this.getTileDownloadDescriptors(e,t);for(const e of s)!e||e.status!==G.Z.None&&e.status!==G.Z.Queued||i.push(e)}forceQueueTiles(e,t,i,s,n,o){const r=this.persistentStorage.getArray("forceQueueTiles:remaining"),a=this.persistentStorage.getArray("forceQueueTiles:matching"),h=this.persistentStorage.getArray("forceQueueTiles:toDownload");if(this.getNonDownloadedTiles(e,t,r),h.length=0,r.length>0){this.tilePrioritizer.sortTiles(r,e,i),a.length=0,T.oU(e,t,i,a,!0);for(const e of r)for(const t of a)e.face===t.face&&e.faceTileIndex===t.faceTileIndex&&h.push(e);this.forceQueue.push.apply(this.forceQueue,h),this.setStatusForAllDescriptors(this.forceQueue,G.Z.ForceQueued),this.clearFromQueue(this.priorityQueue,G.Z.ForceQueued,!1),s&&this.processQueue(this.forceQueue,!0)}}clearForceQueue(){this.clearQueue(this.forceQueue)}queuePrioritizedTiles(e){this.tilePrioritizer&&(this.clearQueue(this.priorityQueue),this.tilePrioritizer.filterAndPrioritize(this.priorityQueue,e,this),this.invalidateDuplicateEntries(this.priorityQueue),this.clearFromQueue(this.priorityQueue,G.Z.None,!0),this.setStatusForAllDescriptors(this.priorityQueue,G.Z.Queued),this.lastPrioritizedTime=Date.now())}clearQueue(e){this.setStatusForAllDescriptors(e,G.Z.None),e.length=0}clearFromQueue(e,t,i){for(let s=0;s<e.length;s++){const n=e[s];n&&(t===n.status&&!i||t!==n.status&&i)&&(e[s]=null)}}clearFromAllQueuesBySweep(e){this.clearFromQueueBySweep(this.forceQueue,e),this.clearFromQueueBySweep(this.priorityQueue,e)}clearFromQueueBySweep(e,t){const i=(0,E.ow)(t);for(let t=0;t<e.length;t++){const s=e[t];s&&s.sweep&&(i[s.sweep.id]||(e[t]=null))}}setStatusForAllDescriptors(e,t){for(const i of e)i&&(i.status=t)}invalidateDuplicateEntries(e){for(const t of e)t&&(t.queuedCount=0);for(let t=0;t<e.length;t++){const i=e[t];i&&(i.queuedCount++,i.queuedCount>1&&(e[t]=null))}}getTileDownloadDescriptors(e,t){const i=this.getAllTileDownloadDescriptors(e.id);let s=i[t];return s||(s=this.buildDownloadDescriptorArray(t),i[t]=s,this.initTileDownloadDescriptors(s,e,t)),s}getAllTileDownloadDescriptors(e){let t=this.downloadDescriptors[e];return t||(t={},this.downloadDescriptors[e]=t),t}deleteAllTileDownloadDescriptors(e){this.downloadDescriptors[e]=null,delete this.downloadDescriptors[e]}processQueue(e,t){if(this.cleanupActiveDownloads(),this.activeDownloads.length<this.settings.concurrentDownloads||t){const i=t?e.length:this.settings.concurrentDownloads-this.activeDownloads.length;let s=0;for(let t=0;s<i&&e.length>0;t++){const t=e.shift();t&&(this.startDownload(t),s++)}}}async startDownload(e){if(!this.urls)throw new Error("Can't call startDownload without signed urls");if(e.sweep){const t=e.status===G.Z.ForceQueued?z.ru.HIGHEST:z.ru.MEDIUM;e.status=G.Z.Downloading;this.checkRestrictedSweep(e.sweep.id)||U.warn("Downloading a tile that is not in restricted list"),this.activeDownloads.push(e);const i=await this.panoQualityManager.getTileUrl(e.sweep,e.panoSize,e.tileSize,e.tileIndex);this.urls.getImageBitmap(i,e.tileSize,e.tileSize,{maxRetries:3,priority:t}).then(this.downloadComplete.bind(this,e),this.downloadFailed.bind(this,e))}}checkRestrictedSweep(e){if(this.tilePrioritizer){const t=this.tilePrioritizer.priorityCriteria.upcomingSweeps;if(t){let i=!1;for(const s of t)s&&s.id===e&&(i=!0);return i}return!0}return!0}downloadFailed(e,t){e.status=G.Z.DownloadFailed}downloadComplete(e,t){if(e.sweep&&(e.status=G.Z.Downloaded,e.image=t,this.onTileDownloaded&&this.onTileDownloaded(e),this.engine.broadcast(new V.o),this.isPanoDownloaded(e.sweep,e.panoSize))){const t={sweep:e.sweep,tileSize:e.tileSize,panoSize:e.panoSize};this.onPanoDownloaded&&this.onPanoDownloaded(t)}}cleanupActiveDownloads(){const e=this.persistentStorage.getArray("cleanupActiveDownloads:temp");e.length=0;for(const t of this.activeDownloads)t.status!==G.Z.Downloaded&&t.status!==G.Z.DownloadFailed&&e.push(t);this.activeDownloads.length=0,this.activeDownloads.push.apply(this.activeDownloads,e)}isPanoDownloaded(e,t){const i=this.getTileDownloadDescriptors(e,t);if(!i||i.length<=0)return!1;for(const e of i)if(e&&e.status!==G.Z.Downloaded)return!1;return!0}buildDownloadDescriptorArray(e){const t=T.Tu(e),i=[];for(let e=0;e<t;e++){const e=this.buildDownloadDescriptor();i.push(e)}return i}buildDownloadDescriptor(){return{sweep:null,panoSize:-1,tileSize:-1,tileIndex:-1,totalTiles:-1,faceTileIndex:-1,status:G.Z.None,url:null,image:null,direction:new d.Vector3,face:-1,cubeFace:-1,tileX:-1,tileY:-1,queuedCount:-1}}initTileDownloadDescriptors(e,t,i){for(let s=0;s<e.length;s++){const n=e[s];n&&this.initTileDownloadDescriptor(n,t,i,s)}}initTileDownloadDescriptor(e,t,i,s){const n=i>=T.I_?T.I_:i;e.face=T.R5(i,s),e.cubeFace=P.m(e.face),e.sweep=t,e.panoSize=i,e.tileSize=n,e.tileIndex=s,e.totalTiles=T.Tu(i),e.status=G.Z.None,e.image=null,T.Tp(e.panoSize,e.tileIndex,e),T.P6(e.panoSize,e.tileSize,e.cubeFace,e.tileX,e.tileY,B.Z.Center,0,e.direction)}}var _=i(46368),H=i(9699),j=i(53954),Z=i(5231),W=i(20387),q=i(9037),Y=i(46950),X=i(34029),$=i(10777),K=i(85992),J=i(18930),ee=i(69505),te=i(61948),ie=i(79596),se=i(2032),ne=i(90365),oe=i(92901);class re extends Z.Z{constructor(){super(...arguments),this.name="sweep-pano-tiling",this.preloadQuality=null,this.preloadResolution=null,this.handleResolutionChange=e=>{const t=this.currentResolution();this.panoRenderer.panoQualityManager.setResolution(this.getVerticalResolution());t!==this.currentResolution()&&e&&this.resetPano(e)}}setPreloadQuality(e){this.settingsData.setProperty(n.YS,e)}async init(e,t){const{market:i}=t,[r,a,h,d]=await Promise.all([t.getModuleBySymbol(s.y.MODEL_DATA),t.getModuleBySymbol(s.y.WEBGL_RENDERER),i.waitForData(j.Z),i.waitForData(K.P)]);[this.cameraData,this.settingsData]=await Promise.all([i.waitForData(q.M),i.waitForData(X.e)]);const l=this.cwfRenderer=a.cwfRenderer,c=a.maxCubemapSize,u=r.getSignedUrls();this.settings=new n.k4,this.qualityManager=new S.Z(u,c,e.navPanoSize,e.zoomPanoSize,this.getVerticalResolution()),this.tilePrioritizer=new N.at(this.qualityManager,this.settings,h,d),t.getModuleBySymbol(s.y.MESH_QUERY).then((e=>this.tilePrioritizer.meshQuery=e)),this.tileDownloader=new Q(u,this.qualityManager,this.tilePrioritizer,this.settings),this.panoRenderer=new k(l,this.qualityManager,this.tileDownloader,this.tilePrioritizer,h,this.cameraData,this.settings,(e=>t.broadcast(e))),t.addComponent(this,this.tileDownloader),t.addComponent(this,this.panoRenderer),this.bindings.push(t.subscribe(te.Z,(e=>{this.setTilingFOV()})),t.subscribe(o.a,(()=>{this.handleResolutionChange(h.currentSweep),this.setTilingFOV()})),t.subscribe(oe.Vx,(()=>{this.handleResolutionChange(h.currentSweep),this.setTilingFOV()})),t.subscribe(_.Z,(e=>{this.tileDownloader.setRestrictedSweeps(e.sweepIds)})),t.subscribe(H.Z,(e=>{this.tileDownloader.clearRestrictedSweeps()})),t.subscribe(J.Z,(e=>{const t=h.getSweep(e.sweepId);this.setHoverPreloadSweep(e.hovered?t:void 0)})),t.subscribe(ie.a,(e=>{this.tilePrioritizer.priorityCriteria.viewMode=e.toMode})),h.onPropertyChanged("transitionActive",(()=>{if(h.transition.to){const e=h.getSweep(h.transition.to);this.handlePreloadQualityChange(e)}})),this.settingsData.onPropertyChanged(n.YS,(()=>{this.preloadQuality=this.settingsData.tryGetProperty(n.YS,null),this.qualityManager.overrideWindowMaximums(null!==this.preloadQuality),h.currentSweepObject&&this.handlePreloadQualityChange(h.currentSweepObject)})),t.commandBinder.addBinding($.D,(async e=>{this.qualityManager.overrideWindowMaximums(e.ignoreWindowSize)})),t.commandBinder.addBinding($.F,(async e=>{this.qualityManager.updateNavPanoSize(e.navSize)})),t.subscribe(oe.zq,(()=>{this.panoRenderer.clearAllQueuedUploads()})),t.subscribe(oe.Xq,(()=>{this.panoRenderer.renderAllActivePanos()}))),this.setTilingFOV(),t.broadcast(new se.em(ne.Y.PanoTiles))}getVerticalResolution(){return this.cwfRenderer.getSize().height*this.cwfRenderer.getPixelRatio()}setTilingFOV(){const e=this.cameraData.fovX(),t=this.cameraData.fovY(),i=Math.max(e,t)*ee.MN;this.tilePrioritizer.setDownloadFOV(i)}getRenderer(){return this.panoRenderer}setHoverPreloadSweep(e){this.tilePrioritizer&&this.tilePrioritizer.setHoveredSweep(e)}async handlePreloadQualityChange(e){if(null!==this.preloadQuality){const t=await this.availableResolution(e,this.preloadQuality);this.preloadResolution=S.Z.getPanoSize(t)}else this.preloadResolution=null;this.enableHighRes(!1)}enableHighRes(e=!0,t){const i=null!==this.preloadResolution?this.preloadResolution:e?this.qualityManager.getZoomPanoSize():this.qualityManager.getNavPanoSize();this.tilePrioritizer.maxResolution!==i&&this.log.debug(`Setting max resolution: ${i}`),this.tilePrioritizer.maxResolution=i,this.panoRenderer.highResRenderTarget(e,t)}async enableZooming(e,t){if(e){const e=S.Z.getPanoSizeClass(this.qualityManager.getZoomPanoSize());return await this.requestResolution(t,e)>=e}return this.enableHighRes(!1,t.id),this.resetPano(t.id),Promise.resolve(!1)}async requestResolution(e,t,i=W.v.CurrentView,s=!1){this.settings.highResUploadsPerFrame=s?n.Xd.maxHighResUploadsPerFrame:n.Xd.highResUploadsPerFrame,this.settings.concurrentDownloads=s?n.Xd.maxConcurrentDownloads:n.Xd.concurrentDownloads,this.settings.downloadFullPano=i===W.v.FullPanorama;const o=await this.availableResolution(e,t);return o>I.SL.HIGH&&(this.qualityManager.overrideWindowMaximums(!0),this.panoRenderer.enableUltraHighQualityMode(e.id)),(this.currentResolution()<o||S.Z.getPanoSize(o)>this.qualityManager.getNavPanoSize())&&(this.enableHighRes(!0,e.id),this.resetPano(e.id)),o}waitForQueue(e,t,i=1e3){const s=new Y.Q,n=()=>{a.cancel(),s.notify(1),s.resolve()};let o=this.tilePrioritizer.getQualityQueueSize(e,t),r=window.setTimeout((()=>{this.log.debug(`Download queue ${e} timed out from inactivity after ${i}ms`),n()}),i);const a=this.tilePrioritizer.makeQueueSubscription(e,t,(e=>{if(r&&(window.clearTimeout(r),r=0,o=e),e>0){const t=(o-e)/Math.max(o,1);s.notify(t)}else n()}));return s.promise()}resetSweep(e){this.enableHighRes(!1,e),this.resetPano(e),this.settings.reset()}availableResolution(e,t){return this.qualityManager.availableResolution(e,t).nativePromise()}currentResolution(){return this.panoRenderer.getCurrentPanoResolution()}resetPano(e){this.panoRenderer.resetRenderStatus(e,!1,!0,this.panoRenderer.panoQualityManager.getNavPanoSize()),this.panoRenderer.clearAllQueuedUploadsForPano(e),this.panoRenderer.renderPanoTiles(e,null,!1,!1)}}},25215:(e,t,i)=>{"use strict";i.d(t,{Z:()=>o});var s=i(63252),n=i(48917);const o=class{constructor(e){this.textureUsageCounter={},this.sweepList=e;const t=new n.Z((e=>e.id));for(let e of this.sweepList)e.isObservableProxy&&(e=(new s.ZP).copy(e)),t.add(e);this.sweepListMap=t}init(){}dispose(){}activate(e){}deactivate(e){}beforeRender(){}render(){}_activateSweep(e){this.initTextureUsage(e)}_useTexture(e){this.incrementTextureUsage(e)}freeTexture(e,t=!1){t?this.setTextureUsage(e,0):this.decrementTextureUsage(e)}initTextureUsage(e){this.textureUsageCounter[e]||(this.textureUsageCounter[e]=0)}setTextureUsage(e,t){this.textureUsageCounter[e]=t}freeUnusedTextures(){for(const e of Object.keys(this.textureUsageCounter))0===this.textureUsageCounter[e]&&this.freeTexture(e)}incrementTextureUsage(e){this.textureUsageCounter[e]++}decrementTextureUsage(e){this.textureUsageCounter[e]>0&&this.textureUsageCounter[e]--}}},5231:(e,t,i)=>{"use strict";i.d(t,{Z:()=>o});var s=i(97542),n=i(76609);class o extends s.Y{constructor(){super(...arguments),this.name="sweep-pano-base",this.panoSizeClass=n.SL}getRenderer(){return this.panoRenderer}}},40327:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>c});var s=i(66777),n=i(25215);class o extends n.Z{constructor(e,t){super(t),this.sweepLoader=new s.Z(e)}activateSweep(e){super._activateSweep(e);const t=this.sweepListMap.get(e);return this.sweepLoader.load(t).then((e=>e))}useTexture(e){const t=this.sweepLoader.useTexture(e);return t&&super._useTexture(e),t}freeTexture(e,t=!1){super.freeTexture(e,t),0===this.textureUsageCounter[e]&&this.sweepLoader.unload(e)}freeAllTextures(e){this.sweepLoader.unloadAll(e)}}var r=i(53954),a=i(5231),h=i(76609),d=i(46950),l=i(69170);class c extends a.Z{constructor(){super(...arguments),this.name="sweep-pano"}async init(e,t){const i=(await t.getModuleBySymbol(l.y.MODEL_DATA)).getSignedUrls(),s=(await t.market.waitForData(r.Z)).getSweepList();this.panoRenderer=new o(i,s),t.addComponent(this,this.panoRenderer)}setPreloadQuality(e){this.log.debugWarn(`preload quality not implemented in SolidPanoRenderer ${e}`)}getRenderer(){return this.panoRenderer}resetSweep(){}async availableResolution(){return h.SL.STANDARD}async requestResolution(){return h.SL.STANDARD}waitForQueue(){return(new d.Q).resolve().promise()}async enableZooming(){return!1}}},9699:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(98010);class n extends s.v{constructor(){super()}}},46368:(e,t,i)=>{"use strict";i.d(t,{Z:()=>n});var s=i(98010);class n extends s.v{constructor(e){super(),this.sweepIds=e}}},21453:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>x});var s=i(97542),n=i(81396),o=i(72996),r=i(94046),a=i(82814),h=i(8948),d=i(45881),l=i(19663);class c extends l.m{constructor(e){super(),this.id="TOGGLE_PUCK_EDITING",this.payload={enabled:e}}}var u=i(10699),p=i(16782),g=i(67678),m=i(86819),w=i(34029),y=i(9037),f=i(21973),v=i(23254),b=i(95882);const T=(0,i(87926).p)("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAMAAABrrFhUAAAAP1BMVEUAAAD///////////////////////////////////////////////////////////////////////////////9Du/pqAAAAFXRSTlMAmYWNk1l7bCJCEQpjKHQ0GE9HHToMZFdDAAAHfklEQVR42uzcC3LcIAwAUAnxMT//73/WTmcnnWw7za6xMMLJO0HsCEkI1vDjx49rhbz7xaTRKkWkETWRUnZMZvF7DnBjIa9pVPiCGtN6v/cw72YkPIBGs89wD8PqCIuQWwfoW/BO4yna+W7XQzYKWSiToTvZEDKivt7BZgjZkdmgC9FbrMT6CNINSWNFOsmuC5PF6uwEUnmFl1AeBIoL4WVoEZcMFsJL0QKSrISXoxWk2AmboB0kGCw2Y9sXxZCwqRSgqVVjY3qFdjaLAtgNGllQiAVaGBSKoRokQ9989X+mPVwrOhTGRfjSfcP/rWVw6/B/vQxuH/6vlsH9w//LZfAtwv+6ZWBQOANVJRQvQUVi099nDmqJIvY+r9kIVQTB6f+ZClDB3M3zI6oZ2A2EHaEBmGXR5f9fOgOrobPnR9QDMJq7iv8Hmr9j/q9TC2KXz4+oIvCwWIUmZUfnRqtIYxVWZv+rnPE5RHgSQ/bGKUQU1xUn5GPNtMGXtslYWTsjg0yUmSK8JU5Gidkde+Sg3RTgkDA5jRy8gAbI+lh43ax5Q8RQANUyQ7F5UW2LocOTxgwn5bFhKVjxHDcAg8HhOWujBJA2YLIl9jRQPwGkGRjNqUEacKIu7wz26jTgsRh5qMDTpd3AoMVdXArpyjSgsJDKUE0u/6vgoEXo0ZS56B7RhmVogsomwjLbFTMQO0N1s71gOrKKDP8PpnpDGDQW0BNcZCr7+wK8K8k4jOE+pkrwpkHKcRz3QeUA77FiDmT/L6h6eXDH48YIF4sjHrfDO0jSpQzezRrBG9ZOnr/oDaxVAmCERsYaIbCUjBsaiYp/SxBJev4/VwsocgcAzdDQTNwhQNcMHNtdXSHmOVjzn3JPvNMxJXP/x7k3VJyv04IAljFobU8J8MNMbP+1obcE8DCxbQpTdwngwTDNBaI+mE3EUHiEjjw1UNCnjTJPJbRyfplR9yaX5TgLIFHfOAuER2wMqUTYp2w8Q/qm7lqg4vVL5xNJ+493/GU4ncBNtxmwIA+asytARA/8bD65BnLnAXAwBPK5FSDy04bbuTWg5I/BX3Fn+vjQdQkoKAQBnvkezgFeGU80cq7PXdCzfGIZ6y63wScSmYYng/jvNr1lKU5ka99N0Ie5+JzUdbwN+syWJgHqdh9cXMyoMHS0uO+5fhZ12VLeu+8CP7iy+zKmu7MAhjMCU9ZCiRoF/iuUNbR0hy7oQZVkwdDhadD/mJJgzrdJAYeSQC7pA0UXwd9iSS+Y7tEGPtiCwd54nxQAYArKgLpPCgCYCipa59PQ4tloQRWEDiAerYMZb9MGHVvQGR52vMlO6MEd3g55vFEROFIGPDwseIthyPGhyPLnlXU/EP/F3pkjAQzCMBDGDBXh/8/NpMmQUunslZ/gHPiQljMu+YVevUgvrB5q6y0Ey3QCWjewz3OjTBkgFAJTTcBoKWIIZY2WgGgpItQERKlC8McDjULTgCemmoCRXhjwja3+03qpVkBpBpwAfwL+CfoYdCHkUrjNDm+G8O0wfiCCH4nhh6L4sTh+MYJfjeGXo/j1uAUSeIkMXiSFl8nhhZJ4qSxeLG25PN4wgbfM4E1TeNucjZN46yzePI23zxuggEdo4CEqeIyOQUp4lBYepmacHh6oiEdqGqqKx+riwcpGa+Ph6ni8vi9YwF+xcbN3pzkOwjAUgJ9DFrLQQLn/XUfzZzSbWjBOa5bvBBEimx3pXSErp4/ZuYKWTh+1dYWtnT5u7/SBi1fk5hW6evrY3St4+fTR21f4+unj95EsMdiKF6m88SV8WboV6rwbOmK5YwVPLH5EcyN3bCtbzTxdRWO1I5559XsrldPAEdPEqDTzmAHNDPxRcSoNXCWhiVSIgV23icTWRTQQO2KLYAjE53sI6z3xBXa5ga+MEDQW2sBkdsFxizJDyFyIQaBwG2mb0ENAH2ibCLZAG90GbDTcaKMgUXXkM9MItnESGEAW6jvw+ZjBkKMnBuHOTSQJNtSEVVINliRE4cM3n3E1Y5FcnSEhDpsVkuNdnfHQXJ0nOQUCAskywcUhZfyQ0xBdMCQrQISnJmxn/C2EmzedpSa8XAtul+SalmmXX0CyVTF2tDt/Hy68/UC0nIID0G/Dzr6AHfDp7c0YCVraVOOOVsKfjcrz7QWtWtXZ0y74jP9oPBV/UXj+/V8h9Qr+UNGaekbR/fexqPpAYCOa6xVvBqbHC2S1S2HIeI27ymlg73jg+NPgye9/+Gmw4Pc/8m6wbPU/7jQwPd5hIiUmvMms4nbkZ6xxtA2Ru/kpeLj0nboHWYzHO2yqniJ9tHN3OwiDMBSA1x7KxgQU5P2f1QtvTIxubox1Zt8btOEnJOUsUkC7QOm0yKDmkDtNEqgpqIt1vLRsAZLKbFvH1AQri/B5cbW0Obv7h/WvBm9oQ8bruPimhrs2Yp3Krf/uLqDqICpjHD8JgrrVK4ptmisIUxV8xOqfRtebtSOWbv/nzjpD7kGLoM/6z/x5bkUi6AeIUlSkNNU0huwj0wSOPoejr/qJPhSXxEfLDBgiAzDb6CW58t+Vn04aPQDVw5SJCNPsmgAAAABJRU5ErkJggg==");var D=i(12039),S=i(5135),P=i(65636),I=i(69170);const M={enabled:T,enabledHover:T};class x extends s.Y{constructor(){super(...arguments),this.name="sweep-pucks",this.IDLE_OPACITY=.3,this.EDITING_OPACITY=.9,this.IDLE_COLOR=new n.Color("white"),this.SELECTION_COLOR=new n.Color(16724312),this.defaultCheckRenderModes=()=>!0,this.unselectingSweep=null,this.editingEnabled=!1,this.selectionBindings=[],this.unselectionBindings=[],this.selectionHandled=!0,this.unselectionHandled=!0,this.handlePuckClickedMessage=e=>{if(!e)throw new Error("SweepPucks -> on PuckClickedMessage: Tried to move to invalid sweep id.");this.canSelectPuck()||this.sweepViewData.data.canTransition()&&this.cameraData.canTransition()&&this.engine.commandBinder.issueCommand(new D.ju({transition:P.y4[this.interactionmodeData.mode],sweep:e}))},this.handleSweepSelectionChange=()=>{this.updateHighlightOnSelectedPuck(!1),this.selectedSweep=this.sweepViewData.selectedSweep,this.updateHighlightOnSelectedPuck(!0),this.updateHandlers()},this.updateViewmode=()=>{this.viewmode=this.viewmodeData.currentMode,this.updateHighlightOnSelectedPuck(this.editingEnabled),this.updateHandlers()},this.updateHandlers=()=>{this.selectionHandled=this.toggleHandlers(this.canSelectPuck(),this.selectionBindings,this.selectionHandled),this.unselectionHandled=this.toggleHandlers(this.canUnselectPuck(),this.unselectionBindings,this.unselectionHandled)},this.unselectPuck=()=>{this.unselectingSweep=null,this.sweepViewData.setSelectedSweep(null)},this.onUnselectPuck=e=>{const t=this.sweepViewData.selectedSweep;return t&&(e.down?this.unselectingSweep=t:this.unselectingSweep&&this.unselectPuck()),!0},this.onPointerOnPuck=(e,t)=>{if(e.button!==p.M.PRIMARY)return;const i=this.renderer.getSweepId(t.id);i&&(e.down?i===this.selectedSweep?this.unselectingSweep=i:(this.unselectingSweep=null,this.sweepViewData.setSelectedSweep(i)):(i===this.unselectingSweep&&this.unselectPuck(),this.unselectingSweep=null))}}async init(e,t){this.engine=t,void 0!==e.checkRenderModes&&(this.defaultCheckRenderModes=e.checkRenderModes);const i=(await t.getModuleBySymbol(I.y.WEBGL_RENDERER)).getScene(),s=await t.getModuleBySymbol(I.y.INPUT),[n,l,u,p,b]=await Promise.all([t.market.waitForData(w.e),t.market.waitForData(y.M),t.market.waitForData(f.D),t.market.waitForData(v.O),t.market.waitForData(S.Z)]);this.viewmodeData=p,this.viewmode=p.currentMode,this.sweepViewData=u,this.cameraData=l,this.interactionmodeData=b;this.renderer=new h.C$(i.scene,s,n,u,M,!0,this.defaultCheckRenderModes,this.IDLE_COLOR,this.SELECTION_COLOR,this.IDLE_OPACITY,this.EDITING_OPACITY,void 0,void 0,t.claimRenderLayer(this.name)),t.addComponent(this,this.renderer),this.bindings.push(t.commandBinder.addBinding(c,(async e=>this.togglePuckEditing(e.enabled))),t.subscribe(d.Z,(e=>this.handlePuckClickedMessage(e.sweepId)))),this.selectionBindings.push(s.registerMeshHandler(g.er,o.s.isType(h.YY),this.onPointerOnPuck),s.registerHandler(g.mE,(()=>{this.unselectingSweep=null}))),this.selectionHandled=this.toggleHandlers(!1,this.selectionBindings,this.selectionHandled),this.selectionSub=this.sweepViewData.onSelectedSweepChanged(this.handleSweepSelectionChange),this.selectionSub.cancel(),this.unselectionBindings.push(s.registerPriorityHandler(m.R,a.S,(()=>!0)),s.registerPriorityHandler(g.er,a.S,this.onUnselectPuck),s.registerPriorityHandler(g.er,r.i,this.onUnselectPuck)),this.unselectionHandled=this.toggleHandlers(!1,this.unselectionBindings,this.unselectionHandled)}dispose(e){for(const e of this.bindings)e.cancel();this.bindings=[],this.togglePuckEditing(!1),super.dispose(e)}updatePuckImagery(e={}){const t=Object.assign(Object.assign({},M),e);t.disabled&&!t.disabledHover&&(t.disabledHover=t.disabled),this.renderer.updatePuckImagery(t)}updateCheckRenderModes(e){this.renderer.updateCheckRenderModes(e||this.defaultCheckRenderModes)}updateHighlightOnSelectedPuck(e){const t=this.selectedSweep;if(t){if(!this.sweepViewData.isSweepAligned(t))return;const i=this.viewmode===b.Ey.Dollhouse||this.viewmode===b.Ey.Floorplan;this.renderer.renderPuckHighlight(t,this.editingEnabled&&i&&e)}}togglePuckEditing(e){this.editingEnabled=e,this.selectedSweep=this.sweepViewData.selectedSweep,this.updateViewmode(),this.renderer.toggleEditingEnabled(e),e?(this.engine.subscribe(u.Z,this.updateViewmode),this.selectionSub.renew()):(this.engine.unsubscribe(u.Z,this.updateViewmode),this.selectionSub.cancel())}canUnselectPuck(){const e=this.viewmode===b.Ey.Dollhouse||this.viewmode===b.Ey.Floorplan;return this.editingEnabled&&!!this.selectedSweep&&e}canSelectPuck(){const e=this.viewmode===b.Ey.Dollhouse||this.viewmode===b.Ey.Floorplan;return this.editingEnabled&&e}toggleHandlers(e,t,i){if(e!==i)for(const i of t)e?i.renew():i.cancel();return e}}},95806:(e,t,i)=>{"use strict";i.r(t),i.d(t,{FAST_FORWARD_FACTOR:()=>re,default:()=>ae});var s=i(26256),n=i(14439),o=i(97542),r=i(95882),a=i(60699),h=i(2473),d=i(65397),l=i(23254),c=i(64918),u=i(96154),p=i(67678),g=i(12250),m=i(89553),w=i(6667),y=i(54244),f=i(10374),v=i(34029),b=i(9037),T=i(69505),D=i(2569),S=i(14715),P=i(59625),I=i(96042),M=i(17686);class x{constructor(e=-1){this.active=!1,this.type=M.Aq.Nop,this.promise=Promise.resolve(),this.stop=()=>Promise.resolve(),this.duration=0,this.started=-1,this.stopped=-1,this.toIndex=e}}var R=i(39880);class E{constructor(e){this.type=M.Aq.Delay,this.toIndex=-1,this.started=-1,this.stopped=-1,this.duration=0,this.currentTransitionPromise=null,this.cancelDelay=()=>null,this.duration=e}get active(){return null!==this.currentTransitionPromise}get promise(){return this.currentTransitionPromise?this.currentTransitionPromise:Promise.resolve()}async stop(){this.currentTransitionPromise&&(this.cancelDelay(),this.currentTransitionPromise=null,this.stopped=Date.now())}start(e,t){if(this.active)throw Error("Transition already active");void 0!==e.duration&&(this.duration=e.duration);const i=(0,R.Ig)(this.duration);return this.cancelDelay=()=>{i.cancel()},this.currentTransitionPromise=i.promise.then((()=>this.stop())),this.toIndex=t,this.started=Date.now(),this.stopped=-1,this}}class C{constructor(e,t,i){this.zoom=e,this.stopZooming=t,this.type=M.Aq.Zoom,this.toIndex=-1,this.started=-1,this.stopped=-1,this.duration=0,this.currentTransitionPromise=null,this.onStopRequested=()=>Promise.resolve(),this.duration=i}get active(){return null!==this.currentTransitionPromise}get promise(){return this.currentTransitionPromise?this.currentTransitionPromise:Promise.resolve()}async stop(){this.currentTransitionPromise&&(await this.onStopRequested(),await this.promise,this.currentTransitionPromise=null,this.stopped=Date.now())}start(e,t){if(this.active)throw Error("Transition already active");return void 0!==e.duration&&(this.duration=e.duration),this.currentTransitionPromise=this.zoom(this.duration,-5e-4).then((()=>{this.currentTransitionPromise=null,this.stopped=Date.now()})),this.toIndex=t,this.started=Date.now(),this.stopped=-1,this.onStopRequested=async()=>{await this.stopZooming()},this}}var A=i(81396),L=i(90304),O=i(21646);class F{constructor(e,t,i){this.settingsData=e,this.rotate=t,this.stopRotating=i,this.type=M.Aq.Burns,this.toIndex=-1,this.started=-1,this.stopped=-1,this.duration=0,this.currentTransitionPromise=null,this.onStopRequested=()=>Promise.resolve(),this.getPanDirection=(e,t)=>{let i=M.kw.Right;if(e&&e.metadata.scanId&&e.metadata.cameraQuaternion&&e.metadata.cameraPosition&&t&&t.metadata.scanId&&t.metadata.cameraPosition&&t.metadata.cameraQuaternion){const s=L.f.FORWARD.clone().applyQuaternion(e.metadata.cameraQuaternion),n=t.metadata.cameraPosition,o=e.metadata.cameraPosition;let r=n.clone().sub(o).normalize();r.lengthSq()<O.Z.epsilon&&(r=L.f.FORWARD.clone().applyQuaternion(t.metadata.cameraQuaternion)),s.cross(r).y>0&&(i=M.kw.Left)}return i}}get active(){return null!==this.currentTransitionPromise}get promise(){return this.currentTransitionPromise?this.currentTransitionPromise:Promise.resolve()}async stop(){this.currentTransitionPromise&&(await this.onStopRequested(),await this.promise,this.currentTransitionPromise=null,this.stopped=Date.now())}start(e,t,i){if(this.active)throw Error("Transition already active");if(!e)throw Error("Tour pan requires two snapshots");if(!e.snapshot||!e.nextSnapshot)return this.currentTransitionPromise=Promise.resolve(),this.toIndex=t,this.started=Date.now(),this.stopped=Date.now(),this;const{deferred:s}=this.build(e.snapshot,e.nextSnapshot,e.panOverrides,i);return this.currentTransitionPromise=s.then((()=>{this.currentTransitionPromise=null,this.stopped=Date.now()})),this.toIndex=t,this.started=Date.now(),this.stopped=-1,this}build(e,t,i,s){const{panDirection:n,panAngle:o}=i,r=ee.getPanValues(this.settingsData,!1,n,o);let a=r.direction;void 0!==a&&a!==M.kw.Auto||(a=this.getPanDirection(e,t)),this.onStopRequested=async()=>{await this.stopRotating()},this.duration=void 0!==s?s:r.ms;return{deferred:this.rotate(this.duration,new A.Vector2(a*r.radiansPerMs,0))}}}var k=i(23885),N=i(46950);const B=.001,G=(e,t,i,s)=>{const n=Math.max(.75,Math.min(e.distanceTo(t),5)),o=n*(1/s)*1e3;let r=o;const a=i/o;if(a>B){r+=r*((a-B)/B)}const h=Math.abs(e.clone().setX(0).setZ(0).distanceTo(t.clone().setX(0).setZ(0))/Math.max(n,1));if(h>.1){r*=.9+.75*h}return r};class z{constructor(e,t,i,s,n,o){this.settingsData=e,this.cameraPose=t,this.moveToSweep=i,this.updateTransitionSpeed=s,this.setRestrictedSweeps=n,this.generators=o,this.toIndex=-1,this.started=-1,this.stopped=-1,this.duration=0,this.currentGenerator=null,this.currentTransitionPromise=null,this.type=M.Aq.Move}get active(){return null!==this.currentTransitionPromise||null!==this.currentGenerator}get promise(){return this.currentTransitionPromise?this.currentTransitionPromise:Promise.resolve()}async stop(){this.currentTransitionPromise&&(await this.onStopRequested(),await this.promise,this.currentTransitionPromise=null,this.stopped=Date.now()),this.currentGenerator&&(this.generators.stopGenerator(this.currentGenerator),this.currentGenerator=null)}start(e,t){if(this.active)throw Error("Transition already active");const{generator:i,deferred:s}=this.build(e.path,e.orientations);return this.generators.startGenerator(i),this.currentGenerator=i,this.currentTransitionPromise=s.nativePromise(),this.toIndex=t,this.started=Date.now(),this.stopped=-1,this}build(e,t){const i=new N.Q,n=this;let o=!1;return this.onStopRequested=async()=>{o=!0,await this.updateTransitionSpeed(re)},{generator:function*(){let r=1;for(;r<e.length&&!o;){const i=r-1,o=e[r],a=o.position,h=e[i],d=t[r],l=(0,D.zW)(n.cameraPose.rotation,d),u=ee.getTransitionSpeed(n.settingsData),p=G(h.position,a,l,u),g={transitionType:c.n.Interpolate,sweepId:o.id,rotation:d,transitionTime:p,easing:k.vG};n.duration=p,n.setRestrictedSweeps(e,i);const m=n.moveToSweep(g);yield new s.M8(m.nativePromise()),r++}n.setRestrictedSweeps(null),i.resolve(),n.currentTransitionPromise=null,n.stop()},deferred:i}}}var V=i(79727);const U=new(i(97998).Z)("tours");class Q{constructor(e,t,i,n,o,r,a,h,d){this.settingsData=e,this.cameraPose=t,this.cameraTransition=i,this.sweepTransition=n,this.sweepControl=o,this.cameraControl=r,this.generators=a,this.setRestrictedSweeps=h,this.getCurve=d,this.type=M.Aq.Path,this.toIndex=-1,this.started=-1,this.stopped=-1,this.duration=0,this.currentTransitionGenerator=null,this.currentTransitionPromise=null,this.canceling=!1,this.buildTransition=(e,t)=>{if(e.length<=2)throw U.debug(`invalid path: ${e}`),new Error("smooth path requires more than 2 stops");const i=this,n=new N.Q;i.setRestrictedSweeps(e);const o=e.map((e=>e.position)),r=i.getCurve(o),a=k.vG,h=k.Fs,d=k.to,l=ee.getTransitionSpeed(i.settingsData);this.duration=((e,t,i)=>{let s=0;for(let n=0;n<e.length-1;n++){const o=(0,D.zW)(t[n],t[n+1]);s+=G(e[n].position,e[n+1].position,o,i)}return s})(e,t,l),U.debug(`path duration: ${this.duration.toFixed(0)}ms, at speed: ${l}m/s`),i.cameraControl.beginExternalTransition();return{generator:function*(){n.notify(0);const o=new A.Vector3,u=new A.Quaternion;let p=0,g=0,m=0,w=1,y=e[w].id;yield new s.M8(i.sweepControl.activateSweepUnsafe({sweepId:y}).then((()=>{i.sweepControl.beginSweepTransition({sweepId:y,transitionTime:i.duration,internalProgress:!1})}))),e.length>2&&i.sweepControl.activateSweepUnsafe({sweepId:e[2].id});let f=i.cameraPose.rotation.clone();for(;p<i.duration&&!i.canceling;){const l=p/i.duration;m>0&&(f=t[m].clone());const c=t[w],v=r.normalSourceDistances[m],b=r.normalSourceDistances[w],T=e[w];if(g=(0,D.et)(l,v,b,0,1),g<=1){const e=d(g,0,1,1);i.sweepTransition.progress.modifyAnimation(e,1,0);const t=h(g,0,1,1);u.copy(f).slerp(c,t)}l<1&&o.copy(r.curve.getPointAt(a(l,0,1,1))),i.cameraControl.updateCameraPosition(o),i.cameraControl.updateCameraRotation(u),l>=b&&(i.sweepControl.endSweepTransition({sweepId:T.id}),m++,w++,y=e[m+1].id,yield new s.M8(i.sweepControl.activateSweepUnsafe({sweepId:y}).then((()=>{i.sweepControl.beginSweepTransition({sweepId:y,transitionTime:i.duration,internalProgress:!1})}))),e.length>m+2&&i.sweepControl.activateSweepUnsafe({sweepId:e[m+2].id})),n.notify(l),p=Date.now()-i.cameraTransition.startTime,yield new s.Jj}if(i.cameraControl.endExternalTransition(),i.canceling){i.canceling=!1;const t=e[w].position,n=G(i.cameraPose.position,t,0,l),o=i.cameraControl.moveTo({transitionTime:n/re,transitionType:c.n.Interpolate,pose:{position:t}});o.progress((e=>{const t=(0,D.et)(e,0,1,g,1);i.sweepTransition.progress.modifyAnimation(t,1,0)})),yield new s.M8(o.nativePromise())}i.sweepControl.endSweepTransition({sweepId:y}),i.setRestrictedSweeps(null),n.notify(1),n.resolve()},deferred:n}}}get active(){return null!==this.currentTransitionPromise||null!==this.currentTransitionGenerator}get promise(){return this.currentTransitionPromise?this.currentTransitionPromise:Promise.resolve()}async stop(){this.canceling=!0,this.currentTransitionPromise&&(await this.promise,this.currentTransitionPromise=null,this.stopped=Date.now()),this.currentTransitionGenerator&&(this.generators.stopGenerator(this.currentTransitionGenerator),this.currentTransitionGenerator=null)}start(e,t){if(U.debug(`starting smooth transition with ${e.path.length-1} stops`),this.active)throw Error("Transition already active");this.canceling=!1;const{generator:i,deferred:s}=this.buildTransition(e.path,e.orientations);return this.generators.startGenerator(i),this.currentTransitionGenerator=i,this.currentTransitionPromise=s.nativePromise().then((()=>{this.currentTransitionPromise=null,this.currentTransitionGenerator=null,this.stopped=Date.now()})),this.toIndex=t,this.started=Date.now(),this.stopped=-1,this}}var _=i(53954);class H{constructor(e,t,i,s,n,o,r,a){this.settingsData=e,this.cameraPose=t,this.viewmodeData=i,this.cameraControl=s,this.sweepControl=n,this.switchToMode=o,this.setRestrictedSweeps=r,this.generators=a,this.toIndex=-1,this.started=-1,this.stopped=-1,this.duration=0,this.type=M.Aq.Move,this.currentTransitionPromise=null,this.onStopRequested=()=>Promise.resolve()}get active(){return null!==this.currentTransitionPromise}get promise(){return this.currentTransitionPromise?this.currentTransitionPromise:Promise.resolve()}async stop(){this.currentTransitionPromise&&(await this.onStopRequested(),await this.promise,this.currentTransitionPromise=null,this.stopped=Date.now())}start(e,t){if(this.active)throw Error("Transition already active");if(!e.snapshot)return this.currentTransitionPromise=Promise.resolve(),this;const{deferred:i}=this.build(e.snapshot,e.currentSweep,e.transitionType);return this.currentTransitionPromise=i.then((()=>{this.currentTransitionPromise=null,this.stopped=Date.now()})),this.toIndex=t,this.started=Date.now(),this.stopped=-1,this}build(e,t,i){let s=Promise.resolve();const n=e.metadata.cameraMode,o=e.metadata.cameraQuaternion,r=e.metadata.scanId,a=this.cameraPose.rotation,h=(0,D.zW)(a,o),d=e.metadata.cameraPosition,l=!e.is360,c={position:d,rotation:o,sweepID:r,zoom:e.metadata.orthoZoom};let u=ee.getOtherModeTransitionTime(this.settingsData,h,i);if(n!==this.viewmodeData.currentMode)s=this.switchToMode(n,i,c,u);else{if(!!r&&this.viewmodeData.isInside()){!t||r!==t?(u=ee.getTransitionTime(this.settingsData),s=this.standardTransitionSweepMovePromise(c,r,l,u)):(u=ee.getSamePanoTransitionTime(this.settingsData,h),s=this.standardTransitionSameSweepRotationPromise(c,h,u))}else s=this.cameraControl.moveTo({transitionType:i,pose:c,transitionTime:u}).nativePromise()}return this.duration=void 0!==u?u:0,{deferred:s}}standardTransitionSameSweepRotationPromise(e,t,i){if(!e.rotation)throw Error("Rotation transition requires a rotation");return t<.01?Promise.resolve():(this.setRestrictedSweeps(null),this.cameraControl.moveTo({transitionType:c.n.Interpolate,pose:{rotation:e.rotation},transitionTime:i}).nativePromise())}standardTransitionSweepMovePromise(e,t,i,n){if(!e.position)throw Error("Push transition requires a position");const o=e.position.clone().sub(this.cameraPose.position).normalize(),r=this.cameraPose.position.clone().add(o.multiplyScalar(.15)),a=new N.Q;this.setRestrictedSweeps(null);const h=this;return this.generators.startGenerator((function*(){yield new s.M8(h.sweepControl.activateSweepUnsafe({sweepId:t}));const o=new A.Vector3,d=h.cameraPose.position.clone(),l=Date.now();let u,p=0,g=!1,m=!1;for(;p<n;){const a=(0,k.FG)(p,0,p/n,n);i&&h.cameraControl.updateCameraPosition(o.copy(d).lerp(r,a)),a>=.3&&!m&&(u=h.cameraControl.moveTo({transitionType:c.n.FadeToBlack,pose:e,transitionTime:n,blackoutTime:.5*n}).progress((e=>{e>=.5&&!g&&(h.sweepControl.instantSweepTransition(t),g=!0)})),m=!0),yield new s.Jj,p=Date.now()-l}u&&(yield new s.M8(u.nativePromise())),a.resolve()})),a.nativePromise()}}class j{constructor(e,t,i,s){this.moveToSweep=e,this.viewmodeData=t,this.cameraControl=i,this.switchToMode=s,this.toIndex=-1,this.started=-1,this.stopped=-1,this.duration=0,this.type=M.Aq.Move,this.currentTransitionPromise=null,this.onStopRequested=()=>Promise.resolve()}get active(){return null!==this.currentTransitionPromise}get promise(){return this.currentTransitionPromise?this.currentTransitionPromise:Promise.resolve()}async stop(){this.currentTransitionPromise&&(await this.onStopRequested(),await this.promise,this.currentTransitionPromise=null,this.stopped=Date.now())}start(e,t){if(this.active)throw Error("Transition already active");if(!e.snapshot)return this.currentTransitionPromise=Promise.resolve(),this.started=Date.now(),this.stopped=Date.now(),this;const{deferred:i}=this.build(e.snapshot,e.currentSweep);return this.currentTransitionPromise=i.then((()=>{this.currentTransitionPromise=null,this.stopped=Date.now()})),this.toIndex=t,this.started=Date.now(),this.stopped=-1,this}build(e,t){let i=Promise.resolve();const s=e.metadata.cameraMode,n=e.metadata.cameraQuaternion,o=e.metadata.scanId,r={position:e.metadata.cameraPosition,rotation:n,sweepID:o,zoom:e.metadata.orthoZoom},a=s!==this.viewmodeData.currentMode,h=!!o&&this.viewmodeData.isInside();if(a)i=this.switchToMode(s,c.n.Instant,r);else if(h){const e={transitionType:c.n.Instant,sweepId:o,rotation:n};i=this.moveToSweep(e).nativePromise()}else i=this.cameraControl.moveTo({transitionType:c.n.Instant,pose:r}).nativePromise();return{deferred:i}}}var Z=i(52498),W=i(33324);class q{constructor(e,t){this.issueCommand=e,this.currentFloorId=t,this.type=M.Aq.FloorChange,this.toIndex=-1,this.started=-1,this.stopped=-1,this.duration=Z.cw,this.currentTransitionPromise=null,this.onStopRequested=()=>Promise.resolve()}get active(){return null!==this.currentTransitionPromise}get promise(){return this.currentTransitionPromise?this.currentTransitionPromise:Promise.resolve()}async stop(){this.currentTransitionPromise&&(await this.onStopRequested(),await this.promise,this.currentTransitionPromise=null,this.stopped=Date.now())}start(e,t){if(this.active)throw Error("Transition already active");let i=Promise.resolve();const s=e.targetSnapshot.metadata.floorId,n=s!==this.currentFloorId(),o=e.targetSnapshot.metadata.cameraMode;return!(0,r.Bw)(o)&&o!==r.Ey.Outdoor&&n&&(i=this.issueCommand(new W.Vw(s,!0,this.duration))),this.currentTransitionPromise=i.then((()=>{this.currentTransitionPromise=null,this.stopped=Date.now()})),this.toIndex=t,this.started=Date.now(),this.stopped=-1,this}}class Y{constructor(e,t,i){this.settingsData=e,this.rotate=t,this.stopRotating=i,this.type=M.Aq.Burns,this.toIndex=-1,this.started=-1,this.stopped=-1,this.duration=0,this.currentTransitionPromise=null,this.onStopRequested=()=>Promise.resolve()}get active(){return null!==this.currentTransitionPromise}get promise(){return this.currentTransitionPromise?this.currentTransitionPromise:Promise.resolve()}async stop(){this.currentTransitionPromise&&(await this.onStopRequested(),await this.promise,this.currentTransitionPromise=null,this.stopped=Date.now())}start(e,t,i){if(this.active)throw Error("Transition already active");if(!e.snapshot||!e.nextSnapshot)return this.currentTransitionPromise=Promise.resolve(),this;const{deferred:s}=this.build(e.snapshot,e.nextSnapshot,e.panOverrides,i);return this.currentTransitionPromise=s.then((()=>{this.currentTransitionPromise=null,this.stopped=Date.now()})),this.toIndex=t,this.started=Date.now(),this.stopped=-1,this}build(e,t,i,s){const{panDirection:n,panAngle:o}=i,r=ee.getPanValues(this.settingsData,!0,n,o);let a=-1*r.radiansPerMs;this.duration=void 0!==s?s:r.ms;const h=r.direction;if(void 0!==h&&h!==M.kw.Auto)a*=h;else if(e&&e.metadata.cameraQuaternion&&t&&t.metadata.cameraQuaternion){const i=L.f.FORWARD.clone().applyQuaternion(e.metadata.cameraQuaternion),s=L.f.FORWARD.clone().applyQuaternion(t.metadata.cameraQuaternion),n=Math.sign(i.cross(s).y);a=0!==n?a*n:a}this.onStopRequested=async()=>{await this.stopRotating()};return{deferred:this.rotate(this.duration,new A.Vector2(a,0))}}}class X{constructor(e,t,i,s,n){this.settingsData=e,this.cameraPose=t,this.rotate=i,this.stopRotating=s,this.getCurve=n,this.type=M.Aq.Burns,this.toIndex=-1,this.started=-1,this.stopped=-1,this.duration=0,this.currentTransitionPromise=null,this.onStopRequested=()=>Promise.resolve()}get active(){return null!==this.currentTransitionPromise}get promise(){return this.currentTransitionPromise?this.currentTransitionPromise:Promise.resolve()}async stop(){this.currentTransitionPromise&&(await this.onStopRequested(),await this.promise,this.currentTransitionPromise=null,this.stopped=Date.now())}start(e,t,i){if(this.active)throw Error("Transition already active");const{deferred:s}=this.build(e.path,e.snapshot,e.nextSnapshot,e.panOverrides,i);return this.currentTransitionPromise=s.then((()=>{this.currentTransitionPromise=null,this.stopped=Date.now()})),this.toIndex=t,this.started=Date.now(),this.stopped=-1,this}build(e,t,i,s,n){this.onStopRequested=async()=>{await this.stopRotating()};const{panDirection:o,panAngle:a}=s,h=ee.getPanValues(this.settingsData,!1,o,a),d=h.direction;let l=h.radiansPerMs;if(void 0!==d&&d!==M.kw.Auto)l*=d;else if(e){const t=this.cameraPose.position.clone().setY(0),i=e.map((e=>e.position)),s=this.getCurve(i).curve.getPointAt(.1).setY(0).clone().sub(t).normalize(),n=L.f.FORWARD.clone().applyQuaternion(this.cameraPose.rotation),o=Math.sign(n.cross(s).y);l=0!==o?l*o:l}else if(i&&t){if(!(0,r.Bw)(t.metadata.cameraMode)&&(l=-l),t.metadata.scanId===i.metadata.scanId){const e=L.f.FORWARD.clone().applyQuaternion(this.cameraPose.rotation),t=L.f.FORWARD.clone().applyQuaternion(i.metadata.cameraQuaternion),s=Math.sign(e.cross(t).y);l=0!==s?l*s:l}}this.duration=void 0!==n?n:h.ms;return{deferred:this.rotate(this.duration,new A.Vector2(l,0))}}}const $={sharpTurnDotThreshold:.65,directionWeightFactorStd:.75,directionWeightFactorSharp:.2,positionalWeightFactorStd:.4,positionalWeightFactorSharp:.2,finalWalkingNodeDirectionWeight:5,lookAheadNodes:3};class K{constructor(e=$){this.settings=e}getOrientationsForPath(e,t){const i=[];for(let s=0;s<e.length;s++){const n=new A.Vector3;this.getLookVectorsForPathNode(e,s,t,n);const o=(new A.Matrix4).lookAt(e[s],n,L.f.UP);i[s]=(new A.Quaternion).setFromRotationMatrix(o)}return i.push(t),i}getLookVectorsForPathNode(e,t,i,s){const n=new A.Vector3,o=new A.Vector3,r=new A.Vector3,a=new A.Vector3,h=e.length;if(t>=h)return!1;let d=1,l=1;const c=new A.Vector3;let u;for(let s=t;s<t+this.settings.lookAheadNodes&&s<h;s++){if(u=e[s],this.getOrientationForPathNode(e,s,i,r),s===t&&n.copy(r),s>t){const e=n.dot(r)<this.settings.sharpTurnDotThreshold;d*=e?this.settings.directionWeightFactorSharp:this.settings.directionWeightFactorStd,l*=e?this.settings.positionalWeightFactorSharp:this.settings.positionalWeightFactorStd}s===h-1&&(d=this.settings.finalWalkingNodeDirectionWeight,l=1),c.copy(r),r.multiplyScalar(d),o.add(r),a.lerp(u,l)}return o.normalize(),s.copy(a),s.add(o),!0}getOrientationForPathNode(e,t,i,s){if(t>=e.length)return!1;if(t===e.length-1)s.copy(L.f.FORWARD).applyQuaternion(i);else{const i=e[t],n=e[t+1];s.copy(n).sub(i)}return s.normalize(),!0}}var J=i(69170);class ee{constructor(e,t,i,s,o){this.engine=e,this.tourData=t,this.cameraData=i,this.settingsData=s,this.viewmodeData=o,this.init=async()=>{this.sweepModule=await this.engine.getModuleBySymbol(J.y.SWEEP_DATA),this.sweepData=await this.engine.market.waitForData(_.Z),this.cameraModule=await this.engine.getModuleBySymbol(J.y.CAMERA),this.pathModule=await this.engine.getModuleBySymbol(J.y.SWEEP_PATH),this.floorsViewData=await this.engine.market.waitForData(V.c),this.commonControlsModule=await this.engine.getModuleBySymbol(J.y.CONTROLS_COMMON),this.viewmodeModule=await this.engine.getModuleBySymbol(J.y.VIEWMODE),this.pathOrientHelper=new K,this.setRestrictedSweeps=this.pathModule.setRestrictedSweeps.bind(this.pathModule),this.getCurveForPath=this.pathModule.getCurveForPath.bind(this.pathModule),this.moveToSweep=this.sweepModule.moveToSweep.bind(this.sweepModule),this.updateTransitionSpeed=this.cameraModule.updateTransitionSpeed.bind(this.cameraModule),this.switchToMode=this.viewmodeModule.switchToMode.bind(this.viewmodeModule),this.startRotateTransition=this.commonControlsModule.startRotateTransition.bind(this.commonControlsModule),this.stopCamera=this.commonControlsModule.stop.bind(this.commonControlsModule),this.startZoomTransition=this.commonControlsModule.startZoomTransition.bind(this.commonControlsModule),this.issueCommand=this.engine.commandBinder.issueCommand.bind(this.engine.commandBinder)},this.getValidWalkingPath=e=>{const t=e.metadata.scanId,i=this.sweepData.currentSweep,s=this.tourData.getTourCurrentSnapshotIndex();let o=null;if(s>=0){const e=this.tourData.getTourSnapshotSid(s);o=this.tourData.getSnapshot(e)}if(this.viewmodeData.currentMode!==r.Ey.Panorama||!i||!t||t===i||e.is360||!o||o.is360)return null;const a=this.pathModule.findShortestPath(i,t,n.Xd.walkingTourIncludeExtraPanosDistance,n.Xd.walkingStageMinimumDistance,n.Xd.maxWalkingSweepsBetweenSnapshots)||[];return 0===a.length?null:a}}static isDelayTransition(e,t,i){return!(0,n.dF)(e)||t!==M.BZ.Zoom&&0===ee.getPanDegrees(e,i.panAngle)}static getTourBurnsStyle(e,t,i){return ee.isDelayTransition(e,t,i)?M.BZ.Delay:t}static getPanDegrees(e,t){let i;return i=(0,n.dF)(e)?-1!==e.getOverrideParam(n.xs,-1)?(0,n.y)(e):void 0!==t?t:e.tryGetProperty(P.gx.PanAngle,n.BA):0,Math.max(i,0)}static getPanDirection(e,t){return void 0!==t?t:e.tryGetProperty(P.gx.PanDirection,S.y6)}static getDelayDuration(e){return-1!==e.getOverrideParam(n.lY,-1)||0===e.getOverrideParam(n._c,-1)?(0,n.g_)(e):n.mS}static getZoomDuration(e){return-1!==e.getOverrideParam(n.lY,-1)?(0,n.g_)(e):e.tryGetProperty(P.gx.ZoomDuration,n.i7)}static getPanRadiansPerMs(e,t,i){if(-1!==e.getOverrideParam(n.lY,-1)){const t=(0,n.g_)(e);return t>0?i/t:0}const s=t?e.tryGetProperty(P.gx.DollhousePanSpeed,n.su):e.tryGetProperty(P.gx.PanSpeed,n.pn);return(0,I.DA)(s)}static getPanValues(e,t,i,s){const o=ee.getPanDirection(e,i),r=ee.getPanDegrees(e,s),a=(0,T.Id)(r),h=ee.getPanRadiansPerMs(e,t,a);let d=h>0?a/h:0;return t&&void 0===s&&(d=(0,n.g_)(e)),{degrees:r,radiansPerMs:h,ms:d,direction:o}}static getTransitionSpeed(e){if(-1!==e.getOverrideParam("wts",-1))return e.tryGetProperty(n.EU,n.Im);const t=e.tryGetProperty(P.gx.TransitionSpeed,n.Mk);return(0,I.mf)(t/1e3)}static getTransitionTime(e){const t=e.tryGetProperty(P.gx.TransitionTime,n.mL);return Math.min(Math.max(n.eu,t),n.NY)}static getOtherModeTransitionTime(e,t,i){if(i===c.n.FadeToBlack){return ee.getTransitionTime(e)+n.HJ}let s=n.Cp,o=n.f7;if(-1===e.getOverrideParam("wts",-1)){const t=1e3*ee.getTransitionSpeed(e);s=Math.sqrt(2*(t-n.Pv))+45,t!==n.Mk&&(o=n._D)}const r=1e3*t/(T.Ue*s);return Math.max(r,o)}static getSamePanoTransitionTime(e,t){const i=e.tryGetProperty(P.gx.PanSpeed,n.pn);if(i===n.pn)return Math.max(1e3*t/(T.Ue*n.O2),n.gS);{const e=(0,D.dS)(i,n.z$,n.b_,n.rM,n.z8),s=(0,I.DA)(e);return s>0?t/s:0}}getFloorTransition(e){const t=this.tourData.getTourSnapshotSid(e),i=this.tourData.getSnapshot(t);if(!i){return new x(e)}return new q(this.issueCommand,(()=>this.floorsViewData.currentFloorId)).start({targetSnapshot:i},e)}getMainTransition(e,t){const i=this.tourData.getTourSnapshotSid(e),s=this.tourData.getSnapshot(i);if(!s){return new x(e)}let n=null;if(t===c.n.Interpolate){const t=s.metadata.cameraQuaternion,i=this.getValidWalkingPath(s);if(i){const s=i.map((e=>e.position)),o=this.pathOrientHelper.getOrientationsForPath(s,(0,D.Z)(t));n=i.length>2?new Q(this.settingsData,this.cameraData.pose,this.cameraData.transition,this.sweepData.transition,this.sweepModule,this.cameraModule,this.engine,this.setRestrictedSweeps,this.getCurveForPath).start({path:i,orientations:o},e):new z(this.settingsData,this.cameraData.pose,this.moveToSweep,this.updateTransitionSpeed,this.setRestrictedSweeps,this.engine).start({path:i,orientations:o},e)}}else if(t===c.n.Instant){const t=this.sweepData.currentSweep;n=new j(this.moveToSweep,this.viewmodeData,this.cameraModule,this.switchToMode).start({snapshot:s,currentSweep:t},e)}if(!n){const i=this.sweepData.currentSweep;n=new H(this.settingsData,this.cameraData.pose,this.viewmodeData,this.cameraModule,this.sweepModule,this.switchToMode,this.setRestrictedSweeps,this.engine).start({snapshot:s,currentSweep:i,transitionType:t},e)}return n}getBurnsTransition(e,t,i){const s=this.tourData.getTourSnapshotSid(e),n=(e+1)%this.tourData.getSnapshotCount(),o=this.tourData.getTourSnapshotSid(n),r=this.tourData.getTourStop(s),a={};r.reelEntry&&r.reelEntry.overrides&&(a.panDirection=r.reelEntry.overrides.panDirection,a.panAngle=r.reelEntry.overrides.panAngle);const h=this.tourData.getSnapshot(o);let d=new x(e);switch(t){case M.BZ.Pan:if(h){const t=this.getValidWalkingPath(h);d=new X(this.settingsData,this.cameraData.pose,this.startRotateTransition,this.stopCamera,this.getCurveForPath).start({path:t,snapshot:r.snapshot,nextSnapshot:h,panOverrides:a},e,i)}d.type===M.Aq.Nop&&(d=new F(this.settingsData,this.startRotateTransition,this.stopCamera).start({snapshot:r.snapshot,nextSnapshot:h,panOverrides:a},e,i));break;case M.BZ.PanDollhouse:d=new Y(this.settingsData,this.startRotateTransition,this.stopCamera).start({snapshot:r.snapshot,nextSnapshot:h,panOverrides:a},e,i);break;case M.BZ.Zoom:d=new C(this.startZoomTransition,this.stopCamera,ee.getZoomDuration(this.settingsData)).start({duration:i},e);break;case M.BZ.Delay:const t=ee.getDelayDuration(this.settingsData);d=new E(t).start({duration:i},e);break;case M.BZ.None:d=new x(e);break;default:throw Error("unhandled TourBurnsStyle")}return d}}var te=i(71239),ie=i(96767),se=i(33397),ne=i(97478),oe=i(80742);const re=5;class ae extends o.Y{constructor(){super(...arguments),this.name="tours-controls",this.getBurnsStyleForSnapshot=(e,t)=>{const i=this.data,s=i.getTourSnapshotSid(e),n=i.getTourStop(s),o=i.getSnapshotCount();if(!n||!n.snapshot)return M.BZ.None;if(e===o-1&&this.isLastStopStatic(t))return this.toursViewData.getTourStoryMode()?M.BZ.Delay:M.BZ.None;const a=n.snapshot.metadata.cameraMode,h=a===r.Ey.Dollhouse?M.BZ.PanDollhouse:a===r.Ey.Floorplan?M.BZ.Zoom:M.BZ.Pan;return ee.getTourBurnsStyle(this.settingsData,h,t)},this.canChangeTourLocation=()=>{const e=this.data.getTourState(),t=this.data.isTourTransitionActive(),i=this.cameraData.canTransition();return e===a.Vs.Inactive&&!t&&!(this.viewmodeData.transition&&this.viewmodeData.transition.active)&&i}}async init(e,t){this.engine=t,[this.cameraData,this.viewmodeData,this.settingsData,this.data,this.toursViewData]=await Promise.all([t.market.waitForData(b.M),t.market.waitForData(l.O),t.market.waitForData(v.e),t.market.waitForData(h.k),t.market.waitForData(d.T)]);const i=await t.market.waitForData(oe.R);t.getModuleBySymbol(J.y.INPUT).then((e=>{e.registerHandler(p.er,(()=>{this.handleTourInputInterrupt()})),e.registerHandler(g.a,(()=>{this.handleTourInputInterrupt()})),e.registerHandler(m.e,(e=>{e.state===w.M.DOWN&&this.handleTourInputInterrupt()}))})),this.transitionFactory=new ee(t,this.data,this.cameraData,this.settingsData,this.viewmodeData),await this.transitionFactory.init(),this.setupAutoPlay(t),this.bindings.push(t.commandBinder.addBinding(ie.TH,(async e=>this.startTour(e.index,e.steps,e.loop)))),this.bindings.push(t.commandBinder.addBinding(ie.vy,(async e=>this.stopTour(e.willResume)))),this.bindings.push(t.commandBinder.addBinding(ie.rU,(async e=>this.tourGoTo(e.index,e.instant?c.n.Instant:void 0)))),this.bindings.push(t.commandBinder.addBinding(ie.HW,(async e=>e.forward?this.tourGoNext(e.instant):this.tourGoPrevious(e.instant)))),this.bindings.push(t.commandBinder.addBinding(ie.r2,(async e=>{const t=this.data.tourPlaying;try{t&&await this.stopTour(!0),await this.tourGoNext(!1),t&&await this.startTour()}catch(e){this.log.debug(e)}}))),this.bindings.push(t.commandBinder.addBinding(ie.Ri,(async e=>{const t=this.data.tourPlaying;try{t&&await this.stopTour(!0),await this.tourGoPrevious(!1),t&&await this.startTour()}catch(e){this.log.debug(e)}}))),this.bindings.push(i.onPropertyChanged("currentViewId",(()=>this.stopTour(!1))))}handleTourInputInterrupt(){this.data.getTourState()!==a.Vs.Inactive&&this.stopTour()}canTourProceed(e,t,i){const s=this.data.getSnapshotCount();if(0===s||0===i||this.data.getTourState()!==a.Vs.Inactive)return!1;if(void 0!==t){if(t<-1)return!1;if(!0!==e&&t>s-1)return!1}return!0}shouldTourContinue(e,t,i,s){return void 0!==s?i<s:t<e-1}startTour(e,t,i){if(!this.canChangeTourLocation())throw new se.Y("Cannot start tour at this time, another transition is active");const n=void 0!==i?i:this.data.isLooping();if(!this.canTourProceed(n,e,t))return;this.data.setLooping(n);const o=this.data.getActiveReelTourMode(),r=(0,ne.Cf)(this.settingsData,o),h=this.data.getTourCurrentSnapshotIndex(),d=this.data.getSnapshotCount(),l=this.data.transition,c=h===d-1&&(M.c5.includes(l.type)||!r)&&l.toIndex===d-1&&l.stopped-l.started>=l.duration;let p,g=0;p=void 0!==e?e-1:c?-1:Math.max(h-1,-1);const m=this.settingsData.tryGetProperty(te.YS,null);this.settingsData.setProperty(te.YS,null);const w=this;this.tourGenerator=function*(){for(;w.shouldTourContinue(d,p,g,t);){const e=p+1,t=w.composeTourTransition(e);yield new s.M8(t),p=e,p===d-1&&n&&(p=-1),g++}w.stopTour(),w.settingsData.setProperty(te.YS,m)},this.engine.startGenerator(this.tourGenerator),this.data.setTourState(a.Vs.Active),this.data.tourEnded=!1,this.data.tourWillResume=!1,this.data.tourPlaying=!0,this.data.commit(),this.engine.broadcast(new u.oR)}async composeTourTransition(e,t,i){var s,o,h;const d=this.data.getTourSnapshotSid(e),l=this.data.getTourStop(d);if(!l.snapshot)throw Error(`Highlight not found for reel index ${e}`);const p=this.data.getTourCurrentSnapshotSid()===d,g=this.cameraData.transition.startTime>this.data.transition.stopped;let m=0;const w=this.data.transition.duration;if(p){const{started:e,stopped:t}=this.data.transition;m=(t-e)/w||0,m=Math.min(1,m)}if(g||!p){let t=this.settingsData.tryGetProperty(S.gj,c.n.Interpolate);const n=l.snapshot.metadata.cameraMode,h=n===r.Ey.Dollhouse||n===r.Ey.Floorplan,d=(0,r.Bw)(n),p=!this.viewmodeData.isInside()&&d,g=this.viewmodeData.isInside()&&h,m=!this.viewmodeData.isInside()&&h,w=this.viewmodeData.isInside()&&d;(p||g||m)&&(t=c.n.Interpolate),void 0!==(null===(o=null===(s=l.reelEntry)||void 0===s?void 0:s.overrides)||void 0===o?void 0:o.transitionType)&&(t=l.reelEntry.overrides.transitionType),w&&0===e&&(t=c.n.FadeToBlack),void 0!==i&&(t=i),this.engine.broadcast(new u.dW(e));const y=this.transitionFactory.getFloorTransition(e);if(this.data.useTransition(y),await y.promise,this.data.getTourState()===a.Vs.StopScheduled)return;const f=this.transitionFactory.getMainTransition(e,t);this.data.useTransition(f),await f.promise,this.data.setTourCurrentSnapshotByIndex(e),this.engine.broadcast(new u.Vx(e))}if(this.data.getTourState()===a.Vs.StopScheduled)return;const y={};(null===(h=l.reelEntry)||void 0===h?void 0:h.overrides)&&(y.panAngle=l.reelEntry.overrides.panAngle,y.panDirection=l.reelEntry.overrides.panDirection);const f=t||this.getBurnsStyleForSnapshot(e,y);let v;if(this.toursViewData.getTourStoryMode()){e===this.data.getSnapshotCount()-1&&this.isLastStopStatic(y)&&(v=n.GS)}m>0&&(v=(1-m)*w);const b=this.transitionFactory.getBurnsTransition(e,f,v);this.engine.broadcast(new u._3(e,b.type,b.duration)),this.data.useTransition(b),await b.promise}isLastStopStatic(e){const t=ee.getPanDirection(this.settingsData,e.panDirection),i=ee.getPanDegrees(this.settingsData,e.panAngle),s=this.data.getActiveReelTourMode(),n=(0,ne.Cf)(this.settingsData,s);return 0===i||!n&&t===M.kw.Auto}async stopTour(e=!1){this.data.getTourState()===a.Vs.Active&&(this.data.setTourState(a.Vs.StopScheduled),this.data.tourWillResume=e,this.data.tourPlaying=!1,await this.data.stopTourTransition(),this.tourGenerator&&this.engine.stopGenerator(this.tourGenerator),this.engine.broadcast(new u.NR(e)),this.data.getTourCurrentSnapshotIndex()!==this.data.getSnapshotCount()-1||this.data.isLooping()||(this.data.tourEnded=!0,this.engine.broadcast(new u.Mt)),this.data.setTourState(a.Vs.Inactive),this.data.commit())}async tourGoNext(e){let t=this.data.getTourCurrentSnapshotIndex()+1;t>=this.data.getSnapshotCount()&&(t=0);const i=e?c.n.Instant:void 0;return this.tourGoTo(t,i)}async tourGoPrevious(e){let t=this.data.getTourCurrentSnapshotIndex();t<0&&(t=0);let i=t-1;i<0&&(i=this.data.getSnapshotCount()-1);const s=e?c.n.Instant:void 0;return this.tourGoTo(i,s)}async tourGoTo(e,t=c.n.FadeToBlack){if(!this.canChangeTourLocation())throw new se.z("Cannot change tour location at this time, another transition is active");if(this.viewmodeData.transition&&this.viewmodeData.transition.active)throw new se.z("Cannot go to tour location during viewmode transition");if(this.data.getTourState()!==a.Vs.Inactive)throw new se.z("Cannot jump to tour location while tour is active");try{this.data.setTourState(a.Vs.Active),await this.composeTourTransition(e,M.BZ.None,t)}catch(e){this.log.error(e)}finally{this.data.setTourState(a.Vs.Inactive)}}setupAutoPlay(e){const t=1e3*(0,n.zi)(this.settingsData),i=()=>{let e=!0;const i=this.cameraData.pose.onChanged((()=>{e=!1,i.cancel()}));setTimeout((()=>{e&&this.startTour(),i.cancel()}),t)};if(t>=0){const t=e.market.tryGetData(y.pu);if(t&&t.phase===y.nh.PLAYING)i();else{const t=s=>{s.phase===y.nh.PLAYING&&(i(),e.unsubscribe(f.LZ,t))};e.subscribe(f.LZ,t)}}}}},87152:(e,t,i)=>{"use strict";i.r(t),i.d(t,{HighlightReel:()=>w,ToggleForceShowStoryTextCommand:()=>z.iy,ToggleHighlightReelOpenCommand:()=>z.Av,TourAddPosition:()=>G.VH,TourChangeDescriptionCommand:()=>z.K1,TourChangeTitleCommand:()=>z.Ty,TourData:()=>s.k,TourMode:()=>G.zz,TourRenameCommand:()=>z.CI,TourSetTourModeCommand:()=>z.Te,TourState:()=>G.Vs,ToursViewData:()=>n.T,default:()=>ee});var s=i(2473),n=i(65397),o=i(97542),r=i(34029),a=i(95882),h=i(53954),d=i(42418),l=i(59625),c=i(17788),u=i(32082),p=i(97998),g=i(10385),m=i(75287);class w extends m.T{constructor(e){super(),this.reel=(0,g.C)([]),this.modified=new Date,this.mode=e,this.commit()}replace(e){this.atomic((()=>{this.sid=e.sid,this.reel.replace(Array.from(e.reel.values())),this.mode=e.mode,this.modified=e.modified}))}}var y=i(64918),f=i(17686),v=i(37519),b=i(29282),T=i(5823);const D=new p.Z("mds-reel-element-serializer"),S={[T.y8.FADE_TO_BLACK]:y.n.FadeToBlack,[T.y8.INSTANT]:y.n.Instant,[T.y8.INTERPOLATE]:y.n.Interpolate},P={[T.Y6.LEFT]:f.kw.Left,[T.Y6.RIGHT]:f.kw.Right,[T.Y6.AUTO]:f.kw.Auto};class I{deserialize(e){var t;if(!e||!(null===(t=null==e?void 0:e.asset)||void 0===t?void 0:t.id))return D.debug("Deserialized invalid highlight reel entry from MDS",e),null;const i=e.overrides,s={},n=(null==i?void 0:i.transitionType)?S[null==i?void 0:i.transitionType]:void 0,o=(null==i?void 0:i.panDirection)?P[null==i?void 0:i.panDirection]:void 0,r=null==i?void 0:i.panAngle;(0,b.r)(n)&&(s.transitionType=n),(0,b.r)(o)&&(s.panDirection=o),(0,v.hj)(r)&&(s.panAngle=r);const a={sid:e.asset.id,overrides:s};return e.title&&(a.title=e.title),e.description&&(a.description=e.description),a}}const M=new p.Z("mds-highlight-reel-serializer");class x{constructor(e){this.defaultTourMode=e,this.reelEntrySerializer=new I}deserialize(e){if(!e||!this.validate(e))return M.debug("Deserialized invalid active reel data from MDS",e),null;const t=new w(e.mode||this.defaultTourMode);if(t.sid=e.id,e.reel)for(const i of e.reel){if(!i)continue;const e=this.reelEntrySerializer.deserialize(i);e&&t.reel.push(e)}return t}validate(e){return["id"].every((t=>t in e))}}const R={[y.n.FadeToBlack]:T.y8.FADE_TO_BLACK,[y.n.Instant]:T.y8.INSTANT,[y.n.Interpolate]:T.y8.INTERPOLATE,[y.n.MoveToBlack]:T.y8.FADE_TO_BLACK},E={[f.kw.Left]:T.Y6.LEFT,[f.kw.Right]:T.Y6.RIGHT,[f.kw.Auto]:T.Y6.AUTO};class C{serialize(e){const t={id:e.sid};return e.title&&(t.title=e.title),e.description&&(t.description=e.description),e.overrides&&(t.overrides={},void 0!==e.overrides.transitionType&&(t.overrides.transitionType=R[e.overrides.transitionType]),void 0!==e.overrides.panDirection&&(t.overrides.panDirection=E[e.overrides.panDirection]),void 0!==e.overrides.panAngle&&(t.overrides.panAngle=e.overrides.panAngle)),t}}const A=new p.Z("mds-highlight-reel-store");class L extends c.u{constructor(e,t,i){super(e),this.baseModelId=i,this.serializer=new C,this.prefetchKey="data.model.activeHighlightReel",this.deserializer=new x(t)}async read(e){const t={modelId:this.getViewId(),prefetchKey:this.prefetchKey};return this.query(u.GetHighlightReel,t,e).then((e=>{var t,i;const s=null===(i=null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.model)||void 0===i?void 0:i.activeHighlightReel;return this.deserializer.deserialize(s)}))}async update(e){const t=this.getViewId(),i=e.reel.map((e=>this.serializer.serialize(e))),s=e.mode;return this.mutate(u.PutActiveReel,{modelId:t,elements:i,mode:s}).then((async e=>{A.debug(e)}))}async fetchAllTourSweeps(){var e,t;const i={modelId:this.baseModelId},s=null===(t=null===(e=(await this.query(u.GetHighlightReelSweeps,i,{fetchPolicy:"no-cache"})).data)||void 0===e?void 0:e.model)||void 0===t?void 0:t.views,n=[];return s&&s.forEach((e=>{var t,i;const s=null===(i=null===(t=e.model)||void 0===t?void 0:t.activeHighlightReel)||void 0===i?void 0:i.reel;s&&s.forEach((t=>{var i,s,o;const r=null===(o=null===(s=null===(i=t.asset)||void 0===i?void 0:i.snapshotLocation)||void 0===s?void 0:s.anchor)||void 0===o?void 0:o.id;r&&n.push({viewId:e.id,sweepId:r})}))})),n}}var O=i(86090),F=i(2541),k=i(79728),N=i(90632),B=i(635),G=i(60699),z=i(89264),V=i(97478),U=i(69170),Q=i(54244),_=i(89570),H=i(38399),j=i(71166),Z=i(35221),W=i(56163),q=i(96767);const{HLR:Y}=H.Z.WORKSHOP;class X extends W.K{constructor(e,t,i,s,n,o){if(super(e,void 0,t),this.reelEntry=i,this.index=s,this.tourMode=n,this.locale=o,this.id=this.reelEntry.id,this.title=this.reelEntry.title||"",this.description=this.reelEntry.description||"",this.icon="icon-toolbar-hlr",this.typeId=T.SF.HIGHLIGHTREEL,this.floorId="",this.dateBucket=(0,Z.f)(this.reelEntry.snapshot.created),this.onSelect=async()=>{super.onSelect(),await this.commandBinder.issueCommand(new q.rU(this.index)),this.tourMode===G.zz.STORIES?await this.commandBinder.issueCommand(new z.iy(!0)):this.commandBinder.issueCommand(new z.Av(!0))},n===G.zz.STORIES){const e=!!i.title,t=!!i.snapshot.name;this.title=e&&t?i.snapshot.name+" - "+i.title:e||t?i.title?i.title:i.snapshot.name:this.getDefaultName()}else this.title=i.snapshot.name?i.snapshot.name:this.getDefaultName(),this.description="";this.imgUrl=this.reelEntry.snapshot.thumbnailUrl}supportsBatchDelete(){return!1}getDefaultName(){return this.locale.t(Y.SEARCH_HIGHLIGHT_DEFAULTNAME)+" "+(this.index+1)}}const{HLR:$}=H.Z.WORKSHOP;var K=i(21359),J=i(80742);class ee extends o.Y{constructor(){super(...arguments),this.name="tours-data",this.defaultModes=[a.Ey.Panorama,a.Ey.Outdoor],this.fetchAllTourSweeps=async()=>{const e=await this.store.fetchAllTourSweeps();this.viewData.setSweepsInToursAcrossViews(e)},this.updateTourMode=()=>{this.viewData.currentTourMode=this.getCurrentTourMode(),this.viewData.setTourModeSetting(this.getTourModeSetting()),this.viewData.commit()},this.closeReelIfEmpty=()=>{0===this.tourData.getSnapshotCount()&&this.viewData.reelOpen&&this.toggleReel(!1)},this.saveTourModeChange=async e=>{const{tourMode:t}=e;t===G.zz.STORIES?this.tourData.setActiveReelTourMode(T.Z1.STORY):t===G.zz.LEGACY&&this.tourData.setActiveReelTourMode(T.Z1.REEL),this.updateTourMode()},this.onToggleReel=async e=>{this.toggleReel(e.open)},this.onForceShowStoryText=async e=>{this.engine.broadcast(new K.Q)},this.onUpdateSnapshots=()=>{this.tourData.updateSnapshots(this.snapshotsData.collection)}}async init(e,t){const{readonly:i,baseUrl:o,storyToursFeature:a,baseModelId:c}=e;this.engine=t,this.config=e;const[u,p,g,m]=await Promise.all([t.market.waitForData(r.e),t.market.waitForData(h.Z),t.market.waitForData(d.P),t.market.waitForData(J.R)]);this.settingsData=u,this.snapshotsData=g;const y=this.getFilterModes(this.defaultModes),f=a?T.Z1.STORY:T.Z1.REEL;if(this.tourData=new s.k(this.snapshotsData.collection,new w(f),y,p.getSweepList(),e.looping,this.log),this.viewData=new n.T(this.tourData,this.getTourModeSetting(),this.getCurrentTourMode()),!1===i){const[e,i]=await Promise.all([t.getModuleBySymbol(U.y.STORAGE),t.market.waitForData(N.Q)]),s=this.tourData.getReel();this.monitor=new O.u(s,{aggregationType:F.E.NextFrame},t),this.monitor.onChanged((()=>{this.monitor.hasDiffRecord()&&this.engine.commandBinder.issueCommand(new B.VQ({dataTypes:[k.g.HIGHLIGHTS]}))})),this.bindings.push(e.onSave((()=>this.save()),{dataType:k.g.HIGHLIGHTS}),e.onSave((()=>this.fetchAllTourSweeps()),{dataType:k.g.SWEEPS})),i.setRevertableType(k.g.HIGHLIGHTS),i.setPublishableType(k.g.HIGHLIGHTS),this.bindings.push(t.commandBinder.addBinding(z.Te,this.saveTourModeChange),this.settingsData.onPropertyChanged(l.gx.TourButtons,this.updateTourMode),this.settingsData.onPropertyChanged(l.gx.HighlightReel,this.updateTourMode))}this.store=new L({context:m.mdsContext,readonly:i,baseUrl:o},f,c),this.bindings.push(this.store.onNewData((async e=>{this.tourData.atomic((()=>{var t;this.tourData.setHighlightReel(e||new w(f)),null===(t=this.monitor)||void 0===t||t.clearDiffRecord()})),this.updateTourMode(),this.closeReelIfEmpty()}))),await this.store.refresh(),this.bindings.push(t.commandBinder.addBinding(z.Av,this.onToggleReel),t.commandBinder.addBinding(z.iy,this.onForceShowStoryText),this.snapshotsData.onChanged(this.onUpdateSnapshots)),async function(e,t,i){const s=await e.market.waitForData(Q.pu),n=await e.getModuleBySymbol(U.y.LOCALE),o=(s,o,r,a=[])=>{const h=[],d=t.getCurrentTourState().highlights,l=i.currentTourMode;if(a.length>0||l===G.zz.NONE)return h;const c=l===G.zz.STORIES;let u=0;return d.forEach((t=>{const i=t.title&&c?t.title:n.t($.SEARCH_HIGHLIGHT_DEFAULTNAME)+" "+(u+1);if(s(i)||t.snapshot.name&&s(t.snapshot.name)||c&&t.description&&s(t.description)){const i=new X(e.commandBinder,o,t,u,l,n);h.push(i)}u++})),h},r=e=>new _.V(t.onChanged(e),i.onTourModeSettingChanged(e)),a=()=>{e.commandBinder.issueCommandWhenBound(new j.c6({id:T.SF.HIGHLIGHTREEL,groupPhraseKey:$.SEARCH_TOUR_HEADER,getSimpleMatches:o,registerChangeObserver:r,groupOrder:10,groupIcon:"toolbar-hlr"}))},h=()=>{e.commandBinder.issueCommandWhenBound(new j.Pe(T.SF.HIGHLIGHTREEL))},d={renew:a,cancel:h},l=e=>{h(),a()},c=s.onPropertyChanged("application",l);l(s.application),new _.V(d,c)}(t,this.tourData,this.viewData),t.market.register(this,s.k,this.tourData),i?t.market.register(this,n.T,this.viewData):this.fetchAllTourSweeps().then((()=>{t.market.register(this,n.T,this.viewData)}))}dispose(e){this.store.dispose(),super.dispose(e)}async save(){if(!this.monitor||this.config.readonly)return void this.log.warn("Tour changes will NOT be saved");const e=this.tourData.getReel();await this.store.update(e),this.fetchAllTourSweeps(),this.monitor.clearDiffRecord()}getCurrentTourMode(){return(0,V.aW)(this.settingsData,this.tourData.getActiveReelTourMode())}getTourModeSetting(){return(0,V.w7)(this.settingsData,this.tourData.getActiveReelTourMode())}toggleReel(e){this.viewData.reelOpen=e,this.viewData.commit()}getFilterModes(e){const t=this.settingsData.getOverrideParam("dh",1)>0,i=this.settingsData.tryGetProperty(l.gx.Dollhouse,!0);t&&i&&e.push(a.Ey.Dollhouse);const s=this.settingsData.getOverrideParam("fp",1)>0,n=this.settingsData.tryGetProperty(l.gx.FloorPlan,!0);return s&&n&&e.push(a.Ey.Floorplan),e}}},79232:(e,t,i)=>{"use strict";i.d(t,{F:()=>o});var s=i(75287),n=i(39880);class o extends s.T{constructor(e){super(),this.id=(0,n.O1)(11),e&&Object.assign(this,e)}}},33824:(e,t,i)=>{"use strict";i.d(t,{B:()=>n,p:()=>o});var s=i(19663);class n extends s.m{constructor(e){super(),this.id="REGISTER_DELETED_OBJECT_TYPE_COMMAND",this.payload=e}}class o extends s.m{constructor(e){super(),this.id="RESTORE_DELETED_OBJECT_COMMAND",this.payload={id:e}}}},76539:(e,t,i)=>{"use strict";i.r(t),i.d(t,{DeletedObject:()=>s.F,default:()=>I});var s=i(79232),n=i(97542),o=i(79728),r=i(45905),a=i(635),h=i(94753),d=i(3907),l=i(9133);function c(e){return{id:e.id,label:e.label,object_id:e.objectId,object_type:e.objectType,created:(0,l.U)(e.created),json_string:JSON.stringify(e.value)}}function u(e){const t={};for(const i of Object.values(e)){const e=c(i);e&&(t[i.id]=e)}return t}function p(e){const t=e.id,i=e.label,n=e.object_id,o=e.object_type,r=(0,l.p)(e.created);let a;try{a=JSON.parse(e.json_string)}catch(e){}if(!(t&&n&&o&&a))return null;return new s.F({id:t,label:i,objectId:n,objectType:o,created:r,value:a})}function g(e){const t={};for(const i in e){const s=p(e[i]);s&&(t[i]=s)}return t}class m extends d.MU{constructor(e,t,i){super({queue:t,path:`${i}/api/v1/jsonstore/model/trash/${e}`,batchUpdate:!0,deserialize:g,serialize:u})}}var w=i(67992),y=i(15637),f=i(39880);const v=new(i(97998).Z)("TrashData");class b extends w.V{constructor(e){super(),this.trash=new y.v,this.registry=new Map,e&&this.add(...Object.values(e))}get(e){return this.trash.get(e)}add(...e){this.atomic((()=>{this.trash.atomic((()=>{for(const t of e)t.atomic((()=>{for(;!t.id||this.trash.has(t.id);)t.id=(0,f.O1)(11),t.commit()})),this.trash.set(t.id,t)})),this.commit()}))}create(e,t){const i=this.registry.get(e);if(!i)return void v.debug(`Unsupported type added to trash: ${e}`);const s=i.create(t);return this.add(s),s}restore(e){const t=this.trash.get(e),i=this.registry.get(t.objectType);if(!i)throw new Error(`Can't restore unsupported type ${t.objectType}`);return i.restore(t)}register(e){v.debug(`Registered type ${e.objectType}`);const{objectType:t}=e;this.registry.has(t)?v.debug(`Type ${t} already registered`):this.registry.set(t,e)}unregister(e){return v.debug(`Unregistered type ${e}`),this.registry.delete(e)}isSupported(e){return this.registry.has(e)}}var T=i(33824),D=i(35895),S=i(69170);class P extends n.Y{constructor(){super(...arguments),this.name="trash"}async init(e,t){const{baseModelId:i,queue:s,baseUrl:n}=e,{market:o,commandBinder:a}=t;this.engine=t,this.store=new m(i,s,n),this.data=new b,o.register(this,b,this.data),this.engine.getModuleBySymbol(S.y.STORAGE).then((e=>{this.bindings.push(e.onPublish((async()=>this.backup()),{phase:r.Q.BEFORE}))})),this.bindings.push(a.addBinding(T.B,(async e=>this.registerDeletedObject(e))),a.addBinding(T.p,(async({id:e})=>this.restore(e))))}dispose(e){super.dispose(e),e.market.unregister(this,b)}async registerDeletedObject(e){const{objectType:t}=e;return(0,D.k1)((()=>this.data.register(e)),(()=>this.data.unregister(t)),!0)}async backup(){const{commandBinder:e}=this.engine,t=await e.issueCommand(new a.ff).catch((e=>{throw new h.AE(e)})),i={};for(const e in t)this.data.isSupported(e)&&t[e].forEach((t=>{const s=this.data.create(e,t);s&&(i[s.id]=s)}));if(Object.keys(i).length)return this.store.update(i)}async restore(...e){const t=new Set;for(const i of e){const e=this.data.get(i);this.log.debug(`Restoring ${e.objectType} ${e.id}`),Object.values(o.g).includes(null==e?void 0:e.objectType)&&t.add(e.objectType),this.data.restore(i)}if(t.size>0)return this.engine.commandBinder.issueCommand(new a.VQ({dataTypes:[...t]}))}}const I=P},10805:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>p});var s=i(69170),n=i(97542),o=i(96767),r=i(96154),a=i(31362),h=i(50575);class d{constructor(){this._dateNow=Date.now,this._performanceNow=performance.now,this.nowOverride=0}slowTime(e){this.fps=e,this.nowOverride=Date.now(),Date.now=()=>this.nowOverride,performance.now=()=>this.nowOverride}tick(){this.nowOverride+=1e3/this.fps}resetTime(){Date.now=this._dateNow,performance.now=this._performanceNow}}var l,c=i(38319),u=i(26256);!function(e){e[e.STOPPED=0]="STOPPED",e[e.RECORDING=1]="RECORDING"}(l||(l={}));class p extends n.Y{constructor(){super(...arguments),this.name="video-recorder-module",this.state=l.STOPPED,this.frostMage=new d}async init(e,t){this.settingsModule=await t.getModuleBySymbol(s.y.SETTINGS),this.canvasModule=await t.getModuleBySymbol(s.y.CANVAS),this.engine=t,this.settingsModule.registerButton("Tour Recorder (Chrome Only)","Download 1080p @ 60",(()=>{this.state===l.STOPPED&&this.record(1920,1080,60)})),this.settingsModule.registerButton("Tour Recorder (Chrome Only)","Download 720p @ 30",(()=>{this.state===l.STOPPED&&this.record(1280,720,30)})),this.settingsModule.registerButton("Tour Recorder (Chrome Only)","Download instagram",(()=>{this.state===l.STOPPED&&this.record(1080,1080,30)})),this.settingsModule.registerButton("Tour Recorder (Chrome Only)","Download instagram story",(()=>{this.state===l.STOPPED&&this.record(1080,1920,30)})),this.settingsModule.registerButton("Tour Recorder (Chrome Only)","Stop & download current",(()=>{this.state===l.RECORDING&&this.stop()}))}async record(e,t,s){if(this.state!==l.STOPPED)return void this.log.warn("Can't start recording... we're already recording!");this.log.info("Starting recording of tour. Now is a good time to get a coffee :)"),this.state=l.RECORDING;const n=await Promise.all([i.e(764),i.e(330),i.e(718)]).then(i.bind(i,15730));this.encoder=new n.WebMWriter({quality:.95,frameRate:s}),this.frostMage.slowTime(s),await this.engine.commandBinder.issueCommand(new h.M({resizeDimensions:[{property:h.P.width,setDimension:e,duration:0},{property:h.P.height,setDimension:t,duration:0}]})),await this.engine.commandBinder.issueCommand(new o.TH);const a=this.engine.subscribe(r.NR,(()=>{a.cancel(),this.state===l.RECORDING&&this.stop()})),d=this,c=this.canvasModule.element;this.engine.startGenerator((function*(){for(;d.state===l.RECORDING;)d.encoder.addFrame(c),yield new u.Jj,d.frostMage.tick(),yield new u.Jj}))}async stop(){if(this.state!==l.RECORDING)return void this.log.warn("Can't stop recording, we weren't recording at all");this.frostMage.resetTime(),this.state=l.STOPPED,await this.engine.commandBinder.issueCommand(new h.M((0,c.lb)(0))),this.log.info("Encoding tour to video...");const e=await this.encoder.complete();this.log.info("Tour encoded! Prompting user to download."),(0,a.Hx)(e,"tour.webm")}}},64952:(e,t,i)=>{"use strict";i.r(t),i.d(t,{default:()=>le});var s=i(97542),n=i(69170),o=i(89570),r=i(69505),a=i(2569),h=i(81396),d=i(90304),l=i(9037),c=i(85992),u=i(34029),p=i(59370);const g=new h.Vector3(0,-100,0),m=new h.Vector2(-2,-2),w=new h.Vector3(-1,-1,-1),y=new h.Vector3(1,1,1);class f{constructor(e){this.raycaster=e,this.currentRay=new h.Ray,this.origin=g,this.direction=new h.Vector3,this.pointerNdc=m,this.cameraCache={position:new h.Vector3,quaternion:new h.Quaternion,camera:void 0},this.cast=e=>{const t=this.currentRay,i=this.raycaster.cast(t.origin,t.direction,e).slice();return i.length&&(this.lastHit=i[0]),i},this.update3D=(e,t,i)=>{e instanceof h.Vector3&&this.origin.copy(e),t instanceof h.Vector3&&this.direction.copy(t),this.cameraCache.camera=i,this.currentRay.set(this.origin,this.direction)},this.updateNDCPosition=()=>{const e=this.lastHit;if(this.cameraCache.camera&&e&&e.point){const t=this.cameraCache.camera;this.cameraCache.position.setFromMatrixPosition(t.matrixWorld),this.cameraCache.quaternion.setFromRotationMatrix(t.matrixWorld);const i=(0,p.D_)(e.point,this.cameraCache.position,this.cameraCache.quaternion,t.projectionMatrix);i.clamp(w,y),this.pointerNdc.set(i.x,i.y)}},this.updatePointer=()=>{}}get pointerRay(){return this.currentRay}get ndcPosition(){return this.updateNDCPosition(),this.pointerNdc}}var v=i(98010);class b extends v.v{}class T extends b{constructor(e){super(),this.trackedCamera=e}}class D extends b{}class S extends b{}var P,I=i(81456),M=i(13693),x=i(17878);!function(e){e[e.Mono=0]="Mono",e[e.Stereo=1]="Stereo",e[e.SixDof=2]="SixDof",e[e.__length=3]="__length"}(P||(P={}));const R={controllers:Object.freeze([0,1]),rotationDegrees:25};var E;!function(e){e[e.touchpadX=0]="touchpadX",e[e.touchpadY=1]="touchpadY",e[e.thumbstickX=2]="thumbstickX",e[e.thumbstickY=3]="thumbstickY"}(E||(E={}));const C={x:0,y:0,z:0,w:1};class A extends M.Y{constructor(e,t,i,s,n){super(),this.engine=e,this.renderer=t,this.webglScene=i,this.cameraData=s,this.cameraModule=n,this.trackingStyle=P.Mono,this.session=null,this.rotations={initialYawOffset:new h.Quaternion,yawOffset:new h.Quaternion,invYawOffset:new h.Quaternion,trackingOffset:new h.Quaternion},this.setTrackingStyle=e=>{e<P.__length&&(this.trackingStyle=e,this.resetInitialRotation())},this.offsetRotation=e=>{this.rotations.invYawOffset.multiply(e),this.rotations.yawOffset.copy(this.rotations.invYawOffset).invert()},this.onPresentStart=e=>{e.cameras[0].layers.mask=x.o.ALL.mask,e.cameras[1].layers.mask=x.o.ALL.mask,e.cameras[0].far=e.far,e.cameras[1].far=e.far,e.layers.mask=x.o.ALL.mask,this.resetInitialRotation(),this.broadcast(new D)},this.resetInitialRotation=()=>{const e=this.cameraData.pose.rotation.clone();(0,a.Rq)(e,this.rotations.initialYawOffset),this.rotations.yawOffset.copy(this.rotations.initialYawOffset),this.rotations.invYawOffset.copy(this.rotations.initialYawOffset).invert()},this.onPresentEnd=()=>{this.broadcast(new S)},this.applyTrackingOverrides=(e,t,i)=>{if(e.xr.isPresenting&&i instanceof h.ArrayCamera){e.clear();const t=i.cameras[0],s=i.cameras[1];if(this.frame=this.engine.getXrFrame(),this.session||(this.session=e.xr.getSession(),this.onPresentStart(i)),this.frame&&this.session){this.rotations.trackingOffset.copy(this.rotations.yawOffset).multiply(i.quaternion),this.cameraModule.updateCameraRotation(this.rotations.trackingOffset);const e=this.webglScene.camera.parent;if(e){const t=this.getReferenceSpace(this.frame,e);this.updateCameras(i,this.frame,t,e),this.updateControllers(this.session,this.frame,t,e)}switch(this.trackingStyle){case P.Mono:s.matrixWorld.copy(t.matrixWorld),s.matrixWorldInverse.copy(s.matrixWorld),s.matrixWorldInverse.invert()}this.broadcast(new T(t))}}else this.session&&(this.session=null,this.onPresentEnd())},this.getReferenceSpace=(e,t)=>{const i=this.renderer.xr.getReferenceSpace(),s=e.getViewerPose(i).views[0].transform.position,n=this.trackingStyle===P.SixDof?C:s,o=new XRRigidTransform({x:n.x-t.position.x,y:n.y-t.position.y,z:n.z-t.position.z}),r=i.getOffsetReferenceSpace(o),a=this.rotations.invYawOffset,h=this.cameraData.pose.position,d=new XRRigidTransform({x:h.x,y:h.y,z:h.z,w:1},{x:a.x,y:a.y,z:a.z,w:a.w});return r.getOffsetReferenceSpace(d)},this.updateCameras=(e,t,i,s)=>{const n=t.getViewerPose(i);if(n){const t=n.views;for(let i=0;i<t.length;i++){const n=t[i],o=e.cameras[i];o.matrix.fromArray(n.transform.matrix),o.projectionMatrix.fromArray(n.projectionMatrix),o.projectionMatrixInverse.copy(o.projectionMatrix),o.projectionMatrixInverse.invert(),o.matrixWorld.multiplyMatrices(s.matrixWorld,o.matrix),o.matrixWorldInverse.copy(o.matrixWorld),o.matrixWorldInverse.invert(),o.matrix.decompose(o.position,o.quaternion,o.scale),0===i&&(e.matrix.copy(o.matrix),e.matrix.decompose(e.position,e.quaternion,e.scale),e.matrixWorld.copy(o.matrixWorld),e.matrixWorldInverse.copy(o.matrixWorldInverse),e.projectionMatrix.copy(o.projectionMatrix),e.projectionMatrixInverse.copy(o.projectionMatrixInverse))}}},this.updateControllers=(e,t,i,s)=>{for(let n=0;n<2;n++){const o=this.renderer.xr.getController(n),r=this.renderer.xr.getControllerGrip(n),a=e.inputSources[n];let h=null,d=null;a&&(o&&(h=t.getPose(a.targetRaySpace,i),h&&(o.matrix.fromArray(h.transform.matrix),o.matrixWorld.multiplyMatrices(s.matrixWorld,o.matrix),o.matrix.decompose(o.position,o.quaternion,o.scale)),o.visible=!!h),r&&a.gripSpace&&(d=t.getPose(a.gripSpace,i),d&&(r.matrix.fromArray(d.transform.matrix),r.matrixWorld.multiplyMatrices(s.matrixWorld,r.matrix),r.children.forEach((e=>{e.updateMatrixWorld()})),r.matrix.decompose(r.position,r.quaternion,r.scale)))),r&&(r.visible=!!d)}},this.webglScene.scene.onBeforeRender=this.applyTrackingOverrides}}var L=i(37082),O=i(87928),F=i(85255),k=i(48786),N=i(20043),B=i(35826),G=i(8948),z=i(53954),V=i(5135),U=i(23254),Q=i(13310),_=i(87926);const H=i.p+"images/selected_sweep_glow.png";class j{constructor(e){this.meshQuery=e,this.active=!1,this.target=new L.f(null),this.previousSweep=null,this.activate=()=>{this.active||(this.updateLoopSub.renew(),this.selectionChangeSub.renew(),this.ray.toggle(!0),this.targetDecoration.toggle(!0),this.active=!0)},this.deactivate=()=>{this.active&&(this.target.value=null,this.selectionChangeSub.cancel(),this.updateLoopSub.cancel(),this.ray.toggle(!1),this.targetDecoration.toggle(!1),this.active=!1)},this.getTargetSweep=(e,t,i)=>{let s=null;if(t.object instanceof G.YY)return s=e.getSweep(t.object.userData.sid),s;const n=(0,N.bG)(e,!0,t.intersection,this.meshQuery);return s=n.length>0?n[0].sweep:null,s}}get container(){return this._container}async init(e){this.engine=e,this._container=new h.Group,this._container.name="XRNavigationVisuals",this.ray=new Z(this.container),this.targetDecoration=new W(this.container);const t=await this.engine.market.waitForData(c.P);return this.updateLoopSub=t.onChanged((()=>this.update(t))),this.updateLoopSub.cancel(),this.selectionChangeSub=this.target.onChanged((e=>{null!==this.previousSweep&&this.engine.commandBinder.issueCommand(new B.kR(this.previousSweep.id,!1,200)),null!==e&&(this.engine.commandBinder.issueCommand(new B.kR(e.id,!0,200)),this.targetDecoration.updateTargetPosition(e.floorPosition)),this.previousSweep=e})),this.selectionChangeSub.cancel(),this}update(e){const t=this.engine.market.tryGetData(z.Z),i=this.engine.market.tryGetData(l.M),s=this.engine.market.tryGetData(U.O),n=this.engine.market.tryGetData(Q.Y),o=this.engine.market.tryGetData(V.Z);if(!(t&&i&&s&&o&&n))return;if(!o.isVR())return;if(!s.isInside())return;const{hit:r,pointerDirection:a,pointerOrigin:h}=e;if(!r)return;const d=this.getTargetSweep(t,r,a);this.target.value=d,this.ray.update(h,r.point,n.opacity.value),this.targetDecoration.update(i.pose.rotation,n.opacity.value)}}class Z{constructor(e){this.container=e,this.styles={ray:{color:"white",transparent:!0,opacity:.3,linewidth:2,depthWrite:!1},hit:{color:"white",transparent:!0,opacity:.3},hitScale:.02},this.update=(e,t,i)=>{this.ray.updatePositions(e,t).opacity(Math.min(i,this.styles.ray.opacity)),this.hitMarker.position.copy(t),this.hitMarker.material.opacity=Math.min(i,this.styles.hit.opacity)},this.toggle=e=>{e?(this.container.add(...this.ray.children),this.container.add(this.hitMarker)):(this.container.remove(...this.ray.children),this.container.remove(this.hitMarker))};const{ray:t,hit:i}=this.styles,s=(0,F.makeLineMaterial)(t.color,!1,t);this.ray=new k.c(new h.Vector3,new h.Vector3,s,{}),this.ray.updateResolution(window.innerWidth,window.innerHeight),this.hitMarker=new O.E(new h.SphereGeometry(this.styles.hitScale),new h.MeshBasicMaterial(i)),this.hitMarker.name="hit"}}class W{constructor(e){this.container=e,this.styles={scale:.46,animationSpeed:1,plane:{color:"white",transparent:!0,opacity:.6,depthWrite:!1,depthTest:!1,map:(0,_.p)(H)}},this.position=new h.Vector3,this.quaternion=new h.Quaternion,this.updateTargetPosition=e=>{this.position.copy((0,a.Xv)(e,d.f.UP,.05))},this.update=(e,t)=>{const i=(0,a.Rq)(e,this.quaternion);this.target.quaternion.copy(i),this.target.position.lerp(this.position,this.styles.animationSpeed),this.target.material.opacity=Math.min(t,this.styles.plane.opacity)},this.toggle=e=>{e?this.container.add(this.target):this.container.remove(this.target)};const t=new h.PlaneGeometry(1),i=new h.Matrix4;i.makeRotationFromEuler(new h.Euler(-Math.PI/2,0,0,"XYZ")),t.applyMatrix4(i),this.target=new O.E(t,new h.MeshBasicMaterial(this.styles.plane)),this.target.name="Destination",this.target.scale.set(this.styles.scale,this.styles.scale,this.styles.scale)}}class q{constructor(e){this.controllers=e,this._lastInputWas=0}focus(e){e!==this._lastInputWas&&(R.controllers.forEach((t=>{this.controllers.controller(t).grip.visible=t!==e})),this._lastInputWas=e)}}var Y=i(35895);class X{constructor(e){this.renderer=e,this._defaultController=0,this.controllerGroups=[],this.bindings=[],this.cancel=()=>{this.bindings.forEach((e=>e.cancel())),this.bindings.length=0},this.container=new h.Group,this.container.name="XRControllerMesh",R.controllers.forEach((e=>{const t=this.createControllerGroup(e);this.controllerGroups.push(t),this.container.add(t.grip,t.pointer)})),this.connectControllerModel(),this.container.matrixAutoUpdate=!1}controller(e=this._defaultController){return this.controllerGroups[e]}setDefault(e){this._defaultController=e}async connectControllerModel(){const e=new((await Promise.all([i.e(217),i.e(376)]).then(i.bind(i,92583))).XRControllerModelFactory);R.controllers.forEach((t=>{const i=this.controller(t).grip;i.add(e.createControllerModel(i))}))}createControllerGroup(e){const t=this.renderer.xr.getController(e);t.name=`Controller Ray ${e}`;const i=this.renderer.xr.getControllerGrip(e);i.name=`Controller Grip ${e}`,i.visible=!1;const s={index:e,pointer:t,grip:i,connected:!1,hand:"none"},n=e=>{s.hand=e.data.handedness,s.connected=!0},o=()=>{s.hand="none",s.connected=!1};return this.bindings.push((0,Y.k1)((()=>t.addEventListener("connected",n)),(()=>t.removeEventListener("connected",n))),(0,Y.k1)((()=>t.addEventListener("disconnected",o)),(()=>t.removeEventListener("disconnected",o)))),s}}const $=new(i(97998).Z)("xr-input-forwarding");class K{constructor(e){this.options=e,this.dispatchPointerDown=e=>{this.forwardEvent("pointerdown",this.mockPointerEventInit(e))},this.dispatchPointerUp=e=>{this.forwardEvent("pointerup",this.mockPointerEventInit(e))},this.target=e.forwardToElement}dispatchPointerMove(e){this.forwardEvent("pointermove",this.mockPointerEventInit(e))}mockPointerEventInit(e){let t=0,i=0;if(this.options.getPointerScreenPosition){const e=this.options.getPointerScreenPosition();t=e.x,i=e.y}return{pointerType:"gamepad",pointerId:e,clientX:t,clientY:i}}forwardEvent(e,t){let i;try{i=window.PointerEvent?new PointerEvent(e,t):new MouseEvent(e,t),i&&this.target.dispatchEvent(i)}catch(e){$.error(e)}}}class J extends h.EventDispatcher{constructor(e,t){super(),this.renderer=e,this.options={forwardNativeXrEvents:!0,dispatchToControllerGroup:!1,axisMoveTriggerThreshold:.5},this.previousGamepad=new Map,this.forwardedEvents=["selectstart","select","selectend","squeeze","squeezestart","squeezeend"],this.active=!1,this.renew=()=>{!this.active&&this.options.forwardNativeXrEvents&&(this.addSessionListeners(),this.active=!0)},this.cancel=()=>{this.active&&this.options.forwardNativeXrEvents&&(this.removeSessionListeners(),this.active=!1)},this.updateFromGamepads=()=>{if(!this.active)return;const e=this.renderer.xr.getSession();if(e)for(const t of R.controllers){const i=e.inputSources[t];if(!i||!i.gamepad)continue;const s=this.renderer.xr.getController(t),n=this.previousGamepad.get(i),o={buttons:i.gamepad.buttons.map((e=>e.value)),axes:new Float32Array(i.gamepad.axes.slice())},r={controllerIndex:t,inputSource:i,axes:o.axes};n&&(o.buttons.forEach(((e,t)=>{e!==n.buttons[t]&&(1===e?this.sendGamepadEvent(s,Object.assign(Object.assign({},r),{type:"buttondown",value:e,index:t,target:s})):0===e&&this.sendGamepadEvent(s,Object.assign(Object.assign({},r),{type:"buttonup",value:e,index:t,target:s})))})),o.axes.forEach(((e,t)=>{const i=n.axes[t];if(e!==i){this.sendGamepadEvent(s,Object.assign(Object.assign({},r),{type:"axesmove",value:e,index:t,target:s})),0===i&&this.sendGamepadEvent(s,Object.assign(Object.assign({},r),{type:"axesmovestart",value:e,index:t,target:s}));const n=this.options.axisMoveTriggerThreshold;Math.abs(i)<n&&Math.abs(e)>n&&this.sendGamepadEvent(s,Object.assign(Object.assign({},r),{type:"axestriggered",value:e,index:t,target:s})),0===e&&this.sendGamepadEvent(s,Object.assign(Object.assign({},r),{type:"axesmoveend",value:e,index:t,target:s}))}}))),this.previousGamepad.set(i,o)}},this.onGamepadEvent=(e,t)=>(0,Y.k1)((()=>super.addEventListener(e,t)),(()=>super.removeEventListener(e,t))),this.onSessionEvent=(e,t)=>(0,Y.k1)((()=>super.addEventListener(e,t)),(()=>super.removeEventListener(e,t))),this.sendGamepadEvent=(e,t)=>{this.dispatchEvent(t),this.options.dispatchToControllerGroup&&e.dispatchEvent(t)},this.sendSessionEvent=(e,t)=>{this.dispatchEvent({type:e,controllerIndex:t})},this.addSessionListeners=()=>{R.controllers.forEach((e=>{const t=this.renderer.xr.getController(e);for(const i of this.forwardedEvents)t.addEventListener(i,(t=>this.sendSessionEvent(t.type,e)))}))},this.removeSessionListeners=()=>{R.controllers.forEach((e=>{const t=this.renderer.xr.getController(e);for(const i of this.forwardedEvents)t.removeEventListener(i,(t=>this.sendSessionEvent(t.type,e)))}))},t&&(this.options=Object.assign(Object.assign({},this.options),t)),this.renew()}}var ee=i(11642),te=i(44578),ie=i(10777),se=i(76609),ne=i(71239),oe=i(31362);var re=i(41326);const ae=(new h.Quaternion).setFromAxisAngle(d.f.UP,r.Ue*R.rotationDegrees),he=(new h.Quaternion).setFromAxisAngle(d.f.UP,r.Ue*-R.rotationDegrees);class de extends s.Y{constructor(){super(...arguments),this.name="webxr",this.framebufferScaledTo=1,this.framebufferScale=0,this.ray={forward:new h.Vector3,origin:new h.Vector3},this.onXrPresentBegin=()=>{const e=this.renderer.xr.getSession();e&&(this.log.info(`Session framebuffer: ${e.renderState.baseLayer}`),this.engine.commandBinder.issueCommand(new ie.D(!0)),this.engine.commandBinder.issueCommand(new ie.F(se.AB.HIGH)),this.viewmodeData.isInside()||this.engine.commandBinder.issueCommand(new re._i(re.BD.INSIDE)),this.xrPointer=new f(this.raycaster.picking),this.raycaster.setOverridePointer(this.xrPointer),this.xrNavVisuals.activate())},this.onXrPresentEnd=()=>{const e=null!==this.settings.tryGetProperty(ne.YS,null);this.engine.commandBinder.issueCommand(new ie.D(e)),this.engine.commandBinder.issueCommand(new ie.F(this.config.navPanoSize)),this.xrNavVisuals.deactivate(),this.raycaster.setOverridePointer(null),this.cameraModule.updateCameraRotation((0,a.Rq)(this.cameraData.pose.rotation,new h.Quaternion)),this.webglScene.setCameraDirty()},this.onXrTrackingApplied=e=>{const t=this.controllerMesh.controller();if(t.connected){const i=this.ray.forward.copy(d.f.FORWARD).applyQuaternion(t.pointer.quaternion),s=this.ray.origin.setFromMatrixPosition(t.pointer.matrixWorld);this.xrPointer.update3D(s,i,e.trackedCamera),this.xrPointerInput.dispatchPointerMove(t.index)}this.xrGamepadInput.updateFromGamepads()},this.requestSession=async(e,t)=>{var i;if(await(0,ee.pl)(this.config.xrBrowsersUnlocked)!==ee.bk.webxr)return null;if(this.renderer.xr.isPresenting)return this.renderer.xr.getSession();if(te.Z.apiExists()){const s=await(null===(i=navigator.xr)||void 0===i?void 0:i.requestSession(e,{optionalFeatures:t}));if(!s)return null;const n=XRWebGLLayer.getNativeFramebufferScaleFactor(s);return this.framebufferScaledTo=this.framebufferScale*(n-1)+1,this.log.info("Scaling framebuffer by:",this.framebufferScaledTo,"native size:",n," * factor:",this.framebufferScale),0!==this.framebufferScale&&this.renderer.xr.setFramebufferScaleFactor(this.framebufferScaledTo),this.renderer.xr.setSession(s),s}return null}}async init(e,t){this.config=e,this.engine=t;const[i,s]=await Promise.all([t.getModuleBySymbol(n.y.WEBGL_RENDERER),t.getModuleBySymbol(n.y.MESH_QUERY)]);this.renderer=i.threeRenderer,this.webglScene=i.getScene(),this.settings=await t.market.waitForData(u.e),this.bindings.push(t.commandBinder.addBinding(I.j,(e=>this.requestSession(e.type,e.features))));if(await(0,ee.pl)(e.xrBrowsersUnlocked)!==ee.bk.webxr)return;[this.canvasModule,this.cameraModule,this.raycaster]=await Promise.all([t.getModuleBySymbol(n.y.CANVAS),t.getModuleBySymbol(n.y.CAMERA),t.getModuleBySymbol(n.y.RAYCASTER)]),[this.cameraData,this.raycasterData,this.viewmodeData]=await Promise.all([t.market.waitForData(l.M),t.market.waitForData(c.P),t.market.waitForData(U.O)]),this.renderer.xr.setReferenceSpaceType("local"),this.framebufferScale=this.config.framebufferScaling||function(e){const t=(0,oe.tq)();return!t||t&&function(e){return/Adreno \(TM\) (540|[6-9]\d\d)/.test(e.renderer)}(e)?1:0}(i.gpuInfo);const r=new A(t,this.renderer,this.webglScene,this.cameraData,this.cameraModule);r.setTrackingStyle(e.tracking),this.bindings.push(r.subscribe(D,this.onXrPresentBegin),r.subscribe(S,this.onXrPresentEnd),r.subscribe(T,this.onXrTrackingApplied)),this.controllerMesh=new X(this.renderer),this.webglScene.add(this.controllerMesh.container);const a=new q(this.controllerMesh),h=e.enableEventPositions?()=>this.raycasterData.pointerScreenPosition:void 0;this.xrPointerInput=new K({forwardToElement:this.canvasModule.element,getPointerScreenPosition:h}),this.xrGamepadInput=new J(this.renderer);const d=new o.V(this.xrGamepadInput.onGamepadEvent("axestriggered",(e=>{if(e.index===E.thumbstickX||e.index===E.touchpadX){this.log.debug(`${e.inputSource.handedness} ${E[e.index]} axis.value over threshold, do the rotate!`);Math.sign(e.value)>0?r.offsetRotation(ae):r.offsetRotation(he)}a.focus(e.controllerIndex),this.controllerMesh.setDefault(e.controllerIndex)})),this.xrGamepadInput.onSessionEvent("selectstart",(e=>{this.xrPointerInput.dispatchPointerDown(e.controllerIndex),a.focus(e.controllerIndex),this.controllerMesh.setDefault(e.controllerIndex)})),this.xrGamepadInput.onSessionEvent("selectend",(e=>{this.xrPointerInput.dispatchPointerUp(e.controllerIndex),a.focus(e.controllerIndex),this.controllerMesh.setDefault(e.controllerIndex)})),this.xrGamepadInput.onSessionEvent("squeezestart",(e=>{a.focus(e.controllerIndex),this.controllerMesh.setDefault(e.controllerIndex)})));this.bindings.push(d,this.xrGamepadInput),this.xrNavVisuals=new j(s),this.xrNavVisuals.init(t),this.webglScene.add(this.xrNavVisuals.container)}}const le=de},70903:(e,t,i)=>{"use strict";i.d(t,{L:()=>s});class s{constructor(e){this.comparer=e||this.defaultComparer,this.poolArray=[]}add(e){const t=this.createObjectDescriptor(e);return t.object=e,t.inUse=!0,this.addObjectDescriptorToPool(t),t}get(e){for(const t of this.poolArray)if(!t.inUse&&this.comparer(t,e))return t.inUse=!0,t;return null}free(e){for(const t of this.poolArray)if(t.object===e)return t.inUse=!1,!0;return!1}all(){return this.poolArray}remove(e){const t=this.poolArray.findIndex((t=>t.object===e));return-1!==t&&(this.poolArray.splice(t,1),!0)}defaultComparer(e,t){return!0}createObjectDescriptor(e){return{object:e,inUse:!1}}addObjectDescriptorToPool(e){this.poolArray.push(e)}}},87928:(e,t,i)=>{"use strict";i.d(t,{E:()=>n});var s=i(81396);class n extends s.Mesh{constructor(e,t){super(e,t)}}},68512:e=>{var t={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetScans"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"modelId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ID"}}},directives:[]}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"model"},arguments:[{kind:"Argument",name:{kind:"Name",value:"id"},value:{kind:"Variable",name:{kind:"Name",value:"modelId"}}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"assets"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"scans"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"ScanDetails"},directives:[]}]}}]}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"ScanDetails"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"Scan"}},directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"index"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"name"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"created"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"alignment"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"options"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"url"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"timeOfDay"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"anchor"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]}]}},{kind:"Field",name:{kind:"Name",value:"camera"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"name"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"vendor"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"model"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"captureMode"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"depthCameraType"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"cameraTypes"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"sensorSerialNumbers"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"serialNumber"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"mountCalibrationVersion"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"softwareVersion"},arguments:[],directives:[]}]}}]}}],loc:{start:0,end:452}};t.loc.source={body:"query GetScans($modelId: ID!) {\n model(id: $modelId) {\n id\n assets {\n scans {\n ...ScanDetails\n }\n }\n }\n}\n\nfragment ScanDetails on Scan {\n id\n index\n name\n created\n alignment\n options\n url\n timeOfDay\n anchor {\n id\n }\n camera {\n id\n name\n vendor\n model\n captureMode\n depthCameraType\n cameraTypes\n sensorSerialNumbers\n serialNumber\n mountCalibrationVersion\n softwareVersion\n }\n}\n",name:"GraphQL request",locationOffset:{line:1,column:1}};function i(e,t){if("FragmentSpread"===e.kind)t.add(e.name.value);else if("VariableDefinition"===e.kind){var s=e.type;"NamedType"===s.kind&&t.add(s.name.value)}e.selectionSet&&e.selectionSet.selections.forEach((function(e){i(e,t)})),e.variableDefinitions&&e.variableDefinitions.forEach((function(e){i(e,t)})),e.definitions&&e.definitions.forEach((function(e){i(e,t)}))}var s={};function n(e,t){for(var i=0;i<e.definitions.length;i++){var s=e.definitions[i];if(s.name&&s.name.value==t)return s}}function o(e,t){var i={kind:e.kind,definitions:[n(e,t)]};e.hasOwnProperty("loc")&&(i.loc=e.loc);var o=s[t]||new Set,r=new Set,a=new Set;for(o.forEach((function(e){a.add(e)}));a.size>0;){var h=a;a=new Set,h.forEach((function(e){r.has(e)||(r.add(e),(s[e]||new Set).forEach((function(e){a.add(e)})))}))}return r.forEach((function(t){var s=n(e,t);s&&i.definitions.push(s)})),i}t.definitions.forEach((function(e){if(e.name){var t=new Set;i(e,t),s[e.name.value]=t}})),e.exports=t,e.exports.GetScans=o(t,"GetScans"),e.exports.ScanDetails=o(t,"ScanDetails")},43890:(e,t,i)=>{"use strict";e.exports=i.p+"images/outlineBasic1024.png"},75183:(e,t,i)=>{"use strict";e.exports=i.p+"images/outlineBasic2048.png"},94326:(e,t,i)=>{"use strict";e.exports=i.p+"images/outlineBasic4096.png"},95405:(e,t,i)=>{"use strict";e.exports=i.p+"images/outlineBasic512.png"},20699:(e,t,i)=>{"use strict";e.exports=i.p+"images/outlineEnhanced1024.png"},5793:(e,t,i)=>{"use strict";e.exports=i.p+"images/outlineEnhanced2048.png"},94991:(e,t,i)=>{"use strict";e.exports=i.p+"images/outlineEnhanced4096.png"},21742:(e,t,i)=>{"use strict";e.exports=i.p+"images/outlineEnhanced512.png"}}]);
|