@labelbee/lb-components 1.23.0-alpha.3 → 1.23.0-alpha.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/dist/App.js +1 -1
  2. package/dist/assets/annotation/pointCloudTool/leftArrow.svg.js +1 -1
  3. package/dist/assets/annotation/pointCloudTool/rightArrow.svg.js +1 -1
  4. package/dist/components/LLMToolView/index.js +1 -1
  5. package/dist/components/LLMToolView/sidebar/components/textEditor/index.js +2 -2
  6. package/dist/components/LLMToolView/sidebar/components/textEditor/index.module.scss.js +1 -1
  7. package/dist/components/LLMToolView/sidebar/components/textInputBox/index.js +2 -2
  8. package/dist/components/LLMToolView/sidebar/index.js +1 -1
  9. package/dist/components/LLMToolView/utils/data.js +1 -1
  10. package/dist/components/NLPToolView/index.js +1 -1
  11. package/dist/components/NLPToolView/textContent/index.js +1 -1
  12. package/dist/components/audioAnnotate/audioContext/index.js +1 -1
  13. package/dist/components/audioAnnotate/audioSide/clipSidebar/index.js +1 -1
  14. package/dist/components/audioAnnotate/index.js +1 -1
  15. package/dist/components/audioAnnotate/textInput/index.js +1 -1
  16. package/dist/components/audioAnnotate/textInput/index.module.scss.js +1 -1
  17. package/dist/components/audioAnnotate/utils/dataTransform.js +1 -0
  18. package/dist/components/audioPlayer/clipRegion/index.js +1 -1
  19. package/dist/components/audioPlayer/index.js +1 -1
  20. package/dist/components/audioPlayer/useAudioCombine/index.js +3 -2
  21. package/dist/components/audioPlayer/useAudioSegment/index.js +1 -1
  22. package/dist/components/longText/index.js +1 -1
  23. package/dist/components/pointCloud2DRectOperationView/index.js +1 -1
  24. package/dist/components/pointCloudView/PointCloud2DView.js +1 -1
  25. package/dist/components/pointCloudView/PointCloud3DView.js +1 -1
  26. package/dist/components/pointCloudView/PointCloudContext.js +1 -1
  27. package/dist/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
  28. package/dist/components/pointCloudView/hooks/useStatus.js +1 -1
  29. package/dist/components/pointCloudView/index.js +1 -1
  30. package/dist/components/subAttributeList/index.js +1 -0
  31. package/dist/components/videoAnnotate/videoClipTool/index.js +1 -1
  32. package/dist/components/videoAnnotate/videoTagTool/TagToolInstanceAdaptor.js +1 -1
  33. package/dist/index.css +35 -9
  34. package/dist/index.js +1 -1
  35. package/dist/store/Actions.js +1 -1
  36. package/dist/store/annotation/actionCreators.js +1 -1
  37. package/dist/store/annotation/reducer.js +1 -1
  38. package/dist/types/App.d.ts +3 -1
  39. package/dist/types/components/LLMToolView/utils/data.d.ts +1 -1
  40. package/dist/types/components/audioAnnotate/audioContext/index.d.ts +10 -2
  41. package/dist/types/components/audioAnnotate/textInput/index.d.ts +1 -0
  42. package/dist/types/components/audioAnnotate/utils/dataTransform.d.ts +9 -0
  43. package/dist/types/components/audioPlayer/index.d.ts +28 -21
  44. package/dist/types/components/longText/index.d.ts +1 -0
  45. package/dist/types/components/pointCloudView/PointCloud2DView.d.ts +1 -1
  46. package/dist/types/components/pointCloudView/PointCloudContext.d.ts +6 -1
  47. package/dist/types/components/pointCloudView/hooks/usePointCloudViews.d.ts +5 -0
  48. package/dist/types/components/subAttributeList/index.d.ts +9 -0
  49. package/dist/types/components/videoAnnotate/index.d.ts +2 -1
  50. package/dist/types/components/videoAnnotate/videoClipTool/index.d.ts +2 -1
  51. package/dist/types/components/videoAnnotate/videoTagTool/TagToolInstanceAdaptor.d.ts +1 -1
  52. package/dist/types/index.d.ts +3 -1
  53. package/dist/types/store/Actions.d.ts +1 -0
  54. package/dist/types/store/annotation/actionCreators.d.ts +3 -2
  55. package/dist/types/store/annotation/reducer.d.ts +1 -0
  56. package/dist/types/store/annotation/types.d.ts +9 -2
  57. package/dist/types/utils/AnnotationDataUtils.d.ts +54 -1
  58. package/dist/types/utils/index.d.ts +25 -1
  59. package/dist/types/views/MainView/sidebar/TextToolSidebar/index.d.ts +1 -1
  60. package/dist/types/views/MainView/toolFooter/index.d.ts +1 -1
  61. package/dist/types/views/MainView/toolHeader/StepSwitch/index.d.ts +1 -1
  62. package/dist/types/views/MainView/toolHeader/index.d.ts +1 -1
  63. package/dist/utils/AnnotationDataUtils.js +1 -1
  64. package/dist/utils/index.js +1 -1
  65. package/dist/views/MainView/index.js +1 -1
  66. package/dist/views/MainView/sidebar/GeneralOperation/ActionsConfirm.js +1 -1
  67. package/dist/views/MainView/sidebar/NLPSidebar/NLPAnnotatedList.js +1 -1
  68. package/dist/views/MainView/sidebar/PointCloudToolSidebar/index.js +1 -1
  69. package/dist/views/MainView/sidebar/TagSidebar/index.js +1 -1
  70. package/dist/views/MainView/sidebar/TextToolSidebar/index.js +1 -1
  71. package/es/App.js +1 -1
  72. package/es/assets/annotation/pointCloudTool/leftArrow.svg.js +1 -1
  73. package/es/assets/annotation/pointCloudTool/rightArrow.svg.js +1 -1
  74. package/es/components/LLMToolView/index.js +1 -1
  75. package/es/components/LLMToolView/sidebar/components/textEditor/index.js +2 -2
  76. package/es/components/LLMToolView/sidebar/components/textEditor/index.module.scss.js +1 -1
  77. package/es/components/LLMToolView/sidebar/components/textInputBox/index.js +2 -2
  78. package/es/components/LLMToolView/sidebar/index.js +1 -1
  79. package/es/components/LLMToolView/utils/data.js +1 -1
  80. package/es/components/NLPToolView/index.js +1 -1
  81. package/es/components/NLPToolView/textContent/index.js +1 -1
  82. package/es/components/audioAnnotate/audioContext/index.js +1 -1
  83. package/es/components/audioAnnotate/audioSide/clipSidebar/index.js +1 -1
  84. package/es/components/audioAnnotate/index.js +1 -1
  85. package/es/components/audioAnnotate/textInput/index.js +1 -1
  86. package/es/components/audioAnnotate/textInput/index.module.scss.js +1 -1
  87. package/es/components/audioAnnotate/utils/dataTransform.js +1 -0
  88. package/es/components/audioPlayer/clipRegion/index.js +1 -1
  89. package/es/components/audioPlayer/index.js +1 -1
  90. package/es/components/audioPlayer/useAudioCombine/index.js +3 -2
  91. package/es/components/audioPlayer/useAudioSegment/index.js +1 -1
  92. package/es/components/longText/index.js +1 -1
  93. package/es/components/pointCloud2DRectOperationView/index.js +1 -1
  94. package/es/components/pointCloudView/PointCloud2DView.js +1 -1
  95. package/es/components/pointCloudView/PointCloud3DView.js +1 -1
  96. package/es/components/pointCloudView/PointCloudContext.js +1 -1
  97. package/es/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
  98. package/es/components/pointCloudView/hooks/useStatus.js +1 -1
  99. package/es/components/pointCloudView/index.js +1 -1
  100. package/es/components/subAttributeList/index.js +1 -0
  101. package/es/components/videoAnnotate/videoClipTool/index.js +1 -1
  102. package/es/components/videoAnnotate/videoTagTool/TagToolInstanceAdaptor.js +1 -1
  103. package/es/index.css +35 -9
  104. package/es/index.js +1 -1
  105. package/es/store/Actions.js +1 -1
  106. package/es/store/annotation/actionCreators.js +1 -1
  107. package/es/store/annotation/reducer.js +1 -1
  108. package/es/utils/AnnotationDataUtils.js +1 -1
  109. package/es/utils/index.js +1 -1
  110. package/es/views/MainView/index.js +1 -1
  111. package/es/views/MainView/sidebar/GeneralOperation/ActionsConfirm.js +1 -1
  112. package/es/views/MainView/sidebar/NLPSidebar/NLPAnnotatedList.js +1 -1
  113. package/es/views/MainView/sidebar/PointCloudToolSidebar/index.js +1 -1
  114. package/es/views/MainView/sidebar/TagSidebar/index.js +1 -1
  115. package/es/views/MainView/sidebar/TextToolSidebar/index.js +1 -1
  116. package/package.json +3 -3
