@labelbee/lb-components 1.23.0-alpha.21 → 1.23.0-alpha.23

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 (33) hide show
  1. package/dist/components/audioAnnotate/audioContext/index.js +1 -1
  2. package/dist/components/audioAnnotate/audioSide/clipSidebar/index.js +1 -1
  3. package/dist/components/audioAnnotate/index.js +1 -1
  4. package/dist/components/audioAnnotate/textInput/index.js +1 -1
  5. package/dist/components/audioPlayer/clipRegion/index.js +1 -1
  6. package/dist/components/audioPlayer/index.js +1 -1
  7. package/dist/components/pointCloud2DRectOperationView/index.js +1 -1
  8. package/dist/components/pointCloudView/PointCloud3DView.js +1 -1
  9. package/dist/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
  10. package/dist/store/annotation/reducer.js +1 -1
  11. package/dist/types/components/audioAnnotate/audioContext/index.d.ts +9 -1
  12. package/dist/types/components/audioAnnotate/textInput/index.d.ts +1 -0
  13. package/dist/types/components/audioPlayer/index.d.ts +3 -2
  14. package/dist/types/components/pointCloudView/hooks/usePointCloudViews.d.ts +5 -0
  15. package/dist/types/components/videoAnnotate/index.d.ts +1 -1
  16. package/dist/types/utils/AnnotationDataUtils.d.ts +54 -1
  17. package/dist/types/views/MainView/sidebar/TextToolSidebar/index.d.ts +1 -1
  18. package/dist/types/views/MainView/toolFooter/index.d.ts +1 -1
  19. package/dist/types/views/MainView/toolHeader/StepSwitch/index.d.ts +1 -1
  20. package/dist/types/views/MainView/toolHeader/index.d.ts +1 -1
  21. package/dist/utils/AnnotationDataUtils.js +1 -1
  22. package/es/components/audioAnnotate/audioContext/index.js +1 -1
  23. package/es/components/audioAnnotate/audioSide/clipSidebar/index.js +1 -1
  24. package/es/components/audioAnnotate/index.js +1 -1
  25. package/es/components/audioAnnotate/textInput/index.js +1 -1
  26. package/es/components/audioPlayer/clipRegion/index.js +1 -1
  27. package/es/components/audioPlayer/index.js +1 -1
  28. package/es/components/pointCloud2DRectOperationView/index.js +1 -1
  29. package/es/components/pointCloudView/PointCloud3DView.js +1 -1
  30. package/es/components/pointCloudView/hooks/usePointCloudViews.js +1 -1
  31. package/es/store/annotation/reducer.js +1 -1
  32. package/es/utils/AnnotationDataUtils.js +1 -1
  33. package/package.json +3 -3
@@ -24,5 +24,5 @@ export interface IVideoAnnotateProps {
24
24
  }
25
25
  declare const _default: import("react-redux").ConnectedComponent<React.FC<IVideoAnnotateProps>, import("react-redux").Omit<IVideoAnnotateProps & {
26
26
  children?: React.ReactNode;
27
- }, "stepList" | "step" | "imgIndex" | "imgList" | "config" | "skipBeforePageTurning" | "loading" | "path" | "stepInfo">>;
27
+ }, "step" | "stepList" | "imgIndex" | "imgList" | "config" | "skipBeforePageTurning" | "loading" | "path" | "stepInfo">>;
28
28
  export default _default;
@@ -1,5 +1,57 @@
1
1
  import { IStepInfo } from '@/types/step';
2
+ import { IMappingImg } from '@/types/data';
3
+ interface ICopyResultChangeParams {
4
+ copyResult: string;
5
+ step: number;
6
+ currentResult: string;
7
+ mappingImgList: IMappingImg[];
8
+ preMappingImgList: IMappingImg[];
9
+ }
10
+ interface IGetNextPath {
11
+ prePath: string;
12
+ preMappingImgList: IMappingImg[];
13
+ nextMappingImgList: IMappingImg[];
14
+ }
15
+ interface ICopyResultItemHandlerParams {
16
+ item: any;
17
+ key?: string | number;
18
+ parent: any;
19
+ mappingImgList: IMappingImg[];
20
+ preMappingImgList: IMappingImg[];
21
+ }
2
22
  export default class AnnotationDataUtils {
23
+ /**
24
+ * Performs a depth-first traversal of an object or array, executing a callback function on each element.
25
+ *
26
+ * @param {any} objOrArr - The object or array to be traversed.
27
+ * @param {Function} callback - The callback function to be executed on each element.
28
+ * The callback function takes three parameters: element, key, and parent.
29
+ * @param {string | number} [key] - The key or index of the current element in its parent (optional).
30
+ * @param {any} [parent] - The parent of the current element (optional).
31
+ */
32
+ static traverseDF(objOrArr: any, callback: (element: any, key?: string | number, parent?: any) => void, key?: string | number, parent?: any): void;
33
+ /**
34
+ * Calculates the next path based on the provided parameters.
35
+ *
36
+ * @param {IGetNextPath} params - The object containing necessary information.
37
+ * @param {string} params.prePath - The current path.
38
+ * @param {IImgList} params.preMappingImgList - The list of current mapping images.
39
+ * @param {IImgList} params.nextMappingImgList - The list of next mapping images.
40
+ * @returns {string} The next path, returns an empty string if not found.
41
+ */
42
+ static getNextPath(params: IGetNextPath): string;
43
+ /**
44
+ * Handles the processing of individual items during the traversal of results or resultRect.
45
+ * This function updates specific properties of the parent object based on the key of the current item.
46
+ *
47
+ * @param {ICopyResultItemHandlerParams} params - Parameters containing the current item, its key, parent object, and image lists.
48
+ * @param {ICopyResultItemHandlerParams.item} item - The current item being processed.
49
+ * @param {ICopyResultItemHandlerParams.key} key - The key associated with the current item.
50
+ * @param {ICopyResultItemHandlerParams.parent} parent - The parent object of the current item.
51
+ * @param {ICopyResultItemHandlerParams.mappingImgList} mappingImgList - The list of images for mapping.
52
+ * @param {ICopyResultItemHandlerParams.preMappingImgList} preMappingImgList - The list of images before mapping.
53
+ */
54
+ static copyResultItemHandler(params: ICopyResultItemHandlerParams): void;
3
55
  /**
4
56
  * 复制上一张图片结果
5
57
  * @param copyResult 复制的结果
@@ -7,7 +59,7 @@ export default class AnnotationDataUtils {
7
59
  * @param currentResult 当前的步骤
8
60
  * @returns
9
61
  */
10
- static copyResultChange(copyResult: string, step: number, currentResult: string): string;
62
+ static copyResultChange(params: ICopyResultChangeParams): string;
11
63
  /**
12
64
  * 判断结果sourceID与依赖数据的id是否能对应
13
65
  * @param result
@@ -75,3 +127,4 @@ export default class AnnotationDataUtils {
75
127
  */
76
128
  static deleteRes(resData: any, dataSourceStep: number, deletedIds: string[], stepKeys: number[]): void;
77
129
  }
130
+ export {};
@@ -20,5 +20,5 @@ interface IProps {
20
20
  export declare const SingleTextInput: (props: any) => React.JSX.Element;
21
21
  declare const _default: import("react-redux").ConnectedComponent<React.FC<IProps>, import("react-redux").Omit<IProps & {
22
22
  children?: React.ReactNode;
23
- }, "stepList" | "step" | "imgIndex" | "basicResultList" | "toolInstance" | "triggerEventAfterIndexChanged" | "dispatch">>;
23
+ }, "step" | "stepList" | "imgIndex" | "basicResultList" | "toolInstance" | "triggerEventAfterIndexChanged" | "dispatch">>;
24
24
  export default _default;
@@ -20,5 +20,5 @@ export declare const footerCls: string;
20
20
  export declare const FooterDivider: () => React.JSX.Element;
21
21
  declare const _default: import("react-redux").ConnectedComponent<React.FC<IProps>, import("react-redux").Omit<IProps & {
22
22
  children?: React.ReactNode;
23
- }, "stepList" | "step" | "imgIndex" | "basicResultList" | "basicIndex" | "skipBeforePageTurning" | "totalPage">>;
23
+ }, "step" | "stepList" | "imgIndex" | "basicResultList" | "basicIndex" | "skipBeforePageTurning" | "totalPage">>;
24
24
  export default _default;
@@ -10,5 +10,5 @@ interface IProps {
10
10
  }
11
11
  declare const _default: import("react-redux").ConnectedComponent<React.FC<IProps>, import("react-redux").Omit<IProps & {
12
12
  children?: React.ReactNode;
13
- }, "stepList" | "step">>;
13
+ }, "step" | "stepList">>;
14
14
  export default _default;
@@ -22,5 +22,5 @@ interface IToolHeaderProps {
22
22
  }
23
23
  declare const _default: import("react-redux").ConnectedComponent<React.FC<IToolHeaderProps>, import("react-redux").Omit<IToolHeaderProps & {
24
24
  children?: React.ReactNode;
25
- }, "stepList" | "step" | "imgList" | "annotationEngine" | "toolName" | "stepInfo" | "stepProgress">>;
25
+ }, "step" | "stepList" | "imgList" | "annotationEngine" | "toolName" | "stepInfo" | "stepProgress">>;
26
26
  export default _default;
