From 644013399d7aa86cf6de8f8f70244252c91c3fc5 Mon Sep 17 00:00:00 2001 From: brentyi Date: Fri, 4 Oct 2024 18:07:53 -0700 Subject: [PATCH] Sync --- viser-embed/assets/{index-CXUjpXJZ.js => index-rvSkk8ep.js} | 2 +- viser-embed/index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename viser-embed/assets/{index-CXUjpXJZ.js => index-rvSkk8ep.js} (99%) diff --git a/viser-embed/assets/index-CXUjpXJZ.js b/viser-embed/assets/index-rvSkk8ep.js similarity index 99% rename from viser-embed/assets/index-CXUjpXJZ.js rename to viser-embed/assets/index-rvSkk8ep.js index e88d1e1..7ecb331 100644 --- a/viser-embed/assets/index-CXUjpXJZ.js +++ b/viser-embed/assets/index-rvSkk8ep.js @@ -5015,7 +5015,7 @@ Defaulting to 2020, but this will stop working in the future.`)),_e.ecmaVersion= * * This source code is licensed under the MIT license. * See the LICENSE file in the root directory of this source tree. - */var IconPlayerPlayFilled=createReactComponent("filled","player-play-filled","IconPlayerPlayFilled",[["path",{d:"M6 4v16a1 1 0 0 0 1.524 .852l13 -8a1 1 0 0 0 0 -1.704l-13 -8a1 1 0 0 0 -1.524 .852z",key:"svg-0"}]]);function FolderComponent({id:nt,props:{label:_e,visible:rt,expand_by_default:it}}){const st=reactExports.useContext(ViewerContext),[ot,{toggle:at}]=useDisclosure(it),ct=st.useGui(xt=>xt.guiIdSetFromContainerId[nt]),ft=reactExports.useContext(GuiComponentContext),pt=ct===void 0||Object.keys(ct).length===0,mt=ot?IconChevronUp:IconChevronDown;return rt?jsxRuntimeExports.jsxs(Paper,{withBorder:!0,className:folderWrapper,children:[jsxRuntimeExports.jsxs(Paper,{className:folderLabel,style:{cursor:pt?void 0:"pointer"},onClick:at,children:[_e,jsxRuntimeExports.jsx(mt,{className:folderToggleIcon,style:{display:pt?"none":void 0}})]}),jsxRuntimeExports.jsx(Collapse,{in:ot&&!pt,pt:"0.2em",children:jsxRuntimeExports.jsx(GuiComponentContext.Provider,{value:{...ft,folderDepth:ft.folderDepth+1},children:jsxRuntimeExports.jsx(ft.GuiContainer,{containerId:nt})})}),jsxRuntimeExports.jsx(Collapse,{in:!(ot&&!pt),children:jsxRuntimeExports.jsx(Box,{p:"xs"})})]}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{})}const[SliderProvider,useSliderContext]=createSafeContext("SliderProvider was not found in tree"),SliderRoot=reactExports.forwardRef(({size:nt,variant:_e,...rt},it)=>{const{getStyles:st}=useSliderContext();return jsxRuntimeExports.jsx(Box,{tabIndex:-1,variant:_e,size:nt,ref:it,...st("root"),...rt})});SliderRoot.displayName="@mantine/core/SliderRoot";const Thumb=reactExports.forwardRef(({max:nt,min:_e,value:rt,position:it,label:st,dragging:ot,draggingThisThumb:at,onMouseDown:ct,onKeyDownCapture:ft,labelTransitionProps:pt,labelAlwaysOn:mt,thumbLabel:xt,onFocus:yt,onBlur:vt,showLabelOnHover:bt,isHovered:wt,children:Tt=null,disabled:St},Rt)=>{const{getStyles:Mt}=useSliderContext(),[Pt,Dt]=reactExports.useState(!1),It=mt||ot||Pt||bt&&wt;return jsxRuntimeExports.jsxs(Box,{tabIndex:0,role:"slider","aria-label":xt,"aria-valuemax":nt,"aria-valuemin":_e,"aria-valuenow":rt,ref:Rt,__vars:{"--slider-thumb-offset":`${it}%`},...Mt("thumb",{focusable:!0,style:{...at?{zIndex:1e3}:{}}}),mod:{dragging:ot,disabled:St},onFocus:()=>{Dt(!0),typeof yt=="function"&&yt()},onBlur:()=>{Dt(!1),typeof vt=="function"&&vt()},onTouchStart:ct,onMouseDown:ct,onKeyDownCapture:ft,onClick:Nt=>Nt.stopPropagation(),children:[Tt,jsxRuntimeExports.jsx(Transition$1,{mounted:st!=null&&!!It,transition:"fade",duration:0,...pt,children:Nt=>jsxRuntimeExports.jsx("div",{...Mt("label",{style:{...Nt}}),children:st})})]})});Thumb.displayName="@mantine/core/SliderThumb";function getPosition({value:nt,min:_e,max:rt}){const it=(nt-_e)/(rt-_e)*100;return Math.min(Math.max(it,0),100)}function Marks({marks:nt,min:_e,max:rt,disabled:it,value:st,offset:ot,inverted:at}){const{getStyles:ct}=useSliderContext();if(!nt)return null;const ft=nt.map((pt,mt)=>reactExports.createElement(Box,{...ct("markWrapper"),__vars:{"--mark-offset":`${getPosition({value:pt.value,min:_e,max:rt})}%`},key:mt},jsxRuntimeExports.jsx(Box,{...ct("mark"),mod:{filled:!1,disabled:it}}),pt.label&&jsxRuntimeExports.jsx("div",{...ct("markLabel"),children:pt.label})));return jsxRuntimeExports.jsx("div",{children:ft})}Marks.displayName="@mantine/core/SliderMarks";function Track({children:nt,disabled:_e,marksOffset:rt,inverted:it,containerProps:st,...ot}){const{getStyles:at}=useSliderContext();return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(Box,{...at("trackContainer"),mod:{disabled:_e},...st,children:jsxRuntimeExports.jsxs(Box,{...at("track"),mod:{inverted:it,disabled:_e},children:[nt,jsxRuntimeExports.jsx(Marks,{...ot,offset:rt,disabled:_e,inverted:it})]})})})}Track.displayName="@mantine/core/SliderTrack";function getChangeValue({value:nt,containerWidth:_e,min:rt,max:it,step:st,precision:ot}){const ct=(_e?Math.min(Math.max(nt,0),_e)/_e:nt)*(it-rt),ft=(ct!==0?Math.round(ct/st)*st:0)+rt,pt=Math.max(ft,rt);return ot!==void 0?Number(pt.toFixed(ot)):pt}function getPrecision(nt){if(!nt)return 0;const _e=nt.toString().split(".");return _e.length>1?_e[1].length:0}const root="_root_1nr0a_1",label="_label_1nr0a_33",thumb="_thumb_1nr0a_54",trackContainer="_trackContainer_1nr0a_102",track="_track_1nr0a_102",bar="_bar_1nr0a_141",markWrapper="_markWrapper_1nr0a_167",mark="_mark_1nr0a_167",markLabel="_markLabel_1nr0a_208",classes={root,label,thumb,trackContainer,track,bar,markWrapper,mark,markLabel},defaultProps={radius:"xl",min:0,max:100,step:1,fixedEndpoints:!0,marks:[],label:nt=>nt,labelTransitionProps:{transition:"fade",duration:0},labelAlwaysOn:!1,thumbLabel:"",showLabelOnHover:!0,disabled:!1,scale:nt=>nt},varsResolver=(nt,{size:_e,color:rt,thumbSize:it,radius:st})=>({root:{"--slider-size":getSize(_e,"slider-size"),"--slider-color":rt?getThemeColor(rt,nt):void 0,"--slider-radius":st===void 0?void 0:getRadius(st),"--slider-thumb-size":it!==void 0?rem(it):"calc(var(--slider-size) * 2)"}}),MultiSlider=factory((nt,_e)=>{const rt=useProps("MultiSlider",defaultProps,nt),{classNames:it,styles:st,value:ot,onChange:at,onChangeEnd:ct,size:ft,min:pt,max:mt,step:xt,fixedEndpoints:yt,minRange:vt,precision:bt,defaultValue:wt,name:Tt,marks:St,label:Rt,labelTransitionProps:Mt,labelAlwaysOn:Pt,thumbLabel:Dt,showLabelOnHover:It,thumbChildren:Nt,disabled:$t,unstyled:Ut,scale:Ft,inverted:Vt,className:Xt,style:en,vars:nn,...rn}=rt,qt=useStyles({name:"MultiSlider",props:rt,classes,classNames:it,className:Xt,styles:st,style:en,vars:nn,varsResolver,unstyled:Ut}),{dir:Kt}=useDirection(),[Gt,tn]=reactExports.useState(!1),[jt,fn]=useUncontrolled({value:ot===void 0?ot:ot.map($n=>clamp$5($n,pt,mt)),defaultValue:wt===void 0?wt:wt.map($n=>clamp$5($n,pt,mt)),finalValue:[clamp$5(0,pt,mt)],onChange:at}),hn=reactExports.useRef(jt),Qt=reactExports.useRef(),gn=reactExports.useRef([]),pn=reactExports.useRef(-1),En=jt.map($n=>getPosition({value:$n,min:pt,max:mt})),kn=bt??getPrecision(xt);hn.current=jt;const Hn=($n,Tn,In)=>{const An=[...hn.current];An[Tn]=$n;const Vn=vt||xt;TnAn[Tn+1]-(Vn-1e-9)&&(An[Tn]=Math.max(pt,An[Tn+1]-Vn)),$n>(mt-(Vn-1e-9)||pt)&&(An[Tn]=hn.current[Tn])),Tn>0&&$n{if(!$t){const Tn=getChangeValue({value:$n,min:pt,max:mt,step:xt,precision:kn});Hn(Tn,pn.current,!1)}},[$t,pt,mt,xt,kn,fn]),{ref:Zn,active:Wn}=useMove(Xn,{onScrubEnd:()=>ct?.(hn.current)},Kt);function sn($n){return"TouchEvent"in window&&$n instanceof window.TouchEvent?$n.touches[0].clientX:$n.clientX}const Ln=$n=>{Zn.current.focus();const Tn=Zn.current.getBoundingClientRect(),In=sn($n.nativeEvent),An=getChangeValue({value:In-Tn.left,max:mt,min:pt,step:xt,containerWidth:Tn.width}),Vn=jt.map(ln=>Math.abs(ln-An)).indexOf(Math.min(...jt.map(ln=>Math.abs(ln-An))));pn.current=Vn},Bn=$n=>{if(!$t){const Tn=pn.current;switch($n.key){case"ArrowUp":{$n.preventDefault(),gn.current[Tn].focus(),Hn(Math.min(Math.max(hn.current[Tn]+xt,pt),mt),Tn,!0);break}case"ArrowRight":{$n.preventDefault(),gn.current[Tn]?.focus(),Hn(Math.min(Math.max(Kt==="rtl"?hn.current[Tn]-xt:hn.current[Tn]+xt,pt),mt),Tn,!0);break}case"ArrowDown":{$n.preventDefault(),gn.current[Tn]?.focus(),Hn(Math.min(Math.max(hn.current[Tn]-xt,pt),mt),Tn,!0);break}case"ArrowLeft":{$n.preventDefault(),gn.current[Tn]?.focus(),Hn(Math.min(Math.max(Kt==="rtl"?hn.current[Tn]+xt:hn.current[Tn]-xt,pt),mt),Tn,!0);break}case"Home":{$n.preventDefault(),gn.current[Tn]?.focus(),Hn(pt,Tn,!0);break}case"End":{$n.preventDefault(),gn.current[Tn]?.focus(),Hn(mt,Tn,!0);break}}}};return jsxRuntimeExports.jsx(SliderProvider,{value:{getStyles:qt},children:jsxRuntimeExports.jsxs(SliderRoot,{...rn,ref:useMergedRef(_e,Qt),onKeyDownCapture:Bn,onMouseDownCapture:()=>Qt.current?.focus(),size:ft,disabled:$t,children:[jsxRuntimeExports.jsx(Track,{inverted:Vt,offset:0,filled:0,value:0,marks:St,min:pt,max:mt,disabled:$t,containerProps:{ref:Zn,onMouseEnter:It?()=>tn(!0):void 0,onMouseLeave:It?()=>tn(!1):void 0,onTouchStartCapture:Ln,onTouchEndCapture:()=>{pn.current=-1},onMouseDownCapture:Ln,onMouseUpCapture:()=>{pn.current=-1}},children:jt.map(($n,Tn)=>jsxRuntimeExports.jsx(Thumb,{max:mt,min:pt,value:Ft($n),position:En[Tn],dragging:Wn,draggingThisThumb:Wn&&pn.current===Tn,label:typeof Rt=="function"?Rt(Ft($n)):Rt,ref:In=>{gn.current[Tn]=In},labelTransitionProps:Mt,labelAlwaysOn:Pt,thumbLabel:Dt,showLabelOnHover:It,isHovered:Gt,disabled:$t,children:Nt},Tn))}),jt.map(($n,Tn)=>jsxRuntimeExports.jsx("input",{type:"hidden",name:`${Tt}[]`,value:$n},Tn))]})})});MultiSlider.classes=classes;MultiSlider.displayName="MultiSlider";function MultiSliderComponent({id:nt,value:_e,props:{label:rt,hint:it,visible:st,disabled:ot,min:at,max:ct,precision:ft,step:pt,_marks:mt,fixed_endpoints:xt,min_range:yt}}){const{setValue:vt}=React.useContext(GuiComponentContext);if(!st)return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{});const bt=St=>vt(nt,St),wt=useMantineColorScheme().colorScheme,Tt=jsxRuntimeExports.jsx(Box,{mt:"0.2em",mb:"0.4em",children:jsxRuntimeExports.jsx(MultiSlider,{id:nt,className:mt===null?sliderDefaultMarks:void 0,size:"xs",radius:"xs",styles:St=>({thumb:{height:"0.75rem",width:"0.5rem"},trackContainer:{zIndex:3,position:"relative"},markLabel:{transform:"translate(-50%, 0.03rem)",fontSize:"0.6rem",textAlign:"center"},mark:{transform:"scale(1.85)"},markFilled:{background:ot?wt==="dark"?St.colors.dark[3]:St.colors.gray[4]:St.primaryColor}}),pt:"0.2em",pb:"0.4em",min:at,max:ct,step:pt??void 0,fixedEndpoints:xt,precision:ft,minRange:yt??void 0,marks:mt===null?[{value:at,label:`${parseInt(at.toFixed(6))}`},{value:ct,label:`${parseInt(ct.toFixed(6))}`}]:mt,value:_e,onChange:bt})});return jsxRuntimeExports.jsx(ViserInputComponent,{id:nt,hint:it,label:rt,children:Tt})}function UploadButtonComponent({id:nt,props:{disabled:_e,mime_type:rt,color:it,_icon_html:st,label:ot}}){const at=reactExports.useContext(ViewerContext),ct=React.useRef(null),{isUploading:ft,upload:pt}=useFileUpload({viewer:at,componentId:nt});return jsxRuntimeExports.jsxs(Box,{mx:"xs",mb:"0.5em",children:[jsxRuntimeExports.jsx("input",{type:"file",style:{display:"none"},id:`file_upload_${nt}`,name:"file",accept:rt,ref:ct,onChange:mt=>{const xt=mt.target;xt.files&&pt(xt.files[0])}}),jsxRuntimeExports.jsx(Button,{id:nt,fullWidth:!0,color:it??void 0,onClick:()=>{ct.current!==null&&(ct.current.value=ct.current.defaultValue,ct.current.click())},style:{height:"2.125em"},disabled:_e||ft,size:"sm",leftSection:st===null?void 0:jsxRuntimeExports.jsx("div",{className:htmlIconWrapper,dangerouslySetInnerHTML:{__html:st}}),children:ot})]})}function useFileUpload({viewer:nt,componentId:_e}){const rt=nt.useGui(ft=>ft.updateUploadState),it=nt.useGui(ft=>ft.uploadsInProgress[_e]),st=it?.totalBytes,ot=React.useMemo(()=>{if(st===void 0)return"";let ft=st;const pt=["B","K","M","G","T","P"];let mt=0;for(;ft>=100&&mt{if(it===void 0)return;const{notificationId:ft,filename:pt}=it;if(it.uploadedBytes===0)notifications.show({id:ft,title:`Uploading ${pt} (${ot})`,message:jsxRuntimeExports.jsx(Progress,{size:"sm",value:0}),autoClose:!1,withCloseButton:!1,loading:!0});else{const mt=it.uploadedBytes/it.totalBytes,xt=mt===1;notifications.update({id:ft,title:`Uploading ${pt} (${ot})`,message:xt?"File uploaded successfully.":jsxRuntimeExports.jsx(Progress,{size:"sm",transitionDuration:10,value:100*mt}),autoClose:xt,withCloseButton:xt,loading:!xt,icon:xt?jsxRuntimeExports.jsx(IconCheck,{}):void 0})}},[it,ot]);const at=it!==void 0&&it.uploadedBytesot.updateGuiProps),it=useThrottledMessageSender(50);function st(ot,at){rt(ot,{value:at}),it({type:"GuiUpdateMessage",id:ot,updates:{value:at}})}return jsxRuntimeExports.jsx(GuiComponentContext.Provider,{value:{folderDepth:0,GuiContainer,messageSender:it,setValue:st},children:jsxRuntimeExports.jsx(GuiContainer,{containerId:nt})})}function GuiContainer({containerId:nt}){const _e=React.useContext(ViewerContext),rt=_e.useGui(ct=>ct.guiIdSetFromContainerId[nt])??{},it=[...Object.keys(rt)],st=_e.useGui(ct=>ct.guiOrderFromId);if(rt===void 0)return null;let ot=it.map(ct=>({id:ct,order:st[ct]}));return ot=ot.sort((ct,ft)=>ct.order-ft.order),jsxRuntimeExports.jsx(Box,{pt:"xs",children:ot.map(ct=>jsxRuntimeExports.jsx(GeneratedInput,{guiId:ct.id},ct.id))})}function GeneratedInput(nt){const rt=React.useContext(ViewerContext).useGui(it=>it.guiConfigFromId[nt.guiId]);switch(rt.type){case"GuiFolderMessage":return jsxRuntimeExports.jsx(FolderComponent,{...rt});case"GuiTabGroupMessage":return jsxRuntimeExports.jsx(TabGroupComponent,{...rt});case"GuiMarkdownMessage":return jsxRuntimeExports.jsx(MarkdownComponent,{...rt});case"GuiPlotlyMessage":return jsxRuntimeExports.jsx(PlotlyComponent,{...rt});case"GuiButtonMessage":return jsxRuntimeExports.jsx(ButtonComponent,{...rt});case"GuiUploadButtonMessage":return jsxRuntimeExports.jsx(UploadButtonComponent,{...rt});case"GuiSliderMessage":return jsxRuntimeExports.jsx(SliderComponent,{...rt});case"GuiMultiSliderMessage":return jsxRuntimeExports.jsx(MultiSliderComponent,{...rt});case"GuiNumberMessage":return jsxRuntimeExports.jsx(NumberInputComponent,{...rt});case"GuiTextMessage":return jsxRuntimeExports.jsx(TextInputComponent,{...rt});case"GuiCheckboxMessage":return jsxRuntimeExports.jsx(CheckboxComponent,{...rt});case"GuiVector2Message":return jsxRuntimeExports.jsx(Vector2Component,{...rt});case"GuiVector3Message":return jsxRuntimeExports.jsx(Vector3Component,{...rt});case"GuiDropdownMessage":return jsxRuntimeExports.jsx(DropdownComponent,{...rt});case"GuiRgbMessage":return jsxRuntimeExports.jsx(RgbComponent,{...rt});case"GuiRgbaMessage":return jsxRuntimeExports.jsx(RgbaComponent,{...rt});case"GuiButtonGroupMessage":return jsxRuntimeExports.jsx(ButtonGroupComponent,{...rt});case"GuiProgressBarMessage":return jsxRuntimeExports.jsx(ProgressBarComponent,{...rt});default:assertNeverType(rt)}}function assertNeverType(nt){throw new Error("Unexpected object: "+nt.type)}function rgbToInt(nt){return nt[0]<<16|nt[1]<<8|nt[2]}function SceneNodeThreeChildren(nt){const _e=React.useContext(ViewerContext),[rt,it]=React.useState(_e.useSceneTree.getState().nodeFromName[nt.name]?.children??[]);return React.useEffect(()=>{let st=!1;return _e.useSceneTree.subscribe(ot=>{if(st)return;const at=ot.nodeFromName[nt.name]?.children;at===void 0||at===rt||at.length===0&&rt.length==0||(st=!0,setTimeout(()=>{st=!1;const ct=_e.useSceneTree.getState().nodeFromName[nt.name].children;it(ct)},at.length<=16?10:at.length<=128?50:200))})},[]),createPortal(jsxRuntimeExports.jsxs("group",{children:[rt&&rt.map(st=>jsxRuntimeExports.jsx(SceneNodeThreeObject,{name:st,parent:nt.parent},st)),jsxRuntimeExports.jsx(SceneNodeLabel,{name:nt.name})]}),nt.parent)}function SceneNodeLabel(nt){return React.useContext(ViewerContext).useSceneTree(it=>it.labelVisibleFromName[nt.name])?jsxRuntimeExports.jsx(Html,{children:jsxRuntimeExports.jsx("span",{style:{backgroundColor:"rgba(240, 240, 240, 0.9)",borderRadius:"0.2rem",userSelect:"none",padding:"0.1em 0.2em"},children:nt.name})}):null}function useObjectFactory(nt){const _e=React.useContext(ViewerContext),rt=useContextBridge();if(nt===void 0)return{makeObject:()=>null};switch(nt.type){case"FrameMessage":return{makeObject:it=>jsxRuntimeExports.jsx(CoordinateFrame,{ref:it,showAxes:nt.props.show_axes,axesLength:nt.props.axes_length,axesRadius:nt.props.axes_radius,originRadius:nt.props.origin_radius})};case"BatchedAxesMessage":return{makeObject:it=>jsxRuntimeExports.jsx(InstancedAxes,{ref:it,wxyzsBatched:new Float32Array(nt.props.wxyzs_batched.buffer.slice(nt.props.wxyzs_batched.byteOffset,nt.props.wxyzs_batched.byteOffset+nt.props.wxyzs_batched.byteLength)),positionsBatched:new Float32Array(nt.props.positions_batched.buffer.slice(nt.props.positions_batched.byteOffset,nt.props.positions_batched.byteOffset+nt.props.positions_batched.byteLength)),axes_length:nt.props.axes_length,axes_radius:nt.props.axes_radius}),computeClickInstanceIndexFromInstanceId:it=>Math.floor(it/3)};case"GridMessage":return{makeObject:it=>jsxRuntimeExports.jsx("group",{ref:it,children:jsxRuntimeExports.jsx(Grid,{args:[nt.props.width,nt.props.height,nt.props.width_segments,nt.props.height_segments],side:DoubleSide,cellColor:rgbToInt(nt.props.cell_color),cellThickness:nt.props.cell_thickness,cellSize:nt.props.cell_size,sectionColor:rgbToInt(nt.props.section_color),sectionThickness:nt.props.section_thickness,sectionSize:nt.props.section_size,rotation:nt.props.plane=="xz"?new Euler(0,0,0):nt.props.plane=="xy"?new Euler(Math.PI/2,0,0):nt.props.plane=="yx"?new Euler(0,Math.PI/2,Math.PI/2):nt.props.plane=="yz"?new Euler(0,0,Math.PI/2):nt.props.plane=="zx"?new Euler(0,Math.PI/2,0):nt.props.plane=="zy"?new Euler(-Math.PI/2,0,-Math.PI/2):void 0})})};case"PointCloudMessage":return{makeObject:it=>jsxRuntimeExports.jsx(PointCloud,{ref:it,pointSize:nt.props.point_size,pointBallNorm:nt.props.point_ball_norm,points:new Float32Array(nt.props.points.buffer.slice(nt.props.points.byteOffset,nt.props.points.byteOffset+nt.props.points.byteLength)),colors:new Uint8Array(nt.props.colors)})};case"SkinnedMeshMessage":case"MeshMessage":return{makeObject:it=>jsxRuntimeExports.jsx(ViserMesh,{ref:it,...nt})};case"CameraFrustumMessage":return{makeObject:it=>jsxRuntimeExports.jsx(CameraFrustum,{ref:it,fov:nt.props.fov,aspect:nt.props.aspect,scale:nt.props.scale,color:rgbToInt(nt.props.color),imageBinary:nt.props.image_binary,imageMediaType:nt.props.image_media_type})};case"TransformControlsMessage":{const it=nt.name,st=makeThrottledMessageSender(_e,50);return{makeObject:ot=>jsxRuntimeExports.jsx("group",{onClick:at=>at.stopPropagation(),children:jsxRuntimeExports.jsx(PivotControls,{ref:ot,scale:nt.props.scale,lineWidth:nt.props.line_width,fixed:nt.props.fixed,autoTransform:nt.props.auto_transform,activeAxes:nt.props.active_axes,disableAxes:nt.props.disable_axes,disableSliders:nt.props.disable_sliders,disableRotations:nt.props.disable_rotations,disableScaling:!0,translationLimits:nt.props.translation_limits,rotationLimits:nt.props.rotation_limits,depthTest:nt.props.depth_test,opacity:nt.props.opacity,onDrag:at=>{const ct=_e.nodeAttributesFromName.current;ct[nt.name]===void 0&&(ct[nt.name]={});const ft=new Quaternion;ft.setFromRotationMatrix(at);const pt=new Vector3().setFromMatrixPosition(at),mt=ct[nt.name];mt.wxyz=[ft.w,ft.x,ft.y,ft.z],mt.position=pt.toArray(),st({type:"TransformControlsUpdateMessage",name:it,wxyz:mt.wxyz,position:mt.position})}})}),unmountWhenInvisible:!0}}case"LabelMessage":return{makeObject:it=>jsxRuntimeExports.jsx("group",{ref:it,children:jsxRuntimeExports.jsx(Html,{children:jsxRuntimeExports.jsx("div",{style:{width:"10em",fontSize:"0.8em",transform:"translateX(0.1em) translateY(0.5em)"},children:jsxRuntimeExports.jsx("span",{style:{background:"#fff",border:"1px solid #777",borderRadius:"0.2em",color:"#333",padding:"0.2em"},children:nt.props.text})})})}),unmountWhenInvisible:!0};case"Gui3DMessage":return{makeObject:it=>jsxRuntimeExports.jsx("group",{ref:it,position:new Vector3(1e8,1e8,1e8),children:jsxRuntimeExports.jsx(Html,{children:jsxRuntimeExports.jsx(rt,{children:jsxRuntimeExports.jsx(Paper,{style:{width:"18em",fontSize:"0.875em",marginLeft:"0.5em",marginTop:"0.5em"},shadow:"0 0 0.8em 0 rgba(0,0,0,0.1)",pb:"0.25em",onPointerDown:st=>{st.stopPropagation()},children:jsxRuntimeExports.jsx(GeneratedGuiContainer,{containerId:nt.props.container_id})})})})}),unmountWhenInvisible:!0};case"ImageMessage":return{makeObject:it=>jsxRuntimeExports.jsx(ViserImage,{ref:it,...nt})};case"GlbMessage":return{makeObject:it=>jsxRuntimeExports.jsx(GlbAsset,{ref:it,glb_data:new Uint8Array(nt.props.glb_data),scale:nt.props.scale})};case"CatmullRomSplineMessage":return{makeObject:it=>jsxRuntimeExports.jsx("group",{ref:it,children:jsxRuntimeExports.jsx(CatmullRomLine,{points:nt.props.positions,closed:nt.props.closed,curveType:nt.props.curve_type,tension:nt.props.tension,lineWidth:nt.props.line_width,color:rgbToInt(nt.props.color),segments:nt.props.segments??void 0})})};case"CubicBezierSplineMessage":return{makeObject:it=>jsxRuntimeExports.jsx("group",{ref:it,children:[...Array(nt.props.positions.length-1).keys()].map(st=>jsxRuntimeExports.jsx(CubicBezierLine,{start:nt.props.positions[st],end:nt.props.positions[st+1],midA:nt.props.control_points[2*st],midB:nt.props.control_points[2*st+1],lineWidth:nt.props.line_width,color:rgbToInt(nt.props.color),segments:nt.props.segments??void 0},st))})};case"GaussianSplatsMessage":return{makeObject:it=>jsxRuntimeExports.jsx(SplatObject,{ref:it,buffer:new Uint32Array(nt.props.buffer.buffer.slice(nt.props.buffer.byteOffset,nt.props.buffer.byteOffset+nt.props.buffer.byteLength))})};case"DirectionalLightMessage":return{makeObject:it=>jsxRuntimeExports.jsx("directionalLight",{ref:it,intensity:nt.props.intensity,color:rgbToInt(nt.props.color)})};case"AmbientLightMessage":return{makeObject:it=>jsxRuntimeExports.jsx("ambientLight",{ref:it,intensity:nt.props.intensity,color:rgbToInt(nt.props.color)})};case"HemisphereLightMessage":return{makeObject:it=>jsxRuntimeExports.jsx("hemisphereLight",{ref:it,intensity:nt.props.intensity,color:rgbToInt(nt.props.sky_color),groundColor:rgbToInt(nt.props.ground_color)})};case"PointLightMessage":return{makeObject:it=>jsxRuntimeExports.jsx("pointLight",{ref:it,intensity:nt.props.intensity,color:rgbToInt(nt.props.color),distance:nt.props.distance,decay:nt.props.decay})};case"RectAreaLightMessage":return{makeObject:it=>jsxRuntimeExports.jsx("rectAreaLight",{ref:it,intensity:nt.props.intensity,color:rgbToInt(nt.props.color),width:nt.props.width,height:nt.props.height})};case"SpotLightMessage":return{makeObject:it=>jsxRuntimeExports.jsx("spotLight",{ref:it,intensity:nt.props.intensity,color:rgbToInt(nt.props.color),distance:nt.props.distance,angle:nt.props.angle,penumbra:nt.props.penumbra,decay:nt.props.decay})};default:return console.log("Received message did not match any known types:",nt),{makeObject:()=>null}}}function SceneNodeThreeObject(nt){const _e=React.useContext(ViewerContext),rt=_e.useSceneTree(Mt=>Mt.nodeFromName[nt.name]?.message),{makeObject:it,unmountWhenInvisible:st,computeClickInstanceIndexFromInstanceId:ot}=useObjectFactory(rt),[at,ct]=React.useState(!1),ft=_e.useSceneTree(Mt=>Mt.nodeFromName[nt.name]?.clickable)??!1,[pt,mt]=React.useState(null);React.useEffect(()=>{pt!==null&&(_e.nodeRefFromName.current[nt.name]=pt)},[pt]);const xt=React.useMemo(()=>{if(it===void 0)return null;const Mt=_e.nodeAttributesFromName.current;return nt.name in Mt||(Mt[nt.name]={}),Mt[nt.name].poseUpdateState="needsUpdate",it(mt)},[it]),yt=pt===null?null:jsxRuntimeExports.jsx(SceneNodeThreeChildren,{name:nt.name,parent:pt});function vt(){const Mt=_e.nodeAttributesFromName.current[nt.name];if(((Mt?.overrideVisibility===void 0?Mt?.visibility:Mt.overrideVisibility)??!0)===!1)return!1;if(nt.parent===null)return!0;let Dt=nt.parent.visible;return Dt&&nt.parent.traverseAncestors(It=>{Dt=Dt&&It.visible}),Dt}React.useEffect(()=>{const Mt=_e.nodeAttributesFromName.current[nt.name];Mt!==void 0&&(Mt.poseUpdateState="needsUpdate")}),useFrame(()=>{const Mt=_e.nodeAttributesFromName.current[nt.name];if(st){const Dt=vt();Dt&&at&&(pt!==null&&(pt.visible=!1),ct(!1)),!Dt&&!at&&ct(!0)}if(pt===null||Mt===void 0)return;const Pt=(Mt?.overrideVisibility===void 0?Mt?.visibility:Mt.overrideVisibility)??!0;if(pt.visible=Pt,Mt.poseUpdateState=="needsUpdate"){Mt.poseUpdateState="updated";const Dt=Mt.wxyz;Dt!==void 0&&pt.quaternion.set(Dt[1],Dt[2],Dt[3],Dt[0]);const It=Mt.position;It!==void 0&&pt.position.set(It[0],It[1],It[2]),pt.matrixAutoUpdate||pt.updateMatrix(),pt.matrixWorldAutoUpdate||pt.updateMatrixWorld()}},-1e4);const bt=useThrottledMessageSender(50),[wt,Tt]=React.useState(!1);useCursor(wt);const St=React.useRef(!1);!ft&&wt&&Tt(!1);const Rt=React.useRef({dragging:!1,startClientX:0,startClientY:0});return xt===void 0||at?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:yt}):ft?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs(ErrorBoundary,{fallbackRender:()=>(console.error("There was an error rendering a scene node object:",xt),null),children:[jsxRuntimeExports.jsx("group",{onPointerDown:Mt=>{if(!vt())return;Mt.stopPropagation();const Pt=Rt.current,Dt=_e.canvasRef.current.getBoundingClientRect();Pt.startClientX=Mt.clientX-Dt.left,Pt.startClientY=Mt.clientY-Dt.top,Pt.dragging=!1},onPointerMove:Mt=>{if(!vt())return;Mt.stopPropagation();const Pt=Rt.current,Dt=_e.canvasRef.current.getBoundingClientRect(),It=Mt.clientX-Dt.left-Pt.startClientX,Nt=Mt.clientY-Dt.top-Pt.startClientY;Math.abs(It)<=3&&Math.abs(Nt)<=3||(Pt.dragging=!0)},onPointerUp:Mt=>{if(!vt()||(Mt.stopPropagation(),Rt.current.dragging))return;const Dt=rayToViserCoords(_e,Mt.ray),It=_e.canvasRef.current.getBoundingClientRect(),Nt=opencvXyFromPointerXy(_e,[Mt.clientX-It.left,Mt.clientY-It.top]);bt({type:"SceneNodeClickMessage",name:nt.name,instance_index:ot===void 0?null:ot(Mt.instanceId),ray_origin:[Dt.origin.x,Dt.origin.y,Dt.origin.z],ray_direction:[Dt.direction.x,Dt.direction.y,Dt.direction.z],screen_pos:[Nt.x,Nt.y]})},onPointerOver:Mt=>{vt()&&(Mt.stopPropagation(),Tt(!0),St.current=!0)},onPointerOut:()=>{vt()&&(Tt(!1),St.current=!1)},children:jsxRuntimeExports.jsx(HoverableContext.Provider,{value:St,children:xt})}),yt]})}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("group",{children:xt}),yt]})}var lib={},ErrorCorrectLevel={L:1,M:0,Q:3,H:2},mode$1={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},mode=mode$1;function QR8bitByte(nt){this.mode=mode.MODE_8BIT_BYTE,this.data=nt}QR8bitByte.prototype={getLength:function(nt){return this.data.length},write:function(nt){for(var _e=0;_e>>7-nt%8&1)==1},put:function(nt,_e){for(var rt=0;rt<_e;rt++)this.putBit((nt>>>_e-rt-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(nt){var _e=Math.floor(this.length/8);this.buffer.length<=_e&&this.buffer.push(0),nt&&(this.buffer[_e]|=128>>>this.length%8),this.length++}};var BitBuffer$1=QRBitBuffer,QRMath={glog:function(nt){if(nt<1)throw new Error("glog("+nt+")");return QRMath.LOG_TABLE[nt]},gexp:function(nt){for(;nt<0;)nt+=255;for(;nt>=256;)nt-=255;return QRMath.EXP_TABLE[nt]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)};for(var i$2=0;i$2<8;i$2++)QRMath.EXP_TABLE[i$2]=1<=0;)_e^=QRUtil.G15<=0;)_e^=QRUtil.G18<>>=1;return _e},getPatternPosition:function(nt){return QRUtil.PATTERN_POSITION_TABLE[nt-1]},getMask:function(nt,_e,rt){switch(nt){case QRMaskPattern.PATTERN000:return(_e+rt)%2==0;case QRMaskPattern.PATTERN001:return _e%2==0;case QRMaskPattern.PATTERN010:return rt%3==0;case QRMaskPattern.PATTERN011:return(_e+rt)%3==0;case QRMaskPattern.PATTERN100:return(Math.floor(_e/2)+Math.floor(rt/3))%2==0;case QRMaskPattern.PATTERN101:return _e*rt%2+_e*rt%3==0;case QRMaskPattern.PATTERN110:return(_e*rt%2+_e*rt%3)%2==0;case QRMaskPattern.PATTERN111:return(_e*rt%3+(_e+rt)%2)%2==0;default:throw new Error("bad maskPattern:"+nt)}},getErrorCorrectPolynomial:function(nt){for(var _e=new Polynomial$1([1],0),rt=0;rt5&&(rt+=3+ot-5)}for(var it=0;it<_e-1;it++)for(var st=0;st<_e-1;st++){var pt=0;nt.isDark(it,st)&&pt++,nt.isDark(it+1,st)&&pt++,nt.isDark(it,st+1)&&pt++,nt.isDark(it+1,st+1)&&pt++,(pt==0||pt==4)&&(rt+=3)}for(var it=0;it<_e;it++)for(var st=0;st<_e-6;st++)nt.isDark(it,st)&&!nt.isDark(it,st+1)&&nt.isDark(it,st+2)&&nt.isDark(it,st+3)&&nt.isDark(it,st+4)&&!nt.isDark(it,st+5)&&nt.isDark(it,st+6)&&(rt+=40);for(var st=0;st<_e;st++)for(var it=0;it<_e-6;it++)nt.isDark(it,st)&&!nt.isDark(it+1,st)&&nt.isDark(it+2,st)&&nt.isDark(it+3,st)&&nt.isDark(it+4,st)&&!nt.isDark(it+5,st)&&nt.isDark(it+6,st)&&(rt+=40);for(var mt=0,st=0;st<_e;st++)for(var it=0;it<_e;it++)nt.isDark(it,st)&&mt++;var xt=Math.abs(100*mt/_e/_e-50)/5;return rt+=xt*10,rt}},util$1=QRUtil,BitByte=_8BitByte,RSBlock=RSBlock$1,BitBuffer=BitBuffer$1,util=util$1,Polynomial=Polynomial$2;function QRCode$1(nt,_e){this.typeNumber=nt,this.errorCorrectLevel=_e,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}var proto=QRCode$1.prototype;proto.addData=function(nt){var _e=new BitByte(nt);this.dataList.push(_e),this.dataCache=null};proto.isDark=function(nt,_e){if(nt<0||this.moduleCount<=nt||_e<0||this.moduleCount<=_e)throw new Error(nt+","+_e);return this.modules[nt][_e]};proto.getModuleCount=function(){return this.moduleCount};proto.make=function(){if(this.typeNumber<1){var nt=1;for(nt=1;nt<40;nt++){for(var _e=RSBlock.getRSBlocks(nt,this.errorCorrectLevel),rt=new BitBuffer,it=0,st=0;st<_e.length;st++)it+=_e[st].dataCount;for(var st=0;st=7&&this.setupTypeNumber(nt),this.dataCache==null&&(this.dataCache=QRCode$1.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,_e)};proto.setupPositionProbePattern=function(nt,_e){for(var rt=-1;rt<=7;rt++)if(!(nt+rt<=-1||this.moduleCount<=nt+rt))for(var it=-1;it<=7;it++)_e+it<=-1||this.moduleCount<=_e+it||(0<=rt&&rt<=6&&(it==0||it==6)||0<=it&&it<=6&&(rt==0||rt==6)||2<=rt&&rt<=4&&2<=it&&it<=4?this.modules[nt+rt][_e+it]=!0:this.modules[nt+rt][_e+it]=!1)};proto.getBestMaskPattern=function(){for(var nt=0,_e=0,rt=0;rt<8;rt++){this.makeImpl(!0,rt);var it=util.getLostPoint(this);(rt==0||nt>it)&&(nt=it,_e=rt)}return _e};proto.createMovieClip=function(nt,_e,rt){var it=nt.createEmptyMovieClip(_e,rt),st=1;this.make();for(var ot=0;ot>rt&1)==1;this.modules[Math.floor(rt/3)][rt%3+this.moduleCount-8-3]=it}for(var rt=0;rt<18;rt++){var it=!nt&&(_e>>rt&1)==1;this.modules[rt%3+this.moduleCount-8-3][Math.floor(rt/3)]=it}};proto.setupTypeInfo=function(nt,_e){for(var rt=this.errorCorrectLevel<<3|_e,it=util.getBCHTypeInfo(rt),st=0;st<15;st++){var ot=!nt&&(it>>st&1)==1;st<6?this.modules[st][8]=ot:st<8?this.modules[st+1][8]=ot:this.modules[this.moduleCount-15+st][8]=ot}for(var st=0;st<15;st++){var ot=!nt&&(it>>st&1)==1;st<8?this.modules[8][this.moduleCount-st-1]=ot:st<9?this.modules[8][15-st-1+1]=ot:this.modules[8][15-st-1]=ot}this.modules[this.moduleCount-8][8]=!nt};proto.mapData=function(nt,_e){for(var rt=-1,it=this.moduleCount-1,st=7,ot=0,at=this.moduleCount-1;at>0;at-=2)for(at==6&&at--;;){for(var ct=0;ct<2;ct++)if(this.modules[it][at-ct]==null){var ft=!1;ot>>st&1)==1);var pt=util.getMask(_e,it,at-ct);pt&&(ft=!ft),this.modules[it][at-ct]=ft,st--,st==-1&&(ot++,st=7)}if(it+=rt,it<0||this.moduleCount<=it){it-=rt,rt=-rt;break}}};QRCode$1.PAD0=236;QRCode$1.PAD1=17;QRCode$1.createData=function(nt,_e,rt){for(var it=RSBlock.getRSBlocks(nt,_e),st=new BitBuffer,ot=0;otct*8)throw new Error("code length overflow. ("+st.getLengthInBits()+">"+ct*8+")");for(st.getLengthInBits()+4<=ct*8&&st.put(0,4);st.getLengthInBits()%8!=0;)st.putBit(!1);for(;!(st.getLengthInBits()>=ct*8||(st.put(QRCode$1.PAD0,8),st.getLengthInBits()>=ct*8));)st.put(QRCode$1.PAD1,8);return QRCode$1.createBytes(st,it)};QRCode$1.createBytes=function(nt,_e){for(var rt=0,it=0,st=0,ot=new Array(_e.length),at=new Array(_e.length),ct=0;ct<_e.length;ct++){var ft=_e[ct].dataCount,pt=_e[ct].totalCount-ft;it=Math.max(it,ft),st=Math.max(st,pt),ot[ct]=new Array(ft);for(var mt=0;mt=0?vt.get(bt):0}}for(var wt=0,mt=0;mt<_e.length;mt++)wt+=_e[mt].totalCount;for(var Tt=new Array(wt),St=0,mt=0;mt=0||Object.prototype.hasOwnProperty.call(nt,it)&&(rt[it]=nt[it]);return rt}var propTypes$1={bgColor:_propTypes2$1.default.oneOfType([_propTypes2$1.default.object,_propTypes2$1.default.string]).isRequired,bgD:_propTypes2$1.default.string.isRequired,fgColor:_propTypes2$1.default.oneOfType([_propTypes2$1.default.object,_propTypes2$1.default.string]).isRequired,fgD:_propTypes2$1.default.string.isRequired,size:_propTypes2$1.default.number.isRequired,title:_propTypes2$1.default.string,viewBoxSize:_propTypes2$1.default.number.isRequired,xmlns:_propTypes2$1.default.string},QRCodeSvg=(0,_react$1.forwardRef)(function(nt,_e){var rt=nt.bgColor,it=nt.bgD,st=nt.fgD,ot=nt.fgColor,at=nt.size,ct=nt.title,ft=nt.viewBoxSize,pt=nt.xmlns,mt=pt===void 0?"http://www.w3.org/2000/svg":pt,xt=_objectWithoutProperties$1(nt,["bgColor","bgD","fgD","fgColor","size","title","viewBoxSize","xmlns"]);return _react2$1.default.createElement("svg",_extends$1({},xt,{height:at,ref:_e,viewBox:"0 0 "+ft+" "+ft,width:at,xmlns:mt}),ct?_react2$1.default.createElement("title",null,ct):null,_react2$1.default.createElement("path",{d:it,fill:rt}),_react2$1.default.createElement("path",{d:st,fill:ot}))});QRCodeSvg.displayName="QRCodeSvg";QRCodeSvg.propTypes=propTypes$1;QRCodeSvg$1.default=QRCodeSvg;Object.defineProperty(lib,"__esModule",{value:!0});lib.QRCode=void 0;var _extends=Object.assign||function(nt){for(var _e=1;_e=0||Object.prototype.hasOwnProperty.call(nt,it)&&(rt[it]=nt[it]);return rt}var propTypes={bgColor:_propTypes2.default.oneOfType([_propTypes2.default.object,_propTypes2.default.string]),fgColor:_propTypes2.default.oneOfType([_propTypes2.default.object,_propTypes2.default.string]),level:_propTypes2.default.string,size:_propTypes2.default.number,value:_propTypes2.default.string.isRequired},QRCode=(0,_react.forwardRef)(function(nt,_e){var rt=nt.bgColor,it=rt===void 0?"#FFFFFF":rt,st=nt.fgColor,ot=st===void 0?"#000000":st,at=nt.level,ct=at===void 0?"L":at,ft=nt.size,pt=ft===void 0?256:ft,mt=nt.value,xt=_objectWithoutProperties(nt,["bgColor","fgColor","level","size","value"]),yt=new _QRCode2.default(-1,_ErrorCorrectLevel2.default[ct]);yt.addData(mt),yt.make();var vt=yt.modules;return _react2.default.createElement(_QRCodeSvg2.default,_extends({},xt,{bgColor:it,bgD:vt.map(function(bt,wt){return bt.map(function(Tt,St){return Tt?"":"M "+St+" "+wt+" l 1 0 0 1 -1 0 Z"}).join(" ")}).join(" "),fgColor:ot,fgD:vt.map(function(bt,wt){return bt.map(function(Tt,St){return Tt?"M "+St+" "+wt+" l 1 0 0 1 -1 0 Z":""}).join(" ")}).join(" "),ref:_e,size:pt,viewBoxSize:vt.length}))});lib.QRCode=QRCode;QRCode.displayName="QRCode";QRCode.propTypes=propTypes;var _default=lib.default=QRCode,tableWrapper="z8daqr0",icon="z8daqr1",tableRow="z8daqr2";function SceneTreeTable(){const _e=React.useContext(ViewerContext).useSceneTree(rt=>rt.nodeFromName[""].children);return jsxRuntimeExports.jsx(Stack,{className:tableWrapper,style:{padding:"0.1em 0"},gap:0,children:_e.map(rt=>jsxRuntimeExports.jsx(SceneTreeTableRow,{nodeName:rt,isParentVisible:!0,indentCount:0},rt))})}const SceneTreeTableRow=React.memo(function nt(_e){const rt=React.useContext(ViewerContext),it=rt.useSceneTree(wt=>wt.nodeFromName[_e.nodeName].children),st=it.length>0,[ot,{toggle:at}]=useDisclosure(!1);function ct(wt,Tt){const St=rt.nodeAttributesFromName.current;St[wt].overrideVisibility=Tt,mt()}const ft=rt.useSceneTree(wt=>wt.setLabelVisibility),[,pt]=React.useState(Date.now());function mt(){pt(Date.now())}React.useEffect(()=>{const wt=setInterval(mt,200);return()=>{clearInterval(wt)}},[]);const xt=rt.nodeAttributesFromName.current[_e.nodeName],yt=(xt?.overrideVisibility===void 0?xt?.visibility:xt.overrideVisibility)??!0,vt=yt&&_e.isParentVisible,bt=yt?IconEye:IconEyeOff;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs(Box,{className:tableRow,style:{cursor:st?"pointer":void 0,marginLeft:(_e.indentCount*.75).toString()+"em"},onClick:st?at:void 0,onMouseOver:()=>ft(_e.nodeName,!0),onMouseOut:()=>ft(_e.nodeName,!1),children:[jsxRuntimeExports.jsx(Box,{style:{opacity:st?1:.3},children:ot?jsxRuntimeExports.jsx(IconCaretDown,{className:icon}):jsxRuntimeExports.jsx(IconCaretRight,{className:icon})}),jsxRuntimeExports.jsx(Tooltip,{label:"Override visibility",children:jsxRuntimeExports.jsx(bt,{style:{cursor:"pointer",opacity:vt?.85:.25},onClick:wt=>{wt.stopPropagation(),ct(_e.nodeName,!yt)}})}),jsxRuntimeExports.jsx(Box,{children:_e.nodeName.split("/").filter(wt=>wt.length>0).map((wt,Tt,St)=>jsxRuntimeExports.jsxs("span",{style:{userSelect:"none"},children:[jsxRuntimeExports.jsx("span",{style:{opacity:"0.3"},children:Tt===St.length-1?"/":`/${wt}`}),Tt===St.length-1?wt:""]},Tt))})]}),ot?it.map(wt=>jsxRuntimeExports.jsx(nt,{nodeName:wt,isParentVisible:vt,indentCount:_e.indentCount+1},wt)):null]})});function ServerControls(){const nt=React.useContext(ViewerContext),[_e,rt]=React.useState(!1);function it(ot){ot.key==="Enter"&&(ot.currentTarget.blur(),ot.currentTarget.focus())}const st=React.memo(SceneTreeTable);return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[_e?jsxRuntimeExports.jsx(Stats,{className:"stats-panel"}):null,jsxRuntimeExports.jsxs(Stack,{gap:"xs",children:[jsxRuntimeExports.jsx(TextInput,{label:"Server",defaultValue:nt.useGui(ot=>ot.server),onBlur:ot=>nt.useGui.setState({server:ot.currentTarget.value}),onKeyDown:it,styles:{input:{minHeight:"1.75rem",height:"1.75rem",padding:"0 0.5em"}}}),jsxRuntimeExports.jsx(TextInput,{label:"Label",defaultValue:nt.useGui(ot=>ot.label),onBlur:ot=>nt.useGui.setState({label:ot.currentTarget.value}),onKeyDown:it,styles:{input:{minHeight:"1.75rem",height:"1.75rem",padding:"0 0.5em"}},mb:"0.375em"}),jsxRuntimeExports.jsx(Button,{onClick:async()=>{if("showSaveFilePicker"in window&&(()=>{try{return window.self===window.top}catch{return!1}})()){const at=window.showSaveFilePicker({suggestedName:"render.png",types:[{accept:{"image/png":[".png"]}}]});nt.canvasRef.current?.toBlob(async ct=>{if(ct===null){console.error("Export failed");return}const pt=await(await at).createWritable();await pt.write(ct),await pt.close()})}else nt.canvasRef.current?.toBlob(at=>{if(at===null){console.error("Export failed");return}const ct=URL.createObjectURL(at),ft=document.createElement("a");ft.href=ct;const pt="render.png";ft.download=pt,document.body.appendChild(ft),ft.click(),document.body.removeChild(ft),URL.revokeObjectURL(ct)})},fullWidth:!0,leftSection:jsxRuntimeExports.jsx(IconPhoto,{size:"1rem"}),style:{height:"1.875rem"},children:"Export Canvas"}),jsxRuntimeExports.jsx(Button,{onClick:()=>{nt.resetCameraViewRef.current()},fullWidth:!0,leftSection:jsxRuntimeExports.jsx(IconHomeMove,{size:"1rem"}),style:{height:"1.875rem"},children:"Reset View"}),jsxRuntimeExports.jsx(Switch,{radius:"sm",label:"WebGL Statistics",onChange:ot=>{rt(ot.currentTarget.checked)},size:"sm"}),jsxRuntimeExports.jsx(Divider,{mt:"xs"}),jsxRuntimeExports.jsxs(Box,{children:[jsxRuntimeExports.jsx(Text,{mb:"0.2em",fw:500,children:"Scene tree"}),jsxRuntimeExports.jsx(st,{})]})]})]})}const BottomPanelContext=React.createContext(null);function BottomPanel({children:nt}){const _e=React.useRef(null),[rt,{toggle:it}]=useDisclosure(!0);return jsxRuntimeExports.jsx(BottomPanelContext.Provider,{value:{wrapperRef:_e,expanded:rt,toggleExpanded:it},children:jsxRuntimeExports.jsx(Paper,{radius:"0",style:st=>({borderTopWidth:"1px",borderTopStyle:"solid",borderColor:useMantineColorScheme().colorScheme=="dark"?st.colors.dark[4]:st.colors.gray[3],boxSizing:"border-box",width:"100%",zIndex:10,position:"fixed",bottom:0,left:0,margin:0,overflow:"scroll",minHeight:"3.5em",maxHeight:"60%",transition:"height 0.3s linear"}),ref:_e,children:nt})})}BottomPanel.Handle=function({children:_e}){const rt=React.useContext(BottomPanelContext);return jsxRuntimeExports.jsx(Box,{color:"red",style:it=>({borderBottomWidth:rt.expanded?"1px":void 0,borderBottomStyle:"solid",borderColor:useMantineColorScheme().colorScheme=="dark"?it.colors.dark[4]:it.colors.gray[3],cursor:"pointer",position:"relative",fontWeight:400,userSelect:"none",display:"flex",alignItems:"center",padding:"0 0.8em",height:"3.5em"}),onClick:()=>{rt.toggleExpanded()},children:_e})};BottomPanel.Contents=function({children:_e}){const rt=React.useContext(BottomPanelContext);return jsxRuntimeExports.jsx(Collapse,{in:rt.expanded,children:_e})};BottomPanel.HideWhenCollapsed=function({children:_e}){return React.useContext(BottomPanelContext)?.expanded??!0?_e:null};const touchEvents={move:"touchmove",end:"touchend"},mouseEvents={move:"mousemove",end:"mouseup"};function isTouchEvent(nt){return nt.type==="touchmove"}function isMouseEvent(nt){return nt.type==="mousemove"}const FloatingPanelContext=React.createContext(null);function FloatingPanel({children:nt,width:_e}){const rt=React.useRef(null),[it,{toggle:st}]=useDisclosure(!0),[ot,at]=React.useState(800),ct=React.useRef({dragging:!1,startPosX:0,startPosY:0,startClientX:0,startClientY:0}),ft=React.useRef({}),pt=(vt,bt,wt)=>Math.abs(vt+bt/2){const vt=rt.current;if(vt===null)return;const bt=vt.parentElement;if(bt===null)return;const wt=new ResizeObserver(()=>{ft.current.x===void 0&&(ft.current.x=pt(vt.offsetLeft,vt.clientWidth,bt.clientWidth)),ft.current.y===void 0&&(ft.current.y=pt(vt.offsetTop,vt.clientHeight,bt.clientHeight));const Tt=bt.clientHeight-mt*2-2.5*16;ot!==Tt&&at(Tt);let St=ft.current.x,Rt=ft.current.y;for(;St<0;)St+=bt.clientWidth;for(;Rt<0;)Rt+=bt.clientHeight;xt(St,Rt)});return wt.observe(vt),wt.observe(bt),()=>{wt.disconnect()}});const yt=vt=>{const bt=ct.current,wt=rt.current;if(!wt)return;vt.type=="touchstart"?(vt=vt,bt.startClientX=vt.touches[0].clientX,bt.startClientY=vt.touches[0].clientY):(vt=vt,bt.startClientX=vt.clientX,bt.startClientY=vt.clientY),bt.startPosX=wt.offsetLeft,bt.startPosY=wt.offsetTop;const Tt=vt.type=="touchstart"?touchEvents:mouseEvents;function St(Rt){let Mt=0,Pt=0;if(isTouchEvent(Rt)?(Rt=Rt,Mt=Rt.touches[0].clientX-bt.startClientX,Pt=Rt.touches[0].clientY-bt.startClientY):isMouseEvent(Rt)&&(Rt=Rt,Mt=Rt.clientX-bt.startClientX,Pt=Rt.clientY-bt.startClientY),Math.abs(Mt)<=3&&Math.abs(Pt)<=3)return;bt.dragging=!0;const Dt=bt.startPosX+Mt,It=bt.startPosY+Pt;[ft.current.x,ft.current.y]=xt(Dt,It)}window.addEventListener(Tt.move,St),window.addEventListener(Tt.end,()=>{vt.type=="touchstart"&&(bt.dragging=!1),window.removeEventListener(Tt.move,St)},{once:!0})};return jsxRuntimeExports.jsx(FloatingPanelContext.Provider,{value:{wrapperRef:rt,expanded:it,width:_e,maxHeight:ot,toggleExpanded:st,dragHandler:yt,dragInfo:ct},children:jsxRuntimeExports.jsx(Paper,{radius:"xs",shadow:"0.1em 0 1em 0 rgba(0,0,0,0.1)",style:{boxSizing:"border-box",width:_e,zIndex:10,position:"absolute",top:"1em",right:"1em",margin:0,"& .expandIcon":{transform:"rotate(0)"},overflow:"hidden"},ref:rt,children:nt})})}FloatingPanel.Handle=function({children:_e}){const rt=React.useContext(FloatingPanelContext);return jsxRuntimeExports.jsx(Box,{style:it=>({borderRadius:"0.2em 0.2em 0 0",lineHeight:"1.5em",cursor:"pointer",position:"relative",fontWeight:400,userSelect:"none",display:"flex",alignItems:"center",padding:"0 0.75em",height:"2.75em",borderBottomWidth:rt.expanded?"1px":0,borderBottomStyle:"solid",borderColor:useMantineColorScheme().colorScheme=="dark"?it.colors.dark[4]:it.colors.gray[3]}),onClick:()=>{const it=rt.dragInfo.current;if(it.dragging){it.dragging=!1;return}rt.toggleExpanded()},onTouchStart:it=>{rt.dragHandler(it)},onMouseDown:it=>{rt.dragHandler(it)},children:_e})};FloatingPanel.Contents=function({children:_e}){const rt=React.useContext(FloatingPanelContext);return jsxRuntimeExports.jsx(Collapse,{in:rt.expanded,children:jsxRuntimeExports.jsx(ScrollArea.Autosize,{mah:rt.maxHeight,children:jsxRuntimeExports.jsx(Box,{w:rt.width,children:_e})})})};FloatingPanel.HideWhenCollapsed=function({children:_e}){return React.useContext(FloatingPanelContext)?.expanded??!0?_e:null};const SidebarPanelContext=React.createContext(null);function SidebarPanel({children:nt,collapsible:_e,width:rt}){const[it,{toggle:st}]=useDisclosure(!1),ot=jsxRuntimeExports.jsx(Box,{style:at=>({position:"absolute",top:0,right:it?"0em":"-3em",transitionProperty:"right",transitionDuration:"0.5s",transitionDelay:"0.25s",borderBottomLeftRadius:"0.5em",backgroundColor:useMantineColorScheme().colorScheme=="dark"?at.colors.dark[5]:at.colors.gray[2],padding:"0.5em"}),children:jsxRuntimeExports.jsx(ActionIcon,{onClick:at=>{at.stopPropagation(),st()},children:jsxRuntimeExports.jsx(Tooltip,{zIndex:100,label:"Show sidebar",children:jsxRuntimeExports.jsx(IconChevronLeft,{})})})});return jsxRuntimeExports.jsxs(SidebarPanelContext.Provider,{value:{collapsible:_e,toggleCollapsed:st},children:[ot,jsxRuntimeExports.jsx(Paper,{shadow:"0 0 1em 0 rgba(0,0,0,0.1)",style:{width:it?0:rt,boxSizing:"content-box",transition:"width 0.5s 0s",zIndex:8}}),jsxRuntimeExports.jsx(Paper,{radius:0,style:{width:it?0:rt,top:0,bottom:0,right:0,position:"absolute",boxSizing:"content-box",transition:"width 0.5s 0s",zIndex:20},children:jsxRuntimeExports.jsx(Box,{style:{width:rt,height:"100%",display:"flex",flexDirection:"column"},children:nt})})]})}SidebarPanel.Handle=function({children:_e}){const{toggleCollapsed:rt,collapsible:it}=React.useContext(SidebarPanelContext),st=jsxRuntimeExports.jsx(ActionIcon,{onClick:ot=>{ot.stopPropagation(),rt()},children:jsxRuntimeExports.jsx(Tooltip,{zIndex:100,label:"Collapse sidebar",children:jsxRuntimeExports.jsx(IconChevronRight,{stroke:1.625})})});return jsxRuntimeExports.jsxs(Box,{p:"xs",style:ot=>({borderBottom:"1px solid",borderColor:useMantineColorScheme().colorScheme=="dark"?ot.colors.dark[4]:ot.colors.gray[3],lineHeight:"1.5em",fontWeight:400,position:"relative",zIndex:20,alignItems:"center",display:"flex",flexDirection:"row"}),children:[_e,it?st:null]})};SidebarPanel.Contents=function({children:_e}){return jsxRuntimeExports.jsx(ScrollArea,{style:{flexGrow:1},children:_e})};const ROOT_CONTAINER_ID="root";function ControlPanel(nt){const _e=useMantineTheme(),rt=useMediaQuery(`(max-width: ${_e.breakpoints.xs})`),it=React.useContext(ViewerContext),st=it.useGui(xt=>"root"in xt.guiIdSetFromContainerId),[ot,{toggle:at}]=useDisclosure(!1),ct=it.useGui(xt=>xt.theme.control_width),ft=ct=="small"?"16em":ct=="medium"?"20em":ct=="large"?"24em":null,pt=jsxRuntimeExports.jsx(ActionIcon,{onClick:xt=>{xt.stopPropagation(),at()},style:{display:st?void 0:"none",transform:"translateY(0.05em)"},children:jsxRuntimeExports.jsx(Tooltip,{zIndex:100,label:ot?"Return to GUI":"Connection & diagnostics",withinPortal:!0,children:ot?jsxRuntimeExports.jsx(IconArrowBack,{stroke:1.625}):jsxRuntimeExports.jsx(IconAdjustments,{stroke:1.625})})}),mt=jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(Collapse,{in:!st||ot,p:"xs",pt:"0.375em",children:jsxRuntimeExports.jsx(ServerControls,{})}),jsxRuntimeExports.jsx(Collapse,{in:st&&!ot,children:jsxRuntimeExports.jsx(GeneratedGuiContainer,{containerId:ROOT_CONTAINER_ID})})]});return rt?jsxRuntimeExports.jsxs(BottomPanel,{children:[jsxRuntimeExports.jsxs(BottomPanel.Handle,{children:[jsxRuntimeExports.jsx(ConnectionStatus,{}),jsxRuntimeExports.jsxs(BottomPanel.HideWhenCollapsed,{children:[jsxRuntimeExports.jsx(ShareButton,{}),pt]})]}),jsxRuntimeExports.jsx(BottomPanel.Contents,{children:mt})]}):nt.control_layout==="floating"?jsxRuntimeExports.jsxs(FloatingPanel,{width:ft,children:[jsxRuntimeExports.jsxs(FloatingPanel.Handle,{children:[jsxRuntimeExports.jsx(ConnectionStatus,{}),jsxRuntimeExports.jsxs(FloatingPanel.HideWhenCollapsed,{children:[jsxRuntimeExports.jsx(ShareButton,{}),pt]})]}),jsxRuntimeExports.jsx(FloatingPanel.Contents,{children:mt})]}):jsxRuntimeExports.jsxs(SidebarPanel,{width:ft,collapsible:nt.control_layout==="collapsible",children:[jsxRuntimeExports.jsxs(SidebarPanel.Handle,{children:[jsxRuntimeExports.jsx(ConnectionStatus,{}),jsxRuntimeExports.jsx(ShareButton,{}),pt]}),jsxRuntimeExports.jsx(SidebarPanel.Contents,{children:mt})]})}function ConnectionStatus(){const{useGui:nt}=React.useContext(ViewerContext),_e=nt(it=>it.websocketConnected),rt=nt(it=>it.label);return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{style:{width:"1.1em"}})," ",jsxRuntimeExports.jsx(Transition$1,{transition:"skew-down",mounted:_e,children:it=>jsxRuntimeExports.jsx(IconCloudCheck,{color:"#0b0",style:{position:"absolute",width:"1.25em",height:"1.25em",...it}})}),jsxRuntimeExports.jsx(Transition$1,{transition:"skew-down",mounted:!_e,children:it=>jsxRuntimeExports.jsx(Loader$1,{size:"xs",type:"dots",color:"red",style:{position:"absolute",...it}})}),jsxRuntimeExports.jsx(Box,{px:"xs",style:{flexGrow:1},lts:"-0.5px",pt:"0.1em",children:rt!==""?rt:_e?"Connected":"Connecting..."})]})}function ShareButton(){const nt=React.useContext(ViewerContext),_e=nt.useGui(yt=>yt.websocketConnected),rt=nt.useGui(yt=>yt.shareUrl),it=nt.useGui(yt=>yt.setShareUrl),[st,ot]=React.useState(!1),[at,{open:ct,close:ft}]=useDisclosure(!1),[pt,{toggle:mt}]=useDisclosure();if(React.useEffect(()=>{rt!==null&&ot(!1)},[rt]),React.useEffect(()=>{!_e&&at&&ft()},[_e,at]),nt.useGui(yt=>yt.theme).show_share_button===!1)return null;const xt=useMantineColorScheme().colorScheme;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(Tooltip,{zIndex:100,label:_e?"Share":"Share (needs connection)",withinPortal:!0,children:jsxRuntimeExports.jsx(ActionIcon,{onClick:yt=>{yt.stopPropagation(),ct()},style:{transform:"translateY(0.05em)"},disabled:!_e,children:jsxRuntimeExports.jsx(IconShare,{stroke:2,height:"1.125em",width:"1.125em"})})}),jsxRuntimeExports.jsxs(Modal,{title:"Share",opened:at,onClose:ft,withCloseButton:!1,zIndex:100,withinPortal:!0,onClick:yt=>yt.stopPropagation(),onMouseDown:yt=>yt.stopPropagation(),onMouseMove:yt=>yt.stopPropagation(),onMouseUp:yt=>yt.stopPropagation(),styles:{title:{fontWeight:600}},children:[rt===null?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:st?jsxRuntimeExports.jsx(Stack,{mb:"xl",children:jsxRuntimeExports.jsx(Loader$1,{size:"xl",mx:"auto",type:"dots"})}):jsxRuntimeExports.jsxs(Stack,{mb:"md",children:[jsxRuntimeExports.jsx(Text,{children:"Create a public, shareable URL to this Viser instance."}),jsxRuntimeExports.jsx(Button,{fullWidth:!0,onClick:()=>{nt.sendMessageRef.current({type:"ShareUrlRequest"}),ot(!0)},children:"Request Share URL"})]})}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(Text,{children:"Share URL is connected."}),jsxRuntimeExports.jsxs(Stack,{gap:"xs",my:"md",children:[jsxRuntimeExports.jsx(TextInput,{value:rt}),jsxRuntimeExports.jsxs(Flex,{justify:"space-between",columnGap:"0.5em",align:"center",children:[jsxRuntimeExports.jsx(CopyButton,{value:rt,children:({copied:yt,copy:vt})=>jsxRuntimeExports.jsx(Button,{style:{width:"50%"},leftSection:yt?jsxRuntimeExports.jsx(IconCheck,{height:"1.375em",width:"1.375em"}):jsxRuntimeExports.jsx(IconCopy,{height:"1.375em",width:"1.375em"}),onClick:vt,variant:yt?"outline":"filled",children:yt?"Copied!":"Copy URL"})}),jsxRuntimeExports.jsx(Button,{style:{flexGrow:1},leftSection:pt?jsxRuntimeExports.jsx(IconQrcodeOff,{}):jsxRuntimeExports.jsx(IconQrcode,{}),onClick:mt,children:"QR Code"}),jsxRuntimeExports.jsx(Tooltip,{zIndex:100,label:"Disconnect",withinPortal:!0,children:jsxRuntimeExports.jsx(Button,{color:"red",onClick:()=>{nt.sendMessageRef.current({type:"ShareUrlDisconnect"}),it(null)},children:jsxRuntimeExports.jsx(IconPlugConnectedX,{})})})]}),jsxRuntimeExports.jsx(Collapse,{in:pt,children:jsxRuntimeExports.jsx(_default,{value:rt,fgColor:xt==="dark"?"#ffffff":"#000000",bgColor:"rgba(0,0,0,0)",level:"M",style:{width:"100%",height:"auto",margin:"1em auto 0 auto"}})})]})]}),jsxRuntimeExports.jsxs(Text,{size:"xs",children:["This feature is experimental. Problems? Consider"," ",jsxRuntimeExports.jsx(Anchor,{href:"https://github.com/nerfstudio-project/viser/issues",children:"reporting on GitHub"}),"."]})]})]})}var t,e,s,i$1;(function(nt){nt.HEX="HEX",nt.RGB="RGB",nt.HSL="HSL",nt.CIELab="CIELab",nt.CMYK="CMYK"})(t||(t={})),function(nt){nt.ANALOGOUS="ANALOGOUS",nt.COMPLEMENTARY="COMPLEMENTARY",nt.SPLIT_COMPLEMENTARY="SPLIT_COMPLEMENTARY",nt.TRIADIC="TRIADIC",nt.TETRADIC="TETRADIC",nt.SQUARE="SQUARE"}(e||(e={})),function(nt){nt.ADDITIVE="ADDITIVE",nt.SUBTRACTIVE="SUBTRACTIVE"}(s||(s={})),function(nt){nt.black="#000000",nt.silver="#C0C0C0",nt.gray="#808080",nt.white="#FFFFFF",nt.maroon="#800000",nt.red="#FF0000",nt.purple="#800080",nt.fuchsia="#FF00FF",nt.green="#008000",nt.lime="#00FF00",nt.olive="#808000",nt.yellow="#FFFF00",nt.navy="#000080",nt.blue="#0000FF",nt.teal="#008080",nt.aqua="#00FFFF",nt.orange="#FFA500",nt.aliceblue="#F0F8FF",nt.antiquewhite="#FAEBD7",nt.aquamarine="#7FFFD4",nt.azure="#F0FFFF",nt.beige="#F5F5DC",nt.bisque="#FFE4C4",nt.blanchedalmond="#FFEBCD",nt.blueviolet="#8A2BE2",nt.brown="#A52A2A",nt.burlywood="#DEB887",nt.cadetblue="#5F9EA0",nt.chartreuse="#7FFF00",nt.chocolate="#D2691E",nt.coral="#FF7F50",nt.cornflowerblue="#6495ED",nt.cornsilk="#FFF8DC",nt.crimson="#DC143C",nt.cyan="#00FFFF",nt.darkblue="#00008B",nt.darkcyan="#008B8B",nt.darkgoldenrod="#B8860B",nt.darkgray="#A9A9A9",nt.darkgreen="#006400",nt.darkgrey="#A9A9A9",nt.darkkhaki="#BDB76B",nt.darkmagenta="#8B008B",nt.darkolivegreen="#556B2F",nt.darkorange="#FF8C00",nt.darkorchid="#9932CC",nt.darkred="#8B0000",nt.darksalmon="#E9967A",nt.darkseagreen="#8FBC8F",nt.darkslateblue="#483D8B",nt.darkslategray="#2F4F4F",nt.darkslategrey="#2F4F4F",nt.darkturquoise="#00CED1",nt.darkviolet="#9400D3",nt.deeppink="#FF1493",nt.deepskyblue="#00BFFF",nt.dimgray="#696969",nt.dimgrey="#696969",nt.dodgerblue="#1E90FF",nt.firebrick="#B22222",nt.floralwhite="#FFFAF0",nt.forestgreen="#228B22",nt.gainsboro="#DCDCDC",nt.ghostwhite="#F8F8FF",nt.gold="#FFD700",nt.goldenrod="#DAA520",nt.greenyellow="#ADFF2F",nt.grey="#808080",nt.honeydew="#F0FFF0",nt.hotpink="#FF69B4",nt.indianred="#CD5C5C",nt.indigo="#4B0082",nt.ivory="#FFFFF0",nt.khaki="#F0E68C",nt.lavender="#E6E6FA",nt.lavenderblush="#FFF0F5",nt.lawngreen="#7CFC00",nt.lemonchiffon="#FFFACD",nt.lightblue="#ADD8E6",nt.lightcoral="#F08080",nt.lightcyan="#E0FFFF",nt.lightgoldenrodyellow="#FAFAD2",nt.lightgray="#D3D3D3",nt.lightgreen="#90EE90",nt.lightgrey="#D3D3D3",nt.lightpink="#FFB6C1",nt.lightsalmon="#FFA07A",nt.lightseagreen="#20B2AA",nt.lightskyblue="#87CEFA",nt.lightslategray="#778899",nt.lightslategrey="#778899",nt.lightsteelblue="#B0C4DE",nt.lightyellow="#FFFFE0",nt.limegreen="#32CD32",nt.linen="#FAF0E6",nt.magenta="#FF00FF",nt.mediumaquamarine="#66CDAA",nt.mediumblue="#0000CD",nt.mediumorchid="#BA55D3",nt.mediumpurple="#9370DB",nt.mediumseagreen="#3CB371",nt.mediumslateblue="#7B68EE",nt.mediumspringgreen="#00FA9A",nt.mediumturquoise="#48D1CC",nt.mediumvioletred="#C71585",nt.midnightblue="#191970",nt.mintcream="#F5FFFA",nt.mistyrose="#FFE4E1",nt.moccasin="#FFE4B5",nt.navajowhite="#FFDEAD",nt.oldlace="#FDF5E6",nt.olivedrab="#6B8E23",nt.orangered="#FF4500",nt.orchid="#DA70D6",nt.palegoldenrod="#EEE8AA",nt.palegreen="#98FB98",nt.paleturquoise="#AFEEEE",nt.palevioletred="#DB7093",nt.papayawhip="#FFEFD5",nt.peachpuff="#FFDAB9",nt.peru="#CD853F",nt.pink="#FFC0CB",nt.plum="#DDA0DD",nt.powderblue="#B0E0E6",nt.rosybrown="#BC8F8F",nt.royalblue="#4169E1",nt.saddlebrown="#8B4513",nt.salmon="#FA8072",nt.sandybrown="#F4A460",nt.seagreen="#2E8B57",nt.seashell="#FFF5EE",nt.sienna="#A0522D",nt.skyblue="#87CEEB",nt.slateblue="#6A5ACD",nt.slategray="#708090",nt.slategrey="#708090",nt.snow="#FFFAFA",nt.springgreen="#00FF7F",nt.steelblue="#4682B4",nt.tan="#D2B48C",nt.thistle="#D8BFD8",nt.tomato="#FF6347",nt.turquoise="#40E0D0",nt.violet="#EE82EE",nt.wheat="#F5DEB3",nt.whitesmoke="#F5F5F5",nt.yellowgreen="#9ACD32",nt.rebeccapurple="#663399"}(i$1||(i$1={}));const a=Object.keys(i$1),r={HEX:["R","G","B","A"],RGB:["R","G","B","A"],HSL:["H","S","L","A"],CIELab:["L","a","b","A"],CMYK:["C","M","Y","K","A"]},n={BGR:t.RGB,ABGR:t.RGB,HLS:t.HSL,AHLS:t.HSL,LAB:t.CIELab,ALAB:t.CIELab,CKMY:t.CMYK,ACKMY:t.CMYK};var c;(function(nt){nt.NUMBER="number",nt.BOOLEAN="boolean"})(c||(c={}));const o={[t.HEX]:/^#(?:([a-f\d])([a-f\d])([a-f\d])([a-f\d])?|([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?)$/i,[t.RGB]:/^rgba?\s*\(\s*(?:((?:\d*\.)?\d+%?)\s*,\s*((?:\d*\.)?\d+%?)\s*,\s*((?:\d*\.)?\d+%?)(?:\s*,\s*((?:\d*\.)?\d+))?|((?:\d*\.)?\d+%?)\s*((?:\d*\.)?\d+%?)\s*((?:\d*\.)?\d+%?)(?:\s*\/\s*((?:\d*\.)?\d+%?))?)\s*\)$/,[t.HSL]:/^hsla?\s*\(\s*(?:(-?(?:\d*\.)?\d+(?:deg|grad|rad|turn)?)\s*,\s*((?:\d*\.)?\d+)%\s*,\s*((?:\d*\.)?\d+)%(?:\s*,\s*((?:\d*\.)?\d+))?|(-?(?:\d*\.)?\d+(?:deg|grad|rad|turn)?)\s*((?:\d*\.)?\d+)%\s*((?:\d*\.)?\d+)%(?:\s*\/\s*((?:\d*\.)?\d+%?))?)\s*\)$/,[t.CIELab]:/^lab\s*\(\s*(?:((?:\d*\.)?\d+%?)\s*(-?(?:\d*\.)?\d+%?)\s*(-?(?:\d*\.)?\d+%?)(?:\s*\/\s*((?:\d*\.)?\d+%?))?)\s*\)$/,[t.CMYK]:/^(?:device-cmyk|cmyk)\s*\(\s*(?:((?:\d*\.)?\d+%?)\s*,\s*((?:\d*\.)?\d+%?)\s*,\s*((?:\d*\.)?\d+%?)\s*,\s*((?:\d*\.)?\d+%?)(?:\s*,\s*((?:\d*\.)?\d+))?|((?:\d*\.)?\d+%?)\s*((?:\d*\.)?\d+%?)\s*((?:\d*\.)?\d+%?)\s*((?:\d*\.)?\d+%?)(?:\s*\/\s*((?:\d*\.)?\d+%?))?)\s*\)$/},A=/^(-?(?:\d*\.)?\d+)((?:deg|grad|rad|turn)?)$/,h=/^(-?\d+(?:\.\d+)?|-?\.\d+)%$/,u=/^0x([a-f\d]{1,2})$/i,d=/\{(\d+)\}/g,m="The provided string color doesn't have a correct format",b="The provided color object doesn't have the proper keys or format";var C,L,g;(function(nt){nt.NONE="none",nt.DEGREES="deg",nt.GRADIANS="grad",nt.RADIANS="rad",nt.TURNS="turn"})(C||(C={})),function(nt){nt.NONE="none",nt.PERCENT="percent"}(L||(L={})),function(nt){nt.DEVICE_CMYK="device-cmyk",nt.CMYK="cmyk"}(g||(g={}));C.NONE,L.NONE,L.NONE,L.PERCENT,L.NONE,g.DEVICE_CMYK;const p=(nt,_e)=>Object.prototype.hasOwnProperty.call(nt,_e),H=nt=>+`${nt}`.replace(h,"$1"),F=nt=>h.test(`${nt}`)?H(nt):Math.min(+nt,100),R=nt=>(nt.length===1&&(nt+=nt),parseInt(nt,16)),S=nt=>{const _e=D(nt,0).toString(16).toUpperCase();return _e.length===1?`0x0${_e}`:`0x${_e}`},I=(nt,_e=!1)=>!_e&&h.test(nt)?Math.min(255*H(nt)/100,255):u.test(nt)?(nt.length===3&&(nt+=nt.slice(-1)),_e?D(nt)/255:D(nt)):Math.min(+nt,_e?1:255),G=nt=>h.test(nt)?f(125*H(nt)/100,-125,125):f(+nt,-125,125),M=nt=>Math.min(h.test(nt)?H(nt)/100:+nt,1),y=nt=>[...nt].sort().join("").toUpperCase(),D=(nt,_e=6)=>{const rt=Math.pow(10,_e);return Math.round(+nt*rt)/rt},f=(nt,_e,rt)=>Math.max(_e,Math.min(nt,rt)),O=nt=>{if(typeof nt=="string"){const _e=nt.match(A),rt=+_e[1];switch(_e[2]){case C.RADIANS:nt=D(180*rt/Math.PI);break;case C.TURNS:nt=D(360*rt);break;case C.GRADIANS:nt=D(.9*rt);break;case C.DEGREES:default:nt=rt}}return(nt>360||nt<0)&&(nt-=360*Math.floor(nt/360)),nt},Y=(nt,_e)=>{let rt;switch(_e){case C.RADIANS:rt=D((it=>it*Math.PI/180)(nt));break;case C.TURNS:rt=D(nt/360);break;case C.GRADIANS:rt=D(10/9*nt);break;case C.DEGREES:case C.NONE:default:rt=nt}return rt},X=[[.4360747,.3850649,.1430804],[.2225045,.7168786,.0606169],[.0139322,.0971045,.7141733]],T=[[3.1338561,-1.6168667,-.4906146],[-.9787684,1.9161415,.033454],[.0719453,-.2289914,1.4052427]],N=X.map(nt=>nt.reduce((_e,rt)=>_e+rt,0)),$=(nt,_e,rt)=>(rt<0&&(rt+=6),rt>=6&&(rt-=6),D(rt<1?255*((_e-nt)*rt+nt):rt<3?255*_e:rt<4?255*((_e-nt)*(4-rt)+nt):255*nt)),j=nt=>nt<=.04045?nt/12.92:((nt+.055)/1.055)**2.4,U=nt=>nt<=.0031308?12.92*nt:1.055*nt**(1/2.4)-.055,w=(nt,_e,rt,it)=>{const st=[0,0,0],ot=[nt,_e,rt];return it.forEach((at,ct)=>{at.forEach((ft,pt)=>{st[ct]+=ft*ot[pt]})}),st},x$1=(nt,_e,rt)=>{_e/=100;const it=(rt/=100)<=.5?rt*(_e+1):rt+_e-rt*_e,st=2*rt-it;return{R:$(st,it,(nt/=60)+2),G:$(st,it,nt),B:$(st,it,nt-2)}},v=(nt,_e,rt,it=1)=>{nt/=255,_e/=255,rt/=255,it=Math.min(it,1);const st=Math.max(nt,_e,rt),ot=Math.min(nt,_e,rt),at=st-ot;let ct=0,ft=0;const pt=(st+ot)/2;if(at!==0){switch(st){case nt:ct=(_e-rt)/at%6;break;case _e:ct=(rt-nt)/at+2;break;case rt:ct=(nt-_e)/at+4}ct=D(60*ct),ct<0&&(ct+=360),ft=at/(1-Math.abs(2*pt-1))}return{H:ct,S:D(100*ft),L:D(100*pt),A:it}},V=(nt,_e,rt)=>{const it=[nt/255,_e/255,rt/255].map(j),st=w(it[0],it[1],it[2],X),ot=((at,ct,ft)=>{const pt=yt=>yt>.008856451679035631?Math.cbrt(yt):yt/.12841854934601665+.13793103448275862,mt=pt(at/N[0]),xt=pt(ct/N[1]);return[116*xt-16,500*(mt-xt),200*(xt-pt(ft/N[2]))]})(st[0],st[1],st[2]);return{L:ot[0],a:ot[1],b:ot[2]}},P=(nt,_e,rt)=>{const it=((ot,at,ct)=>{const ft=yt=>yt>.20689655172413793?yt**3:.12841854934601665*(yt-.13793103448275862),pt=(ot+16)/116,mt=at/500,xt=ct/200;return[N[0]*ft(pt+mt),N[1]*ft(pt),N[2]*ft(pt-xt)]})(nt,_e,rt),st=w(it[0],it[1],it[2],T).map(U);return{R:f(255*st[0],0,255),G:f(255*st[1],0,255),B:f(255*st[2],0,255)}},q=(nt,_e,rt,it)=>({R:D(255*(1-nt)*(it=1-it)),G:D(255*(1-_e)*it),B:D(255*(1-rt)*it)}),_=(nt,_e,rt)=>{nt/=255,_e/=255,rt/=255;const it=1-Math.max(nt,_e,rt),st=1-it,ot=st&&(st-_e)/st,at=st&&(st-rt)/st;return{C:D(100*(st&&(st-nt)/st)),M:D(100*ot),Y:D(100*at),K:D(100*it)}},Q=nt=>nt?", ":",",W=(nt,_e)=>{const rt=y(Object.keys(nt));return r[n[rt]].reduce((it,st,ot)=>{const at=nt[st];return at!==void 0&&it.push(_e(at,ot)),it},[])},J=(nt,_e)=>nt.replace(d,(rt,it)=>`${_e[+it-1]}`),Z=(nt,_e,rt=!1)=>{const{alphaUnit:it,legacyCSS:st,decimals:ot}=_e;return it!==L.PERCENT||st&&!rt?D(nt,ot):`${D(100*nt,ot)}%`},tt={[t.HEX]:nt=>{const _e=W(nt,it=>(st=>{let ot=D(st,0).toString(16).toUpperCase();return ot.length===1&&(ot=`0${ot}`),ot})(D(it))),rt=_e.length===4?"#{1}{2}{3}{4}":"#{1}{2}{3}";return J(rt,_e)},[t.RGB]:(nt,_e)=>{const{decimals:rt,legacyCSS:it,spacesAfterCommas:st,rgbUnit:ot}=_e,at=Q(st),ct=W(nt,(pt,mt)=>ot===L.PERCENT&&mt<3?`${((xt,yt)=>D(xt/255*100,yt))(pt,rt)}%`:mt===3?Z(pt,_e):D(pt,rt)),ft=it?ct.length===4?`rgba({1}${at}{2}${at}{3}${at}{4})`:`rgb({1}${at}{2}${at}{3})`:ct.length===4?"rgb({1} {2} {3} / {4})":"rgb({1} {2} {3})";return J(ft,ct)},[t.HSL]:(nt,_e)=>{const{decimals:rt,legacyCSS:it,spacesAfterCommas:st,anglesUnit:ot}=_e,at=Q(st),ct=W(nt,(pt,mt)=>mt===0&&ot!==C.NONE?`${D(Y(pt,ot),rt)}${ot}`:mt===3?Z(pt,_e):D(pt,rt)),ft=it?ct.length===4?`hsla({1}${at}{2}%${at}{3}%${at}{4})`:`hsl({1}${at}{2}%${at}{3}%)`:ct.length===4?"hsl({1} {2}% {3}% / {4})":"hsl({1} {2}% {3}%)";return J(ft,ct)},[t.CIELab]:(nt,_e)=>{const{decimals:rt,labUnit:it}=_e,st=W(nt,(at,ct)=>{if(ct===0){const ft=D(F(at),rt);return it===L.PERCENT?`${ft}%`:`${ft}`}return ct<3?it===L.PERCENT?`${((ft,pt)=>D(ft/125*100,pt))(at,rt)}%`:D(at,rt):Z(at,_e,!0)}),ot=st.length===4?"lab({1} {2} {3} / {4})":"lab({1} {2} {3})";return J(ot,st)},[t.CMYK]:(nt,_e)=>{const{decimals:rt,legacyCSS:it,spacesAfterCommas:st,cmykUnit:ot,cmykFunction:at}=_e,ct=Q(st),ft=W(nt,(mt,xt)=>ot===L.PERCENT&&xt<4?`${D(mt,rt)}%`:xt===4?Z(mt,_e):D(mt/100,rt)),pt=it?ft.length===5?`${at}({1}${ct}{2}${ct}{3}${ct}{4}${ct}{5})`:`${at}({1}${ct}{2}${ct}{3}${ct}{4})`:ft.length===5?`${at}({1} {2} {3} {4} / {5})`:`${at}({1} {2} {3} {4})`;return J(pt,ft)}},et$1=nt=>(typeof nt=="string"&&(nt=h.test(nt)?H(nt)/100:+nt),isNaN(+nt)||nt>1?1:D(nt)),At=nt=>typeof nt=="string"?(_e=>{let rt;if(Object.keys(t).some(it=>{if(o[it].test(_e))return rt=it,!0}),!rt&&~a.indexOf(_e)&&(rt=t.HEX),!rt)throw new Error(m);return rt})(nt):(_e=>{let rt,it=!1;const st=y(Object.keys(_e));if(n[st]&&(rt=n[st]),rt&&rt===t.RGB){const ot=Object.entries(_e).some(ct=>!u.test(`${ct[1]}`)),at=Object.entries(_e).some(ct=>!(h.test(`${ct[1]}`)||!u.test(`${ct[1]}`)&&!isNaN(+ct[1])&&+ct[1]<=255));ot&&at&&(it=!0),ot||(rt=t.HEX)}if(!rt||it)throw new Error(b);return rt})(nt),ht={[t.HEX](nt){const _e=(~a.indexOf(nt)?i$1[nt]:nt).match(o.HEX),rt={R:R(_e[1]||_e[5]),G:R(_e[2]||_e[6]),B:R(_e[3]||_e[7])},it=_e[4]||_e[8];return it!==void 0&&(rt.A=R(it)/255),rt},[t.RGB](nt){const _e=nt.match(o.RGB),rt=I(_e[1]||_e[5]),it=I(_e[2]||_e[6]),st=I(_e[3]||_e[7]),ot=_e[4]||_e[8],at={R:Math.min(rt,255),G:Math.min(it,255),B:Math.min(st,255)};return ot!==void 0&&(at.A=et$1(ot)),at},[t.HSL](nt){const _e=nt.match(o.HSL),rt=O(_e[1]||_e[5]),it=F(_e[2]||_e[6]),st=F(_e[3]||_e[7]),ot=_e[4]||_e[8],at=x$1(rt,it,st);return ot!==void 0&&(at.A=et$1(ot)),at},[t.CIELab](nt){const _e=nt.match(o.CIELab),rt=F(_e[1]),it=G(_e[2]),st=G(_e[3]),ot=_e[4],at=P(rt,it,st);return ot!==void 0&&(at.A=et$1(ot)),at},[t.CMYK](nt){const _e=nt.match(o.CMYK),rt=M(_e[1]||_e[6]),it=M(_e[2]||_e[7]),st=M(_e[3]||_e[8]),ot=M(_e[4]||_e[9]),at=_e[5]||_e[10],ct=q(rt,it,st,ot);return at!==void 0&&(ct.A=et$1(at)),ct}},ut={[t.HEX](nt){const _e={R:I(`${nt.R}`),G:I(`${nt.G}`),B:I(`${nt.B}`)};return p(nt,"A")&&(_e.A=Math.min(I(`${nt.A}`,!0),1)),_e},[t.RGB](nt){return this.HEX(nt)},[t.HSL](nt){const _e=F(`${nt.S}`),rt=F(`${nt.L}`),it=x$1(O(nt.H),_e,rt);return p(nt,"A")&&(it.A=et$1(nt.A)),it},[t.CIELab](nt){const _e=F(`${nt.L}`),rt=G(`${nt.a}`),it=G(`${nt.b}`),st=P(_e,rt,it);return p(nt,"A")&&(st.A=et$1(nt.A)),st},[t.CMYK](nt){const _e=M(`${nt.C}`),rt=M(`${nt.M}`),it=M(`${nt.Y}`),st=M(`${nt.K}`),ot=q(_e,rt,it,st);return p(nt,"A")&&(ot.A=et$1(nt.A)),ot}},dt=(nt,_e=At(nt))=>typeof nt=="string"?ht[_e](nt):ut[_e](nt),lt={[t.HEX]:nt=>({R:S(nt.R),G:S(nt.G),B:S(nt.B)}),HEXA(nt){const _e=lt.HEX(nt);return _e.A=p(nt,"A")?S(255*nt.A):"0xFF",_e},[t.RGB](nt,_e){const rt=Ct(nt,_e);return p(rt,"A")&&delete rt.A,rt},RGBA(nt,_e){const rt=lt.RGB(nt,_e);return rt.A=p(nt,"A")?D(nt.A):1,rt},[t.HSL](nt,_e){const rt=v(nt.R,nt.G,nt.B);return delete rt.A,Lt(rt,_e)},HSLA(nt,_e){const rt=lt.HSL(nt,_e);return rt.A=p(nt,"A")?D(nt.A,_e):1,rt},[t.CIELab](nt,_e){const rt=V(nt.R,nt.G,nt.B);return gt(rt,_e)},CIELabA(nt,_e){const rt=lt.CIELab(nt,_e);return rt.A=p(nt,"A")?D(nt.A,_e):1,rt},[t.CMYK]:(nt,_e)=>Bt(_(nt.R,nt.G,nt.B),_e),CMYKA(nt,_e){const rt=lt.CMYK(nt,_e);return rt.A=p(nt,"A")?D(nt.A,_e):1,rt}};t.HEX+"",t.RGB+"",t.HSL+"",t.CIELab+"";t.HEX+"",t.RGB+"",t.HSL+"",t.CIELab+"";const Ct=(nt,_e)=>({R:D(nt.R,_e),G:D(nt.G,_e),B:D(nt.B,_e),...p(nt,"A")?{A:D(nt.A,_e)}:{}}),Lt=(nt,_e)=>({H:D(nt.H,_e),S:D(nt.S,_e),L:D(nt.L,_e),...p(nt,"A")?{A:D(nt.A,_e)}:{}}),gt=(nt,_e)=>({L:D(nt.L,_e),a:D(nt.a,_e),b:D(nt.b,_e)}),Bt=(nt,_e)=>({C:D(nt.C,_e),M:D(nt.M,_e),Y:D(nt.Y,_e),K:D(nt.K,_e)});var NOTHING=Symbol.for("immer-nothing"),DRAFTABLE=Symbol.for("immer-draftable"),DRAFT_STATE=Symbol.for("immer-state");function die(nt,..._e){throw new Error(`[Immer] minified error nr: ${nt}. Full error at: https://bit.ly/3cXEKWf`)}var getPrototypeOf=Object.getPrototypeOf;function isDraft(nt){return!!nt&&!!nt[DRAFT_STATE]}function isDraftable(nt){return nt?isPlainObject(nt)||Array.isArray(nt)||!!nt[DRAFTABLE]||!!nt.constructor?.[DRAFTABLE]||isMap(nt)||isSet(nt):!1}var objectCtorString=Object.prototype.constructor.toString();function isPlainObject(nt){if(!nt||typeof nt!="object")return!1;const _e=getPrototypeOf(nt);if(_e===null)return!0;const rt=Object.hasOwnProperty.call(_e,"constructor")&&_e.constructor;return rt===Object?!0:typeof rt=="function"&&Function.toString.call(rt)===objectCtorString}function each(nt,_e){getArchtype(nt)===0?Reflect.ownKeys(nt).forEach(rt=>{_e(rt,nt[rt],nt)}):nt.forEach((rt,it)=>_e(it,rt,nt))}function getArchtype(nt){const _e=nt[DRAFT_STATE];return _e?_e.type_:Array.isArray(nt)?1:isMap(nt)?2:isSet(nt)?3:0}function has(nt,_e){return getArchtype(nt)===2?nt.has(_e):Object.prototype.hasOwnProperty.call(nt,_e)}function set(nt,_e,rt){const it=getArchtype(nt);it===2?nt.set(_e,rt):it===3?nt.add(rt):nt[_e]=rt}function is(nt,_e){return nt===_e?nt!==0||1/nt===1/_e:nt!==nt&&_e!==_e}function isMap(nt){return nt instanceof Map}function isSet(nt){return nt instanceof Set}function latest(nt){return nt.copy_||nt.base_}function shallowCopy(nt,_e){if(isMap(nt))return new Map(nt);if(isSet(nt))return new Set(nt);if(Array.isArray(nt))return Array.prototype.slice.call(nt);const rt=isPlainObject(nt);if(_e===!0||_e==="class_only"&&!rt){const it=Object.getOwnPropertyDescriptors(nt);delete it[DRAFT_STATE];let st=Reflect.ownKeys(it);for(let ot=0;ot1&&(nt.set=nt.add=nt.clear=nt.delete=dontMutateFrozenCollections),Object.freeze(nt),_e&&Object.entries(nt).forEach(([rt,it])=>freeze(it,!0))),nt}function dontMutateFrozenCollections(){die(2)}function isFrozen(nt){return Object.isFrozen(nt)}var plugins={};function getPlugin(nt){const _e=plugins[nt];return _e||die(0,nt),_e}function loadPlugin(nt,_e){plugins[nt]||(plugins[nt]=_e)}var currentScope;function getCurrentScope(){return currentScope}function createScope(nt,_e){return{drafts_:[],parent_:nt,immer_:_e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function usePatchesInScope(nt,_e){_e&&(getPlugin("Patches"),nt.patches_=[],nt.inversePatches_=[],nt.patchListener_=_e)}function revokeScope(nt){leaveScope(nt),nt.drafts_.forEach(revokeDraft),nt.drafts_=null}function leaveScope(nt){nt===currentScope&&(currentScope=nt.parent_)}function enterScope(nt){return currentScope=createScope(currentScope,nt)}function revokeDraft(nt){const _e=nt[DRAFT_STATE];_e.type_===0||_e.type_===1?_e.revoke_():_e.revoked_=!0}function processResult(nt,_e){_e.unfinalizedDrafts_=_e.drafts_.length;const rt=_e.drafts_[0];return nt!==void 0&&nt!==rt?(rt[DRAFT_STATE].modified_&&(revokeScope(_e),die(4)),isDraftable(nt)&&(nt=finalize(_e,nt),_e.parent_||maybeFreeze(_e,nt)),_e.patches_&&getPlugin("Patches").generateReplacementPatches_(rt[DRAFT_STATE].base_,nt,_e.patches_,_e.inversePatches_)):nt=finalize(_e,rt,[]),revokeScope(_e),_e.patches_&&_e.patchListener_(_e.patches_,_e.inversePatches_),nt!==NOTHING?nt:void 0}function finalize(nt,_e,rt){if(isFrozen(_e))return _e;const it=_e[DRAFT_STATE];if(!it)return each(_e,(st,ot)=>finalizeProperty(nt,it,_e,st,ot,rt)),_e;if(it.scope_!==nt)return _e;if(!it.modified_)return maybeFreeze(nt,it.base_,!0),it.base_;if(!it.finalized_){it.finalized_=!0,it.scope_.unfinalizedDrafts_--;const st=it.copy_;let ot=st,at=!1;it.type_===3&&(ot=new Set(st),st.clear(),at=!0),each(ot,(ct,ft)=>finalizeProperty(nt,it,st,ct,ft,rt,at)),maybeFreeze(nt,st,!1),rt&&nt.patches_&&getPlugin("Patches").generatePatches_(it,rt,nt.patches_,nt.inversePatches_)}return it.copy_}function finalizeProperty(nt,_e,rt,it,st,ot,at){if(isDraft(st)){const ct=ot&&_e&&_e.type_!==3&&!has(_e.assigned_,it)?ot.concat(it):void 0,ft=finalize(nt,st,ct);if(set(rt,it,ft),isDraft(ft))nt.canAutoFreeze_=!1;else return}else at&&rt.add(st);if(isDraftable(st)&&!isFrozen(st)){if(!nt.immer_.autoFreeze_&&nt.unfinalizedDrafts_<1)return;finalize(nt,st),(!_e||!_e.scope_.parent_)&&typeof it!="symbol"&&Object.prototype.propertyIsEnumerable.call(rt,it)&&maybeFreeze(nt,st)}}function maybeFreeze(nt,_e,rt=!1){!nt.parent_&&nt.immer_.autoFreeze_&&nt.canAutoFreeze_&&freeze(_e,rt)}function createProxyProxy(nt,_e){const rt=Array.isArray(nt),it={type_:rt?1:0,scope_:_e?_e.scope_:getCurrentScope(),modified_:!1,finalized_:!1,assigned_:{},parent_:_e,base_:nt,draft_:null,copy_:null,revoke_:null,isManual_:!1};let st=it,ot=objectTraps;rt&&(st=[it],ot=arrayTraps);const{revoke:at,proxy:ct}=Proxy.revocable(st,ot);return it.draft_=ct,it.revoke_=at,ct}var objectTraps={get(nt,_e){if(_e===DRAFT_STATE)return nt;const rt=latest(nt);if(!has(rt,_e))return readPropFromProto(nt,rt,_e);const it=rt[_e];return nt.finalized_||!isDraftable(it)?it:it===peek(nt.base_,_e)?(prepareCopy(nt),nt.copy_[_e]=createProxy(it,nt)):it},has(nt,_e){return _e in latest(nt)},ownKeys(nt){return Reflect.ownKeys(latest(nt))},set(nt,_e,rt){const it=getDescriptorFromProto(latest(nt),_e);if(it?.set)return it.set.call(nt.draft_,rt),!0;if(!nt.modified_){const st=peek(latest(nt),_e),ot=st?.[DRAFT_STATE];if(ot&&ot.base_===rt)return nt.copy_[_e]=rt,nt.assigned_[_e]=!1,!0;if(is(rt,st)&&(rt!==void 0||has(nt.base_,_e)))return!0;prepareCopy(nt),markChanged(nt)}return nt.copy_[_e]===rt&&(rt!==void 0||_e in nt.copy_)||Number.isNaN(rt)&&Number.isNaN(nt.copy_[_e])||(nt.copy_[_e]=rt,nt.assigned_[_e]=!0),!0},deleteProperty(nt,_e){return peek(nt.base_,_e)!==void 0||_e in nt.base_?(nt.assigned_[_e]=!1,prepareCopy(nt),markChanged(nt)):delete nt.assigned_[_e],nt.copy_&&delete nt.copy_[_e],!0},getOwnPropertyDescriptor(nt,_e){const rt=latest(nt),it=Reflect.getOwnPropertyDescriptor(rt,_e);return it&&{writable:!0,configurable:nt.type_!==1||_e!=="length",enumerable:it.enumerable,value:rt[_e]}},defineProperty(){die(11)},getPrototypeOf(nt){return getPrototypeOf(nt.base_)},setPrototypeOf(){die(12)}},arrayTraps={};each(objectTraps,(nt,_e)=>{arrayTraps[nt]=function(){return arguments[0]=arguments[0][0],_e.apply(this,arguments)}});arrayTraps.deleteProperty=function(nt,_e){return arrayTraps.set.call(this,nt,_e,void 0)};arrayTraps.set=function(nt,_e,rt){return objectTraps.set.call(this,nt[0],_e,rt,nt[0])};function peek(nt,_e){const rt=nt[DRAFT_STATE];return(rt?latest(rt):nt)[_e]}function readPropFromProto(nt,_e,rt){const it=getDescriptorFromProto(_e,rt);return it?"value"in it?it.value:it.get?.call(nt.draft_):void 0}function getDescriptorFromProto(nt,_e){if(!(_e in nt))return;let rt=getPrototypeOf(nt);for(;rt;){const it=Object.getOwnPropertyDescriptor(rt,_e);if(it)return it;rt=getPrototypeOf(rt)}}function markChanged(nt){nt.modified_||(nt.modified_=!0,nt.parent_&&markChanged(nt.parent_))}function prepareCopy(nt){nt.copy_||(nt.copy_=shallowCopy(nt.base_,nt.scope_.immer_.useStrictShallowCopy_))}var Immer2=class{constructor(nt){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(_e,rt,it)=>{if(typeof _e=="function"&&typeof rt!="function"){const ot=rt;rt=_e;const at=this;return function(ft=ot,...pt){return at.produce(ft,mt=>rt.call(this,mt,...pt))}}typeof rt!="function"&&die(6),it!==void 0&&typeof it!="function"&&die(7);let st;if(isDraftable(_e)){const ot=enterScope(this),at=createProxy(_e,void 0);let ct=!0;try{st=rt(at),ct=!1}finally{ct?revokeScope(ot):leaveScope(ot)}return usePatchesInScope(ot,it),processResult(st,ot)}else if(!_e||typeof _e!="object"){if(st=rt(_e),st===void 0&&(st=_e),st===NOTHING&&(st=void 0),this.autoFreeze_&&freeze(st,!0),it){const ot=[],at=[];getPlugin("Patches").generateReplacementPatches_(_e,st,ot,at),it(ot,at)}return st}else die(1,_e)},this.produceWithPatches=(_e,rt)=>{if(typeof _e=="function")return(at,...ct)=>this.produceWithPatches(at,ft=>_e(ft,...ct));let it,st;return[this.produce(_e,rt,(at,ct)=>{it=at,st=ct}),it,st]},typeof nt?.autoFreeze=="boolean"&&this.setAutoFreeze(nt.autoFreeze),typeof nt?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(nt.useStrictShallowCopy)}createDraft(nt){isDraftable(nt)||die(8),isDraft(nt)&&(nt=current(nt));const _e=enterScope(this),rt=createProxy(nt,void 0);return rt[DRAFT_STATE].isManual_=!0,leaveScope(_e),rt}finishDraft(nt,_e){const rt=nt&&nt[DRAFT_STATE];(!rt||!rt.isManual_)&&die(9);const{scope_:it}=rt;return usePatchesInScope(it,_e),processResult(void 0,it)}setAutoFreeze(nt){this.autoFreeze_=nt}setUseStrictShallowCopy(nt){this.useStrictShallowCopy_=nt}applyPatches(nt,_e){let rt;for(rt=_e.length-1;rt>=0;rt--){const st=_e[rt];if(st.path.length===0&&st.op==="replace"){nt=st.value;break}}rt>-1&&(_e=_e.slice(rt+1));const it=getPlugin("Patches").applyPatches_;return isDraft(nt)?it(nt,_e):this.produce(nt,st=>it(st,_e))}};function createProxy(nt,_e){const rt=isMap(nt)?getPlugin("MapSet").proxyMap_(nt,_e):isSet(nt)?getPlugin("MapSet").proxySet_(nt,_e):createProxyProxy(nt,_e);return(_e?_e.scope_:getCurrentScope()).drafts_.push(rt),rt}function current(nt){return isDraft(nt)||die(10,nt),currentImpl(nt)}function currentImpl(nt){if(!isDraftable(nt)||isFrozen(nt))return nt;const _e=nt[DRAFT_STATE];let rt;if(_e){if(!_e.modified_)return _e.base_;_e.finalized_=!0,rt=shallowCopy(nt,_e.scope_.immer_.useStrictShallowCopy_)}else rt=shallowCopy(nt,!0);return each(rt,(it,st)=>{set(rt,it,currentImpl(st))}),_e&&(_e.finalized_=!1),rt}function enableMapSet(){class nt extends Map{constructor(ft,pt){super(),this[DRAFT_STATE]={type_:2,parent_:pt,scope_:pt?pt.scope_:getCurrentScope(),modified_:!1,finalized_:!1,copy_:void 0,assigned_:void 0,base_:ft,draft_:this,isManual_:!1,revoked_:!1}}get size(){return latest(this[DRAFT_STATE]).size}has(ft){return latest(this[DRAFT_STATE]).has(ft)}set(ft,pt){const mt=this[DRAFT_STATE];return at(mt),(!latest(mt).has(ft)||latest(mt).get(ft)!==pt)&&(rt(mt),markChanged(mt),mt.assigned_.set(ft,!0),mt.copy_.set(ft,pt),mt.assigned_.set(ft,!0)),this}delete(ft){if(!this.has(ft))return!1;const pt=this[DRAFT_STATE];return at(pt),rt(pt),markChanged(pt),pt.base_.has(ft)?pt.assigned_.set(ft,!1):pt.assigned_.delete(ft),pt.copy_.delete(ft),!0}clear(){const ft=this[DRAFT_STATE];at(ft),latest(ft).size&&(rt(ft),markChanged(ft),ft.assigned_=new Map,each(ft.base_,pt=>{ft.assigned_.set(pt,!1)}),ft.copy_.clear())}forEach(ft,pt){const mt=this[DRAFT_STATE];latest(mt).forEach((xt,yt,vt)=>{ft.call(pt,this.get(yt),yt,this)})}get(ft){const pt=this[DRAFT_STATE];at(pt);const mt=latest(pt).get(ft);if(pt.finalized_||!isDraftable(mt)||mt!==pt.base_.get(ft))return mt;const xt=createProxy(mt,pt);return rt(pt),pt.copy_.set(ft,xt),xt}keys(){return latest(this[DRAFT_STATE]).keys()}values(){const ft=this.keys();return{[Symbol.iterator]:()=>this.values(),next:()=>{const pt=ft.next();return pt.done?pt:{done:!1,value:this.get(pt.value)}}}}entries(){const ft=this.keys();return{[Symbol.iterator]:()=>this.entries(),next:()=>{const pt=ft.next();if(pt.done)return pt;const mt=this.get(pt.value);return{done:!1,value:[pt.value,mt]}}}}[Symbol.iterator](){return this.entries()}}function _e(ct,ft){return new nt(ct,ft)}function rt(ct){ct.copy_||(ct.assigned_=new Map,ct.copy_=new Map(ct.base_))}class it extends Set{constructor(ft,pt){super(),this[DRAFT_STATE]={type_:3,parent_:pt,scope_:pt?pt.scope_:getCurrentScope(),modified_:!1,finalized_:!1,copy_:void 0,base_:ft,draft_:this,drafts_:new Map,revoked_:!1,isManual_:!1}}get size(){return latest(this[DRAFT_STATE]).size}has(ft){const pt=this[DRAFT_STATE];return at(pt),pt.copy_?!!(pt.copy_.has(ft)||pt.drafts_.has(ft)&&pt.copy_.has(pt.drafts_.get(ft))):pt.base_.has(ft)}add(ft){const pt=this[DRAFT_STATE];return at(pt),this.has(ft)||(ot(pt),markChanged(pt),pt.copy_.add(ft)),this}delete(ft){if(!this.has(ft))return!1;const pt=this[DRAFT_STATE];return at(pt),ot(pt),markChanged(pt),pt.copy_.delete(ft)||(pt.drafts_.has(ft)?pt.copy_.delete(pt.drafts_.get(ft)):!1)}clear(){const ft=this[DRAFT_STATE];at(ft),latest(ft).size&&(ot(ft),markChanged(ft),ft.copy_.clear())}values(){const ft=this[DRAFT_STATE];return at(ft),ot(ft),ft.copy_.values()}entries(){const ft=this[DRAFT_STATE];return at(ft),ot(ft),ft.copy_.entries()}keys(){return this.values()}[Symbol.iterator](){return this.values()}forEach(ft,pt){const mt=this.values();let xt=mt.next();for(;!xt.done;)ft.call(pt,xt.value,xt.value,this),xt=mt.next()}}function st(ct,ft){return new it(ct,ft)}function ot(ct){ct.copy_||(ct.copy_=new Set,ct.base_.forEach(ft=>{if(isDraftable(ft)){const pt=createProxy(ft,ct);ct.drafts_.set(ft,pt),ct.copy_.add(pt)}else ct.copy_.add(ft)}))}function at(ct){ct.revoked_&&die(3,JSON.stringify(latest(ct)))}loadPlugin("MapSet",{proxyMap_:_e,proxySet_:st})}var immer$1=new Immer2,produce=immer$1.produce;immer$1.produceWithPatches.bind(immer$1);immer$1.setAutoFreeze.bind(immer$1);immer$1.setUseStrictShallowCopy.bind(immer$1);immer$1.applyPatches.bind(immer$1);immer$1.createDraft.bind(immer$1);immer$1.finishDraft.bind(immer$1);const immerImpl=nt=>(_e,rt,it)=>(it.setState=(st,ot,...at)=>{const ct=typeof st=="function"?produce(st):st;return _e(ct,ot,...at)},nt(it.setState,rt,it)),immer=immerImpl,cleanGuiState={theme:{type:"ThemeConfigurationMessage",titlebar_content:null,control_layout:"floating",control_width:"medium",dark_mode:!1,show_logo:!0,show_share_button:!0,colors:null},label:"",server:"ws://localhost:8080",shareUrl:null,websocketConnected:!1,backgroundAvailable:!1,guiIdSetFromContainerId:{},modals:[],guiOrderFromId:{},guiConfigFromId:{},uploadsInProgress:{}};function useGuiState(nt){return React.useState(()=>create$3(immer(_e=>({...cleanGuiState,server:nt,setTheme:rt=>_e(it=>{it.theme=rt}),setShareUrl:rt=>_e(it=>{it.shareUrl=rt}),addGui:rt=>_e(it=>{it.guiOrderFromId[rt.id]=rt.props.order,it.guiConfigFromId[rt.id]=rt,rt.container_id in it.guiIdSetFromContainerId||(it.guiIdSetFromContainerId[rt.container_id]={}),it.guiIdSetFromContainerId[rt.container_id][rt.id]=!0}),addModal:rt=>_e(it=>{it.modals.push(rt)}),removeModal:rt=>_e(it=>{it.modals=it.modals.filter(st=>st.id!==rt)}),removeGui:rt=>_e(it=>{const st=it.guiConfigFromId[rt];delete it.guiIdSetFromContainerId[st.container_id][rt],delete it.guiOrderFromId[rt],delete it.guiConfigFromId[rt],Object.keys(it.guiIdSetFromContainerId[st.container_id]).length==0&&delete it.guiIdSetFromContainerId[st.container_id]}),resetGui:()=>_e(rt=>{rt.shareUrl=null,rt.guiIdSetFromContainerId={},rt.modals=[],rt.guiOrderFromId={},rt.guiConfigFromId={},rt.uploadsInProgress={}}),updateUploadState:rt=>_e(it=>{const{componentId:st,...ot}=rt;it.uploadsInProgress[st]={...it.uploadsInProgress[st],...ot}}),updateGuiProps:(rt,it)=>{_e(st=>{const ot=st.guiConfigFromId[rt];if(ot===void 0){console.error("Tried to update non-existent component",rt);return}for(const[at,ct]of Object.entries(it))at==="value"?st.guiConfigFromId[rt].value=ct:at in ot.props?st.guiConfigFromId[rt].props[at]=ct:console.error(`Tried to update nonexistent property '${at}' of GUI element ${rt}!`)})}}))))[0]}const searchParamKey="websocket";function syncSearchParamServer(nt){const _e=new URLSearchParams(window.location.search),rt=window.location.host.includes(nt.replace("ws://","").replace("/",""))||window.location.host.includes(nt.replace("wss://","").replace("/",""));rt&&_e.has(searchParamKey)?_e.delete(searchParamKey):rt||_e.set(searchParamKey,nt),window.history.replaceState(null,"Viser",_e.size===0?window.location.href.split("?")[0]:"?"+Array.from(_e.entries()).map(([it,st])=>`${it}=${st}`).join("&"))}function WorkerWrapper(nt){return new Worker("/egoallo/viser-embed/assets/WebsocketServerWorker-2xce1CWr.js",{type:"module",name:nt?.name})}function WebsocketMessageProducer(){const nt=reactExports.useContext(ViewerContext).messageQueueRef,_e=reactExports.useContext(ViewerContext),rt=_e.useGui(st=>st.server),it=_e.useGui(st=>st.resetGui);return syncSearchParamServer(rt),React.useEffect(()=>{const st=new WorkerWrapper;st.onmessage=at=>{const ct=at.data;ct.type==="connected"?(it(),_e.useGui.setState({websocketConnected:!0}),_e.sendMessageRef.current=ft=>{ot({type:"send",message:ft})}):ct.type==="closed"?(it(),_e.useGui.setState({websocketConnected:!1}),_e.sendMessageRef.current=ft=>{console.log(`Tried to send ${ft.type} but websocket is not connected!`)}):ct.type==="message_batch"&&nt.current.push(...ct.messages)};function ot(at){st.postMessage(at)}return ot({type:"set_server",server:rt}),()=>{ot({type:"close"}),_e.sendMessageRef.current=at=>console.log(`Tried to send ${at.type} but websocket is not connected!`),_e.useGui.setState({websocketConnected:!1})}},[rt,it]),jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{})}function assertUnreachable(nt){throw new Error("Didn't expect to get here",nt)}function getIcon(nt){let _e=null;switch(nt){case null:break;case"GitHub":_e=IconBrandGithub;break;case"Description":_e=IconFileDescription;break;case"Keyboard":_e=IconKeyboard;break;default:assertUnreachable(nt)}return _e}function TitlebarButton(nt){const _e=getIcon(nt.icon);return jsxRuntimeExports.jsx(Button,{component:"a",variant:"default",size:"compact-sm",href:nt.href||void 0,target:"_blank",leftSection:_e===null?null:jsxRuntimeExports.jsx(_e,{size:"1em"}),ml:"xs",color:"gray",children:nt.text})}function MobileTitlebarButton(nt){const _e=getIcon(nt.icon);return jsxRuntimeExports.jsx(Button,{m:"sm",component:"a",variant:"default",href:nt.href||void 0,target:"_blank",leftSection:_e===null?null:jsxRuntimeExports.jsx(_e,{size:"1.5em"}),ml:"sm",color:"gray",children:nt.text})}function TitlebarImage(nt,_e){let rt;nt.image_url_dark==null||_e==="light"?rt=nt.image_url_light:rt=nt.image_url_dark;const it=jsxRuntimeExports.jsx("img",{src:rt,alt:nt.image_alt,style:{height:"1.8em",margin:"0 0.5em"}});return nt.href==null?it:jsxRuntimeExports.jsx("a",{style:{display:"block",height:"1.8em"},href:nt.href,children:it})}function Titlebar(){const _e=reactExports.useContext(ViewerContext).useGui(ct=>ct.theme.titlebar_content),rt=useMantineColorScheme().colorScheme,[it,st]=useDisclosure(!1);if(_e==null)return null;const ot=_e.buttons,at=_e.image;return jsxRuntimeExports.jsx(Box,{style:{height:"3.2em",margin:0,border:"0",zIndex:10},children:jsxRuntimeExports.jsxs(Paper,{shadow:"0 0 0.8em 0 rgba(0,0,0,0.1)",style:{height:"100%"},children:[jsxRuntimeExports.jsxs(Container,{fluid:!0,style:()=>({height:"100%",display:"flex",alignItems:"center"}),children:[jsxRuntimeExports.jsx(Group$1,{style:()=>({marginRight:"auto"}),children:at!==null?TitlebarImage(at,rt):null}),jsxRuntimeExports.jsx(Group$1,{display:{base:"none",xs:"flex"},style:()=>({flexWrap:"nowrap",overflowX:"scroll",msOverflowStyle:"none",scrollbarWidth:"none"}),children:ot?.map((ct,ft)=>reactExports.createElement(TitlebarButton,{...ct,key:ft}))}),jsxRuntimeExports.jsx(Burger,{size:"sm",opened:it,onClick:st.toggle,title:it?"Close navigation":"Open navigation",display:{base:"block",xs:"none"}})]}),jsxRuntimeExports.jsx(Portal$1,{children:jsxRuntimeExports.jsx(Paper,{display:{base:"flex",xs:"none"},radius:"0",style:{flexDirection:"column",position:"absolute",top:"3.2em",zIndex:2e3,height:it?"calc(100vh - 2.375em)":"0",width:"100vw",transition:"all 0.5s",overflow:it?"scroll":"hidden",padding:it?"1rem":"0"},children:ot?.map((ct,ft)=>reactExports.createElement(MobileTitlebarButton,{...ct,key:ft}))})})]})})}function ViserModal(){return reactExports.useContext(ViewerContext).useGui(it=>it.modals).map((it,st)=>jsxRuntimeExports.jsx(GeneratedModal,{conf:it,index:st},it.id))}function GeneratedModal({conf:nt,index:_e}){return jsxRuntimeExports.jsx(Modal,{opened:!0,title:nt.title,onClose:()=>{},withCloseButton:!1,centered:!0,zIndex:100+_e,children:jsxRuntimeExports.jsx(GeneratedGuiContainer,{containerId:nt.id})})}const rootNodeTemplate={message:{type:"FrameMessage",name:"",props:{show_axes:!1,axes_length:.5,axes_radius:.0125,origin_radius:.025}},children:["/WorldAxes"],clickable:!1},worldAxesNodeTemplate={message:{type:"FrameMessage",name:"/WorldAxes",props:{show_axes:!0,axes_length:.5,axes_radius:.0125,origin_radius:.025}},children:[],clickable:!1};function useSceneTreeState(nt){return React.useState(()=>create$3(immer(_e=>({nodeFromName:{"":rootNodeTemplate,"/WorldAxes":worldAxesNodeTemplate},labelVisibleFromName:{},enableDefaultLights:!0,environmentMap:{type:"EnvironmentMapMessage",hdri:"city",background:!1,background_blurriness:0,background_intensity:1,background_rotation:[0,0,0],environment_intensity:1,environment_rotation:[0,0,0]},setClickable:(rt,it)=>_e(st=>{const ot=st.nodeFromName[rt];ot!==void 0&&(ot.clickable=it)}),addSceneNode:rt=>_e(it=>{const st=it.nodeFromName[rt.name];if(st!==void 0)delete nt.current[rt.name],it.nodeFromName[rt.name]={...st,message:rt};else{const ot=rt.name.split("/").slice(0,-1).join("/");it.nodeFromName[rt.name]={message:rt,children:[],clickable:!1},it.nodeFromName[ot].children.push(rt.name)}}),removeSceneNode:rt=>_e(it=>{if(!(rt in it.nodeFromName)){console.log("Skipping scene node removal for "+rt);return}const st=[];function ot(ct){st.push(ct),it.nodeFromName[ct].children.forEach(ot)}ot(rt),st.forEach(ct=>{delete it.nodeFromName[ct],delete nt.current[ct]});const at=rt.split("/").slice(0,-1).join("/");it.nodeFromName[at].children=it.nodeFromName[at].children.filter(ct=>ct!==rt)}),updateSceneNode:(rt,it)=>_e(st=>{st.nodeFromName[rt].message.props={...st.nodeFromName[rt].message.props,...it}}),resetScene:()=>_e(rt=>{for(const it of Object.keys(rt.nodeFromName))it!==""&&it!=="/WorldAxes"&&delete rt.nodeFromName[it];rt.nodeFromName[""]=rootNodeTemplate,rt.nodeFromName["/WorldAxes"]=worldAxesNodeTemplate}),setLabelVisibility:(rt,it)=>_e(st=>{st.labelVisibleFromName[rt]=it})}))))[0]}function getSizesVariables(nt,_e,rt){return Object.keys(nt[_e]).reduce((it,st)=>(it[st]=`var(--mantine-${rt}-${st})`,it),{})}function getBreakpointValue(nt,_e){return nt in _e.breakpoints?_e.breakpoints[nt]:em(nt)}function themeToVars(nt){const _e=mergeMantineTheme(DEFAULT_THEME,nt),rt=getSizesVariables(_e,"fontSizes","font-size"),it=getSizesVariables(_e,"lineHeights","line-height"),st=getSizesVariables(_e,"shadows","shadow"),ot=getSizesVariables(_e,"radius","radius"),at=getSizesVariables(_e,"spacing","spacing"),ct=Object.keys(_e.headings.sizes).reduce((pt,mt)=>(pt[mt]={fontSize:`var(--mantine-${mt}-font-size)`,lineHeight:`var(--mantine-${mt}-line-height)`,fontWeight:`var(--mantine-${mt}-font-weight)`},pt),{}),ft=Object.keys(_e.colors).reduce((pt,mt)=>(pt[mt]={0:`var(--mantine-color-${mt}-0)`,1:`var(--mantine-color-${mt}-1)`,2:`var(--mantine-color-${mt}-2)`,3:`var(--mantine-color-${mt}-3)`,4:`var(--mantine-color-${mt}-4)`,5:`var(--mantine-color-${mt}-5)`,6:`var(--mantine-color-${mt}-6)`,7:`var(--mantine-color-${mt}-7)`,8:`var(--mantine-color-${mt}-8)`,9:`var(--mantine-color-${mt}-9)`,filled:`var(--mantine-color-${mt}-filled)`,filledHover:`var(--mantine-color-${mt}-filled-hover)`,light:`var(--mantine-color-${mt}-light)`,lightHover:`var(--mantine-color-${mt}-light-hover)`,lightColor:`var(--mantine-color-${mt}-light-color)`,outline:`var(--mantine-color-${mt}-outline)`,outlineHover:`var(--mantine-color-${mt}-outline-hover)`},pt),{primary:"var(--mantine-primary-color-filled)",primaryColors:{0:"var(--mantine-primary-color-0)",1:"var(--mantine-primary-color-1)",2:"var(--mantine-primary-color-2)",3:"var(--mantine-primary-color-3)",4:"var(--mantine-primary-color-4)",5:"var(--mantine-primary-color-5)",6:"var(--mantine-primary-color-6)",7:"var(--mantine-primary-color-7)",8:"var(--mantine-primary-color-8)",9:"var(--mantine-primary-color-9)",filled:"var(--mantine-primary-color-filled)",filledHover:"var(--mantine-primary-color-filled-hover)",light:"var(--mantine-primary-color-light)",lightHover:"var(--mantine-primary-color-light-hover)",lightColor:"var(--mantine-primary-color-light-color)",outline:"var(--mantine-primary-color-outline)",outlineHover:"var(--mantine-primary-color-outline-hover)"},white:"var(--mantine-color-white)",black:"var(--mantine-color-black)",text:"var(--mantine-color-text)",body:"var(--mantine-color-body)",error:"var(--mantine-color-error)",placeholder:"var(--mantine-color-placeholder)",anchor:"var(--mantine-color-anchor)",default:"var(--mantine-color-default)",defaultHover:"var(--mantine-color-default-hover)",defaultColor:"var(--mantine-color-default-color)",defaultBorder:"var(--mantine-color-default-border)",dimmed:"var(--mantine-color-dimmed)"});return{scale:"var(--mantine-scale)",cursorType:"var(--mantine-cursor-type)",webkitFontSmoothing:"var(--mantine-webkit-font-smoothing)",mozFontSmoothing:"var(--mantine-moz-font-smoothing)",lineHeight:"var(--mantine-line-height)",fontFamily:"var(--mantine-font-family)",fontFamilyMonospace:"var(--mantine-font-family-monospace)",fontFamilyHeadings:"var(--mantine-font-family-headings)",headingFontWeight:"var(--mantine-heading-font-weight)",radiusDefault:"var(--mantine-radius-default)",breakpoints:_e.breakpoints,fontSizes:rt,lineHeights:it,shadows:st,radius:ot,headings:ct,spacing:at,colors:ft,rtlSelector:'[dir="rtl"] &',darkSelector:'[data-mantine-color-scheme="dark"] &',lightSelector:'[data-mantine-color-scheme="light"] &',smallerThan:pt=>`(max-width: ${getBreakpointValue(pt,_e)})`,largerThan:pt=>`(min-width: ${getBreakpointValue(pt,_e)})`}}const theme={fontFamily:"Inter",autoContrast:!0,components:{Checkbox:Checkbox.extend({defaultProps:{radius:"xs"}}),ColorInput:ColorInput.extend({defaultProps:{radius:"xs"}}),Select:Select.extend({defaultProps:{radius:"sm"}}),TextInput:TextInput.extend({defaultProps:{radius:"xs"}}),NumberInput:NumberInput.extend({defaultProps:{radius:"xs"}}),Paper:Paper.extend({defaultProps:{radius:"xs",shadow:"0"}}),ActionIcon:ActionIcon.extend({defaultProps:{variant:"subtle",color:"gray",radius:"xs"}}),Button:Button.extend({defaultProps:{radius:"xs",fw:450}})}};themeToVars(theme);const typeSetSceneNodeMessage=new Set(["CameraFrustumMessage","GlbMessage","FrameMessage","BatchedAxesMessage","GridMessage","LabelMessage","Gui3DMessage","PointCloudMessage","DirectionalLightMessage","AmbientLightMessage","HemisphereLightMessage","PointLightMessage","RectAreaLightMessage","SpotLightMessage","MeshMessage","SkinnedMeshMessage","TransformControlsMessage","ImageMessage","CatmullRomSplineMessage","CubicBezierSplineMessage","GaussianSplatsMessage"]);function isSceneNodeMessage(nt){return typeSetSceneNodeMessage.has(nt.type)}const typeSetGuiComponentMessage=new Set(["GuiFolderMessage","GuiMarkdownMessage","GuiProgressBarMessage","GuiPlotlyMessage","GuiTabGroupMessage","GuiButtonMessage","GuiUploadButtonMessage","GuiSliderMessage","GuiMultiSliderMessage","GuiNumberMessage","GuiRgbMessage","GuiRgbaMessage","GuiCheckboxMessage","GuiVector2Message","GuiVector3Message","GuiTextMessage","GuiDropdownMessage","GuiButtonGroupMessage"]);function isGuiComponentMessage(nt){return typeSetGuiComponentMessage.has(nt.type)}function useMessageHandler(){const viewer=reactExports.useContext(ViewerContext),updateSceneNode=viewer.useSceneTree(nt=>nt.updateSceneNode),removeSceneNode=viewer.useSceneTree(nt=>nt.removeSceneNode),resetScene=viewer.useSceneTree(nt=>nt.resetScene),addSceneNode=viewer.useSceneTree(nt=>nt.addSceneNode),resetGui=viewer.useGui(nt=>nt.resetGui),setTheme=viewer.useGui(nt=>nt.setTheme),setShareUrl=viewer.useGui(nt=>nt.setShareUrl),addGui=viewer.useGui(nt=>nt.addGui),addModal=viewer.useGui(nt=>nt.addModal),removeModal=viewer.useGui(nt=>nt.removeModal),removeGui=viewer.useGui(nt=>nt.removeGui),updateGuiProps=viewer.useGui(nt=>nt.updateGuiProps),setClickable=viewer.useSceneTree(nt=>nt.setClickable),updateUploadState=viewer.useGui(nt=>nt.updateUploadState);function addSceneNodeMakeParents(nt){const _e=viewer.nodeAttributesFromName.current;_e[nt.name]={overrideVisibility:_e[nt.name]?.overrideVisibility},_e[nt.name].poseUpdateState="waitForMakeObject";const rt=viewer.useSceneTree.getState().nodeFromName,it=nt.name.split("/").slice(0,-1).join("/");it in rt||addSceneNodeMakeParents({...rootNodeTemplate.message,name:it}),addSceneNode(nt)}const fileDownloadHandler=useFileDownloadHandler();return message=>{if(isGuiComponentMessage(message)){addGui(message);return}if(isSceneNodeMessage(message)){if(message.type==="SkinnedMeshMessage"){viewer.skinnedMeshState.current[message.name]={initialized:!1,poses:[]};const nt=new Float32Array(message.props.bone_wxyzs.buffer.slice(message.props.bone_wxyzs.byteOffset,message.props.bone_wxyzs.byteOffset+message.props.bone_wxyzs.byteLength)),_e=new Float32Array(message.props.bone_positions.buffer.slice(message.props.bone_positions.byteOffset,message.props.bone_positions.byteOffset+message.props.bone_positions.byteLength));for(let rt=0;rt{URL.revokeObjectURL(nt);const rt=viewer.backgroundMaterialRef.current.uniforms.colorMap.value;viewer.backgroundMaterialRef.current.uniforms.colorMap.value=_e,isTexture(rt)&&rt.dispose(),viewer.useGui.setState({backgroundAvailable:!0})}),viewer.backgroundMaterialRef.current.uniforms.enabled.value=!0,viewer.backgroundMaterialRef.current.uniforms.hasDepth.value=message.depth_bytes!==null,message.depth_bytes!==null){const _e=URL.createObjectURL(new Blob([message.depth_bytes],{type:message.media_type}));new TextureLoader().load(_e,rt=>{URL.revokeObjectURL(_e);const it=viewer.backgroundMaterialRef.current?.uniforms.depthMap.value;viewer.backgroundMaterialRef.current.uniforms.depthMap.value=rt,isTexture(it)&&it.dispose()})}return}case"RemoveSceneNodeMessage":{console.log("Removing scene node:",message.name),removeSceneNode(message.name);const nt=viewer.nodeAttributesFromName.current;delete nt[message.name],viewer.skinnedMeshState.current[message.name]!==void 0&&delete viewer.skinnedMeshState.current[message.name];return}case"SetSceneNodeClickableMessage":{setTimeout(()=>setClickable(message.name,message.clickable),50);return}case"ResetSceneMessage":{resetScene();const nt=viewer.sceneRef.current?.background;viewer.sceneRef.current.background=null,isTexture(nt)&&nt.dispose(),viewer.useGui.setState({backgroundAvailable:!1}),viewer.backgroundMaterialRef.current.uniforms.enabled.value=!1;return}case"ResetGuiMessage":{resetGui();return}case"GuiUpdateMessage":{updateGuiProps(message.id,message.updates);return}case"GuiRemoveMessage":{removeGui(message.id);return}case"FileTransferStart":case"FileTransferPart":{fileDownloadHandler(message);return}case"FileTransferPartAck":{updateUploadState({componentId:message.source_component_id,uploadedBytes:message.transferred_bytes,totalBytes:message.total_bytes});return}default:{console.log("Received message did not match any known types:",message);return}}}}function useFileDownloadHandler(){const nt=React.useRef({});return _e=>{const rt="download-"+_e.transfer_uuid;switch(_e.type){case"FileTransferStart":{let at=_e.size_bytes;const ct=["B","K","M","G","T","P"];let ft=0;for(;at>=100&&ft{if(_e.getRenderRequestState.current==="triggered")_e.getRenderRequestState.current="pause";else if(_e.getRenderRequestState.current==="pause"){const it=_e.canvasRef.current,st=_e.getRenderRequest.current.width,ot=_e.getRenderRequest.current.height,at=new OffscreenCanvas(st,ot),ct=at.getContext("2d");ct.reset(),_e.getRenderRequest.current?.format==="image/jpeg"&&(ct.fillStyle="white",ct.fillRect(0,0,at.width,at.height));let ft=it.width,pt=it.height;const mt=ft/pt,xt=st/ot;mt>xt?ft=Math.round(xt*pt):mt{if(yt===null){console.error("Render failed"),_e.getRenderRequestState.current="ready";return}const vt=new Uint8Array(await yt.arrayBuffer());_e.sendMessageRef.current({type:"GetRenderResponseMessage",payload:vt}),_e.getRenderRequestState.current="ready"})}if(_e.getRenderRequestState.current==="ready"){const it=rt.current.findIndex(at=>at.type==="GetRenderRequestMessage"),st=it!==-1?it+1:rt.current.length;rt.current.splice(0,st).forEach(nt)}}),null}new TextEncoder;var CHUNK_SIZE=4096;function utf8DecodeJs(nt,_e,rt){for(var it=_e,st=it+rt,ot=[],at="";it65535&&(xt-=65536,ot.push(xt>>>10&1023|55296),xt=56320|xt&1023),ot.push(xt)}else ot.push(ct);ot.length>=CHUNK_SIZE&&(at+=String.fromCharCode.apply(String,ot),ot.length=0)}return ot.length>0&&(at+=String.fromCharCode.apply(String,ot)),at}var sharedTextDecoder=new TextDecoder,TEXT_DECODER_THRESHOLD=200;function utf8DecodeTD(nt,_e,rt){var it=nt.subarray(_e,_e+rt);return sharedTextDecoder.decode(it)}function utf8Decode(nt,_e,rt){return rt>TEXT_DECODER_THRESHOLD?utf8DecodeTD(nt,_e,rt):utf8DecodeJs(nt,_e,rt)}var ExtData=function(){function nt(_e,rt){this.type=_e,this.data=rt}return nt}(),__extends=function(){var nt=function(_e,rt){return nt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(it,st){it.__proto__=st}||function(it,st){for(var ot in st)Object.prototype.hasOwnProperty.call(st,ot)&&(it[ot]=st[ot])},nt(_e,rt)};return function(_e,rt){if(typeof rt!="function"&&rt!==null)throw new TypeError("Class extends value "+String(rt)+" is not a constructor or null");nt(_e,rt);function it(){this.constructor=_e}_e.prototype=rt===null?Object.create(rt):(it.prototype=rt.prototype,new it)}}(),DecodeError=function(nt){__extends(_e,nt);function _e(rt){var it=nt.call(this,rt)||this,st=Object.create(_e.prototype);return Object.setPrototypeOf(it,st),Object.defineProperty(it,"name",{configurable:!0,enumerable:!1,value:_e.name}),it}return _e}(Error),UINT32_MAX=4294967295;function setInt64(nt,_e,rt){var it=Math.floor(rt/4294967296),st=rt;nt.setUint32(_e,it),nt.setUint32(_e+4,st)}function getInt64(nt,_e){var rt=nt.getInt32(_e),it=nt.getUint32(_e+4);return rt*4294967296+it}function getUint64(nt,_e){var rt=nt.getUint32(_e),it=nt.getUint32(_e+4);return rt*4294967296+it}var EXT_TIMESTAMP=-1,TIMESTAMP32_MAX_SEC=4294967296-1,TIMESTAMP64_MAX_SEC=17179869184-1;function encodeTimeSpecToTimestamp(nt){var _e=nt.sec,rt=nt.nsec;if(_e>=0&&rt>=0&&_e<=TIMESTAMP64_MAX_SEC)if(rt===0&&_e<=TIMESTAMP32_MAX_SEC){var it=new Uint8Array(4),st=new DataView(it.buffer);return st.setUint32(0,_e),it}else{var ot=_e/4294967296,at=_e&4294967295,it=new Uint8Array(8),st=new DataView(it.buffer);return st.setUint32(0,rt<<2|ot&3),st.setUint32(4,at),it}else{var it=new Uint8Array(12),st=new DataView(it.buffer);return st.setUint32(0,rt),setInt64(st,4,_e),it}}function encodeDateToTimeSpec(nt){var _e=nt.getTime(),rt=Math.floor(_e/1e3),it=(_e-rt*1e3)*1e6,st=Math.floor(it/1e9);return{sec:rt+st,nsec:it-st*1e9}}function encodeTimestampExtension(nt){if(nt instanceof Date){var _e=encodeDateToTimeSpec(nt);return encodeTimeSpecToTimestamp(_e)}else return null}function decodeTimestampToTimeSpec(nt){var _e=new DataView(nt.buffer,nt.byteOffset,nt.byteLength);switch(nt.byteLength){case 4:{var rt=_e.getUint32(0),it=0;return{sec:rt,nsec:it}}case 8:{var st=_e.getUint32(0),ot=_e.getUint32(4),rt=(st&3)*4294967296+ot,it=st>>>2;return{sec:rt,nsec:it}}case 12:{var rt=getInt64(_e,4),it=_e.getUint32(0);return{sec:rt,nsec:it}}default:throw new DecodeError("Unrecognized data size for timestamp (expected 4, 8, or 12): ".concat(nt.length))}}function decodeTimestampExtension(nt){var _e=decodeTimestampToTimeSpec(nt);return new Date(_e.sec*1e3+_e.nsec/1e6)}var timestampExtension={type:EXT_TIMESTAMP,encode:encodeTimestampExtension,decode:decodeTimestampExtension},ExtensionCodec=function(){function nt(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(timestampExtension)}return nt.prototype.register=function(_e){var rt=_e.type,it=_e.encode,st=_e.decode;if(rt>=0)this.encoders[rt]=it,this.decoders[rt]=st;else{var ot=1+rt;this.builtInEncoders[ot]=it,this.builtInDecoders[ot]=st}},nt.prototype.tryToEncode=function(_e,rt){for(var it=0;it0&&_e<=this.maxKeyLength},nt.prototype.find=function(_e,rt,it){var st=this.caches[it-1];e:for(var ot=0,at=st;ot=this.maxLengthPerKey?it[Math.random()*it.length|0]=st:it.push(st)},nt.prototype.decode=function(_e,rt,it){var st=this.find(_e,rt,it);if(st!=null)return this.hit++,st;this.miss++;var ot=utf8DecodeJs(_e,rt,it),at=Uint8Array.prototype.slice.call(_e,rt,rt+it);return this.store(at,ot),ot},nt}(),__awaiter$1=function(nt,_e,rt,it){function st(ot){return ot instanceof rt?ot:new rt(function(at){at(ot)})}return new(rt||(rt=Promise))(function(ot,at){function ct(mt){try{pt(it.next(mt))}catch(xt){at(xt)}}function ft(mt){try{pt(it.throw(mt))}catch(xt){at(xt)}}function pt(mt){mt.done?ot(mt.value):st(mt.value).then(ct,ft)}pt((it=it.apply(nt,_e||[])).next())})},__generator$2=function(nt,_e){var rt={label:0,sent:function(){if(ot[0]&1)throw ot[1];return ot[1]},trys:[],ops:[]},it,st,ot,at;return at={next:ct(0),throw:ct(1),return:ct(2)},typeof Symbol=="function"&&(at[Symbol.iterator]=function(){return this}),at;function ct(pt){return function(mt){return ft([pt,mt])}}function ft(pt){if(it)throw new TypeError("Generator is already executing.");for(;at&&(at=0,pt[0]&&(rt=0)),rt;)try{if(it=1,st&&(ot=pt[0]&2?st.return:pt[0]?st.throw||((ot=st.return)&&ot.call(st),0):st.next)&&!(ot=ot.call(st,pt[1])).done)return ot;switch(st=0,ot&&(pt=[pt[0]&2,ot.value]),pt[0]){case 0:case 1:ot=pt;break;case 4:return rt.label++,{value:pt[1],done:!1};case 5:rt.label++,st=pt[1],pt=[0];continue;case 7:pt=rt.ops.pop(),rt.trys.pop();continue;default:if(ot=rt.trys,!(ot=ot.length>0&&ot[ot.length-1])&&(pt[0]===6||pt[0]===2)){rt=0;continue}if(pt[0]===3&&(!ot||pt[1]>ot[0]&&pt[1]1||ct(yt,vt)})})}function ct(yt,vt){try{ft(it[yt](vt))}catch(bt){xt(ot[0][3],bt)}}function ft(yt){yt.value instanceof __await$1?Promise.resolve(yt.value.v).then(pt,mt):xt(ot[0][2],yt)}function pt(yt){ct("next",yt)}function mt(yt){ct("throw",yt)}function xt(yt,vt){yt(vt),ot.shift(),ot.length&&ct(ot[0][0],ot[0][1])}},STATE_ARRAY="array",STATE_MAP_KEY="map_key",STATE_MAP_VALUE="map_value",isValidMapKeyType=function(nt){return typeof nt=="string"||typeof nt=="number"},HEAD_BYTE_REQUIRED=-1,EMPTY_VIEW=new DataView(new ArrayBuffer(0)),EMPTY_BYTES=new Uint8Array(EMPTY_VIEW.buffer);try{EMPTY_VIEW.getInt8(0)}catch(nt){if(!(nt instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}var DataViewIndexOutOfBoundsError=RangeError,MORE_DATA=new DataViewIndexOutOfBoundsError("Insufficient data"),sharedCachedKeyDecoder=new CachedKeyDecoder,Decoder=function(){function nt(_e){var rt,it,st,ot,at,ct,ft;this.totalPos=0,this.pos=0,this.view=EMPTY_VIEW,this.bytes=EMPTY_BYTES,this.headByte=HEAD_BYTE_REQUIRED,this.stack=[],this.extensionCodec=(rt=_e?.extensionCodec)!==null&&rt!==void 0?rt:ExtensionCodec.defaultCodec,this.context=_e?.context,this.useBigInt64=(it=_e?.useBigInt64)!==null&&it!==void 0?it:!1,this.maxStrLength=(st=_e?.maxStrLength)!==null&&st!==void 0?st:UINT32_MAX,this.maxBinLength=(ot=_e?.maxBinLength)!==null&&ot!==void 0?ot:UINT32_MAX,this.maxArrayLength=(at=_e?.maxArrayLength)!==null&&at!==void 0?at:UINT32_MAX,this.maxMapLength=(ct=_e?.maxMapLength)!==null&&ct!==void 0?ct:UINT32_MAX,this.maxExtLength=(ft=_e?.maxExtLength)!==null&&ft!==void 0?ft:UINT32_MAX,this.keyDecoder=_e?.keyDecoder!==void 0?_e.keyDecoder:sharedCachedKeyDecoder}return nt.prototype.reinitializeState=function(){this.totalPos=0,this.headByte=HEAD_BYTE_REQUIRED,this.stack.length=0},nt.prototype.setBuffer=function(_e){this.bytes=ensureUint8Array(_e),this.view=createDataView(this.bytes),this.pos=0},nt.prototype.appendBuffer=function(_e){if(this.headByte===HEAD_BYTE_REQUIRED&&!this.hasRemaining(1))this.setBuffer(_e);else{var rt=this.bytes.subarray(this.pos),it=ensureUint8Array(_e),st=new Uint8Array(rt.length+it.length);st.set(rt),st.set(it,rt.length),this.setBuffer(st)}},nt.prototype.hasRemaining=function(_e){return this.view.byteLength-this.pos>=_e},nt.prototype.createExtraByteError=function(_e){var rt=this,it=rt.view,st=rt.pos;return new RangeError("Extra ".concat(it.byteLength-st," of ").concat(it.byteLength," byte(s) found at buffer[").concat(_e,"]"))},nt.prototype.decode=function(_e){this.reinitializeState(),this.setBuffer(_e);var rt=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return rt},nt.prototype.decodeMulti=function(_e){return __generator$2(this,function(rt){switch(rt.label){case 0:this.reinitializeState(),this.setBuffer(_e),rt.label=1;case 1:return this.hasRemaining(1)?[4,this.doDecodeSync()]:[3,3];case 2:return rt.sent(),[3,1];case 3:return[2]}})},nt.prototype.decodeAsync=function(_e){var rt,it,st,ot,at,ct,ft;return __awaiter$1(this,void 0,void 0,function(){var pt,mt,xt,yt,vt,bt,wt,Tt;return __generator$2(this,function(St){switch(St.label){case 0:pt=!1,St.label=1;case 1:St.trys.push([1,6,7,12]),rt=!0,it=__asyncValues(_e),St.label=2;case 2:return[4,it.next()];case 3:if(st=St.sent(),ot=st.done,!!ot)return[3,5];ft=st.value,rt=!1;try{if(xt=ft,pt)throw this.createExtraByteError(this.totalPos);this.appendBuffer(xt);try{mt=this.doDecodeSync(),pt=!0}catch(Rt){if(!(Rt instanceof DataViewIndexOutOfBoundsError))throw Rt}this.totalPos+=this.pos}finally{rt=!0}St.label=4;case 4:return[3,2];case 5:return[3,12];case 6:return yt=St.sent(),at={error:yt},[3,12];case 7:return St.trys.push([7,,10,11]),!rt&&!ot&&(ct=it.return)?[4,ct.call(it)]:[3,9];case 8:St.sent(),St.label=9;case 9:return[3,11];case 10:if(at)throw at.error;return[7];case 11:return[7];case 12:if(pt){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return[2,mt]}throw vt=this,bt=vt.headByte,wt=vt.pos,Tt=vt.totalPos,new RangeError("Insufficient data in parsing ".concat(prettyByte(bt)," at ").concat(Tt," (").concat(wt," in the current buffer)"))}})})},nt.prototype.decodeArrayStream=function(_e){return this.decodeMultiAsync(_e,!0)},nt.prototype.decodeStream=function(_e){return this.decodeMultiAsync(_e,!1)},nt.prototype.decodeMultiAsync=function(_e,rt){return __asyncGenerator$1(this,arguments,function(){var st,ot,at,ct,ft,pt,mt,xt,yt,vt,bt,wt;return __generator$2(this,function(Tt){switch(Tt.label){case 0:st=rt,ot=-1,Tt.label=1;case 1:Tt.trys.push([1,15,16,21]),at=!0,ct=__asyncValues(_e),Tt.label=2;case 2:return[4,__await$1(ct.next())];case 3:if(ft=Tt.sent(),yt=ft.done,!!yt)return[3,14];wt=ft.value,at=!1,Tt.label=4;case 4:if(Tt.trys.push([4,,12,13]),pt=wt,rt&&ot===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(pt),st&&(ot=this.readArraySize(),st=!1,this.complete()),Tt.label=5;case 5:Tt.trys.push([5,10,,11]),Tt.label=6;case 6:return[4,__await$1(this.doDecodeSync())];case 7:return[4,Tt.sent()];case 8:return Tt.sent(),--ot===0?[3,9]:[3,6];case 9:return[3,11];case 10:if(mt=Tt.sent(),!(mt instanceof DataViewIndexOutOfBoundsError))throw mt;return[3,11];case 11:return this.totalPos+=this.pos,[3,13];case 12:return at=!0,[7];case 13:return[3,2];case 14:return[3,21];case 15:return xt=Tt.sent(),vt={error:xt},[3,21];case 16:return Tt.trys.push([16,,19,20]),!at&&!yt&&(bt=ct.return)?[4,__await$1(bt.call(ct))]:[3,18];case 17:Tt.sent(),Tt.label=18;case 18:return[3,20];case 19:if(vt)throw vt.error;return[7];case 20:return[7];case 21:return[2]}})})},nt.prototype.doDecodeSync=function(){e:for(;;){var _e=this.readHeadByte(),rt=void 0;if(_e>=224)rt=_e-256;else if(_e<192)if(_e<128)rt=_e;else if(_e<144){var it=_e-128;if(it!==0){this.pushMapState(it),this.complete();continue e}else rt={}}else if(_e<160){var it=_e-144;if(it!==0){this.pushArrayState(it),this.complete();continue e}else rt=[]}else{var st=_e-160;rt=this.decodeUtf8String(st,0)}else if(_e===192)rt=null;else if(_e===194)rt=!1;else if(_e===195)rt=!0;else if(_e===202)rt=this.readF32();else if(_e===203)rt=this.readF64();else if(_e===204)rt=this.readU8();else if(_e===205)rt=this.readU16();else if(_e===206)rt=this.readU32();else if(_e===207)this.useBigInt64?rt=this.readU64AsBigInt():rt=this.readU64();else if(_e===208)rt=this.readI8();else if(_e===209)rt=this.readI16();else if(_e===210)rt=this.readI32();else if(_e===211)this.useBigInt64?rt=this.readI64AsBigInt():rt=this.readI64();else if(_e===217){var st=this.lookU8();rt=this.decodeUtf8String(st,1)}else if(_e===218){var st=this.lookU16();rt=this.decodeUtf8String(st,2)}else if(_e===219){var st=this.lookU32();rt=this.decodeUtf8String(st,4)}else if(_e===220){var it=this.readU16();if(it!==0){this.pushArrayState(it),this.complete();continue e}else rt=[]}else if(_e===221){var it=this.readU32();if(it!==0){this.pushArrayState(it),this.complete();continue e}else rt=[]}else if(_e===222){var it=this.readU16();if(it!==0){this.pushMapState(it),this.complete();continue e}else rt={}}else if(_e===223){var it=this.readU32();if(it!==0){this.pushMapState(it),this.complete();continue e}else rt={}}else if(_e===196){var it=this.lookU8();rt=this.decodeBinary(it,1)}else if(_e===197){var it=this.lookU16();rt=this.decodeBinary(it,2)}else if(_e===198){var it=this.lookU32();rt=this.decodeBinary(it,4)}else if(_e===212)rt=this.decodeExtension(1,0);else if(_e===213)rt=this.decodeExtension(2,0);else if(_e===214)rt=this.decodeExtension(4,0);else if(_e===215)rt=this.decodeExtension(8,0);else if(_e===216)rt=this.decodeExtension(16,0);else if(_e===199){var it=this.lookU8();rt=this.decodeExtension(it,1)}else if(_e===200){var it=this.lookU16();rt=this.decodeExtension(it,2)}else if(_e===201){var it=this.lookU32();rt=this.decodeExtension(it,4)}else throw new DecodeError("Unrecognized type byte: ".concat(prettyByte(_e)));this.complete();for(var ot=this.stack;ot.length>0;){var at=ot[ot.length-1];if(at.type===STATE_ARRAY)if(at.array[at.position]=rt,at.position++,at.position===at.size)ot.pop(),rt=at.array;else continue e;else if(at.type===STATE_MAP_KEY){if(!isValidMapKeyType(rt))throw new DecodeError("The type of key must be string or number but "+typeof rt);if(rt==="__proto__")throw new DecodeError("The key __proto__ is not allowed");at.key=rt,at.type=STATE_MAP_VALUE;continue e}else if(at.map[at.key]=rt,at.readCount++,at.readCount===at.size)ot.pop(),rt=at.map;else{at.key=null,at.type=STATE_MAP_KEY;continue e}}return rt}},nt.prototype.readHeadByte=function(){return this.headByte===HEAD_BYTE_REQUIRED&&(this.headByte=this.readU8()),this.headByte},nt.prototype.complete=function(){this.headByte=HEAD_BYTE_REQUIRED},nt.prototype.readArraySize=function(){var _e=this.readHeadByte();switch(_e){case 220:return this.readU16();case 221:return this.readU32();default:{if(_e<160)return _e-144;throw new DecodeError("Unrecognized array type byte: ".concat(prettyByte(_e)))}}},nt.prototype.pushMapState=function(_e){if(_e>this.maxMapLength)throw new DecodeError("Max length exceeded: map length (".concat(_e,") > maxMapLengthLength (").concat(this.maxMapLength,")"));this.stack.push({type:STATE_MAP_KEY,size:_e,key:null,readCount:0,map:{}})},nt.prototype.pushArrayState=function(_e){if(_e>this.maxArrayLength)throw new DecodeError("Max length exceeded: array length (".concat(_e,") > maxArrayLength (").concat(this.maxArrayLength,")"));this.stack.push({type:STATE_ARRAY,size:_e,array:new Array(_e),position:0})},nt.prototype.decodeUtf8String=function(_e,rt){var it;if(_e>this.maxStrLength)throw new DecodeError("Max length exceeded: UTF-8 byte length (".concat(_e,") > maxStrLength (").concat(this.maxStrLength,")"));if(this.bytes.byteLength0){var _e=this.stack[this.stack.length-1];return _e.type===STATE_MAP_KEY}return!1},nt.prototype.decodeBinary=function(_e,rt){if(_e>this.maxBinLength)throw new DecodeError("Max length exceeded: bin length (".concat(_e,") > maxBinLength (").concat(this.maxBinLength,")"));if(!this.hasRemaining(_e+rt))throw MORE_DATA;var it=this.pos+rt,st=this.bytes.subarray(it,it+_e);return this.pos+=rt+_e,st},nt.prototype.decodeExtension=function(_e,rt){if(_e>this.maxExtLength)throw new DecodeError("Max length exceeded: ext length (".concat(_e,") > maxExtLength (").concat(this.maxExtLength,")"));var it=this.view.getInt8(this.pos+rt),st=this.decodeBinary(_e,rt+1);return this.extensionCodec.decode(st,it,this.context)},nt.prototype.lookU8=function(){return this.view.getUint8(this.pos)},nt.prototype.lookU16=function(){return this.view.getUint16(this.pos)},nt.prototype.lookU32=function(){return this.view.getUint32(this.pos)},nt.prototype.readU8=function(){var _e=this.view.getUint8(this.pos);return this.pos++,_e},nt.prototype.readI8=function(){var _e=this.view.getInt8(this.pos);return this.pos++,_e},nt.prototype.readU16=function(){var _e=this.view.getUint16(this.pos);return this.pos+=2,_e},nt.prototype.readI16=function(){var _e=this.view.getInt16(this.pos);return this.pos+=2,_e},nt.prototype.readU32=function(){var _e=this.view.getUint32(this.pos);return this.pos+=4,_e},nt.prototype.readI32=function(){var _e=this.view.getInt32(this.pos);return this.pos+=4,_e},nt.prototype.readU64=function(){var _e=getUint64(this.view,this.pos);return this.pos+=8,_e},nt.prototype.readI64=function(){var _e=getInt64(this.view,this.pos);return this.pos+=8,_e},nt.prototype.readU64AsBigInt=function(){var _e=this.view.getBigUint64(this.pos);return this.pos+=8,_e},nt.prototype.readI64AsBigInt=function(){var _e=this.view.getBigInt64(this.pos);return this.pos+=8,_e},nt.prototype.readF32=function(){var _e=this.view.getFloat32(this.pos);return this.pos+=4,_e},nt.prototype.readF64=function(){var _e=this.view.getFloat64(this.pos);return this.pos+=8,_e},nt}();function decode(nt,_e){var rt=new Decoder(_e);return rt.decode(nt)}var __generator$1=function(nt,_e){var rt={label:0,sent:function(){if(ot[0]&1)throw ot[1];return ot[1]},trys:[],ops:[]},it,st,ot,at;return at={next:ct(0),throw:ct(1),return:ct(2)},typeof Symbol=="function"&&(at[Symbol.iterator]=function(){return this}),at;function ct(pt){return function(mt){return ft([pt,mt])}}function ft(pt){if(it)throw new TypeError("Generator is already executing.");for(;at&&(at=0,pt[0]&&(rt=0)),rt;)try{if(it=1,st&&(ot=pt[0]&2?st.return:pt[0]?st.throw||((ot=st.return)&&ot.call(st),0):st.next)&&!(ot=ot.call(st,pt[1])).done)return ot;switch(st=0,ot&&(pt=[pt[0]&2,ot.value]),pt[0]){case 0:case 1:ot=pt;break;case 4:return rt.label++,{value:pt[1],done:!1};case 5:rt.label++,st=pt[1],pt=[0];continue;case 7:pt=rt.ops.pop(),rt.trys.pop();continue;default:if(ot=rt.trys,!(ot=ot.length>0&&ot[ot.length-1])&&(pt[0]===6||pt[0]===2)){rt=0;continue}if(pt[0]===3&&(!ot||pt[1]>ot[0]&&pt[1]1||ct(yt,vt)})})}function ct(yt,vt){try{ft(it[yt](vt))}catch(bt){xt(ot[0][3],bt)}}function ft(yt){yt.value instanceof __await?Promise.resolve(yt.value.v).then(pt,mt):xt(ot[0][2],yt)}function pt(yt){ct("next",yt)}function mt(yt){ct("throw",yt)}function xt(yt,vt){yt(vt),ot.shift(),ot.length&&ct(ot[0][0],ot[0][1])}};function isAsyncIterable(nt){return nt[Symbol.asyncIterator]!=null}function assertNonNull(nt){if(nt==null)throw new Error("Assertion Failure: value must not be null nor undefined")}function asyncIterableFromStream(nt){return __asyncGenerator(this,arguments,function(){var rt,it,st,ot;return __generator$1(this,function(at){switch(at.label){case 0:rt=nt.getReader(),at.label=1;case 1:at.trys.push([1,,9,10]),at.label=2;case 2:return[4,__await(rt.read())];case 3:return it=at.sent(),st=it.done,ot=it.value,st?[4,__await(void 0)]:[3,5];case 4:return[2,at.sent()];case 5:return assertNonNull(ot),[4,__await(ot)];case 6:return[4,at.sent()];case 7:return at.sent(),[3,2];case 8:return[3,10];case 9:return rt.releaseLock(),[7];case 10:return[2]}})})}function ensureAsyncIterable(nt){return isAsyncIterable(nt)?nt:asyncIterableFromStream(nt)}var __awaiter=function(nt,_e,rt,it){function st(ot){return ot instanceof rt?ot:new rt(function(at){at(ot)})}return new(rt||(rt=Promise))(function(ot,at){function ct(mt){try{pt(it.next(mt))}catch(xt){at(xt)}}function ft(mt){try{pt(it.throw(mt))}catch(xt){at(xt)}}function pt(mt){mt.done?ot(mt.value):st(mt.value).then(ct,ft)}pt((it=it.apply(nt,_e||[])).next())})},__generator=function(nt,_e){var rt={label:0,sent:function(){if(ot[0]&1)throw ot[1];return ot[1]},trys:[],ops:[]},it,st,ot,at;return at={next:ct(0),throw:ct(1),return:ct(2)},typeof Symbol=="function"&&(at[Symbol.iterator]=function(){return this}),at;function ct(pt){return function(mt){return ft([pt,mt])}}function ft(pt){if(it)throw new TypeError("Generator is already executing.");for(;at&&(at=0,pt[0]&&(rt=0)),rt;)try{if(it=1,st&&(ot=pt[0]&2?st.return:pt[0]?st.throw||((ot=st.return)&&ot.call(st),0):st.next)&&!(ot=ot.call(st,pt[1])).done)return ot;switch(st=0,ot&&(pt=[pt[0]&2,ot.value]),pt[0]){case 0:case 1:ot=pt;break;case 4:return rt.label++,{value:pt[1],done:!1};case 5:rt.label++,st=pt[1],pt=[0];continue;case 7:pt=rt.ops.pop(),rt.trys.pop();continue;default:if(ot=rt.trys,!(ot=ot.length>0&&ot[ot.length-1])&&(pt[0]===6||pt[0]===2)){rt=0;continue}if(pt[0]===3&&(!ot||pt[1]>ot[0]&&pt[1]>1|(i&21845)<<1;x=(x&52428)>>2|(x&13107)<<2,x=(x&61680)>>4|(x&3855)<<4,rev[i]=((x&65280)>>8|(x&255)<<8)>>1}var hMap=function(nt,_e,rt){for(var it=nt.length,st=0,ot=new u16(_e);st>ft]=pt}else for(ct=new u16(it),st=0;st>15-nt[st]);return ct},flt=new u8(288);for(var i=0;i<144;++i)flt[i]=8;for(var i=144;i<256;++i)flt[i]=9;for(var i=256;i<280;++i)flt[i]=7;for(var i=280;i<288;++i)flt[i]=8;var fdt=new u8(32);for(var i=0;i<32;++i)fdt[i]=5;var flrm=hMap(flt,9,1),fdrm=hMap(fdt,5,1),max=function(nt){for(var _e=nt[0],rt=1;rt_e&&(_e=nt[rt]);return _e},bits=function(nt,_e,rt){var it=_e/8|0;return(nt[it]|nt[it+1]<<8)>>(_e&7)&rt},bits16=function(nt,_e){var rt=_e/8|0;return(nt[rt]|nt[rt+1]<<8|nt[rt+2]<<16)>>(_e&7)},shft=function(nt){return(nt+7)/8|0},slc=function(nt,_e,rt){return(_e==null||_e<0)&&(_e=0),(rt==null||rt>nt.length)&&(rt=nt.length),new u8(nt.subarray(_e,rt))},ec=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],err=function(nt,_e,rt){var it=new Error(_e||ec[nt]);if(it.code=nt,Error.captureStackTrace&&Error.captureStackTrace(it,err),!rt)throw it;return it},inflt=function(nt,_e,rt,it){var st=nt.length,ot=it?it.length:0;if(!st||_e.f&&!_e.l)return rt||new u8(0);var at=!rt,ct=at||_e.i!=2,ft=_e.i;at&&(rt=new u8(st*3));var pt=function(Wn){var sn=rt.length;if(Wn>sn){var Ln=new u8(Math.max(sn*2,Wn));Ln.set(rt),rt=Ln}},mt=_e.f||0,xt=_e.p||0,yt=_e.b||0,vt=_e.l,bt=_e.d,wt=_e.m,Tt=_e.n,St=st*8;do{if(!vt){mt=bits(nt,xt,1);var Rt=bits(nt,xt+1,3);if(xt+=3,Rt)if(Rt==1)vt=flrm,bt=fdrm,wt=9,Tt=5;else if(Rt==2){var It=bits(nt,xt,31)+257,Nt=bits(nt,xt+10,15)+4,$t=It+bits(nt,xt+5,31)+1;xt+=14;for(var Ut=new u8($t),Ft=new u8(19),Vt=0;Vt>4;if(Mt<16)Ut[Vt++]=Mt;else{var qt=0,Kt=0;for(Mt==16?(Kt=3+bits(nt,xt,3),xt+=2,qt=Ut[Vt-1]):Mt==17?(Kt=3+bits(nt,xt,7),xt+=3):Mt==18&&(Kt=11+bits(nt,xt,127),xt+=7);Kt--;)Ut[Vt++]=qt}}var Gt=Ut.subarray(0,It),tn=Ut.subarray(It);wt=max(Gt),Tt=max(tn),vt=hMap(Gt,wt,1),bt=hMap(tn,Tt,1)}else err(1);else{var Mt=shft(xt)+4,Pt=nt[Mt-4]|nt[Mt-3]<<8,Dt=Mt+Pt;if(Dt>st){ft&&err(0);break}ct&&pt(yt+Pt),rt.set(nt.subarray(Mt,Dt),yt),_e.b=yt+=Pt,_e.p=xt=Dt*8,_e.f=mt;continue}if(xt>St){ft&&err(0);break}}ct&&pt(yt+131072);for(var jt=(1<>4;if(xt+=qt&15,xt>St){ft&&err(0);break}if(qt||err(2),Qt<256)rt[yt++]=Qt;else if(Qt==256){hn=xt,vt=null;break}else{var gn=Qt-254;if(Qt>264){var Vt=Qt-257,pn=fleb[Vt];gn=bits(nt,xt,(1<>4;En||err(3),xt+=En&15;var tn=fd[kn];if(kn>3){var pn=fdeb[kn];tn+=bits16(nt,xt)&(1<St){ft&&err(0);break}ct&&pt(yt+131072);var Hn=yt+gn;if(yt>3&1)+(_e>>4&1);it>0;it-=!nt[rt++]);return rt+(_e&2)},gzl=function(nt){var _e=nt.length;return(nt[_e-4]|nt[_e-3]<<8|nt[_e-2]<<16|nt[_e-1]<<24)>>>0},zls=function(nt,_e){return((nt[0]&15)!=8||nt[0]>>4>7||(nt[0]<<8|nt[1])%31)&&err(6,"invalid zlib data"),(nt[1]>>5&1)==+!_e&&err(6,"invalid zlib data: "+(nt[1]&32?"need":"unexpected")+" dictionary"),(nt[1]>>3&4)+2};function inflate(nt,_e,rt){return rt||(rt=_e,_e={}),typeof rt!="function"&&err(7),cbify(nt,_e,[bInflt],function(it){return pbf(inflateSync(it.data[0],gopt(it.data[1])))},1,rt)}function inflateSync(nt,_e){return inflt(nt,{i:2},_e&&_e.out,_e&&_e.dictionary)}function gunzip(nt,_e,rt){return rt||(rt=_e,_e={}),typeof rt!="function"&&err(7),cbify(nt,_e,[bInflt,guze,function(){return[gunzipSync]}],function(it){return pbf(gunzipSync(it.data[0],it.data[1]))},3,rt)}function gunzipSync(nt,_e){var rt=gzs(nt);return rt+8>nt.length&&err(6,"invalid gzip data"),inflt(nt.subarray(rt,-8),{i:2},_e&&_e.out||new u8(gzl(nt)),_e&&_e.dictionary)}function unzlib(nt,_e,rt){return rt||(rt=_e,_e={}),typeof rt!="function"&&err(7),cbify(nt,_e,[bInflt,zule,function(){return[unzlibSync]}],function(it){return pbf(unzlibSync(it.data[0],gopt(it.data[1])))},5,rt)}function unzlibSync(nt,_e){return inflt(nt.subarray(zls(nt,_e&&_e.dictionary),-4),{i:2},_e&&_e.out,_e&&_e.dictionary)}function decompress(nt,_e,rt){return rt||(rt=_e,_e={}),typeof rt!="function"&&err(7),nt[0]==31&&nt[1]==139&&nt[2]==8?gunzip(nt,_e,rt):(nt[0]&15)!=8||nt[0]>>4>7||(nt[0]<<8|nt[1])%31?inflate(nt,_e,rt):unzlib(nt,_e,rt)}var td=typeof TextDecoder<"u"&&new TextDecoder,tds=0;try{td.decode(et,{stream:!0}),tds=1}catch(nt){}async function deserializeGzippedMsgpackFile(nt,_e){const rt=await fetch(nt);if(!rt.ok)throw new Error(`Failed to fetch the file: ${rt.statusText}`);return new Promise(it=>{const st=parseInt(rt.headers.get("Content-Length"));if(typeof DecompressionStream>"u")console.log("DecompressionStream is unavailable. Using fallback."),_e({downloaded:.1*st,total:st}),rt.arrayBuffer().then(ot=>{_e({downloaded:.8*st,total:st}),decompress(new Uint8Array(ot),(at,ct)=>{_e({downloaded:1*st,total:st}),it(decode(ct))})});else{let ot=0;const at=new TransformStream({transform(ct,ft){ot+=ct.length,_e({downloaded:ot,total:st}),ft.enqueue(ct)}});decodeAsync(rt.body.pipeThrough(at).pipeThrough(new DecompressionStream("gzip"))).then(ct=>it(ct))}})}function PlaybackFromFile({fileUrl:nt}){const _e=reactExports.useContext(ViewerContext),rt=_e.messageQueueRef,it=reactExports.useRef(null),st=_e.useGui(It=>It.theme.dark_mode),[ot,at]=reactExports.useState({downloaded:0,total:0}),[ct,ft]=reactExports.useState("1x"),[pt,mt]=reactExports.useState(!1),[xt,yt]=reactExports.useState(null),vt=new URLSearchParams(window.location.search),bt=vt.getAll("synchronizedVideoOverlay"),wt=parseFloat(vt.get("synchronizedVideoTimeOffset")||"0"),[Tt,St]=reactExports.useState(0),Rt=useMantineTheme();reactExports.useEffect(()=>{deserializeGzippedMsgpackFile(nt,at).then(yt)},[]);const Mt=reactExports.useRef({currentTime:0,currentIndex:0}),Pt=reactExports.useCallback(()=>{if(xt===null)return;const It=Mt.current;for(;It.currentIndex=xt.durationSeconds&&xt.loopStartIndex!==null&&(It.currentIndex=xt.loopStartIndex,It.currentTime=xt.messages[xt.loopStartIndex][0]),St(It.currentTime)},[xt]);reactExports.useEffect(()=>{let It;const Nt=()=>{it.current&&it.current.readyState>=2&&(it.current.currentTime=Math.max(0,Mt.current.currentTime+wt)),It=requestAnimationFrame(Nt)};return Nt(),()=>{It&&cancelAnimationFrame(It)}},[]),reactExports.useEffect(()=>{const It=parseFloat(ct);if(xt!==null&&!pt){let Nt=Date.now();const $t=setInterval(()=>{const Ut=Date.now();Mt.current.currentTime+=(Ut-Nt)/1e3*It,Nt=Ut,Pt(),Mt.current.currentIndex===xt.messages.length&&xt.loopStartIndex===null&&clearInterval($t)},1e3/120);return()=>clearInterval($t)}},[Pt,xt,pt,ct,rt,St]),reactExports.useEffect(()=>{function It(Nt){Nt.code==="Space"&&mt(!pt)}return window.addEventListener("keydown",It),()=>{window.removeEventListener("keydown",It)}},[pt]);const Dt=reactExports.useCallback(It=>{It0&&jsxRuntimeExports.jsxs("div",{style:{position:"fixed",top:"1.5em",left:"1em",zIndex:2,maxHeight:"auto",border:"0.2em solid rgba(255, 255, 255, 0.5)",overflow:"hidden",borderRadius:"0.3rem",padding:"0"},children:[jsxRuntimeExports.jsx("div",{style:{textAlign:"center",position:"absolute",top:"0",backgroundColor:"rgba(0,0,0,0.75)",color:"#eee",fontFamily:"Inter",padding:"0.25em 1em 0.125em 1em",fontWeight:"500"},children:"Input video"}),jsxRuntimeExports.jsx("video",{ref:it,src:bt[0],style:{width:"15rem",maxWidth:"25vw",aspectRatio:"1",margin:"0",display:"block"},muted:!0})]}),jsxRuntimeExports.jsxs(Paper,{radius:"xs",shadow:"0.1em 0 1em 0 rgba(0,0,0,0.1)",style:{position:"fixed",bottom:"1em",left:"50%",transform:"translateX(-50%)",width:"25em",maxWidth:"95%",zIndex:1,padding:"0.5em",display:xt.durationSeconds===0?"none":"flex",alignItems:"center",justifyContent:"space-between",gap:"0.375em"},children:[jsxRuntimeExports.jsx(ActionIcon,{size:"md",variant:"subtle",children:pt?jsxRuntimeExports.jsx(IconPlayerPlayFilled,{onClick:()=>mt(!1),height:"1.125em",width:"1.125em"}):jsxRuntimeExports.jsx(IconPlayerPauseFilled,{onClick:()=>mt(!0),height:"1.125em",width:"1.125em"})}),jsxRuntimeExports.jsx(NumberInput,{size:"xs",hideControls:!0,value:Tt.toFixed(1),step:.01,styles:{wrapper:{width:"3.1em"},input:{padding:"0.2em",fontFamily:Rt.fontFamilyMonospace,textAlign:"center"}},onChange:It=>Dt(typeof It=="number"?It:parseFloat(It))}),jsxRuntimeExports.jsx(Slider,{thumbSize:0,radius:"xs",step:1e-4,style:{flexGrow:1},min:0,max:xt.durationSeconds,value:Tt,onChange:Dt,styles:{thumb:{display:"none"}}}),jsxRuntimeExports.jsx(Tooltip,{zIndex:10,label:"Playback speed",withinPortal:!0,children:jsxRuntimeExports.jsx(Select,{size:"xs",value:ct,onChange:It=>It===null?null:ft(It),radius:"xs",data:["0.5x","1x","2x","4x","8x"],styles:{wrapper:{width:"3.25em"}},comboboxProps:{zIndex:5,width:"5.25em"}})})]})]})}var __spreadArray=function(nt,_e,rt){if(rt||arguments.length===2)for(var it=0,st=_e.length,ot;it"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new ReactNativeInfo:typeof navigator<"u"?parseUserAgent(navigator.userAgent):getNodeVersion()}function matchUserAgent(nt){return nt!==""&&userAgentRules.reduce(function(_e,rt){var it=rt[0],st=rt[1];if(_e)return _e;var ot=st.exec(nt);return!!ot&&[it,ot]},!1)}function parseUserAgent(nt){var _e=matchUserAgent(nt);if(!_e)return null;var rt=_e[0],it=_e[1];if(rt==="searchbot")return new BotInfo;var st=it[1]&&it[1].split(".").join("_").split("_").slice(0,3);st?st.length{const nt=detect();if(nt===null||nt.version===null)console.log("Failed to detect browser"),notifications.show({title:"Could not detect browser version",message:"Your browser version could not be detected. It may not be supported.",autoClose:!1,color:"red"});else{const _e=parseFloat(nt.version);console.log(`Detected ${nt.name} version ${_e}`),(nt.name==="chrome"&&_e<91||nt.name==="edge"&&_e<91||nt.name==="firefox"&&_e<89||nt.name==="opera"&&_e<77||nt.name==="safari"&&_e<16.4)&¬ifications.show({title:"Unsuppported browser",message:`Your browser (${nt.name.slice(0,1).toUpperCase()+nt.name.slice(1)}/${nt.version}) is outdated, which may cause problems. Consider updating.`,autoClose:!1,color:"red"})}}),null}const ViewerContext=React.createContext(null);ColorManagement.enabled=!0;function ViewerRoot(){function nt(){let pt=window.location.href;return pt=pt.replace("http://","ws://"),pt=pt.replace("https://","wss://"),pt=pt.split("?")[0],pt.endsWith("/")&&(pt=pt.slice(0,-1)),pt}const _e=new URLSearchParams(window.location.search).getAll(searchParamKey),rt=_e.length>=1?_e[0]:nt(),it=new URLSearchParams(window.location.search),st=it.get("playbackPath"),ot=it.get("darkMode")!==null,at=it.get("showStats")!==null,ct=React.useRef({}),ft={messageSource:st===null?"websocket":"file_playback",useSceneTree:useSceneTreeState(ct),useGui:useGuiState(rt),sendMessageRef:React.useRef(st==null?pt=>console.log(`Tried to send ${pt.type} but websocket is not connected!`):()=>null),canvasRef:React.useRef(null),sceneRef:React.useRef(null),cameraRef:React.useRef(null),backgroundMaterialRef:React.useRef(null),cameraControlRef:React.useRef(null),sendCameraRef:React.useRef(null),resetCameraViewRef:React.useRef(null),nodeAttributesFromName:React.useRef({"":{wxyz:(()=>{const pt=new Quaternion().setFromEuler(new Euler(Math.PI/2,Math.PI,-Math.PI/2));return[pt.w,pt.x,pt.y,pt.z]})()}}),nodeRefFromName:ct,messageQueueRef:React.useRef([]),getRenderRequestState:React.useRef("ready"),getRenderRequest:React.useRef(null),scenePointerInfo:React.useRef({enabled:!1,dragStart:[0,0],dragEnd:[0,0],isDragging:!1}),canvas2dRef:React.useRef(null),skinnedMeshState:React.useRef({})};return ot&&(ft.useGui.getState().theme.dark_mode=ot),jsxRuntimeExports.jsx(ViewerContext.Provider,{value:ft,children:jsxRuntimeExports.jsxs(ViewerContents,{children:[ft.messageSource==="websocket"?jsxRuntimeExports.jsx(WebsocketMessageProducer,{}):null,ft.messageSource==="file_playback"?jsxRuntimeExports.jsx(PlaybackFromFile,{fileUrl:st}):null,at?jsxRuntimeExports.jsx(Stats,{className:"stats-panel"}):null]})})}function ViewerContents({children:nt}){const _e=React.useContext(ViewerContext),rt=_e.useGui(ot=>ot.theme.dark_mode),it=_e.useGui(ot=>ot.theme.colors),st=_e.useGui(ot=>ot.theme.control_layout);return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(ColorSchemeScript,{forceColorScheme:rt?"dark":"light"}),jsxRuntimeExports.jsxs(MantineProvider,{theme:{...theme,...it===null?{}:{colors:{custom:it},primaryColor:"custom"}},forceColorScheme:rt?"dark":"light",children:[nt,jsxRuntimeExports.jsx(Notifications,{position:"top-left",limit:10,containerWidth:"20em",styles:{root:{boxShadow:"0.1em 0 1em 0 rgba(0,0,0,0.1) !important"}}}),jsxRuntimeExports.jsx(BrowserWarning,{}),jsxRuntimeExports.jsx(ViserModal,{}),jsxRuntimeExports.jsxs(Box,{style:{width:"100%",height:"100%",display:"flex",position:"relative",flexDirection:"column"},children:[jsxRuntimeExports.jsx(Titlebar,{}),jsxRuntimeExports.jsxs(Box,{style:{width:"100%",position:"relative",flexGrow:1,overflow:"hidden",display:"flex"},children:[jsxRuntimeExports.jsxs(Box,{style:ot=>({backgroundColor:rt?ot.colors.dark[9]:"#fff",flexGrow:1,overflow:"hidden",height:"100%"}),children:[jsxRuntimeExports.jsx(Viewer2DCanvas,{}),jsxRuntimeExports.jsx(ViewerCanvas,{children:jsxRuntimeExports.jsx(FrameSynchronizedMessageHandler,{})}),_e.useGui(ot=>ot.theme.show_logo)&&_e.messageSource=="websocket"?jsxRuntimeExports.jsx(ViserLogo,{}):null]}),_e.messageSource=="websocket"?jsxRuntimeExports.jsx(ControlPanel,{control_layout:st}):null]})]})]})]})}function ViewerCanvas({children:nt}){const _e=React.useContext(ViewerContext),rt=useThrottledMessageSender(20),it=useMantineTheme();return jsxRuntimeExports.jsxs(Canvas,{camera:{position:[-3,3,-3],near:.05},gl:{preserveDrawingBuffer:!0},style:{position:"relative",zIndex:0,width:"100%",height:"100%"},ref:_e.canvasRef,onPointerDown:st=>{const ot=_e.scenePointerInfo.current;if(ot.enabled===!1)return;const at=_e.canvasRef.current.getBoundingClientRect();if(ot.dragStart=[st.clientX-at.left,st.clientY-at.top],ot.dragEnd=ot.dragStart,ndcFromPointerXy(_e,ot.dragEnd)===null||ot.isDragging)return;ot.isDragging=!0,_e.cameraControlRef.current.enabled=!1;const ct=_e.canvas2dRef.current.getContext("2d");ct.clearRect(0,0,ct.canvas.width,ct.canvas.height)},onPointerMove:st=>{const ot=_e.scenePointerInfo.current;if(ot.enabled===!1||!ot.isDragging)return;const at=_e.canvasRef.current.getBoundingClientRect(),ct=[st.clientX-at.left,st.clientY-at.top];if(ndcFromPointerXy(_e,ct)!==null&&(ot.dragEnd=ct,!(Math.abs(ot.dragEnd[0]-ot.dragStart[0])<=3&&Math.abs(ot.dragEnd[1]-ot.dragStart[1])<=3)&&ot.enabled==="rect-select")){const ft=_e.canvas2dRef.current.getContext("2d");ft.clearRect(0,0,ft.canvas.width,ft.canvas.height),ft.beginPath(),ft.fillStyle=it.primaryColor,ft.strokeStyle="blue",ft.globalAlpha=.2,ft.fillRect(ot.dragStart[0],ot.dragStart[1],ot.dragEnd[0]-ot.dragStart[0],ot.dragEnd[1]-ot.dragStart[1]),ft.globalAlpha=1,ft.stroke()}},onPointerUp:()=>{const st=_e.scenePointerInfo.current;if(_e.cameraControlRef.current.enabled=!0,st.enabled===!1||!st.isDragging)return;const ot=_e.canvas2dRef.current.getContext("2d");if(ot.clearRect(0,0,ot.canvas.width,ot.canvas.height),st.enabled==="click"){const at=new Raycaster,ct=ndcFromPointerXy(_e,st.dragEnd);if(ct===null)return;at.setFromCamera(ct,_e.cameraRef.current);const ft=rayToViserCoords(_e,at.ray),pt=opencvXyFromPointerXy(_e,st.dragEnd);rt({type:"ScenePointerMessage",event_type:"click",ray_origin:[ft.origin.x,ft.origin.y,ft.origin.z],ray_direction:[ft.direction.x,ft.direction.y,ft.direction.z],screen_pos:[[pt.x,pt.y]]})}else if(st.enabled==="rect-select"){const at=opencvXyFromPointerXy(_e,st.dragStart),ct=opencvXyFromPointerXy(_e,st.dragEnd),ft=Math.min(at.x,ct.x),pt=Math.max(at.x,ct.x),mt=Math.min(at.y,ct.y),xt=Math.max(at.y,ct.y);rt({type:"ScenePointerMessage",event_type:"rect-select",ray_origin:null,ray_direction:null,screen_pos:[[ft,mt],[pt,xt]]})}st.isDragging=!1},children:[nt,jsxRuntimeExports.jsx(BackgroundImage,{}),jsxRuntimeExports.jsx(AdaptiveDpr,{}),jsxRuntimeExports.jsx(SceneContextSetter,{}),jsxRuntimeExports.jsx(SynchronizedCameraControls,{}),jsxRuntimeExports.jsx(SplatRenderContext,{children:jsxRuntimeExports.jsx(SceneNodeThreeObject,{name:"",parent:null})}),jsxRuntimeExports.jsx(DefaultLights,{})]})}function DefaultLights(){const nt=React.useContext(ViewerContext),_e=nt.useSceneTree(st=>st.enableDefaultLights),rt=nt.useSceneTree(st=>st.environmentMap);let it;if(rt.hdri===null)it=null;else{const st={apartment:"lebombo_1k.hdr",city:"potsdamer_platz_1k.hdr",dawn:"kiara_1_dawn_1k.hdr",forest:"forest_slope_1k.hdr",lobby:"st_fagans_interior_1k.hdr",night:"dikhololo_night_1k.hdr",park:"rooitou_park_1k.hdr",studio:"studio_small_03_1k.hdr",sunset:"venice_sunset_1k.hdr",warehouse:"empty_warehouse_01_1k.hdr"};console.log(rt.environment_intensity),it=jsxRuntimeExports.jsx(Environment,{files:`hdri/${st[rt.hdri]}`,background:rt.background,backgroundBlurriness:rt.background_blurriness,backgroundIntensity:rt.background_intensity,backgroundRotation:rt.background_rotation,environmentIntensity:rt.environment_intensity,environmentRotation:rt.environment_rotation})}return _e?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[it,jsxRuntimeExports.jsx("directionalLight",{color:255,intensity:1,position:[0,1,0]}),jsxRuntimeExports.jsx("directionalLight",{color:65280,intensity:.2,position:[0,-1,0]})]}):it}function AdaptiveDpr(){const nt=useThree(_e=>_e.setDpr);return jsxRuntimeExports.jsx(PerformanceMonitor,{factor:1,ms:100,iterations:5,step:.1,bounds:_e=>{const rt=Math.min(_e*.75,85);return[Math.max(rt*.5,38),rt]},onChange:({factor:_e,fps:rt,refreshrate:it})=>{const st=window.devicePixelRatio*(.2+.8*_e);console.log(`[Performance] Setting DPR to ${st}; FPS=${rt}/${it}`),nt(st)}})}function Viewer2DCanvas(){const nt=React.useContext(ViewerContext);return reactExports.useEffect(()=>{const _e=new ResizeObserver(it=>{const{width:st,height:ot}=it[0].contentRect;rt.width=st,rt.height=ot}),rt=nt.canvas2dRef.current;return _e.observe(rt),()=>_e.disconnect()}),jsxRuntimeExports.jsx("canvas",{ref:nt.canvas2dRef,style:{position:"absolute",zIndex:1,width:"100%",height:"100%",pointerEvents:"none"}})}function BackgroundImage(){const nt=` + */var IconPlayerPlayFilled=createReactComponent("filled","player-play-filled","IconPlayerPlayFilled",[["path",{d:"M6 4v16a1 1 0 0 0 1.524 .852l13 -8a1 1 0 0 0 0 -1.704l-13 -8a1 1 0 0 0 -1.524 .852z",key:"svg-0"}]]);function FolderComponent({id:nt,props:{label:_e,visible:rt,expand_by_default:it}}){const st=reactExports.useContext(ViewerContext),[ot,{toggle:at}]=useDisclosure(it),ct=st.useGui(xt=>xt.guiIdSetFromContainerId[nt]),ft=reactExports.useContext(GuiComponentContext),pt=ct===void 0||Object.keys(ct).length===0,mt=ot?IconChevronUp:IconChevronDown;return rt?jsxRuntimeExports.jsxs(Paper,{withBorder:!0,className:folderWrapper,children:[jsxRuntimeExports.jsxs(Paper,{className:folderLabel,style:{cursor:pt?void 0:"pointer"},onClick:at,children:[_e,jsxRuntimeExports.jsx(mt,{className:folderToggleIcon,style:{display:pt?"none":void 0}})]}),jsxRuntimeExports.jsx(Collapse,{in:ot&&!pt,pt:"0.2em",children:jsxRuntimeExports.jsx(GuiComponentContext.Provider,{value:{...ft,folderDepth:ft.folderDepth+1},children:jsxRuntimeExports.jsx(ft.GuiContainer,{containerId:nt})})}),jsxRuntimeExports.jsx(Collapse,{in:!(ot&&!pt),children:jsxRuntimeExports.jsx(Box,{p:"xs"})})]}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{})}const[SliderProvider,useSliderContext]=createSafeContext("SliderProvider was not found in tree"),SliderRoot=reactExports.forwardRef(({size:nt,variant:_e,...rt},it)=>{const{getStyles:st}=useSliderContext();return jsxRuntimeExports.jsx(Box,{tabIndex:-1,variant:_e,size:nt,ref:it,...st("root"),...rt})});SliderRoot.displayName="@mantine/core/SliderRoot";const Thumb=reactExports.forwardRef(({max:nt,min:_e,value:rt,position:it,label:st,dragging:ot,draggingThisThumb:at,onMouseDown:ct,onKeyDownCapture:ft,labelTransitionProps:pt,labelAlwaysOn:mt,thumbLabel:xt,onFocus:yt,onBlur:vt,showLabelOnHover:bt,isHovered:wt,children:Tt=null,disabled:St},Rt)=>{const{getStyles:Mt}=useSliderContext(),[Pt,Dt]=reactExports.useState(!1),It=mt||ot||Pt||bt&&wt;return jsxRuntimeExports.jsxs(Box,{tabIndex:0,role:"slider","aria-label":xt,"aria-valuemax":nt,"aria-valuemin":_e,"aria-valuenow":rt,ref:Rt,__vars:{"--slider-thumb-offset":`${it}%`},...Mt("thumb",{focusable:!0,style:{...at?{zIndex:1e3}:{}}}),mod:{dragging:ot,disabled:St},onFocus:()=>{Dt(!0),typeof yt=="function"&&yt()},onBlur:()=>{Dt(!1),typeof vt=="function"&&vt()},onTouchStart:ct,onMouseDown:ct,onKeyDownCapture:ft,onClick:Nt=>Nt.stopPropagation(),children:[Tt,jsxRuntimeExports.jsx(Transition$1,{mounted:st!=null&&!!It,transition:"fade",duration:0,...pt,children:Nt=>jsxRuntimeExports.jsx("div",{...Mt("label",{style:{...Nt}}),children:st})})]})});Thumb.displayName="@mantine/core/SliderThumb";function getPosition({value:nt,min:_e,max:rt}){const it=(nt-_e)/(rt-_e)*100;return Math.min(Math.max(it,0),100)}function Marks({marks:nt,min:_e,max:rt,disabled:it,value:st,offset:ot,inverted:at}){const{getStyles:ct}=useSliderContext();if(!nt)return null;const ft=nt.map((pt,mt)=>reactExports.createElement(Box,{...ct("markWrapper"),__vars:{"--mark-offset":`${getPosition({value:pt.value,min:_e,max:rt})}%`},key:mt},jsxRuntimeExports.jsx(Box,{...ct("mark"),mod:{filled:!1,disabled:it}}),pt.label&&jsxRuntimeExports.jsx("div",{...ct("markLabel"),children:pt.label})));return jsxRuntimeExports.jsx("div",{children:ft})}Marks.displayName="@mantine/core/SliderMarks";function Track({children:nt,disabled:_e,marksOffset:rt,inverted:it,containerProps:st,...ot}){const{getStyles:at}=useSliderContext();return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(Box,{...at("trackContainer"),mod:{disabled:_e},...st,children:jsxRuntimeExports.jsxs(Box,{...at("track"),mod:{inverted:it,disabled:_e},children:[nt,jsxRuntimeExports.jsx(Marks,{...ot,offset:rt,disabled:_e,inverted:it})]})})})}Track.displayName="@mantine/core/SliderTrack";function getChangeValue({value:nt,containerWidth:_e,min:rt,max:it,step:st,precision:ot}){const ct=(_e?Math.min(Math.max(nt,0),_e)/_e:nt)*(it-rt),ft=(ct!==0?Math.round(ct/st)*st:0)+rt,pt=Math.max(ft,rt);return ot!==void 0?Number(pt.toFixed(ot)):pt}function getPrecision(nt){if(!nt)return 0;const _e=nt.toString().split(".");return _e.length>1?_e[1].length:0}const root="_root_1nr0a_1",label="_label_1nr0a_33",thumb="_thumb_1nr0a_54",trackContainer="_trackContainer_1nr0a_102",track="_track_1nr0a_102",bar="_bar_1nr0a_141",markWrapper="_markWrapper_1nr0a_167",mark="_mark_1nr0a_167",markLabel="_markLabel_1nr0a_208",classes={root,label,thumb,trackContainer,track,bar,markWrapper,mark,markLabel},defaultProps={radius:"xl",min:0,max:100,step:1,fixedEndpoints:!0,marks:[],label:nt=>nt,labelTransitionProps:{transition:"fade",duration:0},labelAlwaysOn:!1,thumbLabel:"",showLabelOnHover:!0,disabled:!1,scale:nt=>nt},varsResolver=(nt,{size:_e,color:rt,thumbSize:it,radius:st})=>({root:{"--slider-size":getSize(_e,"slider-size"),"--slider-color":rt?getThemeColor(rt,nt):void 0,"--slider-radius":st===void 0?void 0:getRadius(st),"--slider-thumb-size":it!==void 0?rem(it):"calc(var(--slider-size) * 2)"}}),MultiSlider=factory((nt,_e)=>{const rt=useProps("MultiSlider",defaultProps,nt),{classNames:it,styles:st,value:ot,onChange:at,onChangeEnd:ct,size:ft,min:pt,max:mt,step:xt,fixedEndpoints:yt,minRange:vt,precision:bt,defaultValue:wt,name:Tt,marks:St,label:Rt,labelTransitionProps:Mt,labelAlwaysOn:Pt,thumbLabel:Dt,showLabelOnHover:It,thumbChildren:Nt,disabled:$t,unstyled:Ut,scale:Ft,inverted:Vt,className:Xt,style:en,vars:nn,...rn}=rt,qt=useStyles({name:"MultiSlider",props:rt,classes,classNames:it,className:Xt,styles:st,style:en,vars:nn,varsResolver,unstyled:Ut}),{dir:Kt}=useDirection(),[Gt,tn]=reactExports.useState(!1),[jt,fn]=useUncontrolled({value:ot===void 0?ot:ot.map($n=>clamp$5($n,pt,mt)),defaultValue:wt===void 0?wt:wt.map($n=>clamp$5($n,pt,mt)),finalValue:[clamp$5(0,pt,mt)],onChange:at}),hn=reactExports.useRef(jt),Qt=reactExports.useRef(),gn=reactExports.useRef([]),pn=reactExports.useRef(-1),En=jt.map($n=>getPosition({value:$n,min:pt,max:mt})),kn=bt??getPrecision(xt);hn.current=jt;const Hn=($n,Tn,In)=>{const An=[...hn.current];An[Tn]=$n;const Vn=vt||xt;TnAn[Tn+1]-(Vn-1e-9)&&(An[Tn]=Math.max(pt,An[Tn+1]-Vn)),$n>(mt-(Vn-1e-9)||pt)&&(An[Tn]=hn.current[Tn])),Tn>0&&$n{if(!$t){const Tn=getChangeValue({value:$n,min:pt,max:mt,step:xt,precision:kn});Hn(Tn,pn.current,!1)}},[$t,pt,mt,xt,kn,fn]),{ref:Zn,active:Wn}=useMove(Xn,{onScrubEnd:()=>ct?.(hn.current)},Kt);function sn($n){return"TouchEvent"in window&&$n instanceof window.TouchEvent?$n.touches[0].clientX:$n.clientX}const Ln=$n=>{Zn.current.focus();const Tn=Zn.current.getBoundingClientRect(),In=sn($n.nativeEvent),An=getChangeValue({value:In-Tn.left,max:mt,min:pt,step:xt,containerWidth:Tn.width}),Vn=jt.map(ln=>Math.abs(ln-An)).indexOf(Math.min(...jt.map(ln=>Math.abs(ln-An))));pn.current=Vn},Bn=$n=>{if(!$t){const Tn=pn.current;switch($n.key){case"ArrowUp":{$n.preventDefault(),gn.current[Tn].focus(),Hn(Math.min(Math.max(hn.current[Tn]+xt,pt),mt),Tn,!0);break}case"ArrowRight":{$n.preventDefault(),gn.current[Tn]?.focus(),Hn(Math.min(Math.max(Kt==="rtl"?hn.current[Tn]-xt:hn.current[Tn]+xt,pt),mt),Tn,!0);break}case"ArrowDown":{$n.preventDefault(),gn.current[Tn]?.focus(),Hn(Math.min(Math.max(hn.current[Tn]-xt,pt),mt),Tn,!0);break}case"ArrowLeft":{$n.preventDefault(),gn.current[Tn]?.focus(),Hn(Math.min(Math.max(Kt==="rtl"?hn.current[Tn]+xt:hn.current[Tn]-xt,pt),mt),Tn,!0);break}case"Home":{$n.preventDefault(),gn.current[Tn]?.focus(),Hn(pt,Tn,!0);break}case"End":{$n.preventDefault(),gn.current[Tn]?.focus(),Hn(mt,Tn,!0);break}}}};return jsxRuntimeExports.jsx(SliderProvider,{value:{getStyles:qt},children:jsxRuntimeExports.jsxs(SliderRoot,{...rn,ref:useMergedRef(_e,Qt),onKeyDownCapture:Bn,onMouseDownCapture:()=>Qt.current?.focus(),size:ft,disabled:$t,children:[jsxRuntimeExports.jsx(Track,{inverted:Vt,offset:0,filled:0,value:0,marks:St,min:pt,max:mt,disabled:$t,containerProps:{ref:Zn,onMouseEnter:It?()=>tn(!0):void 0,onMouseLeave:It?()=>tn(!1):void 0,onTouchStartCapture:Ln,onTouchEndCapture:()=>{pn.current=-1},onMouseDownCapture:Ln,onMouseUpCapture:()=>{pn.current=-1}},children:jt.map(($n,Tn)=>jsxRuntimeExports.jsx(Thumb,{max:mt,min:pt,value:Ft($n),position:En[Tn],dragging:Wn,draggingThisThumb:Wn&&pn.current===Tn,label:typeof Rt=="function"?Rt(Ft($n)):Rt,ref:In=>{gn.current[Tn]=In},labelTransitionProps:Mt,labelAlwaysOn:Pt,thumbLabel:Dt,showLabelOnHover:It,isHovered:Gt,disabled:$t,children:Nt},Tn))}),jt.map(($n,Tn)=>jsxRuntimeExports.jsx("input",{type:"hidden",name:`${Tt}[]`,value:$n},Tn))]})})});MultiSlider.classes=classes;MultiSlider.displayName="MultiSlider";function MultiSliderComponent({id:nt,value:_e,props:{label:rt,hint:it,visible:st,disabled:ot,min:at,max:ct,precision:ft,step:pt,_marks:mt,fixed_endpoints:xt,min_range:yt}}){const{setValue:vt}=React.useContext(GuiComponentContext);if(!st)return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{});const bt=St=>vt(nt,St),wt=useMantineColorScheme().colorScheme,Tt=jsxRuntimeExports.jsx(Box,{mt:"0.2em",mb:"0.4em",children:jsxRuntimeExports.jsx(MultiSlider,{id:nt,className:mt===null?sliderDefaultMarks:void 0,size:"xs",radius:"xs",styles:St=>({thumb:{height:"0.75rem",width:"0.5rem"},trackContainer:{zIndex:3,position:"relative"},markLabel:{transform:"translate(-50%, 0.03rem)",fontSize:"0.6rem",textAlign:"center"},mark:{transform:"scale(1.85)"},markFilled:{background:ot?wt==="dark"?St.colors.dark[3]:St.colors.gray[4]:St.primaryColor}}),pt:"0.2em",pb:"0.4em",min:at,max:ct,step:pt??void 0,fixedEndpoints:xt,precision:ft,minRange:yt??void 0,marks:mt===null?[{value:at,label:`${parseInt(at.toFixed(6))}`},{value:ct,label:`${parseInt(ct.toFixed(6))}`}]:mt,value:_e,onChange:bt})});return jsxRuntimeExports.jsx(ViserInputComponent,{id:nt,hint:it,label:rt,children:Tt})}function UploadButtonComponent({id:nt,props:{disabled:_e,mime_type:rt,color:it,_icon_html:st,label:ot}}){const at=reactExports.useContext(ViewerContext),ct=React.useRef(null),{isUploading:ft,upload:pt}=useFileUpload({viewer:at,componentId:nt});return jsxRuntimeExports.jsxs(Box,{mx:"xs",mb:"0.5em",children:[jsxRuntimeExports.jsx("input",{type:"file",style:{display:"none"},id:`file_upload_${nt}`,name:"file",accept:rt,ref:ct,onChange:mt=>{const xt=mt.target;xt.files&&pt(xt.files[0])}}),jsxRuntimeExports.jsx(Button,{id:nt,fullWidth:!0,color:it??void 0,onClick:()=>{ct.current!==null&&(ct.current.value=ct.current.defaultValue,ct.current.click())},style:{height:"2.125em"},disabled:_e||ft,size:"sm",leftSection:st===null?void 0:jsxRuntimeExports.jsx("div",{className:htmlIconWrapper,dangerouslySetInnerHTML:{__html:st}}),children:ot})]})}function useFileUpload({viewer:nt,componentId:_e}){const rt=nt.useGui(ft=>ft.updateUploadState),it=nt.useGui(ft=>ft.uploadsInProgress[_e]),st=it?.totalBytes,ot=React.useMemo(()=>{if(st===void 0)return"";let ft=st;const pt=["B","K","M","G","T","P"];let mt=0;for(;ft>=100&&mt{if(it===void 0)return;const{notificationId:ft,filename:pt}=it;if(it.uploadedBytes===0)notifications.show({id:ft,title:`Uploading ${pt} (${ot})`,message:jsxRuntimeExports.jsx(Progress,{size:"sm",value:0}),autoClose:!1,withCloseButton:!1,loading:!0});else{const mt=it.uploadedBytes/it.totalBytes,xt=mt===1;notifications.update({id:ft,title:`Uploading ${pt} (${ot})`,message:xt?"File uploaded successfully.":jsxRuntimeExports.jsx(Progress,{size:"sm",transitionDuration:10,value:100*mt}),autoClose:xt,withCloseButton:xt,loading:!xt,icon:xt?jsxRuntimeExports.jsx(IconCheck,{}):void 0})}},[it,ot]);const at=it!==void 0&&it.uploadedBytesot.updateGuiProps),it=useThrottledMessageSender(50);function st(ot,at){rt(ot,{value:at}),it({type:"GuiUpdateMessage",id:ot,updates:{value:at}})}return jsxRuntimeExports.jsx(GuiComponentContext.Provider,{value:{folderDepth:0,GuiContainer,messageSender:it,setValue:st},children:jsxRuntimeExports.jsx(GuiContainer,{containerId:nt})})}function GuiContainer({containerId:nt}){const _e=React.useContext(ViewerContext),rt=_e.useGui(ct=>ct.guiIdSetFromContainerId[nt])??{},it=[...Object.keys(rt)],st=_e.useGui(ct=>ct.guiOrderFromId);if(rt===void 0)return null;let ot=it.map(ct=>({id:ct,order:st[ct]}));return ot=ot.sort((ct,ft)=>ct.order-ft.order),jsxRuntimeExports.jsx(Box,{pt:"xs",children:ot.map(ct=>jsxRuntimeExports.jsx(GeneratedInput,{guiId:ct.id},ct.id))})}function GeneratedInput(nt){const rt=React.useContext(ViewerContext).useGui(it=>it.guiConfigFromId[nt.guiId]);switch(rt.type){case"GuiFolderMessage":return jsxRuntimeExports.jsx(FolderComponent,{...rt});case"GuiTabGroupMessage":return jsxRuntimeExports.jsx(TabGroupComponent,{...rt});case"GuiMarkdownMessage":return jsxRuntimeExports.jsx(MarkdownComponent,{...rt});case"GuiPlotlyMessage":return jsxRuntimeExports.jsx(PlotlyComponent,{...rt});case"GuiButtonMessage":return jsxRuntimeExports.jsx(ButtonComponent,{...rt});case"GuiUploadButtonMessage":return jsxRuntimeExports.jsx(UploadButtonComponent,{...rt});case"GuiSliderMessage":return jsxRuntimeExports.jsx(SliderComponent,{...rt});case"GuiMultiSliderMessage":return jsxRuntimeExports.jsx(MultiSliderComponent,{...rt});case"GuiNumberMessage":return jsxRuntimeExports.jsx(NumberInputComponent,{...rt});case"GuiTextMessage":return jsxRuntimeExports.jsx(TextInputComponent,{...rt});case"GuiCheckboxMessage":return jsxRuntimeExports.jsx(CheckboxComponent,{...rt});case"GuiVector2Message":return jsxRuntimeExports.jsx(Vector2Component,{...rt});case"GuiVector3Message":return jsxRuntimeExports.jsx(Vector3Component,{...rt});case"GuiDropdownMessage":return jsxRuntimeExports.jsx(DropdownComponent,{...rt});case"GuiRgbMessage":return jsxRuntimeExports.jsx(RgbComponent,{...rt});case"GuiRgbaMessage":return jsxRuntimeExports.jsx(RgbaComponent,{...rt});case"GuiButtonGroupMessage":return jsxRuntimeExports.jsx(ButtonGroupComponent,{...rt});case"GuiProgressBarMessage":return jsxRuntimeExports.jsx(ProgressBarComponent,{...rt});default:assertNeverType(rt)}}function assertNeverType(nt){throw new Error("Unexpected object: "+nt.type)}function rgbToInt(nt){return nt[0]<<16|nt[1]<<8|nt[2]}function SceneNodeThreeChildren(nt){const _e=React.useContext(ViewerContext),[rt,it]=React.useState(_e.useSceneTree.getState().nodeFromName[nt.name]?.children??[]);return React.useEffect(()=>{let st=!1;return _e.useSceneTree.subscribe(ot=>{if(st)return;const at=ot.nodeFromName[nt.name]?.children;at===void 0||at===rt||at.length===0&&rt.length==0||(st=!0,setTimeout(()=>{st=!1;const ct=_e.useSceneTree.getState().nodeFromName[nt.name].children;it(ct)},at.length<=16?10:at.length<=128?50:200))})},[]),createPortal(jsxRuntimeExports.jsxs("group",{children:[rt&&rt.map(st=>jsxRuntimeExports.jsx(SceneNodeThreeObject,{name:st,parent:nt.parent},st)),jsxRuntimeExports.jsx(SceneNodeLabel,{name:nt.name})]}),nt.parent)}function SceneNodeLabel(nt){return React.useContext(ViewerContext).useSceneTree(it=>it.labelVisibleFromName[nt.name])?jsxRuntimeExports.jsx(Html,{children:jsxRuntimeExports.jsx("span",{style:{backgroundColor:"rgba(240, 240, 240, 0.9)",borderRadius:"0.2rem",userSelect:"none",padding:"0.1em 0.2em"},children:nt.name})}):null}function useObjectFactory(nt){const _e=React.useContext(ViewerContext),rt=useContextBridge();if(nt===void 0)return{makeObject:()=>null};switch(nt.type){case"FrameMessage":return{makeObject:it=>jsxRuntimeExports.jsx(CoordinateFrame,{ref:it,showAxes:nt.props.show_axes,axesLength:nt.props.axes_length,axesRadius:nt.props.axes_radius,originRadius:nt.props.origin_radius})};case"BatchedAxesMessage":return{makeObject:it=>jsxRuntimeExports.jsx(InstancedAxes,{ref:it,wxyzsBatched:new Float32Array(nt.props.wxyzs_batched.buffer.slice(nt.props.wxyzs_batched.byteOffset,nt.props.wxyzs_batched.byteOffset+nt.props.wxyzs_batched.byteLength)),positionsBatched:new Float32Array(nt.props.positions_batched.buffer.slice(nt.props.positions_batched.byteOffset,nt.props.positions_batched.byteOffset+nt.props.positions_batched.byteLength)),axes_length:nt.props.axes_length,axes_radius:nt.props.axes_radius}),computeClickInstanceIndexFromInstanceId:it=>Math.floor(it/3)};case"GridMessage":return{makeObject:it=>jsxRuntimeExports.jsx("group",{ref:it,children:jsxRuntimeExports.jsx(Grid,{args:[nt.props.width,nt.props.height,nt.props.width_segments,nt.props.height_segments],side:DoubleSide,cellColor:rgbToInt(nt.props.cell_color),cellThickness:nt.props.cell_thickness,cellSize:nt.props.cell_size,sectionColor:rgbToInt(nt.props.section_color),sectionThickness:nt.props.section_thickness,sectionSize:nt.props.section_size,rotation:nt.props.plane=="xz"?new Euler(0,0,0):nt.props.plane=="xy"?new Euler(Math.PI/2,0,0):nt.props.plane=="yx"?new Euler(0,Math.PI/2,Math.PI/2):nt.props.plane=="yz"?new Euler(0,0,Math.PI/2):nt.props.plane=="zx"?new Euler(0,Math.PI/2,0):nt.props.plane=="zy"?new Euler(-Math.PI/2,0,-Math.PI/2):void 0})})};case"PointCloudMessage":return{makeObject:it=>jsxRuntimeExports.jsx(PointCloud,{ref:it,pointSize:nt.props.point_size,pointBallNorm:nt.props.point_ball_norm,points:new Float32Array(nt.props.points.buffer.slice(nt.props.points.byteOffset,nt.props.points.byteOffset+nt.props.points.byteLength)),colors:new Uint8Array(nt.props.colors)})};case"SkinnedMeshMessage":case"MeshMessage":return{makeObject:it=>jsxRuntimeExports.jsx(ViserMesh,{ref:it,...nt})};case"CameraFrustumMessage":return{makeObject:it=>jsxRuntimeExports.jsx(CameraFrustum,{ref:it,fov:nt.props.fov,aspect:nt.props.aspect,scale:nt.props.scale,color:rgbToInt(nt.props.color),imageBinary:nt.props.image_binary,imageMediaType:nt.props.image_media_type})};case"TransformControlsMessage":{const it=nt.name,st=makeThrottledMessageSender(_e,50);return{makeObject:ot=>jsxRuntimeExports.jsx("group",{onClick:at=>at.stopPropagation(),children:jsxRuntimeExports.jsx(PivotControls,{ref:ot,scale:nt.props.scale,lineWidth:nt.props.line_width,fixed:nt.props.fixed,autoTransform:nt.props.auto_transform,activeAxes:nt.props.active_axes,disableAxes:nt.props.disable_axes,disableSliders:nt.props.disable_sliders,disableRotations:nt.props.disable_rotations,disableScaling:!0,translationLimits:nt.props.translation_limits,rotationLimits:nt.props.rotation_limits,depthTest:nt.props.depth_test,opacity:nt.props.opacity,onDrag:at=>{const ct=_e.nodeAttributesFromName.current;ct[nt.name]===void 0&&(ct[nt.name]={});const ft=new Quaternion;ft.setFromRotationMatrix(at);const pt=new Vector3().setFromMatrixPosition(at),mt=ct[nt.name];mt.wxyz=[ft.w,ft.x,ft.y,ft.z],mt.position=pt.toArray(),st({type:"TransformControlsUpdateMessage",name:it,wxyz:mt.wxyz,position:mt.position})}})}),unmountWhenInvisible:!0}}case"LabelMessage":return{makeObject:it=>jsxRuntimeExports.jsx("group",{ref:it,children:jsxRuntimeExports.jsx(Html,{children:jsxRuntimeExports.jsx("div",{style:{width:"10em",fontSize:"0.8em",transform:"translateX(0.1em) translateY(0.5em)"},children:jsxRuntimeExports.jsx("span",{style:{background:"#fff",border:"1px solid #777",borderRadius:"0.2em",color:"#333",padding:"0.2em"},children:nt.props.text})})})}),unmountWhenInvisible:!0};case"Gui3DMessage":return{makeObject:it=>jsxRuntimeExports.jsx("group",{ref:it,position:new Vector3(1e8,1e8,1e8),children:jsxRuntimeExports.jsx(Html,{children:jsxRuntimeExports.jsx(rt,{children:jsxRuntimeExports.jsx(Paper,{style:{width:"18em",fontSize:"0.875em",marginLeft:"0.5em",marginTop:"0.5em"},shadow:"0 0 0.8em 0 rgba(0,0,0,0.1)",pb:"0.25em",onPointerDown:st=>{st.stopPropagation()},children:jsxRuntimeExports.jsx(GeneratedGuiContainer,{containerId:nt.props.container_id})})})})}),unmountWhenInvisible:!0};case"ImageMessage":return{makeObject:it=>jsxRuntimeExports.jsx(ViserImage,{ref:it,...nt})};case"GlbMessage":return{makeObject:it=>jsxRuntimeExports.jsx(GlbAsset,{ref:it,glb_data:new Uint8Array(nt.props.glb_data),scale:nt.props.scale})};case"CatmullRomSplineMessage":return{makeObject:it=>jsxRuntimeExports.jsx("group",{ref:it,children:jsxRuntimeExports.jsx(CatmullRomLine,{points:nt.props.positions,closed:nt.props.closed,curveType:nt.props.curve_type,tension:nt.props.tension,lineWidth:nt.props.line_width,color:rgbToInt(nt.props.color),segments:nt.props.segments??void 0})})};case"CubicBezierSplineMessage":return{makeObject:it=>jsxRuntimeExports.jsx("group",{ref:it,children:[...Array(nt.props.positions.length-1).keys()].map(st=>jsxRuntimeExports.jsx(CubicBezierLine,{start:nt.props.positions[st],end:nt.props.positions[st+1],midA:nt.props.control_points[2*st],midB:nt.props.control_points[2*st+1],lineWidth:nt.props.line_width,color:rgbToInt(nt.props.color),segments:nt.props.segments??void 0},st))})};case"GaussianSplatsMessage":return{makeObject:it=>jsxRuntimeExports.jsx(SplatObject,{ref:it,buffer:new Uint32Array(nt.props.buffer.buffer.slice(nt.props.buffer.byteOffset,nt.props.buffer.byteOffset+nt.props.buffer.byteLength))})};case"DirectionalLightMessage":return{makeObject:it=>jsxRuntimeExports.jsx("directionalLight",{ref:it,intensity:nt.props.intensity,color:rgbToInt(nt.props.color)})};case"AmbientLightMessage":return{makeObject:it=>jsxRuntimeExports.jsx("ambientLight",{ref:it,intensity:nt.props.intensity,color:rgbToInt(nt.props.color)})};case"HemisphereLightMessage":return{makeObject:it=>jsxRuntimeExports.jsx("hemisphereLight",{ref:it,intensity:nt.props.intensity,color:rgbToInt(nt.props.sky_color),groundColor:rgbToInt(nt.props.ground_color)})};case"PointLightMessage":return{makeObject:it=>jsxRuntimeExports.jsx("pointLight",{ref:it,intensity:nt.props.intensity,color:rgbToInt(nt.props.color),distance:nt.props.distance,decay:nt.props.decay})};case"RectAreaLightMessage":return{makeObject:it=>jsxRuntimeExports.jsx("rectAreaLight",{ref:it,intensity:nt.props.intensity,color:rgbToInt(nt.props.color),width:nt.props.width,height:nt.props.height})};case"SpotLightMessage":return{makeObject:it=>jsxRuntimeExports.jsx("spotLight",{ref:it,intensity:nt.props.intensity,color:rgbToInt(nt.props.color),distance:nt.props.distance,angle:nt.props.angle,penumbra:nt.props.penumbra,decay:nt.props.decay})};default:return console.log("Received message did not match any known types:",nt),{makeObject:()=>null}}}function SceneNodeThreeObject(nt){const _e=React.useContext(ViewerContext),rt=_e.useSceneTree(Mt=>Mt.nodeFromName[nt.name]?.message),{makeObject:it,unmountWhenInvisible:st,computeClickInstanceIndexFromInstanceId:ot}=useObjectFactory(rt),[at,ct]=React.useState(!1),ft=_e.useSceneTree(Mt=>Mt.nodeFromName[nt.name]?.clickable)??!1,[pt,mt]=React.useState(null);React.useEffect(()=>{pt!==null&&(_e.nodeRefFromName.current[nt.name]=pt)},[pt]);const xt=React.useMemo(()=>{if(it===void 0)return null;const Mt=_e.nodeAttributesFromName.current;return nt.name in Mt||(Mt[nt.name]={}),Mt[nt.name].poseUpdateState="needsUpdate",it(mt)},[it]),yt=pt===null?null:jsxRuntimeExports.jsx(SceneNodeThreeChildren,{name:nt.name,parent:pt});function vt(){const Mt=_e.nodeAttributesFromName.current[nt.name];if(((Mt?.overrideVisibility===void 0?Mt?.visibility:Mt.overrideVisibility)??!0)===!1)return!1;if(nt.parent===null)return!0;let Dt=nt.parent.visible;return Dt&&nt.parent.traverseAncestors(It=>{Dt=Dt&&It.visible}),Dt}React.useEffect(()=>{const Mt=_e.nodeAttributesFromName.current[nt.name];Mt!==void 0&&(Mt.poseUpdateState="needsUpdate")}),useFrame(()=>{const Mt=_e.nodeAttributesFromName.current[nt.name];if(st){const Dt=vt();Dt&&at&&(pt!==null&&(pt.visible=!1),ct(!1)),!Dt&&!at&&ct(!0)}if(pt===null||Mt===void 0)return;const Pt=(Mt?.overrideVisibility===void 0?Mt?.visibility:Mt.overrideVisibility)??!0;if(pt.visible=Pt,Mt.poseUpdateState=="needsUpdate"){Mt.poseUpdateState="updated";const Dt=Mt.wxyz;Dt!==void 0&&pt.quaternion.set(Dt[1],Dt[2],Dt[3],Dt[0]);const It=Mt.position;It!==void 0&&pt.position.set(It[0],It[1],It[2]),pt.matrixAutoUpdate||pt.updateMatrix(),pt.matrixWorldAutoUpdate||pt.updateMatrixWorld()}},-1e4);const bt=useThrottledMessageSender(50),[wt,Tt]=React.useState(!1);useCursor(wt);const St=React.useRef(!1);!ft&&wt&&Tt(!1);const Rt=React.useRef({dragging:!1,startClientX:0,startClientY:0});return xt===void 0||at?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:yt}):ft?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs(ErrorBoundary,{fallbackRender:()=>(console.error("There was an error rendering a scene node object:",xt),null),children:[jsxRuntimeExports.jsx("group",{onPointerDown:Mt=>{if(!vt())return;Mt.stopPropagation();const Pt=Rt.current,Dt=_e.canvasRef.current.getBoundingClientRect();Pt.startClientX=Mt.clientX-Dt.left,Pt.startClientY=Mt.clientY-Dt.top,Pt.dragging=!1},onPointerMove:Mt=>{if(!vt())return;Mt.stopPropagation();const Pt=Rt.current,Dt=_e.canvasRef.current.getBoundingClientRect(),It=Mt.clientX-Dt.left-Pt.startClientX,Nt=Mt.clientY-Dt.top-Pt.startClientY;Math.abs(It)<=3&&Math.abs(Nt)<=3||(Pt.dragging=!0)},onPointerUp:Mt=>{if(!vt()||(Mt.stopPropagation(),Rt.current.dragging))return;const Dt=rayToViserCoords(_e,Mt.ray),It=_e.canvasRef.current.getBoundingClientRect(),Nt=opencvXyFromPointerXy(_e,[Mt.clientX-It.left,Mt.clientY-It.top]);bt({type:"SceneNodeClickMessage",name:nt.name,instance_index:ot===void 0?null:ot(Mt.instanceId),ray_origin:[Dt.origin.x,Dt.origin.y,Dt.origin.z],ray_direction:[Dt.direction.x,Dt.direction.y,Dt.direction.z],screen_pos:[Nt.x,Nt.y]})},onPointerOver:Mt=>{vt()&&(Mt.stopPropagation(),Tt(!0),St.current=!0)},onPointerOut:()=>{vt()&&(Tt(!1),St.current=!1)},children:jsxRuntimeExports.jsx(HoverableContext.Provider,{value:St,children:xt})}),yt]})}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("group",{children:xt}),yt]})}var lib={},ErrorCorrectLevel={L:1,M:0,Q:3,H:2},mode$1={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},mode=mode$1;function QR8bitByte(nt){this.mode=mode.MODE_8BIT_BYTE,this.data=nt}QR8bitByte.prototype={getLength:function(nt){return this.data.length},write:function(nt){for(var _e=0;_e>>7-nt%8&1)==1},put:function(nt,_e){for(var rt=0;rt<_e;rt++)this.putBit((nt>>>_e-rt-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(nt){var _e=Math.floor(this.length/8);this.buffer.length<=_e&&this.buffer.push(0),nt&&(this.buffer[_e]|=128>>>this.length%8),this.length++}};var BitBuffer$1=QRBitBuffer,QRMath={glog:function(nt){if(nt<1)throw new Error("glog("+nt+")");return QRMath.LOG_TABLE[nt]},gexp:function(nt){for(;nt<0;)nt+=255;for(;nt>=256;)nt-=255;return QRMath.EXP_TABLE[nt]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)};for(var i$2=0;i$2<8;i$2++)QRMath.EXP_TABLE[i$2]=1<=0;)_e^=QRUtil.G15<=0;)_e^=QRUtil.G18<>>=1;return _e},getPatternPosition:function(nt){return QRUtil.PATTERN_POSITION_TABLE[nt-1]},getMask:function(nt,_e,rt){switch(nt){case QRMaskPattern.PATTERN000:return(_e+rt)%2==0;case QRMaskPattern.PATTERN001:return _e%2==0;case QRMaskPattern.PATTERN010:return rt%3==0;case QRMaskPattern.PATTERN011:return(_e+rt)%3==0;case QRMaskPattern.PATTERN100:return(Math.floor(_e/2)+Math.floor(rt/3))%2==0;case QRMaskPattern.PATTERN101:return _e*rt%2+_e*rt%3==0;case QRMaskPattern.PATTERN110:return(_e*rt%2+_e*rt%3)%2==0;case QRMaskPattern.PATTERN111:return(_e*rt%3+(_e+rt)%2)%2==0;default:throw new Error("bad maskPattern:"+nt)}},getErrorCorrectPolynomial:function(nt){for(var _e=new Polynomial$1([1],0),rt=0;rt5&&(rt+=3+ot-5)}for(var it=0;it<_e-1;it++)for(var st=0;st<_e-1;st++){var pt=0;nt.isDark(it,st)&&pt++,nt.isDark(it+1,st)&&pt++,nt.isDark(it,st+1)&&pt++,nt.isDark(it+1,st+1)&&pt++,(pt==0||pt==4)&&(rt+=3)}for(var it=0;it<_e;it++)for(var st=0;st<_e-6;st++)nt.isDark(it,st)&&!nt.isDark(it,st+1)&&nt.isDark(it,st+2)&&nt.isDark(it,st+3)&&nt.isDark(it,st+4)&&!nt.isDark(it,st+5)&&nt.isDark(it,st+6)&&(rt+=40);for(var st=0;st<_e;st++)for(var it=0;it<_e-6;it++)nt.isDark(it,st)&&!nt.isDark(it+1,st)&&nt.isDark(it+2,st)&&nt.isDark(it+3,st)&&nt.isDark(it+4,st)&&!nt.isDark(it+5,st)&&nt.isDark(it+6,st)&&(rt+=40);for(var mt=0,st=0;st<_e;st++)for(var it=0;it<_e;it++)nt.isDark(it,st)&&mt++;var xt=Math.abs(100*mt/_e/_e-50)/5;return rt+=xt*10,rt}},util$1=QRUtil,BitByte=_8BitByte,RSBlock=RSBlock$1,BitBuffer=BitBuffer$1,util=util$1,Polynomial=Polynomial$2;function QRCode$1(nt,_e){this.typeNumber=nt,this.errorCorrectLevel=_e,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}var proto=QRCode$1.prototype;proto.addData=function(nt){var _e=new BitByte(nt);this.dataList.push(_e),this.dataCache=null};proto.isDark=function(nt,_e){if(nt<0||this.moduleCount<=nt||_e<0||this.moduleCount<=_e)throw new Error(nt+","+_e);return this.modules[nt][_e]};proto.getModuleCount=function(){return this.moduleCount};proto.make=function(){if(this.typeNumber<1){var nt=1;for(nt=1;nt<40;nt++){for(var _e=RSBlock.getRSBlocks(nt,this.errorCorrectLevel),rt=new BitBuffer,it=0,st=0;st<_e.length;st++)it+=_e[st].dataCount;for(var st=0;st=7&&this.setupTypeNumber(nt),this.dataCache==null&&(this.dataCache=QRCode$1.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,_e)};proto.setupPositionProbePattern=function(nt,_e){for(var rt=-1;rt<=7;rt++)if(!(nt+rt<=-1||this.moduleCount<=nt+rt))for(var it=-1;it<=7;it++)_e+it<=-1||this.moduleCount<=_e+it||(0<=rt&&rt<=6&&(it==0||it==6)||0<=it&&it<=6&&(rt==0||rt==6)||2<=rt&&rt<=4&&2<=it&&it<=4?this.modules[nt+rt][_e+it]=!0:this.modules[nt+rt][_e+it]=!1)};proto.getBestMaskPattern=function(){for(var nt=0,_e=0,rt=0;rt<8;rt++){this.makeImpl(!0,rt);var it=util.getLostPoint(this);(rt==0||nt>it)&&(nt=it,_e=rt)}return _e};proto.createMovieClip=function(nt,_e,rt){var it=nt.createEmptyMovieClip(_e,rt),st=1;this.make();for(var ot=0;ot>rt&1)==1;this.modules[Math.floor(rt/3)][rt%3+this.moduleCount-8-3]=it}for(var rt=0;rt<18;rt++){var it=!nt&&(_e>>rt&1)==1;this.modules[rt%3+this.moduleCount-8-3][Math.floor(rt/3)]=it}};proto.setupTypeInfo=function(nt,_e){for(var rt=this.errorCorrectLevel<<3|_e,it=util.getBCHTypeInfo(rt),st=0;st<15;st++){var ot=!nt&&(it>>st&1)==1;st<6?this.modules[st][8]=ot:st<8?this.modules[st+1][8]=ot:this.modules[this.moduleCount-15+st][8]=ot}for(var st=0;st<15;st++){var ot=!nt&&(it>>st&1)==1;st<8?this.modules[8][this.moduleCount-st-1]=ot:st<9?this.modules[8][15-st-1+1]=ot:this.modules[8][15-st-1]=ot}this.modules[this.moduleCount-8][8]=!nt};proto.mapData=function(nt,_e){for(var rt=-1,it=this.moduleCount-1,st=7,ot=0,at=this.moduleCount-1;at>0;at-=2)for(at==6&&at--;;){for(var ct=0;ct<2;ct++)if(this.modules[it][at-ct]==null){var ft=!1;ot>>st&1)==1);var pt=util.getMask(_e,it,at-ct);pt&&(ft=!ft),this.modules[it][at-ct]=ft,st--,st==-1&&(ot++,st=7)}if(it+=rt,it<0||this.moduleCount<=it){it-=rt,rt=-rt;break}}};QRCode$1.PAD0=236;QRCode$1.PAD1=17;QRCode$1.createData=function(nt,_e,rt){for(var it=RSBlock.getRSBlocks(nt,_e),st=new BitBuffer,ot=0;otct*8)throw new Error("code length overflow. ("+st.getLengthInBits()+">"+ct*8+")");for(st.getLengthInBits()+4<=ct*8&&st.put(0,4);st.getLengthInBits()%8!=0;)st.putBit(!1);for(;!(st.getLengthInBits()>=ct*8||(st.put(QRCode$1.PAD0,8),st.getLengthInBits()>=ct*8));)st.put(QRCode$1.PAD1,8);return QRCode$1.createBytes(st,it)};QRCode$1.createBytes=function(nt,_e){for(var rt=0,it=0,st=0,ot=new Array(_e.length),at=new Array(_e.length),ct=0;ct<_e.length;ct++){var ft=_e[ct].dataCount,pt=_e[ct].totalCount-ft;it=Math.max(it,ft),st=Math.max(st,pt),ot[ct]=new Array(ft);for(var mt=0;mt=0?vt.get(bt):0}}for(var wt=0,mt=0;mt<_e.length;mt++)wt+=_e[mt].totalCount;for(var Tt=new Array(wt),St=0,mt=0;mt=0||Object.prototype.hasOwnProperty.call(nt,it)&&(rt[it]=nt[it]);return rt}var propTypes$1={bgColor:_propTypes2$1.default.oneOfType([_propTypes2$1.default.object,_propTypes2$1.default.string]).isRequired,bgD:_propTypes2$1.default.string.isRequired,fgColor:_propTypes2$1.default.oneOfType([_propTypes2$1.default.object,_propTypes2$1.default.string]).isRequired,fgD:_propTypes2$1.default.string.isRequired,size:_propTypes2$1.default.number.isRequired,title:_propTypes2$1.default.string,viewBoxSize:_propTypes2$1.default.number.isRequired,xmlns:_propTypes2$1.default.string},QRCodeSvg=(0,_react$1.forwardRef)(function(nt,_e){var rt=nt.bgColor,it=nt.bgD,st=nt.fgD,ot=nt.fgColor,at=nt.size,ct=nt.title,ft=nt.viewBoxSize,pt=nt.xmlns,mt=pt===void 0?"http://www.w3.org/2000/svg":pt,xt=_objectWithoutProperties$1(nt,["bgColor","bgD","fgD","fgColor","size","title","viewBoxSize","xmlns"]);return _react2$1.default.createElement("svg",_extends$1({},xt,{height:at,ref:_e,viewBox:"0 0 "+ft+" "+ft,width:at,xmlns:mt}),ct?_react2$1.default.createElement("title",null,ct):null,_react2$1.default.createElement("path",{d:it,fill:rt}),_react2$1.default.createElement("path",{d:st,fill:ot}))});QRCodeSvg.displayName="QRCodeSvg";QRCodeSvg.propTypes=propTypes$1;QRCodeSvg$1.default=QRCodeSvg;Object.defineProperty(lib,"__esModule",{value:!0});lib.QRCode=void 0;var _extends=Object.assign||function(nt){for(var _e=1;_e=0||Object.prototype.hasOwnProperty.call(nt,it)&&(rt[it]=nt[it]);return rt}var propTypes={bgColor:_propTypes2.default.oneOfType([_propTypes2.default.object,_propTypes2.default.string]),fgColor:_propTypes2.default.oneOfType([_propTypes2.default.object,_propTypes2.default.string]),level:_propTypes2.default.string,size:_propTypes2.default.number,value:_propTypes2.default.string.isRequired},QRCode=(0,_react.forwardRef)(function(nt,_e){var rt=nt.bgColor,it=rt===void 0?"#FFFFFF":rt,st=nt.fgColor,ot=st===void 0?"#000000":st,at=nt.level,ct=at===void 0?"L":at,ft=nt.size,pt=ft===void 0?256:ft,mt=nt.value,xt=_objectWithoutProperties(nt,["bgColor","fgColor","level","size","value"]),yt=new _QRCode2.default(-1,_ErrorCorrectLevel2.default[ct]);yt.addData(mt),yt.make();var vt=yt.modules;return _react2.default.createElement(_QRCodeSvg2.default,_extends({},xt,{bgColor:it,bgD:vt.map(function(bt,wt){return bt.map(function(Tt,St){return Tt?"":"M "+St+" "+wt+" l 1 0 0 1 -1 0 Z"}).join(" ")}).join(" "),fgColor:ot,fgD:vt.map(function(bt,wt){return bt.map(function(Tt,St){return Tt?"M "+St+" "+wt+" l 1 0 0 1 -1 0 Z":""}).join(" ")}).join(" "),ref:_e,size:pt,viewBoxSize:vt.length}))});lib.QRCode=QRCode;QRCode.displayName="QRCode";QRCode.propTypes=propTypes;var _default=lib.default=QRCode,tableWrapper="z8daqr0",icon="z8daqr1",tableRow="z8daqr2";function SceneTreeTable(){const _e=React.useContext(ViewerContext).useSceneTree(rt=>rt.nodeFromName[""].children);return jsxRuntimeExports.jsx(Stack,{className:tableWrapper,style:{padding:"0.1em 0"},gap:0,children:_e.map(rt=>jsxRuntimeExports.jsx(SceneTreeTableRow,{nodeName:rt,isParentVisible:!0,indentCount:0},rt))})}const SceneTreeTableRow=React.memo(function nt(_e){const rt=React.useContext(ViewerContext),it=rt.useSceneTree(wt=>wt.nodeFromName[_e.nodeName].children),st=it.length>0,[ot,{toggle:at}]=useDisclosure(!1);function ct(wt,Tt){const St=rt.nodeAttributesFromName.current;St[wt].overrideVisibility=Tt,mt()}const ft=rt.useSceneTree(wt=>wt.setLabelVisibility),[,pt]=React.useState(Date.now());function mt(){pt(Date.now())}React.useEffect(()=>{const wt=setInterval(mt,200);return()=>{clearInterval(wt)}},[]);const xt=rt.nodeAttributesFromName.current[_e.nodeName],yt=(xt?.overrideVisibility===void 0?xt?.visibility:xt.overrideVisibility)??!0,vt=yt&&_e.isParentVisible,bt=yt?IconEye:IconEyeOff;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs(Box,{className:tableRow,style:{cursor:st?"pointer":void 0,marginLeft:(_e.indentCount*.75).toString()+"em"},onClick:st?at:void 0,onMouseOver:()=>ft(_e.nodeName,!0),onMouseOut:()=>ft(_e.nodeName,!1),children:[jsxRuntimeExports.jsx(Box,{style:{opacity:st?1:.3},children:ot?jsxRuntimeExports.jsx(IconCaretDown,{className:icon}):jsxRuntimeExports.jsx(IconCaretRight,{className:icon})}),jsxRuntimeExports.jsx(Tooltip,{label:"Override visibility",children:jsxRuntimeExports.jsx(bt,{style:{cursor:"pointer",opacity:vt?.85:.25},onClick:wt=>{wt.stopPropagation(),ct(_e.nodeName,!yt)}})}),jsxRuntimeExports.jsx(Box,{children:_e.nodeName.split("/").filter(wt=>wt.length>0).map((wt,Tt,St)=>jsxRuntimeExports.jsxs("span",{style:{userSelect:"none"},children:[jsxRuntimeExports.jsx("span",{style:{opacity:"0.3"},children:Tt===St.length-1?"/":`/${wt}`}),Tt===St.length-1?wt:""]},Tt))})]}),ot?it.map(wt=>jsxRuntimeExports.jsx(nt,{nodeName:wt,isParentVisible:vt,indentCount:_e.indentCount+1},wt)):null]})});function ServerControls(){const nt=React.useContext(ViewerContext),[_e,rt]=React.useState(!1);function it(ot){ot.key==="Enter"&&(ot.currentTarget.blur(),ot.currentTarget.focus())}const st=React.memo(SceneTreeTable);return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[_e?jsxRuntimeExports.jsx(Stats,{className:"stats-panel"}):null,jsxRuntimeExports.jsxs(Stack,{gap:"xs",children:[jsxRuntimeExports.jsx(TextInput,{label:"Server",defaultValue:nt.useGui(ot=>ot.server),onBlur:ot=>nt.useGui.setState({server:ot.currentTarget.value}),onKeyDown:it,styles:{input:{minHeight:"1.75rem",height:"1.75rem",padding:"0 0.5em"}}}),jsxRuntimeExports.jsx(TextInput,{label:"Label",defaultValue:nt.useGui(ot=>ot.label),onBlur:ot=>nt.useGui.setState({label:ot.currentTarget.value}),onKeyDown:it,styles:{input:{minHeight:"1.75rem",height:"1.75rem",padding:"0 0.5em"}},mb:"0.375em"}),jsxRuntimeExports.jsx(Button,{onClick:async()=>{if("showSaveFilePicker"in window&&(()=>{try{return window.self===window.top}catch{return!1}})()){const at=window.showSaveFilePicker({suggestedName:"render.png",types:[{accept:{"image/png":[".png"]}}]});nt.canvasRef.current?.toBlob(async ct=>{if(ct===null){console.error("Export failed");return}const pt=await(await at).createWritable();await pt.write(ct),await pt.close()})}else nt.canvasRef.current?.toBlob(at=>{if(at===null){console.error("Export failed");return}const ct=URL.createObjectURL(at),ft=document.createElement("a");ft.href=ct;const pt="render.png";ft.download=pt,document.body.appendChild(ft),ft.click(),document.body.removeChild(ft),URL.revokeObjectURL(ct)})},fullWidth:!0,leftSection:jsxRuntimeExports.jsx(IconPhoto,{size:"1rem"}),style:{height:"1.875rem"},children:"Export Canvas"}),jsxRuntimeExports.jsx(Button,{onClick:()=>{nt.resetCameraViewRef.current()},fullWidth:!0,leftSection:jsxRuntimeExports.jsx(IconHomeMove,{size:"1rem"}),style:{height:"1.875rem"},children:"Reset View"}),jsxRuntimeExports.jsx(Switch,{radius:"sm",label:"WebGL Statistics",onChange:ot=>{rt(ot.currentTarget.checked)},size:"sm"}),jsxRuntimeExports.jsx(Divider,{mt:"xs"}),jsxRuntimeExports.jsxs(Box,{children:[jsxRuntimeExports.jsx(Text,{mb:"0.2em",fw:500,children:"Scene tree"}),jsxRuntimeExports.jsx(st,{})]})]})]})}const BottomPanelContext=React.createContext(null);function BottomPanel({children:nt}){const _e=React.useRef(null),[rt,{toggle:it}]=useDisclosure(!0);return jsxRuntimeExports.jsx(BottomPanelContext.Provider,{value:{wrapperRef:_e,expanded:rt,toggleExpanded:it},children:jsxRuntimeExports.jsx(Paper,{radius:"0",style:st=>({borderTopWidth:"1px",borderTopStyle:"solid",borderColor:useMantineColorScheme().colorScheme=="dark"?st.colors.dark[4]:st.colors.gray[3],boxSizing:"border-box",width:"100%",zIndex:10,position:"fixed",bottom:0,left:0,margin:0,overflow:"scroll",minHeight:"3.5em",maxHeight:"60%",transition:"height 0.3s linear"}),ref:_e,children:nt})})}BottomPanel.Handle=function({children:_e}){const rt=React.useContext(BottomPanelContext);return jsxRuntimeExports.jsx(Box,{color:"red",style:it=>({borderBottomWidth:rt.expanded?"1px":void 0,borderBottomStyle:"solid",borderColor:useMantineColorScheme().colorScheme=="dark"?it.colors.dark[4]:it.colors.gray[3],cursor:"pointer",position:"relative",fontWeight:400,userSelect:"none",display:"flex",alignItems:"center",padding:"0 0.8em",height:"3.5em"}),onClick:()=>{rt.toggleExpanded()},children:_e})};BottomPanel.Contents=function({children:_e}){const rt=React.useContext(BottomPanelContext);return jsxRuntimeExports.jsx(Collapse,{in:rt.expanded,children:_e})};BottomPanel.HideWhenCollapsed=function({children:_e}){return React.useContext(BottomPanelContext)?.expanded??!0?_e:null};const touchEvents={move:"touchmove",end:"touchend"},mouseEvents={move:"mousemove",end:"mouseup"};function isTouchEvent(nt){return nt.type==="touchmove"}function isMouseEvent(nt){return nt.type==="mousemove"}const FloatingPanelContext=React.createContext(null);function FloatingPanel({children:nt,width:_e}){const rt=React.useRef(null),[it,{toggle:st}]=useDisclosure(!0),[ot,at]=React.useState(800),ct=React.useRef({dragging:!1,startPosX:0,startPosY:0,startClientX:0,startClientY:0}),ft=React.useRef({}),pt=(vt,bt,wt)=>Math.abs(vt+bt/2){const vt=rt.current;if(vt===null)return;const bt=vt.parentElement;if(bt===null)return;const wt=new ResizeObserver(()=>{ft.current.x===void 0&&(ft.current.x=pt(vt.offsetLeft,vt.clientWidth,bt.clientWidth)),ft.current.y===void 0&&(ft.current.y=pt(vt.offsetTop,vt.clientHeight,bt.clientHeight));const Tt=bt.clientHeight-mt*2-2.5*16;ot!==Tt&&at(Tt);let St=ft.current.x,Rt=ft.current.y;for(;St<0;)St+=bt.clientWidth;for(;Rt<0;)Rt+=bt.clientHeight;xt(St,Rt)});return wt.observe(vt),wt.observe(bt),()=>{wt.disconnect()}});const yt=vt=>{const bt=ct.current,wt=rt.current;if(!wt)return;vt.type=="touchstart"?(vt=vt,bt.startClientX=vt.touches[0].clientX,bt.startClientY=vt.touches[0].clientY):(vt=vt,bt.startClientX=vt.clientX,bt.startClientY=vt.clientY),bt.startPosX=wt.offsetLeft,bt.startPosY=wt.offsetTop;const Tt=vt.type=="touchstart"?touchEvents:mouseEvents;function St(Rt){let Mt=0,Pt=0;if(isTouchEvent(Rt)?(Rt=Rt,Mt=Rt.touches[0].clientX-bt.startClientX,Pt=Rt.touches[0].clientY-bt.startClientY):isMouseEvent(Rt)&&(Rt=Rt,Mt=Rt.clientX-bt.startClientX,Pt=Rt.clientY-bt.startClientY),Math.abs(Mt)<=3&&Math.abs(Pt)<=3)return;bt.dragging=!0;const Dt=bt.startPosX+Mt,It=bt.startPosY+Pt;[ft.current.x,ft.current.y]=xt(Dt,It)}window.addEventListener(Tt.move,St),window.addEventListener(Tt.end,()=>{vt.type=="touchstart"&&(bt.dragging=!1),window.removeEventListener(Tt.move,St)},{once:!0})};return jsxRuntimeExports.jsx(FloatingPanelContext.Provider,{value:{wrapperRef:rt,expanded:it,width:_e,maxHeight:ot,toggleExpanded:st,dragHandler:yt,dragInfo:ct},children:jsxRuntimeExports.jsx(Paper,{radius:"xs",shadow:"0.1em 0 1em 0 rgba(0,0,0,0.1)",style:{boxSizing:"border-box",width:_e,zIndex:10,position:"absolute",top:"1em",right:"1em",margin:0,"& .expandIcon":{transform:"rotate(0)"},overflow:"hidden"},ref:rt,children:nt})})}FloatingPanel.Handle=function({children:_e}){const rt=React.useContext(FloatingPanelContext);return jsxRuntimeExports.jsx(Box,{style:it=>({borderRadius:"0.2em 0.2em 0 0",lineHeight:"1.5em",cursor:"pointer",position:"relative",fontWeight:400,userSelect:"none",display:"flex",alignItems:"center",padding:"0 0.75em",height:"2.75em",borderBottomWidth:rt.expanded?"1px":0,borderBottomStyle:"solid",borderColor:useMantineColorScheme().colorScheme=="dark"?it.colors.dark[4]:it.colors.gray[3]}),onClick:()=>{const it=rt.dragInfo.current;if(it.dragging){it.dragging=!1;return}rt.toggleExpanded()},onTouchStart:it=>{rt.dragHandler(it)},onMouseDown:it=>{rt.dragHandler(it)},children:_e})};FloatingPanel.Contents=function({children:_e}){const rt=React.useContext(FloatingPanelContext);return jsxRuntimeExports.jsx(Collapse,{in:rt.expanded,children:jsxRuntimeExports.jsx(ScrollArea.Autosize,{mah:rt.maxHeight,children:jsxRuntimeExports.jsx(Box,{w:rt.width,children:_e})})})};FloatingPanel.HideWhenCollapsed=function({children:_e}){return React.useContext(FloatingPanelContext)?.expanded??!0?_e:null};const SidebarPanelContext=React.createContext(null);function SidebarPanel({children:nt,collapsible:_e,width:rt}){const[it,{toggle:st}]=useDisclosure(!1),ot=jsxRuntimeExports.jsx(Box,{style:at=>({position:"absolute",top:0,right:it?"0em":"-3em",transitionProperty:"right",transitionDuration:"0.5s",transitionDelay:"0.25s",borderBottomLeftRadius:"0.5em",backgroundColor:useMantineColorScheme().colorScheme=="dark"?at.colors.dark[5]:at.colors.gray[2],padding:"0.5em"}),children:jsxRuntimeExports.jsx(ActionIcon,{onClick:at=>{at.stopPropagation(),st()},children:jsxRuntimeExports.jsx(Tooltip,{zIndex:100,label:"Show sidebar",children:jsxRuntimeExports.jsx(IconChevronLeft,{})})})});return jsxRuntimeExports.jsxs(SidebarPanelContext.Provider,{value:{collapsible:_e,toggleCollapsed:st},children:[ot,jsxRuntimeExports.jsx(Paper,{shadow:"0 0 1em 0 rgba(0,0,0,0.1)",style:{width:it?0:rt,boxSizing:"content-box",transition:"width 0.5s 0s",zIndex:8}}),jsxRuntimeExports.jsx(Paper,{radius:0,style:{width:it?0:rt,top:0,bottom:0,right:0,position:"absolute",boxSizing:"content-box",transition:"width 0.5s 0s",zIndex:20},children:jsxRuntimeExports.jsx(Box,{style:{width:rt,height:"100%",display:"flex",flexDirection:"column"},children:nt})})]})}SidebarPanel.Handle=function({children:_e}){const{toggleCollapsed:rt,collapsible:it}=React.useContext(SidebarPanelContext),st=jsxRuntimeExports.jsx(ActionIcon,{onClick:ot=>{ot.stopPropagation(),rt()},children:jsxRuntimeExports.jsx(Tooltip,{zIndex:100,label:"Collapse sidebar",children:jsxRuntimeExports.jsx(IconChevronRight,{stroke:1.625})})});return jsxRuntimeExports.jsxs(Box,{p:"xs",style:ot=>({borderBottom:"1px solid",borderColor:useMantineColorScheme().colorScheme=="dark"?ot.colors.dark[4]:ot.colors.gray[3],lineHeight:"1.5em",fontWeight:400,position:"relative",zIndex:20,alignItems:"center",display:"flex",flexDirection:"row"}),children:[_e,it?st:null]})};SidebarPanel.Contents=function({children:_e}){return jsxRuntimeExports.jsx(ScrollArea,{style:{flexGrow:1},children:_e})};const ROOT_CONTAINER_ID="root";function ControlPanel(nt){const _e=useMantineTheme(),rt=useMediaQuery(`(max-width: ${_e.breakpoints.xs})`),it=React.useContext(ViewerContext),st=it.useGui(xt=>"root"in xt.guiIdSetFromContainerId),[ot,{toggle:at}]=useDisclosure(!1),ct=it.useGui(xt=>xt.theme.control_width),ft=ct=="small"?"16em":ct=="medium"?"20em":ct=="large"?"24em":null,pt=jsxRuntimeExports.jsx(ActionIcon,{onClick:xt=>{xt.stopPropagation(),at()},style:{display:st?void 0:"none",transform:"translateY(0.05em)"},children:jsxRuntimeExports.jsx(Tooltip,{zIndex:100,label:ot?"Return to GUI":"Connection & diagnostics",withinPortal:!0,children:ot?jsxRuntimeExports.jsx(IconArrowBack,{stroke:1.625}):jsxRuntimeExports.jsx(IconAdjustments,{stroke:1.625})})}),mt=jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(Collapse,{in:!st||ot,p:"xs",pt:"0.375em",children:jsxRuntimeExports.jsx(ServerControls,{})}),jsxRuntimeExports.jsx(Collapse,{in:st&&!ot,children:jsxRuntimeExports.jsx(GeneratedGuiContainer,{containerId:ROOT_CONTAINER_ID})})]});return rt?jsxRuntimeExports.jsxs(BottomPanel,{children:[jsxRuntimeExports.jsxs(BottomPanel.Handle,{children:[jsxRuntimeExports.jsx(ConnectionStatus,{}),jsxRuntimeExports.jsxs(BottomPanel.HideWhenCollapsed,{children:[jsxRuntimeExports.jsx(ShareButton,{}),pt]})]}),jsxRuntimeExports.jsx(BottomPanel.Contents,{children:mt})]}):nt.control_layout==="floating"?jsxRuntimeExports.jsxs(FloatingPanel,{width:ft,children:[jsxRuntimeExports.jsxs(FloatingPanel.Handle,{children:[jsxRuntimeExports.jsx(ConnectionStatus,{}),jsxRuntimeExports.jsxs(FloatingPanel.HideWhenCollapsed,{children:[jsxRuntimeExports.jsx(ShareButton,{}),pt]})]}),jsxRuntimeExports.jsx(FloatingPanel.Contents,{children:mt})]}):jsxRuntimeExports.jsxs(SidebarPanel,{width:ft,collapsible:nt.control_layout==="collapsible",children:[jsxRuntimeExports.jsxs(SidebarPanel.Handle,{children:[jsxRuntimeExports.jsx(ConnectionStatus,{}),jsxRuntimeExports.jsx(ShareButton,{}),pt]}),jsxRuntimeExports.jsx(SidebarPanel.Contents,{children:mt})]})}function ConnectionStatus(){const{useGui:nt}=React.useContext(ViewerContext),_e=nt(it=>it.websocketConnected),rt=nt(it=>it.label);return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{style:{width:"1.1em"}})," ",jsxRuntimeExports.jsx(Transition$1,{transition:"skew-down",mounted:_e,children:it=>jsxRuntimeExports.jsx(IconCloudCheck,{color:"#0b0",style:{position:"absolute",width:"1.25em",height:"1.25em",...it}})}),jsxRuntimeExports.jsx(Transition$1,{transition:"skew-down",mounted:!_e,children:it=>jsxRuntimeExports.jsx(Loader$1,{size:"xs",type:"dots",color:"red",style:{position:"absolute",...it}})}),jsxRuntimeExports.jsx(Box,{px:"xs",style:{flexGrow:1},lts:"-0.5px",pt:"0.1em",children:rt!==""?rt:_e?"Connected":"Connecting..."})]})}function ShareButton(){const nt=React.useContext(ViewerContext),_e=nt.useGui(yt=>yt.websocketConnected),rt=nt.useGui(yt=>yt.shareUrl),it=nt.useGui(yt=>yt.setShareUrl),[st,ot]=React.useState(!1),[at,{open:ct,close:ft}]=useDisclosure(!1),[pt,{toggle:mt}]=useDisclosure();if(React.useEffect(()=>{rt!==null&&ot(!1)},[rt]),React.useEffect(()=>{!_e&&at&&ft()},[_e,at]),nt.useGui(yt=>yt.theme).show_share_button===!1)return null;const xt=useMantineColorScheme().colorScheme;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(Tooltip,{zIndex:100,label:_e?"Share":"Share (needs connection)",withinPortal:!0,children:jsxRuntimeExports.jsx(ActionIcon,{onClick:yt=>{yt.stopPropagation(),ct()},style:{transform:"translateY(0.05em)"},disabled:!_e,children:jsxRuntimeExports.jsx(IconShare,{stroke:2,height:"1.125em",width:"1.125em"})})}),jsxRuntimeExports.jsxs(Modal,{title:"Share",opened:at,onClose:ft,withCloseButton:!1,zIndex:100,withinPortal:!0,onClick:yt=>yt.stopPropagation(),onMouseDown:yt=>yt.stopPropagation(),onMouseMove:yt=>yt.stopPropagation(),onMouseUp:yt=>yt.stopPropagation(),styles:{title:{fontWeight:600}},children:[rt===null?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:st?jsxRuntimeExports.jsx(Stack,{mb:"xl",children:jsxRuntimeExports.jsx(Loader$1,{size:"xl",mx:"auto",type:"dots"})}):jsxRuntimeExports.jsxs(Stack,{mb:"md",children:[jsxRuntimeExports.jsx(Text,{children:"Create a public, shareable URL to this Viser instance."}),jsxRuntimeExports.jsx(Button,{fullWidth:!0,onClick:()=>{nt.sendMessageRef.current({type:"ShareUrlRequest"}),ot(!0)},children:"Request Share URL"})]})}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(Text,{children:"Share URL is connected."}),jsxRuntimeExports.jsxs(Stack,{gap:"xs",my:"md",children:[jsxRuntimeExports.jsx(TextInput,{value:rt}),jsxRuntimeExports.jsxs(Flex,{justify:"space-between",columnGap:"0.5em",align:"center",children:[jsxRuntimeExports.jsx(CopyButton,{value:rt,children:({copied:yt,copy:vt})=>jsxRuntimeExports.jsx(Button,{style:{width:"50%"},leftSection:yt?jsxRuntimeExports.jsx(IconCheck,{height:"1.375em",width:"1.375em"}):jsxRuntimeExports.jsx(IconCopy,{height:"1.375em",width:"1.375em"}),onClick:vt,variant:yt?"outline":"filled",children:yt?"Copied!":"Copy URL"})}),jsxRuntimeExports.jsx(Button,{style:{flexGrow:1},leftSection:pt?jsxRuntimeExports.jsx(IconQrcodeOff,{}):jsxRuntimeExports.jsx(IconQrcode,{}),onClick:mt,children:"QR Code"}),jsxRuntimeExports.jsx(Tooltip,{zIndex:100,label:"Disconnect",withinPortal:!0,children:jsxRuntimeExports.jsx(Button,{color:"red",onClick:()=>{nt.sendMessageRef.current({type:"ShareUrlDisconnect"}),it(null)},children:jsxRuntimeExports.jsx(IconPlugConnectedX,{})})})]}),jsxRuntimeExports.jsx(Collapse,{in:pt,children:jsxRuntimeExports.jsx(_default,{value:rt,fgColor:xt==="dark"?"#ffffff":"#000000",bgColor:"rgba(0,0,0,0)",level:"M",style:{width:"100%",height:"auto",margin:"1em auto 0 auto"}})})]})]}),jsxRuntimeExports.jsxs(Text,{size:"xs",children:["This feature is experimental. Problems? Consider"," ",jsxRuntimeExports.jsx(Anchor,{href:"https://github.com/nerfstudio-project/viser/issues",children:"reporting on GitHub"}),"."]})]})]})}var t,e,s,i$1;(function(nt){nt.HEX="HEX",nt.RGB="RGB",nt.HSL="HSL",nt.CIELab="CIELab",nt.CMYK="CMYK"})(t||(t={})),function(nt){nt.ANALOGOUS="ANALOGOUS",nt.COMPLEMENTARY="COMPLEMENTARY",nt.SPLIT_COMPLEMENTARY="SPLIT_COMPLEMENTARY",nt.TRIADIC="TRIADIC",nt.TETRADIC="TETRADIC",nt.SQUARE="SQUARE"}(e||(e={})),function(nt){nt.ADDITIVE="ADDITIVE",nt.SUBTRACTIVE="SUBTRACTIVE"}(s||(s={})),function(nt){nt.black="#000000",nt.silver="#C0C0C0",nt.gray="#808080",nt.white="#FFFFFF",nt.maroon="#800000",nt.red="#FF0000",nt.purple="#800080",nt.fuchsia="#FF00FF",nt.green="#008000",nt.lime="#00FF00",nt.olive="#808000",nt.yellow="#FFFF00",nt.navy="#000080",nt.blue="#0000FF",nt.teal="#008080",nt.aqua="#00FFFF",nt.orange="#FFA500",nt.aliceblue="#F0F8FF",nt.antiquewhite="#FAEBD7",nt.aquamarine="#7FFFD4",nt.azure="#F0FFFF",nt.beige="#F5F5DC",nt.bisque="#FFE4C4",nt.blanchedalmond="#FFEBCD",nt.blueviolet="#8A2BE2",nt.brown="#A52A2A",nt.burlywood="#DEB887",nt.cadetblue="#5F9EA0",nt.chartreuse="#7FFF00",nt.chocolate="#D2691E",nt.coral="#FF7F50",nt.cornflowerblue="#6495ED",nt.cornsilk="#FFF8DC",nt.crimson="#DC143C",nt.cyan="#00FFFF",nt.darkblue="#00008B",nt.darkcyan="#008B8B",nt.darkgoldenrod="#B8860B",nt.darkgray="#A9A9A9",nt.darkgreen="#006400",nt.darkgrey="#A9A9A9",nt.darkkhaki="#BDB76B",nt.darkmagenta="#8B008B",nt.darkolivegreen="#556B2F",nt.darkorange="#FF8C00",nt.darkorchid="#9932CC",nt.darkred="#8B0000",nt.darksalmon="#E9967A",nt.darkseagreen="#8FBC8F",nt.darkslateblue="#483D8B",nt.darkslategray="#2F4F4F",nt.darkslategrey="#2F4F4F",nt.darkturquoise="#00CED1",nt.darkviolet="#9400D3",nt.deeppink="#FF1493",nt.deepskyblue="#00BFFF",nt.dimgray="#696969",nt.dimgrey="#696969",nt.dodgerblue="#1E90FF",nt.firebrick="#B22222",nt.floralwhite="#FFFAF0",nt.forestgreen="#228B22",nt.gainsboro="#DCDCDC",nt.ghostwhite="#F8F8FF",nt.gold="#FFD700",nt.goldenrod="#DAA520",nt.greenyellow="#ADFF2F",nt.grey="#808080",nt.honeydew="#F0FFF0",nt.hotpink="#FF69B4",nt.indianred="#CD5C5C",nt.indigo="#4B0082",nt.ivory="#FFFFF0",nt.khaki="#F0E68C",nt.lavender="#E6E6FA",nt.lavenderblush="#FFF0F5",nt.lawngreen="#7CFC00",nt.lemonchiffon="#FFFACD",nt.lightblue="#ADD8E6",nt.lightcoral="#F08080",nt.lightcyan="#E0FFFF",nt.lightgoldenrodyellow="#FAFAD2",nt.lightgray="#D3D3D3",nt.lightgreen="#90EE90",nt.lightgrey="#D3D3D3",nt.lightpink="#FFB6C1",nt.lightsalmon="#FFA07A",nt.lightseagreen="#20B2AA",nt.lightskyblue="#87CEFA",nt.lightslategray="#778899",nt.lightslategrey="#778899",nt.lightsteelblue="#B0C4DE",nt.lightyellow="#FFFFE0",nt.limegreen="#32CD32",nt.linen="#FAF0E6",nt.magenta="#FF00FF",nt.mediumaquamarine="#66CDAA",nt.mediumblue="#0000CD",nt.mediumorchid="#BA55D3",nt.mediumpurple="#9370DB",nt.mediumseagreen="#3CB371",nt.mediumslateblue="#7B68EE",nt.mediumspringgreen="#00FA9A",nt.mediumturquoise="#48D1CC",nt.mediumvioletred="#C71585",nt.midnightblue="#191970",nt.mintcream="#F5FFFA",nt.mistyrose="#FFE4E1",nt.moccasin="#FFE4B5",nt.navajowhite="#FFDEAD",nt.oldlace="#FDF5E6",nt.olivedrab="#6B8E23",nt.orangered="#FF4500",nt.orchid="#DA70D6",nt.palegoldenrod="#EEE8AA",nt.palegreen="#98FB98",nt.paleturquoise="#AFEEEE",nt.palevioletred="#DB7093",nt.papayawhip="#FFEFD5",nt.peachpuff="#FFDAB9",nt.peru="#CD853F",nt.pink="#FFC0CB",nt.plum="#DDA0DD",nt.powderblue="#B0E0E6",nt.rosybrown="#BC8F8F",nt.royalblue="#4169E1",nt.saddlebrown="#8B4513",nt.salmon="#FA8072",nt.sandybrown="#F4A460",nt.seagreen="#2E8B57",nt.seashell="#FFF5EE",nt.sienna="#A0522D",nt.skyblue="#87CEEB",nt.slateblue="#6A5ACD",nt.slategray="#708090",nt.slategrey="#708090",nt.snow="#FFFAFA",nt.springgreen="#00FF7F",nt.steelblue="#4682B4",nt.tan="#D2B48C",nt.thistle="#D8BFD8",nt.tomato="#FF6347",nt.turquoise="#40E0D0",nt.violet="#EE82EE",nt.wheat="#F5DEB3",nt.whitesmoke="#F5F5F5",nt.yellowgreen="#9ACD32",nt.rebeccapurple="#663399"}(i$1||(i$1={}));const a=Object.keys(i$1),r={HEX:["R","G","B","A"],RGB:["R","G","B","A"],HSL:["H","S","L","A"],CIELab:["L","a","b","A"],CMYK:["C","M","Y","K","A"]},n={BGR:t.RGB,ABGR:t.RGB,HLS:t.HSL,AHLS:t.HSL,LAB:t.CIELab,ALAB:t.CIELab,CKMY:t.CMYK,ACKMY:t.CMYK};var c;(function(nt){nt.NUMBER="number",nt.BOOLEAN="boolean"})(c||(c={}));const o={[t.HEX]:/^#(?:([a-f\d])([a-f\d])([a-f\d])([a-f\d])?|([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?)$/i,[t.RGB]:/^rgba?\s*\(\s*(?:((?:\d*\.)?\d+%?)\s*,\s*((?:\d*\.)?\d+%?)\s*,\s*((?:\d*\.)?\d+%?)(?:\s*,\s*((?:\d*\.)?\d+))?|((?:\d*\.)?\d+%?)\s*((?:\d*\.)?\d+%?)\s*((?:\d*\.)?\d+%?)(?:\s*\/\s*((?:\d*\.)?\d+%?))?)\s*\)$/,[t.HSL]:/^hsla?\s*\(\s*(?:(-?(?:\d*\.)?\d+(?:deg|grad|rad|turn)?)\s*,\s*((?:\d*\.)?\d+)%\s*,\s*((?:\d*\.)?\d+)%(?:\s*,\s*((?:\d*\.)?\d+))?|(-?(?:\d*\.)?\d+(?:deg|grad|rad|turn)?)\s*((?:\d*\.)?\d+)%\s*((?:\d*\.)?\d+)%(?:\s*\/\s*((?:\d*\.)?\d+%?))?)\s*\)$/,[t.CIELab]:/^lab\s*\(\s*(?:((?:\d*\.)?\d+%?)\s*(-?(?:\d*\.)?\d+%?)\s*(-?(?:\d*\.)?\d+%?)(?:\s*\/\s*((?:\d*\.)?\d+%?))?)\s*\)$/,[t.CMYK]:/^(?:device-cmyk|cmyk)\s*\(\s*(?:((?:\d*\.)?\d+%?)\s*,\s*((?:\d*\.)?\d+%?)\s*,\s*((?:\d*\.)?\d+%?)\s*,\s*((?:\d*\.)?\d+%?)(?:\s*,\s*((?:\d*\.)?\d+))?|((?:\d*\.)?\d+%?)\s*((?:\d*\.)?\d+%?)\s*((?:\d*\.)?\d+%?)\s*((?:\d*\.)?\d+%?)(?:\s*\/\s*((?:\d*\.)?\d+%?))?)\s*\)$/},A=/^(-?(?:\d*\.)?\d+)((?:deg|grad|rad|turn)?)$/,h=/^(-?\d+(?:\.\d+)?|-?\.\d+)%$/,u=/^0x([a-f\d]{1,2})$/i,d=/\{(\d+)\}/g,m="The provided string color doesn't have a correct format",b="The provided color object doesn't have the proper keys or format";var C,L,g;(function(nt){nt.NONE="none",nt.DEGREES="deg",nt.GRADIANS="grad",nt.RADIANS="rad",nt.TURNS="turn"})(C||(C={})),function(nt){nt.NONE="none",nt.PERCENT="percent"}(L||(L={})),function(nt){nt.DEVICE_CMYK="device-cmyk",nt.CMYK="cmyk"}(g||(g={}));C.NONE,L.NONE,L.NONE,L.PERCENT,L.NONE,g.DEVICE_CMYK;const p=(nt,_e)=>Object.prototype.hasOwnProperty.call(nt,_e),H=nt=>+`${nt}`.replace(h,"$1"),F=nt=>h.test(`${nt}`)?H(nt):Math.min(+nt,100),R=nt=>(nt.length===1&&(nt+=nt),parseInt(nt,16)),S=nt=>{const _e=D(nt,0).toString(16).toUpperCase();return _e.length===1?`0x0${_e}`:`0x${_e}`},I=(nt,_e=!1)=>!_e&&h.test(nt)?Math.min(255*H(nt)/100,255):u.test(nt)?(nt.length===3&&(nt+=nt.slice(-1)),_e?D(nt)/255:D(nt)):Math.min(+nt,_e?1:255),G=nt=>h.test(nt)?f(125*H(nt)/100,-125,125):f(+nt,-125,125),M=nt=>Math.min(h.test(nt)?H(nt)/100:+nt,1),y=nt=>[...nt].sort().join("").toUpperCase(),D=(nt,_e=6)=>{const rt=Math.pow(10,_e);return Math.round(+nt*rt)/rt},f=(nt,_e,rt)=>Math.max(_e,Math.min(nt,rt)),O=nt=>{if(typeof nt=="string"){const _e=nt.match(A),rt=+_e[1];switch(_e[2]){case C.RADIANS:nt=D(180*rt/Math.PI);break;case C.TURNS:nt=D(360*rt);break;case C.GRADIANS:nt=D(.9*rt);break;case C.DEGREES:default:nt=rt}}return(nt>360||nt<0)&&(nt-=360*Math.floor(nt/360)),nt},Y=(nt,_e)=>{let rt;switch(_e){case C.RADIANS:rt=D((it=>it*Math.PI/180)(nt));break;case C.TURNS:rt=D(nt/360);break;case C.GRADIANS:rt=D(10/9*nt);break;case C.DEGREES:case C.NONE:default:rt=nt}return rt},X=[[.4360747,.3850649,.1430804],[.2225045,.7168786,.0606169],[.0139322,.0971045,.7141733]],T=[[3.1338561,-1.6168667,-.4906146],[-.9787684,1.9161415,.033454],[.0719453,-.2289914,1.4052427]],N=X.map(nt=>nt.reduce((_e,rt)=>_e+rt,0)),$=(nt,_e,rt)=>(rt<0&&(rt+=6),rt>=6&&(rt-=6),D(rt<1?255*((_e-nt)*rt+nt):rt<3?255*_e:rt<4?255*((_e-nt)*(4-rt)+nt):255*nt)),j=nt=>nt<=.04045?nt/12.92:((nt+.055)/1.055)**2.4,U=nt=>nt<=.0031308?12.92*nt:1.055*nt**(1/2.4)-.055,w=(nt,_e,rt,it)=>{const st=[0,0,0],ot=[nt,_e,rt];return it.forEach((at,ct)=>{at.forEach((ft,pt)=>{st[ct]+=ft*ot[pt]})}),st},x$1=(nt,_e,rt)=>{_e/=100;const it=(rt/=100)<=.5?rt*(_e+1):rt+_e-rt*_e,st=2*rt-it;return{R:$(st,it,(nt/=60)+2),G:$(st,it,nt),B:$(st,it,nt-2)}},v=(nt,_e,rt,it=1)=>{nt/=255,_e/=255,rt/=255,it=Math.min(it,1);const st=Math.max(nt,_e,rt),ot=Math.min(nt,_e,rt),at=st-ot;let ct=0,ft=0;const pt=(st+ot)/2;if(at!==0){switch(st){case nt:ct=(_e-rt)/at%6;break;case _e:ct=(rt-nt)/at+2;break;case rt:ct=(nt-_e)/at+4}ct=D(60*ct),ct<0&&(ct+=360),ft=at/(1-Math.abs(2*pt-1))}return{H:ct,S:D(100*ft),L:D(100*pt),A:it}},V=(nt,_e,rt)=>{const it=[nt/255,_e/255,rt/255].map(j),st=w(it[0],it[1],it[2],X),ot=((at,ct,ft)=>{const pt=yt=>yt>.008856451679035631?Math.cbrt(yt):yt/.12841854934601665+.13793103448275862,mt=pt(at/N[0]),xt=pt(ct/N[1]);return[116*xt-16,500*(mt-xt),200*(xt-pt(ft/N[2]))]})(st[0],st[1],st[2]);return{L:ot[0],a:ot[1],b:ot[2]}},P=(nt,_e,rt)=>{const it=((ot,at,ct)=>{const ft=yt=>yt>.20689655172413793?yt**3:.12841854934601665*(yt-.13793103448275862),pt=(ot+16)/116,mt=at/500,xt=ct/200;return[N[0]*ft(pt+mt),N[1]*ft(pt),N[2]*ft(pt-xt)]})(nt,_e,rt),st=w(it[0],it[1],it[2],T).map(U);return{R:f(255*st[0],0,255),G:f(255*st[1],0,255),B:f(255*st[2],0,255)}},q=(nt,_e,rt,it)=>({R:D(255*(1-nt)*(it=1-it)),G:D(255*(1-_e)*it),B:D(255*(1-rt)*it)}),_=(nt,_e,rt)=>{nt/=255,_e/=255,rt/=255;const it=1-Math.max(nt,_e,rt),st=1-it,ot=st&&(st-_e)/st,at=st&&(st-rt)/st;return{C:D(100*(st&&(st-nt)/st)),M:D(100*ot),Y:D(100*at),K:D(100*it)}},Q=nt=>nt?", ":",",W=(nt,_e)=>{const rt=y(Object.keys(nt));return r[n[rt]].reduce((it,st,ot)=>{const at=nt[st];return at!==void 0&&it.push(_e(at,ot)),it},[])},J=(nt,_e)=>nt.replace(d,(rt,it)=>`${_e[+it-1]}`),Z=(nt,_e,rt=!1)=>{const{alphaUnit:it,legacyCSS:st,decimals:ot}=_e;return it!==L.PERCENT||st&&!rt?D(nt,ot):`${D(100*nt,ot)}%`},tt={[t.HEX]:nt=>{const _e=W(nt,it=>(st=>{let ot=D(st,0).toString(16).toUpperCase();return ot.length===1&&(ot=`0${ot}`),ot})(D(it))),rt=_e.length===4?"#{1}{2}{3}{4}":"#{1}{2}{3}";return J(rt,_e)},[t.RGB]:(nt,_e)=>{const{decimals:rt,legacyCSS:it,spacesAfterCommas:st,rgbUnit:ot}=_e,at=Q(st),ct=W(nt,(pt,mt)=>ot===L.PERCENT&&mt<3?`${((xt,yt)=>D(xt/255*100,yt))(pt,rt)}%`:mt===3?Z(pt,_e):D(pt,rt)),ft=it?ct.length===4?`rgba({1}${at}{2}${at}{3}${at}{4})`:`rgb({1}${at}{2}${at}{3})`:ct.length===4?"rgb({1} {2} {3} / {4})":"rgb({1} {2} {3})";return J(ft,ct)},[t.HSL]:(nt,_e)=>{const{decimals:rt,legacyCSS:it,spacesAfterCommas:st,anglesUnit:ot}=_e,at=Q(st),ct=W(nt,(pt,mt)=>mt===0&&ot!==C.NONE?`${D(Y(pt,ot),rt)}${ot}`:mt===3?Z(pt,_e):D(pt,rt)),ft=it?ct.length===4?`hsla({1}${at}{2}%${at}{3}%${at}{4})`:`hsl({1}${at}{2}%${at}{3}%)`:ct.length===4?"hsl({1} {2}% {3}% / {4})":"hsl({1} {2}% {3}%)";return J(ft,ct)},[t.CIELab]:(nt,_e)=>{const{decimals:rt,labUnit:it}=_e,st=W(nt,(at,ct)=>{if(ct===0){const ft=D(F(at),rt);return it===L.PERCENT?`${ft}%`:`${ft}`}return ct<3?it===L.PERCENT?`${((ft,pt)=>D(ft/125*100,pt))(at,rt)}%`:D(at,rt):Z(at,_e,!0)}),ot=st.length===4?"lab({1} {2} {3} / {4})":"lab({1} {2} {3})";return J(ot,st)},[t.CMYK]:(nt,_e)=>{const{decimals:rt,legacyCSS:it,spacesAfterCommas:st,cmykUnit:ot,cmykFunction:at}=_e,ct=Q(st),ft=W(nt,(mt,xt)=>ot===L.PERCENT&&xt<4?`${D(mt,rt)}%`:xt===4?Z(mt,_e):D(mt/100,rt)),pt=it?ft.length===5?`${at}({1}${ct}{2}${ct}{3}${ct}{4}${ct}{5})`:`${at}({1}${ct}{2}${ct}{3}${ct}{4})`:ft.length===5?`${at}({1} {2} {3} {4} / {5})`:`${at}({1} {2} {3} {4})`;return J(pt,ft)}},et$1=nt=>(typeof nt=="string"&&(nt=h.test(nt)?H(nt)/100:+nt),isNaN(+nt)||nt>1?1:D(nt)),At=nt=>typeof nt=="string"?(_e=>{let rt;if(Object.keys(t).some(it=>{if(o[it].test(_e))return rt=it,!0}),!rt&&~a.indexOf(_e)&&(rt=t.HEX),!rt)throw new Error(m);return rt})(nt):(_e=>{let rt,it=!1;const st=y(Object.keys(_e));if(n[st]&&(rt=n[st]),rt&&rt===t.RGB){const ot=Object.entries(_e).some(ct=>!u.test(`${ct[1]}`)),at=Object.entries(_e).some(ct=>!(h.test(`${ct[1]}`)||!u.test(`${ct[1]}`)&&!isNaN(+ct[1])&&+ct[1]<=255));ot&&at&&(it=!0),ot||(rt=t.HEX)}if(!rt||it)throw new Error(b);return rt})(nt),ht={[t.HEX](nt){const _e=(~a.indexOf(nt)?i$1[nt]:nt).match(o.HEX),rt={R:R(_e[1]||_e[5]),G:R(_e[2]||_e[6]),B:R(_e[3]||_e[7])},it=_e[4]||_e[8];return it!==void 0&&(rt.A=R(it)/255),rt},[t.RGB](nt){const _e=nt.match(o.RGB),rt=I(_e[1]||_e[5]),it=I(_e[2]||_e[6]),st=I(_e[3]||_e[7]),ot=_e[4]||_e[8],at={R:Math.min(rt,255),G:Math.min(it,255),B:Math.min(st,255)};return ot!==void 0&&(at.A=et$1(ot)),at},[t.HSL](nt){const _e=nt.match(o.HSL),rt=O(_e[1]||_e[5]),it=F(_e[2]||_e[6]),st=F(_e[3]||_e[7]),ot=_e[4]||_e[8],at=x$1(rt,it,st);return ot!==void 0&&(at.A=et$1(ot)),at},[t.CIELab](nt){const _e=nt.match(o.CIELab),rt=F(_e[1]),it=G(_e[2]),st=G(_e[3]),ot=_e[4],at=P(rt,it,st);return ot!==void 0&&(at.A=et$1(ot)),at},[t.CMYK](nt){const _e=nt.match(o.CMYK),rt=M(_e[1]||_e[6]),it=M(_e[2]||_e[7]),st=M(_e[3]||_e[8]),ot=M(_e[4]||_e[9]),at=_e[5]||_e[10],ct=q(rt,it,st,ot);return at!==void 0&&(ct.A=et$1(at)),ct}},ut={[t.HEX](nt){const _e={R:I(`${nt.R}`),G:I(`${nt.G}`),B:I(`${nt.B}`)};return p(nt,"A")&&(_e.A=Math.min(I(`${nt.A}`,!0),1)),_e},[t.RGB](nt){return this.HEX(nt)},[t.HSL](nt){const _e=F(`${nt.S}`),rt=F(`${nt.L}`),it=x$1(O(nt.H),_e,rt);return p(nt,"A")&&(it.A=et$1(nt.A)),it},[t.CIELab](nt){const _e=F(`${nt.L}`),rt=G(`${nt.a}`),it=G(`${nt.b}`),st=P(_e,rt,it);return p(nt,"A")&&(st.A=et$1(nt.A)),st},[t.CMYK](nt){const _e=M(`${nt.C}`),rt=M(`${nt.M}`),it=M(`${nt.Y}`),st=M(`${nt.K}`),ot=q(_e,rt,it,st);return p(nt,"A")&&(ot.A=et$1(nt.A)),ot}},dt=(nt,_e=At(nt))=>typeof nt=="string"?ht[_e](nt):ut[_e](nt),lt={[t.HEX]:nt=>({R:S(nt.R),G:S(nt.G),B:S(nt.B)}),HEXA(nt){const _e=lt.HEX(nt);return _e.A=p(nt,"A")?S(255*nt.A):"0xFF",_e},[t.RGB](nt,_e){const rt=Ct(nt,_e);return p(rt,"A")&&delete rt.A,rt},RGBA(nt,_e){const rt=lt.RGB(nt,_e);return rt.A=p(nt,"A")?D(nt.A):1,rt},[t.HSL](nt,_e){const rt=v(nt.R,nt.G,nt.B);return delete rt.A,Lt(rt,_e)},HSLA(nt,_e){const rt=lt.HSL(nt,_e);return rt.A=p(nt,"A")?D(nt.A,_e):1,rt},[t.CIELab](nt,_e){const rt=V(nt.R,nt.G,nt.B);return gt(rt,_e)},CIELabA(nt,_e){const rt=lt.CIELab(nt,_e);return rt.A=p(nt,"A")?D(nt.A,_e):1,rt},[t.CMYK]:(nt,_e)=>Bt(_(nt.R,nt.G,nt.B),_e),CMYKA(nt,_e){const rt=lt.CMYK(nt,_e);return rt.A=p(nt,"A")?D(nt.A,_e):1,rt}};t.HEX+"",t.RGB+"",t.HSL+"",t.CIELab+"";t.HEX+"",t.RGB+"",t.HSL+"",t.CIELab+"";const Ct=(nt,_e)=>({R:D(nt.R,_e),G:D(nt.G,_e),B:D(nt.B,_e),...p(nt,"A")?{A:D(nt.A,_e)}:{}}),Lt=(nt,_e)=>({H:D(nt.H,_e),S:D(nt.S,_e),L:D(nt.L,_e),...p(nt,"A")?{A:D(nt.A,_e)}:{}}),gt=(nt,_e)=>({L:D(nt.L,_e),a:D(nt.a,_e),b:D(nt.b,_e)}),Bt=(nt,_e)=>({C:D(nt.C,_e),M:D(nt.M,_e),Y:D(nt.Y,_e),K:D(nt.K,_e)});var NOTHING=Symbol.for("immer-nothing"),DRAFTABLE=Symbol.for("immer-draftable"),DRAFT_STATE=Symbol.for("immer-state");function die(nt,..._e){throw new Error(`[Immer] minified error nr: ${nt}. Full error at: https://bit.ly/3cXEKWf`)}var getPrototypeOf=Object.getPrototypeOf;function isDraft(nt){return!!nt&&!!nt[DRAFT_STATE]}function isDraftable(nt){return nt?isPlainObject(nt)||Array.isArray(nt)||!!nt[DRAFTABLE]||!!nt.constructor?.[DRAFTABLE]||isMap(nt)||isSet(nt):!1}var objectCtorString=Object.prototype.constructor.toString();function isPlainObject(nt){if(!nt||typeof nt!="object")return!1;const _e=getPrototypeOf(nt);if(_e===null)return!0;const rt=Object.hasOwnProperty.call(_e,"constructor")&&_e.constructor;return rt===Object?!0:typeof rt=="function"&&Function.toString.call(rt)===objectCtorString}function each(nt,_e){getArchtype(nt)===0?Reflect.ownKeys(nt).forEach(rt=>{_e(rt,nt[rt],nt)}):nt.forEach((rt,it)=>_e(it,rt,nt))}function getArchtype(nt){const _e=nt[DRAFT_STATE];return _e?_e.type_:Array.isArray(nt)?1:isMap(nt)?2:isSet(nt)?3:0}function has(nt,_e){return getArchtype(nt)===2?nt.has(_e):Object.prototype.hasOwnProperty.call(nt,_e)}function set(nt,_e,rt){const it=getArchtype(nt);it===2?nt.set(_e,rt):it===3?nt.add(rt):nt[_e]=rt}function is(nt,_e){return nt===_e?nt!==0||1/nt===1/_e:nt!==nt&&_e!==_e}function isMap(nt){return nt instanceof Map}function isSet(nt){return nt instanceof Set}function latest(nt){return nt.copy_||nt.base_}function shallowCopy(nt,_e){if(isMap(nt))return new Map(nt);if(isSet(nt))return new Set(nt);if(Array.isArray(nt))return Array.prototype.slice.call(nt);const rt=isPlainObject(nt);if(_e===!0||_e==="class_only"&&!rt){const it=Object.getOwnPropertyDescriptors(nt);delete it[DRAFT_STATE];let st=Reflect.ownKeys(it);for(let ot=0;ot1&&(nt.set=nt.add=nt.clear=nt.delete=dontMutateFrozenCollections),Object.freeze(nt),_e&&Object.entries(nt).forEach(([rt,it])=>freeze(it,!0))),nt}function dontMutateFrozenCollections(){die(2)}function isFrozen(nt){return Object.isFrozen(nt)}var plugins={};function getPlugin(nt){const _e=plugins[nt];return _e||die(0,nt),_e}function loadPlugin(nt,_e){plugins[nt]||(plugins[nt]=_e)}var currentScope;function getCurrentScope(){return currentScope}function createScope(nt,_e){return{drafts_:[],parent_:nt,immer_:_e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function usePatchesInScope(nt,_e){_e&&(getPlugin("Patches"),nt.patches_=[],nt.inversePatches_=[],nt.patchListener_=_e)}function revokeScope(nt){leaveScope(nt),nt.drafts_.forEach(revokeDraft),nt.drafts_=null}function leaveScope(nt){nt===currentScope&&(currentScope=nt.parent_)}function enterScope(nt){return currentScope=createScope(currentScope,nt)}function revokeDraft(nt){const _e=nt[DRAFT_STATE];_e.type_===0||_e.type_===1?_e.revoke_():_e.revoked_=!0}function processResult(nt,_e){_e.unfinalizedDrafts_=_e.drafts_.length;const rt=_e.drafts_[0];return nt!==void 0&&nt!==rt?(rt[DRAFT_STATE].modified_&&(revokeScope(_e),die(4)),isDraftable(nt)&&(nt=finalize(_e,nt),_e.parent_||maybeFreeze(_e,nt)),_e.patches_&&getPlugin("Patches").generateReplacementPatches_(rt[DRAFT_STATE].base_,nt,_e.patches_,_e.inversePatches_)):nt=finalize(_e,rt,[]),revokeScope(_e),_e.patches_&&_e.patchListener_(_e.patches_,_e.inversePatches_),nt!==NOTHING?nt:void 0}function finalize(nt,_e,rt){if(isFrozen(_e))return _e;const it=_e[DRAFT_STATE];if(!it)return each(_e,(st,ot)=>finalizeProperty(nt,it,_e,st,ot,rt)),_e;if(it.scope_!==nt)return _e;if(!it.modified_)return maybeFreeze(nt,it.base_,!0),it.base_;if(!it.finalized_){it.finalized_=!0,it.scope_.unfinalizedDrafts_--;const st=it.copy_;let ot=st,at=!1;it.type_===3&&(ot=new Set(st),st.clear(),at=!0),each(ot,(ct,ft)=>finalizeProperty(nt,it,st,ct,ft,rt,at)),maybeFreeze(nt,st,!1),rt&&nt.patches_&&getPlugin("Patches").generatePatches_(it,rt,nt.patches_,nt.inversePatches_)}return it.copy_}function finalizeProperty(nt,_e,rt,it,st,ot,at){if(isDraft(st)){const ct=ot&&_e&&_e.type_!==3&&!has(_e.assigned_,it)?ot.concat(it):void 0,ft=finalize(nt,st,ct);if(set(rt,it,ft),isDraft(ft))nt.canAutoFreeze_=!1;else return}else at&&rt.add(st);if(isDraftable(st)&&!isFrozen(st)){if(!nt.immer_.autoFreeze_&&nt.unfinalizedDrafts_<1)return;finalize(nt,st),(!_e||!_e.scope_.parent_)&&typeof it!="symbol"&&Object.prototype.propertyIsEnumerable.call(rt,it)&&maybeFreeze(nt,st)}}function maybeFreeze(nt,_e,rt=!1){!nt.parent_&&nt.immer_.autoFreeze_&&nt.canAutoFreeze_&&freeze(_e,rt)}function createProxyProxy(nt,_e){const rt=Array.isArray(nt),it={type_:rt?1:0,scope_:_e?_e.scope_:getCurrentScope(),modified_:!1,finalized_:!1,assigned_:{},parent_:_e,base_:nt,draft_:null,copy_:null,revoke_:null,isManual_:!1};let st=it,ot=objectTraps;rt&&(st=[it],ot=arrayTraps);const{revoke:at,proxy:ct}=Proxy.revocable(st,ot);return it.draft_=ct,it.revoke_=at,ct}var objectTraps={get(nt,_e){if(_e===DRAFT_STATE)return nt;const rt=latest(nt);if(!has(rt,_e))return readPropFromProto(nt,rt,_e);const it=rt[_e];return nt.finalized_||!isDraftable(it)?it:it===peek(nt.base_,_e)?(prepareCopy(nt),nt.copy_[_e]=createProxy(it,nt)):it},has(nt,_e){return _e in latest(nt)},ownKeys(nt){return Reflect.ownKeys(latest(nt))},set(nt,_e,rt){const it=getDescriptorFromProto(latest(nt),_e);if(it?.set)return it.set.call(nt.draft_,rt),!0;if(!nt.modified_){const st=peek(latest(nt),_e),ot=st?.[DRAFT_STATE];if(ot&&ot.base_===rt)return nt.copy_[_e]=rt,nt.assigned_[_e]=!1,!0;if(is(rt,st)&&(rt!==void 0||has(nt.base_,_e)))return!0;prepareCopy(nt),markChanged(nt)}return nt.copy_[_e]===rt&&(rt!==void 0||_e in nt.copy_)||Number.isNaN(rt)&&Number.isNaN(nt.copy_[_e])||(nt.copy_[_e]=rt,nt.assigned_[_e]=!0),!0},deleteProperty(nt,_e){return peek(nt.base_,_e)!==void 0||_e in nt.base_?(nt.assigned_[_e]=!1,prepareCopy(nt),markChanged(nt)):delete nt.assigned_[_e],nt.copy_&&delete nt.copy_[_e],!0},getOwnPropertyDescriptor(nt,_e){const rt=latest(nt),it=Reflect.getOwnPropertyDescriptor(rt,_e);return it&&{writable:!0,configurable:nt.type_!==1||_e!=="length",enumerable:it.enumerable,value:rt[_e]}},defineProperty(){die(11)},getPrototypeOf(nt){return getPrototypeOf(nt.base_)},setPrototypeOf(){die(12)}},arrayTraps={};each(objectTraps,(nt,_e)=>{arrayTraps[nt]=function(){return arguments[0]=arguments[0][0],_e.apply(this,arguments)}});arrayTraps.deleteProperty=function(nt,_e){return arrayTraps.set.call(this,nt,_e,void 0)};arrayTraps.set=function(nt,_e,rt){return objectTraps.set.call(this,nt[0],_e,rt,nt[0])};function peek(nt,_e){const rt=nt[DRAFT_STATE];return(rt?latest(rt):nt)[_e]}function readPropFromProto(nt,_e,rt){const it=getDescriptorFromProto(_e,rt);return it?"value"in it?it.value:it.get?.call(nt.draft_):void 0}function getDescriptorFromProto(nt,_e){if(!(_e in nt))return;let rt=getPrototypeOf(nt);for(;rt;){const it=Object.getOwnPropertyDescriptor(rt,_e);if(it)return it;rt=getPrototypeOf(rt)}}function markChanged(nt){nt.modified_||(nt.modified_=!0,nt.parent_&&markChanged(nt.parent_))}function prepareCopy(nt){nt.copy_||(nt.copy_=shallowCopy(nt.base_,nt.scope_.immer_.useStrictShallowCopy_))}var Immer2=class{constructor(nt){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(_e,rt,it)=>{if(typeof _e=="function"&&typeof rt!="function"){const ot=rt;rt=_e;const at=this;return function(ft=ot,...pt){return at.produce(ft,mt=>rt.call(this,mt,...pt))}}typeof rt!="function"&&die(6),it!==void 0&&typeof it!="function"&&die(7);let st;if(isDraftable(_e)){const ot=enterScope(this),at=createProxy(_e,void 0);let ct=!0;try{st=rt(at),ct=!1}finally{ct?revokeScope(ot):leaveScope(ot)}return usePatchesInScope(ot,it),processResult(st,ot)}else if(!_e||typeof _e!="object"){if(st=rt(_e),st===void 0&&(st=_e),st===NOTHING&&(st=void 0),this.autoFreeze_&&freeze(st,!0),it){const ot=[],at=[];getPlugin("Patches").generateReplacementPatches_(_e,st,ot,at),it(ot,at)}return st}else die(1,_e)},this.produceWithPatches=(_e,rt)=>{if(typeof _e=="function")return(at,...ct)=>this.produceWithPatches(at,ft=>_e(ft,...ct));let it,st;return[this.produce(_e,rt,(at,ct)=>{it=at,st=ct}),it,st]},typeof nt?.autoFreeze=="boolean"&&this.setAutoFreeze(nt.autoFreeze),typeof nt?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(nt.useStrictShallowCopy)}createDraft(nt){isDraftable(nt)||die(8),isDraft(nt)&&(nt=current(nt));const _e=enterScope(this),rt=createProxy(nt,void 0);return rt[DRAFT_STATE].isManual_=!0,leaveScope(_e),rt}finishDraft(nt,_e){const rt=nt&&nt[DRAFT_STATE];(!rt||!rt.isManual_)&&die(9);const{scope_:it}=rt;return usePatchesInScope(it,_e),processResult(void 0,it)}setAutoFreeze(nt){this.autoFreeze_=nt}setUseStrictShallowCopy(nt){this.useStrictShallowCopy_=nt}applyPatches(nt,_e){let rt;for(rt=_e.length-1;rt>=0;rt--){const st=_e[rt];if(st.path.length===0&&st.op==="replace"){nt=st.value;break}}rt>-1&&(_e=_e.slice(rt+1));const it=getPlugin("Patches").applyPatches_;return isDraft(nt)?it(nt,_e):this.produce(nt,st=>it(st,_e))}};function createProxy(nt,_e){const rt=isMap(nt)?getPlugin("MapSet").proxyMap_(nt,_e):isSet(nt)?getPlugin("MapSet").proxySet_(nt,_e):createProxyProxy(nt,_e);return(_e?_e.scope_:getCurrentScope()).drafts_.push(rt),rt}function current(nt){return isDraft(nt)||die(10,nt),currentImpl(nt)}function currentImpl(nt){if(!isDraftable(nt)||isFrozen(nt))return nt;const _e=nt[DRAFT_STATE];let rt;if(_e){if(!_e.modified_)return _e.base_;_e.finalized_=!0,rt=shallowCopy(nt,_e.scope_.immer_.useStrictShallowCopy_)}else rt=shallowCopy(nt,!0);return each(rt,(it,st)=>{set(rt,it,currentImpl(st))}),_e&&(_e.finalized_=!1),rt}function enableMapSet(){class nt extends Map{constructor(ft,pt){super(),this[DRAFT_STATE]={type_:2,parent_:pt,scope_:pt?pt.scope_:getCurrentScope(),modified_:!1,finalized_:!1,copy_:void 0,assigned_:void 0,base_:ft,draft_:this,isManual_:!1,revoked_:!1}}get size(){return latest(this[DRAFT_STATE]).size}has(ft){return latest(this[DRAFT_STATE]).has(ft)}set(ft,pt){const mt=this[DRAFT_STATE];return at(mt),(!latest(mt).has(ft)||latest(mt).get(ft)!==pt)&&(rt(mt),markChanged(mt),mt.assigned_.set(ft,!0),mt.copy_.set(ft,pt),mt.assigned_.set(ft,!0)),this}delete(ft){if(!this.has(ft))return!1;const pt=this[DRAFT_STATE];return at(pt),rt(pt),markChanged(pt),pt.base_.has(ft)?pt.assigned_.set(ft,!1):pt.assigned_.delete(ft),pt.copy_.delete(ft),!0}clear(){const ft=this[DRAFT_STATE];at(ft),latest(ft).size&&(rt(ft),markChanged(ft),ft.assigned_=new Map,each(ft.base_,pt=>{ft.assigned_.set(pt,!1)}),ft.copy_.clear())}forEach(ft,pt){const mt=this[DRAFT_STATE];latest(mt).forEach((xt,yt,vt)=>{ft.call(pt,this.get(yt),yt,this)})}get(ft){const pt=this[DRAFT_STATE];at(pt);const mt=latest(pt).get(ft);if(pt.finalized_||!isDraftable(mt)||mt!==pt.base_.get(ft))return mt;const xt=createProxy(mt,pt);return rt(pt),pt.copy_.set(ft,xt),xt}keys(){return latest(this[DRAFT_STATE]).keys()}values(){const ft=this.keys();return{[Symbol.iterator]:()=>this.values(),next:()=>{const pt=ft.next();return pt.done?pt:{done:!1,value:this.get(pt.value)}}}}entries(){const ft=this.keys();return{[Symbol.iterator]:()=>this.entries(),next:()=>{const pt=ft.next();if(pt.done)return pt;const mt=this.get(pt.value);return{done:!1,value:[pt.value,mt]}}}}[Symbol.iterator](){return this.entries()}}function _e(ct,ft){return new nt(ct,ft)}function rt(ct){ct.copy_||(ct.assigned_=new Map,ct.copy_=new Map(ct.base_))}class it extends Set{constructor(ft,pt){super(),this[DRAFT_STATE]={type_:3,parent_:pt,scope_:pt?pt.scope_:getCurrentScope(),modified_:!1,finalized_:!1,copy_:void 0,base_:ft,draft_:this,drafts_:new Map,revoked_:!1,isManual_:!1}}get size(){return latest(this[DRAFT_STATE]).size}has(ft){const pt=this[DRAFT_STATE];return at(pt),pt.copy_?!!(pt.copy_.has(ft)||pt.drafts_.has(ft)&&pt.copy_.has(pt.drafts_.get(ft))):pt.base_.has(ft)}add(ft){const pt=this[DRAFT_STATE];return at(pt),this.has(ft)||(ot(pt),markChanged(pt),pt.copy_.add(ft)),this}delete(ft){if(!this.has(ft))return!1;const pt=this[DRAFT_STATE];return at(pt),ot(pt),markChanged(pt),pt.copy_.delete(ft)||(pt.drafts_.has(ft)?pt.copy_.delete(pt.drafts_.get(ft)):!1)}clear(){const ft=this[DRAFT_STATE];at(ft),latest(ft).size&&(ot(ft),markChanged(ft),ft.copy_.clear())}values(){const ft=this[DRAFT_STATE];return at(ft),ot(ft),ft.copy_.values()}entries(){const ft=this[DRAFT_STATE];return at(ft),ot(ft),ft.copy_.entries()}keys(){return this.values()}[Symbol.iterator](){return this.values()}forEach(ft,pt){const mt=this.values();let xt=mt.next();for(;!xt.done;)ft.call(pt,xt.value,xt.value,this),xt=mt.next()}}function st(ct,ft){return new it(ct,ft)}function ot(ct){ct.copy_||(ct.copy_=new Set,ct.base_.forEach(ft=>{if(isDraftable(ft)){const pt=createProxy(ft,ct);ct.drafts_.set(ft,pt),ct.copy_.add(pt)}else ct.copy_.add(ft)}))}function at(ct){ct.revoked_&&die(3,JSON.stringify(latest(ct)))}loadPlugin("MapSet",{proxyMap_:_e,proxySet_:st})}var immer$1=new Immer2,produce=immer$1.produce;immer$1.produceWithPatches.bind(immer$1);immer$1.setAutoFreeze.bind(immer$1);immer$1.setUseStrictShallowCopy.bind(immer$1);immer$1.applyPatches.bind(immer$1);immer$1.createDraft.bind(immer$1);immer$1.finishDraft.bind(immer$1);const immerImpl=nt=>(_e,rt,it)=>(it.setState=(st,ot,...at)=>{const ct=typeof st=="function"?produce(st):st;return _e(ct,ot,...at)},nt(it.setState,rt,it)),immer=immerImpl,cleanGuiState={theme:{type:"ThemeConfigurationMessage",titlebar_content:null,control_layout:"floating",control_width:"medium",dark_mode:!1,show_logo:!0,show_share_button:!0,colors:null},label:"",server:"ws://localhost:8080",shareUrl:null,websocketConnected:!1,backgroundAvailable:!1,guiIdSetFromContainerId:{},modals:[],guiOrderFromId:{},guiConfigFromId:{},uploadsInProgress:{}};function useGuiState(nt){return React.useState(()=>create$3(immer(_e=>({...cleanGuiState,server:nt,setTheme:rt=>_e(it=>{it.theme=rt}),setShareUrl:rt=>_e(it=>{it.shareUrl=rt}),addGui:rt=>_e(it=>{it.guiOrderFromId[rt.id]=rt.props.order,it.guiConfigFromId[rt.id]=rt,rt.container_id in it.guiIdSetFromContainerId||(it.guiIdSetFromContainerId[rt.container_id]={}),it.guiIdSetFromContainerId[rt.container_id][rt.id]=!0}),addModal:rt=>_e(it=>{it.modals.push(rt)}),removeModal:rt=>_e(it=>{it.modals=it.modals.filter(st=>st.id!==rt)}),removeGui:rt=>_e(it=>{const st=it.guiConfigFromId[rt];delete it.guiIdSetFromContainerId[st.container_id][rt],delete it.guiOrderFromId[rt],delete it.guiConfigFromId[rt],Object.keys(it.guiIdSetFromContainerId[st.container_id]).length==0&&delete it.guiIdSetFromContainerId[st.container_id]}),resetGui:()=>_e(rt=>{rt.shareUrl=null,rt.guiIdSetFromContainerId={},rt.modals=[],rt.guiOrderFromId={},rt.guiConfigFromId={},rt.uploadsInProgress={}}),updateUploadState:rt=>_e(it=>{const{componentId:st,...ot}=rt;it.uploadsInProgress[st]={...it.uploadsInProgress[st],...ot}}),updateGuiProps:(rt,it)=>{_e(st=>{const ot=st.guiConfigFromId[rt];if(ot===void 0){console.error("Tried to update non-existent component",rt);return}for(const[at,ct]of Object.entries(it))at==="value"?st.guiConfigFromId[rt].value=ct:at in ot.props?st.guiConfigFromId[rt].props[at]=ct:console.error(`Tried to update nonexistent property '${at}' of GUI element ${rt}!`)})}}))))[0]}const searchParamKey="websocket";function syncSearchParamServer(nt){const _e=new URLSearchParams(window.location.search),rt=window.location.host.includes(nt.replace("ws://","").replace("/",""))||window.location.host.includes(nt.replace("wss://","").replace("/",""));rt&&_e.has(searchParamKey)?_e.delete(searchParamKey):rt||_e.set(searchParamKey,nt),window.history.replaceState(null,"Viser",_e.size===0?window.location.href.split("?")[0]:"?"+Array.from(_e.entries()).map(([it,st])=>`${it}=${st}`).join("&"))}function WorkerWrapper(nt){return new Worker("/egoallo/viser-embed/assets/WebsocketServerWorker-2xce1CWr.js",{type:"module",name:nt?.name})}function WebsocketMessageProducer(){const nt=reactExports.useContext(ViewerContext).messageQueueRef,_e=reactExports.useContext(ViewerContext),rt=_e.useGui(st=>st.server),it=_e.useGui(st=>st.resetGui);return syncSearchParamServer(rt),React.useEffect(()=>{const st=new WorkerWrapper;st.onmessage=at=>{const ct=at.data;ct.type==="connected"?(it(),_e.useGui.setState({websocketConnected:!0}),_e.sendMessageRef.current=ft=>{ot({type:"send",message:ft})}):ct.type==="closed"?(it(),_e.useGui.setState({websocketConnected:!1}),_e.sendMessageRef.current=ft=>{console.log(`Tried to send ${ft.type} but websocket is not connected!`)}):ct.type==="message_batch"&&nt.current.push(...ct.messages)};function ot(at){st.postMessage(at)}return ot({type:"set_server",server:rt}),()=>{ot({type:"close"}),_e.sendMessageRef.current=at=>console.log(`Tried to send ${at.type} but websocket is not connected!`),_e.useGui.setState({websocketConnected:!1})}},[rt,it]),jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{})}function assertUnreachable(nt){throw new Error("Didn't expect to get here",nt)}function getIcon(nt){let _e=null;switch(nt){case null:break;case"GitHub":_e=IconBrandGithub;break;case"Description":_e=IconFileDescription;break;case"Keyboard":_e=IconKeyboard;break;default:assertUnreachable(nt)}return _e}function TitlebarButton(nt){const _e=getIcon(nt.icon);return jsxRuntimeExports.jsx(Button,{component:"a",variant:"default",size:"compact-sm",href:nt.href||void 0,target:"_blank",leftSection:_e===null?null:jsxRuntimeExports.jsx(_e,{size:"1em"}),ml:"xs",color:"gray",children:nt.text})}function MobileTitlebarButton(nt){const _e=getIcon(nt.icon);return jsxRuntimeExports.jsx(Button,{m:"sm",component:"a",variant:"default",href:nt.href||void 0,target:"_blank",leftSection:_e===null?null:jsxRuntimeExports.jsx(_e,{size:"1.5em"}),ml:"sm",color:"gray",children:nt.text})}function TitlebarImage(nt,_e){let rt;nt.image_url_dark==null||_e==="light"?rt=nt.image_url_light:rt=nt.image_url_dark;const it=jsxRuntimeExports.jsx("img",{src:rt,alt:nt.image_alt,style:{height:"1.8em",margin:"0 0.5em"}});return nt.href==null?it:jsxRuntimeExports.jsx("a",{style:{display:"block",height:"1.8em"},href:nt.href,children:it})}function Titlebar(){const _e=reactExports.useContext(ViewerContext).useGui(ct=>ct.theme.titlebar_content),rt=useMantineColorScheme().colorScheme,[it,st]=useDisclosure(!1);if(_e==null)return null;const ot=_e.buttons,at=_e.image;return jsxRuntimeExports.jsx(Box,{style:{height:"3.2em",margin:0,border:"0",zIndex:10},children:jsxRuntimeExports.jsxs(Paper,{shadow:"0 0 0.8em 0 rgba(0,0,0,0.1)",style:{height:"100%"},children:[jsxRuntimeExports.jsxs(Container,{fluid:!0,style:()=>({height:"100%",display:"flex",alignItems:"center"}),children:[jsxRuntimeExports.jsx(Group$1,{style:()=>({marginRight:"auto"}),children:at!==null?TitlebarImage(at,rt):null}),jsxRuntimeExports.jsx(Group$1,{display:{base:"none",xs:"flex"},style:()=>({flexWrap:"nowrap",overflowX:"scroll",msOverflowStyle:"none",scrollbarWidth:"none"}),children:ot?.map((ct,ft)=>reactExports.createElement(TitlebarButton,{...ct,key:ft}))}),jsxRuntimeExports.jsx(Burger,{size:"sm",opened:it,onClick:st.toggle,title:it?"Close navigation":"Open navigation",display:{base:"block",xs:"none"}})]}),jsxRuntimeExports.jsx(Portal$1,{children:jsxRuntimeExports.jsx(Paper,{display:{base:"flex",xs:"none"},radius:"0",style:{flexDirection:"column",position:"absolute",top:"3.2em",zIndex:2e3,height:it?"calc(100vh - 2.375em)":"0",width:"100vw",transition:"all 0.5s",overflow:it?"scroll":"hidden",padding:it?"1rem":"0"},children:ot?.map((ct,ft)=>reactExports.createElement(MobileTitlebarButton,{...ct,key:ft}))})})]})})}function ViserModal(){return reactExports.useContext(ViewerContext).useGui(it=>it.modals).map((it,st)=>jsxRuntimeExports.jsx(GeneratedModal,{conf:it,index:st},it.id))}function GeneratedModal({conf:nt,index:_e}){return jsxRuntimeExports.jsx(Modal,{opened:!0,title:nt.title,onClose:()=>{},withCloseButton:!1,centered:!0,zIndex:100+_e,children:jsxRuntimeExports.jsx(GeneratedGuiContainer,{containerId:nt.id})})}const rootNodeTemplate={message:{type:"FrameMessage",name:"",props:{show_axes:!1,axes_length:.5,axes_radius:.0125,origin_radius:.025}},children:["/WorldAxes"],clickable:!1},worldAxesNodeTemplate={message:{type:"FrameMessage",name:"/WorldAxes",props:{show_axes:!0,axes_length:.5,axes_radius:.0125,origin_radius:.025}},children:[],clickable:!1};function useSceneTreeState(nt){return React.useState(()=>create$3(immer(_e=>({nodeFromName:{"":rootNodeTemplate,"/WorldAxes":worldAxesNodeTemplate},labelVisibleFromName:{},enableDefaultLights:!0,environmentMap:{type:"EnvironmentMapMessage",hdri:"city",background:!1,background_blurriness:0,background_intensity:1,background_rotation:[0,0,0],environment_intensity:1,environment_rotation:[0,0,0]},setClickable:(rt,it)=>_e(st=>{const ot=st.nodeFromName[rt];ot!==void 0&&(ot.clickable=it)}),addSceneNode:rt=>_e(it=>{const st=it.nodeFromName[rt.name];if(st!==void 0)delete nt.current[rt.name],it.nodeFromName[rt.name]={...st,message:rt};else{const ot=rt.name.split("/").slice(0,-1).join("/");it.nodeFromName[rt.name]={message:rt,children:[],clickable:!1},it.nodeFromName[ot].children.push(rt.name)}}),removeSceneNode:rt=>_e(it=>{if(!(rt in it.nodeFromName)){console.log("Skipping scene node removal for "+rt);return}const st=[];function ot(ct){st.push(ct),it.nodeFromName[ct].children.forEach(ot)}ot(rt),st.forEach(ct=>{delete it.nodeFromName[ct],delete nt.current[ct]});const at=rt.split("/").slice(0,-1).join("/");it.nodeFromName[at].children=it.nodeFromName[at].children.filter(ct=>ct!==rt)}),updateSceneNode:(rt,it)=>_e(st=>{st.nodeFromName[rt].message.props={...st.nodeFromName[rt].message.props,...it}}),resetScene:()=>_e(rt=>{for(const it of Object.keys(rt.nodeFromName))it!==""&&it!=="/WorldAxes"&&delete rt.nodeFromName[it];rt.nodeFromName[""]=rootNodeTemplate,rt.nodeFromName["/WorldAxes"]=worldAxesNodeTemplate}),setLabelVisibility:(rt,it)=>_e(st=>{st.labelVisibleFromName[rt]=it})}))))[0]}function getSizesVariables(nt,_e,rt){return Object.keys(nt[_e]).reduce((it,st)=>(it[st]=`var(--mantine-${rt}-${st})`,it),{})}function getBreakpointValue(nt,_e){return nt in _e.breakpoints?_e.breakpoints[nt]:em(nt)}function themeToVars(nt){const _e=mergeMantineTheme(DEFAULT_THEME,nt),rt=getSizesVariables(_e,"fontSizes","font-size"),it=getSizesVariables(_e,"lineHeights","line-height"),st=getSizesVariables(_e,"shadows","shadow"),ot=getSizesVariables(_e,"radius","radius"),at=getSizesVariables(_e,"spacing","spacing"),ct=Object.keys(_e.headings.sizes).reduce((pt,mt)=>(pt[mt]={fontSize:`var(--mantine-${mt}-font-size)`,lineHeight:`var(--mantine-${mt}-line-height)`,fontWeight:`var(--mantine-${mt}-font-weight)`},pt),{}),ft=Object.keys(_e.colors).reduce((pt,mt)=>(pt[mt]={0:`var(--mantine-color-${mt}-0)`,1:`var(--mantine-color-${mt}-1)`,2:`var(--mantine-color-${mt}-2)`,3:`var(--mantine-color-${mt}-3)`,4:`var(--mantine-color-${mt}-4)`,5:`var(--mantine-color-${mt}-5)`,6:`var(--mantine-color-${mt}-6)`,7:`var(--mantine-color-${mt}-7)`,8:`var(--mantine-color-${mt}-8)`,9:`var(--mantine-color-${mt}-9)`,filled:`var(--mantine-color-${mt}-filled)`,filledHover:`var(--mantine-color-${mt}-filled-hover)`,light:`var(--mantine-color-${mt}-light)`,lightHover:`var(--mantine-color-${mt}-light-hover)`,lightColor:`var(--mantine-color-${mt}-light-color)`,outline:`var(--mantine-color-${mt}-outline)`,outlineHover:`var(--mantine-color-${mt}-outline-hover)`},pt),{primary:"var(--mantine-primary-color-filled)",primaryColors:{0:"var(--mantine-primary-color-0)",1:"var(--mantine-primary-color-1)",2:"var(--mantine-primary-color-2)",3:"var(--mantine-primary-color-3)",4:"var(--mantine-primary-color-4)",5:"var(--mantine-primary-color-5)",6:"var(--mantine-primary-color-6)",7:"var(--mantine-primary-color-7)",8:"var(--mantine-primary-color-8)",9:"var(--mantine-primary-color-9)",filled:"var(--mantine-primary-color-filled)",filledHover:"var(--mantine-primary-color-filled-hover)",light:"var(--mantine-primary-color-light)",lightHover:"var(--mantine-primary-color-light-hover)",lightColor:"var(--mantine-primary-color-light-color)",outline:"var(--mantine-primary-color-outline)",outlineHover:"var(--mantine-primary-color-outline-hover)"},white:"var(--mantine-color-white)",black:"var(--mantine-color-black)",text:"var(--mantine-color-text)",body:"var(--mantine-color-body)",error:"var(--mantine-color-error)",placeholder:"var(--mantine-color-placeholder)",anchor:"var(--mantine-color-anchor)",default:"var(--mantine-color-default)",defaultHover:"var(--mantine-color-default-hover)",defaultColor:"var(--mantine-color-default-color)",defaultBorder:"var(--mantine-color-default-border)",dimmed:"var(--mantine-color-dimmed)"});return{scale:"var(--mantine-scale)",cursorType:"var(--mantine-cursor-type)",webkitFontSmoothing:"var(--mantine-webkit-font-smoothing)",mozFontSmoothing:"var(--mantine-moz-font-smoothing)",lineHeight:"var(--mantine-line-height)",fontFamily:"var(--mantine-font-family)",fontFamilyMonospace:"var(--mantine-font-family-monospace)",fontFamilyHeadings:"var(--mantine-font-family-headings)",headingFontWeight:"var(--mantine-heading-font-weight)",radiusDefault:"var(--mantine-radius-default)",breakpoints:_e.breakpoints,fontSizes:rt,lineHeights:it,shadows:st,radius:ot,headings:ct,spacing:at,colors:ft,rtlSelector:'[dir="rtl"] &',darkSelector:'[data-mantine-color-scheme="dark"] &',lightSelector:'[data-mantine-color-scheme="light"] &',smallerThan:pt=>`(max-width: ${getBreakpointValue(pt,_e)})`,largerThan:pt=>`(min-width: ${getBreakpointValue(pt,_e)})`}}const theme={fontFamily:"Inter",autoContrast:!0,components:{Checkbox:Checkbox.extend({defaultProps:{radius:"xs"}}),ColorInput:ColorInput.extend({defaultProps:{radius:"xs"}}),Select:Select.extend({defaultProps:{radius:"sm"}}),TextInput:TextInput.extend({defaultProps:{radius:"xs"}}),NumberInput:NumberInput.extend({defaultProps:{radius:"xs"}}),Paper:Paper.extend({defaultProps:{radius:"xs",shadow:"0"}}),ActionIcon:ActionIcon.extend({defaultProps:{variant:"subtle",color:"gray",radius:"xs"}}),Button:Button.extend({defaultProps:{radius:"xs",fw:450}})}};themeToVars(theme);const typeSetSceneNodeMessage=new Set(["CameraFrustumMessage","GlbMessage","FrameMessage","BatchedAxesMessage","GridMessage","LabelMessage","Gui3DMessage","PointCloudMessage","DirectionalLightMessage","AmbientLightMessage","HemisphereLightMessage","PointLightMessage","RectAreaLightMessage","SpotLightMessage","MeshMessage","SkinnedMeshMessage","TransformControlsMessage","ImageMessage","CatmullRomSplineMessage","CubicBezierSplineMessage","GaussianSplatsMessage"]);function isSceneNodeMessage(nt){return typeSetSceneNodeMessage.has(nt.type)}const typeSetGuiComponentMessage=new Set(["GuiFolderMessage","GuiMarkdownMessage","GuiProgressBarMessage","GuiPlotlyMessage","GuiTabGroupMessage","GuiButtonMessage","GuiUploadButtonMessage","GuiSliderMessage","GuiMultiSliderMessage","GuiNumberMessage","GuiRgbMessage","GuiRgbaMessage","GuiCheckboxMessage","GuiVector2Message","GuiVector3Message","GuiTextMessage","GuiDropdownMessage","GuiButtonGroupMessage"]);function isGuiComponentMessage(nt){return typeSetGuiComponentMessage.has(nt.type)}function useMessageHandler(){const viewer=reactExports.useContext(ViewerContext),updateSceneNode=viewer.useSceneTree(nt=>nt.updateSceneNode),removeSceneNode=viewer.useSceneTree(nt=>nt.removeSceneNode),resetScene=viewer.useSceneTree(nt=>nt.resetScene),addSceneNode=viewer.useSceneTree(nt=>nt.addSceneNode),resetGui=viewer.useGui(nt=>nt.resetGui),setTheme=viewer.useGui(nt=>nt.setTheme),setShareUrl=viewer.useGui(nt=>nt.setShareUrl),addGui=viewer.useGui(nt=>nt.addGui),addModal=viewer.useGui(nt=>nt.addModal),removeModal=viewer.useGui(nt=>nt.removeModal),removeGui=viewer.useGui(nt=>nt.removeGui),updateGuiProps=viewer.useGui(nt=>nt.updateGuiProps),setClickable=viewer.useSceneTree(nt=>nt.setClickable),updateUploadState=viewer.useGui(nt=>nt.updateUploadState);function addSceneNodeMakeParents(nt){const _e=viewer.nodeAttributesFromName.current;_e[nt.name]={overrideVisibility:_e[nt.name]?.overrideVisibility},_e[nt.name].poseUpdateState="waitForMakeObject";const rt=viewer.useSceneTree.getState().nodeFromName,it=nt.name.split("/").slice(0,-1).join("/");it in rt||addSceneNodeMakeParents({...rootNodeTemplate.message,name:it}),addSceneNode(nt)}const fileDownloadHandler=useFileDownloadHandler();return message=>{if(isGuiComponentMessage(message)){addGui(message);return}if(isSceneNodeMessage(message)){if(message.type==="SkinnedMeshMessage"){viewer.skinnedMeshState.current[message.name]={initialized:!1,poses:[]};const nt=new Float32Array(message.props.bone_wxyzs.buffer.slice(message.props.bone_wxyzs.byteOffset,message.props.bone_wxyzs.byteOffset+message.props.bone_wxyzs.byteLength)),_e=new Float32Array(message.props.bone_positions.buffer.slice(message.props.bone_positions.byteOffset,message.props.bone_positions.byteOffset+message.props.bone_positions.byteLength));for(let rt=0;rt{URL.revokeObjectURL(nt);const rt=viewer.backgroundMaterialRef.current.uniforms.colorMap.value;viewer.backgroundMaterialRef.current.uniforms.colorMap.value=_e,isTexture(rt)&&rt.dispose(),viewer.useGui.setState({backgroundAvailable:!0})}),viewer.backgroundMaterialRef.current.uniforms.enabled.value=!0,viewer.backgroundMaterialRef.current.uniforms.hasDepth.value=message.depth_bytes!==null,message.depth_bytes!==null){const _e=URL.createObjectURL(new Blob([message.depth_bytes],{type:message.media_type}));new TextureLoader().load(_e,rt=>{URL.revokeObjectURL(_e);const it=viewer.backgroundMaterialRef.current?.uniforms.depthMap.value;viewer.backgroundMaterialRef.current.uniforms.depthMap.value=rt,isTexture(it)&&it.dispose()})}return}case"RemoveSceneNodeMessage":{console.log("Removing scene node:",message.name),removeSceneNode(message.name);const nt=viewer.nodeAttributesFromName.current;delete nt[message.name],viewer.skinnedMeshState.current[message.name]!==void 0&&delete viewer.skinnedMeshState.current[message.name];return}case"SetSceneNodeClickableMessage":{setTimeout(()=>setClickable(message.name,message.clickable),50);return}case"ResetSceneMessage":{resetScene();const nt=viewer.sceneRef.current?.background;viewer.sceneRef.current.background=null,isTexture(nt)&&nt.dispose(),viewer.useGui.setState({backgroundAvailable:!1}),viewer.backgroundMaterialRef.current.uniforms.enabled.value=!1;return}case"ResetGuiMessage":{resetGui();return}case"GuiUpdateMessage":{updateGuiProps(message.id,message.updates);return}case"GuiRemoveMessage":{removeGui(message.id);return}case"FileTransferStart":case"FileTransferPart":{fileDownloadHandler(message);return}case"FileTransferPartAck":{updateUploadState({componentId:message.source_component_id,uploadedBytes:message.transferred_bytes,totalBytes:message.total_bytes});return}default:{console.log("Received message did not match any known types:",message);return}}}}function useFileDownloadHandler(){const nt=React.useRef({});return _e=>{const rt="download-"+_e.transfer_uuid;switch(_e.type){case"FileTransferStart":{let at=_e.size_bytes;const ct=["B","K","M","G","T","P"];let ft=0;for(;at>=100&&ft{if(_e.getRenderRequestState.current==="triggered")_e.getRenderRequestState.current="pause";else if(_e.getRenderRequestState.current==="pause"){const it=_e.canvasRef.current,st=_e.getRenderRequest.current.width,ot=_e.getRenderRequest.current.height,at=new OffscreenCanvas(st,ot),ct=at.getContext("2d");ct.reset(),_e.getRenderRequest.current?.format==="image/jpeg"&&(ct.fillStyle="white",ct.fillRect(0,0,at.width,at.height));let ft=it.width,pt=it.height;const mt=ft/pt,xt=st/ot;mt>xt?ft=Math.round(xt*pt):mt{if(yt===null){console.error("Render failed"),_e.getRenderRequestState.current="ready";return}const vt=new Uint8Array(await yt.arrayBuffer());_e.sendMessageRef.current({type:"GetRenderResponseMessage",payload:vt}),_e.getRenderRequestState.current="ready"})}if(_e.getRenderRequestState.current==="ready"){const it=rt.current.findIndex(at=>at.type==="GetRenderRequestMessage"),st=it!==-1?it+1:rt.current.length;rt.current.splice(0,st).forEach(nt)}}),null}new TextEncoder;var CHUNK_SIZE=4096;function utf8DecodeJs(nt,_e,rt){for(var it=_e,st=it+rt,ot=[],at="";it65535&&(xt-=65536,ot.push(xt>>>10&1023|55296),xt=56320|xt&1023),ot.push(xt)}else ot.push(ct);ot.length>=CHUNK_SIZE&&(at+=String.fromCharCode.apply(String,ot),ot.length=0)}return ot.length>0&&(at+=String.fromCharCode.apply(String,ot)),at}var sharedTextDecoder=new TextDecoder,TEXT_DECODER_THRESHOLD=200;function utf8DecodeTD(nt,_e,rt){var it=nt.subarray(_e,_e+rt);return sharedTextDecoder.decode(it)}function utf8Decode(nt,_e,rt){return rt>TEXT_DECODER_THRESHOLD?utf8DecodeTD(nt,_e,rt):utf8DecodeJs(nt,_e,rt)}var ExtData=function(){function nt(_e,rt){this.type=_e,this.data=rt}return nt}(),__extends=function(){var nt=function(_e,rt){return nt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(it,st){it.__proto__=st}||function(it,st){for(var ot in st)Object.prototype.hasOwnProperty.call(st,ot)&&(it[ot]=st[ot])},nt(_e,rt)};return function(_e,rt){if(typeof rt!="function"&&rt!==null)throw new TypeError("Class extends value "+String(rt)+" is not a constructor or null");nt(_e,rt);function it(){this.constructor=_e}_e.prototype=rt===null?Object.create(rt):(it.prototype=rt.prototype,new it)}}(),DecodeError=function(nt){__extends(_e,nt);function _e(rt){var it=nt.call(this,rt)||this,st=Object.create(_e.prototype);return Object.setPrototypeOf(it,st),Object.defineProperty(it,"name",{configurable:!0,enumerable:!1,value:_e.name}),it}return _e}(Error),UINT32_MAX=4294967295;function setInt64(nt,_e,rt){var it=Math.floor(rt/4294967296),st=rt;nt.setUint32(_e,it),nt.setUint32(_e+4,st)}function getInt64(nt,_e){var rt=nt.getInt32(_e),it=nt.getUint32(_e+4);return rt*4294967296+it}function getUint64(nt,_e){var rt=nt.getUint32(_e),it=nt.getUint32(_e+4);return rt*4294967296+it}var EXT_TIMESTAMP=-1,TIMESTAMP32_MAX_SEC=4294967296-1,TIMESTAMP64_MAX_SEC=17179869184-1;function encodeTimeSpecToTimestamp(nt){var _e=nt.sec,rt=nt.nsec;if(_e>=0&&rt>=0&&_e<=TIMESTAMP64_MAX_SEC)if(rt===0&&_e<=TIMESTAMP32_MAX_SEC){var it=new Uint8Array(4),st=new DataView(it.buffer);return st.setUint32(0,_e),it}else{var ot=_e/4294967296,at=_e&4294967295,it=new Uint8Array(8),st=new DataView(it.buffer);return st.setUint32(0,rt<<2|ot&3),st.setUint32(4,at),it}else{var it=new Uint8Array(12),st=new DataView(it.buffer);return st.setUint32(0,rt),setInt64(st,4,_e),it}}function encodeDateToTimeSpec(nt){var _e=nt.getTime(),rt=Math.floor(_e/1e3),it=(_e-rt*1e3)*1e6,st=Math.floor(it/1e9);return{sec:rt+st,nsec:it-st*1e9}}function encodeTimestampExtension(nt){if(nt instanceof Date){var _e=encodeDateToTimeSpec(nt);return encodeTimeSpecToTimestamp(_e)}else return null}function decodeTimestampToTimeSpec(nt){var _e=new DataView(nt.buffer,nt.byteOffset,nt.byteLength);switch(nt.byteLength){case 4:{var rt=_e.getUint32(0),it=0;return{sec:rt,nsec:it}}case 8:{var st=_e.getUint32(0),ot=_e.getUint32(4),rt=(st&3)*4294967296+ot,it=st>>>2;return{sec:rt,nsec:it}}case 12:{var rt=getInt64(_e,4),it=_e.getUint32(0);return{sec:rt,nsec:it}}default:throw new DecodeError("Unrecognized data size for timestamp (expected 4, 8, or 12): ".concat(nt.length))}}function decodeTimestampExtension(nt){var _e=decodeTimestampToTimeSpec(nt);return new Date(_e.sec*1e3+_e.nsec/1e6)}var timestampExtension={type:EXT_TIMESTAMP,encode:encodeTimestampExtension,decode:decodeTimestampExtension},ExtensionCodec=function(){function nt(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(timestampExtension)}return nt.prototype.register=function(_e){var rt=_e.type,it=_e.encode,st=_e.decode;if(rt>=0)this.encoders[rt]=it,this.decoders[rt]=st;else{var ot=1+rt;this.builtInEncoders[ot]=it,this.builtInDecoders[ot]=st}},nt.prototype.tryToEncode=function(_e,rt){for(var it=0;it0&&_e<=this.maxKeyLength},nt.prototype.find=function(_e,rt,it){var st=this.caches[it-1];e:for(var ot=0,at=st;ot=this.maxLengthPerKey?it[Math.random()*it.length|0]=st:it.push(st)},nt.prototype.decode=function(_e,rt,it){var st=this.find(_e,rt,it);if(st!=null)return this.hit++,st;this.miss++;var ot=utf8DecodeJs(_e,rt,it),at=Uint8Array.prototype.slice.call(_e,rt,rt+it);return this.store(at,ot),ot},nt}(),__awaiter$1=function(nt,_e,rt,it){function st(ot){return ot instanceof rt?ot:new rt(function(at){at(ot)})}return new(rt||(rt=Promise))(function(ot,at){function ct(mt){try{pt(it.next(mt))}catch(xt){at(xt)}}function ft(mt){try{pt(it.throw(mt))}catch(xt){at(xt)}}function pt(mt){mt.done?ot(mt.value):st(mt.value).then(ct,ft)}pt((it=it.apply(nt,_e||[])).next())})},__generator$2=function(nt,_e){var rt={label:0,sent:function(){if(ot[0]&1)throw ot[1];return ot[1]},trys:[],ops:[]},it,st,ot,at;return at={next:ct(0),throw:ct(1),return:ct(2)},typeof Symbol=="function"&&(at[Symbol.iterator]=function(){return this}),at;function ct(pt){return function(mt){return ft([pt,mt])}}function ft(pt){if(it)throw new TypeError("Generator is already executing.");for(;at&&(at=0,pt[0]&&(rt=0)),rt;)try{if(it=1,st&&(ot=pt[0]&2?st.return:pt[0]?st.throw||((ot=st.return)&&ot.call(st),0):st.next)&&!(ot=ot.call(st,pt[1])).done)return ot;switch(st=0,ot&&(pt=[pt[0]&2,ot.value]),pt[0]){case 0:case 1:ot=pt;break;case 4:return rt.label++,{value:pt[1],done:!1};case 5:rt.label++,st=pt[1],pt=[0];continue;case 7:pt=rt.ops.pop(),rt.trys.pop();continue;default:if(ot=rt.trys,!(ot=ot.length>0&&ot[ot.length-1])&&(pt[0]===6||pt[0]===2)){rt=0;continue}if(pt[0]===3&&(!ot||pt[1]>ot[0]&&pt[1]1||ct(yt,vt)})})}function ct(yt,vt){try{ft(it[yt](vt))}catch(bt){xt(ot[0][3],bt)}}function ft(yt){yt.value instanceof __await$1?Promise.resolve(yt.value.v).then(pt,mt):xt(ot[0][2],yt)}function pt(yt){ct("next",yt)}function mt(yt){ct("throw",yt)}function xt(yt,vt){yt(vt),ot.shift(),ot.length&&ct(ot[0][0],ot[0][1])}},STATE_ARRAY="array",STATE_MAP_KEY="map_key",STATE_MAP_VALUE="map_value",isValidMapKeyType=function(nt){return typeof nt=="string"||typeof nt=="number"},HEAD_BYTE_REQUIRED=-1,EMPTY_VIEW=new DataView(new ArrayBuffer(0)),EMPTY_BYTES=new Uint8Array(EMPTY_VIEW.buffer);try{EMPTY_VIEW.getInt8(0)}catch(nt){if(!(nt instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}var DataViewIndexOutOfBoundsError=RangeError,MORE_DATA=new DataViewIndexOutOfBoundsError("Insufficient data"),sharedCachedKeyDecoder=new CachedKeyDecoder,Decoder=function(){function nt(_e){var rt,it,st,ot,at,ct,ft;this.totalPos=0,this.pos=0,this.view=EMPTY_VIEW,this.bytes=EMPTY_BYTES,this.headByte=HEAD_BYTE_REQUIRED,this.stack=[],this.extensionCodec=(rt=_e?.extensionCodec)!==null&&rt!==void 0?rt:ExtensionCodec.defaultCodec,this.context=_e?.context,this.useBigInt64=(it=_e?.useBigInt64)!==null&&it!==void 0?it:!1,this.maxStrLength=(st=_e?.maxStrLength)!==null&&st!==void 0?st:UINT32_MAX,this.maxBinLength=(ot=_e?.maxBinLength)!==null&&ot!==void 0?ot:UINT32_MAX,this.maxArrayLength=(at=_e?.maxArrayLength)!==null&&at!==void 0?at:UINT32_MAX,this.maxMapLength=(ct=_e?.maxMapLength)!==null&&ct!==void 0?ct:UINT32_MAX,this.maxExtLength=(ft=_e?.maxExtLength)!==null&&ft!==void 0?ft:UINT32_MAX,this.keyDecoder=_e?.keyDecoder!==void 0?_e.keyDecoder:sharedCachedKeyDecoder}return nt.prototype.reinitializeState=function(){this.totalPos=0,this.headByte=HEAD_BYTE_REQUIRED,this.stack.length=0},nt.prototype.setBuffer=function(_e){this.bytes=ensureUint8Array(_e),this.view=createDataView(this.bytes),this.pos=0},nt.prototype.appendBuffer=function(_e){if(this.headByte===HEAD_BYTE_REQUIRED&&!this.hasRemaining(1))this.setBuffer(_e);else{var rt=this.bytes.subarray(this.pos),it=ensureUint8Array(_e),st=new Uint8Array(rt.length+it.length);st.set(rt),st.set(it,rt.length),this.setBuffer(st)}},nt.prototype.hasRemaining=function(_e){return this.view.byteLength-this.pos>=_e},nt.prototype.createExtraByteError=function(_e){var rt=this,it=rt.view,st=rt.pos;return new RangeError("Extra ".concat(it.byteLength-st," of ").concat(it.byteLength," byte(s) found at buffer[").concat(_e,"]"))},nt.prototype.decode=function(_e){this.reinitializeState(),this.setBuffer(_e);var rt=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return rt},nt.prototype.decodeMulti=function(_e){return __generator$2(this,function(rt){switch(rt.label){case 0:this.reinitializeState(),this.setBuffer(_e),rt.label=1;case 1:return this.hasRemaining(1)?[4,this.doDecodeSync()]:[3,3];case 2:return rt.sent(),[3,1];case 3:return[2]}})},nt.prototype.decodeAsync=function(_e){var rt,it,st,ot,at,ct,ft;return __awaiter$1(this,void 0,void 0,function(){var pt,mt,xt,yt,vt,bt,wt,Tt;return __generator$2(this,function(St){switch(St.label){case 0:pt=!1,St.label=1;case 1:St.trys.push([1,6,7,12]),rt=!0,it=__asyncValues(_e),St.label=2;case 2:return[4,it.next()];case 3:if(st=St.sent(),ot=st.done,!!ot)return[3,5];ft=st.value,rt=!1;try{if(xt=ft,pt)throw this.createExtraByteError(this.totalPos);this.appendBuffer(xt);try{mt=this.doDecodeSync(),pt=!0}catch(Rt){if(!(Rt instanceof DataViewIndexOutOfBoundsError))throw Rt}this.totalPos+=this.pos}finally{rt=!0}St.label=4;case 4:return[3,2];case 5:return[3,12];case 6:return yt=St.sent(),at={error:yt},[3,12];case 7:return St.trys.push([7,,10,11]),!rt&&!ot&&(ct=it.return)?[4,ct.call(it)]:[3,9];case 8:St.sent(),St.label=9;case 9:return[3,11];case 10:if(at)throw at.error;return[7];case 11:return[7];case 12:if(pt){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return[2,mt]}throw vt=this,bt=vt.headByte,wt=vt.pos,Tt=vt.totalPos,new RangeError("Insufficient data in parsing ".concat(prettyByte(bt)," at ").concat(Tt," (").concat(wt," in the current buffer)"))}})})},nt.prototype.decodeArrayStream=function(_e){return this.decodeMultiAsync(_e,!0)},nt.prototype.decodeStream=function(_e){return this.decodeMultiAsync(_e,!1)},nt.prototype.decodeMultiAsync=function(_e,rt){return __asyncGenerator$1(this,arguments,function(){var st,ot,at,ct,ft,pt,mt,xt,yt,vt,bt,wt;return __generator$2(this,function(Tt){switch(Tt.label){case 0:st=rt,ot=-1,Tt.label=1;case 1:Tt.trys.push([1,15,16,21]),at=!0,ct=__asyncValues(_e),Tt.label=2;case 2:return[4,__await$1(ct.next())];case 3:if(ft=Tt.sent(),yt=ft.done,!!yt)return[3,14];wt=ft.value,at=!1,Tt.label=4;case 4:if(Tt.trys.push([4,,12,13]),pt=wt,rt&&ot===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(pt),st&&(ot=this.readArraySize(),st=!1,this.complete()),Tt.label=5;case 5:Tt.trys.push([5,10,,11]),Tt.label=6;case 6:return[4,__await$1(this.doDecodeSync())];case 7:return[4,Tt.sent()];case 8:return Tt.sent(),--ot===0?[3,9]:[3,6];case 9:return[3,11];case 10:if(mt=Tt.sent(),!(mt instanceof DataViewIndexOutOfBoundsError))throw mt;return[3,11];case 11:return this.totalPos+=this.pos,[3,13];case 12:return at=!0,[7];case 13:return[3,2];case 14:return[3,21];case 15:return xt=Tt.sent(),vt={error:xt},[3,21];case 16:return Tt.trys.push([16,,19,20]),!at&&!yt&&(bt=ct.return)?[4,__await$1(bt.call(ct))]:[3,18];case 17:Tt.sent(),Tt.label=18;case 18:return[3,20];case 19:if(vt)throw vt.error;return[7];case 20:return[7];case 21:return[2]}})})},nt.prototype.doDecodeSync=function(){e:for(;;){var _e=this.readHeadByte(),rt=void 0;if(_e>=224)rt=_e-256;else if(_e<192)if(_e<128)rt=_e;else if(_e<144){var it=_e-128;if(it!==0){this.pushMapState(it),this.complete();continue e}else rt={}}else if(_e<160){var it=_e-144;if(it!==0){this.pushArrayState(it),this.complete();continue e}else rt=[]}else{var st=_e-160;rt=this.decodeUtf8String(st,0)}else if(_e===192)rt=null;else if(_e===194)rt=!1;else if(_e===195)rt=!0;else if(_e===202)rt=this.readF32();else if(_e===203)rt=this.readF64();else if(_e===204)rt=this.readU8();else if(_e===205)rt=this.readU16();else if(_e===206)rt=this.readU32();else if(_e===207)this.useBigInt64?rt=this.readU64AsBigInt():rt=this.readU64();else if(_e===208)rt=this.readI8();else if(_e===209)rt=this.readI16();else if(_e===210)rt=this.readI32();else if(_e===211)this.useBigInt64?rt=this.readI64AsBigInt():rt=this.readI64();else if(_e===217){var st=this.lookU8();rt=this.decodeUtf8String(st,1)}else if(_e===218){var st=this.lookU16();rt=this.decodeUtf8String(st,2)}else if(_e===219){var st=this.lookU32();rt=this.decodeUtf8String(st,4)}else if(_e===220){var it=this.readU16();if(it!==0){this.pushArrayState(it),this.complete();continue e}else rt=[]}else if(_e===221){var it=this.readU32();if(it!==0){this.pushArrayState(it),this.complete();continue e}else rt=[]}else if(_e===222){var it=this.readU16();if(it!==0){this.pushMapState(it),this.complete();continue e}else rt={}}else if(_e===223){var it=this.readU32();if(it!==0){this.pushMapState(it),this.complete();continue e}else rt={}}else if(_e===196){var it=this.lookU8();rt=this.decodeBinary(it,1)}else if(_e===197){var it=this.lookU16();rt=this.decodeBinary(it,2)}else if(_e===198){var it=this.lookU32();rt=this.decodeBinary(it,4)}else if(_e===212)rt=this.decodeExtension(1,0);else if(_e===213)rt=this.decodeExtension(2,0);else if(_e===214)rt=this.decodeExtension(4,0);else if(_e===215)rt=this.decodeExtension(8,0);else if(_e===216)rt=this.decodeExtension(16,0);else if(_e===199){var it=this.lookU8();rt=this.decodeExtension(it,1)}else if(_e===200){var it=this.lookU16();rt=this.decodeExtension(it,2)}else if(_e===201){var it=this.lookU32();rt=this.decodeExtension(it,4)}else throw new DecodeError("Unrecognized type byte: ".concat(prettyByte(_e)));this.complete();for(var ot=this.stack;ot.length>0;){var at=ot[ot.length-1];if(at.type===STATE_ARRAY)if(at.array[at.position]=rt,at.position++,at.position===at.size)ot.pop(),rt=at.array;else continue e;else if(at.type===STATE_MAP_KEY){if(!isValidMapKeyType(rt))throw new DecodeError("The type of key must be string or number but "+typeof rt);if(rt==="__proto__")throw new DecodeError("The key __proto__ is not allowed");at.key=rt,at.type=STATE_MAP_VALUE;continue e}else if(at.map[at.key]=rt,at.readCount++,at.readCount===at.size)ot.pop(),rt=at.map;else{at.key=null,at.type=STATE_MAP_KEY;continue e}}return rt}},nt.prototype.readHeadByte=function(){return this.headByte===HEAD_BYTE_REQUIRED&&(this.headByte=this.readU8()),this.headByte},nt.prototype.complete=function(){this.headByte=HEAD_BYTE_REQUIRED},nt.prototype.readArraySize=function(){var _e=this.readHeadByte();switch(_e){case 220:return this.readU16();case 221:return this.readU32();default:{if(_e<160)return _e-144;throw new DecodeError("Unrecognized array type byte: ".concat(prettyByte(_e)))}}},nt.prototype.pushMapState=function(_e){if(_e>this.maxMapLength)throw new DecodeError("Max length exceeded: map length (".concat(_e,") > maxMapLengthLength (").concat(this.maxMapLength,")"));this.stack.push({type:STATE_MAP_KEY,size:_e,key:null,readCount:0,map:{}})},nt.prototype.pushArrayState=function(_e){if(_e>this.maxArrayLength)throw new DecodeError("Max length exceeded: array length (".concat(_e,") > maxArrayLength (").concat(this.maxArrayLength,")"));this.stack.push({type:STATE_ARRAY,size:_e,array:new Array(_e),position:0})},nt.prototype.decodeUtf8String=function(_e,rt){var it;if(_e>this.maxStrLength)throw new DecodeError("Max length exceeded: UTF-8 byte length (".concat(_e,") > maxStrLength (").concat(this.maxStrLength,")"));if(this.bytes.byteLength0){var _e=this.stack[this.stack.length-1];return _e.type===STATE_MAP_KEY}return!1},nt.prototype.decodeBinary=function(_e,rt){if(_e>this.maxBinLength)throw new DecodeError("Max length exceeded: bin length (".concat(_e,") > maxBinLength (").concat(this.maxBinLength,")"));if(!this.hasRemaining(_e+rt))throw MORE_DATA;var it=this.pos+rt,st=this.bytes.subarray(it,it+_e);return this.pos+=rt+_e,st},nt.prototype.decodeExtension=function(_e,rt){if(_e>this.maxExtLength)throw new DecodeError("Max length exceeded: ext length (".concat(_e,") > maxExtLength (").concat(this.maxExtLength,")"));var it=this.view.getInt8(this.pos+rt),st=this.decodeBinary(_e,rt+1);return this.extensionCodec.decode(st,it,this.context)},nt.prototype.lookU8=function(){return this.view.getUint8(this.pos)},nt.prototype.lookU16=function(){return this.view.getUint16(this.pos)},nt.prototype.lookU32=function(){return this.view.getUint32(this.pos)},nt.prototype.readU8=function(){var _e=this.view.getUint8(this.pos);return this.pos++,_e},nt.prototype.readI8=function(){var _e=this.view.getInt8(this.pos);return this.pos++,_e},nt.prototype.readU16=function(){var _e=this.view.getUint16(this.pos);return this.pos+=2,_e},nt.prototype.readI16=function(){var _e=this.view.getInt16(this.pos);return this.pos+=2,_e},nt.prototype.readU32=function(){var _e=this.view.getUint32(this.pos);return this.pos+=4,_e},nt.prototype.readI32=function(){var _e=this.view.getInt32(this.pos);return this.pos+=4,_e},nt.prototype.readU64=function(){var _e=getUint64(this.view,this.pos);return this.pos+=8,_e},nt.prototype.readI64=function(){var _e=getInt64(this.view,this.pos);return this.pos+=8,_e},nt.prototype.readU64AsBigInt=function(){var _e=this.view.getBigUint64(this.pos);return this.pos+=8,_e},nt.prototype.readI64AsBigInt=function(){var _e=this.view.getBigInt64(this.pos);return this.pos+=8,_e},nt.prototype.readF32=function(){var _e=this.view.getFloat32(this.pos);return this.pos+=4,_e},nt.prototype.readF64=function(){var _e=this.view.getFloat64(this.pos);return this.pos+=8,_e},nt}();function decode(nt,_e){var rt=new Decoder(_e);return rt.decode(nt)}var __generator$1=function(nt,_e){var rt={label:0,sent:function(){if(ot[0]&1)throw ot[1];return ot[1]},trys:[],ops:[]},it,st,ot,at;return at={next:ct(0),throw:ct(1),return:ct(2)},typeof Symbol=="function"&&(at[Symbol.iterator]=function(){return this}),at;function ct(pt){return function(mt){return ft([pt,mt])}}function ft(pt){if(it)throw new TypeError("Generator is already executing.");for(;at&&(at=0,pt[0]&&(rt=0)),rt;)try{if(it=1,st&&(ot=pt[0]&2?st.return:pt[0]?st.throw||((ot=st.return)&&ot.call(st),0):st.next)&&!(ot=ot.call(st,pt[1])).done)return ot;switch(st=0,ot&&(pt=[pt[0]&2,ot.value]),pt[0]){case 0:case 1:ot=pt;break;case 4:return rt.label++,{value:pt[1],done:!1};case 5:rt.label++,st=pt[1],pt=[0];continue;case 7:pt=rt.ops.pop(),rt.trys.pop();continue;default:if(ot=rt.trys,!(ot=ot.length>0&&ot[ot.length-1])&&(pt[0]===6||pt[0]===2)){rt=0;continue}if(pt[0]===3&&(!ot||pt[1]>ot[0]&&pt[1]1||ct(yt,vt)})})}function ct(yt,vt){try{ft(it[yt](vt))}catch(bt){xt(ot[0][3],bt)}}function ft(yt){yt.value instanceof __await?Promise.resolve(yt.value.v).then(pt,mt):xt(ot[0][2],yt)}function pt(yt){ct("next",yt)}function mt(yt){ct("throw",yt)}function xt(yt,vt){yt(vt),ot.shift(),ot.length&&ct(ot[0][0],ot[0][1])}};function isAsyncIterable(nt){return nt[Symbol.asyncIterator]!=null}function assertNonNull(nt){if(nt==null)throw new Error("Assertion Failure: value must not be null nor undefined")}function asyncIterableFromStream(nt){return __asyncGenerator(this,arguments,function(){var rt,it,st,ot;return __generator$1(this,function(at){switch(at.label){case 0:rt=nt.getReader(),at.label=1;case 1:at.trys.push([1,,9,10]),at.label=2;case 2:return[4,__await(rt.read())];case 3:return it=at.sent(),st=it.done,ot=it.value,st?[4,__await(void 0)]:[3,5];case 4:return[2,at.sent()];case 5:return assertNonNull(ot),[4,__await(ot)];case 6:return[4,at.sent()];case 7:return at.sent(),[3,2];case 8:return[3,10];case 9:return rt.releaseLock(),[7];case 10:return[2]}})})}function ensureAsyncIterable(nt){return isAsyncIterable(nt)?nt:asyncIterableFromStream(nt)}var __awaiter=function(nt,_e,rt,it){function st(ot){return ot instanceof rt?ot:new rt(function(at){at(ot)})}return new(rt||(rt=Promise))(function(ot,at){function ct(mt){try{pt(it.next(mt))}catch(xt){at(xt)}}function ft(mt){try{pt(it.throw(mt))}catch(xt){at(xt)}}function pt(mt){mt.done?ot(mt.value):st(mt.value).then(ct,ft)}pt((it=it.apply(nt,_e||[])).next())})},__generator=function(nt,_e){var rt={label:0,sent:function(){if(ot[0]&1)throw ot[1];return ot[1]},trys:[],ops:[]},it,st,ot,at;return at={next:ct(0),throw:ct(1),return:ct(2)},typeof Symbol=="function"&&(at[Symbol.iterator]=function(){return this}),at;function ct(pt){return function(mt){return ft([pt,mt])}}function ft(pt){if(it)throw new TypeError("Generator is already executing.");for(;at&&(at=0,pt[0]&&(rt=0)),rt;)try{if(it=1,st&&(ot=pt[0]&2?st.return:pt[0]?st.throw||((ot=st.return)&&ot.call(st),0):st.next)&&!(ot=ot.call(st,pt[1])).done)return ot;switch(st=0,ot&&(pt=[pt[0]&2,ot.value]),pt[0]){case 0:case 1:ot=pt;break;case 4:return rt.label++,{value:pt[1],done:!1};case 5:rt.label++,st=pt[1],pt=[0];continue;case 7:pt=rt.ops.pop(),rt.trys.pop();continue;default:if(ot=rt.trys,!(ot=ot.length>0&&ot[ot.length-1])&&(pt[0]===6||pt[0]===2)){rt=0;continue}if(pt[0]===3&&(!ot||pt[1]>ot[0]&&pt[1]>1|(i&21845)<<1;x=(x&52428)>>2|(x&13107)<<2,x=(x&61680)>>4|(x&3855)<<4,rev[i]=((x&65280)>>8|(x&255)<<8)>>1}var hMap=function(nt,_e,rt){for(var it=nt.length,st=0,ot=new u16(_e);st>ft]=pt}else for(ct=new u16(it),st=0;st>15-nt[st]);return ct},flt=new u8(288);for(var i=0;i<144;++i)flt[i]=8;for(var i=144;i<256;++i)flt[i]=9;for(var i=256;i<280;++i)flt[i]=7;for(var i=280;i<288;++i)flt[i]=8;var fdt=new u8(32);for(var i=0;i<32;++i)fdt[i]=5;var flrm=hMap(flt,9,1),fdrm=hMap(fdt,5,1),max=function(nt){for(var _e=nt[0],rt=1;rt_e&&(_e=nt[rt]);return _e},bits=function(nt,_e,rt){var it=_e/8|0;return(nt[it]|nt[it+1]<<8)>>(_e&7)&rt},bits16=function(nt,_e){var rt=_e/8|0;return(nt[rt]|nt[rt+1]<<8|nt[rt+2]<<16)>>(_e&7)},shft=function(nt){return(nt+7)/8|0},slc=function(nt,_e,rt){return(_e==null||_e<0)&&(_e=0),(rt==null||rt>nt.length)&&(rt=nt.length),new u8(nt.subarray(_e,rt))},ec=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],err=function(nt,_e,rt){var it=new Error(_e||ec[nt]);if(it.code=nt,Error.captureStackTrace&&Error.captureStackTrace(it,err),!rt)throw it;return it},inflt=function(nt,_e,rt,it){var st=nt.length,ot=it?it.length:0;if(!st||_e.f&&!_e.l)return rt||new u8(0);var at=!rt,ct=at||_e.i!=2,ft=_e.i;at&&(rt=new u8(st*3));var pt=function(Wn){var sn=rt.length;if(Wn>sn){var Ln=new u8(Math.max(sn*2,Wn));Ln.set(rt),rt=Ln}},mt=_e.f||0,xt=_e.p||0,yt=_e.b||0,vt=_e.l,bt=_e.d,wt=_e.m,Tt=_e.n,St=st*8;do{if(!vt){mt=bits(nt,xt,1);var Rt=bits(nt,xt+1,3);if(xt+=3,Rt)if(Rt==1)vt=flrm,bt=fdrm,wt=9,Tt=5;else if(Rt==2){var It=bits(nt,xt,31)+257,Nt=bits(nt,xt+10,15)+4,$t=It+bits(nt,xt+5,31)+1;xt+=14;for(var Ut=new u8($t),Ft=new u8(19),Vt=0;Vt>4;if(Mt<16)Ut[Vt++]=Mt;else{var qt=0,Kt=0;for(Mt==16?(Kt=3+bits(nt,xt,3),xt+=2,qt=Ut[Vt-1]):Mt==17?(Kt=3+bits(nt,xt,7),xt+=3):Mt==18&&(Kt=11+bits(nt,xt,127),xt+=7);Kt--;)Ut[Vt++]=qt}}var Gt=Ut.subarray(0,It),tn=Ut.subarray(It);wt=max(Gt),Tt=max(tn),vt=hMap(Gt,wt,1),bt=hMap(tn,Tt,1)}else err(1);else{var Mt=shft(xt)+4,Pt=nt[Mt-4]|nt[Mt-3]<<8,Dt=Mt+Pt;if(Dt>st){ft&&err(0);break}ct&&pt(yt+Pt),rt.set(nt.subarray(Mt,Dt),yt),_e.b=yt+=Pt,_e.p=xt=Dt*8,_e.f=mt;continue}if(xt>St){ft&&err(0);break}}ct&&pt(yt+131072);for(var jt=(1<>4;if(xt+=qt&15,xt>St){ft&&err(0);break}if(qt||err(2),Qt<256)rt[yt++]=Qt;else if(Qt==256){hn=xt,vt=null;break}else{var gn=Qt-254;if(Qt>264){var Vt=Qt-257,pn=fleb[Vt];gn=bits(nt,xt,(1<>4;En||err(3),xt+=En&15;var tn=fd[kn];if(kn>3){var pn=fdeb[kn];tn+=bits16(nt,xt)&(1<St){ft&&err(0);break}ct&&pt(yt+131072);var Hn=yt+gn;if(yt>3&1)+(_e>>4&1);it>0;it-=!nt[rt++]);return rt+(_e&2)},gzl=function(nt){var _e=nt.length;return(nt[_e-4]|nt[_e-3]<<8|nt[_e-2]<<16|nt[_e-1]<<24)>>>0},zls=function(nt,_e){return((nt[0]&15)!=8||nt[0]>>4>7||(nt[0]<<8|nt[1])%31)&&err(6,"invalid zlib data"),(nt[1]>>5&1)==+!_e&&err(6,"invalid zlib data: "+(nt[1]&32?"need":"unexpected")+" dictionary"),(nt[1]>>3&4)+2};function inflate(nt,_e,rt){return rt||(rt=_e,_e={}),typeof rt!="function"&&err(7),cbify(nt,_e,[bInflt],function(it){return pbf(inflateSync(it.data[0],gopt(it.data[1])))},1,rt)}function inflateSync(nt,_e){return inflt(nt,{i:2},_e&&_e.out,_e&&_e.dictionary)}function gunzip(nt,_e,rt){return rt||(rt=_e,_e={}),typeof rt!="function"&&err(7),cbify(nt,_e,[bInflt,guze,function(){return[gunzipSync]}],function(it){return pbf(gunzipSync(it.data[0],it.data[1]))},3,rt)}function gunzipSync(nt,_e){var rt=gzs(nt);return rt+8>nt.length&&err(6,"invalid gzip data"),inflt(nt.subarray(rt,-8),{i:2},_e&&_e.out||new u8(gzl(nt)),_e&&_e.dictionary)}function unzlib(nt,_e,rt){return rt||(rt=_e,_e={}),typeof rt!="function"&&err(7),cbify(nt,_e,[bInflt,zule,function(){return[unzlibSync]}],function(it){return pbf(unzlibSync(it.data[0],gopt(it.data[1])))},5,rt)}function unzlibSync(nt,_e){return inflt(nt.subarray(zls(nt,_e&&_e.dictionary),-4),{i:2},_e&&_e.out,_e&&_e.dictionary)}function decompress(nt,_e,rt){return rt||(rt=_e,_e={}),typeof rt!="function"&&err(7),nt[0]==31&&nt[1]==139&&nt[2]==8?gunzip(nt,_e,rt):(nt[0]&15)!=8||nt[0]>>4>7||(nt[0]<<8|nt[1])%31?inflate(nt,_e,rt):unzlib(nt,_e,rt)}var td=typeof TextDecoder<"u"&&new TextDecoder,tds=0;try{td.decode(et,{stream:!0}),tds=1}catch(nt){}async function deserializeGzippedMsgpackFile(nt,_e){const rt=await fetch(nt);if(!rt.ok)throw new Error(`Failed to fetch the file: ${rt.statusText}`);return new Promise(it=>{const st=parseInt(rt.headers.get("Content-Length"));if(typeof DecompressionStream>"u")console.log("DecompressionStream is unavailable. Using fallback."),_e({downloaded:.1*st,total:st}),rt.arrayBuffer().then(ot=>{_e({downloaded:.8*st,total:st}),decompress(new Uint8Array(ot),(at,ct)=>{_e({downloaded:1*st,total:st}),it(decode(ct))})});else{let ot=0;const at=new TransformStream({transform(ct,ft){ot+=ct.length,_e({downloaded:ot,total:st}),ft.enqueue(ct)}});decodeAsync(rt.body.pipeThrough(at).pipeThrough(new DecompressionStream("gzip"))).then(ct=>it(ct))}})}function PlaybackFromFile({fileUrl:nt}){const _e=reactExports.useContext(ViewerContext),rt=_e.messageQueueRef,it=reactExports.useRef(null),st=_e.useGui(It=>It.theme.dark_mode),[ot,at]=reactExports.useState({downloaded:0,total:0}),[ct,ft]=reactExports.useState("1x"),[pt,mt]=reactExports.useState(!1),[xt,yt]=reactExports.useState(null),vt=new URLSearchParams(window.location.search),bt=vt.getAll("synchronizedVideoOverlay"),wt=parseFloat(vt.get("synchronizedVideoTimeOffset")||"0"),[Tt,St]=reactExports.useState(0),Rt=useMantineTheme();reactExports.useEffect(()=>{deserializeGzippedMsgpackFile(nt,at).then(yt)},[]);const Mt=reactExports.useRef({currentTime:0,currentIndex:0}),Pt=reactExports.useCallback(()=>{if(xt===null)return;const It=Mt.current;for(;It.currentIndex=xt.durationSeconds&&xt.loopStartIndex!==null&&(It.currentIndex=xt.loopStartIndex,It.currentTime=xt.messages[xt.loopStartIndex][0]),St(It.currentTime)},[xt]);reactExports.useEffect(()=>{let It;const Nt=()=>{it.current&&it.current.readyState>=2&&(it.current.currentTime=Math.max(0,Mt.current.currentTime+wt)),It=requestAnimationFrame(Nt)};return Nt(),()=>{It&&cancelAnimationFrame(It)}},[]),reactExports.useEffect(()=>{const It=parseFloat(ct);if(xt!==null&&!pt){let Nt=Date.now();const $t=setInterval(()=>{const Ut=Date.now();Mt.current.currentTime+=(Ut-Nt)/1e3*It,Nt=Ut,Pt(),Mt.current.currentIndex===xt.messages.length&&xt.loopStartIndex===null&&clearInterval($t)},1e3/120);return()=>clearInterval($t)}},[Pt,xt,pt,ct,rt,St]),reactExports.useEffect(()=>{function It(Nt){Nt.code==="Space"&&mt(!pt)}return window.addEventListener("keydown",It),()=>{window.removeEventListener("keydown",It)}},[pt]);const Dt=reactExports.useCallback(It=>{It0&&jsxRuntimeExports.jsxs("div",{style:{position:"fixed",top:"1.5em",left:"1em",zIndex:2,maxHeight:"auto",border:"0.2em solid rgba(255, 255, 255, 0.5)",overflow:"hidden",borderRadius:"0.3rem",padding:"0"},children:[jsxRuntimeExports.jsx("div",{style:{textAlign:"center",position:"absolute",top:"0",backgroundColor:"rgba(0,0,0,0.75)",color:"#eee",fontFamily:"Inter",padding:"0.25em 1em 0.125em 1em",fontWeight:"500"},children:"Input video"}),jsxRuntimeExports.jsx("video",{ref:it,src:bt[0],style:{width:"15rem",maxWidth:"20vw",aspectRatio:"1",margin:"0",display:"block"},muted:!0})]}),jsxRuntimeExports.jsxs(Paper,{radius:"xs",shadow:"0.1em 0 1em 0 rgba(0,0,0,0.1)",style:{position:"fixed",bottom:"1em",left:"50%",transform:"translateX(-50%)",width:"25em",maxWidth:"95%",zIndex:1,padding:"0.5em",display:xt.durationSeconds===0?"none":"flex",alignItems:"center",justifyContent:"space-between",gap:"0.375em"},children:[jsxRuntimeExports.jsx(ActionIcon,{size:"md",variant:"subtle",children:pt?jsxRuntimeExports.jsx(IconPlayerPlayFilled,{onClick:()=>mt(!1),height:"1.125em",width:"1.125em"}):jsxRuntimeExports.jsx(IconPlayerPauseFilled,{onClick:()=>mt(!0),height:"1.125em",width:"1.125em"})}),jsxRuntimeExports.jsx(NumberInput,{size:"xs",hideControls:!0,value:Tt.toFixed(1),step:.01,styles:{wrapper:{width:"3.1em"},input:{padding:"0.2em",fontFamily:Rt.fontFamilyMonospace,textAlign:"center"}},onChange:It=>Dt(typeof It=="number"?It:parseFloat(It))}),jsxRuntimeExports.jsx(Slider,{thumbSize:0,radius:"xs",step:1e-4,style:{flexGrow:1},min:0,max:xt.durationSeconds,value:Tt,onChange:Dt,styles:{thumb:{display:"none"}}}),jsxRuntimeExports.jsx(Tooltip,{zIndex:10,label:"Playback speed",withinPortal:!0,children:jsxRuntimeExports.jsx(Select,{size:"xs",value:ct,onChange:It=>It===null?null:ft(It),radius:"xs",data:["0.5x","1x","2x","4x","8x"],styles:{wrapper:{width:"3.25em"}},comboboxProps:{zIndex:5,width:"5.25em"}})})]})]})}var __spreadArray=function(nt,_e,rt){if(rt||arguments.length===2)for(var it=0,st=_e.length,ot;it"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new ReactNativeInfo:typeof navigator<"u"?parseUserAgent(navigator.userAgent):getNodeVersion()}function matchUserAgent(nt){return nt!==""&&userAgentRules.reduce(function(_e,rt){var it=rt[0],st=rt[1];if(_e)return _e;var ot=st.exec(nt);return!!ot&&[it,ot]},!1)}function parseUserAgent(nt){var _e=matchUserAgent(nt);if(!_e)return null;var rt=_e[0],it=_e[1];if(rt==="searchbot")return new BotInfo;var st=it[1]&&it[1].split(".").join("_").split("_").slice(0,3);st?st.length{const nt=detect();if(nt===null||nt.version===null)console.log("Failed to detect browser"),notifications.show({title:"Could not detect browser version",message:"Your browser version could not be detected. It may not be supported.",autoClose:!1,color:"red"});else{const _e=parseFloat(nt.version);console.log(`Detected ${nt.name} version ${_e}`),(nt.name==="chrome"&&_e<91||nt.name==="edge"&&_e<91||nt.name==="firefox"&&_e<89||nt.name==="opera"&&_e<77||nt.name==="safari"&&_e<16.4)&¬ifications.show({title:"Unsuppported browser",message:`Your browser (${nt.name.slice(0,1).toUpperCase()+nt.name.slice(1)}/${nt.version}) is outdated, which may cause problems. Consider updating.`,autoClose:!1,color:"red"})}}),null}const ViewerContext=React.createContext(null);ColorManagement.enabled=!0;function ViewerRoot(){function nt(){let pt=window.location.href;return pt=pt.replace("http://","ws://"),pt=pt.replace("https://","wss://"),pt=pt.split("?")[0],pt.endsWith("/")&&(pt=pt.slice(0,-1)),pt}const _e=new URLSearchParams(window.location.search).getAll(searchParamKey),rt=_e.length>=1?_e[0]:nt(),it=new URLSearchParams(window.location.search),st=it.get("playbackPath"),ot=it.get("darkMode")!==null,at=it.get("showStats")!==null,ct=React.useRef({}),ft={messageSource:st===null?"websocket":"file_playback",useSceneTree:useSceneTreeState(ct),useGui:useGuiState(rt),sendMessageRef:React.useRef(st==null?pt=>console.log(`Tried to send ${pt.type} but websocket is not connected!`):()=>null),canvasRef:React.useRef(null),sceneRef:React.useRef(null),cameraRef:React.useRef(null),backgroundMaterialRef:React.useRef(null),cameraControlRef:React.useRef(null),sendCameraRef:React.useRef(null),resetCameraViewRef:React.useRef(null),nodeAttributesFromName:React.useRef({"":{wxyz:(()=>{const pt=new Quaternion().setFromEuler(new Euler(Math.PI/2,Math.PI,-Math.PI/2));return[pt.w,pt.x,pt.y,pt.z]})()}}),nodeRefFromName:ct,messageQueueRef:React.useRef([]),getRenderRequestState:React.useRef("ready"),getRenderRequest:React.useRef(null),scenePointerInfo:React.useRef({enabled:!1,dragStart:[0,0],dragEnd:[0,0],isDragging:!1}),canvas2dRef:React.useRef(null),skinnedMeshState:React.useRef({})};return ot&&(ft.useGui.getState().theme.dark_mode=ot),jsxRuntimeExports.jsx(ViewerContext.Provider,{value:ft,children:jsxRuntimeExports.jsxs(ViewerContents,{children:[ft.messageSource==="websocket"?jsxRuntimeExports.jsx(WebsocketMessageProducer,{}):null,ft.messageSource==="file_playback"?jsxRuntimeExports.jsx(PlaybackFromFile,{fileUrl:st}):null,at?jsxRuntimeExports.jsx(Stats,{className:"stats-panel"}):null]})})}function ViewerContents({children:nt}){const _e=React.useContext(ViewerContext),rt=_e.useGui(ot=>ot.theme.dark_mode),it=_e.useGui(ot=>ot.theme.colors),st=_e.useGui(ot=>ot.theme.control_layout);return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(ColorSchemeScript,{forceColorScheme:rt?"dark":"light"}),jsxRuntimeExports.jsxs(MantineProvider,{theme:{...theme,...it===null?{}:{colors:{custom:it},primaryColor:"custom"}},forceColorScheme:rt?"dark":"light",children:[nt,jsxRuntimeExports.jsx(Notifications,{position:"top-left",limit:10,containerWidth:"20em",styles:{root:{boxShadow:"0.1em 0 1em 0 rgba(0,0,0,0.1) !important"}}}),jsxRuntimeExports.jsx(BrowserWarning,{}),jsxRuntimeExports.jsx(ViserModal,{}),jsxRuntimeExports.jsxs(Box,{style:{width:"100%",height:"100%",display:"flex",position:"relative",flexDirection:"column"},children:[jsxRuntimeExports.jsx(Titlebar,{}),jsxRuntimeExports.jsxs(Box,{style:{width:"100%",position:"relative",flexGrow:1,overflow:"hidden",display:"flex"},children:[jsxRuntimeExports.jsxs(Box,{style:ot=>({backgroundColor:rt?ot.colors.dark[9]:"#fff",flexGrow:1,overflow:"hidden",height:"100%"}),children:[jsxRuntimeExports.jsx(Viewer2DCanvas,{}),jsxRuntimeExports.jsx(ViewerCanvas,{children:jsxRuntimeExports.jsx(FrameSynchronizedMessageHandler,{})}),_e.useGui(ot=>ot.theme.show_logo)&&_e.messageSource=="websocket"?jsxRuntimeExports.jsx(ViserLogo,{}):null]}),_e.messageSource=="websocket"?jsxRuntimeExports.jsx(ControlPanel,{control_layout:st}):null]})]})]})]})}function ViewerCanvas({children:nt}){const _e=React.useContext(ViewerContext),rt=useThrottledMessageSender(20),it=useMantineTheme();return jsxRuntimeExports.jsxs(Canvas,{camera:{position:[-3,3,-3],near:.05},gl:{preserveDrawingBuffer:!0},style:{position:"relative",zIndex:0,width:"100%",height:"100%"},ref:_e.canvasRef,onPointerDown:st=>{const ot=_e.scenePointerInfo.current;if(ot.enabled===!1)return;const at=_e.canvasRef.current.getBoundingClientRect();if(ot.dragStart=[st.clientX-at.left,st.clientY-at.top],ot.dragEnd=ot.dragStart,ndcFromPointerXy(_e,ot.dragEnd)===null||ot.isDragging)return;ot.isDragging=!0,_e.cameraControlRef.current.enabled=!1;const ct=_e.canvas2dRef.current.getContext("2d");ct.clearRect(0,0,ct.canvas.width,ct.canvas.height)},onPointerMove:st=>{const ot=_e.scenePointerInfo.current;if(ot.enabled===!1||!ot.isDragging)return;const at=_e.canvasRef.current.getBoundingClientRect(),ct=[st.clientX-at.left,st.clientY-at.top];if(ndcFromPointerXy(_e,ct)!==null&&(ot.dragEnd=ct,!(Math.abs(ot.dragEnd[0]-ot.dragStart[0])<=3&&Math.abs(ot.dragEnd[1]-ot.dragStart[1])<=3)&&ot.enabled==="rect-select")){const ft=_e.canvas2dRef.current.getContext("2d");ft.clearRect(0,0,ft.canvas.width,ft.canvas.height),ft.beginPath(),ft.fillStyle=it.primaryColor,ft.strokeStyle="blue",ft.globalAlpha=.2,ft.fillRect(ot.dragStart[0],ot.dragStart[1],ot.dragEnd[0]-ot.dragStart[0],ot.dragEnd[1]-ot.dragStart[1]),ft.globalAlpha=1,ft.stroke()}},onPointerUp:()=>{const st=_e.scenePointerInfo.current;if(_e.cameraControlRef.current.enabled=!0,st.enabled===!1||!st.isDragging)return;const ot=_e.canvas2dRef.current.getContext("2d");if(ot.clearRect(0,0,ot.canvas.width,ot.canvas.height),st.enabled==="click"){const at=new Raycaster,ct=ndcFromPointerXy(_e,st.dragEnd);if(ct===null)return;at.setFromCamera(ct,_e.cameraRef.current);const ft=rayToViserCoords(_e,at.ray),pt=opencvXyFromPointerXy(_e,st.dragEnd);rt({type:"ScenePointerMessage",event_type:"click",ray_origin:[ft.origin.x,ft.origin.y,ft.origin.z],ray_direction:[ft.direction.x,ft.direction.y,ft.direction.z],screen_pos:[[pt.x,pt.y]]})}else if(st.enabled==="rect-select"){const at=opencvXyFromPointerXy(_e,st.dragStart),ct=opencvXyFromPointerXy(_e,st.dragEnd),ft=Math.min(at.x,ct.x),pt=Math.max(at.x,ct.x),mt=Math.min(at.y,ct.y),xt=Math.max(at.y,ct.y);rt({type:"ScenePointerMessage",event_type:"rect-select",ray_origin:null,ray_direction:null,screen_pos:[[ft,mt],[pt,xt]]})}st.isDragging=!1},children:[nt,jsxRuntimeExports.jsx(BackgroundImage,{}),jsxRuntimeExports.jsx(AdaptiveDpr,{}),jsxRuntimeExports.jsx(SceneContextSetter,{}),jsxRuntimeExports.jsx(SynchronizedCameraControls,{}),jsxRuntimeExports.jsx(SplatRenderContext,{children:jsxRuntimeExports.jsx(SceneNodeThreeObject,{name:"",parent:null})}),jsxRuntimeExports.jsx(DefaultLights,{})]})}function DefaultLights(){const nt=React.useContext(ViewerContext),_e=nt.useSceneTree(st=>st.enableDefaultLights),rt=nt.useSceneTree(st=>st.environmentMap);let it;if(rt.hdri===null)it=null;else{const st={apartment:"lebombo_1k.hdr",city:"potsdamer_platz_1k.hdr",dawn:"kiara_1_dawn_1k.hdr",forest:"forest_slope_1k.hdr",lobby:"st_fagans_interior_1k.hdr",night:"dikhololo_night_1k.hdr",park:"rooitou_park_1k.hdr",studio:"studio_small_03_1k.hdr",sunset:"venice_sunset_1k.hdr",warehouse:"empty_warehouse_01_1k.hdr"};console.log(rt.environment_intensity),it=jsxRuntimeExports.jsx(Environment,{files:`hdri/${st[rt.hdri]}`,background:rt.background,backgroundBlurriness:rt.background_blurriness,backgroundIntensity:rt.background_intensity,backgroundRotation:rt.background_rotation,environmentIntensity:rt.environment_intensity,environmentRotation:rt.environment_rotation})}return _e?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[it,jsxRuntimeExports.jsx("directionalLight",{color:255,intensity:1,position:[0,1,0]}),jsxRuntimeExports.jsx("directionalLight",{color:65280,intensity:.2,position:[0,-1,0]})]}):it}function AdaptiveDpr(){const nt=useThree(_e=>_e.setDpr);return jsxRuntimeExports.jsx(PerformanceMonitor,{factor:1,ms:100,iterations:5,step:.1,bounds:_e=>{const rt=Math.min(_e*.75,85);return[Math.max(rt*.5,38),rt]},onChange:({factor:_e,fps:rt,refreshrate:it})=>{const st=window.devicePixelRatio*(.2+.8*_e);console.log(`[Performance] Setting DPR to ${st}; FPS=${rt}/${it}`),nt(st)}})}function Viewer2DCanvas(){const nt=React.useContext(ViewerContext);return reactExports.useEffect(()=>{const _e=new ResizeObserver(it=>{const{width:st,height:ot}=it[0].contentRect;rt.width=st,rt.height=ot}),rt=nt.canvas2dRef.current;return _e.observe(rt),()=>_e.disconnect()}),jsxRuntimeExports.jsx("canvas",{ref:nt.canvas2dRef,style:{position:"absolute",zIndex:1,width:"100%",height:"100%",pointerEvents:"none"}})}function BackgroundImage(){const nt=` varying vec2 vUv; void main() { diff --git a/viser-embed/index.html b/viser-embed/index.html index d5c83b2..49dc34d 100644 --- a/viser-embed/index.html +++ b/viser-embed/index.html @@ -26,7 +26,7 @@ --> Viser - +