@@ -1 +1 @@
1
- import i,{useState as F,useEffect as B,useMemo as ne}from"react";import{AudioPlayer as _e}from"../audioPlayer/index.js";import{getClassName as Ce}from"../../utils/dom.js";import Re from"../predictTracking/previewResult/index.js";import{Layout as oe}from"antd/es";import{Spin as Te}from"antd";import{prefix as je}from"../../constant/index.js";import{cKeyCode as Pe,CommonToolUtils as K,uuid as he,TagUtils as we,EventBus as Le,cTool as Oe}from"@labelbee/lb-annotation";import N from"./index.module.scss.js";import Ae from"./tagResultShow/index.js";import{AudioClipProvider as Ie,useAudioClipStore as Ne}from"./audioContext/index.js";import ke from"./textInput/index.js";import{connect as De}from"react-redux";import{a2MapStateToProps as $e}from"../../store/annotation/map.js";import{LabelBeeContext as Me}from"../../store/ctx.js";import{jsonParser as Ve}from"../../utils/index.js";import{useCustomToolInstance as Be}from"../../hooks/annotation.js";import{sidebarCls as Q}from"../../views/MainView/sidebar/index.js";import Ke from"./audioSide/labelSidebar/index.js";import We from"./audioSide/clipSidebar/index.js";import Ue from"../../assets/annotation/audio/tag.svg.js";import Fe from"../../assets/annotation/audio/tagA.svg.js";import Xe from"../../assets/annotation/audio/clip.svg.js";import qe from"../../assets/annotation/audio/clipA.svg.js";var ze=Object.defineProperty,Ge=Object.defineProperties,He=Object.getOwnPropertyDescriptors,ie=Object.getOwnPropertySymbols,Je=Object.prototype.hasOwnProperty,Qe=Object.prototype.propertyIsEnumerable,le=(t,n,s)=>n in t?ze(t,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[n]=s,E=(t,n)=>{for(var s in n||(n={}))Je.call(n,s)&&le(t,s,n[s]);if(ie)for(var s of ie(n))Qe.call(n,s)&&le(t,s,n[s]);return t},k=(t,n)=>Ge(t,He(n));const{EAudioToolName:Ye}=Oe,re=Pe.default,{Sider:Ze,Content:et}=oe,se=`${je}-layout`,tt=({setSideTab:t,sideTab:n})=>{const s=[{tab:"tag",commonSvg:Ue,selectedSvg:Fe},{tab:"clip",commonSvg:Xe,selectedSvg:qe}];return i.createElement("div",{className:N.toggleAudioOption},s.map((p,S)=>{const{tab:f,selectedSvg:x,commonSvg:R}=p;return i.createElement("div",{key:S,className:N.option},i.createElement("img",{className:N.icon,src:n===f?x:R,onClick:()=>{n!==f&&t(f)}}))}))},nt=({result:t,inputDisabled:n,updateText:s,configList:p,autofocus:S,preContext:f,isCheck:x,clipAttributeConfigurable:R,clipTextConfigurable:D,textConfigurable:g,updateRegion:_,clipAttributeList:m})=>i.createElement("div",{className:N.textareaContainer},i.createElement("div",{className:N.textareaContent},i.createElement(ke,{isCheck:x,result:t==null?void 0:t.value,textInputDisabled:n,textID:(t==null?void 0:t.id)||0,updateText:s,configList:p,autofocus:!n&&S,preContext:f,regions:t==null?void 0:t.regions,clipAttributeConfigurable:R,clipTextConfigurable:D,textConfigurable:g,updateRegion:_,clipAttributeList:m}))),ot=t=>{var n,s;const{sider:p,config:S,result:f,updateTagResult:x,updateRegion:R,isEdit:D,tagConfigurable:g,clipConfigurable:_}=t;let m=(S==null?void 0:S.inputList)||[],C=(n=f==null?void 0:f.tag)!=null?n:{},a=(s=f==null?void 0:f.regions)!=null?s:[];const[X,L]=F([]),[T,v]=F("tag");B(()=>{if(!g&&_){v("clip");return}v("tag")},[g,_]),B(()=>(window.addEventListener("keydown",$),()=>{window.removeEventListener("keydown",$)}));const $=l=>{if(g&&_)switch(l.keyCode){case re.L:v("tag");break;case re.X:v("clip");break}if(T==="tag"){if(!K.hotkeyFilter(l))return;K.isMoveKey(l==null?void 0:l.keyCode)&&l.preventDefault();let r=l.keyCode;if(r&&(r<=57&&r>=49||r<=105&&r>=97)){r>57?r=r-97:r=r-49;const d=X.slice();m.length===1?(j(0,r),L([0,r]),setTimeout(()=>{L([])},500)):d.length===1?(j(d[0],r),L([d[0],r]),setTimeout(()=>{L([])},500)):L([r])}}},j=(l,r)=>{if(l<m.length&&m[l].subSelected&&r<m[l].subSelected.length){const d=m[l].value,b=m[l].isMulti;let P=m[l].subSelected[r].value,q=0;const W=C;for(const h in C)if(h===m[l].value){if(q++,b===!0){const I=W[h].split(";").filter(z=>z!==""),V=I.indexOf(P);V===-1?I.push(P):I.splice(V,1),P=I.join(";")}P===""?delete W[h]:W[h]=P}q===0&&Object.assign(C,{[d]:P}),x(C)}},O=l=>{delete C[l],x(C)},A=g&&_&&i.createElement(tt,{setSideTab:v,sideTab:T}),M=T==="tag"&&i.createElement(Ke,{labelInfoSet:g?m:[],labelSelectedList:X,setLabel:j,tagResult:C,clearResult:O,isEdit:D,withPanelTab:!1}),u=T==="clip"&&i.createElement(We,{regions:a,updateRegion:R,useAudioClipStore:Ne});return p?typeof p=="function"?i.createElement("div",{className:`${Q}`},p({toggleAudioOption:A,labelSidebar:M,clipSidebar:u})):p:i.createElement("div",{className:`${Q}`},i.createElement("div",{className:`${Q}__content`},A,M,u))},it=t=>{var n,s,p,S,f,x,R,D,g;const _=(s=(n=t.style)==null?void 0:n.sider)==null?void 0:s.width,{step:m,stepList:C,audioContext:a,sider:X,drawLayerSlot:L,imgList:T,imgIndex:v,currentData:$,config:j,stepInfo:O}=t,A=K.getCurrentStepToolAndConfig(m,C),M=Ve($.result),{toolInstanceRef:u}=Be({basicInfo:M}),[l,r]=F(!0),[d,b]=F(null),[P,q]=F(0);B(()=>{r(!0)},[v]),B(()=>{l===!1&&pe()},[l]),B(()=>{W()},[]),B(()=>{u.current.exportData=()=>[[d],{duration:P,valid:H}],u.current.setResult=Se,u.current.clearResult=xe,u.current.currentPageResult=d==null?void 0:d.regions,u.current.emit("updatePageNumber")},[d]);const W=()=>{u.current.emit=e=>{const o=u.current.fns.get(e);o&&o.forEach(c=>{c&&(c==null||c())})},u.current.fns=new Map,u.current.singleOn=(e,o)=>{u.current.fns.set(e,[o])},u.current.on=(e,o)=>{u.current.singleOn(e,o)},u.current.unbindAll=e=>{u.current.fns.delete(e)}},h=ne(()=>{const e=M[`step_${O==null?void 0:O.step}`];return(e==null?void 0:e.result)||[]},[j,M,O]),{tagConfigurable:I,textConfigurable:V=!0,clipConfigurable:z=!1,clipAttributeConfigurable:Y=!1,clipAttributeList:Z=[],clipTextConfigurable:G=!1,inputList:ae=[],configList:ue=[]}=ne(()=>{if(A)return K.jsonParser(A==null?void 0:A.config)},[A]),ce={clipConfigurable:z,clipAttributeConfigurable:Y,clipAttributeList:Z,clipTextConfigurable:G},H=a?a==null?void 0:a.valid:!0,de=(S=(p=K.jsonParser($.result))==null?void 0:p.duration)!=null?S:0,fe=H?de:0,me=!H||l||![V,G].includes(!0);let ee={};if(v!==-1&&(T==null?void 0:T.length)){const e=(f=T[v])==null?void 0:f.preResult,o=(a==null?void 0:a.isEdit)?(x=a==null?void 0:a.stepConfig)==null?void 0:x.loadPreStep:O==null?void 0:O.loadPreStep;if(e&&o){const c=K.jsonParser(e),y=(D=(R=c==null?void 0:c.config)==null?void 0:R.context)!=null?D:{};Object.keys(y).forEach(w=>{w&&y[w]&&(ee[w]={visible:!0,content:y[w],type:w})})}}const pe=()=>{(h==null?void 0:h.length)>0?b(h[0]):b({id:he(),sourceID:"",value:te(),tag:ge(),regions:[]})},te=(e=!0)=>{const o={};let c=j.configList||[];return c.length>0&&c.forEach(y=>{o[y.key]=e&&y.default||""}),o},ge=()=>we.getDefaultResultByConfig(j.inputList||[]),ve=({duration:e,hasError:o})=>{r(!1),q(e)},be=e=>{b(o=>k(E({},o),{regions:((o==null?void 0:o.regions)||[]).filter(c=>c.id!==e)}))},J=e=>{b(o=>{var c;const y=(c=o==null?void 0:o.regions)!=null?c:[],{id:w}=e;return y.find(U=>U.id===w)?k(E({},o),{regions:y.map(U=>w===U.id?E(E({},U),e):U)}):k(E({},o),{regions:[...y,e]})})},ye=(e,o)=>{b(c=>k(E({},c),{value:k(E({},c.value),{[o]:e})}))},Ee=e=>{b(o=>k(E({},o),{tag:e}))},Se=e=>{b(e)},xe=()=>{b(e=>k(E({},e),{value:te(),tag:{},regions:[]})),Le.emit("clearRegions")};return i.createElement(Ie,null,i.createElement(Te,{spinning:l,wrapperClassName:"audio-tool-spinner"},i.createElement(oe,{className:Ce("layout","container"),style:{height:"100%"}},t==null?void 0:t.leftSider,i.createElement(et,{className:`${se}__content`},i.createElement("div",{className:N.containerWrapper},i.createElement("div",{className:N.audioWrapper},I&&i.createElement(Ae,{result:d==null?void 0:d.tag,labelInfoSet:ae,hasPromptLayer:!!(a==null?void 0:a.promptLayer)}),a==null?void 0:a.promptLayer,i.createElement(_e,E({context:{isEdit:a==null?void 0:a.isEdit,count:fe,toolName:Ye.AudioTextTool,imgIndex:v},drawLayerSlot:L,fileData:$,onLoaded:ve,invalid:!H,updateRegion:J,removeRegion:be,regions:d==null?void 0:d.regions,activeToolPanel:a==null?void 0:a.activeToolPanel,footer:t.footer},ce))),(V||G)&&i.createElement(nt,{preContext:ee,result:d,inputDisabled:me,updateText:ye,updateRegion:J,configList:ue,autofocus:!1,textConfigurable:V,clipTextConfigurable:G,clipAttributeList:Z,clipAttributeConfigurable:Y}))),i.createElement(Ze,{className:`${se}__side`,width:_!=null?_:240,style:(g=t.style)==null?void 0:g.sider},i.createElement(ot,{sider:X,config:j,result:d,updateTagResult:Ee,updateRegion:J,isEdit:a==null?void 0:a.isEdit,tagConfigurable:I,clipConfigurable:z})),i.createElement(Re,null))))};var lt=De($e,null,null,{context:Me})(it);export{lt as default};
1
+ import l,{useState as U,useEffect as B,useMemo as le}from"react";import{AudioPlayer as Pe}from"../audioPlayer/index.js";import{getClassName as je}from"../../utils/dom.js";import we from"../predictTracking/previewResult/index.js";import{Layout as re}from"antd/es";import{Spin as Ae}from"antd";import{prefix as Ie}from"../../constant/index.js";import{cKeyCode as Oe,CommonToolUtils as K,EventBus as se,uuid as Ne,TagUtils as ke,cTool as De}from"@labelbee/lb-annotation";import A from"./index.module.scss.js";import $e from"./tagResultShow/index.js";import{AudioClipProvider as Me,DEFAULT_CLIP_TEXT_CONFIG_ITEM as Ve,useAudioClipStore as Be}from"./audioContext/index.js";import Ke from"./textInput/index.js";import{connect as We}from"react-redux";import{a2MapStateToProps as Fe}from"../../store/annotation/map.js";import{LabelBeeContext as Ue}from"../../store/ctx.js";import{jsonParser as Xe}from"../../utils/index.js";import{useCustomToolInstance as Ge}from"../../hooks/annotation.js";import{sidebarCls as Y}from"../../views/MainView/sidebar/index.js";import qe from"./audioSide/labelSidebar/index.js";import ze from"./audioSide/clipSidebar/index.js";import He from"../../assets/annotation/audio/tag.svg.js";import Je from"../../assets/annotation/audio/tagA.svg.js";import Qe from"../../assets/annotation/audio/clip.svg.js";import Ye from"../../assets/annotation/audio/clipA.svg.js";var Ze=Object.defineProperty,et=Object.defineProperties,tt=Object.getOwnPropertyDescriptors,ae=Object.getOwnPropertySymbols,nt=Object.prototype.hasOwnProperty,ot=Object.prototype.propertyIsEnumerable,ue=(n,o,a)=>o in n?Ze(n,o,{enumerable:!0,configurable:!0,writable:!0,value:a}):n[o]=a,E=(n,o)=>{for(var a in o||(o={}))nt.call(o,a)&&ue(n,a,o[a]);if(ae)for(var a of ae(o))ot.call(o,a)&&ue(n,a,o[a]);return n},I=(n,o)=>et(n,tt(o));const{EAudioToolName:it}=De,ce=Oe.default,{Sider:lt,Content:rt}=re,de=`${Ie}-layout`,st=({setSideTab:n,sideTab:o})=>{const a=[{tab:"tag",commonSvg:He,selectedSvg:Je},{tab:"clip",commonSvg:Qe,selectedSvg:Ye}];return l.createElement("div",{className:A.toggleAudioOption},a.map((p,S)=>{const{tab:d,selectedSvg:_,commonSvg:C}=p;return l.createElement("div",{key:S,className:A.option},l.createElement("img",{className:A.icon,src:o===d?_:C,onClick:()=>{o!==d&&n(d)}}))}))},at=({result:n,inputDisabled:o,updateText:a,configList:p,autofocus:S,preContext:d,isCheck:_,clipAttributeConfigurable:C,clipTextConfigurable:O,textConfigurable:v,updateRegion:x,clipAttributeList:f,clipTextList:g})=>l.createElement("div",{className:A.textareaContainer},l.createElement("div",{className:A.textareaContent},l.createElement(Ke,{isCheck:_,result:n==null?void 0:n.value,textInputDisabled:o,textID:(n==null?void 0:n.id)||0,updateText:a,configList:p,autofocus:!o&&S,preContext:d,regions:n==null?void 0:n.regions,clipAttributeConfigurable:C,clipTextConfigurable:O,textConfigurable:v,updateRegion:x,clipAttributeList:f,clipTextList:g}))),ut=n=>{var o,a;const{sider:p,config:S,result:d,updateTagResult:_,updateRegion:C,isEdit:O,tagConfigurable:v,clipConfigurable:x}=n;let f=(S==null?void 0:S.inputList)||[],g=(o=d==null?void 0:d.tag)!=null?o:{},r=(a=d==null?void 0:d.regions)!=null?a:[];const[X,P]=U([]),[T,b]=U("tag");B(()=>{if(!v&&x){b("clip");return}b("tag")},[v,x]),B(()=>(window.addEventListener("keydown",N),()=>{window.removeEventListener("keydown",N)}));const N=t=>{if(v&&x)switch(t.keyCode){case ce.L:b("tag");break;case ce.X:b("clip");break}if(T==="tag"){if(!K.hotkeyFilter(t))return;K.isMoveKey(t==null?void 0:t.keyCode)&&t.preventDefault();let s=t.keyCode;if(s&&(s<=57&&s>=49||s<=105&&s>=97)){s>57?s=s-97:s=s-49;const R=X.slice();f.length===1?(L(0,s),P([0,s]),setTimeout(()=>{P([])},500)):R.length===1?(L(R[0],s),P([R[0],s]),setTimeout(()=>{P([])},500)):P([s])}}},L=(t,s)=>{if(t<f.length&&f[t].subSelected&&s<f[t].subSelected.length){const R=f[t].value,m=f[t].isMulti;let c=f[t].subSelected[s].value,G=0;const W=g;for(const $ in g)if($===f[t].value){if(G++,m===!0){const M=W[$].split(";").filter(q=>q!==""),V=M.indexOf(c);V===-1?M.push(c):M.splice(V,1),c=M.join(";")}c===""?delete W[$]:W[$]=c}G===0&&Object.assign(g,{[R]:c}),_(g)}},j=t=>{delete g[t],_(g)},k=v&&x&&l.createElement(st,{setSideTab:b,sideTab:T}),w=T==="tag"&&l.createElement(qe,{labelInfoSet:v?f:[],labelSelectedList:X,setLabel:L,tagResult:g,clearResult:j,isEdit:O,withPanelTab:!1}),D=T==="clip"&&l.createElement(ze,{regions:r,updateRegion:C,useAudioClipStore:Be});return p?typeof p=="function"?l.createElement("div",{className:`${Y}`},p({toggleAudioOption:k,labelSidebar:w,clipSidebar:D})):p:l.createElement("div",{className:`${Y}`},l.createElement("div",{className:`${Y}__content`},k,w,D))},ct=n=>{var o,a,p,S,d,_,C,O,v;const x=(a=(o=n.style)==null?void 0:o.sider)==null?void 0:a.width,{step:f,stepList:g,audioContext:r,sider:X,drawLayerSlot:P,imgList:T,imgIndex:b,currentData:N,config:L,stepInfo:j,checkMode:k}=n,w=K.getCurrentStepToolAndConfig(f,g),D=Xe(N.result),{toolInstanceRef:t}=Ge({basicInfo:D}),[s,R]=U(!0),[m,c]=U(null),[G,W]=U(0);B(()=>{R(!0)},[b]),B(()=>{s===!1&&Se()},[s]),B(()=>{M()},[]),B(()=>{t.current.exportData=()=>[[m],{duration:G,valid:H}],t.current.setResult=Re,t.current.clearResult=he,t.current.currentPageResult=m==null?void 0:m.regions,t.current.emit("updatePageNumber"),t.current.setSelectedRegion=$},[m]);const $=e=>{se.emit("setSelectedRegion",{id:e,isLoopStatus:!0,playImmediately:!0})},M=()=>{t.current.emit=e=>{const i=t.current.fns.get(e);i&&i.forEach(u=>{u&&(u==null||u())})},t.current.fns=new Map,t.current.singleOn=(e,i)=>{t.current.fns.set(e,[i])},t.current.on=(e,i)=>{t.current.singleOn(e,i)},t.current.unbindAll=e=>{t.current.fns.delete(e)}},V=le(()=>{const e=D[`step_${j==null?void 0:j.step}`];return(e==null?void 0:e.result)||[]},[L,D,j]),{tagConfigurable:q,textConfigurable:J=!0,clipConfigurable:Z=!1,clipAttributeConfigurable:ee=!1,clipAttributeList:te=[],clipTextConfigurable:z=!1,subAttributeList:fe=[],secondaryAttributeConfigurable:me=!1,inputList:pe=[],configList:ge=[],clipTextList:ne=Ve}=le(()=>{if(w)return K.jsonParser(w==null?void 0:w.config)},[w]),ve={clipConfigurable:Z,clipAttributeConfigurable:ee,clipAttributeList:te,clipTextConfigurable:z,subAttributeList:fe,secondaryAttributeConfigurable:me,clipTextList:ne},H=r?r==null?void 0:r.valid:!0,be=(S=(p=K.jsonParser(N.result))==null?void 0:p.duration)!=null?S:0,ye=H?be:0,Ee=!H||s||![J,z].includes(!0)||k;let oe={};if(b!==-1&&(T==null?void 0:T.length)){const e=(d=T[b])==null?void 0:d.preResult,i=(r==null?void 0:r.isEdit)?(_=r==null?void 0:r.stepConfig)==null?void 0:_.loadPreStep:j==null?void 0:j.loadPreStep;if(e&&i){const u=K.jsonParser(e),y=(O=(C=u==null?void 0:u.config)==null?void 0:C.context)!=null?O:{};Object.keys(y).forEach(h=>{h&&y[h]&&(oe[h]={visible:!0,content:y[h],type:h})})}}const Se=()=>{(V==null?void 0:V.length)>0?c(V[0]):c({id:Ne(),sourceID:"",value:ie(),tag:_e(),regions:[]})},ie=(e=!0)=>{const i={};let u=L.configList||[];return u.length>0&&u.forEach(y=>{i[y.key]=e&&y.default||""}),i},_e=()=>ke.getDefaultResultByConfig(L.inputList||[]),xe=({duration:e,hasError:i})=>{(r==null?void 0:r.onLoaded)&&(r==null||r.onLoaded()),R(!1),W(e)},Ce=e=>{c(i=>I(E({},i),{regions:((i==null?void 0:i.regions)||[]).filter(u=>u.id!==e)}))},Q=e=>{c(i=>{var u;const y=(u=i==null?void 0:i.regions)!=null?u:[],{id:h}=e;return y.find(F=>F.id===h)?I(E({},i),{regions:y.map(F=>h===F.id?E(E({},F),e):F)}):I(E({},i),{regions:[...y,e]})})},Te=(e,i)=>{c(u=>I(E({},u),{value:I(E({},u.value),{[i]:e})}))},Le=e=>{c(i=>I(E({},i),{tag:e}))},Re=e=>{c(e)},he=()=>{c(e=>I(E({},e),{value:ie(),tag:{},regions:[]})),se.emit("clearRegions")};return l.createElement(Me,null,l.createElement(Ae,{spinning:s,wrapperClassName:"audio-tool-spinner"},l.createElement(re,{className:je("layout","container"),style:{height:"100%"}},n==null?void 0:n.leftSider,l.createElement(rt,{className:`${de}__content`},l.createElement("div",{className:A.containerWrapper},l.createElement("div",{className:A.audioWrapper},q&&l.createElement($e,{result:m==null?void 0:m.tag,labelInfoSet:pe,hasPromptLayer:!!(r==null?void 0:r.promptLayer)}),r==null?void 0:r.promptLayer,l.createElement(Pe,E({context:{isEdit:r==null?void 0:r.isEdit,count:ye,toolName:it.AudioTextTool,imgIndex:b},drawLayerSlot:P,fileData:N,onLoaded:xe,invalid:!H,updateRegion:Q,removeRegion:Ce,regions:m==null?void 0:m.regions,activeToolPanel:r==null?void 0:r.activeToolPanel,footer:n.footer,isCheck:k},ve))),(J||z)&&l.createElement(at,{preContext:oe,result:m,inputDisabled:Ee,updateText:Te,updateRegion:Q,configList:ge,autofocus:!1,textConfigurable:J,clipTextConfigurable:z,clipAttributeList:te,clipAttributeConfigurable:ee,clipTextList:ne,isCheck:k}))),l.createElement(lt,{className:`${de}__side`,width:x!=null?x:240,style:(v=n.style)==null?void 0:v.sider},l.createElement(ut,{sider:X,config:L,result:m,updateTagResult:Le,updateRegion:Q,isEdit:r==null?void 0:r.isEdit,tagConfigurable:q,clipConfigurable:Z})),l.createElement(we,null))))};var dt=We(Fe,null,null,{context:Ue})(ct);export{dt as default};
@@ -1 +1 @@
1
- import e,{useState as M,useRef as X,useEffect as q}from"react";import{Tooltip as J,Radio as K,Switch as se}from"antd";import{QuestionCircleOutlined as ce}from"@ant-design/icons";import{TextareaWithFooter as ie}from"../../../views/MainView/sidebar/TextToolSidebar/index.js";import{timeFormat as Y,getAttributeColor as de,getAttributeFontColor as me,updateColorOpacity as Ee,getAttributeShowText as pe,DEFAULT_TEXT_CONFIG_ITEM as fe}from"../../../utils/audio.js";import{cKeyCode as ve}from"@labelbee/lb-annotation";import z from"classnames";import Z,{useAudioClipStore as xe}from"../audioContext/index.js";import o from"./index.module.scss.js";import{useTranslation as ee}from"react-i18next";var Fe=Object.defineProperty,ge=Object.defineProperties,Ce=Object.getOwnPropertyDescriptors,te=Object.getOwnPropertySymbols,he=Object.prototype.hasOwnProperty,be=Object.prototype.propertyIsEnumerable,ae=(u,n,r)=>n in u?Fe(u,n,{enumerable:!0,configurable:!0,writable:!0,value:r}):u[n]=r,le=(u,n)=>{for(var r in n||(n={}))he.call(n,r)&&ae(u,r,n[r]);if(te)for(var r of te(n))be.call(n,r)&&ae(u,r,n[r]);return u},Te=(u,n)=>ge(u,Ce(n));const d=ve.default,ne=({onClick:u,title:n,disabled:r})=>e.createElement(J,{placement:"bottom",title:n},e.createElement("span",{className:z({[o.clearIcon]:!0,[o.disabled]:r}),onClick:u})),G=u=>{var n;const{t:r}=ee(),D=X(null),[f,y]=M(!1),[w,v]=M(!1),{disabled:s,config:c,result:P,updateText:x,index:F,switchToNextTextarea:O,hasMultiple:L,textID:b,addPlaceholder:g,onFocus:N,onBlur:T,onFocusStyle:k={},extra:$}=u,{maxLength:C}=c,B=P?P[c.key]:"",I=(n=B==null?void 0:B.length)!=null?n:0,S=a=>{x&&(x(a,c.key),c.required&&v(!a))},j=L&&O,m={id:`textInput-${F}`,ref:D,disabled:s,value:B,maxLength:C,autoSize:{minRows:2,maxRows:6},onChange:a=>{const i=a.target.value;S(i)},onFocus:a=>{y(!0),N==null||N(a),a.target.value&&v(!1)},onBlur:a=>{y(!1),T==null||T(a),c.required&&v(!a.target.value)},style:{resize:"none",wordBreak:"break-all"},onKeyDownCapture:a=>{const{keyCode:i}=a;if(a.ctrlKey){if(i===d.Enter&&a.preventDefault(),g&&[d.One,d.Two,d.Three].includes(i))switch(a.preventDefault(),i){case d.One:g("\u4986");break;case d.Two:g("\u652B");break;case d.Three:g("\u7383");break}}else i===d.Tab&&j?(a.preventDefault(),a.nativeEvent.stopImmediatePropagation(),O(F)):a.nativeEvent.stopPropagation()}},E=e.createElement("div",{className:o.textAreaFooter},e.createElement("div",{className:o.hotkeyTip},j&&e.createElement("span",null,"[",r("Switch"),"]Tab"),e.createElement("span",null,"[",r("TurnPage"),"]Ctrl+Enter")),e.createElement("div",{className:o.wordCount},e.createElement("span",{className:I>=C?o.warning:""},I),"/",e.createElement("span",null,C)));return q(()=>{s&&y(!1)},[s]),q(()=>{v(!1)},[b]),e.createElement("div",{className:o.textField},e.createElement("div",{className:o.label},e.createElement("span",{className:z({[o.required]:c.required})},c.label),e.createElement(ne,{onClick:()=>{s||S("")},title:"",disabled:s}),e.createElement("div",{className:o.extra},$)),e.createElement("div",{className:z({disabled:s,"textarea-outline":!0,"ant-input-focused":f,[o.textareaContainer]:!0,[o.focus]:f,[o.invalid]:w}),style:f?k:{}},e.createElement(ie,{footer:E,textareaProps:m})))},ye=u=>{const{configList:n,autofocus:r,textID:D,result:f,showText:y,updateText:w,toggleShowText:v,textInputDisabled:s,isCheck:c,isEdit:P,config:x,preContext:F,regions:O=[],textConfigurable:L=!0,clipTextConfigurable:b,clipAttributeConfigurable:g,updateRegion:N,clipAttributeList:T=[]}=u,{t:k}=ee(),[$,C]=M(0),[B,I]=M(""),S=X(null),{audioClipState:j}=xe(),m=n||[le({},fe)];let E=O;if(b&&!c){const t=j.selectedRegion.id;E=E.filter(l=>l.id===t)}const a=t=>{setTimeout(()=>{const l=document.getElementById(`textInput-${t}`);l&&(C(t),l.focus(),l.select(),l.scrollIntoView({behavior:"smooth",block:"center"}))})},i=t=>{const l=L?m.length:0,p=b?E.length:0,h=l+p,_=(t+1)%h;a(_)},Q=t=>{t.keyCode===d.Tab&&(t.preventDefault(),m.length>0&&a(0))},R=t=>{const l=document.getElementById(`textInput-${$}`);if(!(x==null?void 0:x.enablePlaceholderHotkey)||!l||!w)return;const{value:p,selectionStart:h,selectionEnd:_}=l,A=`${p.slice(0,h)}${t}${p.slice(_)}`;w(A,m[$].key),I(t),setTimeout(()=>{l.setSelectionRange(h+1,h+1),l.focus()},0),clearTimeout(S.current),S.current=setTimeout(()=>{I("")},400)};q(()=>(P||document.addEventListener("keydown",Q),()=>{document.removeEventListener("keydown",Q)}),[n]),q(()=>{r&&!s&&a(0)},[D]);let H=m;c&&(H=m.filter(t=>(f==null?void 0:f[t.key])!==void 0));let U={};return b&&E&&E.forEach(t=>{const{id:l,text:p}=t;U[l]=p}),e.createElement(e.Fragment,null,(x==null?void 0:x.enablePlaceholderHotkey)&&e.createElement("div",{className:o.placeholderHotkey},e.createElement("div",{className:o.title},"\u5360\u4F4D\u7B26\u5FEB\u6377\u8F93\u5165",e.createElement(J,{overlayStyle:{maxWidth:240},title:e.createElement("div",null,e.createElement("div",null,"\u4986\uFF08Ctrl+1\uFF09\uFF1A"),e.createElement("div",{style:{marginBottom:12}},"\u6587\u5B57\u5F02\u5E38\uFF0C\u4F46\u53EA\u6839\u636E\u8FD9\u4E2A\u5B57\u7684\u5F62\u72B6\u5C31\u53EF\u4EE5\u731C\u51FA\u662F\u4EC0\u4E48\u5B57"),e.createElement("div",null,"\u652B\uFF08Ctrl+2\uFF09\uFF1A"),e.createElement("div",{style:{marginBottom:12}},"\u6587\u5B57\u5F02\u5E38\uFF0C\u4E14\u65E0\u6CD5\u6839\u636E\u5F62\u72B6\u731C\u5B57\uFF0C\u4F46\u80FD\u7ED3\u5408\u4E0A\u4E0B\u6587\u8BED\u4E49\u5224\u65AD\u51FA\u662F\u4EC0\u4E48\u5B57"),e.createElement("div",null,"\u7383\uFF08Ctrl+3\uFF09\uFF1A"),e.createElement("div",null,"\u5B8C\u5168\u65E0\u6CD5\u5224\u65AD\u662F\u4EC0\u4E48\u5B57")),placement:"bottom"},e.createElement(ce,{className:o.questionIcon}))),e.createElement(K.Group,{value:B},e.createElement(K.Button,{value:"\u4986",onClick:t=>R(t.target.value)},e.createElement("div",{className:"label"},e.createElement("div",{className:"text"},"\u4986 (\u89C6\u89C9)"),e.createElement("div",{className:"hotkey"},"Ctrl+1"))),e.createElement(K.Button,{value:"\u652B",onClick:t=>R(t.target.value)},e.createElement("div",{className:"label"},e.createElement("div",{className:"text"},"\u652B (\u8BED\u4E49)"),e.createElement("div",{className:"hotkey"},"Ctrl+2"))),e.createElement(K.Button,{value:"\u7383",onClick:t=>R(t.target.value)},e.createElement("div",{className:"label"},e.createElement("div",{className:"text"},"\u7383 (\u65E0\u6548)"),e.createElement("div",{className:"hotkey"},"Ctrl+3"))))),e.createElement("div",{className:o.textInputContainer},e.createElement(Z,{audioContext:F==null?void 0:F.before}),L&&H.map((t,l)=>e.createElement(G,{config:t,key:l,index:l,result:f,updateText:w,switchToNextTextarea:i,hasMultiple:m.length>1,disabled:s,textID:D,addPlaceholder:R,onFocus:()=>C(l)})),b&&E.map((t,l)=>{const{id:p,start:h,end:_,attribute:A}=t,oe={label:`${k("textTool")}\uFF08${Y(h,"ss.SSS")} - ${Y(_,"ss.SSS")}\uFF09`,key:p,maxLength:3e3},V=H.length+l,W=de(A,T),re={color:me(A,T),backgroundColor:W};return e.createElement(G,{config:oe,key:l,index:V,disabled:s,result:U,updateText:ue=>{N==null||N(Te(le({},t),{text:ue}))},switchToNextTextarea:()=>{i(V)},hasMultiple:!0,onFocus:()=>C(V),onFocusStyle:g?{borderColor:W,boxShadow:`0 0 0 2px ${Ee(W,.4)}`}:{},extra:g?e.createElement("div",{style:re,className:o.attribute},pe(A,[{value:"",key:k("NoAttribute")},...T])):null})}),e.createElement(Z,{audioContext:F==null?void 0:F.after}),v&&e.createElement("div",{className:o.switchItem},k("toggleShowText"),e.createElement(se,{style:{alignSelf:"center"},checked:y,onChange:t=>{v(t)}}))))};export{ne as ClearIcon,G as SingleTextInput,ye as default};
1
+ import e,{useState as M,useRef as te,useEffect as q,useMemo as Ce}from"react";import{Tooltip as ae,Radio as K,Switch as be}from"antd";import{QuestionCircleOutlined as ye}from"@ant-design/icons";import{TextareaWithFooter as Ne}from"../../../views/MainView/sidebar/TextToolSidebar/index.js";import{timeFormat as le,getAttributeColor as we,getAttributeFontColor as Be,getAttributeShowText as ke,updateColorOpacity as Ie,DEFAULT_TEXT_CONFIG_ITEM as _e}from"../../../utils/audio.js";import{cKeyCode as Se}from"@labelbee/lb-annotation";import U from"classnames";import ne,{useAudioClipStore as Ae,DEFAULT_CLIP_TEXT_CONFIG_ITEM as De}from"../audioContext/index.js";import r from"./index.module.scss.js";import{useTranslation as re}from"react-i18next";import oe from"../../longText/index.js";var Le=Object.defineProperty,Pe=Object.defineProperties,Oe=Object.getOwnPropertyDescriptors,ue=Object.getOwnPropertySymbols,Re=Object.prototype.hasOwnProperty,$e=Object.prototype.propertyIsEnumerable,se=(u,n,o)=>n in u?Le(u,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):u[n]=o,X=(u,n)=>{for(var o in n||(n={}))Re.call(n,o)&&se(u,o,n[o]);if(ue)for(var o of ue(n))$e.call(n,o)&&se(u,o,n[o]);return u},ce=(u,n)=>Pe(u,Oe(n));const E=Se.default,ie=({onClick:u,title:n,disabled:o})=>e.createElement(ae,{placement:"bottom",title:n},e.createElement("span",{className:U({[r.clearIcon]:!0,[r.disabled]:o}),onClick:u})),Q=u=>{var n;const{t:o}=re(),P=te(null),[x,w]=M(!1),[B,v]=M(!1),{disabled:c,config:i,result:O,updateText:g,index:T,switchToNextTextarea:R,hasMultiple:k,textID:C,addPlaceholder:F,onFocus:I,onBlur:b,onFocusStyle:y={},extra:N,errorText:_}=u,{maxLength:h}=i,S=O?O[i.key]:"",A=(n=S==null?void 0:S.length)!=null?n:0,D=l=>{g&&(g(l,i.key),i.required&&v(!l))},$=k&&R,p={id:`textInput-${T}`,ref:P,disabled:c,value:S,maxLength:h,autoSize:{minRows:2,maxRows:6},onChange:l=>{const m=l.target.value;D(m)},onFocus:l=>{w(!0),I==null||I(l),l.target.value&&v(!1)},onBlur:l=>{w(!1),b==null||b(l),i.required&&v(!l.target.value)},style:{resize:"none",wordBreak:"break-all"},onKeyDownCapture:l=>{const{keyCode:m}=l;if(l.ctrlKey){if(m===E.Enter&&l.preventDefault(),F&&[E.One,E.Two,E.Three].includes(m))switch(l.preventDefault(),m){case E.One:F("\u4986");break;case E.Two:F("\u652B");break;case E.Three:F("\u7383");break}}else m===E.Tab&&$?(l.preventDefault(),l.nativeEvent.stopImmediatePropagation(),R(T)):l.nativeEvent.stopPropagation()}},f=e.createElement("div",{className:r.textAreaFooter},e.createElement("div",{className:r.hotkeyTip},$&&e.createElement("span",null,"[",o("Switch"),"]Tab"),e.createElement("span",null,"[",o("TurnPage"),"]Ctrl+Enter")),e.createElement("div",{className:r.wordCount},e.createElement("span",{className:A>=h?r.warning:""},A),"/",e.createElement("span",null,h)));return q(()=>{c&&w(!1)},[c]),q(()=>{v(!1)},[C]),e.createElement("div",{className:r.textField},e.createElement("div",{className:r.label},e.createElement("div",{className:r.labelText},e.createElement("span",{className:U({[r.titleText]:!0,[r.required]:i.required})},e.createElement(oe,{text:i.label,openByText:!0,isToolTips:!0})),e.createElement(ie,{onClick:()=>{c||D("")},title:"",disabled:c})),e.createElement("div",{className:r.extra},N)),e.createElement("div",{className:U({disabled:c,"textarea-outline":!0,"ant-input-focused":x,[r.textareaContainer]:!0,[r.focus]:x,[r.invalid]:B}),style:x?y:{}},e.createElement(Ne,{footer:f,textareaProps:p})),_&&e.createElement("span",{style:{color:"#ff4d4f",lineHeight:"22px"}},_))},je=u=>{const{configList:n,autofocus:o,textID:P,result:x,showText:w,updateText:B,toggleShowText:v,textInputDisabled:c,isCheck:i,isEdit:O,config:g,preContext:T,regions:R=[],textConfigurable:k=!0,clipTextConfigurable:C,clipAttributeConfigurable:F,updateRegion:I,clipAttributeList:b=[],clipTextList:y=De}=u,{t:N}=re(),[_,h]=M(0),[S,A]=M(""),D=te(null),{audioClipState:$}=Ae(),p=n||[X({},_e)];let f=R;if(C&&!i){const t=$.selectedRegion.id;f=f.filter(a=>a.id===t)}const l=t=>{setTimeout(()=>{const a=document.getElementById(`textInput-${t}`);a&&(h(t),a.focus(),a.select(),a.scrollIntoView({behavior:"smooth",block:"center"}))})},m=t=>{const a=k?p.length:0,d=C?f.length*y.length:0,s=a+d,L=(t+1)%s;l(L)},J=t=>{t.keyCode===E.Tab&&(t.preventDefault(),(p.length>0||C&&y.length>0)&&l(0))},j=t=>{const a=document.getElementById(`textInput-${_}`);if(!(g==null?void 0:g.enablePlaceholderHotkey)||!a||!B)return;const{value:d,selectionStart:s,selectionEnd:L}=a,G=`${d.slice(0,s)}${t}${d.slice(L)}`;B(G,p[_].key),A(t),setTimeout(()=>{a.setSelectionRange(s+1,s+1),a.focus()},0),clearTimeout(D.current),D.current=setTimeout(()=>{A("")},400)};q(()=>(O||document.addEventListener("keydown",J),()=>{document.removeEventListener("keydown",J)}),[n]),q(()=>{o&&!c&&l(0)},[P]);let H=p;i&&(H=p.filter(t=>(x==null?void 0:x[t.key])!==void 0));const de=Ce(()=>y.reduce((t,a)=>(f.forEach(d=>{d&&t.push(ce(X({},a),{clipTextResult:d}))}),t),[]),[y,f]);return e.createElement(e.Fragment,null,(g==null?void 0:g.enablePlaceholderHotkey)&&e.createElement("div",{className:r.placeholderHotkey},e.createElement("div",{className:r.title},"\u5360\u4F4D\u7B26\u5FEB\u6377\u8F93\u5165",e.createElement(ae,{overlayStyle:{maxWidth:240},title:e.createElement("div",null,e.createElement("div",null,"\u4986\uFF08Ctrl+1\uFF09\uFF1A"),e.createElement("div",{style:{marginBottom:12}},"\u6587\u5B57\u5F02\u5E38\uFF0C\u4F46\u53EA\u6839\u636E\u8FD9\u4E2A\u5B57\u7684\u5F62\u72B6\u5C31\u53EF\u4EE5\u731C\u51FA\u662F\u4EC0\u4E48\u5B57"),e.createElement("div",null,"\u652B\uFF08Ctrl+2\uFF09\uFF1A"),e.createElement("div",{style:{marginBottom:12}},"\u6587\u5B57\u5F02\u5E38\uFF0C\u4E14\u65E0\u6CD5\u6839\u636E\u5F62\u72B6\u731C\u5B57\uFF0C\u4F46\u80FD\u7ED3\u5408\u4E0A\u4E0B\u6587\u8BED\u4E49\u5224\u65AD\u51FA\u662F\u4EC0\u4E48\u5B57"),e.createElement("div",null,"\u7383\uFF08Ctrl+3\uFF09\uFF1A"),e.createElement("div",null,"\u5B8C\u5168\u65E0\u6CD5\u5224\u65AD\u662F\u4EC0\u4E48\u5B57")),placement:"bottom"},e.createElement(ye,{className:r.questionIcon}))),e.createElement(K.Group,{value:S},e.createElement(K.Button,{value:"\u4986",onClick:t=>j(t.target.value)},e.createElement("div",{className:"label"},e.createElement("div",{className:"text"},"\u4986 (\u89C6\u89C9)"),e.createElement("div",{className:"hotkey"},"Ctrl+1"))),e.createElement(K.Button,{value:"\u652B",onClick:t=>j(t.target.value)},e.createElement("div",{className:"label"},e.createElement("div",{className:"text"},"\u652B (\u8BED\u4E49)"),e.createElement("div",{className:"hotkey"},"Ctrl+2"))),e.createElement(K.Button,{value:"\u7383",onClick:t=>j(t.target.value)},e.createElement("div",{className:"label"},e.createElement("div",{className:"text"},"\u7383 (\u65E0\u6548)"),e.createElement("div",{className:"hotkey"},"Ctrl+3"))))),e.createElement("div",{className:r.textInputContainer},e.createElement(ne,{audioContext:T==null?void 0:T.before}),k&&H.map((t,a)=>e.createElement(Q,{config:t,key:a,index:a,result:x,updateText:B,switchToNextTextarea:m,hasMultiple:p.length>1,disabled:c,textID:P,addPlaceholder:j,onFocus:()=>h(a)})),C&&f.length>0&&de.map((t,a)=>{var d;const{clipTextResult:s}=t,{id:L,start:G,end:me,attribute:V}=s,{maxLength:Ee=3e3,label:Y,key:Z,required:pe}=t,ee=s==null?void 0:s[Z],fe={[s.id]:ee},xe={label:`${Y!=null?Y:N("textTool")}\uFF08${le(G,"ss.SSS")} - ${le(me,"ss.SSS")}\uFF09`,key:L,maxLength:Ee},W=(k?H.length:0)+a,z=we(V,b),ve={color:Be(V,b),backgroundColor:z},ge=N("LeastCharacterError",{num:1}),Te=pe&&ee.length<1?ge:void 0,Fe=(d=ke(V,[{value:"",key:N("NoAttribute")},...b]))!=null?d:"";return e.createElement(Q,{config:xe,key:a,index:W,disabled:c,result:fe,updateText:he=>{I==null||I(ce(X({},s),{[Z]:he}))},switchToNextTextarea:()=>{m(W)},hasMultiple:!0,onFocus:()=>h(W),onFocusStyle:F?{borderColor:z,boxShadow:`0 0 0 2px ${Ie(z,.4)}`}:{},extra:F?e.createElement("div",{style:ve,className:r.attribute},e.createElement(oe,{text:Fe,openByText:!0,isToolTips:!0})):null,errorText:Te})}),e.createElement(ne,{audioContext:T==null?void 0:T.after}),v&&e.createElement("div",{className:r.switchItem},N("toggleShowText"),e.createElement(be,{style:{alignSelf:"center"},checked:w,onChange:t=>{v(t)}}))))};export{ie as ClearIcon,Q as SingleTextInput,je as default};
@@ -1 +1 @@
1
- var e={textInputContainer:"index-module_textInputContainer__ES6X3",textField:"index-module_textField__uRcb7",label:"index-module_label__xE6hM",required:"index-module_required__iElYl",extra:"index-module_extra__PW5Qk",textareaContainer:"index-module_textareaContainer__dTIv4",textAreaFooter:"index-module_textAreaFooter__h1Vv-",warning:"index-module_warning__NKpW6",hotkeyTip:"index-module_hotkeyTip__BSJ6A",wordCount:"index-module_wordCount__OD4eL",focus:"index-module_focus__H07-Y",invalid:"index-module_invalid__F9RC5",inputCount:"index-module_inputCount__--XiT",notify:"index-module_notify__rYuqq",switchItem:"index-module_switchItem__Q256x",placeholderHotkey:"index-module_placeholderHotkey__0SKPo",title:"index-module_title__YRpw9",questionIcon:"index-module_questionIcon__oK1HK",attribute:"index-module_attribute__g8Vbl",clearIcon:"index-module_clearIcon__ZBZqI",disabled:"index-module_disabled__zqh8C"};export{e as default};
1
+ var e={textInputContainer:"index-module_textInputContainer__ES6X3",textField:"index-module_textField__uRcb7",label:"index-module_label__xE6hM",labelText:"index-module_labelText__Zg1c4",titleText:"index-module_titleText__BRM44",required:"index-module_required__iElYl",extra:"index-module_extra__PW5Qk",textareaContainer:"index-module_textareaContainer__dTIv4",textAreaFooter:"index-module_textAreaFooter__h1Vv-",warning:"index-module_warning__NKpW6",hotkeyTip:"index-module_hotkeyTip__BSJ6A",wordCount:"index-module_wordCount__OD4eL",focus:"index-module_focus__H07-Y",invalid:"index-module_invalid__F9RC5",inputCount:"index-module_inputCount__--XiT",notify:"index-module_notify__rYuqq",switchItem:"index-module_switchItem__Q256x",placeholderHotkey:"index-module_placeholderHotkey__0SKPo",title:"index-module_title__YRpw9",questionIcon:"index-module_questionIcon__oK1HK",attribute:"index-module_attribute__g8Vbl",clearIcon:"index-module_clearIcon__ZBZqI",disabled:"index-module_disabled__zqh8C"};export{e as default};
@@ -0,0 +1 @@
1
+ import r from"lodash";class o{}o.getClipTextByConfig=(a,f,l=!1)=>{const t=r.cloneDeep(a);return f.forEach((e,c)=>{var s;const n=(s=e==null?void 0:e.default)!=null?s:"";c===0?Object.assign(t,{text:l?n:a[e.key]}):Object.assign(t,{[e.key]:l?n:a[e.key]})}),t};export{o as default};
@@ -1 +1 @@
1
- import t,{useRef as k}from"react";import S from"react-dom";import{useAudioClipStore as $}from"../../audioAnnotate/audioContext/index.js";import{getAttributeColor as w,getAttributeFontColor as N,updateColorOpacity as O,getAttributeShowText as T}from"../../../utils/audio.js";import F from"../../../assets/annotation/audio/loop.svg.js";import{Typography as P}from"antd";import{useClickAway as _}from"ahooks";import{classnames as D}from"../../../utils/index.js";import r from"./index.module.scss.js";const{Paragraph:I}=P,M=m=>{const{audioClipState:f,setAudioClipState:g}=$(),{clipAttributeList:i,clipAttributeConfigurable:b,clipTextConfigurable:x,selectedRegion:n}=f,c=k(null),{el:C,region:h,edgeAdsorption:y,clipping:A,instance:d}=m,{attribute:s="",text:v="",id:l,start:E,end:R}=h,{id:a}=n,o=w(s,i),u={color:N(s,i),backgroundColor:o},e={border:`2px solid ${o}`};if(l===a)e.backgroundColor=O(o,.6),e.borderLeft=`2px solid ${o}`,e.borderRight=`2px solid ${o}`;else if(d==null||d.setLoop(!1),e.borderLeft=`2px solid ${o}`,e.borderRight=`2px solid ${o}`,A){const p=Object.values(y);p.includes(E)&&(e.borderLeft="3px dashed #fff"),p.includes(R)&&(e.borderRight="3px dashed #fff")}_(()=>{l===a&&g({selectedRegion:{}})},c,["contextmenu"]);const j=l===a&&n.loop,L=t.createElement("div",{style:e,ref:c,className:D({[r.container]:!0})},j&&t.createElement("div",{className:r.loop},t.createElement("img",{src:F})),b&&t.createElement("div",null,t.createElement("div",{style:u,className:r.attribute},T(s,[{value:"",key:"\u65E0\u5C5E\u6027"},...i]))),x&&t.createElement(I,{ellipsis:{rows:2},className:r.text,style:u},"\u6587\u672C:",v));return t.createElement(t.Fragment,null,S.createPortal(L,C))};export{M as default};
1
+ import t,{useRef as w}from"react";import N from"react-dom";import{useAudioClipStore as _}from"../../audioAnnotate/audioContext/index.js";import{getAttributeColor as O,getAttributeFontColor as F,updateColorOpacity as P,getAttributeShowText as D}from"../../../utils/audio.js";import I from"../../../assets/annotation/audio/loop.svg.js";import{Typography as M}from"antd";import{useClickAway as q}from"ahooks";import{classnames as z}from"../../../utils/index.js";import r from"./index.module.scss.js";import{useTranslation as B}from"react-i18next";const{Paragraph:G}=M,H=x=>{const{t:C}=B(),{audioClipState:v,setAudioClipState:y}=_(),{clipAttributeList:i,clipAttributeConfigurable:h,clipTextConfigurable:A,selectedRegion:c,clipTextList:d}=v,u=w(null),{el:E,region:p,edgeAdsorption:R,clipping:k,instance:m}=x,{attribute:s="",text:J="",id:a,start:L,end:j}=p,{id:n}=c,o=O(s,i),f={color:F(s,i),backgroundColor:o},e={border:`2px solid ${o}`};if(a===n)e.backgroundColor=P(o,.6),e.borderLeft=`2px solid ${o}`,e.borderRight=`2px solid ${o}`;else if(m==null||m.setLoop(!1),e.borderLeft=`2px solid ${o}`,e.borderRight=`2px solid ${o}`,k){const l=Object.values(R);l.includes(L)&&(e.borderLeft="3px dashed #fff"),l.includes(j)&&(e.borderRight="3px dashed #fff")}q(()=>{a===n&&y({selectedRegion:{}})},u,["contextmenu"]);const T=a===n&&c.loop,S=t.createElement("div",{style:e,ref:u,className:z({[r.container]:!0})},T&&t.createElement("div",{className:r.loop},t.createElement("img",{src:I})),h&&t.createElement("div",null,t.createElement("div",{style:f,className:r.attribute},D(s,[{value:"",key:"\u65E0\u5C5E\u6027"},...i]))),A&&(d==null?void 0:d.map((l,$)=>{var b,g;return t.createElement(G,{ellipsis:{rows:2},className:r.text,style:f,key:$},(b=l==null?void 0:l.label)!=null?b:C("textTool"),":",(g=p[l==null?void 0:l.key])!=null?g:"")})));return t.createElement(t.Fragment,null,N.createPortal(S,E))};export{H as default};
@@ -1 +1 @@
1
- import i,{useState as g,useRef as z,useEffect as A}from"react";import{getWebPcm2WavBase64 as Kt}from"../audioAnnotate/utils/getWebPcm2Wac.js";import Vt,{debounce as Gt,sortBy as Yt}from"lodash";import{PauseOutlined as Jt,CaretRightOutlined as Qt}from"@ant-design/icons";import{cKeyCode as er,cTool as tr,EventBus as _}from"@labelbee/lb-annotation";import{Button as rr}from"antd";import or from"../invalidPage/index.js";import nr from"../imageError/index.js";import{classnames as $}from"../../utils/index.js";import ir,{EPlayerType as lr}from"../videoPlayer/components/SpeedController/index.js";import sr from"@labelbee/wavesurfer";import ar from"@labelbee/wavesurfer/dist/plugin/wavesurfer.regions.js";import ur from"@labelbee/wavesurfer/dist/plugin/wavesurfer.cursor.js";import cr,{audioZoomInfo as Xe}from"./zoomSlider/index.js";import dr from"./labelDisplayToggle/index.js";import mr from"./clipRegion/index.js";import{useAudioClipStore as pr}from"../audioAnnotate/audioContext/index.js";import{useLatest as H,useUpdate as fr,useDeepCompareEffect as Ze,useThrottleFn as vr}from"ahooks";import gr from"./useAudioScroll/index.js";import b from"./index.module.scss.js";import{getAttributeColor as br,formatTime as qe,timeFormat as Ke,dispatchResizeEvent as yr,precisionMinus as Ve,isDoubleClick as _r,getCanMoveRange as Er}from"../../utils/audio.js";import hr from"./progressDot/index.js";import Pr from"./clipTip/index.js";import Sr from"./useSwitchHotkey/index.js";import Cr from"./useAudioCombine/index.js";import Rr from"./useAudioSegment/index.js";import wr from"./combineTip/index.js";import Tr from"./segmentTip/index.js";import Ar from"../../views/MainView/toolFooter/index.js";import{decimalReserved as U}from"../videoPlayer/utils.js";var jr=Object.defineProperty,xr=Object.defineProperties,Dr=Object.getOwnPropertyDescriptors,Ge=Object.getOwnPropertySymbols,Mr=Object.prototype.hasOwnProperty,kr=Object.prototype.propertyIsEnumerable,Ye=(f,a,u)=>a in f?jr(f,a,{enumerable:!0,configurable:!0,writable:!0,value:u}):f[a]=u,Je=(f,a)=>{for(var u in a||(a={}))Mr.call(a,u)&&Ye(f,u,a[u]);if(Ge)for(var u of Ge(a))kr.call(a,u)&&Ye(f,u,a[u]);return f},Qe=(f,a)=>xr(f,Dr(a));const{EToolName:et}=tr,X=er.default,tt=.1,rt=i.createContext({count:0,isEdit:!1,toolName:et.Empty,imgIndex:0}),Ir=({fileData:f={},onLoaded:a,context:u,invalid:ot,height:nt,hideError:it,onError:ce,updateRegion:j,removeRegion:L,regions:x=[],activeToolPanel:lt,clipConfigurable:st,clipTextConfigurable:at,clipAttributeList:ut,clipAttributeConfigurable:de,isCheck:S,hoverRegionId:Z,footer:ct,drawLayerSlot:me})=>{var pe,fe;const{url:O,path:ve}=f,[q,K]=g(!1),[ge,be]=g(!1),[C,dt]=g(0),[mt,ye]=g(!1),[N,_e]=g(0),n=z(null),R=z(null),Ee=z(C),V=e=>{Ee.current=e,dt(e)},[he,pt]=g(0),[F,ft]=g(1),G=z(null),[Pe,vt]=g({}),{audioClipState:Y,setAudioClipState:k}=pr(),[J,Q]=g(!1),c=H(Y),Se=H(Pe),gt=H(q),D=H(x),Ce=fr(),[Re,bt]=g([]),[we,yt]=g({}),_t=Gt(()=>{_.emit("audioZoom")},500),Te=e=>{e<Xe.min||e>Xe.max||(ft(e),yr(),_t())};gr({container:G.current,target:document.querySelector(`[data-id=${(fe=(pe=c.current)==null?void 0:pe.selectedRegion)==null?void 0:fe.id}]`),clipping:J,zoom:F,zoomHandler:Te});const W=()=>{let e=D.current;const{attributeLockList:r}=c.current;r.length&&(e=e.filter(t=>r.includes(t.attribute))),te(),e.forEach(t=>{var o;(o=n.current)==null||o.addRegion(Qe(Je({},t),{drag:!S,resize:!S,color:"rgba(0, 0, 0, 0)"}))}),Ce()},m=e=>{var r,t,o,l,s,p,E;const{id:d,loop:v=!0,playImmediately:P=!1}=e;if(d){const M=(o=(t=(r=n.current)==null?void 0:r.regions)==null?void 0:t.list)!=null?o:{};Object.entries(M).forEach(([,y])=>{const{id:T}=y;d===T?y.select():y.cancelSelect()}),k({selectedRegion:{id:d,loop:v},selectedAttribute:(p=(s=(l=D.current)==null?void 0:l.find(y=>y.id===d))==null?void 0:s.attribute)!=null?p:""}),v&&P&&((E=I(d))==null||E.playLoop())}else k({selectedRegion:{}})},{combineInstance:Et}=Cr({waveRef:n,sortByStartRegions:Re,regionMap:we,updateRegion:j,removeRegion:L,generateRegions:W,setSelectedRegion:m}),{segmentInstance:ht,onRegionMouseMove:Pt,segmentTimeTip:St}=Rr({waveRef:n,regionMap:we,updateRegion:j,removeRegion:L,generateRegions:W,setSelectedRegion:m}),Ae={clipTextConfigurable:at,clipAttributeList:ut,clipAttributeConfigurable:de,clipConfigurable:st};A(()=>{k({selectedAttribute:""})},[de]),A(()=>{ee()},[Y.selectedAttribute]),A(()=>{W()},[Y.attributeLockList]),Ze(()=>{k(Ae),setTimeout(()=>{je()})},[Ae]),Ze(()=>{bt(Yt(x,["start"])),yt(x.reduce((e,r)=>{const{id:t}=r;return Qe(Je({},e),{[t]:r})},{}))},[x]),A(()=>{if(Z){const e=gt.current;m({id:Z,loop:e,playImmediately:!0})}else m({})},[Z]);const je=()=>{var e,r;c.current.clipConfigurable?(!S&&n.current&&((e=n.current)==null||e.enableDragSelection({slop:5})),W()):((r=n.current)==null||r.disableDragSelection(),te()),ee()},ee=()=>{var e,r,t,o,l;let s="";c.current.clipConfigurable?s=br(c.current.selectedAttribute,(e=c.current.clipAttributeList)!=null?e:[]):s="transparent",((t=(r=n==null?void 0:n.current)==null?void 0:r.cursor)==null?void 0:t.cursor)&&((l=(o=n==null?void 0:n.current)==null?void 0:o.cursor)==null||l.setStyle({border:`2px dashed ${s}`}))},I=e=>{var r,t,o;return((o=(t=(r=n.current)==null?void 0:r.regions)==null?void 0:t.list)!=null?o:{})[e]},xe=()=>{var e,r;if(O){const t=((r=(e=ve==null?void 0:ve.split("."))==null?void 0:e.pop())==null?void 0:r.toLowerCase())==="pcm";ye(!1),t?Kt(O).then(o=>{De(o)}):De(O)}},De=e=>{var r;e&&(be(!0),V(0),_e(0),(r=n==null?void 0:n.current)==null||r.load(e))},te=()=>{var e;(e=n.current)==null||e.clearRegions()},re=e=>{const r=I(e);r&&(Q(!1),r==null||r.remove(),L==null||L(e),m({}))},{run:Me}=vr(m,{wait:500});Sr({sortByStartRegions:Re,setSelectedRegion:m});const Ct=e=>{const{start:r,end:t}=Se.current;return(r||t)&&e.update(Se.current),e},Rt=({action:e,id:r,eventDownTime:t})=>{var o,l;if(!c.current.clipConfigurable)return;r&&m({id:r});const s=I((r!=null?r:(o=c.current.selectedRegion)==null?void 0:o.id)||""),p=[];(e==="create"?D.current:(l=D.current)==null?void 0:l.filter(v=>v.id!==s.id)).forEach(v=>{const{start:P,end:M,attribute:y}=v;y===c.current.selectedAttribute&&[P,M].forEach(T=>{p.includes(T)||p.push(T)})});const d=Er(p.sort((v,P)=>v-P),t);n.current.range=d},wt=e=>{ee(),setTimeout(()=>{Q(!1)});const r=Ct(e),{id:t,start:o,end:l}=r;m({id:t,playImmediately:!0});const s={id:t,start:U(o,3),end:U(l,3)};j==null||j(s),Ce()},Tt=()=>{const e=sr.create({container:"#waveform",waveColor:"#999",progressColor:"#999",height:nt||245,normalize:!0,cursorWidth:2,cursorColor:"white",responsive:0,hideScrollbar:!0,plugins:[ar.create({regions:x,dragSelection:{slop:5},canMove:!1}),ur.create({opacity:1,customStyle:{border:"2px dashed transparent"}})]}),r=()=>{var t;V(((t=n==null?void 0:n.current)==null?void 0:t.getCurrentTime())||0)};e.on("ready",()=>{var t;const o=((t=n==null?void 0:n.current)==null?void 0:t.getDuration())||0;_e(o),r(),a==null||a({duration:Math.round(o)}),be(!1),B(),_.on("setCurrentTimeByPosition",ne),_.on("clearRegions",te),_.on("removeRegionById",re),_.on("setSelectedRegion",Me),e.on("regions-eventDown",Rt),je()}),e.on("audioprocess",()=>{r()}),e.on("play",()=>{K(!0)}),e.on("pause",()=>{K(!1)}),e.on("finish",()=>{K(!1)}),e.on("seek",()=>{r()}),e.on("error",()=>{ye(!0),a==null||a({hasError:!0}),ce==null||ce()}),e.on("region-created",t=>{const{id:o,start:l,end:s}=t;if(D.current.find(E=>E.id===o))return;const p={id:o,start:U(l,3),end:U(s,3),attribute:c.current.selectedAttribute,text:""};j==null||j(p)}),e.on("region-updated",(t,o)=>{var l,s,p,E,d,v,P,M,y,T;const We=o==null?void 0:o.action;k({combined:!1,segment:!1}),We==="resize"&&((s=(l=n==null?void 0:n.current)==null?void 0:l.cursor)==null||s.setStyle({borderStyle:"solid"})),We==="drag"&&((E=(p=n==null?void 0:n.current)==null?void 0:p.cursor)==null||E.setStyle({borderColor:"transparent"}));const ie={},le=[],se={},Ft=(d=D.current)==null?void 0:d.filter(h=>h.id!==t.id),Wt=(M=(P=(v=n.current)==null?void 0:v.regions)==null?void 0:P.list)!=null?M:{};Ft.forEach(h=>{var $e,He;const{element:ae}=($e=Wt[h.id])!=null?$e:{},{start:Ht,end:Ut}=h;if(ae){const{x:Ue,width:Xt}=((He=ae.getBoundingClientRect)==null?void 0:He.call(ae))||{},Zt=Ue+Xt;[Ue,Zt].forEach((ue,qt)=>{le.includes(ue)||(le.push(ue),se[ue]=qt===0?Ht:Ut)})}});const{x:ze,width:zt}=((T=(y=t.element).getBoundingClientRect)==null?void 0:T.call(y))||{},$t=ze+zt;le.forEach(h=>{Math.abs(Ve(h,ze))<5&&(ie.start=se[h]),Math.abs(Ve(h,$t))<5&&(ie.end=se[h])}),vt(ie),Me({id:t.id}),Q(!0)}),e.on("region-update-end",t=>{wt(t)}),e.on("region-contextmenu",(t,o)=>{if(!S){if(o.preventDefault(),o.stopPropagation(),_r(o)){re(t.id);return}m({id:t.id,playImmediately:!0})}}),e.on("region-click",(t,o,l)=>{if(!S){if(o.preventDefault(),o.stopPropagation(),c.current.combined){Et(t);return}if(c.current.segment){ht(t,l);return}m({id:t.id,playImmediately:!0})}}),e.on("region-mousemove",Pt),n.current=e},At=q?i.createElement(Jt,null):i.createElement(Qt,null),ke=e=>e?`${parseFloat((e/N*100).toFixed(4))}%`:"0%",Ie=ke(C),jt=ke(he),w=()=>{if(!ge)return n==null?void 0:n.current},xt=()=>{var e;(e=w())==null||e.skipForward(tt)},Dt=()=>{var e;(e=w())==null||e.skipBackward(tt)},B=()=>{var e;(e=w())==null||e.playPause(),m({})},Be=e=>{var r;switch(e.keyCode){case X.Right:xt();break;case X.Left:Dt();break;case X.Space:e.preventDefault(),B();break;case X.Delete:if(!S){const{id:t}=((r=c.current)==null?void 0:r.selectedRegion)||{};t&&re(t)}break}},Mt=e=>{ne(e)},Le=Vt.throttle(Mt,50);let oe=!1;const Oe=()=>{oe&&(B(),oe=!1),document.removeEventListener("mousemove",Le),document.removeEventListener("mouseup",Oe)},kt=e=>{ne(e),q&&(oe=!0,B()),document.addEventListener("mousemove",Le),document.addEventListener("mouseup",Oe)},It=()=>{xe()};A(()=>(Tt(),()=>{var e;(e=n==null?void 0:n.current)==null||e.destroy(),n.current=null,_.unbindAll("setCurrentTimeByPosition"),_.unbindAll("clearRegions"),_.unbindAll("removeRegionById"),_.unbindAll("setSelectedRegion")}),[]);const Bt=e=>{var r,t,o;(r=w())==null||r.playPause(),(t=w())==null||t.setPlaybackRate(e),(o=w())==null||o.playPause()};A(()=>(document.addEventListener("keydown",Be),()=>{document.removeEventListener("keydown",Be)})),A(()=>{m({}),xe()},[O]);const Ne=e=>{var r,t,o,l;if((n==null?void 0:n.current)&&(R==null?void 0:R.current)){const s=(t=(r=n==null?void 0:n.current)==null?void 0:r.getDuration())!=null?t:0,p=(o=R==null?void 0:R.current)==null?void 0:o.getBoundingClientRect();let d=(e.clientX-p.left)/(((l=R==null?void 0:R.current)==null?void 0:l.clientWidth)||0)*s;return d>s&&(d=s),d}return 0},ne=e=>{var r;const t=Ne(e);(r=n==null?void 0:n.current)==null||r.skip(t-Ee.current),V(t)},Lt=e=>{pt(Ne(e))},Ot=N?Math.max(N-C,0):0,Nt=(u==null?void 0:u.toolName)!==et.Empty&&(u==null?void 0:u.isEdit)!==!0&&(lt==="remark"||S),Fe=i.createElement("div",{className:b.audioPlayer},mt&&!it&&i.createElement(nr,{fileTypeName:"\u97F3\u9891",ignoreOffsetY:!0,reloadImage:It,backgroundColor:"#ffffffbb"}),i.createElement(Pr,{getRegionInstanceById:I,clipping:J}),i.createElement(wr,{container:G.current}),i.createElement(Tr,{segmentTimeTip:St}),i.createElement("div",{className:b.waveformContainer,ref:G},i.createElement("div",{id:"waveform",style:{width:`${F*100}%`},className:$({[b.waveform]:!0,"bee-audio-combined":c.current.combined,"bee-audio-clip":c.current.clipConfigurable})},ot&&i.createElement(or,{isAudio:!0}),i.createElement("div",{ref:R,className:b.progress,onMouseDown:kt,onMouseMove:Lt},i.createElement("div",{className:$({[b.radioTooltip]:!0}),style:{left:Ie}},qe(C)),i.createElement("div",{className:$({[b.radioTooltip]:!0,[b.mouseTooltip]:!0}),style:{left:jt}},qe(he)),i.createElement(hr,{playPercentage:Ie})),Nt&&(me==null?void 0:me({currentTime:C,remainingTime:Ot,audioPlayer:w()})))),i.createElement("div",{className:b.controlBar},i.createElement(rr,{type:"link",icon:At,onClick:()=>{B()},className:$({[b.playButton]:!0,[b.playButtonDisabled]:ge})}),i.createElement("span",{className:b.time},`${Ke(C,"ss.SSS")} / -${Ke(N-C,"ss.SSS")}`),i.createElement(ir,{playerType:lr.Audio,onChange:e=>{Bt(e)}}),i.createElement(cr,{onChange:e=>{Te(e)},zoom:F}),i.createElement(dr,{EventBus:_})));return u?i.createElement(rt.Provider,{value:u},Fe,x.map(e=>{const{id:r}=e,t=document.querySelector(`[data-id=${r}]`);return t?i.createElement(mr,{el:t,key:r,region:e,edgeAdsorption:Pe,clipping:J,zoom:F,instance:I(r)}):null}),i.createElement(Ar,{footer:ct})):Fe};export{Ir as AudioPlayer,rt as AudioPlayerContext};
1
+ import i,{useState as b,useRef as H,useEffect as P}from"react";import{getWebPcm2WavBase64 as er}from"../audioAnnotate/utils/getWebPcm2Wac.js";import tr,{debounce as rr,sortBy as or}from"lodash";import{PauseOutlined as nr,CaretRightOutlined as ir}from"@ant-design/icons";import{cKeyCode as lr,cTool as sr,EventBus as E,TagUtils as ar}from"@labelbee/lb-annotation";import{i18n as Ve}from"@labelbee/lb-utils";import{Button as ur}from"antd";import cr from"../invalidPage/index.js";import dr from"../imageError/index.js";import{classnames as U}from"../../utils/index.js";import mr,{EPlayerType as pr}from"../videoPlayer/components/SpeedController/index.js";import fr from"@labelbee/wavesurfer";import vr from"@labelbee/wavesurfer/dist/plugin/wavesurfer.regions.js";import gr from"@labelbee/wavesurfer/dist/plugin/wavesurfer.cursor.js";import br,{audioZoomInfo as Ge}from"./zoomSlider/index.js";import yr from"./labelDisplayToggle/index.js";import _r from"./clipRegion/index.js";import{useAudioClipStore as Er}from"../audioAnnotate/audioContext/index.js";import{useLatest as X,useUpdate as hr,useDeepCompareEffect as Ye,useThrottleFn as Sr}from"ahooks";import Pr from"./useAudioScroll/index.js";import y from"./index.module.scss.js";import{getAttributeColor as Cr,formatTime as Je,timeFormat as Qe,dispatchResizeEvent as Rr,precisionMinus as et,isDoubleClick as wr,getCanMoveRange as Tr}from"../../utils/audio.js";import Ar from"./progressDot/index.js";import xr from"./clipTip/index.js";import jr from"./useSwitchHotkey/index.js";import Dr from"./useAudioCombine/index.js";import kr from"./useAudioSegment/index.js";import Lr from"./combineTip/index.js";import Mr from"./segmentTip/index.js";import Ir from"../../views/MainView/toolFooter/index.js";import{decimalReserved as Z}from"../videoPlayer/utils.js";import{I18nextProvider as Br}from"react-i18next";var Or=Object.defineProperty,Nr=Object.defineProperties,Wr=Object.getOwnPropertyDescriptors,tt=Object.getOwnPropertySymbols,Fr=Object.prototype.hasOwnProperty,zr=Object.prototype.propertyIsEnumerable,rt=(p,u,d)=>u in p?Or(p,u,{enumerable:!0,configurable:!0,writable:!0,value:d}):p[u]=d,de=(p,u)=>{for(var d in u||(u={}))Fr.call(u,d)&&rt(p,d,u[d]);if(tt)for(var d of tt(u))zr.call(u,d)&&rt(p,d,u[d]);return p},ot=(p,u)=>Nr(p,Wr(u));const{EToolName:nt}=sr,q=lr.default,it=.1,lt=i.createContext({count:0,isEdit:!1,toolName:nt.Empty,imgIndex:0}),st=({fileData:p={},onLoaded:u,context:d,invalid:at,height:ut,hideError:ct,onError:me,updateRegion:j,removeRegion:N,regions:D=[],activeToolPanel:dt,clipConfigurable:mt,clipTextConfigurable:pe,clipAttributeList:pt,clipAttributeConfigurable:fe,secondaryAttributeConfigurable:ft,subAttributeList:vt,isCheck:C,hoverRegionId:K,footer:gt,drawLayerSlot:ve,clipTextList:bt,lang:ge})=>{var be,ye;const{url:W,path:_e}=p,[V,G]=b(!1),[Ee,he]=b(!1),[R,yt]=b(0),[_t,Se]=b(!1),[F,Pe]=b(0),n=H(null),w=H(null),Ce=H(R),Y=e=>{Ce.current=e,yt(e)},[Re,Et]=b(0),[z,ht]=b(1),J=H(null),[we,St]=b({}),{audioClipState:Q,setAudioClipState:M}=Er(),[ee,te]=b(!1),c=X(Q),Te=X(we),Ae=X(V),k=X(D),xe=hr(),[je,Pt]=b([]),[De,Ct]=b({}),Rt=rr(()=>{E.emit("audioZoom")},500),ke=e=>{e<Ge.min||e>Ge.max||(ht(e),Rr(),Rt())};Pr({container:J.current,target:document.querySelector(`[data-id=${(ye=(be=c.current)==null?void 0:be.selectedRegion)==null?void 0:ye.id}]`),clipping:ee,zoom:z,zoomHandler:ke});const $=()=>{let e=k.current;const{attributeLockList:r}=c.current;r.length&&(e=e.filter(t=>r.includes(t.attribute))),oe(),e.forEach(t=>{var o;(o=n.current)==null||o.addRegion(ot(de({},t),{drag:!C,resize:!C,color:"rgba(0, 0, 0, 0)"}))}),xe()},f=e=>{var r,t,o,l,a,v,g;const{id:s,loop:m=!0,playImmediately:_=!1,isLoopStatus:L}=e,A=L?Ae.current:m;if(s){const x=(o=(t=(r=n.current)==null?void 0:r.regions)==null?void 0:t.list)!=null?o:{};Object.entries(x).forEach(([,S])=>{const{id:O}=S;s===O?S.select():S.cancelSelect()}),M({selectedRegion:{id:s,loop:A},selectedAttribute:(v=(a=(l=k.current)==null?void 0:l.find(S=>S.id===s))==null?void 0:a.attribute)!=null?v:""}),A&&_&&((g=I(s))==null||g.playLoop())}else M({selectedRegion:{}})},{combineInstance:wt}=Dr({waveRef:n,sortByStartRegions:je,regionMap:De,updateRegion:j,removeRegion:N,generateRegions:$,setSelectedRegion:f}),{segmentInstance:Tt,onRegionMouseMove:At,segmentTimeTip:xt}=kr({waveRef:n,regionMap:De,updateRegion:j,removeRegion:N,generateRegions:$,setSelectedRegion:f}),Le={clipTextConfigurable:pe,clipAttributeList:pt,clipAttributeConfigurable:fe,clipConfigurable:mt,secondaryAttributeConfigurable:ft,subAttributeList:vt,clipTextList:bt};P(()=>{var e;ge&&((e=Ve)==null||e.changeLanguage(ge))},[]),P(()=>{M({selectedAttribute:""})},[fe]),P(()=>{re()},[Q.selectedAttribute]),P(()=>{$()},[Q.attributeLockList]),Ye(()=>{M(Le),setTimeout(()=>{Me()})},[Le]),Ye(()=>{Pt(or(D,["start"])),Ct(D.reduce((e,r)=>{const{id:t}=r;return ot(de({},e),{[t]:r})},{}))},[D]),P(()=>{if(K){const e=Ae.current;f({id:K,loop:e,playImmediately:!0})}else f({})},[K]);const Me=()=>{var e,r;c.current.clipConfigurable?(!C&&n.current&&((e=n.current)==null||e.enableDragSelection({slop:5})),$()):((r=n.current)==null||r.disableDragSelection(),oe()),re()},re=()=>{var e,r,t,o,l;let a="";c.current.clipConfigurable?a=Cr(c.current.selectedAttribute,(e=c.current.clipAttributeList)!=null?e:[]):a="transparent",((t=(r=n==null?void 0:n.current)==null?void 0:r.cursor)==null?void 0:t.cursor)&&((l=(o=n==null?void 0:n.current)==null?void 0:o.cursor)==null||l.setStyle({border:`2px dashed ${a}`}))},I=e=>{var r,t,o;return((o=(t=(r=n.current)==null?void 0:r.regions)==null?void 0:t.list)!=null?o:{})[e]},Ie=()=>{var e,r;if(W){const t=((r=(e=_e==null?void 0:_e.split("."))==null?void 0:e.pop())==null?void 0:r.toLowerCase())==="pcm";Se(!1),t?er(W).then(o=>{Be(o)}):Be(W)}},Be=e=>{var r;e&&(he(!0),Y(0),Pe(0),(r=n==null?void 0:n.current)==null||r.load(e))},oe=()=>{var e;(e=n.current)==null||e.clearRegions()},ne=e=>{const r=I(e);r&&(te(!1),r==null||r.remove(),N==null||N(e),f({}))},{run:Oe}=Sr(f,{wait:500});jr({sortByStartRegions:je,setSelectedRegion:f});const jt=e=>{const{start:r,end:t}=Te.current;return(r||t)&&e.update(Te.current),e},Dt=({action:e,id:r,eventDownTime:t})=>{var o,l;if(!c.current.clipConfigurable)return;r&&f({id:r});const a=I((r!=null?r:(o=c.current.selectedRegion)==null?void 0:o.id)||""),v=[];(e==="create"?k.current:(l=k.current)==null?void 0:l.filter(m=>m.id!==a.id)).forEach(m=>{const{start:_,end:L,attribute:A}=m;A===c.current.selectedAttribute&&[_,L].forEach(x=>{v.includes(x)||v.push(x)})});const s=Tr(v.sort((m,_)=>m-_),t);n.current.range=s},kt=e=>{re(),setTimeout(()=>{te(!1)});const r=jt(e),{id:t,start:o,end:l}=r;f({id:t,playImmediately:!0});const a={id:t,start:Z(o,3),end:Z(l,3)};j==null||j(a),xe()},Lt=()=>{const e=fr.create({container:"#waveform",waveColor:"#999",progressColor:"#999",height:ut||245,normalize:!0,cursorWidth:2,cursorColor:"white",responsive:0,hideScrollbar:!0,plugins:[vr.create({regions:D,dragSelection:{slop:5},canMove:!1}),gr.create({opacity:1,customStyle:{border:"2px dashed transparent"}})]}),r=()=>{var t;Y(((t=n==null?void 0:n.current)==null?void 0:t.getCurrentTime())||0)};e.on("ready",()=>{var t;const o=((t=n==null?void 0:n.current)==null?void 0:t.getDuration())||0;Pe(o),r(),u==null||u({duration:Math.round(o)}),he(!1),B(),E.on("setCurrentTimeByPosition",le),E.on("clearRegions",oe),E.on("removeRegionById",ne),E.on("setSelectedRegion",Oe),e.on("regions-eventDown",Dt),Me()}),e.on("audioprocess",()=>{r()}),e.on("play",()=>{G(!0)}),e.on("pause",()=>{G(!1)}),e.on("finish",()=>{G(!1)}),e.on("seek",()=>{r()}),e.on("error",()=>{Se(!0),u==null||u({hasError:!0}),me==null||me()}),e.on("region-created",t=>{var o;const{id:l,start:a,end:v}=t;if(k.current.find(s=>s.id===l))return;const g={id:l,start:Z(a,3),end:Z(v,3),attribute:c.current.selectedAttribute,text:""};if(c.current.secondaryAttributeConfigurable){const s=ar.getDefaultResultByConfig((o=c.current.subAttributeList)!=null?o:[]);g.subAttribute=s!=null?s:{}}pe&&c.current.clipTextList.forEach((m,_)=>{_===0?Object.assign(g,{text:m==null?void 0:m.default}):Object.assign(g,{[m.key]:m==null?void 0:m.default})}),j==null||j(g)}),e.on("region-updated",(t,o)=>{var l,a,v,g,s,m,_,L,A,x;const S=o==null?void 0:o.action;M({combined:!1,segment:!1}),S==="resize"&&((a=(l=n==null?void 0:n.current)==null?void 0:l.cursor)==null||a.setStyle({borderStyle:"solid"})),S==="drag"&&((g=(v=n==null?void 0:n.current)==null?void 0:v.cursor)==null||g.setStyle({borderColor:"transparent"}));const O={},se=[],ae={},Xt=(s=k.current)==null?void 0:s.filter(h=>h.id!==t.id),Zt=(L=(_=(m=n.current)==null?void 0:m.regions)==null?void 0:_.list)!=null?L:{};Xt.forEach(h=>{var Ze,qe;const{element:ue}=(Ze=Zt[h.id])!=null?Ze:{},{start:Vt,end:Gt}=h;if(ue){const{x:Ke,width:Yt}=((qe=ue.getBoundingClientRect)==null?void 0:qe.call(ue))||{},Jt=Ke+Yt;[Ke,Jt].forEach((ce,Qt)=>{se.includes(ce)||(se.push(ce),ae[ce]=Qt===0?Vt:Gt)})}});const{x:Xe,width:qt}=((x=(A=t.element).getBoundingClientRect)==null?void 0:x.call(A))||{},Kt=Xe+qt;se.forEach(h=>{Math.abs(et(h,Xe))<5&&(O.start=ae[h]),Math.abs(et(h,Kt))<5&&(O.end=ae[h])}),St(O),Oe({id:t.id}),te(!0)}),e.on("region-update-end",t=>{kt(t)}),e.on("region-contextmenu",(t,o)=>{if(!C){if(o.preventDefault(),o.stopPropagation(),wr(o)){ne(t.id);return}f({id:t.id,playImmediately:!0})}}),e.on("region-click",(t,o,l)=>{if(!C){if(o.preventDefault(),o.stopPropagation(),c.current.combined){wt(t);return}if(c.current.segment){Tt(t,l);return}f({id:t.id,playImmediately:!0})}}),e.on("region-mousemove",At),n.current=e},Mt=V?i.createElement(nr,null):i.createElement(ir,null),Ne=e=>e?`${parseFloat((e/F*100).toFixed(4))}%`:"0%",We=Ne(R),It=Ne(Re),T=()=>{if(!Ee)return n==null?void 0:n.current},Bt=()=>{var e;(e=T())==null||e.skipForward(it)},Ot=()=>{var e;(e=T())==null||e.skipBackward(it)},B=()=>{var e;(e=T())==null||e.playPause(),f({})},Fe=e=>{var r;switch(e.keyCode){case q.Right:Bt();break;case q.Left:Ot();break;case q.Space:e.preventDefault(),B();break;case q.Delete:if(!C){const{id:t}=((r=c.current)==null?void 0:r.selectedRegion)||{};t&&ne(t)}break}},Nt=e=>{le(e)},ze=tr.throttle(Nt,50);let ie=!1;const $e=()=>{ie&&(B(),ie=!1),document.removeEventListener("mousemove",ze),document.removeEventListener("mouseup",$e)},Wt=e=>{le(e),V&&(ie=!0,B()),document.addEventListener("mousemove",ze),document.addEventListener("mouseup",$e)},Ft=()=>{Ie()};P(()=>(Lt(),()=>{var e;(e=n==null?void 0:n.current)==null||e.destroy(),n.current=null,E.unbindAll("setCurrentTimeByPosition"),E.unbindAll("clearRegions"),E.unbindAll("removeRegionById"),E.unbindAll("setSelectedRegion")}),[]);const zt=e=>{var r,t,o;(r=T())==null||r.playPause(),(t=T())==null||t.setPlaybackRate(e),(o=T())==null||o.playPause()};P(()=>(document.addEventListener("keydown",Fe),()=>{document.removeEventListener("keydown",Fe)})),P(()=>{f({}),Ie()},[W]);const He=e=>{var r,t,o,l;if((n==null?void 0:n.current)&&(w==null?void 0:w.current)){const a=(t=(r=n==null?void 0:n.current)==null?void 0:r.getDuration())!=null?t:0,v=(o=w==null?void 0:w.current)==null?void 0:o.getBoundingClientRect();let s=(e.clientX-v.left)/(((l=w==null?void 0:w.current)==null?void 0:l.clientWidth)||0)*a;return s>a&&(s=a),s}return 0},le=e=>{var r;const t=He(e);(r=n==null?void 0:n.current)==null||r.skip(t-Ce.current),Y(t)},$t=e=>{Et(He(e))},Ht=F?Math.max(F-R,0):0,Ut=(d==null?void 0:d.toolName)!==nt.Empty&&(d==null?void 0:d.isEdit)!==!0&&(dt==="remark"||C),Ue=i.createElement("div",{className:y.audioPlayer},_t&&!ct&&i.createElement(dr,{fileTypeName:"\u97F3\u9891",ignoreOffsetY:!0,reloadImage:Ft,backgroundColor:"#ffffffbb"}),i.createElement(xr,{getRegionInstanceById:I,clipping:ee}),i.createElement(Lr,{container:J.current}),i.createElement(Mr,{segmentTimeTip:xt}),i.createElement("div",{className:y.waveformContainer,ref:J},i.createElement("div",{id:"waveform",style:{width:`${z*100}%`},className:U({[y.waveform]:!0,"bee-audio-combined":c.current.combined,"bee-audio-clip":c.current.clipConfigurable})},at&&i.createElement(cr,{isAudio:!0}),i.createElement("div",{ref:w,className:y.progress,onMouseDown:Wt,onMouseMove:$t},i.createElement("div",{className:U({[y.radioTooltip]:!0}),style:{left:We}},Je(R)),i.createElement("div",{className:U({[y.radioTooltip]:!0,[y.mouseTooltip]:!0}),style:{left:It}},Je(Re)),i.createElement(Ar,{playPercentage:We})),Ut&&(ve==null?void 0:ve({currentTime:R,remainingTime:Ht,audioPlayer:T()})))),i.createElement("div",{className:y.controlBar},i.createElement(ur,{type:"link",icon:Mt,onClick:()=>{B()},className:U({[y.playButton]:!0,[y.playButtonDisabled]:Ee})}),i.createElement("span",{className:y.time},`${Qe(R,"ss.SSS")} / -${Qe(F-R,"ss.SSS")}`),i.createElement(mr,{playerType:pr.Audio,onChange:e=>{zt(e)}}),i.createElement(br,{onChange:e=>{ke(e)},zoom:z}),i.createElement(yr,{EventBus:E})));return d?i.createElement(lt.Provider,{value:d},Ue,D.map(e=>{const{id:r}=e,t=document.querySelector(`[data-id=${r}]`);return t?i.createElement(_r,{el:t,key:r,region:e,edgeAdsorption:we,clipping:ee,zoom:z,instance:I(r)}):null}),i.createElement(Ir,{footer:gt})):Ue},$r=p=>i.createElement(Br,{i18n:Ve},i.createElement(st,de({},p)));export{st as AudioPlayer,lt as AudioPlayerContext,$r as WrapAudioPlayer};
@@ -1,2 +1,3 @@
1
- import{message as a}from"antd";import{cKeyCode as k}from"@labelbee/lb-annotation";import{useAudioClipStore as w}from"../../audioAnnotate/audioContext/index.js";import{useMemoizedFn as b,useEventListener as $}from"ahooks";import{useEffect as K}from"react";const _=k.default,j=g=>{const{waveRef:p,sortByStartRegions:x,regionMap:d,updateRegion:c,removeRegion:u,generateRegions:C,setSelectedRegion:B}=g,{audioClipState:E,setAudioClipState:s}=w(),{selectedRegion:v,clipConfigurable:y,combined:R}=E,{id:n}=v,A=b(i=>{var l;if(!n)return;const e=d[n],o=d[i.id];if(e.attribute!==o.attribute){a.info("\u8BF7\u9009\u62E9\u76F8\u90BB\u540C\u5C5E\u6027\u7247\u6BB5");return}const f=x.filter(t=>t.attribute===e.attribute),F=f.findIndex(t=>t.id===n),I=f.findIndex(t=>t.id===i.id);if(Math.abs(F-I)!==1){a.info("\u8BF7\u9009\u62E9\u76F8\u90BB\u540C\u5C5E\u6027\u7247\u6BB5");return}const r=[];["start","end"].forEach(t=>{r.push(e[t]),r.push(o[t])});const M=Math.min(...r),S=Math.max(...r),m={id:(l=p.current)==null?void 0:l.util.getId("combined_"),start:M,end:S,attribute:e.attribute,text:[e.text,o.text].includes("")?`${e.text}${o.text}`:`${e.text}
2
- ${o.text}`};c==null||c(m),u==null||u(n),u==null||u(o.id),C(),s({combined:!1}),B({id:m.id,playImmediately:!0})}),h=b(i=>{if(!!y&&i.altKey&&i.keyCode===_.Z){if(!n){a.info("\u8BF7\u5148\u9009\u62E9\u9700\u8981\u5408\u5E76\u7684\u533A\u95F4");return}s({combined:!0,segment:!1})}});return K(()=>{R&&s({combined:!1})},[n]),$("keydown",h),{combineInstance:A}};export{j as default};
1
+ import{message as b}from"antd";import{cKeyCode as K}from"@labelbee/lb-annotation";import{useAudioClipStore as _}from"../../audioAnnotate/audioContext/index.js";import{useMemoizedFn as C,useEventListener as D}from"ahooks";import{useEffect as L}from"react";import{cloneDeep as O}from"lodash";const z=K.default,Z=y=>{const{waveRef:E,sortByStartRegions:B,regionMap:g,updateRegion:x,removeRegion:a,generateRegions:h,setSelectedRegion:A}=y,{audioClipState:R,setAudioClipState:m}=_(),{selectedRegion:v,clipConfigurable:$,combined:k,clipTextList:F}=R,{id:i}=v,I=(o,d,c)=>{const t=O(o);return F.forEach((e,l)=>{const u=d[e.key],s=c[e.key],f=[u,s].includes("")?`${u}${s}`:`${u}
2
+ ${s}`;l===0?Object.assign(t,{text:f}):Object.assign(t,{[e.key]:f})}),t},w=C(o=>{var d,c;if(!i)return;const t=g[i],e=g[o.id];if(t.attribute!==e.attribute){b.info("\u8BF7\u9009\u62E9\u76F8\u90BB\u540C\u5C5E\u6027\u7247\u6BB5");return}const l=B.filter(n=>n.attribute===t.attribute),u=l.findIndex(n=>n.id===i),s=l.findIndex(n=>n.id===o.id);if(Math.abs(u-s)!==1){b.info("\u8BF7\u9009\u62E9\u76F8\u90BB\u540C\u5C5E\u6027\u7247\u6BB5");return}const r=[];["start","end"].forEach(n=>{r.push(t[n]),r.push(e[n])});const S=Math.min(...r),T=Math.max(...r),j={id:(d=E.current)==null?void 0:d.util.getId("combined_"),start:S,end:T,attribute:t.attribute,text:[t.text,e.text].includes("")?`${t.text}${e.text}`:`${t.text}
3
+ ${e.text}`,subAttribute:(c=e.subAttribute)!=null?c:{}},p=I(j,t,e);x==null||x(p),a==null||a(i),a==null||a(e.id),h(),m({combined:!1}),A({id:p.id,playImmediately:!0})}),M=C(o=>{if(!!$&&o.altKey&&o.keyCode===z.Z){if(!i){b.info("\u8BF7\u5148\u9009\u62E9\u9700\u8981\u5408\u5E76\u7684\u533A\u95F4");return}m({combined:!0,segment:!1})}});return L(()=>{k&&m({combined:!1})},[i]),D("keydown",M),{combineInstance:w}};export{Z as default};
@@ -1 +1 @@
1
- import{useRef as _,useEffect as R}from"react";import{message as y}from"antd";import{cKeyCode as h}from"@labelbee/lb-annotation";import{useAudioClipStore as K}from"../../audioAnnotate/audioContext/index.js";import{useMemoizedFn as v,useEventListener as D}from"ahooks";const L=h.default,j=C=>{const{waveRef:o,regionMap:p,updateRegion:s,removeRegion:b,generateRegions:E,setSelectedRegion:x}=C,{audioClipState:A,setAudioClipState:c}=K(),{selectedRegion:F,clipConfigurable:S,segment:g}=A,{id:e}=F,m=_(null),a=_(null);R(()=>{var t,u,r,i,n,l,d;if(a.current&&o.current&&g&&e){const f=(l=(r=(u=(t=o.current)==null?void 0:t.regions)==null?void 0:u.util)==null?void 0:r.getRegionSnapToGridValue)==null?void 0:l.call(r,((i=o.current)==null?void 0:i.drawer.handleEvent(a.current))*((n=o.current)==null?void 0:n.getDuration())),B=(d=p[e])!=null?d:{},{start:I,end:M}=B;if(f>I&&f<M){m.current=f;return}}m.current=null},[a.current,g]);const T=v((t,u)=>{var r,i;if(!e||e!==t.id){y.info("\u8BF7\u70B9\u51FB\u6240\u9009\u533A\u95F4");return}const n=p[e],l={id:(r=o.current)==null?void 0:r.util.getId("segment_"),start:n.start,end:u,attribute:n.attribute,text:n.text},d={id:(i=o.current)==null?void 0:i.util.getId("segment_"),start:u,end:n.end,attribute:n.attribute,text:""};s==null||s(l),s==null||s(d),b==null||b(e),E(),c({segment:!1}),x({id:l.id,playImmediately:!0})}),k=v(t=>{if(!!S&&t.altKey&&t.keyCode===L.X){if(!e){y.info("\u8BF7\u5148\u9009\u62E9\u9700\u8981\u5206\u5272\u7684\u533A\u95F4");return}c({segment:!0,combined:!1})}}),w=v((t,u)=>{a.current=u});return D("keydown",k),R(()=>{g&&c({segment:!1})},[e]),{segmentInstance:T,onRegionMouseMove:w,segmentTimeTip:m.current}};export{j as default};
1
+ import{useRef as O,useEffect as P}from"react";import{message as T}from"antd";import{cKeyCode as z,TagUtils as G}from"@labelbee/lb-annotation";import{useAudioClipStore as N}from"../../audioAnnotate/audioContext/index.js";import{useMemoizedFn as y,useEventListener as U}from"ahooks";import R from"../../audioAnnotate/utils/dataTransform.js";var X=Object.defineProperty,q=Object.defineProperties,H=Object.getOwnPropertyDescriptors,E=Object.getOwnPropertySymbols,J=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable,S=(r,e,t)=>e in r?X(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,x=(r,e)=>{for(var t in e||(e={}))J.call(e,t)&&S(r,t,e[t]);if(E)for(var t of E(e))Q.call(e,t)&&S(r,t,e[t]);return r},B=(r,e)=>q(r,H(e));const W=z.default,Y=r=>{const{waveRef:e,regionMap:t,updateRegion:d,removeRegion:C,generateRegions:D,setSelectedRegion:j}=r,{audioClipState:F,setAudioClipState:p}=N(),{selectedRegion:I,clipConfigurable:h,segment:m,clipTextList:w,subAttributeList:A,secondaryAttributeConfigurable:L=!1}=F,{id:n}=I,v=O(null),f=O(null);P(()=>{var o,u,i,a,c,s,g;if(f.current&&e.current&&m&&n){const l=(s=(i=(u=(o=e.current)==null?void 0:o.regions)==null?void 0:u.util)==null?void 0:i.getRegionSnapToGridValue)==null?void 0:s.call(i,((a=e.current)==null?void 0:a.drawer.handleEvent(f.current))*((c=e.current)==null?void 0:c.getDuration())),_=(g=t[n])!=null?g:{},{start:b,end:V}=_;if(l>b&&l<V){v.current=l;return}}v.current=null},[f.current,m]);const M=y((o,u)=>{var i,a,c;if(!n||n!==o.id){T.info("\u8BF7\u70B9\u51FB\u6240\u9009\u533A\u95F4");return}const s=t[n],g=R.getClipTextByConfig(s,w),l=B(x({},g),{id:(i=e.current)==null?void 0:i.util.getId("segment_"),end:u,subAttribute:(a=s.subAttribute)!=null?a:{}}),_=R.getClipTextByConfig(s,w,!0),b=B(x({},_),{id:(c=e.current)==null?void 0:c.util.getId("segment_"),start:u,subAttribute:G.getDefaultResultByConfig(L?A!=null?A:[]:[])});d==null||d(l),d==null||d(b),C==null||C(n),D(),p({segment:!1}),j({id:l.id,playImmediately:!0})}),K=y(o=>{if(!!h&&o.altKey&&o.keyCode===W.X){if(!n){T.info("\u8BF7\u5148\u9009\u62E9\u9700\u8981\u5206\u5272\u7684\u533A\u95F4");return}p({segment:!0,combined:!1})}}),k=y((o,u)=>{f.current=u});return U("keydown",K),P(()=>{m&&p({segment:!1})},[n]),{segmentInstance:M,onRegionMouseMove:k,segmentTimeTip:v.current}};export{Y as default};
@@ -1 +1 @@
1
- import n,{useRef as P}from"react";import{Popover as m,Tooltip as x}from"antd";import{useSize as E}from"ahooks";import{prefix as g}from"../../constant/index.js";import{SearchOutlined as h}from"@ant-design/icons";var T=Object.defineProperty,b=Object.defineProperties,N=Object.getOwnPropertyDescriptors,v=Object.getOwnPropertySymbols,$=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable,d=(r,e,t)=>e in r?T(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,_=(r,e)=>{for(var t in e||(e={}))$.call(e,t)&&d(r,t,e[t]);if(v)for(var t of v(e))j.call(e,t)&&d(r,t,e[t]);return r},S=(r,e)=>b(r,N(e));const l=`${g}-longText`,C=r=>{var e,t;const{text:o,placement:c="bottom",icon:y=n.createElement(h,null),openByText:O,style:f,isToolTips:w,wordCount:p}=r,a=P(null);E(a);const i=a.current&&((e=a.current)==null?void 0:e.clientWidth)<((t=a.current)==null?void 0:t.scrollWidth);if(p)if((o==null?void 0:o.length)>p){const s=o.slice(0,p);return n.createElement(m,{placement:c,overlayClassName:`${l}-popover`,content:o},n.createElement("span",{style:{cursor:"pointer",whiteSpace:"pre-wrap"}},s,"..."))}else return n.createElement("div",{style:{whiteSpace:"pre-wrap"}}," ",o);if(O){let s={placement:c,overlayClassName:`${l}-popover`,content:o,key:`${i}`};i||Object.assign(s,{open:!1});const u=n.createElement("div",{className:`${l}-text`,style:f,ref:a},o);return w?n.createElement(x,S(_({},s),{title:o}),u):n.createElement(m,_({},s),u)}return n.createElement("div",{className:l,style:f},n.createElement("div",{className:`${l}-text`,ref:a},o),i&&n.createElement(m,{placement:c,overlayClassName:`${l}-popover`,content:o},y))};export{C as default};
1
+ import l,{forwardRef as h,useRef as E,useMemo as S}from"react";import{Tooltip as T,Popover as x}from"antd";import{useSize as j}from"ahooks";import{prefix as L}from"../../constant/index.js";import{SearchOutlined as C}from"@ant-design/icons";var M=Object.defineProperty,N=Object.defineProperties,R=Object.getOwnPropertyDescriptors,p=Object.getOwnPropertySymbols,g=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable,b=(t,e,r)=>e in t?M(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,c=(t,e)=>{for(var r in e||(e={}))g.call(e,r)&&b(t,r,e[r]);if(p)for(var r of p(e))P.call(e,r)&&b(t,r,e[r]);return t},W=(t,e)=>N(t,R(e)),$=(t,e)=>{var r={};for(var n in t)g.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&p)for(var n of p(t))e.indexOf(n)<0&&P.call(t,n)&&(r[n]=t[n]);return r};const u=`${L}-longText`,_=h((t,e)=>{var r=t,{text:n,overflowMaxLines:f,style:i}=r,v=$(r,["text","overflowMaxLines","style"]);const a={whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},o={display:"-webkit-box",WebkitLineClamp:f,WebkitBoxOrient:"vertical",overflow:"hidden"},m=f>1?o:a;return l.createElement("div",c({style:c(c({},m),i),ref:e},v),n)}),k=t=>{const{text:e,placement:r="bottom",icon:n=l.createElement(C,null),openByText:f,style:i,isToolTips:v,overflowMaxLines:a=1}=t,o=E(null),m=j(o),d=S(()=>{var s,y,O,w;return a>1?o.current&&((s=o.current)==null?void 0:s.clientHeight)<((y=o.current)==null?void 0:y.scrollHeight):o.current&&((O=o.current)==null?void 0:O.clientWidth)<((w=o.current)==null?void 0:w.scrollWidth)},[m]);if(f){let s={placement:r,overlayClassName:`${u}-popover`,content:e,key:`${d}`};return d||Object.assign(s,{open:!1}),v?l.createElement(T,W(c({},s),{title:e}),l.createElement(_,{overflowMaxLines:a,style:i,ref:o,text:e})):l.createElement(x,c({},s),l.createElement(_,{overflowMaxLines:a,style:i,ref:o,text:e}))}return l.createElement("div",{className:u,style:i},l.createElement(_,{overflowMaxLines:a,style:i,ref:o,text:e}),d&&l.createElement(x,{placement:r,overlayClassName:`${u}-popover`,content:e},n))};export{k as default};
@@ -1 +1 @@
1
- import{useLatest as B}from"ahooks";import{Spin as M}from"antd/es";import d,{useContext as N,useRef as w,useState as U,useEffect as u}from"react";import{connect as F}from"react-redux";import{usePointCloudViews as T}from"../pointCloudView/hooks/usePointCloudViews.js";import{PointCloudContext as $}from"../pointCloudView/PointCloudContext.js";import{a2MapStateToProps as q}from"../../store/annotation/map.js";import{LabelBeeContext as A}from"../../store/ctx.js";import{PointCloud2DRectOperation as G,ImgUtils as H}from"@labelbee/lb-annotation";var J=Object.defineProperty,K=Object.defineProperties,Q=Object.getOwnPropertyDescriptors,C=Object.getOwnPropertySymbols,W=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable,O=(o,e,t)=>e in o?J(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,f=(o,e)=>{for(var t in e||(e={}))W.call(e,t)&&O(o,t,e[t]);if(C)for(var t of C(e))X.call(e,t)&&O(o,t,e[t]);return o},R=(o,e)=>K(o,Q(e));const Y=o=>{var e;const{mappingData:t,size:l,config:b,checkMode:D,afterImgOnLoad:h}=o,s=(e=t==null?void 0:t.url)!=null?e:"",{pointCloudBoxList:c,setPointCloudResult:x}=N($),{update2DViewRect:y}=T(),p=d.useRef(null),n=w(null),m=B(y),_=w(null),[I,V]=U(!0),v=r=>{var a;const i=(a=m.current)==null?void 0:a.call(m,r);_.current=i,x(i)},j=()=>{var r;let a=[];c.forEach(i=>{const{rects:S=[],id:P,attribute:E,trackID:L}=i,g=S.find(z=>z.imageName===(t==null?void 0:t.path)),k=P+"_"+(t==null?void 0:t.path);g&&(a=[...a,R(f({},g),{boxID:P,id:k,attribute:E,order:L})])}),(r=n.current)==null||r.setResult(a)};return u(()=>{if(p.current){const r=new G({container:p.current,size:l,config:R(f({},b),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:D});return n.current=r,n.current.init(),n.current.on("updateDragResult",v),()=>{var a,i;(a=n.current)==null||a.unbind("updateDragResult",v),(i=n.current)==null||i.destroy()}}},[]),u(()=>{n.current&&s&&H.load(s).then(r=>{n.current.setImgNode(r),h(r),V(!1)})},[s]),u(()=>{var r;(r=n.current)==null||r.setSize(l)},[l]),u(()=>{c!==_.current&&j()},[c,s]),d.createElement(M,{spinning:I},d.createElement("div",{ref:p,style:f({position:"relative"},l)}))};var Z=F(q,null,null,{context:A})(Y);export{Z as default};
1
+ import{useMemoizedFn as v,useLatest as K}from"ahooks";import{Spin as Q}from"antd/es";import C,{useContext as W,useRef as E,useState as X,useMemo as Y,useEffect as a}from"react";import{connect as Z}from"react-redux";import{usePointCloudViews as tt}from"../pointCloudView/hooks/usePointCloudViews.js";import{PointCloudContext as et}from"../pointCloudView/PointCloudContext.js";import{a2MapStateToProps as rt}from"../../store/annotation/map.js";import{LabelBeeContext as nt}from"../../store/ctx.js";import{PointCloud2DRectOperation as ot,ImgUtils as it}from"@labelbee/lb-annotation";var ct=Object.defineProperty,ut=Object.defineProperties,lt=Object.getOwnPropertyDescriptors,A=Object.getOwnPropertySymbols,at=Object.prototype.hasOwnProperty,st=Object.prototype.propertyIsEnumerable,N=(u,i,n)=>i in u?ct(u,i,{enumerable:!0,configurable:!0,writable:!0,value:n}):u[i]=n,s=(u,i)=>{for(var n in i||(i={}))at.call(i,n)&&N(u,n,i[n]);if(A)for(var n of A(i))st.call(i,n)&&N(u,n,i[n]);return u},d=(u,i)=>ut(u,lt(i));const dt=u=>{var i;const{mappingData:n,size:p,config:_,checkMode:M,afterImgOnLoad:z}=u,R=(i=n==null?void 0:n.url)!=null?i:"",{pointCloudBoxList:g,setPointCloudResult:O,defaultAttribute:D,rectList:b,addRectIn2DView:F,updateRectIn2DView:h,removeRectIn2DView:k}=W(et),{update2DViewRect:U,remove2DViewRect:J}=tt(),w=C.useRef(null),r=E(null),x=v(U),L=v(J),P=E(null),[T,V]=X(!0),I=Y(()=>b==null?void 0:b.filter(t=>t.imageName===(n==null?void 0:n.path)),[n==null?void 0:n.path,b]),f=K(n==null?void 0:n.path),y=t=>{const{boxID:o}=t;if(o){const e=x==null?void 0:x(t);P.current=e,O(e);return}h(t)},S=t=>{f.current&&F(d(s({},t),{imageName:f.current}))},j=t=>{const o=t.find(e=>e.boxID);if(o){const e=L==null?void 0:L(o);P.current=e,O(e),m();return}k(t)},$=v(()=>{let t=[];return g.forEach(o=>{const{rects:e=[],id:c,attribute:l,trackID:q}=o,B=e.find(H=>H.imageName===f.current),G=c+"_"+f.current;B&&(t=[...t,d(s({},B),{boxID:c,id:G,attribute:l,order:q})])}),t}),m=v(()=>{var t,o,e;const c=$(),l=(t=r.current)==null?void 0:t.selectedRectID;(o=r.current)==null||o.setResult([...c,...I]),l&&((e=r.current)==null||e.setSelectedRectID(l))});return a(()=>{if(w.current){const t=new ot({container:w.current,size:p,config:d(s({},_),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:M});return r.current=t,r.current.init(),r.current.on("updateDragResult",y),r.current.on("afterAddingDrawingRect",S),r.current.on("deleteSelectedRects",j),()=>{var o,e,c,l;(o=r.current)==null||o.unbind("updateDragResult",y),(e=r.current)==null||e.unbind("afterAddingDrawingRect",S),(c=r.current)==null||c.unbind("deleteSelectedRects",j),(l=r.current)==null||l.destroy()}}},[]),a(()=>{V(!0),r.current&&R&&it.load(R).then(t=>{r.current.setImgNode(t),z(t),V(!1)})},[R]),a(()=>{var t;(t=r.current)==null||t.setSize(p)},[p]),a(()=>{g!==P.current&&m()},[g]),a(()=>{var t,o,e;const c=I.find(l=>l.id===r.current.selectedRectID);(o=(t=r.current)==null?void 0:t.setDefaultAttribute)==null||o.call(t,D),c&&h(d(s({},(e=r.current)==null?void 0:e.selectedRect),{attribute:D})),m()},[D]),a(()=>{m()},[I]),a(()=>{var t,o,e,c;const l=(o=(t=r.current)==null?void 0:t.config)!=null?o:{};(c=r.current)==null||c.setConfig(JSON.stringify(d(s({},l),{attributeList:(e=_.attributeList)!=null?e:[]})))},[_.attributeList]),C.createElement(Q,{spinning:T},C.createElement("div",{ref:w,style:s({position:"relative"},p)}))};var pt=Z(rt,null,null,{context:nt})(dt);export{pt as default};
@@ -1 +1 @@
1
- import{getClassName as J}from"../../utils/dom.js";import i,{useState as L,useContext as ie,useEffect as Q}from"react";import{PointCloudContainer as le}from"./PointCloudLayout.js";import{PointCloudContext as re}from"./PointCloudContext.js";import{connect as se}from"react-redux";import{cKeyCode as ae,pointCloudLidar2image as ue,pointListLidar2Img as ce}from"@labelbee/lb-annotation";import{LabelBeeContext as de}from"../../store/ctx.js";import{a2MapStateToProps as me}from"../../store/annotation/map.js";import{toolStyleConverter as U}from"@labelbee/lb-utils";import fe from"./PointCloud2DSingleView.js";import W from"./components/TitleButton/index.js";import{LeftOutlined as pe}from"@ant-design/icons";import ge from"classnames";import ve from"../../assets/annotation/common/icon_esc.svg.js";import be from"../../assets/annotation/common/icon_left_squareOutlined.svg.js";import ye from"../../assets/annotation/common/icon_right_squareOutlined.svg.js";import{isNumber as Ee}from"lodash";var _e=Object.defineProperty,he=Object.defineProperties,we=Object.getOwnPropertyDescriptors,X=Object.getOwnPropertySymbols,Ce=Object.prototype.hasOwnProperty,Pe=Object.prototype.propertyIsEnumerable,Y=(e,n,t)=>n in e?_e(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,f=(e,n)=>{for(var t in n||(n={}))Ce.call(n,t)&&Y(e,t,n[t]);if(X)for(var t of X(n))Pe.call(n,t)&&Y(e,t,n[t]);return e},p=(e,n)=>he(e,we(n));const I=ae.default,Le=({showEnlarge:e,isEnlargeTopView:n,data:t,setIsEnlarge:y,setCurIndex:g,curIndex:E=0,index:x,annotations2d:_})=>n?i.createElement(W,{title:t==null?void 0:t.calName,style:{background:"rgba(0, 0, 0, 0.74)",color:"#FFFFFF"}}):e?i.createElement("div",{style:{display:"flex",alignItems:"center"}},i.createElement(pe,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{y(!1),g(void 0)}}),i.createElement("span",null,t==null?void 0:t.calName),i.createElement("span",{style:{marginLeft:"8px"}},E+1,"/",_==null?void 0:_.length)):i.createElement(W,{title:t==null?void 0:t.calName,onClick:()=>{y(!0),g(x)},style:{background:"rgba(0, 0, 0, 0.74)",color:"#FFFFFF"}}),xe=({currentData:e,config:n,thumbnailWidth:t,isEnlargeTopView:y,highlightAttribute:g,loadPCDFileLoading:E,checkMode:x,measureVisible:_})=>{var O;const[d,Z]=L([]),{topViewInstance:B,displayPointCloudList:j,polygonList:S,imageSizes:N,selectedIDs:V}=ie(re),[F,D]=L(""),[h,k]=L(!1),[a,w]=L(void 0);Q(()=>{var l;if(!E&&B&&(e==null?void 0:e.mappingImgList)&&((l=e==null?void 0:e.mappingImgList)==null?void 0:l.length)>0){const r={fill:"transparent",color:"green"};let s=[];e==null||e.mappingImgList.forEach(o=>{var v,T,K;const $=j.reduce((m,c)=>{var b,u;const C=c.id===F||g===c.attribute,{transferViewData:H,viewRangePointList:P}=(b=ue(c,o.calib,{createRange:C}))!=null?b:{};if(!H||!P)return[];const M=(u=U.getColorFromConfig({attribute:c.attribute},p(f({},n),{attributeConfigurable:!0}),{}))==null?void 0:u.stroke,ne=ee({viewDataPointList:H,pointCloudBox:c,defaultViewStyle:r,stroke:M}),G=[...m,...ne];return(P==null?void 0:P.length)>0&&G.unshift({type:"polygon",annotation:p(f({id:F,pointList:P},r),{stroke:M,fill:"rgba(255, 255, 255, 0.6)"})}),G},[]),q=N[(v=o==null?void 0:o.path)!=null?v:""];q&&Ee((T=o==null?void 0:o.calib)==null?void 0:T.groundHeight)&&S.forEach(m=>{const c=m.pointList.map(u=>{var C;return p(f({},u),{z:(C=o==null?void 0:o.calib)==null?void 0:C.groundHeight})}),b=ce(c,o==null?void 0:o.calib,q);if(b){const u=U.getColorFromConfig({attribute:m.attribute},p(f({},n),{attributeConfigurable:!0}),{});$.push({type:"polygon",annotation:p(f({id:m.id,pointList:b},r),{stroke:u==null?void 0:u.stroke,fill:V.includes(m.id)?u==null?void 0:u.fill:"rgba(255, 255, 255, 0.6)"})})}}),s.push({annotations:$,url:o==null?void 0:o.url,calName:(K=o==null?void 0:o.calib)==null?void 0:K.calName,calib:o==null?void 0:o.calib,path:o==null?void 0:o.path})}),Z(s)}},[j,e==null?void 0:e.mappingImgList,F,g,E,S,N,V]),Q(()=>(window.addEventListener("keydown",R),()=>{window.removeEventListener("keydown",R)}),[a]);const R=l=>{const{keyCode:r}=l;switch(r){case I.Esc:h&&k(!1);break;case I.Left:A();break;case I.Right:z();break}},A=()=>{a===void 0||!h||Number(a)>0&&w(a-1)},z=()=>{a===void 0||!h||Number(a)<(d==null?void 0:d.length)-1&&w(a+1)},ee=({viewDataPointList:l,pointCloudBox:r,defaultViewStyle:s,stroke:o})=>l?l.map(v=>({type:v.type,annotation:p(f({id:r.id,pointList:v.pointList},s),{stroke:o})})):[],te=!e||!(e==null?void 0:e.mappingImgList)||!(((O=e==null?void 0:e.mappingImgList)==null?void 0:O.length)>0),oe=i.createElement("div",{style:{display:"flex",alignItems:"center",fontSize:"14px"}},i.createElement("img",{src:be,style:{height:"24px",marginRight:"8px",cursor:"pointer"},onClick:()=>A()}),i.createElement("span",{style:{marginRight:"12px"}},"\u952E\u76D8\u5DE6\u952E\u4E0A\u4E00\u5F20"),i.createElement("span",{style:{margin:"0px 8px 0px 12px"}},"\u952E\u76D8\u53F3\u952E\u4E0A\u4E00\u5F20"),i.createElement("img",{src:ye,style:{height:"24px",marginRight:"12px",cursor:"pointer"},onClick:()=>z()}),i.createElement("img",{src:ve,style:{height:"24px",margin:"0px 8px 0px 12px",cursor:"pointer"},onClick:()=>{k(!1),w(void 0)}}),i.createElement("span",null,"\u952E\u9000\u51FA"));return(d==null?void 0:d.length)>0?i.createElement(i.Fragment,null,d.map((l,r)=>{const s=h&&r===a;return i.createElement(le,{className:ge({[J("point-cloud-2d-container")]:!0,[J("point-cloud-container","zoom")]:s}),title:i.createElement(Le,{showEnlarge:s,isEnlargeTopView:y,data:l,setIsEnlarge:k,setCurIndex:w,curIndex:a,index:r,annotations2d:d}),titleOnSurface:!s,style:{display:te?"none":"flex",width:s?"100%":t},key:r,toolbar:oe},(l==null?void 0:l.annotations)&&(l==null?void 0:l.url)&&i.createElement(fe,{currentData:e,view2dData:l,setSelectedID:D,showEnlarge:s,checkMode:x,measureVisible:_}))})):null};var Fe=se(me,null,null,{context:de})(xe);export{Fe as default};
1
+ import{getClassName as Q}from"../../utils/dom.js";import i,{useState as L,useContext as ue,useEffect as U}from"react";import{PointCloudContainer as ae}from"./PointCloudLayout.js";import{PointCloudContext as ce}from"./PointCloudContext.js";import{connect as de}from"react-redux";import{cKeyCode as me,pointCloudLidar2image as fe,pointListLidar2Img as pe}from"@labelbee/lb-annotation";import{LabelBeeContext as ge}from"../../store/ctx.js";import{a2MapStateToProps as ve}from"../../store/annotation/map.js";import{toolStyleConverter as W}from"@labelbee/lb-utils";import be from"./PointCloud2DSingleView.js";import X from"./components/TitleButton/index.js";import{LeftOutlined as ye}from"@ant-design/icons";import Ee from"classnames";import he from"../../assets/annotation/common/icon_esc.svg.js";import _e from"../../assets/annotation/common/icon_left_squareOutlined.svg.js";import we from"../../assets/annotation/common/icon_right_squareOutlined.svg.js";import{isNumber as Ce}from"lodash";import{getBoundingRect as Pe,isBoundingRectInImage as Le}from"../../utils/index.js";var xe=Object.defineProperty,Ie=Object.defineProperties,Fe=Object.getOwnPropertyDescriptors,Y=Object.getOwnPropertySymbols,ke=Object.prototype.hasOwnProperty,Oe=Object.prototype.propertyIsEnumerable,Z=(e,n,o)=>n in e?xe(e,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[n]=o,m=(e,n)=>{for(var o in n||(n={}))ke.call(n,o)&&Z(e,o,n[o]);if(Y)for(var o of Y(n))Oe.call(n,o)&&Z(e,o,n[o]);return e},f=(e,n)=>Ie(e,Fe(n));const j=me.default,je=({showEnlarge:e,isEnlargeTopView:n,data:o,setIsEnlarge:y,setCurIndex:g,curIndex:E=0,index:x,annotations2d:h})=>n?i.createElement(X,{title:o==null?void 0:o.calName,style:{background:"rgba(0, 0, 0, 0.74)",color:"#FFFFFF"}}):e?i.createElement("div",{style:{display:"flex",alignItems:"center"}},i.createElement(ye,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{y(!1),g(void 0)}}),i.createElement("span",null,o==null?void 0:o.calName),i.createElement("span",{style:{marginLeft:"8px"}},E+1,"/",h==null?void 0:h.length)):i.createElement(X,{title:o==null?void 0:o.calName,onClick:()=>{y(!0),g(x)},style:{background:"rgba(0, 0, 0, 0.74)",color:"#FFFFFF"}}),Ne=({currentData:e,config:n,thumbnailWidth:o,isEnlargeTopView:y,highlightAttribute:g,loadPCDFileLoading:E,checkMode:x,measureVisible:h})=>{var N;const[p,D]=L([]),{topViewInstance:ee,displayPointCloudList:R,polygonList:S,imageSizes:I,selectedIDs:V}=ue(ce),[F,te]=L(""),[_,k]=L(!1),[u,w]=L(void 0);U(()=>{var l;if(!E&&ee&&(e==null?void 0:e.mappingImgList)&&((l=e==null?void 0:e.mappingImgList)==null?void 0:l.length)>0){const r={fill:"transparent",color:"green"};let s=[];e==null||e.mappingImgList.forEach(t=>{var v,K,$;const q=R.reduce((c,d)=>{var b,a;const C=d.id===F||g===d.attribute,{transferViewData:O,viewRangePointList:P}=(b=fe(d,t.calib,{createRange:C}))!=null?b:{};if(!O||!P)return[];const le=O.reduce((G,J)=>J.type==="line"?[...G,...J.pointList]:G,[]),re=f(m({},Pe(le)),{imageName:t.path});if(!Le(re,t.path,I))return c;const B=(a=W.getColorFromConfig({attribute:d.attribute},f(m({},n),{attributeConfigurable:!0}),{}))==null?void 0:a.stroke,se=oe({viewDataPointList:O,pointCloudBox:d,defaultViewStyle:r,stroke:B}),M=[...c,...se];return(P==null?void 0:P.length)>0&&M.unshift({type:"polygon",annotation:f(m({id:F,pointList:P},r),{stroke:B,fill:"rgba(255, 255, 255, 0.6)"})}),M},[]),H=I[(v=t==null?void 0:t.path)!=null?v:""];H&&Ce((K=t==null?void 0:t.calib)==null?void 0:K.groundHeight)&&S.forEach(c=>{const d=c.pointList.map(a=>{var C;return f(m({},a),{z:(C=t==null?void 0:t.calib)==null?void 0:C.groundHeight})}),b=pe(d,t==null?void 0:t.calib,H);if(b){const a=W.getColorFromConfig({attribute:c.attribute},f(m({},n),{attributeConfigurable:!0}),{});q.push({type:"polygon",annotation:f(m({id:c.id,pointList:b},r),{stroke:a==null?void 0:a.stroke,fill:V.includes(c.id)?a==null?void 0:a.fill:"rgba(255, 255, 255, 0.6)"})})}}),s.push({annotations:q,url:t==null?void 0:t.url,calName:($=t==null?void 0:t.calib)==null?void 0:$.calName,calib:t==null?void 0:t.calib,path:t==null?void 0:t.path})}),D(s)}},[R,e==null?void 0:e.mappingImgList,F,g,E,S,I,V]),U(()=>(window.addEventListener("keydown",A),()=>{window.removeEventListener("keydown",A)}),[u]);const A=l=>{const{keyCode:r}=l;switch(r){case j.Esc:_&&k(!1);break;case j.Left:z();break;case j.Right:T();break}},z=()=>{u===void 0||!_||Number(u)>0&&w(u-1)},T=()=>{u===void 0||!_||Number(u)<(p==null?void 0:p.length)-1&&w(u+1)},oe=({viewDataPointList:l,pointCloudBox:r,defaultViewStyle:s,stroke:t})=>l?l.map(v=>({type:v.type,annotation:f(m({id:r.id,pointList:v.pointList},s),{stroke:t})})):[],ne=!e||!(e==null?void 0:e.mappingImgList)||!(((N=e==null?void 0:e.mappingImgList)==null?void 0:N.length)>0),ie=i.createElement("div",{style:{display:"flex",alignItems:"center",fontSize:"14px"}},i.createElement("img",{src:_e,style:{height:"24px",marginRight:"8px",cursor:"pointer"},onClick:()=>z()}),i.createElement("span",{style:{marginRight:"12px"}},"\u952E\u76D8\u5DE6\u952E\u4E0A\u4E00\u5F20"),i.createElement("span",{style:{margin:"0px 8px 0px 12px"}},"\u952E\u76D8\u53F3\u952E\u4E0A\u4E00\u5F20"),i.createElement("img",{src:we,style:{height:"24px",marginRight:"12px",cursor:"pointer"},onClick:()=>T()}),i.createElement("img",{src:he,style:{height:"24px",margin:"0px 8px 0px 12px",cursor:"pointer"},onClick:()=>{k(!1),w(void 0)}}),i.createElement("span",null,"\u952E\u9000\u51FA"));return(p==null?void 0:p.length)>0?i.createElement(i.Fragment,null,p.map((l,r)=>{const s=_&&r===u;return i.createElement(ae,{className:Ee({[Q("point-cloud-2d-container")]:!0,[Q("point-cloud-container","zoom")]:s}),title:i.createElement(je,{showEnlarge:s,isEnlargeTopView:y,data:l,setIsEnlarge:k,setCurIndex:w,curIndex:u,index:r,annotations2d:p}),titleOnSurface:!s,style:{display:ne?"none":"flex",width:s?"100%":o},key:r,toolbar:ie},(l==null?void 0:l.annotations)&&(l==null?void 0:l.url)&&i.createElement(be,{currentData:e,view2dData:l,setSelectedID:te,showEnlarge:s,checkMode:x,measureVisible:h}))})):null};var Re=de(ve,null,null,{context:ge})(Ne);export{Re as default};
@@ -1 +1 @@
1
- import{getClassName as m}from"../../utils/dom.js";import{cKeyCode as K,PointCloud as M}from"@labelbee/lb-annotation";import{PointCloudUtils as B,toolStyleConverter as Z,EPerspectiveView as E}from"@labelbee/lb-utils";import j from"classnames";import e,{useContext as b,useState as O,useRef as H,useEffect as u,useMemo as U}from"react";import{PointCloudContainer as q}from"./PointCloudLayout.js";import{PointCloudContext as G}from"./PointCloudContext.js";import{a2MapStateToProps as J}from"../../store/annotation/map.js";import{connect as Q}from"react-redux";import{jsonParser as W}from"../../utils/index.js";import{useSingleBox as X}from"./hooks/useSingleBox.js";import{useSphere as Y}from"./hooks/useSphere.js";import{Switch as $,Tooltip as ee}from"antd";import te from"../../hooks/useSize.js";import{usePointCloudViews as oe}from"./hooks/usePointCloudViews.js";import{useTranslation as L}from"react-i18next";import{LabelBeeContext as ne}from"../../store/ctx.js";import ie from"./components/PointCloudSizeSlider/index.js";import re from"./components/TitleButton/index.js";import{LeftOutlined as ae}from"@ant-design/icons";var le=Object.defineProperty,se=Object.defineProperties,ce=Object.getOwnPropertyDescriptors,z=Object.getOwnPropertySymbols,me=Object.prototype.hasOwnProperty,ue=Object.prototype.propertyIsEnumerable,D=(n,r,a)=>r in n?le(n,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):n[r]=a,N=(n,r)=>{for(var a in r||(r={}))me.call(r,a)&&D(n,a,r[a]);if(z)for(var a of z(r))ue.call(r,a)&&D(n,a,r[a]);return n},de=(n,r)=>se(n,ce(r));const pe=K.default,we="LABELBEE-POINTCLOUD",P=e.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),d=({perspectiveView:n})=>{const{isActive:r,setTarget3DView:a}=b(P),o=p=>j({[m("point-cloud-3d-view",p)]:!0,active:r});return e.createElement("span",{onClick:()=>{a(E[n])},className:o(n.toLocaleLowerCase())})},k=({isEnlarge:n})=>{const{reset3DView:r,followTopView:a}=b(P),{t:o}=L(),p=e.createElement(e.Fragment,null,e.createElement(d,{perspectiveView:"Top"}),e.createElement(d,{perspectiveView:"Front"}),e.createElement(d,{perspectiveView:"Left"}),e.createElement(d,{perspectiveView:"Back"}),e.createElement(d,{perspectiveView:"Right"}),e.createElement(d,{perspectiveView:"LFT"}),e.createElement(d,{perspectiveView:"RBT"})),V=e.createElement(e.Fragment,null,e.createElement(ee,{title:o("CameraFollowTopView")},e.createElement("span",{onClick:()=>{a()},className:m("point-cloud-3d-view","followTop")})),e.createElement("span",{onClick:()=>{r()},className:m("point-cloud-3d-view","reset")}));return n?e.createElement("div",{className:m("point-cloud-3d-sidebarZoom")},V,p):e.createElement("div",{className:m("point-cloud-3d-sidebar")},p,V)},ve=({currentData:n,config:r,highlightAttribute:a})=>{const o=b(G),[p,V]=O(!0),[v,_]=O(!1),f=H(null),{initPointCloud3d:S}=oe(),C=te(f),{t:h}=L();u(()=>{!o.mainViewInstance||S==null||S(C)},[C]);const{selectedBox:w}=X(),{selectedSphere:g}=Y(),x=t=>{var i,l;const s=w==null?void 0:w.info;if(s){const c=N({},s.center);c.x=c.x-.01,c.z=1e3;const I=t===E.Top;(i=o.mainViewInstance)==null||i.updateCameraByBox(s,t,I?c:void 0)}g&&((l=o.mainViewInstance)==null||l.updateCameraBySphere(g,t))},R=()=>{var t;(t=o.mainViewInstance)==null||t.resetCamera()},F=()=>{var t,i;const l=(t=o.topViewInstance)==null?void 0:t.pointCloudInstance.camera;l&&((i=o.mainViewInstance)==null||i.applyCameraTarget(l))};u(()=>{if(f.current&&(n==null?void 0:n.url)){let t=o.mainViewInstance;!t&&C.width&&(t=new M({container:f.current,isOrthographicCamera:!0,orthographicParams:B.getDefaultOrthographicParams(C),config:r}),o.setMainViewInstance(t))}},[C,n]),u(()=>{var t;if(f.current&&(n==null?void 0:n.url)&&n.result&&o.mainViewInstance){let i=o.mainViewInstance;const l=B.getBoxParamsFromResultList(n.result);l.forEach(s=>{var c;const I=(c=Z.getColorFromConfig({attribute:s.attribute},de(N({},r),{attributeConfigurable:!0}),{}))==null?void 0:c.hex;i==null||i.addBoxToSense(s,I)}),i.render(),o.setPointCloudResult(l),o.setPointCloudValid((t=W(n.result))==null?void 0:t.valid)}},[n,o.mainViewInstance]),u(()=>{var t,i,l,s;if(w){x(E.Top);const c=(l=(i=(t=o.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:i.camera.zoom)!=null?l:1;(s=o.mainViewInstance)==null||s.updateCameraZoom(c)}},[w]),u(()=>{var t,i,l,s;if(g){x(E.Top);const c=(l=(i=(t=o.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:i.camera.zoom)!=null?l:1;(s=o.mainViewInstance)==null||s.updateCameraZoom(c)}},[g]),u(()=>(window.addEventListener("keydown",T),()=>{window.removeEventListener("keydown",T)}),[]);const T=t=>{if(t.keyCode===pe.Esc){_(!1);return}},y=U(()=>({reset3DView:R,setTarget3DView:x,isActive:!!w,followTopView:F}),[w,o.mainViewInstance]);u(()=>{var t,i,l;const s=o.pointCloudBoxList.filter(c=>c.attribute===a);(s==null?void 0:s.length)>0&&((t=o.mainViewInstance)==null||t.clearHighlightBoxes(),(i=o.mainViewInstance)==null||i.highlightBoxes(s)),s.length===0&&((l=o.mainViewInstance)==null||l.clearHighlightBoxesAndRender())},[a,o.mainViewInstance]);const A=e.createElement(e.Fragment,null,e.createElement(ie,{onChange:t=>{var i;(i=o.mainViewInstance)==null||i.updatePointSize({customSize:t})}}),e.createElement("span",{style:{marginRight:8}},h("ShowArrows")),e.createElement($,{size:"small",checked:p,onChange:t=>{var i;V(t),(i=o.mainViewInstance)==null||i.setShowDirection(t)}}),v&&e.createElement(P.Provider,{value:y},e.createElement(k,{isEnlarge:v})));return e.createElement(q,{className:j({[m("point-cloud-3d-container")]:!0,[m("point-cloud-container","zoom")]:v}),title:v?e.createElement("div",{style:{display:"flex",alignItems:"center"}},e.createElement(ae,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{_(!1)}}),h("3DView")):e.createElement(re,{title:h("3DView"),onClick:()=>{_(!0)}}),toolbar:A},e.createElement("div",{className:m("point-cloud-3d-content")},!v&&e.createElement(P.Provider,{value:y},e.createElement(k,null)),e.createElement("div",{className:m("point-cloud-3d-view"),id:we,ref:f})))};var fe=Q(J,null,null,{context:ne})(ve);export{fe as default};
1
+ import{getClassName as m}from"../../utils/dom.js";import{cKeyCode as M,PointCloud as Z}from"@labelbee/lb-annotation";import{PointCloudUtils as b,toolStyleConverter as H,EPerspectiveView as E}from"@labelbee/lb-utils";import L from"classnames";import e,{useContext as S,useState as j,useRef as U,useEffect as u,useMemo as q}from"react";import{PointCloudContainer as G}from"./PointCloudLayout.js";import{PointCloudContext as J}from"./PointCloudContext.js";import{a2MapStateToProps as Q}from"../../store/annotation/map.js";import{connect as W}from"react-redux";import{jsonParser as X}from"../../utils/index.js";import{useSingleBox as Y}from"./hooks/useSingleBox.js";import{useSphere as $}from"./hooks/useSphere.js";import{Switch as ee,Tooltip as te}from"antd";import oe from"../../hooks/useSize.js";import{usePointCloudViews as ne}from"./hooks/usePointCloudViews.js";import{useTranslation as O}from"react-i18next";import{LabelBeeContext as ie}from"../../store/ctx.js";import re from"./components/PointCloudSizeSlider/index.js";import ae from"./components/TitleButton/index.js";import{LeftOutlined as le}from"@ant-design/icons";var se=Object.defineProperty,ce=Object.defineProperties,me=Object.getOwnPropertyDescriptors,z=Object.getOwnPropertySymbols,ue=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable,D=(n,r,a)=>r in n?se(n,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):n[r]=a,N=(n,r)=>{for(var a in r||(r={}))ue.call(r,a)&&D(n,a,r[a]);if(z)for(var a of z(r))de.call(r,a)&&D(n,a,r[a]);return n},pe=(n,r)=>ce(n,me(r));const we=M.default,ve="LABELBEE-POINTCLOUD",_=e.createContext({isActive:!1,setTarget3DView:()=>{},reset3DView:()=>{},followTopView:()=>{}}),d=({perspectiveView:n})=>{const{isActive:r,setTarget3DView:a}=S(_),o=p=>L({[m("point-cloud-3d-view",p)]:!0,active:r});return e.createElement("span",{onClick:()=>{a(E[n])},className:o(n.toLocaleLowerCase())})},k=({isEnlarge:n})=>{const{reset3DView:r,followTopView:a}=S(_),{t:o}=O(),p=e.createElement(e.Fragment,null,e.createElement(d,{perspectiveView:"Top"}),e.createElement(d,{perspectiveView:"Front"}),e.createElement(d,{perspectiveView:"Left"}),e.createElement(d,{perspectiveView:"Back"}),e.createElement(d,{perspectiveView:"Right"}),e.createElement(d,{perspectiveView:"LFT"}),e.createElement(d,{perspectiveView:"RBT"})),V=e.createElement(e.Fragment,null,e.createElement(te,{title:o("CameraFollowTopView")},e.createElement("span",{onClick:()=>{a()},className:m("point-cloud-3d-view","followTop")})),e.createElement("span",{onClick:()=>{r()},className:m("point-cloud-3d-view","reset")}));return n?e.createElement("div",{className:m("point-cloud-3d-sidebarZoom")},V,p):e.createElement("div",{className:m("point-cloud-3d-sidebar")},p,V)},fe=({currentData:n,config:r,highlightAttribute:a})=>{const o=S(J),[p,V]=j(!0),[v,h]=j(!1),f=U(null),{initPointCloud3d:T}=ne(),C=oe(f),{t:x}=O();u(()=>{!o.mainViewInstance||T==null||T(C)},[C]);const{selectedBox:w}=Y(),{selectedSphere:g}=$(),I=t=>{var i,l;const s=w==null?void 0:w.info;if(s){const c=N({},s.center);c.x=c.x-.01,c.z=1e3;const P=t===E.Top;(i=o.mainViewInstance)==null||i.updateCameraByBox(s,t,P?c:void 0)}g&&((l=o.mainViewInstance)==null||l.updateCameraBySphere(g,t))},R=()=>{var t;(t=o.mainViewInstance)==null||t.resetCamera()},F=()=>{var t,i;const l=(t=o.topViewInstance)==null?void 0:t.pointCloudInstance.camera;l&&((i=o.mainViewInstance)==null||i.applyCameraTarget(l))};u(()=>{if(f.current&&(n==null?void 0:n.url)){let t=o.mainViewInstance;!t&&C.width&&(t=new Z({container:f.current,isOrthographicCamera:!0,orthographicParams:b.getDefaultOrthographicParams(C),config:r}),o.setMainViewInstance(t))}},[C,n]),u(()=>{var t;if(f.current&&(n==null?void 0:n.url)&&n.result&&o.mainViewInstance){let i=o.mainViewInstance;const l=b.getBoxParamsFromResultList(n.result);l.forEach(c=>{var P;const K=(P=H.getColorFromConfig({attribute:c.attribute},pe(N({},r),{attributeConfigurable:!0}),{}))==null?void 0:P.hex;i==null||i.addBoxToSense(c,K)}),i.render(),o.setPointCloudResult(l);const s=b.getRectParamsFromResultList(n.result);o.setRectList(s),o.setPointCloudValid((t=X(n.result))==null?void 0:t.valid)}},[n,o.mainViewInstance]),u(()=>{var t,i,l,s;if(w){I(E.Top);const c=(l=(i=(t=o.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:i.camera.zoom)!=null?l:1;(s=o.mainViewInstance)==null||s.updateCameraZoom(c)}},[w]),u(()=>{var t,i,l,s;if(g){I(E.Top);const c=(l=(i=(t=o.topViewInstance)==null?void 0:t.pointCloudInstance)==null?void 0:i.camera.zoom)!=null?l:1;(s=o.mainViewInstance)==null||s.updateCameraZoom(c)}},[g]),u(()=>(window.addEventListener("keydown",y),()=>{window.removeEventListener("keydown",y)}),[]);const y=t=>{if(t.keyCode===we.Esc){h(!1);return}},B=q(()=>({reset3DView:R,setTarget3DView:I,isActive:!!w,followTopView:F}),[w,o.mainViewInstance]);u(()=>{var t,i,l;const s=o.pointCloudBoxList.filter(c=>c.attribute===a);(s==null?void 0:s.length)>0&&((t=o.mainViewInstance)==null||t.clearHighlightBoxes(),(i=o.mainViewInstance)==null||i.highlightBoxes(s)),s.length===0&&((l=o.mainViewInstance)==null||l.clearHighlightBoxesAndRender())},[a,o.mainViewInstance]);const A=e.createElement(e.Fragment,null,e.createElement(re,{onChange:t=>{var i;(i=o.mainViewInstance)==null||i.updatePointSize({customSize:t})}}),e.createElement("span",{style:{marginRight:8}},x("ShowArrows")),e.createElement(ee,{size:"small",checked:p,onChange:t=>{var i;V(t),(i=o.mainViewInstance)==null||i.setShowDirection(t)}}),v&&e.createElement(_.Provider,{value:B},e.createElement(k,{isEnlarge:v})));return e.createElement(G,{className:L({[m("point-cloud-3d-container")]:!0,[m("point-cloud-container","zoom")]:v}),title:v?e.createElement("div",{style:{display:"flex",alignItems:"center"}},e.createElement(le,{style:{cursor:"pointer",marginRight:"12px"},onClick:()=>{h(!1)}}),x("3DView")):e.createElement(ae,{title:x("3DView"),onClick:()=>{h(!0)}}),toolbar:A},e.createElement("div",{className:m("point-cloud-3d-content")},!v&&e.createElement(_.Provider,{value:B},e.createElement(k,null)),e.createElement("div",{className:m("point-cloud-3d-view"),id:ve,ref:f})))};var Ce=W(Q,null,null,{context:ie})(fe);export{Ce as default};
@@ -1 +1 @@
1
- import{EPointCloudPattern as z}from"@labelbee/lb-utils";import nt,{useState as n,useRef as Vt,useMemo as it,useEffect as E}from"react";import{ActionsHistory as st,EToolName as G}from"@labelbee/lb-annotation";import{useDispatch as Bt}from"../../store/ctx.js";import{ChangeSave as Ot}from"../../store/annotation/actionCreators.js";import Ht from"../../store/annotatedBox/index.js";var Rt=Object.defineProperty,jt=Object.defineProperties,zt=Object.getOwnPropertyDescriptors,lt=Object.getOwnPropertySymbols,Et=Object.prototype.hasOwnProperty,Gt=Object.prototype.propertyIsEnumerable,rt=(a,e,i)=>e in a?Rt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):a[e]=i,Nt=(a,e)=>{for(var i in e||(e={}))Et.call(e,i)&&rt(a,i,e[i]);if(lt)for(var i of lt(e))Gt.call(e,i)&&rt(a,i,e[i]);return a},Ft=(a,e)=>jt(a,zt(e)),Mt=(a,e,i)=>new Promise((m,C)=>{var S=v=>{try{f(i.next(v))}catch(s){C(s)}},_=v=>{try{f(i.throw(v))}catch(s){C(s)}},f=v=>v.done?m(v.value):Promise.resolve(v.value).then(S,_);f((i=i.apply(a,e)).next())});const at=nt.createContext({pointCloudBoxList:[],pointCloudSphereList:[],displayPointCloudList:[],displaySphereList:[],displayLineList:[],polygonList:[],lineList:[],selectedID:"",selectedIDs:[],highlightIDs:[],setHighlightIDs:()=>{},valid:!0,setSelectedIDs:()=>{},setPointCloudResult:()=>{},setPointCloudSphereList:()=>{},setPointCloudValid:()=>{},setTopViewInstance:()=>{},setSideViewInstance:()=>{},setBackViewInstance:()=>{},setMainViewInstance:()=>{},addSelectedID:()=>{},addHighlightID:()=>{},selectedAllBoxes:()=>{},addPointCloudBox:()=>[],addPointCloudSphere:()=>[],setPolygonList:()=>{},setLineList:()=>{},zoom:1,setZoom:()=>{},history:new st,hideAttributes:[],setHideAttributes:()=>{},toggleAttributesVisible:()=>{},reRender:()=>{},setAttrPanelLayout:()=>{},attrPanelLayout:"",syncAllViewPointCloudColor:()=>Promise.resolve(),defaultAttribute:"",setDefaultAttribute:()=>{},pointCloudPattern:G.Rect,setPointCloudPattern:()=>{},selectSpecAttr:()=>{},globalPattern:z.Detection,setGlobalPattern:()=>{},setPtSegmentInstance:()=>{},segmentation:[],setSegmentation:()=>{},clearAllDetectionInstance:()=>{},highlight2DDataList:[],setHighlight2DDataList:()=>{},cuboidBoxIn2DView:!0,setCuboidBoxIn2DView:a=>{},imageSizes:{},cacheImageNodeSize:()=>{}}),Tt=({children:a})=>{const[e,i]=n([]),[m,C]=n([]),[S,_]=n([]),[f,v]=n([]),[s,x]=n([]),[y,V]=n([]),[N,dt]=n(!0),[F,ct]=n(!0),[M,ut]=n(1),[d,T]=n(),[Z,k]=n(),[q,J]=n(),[l,K]=n(),[Q,pt]=n(""),[B,gt]=n(G.Rect),ht=Vt(new st).current,[p,O]=n([]),[U,vt]=n(""),[H,Pt]=n(z.Detection),[b,W]=n(void 0),[R,ft]=n([]),[j,mt]=n([]),g=Ht(),[X,bt]=n({}),It=Bt(),Ct=r=>{const{imgNode:c,path:u}=r;u&&c&&bt(P=>Ft(Nt({},P),{[u]:{width:c.width,height:c.height}}))},Y=it(()=>s.length===1?s[0]:"",[s]),w=it(()=>{const r=e.find(t=>t.id===Y),c=t=>{const o=e.concat(t);return i(o),o},u=t=>{const o=m.concat(t);return C(o),o},P=t=>{dt(t!==!1)},h=t=>{t===void 0&&x([]),typeof t=="string"&&x([t]),Array.isArray(t)&&x(Array.from(new Set(t)))},yt=t=>{s.includes(t)?h(s.filter(o=>o!==t)):h([...s,t])},Lt=t=>{y.includes(t)?V([]):V([t])},Dt=()=>{if(B===G.Rect){const t=e.map(o=>o.id);h(t),d==null||d.pointCloud2dOperation.setSelectedIDs(t)}},wt=t=>{h(e.filter(o=>o.attribute===t).map(o=>o.id))},$=e.filter(t=>!p.includes(t.attribute)),tt=m.filter(t=>!p.includes(t.attribute)),et=f.filter(t=>t.attribute&&!p.includes(t.attribute)),At=t=>{if(p.includes(t))O(p.filter(o=>o!==t));else{const o=p.concat(t);O(o)}},_t=(t=$,o=S,L=tt,A=et,D=R)=>{var I;l==null||l.clearAllBox(),l==null||l.clearAllSphere(),d==null||d.updatePolygonList(t,o),d==null||d.updatePointList(L),d==null||d.updateLineList(A),l==null||l.generateBoxes(t),l==null||l.generateSpheres(L),(I=b==null?void 0:b.store)==null||I.updateCurrentSegment(D),ot(t)},xt=()=>{T(void 0),k(void 0),J(void 0),K(void 0)},ot=(t,o)=>Mt(void 0,null,function*(){var L;if(!l)return;const A=l.pointCloudObject;if(!!A)try{const D=yield l.getHighlightIndexByMappingImgList({mappingImgList:o!=null?o:j,points:A.geometry.attributes.position.array}),I=yield l==null?void 0:l.highlightOriginPointCloud(t,D);return I&&((L=d==null?void 0:d.pointCloudInstance)==null||L.updateColor(I)),I}catch(D){console.error(D)}});return{selectedID:Y,pointCloudBoxList:e,pointCloudSphereList:m,displayPointCloudList:$,displaySphereList:tt,displayLineList:et,selectedIDs:s,setPointCloudResult:i,setSelectedIDs:h,addPointCloudBox:c,addPointCloudSphere:u,setPointCloudSphereList:C,valid:N,selectedPointCloudBox:r,setPointCloudValid:P,addSelectedID:yt,addHighlightID:Lt,selectedAllBoxes:Dt,topViewInstance:d,setTopViewInstance:T,sideViewInstance:Z,setSideViewInstance:k,backViewInstance:q,setBackViewInstance:J,mainViewInstance:l,setMainViewInstance:K,polygonList:S,setPolygonList:_,lineList:f,setLineList:v,zoom:M,setZoom:ut,history:ht,toggleAttributesVisible:At,hideAttributes:p,setHideAttributes:O,reRender:_t,attrPanelLayout:U,setAttrPanelLayout:vt,syncAllViewPointCloudColor:ot,defaultAttribute:Q,setDefaultAttribute:pt,pointCloudPattern:B,setPointCloudPattern:gt,selectSpecAttr:wt,globalPattern:H,setGlobalPattern:t=>{H!==t&&(It(Ot),Pt(t),t===z.Detection&&W(void 0))},ptSegmentInstance:b,setPtSegmentInstance:W,segmentation:R,setSegmentation:ft,clearAllDetectionInstance:xt,highlight2DDataList:j,setHighlight2DDataList:mt,cuboidBoxIn2DView:F,setCuboidBoxIn2DView:ct,imageSizes:X,cacheImageNodeSize:Ct,highlightIDs:y,setHighlightIDs:V}},[N,s,e,m,S,f,d,Z,q,l,M,p,U,Q,B,H,b,R,j,F,X,y]);E(()=>{var r,c,u;(r=g==null?void 0:g.setPointCloudBoxList)==null||r.call(g,e),(c=g==null?void 0:g.setHighlightIDs)==null||c.call(g,y),(u=g==null?void 0:g.setSelectedIDs)==null||u.call(g,s)},[e,s,y]),E(()=>{var r;(r=g==null?void 0:g.setPtCtx)==null||r.call(g,w)},[w]);const St=()=>{const r=e.filter(h=>p.includes(h.attribute)),{setSelectedIDs:c,reRender:u}=w,P=r.map(h=>h.id);P.length>0&&c(s.filter(h=>!P.includes(h))),u()};return E(()=>{var r,c,u,P;St(),(c=(r=d==null?void 0:d.toolInstance)==null?void 0:r.setHiddenAttributes)==null||c.call(r,p),(P=(u=b==null?void 0:b.store)==null?void 0:u.setHiddenAttributes)==null||P.call(u,p)},[p]),nt.createElement(at.Provider,{value:w},a)};export{at as PointCloudContext,Tt as PointCloudProvider};
1
+ import{EPointCloudPattern as E}from"@labelbee/lb-utils";import it,{useState as n,useRef as zt,useMemo as st,useEffect as N}from"react";import{ActionsHistory as lt,EToolName as G}from"@labelbee/lb-annotation";import{useDispatch as Et}from"../../store/ctx.js";import{ChangeSave as Nt}from"../../store/annotation/actionCreators.js";import Gt from"../../store/annotatedBox/index.js";import Ft from"lodash";var Mt=Object.defineProperty,kt=Object.defineProperties,Tt=Object.getOwnPropertyDescriptors,rt=Object.getOwnPropertySymbols,Zt=Object.prototype.hasOwnProperty,qt=Object.prototype.propertyIsEnumerable,at=(s,o,i)=>o in s?Mt(s,o,{enumerable:!0,configurable:!0,writable:!0,value:i}):s[o]=i,Jt=(s,o)=>{for(var i in o||(o={}))Zt.call(o,i)&&at(s,i,o[i]);if(rt)for(var i of rt(o))qt.call(o,i)&&at(s,i,o[i]);return s},Kt=(s,o)=>kt(s,Tt(o)),Qt=(s,o,i)=>new Promise((b,S)=>{var D=u=>{try{C(i.next(u))}catch(I){S(I)}},_=u=>{try{C(i.throw(u))}catch(I){S(I)}},C=u=>u.done?b(u.value):Promise.resolve(u.value).then(D,_);C((i=i.apply(s,o)).next())});const ct=s=>Ft.pick(s,["id","attribute","width","height","x","y","imageName"]),dt=it.createContext({rectList:[],pointCloudBoxList:[],pointCloudSphereList:[],displayPointCloudList:[],displaySphereList:[],displayLineList:[],polygonList:[],lineList:[],selectedID:"",selectedIDs:[],highlightIDs:[],setHighlightIDs:()=>{},valid:!0,setSelectedIDs:()=>{},setPointCloudResult:()=>{},setPointCloudSphereList:()=>{},setPointCloudValid:()=>{},setTopViewInstance:()=>{},setSideViewInstance:()=>{},setBackViewInstance:()=>{},setMainViewInstance:()=>{},addSelectedID:()=>{},addHighlightID:()=>{},selectedAllBoxes:()=>{},addPointCloudBox:()=>[],addPointCloudSphere:()=>[],setPolygonList:()=>{},setRectList:()=>{},addRectIn2DView:()=>{},removeRectIn2DView:()=>{},updateRectIn2DView:()=>{},setLineList:()=>{},zoom:1,setZoom:()=>{},history:new lt,hideAttributes:[],setHideAttributes:()=>{},toggleAttributesVisible:()=>{},reRender:()=>{},setAttrPanelLayout:()=>{},attrPanelLayout:"",syncAllViewPointCloudColor:()=>Promise.resolve(),defaultAttribute:"",setDefaultAttribute:()=>{},pointCloudPattern:G.Rect,setPointCloudPattern:()=>{},selectSpecAttr:()=>{},globalPattern:E.Detection,setGlobalPattern:()=>{},setPtSegmentInstance:()=>{},segmentation:[],setSegmentation:()=>{},clearAllDetectionInstance:()=>{},highlight2DDataList:[],setHighlight2DDataList:()=>{},cuboidBoxIn2DView:!0,setCuboidBoxIn2DView:s=>{},imageSizes:{},cacheImageNodeSize:()=>{}}),Ut=({children:s})=>{const[o,i]=n([]),[b,S]=n([]),[D,_]=n([]),[C,u]=n([]),[I,ut]=n([]),[h,x]=n([]),[y,R]=n([]),[F,pt]=n(!0),[M,gt]=n(!0),[k,ht]=n(1),[a,T]=n(),[Z,q]=n(),[J,K]=n(),[l,Q]=n(),[U,vt]=n(""),[B,ft]=n(G.Rect),Pt=zt(new lt).current,[p,O]=n([]),[W,mt]=n(""),[H,It]=n(E.Detection),[w,X]=n(void 0),[j,bt]=n([]),[z,Ct]=n([]),g=Gt(),[Y,wt]=n({}),Lt=Et(),St=r=>{const{imgNode:c,path:d}=r;d&&c&&wt(P=>Kt(Jt({},P),{[d]:{width:c.width,height:c.height}}))},$=st(()=>h.length===1?h[0]:"",[h]),V=st(()=>{const r=o.find(t=>t.id===$),c=t=>{const e=o.concat(t);return i(e),e},d=t=>{const e=b.concat(t);return S(e),e},P=t=>{pt(t!==!1)},v=t=>{t===void 0&&x([]),typeof t=="string"&&x([t]),Array.isArray(t)&&x(Array.from(new Set(t)))},yt=t=>{h.includes(t)?v(h.filter(e=>e!==t)):v([...h,t])},At=t=>{const e=ct(t);u(f=>[...f,e])},Vt=t=>{const e=ct(t);u(f=>f.map(m=>m.id===t.id?e:m))},_t=t=>{u(e=>e.filter(f=>!t.find(m=>m.id===f.id)))},xt=t=>{y.includes(t)?R([]):R([t])},Rt=()=>{if(B===G.Rect){const t=o.map(e=>e.id);v(t),a==null||a.pointCloud2dOperation.setSelectedIDs(t)}},Bt=t=>{v(o.filter(e=>e.attribute===t).map(e=>e.id))},tt=o.filter(t=>!p.includes(t.attribute)),et=b.filter(t=>!p.includes(t.attribute)),ot=I.filter(t=>t.attribute&&!p.includes(t.attribute)),Ot=t=>{if(p.includes(t))O(p.filter(e=>e!==t));else{const e=p.concat(t);O(e)}},Ht=(t=tt,e=D,f=et,m=ot,A=j)=>{var L;l==null||l.clearAllBox(),l==null||l.clearAllSphere(),a==null||a.updatePolygonList(t,e),a==null||a.updatePointList(f),a==null||a.updateLineList(m),l==null||l.generateBoxes(t),l==null||l.generateSpheres(f),(L=w==null?void 0:w.store)==null||L.updateCurrentSegment(A),nt(t)},jt=()=>{T(void 0),q(void 0),K(void 0),Q(void 0)},nt=(t,e)=>Qt(void 0,null,function*(){var f;if(!l)return;const m=l.pointCloudObject;if(!!m)try{const A=yield l.getHighlightIndexByMappingImgList({mappingImgList:e!=null?e:z,points:m.geometry.attributes.position.array}),L=yield l==null?void 0:l.highlightOriginPointCloud(t,A);return L&&((f=a==null?void 0:a.pointCloudInstance)==null||f.updateColor(L)),L}catch(A){console.error(A)}});return{selectedID:$,pointCloudBoxList:o,pointCloudSphereList:b,displayPointCloudList:tt,displaySphereList:et,displayLineList:ot,selectedIDs:h,setPointCloudResult:i,setSelectedIDs:v,addPointCloudBox:c,addPointCloudSphere:d,setPointCloudSphereList:S,valid:F,selectedPointCloudBox:r,setPointCloudValid:P,addSelectedID:yt,addHighlightID:xt,selectedAllBoxes:Rt,topViewInstance:a,setTopViewInstance:T,sideViewInstance:Z,setSideViewInstance:q,backViewInstance:J,setBackViewInstance:K,mainViewInstance:l,setMainViewInstance:Q,polygonList:D,setPolygonList:_,rectList:C,setRectList:u,addRectIn2DView:At,removeRectIn2DView:_t,updateRectIn2DView:Vt,lineList:I,setLineList:ut,zoom:k,setZoom:ht,history:Pt,toggleAttributesVisible:Ot,hideAttributes:p,setHideAttributes:O,reRender:Ht,attrPanelLayout:W,setAttrPanelLayout:mt,syncAllViewPointCloudColor:nt,defaultAttribute:U,setDefaultAttribute:vt,pointCloudPattern:B,setPointCloudPattern:ft,selectSpecAttr:Bt,globalPattern:H,setGlobalPattern:t=>{H!==t&&(Lt(Nt),It(t),t===E.Detection&&X(void 0))},ptSegmentInstance:w,setPtSegmentInstance:X,segmentation:j,setSegmentation:bt,clearAllDetectionInstance:jt,highlight2DDataList:z,setHighlight2DDataList:Ct,cuboidBoxIn2DView:M,setCuboidBoxIn2DView:gt,imageSizes:Y,cacheImageNodeSize:St,highlightIDs:y,setHighlightIDs:R}},[F,h,o,b,D,I,C,a,Z,J,l,k,p,W,U,B,H,w,j,z,M,Y,y]);N(()=>{var r,c,d;(r=g==null?void 0:g.setPointCloudBoxList)==null||r.call(g,o),(c=g==null?void 0:g.setHighlightIDs)==null||c.call(g,y),(d=g==null?void 0:g.setSelectedIDs)==null||d.call(g,h)},[o,h,y]),N(()=>{var r;(r=g==null?void 0:g.setPtCtx)==null||r.call(g,V)},[V]);const Dt=()=>{const r=o.filter(v=>p.includes(v.attribute)),{setSelectedIDs:c,reRender:d}=V,P=r.map(v=>v.id);P.length>0&&c(h.filter(v=>!P.includes(v))),d()};return N(()=>{var r,c,d,P;Dt(),(c=(r=a==null?void 0:a.toolInstance)==null?void 0:r.setHiddenAttributes)==null||c.call(r,p),(P=(d=w==null?void 0:w.store)==null?void 0:d.setHiddenAttributes)==null||P.call(d,p)},[p]),it.createElement(dt.Provider,{value:V},s)};export{dt as PointCloudContext,Ut as PointCloudProvider};
@@ -1 +1 @@
1
- import{EPointCloudName as nt,MathUtils as B,getCuboidFromPointCloudBox as Mt}from"@labelbee/lb-annotation";import{EPerspectiveView as J,PointCloudUtils as V,POINT_CLOUD_DEFAULT_STEP as Gt,DEFAULT_SPHERE_PARAMS as Jt}from"@labelbee/lb-utils";import{useContext as Qt}from"react";import{PointCloudContext as Xt}from"../PointCloudContext.js";import{useSingleBox as Yt}from"./useSingleBox.js";import{useSphere as qt}from"./useSphere.js";import{useSelector as Kt,useDispatch as $t}from"../../../store/ctx.js";import to from"../../../utils/StepUtils.js";import{jsonParser as it,getRectPointCloudBox as oo}from"../../../utils/index.js";import{PreDataProcess as st,SetPointCloudLoading as Ct,SetLoadPCDFileLoading as Pt}from"../../../store/annotation/actionCreators.js";import{useHistory as eo}from"./useHistory.js";import{usePolygon as no}from"./usePolygon.js";import{useLatest as io}from"ahooks";var so=Object.defineProperty,ro=Object.defineProperties,lo=Object.getOwnPropertyDescriptors,ht=Object.getOwnPropertySymbols,ao=Object.prototype.hasOwnProperty,co=Object.prototype.propertyIsEnumerable,xt=(e,t,i)=>t in e?so(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,L=(e,t)=>{for(var i in t||(t={}))ao.call(t,i)&&xt(e,i,t[i]);if(ht)for(var i of ht(t))co.call(t,i)&&xt(e,i,t[i]);return e},O=(e,t)=>ro(e,lo(t)),rt=(e,t,i)=>new Promise((d,o)=>{var a=u=>{try{c(i.next(u))}catch(h){o(h)}},g=u=>{try{c(i.throw(u))}catch(h){o(h)}},c=u=>u.done?d(u.value):Promise.resolve(u.value).then(a,g);c((i=i.apply(e,t)).next())});const q=5,K=90,mt=.01,y={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},lt=(e,t,i,d,o)=>{const{x:a,y:g}=V.transferCanvas2World(e,t),{defaultZ:c}=Jt,u={center:{x:a,y:g,z:c},id:e.id},h=d?L(L({},d),u):O(L({},u),{attribute:"",valid:!0});return o&&Object.assign(h,o),h},dt=(e,t,i,d,o,a)=>{let g=e.pointList.map(v=>V.transferCanvas2World(v,t)),c=0,u=1,h={};if(i){const v=i.getSensesPointZAxisInPolygon(g,void 0,a);a&&v.fittedCoordinates.length>0&&(g=v.fittedCoordinates),c=(v.maxZ+v.minZ)/2,u=v.maxZ-v.minZ,h={count:v.zCount}}const[m,I,W]=g,z=B.getLineCenterPoint([m,W]),T=B.getLineLength(m,I),R=B.getLineLength(I,W),E=B.getRadiusFromQuadrangle(e.pointList);d&&(c=d.center.z,u=d.depth);const j={center:{x:z.x,y:z.y,z:c},width:a?R+mt:R,height:a?T+mt:T,depth:u,rotation:E,id:e.id},N=L(d?L(L({},d),j):O(L({},j),{attribute:"",valid:!0}),h);o&&Object.assign(N,o);const F=g.map(v=>V.transferWorld2Canvas(v,t));return{boxParams:N,newPointList:F}},Lt=(e,t,i)=>{const d={x:e.x-t.x,y:e.y-t.y};return O(L({},i),{center:{x:i.center.x-d.x,y:i.center.y,z:i.center.z-d.y}})},yt=(e,t,i,d)=>{const[o,a,g]=e.pointList,[c,u,h]=t.pointList,m=B.getLineCenterPoint([o,g]),I=B.getLineCenterPoint([c,h]),z={x:{x:m.x-I.x,y:m.y-I.y}.x,y:0,z:m.y-I.y},T=B.getLineLength(o,a),R=B.getLineLength(c,u),E=T-R,j=B.getLineLength(a,g),N=B.getLineLength(u,h),F=j-N,{newBoxParams:v}=d.getNewBoxBySideUpdate(z,F,E,i);return v},uo=(e,t,i)=>{const d={x:e.x-t.x,y:e.y-t.y};return O(L({},i),{center:{x:i.center.x,y:i.center.y-d.x,z:i.center.z-d.y}})},po=(e,t,i,d)=>{const[o,a,g]=e.pointList,[c,u,h]=t.pointList,m=B.getLineCenterPoint([o,g]),I=B.getLineCenterPoint([c,h]),z={x:{x:m.x-I.x,y:m.y-I.y}.x,y:0,z:m.y-I.y},T=B.getLineLength(o,a),R=B.getLineLength(c,u),E=T-R,j=B.getLineLength(a,g),N=B.getLineLength(u,h),F=j-N;let{newBoxParams:v}=d.getNewBoxByBackUpdate(z,F,E,i);return v},vt=(e,t,i,d,o)=>{var a;if(!i)return;const{toolInstance:g,pointCloudInstance:c}=i;c.loadPCDFile(d,(a=o==null?void 0:o.radius)!=null?a:K);const{cameraPositionVector:u}=c.updateOrthoCameraBySphere(e,J.Left);c.setInitCameraPosition(u);const{point2d:h,zoom:m}=c.getSphereSidePoint2DCoordinate(e);c.camera.zoom=m,c.camera.updateProjectionMatrix(),c.render(),g.initPosition(),g.zoomChangeOnCenter(m),g.setResult([O(L(L({},t),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},Bt=(e,t,i,d)=>{if(!i)return;const{pointCloud2dOperation:o,pointCloudInstance:a}=i;a.loadPCDFileByBox(d,e,{width:q,depth:q});const{cameraPositionVector:g}=a.updateOrthoCamera(e,J.Left);a.setInitCameraPosition(g);const{polygon2d:c,zoom:u}=a.getBoxSidePolygon2DCoordinate(e);a.camera.zoom=u,a.camera.updateProjectionMatrix(),a.render(),o.initPosition(),o.zoomChangeOnCenter(u),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},bt=(e,t,i,d,o)=>{var a;if(!i)return;const{toolInstance:g,pointCloudInstance:c}=i;c.loadPCDFile(d,(a=o==null?void 0:o.radius)!=null?a:K);const{cameraPositionVector:u}=c.updateOrthoCameraBySphere(e,J.Back);c.setInitCameraPosition(u);const{point2d:h,zoom:m}=c.getSphereBackPoint2DCoordinate(e);c.camera.zoom=m,c.camera.updateProjectionMatrix(),c.render(),g.initPosition(),g.zoomChangeOnCenter(m),g.setResult([O(L(L({},t),h),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},wt=(e,t,i,d)=>{if(!i)return;const{pointCloud2dOperation:o,pointCloudInstance:a}=i;a.loadPCDFileByBox(d,e,{height:q,depth:q});const{cameraPositionVector:g}=a.updateOrthoCamera(e,J.Back);a.setInitCameraPosition(g);const{polygon2d:c,zoom:u}=a.getBoxBackPolygon2DCoordinate(e);a.camera.zoom=u,a.camera.updateProjectionMatrix(),a.render(),o.initPosition(),o.zoomChangeOnCenter(u),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:c,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},It=(e,t,i,d)=>{if(!i||!d)return;d.generateSphere(e),d.updateCameraBySphere(e,J.Top),d.render();const{toolInstance:o,pointCloudInstance:a}=i,{point2d:g}=a.getSphereTopPoint2DCoordinate(e),c=[...o.pointList].map(u=>u.id===t.id?O(L(L({},t),g),{valid:e.valid,textAttribute:"",attribute:e.attribute}):u);o.setResult(c),o.setSelectedID(t.id)},at=(e,t,i,d)=>{var o,a;if(!i||!d)return;d.generateBox(e,t.id),d.render();const{pointCloud2dOperation:g,pointCloudInstance:c}=i,{polygon2d:u}=c.getBoxTopPolygon2DCoordinate(e),h=[...g.polygonList],m=h.find(I=>I.id===t.id);m?(m.pointList=u,m.valid=(o=e.valid)!=null?o:!0):h.push({id:t.id,pointList:u,textAttribute:"",isRect:!0,valid:(a=e.valid)!=null?a:!0}),g.setResultAndSelectedID(h,t.id)},go=()=>{const e=Qt(Xt),{topViewInstance:t,sideViewInstance:i,backViewInstance:d,mainViewInstance:o,addPointCloudBox:a,addPointCloudSphere:g,setSelectedIDs:c,selectedIDs:u,pointCloudBoxList:h,pointCloudSphereList:m,hideAttributes:I,setHighlight2DDataList:W,cuboidBoxIn2DView:z,imageSizes:T}=e,{addHistory:R,initHistory:E,pushHistoryUnderUpdatePolygon:j}=eo(),{selectedPolygon:N}=no(),{getPointCloudSphereByID:F,updatePointCloudSphere:v,selectedSphere:Q}=qt(),{currentData:Z,config:S}=Kt(n=>{const{stepList:s,step:p,imgList:r,imgIndex:l}=n.annotation;return{currentData:r[l],config:it(to.getCurrentStepInfo(p,s).config)}}),H=$t(),St=io(z),$=n=>{if(!St.current){const{mappingImgList:s=[]}=Z,p=s.map(r=>oo({pointCloudBox:n,mappingData:r,imageSizes:T}));Object.assign(n,{rects:p.filter(r=>r!==void 0)})}},{selectedBox:_,updateSelectedBox:Dt,updateSelectedBoxes:tt,getPointCloudByID:_t}=Yt({generateRects:$}),ct=_==null?void 0:_.info;if(!t||!i||!d)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:ot}=t,Vt=n=>{o==null||o.generateBox(n),o==null||o.controls.update(),o==null||o.render()},Ot=n=>{o==null||o.generateSphere(n),o==null||o.controls.update(),o==null||o.render()},kt=({newPoint:n,size:s,zoom:p,trackConfigurable:r})=>{var l;const f={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};r===!0&&Object.assign(f,{trackID:V.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:m})});const P=lt(n,s,ot,void 0,f);c(n.id);const x=g(P);X(y.Top,n,P,p,x,S),R({newSphereParams:P})},Rt=({polygon:n,size:s,imgList:p,trackConfigurable:r,zoom:l,intelligentFit:f})=>{var P,x;const C={attribute:(P=t.toolInstance.defaultAttribute)!=null?P:""};r===!0&&Object.assign(C,{trackID:V.getNextTrackID({imgList:[],extraBoxList:h,extraSphereList:m})});const D=t==null?void 0:t.toolInstance,w=L({},n);let{boxParams:b,newPointList:A}=dt(w,s,ot,void 0,C,f);b=H(st({tool:nt.PointCloud,dataList:[b],stepConfig:S,action:"viewUpdateBox"}))[0],f&&(A==null?void 0:A.length)&&(w.pointList=A);const k=I.includes(w.attribute);$(b);const G=a(b),et=(x=e==null?void 0:e.polygonList)!=null?x:[];t==null||t.updatePolygonList(G!=null?G:[],et),k?c([]):(c(b.id),D.selection.setSelectedIDs(w.id),M({omitView:y.Top,polygon:w,boxParams:b,zoom:l,newPointCloudBoxList:G}),f&&at(b,w,t,o)),R({newBoxParams:b})},At=n=>{const{boxID:s,imageName:p,width:r,height:l,x:f,y:P}=n,x=h.find(C=>C.id===s);if(x==null?void 0:x.rects){const{rects:C=[]}=x,D=C.find(w=>w.imageName===p);if(D){let w=C;const b=O(L({},D),{width:r,height:l,x:f,y:P});w=C.map(k=>k===D?b:k);const A=O(L({},x),{rects:w}),U=h.map(k=>k===x?A:k);return t==null||t.updatePolygonList(U!=null?U:[]),U}}},Ut=({newSelectedBox:n,newPointCloudList:s,newSelectedSphere:p,newSphereList:r})=>{var l;const f=t==null?void 0:t.toolInstance;if(!(u.length===0||!f)){if(n||(_==null?void 0:_.info)){const P=n!=null?n:_==null?void 0:_.info;(l=f==null?void 0:f.selection)==null||l.setSelectedIDs(u[0]);const x=f.selectedPolygon;if(u.length===1&&P){M({omitView:y.Top,polygon:x,boxParams:P,newPointCloudBoxList:s});return}}if((p||Q)&&u.length===1){const P=p!=null?p:Q;f.setSelectedID(u[0]);const x=f.selectedPoint;P&&X(y.Top,x,P,void 0,r,S)}}},ut=(n,s,p)=>{if(ct){let r,l;switch(p){case y.Back:r=po;break;case y.Side:r=yt;break;default:r=yt;break}if(l=r(n,s,ct,i.pointCloudInstance),o){const{count:D}=o.getSensesPointZAxisInPolygon(Mt(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=O(L({},l),{count:D})}const P=H(st({tool:nt.PointCloud,dataList:[l],stepConfig:S,action:"viewUpdateBox"}))[0],x=l.valid!==P.valid;l=P;const C=Dt(l);return l=C.find(D=>D.id===l.id),M({omitView:x?void 0:p,polygon:n,boxParams:l,newPointCloudBoxList:C}),C}},pt=(n,s,p)=>{if(Q){let r,l;switch(p){case y.Back:r=uo;break;case y.Side:r=Lt;break;default:r=Lt;break}l=r(n,s,Q);const f=v(l);return X(p,n,l,void 0,f,S),f}},zt=(n,s)=>{pt(n,s,y.Side)},Tt=(n,s)=>{pt(n,s,y.Back)},jt=(n,s)=>{ut(n,s,y.Side)},Nt=(n,s)=>{ut(n,s,y.Back)},Et=(n,s)=>{const p=F(n.id),r=lt(n,s,ot,p),l=v(r);X(y.Top,n,r,void 0,l,S)},Ft=(n,s)=>{if(N){const r=L({},n[0].newPolygon);r.pointList=r.pointList.map(l=>V.transferCanvas2World(l,s)),j(r);return}let p=n.map(({newPolygon:r})=>{const l=_t(r.id),{boxParams:f}=dt(r,s,t.pointCloudInstance,l);return f});if(p=H(st({tool:nt.PointCloud,dataList:p,stepConfig:S,action:"viewUpdateBox"})),p.length===1){const{newPolygon:r}=n[0],l=tt(p);M({polygon:r,boxParams:p[0],newPointCloudBoxList:l})}else{const r=tt(p);r&&e.syncAllViewPointCloudColor(r)}},Ht=n=>{var s,p,r,l,f;if(_){const P=Number(n.widthDefault),x=Number(n.depthDefault),C=Number(n.heightDefault),D=_==null?void 0:_.info.trackID,b=((s=t==null?void 0:t.toolInstance)==null?void 0:s.polygonList).find(Y=>(Y==null?void 0:Y.trackID)===D),A={width:(r=(p=t==null?void 0:t.toolInstance)==null?void 0:p.basicImgInfo)==null?void 0:r.width,height:(f=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:f.height},U=b.pointList.map(Y=>V.transferCanvas2World(Y,A)),k=B.getModifiedRectangleCoordinates(U,C,P),G=k[0],et=k[2],gt=B.getLineCenterPoint([G,et]),Wt=_.info.center.z-_.info.depth/2,ft=O(L({},_.info),{center:{x:gt.x,y:gt.y,z:Wt+x/2},width:P,height:C,depth:x,valid:!0}),Zt=tt([ft]);M({omitView:y["3D"],polygon:b,boxParams:ft,newPointCloudBoxList:Zt})}},X=(n,s,p,r,l,f)=>rt(void 0,null,function*(){const P=Z==null?void 0:Z.url,x={[y.Side]:()=>{vt(p,s,i,P,f)},[y.Back]:()=>{d&&bt(p,s,d,P,f)},[y.Top]:()=>{It(p,s,t,o)}};Object.keys(x).forEach(C=>{C!==n&&x[C]()}),r&&(o==null||o.updateCameraZoom(r)),Ot(p)}),M=n=>rt(void 0,null,function*(){const{omitView:s,polygon:p,boxParams:r,zoom:l,newPointCloudBoxList:f}=n,P=Z==null?void 0:Z.url;f&&(yield e.syncAllViewPointCloudColor(f));const x={[y.Side]:()=>{Bt(r,p,i,P)},[y.Back]:()=>{d&&wt(r,p,d,P)},[y.Top]:()=>{at(r,p,t,o)}};Object.keys(x).forEach(C=>{C!==s&&x[C]()}),l&&(o==null||o.updateCameraZoom(l)),Vt(r)});return{topViewAddSphere:kt,topViewAddBox:Rt,topViewSelectedChanged:Ut,topViewUpdatePoint:Et,sideViewUpdatePoint:zt,backViewUpdatePoint:Tt,topViewUpdateBox:Ft,sideViewUpdateBox:jt,backViewUpdateBox:Nt,pointCloudBoxListUpdated:n=>{t.updatePolygonList(n),o==null||o.generateBoxes(n)},initPointCloud3d:n=>{if(!o)return;const s=V.getDefaultOrthographicParams(n);o.initOrthographicCamera(s),o.initRenderer(),o.render()},updatePointCloudData:(...n)=>rt(void 0,[...n],function*(s=Z){var p,r,l,f,P,x;if(!(s==null?void 0:s.url)||!o)return;W([]),Ct(H,!0),Pt(H,!0),yield o.loadPCDFile(s.url,(p=S==null?void 0:S.radius)!=null?p:K),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let C=[],D=[],w=[],b=[];o.updateTopCamera();const A=(l=(r=it(s.result))==null?void 0:r.valid)!=null?l:!0;if(e.setPointCloudValid(A),(f=e.sideViewInstance)==null||f.clearAllData(),(P=e.backViewInstance)==null||P.clearAllData(),s.result){if(C=V.getBoxParamsFromResultList(s.result),(C==null?void 0:C.length)>0&&s.isPreResult&&(S==null?void 0:S.lowerLimitPointsNumInBox)>0){C=yield o==null?void 0:o.filterPreResult(s.url,S,C);const U=it(s.result);U[Gt].result=C,s.result=JSON.stringify(U),e.setPointCloudResult(C)}w=V.getPolygonListFromResultList(s.result),D=V.getLineListFromResultList(s.result),b=V.getSphereParamsFromResultList(s.result),t.updateData(s.url,s.result,{radius:(x=S==null?void 0:S.radius)!=null?x:K}),o==null||o.generateBoxes(C),o==null||o.generateSpheres(b),yield e.syncAllViewPointCloudColor(C,[])}E({pointCloudBoxList:C,polygonList:w,lineList:D,pointCloudSphereList:b}),Ct(H,!1),Pt(H,!1)}),updateViewsByDefaultSize:Ht,generateRects:$,update2DViewRect:At}};export{bt as syncBackViewByPoint,vt as syncSideViewByPoint,It as syncTopViewByPoint,wt as synchronizeBackView,Bt as synchronizeSideView,at as synchronizeTopView,lt as topViewPoint2PointCloud,dt as topViewPolygon2PointCloud,go as usePointCloudViews};
1
+ import{EPointCloudName as it,TagUtils as Gt,MathUtils as w,getCuboidFromPointCloudBox as Jt}from"@labelbee/lb-annotation";import{EPerspectiveView as G,PointCloudUtils as V,POINT_CLOUD_DEFAULT_STEP as Qt,DEFAULT_SPHERE_PARAMS as Xt}from"@labelbee/lb-utils";import{useContext as Yt}from"react";import{PointCloudContext as qt}from"../PointCloudContext.js";import{useSingleBox as Kt}from"./useSingleBox.js";import{useSphere as $t}from"./useSphere.js";import{useSelector as to,useDispatch as oo}from"../../../store/ctx.js";import eo from"../../../utils/StepUtils.js";import{jsonParser as st,generatePointCloudBoxRects as no}from"../../../utils/index.js";import{PreDataProcess as rt,SetPointCloudLoading as Ct,SetLoadPCDFileLoading as Pt}from"../../../store/annotation/actionCreators.js";import{useHistory as io}from"./useHistory.js";import{usePolygon as so}from"./usePolygon.js";import{useLatest as ro}from"ahooks";var lo=Object.defineProperty,ao=Object.defineProperties,co=Object.getOwnPropertyDescriptors,mt=Object.getOwnPropertySymbols,uo=Object.prototype.hasOwnProperty,po=Object.prototype.propertyIsEnumerable,xt=(e,t,s)=>t in e?lo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,L=(e,t)=>{for(var s in t||(t={}))uo.call(t,s)&&xt(e,s,t[s]);if(mt)for(var s of mt(t))po.call(t,s)&&xt(e,s,t[s]);return e},O=(e,t)=>ao(e,co(t)),lt=(e,t,s)=>new Promise((a,o)=>{var c=p=>{try{u(s.next(p))}catch(m){o(m)}},g=p=>{try{u(s.throw(p))}catch(m){o(m)}},u=p=>p.done?a(p.value):Promise.resolve(p.value).then(c,g);u((s=s.apply(e,t)).next())});const q=5,K=90,ht=.01,y={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},dt=(e,t,s,a,o)=>{const{x:c,y:g}=V.transferCanvas2World(e,t),{defaultZ:u}=Xt,p={center:{x:c,y:g,z:u},id:e.id},m=a?L(L({},a),p):O(L({},p),{attribute:"",valid:!0});return o&&Object.assign(m,o),m},at=(e,t,s,a,o,c)=>{let g=e.pointList.map(b=>V.transferCanvas2World(b,t)),u=0,p=1,m={};if(s){const b=s.getSensesPointZAxisInPolygon(g,void 0,c);c&&b.fittedCoordinates.length>0&&(g=b.fittedCoordinates),u=(b.maxZ+b.minZ)/2,p=b.maxZ-b.minZ,m={count:b.zCount}}const[v,D,H]=g,A=w.getLineCenterPoint([v,H]),k=w.getLineLength(v,D),R=w.getLineLength(D,H),j=w.getRadiusFromQuadrangle(e.pointList);a&&(u=a.center.z,p=a.depth);const U={center:{x:A.x,y:A.y,z:u},width:c?R+ht:R,height:c?k+ht:k,depth:p,rotation:j,id:e.id},T=L(a?L(L({},a),U):O(L({},U),{attribute:"",valid:!0}),m);o&&Object.assign(T,o);const N=g.map(b=>V.transferWorld2Canvas(b,t));return{boxParams:T,newPointList:N}},vt=(e,t,s)=>{const a={x:e.x-t.x,y:e.y-t.y};return O(L({},s),{center:{x:s.center.x-a.x,y:s.center.y,z:s.center.z-a.y}})},Lt=(e,t,s,a)=>{const[o,c,g]=e.pointList,[u,p,m]=t.pointList,v=w.getLineCenterPoint([o,g]),D=w.getLineCenterPoint([u,m]),A={x:{x:v.x-D.x,y:v.y-D.y}.x,y:0,z:v.y-D.y},k=w.getLineLength(o,c),R=w.getLineLength(u,p),j=k-R,U=w.getLineLength(c,g),T=w.getLineLength(p,m),N=U-T,{newBoxParams:b}=a.getNewBoxBySideUpdate(A,N,j,s);return b},go=(e,t,s)=>{const a={x:e.x-t.x,y:e.y-t.y};return O(L({},s),{center:{x:s.center.x,y:s.center.y-a.x,z:s.center.z-a.y}})},fo=(e,t,s,a)=>{const[o,c,g]=e.pointList,[u,p,m]=t.pointList,v=w.getLineCenterPoint([o,g]),D=w.getLineCenterPoint([u,m]),A={x:{x:v.x-D.x,y:v.y-D.y}.x,y:0,z:v.y-D.y},k=w.getLineLength(o,c),R=w.getLineLength(u,p),j=k-R,U=w.getLineLength(c,g),T=w.getLineLength(p,m),N=U-T;let{newBoxParams:b}=a.getNewBoxByBackUpdate(A,N,j,s);return b},yt=(e,t,s,a,o)=>{var c;if(!s)return;const{toolInstance:g,pointCloudInstance:u}=s;u.loadPCDFile(a,(c=o==null?void 0:o.radius)!=null?c:K);const{cameraPositionVector:p}=u.updateOrthoCameraBySphere(e,G.Left);u.setInitCameraPosition(p);const{point2d:m,zoom:v}=u.getSphereSidePoint2DCoordinate(e);u.camera.zoom=v,u.camera.updateProjectionMatrix(),u.render(),g.initPosition(),g.zoomChangeOnCenter(v),g.setResult([O(L(L({},t),m),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},Bt=(e,t,s,a)=>{if(!s)return;const{pointCloud2dOperation:o,pointCloudInstance:c}=s;c.loadPCDFileByBox(a,e,{width:q,depth:q});const{cameraPositionVector:g}=c.updateOrthoCamera(e,G.Left);c.setInitCameraPosition(g);const{polygon2d:u,zoom:p}=c.getBoxSidePolygon2DCoordinate(e);c.camera.zoom=p,c.camera.updateProjectionMatrix(),c.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},bt=(e,t,s,a,o)=>{var c;if(!s)return;const{toolInstance:g,pointCloudInstance:u}=s;u.loadPCDFile(a,(c=o==null?void 0:o.radius)!=null?c:K);const{cameraPositionVector:p}=u.updateOrthoCameraBySphere(e,G.Back);u.setInitCameraPosition(p);const{point2d:m,zoom:v}=u.getSphereBackPoint2DCoordinate(e);u.camera.zoom=v,u.camera.updateProjectionMatrix(),u.render(),g.initPosition(),g.zoomChangeOnCenter(v),g.setResult([O(L(L({},t),m),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},wt=(e,t,s,a)=>{if(!s)return;const{pointCloud2dOperation:o,pointCloudInstance:c}=s;c.loadPCDFileByBox(a,e,{height:q,depth:q});const{cameraPositionVector:g}=c.updateOrthoCamera(e,G.Back);c.setInitCameraPosition(g);const{polygon2d:u,zoom:p}=c.getBoxBackPolygon2DCoordinate(e);c.camera.zoom=p,c.camera.updateProjectionMatrix(),c.render(),o.initPosition(),o.zoomChangeOnCenter(p),o.setResultAndSelectedID([{id:t.id,valid:e.valid,pointList:u,textAttribute:"",isRect:!0,attribute:e.attribute}],t.id)},It=(e,t,s,a)=>{if(!s||!a)return;a.generateSphere(e),a.updateCameraBySphere(e,G.Top),a.render();const{toolInstance:o,pointCloudInstance:c}=s,{point2d:g}=c.getSphereTopPoint2DCoordinate(e),u=[...o.pointList].map(p=>p.id===t.id?O(L(L({},t),g),{valid:e.valid,textAttribute:"",attribute:e.attribute}):p);o.setResult(u),o.setSelectedID(t.id)},ct=(e,t,s,a)=>{var o,c;if(!s||!a)return;a.generateBox(e,t.id),a.render();const{pointCloud2dOperation:g,pointCloudInstance:u}=s,{polygon2d:p}=u.getBoxTopPolygon2DCoordinate(e),m=[...g.polygonList],v=m.find(D=>D.id===t.id);v?(v.pointList=p,v.valid=(o=e.valid)!=null?o:!0):m.push({id:t.id,pointList:p,textAttribute:"",isRect:!0,valid:(c=e.valid)!=null?c:!0}),g.setResultAndSelectedID(m,t.id)},Co=()=>{const e=Yt(qt),{topViewInstance:t,sideViewInstance:s,backViewInstance:a,mainViewInstance:o,addPointCloudBox:c,addPointCloudSphere:g,setSelectedIDs:u,selectedIDs:p,pointCloudBoxList:m,pointCloudSphereList:v,hideAttributes:D,setHighlight2DDataList:H,cuboidBoxIn2DView:A,imageSizes:k}=e,{addHistory:R,initHistory:j,pushHistoryUnderUpdatePolygon:U}=io(),{selectedPolygon:T}=so(),{getPointCloudSphereByID:N,updatePointCloudSphere:b,selectedSphere:J}=$t(),{currentData:W,config:B}=to(i=>{const{stepList:n,step:d,imgList:r,imgIndex:l}=i.annotation;return{currentData:r[l],config:st(eo.getCurrentStepInfo(d,n).config)}}),E=oo(),Dt=ro(A),$=i=>{const{enableAutoMap2DRect:n=!1}=B;if(!Dt.current||n){const{mappingImgList:d=[]}=W;no({pointCloudBox:i,mappingImgList:d,imageSizes:k})}},{selectedBox:_,updateSelectedBox:St,updateSelectedBoxes:tt,getPointCloudByID:_t}=Kt({generateRects:$}),ut=_==null?void 0:_.info;if(!t||!s||!a)return{topViewAddSphere:()=>{},topViewAddBox:()=>{},topViewSelectedChanged:()=>{},sideViewUpdateBox:()=>{},backViewUpdateBox:()=>{}};const{pointCloudInstance:ot}=t,Vt=i=>{o==null||o.generateBox(i),o==null||o.controls.update(),o==null||o.render()},Ot=i=>{o==null||o.generateSphere(i),o==null||o.controls.update(),o==null||o.render()},Rt=({newPoint:i,size:n,zoom:d,trackConfigurable:r})=>{var l;const f={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};r===!0&&Object.assign(f,{trackID:V.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:v})});const P=dt(i,n,ot,void 0,f);u(i.id);const C=g(P);Q(y.Top,i,P,d,C,B),R({newSphereParams:P})},At=({polygon:i,size:n,imgList:d,trackConfigurable:r,zoom:l,intelligentFit:f})=>{var P,C,x;const S={attribute:(P=t.toolInstance.defaultAttribute)!=null?P:""};r===!0&&Object.assign(S,{trackID:V.getNextTrackID({imgList:[],extraBoxList:m,extraSphereList:v})});const F=t==null?void 0:t.toolInstance,I=L({},i);let{boxParams:h,newPointList:z}=at(I,n,ot,void 0,S,f);h=E(rt({tool:it.PointCloud,dataList:[h],stepConfig:B,action:"viewUpdateBox"}))[0],f&&(z==null?void 0:z.length)&&(I.pointList=z);const nt=D.includes(I.attribute);$(h);const M=c(h),X=(C=e==null?void 0:e.polygonList)!=null?C:[];h.subAttribute=Gt.getDefaultResultByConfig((B==null?void 0:B.secondaryAttributeConfigurable)?(x=B==null?void 0:B.inputList)!=null?x:[]:[]),t==null||t.updatePolygonList(M!=null?M:[],X),nt?u([]):(u(h.id),F.selection.setSelectedIDs(I.id),Z({omitView:y.Top,polygon:I,boxParams:h,zoom:l,newPointCloudBoxList:M}),f&&ct(h,I,t,o)),R({newBoxParams:h})},kt=i=>{const{boxID:n,imageName:d,width:r,height:l,x:f,y:P}=i,C=m.find(h=>h.id===n);if(!(C==null?void 0:C.rects)||!C.rects.find(h=>h.imageName===d))return;const S=C.rects.map(h=>h.imageName===d?O(L({},h),{width:r,height:l,x:f,y:P}):h),F=O(L({},C),{rects:S}),I=m.map(h=>h.id===n?F:h);return t==null||t.updatePolygonList(I!=null?I:[]),I},Ut=i=>{const{boxID:n,imageName:d}=i,r=m.find(C=>C.id===n);if(!(r==null?void 0:r.rects))return;const l=r.rects.filter(C=>C.imageName!==d),f=O(L({},r),{rects:l}),P=m.map(C=>C.id===n?f:C);return t==null||t.updatePolygonList(P!=null?P:[]),P},Tt=({newSelectedBox:i,newPointCloudList:n,newSelectedSphere:d,newSphereList:r})=>{var l;const f=t==null?void 0:t.toolInstance;if(!(p.length===0||!f)){if(i||(_==null?void 0:_.info)){const P=i!=null?i:_==null?void 0:_.info;(l=f==null?void 0:f.selection)==null||l.setSelectedIDs(p[0]);const C=f.selectedPolygon;if(p.length===1&&P){Z({omitView:y.Top,polygon:C,boxParams:P,newPointCloudBoxList:n});return}}if((d||J)&&p.length===1){const P=d!=null?d:J;f.setSelectedID(p[0]);const C=f.selectedPoint;P&&Q(y.Top,C,P,void 0,r,B)}}},pt=(i,n,d)=>{if(ut){let r,l;switch(d){case y.Back:r=fo;break;case y.Side:r=Lt;break;default:r=Lt;break}if(l=r(i,n,ut,s.pointCloudInstance),o){const{count:S}=o.getSensesPointZAxisInPolygon(Jt(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=O(L({},l),{count:S})}const P=E(rt({tool:it.PointCloud,dataList:[l],stepConfig:B,action:"viewUpdateBox"}))[0],C=l.valid!==P.valid;l=P;const x=St(l);return l=x.find(S=>S.id===l.id),Z({omitView:C?void 0:d,polygon:i,boxParams:l,newPointCloudBoxList:x}),x}},gt=(i,n,d)=>{if(J){let r,l;switch(d){case y.Back:r=go;break;case y.Side:r=vt;break;default:r=vt;break}l=r(i,n,J);const f=b(l);return Q(d,i,l,void 0,f,B),f}},zt=(i,n)=>{gt(i,n,y.Side)},jt=(i,n)=>{gt(i,n,y.Back)},Nt=(i,n)=>{pt(i,n,y.Side)},Et=(i,n)=>{pt(i,n,y.Back)},Ft=(i,n)=>{const d=N(i.id),r=dt(i,n,ot,d),l=b(r);Q(y.Top,i,r,void 0,l,B)},Ht=(i,n)=>{if(T){const r=L({},i[0].newPolygon);r.pointList=r.pointList.map(l=>V.transferCanvas2World(l,n)),U(r);return}let d=i.map(({newPolygon:r})=>{const l=_t(r.id),{boxParams:f}=at(r,n,t.pointCloudInstance,l);return f});if(d=E(rt({tool:it.PointCloud,dataList:d,stepConfig:B,action:"viewUpdateBox"})),d.length===1){const{newPolygon:r}=i[0],l=tt(d);Z({polygon:r,boxParams:d[0],newPointCloudBoxList:l})}else{const r=tt(d);r&&e.syncAllViewPointCloudColor(r)}},Wt=i=>{var n,d,r,l,f;if(_){const P=Number(i.widthDefault),C=Number(i.depthDefault),x=Number(i.heightDefault),S=_==null?void 0:_.info.trackID,I=((n=t==null?void 0:t.toolInstance)==null?void 0:n.polygonList).find(Y=>(Y==null?void 0:Y.trackID)===S),h={width:(r=(d=t==null?void 0:t.toolInstance)==null?void 0:d.basicImgInfo)==null?void 0:r.width,height:(f=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:f.height},z=I.pointList.map(Y=>V.transferCanvas2World(Y,h)),et=w.getModifiedRectangleCoordinates(z,x,P),nt=et[0],M=et[2],X=w.getLineCenterPoint([nt,M]),Zt=_.info.center.z-_.info.depth/2,ft=O(L({},_.info),{center:{x:X.x,y:X.y,z:Zt+C/2},width:P,height:x,depth:C,valid:!0}),Mt=tt([ft]);Z({omitView:y["3D"],polygon:I,boxParams:ft,newPointCloudBoxList:Mt})}},Q=(i,n,d,r,l,f)=>lt(void 0,null,function*(){const P=W==null?void 0:W.url,C={[y.Side]:()=>{yt(d,n,s,P,f)},[y.Back]:()=>{a&&bt(d,n,a,P,f)},[y.Top]:()=>{It(d,n,t,o)}};Object.keys(C).forEach(x=>{x!==i&&C[x]()}),r&&(o==null||o.updateCameraZoom(r)),Ot(d)}),Z=i=>lt(void 0,null,function*(){const{omitView:n,polygon:d,boxParams:r,zoom:l,newPointCloudBoxList:f}=i,P=W==null?void 0:W.url;f&&(yield e.syncAllViewPointCloudColor(f));const C={[y.Side]:()=>{Bt(r,d,s,P)},[y.Back]:()=>{a&&wt(r,d,a,P)},[y.Top]:()=>{ct(r,d,t,o)}};Object.keys(C).forEach(x=>{x!==n&&C[x]()}),l&&(o==null||o.updateCameraZoom(l)),Vt(r)});return{topViewAddSphere:Rt,topViewAddBox:At,topViewSelectedChanged:Tt,topViewUpdatePoint:Ft,sideViewUpdatePoint:zt,backViewUpdatePoint:jt,topViewUpdateBox:Ht,sideViewUpdateBox:Nt,backViewUpdateBox:Et,pointCloudBoxListUpdated:i=>{t.updatePolygonList(i),o==null||o.generateBoxes(i)},initPointCloud3d:i=>{if(!o)return;const n=V.getDefaultOrthographicParams(i);o.initOrthographicCamera(n),o.initRenderer(),o.render()},updatePointCloudData:(...i)=>lt(void 0,[...i],function*(n=W){var d,r,l,f,P,C;if(!(n==null?void 0:n.url)||!o)return;H([]),Ct(E,!0),Pt(E,!0),yield o.loadPCDFile(n.url,(d=B==null?void 0:B.radius)!=null?d:K),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let x=[],S=[],F=[],I=[];o.updateTopCamera();const h=(l=(r=st(n.result))==null?void 0:r.valid)!=null?l:!0;if(e.setPointCloudValid(h),(f=e.sideViewInstance)==null||f.clearAllData(),(P=e.backViewInstance)==null||P.clearAllData(),n.result){if(x=V.getBoxParamsFromResultList(n.result),(x==null?void 0:x.length)>0&&n.isPreResult&&(B==null?void 0:B.lowerLimitPointsNumInBox)>0){x=yield o==null?void 0:o.filterPreResult(n.url,B,x);const z=st(n.result);z[Qt].result=x,n.result=JSON.stringify(z),e.setPointCloudResult(x)}F=V.getPolygonListFromResultList(n.result),S=V.getLineListFromResultList(n.result),I=V.getSphereParamsFromResultList(n.result),t.updateData(n.url,n.result,{radius:(C=B==null?void 0:B.radius)!=null?C:K}),o==null||o.generateBoxes(x),o==null||o.generateSpheres(I),yield e.syncAllViewPointCloudColor(x,[])}j({pointCloudBoxList:x,polygonList:F,lineList:S,pointCloudSphereList:I}),Ct(E,!1),Pt(E,!1)}),updateViewsByDefaultSize:Wt,generateRects:$,update2DViewRect:kt,remove2DViewRect:Ut}};export{bt as syncBackViewByPoint,yt as syncSideViewByPoint,It as syncTopViewByPoint,wt as synchronizeBackView,Bt as synchronizeSideView,ct as synchronizeTopView,dt as topViewPoint2PointCloud,at as topViewPolygon2PointCloud,Co as usePointCloudViews};
@@ -1 +1 @@
1
- import{useContext as S,useMemo as P}from"react";import{PointCloudContext as I}from"../PointCloudContext.js";import{cTool as E}from"@labelbee/lb-annotation";import{useHistory as x}from"./useHistory.js";import{EPointCloudPattern as C}from"@labelbee/lb-utils";const{EToolName:t,EPolygonPattern:p}=E,A=()=>{const{topViewInstance:r,sideViewInstance:a,backViewInstance:u,mainViewInstance:e,setPointCloudResult:v,setPointCloudSphereList:h,setPolygonList:m,pointCloudPattern:c,setPointCloudPattern:n,syncAllViewPointCloudColor:b,globalPattern:l,setLineList:w}=S(I),{pushHistoryWithList:y}=x(),L=()=>{e==null||e.clearAllBox(),e==null||e.clearAllSphere(),e==null||e.render(),v([]),m([]),h([]),w([]),r==null||r.toolScheduler.clearStatusAndResult(),b([]),y({pointCloudBoxList:[],polygonList:[],pointCloudSphereList:[]})},i=()=>{a==null||a.toolInstance.clearResult(),u==null||u.toolInstance.clearResult()},f=d=>{if(d===c)return;const s=[r,a,u];switch(d){case t.Rect:i(),s.forEach(o=>{o==null||o.switchToCanvas(t.PointCloudPolygon),o==null||o.toolInstance.setPattern(p.Rect)}),n(t.Rect);break;case t.Polygon:i(),s.forEach(o=>{o==null||o.switchToCanvas(t.PointCloudPolygon),o==null||o.toolInstance.setPattern(p.Normal)}),n(t.Polygon);break;case t.Point:i(),s.forEach(o=>{o==null||o.switchToCanvas(t.Point)}),n(t.Point);break;case t.Line:i(),s.forEach(o=>{o==null||o.switchToCanvas(t.Line)}),n(t.Line);break}},g=P(()=>l===C.Detection,[l]),R=P(()=>l===C.Segmentation,[l]);return{clearAllResult:L,updatePointCloudPattern:f,pointCloudPattern:c,isPointCloudDetectionPattern:g,isPointCloudSegmentationPattern:R}};export{A as useStatus};
1
+ import{useContext as I,useMemo as P}from"react";import{PointCloudContext as E}from"../PointCloudContext.js";import{cTool as x}from"@labelbee/lb-annotation";import{useHistory as A}from"./useHistory.js";import{EPointCloudPattern as C}from"@labelbee/lb-utils";const{EToolName:o,EPolygonPattern:p}=x,T=()=>{const{topViewInstance:r,sideViewInstance:a,backViewInstance:u,mainViewInstance:e,setPointCloudResult:v,setPointCloudSphereList:h,setPolygonList:m,setRectList:b,pointCloudPattern:c,setPointCloudPattern:n,syncAllViewPointCloudColor:L,globalPattern:l,setLineList:w}=I(E),{pushHistoryWithList:y}=A(),f=()=>{e==null||e.clearAllBox(),e==null||e.clearAllSphere(),e==null||e.render(),v([]),m([]),h([]),w([]),b([]),r==null||r.toolScheduler.clearStatusAndResult(),L([]),y({pointCloudBoxList:[],polygonList:[],pointCloudSphereList:[]})},i=()=>{a==null||a.toolInstance.clearResult(),u==null||u.toolInstance.clearResult()},g=d=>{if(d===c)return;const s=[r,a,u];switch(d){case o.Rect:i(),s.forEach(t=>{t==null||t.switchToCanvas(o.PointCloudPolygon),t==null||t.toolInstance.setPattern(p.Rect)}),n(o.Rect);break;case o.Polygon:i(),s.forEach(t=>{t==null||t.switchToCanvas(o.PointCloudPolygon),t==null||t.toolInstance.setPattern(p.Normal)}),n(o.Polygon);break;case o.Point:i(),s.forEach(t=>{t==null||t.switchToCanvas(o.Point)}),n(o.Point);break;case o.Line:i(),s.forEach(t=>{t==null||t.switchToCanvas(o.Line)}),n(o.Line);break}},R=P(()=>l===C.Detection,[l]),S=P(()=>l===C.Segmentation,[l]);return{clearAllResult:f,updatePointCloudPattern:g,pointCloudPattern:c,isPointCloudDetectionPattern:R,isPointCloudSegmentationPattern:S}};export{T as useStatus};