@@ -1 +1 @@
1
- "use strict";var lbAnnotation=require("@labelbee/lb-annotation"),index=require("./index.js"),ToolType=require("../data/enums/ToolType.js"),_=require("lodash"),StepUtils=require("./StepUtils.js");function _interopDefaultLegacy(i){return i&&typeof i=="object"&&"default"in i?i:{default:i}}var ___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(i,e,t)=>e in i?__defProp(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,__spreadValues=(i,e)=>{for(var t in e||(e={}))__hasOwnProp.call(e,t)&&__defNormalProp(i,t,e[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(e))__propIsEnum.call(e,t)&&__defNormalProp(i,t,e[t]);return i},__spreadProps=(i,e)=>__defProps(i,__getOwnPropDescs(e));class AnnotationDataUtils{static copyResultChange(e,t,r){try{const s=index.jsonParser(e),n=index.jsonParser(r),o=`step_${t}`;if(s[o]){const a=s[o];if(a.result)return a.result=a.result.map(u=>__spreadProps(__spreadValues({},u),{id:lbAnnotation.uuid(8,62)})),n[o]=a,JSON.stringify(n)}return e}catch(s){return e}}static isResultSourceMatchedDependence(e,t){const r=e==null?void 0:e.map(n=>n.sourceID).sort(),s=t==null?void 0:t.map(n=>n.id).sort();return ___default.default.isEqual(r,s)}static deltaUpdateBasicResultList(e,t){const r=e==null?void 0:e.map(s=>s.sourceID).sort();return t.filter(s=>!r.includes(s.id))}static getInitialResultList(e,t,r,s,n){const o=e!=null?e:[];switch(r.tool){case ToolType.EToolName.Tag:case ToolType.EToolName.Text:{if(r.dataSourceStep>0){const a=this.deltaUpdateBasicResultList(o,s);if(a.length>0)return o.concat(t.getInitResultList(r.dataSourceStep,a))}return n!==!0?o:t.getInitResultList(r.dataSourceStep,s)}default:return o}}static dataCorrection(e,t,r,s){var n,o;try{const u=`step_${StepUtils.getStepInfo(r,s).step}`,l=index.jsonParser(e),f=index.jsonParser(t),d=(n=l[u])==null?void 0:n.result,c=(o=f[u])==null?void 0:o.result;if(!c||___default.default.isEqual(d.sort(this.idCmp),c.sort(this.idCmp)))return e;const p=this.findDeletedIds(d,c);if(p.length===0)return e;const m=r,h=this.getStepKeys(l).sort();return this.deleteRes(l,m,p,h),JSON.stringify(l)}catch(a){return console.error(a),e}}static idCmp(e,t){const r=e.id,s=t.id;return r<s?-1:r>s?1:0}static findDeletedIds(e,t){return this.findDeletedItems(t,e).map(r=>r.id)}static findDeletedItems(e,t){const r=[];return e.forEach(s=>{t.some(o=>o.id===s.id)||r.push(s)}),r}static getStepKeys(e){return Object.keys(e).map(t=>parseInt(t.replace("step_",""),10)).filter(t=>!isNaN(t))}static deleteRes(e,t,r,s){s.forEach(n=>{if(n>t){const o=e[`step_${n}`];if([ToolType.EToolName.FolderTag,ToolType.EToolName.Segmentation].includes(o.tool))return;if(o.dataSourceStep===t){const a=[];o.result=o.result.filter(u=>r.includes(u.sourceID)?(a.push(u.id),!1):!0),this.deleteRes(e,n,a,s)}else o.result=o.result.filter(a=>!r.includes(a.sourceID))}})}}module.exports=AnnotationDataUtils;
1
+ "use strict";var lbAnnotation=require("@labelbee/lb-annotation"),index=require("./index.js"),ToolType=require("../data/enums/ToolType.js"),_=require("lodash"),StepUtils=require("./StepUtils.js");function _interopDefaultLegacy(c){return c&&typeof c=="object"&&"default"in c?c:{default:c}}var ___default=_interopDefaultLegacy(_);class AnnotationDataUtils{static traverseDF(t,e,s,i){e(t,s,i),typeof t=="object"&&t!==null&&(Array.isArray(t)?t.forEach((n,r)=>{this.traverseDF(n,e,r,t)}):Object.keys(t).forEach(n=>{this.traverseDF(t[n],e,n,t)}))}static getNextPath(t){var e,s,i;const{prePath:n,preMappingImgList:r,nextMappingImgList:a}=t,u=(s=(e=r==null?void 0:r.find(l=>l.path===n))==null?void 0:e.calib)==null?void 0:s.calName,o=(i=a.find(l=>{var d;return((d=l.calib)==null?void 0:d.calName)===u}))==null?void 0:i.path;return o!=null?o:""}static copyResultItemHandler(t){const{item:e,key:s,parent:i,mappingImgList:n,preMappingImgList:r}=t;s==="id"&&(i.id=lbAnnotation.uuid(8,62)),s==="imageName"&&(i.imageName=this.getNextPath({prePath:e,preMappingImgList:r,nextMappingImgList:n}))}static copyResultChange(t){const{copyResult:e,step:s,currentResult:i,mappingImgList:n,preMappingImgList:r}=t;try{const a=index.jsonParser(e),u=index.jsonParser(i),o=`step_${s}`;if(a[o]){const l=a[o];return["result","resultRect"].forEach(p=>{l[p]&&this.traverseDF(l[p],(f,m,h)=>{this.copyResultItemHandler({item:f,key:m,parent:h,mappingImgList:n,preMappingImgList:r})})}),u[o]=l,JSON.stringify(u)}return e}catch(a){return e}}static isResultSourceMatchedDependence(t,e){const s=t==null?void 0:t.map(n=>n.sourceID).sort(),i=e==null?void 0:e.map(n=>n.id).sort();return ___default.default.isEqual(s,i)}static deltaUpdateBasicResultList(t,e){const s=t==null?void 0:t.map(i=>i.sourceID).sort();return e.filter(i=>!s.includes(i.id))}static getInitialResultList(t,e,s,i,n){const r=t!=null?t:[];switch(s.tool){case ToolType.EToolName.Tag:case ToolType.EToolName.Text:{if(s.dataSourceStep>0){const a=this.deltaUpdateBasicResultList(r,i);if(a.length>0)return r.concat(e.getInitResultList(s.dataSourceStep,a))}return n!==!0?r:e.getInitResultList(s.dataSourceStep,i)}default:return r}}static dataCorrection(t,e,s,i){var n,r;try{const u=`step_${StepUtils.getStepInfo(s,i).step}`,o=index.jsonParser(t),l=index.jsonParser(e),d=(n=o[u])==null?void 0:n.result,p=(r=l[u])==null?void 0:r.result;if(!p||___default.default.isEqual(d.sort(this.idCmp),p.sort(this.idCmp)))return t;const f=this.findDeletedIds(d,p);if(f.length===0)return t;const m=s,h=this.getStepKeys(o).sort();return this.deleteRes(o,m,f,h),JSON.stringify(o)}catch(a){return console.error(a),t}}static idCmp(t,e){const s=t.id,i=e.id;return s<i?-1:s>i?1:0}static findDeletedIds(t,e){return this.findDeletedItems(e,t).map(s=>s.id)}static findDeletedItems(t,e){const s=[];return t.forEach(i=>{e.some(r=>r.id===i.id)||s.push(i)}),s}static getStepKeys(t){return Object.keys(t).map(e=>parseInt(e.replace("step_",""),10)).filter(e=>!isNaN(e))}static deleteRes(t,e,s,i){i.forEach(n=>{if(n>e){const r=t[`step_${n}`];if([ToolType.EToolName.FolderTag,ToolType.EToolName.Segmentation].includes(r.tool))return;if(r.dataSourceStep===e){const a=[];r.result=r.result.filter(u=>s.includes(u.sourceID)?(a.push(u.id),!1):!0),this.deleteRes(t,n,a,i)}else r.result=r.result.filter(a=>!s.includes(a.sourceID))}})}}module.exports=AnnotationDataUtils;
@@ -1 +1 @@
1
- import{RightOutlined as C}from"@ant-design/icons";import t,{useMemo as p,useContext as b,useState as u,useEffect as A}from"react";import{Input as g}from"antd";import{useSetState as x}from"ahooks";import a from"./index.module.scss.js";var s;(function(o){o.before="\u524D\u6587",o.after="\u540E\u6587"})(s||(s={}));const v=o=>{const{audioContext:e}=o;if(!e||!e.visible)return null;const{content:i,type:n}=e;return t.createElement(E,{title:s==null?void 0:s[n],content:i})},E=o=>{const[e,i]=u(!0),[n,m]=u(""),{title:f,content:l}=o,r=()=>{i(!e)};return A(()=>{m(l),i(!0)},[l]),t.createElement("div",{className:a.audioContextContainer},t.createElement("div",{className:a.title},t.createElement(C,{style:{marginRight:8},rotate:e?90:0,onClick:r}),t.createElement("span",{onClick:r},f)),e&&t.createElement("div",{className:a.content},t.createElement(g.TextArea,{bordered:!1,value:n,disabled:!0,style:{padding:0},autoSize:!0})))},c={selectedAttribute:"",selectedRegion:{},attributeLockList:[],clipConfigurable:!1,clipAttributeConfigurable:!1,clipAttributeList:[],clipTextConfigurable:!1,combined:!1,segment:!1},d=t.createContext({audioClipState:c,setAudioClipState:()=>{}}),S=()=>b(d),y=({children:o})=>{const[e,i]=x(c),n=p(()=>({audioClipState:e,setAudioClipState:i}),[e,i]);return t.createElement(d.Provider,{value:n},o)};export{y as AudioClipProvider,s as EContextType,v as default,S as useAudioClipStore};
1
+ import{RightOutlined as p}from"@ant-design/icons";import t,{useMemo as b,useContext as x,useState as u,useEffect as A}from"react";import{Input as E}from"antd";import{useSetState as g}from"ahooks";import l from"./index.module.scss.js";var s;(function(o){o.before="\u524D\u6587",o.after="\u540E\u6587"})(s||(s={}));const c=[{label:"\u6587\u672C",key:"text",required:!1,default:"",maxLength:3e3}],v=o=>{const{audioContext:e}=o;if(!e||!e.visible)return null;const{content:i,type:n}=e;return t.createElement(S,{title:s==null?void 0:s[n],content:i})},S=o=>{const[e,i]=u(!0),[n,C]=u(""),{title:f,content:a}=o,r=()=>{i(!e)};return A(()=>{C(a),i(!0)},[a]),t.createElement("div",{className:l.audioContextContainer},t.createElement("div",{className:l.title},t.createElement(p,{style:{marginRight:8},rotate:e?90:0,onClick:r}),t.createElement("span",{onClick:r},f)),e&&t.createElement("div",{className:l.content},t.createElement(E.TextArea,{bordered:!1,value:n,disabled:!0,style:{padding:0},autoSize:!0})))},d={selectedAttribute:"",selectedRegion:{},attributeLockList:[],clipConfigurable:!1,clipAttributeConfigurable:!1,clipAttributeList:[],clipTextConfigurable:!1,combined:!1,segment:!1,clipTextList:c},m=t.createContext({audioClipState:d,setAudioClipState:()=>{}}),L=()=>x(m),T=({children:o})=>{const[e,i]=g(d),n=b(()=>({audioClipState:e,setAudioClipState:i}),[e,i]);return t.createElement(m.Provider,{value:n},o)};export{T as AudioClipProvider,c as DEFAULT_CLIP_TEXT_CONFIG_ITEM,s as EContextType,v as default,L as useAudioClipStore};
@@ -1 +1 @@
1
- import t,{useMemo as k}from"react";import F from"../../../attributeList/index.js";import{EventBus as A}from"@labelbee/lb-annotation";import I from"../../../../assets/annotation/audio/clipSmall.svg.js";import D from"../../../../assets/annotation/audio/clipASmall.svg.js";import B from"../../../../assets/annotation/audio/delete.svg.js";import V from"../../../../assets/annotation/audio/loopA.svg.js";import{getAttributeShowText as M,timeFormat as S}from"../../../../utils/audio.js";import q from"../../../longText/index.js";import{classnames as z}from"../../../../utils/index.js";import s from"./index.module.scss.js";import{useTranslation as G}from"react-i18next";import H from"../../../subAttributeList/index.js";var J=Object.defineProperty,K=Object.defineProperties,Q=Object.getOwnPropertyDescriptors,x=Object.getOwnPropertySymbols,U=Object.prototype.hasOwnProperty,W=Object.prototype.propertyIsEnumerable,y=(a,e,i)=>e in a?J(a,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):a[e]=i,m=(a,e)=>{for(var i in e||(e={}))U.call(e,i)&&y(a,i,e[i]);if(x)for(var i of x(e))W.call(e,i)&&y(a,i,e[i]);return a},c=(a,e)=>K(a,Q(e));const X=a=>{const{regions:e=[],updateRegion:i,useAudioClipStore:C}=a,{audioClipState:j,setAudioClipState:v}=C(),{t:d}=G(),{selectedAttribute:N,selectedRegion:f,clipTextConfigurable:E,clipAttributeList:p,clipAttributeConfigurable:b,secondaryAttributeConfigurable:L,subAttributeList:O}=j,{id:l}=f,n=k(()=>e.find(r=>r.id===l),[e,l]),P=r=>{e.length&&l&&i(c(m({},n),{attribute:r})),v({selectedAttribute:r})},h=(r,o)=>{var u;if(e.length&&l){const g=(u=n==null?void 0:n.subAttribute)!=null?u:{};i(c(m({},n),{subAttribute:c(m({},g),{[r]:o})}))}},_=[{label:"\u65E0\u5C5E\u6027",value:"",key:"\u65E0\u5C5E\u6027"},...p.map(r=>c(m({},r),{label:r.key}))];return t.createElement("div",{className:s.clipSidebar},t.createElement("div",{className:s.clipResults},t.createElement("div",{className:s.title},d("ClippedAudio")),e.length>0?t.createElement("div",{className:s.regions},e.map(r=>{const{id:o,attribute:u,text:g,start:w,end:$}=r,R=o===l&&f.loop,T=`${b?M(u,_):""}${b&&E?"\uFF0C":""}${E?`${d("textTool")}\uFF1A${g}`:""}`;return t.createElement("div",{className:z({[s.region]:!0,[s.selected]:o===l}),key:o,onClick:()=>{A.emit("setSelectedRegion",{id:o,playImmediately:!0})}},t.createElement("div",{className:s.label},R&&t.createElement("img",{src:V}),t.createElement("div",{className:s.text},t.createElement(q,{text:T}))),t.createElement("div",{className:s.time},t.createElement("img",{src:l===o?D:I}),S(w,"ss.SSS")," -",S($,"ss.SSS")),t.createElement("div",{className:s.delete,onClick:()=>{A.emit("removeRegionById",o)}},t.createElement("img",{src:B})))})):t.createElement("div",{className:s.empty},d("NoClippedData"))),b&&(p==null?void 0:p.length)>0&&t.createElement("div",{className:s.attributeList},t.createElement(F,{list:_,attributeChanged:P,selectedAttribute:N,attributeLockChange:r=>{v({attributeLockList:r})}}),l&&L&&t.createElement(H,{subAttributeList:O,setSubAttribute:h,getValue:r=>{var o;return(o=n==null?void 0:n.subAttribute)==null?void 0:o[r.value]}})))};export{X as default};
1
+ import r,{useMemo as I}from"react";import D from"../../../attributeList/index.js";import{EventBus as A}from"@labelbee/lb-annotation";import B from"../../../../assets/annotation/audio/clipSmall.svg.js";import V from"../../../../assets/annotation/audio/clipASmall.svg.js";import M from"../../../../assets/annotation/audio/delete.svg.js";import q from"../../../../assets/annotation/audio/loopA.svg.js";import{getAttributeShowText as z,timeFormat as y}from"../../../../utils/audio.js";import G from"../../../longText/index.js";import{classnames as H}from"../../../../utils/index.js";import a from"./index.module.scss.js";import{useTranslation as J}from"react-i18next";import K from"../../../subAttributeList/index.js";var Q=Object.defineProperty,U=Object.defineProperties,W=Object.getOwnPropertyDescriptors,x=Object.getOwnPropertySymbols,X=Object.prototype.hasOwnProperty,Y=Object.prototype.propertyIsEnumerable,C=(o,e,s)=>e in o?Q(o,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):o[e]=s,m=(o,e)=>{for(var s in e||(e={}))X.call(e,s)&&C(o,s,e[s]);if(x)for(var s of x(e))Y.call(e,s)&&C(o,s,e[s]);return o},d=(o,e)=>U(o,W(e));const Z=o=>{const{regions:e=[],updateRegion:s,useAudioClipStore:h}=o,{audioClipState:j,setAudioClipState:v}=h(),{t:f}=J(),{selectedAttribute:L,selectedRegion:E,clipTextConfigurable:N,clipAttributeList:p,clipAttributeConfigurable:b,secondaryAttributeConfigurable:w,subAttributeList:O,clipTextList:g}=j,{id:l}=E,u=I(()=>e.find(t=>t.id===l),[e,l]),P=t=>{e.length&&l&&s(d(m({},u),{attribute:t})),v({selectedAttribute:t})},T=(t,i)=>{var n;if(e.length&&l){const c=(n=u==null?void 0:u.subAttribute)!=null?n:{};s(d(m({},u),{subAttribute:d(m({},c),{[t]:i})}))}},S=[{label:"\u65E0\u5C5E\u6027",value:"",key:"\u65E0\u5C5E\u6027"},...p.map(t=>d(m({},t),{label:t.key}))],$=t=>{let i="";return N&&(g==null?void 0:g.length)>0&&g.forEach((n,c)=>{i=i+`${!b&&c===0?"":"\uFF0C"}${n.label}\uFF1A${t[n.key]}`}),i};return r.createElement("div",{className:a.clipSidebar},r.createElement("div",{className:a.clipResults},r.createElement("div",{className:a.title},f("ClippedAudio")),e.length>0?r.createElement("div",{className:a.regions},e.map(t=>{const{id:i,attribute:n,text:c,start:_,end:R}=t,k=i===l&&E.loop,F=`${b?z(n,S):""}${$(t)}`;return r.createElement("div",{className:H({[a.region]:!0,[a.selected]:i===l}),key:i,onClick:()=>{A.emit("setSelectedRegion",{id:i,playImmediately:!0})}},r.createElement("div",{className:a.label},k&&r.createElement("img",{src:q}),r.createElement("div",{className:a.text},r.createElement(G,{text:F}))),r.createElement("div",{className:a.time},r.createElement("img",{src:l===i?V:B}),y(_,"ss.SSS")," -",y(R,"ss.SSS")),r.createElement("div",{className:a.delete,onClick:()=>{A.emit("removeRegionById",i)}},r.createElement("img",{src:M})))})):r.createElement("div",{className:a.empty},f("NoClippedData"))),b&&(p==null?void 0:p.length)>0&&r.createElement("div",{className:a.attributeList},r.createElement(D,{list:S,attributeChanged:P,selectedAttribute:L,attributeLockChange:t=>{v({attributeLockList:t})}}),l&&w&&r.createElement(K,{subAttributeList:O,setSubAttribute:T,getValue:t=>{var i;return(i=u==null?void 0:u.subAttribute)==null?void 0:i[t.value]}})))};export{Z as default};
@@ -1 +1 @@
1
- import i,{useState as F,useEffect as B,useMemo as ne}from"react";import{AudioPlayer as Re}from"../audioPlayer/index.js";import{getClassName as Te}from"../../utils/dom.js";import je from"../predictTracking/previewResult/index.js";import{Layout as oe}from"antd/es";import{Spin as Pe}from"antd";import{prefix as he}from"../../constant/index.js";import{cKeyCode as Le,CommonToolUtils as K,uuid as we,TagUtils as Ae,EventBus as Oe,cTool as Ie}from"@labelbee/lb-annotation";import N from"./index.module.scss.js";import Ne from"./tagResultShow/index.js";import{AudioClipProvider as ke,useAudioClipStore as De}from"./audioContext/index.js";import $e from"./textInput/index.js";import{connect as Me}from"react-redux";import{a2MapStateToProps as Ve}from"../../store/annotation/map.js";import{LabelBeeContext as Be}from"../../store/ctx.js";import{jsonParser as Ke}from"../../utils/index.js";import{useCustomToolInstance as We}from"../../hooks/annotation.js";import{sidebarCls as Q}from"../../views/MainView/sidebar/index.js";import Ue from"./audioSide/labelSidebar/index.js";import Fe from"./audioSide/clipSidebar/index.js";import Xe from"../../assets/annotation/audio/tag.svg.js";import qe from"../../assets/annotation/audio/tagA.svg.js";import ze from"../../assets/annotation/audio/clip.svg.js";import Ge from"../../assets/annotation/audio/clipA.svg.js";var He=Object.defineProperty,Je=Object.defineProperties,Qe=Object.getOwnPropertyDescriptors,ie=Object.getOwnPropertySymbols,Ye=Object.prototype.hasOwnProperty,Ze=Object.prototype.propertyIsEnumerable,le=(t,n,s)=>n in t?He(t,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[n]=s,E=(t,n)=>{for(var s in n||(n={}))Ye.call(n,s)&&le(t,s,n[s]);if(ie)for(var s of ie(n))Ze.call(n,s)&&le(t,s,n[s]);return t},k=(t,n)=>Je(t,Qe(n));const{EAudioToolName:et}=Ie,re=Le.default,{Sider:tt,Content:nt}=oe,se=`${he}-layout`,ot=({setSideTab:t,sideTab:n})=>{const s=[{tab:"tag",commonSvg:Xe,selectedSvg:qe},{tab:"clip",commonSvg:ze,selectedSvg:Ge}];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)}}))}))},it=({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($e,{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}))),lt=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,w]=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),w([0,r]),setTimeout(()=>{w([])},500)):d.length===1?(j(d[0],r),w([d[0],r]),setTimeout(()=>{w([])},500)):w([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)}},A=l=>{delete C[l],x(C)},O=g&&_&&i.createElement(ot,{setSideTab:v,sideTab:T}),M=T==="tag"&&i.createElement(Ue,{labelInfoSet:g?m:[],labelSelectedList:X,setLabel:j,tagResult:C,clearResult:A,isEdit:D,withPanelTab:!1}),u=T==="clip"&&i.createElement(Fe,{regions:a,updateRegion:R,useAudioClipStore:De});return p?typeof p=="function"?i.createElement("div",{className:`${Q}`},p({toggleAudioOption:O,labelSidebar:M,clipSidebar:u})):p:i.createElement("div",{className:`${Q}`},i.createElement("div",{className:`${Q}__content`},O,M,u))},rt=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:w,imgList:T,imgIndex:v,currentData:$,config:j,stepInfo:A}=t,O=K.getCurrentStepToolAndConfig(m,C),M=Ke($.result),{toolInstanceRef:u}=We({basicInfo:M}),[l,r]=F(!0),[d,b]=F(null),[P,q]=F(0);B(()=>{r(!0)},[v]),B(()=>{l===!1&&ve()},[l]),B(()=>{W()},[]),B(()=>{u.current.exportData=()=>[[d],{duration:P,valid:H}],u.current.setResult=_e,u.current.clearResult=Ce,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_${A==null?void 0:A.step}`];return(e==null?void 0:e.result)||[]},[j,M,A]),{tagConfigurable:I,textConfigurable:V=!0,clipConfigurable:z=!1,clipAttributeConfigurable:Y=!1,clipAttributeList:Z=[],clipTextConfigurable:G=!1,subAttributeList:ae=[],secondaryAttributeConfigurable:ue=!1,inputList:ce=[],configList:de=[]}=ne(()=>{if(O)return K.jsonParser(O==null?void 0:O.config)},[O]),fe={clipConfigurable:z,clipAttributeConfigurable:Y,clipAttributeList:Z,clipTextConfigurable:G,subAttributeList:ae,secondaryAttributeConfigurable:ue},H=a?a==null?void 0:a.valid:!0,me=(S=(p=K.jsonParser($.result))==null?void 0:p.duration)!=null?S:0,pe=H?me:0,ge=!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:A==null?void 0:A.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(L=>{L&&y[L]&&(ee[L]={visible:!0,content:y[L],type:L})})}}const ve=()=>{(h==null?void 0:h.length)>0?b(h[0]):b({id:we(),sourceID:"",value:te(),tag:be(),regions:[]})},te=(e=!0)=>{const o={};let c=j.configList||[];return c.length>0&&c.forEach(y=>{o[y.key]=e&&y.default||""}),o},be=()=>Ae.getDefaultResultByConfig(j.inputList||[]),ye=({duration:e,hasError:o})=>{r(!1),q(e)},Ee=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:L}=e;return y.find(U=>U.id===L)?k(E({},o),{regions:y.map(U=>L===U.id?E(E({},U),e):U)}):k(E({},o),{regions:[...y,e]})})},Se=(e,o)=>{b(c=>k(E({},c),{value:k(E({},c.value),{[o]:e})}))},xe=e=>{b(o=>k(E({},o),{tag:e}))},_e=e=>{b(e)},Ce=()=>{b(e=>k(E({},e),{value:te(),tag:{},regions:[]})),Oe.emit("clearRegions")};return i.createElement(ke,null,i.createElement(Pe,{spinning:l,wrapperClassName:"audio-tool-spinner"},i.createElement(oe,{className:Te("layout","container"),style:{height:"100%"}},t==null?void 0:t.leftSider,i.createElement(nt,{className:`${se}__content`},i.createElement("div",{className:N.containerWrapper},i.createElement("div",{className:N.audioWrapper},I&&i.createElement(Ne,{result:d==null?void 0:d.tag,labelInfoSet:ce,hasPromptLayer:!!(a==null?void 0:a.promptLayer)}),a==null?void 0:a.promptLayer,i.createElement(Re,E({context:{isEdit:a==null?void 0:a.isEdit,count:pe,toolName:et.AudioTextTool,imgIndex:v},drawLayerSlot:w,fileData:$,onLoaded:ye,invalid:!H,updateRegion:J,removeRegion:Ee,regions:d==null?void 0:d.regions,activeToolPanel:a==null?void 0:a.activeToolPanel,footer:t.footer},fe))),(V||G)&&i.createElement(it,{preContext:ee,result:d,inputDisabled:ge,updateText:Se,updateRegion:J,configList:de,autofocus:!1,textConfigurable:V,clipTextConfigurable:G,clipAttributeList:Z,clipAttributeConfigurable:Y}))),i.createElement(tt,{className:`${se}__side`,width:_!=null?_:240,style:(g=t.style)==null?void 0:g.sider},i.createElement(lt,{sider:X,config:j,result:d,updateTagResult:xe,updateRegion:J,isEdit:a==null?void 0:a.isEdit,tagConfigurable:I,clipConfigurable:z})),i.createElement(je,null))))};var st=Me(Ve,null,null,{context:Be})(rt);export{st as default};
1
+ import i,{useState as U,useEffect as B,useMemo as oe}from"react";import{AudioPlayer as Le}from"../audioPlayer/index.js";import{getClassName as Pe}from"../../utils/dom.js";import Re from"../predictTracking/previewResult/index.js";import{Layout as ie}from"antd/es";import{Spin as je}from"antd";import{prefix as he}from"../../constant/index.js";import{cKeyCode as we,CommonToolUtils as K,uuid as Ae,TagUtils as Ie,EventBus as Oe,cTool as Ne}from"@labelbee/lb-annotation";import N from"./index.module.scss.js";import ke from"./tagResultShow/index.js";import{AudioClipProvider as De,DEFAULT_CLIP_TEXT_CONFIG_ITEM as $e,useAudioClipStore as Me}from"./audioContext/index.js";import Ve from"./textInput/index.js";import{connect as Be}from"react-redux";import{a2MapStateToProps as Ke}from"../../store/annotation/map.js";import{LabelBeeContext as We}from"../../store/ctx.js";import{jsonParser as Fe}from"../../utils/index.js";import{useCustomToolInstance as Ue}from"../../hooks/annotation.js";import{sidebarCls as Q}from"../../views/MainView/sidebar/index.js";import Xe from"./audioSide/labelSidebar/index.js";import Ge from"./audioSide/clipSidebar/index.js";import qe from"../../assets/annotation/audio/tag.svg.js";import ze from"../../assets/annotation/audio/tagA.svg.js";import He from"../../assets/annotation/audio/clip.svg.js";import Je from"../../assets/annotation/audio/clipA.svg.js";var Qe=Object.defineProperty,Ye=Object.defineProperties,Ze=Object.getOwnPropertyDescriptors,le=Object.getOwnPropertySymbols,et=Object.prototype.hasOwnProperty,tt=Object.prototype.propertyIsEnumerable,re=(t,n,s)=>n in t?Qe(t,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[n]=s,_=(t,n)=>{for(var s in n||(n={}))et.call(n,s)&&re(t,s,n[s]);if(le)for(var s of le(n))tt.call(n,s)&&re(t,s,n[s]);return t},k=(t,n)=>Ye(t,Ze(n));const{EAudioToolName:nt}=Ne,se=we.default,{Sider:ot,Content:it}=ie,ae=`${he}-layout`,lt=({setSideTab:t,sideTab:n})=>{const s=[{tab:"tag",commonSvg:qe,selectedSvg:ze},{tab:"clip",commonSvg:He,selectedSvg:Je}];return i.createElement("div",{className:N.toggleAudioOption},s.map((p,x)=>{const{tab:f,selectedSvg:S,commonSvg:T}=p;return i.createElement("div",{key:x,className:N.option},i.createElement("img",{className:N.icon,src:n===f?S:T,onClick:()=>{n!==f&&t(f)}}))}))},rt=({result:t,inputDisabled:n,updateText:s,configList:p,autofocus:x,preContext:f,isCheck:S,clipAttributeConfigurable:T,clipTextConfigurable:D,textConfigurable:v,updateRegion:C,clipAttributeList:m,clipTextList:g})=>i.createElement("div",{className:N.textareaContainer},i.createElement("div",{className:N.textareaContent},i.createElement(Ve,{isCheck:S,result:t==null?void 0:t.value,textInputDisabled:n,textID:(t==null?void 0:t.id)||0,updateText:s,configList:p,autofocus:!n&&x,preContext:f,regions:t==null?void 0:t.regions,clipAttributeConfigurable:T,clipTextConfigurable:D,textConfigurable:v,updateRegion:C,clipAttributeList:m,clipTextList:g}))),st=t=>{var n,s;const{sider:p,config:x,result:f,updateTagResult:S,updateRegion:T,isEdit:D,tagConfigurable:v,clipConfigurable:C}=t;let m=(x==null?void 0:x.inputList)||[],g=(n=f==null?void 0:f.tag)!=null?n:{},a=(s=f==null?void 0:f.regions)!=null?s:[];const[X,w]=U([]),[L,b]=U("tag");B(()=>{if(!v&&C){b("clip");return}b("tag")},[v,C]),B(()=>(window.addEventListener("keydown",$),()=>{window.removeEventListener("keydown",$)}));const $=l=>{if(v&&C)switch(l.keyCode){case se.L:b("tag");break;case se.X:b("clip");break}if(L==="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?(P(0,r),w([0,r]),setTimeout(()=>{w([])},500)):d.length===1?(P(d[0],r),w([d[0],r]),setTimeout(()=>{w([])},500)):w([r])}}},P=(l,r)=>{if(l<m.length&&m[l].subSelected&&r<m[l].subSelected.length){const d=m[l].value,E=m[l].isMulti;let R=m[l].subSelected[r].value,G=0;const W=g;for(const j in g)if(j===m[l].value){if(G++,E===!0){const O=W[j].split(";").filter(q=>q!==""),V=O.indexOf(R);V===-1?O.push(R):O.splice(V,1),R=O.join(";")}R===""?delete W[j]:W[j]=R}G===0&&Object.assign(g,{[d]:R}),S(g)}},A=l=>{delete g[l],S(g)},I=v&&C&&i.createElement(lt,{setSideTab:b,sideTab:L}),M=L==="tag"&&i.createElement(Xe,{labelInfoSet:v?m:[],labelSelectedList:X,setLabel:P,tagResult:g,clearResult:A,isEdit:D,withPanelTab:!1}),u=L==="clip"&&i.createElement(Ge,{regions:a,updateRegion:T,useAudioClipStore:Me});return p?typeof p=="function"?i.createElement("div",{className:`${Q}`},p({toggleAudioOption:I,labelSidebar:M,clipSidebar:u})):p:i.createElement("div",{className:`${Q}`},i.createElement("div",{className:`${Q}__content`},I,M,u))},at=t=>{var n,s,p,x,f,S,T,D,v;const C=(s=(n=t.style)==null?void 0:n.sider)==null?void 0:s.width,{step:m,stepList:g,audioContext:a,sider:X,drawLayerSlot:w,imgList:L,imgIndex:b,currentData:$,config:P,stepInfo:A}=t,I=K.getCurrentStepToolAndConfig(m,g),M=Fe($.result),{toolInstanceRef:u}=Ue({basicInfo:M}),[l,r]=U(!0),[d,E]=U(null),[R,G]=U(0);B(()=>{r(!0)},[b]),B(()=>{l===!1&&be()},[l]),B(()=>{W()},[]),B(()=>{u.current.exportData=()=>[[d],{duration:R,valid:H}],u.current.setResult=Ce,u.current.clearResult=Te,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)}},j=oe(()=>{const e=M[`step_${A==null?void 0:A.step}`];return(e==null?void 0:e.result)||[]},[P,M,A]),{tagConfigurable:O,textConfigurable:V=!0,clipConfigurable:q=!1,clipAttributeConfigurable:Y=!1,clipAttributeList:Z=[],clipTextConfigurable:z=!1,subAttributeList:ue=[],secondaryAttributeConfigurable:ce=!1,inputList:de=[],configList:fe=[],clipTextList:ee=$e}=oe(()=>{if(I)return K.jsonParser(I==null?void 0:I.config)},[I]),me={clipConfigurable:q,clipAttributeConfigurable:Y,clipAttributeList:Z,clipTextConfigurable:z,subAttributeList:ue,secondaryAttributeConfigurable:ce,clipTextList:ee},H=a?a==null?void 0:a.valid:!0,pe=(x=(p=K.jsonParser($.result))==null?void 0:p.duration)!=null?x:0,ge=H?pe:0,ve=!H||l||![V,z].includes(!0);let te={};if(b!==-1&&(L==null?void 0:L.length)){const e=(f=L[b])==null?void 0:f.preResult,o=(a==null?void 0:a.isEdit)?(S=a==null?void 0:a.stepConfig)==null?void 0:S.loadPreStep:A==null?void 0:A.loadPreStep;if(e&&o){const c=K.jsonParser(e),y=(D=(T=c==null?void 0:c.config)==null?void 0:T.context)!=null?D:{};Object.keys(y).forEach(h=>{h&&y[h]&&(te[h]={visible:!0,content:y[h],type:h})})}}const be=()=>{(j==null?void 0:j.length)>0?E(j[0]):E({id:Ae(),sourceID:"",value:ne(),tag:Ee(),regions:[]})},ne=(e=!0)=>{const o={};let c=P.configList||[];return c.length>0&&c.forEach(y=>{o[y.key]=e&&y.default||""}),o},Ee=()=>Ie.getDefaultResultByConfig(P.inputList||[]),ye=({duration:e,hasError:o})=>{r(!1),G(e)},_e=e=>{E(o=>k(_({},o),{regions:((o==null?void 0:o.regions)||[]).filter(c=>c.id!==e)}))},J=e=>{E(o=>{var c;const y=(c=o==null?void 0:o.regions)!=null?c:[],{id:h}=e;return y.find(F=>F.id===h)?k(_({},o),{regions:y.map(F=>h===F.id?_(_({},F),e):F)}):k(_({},o),{regions:[...y,e]})})},xe=(e,o)=>{E(c=>k(_({},c),{value:k(_({},c.value),{[o]:e})}))},Se=e=>{E(o=>k(_({},o),{tag:e}))},Ce=e=>{E(e)},Te=()=>{E(e=>k(_({},e),{value:ne(),tag:{},regions:[]})),Oe.emit("clearRegions")};return i.createElement(De,null,i.createElement(je,{spinning:l,wrapperClassName:"audio-tool-spinner"},i.createElement(ie,{className:Pe("layout","container"),style:{height:"100%"}},t==null?void 0:t.leftSider,i.createElement(it,{className:`${ae}__content`},i.createElement("div",{className:N.containerWrapper},i.createElement("div",{className:N.audioWrapper},O&&i.createElement(ke,{result:d==null?void 0:d.tag,labelInfoSet:de,hasPromptLayer:!!(a==null?void 0:a.promptLayer)}),a==null?void 0:a.promptLayer,i.createElement(Le,_({context:{isEdit:a==null?void 0:a.isEdit,count:ge,toolName:nt.AudioTextTool,imgIndex:b},drawLayerSlot:w,fileData:$,onLoaded:ye,invalid:!H,updateRegion:J,removeRegion:_e,regions:d==null?void 0:d.regions,activeToolPanel:a==null?void 0:a.activeToolPanel,footer:t.footer},me))),(V||z)&&i.createElement(rt,{preContext:te,result:d,inputDisabled:ve,updateText:xe,updateRegion:J,configList:fe,autofocus:!1,textConfigurable:V,clipTextConfigurable:z,clipAttributeList:Z,clipAttributeConfigurable:Y,clipTextList:ee}))),i.createElement(ot,{className:`${ae}__side`,width:C!=null?C:240,style:(v=t.style)==null?void 0:v.sider},i.createElement(st,{sider:X,config:P,result:d,updateTagResult:Se,updateRegion:J,isEdit:a==null?void 0:a.isEdit,tagConfigurable:O,clipConfigurable:q})),i.createElement(Re,null))))};var ut=Be(Ke,null,null,{context:We})(at);export{ut 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 q,useRef as ee,useEffect as K}from"react";import{Tooltip as te,Radio as H,Switch as xe}from"antd";import{QuestionCircleOutlined as ge}from"@ant-design/icons";import{TextareaWithFooter as Fe}from"../../../views/MainView/sidebar/TextToolSidebar/index.js";import{timeFormat as ae,getAttributeColor as Ce,getAttributeFontColor as Te,updateColorOpacity as he,getAttributeShowText as be,DEFAULT_TEXT_CONFIG_ITEM as ye}from"../../../utils/audio.js";import{cKeyCode as we}from"@labelbee/lb-annotation";import U from"classnames";import le,{useAudioClipStore as Ne,DEFAULT_CLIP_TEXT_CONFIG_ITEM as ke}from"../audioContext/index.js";import o from"./index.module.scss.js";import{useTranslation as ne}from"react-i18next";var Ie=Object.defineProperty,Be=Object.defineProperties,_e=Object.getOwnPropertyDescriptors,oe=Object.getOwnPropertySymbols,Se=Object.prototype.hasOwnProperty,Ae=Object.prototype.propertyIsEnumerable,re=(u,l,r)=>l in u?Ie(u,l,{enumerable:!0,configurable:!0,writable:!0,value:r}):u[l]=r,ue=(u,l)=>{for(var r in l||(l={}))Se.call(l,r)&&re(u,r,l[r]);if(oe)for(var r of oe(l))Ae.call(l,r)&&re(u,r,l[r]);return u},De=(u,l)=>Be(u,_e(l));const d=we.default,se=({onClick:u,title:l,disabled:r})=>e.createElement(te,{placement:"bottom",title:l},e.createElement("span",{className:U({[o.clearIcon]:!0,[o.disabled]:r}),onClick:u})),X=u=>{var l;const{t:r}=ne(),L=ee(null),[E,y]=q(!1),[w,p]=q(!1),{disabled:s,config:c,result:O,updateText:f,index:v,switchToNextTextarea:$,hasMultiple:R,textID:N,addPlaceholder:x,onFocus:k,onBlur:T,onFocusStyle:G={},extra:h,errorText:I}=u,{maxLength:g}=c,B=O?O[c.key]:"",_=(l=B==null?void 0:B.length)!=null?l:0,S=a=>{f&&(f(a,c.key),c.required&&p(!a))},j=R&&$,m={id:`textInput-${v}`,ref:L,disabled:s,value:B,maxLength:g,autoSize:{minRows:2,maxRows:6},onChange:a=>{const i=a.target.value;S(i)},onFocus:a=>{y(!0),k==null||k(a),a.target.value&&p(!1)},onBlur:a=>{y(!1),T==null||T(a),c.required&&p(!a.target.value)},style:{resize:"none",wordBreak:"break-all"},onKeyDownCapture:a=>{const{keyCode:i}=a;if(a.ctrlKey){if(i===d.Enter&&a.preventDefault(),x&&[d.One,d.Two,d.Three].includes(i))switch(a.preventDefault(),i){case d.One:x("\u4986");break;case d.Two:x("\u652B");break;case d.Three:x("\u7383");break}}else i===d.Tab&&j?(a.preventDefault(),a.nativeEvent.stopImmediatePropagation(),$(v)):a.nativeEvent.stopPropagation()}},F=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:_>=g?o.warning:""},_),"/",e.createElement("span",null,g)));return K(()=>{s&&y(!1)},[s]),K(()=>{p(!1)},[N]),e.createElement("div",{className:o.textField},e.createElement("div",{className:o.label},e.createElement("span",{className:U({[o.required]:c.required})},c.label),e.createElement(se,{onClick:()=>{s||S("")},title:"",disabled:s}),e.createElement("div",{className:o.extra},h)),e.createElement("div",{className:U({disabled:s,"textarea-outline":!0,"ant-input-focused":E,[o.textareaContainer]:!0,[o.focus]:E,[o.invalid]:w}),style:E?G:{}},e.createElement(Fe,{footer:F,textareaProps:m})),I&&e.createElement("span",{style:{color:"#ff4d4f",lineHeight:"22px"}},I))},Pe=u=>{const{configList:l,autofocus:r,textID:L,result:E,showText:y,updateText:w,toggleShowText:p,textInputDisabled:s,isCheck:c,isEdit:O,config:f,preContext:v,regions:$=[],textConfigurable:R=!0,clipTextConfigurable:N,clipAttributeConfigurable:x,updateRegion:k,clipAttributeList:T=[],clipTextList:G=ke}=u,{t:h}=ne(),[I,g]=q(0),[B,_]=q(""),S=ee(null),{audioClipState:j}=Ne(),m=l||[ue({},ye)];let F=$;if(N&&!c){const t=j.selectedRegion.id;F=F.filter(n=>n.id===t)}const a=t=>{setTimeout(()=>{const n=document.getElementById(`textInput-${t}`);n&&(g(t),n.focus(),n.select(),n.scrollIntoView({behavior:"smooth",block:"center"}))})},i=t=>{const n=R?m.length:0,b=N?F.length:0,C=n+b,D=(t+1)%C;a(D)},Q=t=>{t.keyCode===d.Tab&&(t.preventDefault(),m.length>0&&a(0))},M=t=>{const n=document.getElementById(`textInput-${I}`);if(!(f==null?void 0:f.enablePlaceholderHotkey)||!n||!w)return;const{value:b,selectionStart:C,selectionEnd:D}=n,P=`${b.slice(0,C)}${t}${b.slice(D)}`;w(P,m[I].key),_(t),setTimeout(()=>{n.setSelectionRange(C+1,C+1),n.focus()},0),clearTimeout(S.current),S.current=setTimeout(()=>{_("")},400)};K(()=>(O||document.addEventListener("keydown",Q),()=>{document.removeEventListener("keydown",Q)}),[l]),K(()=>{r&&!s&&a(0)},[L]);let V=m;c&&(V=m.filter(t=>(E==null?void 0:E[t.key])!==void 0));const A=F[0];return e.createElement(e.Fragment,null,(f==null?void 0:f.enablePlaceholderHotkey)&&e.createElement("div",{className:o.placeholderHotkey},e.createElement("div",{className:o.title},"\u5360\u4F4D\u7B26\u5FEB\u6377\u8F93\u5165",e.createElement(te,{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(ge,{className:o.questionIcon}))),e.createElement(H.Group,{value:B},e.createElement(H.Button,{value:"\u4986",onClick:t=>M(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(H.Button,{value:"\u652B",onClick:t=>M(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(H.Button,{value:"\u7383",onClick:t=>M(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(le,{audioContext:v==null?void 0:v.before}),R&&V.map((t,n)=>e.createElement(X,{config:t,key:n,index:n,result:E,updateText:w,switchToNextTextarea:i,hasMultiple:m.length>1,disabled:s,textID:L,addPlaceholder:M,onFocus:()=>g(n)})),N&&F.length>0&&G.map((t,n)=>{const{id:b,start:C,end:D,attribute:P}=A,{maxLength:ce=3e3,label:J,key:Y,required:ie}=t,Z=A==null?void 0:A[Y],de={[A.id]:Z},me={label:`${J!=null?J:h("textTool")}\uFF08${ae(C,"ss.SSS")} - ${ae(D,"ss.SSS")}\uFF09`,key:b,maxLength:ce},W=V.length+n,z=Ce(P,T),Ee={color:Te(P,T),backgroundColor:z},pe=h("LeastCharacterError",{num:1}),fe=ie&&Z.length<1?pe:void 0;return e.createElement(X,{config:me,key:n,index:W,disabled:s,result:de,updateText:ve=>{k==null||k(De(ue({},A),{[Y]:ve}))},switchToNextTextarea:()=>{i(W)},hasMultiple:!0,onFocus:()=>g(W),onFocusStyle:x?{borderColor:z,boxShadow:`0 0 0 2px ${he(z,.4)}`}:{},extra:x?e.createElement("div",{style:Ee,className:o.attribute},be(P,[{value:"",key:h("NoAttribute")},...T])):null,errorText:fe})}),e.createElement(le,{audioContext:v==null?void 0:v.after}),p&&e.createElement("div",{className:o.switchItem},h("toggleShowText"),e.createElement(xe,{style:{alignSelf:"center"},checked:y,onChange:t=>{p(t)}}))))};export{se as ClearIcon,X as SingleTextInput,Pe 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 Gt}from"../audioAnnotate/utils/getWebPcm2Wac.js";import Yt,{debounce as Jt,sortBy as Qt}from"lodash";import{PauseOutlined as er,CaretRightOutlined as tr}from"@ant-design/icons";import{cKeyCode as rr,cTool as or,EventBus as E,TagUtils as nr}from"@labelbee/lb-annotation";import{Button as ir}from"antd";import lr from"../invalidPage/index.js";import sr from"../imageError/index.js";import{classnames as $}from"../../utils/index.js";import ar,{EPlayerType as ur}from"../videoPlayer/components/SpeedController/index.js";import cr from"@labelbee/wavesurfer";import dr from"@labelbee/wavesurfer/dist/plugin/wavesurfer.regions.js";import mr from"@labelbee/wavesurfer/dist/plugin/wavesurfer.cursor.js";import pr,{audioZoomInfo as Xe}from"./zoomSlider/index.js";import fr from"./labelDisplayToggle/index.js";import vr from"./clipRegion/index.js";import{useAudioClipStore as gr}from"../audioAnnotate/audioContext/index.js";import{useLatest as H,useUpdate as br,useDeepCompareEffect as Ze,useThrottleFn as yr}from"ahooks";import _r from"./useAudioScroll/index.js";import b from"./index.module.scss.js";import{getAttributeColor as Er,formatTime as qe,timeFormat as Ke,dispatchResizeEvent as hr,precisionMinus as Ve,isDoubleClick as Cr,getCanMoveRange as Sr}from"../../utils/audio.js";import Pr from"./progressDot/index.js";import Rr from"./clipTip/index.js";import wr from"./useSwitchHotkey/index.js";import Tr from"./useAudioCombine/index.js";import Ar from"./useAudioSegment/index.js";import jr from"./combineTip/index.js";import xr from"./segmentTip/index.js";import Dr from"../../views/MainView/toolFooter/index.js";import{decimalReserved as U}from"../videoPlayer/utils.js";var Mr=Object.defineProperty,kr=Object.defineProperties,Ir=Object.getOwnPropertyDescriptors,Ge=Object.getOwnPropertySymbols,Br=Object.prototype.hasOwnProperty,Lr=Object.prototype.propertyIsEnumerable,Ye=(f,u,c)=>u in f?Mr(f,u,{enumerable:!0,configurable:!0,writable:!0,value:c}):f[u]=c,Je=(f,u)=>{for(var c in u||(u={}))Br.call(u,c)&&Ye(f,c,u[c]);if(Ge)for(var c of Ge(u))Lr.call(u,c)&&Ye(f,c,u[c]);return f},Qe=(f,u)=>kr(f,Ir(u));const{EToolName:et}=or,X=rr.default,tt=.1,rt=i.createContext({count:0,isEdit:!1,toolName:et.Empty,imgIndex:0}),Or=({fileData:f={},onLoaded:u,context:c,invalid:ot,height:nt,hideError:it,onError:ce,updateRegion:j,removeRegion:L,regions:x=[],activeToolPanel:lt,clipConfigurable:st,clipTextConfigurable:at,clipAttributeList:ut,clipAttributeConfigurable:de,secondaryAttributeConfigurable:ct,subAttributeList:dt,isCheck:S,hoverRegionId:Z,footer:mt,drawLayerSlot:me})=>{var pe,fe;const{url:O,path:ve}=f,[q,K]=g(!1),[ge,be]=g(!1),[P,pt]=g(0),[ft,ye]=g(!1),[N,_e]=g(0),n=z(null),R=z(null),Ee=z(P),V=e=>{Ee.current=e,pt(e)},[he,vt]=g(0),[F,gt]=g(1),G=z(null),[Ce,bt]=g({}),{audioClipState:Y,setAudioClipState:k}=gr(),[J,Q]=g(!1),d=H(Y),Se=H(Ce),yt=H(q),D=H(x),Pe=br(),[Re,_t]=g([]),[we,Et]=g({}),ht=Jt(()=>{E.emit("audioZoom")},500),Te=e=>{e<Xe.min||e>Xe.max||(gt(e),hr(),ht())};_r({container:G.current,target:document.querySelector(`[data-id=${(fe=(pe=d.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}=d.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)"}))}),Pe()},m=e=>{var r,t,o,l,s,p,y;const{id:a,loop:v=!0,playImmediately:C=!1}=e;if(a){const M=(o=(t=(r=n.current)==null?void 0:r.regions)==null?void 0:t.list)!=null?o:{};Object.entries(M).forEach(([,_])=>{const{id:T}=_;a===T?_.select():_.cancelSelect()}),k({selectedRegion:{id:a,loop:v},selectedAttribute:(p=(s=(l=D.current)==null?void 0:l.find(_=>_.id===a))==null?void 0:s.attribute)!=null?p:""}),v&&C&&((y=I(a))==null||y.playLoop())}else k({selectedRegion:{}})},{combineInstance:Ct}=Tr({waveRef:n,sortByStartRegions:Re,regionMap:we,updateRegion:j,removeRegion:L,generateRegions:W,setSelectedRegion:m}),{segmentInstance:St,onRegionMouseMove:Pt,segmentTimeTip:Rt}=Ar({waveRef:n,regionMap:we,updateRegion:j,removeRegion:L,generateRegions:W,setSelectedRegion:m}),Ae={clipTextConfigurable:at,clipAttributeList:ut,clipAttributeConfigurable:de,clipConfigurable:st,secondaryAttributeConfigurable:ct,subAttributeList:dt};A(()=>{k({selectedAttribute:""})},[de]),A(()=>{ee()},[Y.selectedAttribute]),A(()=>{W()},[Y.attributeLockList]),Ze(()=>{k(Ae),setTimeout(()=>{je()})},[Ae]),Ze(()=>{_t(Qt(x,["start"])),Et(x.reduce((e,r)=>{const{id:t}=r;return Qe(Je({},e),{[t]:r})},{}))},[x]),A(()=>{if(Z){const e=yt.current;m({id:Z,loop:e,playImmediately:!0})}else m({})},[Z]);const je=()=>{var e,r;d.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="";d.current.clipConfigurable?s=Er(d.current.selectedAttribute,(e=d.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?Gt(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}=yr(m,{wait:500});wr({sortByStartRegions:Re,setSelectedRegion:m});const wt=e=>{const{start:r,end:t}=Se.current;return(r||t)&&e.update(Se.current),e},Tt=({action:e,id:r,eventDownTime:t})=>{var o,l;if(!d.current.clipConfigurable)return;r&&m({id:r});const s=I((r!=null?r:(o=d.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:C,end:M,attribute:_}=v;_===d.current.selectedAttribute&&[C,M].forEach(T=>{p.includes(T)||p.push(T)})});const a=Sr(p.sort((v,C)=>v-C),t);n.current.range=a},At=e=>{ee(),setTimeout(()=>{Q(!1)});const r=wt(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),Pe()},jt=()=>{const e=cr.create({container:"#waveform",waveColor:"#999",progressColor:"#999",height:nt||245,normalize:!0,cursorWidth:2,cursorColor:"white",responsive:0,hideScrollbar:!0,plugins:[dr.create({regions:x,dragSelection:{slop:5},canMove:!1}),mr.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(),u==null||u({duration:Math.round(o)}),be(!1),B(),E.on("setCurrentTimeByPosition",ne),E.on("clearRegions",te),E.on("removeRegionById",re),E.on("setSelectedRegion",Me),e.on("regions-eventDown",Tt),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),u==null||u({hasError:!0}),ce==null||ce()}),e.on("region-created",t=>{var o;const{id:l,start:s,end:p}=t;if(D.current.find(a=>a.id===l))return;const y={id:l,start:U(s,3),end:U(p,3),attribute:d.current.selectedAttribute,text:""};if(d.current.secondaryAttributeConfigurable){const a=nr.getDefaultResultByConfig((o=d.current.subAttributeList)!=null?o:[]);y.subAttribute=a!=null?a:{}}j==null||j(y)}),e.on("region-updated",(t,o)=>{var l,s,p,y,a,v,C,M,_,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"&&((y=(p=n==null?void 0:n.current)==null?void 0:p.cursor)==null||y.setStyle({borderColor:"transparent"}));const ie={},le=[],se={},zt=(a=D.current)==null?void 0:a.filter(h=>h.id!==t.id),$t=(M=(C=(v=n.current)==null?void 0:v.regions)==null?void 0:C.list)!=null?M:{};zt.forEach(h=>{var $e,He;const{element:ae}=($e=$t[h.id])!=null?$e:{},{start:Xt,end:Zt}=h;if(ae){const{x:Ue,width:qt}=((He=ae.getBoundingClientRect)==null?void 0:He.call(ae))||{},Kt=Ue+qt;[Ue,Kt].forEach((ue,Vt)=>{le.includes(ue)||(le.push(ue),se[ue]=Vt===0?Xt:Zt)})}});const{x:ze,width:Ht}=((T=(_=t.element).getBoundingClientRect)==null?void 0:T.call(_))||{},Ut=ze+Ht;le.forEach(h=>{Math.abs(Ve(h,ze))<5&&(ie.start=se[h]),Math.abs(Ve(h,Ut))<5&&(ie.end=se[h])}),bt(ie),Me({id:t.id}),Q(!0)}),e.on("region-update-end",t=>{At(t)}),e.on("region-contextmenu",(t,o)=>{if(!S){if(o.preventDefault(),o.stopPropagation(),Cr(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(),d.current.combined){Ct(t);return}if(d.current.segment){St(t,l);return}m({id:t.id,playImmediately:!0})}}),e.on("region-mousemove",Pt),n.current=e},xt=q?i.createElement(er,null):i.createElement(tr,null),ke=e=>e?`${parseFloat((e/N*100).toFixed(4))}%`:"0%",Ie=ke(P),Dt=ke(he),w=()=>{if(!ge)return n==null?void 0:n.current},Mt=()=>{var e;(e=w())==null||e.skipForward(tt)},kt=()=>{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:Mt();break;case X.Left:kt();break;case X.Space:e.preventDefault(),B();break;case X.Delete:if(!S){const{id:t}=((r=d.current)==null?void 0:r.selectedRegion)||{};t&&re(t)}break}},It=e=>{ne(e)},Le=Yt.throttle(It,50);let oe=!1;const Oe=()=>{oe&&(B(),oe=!1),document.removeEventListener("mousemove",Le),document.removeEventListener("mouseup",Oe)},Bt=e=>{ne(e),q&&(oe=!0,B()),document.addEventListener("mousemove",Le),document.addEventListener("mouseup",Oe)},Lt=()=>{xe()};A(()=>(jt(),()=>{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 Ot=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 a=(e.clientX-p.left)/(((l=R==null?void 0:R.current)==null?void 0:l.clientWidth)||0)*s;return a>s&&(a=s),a}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)},Nt=e=>{vt(Ne(e))},Ft=N?Math.max(N-P,0):0,Wt=(c==null?void 0:c.toolName)!==et.Empty&&(c==null?void 0:c.isEdit)!==!0&&(lt==="remark"||S),Fe=i.createElement("div",{className:b.audioPlayer},ft&&!it&&i.createElement(sr,{fileTypeName:"\u97F3\u9891",ignoreOffsetY:!0,reloadImage:Lt,backgroundColor:"#ffffffbb"}),i.createElement(Rr,{getRegionInstanceById:I,clipping:J}),i.createElement(jr,{container:G.current}),i.createElement(xr,{segmentTimeTip:Rt}),i.createElement("div",{className:b.waveformContainer,ref:G},i.createElement("div",{id:"waveform",style:{width:`${F*100}%`},className:$({[b.waveform]:!0,"bee-audio-combined":d.current.combined,"bee-audio-clip":d.current.clipConfigurable})},ot&&i.createElement(lr,{isAudio:!0}),i.createElement("div",{ref:R,className:b.progress,onMouseDown:Bt,onMouseMove:Nt},i.createElement("div",{className:$({[b.radioTooltip]:!0}),style:{left:Ie}},qe(P)),i.createElement("div",{className:$({[b.radioTooltip]:!0,[b.mouseTooltip]:!0}),style:{left:Dt}},qe(he)),i.createElement(Pr,{playPercentage:Ie})),Wt&&(me==null?void 0:me({currentTime:P,remainingTime:Ft,audioPlayer:w()})))),i.createElement("div",{className:b.controlBar},i.createElement(ir,{type:"link",icon:xt,onClick:()=>{B()},className:$({[b.playButton]:!0,[b.playButtonDisabled]:ge})}),i.createElement("span",{className:b.time},`${Ke(P,"ss.SSS")} / -${Ke(N-P,"ss.SSS")}`),i.createElement(ar,{playerType:ur.Audio,onChange:e=>{Ot(e)}}),i.createElement(pr,{onChange:e=>{Te(e)},zoom:F}),i.createElement(fr,{EventBus:E})));return c?i.createElement(rt.Provider,{value:c},Fe,x.map(e=>{const{id:r}=e,t=document.querySelector(`[data-id=${r}]`);return t?i.createElement(vr,{el:t,key:r,region:e,edgeAdsorption:Ce,clipping:J,zoom:F,instance:I(r)}):null}),i.createElement(Dr,{footer:mt})):Fe};export{Or as AudioPlayer,rt as AudioPlayerContext};
1
+ import l,{useState as b,useRef as z,useEffect as A}from"react";import{getWebPcm2WavBase64 as Yt}from"../audioAnnotate/utils/getWebPcm2Wac.js";import Jt,{debounce as Qt,sortBy as er}from"lodash";import{PauseOutlined as tr,CaretRightOutlined as rr}from"@ant-design/icons";import{cKeyCode as or,cTool as nr,EventBus as E,TagUtils as ir}from"@labelbee/lb-annotation";import{Button as lr}from"antd";import sr from"../invalidPage/index.js";import ar from"../imageError/index.js";import{classnames as $}from"../../utils/index.js";import ur,{EPlayerType as cr}from"../videoPlayer/components/SpeedController/index.js";import dr from"@labelbee/wavesurfer";import mr from"@labelbee/wavesurfer/dist/plugin/wavesurfer.regions.js";import fr from"@labelbee/wavesurfer/dist/plugin/wavesurfer.cursor.js";import pr,{audioZoomInfo as qe}from"./zoomSlider/index.js";import vr from"./labelDisplayToggle/index.js";import gr from"./clipRegion/index.js";import{useAudioClipStore as br}from"../audioAnnotate/audioContext/index.js";import{useLatest as H,useUpdate as yr,useDeepCompareEffect as Ke,useThrottleFn as _r}from"ahooks";import Er from"./useAudioScroll/index.js";import y from"./index.module.scss.js";import{getAttributeColor as hr,formatTime as Ve,timeFormat as Ge,dispatchResizeEvent as Sr,precisionMinus as Ye,isDoubleClick as Cr,getCanMoveRange as Pr}from"../../utils/audio.js";import Rr from"./progressDot/index.js";import wr from"./clipTip/index.js";import Tr from"./useSwitchHotkey/index.js";import Ar from"./useAudioCombine/index.js";import jr from"./useAudioSegment/index.js";import xr from"./combineTip/index.js";import Dr from"./segmentTip/index.js";import kr from"../../views/MainView/toolFooter/index.js";import{decimalReserved as U}from"../videoPlayer/utils.js";var Mr=Object.defineProperty,Ir=Object.defineProperties,Br=Object.getOwnPropertyDescriptors,Je=Object.getOwnPropertySymbols,Or=Object.prototype.hasOwnProperty,Lr=Object.prototype.propertyIsEnumerable,Qe=(g,u,c)=>u in g?Mr(g,u,{enumerable:!0,configurable:!0,writable:!0,value:c}):g[u]=c,et=(g,u)=>{for(var c in u||(u={}))Or.call(u,c)&&Qe(g,c,u[c]);if(Je)for(var c of Je(u))Lr.call(u,c)&&Qe(g,c,u[c]);return g},tt=(g,u)=>Ir(g,Br(u));const{EToolName:rt}=nr,X=or.default,ot=.1,nt=l.createContext({count:0,isEdit:!1,toolName:rt.Empty,imgIndex:0}),Nr=({fileData:g={},onLoaded:u,context:c,invalid:it,height:lt,hideError:st,onError:ce,updateRegion:j,removeRegion:O,regions:x=[],activeToolPanel:at,clipConfigurable:ut,clipTextConfigurable:de,clipAttributeList:ct,clipAttributeConfigurable:me,secondaryAttributeConfigurable:dt,subAttributeList:mt,isCheck:C,hoverRegionId:Z,footer:ft,drawLayerSlot:fe,clipTextList:pe})=>{var ve,ge;const{url:L,path:be}=g,[q,K]=b(!1),[ye,_e]=b(!1),[P,pt]=b(0),[vt,Ee]=b(!1),[N,he]=b(0),n=z(null),R=z(null),Se=z(P),V=e=>{Se.current=e,pt(e)},[Ce,gt]=b(0),[F,bt]=b(1),G=z(null),[Pe,yt]=b({}),{audioClipState:Y,setAudioClipState:M}=br(),[J,Q]=b(!1),d=H(Y),Re=H(Pe),_t=H(q),D=H(x),we=yr(),[Te,Et]=b([]),[Ae,ht]=b({}),St=Qt(()=>{E.emit("audioZoom")},500),je=e=>{e<qe.min||e>qe.max||(bt(e),Sr(),St())};Er({container:G.current,target:document.querySelector(`[data-id=${(ge=(ve=d.current)==null?void 0:ve.selectedRegion)==null?void 0:ge.id}]`),clipping:J,zoom:F,zoomHandler:je});const W=()=>{let e=D.current;const{attributeLockList:r}=d.current;r.length&&(e=e.filter(t=>r.includes(t.attribute))),te(),e.forEach(t=>{var o;(o=n.current)==null||o.addRegion(tt(et({},t),{drag:!C,resize:!C,color:"rgba(0, 0, 0, 0)"}))}),we()},m=e=>{var r,t,o,s,a,f,v;const{id:i,loop:p=!0,playImmediately:S=!1}=e;if(i){const k=(o=(t=(r=n.current)==null?void 0:r.regions)==null?void 0:t.list)!=null?o:{};Object.entries(k).forEach(([,_])=>{const{id:T}=_;i===T?_.select():_.cancelSelect()}),M({selectedRegion:{id:i,loop:p},selectedAttribute:(f=(a=(s=D.current)==null?void 0:s.find(_=>_.id===i))==null?void 0:a.attribute)!=null?f:""}),p&&S&&((v=I(i))==null||v.playLoop())}else M({selectedRegion:{}})},{combineInstance:Ct}=Ar({waveRef:n,sortByStartRegions:Te,regionMap:Ae,updateRegion:j,removeRegion:O,generateRegions:W,setSelectedRegion:m}),{segmentInstance:Pt,onRegionMouseMove:Rt,segmentTimeTip:wt}=jr({waveRef:n,regionMap:Ae,updateRegion:j,removeRegion:O,generateRegions:W,setSelectedRegion:m}),xe={clipTextConfigurable:de,clipAttributeList:ct,clipAttributeConfigurable:me,clipConfigurable:ut,secondaryAttributeConfigurable:dt,subAttributeList:mt,clipTextList:pe};A(()=>{M({selectedAttribute:""})},[me]),A(()=>{ee()},[Y.selectedAttribute]),A(()=>{W()},[Y.attributeLockList]),Ke(()=>{M(xe),setTimeout(()=>{De()})},[xe]),Ke(()=>{Et(er(x,["start"])),ht(x.reduce((e,r)=>{const{id:t}=r;return tt(et({},e),{[t]:r})},{}))},[x]),A(()=>{if(Z){const e=_t.current;m({id:Z,loop:e,playImmediately:!0})}else m({})},[Z]);const De=()=>{var e,r;d.current.clipConfigurable?(!C&&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,s;let a="";d.current.clipConfigurable?a=hr(d.current.selectedAttribute,(e=d.current.clipAttributeList)!=null?e:[]):a="transparent",((t=(r=n==null?void 0:n.current)==null?void 0:r.cursor)==null?void 0:t.cursor)&&((s=(o=n==null?void 0:n.current)==null?void 0:o.cursor)==null||s.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]},ke=()=>{var e,r;if(L){const t=((r=(e=be==null?void 0:be.split("."))==null?void 0:e.pop())==null?void 0:r.toLowerCase())==="pcm";Ee(!1),t?Yt(L).then(o=>{Me(o)}):Me(L)}},Me=e=>{var r;e&&(_e(!0),V(0),he(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(),O==null||O(e),m({}))},{run:Ie}=_r(m,{wait:500});Tr({sortByStartRegions:Te,setSelectedRegion:m});const Tt=e=>{const{start:r,end:t}=Re.current;return(r||t)&&e.update(Re.current),e},At=({action:e,id:r,eventDownTime:t})=>{var o,s;if(!d.current.clipConfigurable)return;r&&m({id:r});const a=I((r!=null?r:(o=d.current.selectedRegion)==null?void 0:o.id)||""),f=[];(e==="create"?D.current:(s=D.current)==null?void 0:s.filter(p=>p.id!==a.id)).forEach(p=>{const{start:S,end:k,attribute:_}=p;_===d.current.selectedAttribute&&[S,k].forEach(T=>{f.includes(T)||f.push(T)})});const i=Pr(f.sort((p,S)=>p-S),t);n.current.range=i},jt=e=>{ee(),setTimeout(()=>{Q(!1)});const r=Tt(e),{id:t,start:o,end:s}=r;m({id:t,playImmediately:!0});const a={id:t,start:U(o,3),end:U(s,3)};j==null||j(a),we()},xt=()=>{const e=dr.create({container:"#waveform",waveColor:"#999",progressColor:"#999",height:lt||245,normalize:!0,cursorWidth:2,cursorColor:"white",responsive:0,hideScrollbar:!0,plugins:[mr.create({regions:x,dragSelection:{slop:5},canMove:!1}),fr.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;he(o),r(),u==null||u({duration:Math.round(o)}),_e(!1),B(),E.on("setCurrentTimeByPosition",ne),E.on("clearRegions",te),E.on("removeRegionById",re),E.on("setSelectedRegion",Ie),e.on("regions-eventDown",At),De()}),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",()=>{Ee(!0),u==null||u({hasError:!0}),ce==null||ce()}),e.on("region-created",t=>{var o;const{id:s,start:a,end:f}=t;if(D.current.find(i=>i.id===s))return;const v={id:s,start:U(a,3),end:U(f,3),attribute:d.current.selectedAttribute,text:""};if(d.current.secondaryAttributeConfigurable){const i=ir.getDefaultResultByConfig((o=d.current.subAttributeList)!=null?o:[]);v.subAttribute=i!=null?i:{}}de&&pe.forEach((i,p)=>{p===0?Object.assign(v,{text:i==null?void 0:i.default}):Object.assign(v,{[i.key]:i==null?void 0:i.default})}),j==null||j(v)}),e.on("region-updated",(t,o)=>{var s,a,f,v,i,p,S,k,_,T;const $e=o==null?void 0:o.action;M({combined:!1,segment:!1}),$e==="resize"&&((a=(s=n==null?void 0:n.current)==null?void 0:s.cursor)==null||a.setStyle({borderStyle:"solid"})),$e==="drag"&&((v=(f=n==null?void 0:n.current)==null?void 0:f.cursor)==null||v.setStyle({borderColor:"transparent"}));const ie={},le=[],se={},$t=(i=D.current)==null?void 0:i.filter(h=>h.id!==t.id),Ht=(k=(S=(p=n.current)==null?void 0:p.regions)==null?void 0:S.list)!=null?k:{};$t.forEach(h=>{var Ue,Xe;const{element:ae}=(Ue=Ht[h.id])!=null?Ue:{},{start:Zt,end:qt}=h;if(ae){const{x:Ze,width:Kt}=((Xe=ae.getBoundingClientRect)==null?void 0:Xe.call(ae))||{},Vt=Ze+Kt;[Ze,Vt].forEach((ue,Gt)=>{le.includes(ue)||(le.push(ue),se[ue]=Gt===0?Zt:qt)})}});const{x:He,width:Ut}=((T=(_=t.element).getBoundingClientRect)==null?void 0:T.call(_))||{},Xt=He+Ut;le.forEach(h=>{Math.abs(Ye(h,He))<5&&(ie.start=se[h]),Math.abs(Ye(h,Xt))<5&&(ie.end=se[h])}),yt(ie),Ie({id:t.id}),Q(!0)}),e.on("region-update-end",t=>{jt(t)}),e.on("region-contextmenu",(t,o)=>{if(!C){if(o.preventDefault(),o.stopPropagation(),Cr(o)){re(t.id);return}m({id:t.id,playImmediately:!0})}}),e.on("region-click",(t,o,s)=>{if(!C){if(o.preventDefault(),o.stopPropagation(),d.current.combined){Ct(t);return}if(d.current.segment){Pt(t,s);return}m({id:t.id,playImmediately:!0})}}),e.on("region-mousemove",Rt),n.current=e},Dt=q?l.createElement(tr,null):l.createElement(rr,null),Be=e=>e?`${parseFloat((e/N*100).toFixed(4))}%`:"0%",Oe=Be(P),kt=Be(Ce),w=()=>{if(!ye)return n==null?void 0:n.current},Mt=()=>{var e;(e=w())==null||e.skipForward(ot)},It=()=>{var e;(e=w())==null||e.skipBackward(ot)},B=()=>{var e;(e=w())==null||e.playPause(),m({})},Le=e=>{var r;switch(e.keyCode){case X.Right:Mt();break;case X.Left:It();break;case X.Space:e.preventDefault(),B();break;case X.Delete:if(!C){const{id:t}=((r=d.current)==null?void 0:r.selectedRegion)||{};t&&re(t)}break}},Bt=e=>{ne(e)},Ne=Jt.throttle(Bt,50);let oe=!1;const Fe=()=>{oe&&(B(),oe=!1),document.removeEventListener("mousemove",Ne),document.removeEventListener("mouseup",Fe)},Ot=e=>{ne(e),q&&(oe=!0,B()),document.addEventListener("mousemove",Ne),document.addEventListener("mouseup",Fe)},Lt=()=>{ke()};A(()=>(xt(),()=>{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 Nt=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",Le),()=>{document.removeEventListener("keydown",Le)})),A(()=>{m({}),ke()},[L]);const We=e=>{var r,t,o,s;if((n==null?void 0:n.current)&&(R==null?void 0:R.current)){const a=(t=(r=n==null?void 0:n.current)==null?void 0:r.getDuration())!=null?t:0,f=(o=R==null?void 0:R.current)==null?void 0:o.getBoundingClientRect();let i=(e.clientX-f.left)/(((s=R==null?void 0:R.current)==null?void 0:s.clientWidth)||0)*a;return i>a&&(i=a),i}return 0},ne=e=>{var r;const t=We(e);(r=n==null?void 0:n.current)==null||r.skip(t-Se.current),V(t)},Ft=e=>{gt(We(e))},Wt=N?Math.max(N-P,0):0,zt=(c==null?void 0:c.toolName)!==rt.Empty&&(c==null?void 0:c.isEdit)!==!0&&(at==="remark"||C),ze=l.createElement("div",{className:y.audioPlayer},vt&&!st&&l.createElement(ar,{fileTypeName:"\u97F3\u9891",ignoreOffsetY:!0,reloadImage:Lt,backgroundColor:"#ffffffbb"}),l.createElement(wr,{getRegionInstanceById:I,clipping:J}),l.createElement(xr,{container:G.current}),l.createElement(Dr,{segmentTimeTip:wt}),l.createElement("div",{className:y.waveformContainer,ref:G},l.createElement("div",{id:"waveform",style:{width:`${F*100}%`},className:$({[y.waveform]:!0,"bee-audio-combined":d.current.combined,"bee-audio-clip":d.current.clipConfigurable})},it&&l.createElement(sr,{isAudio:!0}),l.createElement("div",{ref:R,className:y.progress,onMouseDown:Ot,onMouseMove:Ft},l.createElement("div",{className:$({[y.radioTooltip]:!0}),style:{left:Oe}},Ve(P)),l.createElement("div",{className:$({[y.radioTooltip]:!0,[y.mouseTooltip]:!0}),style:{left:kt}},Ve(Ce)),l.createElement(Rr,{playPercentage:Oe})),zt&&(fe==null?void 0:fe({currentTime:P,remainingTime:Wt,audioPlayer:w()})))),l.createElement("div",{className:y.controlBar},l.createElement(lr,{type:"link",icon:Dt,onClick:()=>{B()},className:$({[y.playButton]:!0,[y.playButtonDisabled]:ye})}),l.createElement("span",{className:y.time},`${Ge(P,"ss.SSS")} / -${Ge(N-P,"ss.SSS")}`),l.createElement(ur,{playerType:cr.Audio,onChange:e=>{Nt(e)}}),l.createElement(pr,{onChange:e=>{je(e)},zoom:F}),l.createElement(vr,{EventBus:E})));return c?l.createElement(nt.Provider,{value:c},ze,x.map(e=>{const{id:r}=e,t=document.querySelector(`[data-id=${r}]`);return t?l.createElement(gr,{el:t,key:r,region:e,edgeAdsorption:Pe,clipping:J,zoom:F,instance:I(r)}):null}),l.createElement(kr,{footer:ft})):ze};export{Nr as AudioPlayer,nt as AudioPlayerContext};
@@ -1 +1 @@
1
- import{useLatest as S}from"ahooks";import{Spin as H,message as K}from"antd/es";import P,{useContext as Q,useRef as j,useState as W,useMemo as X,useCallback as Y,useEffect as u}from"react";import{connect as Z}from"react-redux";import{useTranslation as ee}from"react-i18next";import{usePointCloudViews as te}from"../pointCloudView/hooks/usePointCloudViews.js";import{PointCloudContext as re}from"../pointCloudView/PointCloudContext.js";import{a2MapStateToProps as ne}from"../../store/annotation/map.js";import{LabelBeeContext as oe}from"../../store/ctx.js";import{PointCloud2DRectOperation as ie,ImgUtils as ae}from"@labelbee/lb-annotation";var ce=Object.defineProperty,le=Object.defineProperties,ue=Object.getOwnPropertyDescriptors,B=Object.getOwnPropertySymbols,se=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable,E=(c,i,r)=>i in c?ce(c,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):c[i]=r,s=(c,i)=>{for(var r in i||(i={}))se.call(i,r)&&E(c,r,i[r]);if(B)for(var r of B(i))de.call(i,r)&&E(c,r,i[r]);return c},d=(c,i)=>le(c,ue(i));const pe=c=>{var i;const{mappingData:r,size:p,config:v,checkMode:A,afterImgOnLoad:N}=c,_=(i=r==null?void 0:r.url)!=null?i:"",{t:U}=ee(),{pointCloudBoxList:f,setPointCloudResult:k,defaultAttribute:R,rectList:g,addRectIn2DView:M,updateRectIn2DView:C,removeRectIn2DView:z}=Q(re),{update2DViewRect:F}=te(),b=P.useRef(null),t=j(null),I=S(F),O=j(null),[T,h]=W(!0),D=X(()=>g==null?void 0:g.filter(e=>e.imageName===(r==null?void 0:r.path)),[r==null?void 0:r.path,g]),m=S(r==null?void 0:r.path),x=e=>{var n;const{boxID:o}=e;if(o){const a=(n=I.current)==null?void 0:n.call(I,e);O.current=a,k(a);return}C(e)},L=e=>{m.current&&M(d(s({},e),{imageName:m.current}))},y=e=>{e.some(o=>o.boxID)&&K.warning(U("ProjectionFrameCannotBeDeleted")),z(e)},J=Y(()=>{let e=[];return f.forEach(n=>{const{rects:o=[],id:a,attribute:l,trackID:$}=n,V=o.find(G=>G.imageName===m.current),q=a+"_"+m.current;V&&(e=[...e,d(s({},V),{boxID:a,id:q,attribute:l,order:$})])}),e},[f]),w=()=>{var e,n,o;const a=J(),l=(e=t.current)==null?void 0:e.selectedRectID;(n=t.current)==null||n.setResult([...a,...D]),l&&((o=t.current)==null||o.setSelectedRectID(l))};return u(()=>{if(b.current){const e=new ie({container:b.current,size:p,config:d(s({},v),{isShowOrder:!0,attributeConfigurable:!0}),checkMode:A});return t.current=e,t.current.init(),t.current.on("updateDragResult",x),t.current.on("afterAddingDrawingRect",L),t.current.on("deleteSelectedRects",y),()=>{var n,o,a,l;(n=t.current)==null||n.unbind("updateDragResult",x),(o=t.current)==null||o.unbind("afterAddingDrawingRect",L),(a=t.current)==null||a.unbind("deleteSelectedRects",y),(l=t.current)==null||l.destroy()}}},[]),u(()=>{h(!0),t.current&&_&&ae.load(_).then(e=>{t.current.setImgNode(e),N(e),h(!1)})},[_]),u(()=>{var e;(e=t.current)==null||e.setSize(p)},[p]),u(()=>{f!==O.current&&w()},[f]),u(()=>{var e,n,o;const a=D.find(l=>l.id===t.current.selectedRectID);(n=(e=t.current)==null?void 0:e.setDefaultAttribute)==null||n.call(e,R),a&&C(d(s({},(o=t.current)==null?void 0:o.selectedRect),{attribute:R})),w()},[R]),u(()=>{w()},[D]),u(()=>{var e,n,o,a;const l=(n=(e=t.current)==null?void 0:e.config)!=null?n:{};(a=t.current)==null||a.setConfig(JSON.stringify(d(s({},l),{attributeList:(o=v.attributeList)!=null?o:[]})))},[v.attributeList]),P.createElement(H,{spinning:T},P.createElement("div",{ref:b,style:s({position:"relative"},p)}))};var fe=Z(ne,null,null,{context:oe})(pe);export{fe 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 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{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 nt,MathUtils as w,getCuboidFromPointCloudBox as Gt}from"@labelbee/lb-annotation";import{EPerspectiveView as G,PointCloudUtils as O,POINT_CLOUD_DEFAULT_STEP as Jt,DEFAULT_SPHERE_PARAMS as Qt}from"@labelbee/lb-utils";import{useContext as Xt}from"react";import{PointCloudContext as Yt}from"../PointCloudContext.js";import{useSingleBox as qt}from"./useSingleBox.js";import{useSphere as Kt}from"./useSphere.js";import{useSelector as $t,useDispatch as to}from"../../../store/ctx.js";import oo from"../../../utils/StepUtils.js";import{jsonParser as it,getRectPointCloudBox as eo}from"../../../utils/index.js";import{PreDataProcess as st,SetPointCloudLoading as Ct,SetLoadPCDFileLoading as Pt}from"../../../store/annotation/actionCreators.js";import{useHistory as no}from"./useHistory.js";import{usePolygon as io}from"./usePolygon.js";import{useLatest as so}from"ahooks";var ro=Object.defineProperty,lo=Object.defineProperties,ao=Object.getOwnPropertyDescriptors,mt=Object.getOwnPropertySymbols,co=Object.prototype.hasOwnProperty,uo=Object.prototype.propertyIsEnumerable,ht=(e,t,r)=>t in e?ro(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,v=(e,t)=>{for(var r in t||(t={}))co.call(t,r)&&ht(e,r,t[r]);if(mt)for(var r of mt(t))uo.call(t,r)&&ht(e,r,t[r]);return e},R=(e,t)=>lo(e,ao(t)),rt=(e,t,r)=>new Promise((a,o)=>{var c=p=>{try{u(r.next(p))}catch(m){o(m)}},g=p=>{try{u(r.throw(p))}catch(m){o(m)}},u=p=>p.done?a(p.value):Promise.resolve(p.value).then(c,g);u((r=r.apply(e,t)).next())});const q=5,K=90,xt=.01,L={"3D":"3D",Top:"Top",Side:"Side",Back:"Back"},lt=(e,t,r,a,o)=>{const{x:c,y:g}=O.transferCanvas2World(e,t),{defaultZ:u}=Qt,p={center:{x:c,y:g,z:u},id:e.id},m=a?v(v({},a),p):R(v({},p),{attribute:"",valid:!0});return o&&Object.assign(m,o),m},dt=(e,t,r,a,o,c)=>{let g=e.pointList.map(B=>O.transferCanvas2World(B,t)),u=0,p=1,m={};if(r){const B=r.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[x,I,F]=g,A=w.getLineCenterPoint([x,F]),U=w.getLineLength(x,I),k=w.getLineLength(I,F),j=w.getRadiusFromQuadrangle(e.pointList);a&&(u=a.center.z,p=a.depth);const z={center:{x:A.x,y:A.y,z:u},width:c?k+xt:k,height:c?U+xt:U,depth:p,rotation:j,id:e.id},T=v(a?v(v({},a),z):R(v({},z),{attribute:"",valid:!0}),m);o&&Object.assign(T,o);const N=g.map(B=>O.transferWorld2Canvas(B,t));return{boxParams:T,newPointList:N}},vt=(e,t,r)=>{const a={x:e.x-t.x,y:e.y-t.y};return R(v({},r),{center:{x:r.center.x-a.x,y:r.center.y,z:r.center.z-a.y}})},Lt=(e,t,r,a)=>{const[o,c,g]=e.pointList,[u,p,m]=t.pointList,x=w.getLineCenterPoint([o,g]),I=w.getLineCenterPoint([u,m]),A={x:{x:x.x-I.x,y:x.y-I.y}.x,y:0,z:x.y-I.y},U=w.getLineLength(o,c),k=w.getLineLength(u,p),j=U-k,z=w.getLineLength(c,g),T=w.getLineLength(p,m),N=z-T,{newBoxParams:B}=a.getNewBoxBySideUpdate(A,N,j,r);return B},po=(e,t,r)=>{const a={x:e.x-t.x,y:e.y-t.y};return R(v({},r),{center:{x:r.center.x,y:r.center.y-a.x,z:r.center.z-a.y}})},go=(e,t,r,a)=>{const[o,c,g]=e.pointList,[u,p,m]=t.pointList,x=w.getLineCenterPoint([o,g]),I=w.getLineCenterPoint([u,m]),A={x:{x:x.x-I.x,y:x.y-I.y}.x,y:0,z:x.y-I.y},U=w.getLineLength(o,c),k=w.getLineLength(u,p),j=U-k,z=w.getLineLength(c,g),T=w.getLineLength(p,m),N=z-T;let{newBoxParams:B}=a.getNewBoxByBackUpdate(A,N,j,r);return B},yt=(e,t,r,a,o)=>{var c;if(!r)return;const{toolInstance:g,pointCloudInstance:u}=r;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:x}=u.getSphereSidePoint2DCoordinate(e);u.camera.zoom=x,u.camera.updateProjectionMatrix(),u.render(),g.initPosition(),g.zoomChangeOnCenter(x),g.setResult([R(v(v({},t),m),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},Bt=(e,t,r,a)=>{if(!r)return;const{pointCloud2dOperation:o,pointCloudInstance:c}=r;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,r,a,o)=>{var c;if(!r)return;const{toolInstance:g,pointCloudInstance:u}=r;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:x}=u.getSphereBackPoint2DCoordinate(e);u.camera.zoom=x,u.camera.updateProjectionMatrix(),u.render(),g.initPosition(),g.zoomChangeOnCenter(x),g.setResult([R(v(v({},t),m),{valid:e.valid,textAttribute:"",attribute:e.attribute})]),g.setSelectedID(t.id)},wt=(e,t,r,a)=>{if(!r)return;const{pointCloud2dOperation:o,pointCloudInstance:c}=r;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,r,a)=>{if(!r||!a)return;a.generateSphere(e),a.updateCameraBySphere(e,G.Top),a.render();const{toolInstance:o,pointCloudInstance:c}=r,{point2d:g}=c.getSphereTopPoint2DCoordinate(e),u=[...o.pointList].map(p=>p.id===t.id?R(v(v({},t),g),{valid:e.valid,textAttribute:"",attribute:e.attribute}):p);o.setResult(u),o.setSelectedID(t.id)},at=(e,t,r,a)=>{var o,c;if(!r||!a)return;a.generateBox(e,t.id),a.render();const{pointCloud2dOperation:g,pointCloudInstance:u}=r,{polygon2d:p}=u.getBoxTopPolygon2DCoordinate(e),m=[...g.polygonList],x=m.find(I=>I.id===t.id);x?(x.pointList=p,x.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)},fo=()=>{const e=Xt(Yt),{topViewInstance:t,sideViewInstance:r,backViewInstance:a,mainViewInstance:o,addPointCloudBox:c,addPointCloudSphere:g,setSelectedIDs:u,selectedIDs:p,pointCloudBoxList:m,pointCloudSphereList:x,hideAttributes:I,setHighlight2DDataList:F,cuboidBoxIn2DView:A,imageSizes:U}=e,{addHistory:k,initHistory:j,pushHistoryUnderUpdatePolygon:z}=no(),{selectedPolygon:T}=io(),{getPointCloudSphereByID:N,updatePointCloudSphere:B,selectedSphere:J}=Kt(),{currentData:H,config:S}=$t(n=>{const{stepList:i,step:d,imgList:s,imgIndex:l}=n.annotation;return{currentData:s[l],config:it(oo.getCurrentStepInfo(d,i).config)}}),E=to(),St=so(A),$=n=>{if(!St.current){const{mappingImgList:i=[]}=H,d=i.map(s=>eo({pointCloudBox:n,mappingData:s,imageSizes:U}));Object.assign(n,{rects:d.filter(s=>s!==void 0)})}},{selectedBox:D,updateSelectedBox:Dt,updateSelectedBoxes:tt,getPointCloudByID:_t}=qt({generateRects:$}),ct=D==null?void 0:D.info;if(!t||!r||!a)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()},Rt=({newPoint:n,size:i,zoom:d,trackConfigurable:s})=>{var l;const f={attribute:(l=t.toolInstance.defaultAttribute)!=null?l:""};s===!0&&Object.assign(f,{trackID:O.getNextTrackID({imgList:[],extraBoxList:[],extraSphereList:x})});const P=lt(n,i,ot,void 0,f);u(n.id);const C=g(P);Q(L.Top,n,P,d,C,S),k({newSphereParams:P})},kt=({polygon:n,size:i,imgList:d,trackConfigurable:s,zoom:l,intelligentFit:f})=>{var P,C;const h={attribute:(P=t.toolInstance.defaultAttribute)!=null?P:""};s===!0&&Object.assign(h,{trackID:O.getNextTrackID({imgList:[],extraBoxList:m,extraSphereList:x})});const _=t==null?void 0:t.toolInstance,V=v({},n);let{boxParams:y,newPointList:b}=dt(V,i,ot,void 0,h,f);y=E(st({tool:nt.PointCloud,dataList:[y],stepConfig:S,action:"viewUpdateBox"}))[0],f&&(b==null?void 0:b.length)&&(V.pointList=b);const X=I.includes(V.attribute);$(y);const M=c(y),et=(C=e==null?void 0:e.polygonList)!=null?C:[];t==null||t.updatePolygonList(M!=null?M:[],et),X?u([]):(u(y.id),_.selection.setSelectedIDs(V.id),W({omitView:L.Top,polygon:V,boxParams:y,zoom:l,newPointCloudBoxList:M}),f&&at(y,V,t,o)),k({newBoxParams:y})},At=n=>{const{boxID:i,imageName:d,width:s,height:l,x:f,y:P}=n,C=m.find(b=>b.id===i);if(!(C==null?void 0:C.rects)||!C.rects.find(b=>b.imageName===d))return;const _=C.rects.map(b=>b.imageName===d?R(v({},b),{width:s,height:l,x:f,y:P}):b),V=R(v({},C),{rects:_}),y=m.map(b=>b.id===i?V:b);return t==null||t.updatePolygonList(y!=null?y:[]),y},Ut=n=>{const{boxID:i,imageName:d}=n,s=m.find(C=>C.id===i);if(!(s==null?void 0:s.rects))return;const l=s.rects.filter(C=>C.imageName!==d),f=R(v({},s),{rects:l}),P=m.map(C=>C.id===i?f:C);return t==null||t.updatePolygonList(P!=null?P:[]),P},zt=({newSelectedBox:n,newPointCloudList:i,newSelectedSphere:d,newSphereList:s})=>{var l;const f=t==null?void 0:t.toolInstance;if(!(p.length===0||!f)){if(n||(D==null?void 0:D.info)){const P=n!=null?n:D==null?void 0:D.info;(l=f==null?void 0:f.selection)==null||l.setSelectedIDs(p[0]);const C=f.selectedPolygon;if(p.length===1&&P){W({omitView:L.Top,polygon:C,boxParams:P,newPointCloudBoxList:i});return}}if((d||J)&&p.length===1){const P=d!=null?d:J;f.setSelectedID(p[0]);const C=f.selectedPoint;P&&Q(L.Top,C,P,void 0,s,S)}}},ut=(n,i,d)=>{if(ct){let s,l;switch(d){case L.Back:s=go;break;case L.Side:s=Lt;break;default:s=Lt;break}if(l=s(n,i,ct,r.pointCloudInstance),o){const{count:_}=o.getSensesPointZAxisInPolygon(Gt(l).polygonPointList,[l.center.z-l.depth/2,l.center.z+l.depth/2]);l=R(v({},l),{count:_})}const P=E(st({tool:nt.PointCloud,dataList:[l],stepConfig:S,action:"viewUpdateBox"}))[0],C=l.valid!==P.valid;l=P;const h=Dt(l);return l=h.find(_=>_.id===l.id),W({omitView:C?void 0:d,polygon:n,boxParams:l,newPointCloudBoxList:h}),h}},pt=(n,i,d)=>{if(J){let s,l;switch(d){case L.Back:s=po;break;case L.Side:s=vt;break;default:s=vt;break}l=s(n,i,J);const f=B(l);return Q(d,n,l,void 0,f,S),f}},Tt=(n,i)=>{pt(n,i,L.Side)},jt=(n,i)=>{pt(n,i,L.Back)},Nt=(n,i)=>{ut(n,i,L.Side)},Et=(n,i)=>{ut(n,i,L.Back)},Ft=(n,i)=>{const d=N(n.id),s=lt(n,i,ot,d),l=B(s);Q(L.Top,n,s,void 0,l,S)},Ht=(n,i)=>{if(T){const s=v({},n[0].newPolygon);s.pointList=s.pointList.map(l=>O.transferCanvas2World(l,i)),z(s);return}let d=n.map(({newPolygon:s})=>{const l=_t(s.id),{boxParams:f}=dt(s,i,t.pointCloudInstance,l);return f});if(d=E(st({tool:nt.PointCloud,dataList:d,stepConfig:S,action:"viewUpdateBox"})),d.length===1){const{newPolygon:s}=n[0],l=tt(d);W({polygon:s,boxParams:d[0],newPointCloudBoxList:l})}else{const s=tt(d);s&&e.syncAllViewPointCloudColor(s)}},Wt=n=>{var i,d,s,l,f;if(D){const P=Number(n.widthDefault),C=Number(n.depthDefault),h=Number(n.heightDefault),_=D==null?void 0:D.info.trackID,y=((i=t==null?void 0:t.toolInstance)==null?void 0:i.polygonList).find(Y=>(Y==null?void 0:Y.trackID)===_),b={width:(s=(d=t==null?void 0:t.toolInstance)==null?void 0:d.basicImgInfo)==null?void 0:s.width,height:(f=(l=t==null?void 0:t.toolInstance)==null?void 0:l.basicImgInfo)==null?void 0:f.height},Z=y.pointList.map(Y=>O.transferCanvas2World(Y,b)),X=w.getModifiedRectangleCoordinates(Z,h,P),M=X[0],et=X[2],gt=w.getLineCenterPoint([M,et]),Zt=D.info.center.z-D.info.depth/2,ft=R(v({},D.info),{center:{x:gt.x,y:gt.y,z:Zt+C/2},width:P,height:h,depth:C,valid:!0}),Mt=tt([ft]);W({omitView:L["3D"],polygon:y,boxParams:ft,newPointCloudBoxList:Mt})}},Q=(n,i,d,s,l,f)=>rt(void 0,null,function*(){const P=H==null?void 0:H.url,C={[L.Side]:()=>{yt(d,i,r,P,f)},[L.Back]:()=>{a&&bt(d,i,a,P,f)},[L.Top]:()=>{It(d,i,t,o)}};Object.keys(C).forEach(h=>{h!==n&&C[h]()}),s&&(o==null||o.updateCameraZoom(s)),Ot(d)}),W=n=>rt(void 0,null,function*(){const{omitView:i,polygon:d,boxParams:s,zoom:l,newPointCloudBoxList:f}=n,P=H==null?void 0:H.url;f&&(yield e.syncAllViewPointCloudColor(f));const C={[L.Side]:()=>{Bt(s,d,r,P)},[L.Back]:()=>{a&&wt(s,d,a,P)},[L.Top]:()=>{at(s,d,t,o)}};Object.keys(C).forEach(h=>{h!==i&&C[h]()}),l&&(o==null||o.updateCameraZoom(l)),Vt(s)});return{topViewAddSphere:Rt,topViewAddBox:kt,topViewSelectedChanged:zt,topViewUpdatePoint:Ft,sideViewUpdatePoint:Tt,backViewUpdatePoint:jt,topViewUpdateBox:Ht,sideViewUpdateBox:Nt,backViewUpdateBox:Et,pointCloudBoxListUpdated:n=>{t.updatePolygonList(n),o==null||o.generateBoxes(n)},initPointCloud3d:n=>{if(!o)return;const i=O.getDefaultOrthographicParams(n);o.initOrthographicCamera(i),o.initRenderer(),o.render()},updatePointCloudData:(...n)=>rt(void 0,[...n],function*(i=H){var d,s,l,f,P,C;if(!(i==null?void 0:i.url)||!o)return;F([]),Ct(E,!0),Pt(E,!0),yield o.loadPCDFile(i.url,(d=S==null?void 0:S.radius)!=null?d:K),o==null||o.clearAllBox(),o==null||o.clearAllSphere();let h=[],_=[],V=[],y=[];o.updateTopCamera();const b=(l=(s=it(i.result))==null?void 0:s.valid)!=null?l:!0;if(e.setPointCloudValid(b),(f=e.sideViewInstance)==null||f.clearAllData(),(P=e.backViewInstance)==null||P.clearAllData(),i.result){if(h=O.getBoxParamsFromResultList(i.result),(h==null?void 0:h.length)>0&&i.isPreResult&&(S==null?void 0:S.lowerLimitPointsNumInBox)>0){h=yield o==null?void 0:o.filterPreResult(i.url,S,h);const Z=it(i.result);Z[Jt].result=h,i.result=JSON.stringify(Z),e.setPointCloudResult(h)}V=O.getPolygonListFromResultList(i.result),_=O.getLineListFromResultList(i.result),y=O.getSphereParamsFromResultList(i.result),t.updateData(i.url,i.result,{radius:(C=S==null?void 0:S.radius)!=null?C:K}),o==null||o.generateBoxes(h),o==null||o.generateSpheres(y),yield e.syncAllViewPointCloudColor(h,[])}j({pointCloudBoxList:h,polygonList:V,lineList:_,pointCloudSphereList:y}),Ct(E,!1),Pt(E,!1)}),updateViewsByDefaultSize:Wt,generateRects:$,update2DViewRect:At,remove2DViewRect:Ut}};export{bt as syncBackViewByPoint,yt as syncSideViewByPoint,It as syncTopViewByPoint,wt as synchronizeBackView,Bt as synchronizeSideView,at as synchronizeTopView,lt as topViewPoint2PointCloud,dt as topViewPolygon2PointCloud,fo as usePointCloudViews};