@labelbee/lb-components 1.21.0-alpha.9 → 1.21.1

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.
@@ -1 +1 @@
1
- "use strict";var React=require("react"),antd=require("antd"),index=require("../../../../../constant/index.js"),classNames=require("classnames"),imgFail_cn=require("../../../../../assets/annotation/LLMTool/imgFail_cn.svg.js"),imgFail_en=require("../../../../../assets/annotation/LLMTool/imgFail_en.svg.js"),lbUtils=require("@labelbee/lb-utils"),index_module=require("./index.module.scss.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),classNames__default=_interopDefaultLegacy(classNames);const LLMViewCls=`${index.prefix}-LLMView`,ImgView=e=>{const{answerList:t,hoverKey:r}=e,l=lbUtils.i18n.language==="en"?imgFail_en:imgFail_cn;return React__default.default.createElement("div",{className:index_module.imgView},t.map((a,s)=>React__default.default.createElement("div",{key:s,className:index_module.item},React__default.default.createElement(antd.Tag,{className:`${LLMViewCls}__tag`},a==null?void 0:a.order),React__default.default.createElement("div",{className:classNames__default.default({[`${index_module.image}`]:!0,[`${LLMViewCls}__contentActive`]:r===(a==null?void 0:a.order)})},React__default.default.createElement(antd.Image,{src:a==null?void 0:a.url,fallback:l})))))};module.exports=ImgView;
1
+ "use strict";var React=require("react"),antd=require("antd"),index=require("../../../../../constant/index.js"),classNames=require("classnames"),imgFail_cn=require("../../../../../assets/annotation/LLMTool/imgFail_cn.svg.js"),imgFail_en=require("../../../../../assets/annotation/LLMTool/imgFail_en.svg.js"),lbUtils=require("@labelbee/lb-utils"),index_module=require("./index.module.scss.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),classNames__default=_interopDefaultLegacy(classNames);const LLMViewCls=`${index.prefix}-LLMView`,ImgView=e=>{const{answerList:t,hoverKey:r}=e,l=lbUtils.i18n.language==="en"?imgFail_en:imgFail_cn;return React__default.default.createElement("div",{className:index_module.imgView},t.map((a,s)=>React__default.default.createElement("div",{key:s,className:index_module.item},React__default.default.createElement(antd.Tag,{className:`${LLMViewCls}-tag`},a==null?void 0:a.order),React__default.default.createElement("div",{className:classNames__default.default({[`${index_module.image}`]:!0,[`${LLMViewCls}__contentActive`]:r===(a==null?void 0:a.order)})},React__default.default.createElement(antd.Image,{src:a==null?void 0:a.url,fallback:l})))))};module.exports=ImgView;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),antd=require("antd"),index=require("../../../constant/index.js"),classNames=require("classnames"),reactI18next=require("react-i18next"),lbUtils=require("@labelbee/lb-utils"),index$4=require("../../markdownView/index.js"),index$1=require("../modelAPIView/index.js"),index$5=require("../../diffMatchPatchComponent/index.js"),index$2=require("./components/header/index.js"),index$3=require("./components/imgView/index.js"),_=require("lodash");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),classNames__default=_interopDefaultLegacy(classNames),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,r)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,__spreadValues=(e,t)=>{for(var r in t||(t={}))__hasOwnProp.call(t,r)&&__defNormalProp(e,r,t[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(t))__propIsEnum.call(t,r)&&__defNormalProp(e,r,t[r]);return e};const LLMViewCls=`${index.prefix}-LLMView`,RenderAnswer=({i:e,dataFormatType:t,isTextControl:r})=>{var l;return t===index.EDataFormatType.Markdown?React__default.default.createElement(index$4,{value:(l=e==null?void 0:e.newAnswer)!=null?l:e==null?void 0:e.answer}):r?React__default.default.createElement("div",{style:{width:"100%",overflowWrap:"break-word"}},React__default.default.createElement(index$5,{originString:e==null?void 0:e.answer,currentString:e==null?void 0:e.newAnswer})):React__default.default.createElement("div",{style:{whiteSpace:"pre-wrap"}},(e==null?void 0:e.newAnswer)||(e==null?void 0:e.answer))},QuestionView=e=>{var t,r;const{hoverKey:l,answerList:u,question:i,lang:d,modelAPIResponse:f,setModelAPIResponse:m,checkMode:p=!0,LLMConfig:n,answerHeaderSlot:w}=e,[s,x]=React.useState(index.EDataFormatType.Default),E=((t=n==null?void 0:n.dataType)==null?void 0:t.prompt)===index.ELLMDataType.Picture,y=((r=n==null?void 0:n.dataType)==null?void 0:r.response)===index.ELLMDataType.Picture,{t:g}=reactI18next.useTranslation();React.useEffect(()=>{var a;d&&((a=lbUtils.i18n)==null||a.changeLanguage(d))},[]);const L=a=>{var o;return(n==null?void 0:n.isTextEdit)?!!((o=((n==null?void 0:n.textEdit)||[]).filter(v=>(v==null?void 0:v.title)===a.order)[0])==null?void 0:o.textControl):!1},P=React__default.default.createElement("div",null,u.map((a,o)=>{const c=L(a);return React__default.default.createElement("div",{className:classNames__default.default({[`${LLMViewCls}__content`]:!0,[`${LLMViewCls}__contentActive`]:l===(a==null?void 0:a.order)}),key:o},React__default.default.createElement(antd.Tag,{className:`${LLMViewCls}__tag`},a==null?void 0:a.order),React__default.default.createElement(RenderAnswer,{i:a,isTextControl:c,dataFormatType:s}))}),_.isString(i)&&React__default.default.createElement(index$1,{dataFormatType:s,modelAPIResponse:f,question:i,setModelAPIResponse:m,checkMode:p,annotation:e.annotation}));return React__default.default.createElement("div",{className:LLMViewCls},React__default.default.createElement(index$2,{question:i,dataFormatType:s,setDataFormatType:x,isImg:E}),React__default.default.createElement("div",{className:`${LLMViewCls}__textBox`},React__default.default.createElement("div",{className:`${LLMViewCls}__title`},g("Answer")," ",w),y?React__default.default.createElement(index$3,{hoverKey:l,answerList:u}):P))},WrapQuestionView=e=>React__default.default.createElement(reactI18next.I18nextProvider,{i18n:lbUtils.i18n},React__default.default.createElement(QuestionView,__spreadValues({},e)));exports.LLMViewCls=LLMViewCls,exports.default=WrapQuestionView;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),antd=require("antd"),index=require("../../../constant/index.js"),classNames=require("classnames"),reactI18next=require("react-i18next"),lbUtils=require("@labelbee/lb-utils"),index$4=require("../../markdownView/index.js"),index$1=require("../modelAPIView/index.js"),index$5=require("../../diffMatchPatchComponent/index.js"),index$2=require("./components/header/index.js"),index$3=require("./components/imgView/index.js"),_=require("lodash");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),classNames__default=_interopDefaultLegacy(classNames),__defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,r)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,__spreadValues=(e,t)=>{for(var r in t||(t={}))__hasOwnProp.call(t,r)&&__defNormalProp(e,r,t[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(t))__propIsEnum.call(t,r)&&__defNormalProp(e,r,t[r]);return e};const LLMViewCls=`${index.prefix}-LLMView`,RenderAnswer=({i:e,dataFormatType:t,isTextControl:r})=>{var l;return t===index.EDataFormatType.Markdown?React__default.default.createElement(index$4,{value:(l=e==null?void 0:e.newAnswer)!=null?l:e==null?void 0:e.answer}):r?React__default.default.createElement("div",{style:{width:"100%",overflowWrap:"break-word"}},React__default.default.createElement(index$5,{originString:e==null?void 0:e.answer,currentString:e==null?void 0:e.newAnswer})):React__default.default.createElement("div",{style:{whiteSpace:"pre-wrap"}},(e==null?void 0:e.newAnswer)||(e==null?void 0:e.answer))},QuestionView=e=>{var t,r;const{hoverKey:l,answerList:u,question:i,lang:d,modelAPIResponse:f,setModelAPIResponse:m,checkMode:p=!0,LLMConfig:n,answerHeaderSlot:w}=e,[s,x]=React.useState(index.EDataFormatType.Default),E=((t=n==null?void 0:n.dataType)==null?void 0:t.prompt)===index.ELLMDataType.Picture,y=((r=n==null?void 0:n.dataType)==null?void 0:r.response)===index.ELLMDataType.Picture,{t:g}=reactI18next.useTranslation();React.useEffect(()=>{var a;d&&((a=lbUtils.i18n)==null||a.changeLanguage(d))},[]);const L=a=>{var o;return(n==null?void 0:n.isTextEdit)?!!((o=((n==null?void 0:n.textEdit)||[]).filter(v=>(v==null?void 0:v.title)===a.order)[0])==null?void 0:o.textControl):!1},P=React__default.default.createElement("div",null,u.map((a,o)=>{const c=L(a);return React__default.default.createElement("div",{className:classNames__default.default({[`${LLMViewCls}__content`]:!0,[`${LLMViewCls}__contentActive`]:l===(a==null?void 0:a.order)}),key:o},React__default.default.createElement(antd.Tag,{className:`${LLMViewCls}-tag`},a==null?void 0:a.order),React__default.default.createElement(RenderAnswer,{i:a,isTextControl:c,dataFormatType:s}))}),_.isString(i)&&React__default.default.createElement(index$1,{dataFormatType:s,modelAPIResponse:f,question:i,setModelAPIResponse:m,checkMode:p,annotation:e.annotation}));return React__default.default.createElement("div",{className:LLMViewCls},React__default.default.createElement(index$2,{question:i,dataFormatType:s,setDataFormatType:x,isImg:E}),React__default.default.createElement("div",{className:`${LLMViewCls}__textBox`},React__default.default.createElement("div",{className:`${LLMViewCls}__title`},g("Answer")," ",w),y?React__default.default.createElement(index$3,{hoverKey:l,answerList:u}):P))},WrapQuestionView=e=>React__default.default.createElement(reactI18next.I18nextProvider,{i18n:lbUtils.i18n},React__default.default.createElement(QuestionView,__spreadValues({},e)));exports.LLMViewCls=LLMViewCls,exports.default=WrapQuestionView;
@@ -1 +1 @@
1
- "use strict";var React=require("react"),reactRedux=require("react-redux"),ctx=require("../../store/ctx.js"),Actions=require("../../store/Actions.js"),actionCreators=require("../../store/annotation/actionCreators.js"),TagToolInstanceAdaptor=require("./videoTagTool/TagToolInstanceAdaptor.js"),lbAnnotation=require("@labelbee/lb-annotation"),index=require("./videoClipTool/index.js"),StepUtils=require("../../utils/StepUtils.js"),index$2=require("../../utils/index.js"),index$1=require("./videoTextTool/index.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,r)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,__spreadValues=(e,t)=>{for(var r in t||(t={}))__hasOwnProp.call(t,r)&&__defNormalProp(e,r,t[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(t))__propIsEnum.call(t,r)&&__defNormalProp(e,r,t[r]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));const{EVideoToolName}=lbAnnotation.cTool,VideoAnnotate=e=>{const{stepInfo:t,skipBeforePageTurning:r}=e,a=t==null?void 0:t.tool,o=ctx.useDispatch(),i=n=>{o({type:Actions.ANNOTATION_ACTIONS.SET_TOOL,payload:{instance:n}})},l=()=>{o({type:Actions.ANNOTATION_ACTIONS.SET_TOOL,payload:{instance:void 0}})},s=()=>{if(r){r(()=>o(actionCreators.PageBackward()));return}o(actionCreators.PageBackward())},u=()=>{if(r){r(()=>o(actionCreators.PageForward()));return}o(actionCreators.PageForward())};return a===EVideoToolName.VideoClipTool?React__default.default.createElement(index,__spreadProps(__spreadValues({},e),{pageBackward:s,pageForward:u,pageJump:n=>o(actionCreators.PageJump(~~n-1)),onMounted:i,onUnmounted:l})):a===EVideoToolName.VideoTextTool?React__default.default.createElement(index$1.VideoTextTool,__spreadProps(__spreadValues({},e),{pageBackward:s,pageForward:u,pageJump:n=>o(actionCreators.PageJump(~~n-1)),onMounted:i,onUnmounted:l})):a===EVideoToolName.VideoTagTool?React__default.default.createElement(TagToolInstanceAdaptor.TagToolInstanceAdaptor,__spreadProps(__spreadValues({},e),{pageBackward:s,pageForward:u,pageJump:n=>o(actionCreators.PageJump(~~n-1)),onMounted:i,onUnmounted:l})):null},mapStateToProps=e=>{var t,r,a,o,i;const{annotation:{imgList:l,imgIndex:s,step:u,stepList:n,loading:p,skipBeforePageTurning:f}}=e,d=StepUtils.getCurrentStepInfo((t=e.annotation)==null?void 0:t.step,(r=e.annotation)==null?void 0:r.stepList),c=(a=l[s])!=null?a:{};return{imgIndex:s,imgList:l,stepInfo:d,config:index$2.jsonParser(d==null?void 0:d.config),step:u,stepList:n,path:(i=(o=c==null?void 0:c.path)!=null?o:c==null?void 0:c.url)!=null?i:"",loading:p,skipBeforePageTurning:f}};var VideoAnnotate$1=reactRedux.connect(mapStateToProps,null,null,{context:ctx.LabelBeeContext})(VideoAnnotate);module.exports=VideoAnnotate$1;
1
+ "use strict";var React=require("react"),reactRedux=require("react-redux"),ctx=require("../../store/ctx.js"),Actions=require("../../store/Actions.js"),actionCreators=require("../../store/annotation/actionCreators.js"),TagToolInstanceAdaptor=require("./videoTagTool/TagToolInstanceAdaptor.js"),lbAnnotation=require("@labelbee/lb-annotation"),index=require("./videoClipTool/index.js"),StepUtils=require("../../utils/StepUtils.js"),index$2=require("../../utils/index.js"),index$1=require("./videoTextTool/index.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,o)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o,__spreadValues=(e,t)=>{for(var o in t||(t={}))__hasOwnProp.call(t,o)&&__defNormalProp(e,o,t[o]);if(__getOwnPropSymbols)for(var o of __getOwnPropSymbols(t))__propIsEnum.call(t,o)&&__defNormalProp(e,o,t[o]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t));const{EVideoToolName}=lbAnnotation.cTool,VideoAnnotate=e=>{const{stepInfo:t,skipBeforePageTurning:o}=e,n=t==null?void 0:t.tool,r=ctx.useDispatch(),i=a=>{r({type:Actions.ANNOTATION_ACTIONS.SET_TOOL,payload:{instance:a}})},l=()=>{r({type:Actions.ANNOTATION_ACTIONS.SET_TOOL,payload:{instance:void 0}})},s=()=>{r({type:Actions.ANNOTATION_ACTIONS.SET_LOADING,payload:{loading:!1}})},u=()=>{if(o){o(()=>r(actionCreators.PageBackward()));return}r(actionCreators.PageBackward())},d=()=>{if(o){o(()=>r(actionCreators.PageForward()));return}r(actionCreators.PageForward())};return n===EVideoToolName.VideoClipTool?React__default.default.createElement(index,__spreadProps(__spreadValues({},e),{pageBackward:u,pageForward:d,pageJump:a=>r(actionCreators.PageJump(~~a-1)),onMounted:i,onUnmounted:l,onVideoLoaded:s})):n===EVideoToolName.VideoTextTool?React__default.default.createElement(index$1.VideoTextTool,__spreadProps(__spreadValues({},e),{pageBackward:u,pageForward:d,pageJump:a=>r(actionCreators.PageJump(~~a-1)),onMounted:i,onUnmounted:l,onVideoLoaded:s})):n===EVideoToolName.VideoTagTool?React__default.default.createElement(TagToolInstanceAdaptor.TagToolInstanceAdaptor,__spreadProps(__spreadValues({},e),{pageBackward:u,pageForward:d,pageJump:a=>r(actionCreators.PageJump(~~a-1)),onMounted:i,onUnmounted:l,onVideoLoaded:s})):null},mapStateToProps=e=>{var t,o,n,r,i;const{annotation:{imgList:l,imgIndex:s,step:u,stepList:d,loading:a,skipBeforePageTurning:T}}=e,p=StepUtils.getCurrentStepInfo((t=e.annotation)==null?void 0:t.step,(o=e.annotation)==null?void 0:o.stepList),c=(n=l[s])!=null?n:{};return{imgIndex:s,imgList:l,stepInfo:p,config:index$2.jsonParser(p==null?void 0:p.config),step:u,stepList:d,path:(i=(r=c==null?void 0:c.path)!=null?r:c==null?void 0:c.url)!=null?i:"",loading:a,skipBeforePageTurning:T}};var VideoAnnotate$1=reactRedux.connect(mapStateToProps,null,null,{context:ctx.LabelBeeContext})(VideoAnnotate);module.exports=VideoAnnotate$1;
@@ -1 +1 @@
1
- "use strict";var lbAnnotation=require("@labelbee/lb-annotation"),index=require("../../../utils/index.js"),audio=require("../../../utils/audio.js"),antd=require("antd"),_=require("lodash"),React=require("react"),index_module=require("./index.module.scss.js"),VideoClipToolContext=require("./VideoClipToolContext.js"),constant=require("./constant.js"),index$1=require("../../videoPlayer/index.js"),index$2=require("./components/videoTimeSlicesOverVideo/index.js"),icon_videoCutting=require("../../../assets/annotation/video/icon_videoCutting.svg.js"),utils=require("../../videoPlayer/utils.js");function _interopDefaultLegacy(d){return d&&typeof d=="object"&&"default"in d?d:{default:d}}var ___default=_interopDefaultLegacy(_),React__default=_interopDefaultLegacy(React),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(d,s,t)=>s in d?__defProp(d,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):d[s]=t,__spreadValues=(d,s)=>{for(var t in s||(s={}))__hasOwnProp.call(s,t)&&__defNormalProp(d,t,s[t]);if(__getOwnPropSymbols)for(var t of __getOwnPropSymbols(s))__propIsEnum.call(s,t)&&__defNormalProp(d,t,s[t]);return d},__spreadProps=(d,s)=>__defProps(d,__getOwnPropDescs(s));class VideoClipTool extends React__default.default.Component{constructor(s){super(s);this.fns=new Map,this.throttledUpdateTime=___default.default.throttle(t=>{this.videoPlayer.currentTime=t},100,{trailing:!0}),this.stepInfo=()=>this.props.stepInfo,this.emitEvent=t=>{const e=this.fns.get(t);e&&e.forEach(i=>{i&&i()})},this.setValid=t=>{this.setState({valid:t}),t===!1&&(this.clearResult(),this.updateSidebar())},this.updateSidebar=()=>{this.emitEvent("changeClipSidebar"),this.emitEvent("updateTextAttribute"),this.emitEvent("changeAttributeSidebar")},this.exportData=()=>{var t,e;const i=(e=(t=this.videoRef)==null?void 0:t.duration)!=null?e:0;return[this.state.result.filter(r=>r.end!==null),{valid:this.state.valid,duration:i}]},this.updateSelectedSliceTimeStartByPer=t=>{var e,i;if(this.state.clipStatus===constant.EClipStatus.Clipping){antd.message.info("\u622A\u53D6\u4E2D\u4E0D\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}if(this.selectedSliceIndex>-1){const r=(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0,{end:a,start:u,type:l}=this.state.result[this.selectedSliceIndex],n=lbAnnotation.MathUtils.withinRange(audio.precisionAdd(u,t),[0,audio.precisionMinus(l===constant.ETimeSliceType.Time?r:a,constant.PER_SLICE_CHANGE)]);this.updateSelectedSliceTimeProperty(n,"start")}},this.updateSelectedSliceTimeEndByPer=t=>{var e,i;if(this.state.clipStatus===constant.EClipStatus.Clipping){antd.message.info("\u622A\u53D6\u4E2D\u4E0D\u652F\u6301\u8C03\u6574\u7ED3\u675F\u65F6\u95F4");return}if(this.selectedSliceIndex>-1){const r=this.state.result[this.selectedSliceIndex],a=(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0;if(r.type===constant.ETimeSliceType.Time){antd.message.info("\u65F6\u95F4\u70B9\u4EC5\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}const{end:u,start:l}=r,n=lbAnnotation.MathUtils.withinRange(audio.precisionAdd(u,t),[audio.precisionAdd(l,constant.PER_SLICE_CHANGE),a]);this.updateSelectedSliceTimeProperty(n,"end")}},this.updateSelectedSliceTimeProperty=(t,e)=>{if(this.selectedSliceIndex>-1){const{result:i}=this.state;i[this.selectedSliceIndex][e]=t,this.setState({result:___default.default.cloneDeep(i)}),this.updateSidebar()}},this.keyDownEvents=t=>{if(!lbAnnotation.CommonToolUtils.hotkeyFilter(t))return;const e=t.target;switch(e&&(e==null?void 0:e.tag)==="INPUT"&&(e==null?void 0:e.type)==="radio"&&t.preventDefault(),t.key.toLocaleLowerCase()){case"x":this.toggleClipStatus();break;case"e":this.addTime();break;case"escape":this.cancelClipped();break;case"-":this.updateSelectedSliceTimeStartByPer(-constant.PER_SLICE_CHANGE);break;case"=":this.updateSelectedSliceTimeStartByPer(constant.PER_SLICE_CHANGE);break;case"[":this.updateSelectedSliceTimeEndByPer(-constant.PER_SLICE_CHANGE);break;case"]":this.updateSelectedSliceTimeEndByPer(constant.PER_SLICE_CHANGE);break}},this.videoLoaded=t=>{var e;const i=this.resultJSON,r=i&&!["","{}"].includes(i),a=t?parseFloat(t.toFixed(2)):0,u={loading:!1};((e=index.jsonParser(i))==null?void 0:e.duration)||Object.assign(u,{result:JSON.stringify(__spreadProps(__spreadValues({},index.jsonParser(i)),{duration:a}))}),r||Object.assign(u,{result:JSON.stringify({width:0,height:0,rotate:0,valid:!0,duration:a})}),this.setState({loading:!1})},this.setVideoError=(t,e,i)=>{if(t){const{clipStatus:r}=this.state;r===constant.EClipStatus.Clipping&&this.toggleClipStatus(i)}this.setState({videoError:t,loading:!1})},this.clearResult=()=>{this.setState({result:[],selectedID:"",textValue:""}),this.updateSidebar()},this.cancelClipped=()=>{const{result:t,selectedID:e,clipStatus:i}=this.state;if(i!==constant.EClipStatus.Clipping)return;const r=t.findIndex(a=>a.id===e);r>-1&&(t.splice(r,1),this.setState({result:t,selectedID:"",clipStatus:constant.EClipStatus.Stop}),this.updateSidebar())},this.toggleClipStatus=t=>{var e,i,r;if(this.disabled)return;const{clipStatus:a,selectedAttribute:u}=this.state,l=a!==constant.EClipStatus.Clipping;let n=l?constant.EClipStatus.Clipping:constant.EClipStatus.Stop,{result:o,selectedID:c,textValue:h}=this.state;const p=___default.default.cloneDeep(o),S=t||((e=this.videoPlayer)==null?void 0:e.currentTime),v=(i=this.videoPlayer)==null?void 0:i.duration;if(v===void 0||S===void 0)return;const C=utils.decimalReserved(S,2);if(l){const f=lbAnnotation.uuid();c=f,p.push({start:C,end:null,attribute:u,textAttribute:this.defaultTextAttribute,duration:v,id:f,type:constant.ETimeSliceType.Period}),h=this.defaultTextAttribute}else{const f=p.findIndex(m=>m.id===c),g=p[f];g&&(S-g.start<constant.SLICE_MIN_TIME?(p.splice(f,1),antd.message.info(`\u622A\u53D6\u7247\u6BB5\u4E0D\u80FD\u77ED\u4E8E${constant.SLICE_MIN_TIME}s`),n=constant.EClipStatus.Stop,c="",h=""):(p[f].end=utils.decimalReserved(S,2),(r=this.videoPlayer)==null||r.pause(),antd.message.success(`\u5DF2\u622A\u53D6\u7247\u6BB5${o.length}`)))}this.setState({clipStatus:n,result:p,selectedID:c,textValue:h}),this.updateSidebar()},this.addTime=()=>{var t,e,i,r;if(this.disabled)return;const{result:a,selectedAttribute:u,selectedID:l}=this.state,n=lbAnnotation.uuid(),o=___default.default.cloneDeep(a),c=((t=this.videoPlayer)==null?void 0:t.currentTime)||0;o.push({start:c,end:c,attribute:u,textAttribute:this.defaultTextAttribute,id:n,type:constant.ETimeSliceType.Time,duration:(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0});const h={result:o,selectedID:n,textValue:this.defaultTextAttribute},p=o.find(S=>S.id===l);this.isClipping&&p?(delete h.selectedID,delete h.textValue,antd.message.success(`\u5DF2\u622A\u53D6\u65F6\u95F4\u70B9${o.length-1}`)):(r=this.videoPlayer)==null||r.pause(),this.setState(h),this.updateSidebar()},this.updateCurrentTime=t=>{this.setState({currentTime:t})},this.contextToCancel=t=>{this.state.clipStatus===constant.EClipStatus.Stop&&(t.preventDefault(),this.setState({selectedID:""}),this.updateSidebar())},this.onTrackResize=(t,e,i)=>{var r,a;const{result:u}=this.state,l=u.find(n=>n.id===t);if(l){const n=l.duration,o=e==="left",c=o?"start":"end",h=o?-n*i:n*i,p=o?[0,Math.max(((r=l.end)!=null?r:0)-constant.SLICE_MIN_TIME,0)]:[l.start+constant.SLICE_MIN_TIME,n],S=lbAnnotation.MathUtils.withinRange(h+((a=l==null?void 0:l[c])!=null?a:0),p);l[c]=S,this.throttledUpdateTime(S)}this.setState({result:[...u]}),this.updateSidebar()},this.renderMediaContent=()=>{var t;const{pageForward:e,pageJump:i,pageBackward:r}=this.props,{result:a,videoError:u,valid:l,currentTime:n}=this.state;return React__default.default.createElement("div",{className:index_module.clipContainer},React__default.default.createElement(index$1.VideoPlayer,{imgIndex:this.props.imgIndex,imgList:this.props.imgList,pageBackward:r,pageForward:e,pageJump:i,valid:l,setVideoRef:o=>{this.videoPlayer=o},showVideoTrack:!u,onTrackResize:this.onTrackResize,drawLayerSlot:this.props.drawLayerSlot,footer:this.props.footer,dataLoaded:this.videoLoaded,toggleClipStatus:this.toggleClipStatus,addTime:this.addTime,updateCurrentTime:this.updateCurrentTime}),React__default.default.createElement(index$2,{key:(t=this.videoPlayer)==null?void 0:t.currentTime,result:a,currentTime:n,attributeList:this.props.config.attributeList,extraStyle:{top:this.props.drawLayerSlot?40:0}}),this.isClipping&&React__default.default.createElement("i",{className:index_module.clipping,style:{backgroundImage:icon_videoCutting}}))},this.onSelectedTimeSlice=t=>{var e;this.isClipping||(this.setState({selectedID:t.id,selectedAttribute:t.attribute,textValue:t.textAttribute,currentTime:t.start}),this.updateSidebar(),(e=this.videoPlayer)==null||e.pause(),this.videoPlayer.currentTime=t.start)},this.removeTimeSlice=t=>{const{result:e}=this.state,i=this.state.selectedID===t.id?"":this.state.selectedID,r=e.findIndex(a=>a.id===t.id);r>-1&&(e.splice(r,1),this.setState({result:[...e],selectedID:i}),this.updateSidebar())},this.setResult=(t=!0,e=this.props)=>{try{const{imgIndex:i,imgList:r}=e;if(!r[i])return;const u=index.jsonParser(r[i].result)[`step_${this.stepInfo().step}`],l=(u==null?void 0:u.result)||[],n=audio.isImageValue(r[i].result||"[]");this.setState({result:l,loading:t,selectedID:"",textValue:"",selectedAttribute:"",clipStatus:constant.EClipStatus.Stop,valid:n},()=>{this.updateSidebar(),n||antd.message.info("\u65E0\u6548\u89C6\u9891\uFF0C\u8BF7\u8DF3\u8FC7")})}catch(i){console.error("\u6570\u636E\u89E3\u6790\u5931\u8D25"),this.setState({result:[],loading:!1,selectedID:"",textValue:"",selectedAttribute:"",valid:!0},()=>{this.updateSidebar()})}},this.setDefaultAttribute=t=>{const{result:e,selectedID:i}=this.state,r=e.find(a=>a.id===i);r&&i&&(r.attribute=t),this.setState({selectedAttribute:t,result:[...e]}),this.updateSidebar()},this.textChange=t=>{const{result:e,selectedID:i}=this.state;if(this.setState({textValue:t}),i){const r=e.find(a=>a.id===i);r&&(r.textAttribute=t,this.setState({result:[...e]}),this.updateSidebar())}},this.state={result:[],selectedAttribute:"",textValue:"",clipStatus:constant.EClipStatus.Stop,selectedID:"",loading:!1,videoError:!1,remainingTime:0,currentTime:0,configLoading:!1,valid:!0}}get videoUrl(){var s;const{imgIndex:t,imgList:e}=this.props;return((s=e[t])==null?void 0:s.url)||""}get isClipping(){return this.state.clipStatus===constant.EClipStatus.Clipping}get resultJSON(){const{imgIndex:s,imgList:t}=this.props;return t.length===0||!t[s]?"[]":t[s].result}get disabled(){return!this.state.valid||this.state.videoError}get loading(){return this.state.loading||this.state.configLoading}get defaultTextAttribute(){return lbAnnotation.AttributeUtils.getTextAttribute(this.state.result,this.props.config.textCheckType)}get defaultAttribute(){return this.state.selectedAttribute}get selectedID(){return this.state.selectedID}get selectedSliceIndex(){return this.state.result.findIndex(s=>s.id===this.state.selectedID)}get exportContext(){return{selectedID:this.state.selectedID,result:this.state.result,clipStatus:this.state.clipStatus,videoPlayer:this.videoPlayer,attributeList:this.props.config.attributeList,onSelectedTimeSlice:this.onSelectedTimeSlice,removeTimeSlice:this.removeTimeSlice,updateSelectedSliceTimeProperty:this.updateSelectedSliceTimeProperty}}get valid(){return this.state.valid}get config(){var s;return index.jsonParser((s=this.props.stepInfo)==null?void 0:s.config)}get selectedText(){var s,t;return(t=(s=this.state.result)==null?void 0:s[this.selectedSliceIndex])==null?void 0:t.textAttribute}componentDidMount(){this.setState({loading:!1}),this.setResult(!1),this.props.onMounted(this),window.addEventListener("keydown",this.keyDownEvents)}componentWillUnmount(){this.props.onUnmounted(),window.removeEventListener("keydown",this.keyDownEvents)}shouldComponentUpdate(s,t){const e=s.imgIndex-this.props.imgIndex,i=s.step-this.props.step;return(e!==0||i!==0)&&(this.setResult(!0,s),i!==0&&this.setState({loading:!1})),!0}singleOn(s,t){this.fns.set(s,[t])}on(s,t){this.singleOn(s,t)}unbindAll(s){this.fns.delete(s)}render(){const{selectedID:s,result:t,clipStatus:e,selectedAttribute:i}=this.state;return React__default.default.createElement(VideoClipToolContext.VideoClipToolContextProvider,{value:{videoPlayer:this.videoPlayer,result:t,selectedID:s,attributeList:this.props.config.attributeList,clipStatus:e,selectedAttribute:i,contextToCancel:this.contextToCancel}},this.renderMediaContent())}}module.exports=VideoClipTool;
1
+ "use strict";var lbAnnotation=require("@labelbee/lb-annotation"),index$2=require("../../../utils/index.js"),audio=require("../../../utils/audio.js"),antd=require("antd"),_=require("lodash"),React=require("react"),index_module=require("./index.module.scss.js"),VideoClipToolContext=require("./VideoClipToolContext.js"),constant=require("./constant.js"),index=require("../../videoPlayer/index.js"),index$1=require("./components/videoTimeSlicesOverVideo/index.js"),icon_videoCutting=require("../../../assets/annotation/video/icon_videoCutting.svg.js"),utils=require("../../videoPlayer/utils.js");function _interopDefaultLegacy(S){return S&&typeof S=="object"&&"default"in S?S:{default:S}}var ___default=_interopDefaultLegacy(_),React__default=_interopDefaultLegacy(React);class VideoClipTool extends React__default.default.Component{constructor(r){super(r);this.fns=new Map,this.throttledUpdateTime=___default.default.throttle(t=>{this.videoPlayer.currentTime=t},100,{trailing:!0}),this.stepInfo=()=>this.props.stepInfo,this.emitEvent=t=>{const e=this.fns.get(t);e&&e.forEach(i=>{i&&i()})},this.setValid=t=>{this.setState({valid:t}),t===!1&&(this.clearResult(),this.updateSidebar())},this.updateSidebar=()=>{this.emitEvent("changeClipSidebar"),this.emitEvent("updateTextAttribute"),this.emitEvent("changeAttributeSidebar")},this.exportData=()=>{var t,e;const i=(e=(t=this.videoRef)==null?void 0:t.duration)!=null?e:0;return[this.state.result.filter(s=>s.end!==null),{valid:this.state.valid,duration:i}]},this.updateSelectedSliceTimeStartByPer=t=>{var e,i;if(this.state.clipStatus===constant.EClipStatus.Clipping){antd.message.info("\u622A\u53D6\u4E2D\u4E0D\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}if(this.selectedSliceIndex>-1){const s=(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0,{end:a,start:n,type:l}=this.state.result[this.selectedSliceIndex],u=lbAnnotation.MathUtils.withinRange(audio.precisionAdd(n,t),[0,audio.precisionMinus(l===constant.ETimeSliceType.Time?s:a,constant.PER_SLICE_CHANGE)]);this.updateSelectedSliceTimeProperty(u,"start")}},this.updateSelectedSliceTimeEndByPer=t=>{var e,i;if(this.state.clipStatus===constant.EClipStatus.Clipping){antd.message.info("\u622A\u53D6\u4E2D\u4E0D\u652F\u6301\u8C03\u6574\u7ED3\u675F\u65F6\u95F4");return}if(this.selectedSliceIndex>-1){const s=this.state.result[this.selectedSliceIndex],a=(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0;if(s.type===constant.ETimeSliceType.Time){antd.message.info("\u65F6\u95F4\u70B9\u4EC5\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}const{end:n,start:l}=s,u=lbAnnotation.MathUtils.withinRange(audio.precisionAdd(n,t),[audio.precisionAdd(l,constant.PER_SLICE_CHANGE),a]);this.updateSelectedSliceTimeProperty(u,"end")}},this.updateSelectedSliceTimeProperty=(t,e)=>{if(this.selectedSliceIndex>-1){const{result:i}=this.state;i[this.selectedSliceIndex][e]=t,this.setState({result:___default.default.cloneDeep(i)}),this.updateSidebar()}},this.keyDownEvents=t=>{if(!lbAnnotation.CommonToolUtils.hotkeyFilter(t))return;const e=t.target;switch(e&&(e==null?void 0:e.tag)==="INPUT"&&(e==null?void 0:e.type)==="radio"&&t.preventDefault(),t.key.toLocaleLowerCase()){case"x":this.toggleClipStatus();break;case"e":this.addTime();break;case"escape":this.cancelClipped();break;case"-":this.updateSelectedSliceTimeStartByPer(-constant.PER_SLICE_CHANGE);break;case"=":this.updateSelectedSliceTimeStartByPer(constant.PER_SLICE_CHANGE);break;case"[":this.updateSelectedSliceTimeEndByPer(-constant.PER_SLICE_CHANGE);break;case"]":this.updateSelectedSliceTimeEndByPer(constant.PER_SLICE_CHANGE);break}},this.setVideoError=(t,e,i)=>{if(t){const{clipStatus:s}=this.state;s===constant.EClipStatus.Clipping&&this.toggleClipStatus(i)}this.setState({videoError:t,loading:!1})},this.clearResult=()=>{this.setState({result:[],selectedID:"",textValue:""}),this.updateSidebar()},this.cancelClipped=()=>{const{result:t,selectedID:e,clipStatus:i}=this.state;if(i!==constant.EClipStatus.Clipping)return;const s=t.findIndex(a=>a.id===e);s>-1&&(t.splice(s,1),this.setState({result:t,selectedID:"",clipStatus:constant.EClipStatus.Stop}),this.updateSidebar())},this.toggleClipStatus=t=>{var e,i,s;if(this.disabled)return;const{clipStatus:a,selectedAttribute:n}=this.state,l=a!==constant.EClipStatus.Clipping;let u=l?constant.EClipStatus.Clipping:constant.EClipStatus.Stop,{result:d,selectedID:o,textValue:p}=this.state;const c=___default.default.cloneDeep(d),h=t||((e=this.videoPlayer)==null?void 0:e.currentTime),f=(i=this.videoPlayer)==null?void 0:i.duration;if(f===void 0||h===void 0)return;const C=utils.decimalReserved(h,2);if(l){const m=lbAnnotation.uuid();o=m,c.push({start:C,end:null,attribute:n,textAttribute:this.defaultTextAttribute,duration:f,id:m,type:constant.ETimeSliceType.Period}),p=this.defaultTextAttribute}else{const m=c.findIndex(v=>v.id===o),g=c[m];g&&(h-g.start<constant.SLICE_MIN_TIME?(c.splice(m,1),antd.message.info(`\u622A\u53D6\u7247\u6BB5\u4E0D\u80FD\u77ED\u4E8E${constant.SLICE_MIN_TIME}s`),u=constant.EClipStatus.Stop,o="",p=""):(c[m].end=utils.decimalReserved(h,2),(s=this.videoPlayer)==null||s.pause(),antd.message.success(`\u5DF2\u622A\u53D6\u7247\u6BB5${d.length}`)))}this.setState({clipStatus:u,result:c,selectedID:o,textValue:p}),this.updateSidebar()},this.addTime=()=>{var t,e,i,s;if(this.disabled)return;const{result:a,selectedAttribute:n,selectedID:l}=this.state,u=lbAnnotation.uuid(),d=___default.default.cloneDeep(a),o=((t=this.videoPlayer)==null?void 0:t.currentTime)||0;d.push({start:o,end:o,attribute:n,textAttribute:this.defaultTextAttribute,id:u,type:constant.ETimeSliceType.Time,duration:(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0});const p={result:d,selectedID:u,textValue:this.defaultTextAttribute},c=d.find(h=>h.id===l);this.isClipping&&c?(delete p.selectedID,delete p.textValue,antd.message.success(`\u5DF2\u622A\u53D6\u65F6\u95F4\u70B9${d.length-1}`)):(s=this.videoPlayer)==null||s.pause(),this.setState(p),this.updateSidebar()},this.updateCurrentTime=t=>{this.setState({currentTime:t})},this.contextToCancel=t=>{this.state.clipStatus===constant.EClipStatus.Stop&&(t.preventDefault(),this.setState({selectedID:""}),this.updateSidebar())},this.onTrackResize=(t,e,i)=>{var s,a;const{result:n}=this.state,l=n.find(u=>u.id===t);if(l){const u=l.duration,d=e==="left",o=d?"start":"end",p=d?-u*i:u*i,c=d?[0,Math.max(((s=l.end)!=null?s:0)-constant.SLICE_MIN_TIME,0)]:[l.start+constant.SLICE_MIN_TIME,u],h=lbAnnotation.MathUtils.withinRange(p+((a=l==null?void 0:l[o])!=null?a:0),c);l[o]=h,this.throttledUpdateTime(h)}this.setState({result:[...n]}),this.updateSidebar()},this.renderMediaContent=()=>{var t;const{pageForward:e,pageJump:i,pageBackward:s}=this.props,{result:a,videoError:n,valid:l,currentTime:u}=this.state;return React__default.default.createElement("div",{className:index_module.clipContainer},React__default.default.createElement(index.VideoPlayer,{imgIndex:this.props.imgIndex,imgList:this.props.imgList,pageBackward:s,pageForward:e,pageJump:i,valid:l,setVideoRef:d=>{this.videoPlayer=d},showVideoTrack:!n,onTrackResize:this.onTrackResize,drawLayerSlot:this.props.drawLayerSlot,footer:this.props.footer,dataLoaded:this.props.onVideoLoaded,toggleClipStatus:this.toggleClipStatus,addTime:this.addTime,updateCurrentTime:this.updateCurrentTime}),React__default.default.createElement(index$1,{key:(t=this.videoPlayer)==null?void 0:t.currentTime,result:a,currentTime:u,attributeList:this.props.config.attributeList,extraStyle:{top:this.props.drawLayerSlot?40:0}}),this.isClipping&&React__default.default.createElement("i",{className:index_module.clipping,style:{backgroundImage:icon_videoCutting}}))},this.onSelectedTimeSlice=t=>{var e;this.isClipping||(this.setState({selectedID:t.id,selectedAttribute:t.attribute,textValue:t.textAttribute,currentTime:t.start}),this.updateSidebar(),(e=this.videoPlayer)==null||e.pause(),this.videoPlayer.currentTime=t.start)},this.removeTimeSlice=t=>{const{result:e}=this.state,i=this.state.selectedID===t.id?"":this.state.selectedID,s=e.findIndex(a=>a.id===t.id);s>-1&&(e.splice(s,1),this.setState({result:[...e],selectedID:i}),this.updateSidebar())},this.setResult=(t=!0,e=this.props)=>{try{const{imgIndex:i,imgList:s}=e;if(!s[i])return;const n=index$2.jsonParser(s[i].result)[`step_${this.stepInfo().step}`],l=(n==null?void 0:n.result)||[],u=audio.isImageValue(s[i].result||"[]");this.setState({result:l,loading:t,selectedID:"",textValue:"",selectedAttribute:"",clipStatus:constant.EClipStatus.Stop,valid:u},()=>{this.updateSidebar(),u||antd.message.info("\u65E0\u6548\u89C6\u9891\uFF0C\u8BF7\u8DF3\u8FC7")})}catch(i){console.error("\u6570\u636E\u89E3\u6790\u5931\u8D25"),this.setState({result:[],loading:!1,selectedID:"",textValue:"",selectedAttribute:"",valid:!0},()=>{this.updateSidebar()})}},this.setDefaultAttribute=t=>{const{result:e,selectedID:i}=this.state,s=e.find(a=>a.id===i);s&&i&&(s.attribute=t),this.setState({selectedAttribute:t,result:[...e]}),this.updateSidebar()},this.textChange=t=>{const{result:e,selectedID:i}=this.state;if(this.setState({textValue:t}),i){const s=e.find(a=>a.id===i);s&&(s.textAttribute=t,this.setState({result:[...e]}),this.updateSidebar())}},this.state={result:[],selectedAttribute:"",textValue:"",clipStatus:constant.EClipStatus.Stop,selectedID:"",loading:!1,videoError:!1,remainingTime:0,currentTime:0,configLoading:!1,valid:!0}}get videoUrl(){var r;const{imgIndex:t,imgList:e}=this.props;return((r=e[t])==null?void 0:r.url)||""}get isClipping(){return this.state.clipStatus===constant.EClipStatus.Clipping}get resultJSON(){const{imgIndex:r,imgList:t}=this.props;return t.length===0||!t[r]?"[]":t[r].result}get disabled(){return!this.state.valid||this.state.videoError}get loading(){return this.state.loading||this.state.configLoading}get defaultTextAttribute(){return lbAnnotation.AttributeUtils.getTextAttribute(this.state.result,this.props.config.textCheckType)}get defaultAttribute(){return this.state.selectedAttribute}get selectedID(){return this.state.selectedID}get selectedSliceIndex(){return this.state.result.findIndex(r=>r.id===this.state.selectedID)}get exportContext(){return{selectedID:this.state.selectedID,result:this.state.result,clipStatus:this.state.clipStatus,videoPlayer:this.videoPlayer,attributeList:this.props.config.attributeList,onSelectedTimeSlice:this.onSelectedTimeSlice,removeTimeSlice:this.removeTimeSlice,updateSelectedSliceTimeProperty:this.updateSelectedSliceTimeProperty}}get valid(){return this.state.valid}get config(){var r;return index$2.jsonParser((r=this.props.stepInfo)==null?void 0:r.config)}get selectedText(){var r,t;return(t=(r=this.state.result)==null?void 0:r[this.selectedSliceIndex])==null?void 0:t.textAttribute}componentDidMount(){this.setState({loading:!1}),this.setResult(!1),this.props.onMounted(this),window.addEventListener("keydown",this.keyDownEvents)}componentWillUnmount(){this.props.onUnmounted(),window.removeEventListener("keydown",this.keyDownEvents)}shouldComponentUpdate(r,t){const e=r.imgIndex-this.props.imgIndex,i=r.step-this.props.step;return(e!==0||i!==0)&&(this.setResult(!0,r),i!==0&&this.setState({loading:!1})),!0}singleOn(r,t){this.fns.set(r,[t])}on(r,t){this.singleOn(r,t)}unbindAll(r){this.fns.delete(r)}render(){const{selectedID:r,result:t,clipStatus:e,selectedAttribute:i}=this.state;return React__default.default.createElement(VideoClipToolContext.VideoClipToolContextProvider,{value:{videoPlayer:this.videoPlayer,result:t,selectedID:r,attributeList:this.props.config.attributeList,clipStatus:e,selectedAttribute:i,contextToCancel:this.contextToCancel}},this.renderMediaContent())}}module.exports=VideoClipTool;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),lbAnnotation=require("@labelbee/lb-annotation"),index=require("../../../utils/index.js"),index$1=require("../../videoPlayer/index.js"),VideoTagLayer=require("../../videoPlayer/VideoTagLayer.js"),_=require("lodash"),utils=require("../../videoPlayer/utils.js");function _interopDefaultLegacy(h){return h&&typeof h=="object"&&"default"in h?h:{default:h}}var React__default=_interopDefaultLegacy(React),___default=_interopDefaultLegacy(_);class TagToolInstanceAdaptor extends React__default.default.Component{constructor(i){super(i);this.fns={},this.labelSelectedList=[],this.clearResult=(t=!0,e)=>{const l=e?this.state.tagResult.map(s=>((s==null?void 0:s.result[e])&&delete s.result[e],s)):[];this.setState({tagResult:l},()=>this.emitEvent("render"))},this.exportData=()=>{var t,e,l,s,n,r,a;const o=(e=(t=this.videoPlayer)==null?void 0:t.duration)!=null?e:0,d=(l=this.videoPlayer)==null?void 0:l.getVideoPlaybackQuality(),u=d==null?void 0:d.totalVideoFrames,c=(n=(s=this.videoPlayer)==null?void 0:s.videoWidth)!=null?n:0,v=(a=(r=this.videoPlayer)==null?void 0:r.videoHeight)!=null?a:0;return[this.state.tagResult,{valid:this.state.valid,duration:o,frames:u,videoWidth:c,videoHeight:v}]},this.emitEvent=t=>{this.fns[t]&&this.fns[t]()},this.combineResult=(t,e={})=>{var l,s;const{isMulti:n}=t,{key:r,value:a}=t.value;if(n){let o=(s=(l=e[r])==null?void 0:l.split(";"))!=null?s:[];o.includes(a)?o=o.filter(u=>u!==a):o.push(a);const d=new Set(o);return e[r]=Array.from(d).join(";"),___default.default.pickBy(e,u=>u)}return e[r]=e[r]===a?void 0:a,___default.default.pickBy(e,o=>o)},this.setResult=t=>{this.setState({tagResult:t}),this.fns.render&&this.fns.render()},this.setLabel=(t,e)=>{this.setLabelBySelectedList(t,e)},this.keydown=t=>{var e;const l=utils.getKeyCodeNumber(t.keyCode);if(l){const s=l-1;if(((e=this.config.inputList)==null?void 0:e.length)===1){this.labelSelectedList=[0,s],this.setLabel(0,s),setTimeout(()=>{this.labelSelectedList=[],this.emitEvent("render")},500);return}this.labelSelectedList.length===1?(this.labelSelectedList=[this.labelSelectedList[0],s],this.setLabel(this.labelSelectedList[0],s),setTimeout(()=>{this.labelSelectedList=[],this.emitEvent("render")},500)):(this.labelSelectedList=[s],this.emitEvent("expend"))}},this.setValid=t=>{this.setState({valid:t}),t===!1&&this.setState({tagResult:[]}),this.emitEvent("render")},this.setResultFromImgList=t=>{const{imgList:e,imgIndex:l,stepInfo:s}=t;if(!e[l])return;const n=index.jsonParser(e[l].result),r=n[`step_${s.step}`],a=this.getInitResultList();this.setState({tagResult:r?r==null?void 0:r.result:a,valid:(n==null?void 0:n.valid)===void 0?!0:n.valid},()=>this.emitEvent("render"))},this.getInitResultList=()=>{var t;return lbAnnotation.TagUtils.getDefaultTagResult((t=this.config.inputList)!=null?t:[],[])},this.state={tagResult:[],labelSelectedList:[],valid:!0}}get config(){var i;return index.jsonParser((i=this.props.stepInfo)==null?void 0:i.config)}get history(){return{initRecord:()=>{},pushHistory:()=>{}}}get currentTagResult(){var i;return(i=this.state.tagResult[0])!=null?i:{}}get valid(){return this.state.valid}singleOn(i,t){this.fns[i]=t}on(i,t){this.singleOn(i,t)}unbindAll(i){delete this.fns[i]}getTagResultByCode(i,t){var e,l,s;try{const n=(l=(e=this.config)==null?void 0:e.inputList)!=null?l:[],r=(n==null?void 0:n.length)>1,a=t!==void 0?i:0,o=t!==void 0?t:i,d=r?n[a]:n[0],u=((s=d.subSelected)!=null?s:[])[o];if(d&&u)return{value:{key:d.value,value:u.value},isMulti:d.isMulti}}catch(n){return}}setLabelBySelectedList(i,t){var e,l,s,n;const r=this.getTagResultByCode(i,t);if(r){const a=this.combineResult(r,(l=(e=this.state.tagResult[0])==null?void 0:e.result)!=null?l:{}),o=[{sourceID:lbAnnotation.CommonToolUtils.getSourceID(),id:(n=(s=this.currentTagResult)==null?void 0:s.id)!=null?n:lbAnnotation.uuid(8,62),result:a}];this.setState({tagResult:o},()=>this.emitEvent("render"))}}componentDidMount(){document.addEventListener("keydown",this.keydown),this.props.onMounted(this),this.setResultFromImgList(this.props)}componentWillUnmount(){document.addEventListener("keydown",this.keydown),this.props.onUnmounted()}shouldComponentUpdate(i){return i.imgIndex!==this.props.imgIndex&&this.setResultFromImgList(i),!0}render(){var i;const{imgIndex:t,imgList:e,pageForward:l,pageJump:s,pageBackward:n}=this.props,{tagResult:r,valid:a}=this.state;return React__default.default.createElement("div",{style:{height:"100%",width:"100%",position:"relative",display:"flex",flexDirection:"column"}},React__default.default.createElement(index$1.VideoPlayer,{imgIndex:t,imgList:e,pageBackward:n,pageForward:l,pageJump:s,valid:a,setVideoRef:o=>{this.videoPlayer=o},drawLayerSlot:this.props.drawLayerSlot,footer:this.props.footer}),React__default.default.createElement(VideoTagLayer.VideoTagLayer,{result:r,inputList:(i=this.config)==null?void 0:i.inputList,hasPromptLayer:!!this.props.drawLayerSlot}))}}exports.TagToolInstanceAdaptor=TagToolInstanceAdaptor;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),lbAnnotation=require("@labelbee/lb-annotation"),index=require("../../../utils/index.js"),index$1=require("../../videoPlayer/index.js"),VideoTagLayer=require("../../videoPlayer/VideoTagLayer.js"),_=require("lodash"),utils=require("../../videoPlayer/utils.js");function _interopDefaultLegacy(d){return d&&typeof d=="object"&&"default"in d?d:{default:d}}var React__default=_interopDefaultLegacy(React),___default=_interopDefaultLegacy(_);class TagToolInstanceAdaptor extends React__default.default.Component{constructor(s){super(s);this.fns={},this.labelSelectedList=[],this.clearResult=(t=!0,e)=>{const l=e?this.state.tagResult.map(i=>((i==null?void 0:i.result[e])&&delete i.result[e],i)):[];this.setState({tagResult:l},()=>this.emitEvent("render"))},this.exportData=()=>{var t,e;const l=(e=(t=this.videoPlayer)==null?void 0:t.duration)!=null?e:0;return[this.state.tagResult,{valid:this.state.valid,duration:l}]},this.emitEvent=t=>{this.fns[t]&&this.fns[t]()},this.combineResult=(t,e={})=>{var l,i;const{isMulti:n}=t,{key:r,value:a}=t.value;if(n){let o=(i=(l=e[r])==null?void 0:l.split(";"))!=null?i:[];o.includes(a)?o=o.filter(h=>h!==a):o.push(a);const u=new Set(o);return e[r]=Array.from(u).join(";"),___default.default.pickBy(e,h=>h)}return e[r]=e[r]===a?void 0:a,___default.default.pickBy(e,o=>o)},this.setResult=t=>{this.setState({tagResult:t}),this.fns.render&&this.fns.render()},this.setLabel=(t,e)=>{this.setLabelBySelectedList(t,e)},this.keydown=t=>{var e;const l=utils.getKeyCodeNumber(t.keyCode);if(l){const i=l-1;if(((e=this.config.inputList)==null?void 0:e.length)===1){this.labelSelectedList=[0,i],this.setLabel(0,i),setTimeout(()=>{this.labelSelectedList=[],this.emitEvent("render")},500);return}this.labelSelectedList.length===1?(this.labelSelectedList=[this.labelSelectedList[0],i],this.setLabel(this.labelSelectedList[0],i),setTimeout(()=>{this.labelSelectedList=[],this.emitEvent("render")},500)):(this.labelSelectedList=[i],this.emitEvent("expend"))}},this.setValid=t=>{this.setState({valid:t}),t===!1&&this.setState({tagResult:[]}),this.emitEvent("render")},this.setResultFromImgList=t=>{const{imgList:e,imgIndex:l,stepInfo:i}=t;if(!e[l])return;const n=index.jsonParser(e[l].result),r=n[`step_${i.step}`],a=this.getInitResultList();this.setState({tagResult:r?r==null?void 0:r.result:a,valid:(n==null?void 0:n.valid)===void 0?!0:n.valid},()=>this.emitEvent("render"))},this.getInitResultList=()=>{var t;return lbAnnotation.TagUtils.getDefaultTagResult((t=this.config.inputList)!=null?t:[],[])},this.state={tagResult:[],labelSelectedList:[],valid:!0}}get config(){var s;return index.jsonParser((s=this.props.stepInfo)==null?void 0:s.config)}get history(){return{initRecord:()=>{},pushHistory:()=>{}}}get currentTagResult(){var s;return(s=this.state.tagResult[0])!=null?s:{}}get valid(){return this.state.valid}singleOn(s,t){this.fns[s]=t}on(s,t){this.singleOn(s,t)}unbindAll(s){delete this.fns[s]}getTagResultByCode(s,t){var e,l,i;try{const n=(l=(e=this.config)==null?void 0:e.inputList)!=null?l:[],r=(n==null?void 0:n.length)>1,a=t!==void 0?s:0,o=t!==void 0?t:s,u=r?n[a]:n[0],h=((i=u.subSelected)!=null?i:[])[o];if(u&&h)return{value:{key:u.value,value:h.value},isMulti:u.isMulti}}catch(n){return}}setLabelBySelectedList(s,t){var e,l,i,n;const r=this.getTagResultByCode(s,t);if(r){const a=this.combineResult(r,(l=(e=this.state.tagResult[0])==null?void 0:e.result)!=null?l:{}),o=[{sourceID:lbAnnotation.CommonToolUtils.getSourceID(),id:(n=(i=this.currentTagResult)==null?void 0:i.id)!=null?n:lbAnnotation.uuid(8,62),result:a}];this.setState({tagResult:o},()=>this.emitEvent("render"))}}componentDidMount(){document.addEventListener("keydown",this.keydown),this.props.onMounted(this),this.setResultFromImgList(this.props)}componentWillUnmount(){document.addEventListener("keydown",this.keydown),this.props.onUnmounted()}shouldComponentUpdate(s){return s.imgIndex!==this.props.imgIndex&&this.setResultFromImgList(s),!0}render(){var s;const{imgIndex:t,imgList:e,pageForward:l,pageJump:i,pageBackward:n}=this.props,{tagResult:r,valid:a}=this.state;return React__default.default.createElement("div",{style:{height:"100%",width:"100%",position:"relative",display:"flex",flexDirection:"column"}},React__default.default.createElement(index$1.VideoPlayer,{imgIndex:t,imgList:e,pageBackward:n,pageForward:l,pageJump:i,valid:a,setVideoRef:o=>{this.videoPlayer=o},dataLoaded:this.props.onVideoLoaded,drawLayerSlot:this.props.drawLayerSlot,footer:this.props.footer}),React__default.default.createElement(VideoTagLayer.VideoTagLayer,{result:r,inputList:(s=this.config)==null?void 0:s.inputList,hasPromptLayer:!!this.props.drawLayerSlot}))}}exports.TagToolInstanceAdaptor=TagToolInstanceAdaptor;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),index=require("../../../utils/index.js"),index$1=require("../../videoPlayer/index.js"),_=require("lodash"),VideoTextLayer=require("../../videoPlayer/VideoTextLayer.js"),lbUtils=require("@labelbee/lb-utils");function _interopDefaultLegacy(u){return u&&typeof u=="object"&&"default"in u?u:{default:u}}var React__default=_interopDefaultLegacy(React),___default=_interopDefaultLegacy(_);class VideoTextTool extends React__default.default.Component{constructor(i){super(i);this.fns={},this.clearResult=(t=!0)=>{this.setState({result:{}},()=>this.updateSidebar())},this.exportData=()=>{var t,e,s,r,l,o,a;const n=(e=(t=this.videoPlayer)==null?void 0:t.duration)!=null?e:0,d=(s=this.videoPlayer)==null?void 0:s.getVideoPlaybackQuality(),h=d==null?void 0:d.totalVideoFrames,v=(l=(r=this.videoPlayer)==null?void 0:r.videoWidth)!=null?l:0,f=(a=(o=this.videoPlayer)==null?void 0:o.videoHeight)!=null?a:0;return[[this.state.result],{valid:this.state.valid,duration:n,frames:h,videoWidth:v,videoHeight:f}]},this.toggleShowText=t=>{this.setState({showText:t})},this.singleOn=(t,e)=>{this.fns[t]=e},this.on=(t,e)=>{this.singleOn(t,e)},this.unbindAll=t=>{delete this.fns[t]},this.emitEvent=t=>{this.fns[t]&&this.fns[t]()},this.updateSidebar=()=>{this.emitEvent("valueUpdated")},this.updateTextValue=(t,e,s,r)=>{var l;const o=___default.default.cloneDeep(r!=null?r:{});o.value=Object.assign((l=o.value)!=null?l:{},{[t]:e}),this.setState({result:o},()=>s&&this.updateSidebar())},this.setResult=t=>{this.setState({result:t}),this.fns.render&&this.fns.render()},this.setValid=t=>{this.setState({valid:t}),t===!1&&this.setState({result:{}}),this.emitEvent("render")},this.setResultFromImgList=t=>{var e,s;const{imgList:r,imgIndex:l,stepInfo:o}=t;if(!r[l])return;const a=index.jsonParser(r[l].result),n=a[`step_${o.step}`],d={value:this.getInitTextValue()};this.setState({result:n?(s=(e=n==null?void 0:n.result)==null?void 0:e[0])!=null?s:{}:d,valid:(a==null?void 0:a.valid)===void 0?!0:a.valid},()=>this.updateSidebar())},this.getInitTextValue=()=>{let t={};return this.config.configList.forEach(e=>{var s;t[e.key]=(s=e.default)!=null?s:""}),t},this.state={result:{},valid:!0,showText:!0}}get config(){var i;return index.jsonParser((i=this.props.stepInfo)==null?void 0:i.config)}get history(){return{initRecord:()=>{},pushHistory:()=>{}}}get valid(){return this.state.valid}get needConfirm(){var i;const{result:t}=this.state;return(i=this.config.configList)==null?void 0:i.some(e=>{var s;return e.required&&!((s=t==null?void 0:t.value)==null?void 0:s[e.key])})}get textList(){return[this.state.result]}getColor(i=this.config,t=""){return lbUtils.toolStyleConverter.getColorByConfig({attribute:t,config:i})}componentDidMount(){this.props.onMounted(this),this.setResultFromImgList(this.props)}componentWillUnmount(){this.props.onUnmounted()}shouldComponentUpdate(i){return i.imgIndex!==this.props.imgIndex&&this.setResultFromImgList(i),!0}render(){var i,t;const{imgIndex:e,imgList:s,pageForward:r,pageJump:l,pageBackward:o}=this.props,{result:a,valid:n,showText:d}=this.state;return React__default.default.createElement("div",{style:{height:"100%",width:"100%",position:"relative",display:"flex",flexDirection:"column"}},d&&a.value&&React__default.default.createElement(VideoTextLayer.VideoTextLayer,{value:a.value,toolColor:(t=(i=this.getColor(this.config))==null?void 0:i.valid)==null?void 0:t.fill,configList:this.config.configList,hasPromptLayer:!!this.props.drawLayerSlot}),React__default.default.createElement(index$1.VideoPlayer,{imgIndex:e,imgList:s,pageBackward:o,pageForward:r,pageJump:l,valid:n,setVideoRef:h=>{this.videoPlayer=h},drawLayerSlot:this.props.drawLayerSlot,footer:this.props.footer}))}}exports.VideoTextTool=VideoTextTool;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),index=require("../../../utils/index.js"),index$1=require("../../videoPlayer/index.js"),_=require("lodash"),VideoTextLayer=require("../../videoPlayer/VideoTextLayer.js"),lbUtils=require("@labelbee/lb-utils");function _interopDefaultLegacy(n){return n&&typeof n=="object"&&"default"in n?n:{default:n}}var React__default=_interopDefaultLegacy(React),___default=_interopDefaultLegacy(_);class VideoTextTool extends React__default.default.Component{constructor(s){super(s);this.fns={},this.clearResult=(t=!0)=>{this.setState({result:{}},()=>this.updateSidebar())},this.exportData=()=>{var t,e;const i=(e=(t=this.videoPlayer)==null?void 0:t.duration)!=null?e:0;return[[this.state.result],{valid:this.state.valid,duration:i}]},this.toggleShowText=t=>{this.setState({showText:t})},this.singleOn=(t,e)=>{this.fns[t]=e},this.on=(t,e)=>{this.singleOn(t,e)},this.unbindAll=t=>{delete this.fns[t]},this.emitEvent=t=>{this.fns[t]&&this.fns[t]()},this.updateSidebar=()=>{this.emitEvent("valueUpdated")},this.updateTextValue=(t,e,i,r)=>{var o;const l=___default.default.cloneDeep(r!=null?r:{});l.value=Object.assign((o=l.value)!=null?o:{},{[t]:e}),this.setState({result:l},()=>i&&this.updateSidebar())},this.setResult=t=>{this.setState({result:t}),this.fns.render&&this.fns.render()},this.setValid=t=>{this.setState({valid:t}),t===!1&&this.setState({result:{}}),this.emitEvent("render")},this.setResultFromImgList=t=>{var e,i;const{imgList:r,imgIndex:o,stepInfo:l}=t;if(!r[o])return;const a=index.jsonParser(r[o].result),u=a[`step_${l.step}`],d={value:this.getInitTextValue()};this.setState({result:u?(i=(e=u==null?void 0:u.result)==null?void 0:e[0])!=null?i:{}:d,valid:(a==null?void 0:a.valid)===void 0?!0:a.valid},()=>this.updateSidebar())},this.getInitTextValue=()=>{let t={};return this.config.configList.forEach(e=>{var i;t[e.key]=(i=e.default)!=null?i:""}),t},this.state={result:{},valid:!0,showText:!0}}get config(){var s;return index.jsonParser((s=this.props.stepInfo)==null?void 0:s.config)}get history(){return{initRecord:()=>{},pushHistory:()=>{}}}get valid(){return this.state.valid}get needConfirm(){var s;const{result:t}=this.state;return(s=this.config.configList)==null?void 0:s.some(e=>{var i;return e.required&&!((i=t==null?void 0:t.value)==null?void 0:i[e.key])})}get textList(){return[this.state.result]}getColor(s=this.config,t=""){return lbUtils.toolStyleConverter.getColorByConfig({attribute:t,config:s})}componentDidMount(){this.props.onMounted(this),this.setResultFromImgList(this.props)}componentWillUnmount(){this.props.onUnmounted()}shouldComponentUpdate(s){return s.imgIndex!==this.props.imgIndex&&this.setResultFromImgList(s),!0}render(){var s,t;const{imgIndex:e,imgList:i,pageForward:r,pageJump:o,pageBackward:l}=this.props,{result:a,valid:u,showText:d}=this.state;return React__default.default.createElement("div",{style:{height:"100%",width:"100%",position:"relative",display:"flex",flexDirection:"column"}},d&&a.value&&React__default.default.createElement(VideoTextLayer.VideoTextLayer,{value:a.value,toolColor:(t=(s=this.getColor(this.config))==null?void 0:s.valid)==null?void 0:t.fill,configList:this.config.configList,hasPromptLayer:!!this.props.drawLayerSlot}),React__default.default.createElement(index$1.VideoPlayer,{imgIndex:e,imgList:i,pageBackward:l,pageForward:r,pageJump:o,valid:u,setVideoRef:h=>{this.videoPlayer=h},drawLayerSlot:this.props.drawLayerSlot,footer:this.props.footer,dataLoaded:this.props.onVideoLoaded}))}}exports.VideoTextTool=VideoTextTool;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),index$2=require("./components/controller/index.js"),index=require("../videoAnnotate/videoClipTool/components/videoTrack/index.js"),dom=require("../../utils/dom.js"),lbAnnotation=require("@labelbee/lb-annotation"),utils=require("./utils.js"),index$1=require("../fileException/index.js");function _interopDefaultLegacy(o){return o&&typeof o=="object"&&"default"in o?o:{default:o}}var React__default=_interopDefaultLegacy(React);const EKeyCode=lbAnnotation.cKeyCode.default,VideoPlayerCtx=React__default.default.createContext({isPlay:!1,playPause:()=>{},updateNextPlaybackRate:()=>{},playbackRate:1,currentTime:0,duration:0,buffered:0,setCurrentTime:()=>{},imgList:[],imgIndex:-1,pageBackward:()=>{},pageJump:o=>{},pageForward:()=>{},addTime:()=>{},toggleClipStatus:()=>{}}),PER_INTERVAL=50,PER_FORWARD=.1,PLAYBACK_RATES=[.5,1,1.5,2,4,6,8,16];class VideoPlayer extends React__default.default.Component{constructor(a){super(a);this.changePlaybackPate=e=>{this.videoElm&&(this.videoElm.playbackRate=e,this.setState({playbackRate:e}))},this.playPause=()=>{var e,t,i;((e=this.videoElm)==null?void 0:e.paused)?(t=this.videoElm)==null||t.play():(i=this.videoElm)==null||i.pause()},this.updateNextPlaybackRate=(e=!0)=>{const t=PLAYBACK_RATES.findIndex(r=>r===this.state.playbackRate);let i=e?Math.min(t+1,PLAYBACK_RATES.length-1):Math.max(t-1,0);this.changePlaybackPate(PLAYBACK_RATES[i])},this.fastForward=()=>{this.videoElm&&this.setCurrentTime(this.videoElm.currentTime+PER_FORWARD)},this.rewind=()=>{this.videoElm&&this.setCurrentTime(this.videoElm.currentTime-PER_FORWARD)},this.keydown=e=>{e.keyCode===EKeyCode.Space&&(e.preventDefault(),this.playPause()),e.keyCode===EKeyCode.Up&&(e.preventDefault(),this.updateNextPlaybackRate()),e.keyCode===EKeyCode.Down&&(e.preventDefault(),this.updateNextPlaybackRate(!1)),e.keyCode===EKeyCode.Left&&(e.preventDefault(),this.rewind()),e.keyCode===EKeyCode.Right&&(e.preventDefault(),this.fastForward())},this.onPlay=()=>{this.setState({isPlay:!0},this.onVideoStart)},this.onPause=()=>{this.onVideoStopped()},this.onTimeUpdate=()=>{var e;this.videoElm&&this.setState({currentTime:utils.decimalReserved((e=this.videoElm)==null?void 0:e.currentTime,1)})},this.onVideoStopped=()=>{this.setState({isPlay:!1}),this.timeInterval&&(clearInterval(this.timeInterval),this.timeInterval=void 0),this.videoElm&&this.setCurrentTime(this.videoElm.currentTime)},this.onVideoStart=()=>{this.timeInterval=window.setInterval(()=>{var e,t,i;if(this.videoElm)try{if(((e=this.videoElm)==null?void 0:e.buffered.length)>0){const r=(t=this.videoElm)==null?void 0:t.buffered.end(0);this.setState({currentTime:utils.decimalReserved((i=this.videoElm)==null?void 0:i.currentTime,1),buffered:r})}}catch(r){console.error(r)}},PER_INTERVAL)},this.resetVideoData=()=>{this.setState({currentTime:0,buffered:0,error:!1,isPlay:!1}),this.videoElm&&(this.videoElm.playbackRate=this.state.playbackRate),this.onVideoStopped()},this.setDuration=()=>{var e,t,i;if(this.videoElm){const r=utils.decimalReserved((e=this.videoElm)==null?void 0:e.duration,1);(i=(t=this.props).dataLoaded)==null||i.call(t,r),this.setState({duration:r})}},this.setCurrentTime=e=>{var t,i;this.videoElm&&(this.videoElm.currentTime=e,this.setState({currentTime:e}),(i=(t=this.props).updateCurrentTime)==null||i.call(t,e))},this.reload=()=>{var e;(e=this.videoElm)==null||e.load()},this.onError=()=>{this.resetVideoData(),this.setState({error:!0})},this.state={playbackRate:1,currentTime:0,isPlay:!1,duration:0,buffered:0,error:!1},this.videoRef=React__default.default.createRef()}get videoElm(){var a;return(a=this.videoRef)==null?void 0:a.current}get videoSrc(){var a,e;const{imgIndex:t,imgList:i}=this.props;return t>-1&&(e=(a=i[t])==null?void 0:a.url)!=null?e:""}componentDidMount(){var a,e;window.addEventListener("keydown",this.keydown),((a=this.videoRef)==null?void 0:a.current)&&this.props.setVideoRef&&this.props.setVideoRef((e=this.videoRef)==null?void 0:e.current)}componentWillUnmount(){window.removeEventListener("keydown",this.keydown)}render(){const{isPlay:a,playbackRate:e,currentTime:t,duration:i,buffered:r,error:n}=this.state,{imgList:u,imgIndex:h,pageBackward:c,pageJump:v,pageForward:m,valid:p,footer:f,drawLayerSlot:s}=this.props,y=isNaN(i)?0:Math.max(utils.decimalReserved(i,1)-t,0),{playPause:d,updateNextPlaybackRate:E,onPause:g,onPlay:R,onTimeUpdate:P,resetVideoData:k,setDuration:b,setCurrentTime:T,onError:x,videoRef:C,videoSrc:_}=this;return React__default.default.createElement(VideoPlayerCtx.Provider,{value:{videoRef:this.videoRef,addTime:this.props.addTime,toggleClipStatus:this.props.toggleClipStatus,isPlay:a,playPause:d,updateNextPlaybackRate:E,playbackRate:e,currentTime:t,duration:i,buffered:r,setCurrentTime:T,imgIndex:h,imgList:u,pageBackward:c,pageJump:v,pageForward:m}},React__default.default.createElement(React__default.default.Fragment,null,s==null?void 0:s({currentTime:t,remainingTime:y,zoom:1,currentPos:{x:0,y:0}}),React__default.default.createElement("div",{className:dom.getClassName("video-wrapper")},React__default.default.createElement("div",{className:dom.getClassName("video-container")},React__default.default.createElement("video",{ref:C,className:dom.getClassName(this.props.showVideoTrack?"video-track":"video"),src:_,onPause:g,onPlay:R,onTimeUpdate:P,onLoadedMetadata:k,onError:x,onDurationChange:b,width:"100%",height:"100%",onClick:d}),this.props.showVideoTrack&&React__default.default.createElement(index.default,{currentTime:t,onTrackResize:this.props.onTrackResize,onTrackResizeStart:()=>{var l;(l=this.videoElm)==null||l.pause()},readonly:!1}),React__default.default.createElement(index$1,{fileType:"video",errorProps:{reloadImage:this.reload,backgroundColor:"#e2e2e2",ignoreOffsetY:!0,isError:n},invalidProps:{isValid:p}})),React__default.default.createElement(index$2.default,{footer:f}))))}}exports.VideoPlayer=VideoPlayer,exports.VideoPlayerCtx=VideoPlayerCtx,exports.default=VideoPlayer;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var React=require("react"),index$2=require("./components/controller/index.js"),index=require("../videoAnnotate/videoClipTool/components/videoTrack/index.js"),dom=require("../../utils/dom.js"),lbAnnotation=require("@labelbee/lb-annotation"),utils=require("./utils.js"),index$1=require("../fileException/index.js");function _interopDefaultLegacy(o){return o&&typeof o=="object"&&"default"in o?o:{default:o}}var React__default=_interopDefaultLegacy(React);const EKeyCode=lbAnnotation.cKeyCode.default,VideoPlayerCtx=React__default.default.createContext({isPlay:!1,playPause:()=>{},updateNextPlaybackRate:()=>{},playbackRate:1,currentTime:0,duration:0,buffered:0,setCurrentTime:()=>{},imgList:[],imgIndex:-1,pageBackward:()=>{},pageJump:o=>{},pageForward:()=>{},addTime:()=>{},toggleClipStatus:()=>{}}),PER_INTERVAL=50,PER_FORWARD=.1,PLAYBACK_RATES=[.5,1,1.5,2,4,6,8,16];class VideoPlayer extends React__default.default.Component{constructor(a){super(a);this.changePlaybackPate=e=>{this.videoElm&&(this.videoElm.playbackRate=e,this.setState({playbackRate:e}))},this.playPause=()=>{var e,t,i;((e=this.videoElm)==null?void 0:e.paused)?(t=this.videoElm)==null||t.play():(i=this.videoElm)==null||i.pause()},this.updateNextPlaybackRate=(e=!0)=>{const t=PLAYBACK_RATES.findIndex(r=>r===this.state.playbackRate);let i=e?Math.min(t+1,PLAYBACK_RATES.length-1):Math.max(t-1,0);this.changePlaybackPate(PLAYBACK_RATES[i])},this.fastForward=()=>{this.videoElm&&this.setCurrentTime(this.videoElm.currentTime+PER_FORWARD)},this.rewind=()=>{this.videoElm&&this.setCurrentTime(this.videoElm.currentTime-PER_FORWARD)},this.keydown=e=>{e.keyCode===EKeyCode.Space&&(e.preventDefault(),this.playPause()),e.keyCode===EKeyCode.Up&&(e.preventDefault(),this.updateNextPlaybackRate()),e.keyCode===EKeyCode.Down&&(e.preventDefault(),this.updateNextPlaybackRate(!1)),e.keyCode===EKeyCode.Left&&(e.preventDefault(),this.rewind()),e.keyCode===EKeyCode.Right&&(e.preventDefault(),this.fastForward())},this.onPlay=()=>{this.setState({isPlay:!0},this.onVideoStart)},this.onPause=()=>{this.onVideoStopped()},this.onTimeUpdate=()=>{var e;this.videoElm&&this.setState({currentTime:utils.decimalReserved((e=this.videoElm)==null?void 0:e.currentTime,1)})},this.onVideoStopped=()=>{this.setState({isPlay:!1}),this.timeInterval&&(clearInterval(this.timeInterval),this.timeInterval=void 0),this.videoElm&&this.setCurrentTime(this.videoElm.currentTime)},this.onVideoStart=()=>{this.timeInterval=window.setInterval(()=>{var e,t,i;if(this.videoElm)try{if(((e=this.videoElm)==null?void 0:e.buffered.length)>0){const r=(t=this.videoElm)==null?void 0:t.buffered.end(0);this.setState({currentTime:utils.decimalReserved((i=this.videoElm)==null?void 0:i.currentTime,1),buffered:r})}}catch(r){console.error(r)}},PER_INTERVAL)},this.resetVideoData=()=>{this.setState({currentTime:0,buffered:0,error:!1,isPlay:!1}),this.videoElm&&(this.videoElm.playbackRate=this.state.playbackRate),this.onVideoStopped()},this.setDuration=()=>{var e,t,i;if(this.videoElm){const r=utils.decimalReserved((e=this.videoElm)==null?void 0:e.duration,1);(i=(t=this.props).dataLoaded)==null||i.call(t),this.setState({duration:r})}},this.setCurrentTime=e=>{var t,i;this.videoElm&&(this.videoElm.currentTime=e,this.setState({currentTime:e}),(i=(t=this.props).updateCurrentTime)==null||i.call(t,e))},this.reload=()=>{var e;(e=this.videoElm)==null||e.load()},this.onError=()=>{this.resetVideoData(),this.setState({error:!0})},this.state={playbackRate:1,currentTime:0,isPlay:!1,duration:0,buffered:0,error:!1},this.videoRef=React__default.default.createRef()}get videoElm(){var a;return(a=this.videoRef)==null?void 0:a.current}get videoSrc(){var a,e;const{imgIndex:t,imgList:i}=this.props;return t>-1&&(e=(a=i[t])==null?void 0:a.url)!=null?e:""}componentDidMount(){var a,e;window.addEventListener("keydown",this.keydown),((a=this.videoRef)==null?void 0:a.current)&&this.props.setVideoRef&&this.props.setVideoRef((e=this.videoRef)==null?void 0:e.current)}componentWillUnmount(){window.removeEventListener("keydown",this.keydown)}render(){const{isPlay:a,playbackRate:e,currentTime:t,duration:i,buffered:r,error:n}=this.state,{imgList:u,imgIndex:h,pageBackward:c,pageJump:v,pageForward:m,valid:p,footer:f,drawLayerSlot:s}=this.props,y=isNaN(i)?0:Math.max(utils.decimalReserved(i,1)-t,0),{playPause:d,updateNextPlaybackRate:E,onPause:g,onPlay:R,onTimeUpdate:P,resetVideoData:k,setDuration:b,setCurrentTime:T,onError:x,videoRef:C,videoSrc:_}=this;return React__default.default.createElement(VideoPlayerCtx.Provider,{value:{videoRef:this.videoRef,addTime:this.props.addTime,toggleClipStatus:this.props.toggleClipStatus,isPlay:a,playPause:d,updateNextPlaybackRate:E,playbackRate:e,currentTime:t,duration:i,buffered:r,setCurrentTime:T,imgIndex:h,imgList:u,pageBackward:c,pageJump:v,pageForward:m}},React__default.default.createElement(React__default.default.Fragment,null,s==null?void 0:s({currentTime:t,remainingTime:y,zoom:1,currentPos:{x:0,y:0}}),React__default.default.createElement("div",{className:dom.getClassName("video-wrapper")},React__default.default.createElement("div",{className:dom.getClassName("video-container")},React__default.default.createElement("video",{ref:C,className:dom.getClassName(this.props.showVideoTrack?"video-track":"video"),src:_,onPause:g,onPlay:R,onTimeUpdate:P,onLoadedMetadata:k,onError:x,onDurationChange:b,width:"100%",height:"100%",onClick:d}),this.props.showVideoTrack&&React__default.default.createElement(index.default,{currentTime:t,onTrackResize:this.props.onTrackResize,onTrackResizeStart:()=>{var l;(l=this.videoElm)==null||l.pause()},readonly:!1}),React__default.default.createElement(index$1,{fileType:"video",errorProps:{reloadImage:this.reload,backgroundColor:"#e2e2e2",ignoreOffsetY:!0,isError:n},invalidProps:{isValid:p}})),React__default.default.createElement(index$2.default,{footer:f}))))}}exports.VideoPlayer=VideoPlayer,exports.VideoPlayerCtx=VideoPlayerCtx,exports.default=VideoPlayer;
package/dist/index.css CHANGED
@@ -2826,7 +2826,7 @@
2826
2826
  margin-bottom: 24px;
2827
2827
  width: 100%;
2828
2828
  }
2829
- .bee-LLMView__tag {
2829
+ .bee-LLMView .bee-LLMView-tag {
2830
2830
  color: #666FFF;
2831
2831
  background: #eeefff;
2832
2832
  height: 20px;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var index$2=require("../../components/customResizeHook/index.js"),index$1=require("../../constant/index.js"),styleString=require("../../constant/styleString.js"),Actions=require("../Actions.js"),index=require("../../utils/index.js"),AnnotationDataUtils=require("../../utils/AnnotationDataUtils.js"),ConfigUtils=require("../../utils/ConfigUtils.js"),data=require("../../utils/data.js"),StepUtils=require("../../utils/StepUtils.js"),ToolUtils=require("../../utils/ToolUtils.js"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),antd=require("antd"),es=require("antd/es"),_=require("lodash"),actionCreators=require("./actionCreators.js"),ToolType=require("../../data/enums/ToolType.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var ___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,s)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,__spreadValues=(e,t)=>{for(var s in t||(t={}))__hasOwnProp.call(t,s)&&__defNormalProp(e,s,t[s]);if(__getOwnPropSymbols)for(var s of __getOwnPropSymbols(t))__propIsEnum.call(t,s)&&__defNormalProp(e,s,t[s]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__async=(e,t,s)=>new Promise((O,u)=>{var A=I=>{try{S(s.next(I))}catch(m){u(m)}},g=I=>{try{S(s.throw(I))}catch(m){u(m)}},S=I=>I.done?O(I.value):Promise.resolve(I.value).then(A,g);S((s=s.apply(e,t)).next())});const getStepConfig=(e,t)=>e.find(s=>s.step===t),initialState={annotationEngine:null,toolInstance:null,imgList:[],config:"{}",imgIndex:-1,basicIndex:0,imgPageSize:1,step:1,stepList:[],imgNode:new Image,basicResultList:[],resultList:[],stepProgress:0,loading:!1,loadPCDFileLoading:!0,triggerEventAfterIndexChanged:!1,pointCloudLoading:!1,checkMode:!1,predictionResult:[],predictionResultVisible:!1,highlightAttribute:""},getTotalPage=e=>{const{imgList:t,imgPageSize:s}=e;return Math.ceil(t.length/s)},calcStepProgress=(e,t)=>e.reduce((s,O)=>{if(O){const u=O.result;if(index.jsonParser(u)[`step_${t}`])return s+1}return s},0)/e.length,updateToolInstance=(e,t)=>{const{step:s,stepList:O}=e,u=StepUtils.getCurrentStepInfo(s,O),A=ConfigUtils.ConfigUtils.jsonParser(u.config);if(ToolUtils.isVideoTool(u==null?void 0:u.tool)||ToolUtils.isAudioTool(u==null?void 0:u.tool)||ToolUtils.isPointCloudTool(u==null?void 0:u.tool)||ToolType.EToolName.LLM===(u==null?void 0:u.tool))return;const g=document.getElementById("toolContainer");if(!g)throw"Not exist dom named id-toolContainer";const S=index$2.getFormatSize({width:window.innerWidth,height:window.innerHeight}),I=new lbAnnotation.AnnotationEngine({container:g,toolName:u.tool,size:S,imgNode:t,config:A,style:JSON.parse(styleString)});return{toolInstance:I==null?void 0:I.toolInstance,annotationEngine:I}},LoadFileAndFileData=(e,t)=>(s,O)=>__async(void 0,null,function*(){var u;const{stepList:A,step:g}=O().annotation,S=StepUtils.currentToolIsVideo(g,A),I=StepUtils.currentToolIsPointCloud(g,A),m=((u=StepUtils.getCurrentStepInfo(g,A))==null?void 0:u.tool)===ToolType.EToolName.LLM,D=StepUtils.currentToolIsAudio(g,A);if(actionCreators.SetAnnotationLoading(s,!0),yield s(TryGetFileDataByAPI(e)),S||I||m||D){s(AfterVideoLoaded(e));return}s(AfterImageLoaded(e,t))}),TryGetFileDataByAPI=e=>(t,s)=>__async(void 0,null,function*(){const{getFileData:O,imgList:u}=s().annotation;if(O){const A=yield O(u[e],e);t({type:Actions.ANNOTATION_ACTIONS.SET_FILE_DATA,payload:{fileData:A,index:e}})}}),AfterVideoLoaded=e=>t=>{actionCreators.SetAnnotationLoading(t,!1),t({type:Actions.ANNOTATION_ACTIONS.LOAD_FILE_DATA,payload:{nextIndex:e}})},AfterImageLoaded=(e,t)=>(s,O)=>{var u;const{toolInstance:A,imgList:g}=O().annotation,S=(u=g==null?void 0:g[e])==null?void 0:u.url;lbAnnotation.ImgUtils.load(S).then(I=>{actionCreators.SetAnnotationLoading(s,!1),s({type:Actions.ANNOTATION_ACTIONS.LOAD_FILE_DATA,payload:{imgNode:I,nextIndex:e,nextBasicIndex:t}})}).catch(()=>{actionCreators.SetAnnotationLoading(s,!1),A==null||A.setErrorImg(),s({type:Actions.ANNOTATION_ACTIONS.LOAD_FILE_DATA,payload:{nextIndex:e,nextBasicIndex:t}})})},composeResultByToolInstance=({toolInstance:e,imgList:t,imgIndex:s,stepList:O,step:u=1})=>{var A,g,S,I;const m=((A=t[s])==null?void 0:A.result)||"",[D,b,U]=(g=e==null?void 0:e.exportData())!=null?g:[],x=(I=(S=e==null?void 0:e.exportCustomData)==null?void 0:S.call(e))!=null?I:{},B=data.composeResultWithBasicImgInfo(m,b),w=data.composeResult(B,{step:u,stepList:O},{rect:D},x);return t.map((R,F)=>F===s?__spreadValues(__spreadProps(__spreadValues({},R),{result:w}),U):__spreadValues({},R))},annotationReducer=(e=__spreadValues({},initialState),t)=>{var s,O,u,A,g,S,I,m,D,b,U,x,B,w,R,F,G,V,M,q,k,H,z,K,W;switch(t.type){case Actions.ANNOTATION_ACTIONS.INIT_ALL_STATE:return __spreadValues(__spreadValues({},e),initialState);case Actions.ANNOTATION_ACTIONS.UPDATE_TOOL_INSTANCE:return __spreadProps(__spreadValues({},e),{toolInstance:t.payload.toolInstance});case Actions.ANNOTATION_ACTIONS.UPDATE_IMG_LIST:return __spreadProps(__spreadValues({},e),{imgList:t.payload.imgList});case Actions.ANNOTATION_ACTIONS.CALC_STEP_PROGRESS:{const{imgList:n,step:o}=e,i=calcStepProgress(n,o);return __spreadProps(__spreadValues({},e),{stepProgress:i})}case Actions.ANNOTATION_ACTIONS.SUBMIT_FILE_DATA:{const{imgList:n,imgIndex:o,step:i,stepList:l,toolInstance:a,onSubmit:r,resultList:N}=e;if(!a||!n[o])return e;const d=((s=n[o])==null?void 0:s.result)||"",[,c,T]=(O=a==null?void 0:a.exportData())!=null?O:[],p=(A=(u=a==null?void 0:a.exportCustomData)==null?void 0:u.call(a))!=null?A:{},f=data.composeResultWithBasicImgInfo(d,c),C=data.composeResult(f,{step:i,stepList:l},{rect:N},p),L=e.imgList.map((v,E)=>{if(E===o){const h=AnnotationDataUtils.dataCorrection(C,d,i,l);return __spreadValues(__spreadProps(__spreadValues({},v),{result:h}),T)}return v});if(((g=t.payload)==null?void 0:g.submitType)===index$1.ESubmitType.SyncImgList)return __spreadProps(__spreadValues({},e),{imgList:L});r&&r([L[o]],(S=t.payload)==null?void 0:S.submitType,o,L);const y=calcStepProgress(L,i);return __spreadProps(__spreadValues({},e),{stepProgress:y,imgList:L})}case Actions.ANNOTATION_ACTIONS.SAVE_RESULT:{const{imgList:n,imgIndex:o,onSave:i}=e;return i==null||i(n[o],o,n),__spreadValues({},e)}case Actions.ANNOTATION_ACTIONS.SUBMIT_RESULT:{const{imgList:n,basicIndex:o,resultList:i,toolInstance:l,basicResultList:a}=e;if(!l)return e;const[r]=(I=l==null?void 0:l.exportData())!=null?I:[];let N=r;if((a==null?void 0:a.length)>0){const d=(m=a[o])==null?void 0:m.id,c=r.map(T=>__spreadProps(__spreadValues({},T),{sourceID:d}));N=___default.default.cloneDeep(i).filter(T=>T.sourceID!==d),N.push(...c)}return __spreadProps(__spreadValues({},e),{resultList:N,imgList:n})}case Actions.ANNOTATION_ACTIONS.SET_BASIC_INDEX:{const{toolInstance:n,step:o,imgList:i,imgIndex:l,stepList:a,annotationEngine:r,resultList:N,basicResultList:d}=e;if(!n||!r)return e;const c=t.payload.basicIndex,T=(D=d[c])==null?void 0:D.id,p=index.jsonParser((b=i[l])==null?void 0:b.result),f=(N||[]).filter(h=>h.sourceID===T),C=getStepConfig(a,o),{dataSourceStep:L,tool:y}=C,v=getStepConfig(a,L);let E=[];return L&&y&&(E=(U=p[`step_${L}`])==null?void 0:U.result,(E==null?void 0:E.length)>0?(r==null||r.setBasicInfo(v.tool,E[c]),r==null||r.launchOperation()):(r==null||r.setBasicInfo(v.tool),r==null||r.forbidOperation(),es.message.info(lbUtils.i18n.t("NoDependency")))),n==null||n.setResult(f),n==null||n.history.initRecord(f,!0),__spreadProps(__spreadValues({},e),{basicIndex:c})}case Actions.ANNOTATION_ACTIONS.SET_TRIGGER_EVENT_AFTER_INDEX_CHANGED:{const{triggerEventAfterIndexChanged:n}=t.payload;return __spreadProps(__spreadValues({},e),{triggerEventAfterIndexChanged:!!n})}case Actions.ANNOTATION_ACTIONS.LOAD_FILE_DATA:{const{imgList:n,step:o,toolInstance:i,annotationEngine:l,stepList:a}=e;if(!i)return __spreadProps(__spreadValues({},e),{imgIndex:t.payload.nextIndex});const r=StepUtils.getCurrentStepInfo(o,a),{nextIndex:N,imgNode:d,nextBasicIndex:c,imgError:T}=t.payload,p=c!=null?c:0,f=index.jsonParser((x=n[N])==null?void 0:x.result),C=f[`step_${r.step}`],L=!C,y={rotate:(B=f.rotate)!=null?B:0,valid:(w=f.valid)!=null?w:!0};d&&T!==!0?l==null||l.setImgNode(d,y):i==null||i.setValid(y.valid);const v=getStepConfig(a,r.step),{dataSourceStep:E,tool:h}=v,$=getStepConfig(a,E),Y=E&&h,P=(F=(R=f[`step_${E}`])==null?void 0:R.result)!=null?F:[],j=AnnotationDataUtils.getInitialResultList(C==null?void 0:C.result,i,v,P,L);if(l==null||l.launchOperation(),Y&&((P==null?void 0:P.length)>0?l==null||l.setBasicInfo($.tool,P[p]):(l==null||l.setBasicInfo($.tool),l==null||l.forbidOperation(),es.message.info(lbUtils.i18n.t("NoDependency")))),r.tool!=="check"){const J=(V=(G=P[p])==null?void 0:G.id)!=null?V:"",X=Y?j.filter(Z=>lbAnnotation.CommonToolUtils.isSameSourceID(Z.sourceID,J)):j;(M=i==null?void 0:i.history)==null||M.initRecord(j,!0),i==null||i.setResult(X)}return __spreadProps(__spreadValues({},e),{imgIndex:N,basicIndex:p,basicResultList:P,resultList:j})}case Actions.ANNOTATION_ACTIONS.UPDATE_ANNOTATION_CONFIG:return __spreadProps(__spreadValues({},e),{config:(q=t.payload.config)!=null?q:"{}"});case Actions.ANNOTATION_ACTIONS.SET_TASK_STEP_LIST:{const{stepList:n}=t.payload;return __spreadProps(__spreadValues({},e),{stepList:n})}case Actions.ANNOTATION_ACTIONS.SET_TASK_CONFIG:{const{stepList:n,step:o}=t.payload;return __spreadProps(__spreadValues({},e),{stepList:n,step:o})}case Actions.ANNOTATION_ACTIONS.INIT_TOOL:{const{imgNode:n}=e,o=updateToolInstance(e,n);if(o){const{toolInstance:i,annotationEngine:l}=o;return __spreadProps(__spreadValues({},e),{toolInstance:i,annotationEngine:l})}return __spreadValues({},e)}case Actions.ANNOTATION_ACTIONS.SET_TOOL:{const n=(k=t.payload)==null?void 0:k.instance;return n?__spreadProps(__spreadValues({},e),{toolInstance:n}):__spreadValues({},e)}case Actions.ANNOTATION_ACTIONS.UPDATE_ON_SUBMIT:return __spreadProps(__spreadValues({},e),{onSubmit:t.payload.onSubmit});case Actions.ANNOTATION_ACTIONS.UPDATE_ON_SAVE:return __spreadProps(__spreadValues({},e),{onSave:t.payload.onSave});case Actions.ANNOTATION_ACTIONS.UPDATE_ON_PAGE_CHANGE:return __spreadProps(__spreadValues({},e),{onPageChange:t.payload.onPageChange});case Actions.ANNOTATION_ACTIONS.SET_PREDICT_RESULT:return __spreadProps(__spreadValues({},e),{predictionResult:t.payload.result});case Actions.ANNOTATION_ACTIONS.SET_PREDICT_RESULT_VISIBLE:return __spreadProps(__spreadValues({},e),{predictionResultVisible:t.payload.visible});case Actions.ANNOTATION_ACTIONS.UPDATE_ON_STEP_CHANGE:return __spreadProps(__spreadValues({},e),{onStepChange:t.payload.onStepChange});case Actions.ANNOTATION_ACTIONS.UPDATE_GET_FILE_DATA:return __spreadProps(__spreadValues({},e),{getFileData:t.payload.getFileData});case Actions.ANNOTATION_ACTIONS.UPDATE_PAGE_SIZE:return __spreadProps(__spreadValues({},e),{pageSize:t.payload.pageSize});case Actions.ANNOTATION_ACTIONS.UPDATE_LOAD_FILE_LIST:return __spreadProps(__spreadValues({},e),{loadFileList:t.payload.loadFileList});case Actions.ANNOTATION_ACTIONS.UPDATE_BEFORE_ROTATE:return __spreadProps(__spreadValues({},e),{beforeRotate:t.payload.beforeRotate});case Actions.ANNOTATION_ACTIONS.UPDATE_PRE_DATA_PROCESS:return __spreadProps(__spreadValues({},e),{preDataProcess:t.payload.preDataProcess});case Actions.ANNOTATION_ACTIONS.SKIP_BEFORE_PAGE_TURNING:return __spreadProps(__spreadValues({},e),{skipBeforePageTurning:t.payload.skipBeforePageTurning});case Actions.ANNOTATION_ACTIONS.SET_FILE_DATA:{const{fileData:n,index:o}=t.payload,{imgList:i}=e,l=[...i];return l[o]=__spreadValues(__spreadValues({},l[o]),n),__spreadProps(__spreadValues({},e),{imgList:l})}case Actions.ANNOTATION_ACTIONS.UPDATE_ROTATE:{const{toolInstance:n,beforeRotate:o}=e;return o&&o()===!1||(H=n==null?void 0:n.updateRotate)==null||H.call(n),e}case Actions.ANNOTATION_ACTIONS.UPDATE_ANNOTATION_VALID:{const{toolInstance:n}=e,o=(z=n==null?void 0:n.valid)!=null?z:!0;return antd.Modal.destroyAll(),antd.Modal.confirm({content:lbUtils.i18n.t(o?"updateValidFromValidToInValid":"updateValidFromInValidToValid"),onOk:()=>{n==null||n.setValid(!o)},okText:lbUtils.i18n.t("Confirm"),cancelText:lbUtils.i18n.t("Cancel")}),e}case Actions.ANNOTATION_ACTIONS.COPY_BACKWARD_RESULT:{const{toolInstance:n,imgIndex:o,imgList:i,step:l}=e;if(!n)return e;if(o===0||o>=i.length)return console.error("\u65E0\u6CD5\u590D\u5236\u8FB9\u754C\u5916\u7684\u5185\u5BB9"),e;const a=i[o-1].result;if(!a)return e;const r=AnnotationDataUtils.copyResultChange(a,l,(K=i[o].result)!=null?K:"");i[o]=__spreadProps(__spreadValues({},i[o]),{result:r});const d=index.jsonParser(r)[`step_${l}`],c=(d==null?void 0:d.result)||[];return n==null||n.setResult(c),n==null||n.history.pushHistory(c),(W=n==null?void 0:n.asyncData)==null||W.call(n,i[o]),__spreadProps(__spreadValues({},e),{imgList:[...i]})}case Actions.ANNOTATION_ACTIONS.SET_STEP:{const{stepList:n,annotationEngine:o}=e,{toStep:i}=t.payload;if(!o)return e;const l=getStepConfig(n,i);return o==null||o.setToolName(l.tool,l.config),__spreadProps(__spreadValues({},e),{step:i,toolInstance:o==null?void 0:o.toolInstance})}case Actions.ANNOTATION_ACTIONS.SET_LOADPCDFILE_LOADING:{const{loadPCDFileLoading:n}=t.payload;return __spreadProps(__spreadValues({},e),{loadPCDFileLoading:!!n})}case Actions.ANNOTATION_ACTIONS.SET_LOADING:{const{loading:n}=t.payload;return __spreadProps(__spreadValues({},e),{loading:!!n})}case Actions.ANNOTATION_ACTIONS.SET_POINT_CLOUD_LOADING:{const{pointCloudLoading:n}=t.payload;return __spreadProps(__spreadValues({},e),{pointCloudLoading:!!n})}case Actions.ANNOTATION_ACTIONS.SET_CHECK_MODE:{const{checkMode:n}=t.payload;return __spreadProps(__spreadValues({},e),{checkMode:!!n})}case Actions.ANNOTATION_ACTIONS.SET_HIGHLIGHT_ATTRIBUTE:{const{attribute:n}=t.payload;return __spreadProps(__spreadValues({},e),{highlightAttribute:n})}case Actions.ANNOTATION_ACTIONS.BATCH_UPDATE_TRACK_ID:{const{id:n,newID:o,rangeIndex:i,imgList:l}=t.payload,{imgIndex:a,onSubmit:r}=e,N=[],d=l.map((c,T)=>{if(lbAnnotation.MathUtils.isInRange(T,i)){const p=__spreadProps(__spreadValues({},c),{result:lbUtils.PointCloudUtils.batchUpdateTrackID({id:n,newID:o,result:c.result})});return N.push({imgIndex:T,newInfo:p}),p}return c});return r&&r([d[a]],index$1.ESubmitType.BatchUpdateTrackID,a,d,{updateImgList:N}),__spreadProps(__spreadValues({},e),{imgList:d})}case Actions.ANNOTATION_ACTIONS.BATCH_UPDATE_RESULT_BY_TRACK_ID:{const{id:n,newData:o,rangeIndex:i}=t.payload,{imgList:l,imgIndex:a,onSubmit:r}=e,N=[],d=l.map((c,T)=>{if(lbAnnotation.MathUtils.isInRange(T,i)){const p=__spreadProps(__spreadValues({},c),{result:lbUtils.PointCloudUtils.batchUpdateResultByTrackID({id:n,newData:o,result:c.result})});return N.push({imgIndex:T,newInfo:p}),p}return c});return r&&r([d[a]],index$1.ESubmitType.BatchUpdateTrackID,a,d,{updateImgList:N}),__spreadProps(__spreadValues({},e),{imgList:d})}case Actions.ANNOTATION_ACTIONS.BATCH_UPDATE_IMG_LIST_RESULT_BY_PREDICT_RESULT:{const{onSubmit:n,imgList:o,stepList:i,step:l,predictionResult:a}=e,r={};a.forEach(T=>{const{index:p}=T;r[p]=___default.default.pick(T,["center","width","height","depth","rotation","id","attribute","valid","trackID"])});const N=`step_${l}`,d=[],c=o.map((T,p)=>{if(r[p]){const f=T.result==="{}"?index.jsonParser(data.composeResult("",{step:l,stepList:i},{rect:[]},{})):index.jsonParser(T.result);f[N].result.push(r[p]);const C=__spreadProps(__spreadValues({},T),{result:JSON.stringify(f)});return d.push({imgIndex:p,newInfo:C}),C}return T});return n==null||n(c,index$1.ESubmitType.BatchUpdateImgList,-1,c,{updateImgList:d}),__spreadProps(__spreadValues({},e),{imgList:c})}default:return e}};exports.LoadFileAndFileData=LoadFileAndFileData,exports.annotationReducer=annotationReducer,exports.composeResultByToolInstance=composeResultByToolInstance,exports.getStepConfig=getStepConfig,exports.getTotalPage=getTotalPage;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var index$2=require("../../components/customResizeHook/index.js"),index$1=require("../../constant/index.js"),styleString=require("../../constant/styleString.js"),Actions=require("../Actions.js"),index=require("../../utils/index.js"),AnnotationDataUtils=require("../../utils/AnnotationDataUtils.js"),ConfigUtils=require("../../utils/ConfigUtils.js"),data=require("../../utils/data.js"),StepUtils=require("../../utils/StepUtils.js"),ToolUtils=require("../../utils/ToolUtils.js"),lbAnnotation=require("@labelbee/lb-annotation"),lbUtils=require("@labelbee/lb-utils"),antd=require("antd"),es=require("antd/es"),_=require("lodash"),actionCreators=require("./actionCreators.js"),ToolType=require("../../data/enums/ToolType.js");function _interopDefaultLegacy(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var ___default=_interopDefaultLegacy(_),__defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(e,t,s)=>t in e?__defProp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,__spreadValues=(e,t)=>{for(var s in t||(t={}))__hasOwnProp.call(t,s)&&__defNormalProp(e,s,t[s]);if(__getOwnPropSymbols)for(var s of __getOwnPropSymbols(t))__propIsEnum.call(t,s)&&__defNormalProp(e,s,t[s]);return e},__spreadProps=(e,t)=>__defProps(e,__getOwnPropDescs(t)),__async=(e,t,s)=>new Promise((O,a)=>{var A=I=>{try{S(s.next(I))}catch(m){a(m)}},g=I=>{try{S(s.throw(I))}catch(m){a(m)}},S=I=>I.done?O(I.value):Promise.resolve(I.value).then(A,g);S((s=s.apply(e,t)).next())});const getStepConfig=(e,t)=>e.find(s=>s.step===t),initialState={annotationEngine:null,toolInstance:null,imgList:[],config:"{}",imgIndex:-1,basicIndex:0,imgPageSize:1,step:1,stepList:[],imgNode:new Image,basicResultList:[],resultList:[],stepProgress:0,loading:!1,loadPCDFileLoading:!0,triggerEventAfterIndexChanged:!1,pointCloudLoading:!1,checkMode:!1,predictionResult:[],predictionResultVisible:!1,highlightAttribute:""},getTotalPage=e=>{const{imgList:t,imgPageSize:s}=e;return Math.ceil(t.length/s)},calcStepProgress=(e,t)=>e.reduce((s,O)=>{if(O){const a=O.result;if(index.jsonParser(a)[`step_${t}`])return s+1}return s},0)/e.length,updateToolInstance=(e,t)=>{const{step:s,stepList:O}=e,a=StepUtils.getCurrentStepInfo(s,O),A=ConfigUtils.ConfigUtils.jsonParser(a.config);if(ToolUtils.isVideoTool(a==null?void 0:a.tool)||ToolUtils.isAudioTool(a==null?void 0:a.tool)||ToolUtils.isPointCloudTool(a==null?void 0:a.tool)||ToolType.EToolName.LLM===(a==null?void 0:a.tool))return;const g=document.getElementById("toolContainer");if(!g)throw"Not exist dom named id-toolContainer";const S=index$2.getFormatSize({width:window.innerWidth,height:window.innerHeight}),I=new lbAnnotation.AnnotationEngine({container:g,toolName:a.tool,size:S,imgNode:t,config:A,style:JSON.parse(styleString)});return{toolInstance:I==null?void 0:I.toolInstance,annotationEngine:I}},LoadFileAndFileData=(e,t)=>(s,O)=>__async(void 0,null,function*(){var a;const{stepList:A,step:g}=O().annotation,S=StepUtils.currentToolIsVideo(g,A),I=StepUtils.currentToolIsPointCloud(g,A),m=((a=StepUtils.getCurrentStepInfo(g,A))==null?void 0:a.tool)===ToolType.EToolName.LLM,D=StepUtils.currentToolIsAudio(g,A);if(actionCreators.SetAnnotationLoading(s,!0),yield s(TryGetFileDataByAPI(e)),S){s(AfterVideoLoaded(e));return}if(I||m||D){s(AfterCommonLoaded(e));return}s(AfterImageLoaded(e,t))}),TryGetFileDataByAPI=e=>(t,s)=>__async(void 0,null,function*(){const{getFileData:O,imgList:a}=s().annotation;if(O){const A=yield O(a[e],e);t({type:Actions.ANNOTATION_ACTIONS.SET_FILE_DATA,payload:{fileData:A,index:e}})}}),AfterVideoLoaded=e=>t=>{t({type:Actions.ANNOTATION_ACTIONS.LOAD_FILE_DATA,payload:{nextIndex:e}})},AfterCommonLoaded=e=>t=>{actionCreators.SetAnnotationLoading(t,!1),t({type:Actions.ANNOTATION_ACTIONS.LOAD_FILE_DATA,payload:{nextIndex:e}})},AfterImageLoaded=(e,t)=>(s,O)=>{var a;const{toolInstance:A,imgList:g}=O().annotation,S=(a=g==null?void 0:g[e])==null?void 0:a.url;lbAnnotation.ImgUtils.load(S).then(I=>{actionCreators.SetAnnotationLoading(s,!1),s({type:Actions.ANNOTATION_ACTIONS.LOAD_FILE_DATA,payload:{imgNode:I,nextIndex:e,nextBasicIndex:t}})}).catch(()=>{actionCreators.SetAnnotationLoading(s,!1),A==null||A.setErrorImg(),s({type:Actions.ANNOTATION_ACTIONS.LOAD_FILE_DATA,payload:{nextIndex:e,nextBasicIndex:t}})})},composeResultByToolInstance=({toolInstance:e,imgList:t,imgIndex:s,stepList:O,step:a=1})=>{var A,g,S,I;const m=((A=t[s])==null?void 0:A.result)||"",[D,b,U]=(g=e==null?void 0:e.exportData())!=null?g:[],x=(I=(S=e==null?void 0:e.exportCustomData)==null?void 0:S.call(e))!=null?I:{},B=data.composeResultWithBasicImgInfo(m,b),w=data.composeResult(B,{step:a,stepList:O},{rect:D},x);return t.map((R,F)=>F===s?__spreadValues(__spreadProps(__spreadValues({},R),{result:w}),U):__spreadValues({},R))},annotationReducer=(e=__spreadValues({},initialState),t)=>{var s,O,a,A,g,S,I,m,D,b,U,x,B,w,R,F,G,V,M,q,k,H,z,K,W;switch(t.type){case Actions.ANNOTATION_ACTIONS.INIT_ALL_STATE:return __spreadValues(__spreadValues({},e),initialState);case Actions.ANNOTATION_ACTIONS.UPDATE_TOOL_INSTANCE:return __spreadProps(__spreadValues({},e),{toolInstance:t.payload.toolInstance});case Actions.ANNOTATION_ACTIONS.UPDATE_IMG_LIST:return __spreadProps(__spreadValues({},e),{imgList:t.payload.imgList});case Actions.ANNOTATION_ACTIONS.CALC_STEP_PROGRESS:{const{imgList:n,step:o}=e,i=calcStepProgress(n,o);return __spreadProps(__spreadValues({},e),{stepProgress:i})}case Actions.ANNOTATION_ACTIONS.SUBMIT_FILE_DATA:{const{imgList:n,imgIndex:o,step:i,stepList:l,toolInstance:u,onSubmit:r,resultList:N}=e;if(!u||!n[o])return e;const d=((s=n[o])==null?void 0:s.result)||"",[,c,T]=(O=u==null?void 0:u.exportData())!=null?O:[],p=(A=(a=u==null?void 0:u.exportCustomData)==null?void 0:a.call(u))!=null?A:{},f=data.composeResultWithBasicImgInfo(d,c),C=data.composeResult(f,{step:i,stepList:l},{rect:N},p),L=e.imgList.map((v,E)=>{if(E===o){const h=AnnotationDataUtils.dataCorrection(C,d,i,l);return __spreadValues(__spreadProps(__spreadValues({},v),{result:h}),T)}return v});if(((g=t.payload)==null?void 0:g.submitType)===index$1.ESubmitType.SyncImgList)return __spreadProps(__spreadValues({},e),{imgList:L});r&&r([L[o]],(S=t.payload)==null?void 0:S.submitType,o,L);const y=calcStepProgress(L,i);return __spreadProps(__spreadValues({},e),{stepProgress:y,imgList:L})}case Actions.ANNOTATION_ACTIONS.SAVE_RESULT:{const{imgList:n,imgIndex:o,onSave:i}=e;return i==null||i(n[o],o,n),__spreadValues({},e)}case Actions.ANNOTATION_ACTIONS.SUBMIT_RESULT:{const{imgList:n,basicIndex:o,resultList:i,toolInstance:l,basicResultList:u}=e;if(!l)return e;const[r]=(I=l==null?void 0:l.exportData())!=null?I:[];let N=r;if((u==null?void 0:u.length)>0){const d=(m=u[o])==null?void 0:m.id,c=r.map(T=>__spreadProps(__spreadValues({},T),{sourceID:d}));N=___default.default.cloneDeep(i).filter(T=>T.sourceID!==d),N.push(...c)}return __spreadProps(__spreadValues({},e),{resultList:N,imgList:n})}case Actions.ANNOTATION_ACTIONS.SET_BASIC_INDEX:{const{toolInstance:n,step:o,imgList:i,imgIndex:l,stepList:u,annotationEngine:r,resultList:N,basicResultList:d}=e;if(!n||!r)return e;const c=t.payload.basicIndex,T=(D=d[c])==null?void 0:D.id,p=index.jsonParser((b=i[l])==null?void 0:b.result),f=(N||[]).filter(h=>h.sourceID===T),C=getStepConfig(u,o),{dataSourceStep:L,tool:y}=C,v=getStepConfig(u,L);let E=[];return L&&y&&(E=(U=p[`step_${L}`])==null?void 0:U.result,(E==null?void 0:E.length)>0?(r==null||r.setBasicInfo(v.tool,E[c]),r==null||r.launchOperation()):(r==null||r.setBasicInfo(v.tool),r==null||r.forbidOperation(),es.message.info(lbUtils.i18n.t("NoDependency")))),n==null||n.setResult(f),n==null||n.history.initRecord(f,!0),__spreadProps(__spreadValues({},e),{basicIndex:c})}case Actions.ANNOTATION_ACTIONS.SET_TRIGGER_EVENT_AFTER_INDEX_CHANGED:{const{triggerEventAfterIndexChanged:n}=t.payload;return __spreadProps(__spreadValues({},e),{triggerEventAfterIndexChanged:!!n})}case Actions.ANNOTATION_ACTIONS.LOAD_FILE_DATA:{const{imgList:n,step:o,toolInstance:i,annotationEngine:l,stepList:u}=e;if(!i)return __spreadProps(__spreadValues({},e),{imgIndex:t.payload.nextIndex});const r=StepUtils.getCurrentStepInfo(o,u),{nextIndex:N,imgNode:d,nextBasicIndex:c,imgError:T}=t.payload,p=c!=null?c:0,f=index.jsonParser((x=n[N])==null?void 0:x.result),C=f[`step_${r.step}`],L=!C,y={rotate:(B=f.rotate)!=null?B:0,valid:(w=f.valid)!=null?w:!0};d&&T!==!0?l==null||l.setImgNode(d,y):i==null||i.setValid(y.valid);const v=getStepConfig(u,r.step),{dataSourceStep:E,tool:h}=v,$=getStepConfig(u,E),Y=E&&h,P=(F=(R=f[`step_${E}`])==null?void 0:R.result)!=null?F:[],j=AnnotationDataUtils.getInitialResultList(C==null?void 0:C.result,i,v,P,L);if(l==null||l.launchOperation(),Y&&((P==null?void 0:P.length)>0?l==null||l.setBasicInfo($.tool,P[p]):(l==null||l.setBasicInfo($.tool),l==null||l.forbidOperation(),es.message.info(lbUtils.i18n.t("NoDependency")))),r.tool!=="check"){const J=(V=(G=P[p])==null?void 0:G.id)!=null?V:"",X=Y?j.filter(Z=>lbAnnotation.CommonToolUtils.isSameSourceID(Z.sourceID,J)):j;(M=i==null?void 0:i.history)==null||M.initRecord(j,!0),i==null||i.setResult(X)}return __spreadProps(__spreadValues({},e),{imgIndex:N,basicIndex:p,basicResultList:P,resultList:j})}case Actions.ANNOTATION_ACTIONS.UPDATE_ANNOTATION_CONFIG:return __spreadProps(__spreadValues({},e),{config:(q=t.payload.config)!=null?q:"{}"});case Actions.ANNOTATION_ACTIONS.SET_TASK_STEP_LIST:{const{stepList:n}=t.payload;return __spreadProps(__spreadValues({},e),{stepList:n})}case Actions.ANNOTATION_ACTIONS.SET_TASK_CONFIG:{const{stepList:n,step:o}=t.payload;return __spreadProps(__spreadValues({},e),{stepList:n,step:o})}case Actions.ANNOTATION_ACTIONS.INIT_TOOL:{const{imgNode:n}=e,o=updateToolInstance(e,n);if(o){const{toolInstance:i,annotationEngine:l}=o;return __spreadProps(__spreadValues({},e),{toolInstance:i,annotationEngine:l})}return __spreadValues({},e)}case Actions.ANNOTATION_ACTIONS.SET_TOOL:{const n=(k=t.payload)==null?void 0:k.instance;return n?__spreadProps(__spreadValues({},e),{toolInstance:n}):__spreadValues({},e)}case Actions.ANNOTATION_ACTIONS.UPDATE_ON_SUBMIT:return __spreadProps(__spreadValues({},e),{onSubmit:t.payload.onSubmit});case Actions.ANNOTATION_ACTIONS.UPDATE_ON_SAVE:return __spreadProps(__spreadValues({},e),{onSave:t.payload.onSave});case Actions.ANNOTATION_ACTIONS.UPDATE_ON_PAGE_CHANGE:return __spreadProps(__spreadValues({},e),{onPageChange:t.payload.onPageChange});case Actions.ANNOTATION_ACTIONS.SET_PREDICT_RESULT:return __spreadProps(__spreadValues({},e),{predictionResult:t.payload.result});case Actions.ANNOTATION_ACTIONS.SET_PREDICT_RESULT_VISIBLE:return __spreadProps(__spreadValues({},e),{predictionResultVisible:t.payload.visible});case Actions.ANNOTATION_ACTIONS.UPDATE_ON_STEP_CHANGE:return __spreadProps(__spreadValues({},e),{onStepChange:t.payload.onStepChange});case Actions.ANNOTATION_ACTIONS.UPDATE_GET_FILE_DATA:return __spreadProps(__spreadValues({},e),{getFileData:t.payload.getFileData});case Actions.ANNOTATION_ACTIONS.UPDATE_PAGE_SIZE:return __spreadProps(__spreadValues({},e),{pageSize:t.payload.pageSize});case Actions.ANNOTATION_ACTIONS.UPDATE_LOAD_FILE_LIST:return __spreadProps(__spreadValues({},e),{loadFileList:t.payload.loadFileList});case Actions.ANNOTATION_ACTIONS.UPDATE_BEFORE_ROTATE:return __spreadProps(__spreadValues({},e),{beforeRotate:t.payload.beforeRotate});case Actions.ANNOTATION_ACTIONS.UPDATE_PRE_DATA_PROCESS:return __spreadProps(__spreadValues({},e),{preDataProcess:t.payload.preDataProcess});case Actions.ANNOTATION_ACTIONS.SKIP_BEFORE_PAGE_TURNING:return __spreadProps(__spreadValues({},e),{skipBeforePageTurning:t.payload.skipBeforePageTurning});case Actions.ANNOTATION_ACTIONS.SET_FILE_DATA:{const{fileData:n,index:o}=t.payload,{imgList:i}=e,l=[...i];return l[o]=__spreadValues(__spreadValues({},l[o]),n),__spreadProps(__spreadValues({},e),{imgList:l})}case Actions.ANNOTATION_ACTIONS.UPDATE_ROTATE:{const{toolInstance:n,beforeRotate:o}=e;return o&&o()===!1||(H=n==null?void 0:n.updateRotate)==null||H.call(n),e}case Actions.ANNOTATION_ACTIONS.UPDATE_ANNOTATION_VALID:{const{toolInstance:n}=e,o=(z=n==null?void 0:n.valid)!=null?z:!0;return antd.Modal.destroyAll(),antd.Modal.confirm({content:lbUtils.i18n.t(o?"updateValidFromValidToInValid":"updateValidFromInValidToValid"),onOk:()=>{n==null||n.setValid(!o)},okText:lbUtils.i18n.t("Confirm"),cancelText:lbUtils.i18n.t("Cancel")}),e}case Actions.ANNOTATION_ACTIONS.COPY_BACKWARD_RESULT:{const{toolInstance:n,imgIndex:o,imgList:i,step:l}=e;if(!n)return e;if(o===0||o>=i.length)return console.error("\u65E0\u6CD5\u590D\u5236\u8FB9\u754C\u5916\u7684\u5185\u5BB9"),e;const u=i[o-1].result;if(!u)return e;const r=AnnotationDataUtils.copyResultChange(u,l,(K=i[o].result)!=null?K:"");i[o]=__spreadProps(__spreadValues({},i[o]),{result:r});const d=index.jsonParser(r)[`step_${l}`],c=(d==null?void 0:d.result)||[];return n==null||n.setResult(c),n==null||n.history.pushHistory(c),(W=n==null?void 0:n.asyncData)==null||W.call(n,i[o]),__spreadProps(__spreadValues({},e),{imgList:[...i]})}case Actions.ANNOTATION_ACTIONS.SET_STEP:{const{stepList:n,annotationEngine:o}=e,{toStep:i}=t.payload;if(!o)return e;const l=getStepConfig(n,i);return o==null||o.setToolName(l.tool,l.config),__spreadProps(__spreadValues({},e),{step:i,toolInstance:o==null?void 0:o.toolInstance})}case Actions.ANNOTATION_ACTIONS.SET_LOADPCDFILE_LOADING:{const{loadPCDFileLoading:n}=t.payload;return __spreadProps(__spreadValues({},e),{loadPCDFileLoading:!!n})}case Actions.ANNOTATION_ACTIONS.SET_LOADING:{const{loading:n}=t.payload;return __spreadProps(__spreadValues({},e),{loading:!!n})}case Actions.ANNOTATION_ACTIONS.SET_POINT_CLOUD_LOADING:{const{pointCloudLoading:n}=t.payload;return __spreadProps(__spreadValues({},e),{pointCloudLoading:!!n})}case Actions.ANNOTATION_ACTIONS.SET_CHECK_MODE:{const{checkMode:n}=t.payload;return __spreadProps(__spreadValues({},e),{checkMode:!!n})}case Actions.ANNOTATION_ACTIONS.SET_HIGHLIGHT_ATTRIBUTE:{const{attribute:n}=t.payload;return __spreadProps(__spreadValues({},e),{highlightAttribute:n})}case Actions.ANNOTATION_ACTIONS.BATCH_UPDATE_TRACK_ID:{const{id:n,newID:o,rangeIndex:i,imgList:l}=t.payload,{imgIndex:u,onSubmit:r}=e,N=[],d=l.map((c,T)=>{if(lbAnnotation.MathUtils.isInRange(T,i)){const p=__spreadProps(__spreadValues({},c),{result:lbUtils.PointCloudUtils.batchUpdateTrackID({id:n,newID:o,result:c.result})});return N.push({imgIndex:T,newInfo:p}),p}return c});return r&&r([d[u]],index$1.ESubmitType.BatchUpdateTrackID,u,d,{updateImgList:N}),__spreadProps(__spreadValues({},e),{imgList:d})}case Actions.ANNOTATION_ACTIONS.BATCH_UPDATE_RESULT_BY_TRACK_ID:{const{id:n,newData:o,rangeIndex:i}=t.payload,{imgList:l,imgIndex:u,onSubmit:r}=e,N=[],d=l.map((c,T)=>{if(lbAnnotation.MathUtils.isInRange(T,i)){const p=__spreadProps(__spreadValues({},c),{result:lbUtils.PointCloudUtils.batchUpdateResultByTrackID({id:n,newData:o,result:c.result})});return N.push({imgIndex:T,newInfo:p}),p}return c});return r&&r([d[u]],index$1.ESubmitType.BatchUpdateTrackID,u,d,{updateImgList:N}),__spreadProps(__spreadValues({},e),{imgList:d})}case Actions.ANNOTATION_ACTIONS.BATCH_UPDATE_IMG_LIST_RESULT_BY_PREDICT_RESULT:{const{onSubmit:n,imgList:o,stepList:i,step:l,predictionResult:u}=e,r={};u.forEach(T=>{const{index:p}=T;r[p]=___default.default.pick(T,["center","width","height","depth","rotation","id","attribute","valid","trackID"])});const N=`step_${l}`,d=[],c=o.map((T,p)=>{if(r[p]){const f=T.result==="{}"?index.jsonParser(data.composeResult("",{step:l,stepList:i},{rect:[]},{})):index.jsonParser(T.result);f[N].result.push(r[p]);const C=__spreadProps(__spreadValues({},T),{result:JSON.stringify(f)});return d.push({imgIndex:p,newInfo:C}),C}return T});return n==null||n(c,index$1.ESubmitType.BatchUpdateImgList,-1,c,{updateImgList:d}),__spreadProps(__spreadValues({},e),{imgList:c})}default:return e}};exports.LoadFileAndFileData=LoadFileAndFileData,exports.annotationReducer=annotationReducer,exports.composeResultByToolInstance=composeResultByToolInstance,exports.getStepConfig=getStepConfig,exports.getTotalPage=getTotalPage;
@@ -9,6 +9,7 @@ interface IVideoClipProps extends IVideoAnnotateProps {
9
9
  pageBackward: () => void;
10
10
  onMounted: (instance: any) => void;
11
11
  onUnmounted: () => void;
12
+ onVideoLoaded: () => void;
12
13
  }
13
14
  interface IState {
14
15
  result: IVideoTimeSlice[];
@@ -80,7 +81,6 @@ declare class VideoClipTool extends React.Component<IVideoClipProps, IState> {
80
81
  updateSelectedSliceTimeEndByPer: (changeTime: number) => void;
81
82
  updateSelectedSliceTimeProperty: (val: number, key: 'start' | 'end') => void;
82
83
  keyDownEvents: (e: KeyboardEvent) => void;
83
- videoLoaded: (totalTime?: number) => void;
84
84
  setVideoError: (videoError: boolean, errorType: any, curTime: number) => void;
85
85
  clearResult: () => void;
86
86
  /** 取消截取 */
@@ -14,6 +14,7 @@ export interface IVideoTagInstanceAdaptorProps extends IVideoAnnotateProps {
14
14
  pageBackward: () => void;
15
15
  onMounted: (instance: any) => void;
16
16
  onUnmounted: () => void;
17
+ onVideoLoaded: () => void;
17
18
  }
18
19
  interface IVideoTagInstanceAdaptorState {
19
20
  tagResult: any[];
@@ -39,9 +40,6 @@ export declare class TagToolInstanceAdaptor extends React.Component<IVideoTagIns
39
40
  exportData: () => (any[] | {
40
41
  valid: boolean;
41
42
  duration: number;
42
- frames: number | undefined;
43
- videoWidth: number;
44
- videoHeight: number;
45
43
  })[];
46
44
  singleOn(event: string, func: () => void): void;
47
45
  on(event: string, func: () => void): void;
@@ -6,6 +6,7 @@ export interface IVideoTextInstanceAdaptorProps extends IVideoAnnotateProps {
6
6
  pageBackward: () => void;
7
7
  onMounted: (instance: any) => void;
8
8
  onUnmounted: () => void;
9
+ onVideoLoaded: () => void;
9
10
  }
10
11
  interface IVideoTextInstanceAdaptorState {
11
12
  result: any;
@@ -32,9 +33,6 @@ export declare class VideoTextTool extends React.Component<IVideoTextInstanceAda
32
33
  exportData: () => (any[] | {
33
34
  valid: boolean;
34
35
  duration: number;
35
- frames: number | undefined;
36
- videoWidth: number;
37
- videoHeight: number;
38
36
  })[];
39
37
  toggleShowText: (v: boolean) => void;
40
38
  singleOn: (event: string, func: () => void) => void;
@@ -35,7 +35,7 @@ interface IVideoPlayerProps {
35
35
  showVideoTrack?: boolean;
36
36
  onTrackResize?: any;
37
37
  footer?: any;
38
- dataLoaded?: (totalTime: number) => void;
38
+ dataLoaded?: () => void;
39
39
  addTime?: () => void;
40
40
  toggleClipStatus?: () => void;
41
41
  drawLayerSlot?: any;
@@ -1 +1 @@
1
- import t from"react";import{Tag as i,Image as c}from"antd";import{prefix as g}from"../../../../../constant/index.js";import d from"classnames";import f from"../../../../../assets/annotation/LLMTool/imgFail_cn.svg.js";import p from"../../../../../assets/annotation/LLMTool/imgFail_en.svg.js";import{i18n as u}from"@labelbee/lb-utils";import a from"./index.module.scss.js";const s=`${g}-LLMView`,v=m=>{const{answerList:o,hoverKey:r}=m,l=u.language==="en"?p:f;return t.createElement("div",{className:a.imgView},o.map((e,n)=>t.createElement("div",{key:n,className:a.item},t.createElement(i,{className:`${s}__tag`},e==null?void 0:e.order),t.createElement("div",{className:d({[`${a.image}`]:!0,[`${s}__contentActive`]:r===(e==null?void 0:e.order)})},t.createElement(c,{src:e==null?void 0:e.url,fallback:l})))))};export{v as default};
1
+ import t from"react";import{Tag as i,Image as c}from"antd";import{prefix as g}from"../../../../../constant/index.js";import d from"classnames";import f from"../../../../../assets/annotation/LLMTool/imgFail_cn.svg.js";import p from"../../../../../assets/annotation/LLMTool/imgFail_en.svg.js";import{i18n as u}from"@labelbee/lb-utils";import a from"./index.module.scss.js";const s=`${g}-LLMView`,v=m=>{const{answerList:o,hoverKey:r}=m,l=u.language==="en"?p:f;return t.createElement("div",{className:a.imgView},o.map((e,n)=>t.createElement("div",{key:n,className:a.item},t.createElement(i,{className:`${s}-tag`},e==null?void 0:e.order),t.createElement("div",{className:d({[`${a.image}`]:!0,[`${s}__contentActive`]:r===(e==null?void 0:e.order)})},t.createElement(c,{src:e==null?void 0:e.url,fallback:l})))))};export{v as default};
@@ -1 +1 @@
1
- import r,{useState as j,useEffect as C}from"react";import{Tag as O}from"antd";import{EDataFormatType as v,ELLMDataType as w,prefix as S}from"../../../constant/index.js";import b from"classnames";import{I18nextProvider as N,useTranslation as $}from"react-i18next";import{i18n as _}from"@labelbee/lb-utils";import D from"../../markdownView/index.js";import k from"../modelAPIView/index.js";import R from"../../diffMatchPatchComponent/index.js";import F from"./components/header/index.js";import q from"./components/imgView/index.js";import{isString as B}from"lodash";var H=Object.defineProperty,E=Object.getOwnPropertySymbols,Q=Object.prototype.hasOwnProperty,W=Object.prototype.propertyIsEnumerable,g=(e,t,n)=>t in e?H(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,K=(e,t)=>{for(var n in t||(t={}))Q.call(t,n)&&g(e,n,t[n]);if(E)for(var n of E(t))W.call(t,n)&&g(e,n,t[n]);return e};const l=`${S}-LLMView`,z=({i:e,dataFormatType:t,isTextControl:n})=>{var i;return t===v.Markdown?r.createElement(D,{value:(i=e==null?void 0:e.newAnswer)!=null?i:e==null?void 0:e.answer}):n?r.createElement("div",{style:{width:"100%",overflowWrap:"break-word"}},r.createElement(R,{originString:e==null?void 0:e.answer,currentString:e==null?void 0:e.newAnswer})):r.createElement("div",{style:{whiteSpace:"pre-wrap"}},(e==null?void 0:e.newAnswer)||(e==null?void 0:e.answer))},G=e=>{var t,n;const{hoverKey:i,answerList:d,question:m,lang:u,modelAPIResponse:x,setModelAPIResponse:y,checkMode:P=!0,LLMConfig:a,answerHeaderSlot:h}=e,[c,I]=j(v.Default),A=((t=a==null?void 0:a.dataType)==null?void 0:t.prompt)===w.Picture,M=((n=a==null?void 0:a.dataType)==null?void 0:n.response)===w.Picture,{t:T}=$();C(()=>{var o;u&&((o=_)==null||o.changeLanguage(u))},[]);const V=o=>{var s;return(a==null?void 0:a.isTextEdit)?!!((s=((a==null?void 0:a.textEdit)||[]).filter(f=>(f==null?void 0:f.title)===o.order)[0])==null?void 0:s.textControl):!1},L=r.createElement("div",null,d.map((o,s)=>{const p=V(o);return r.createElement("div",{className:b({[`${l}__content`]:!0,[`${l}__contentActive`]:i===(o==null?void 0:o.order)}),key:s},r.createElement(O,{className:`${l}__tag`},o==null?void 0:o.order),r.createElement(z,{i:o,isTextControl:p,dataFormatType:c}))}),B(m)&&r.createElement(k,{dataFormatType:c,modelAPIResponse:x,question:m,setModelAPIResponse:y,checkMode:P,annotation:e.annotation}));return r.createElement("div",{className:l},r.createElement(F,{question:m,dataFormatType:c,setDataFormatType:I,isImg:A}),r.createElement("div",{className:`${l}__textBox`},r.createElement("div",{className:`${l}__title`},T("Answer")," ",h),M?r.createElement(q,{hoverKey:i,answerList:d}):L))},J=e=>r.createElement(N,{i18n:_},r.createElement(G,K({},e)));export{l as LLMViewCls,J as default};
1
+ import r,{useState as j,useEffect as C}from"react";import{Tag as O}from"antd";import{EDataFormatType as v,ELLMDataType as w,prefix as S}from"../../../constant/index.js";import b from"classnames";import{I18nextProvider as N,useTranslation as $}from"react-i18next";import{i18n as E}from"@labelbee/lb-utils";import D from"../../markdownView/index.js";import k from"../modelAPIView/index.js";import R from"../../diffMatchPatchComponent/index.js";import F from"./components/header/index.js";import q from"./components/imgView/index.js";import{isString as B}from"lodash";var H=Object.defineProperty,_=Object.getOwnPropertySymbols,Q=Object.prototype.hasOwnProperty,W=Object.prototype.propertyIsEnumerable,g=(e,t,n)=>t in e?H(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,K=(e,t)=>{for(var n in t||(t={}))Q.call(t,n)&&g(e,n,t[n]);if(_)for(var n of _(t))W.call(t,n)&&g(e,n,t[n]);return e};const l=`${S}-LLMView`,z=({i:e,dataFormatType:t,isTextControl:n})=>{var i;return t===v.Markdown?r.createElement(D,{value:(i=e==null?void 0:e.newAnswer)!=null?i:e==null?void 0:e.answer}):n?r.createElement("div",{style:{width:"100%",overflowWrap:"break-word"}},r.createElement(R,{originString:e==null?void 0:e.answer,currentString:e==null?void 0:e.newAnswer})):r.createElement("div",{style:{whiteSpace:"pre-wrap"}},(e==null?void 0:e.newAnswer)||(e==null?void 0:e.answer))},G=e=>{var t,n;const{hoverKey:i,answerList:d,question:m,lang:u,modelAPIResponse:x,setModelAPIResponse:y,checkMode:P=!0,LLMConfig:a,answerHeaderSlot:h}=e,[c,I]=j(v.Default),A=((t=a==null?void 0:a.dataType)==null?void 0:t.prompt)===w.Picture,M=((n=a==null?void 0:a.dataType)==null?void 0:n.response)===w.Picture,{t:T}=$();C(()=>{var o;u&&((o=E)==null||o.changeLanguage(u))},[]);const V=o=>{var s;return(a==null?void 0:a.isTextEdit)?!!((s=((a==null?void 0:a.textEdit)||[]).filter(f=>(f==null?void 0:f.title)===o.order)[0])==null?void 0:s.textControl):!1},L=r.createElement("div",null,d.map((o,s)=>{const p=V(o);return r.createElement("div",{className:b({[`${l}__content`]:!0,[`${l}__contentActive`]:i===(o==null?void 0:o.order)}),key:s},r.createElement(O,{className:`${l}-tag`},o==null?void 0:o.order),r.createElement(z,{i:o,isTextControl:p,dataFormatType:c}))}),B(m)&&r.createElement(k,{dataFormatType:c,modelAPIResponse:x,question:m,setModelAPIResponse:y,checkMode:P,annotation:e.annotation}));return r.createElement("div",{className:l},r.createElement(F,{question:m,dataFormatType:c,setDataFormatType:I,isImg:A}),r.createElement("div",{className:`${l}__textBox`},r.createElement("div",{className:`${l}__title`},T("Answer")," ",h),M?r.createElement(q,{hoverKey:i,answerList:d}):L))},J=e=>r.createElement(N,{i18n:E},r.createElement(G,K({},e)));export{l as LLMViewCls,J as default};
@@ -1 +1 @@
1
- import u from"react";import{connect as y}from"react-redux";import{LabelBeeContext as I,useDispatch as b}from"../../store/ctx.js";import{ANNOTATION_ACTIONS as _}from"../../store/Actions.js";import{PageJump as m,PageBackward as v,PageForward as O}from"../../store/annotation/actionCreators.js";import{TagToolInstanceAdaptor as S}from"./videoTagTool/TagToolInstanceAdaptor.js";import{cTool as V}from"@labelbee/lb-annotation";import A from"./videoClipTool/index.js";import E from"../../utils/StepUtils.js";import{jsonParser as C}from"../../utils/index.js";import{VideoTextTool as N}from"./videoTextTool/index.js";var h=Object.defineProperty,L=Object.defineProperties,B=Object.getOwnPropertyDescriptors,P=Object.getOwnPropertySymbols,J=Object.prototype.hasOwnProperty,D=Object.prototype.propertyIsEnumerable,j=(e,o,t)=>o in e?h(e,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[o]=t,f=(e,o)=>{for(var t in o||(o={}))J.call(o,t)&&j(e,t,o[t]);if(P)for(var t of P(o))D.call(o,t)&&j(e,t,o[t]);return e},T=(e,o)=>L(e,B(o));const{EVideoToolName:g}=V,U=e=>{const{stepInfo:o,skipBeforePageTurning:t}=e,a=o==null?void 0:o.tool,r=b(),i=n=>{r({type:_.SET_TOOL,payload:{instance:n}})},l=()=>{r({type:_.SET_TOOL,payload:{instance:void 0}})},p=()=>{if(t){t(()=>r(v()));return}r(v())},s=()=>{if(t){t(()=>r(O()));return}r(O())};return a===g.VideoClipTool?u.createElement(A,T(f({},e),{pageBackward:p,pageForward:s,pageJump:n=>r(m(~~n-1)),onMounted:i,onUnmounted:l})):a===g.VideoTextTool?u.createElement(N,T(f({},e),{pageBackward:p,pageForward:s,pageJump:n=>r(m(~~n-1)),onMounted:i,onUnmounted:l})):a===g.VideoTagTool?u.createElement(S,T(f({},e),{pageBackward:p,pageForward:s,pageJump:n=>r(m(~~n-1)),onMounted:i,onUnmounted:l})):null},k=e=>{var o,t,a,r,i;const{annotation:{imgList:l,imgIndex:p,step:s,stepList:n,loading:x,skipBeforePageTurning:w}}=e,d=E.getCurrentStepInfo((o=e.annotation)==null?void 0:o.step,(t=e.annotation)==null?void 0:t.stepList),c=(a=l[p])!=null?a:{};return{imgIndex:p,imgList:l,stepInfo:d,config:C(d==null?void 0:d.config),step:s,stepList:n,path:(i=(r=c==null?void 0:c.path)!=null?r:c==null?void 0:c.url)!=null?i:"",loading:x,skipBeforePageTurning:w}};var F=y(k,null,null,{context:I})(U);export{F as default};
1
+ import m from"react";import{connect as I}from"react-redux";import{LabelBeeContext as w,useDispatch as S}from"../../store/ctx.js";import{ANNOTATION_ACTIONS as f}from"../../store/Actions.js";import{PageJump as T,PageBackward as O,PageForward as P}from"../../store/annotation/actionCreators.js";import{TagToolInstanceAdaptor as V}from"./videoTagTool/TagToolInstanceAdaptor.js";import{cTool as b}from"@labelbee/lb-annotation";import A from"./videoClipTool/index.js";import E from"../../utils/StepUtils.js";import{jsonParser as L}from"../../utils/index.js";import{VideoTextTool as N}from"./videoTextTool/index.js";var C=Object.defineProperty,h=Object.defineProperties,B=Object.getOwnPropertyDescriptors,j=Object.getOwnPropertySymbols,D=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable,y=(e,o,t)=>o in e?C(e,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[o]=t,g=(e,o)=>{for(var t in o||(o={}))D.call(o,t)&&y(e,t,o[t]);if(j)for(var t of j(o))J.call(o,t)&&y(e,t,o[t]);return e},_=(e,o)=>h(e,B(o));const{EVideoToolName:v}=b,U=e=>{const{stepInfo:o,skipBeforePageTurning:t}=e,a=o==null?void 0:o.tool,r=S(),i=n=>{r({type:f.SET_TOOL,payload:{instance:n}})},l=()=>{r({type:f.SET_TOOL,payload:{instance:void 0}})},p=()=>{r({type:f.SET_LOADING,payload:{loading:!1}})},s=()=>{if(t){t(()=>r(O()));return}r(O())},c=()=>{if(t){t(()=>r(P()));return}r(P())};return a===v.VideoClipTool?m.createElement(A,_(g({},e),{pageBackward:s,pageForward:c,pageJump:n=>r(T(~~n-1)),onMounted:i,onUnmounted:l,onVideoLoaded:p})):a===v.VideoTextTool?m.createElement(N,_(g({},e),{pageBackward:s,pageForward:c,pageJump:n=>r(T(~~n-1)),onMounted:i,onUnmounted:l,onVideoLoaded:p})):a===v.VideoTagTool?m.createElement(V,_(g({},e),{pageBackward:s,pageForward:c,pageJump:n=>r(T(~~n-1)),onMounted:i,onUnmounted:l,onVideoLoaded:p})):null},k=e=>{var o,t,a,r,i;const{annotation:{imgList:l,imgIndex:p,step:s,stepList:c,loading:n,skipBeforePageTurning:x}}=e,u=E.getCurrentStepInfo((o=e.annotation)==null?void 0:o.step,(t=e.annotation)==null?void 0:t.stepList),d=(a=l[p])!=null?a:{};return{imgIndex:p,imgList:l,stepInfo:u,config:L(u==null?void 0:u.config),step:s,stepList:c,path:(i=(r=d==null?void 0:d.path)!=null?r:d==null?void 0:d.url)!=null?i:"",loading:n,skipBeforePageTurning:x}};var F=I(k,null,null,{context:w})(U);export{F as default};
@@ -1 +1 @@
1
- import{MathUtils as I,CommonToolUtils as V,uuid as w,AttributeUtils as k}from"@labelbee/lb-annotation";import{jsonParser as T}from"../../../utils/index.js";import{precisionAdd as D,precisionMinus as j,isImageValue as B}from"../../../utils/audio.js";import{message as f}from"antd";import y from"lodash";import v from"react";import A from"./index.module.scss.js";import{VideoClipToolContextProvider as M}from"./VideoClipToolContext.js";import{EClipStatus as d,ETimeSliceType as x,PER_SLICE_CHANGE as b,SLICE_MIN_TIME as C}from"./constant.js";import{VideoPlayer as N}from"../../videoPlayer/index.js";import U from"./components/videoTimeSlicesOverVideo/index.js";import J from"../../../assets/annotation/video/icon_videoCutting.svg.js";import{decimalReserved as F}from"../../videoPlayer/utils.js";var $=Object.defineProperty,z=Object.defineProperties,G=Object.getOwnPropertyDescriptors,L=Object.getOwnPropertySymbols,H=Object.prototype.hasOwnProperty,W=Object.prototype.propertyIsEnumerable,O=(c,s,t)=>s in c?$(c,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):c[s]=t,q=(c,s)=>{for(var t in s||(s={}))H.call(s,t)&&O(c,t,s[t]);if(L)for(var t of L(s))W.call(s,t)&&O(c,t,s[t]);return c},K=(c,s)=>z(c,G(s));class Q extends v.Component{constructor(s){super(s);this.fns=new Map,this.throttledUpdateTime=y.throttle(t=>{this.videoPlayer.currentTime=t},100,{trailing:!0}),this.stepInfo=()=>this.props.stepInfo,this.emitEvent=t=>{const e=this.fns.get(t);e&&e.forEach(i=>{i&&i()})},this.setValid=t=>{this.setState({valid:t}),t===!1&&(this.clearResult(),this.updateSidebar())},this.updateSidebar=()=>{this.emitEvent("changeClipSidebar"),this.emitEvent("updateTextAttribute"),this.emitEvent("changeAttributeSidebar")},this.exportData=()=>{var t,e;const i=(e=(t=this.videoRef)==null?void 0:t.duration)!=null?e:0;return[this.state.result.filter(r=>r.end!==null),{valid:this.state.valid,duration:i}]},this.updateSelectedSliceTimeStartByPer=t=>{var e,i;if(this.state.clipStatus===d.Clipping){f.info("\u622A\u53D6\u4E2D\u4E0D\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}if(this.selectedSliceIndex>-1){const r=(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0,{end:a,start:o,type:l}=this.state.result[this.selectedSliceIndex],n=I.withinRange(D(o,t),[0,j(l===x.Time?r:a,b)]);this.updateSelectedSliceTimeProperty(n,"start")}},this.updateSelectedSliceTimeEndByPer=t=>{var e,i;if(this.state.clipStatus===d.Clipping){f.info("\u622A\u53D6\u4E2D\u4E0D\u652F\u6301\u8C03\u6574\u7ED3\u675F\u65F6\u95F4");return}if(this.selectedSliceIndex>-1){const r=this.state.result[this.selectedSliceIndex],a=(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0;if(r.type===x.Time){f.info("\u65F6\u95F4\u70B9\u4EC5\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}const{end:o,start:l}=r,n=I.withinRange(D(o,t),[D(l,b),a]);this.updateSelectedSliceTimeProperty(n,"end")}},this.updateSelectedSliceTimeProperty=(t,e)=>{if(this.selectedSliceIndex>-1){const{result:i}=this.state;i[this.selectedSliceIndex][e]=t,this.setState({result:y.cloneDeep(i)}),this.updateSidebar()}},this.keyDownEvents=t=>{if(!V.hotkeyFilter(t))return;const e=t.target;switch(e&&(e==null?void 0:e.tag)==="INPUT"&&(e==null?void 0:e.type)==="radio"&&t.preventDefault(),t.key.toLocaleLowerCase()){case"x":this.toggleClipStatus();break;case"e":this.addTime();break;case"escape":this.cancelClipped();break;case"-":this.updateSelectedSliceTimeStartByPer(-b);break;case"=":this.updateSelectedSliceTimeStartByPer(b);break;case"[":this.updateSelectedSliceTimeEndByPer(-b);break;case"]":this.updateSelectedSliceTimeEndByPer(b);break}},this.videoLoaded=t=>{var e;const i=this.resultJSON,r=i&&!["","{}"].includes(i),a=t?parseFloat(t.toFixed(2)):0,o={loading:!1};((e=T(i))==null?void 0:e.duration)||Object.assign(o,{result:JSON.stringify(K(q({},T(i)),{duration:a}))}),r||Object.assign(o,{result:JSON.stringify({width:0,height:0,rotate:0,valid:!0,duration:a})}),this.setState({loading:!1})},this.setVideoError=(t,e,i)=>{if(t){const{clipStatus:r}=this.state;r===d.Clipping&&this.toggleClipStatus(i)}this.setState({videoError:t,loading:!1})},this.clearResult=()=>{this.setState({result:[],selectedID:"",textValue:""}),this.updateSidebar()},this.cancelClipped=()=>{const{result:t,selectedID:e,clipStatus:i}=this.state;if(i!==d.Clipping)return;const r=t.findIndex(a=>a.id===e);r>-1&&(t.splice(r,1),this.setState({result:t,selectedID:"",clipStatus:d.Stop}),this.updateSidebar())},this.toggleClipStatus=t=>{var e,i,r;if(this.disabled)return;const{clipStatus:a,selectedAttribute:o}=this.state,l=a!==d.Clipping;let n=l?d.Clipping:d.Stop,{result:u,selectedID:p,textValue:S}=this.state;const h=y.cloneDeep(u),m=t||((e=this.videoPlayer)==null?void 0:e.currentTime),_=(i=this.videoPlayer)==null?void 0:i.duration;if(_===void 0||m===void 0)return;const R=F(m,2);if(l){const g=w();p=g,h.push({start:R,end:null,attribute:o,textAttribute:this.defaultTextAttribute,duration:_,id:g,type:x.Period}),S=this.defaultTextAttribute}else{const g=h.findIndex(P=>P.id===p),E=h[g];E&&(m-E.start<C?(h.splice(g,1),f.info(`\u622A\u53D6\u7247\u6BB5\u4E0D\u80FD\u77ED\u4E8E${C}s`),n=d.Stop,p="",S=""):(h[g].end=F(m,2),(r=this.videoPlayer)==null||r.pause(),f.success(`\u5DF2\u622A\u53D6\u7247\u6BB5${u.length}`)))}this.setState({clipStatus:n,result:h,selectedID:p,textValue:S}),this.updateSidebar()},this.addTime=()=>{var t,e,i,r;if(this.disabled)return;const{result:a,selectedAttribute:o,selectedID:l}=this.state,n=w(),u=y.cloneDeep(a),p=((t=this.videoPlayer)==null?void 0:t.currentTime)||0;u.push({start:p,end:p,attribute:o,textAttribute:this.defaultTextAttribute,id:n,type:x.Time,duration:(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0});const S={result:u,selectedID:n,textValue:this.defaultTextAttribute},h=u.find(m=>m.id===l);this.isClipping&&h?(delete S.selectedID,delete S.textValue,f.success(`\u5DF2\u622A\u53D6\u65F6\u95F4\u70B9${u.length-1}`)):(r=this.videoPlayer)==null||r.pause(),this.setState(S),this.updateSidebar()},this.updateCurrentTime=t=>{this.setState({currentTime:t})},this.contextToCancel=t=>{this.state.clipStatus===d.Stop&&(t.preventDefault(),this.setState({selectedID:""}),this.updateSidebar())},this.onTrackResize=(t,e,i)=>{var r,a;const{result:o}=this.state,l=o.find(n=>n.id===t);if(l){const n=l.duration,u=e==="left",p=u?"start":"end",S=u?-n*i:n*i,h=u?[0,Math.max(((r=l.end)!=null?r:0)-C,0)]:[l.start+C,n],m=I.withinRange(S+((a=l==null?void 0:l[p])!=null?a:0),h);l[p]=m,this.throttledUpdateTime(m)}this.setState({result:[...o]}),this.updateSidebar()},this.renderMediaContent=()=>{var t;const{pageForward:e,pageJump:i,pageBackward:r}=this.props,{result:a,videoError:o,valid:l,currentTime:n}=this.state;return v.createElement("div",{className:A.clipContainer},v.createElement(N,{imgIndex:this.props.imgIndex,imgList:this.props.imgList,pageBackward:r,pageForward:e,pageJump:i,valid:l,setVideoRef:u=>{this.videoPlayer=u},showVideoTrack:!o,onTrackResize:this.onTrackResize,drawLayerSlot:this.props.drawLayerSlot,footer:this.props.footer,dataLoaded:this.videoLoaded,toggleClipStatus:this.toggleClipStatus,addTime:this.addTime,updateCurrentTime:this.updateCurrentTime}),v.createElement(U,{key:(t=this.videoPlayer)==null?void 0:t.currentTime,result:a,currentTime:n,attributeList:this.props.config.attributeList,extraStyle:{top:this.props.drawLayerSlot?40:0}}),this.isClipping&&v.createElement("i",{className:A.clipping,style:{backgroundImage:J}}))},this.onSelectedTimeSlice=t=>{var e;this.isClipping||(this.setState({selectedID:t.id,selectedAttribute:t.attribute,textValue:t.textAttribute,currentTime:t.start}),this.updateSidebar(),(e=this.videoPlayer)==null||e.pause(),this.videoPlayer.currentTime=t.start)},this.removeTimeSlice=t=>{const{result:e}=this.state,i=this.state.selectedID===t.id?"":this.state.selectedID,r=e.findIndex(a=>a.id===t.id);r>-1&&(e.splice(r,1),this.setState({result:[...e],selectedID:i}),this.updateSidebar())},this.setResult=(t=!0,e=this.props)=>{try{const{imgIndex:i,imgList:r}=e;if(!r[i])return;const o=T(r[i].result)[`step_${this.stepInfo().step}`],l=(o==null?void 0:o.result)||[],n=B(r[i].result||"[]");this.setState({result:l,loading:t,selectedID:"",textValue:"",selectedAttribute:"",clipStatus:d.Stop,valid:n},()=>{this.updateSidebar(),n||f.info("\u65E0\u6548\u89C6\u9891\uFF0C\u8BF7\u8DF3\u8FC7")})}catch(i){console.error("\u6570\u636E\u89E3\u6790\u5931\u8D25"),this.setState({result:[],loading:!1,selectedID:"",textValue:"",selectedAttribute:"",valid:!0},()=>{this.updateSidebar()})}},this.setDefaultAttribute=t=>{const{result:e,selectedID:i}=this.state,r=e.find(a=>a.id===i);r&&i&&(r.attribute=t),this.setState({selectedAttribute:t,result:[...e]}),this.updateSidebar()},this.textChange=t=>{const{result:e,selectedID:i}=this.state;if(this.setState({textValue:t}),i){const r=e.find(a=>a.id===i);r&&(r.textAttribute=t,this.setState({result:[...e]}),this.updateSidebar())}},this.state={result:[],selectedAttribute:"",textValue:"",clipStatus:d.Stop,selectedID:"",loading:!1,videoError:!1,remainingTime:0,currentTime:0,configLoading:!1,valid:!0}}get videoUrl(){var s;const{imgIndex:t,imgList:e}=this.props;return((s=e[t])==null?void 0:s.url)||""}get isClipping(){return this.state.clipStatus===d.Clipping}get resultJSON(){const{imgIndex:s,imgList:t}=this.props;return t.length===0||!t[s]?"[]":t[s].result}get disabled(){return!this.state.valid||this.state.videoError}get loading(){return this.state.loading||this.state.configLoading}get defaultTextAttribute(){return k.getTextAttribute(this.state.result,this.props.config.textCheckType)}get defaultAttribute(){return this.state.selectedAttribute}get selectedID(){return this.state.selectedID}get selectedSliceIndex(){return this.state.result.findIndex(s=>s.id===this.state.selectedID)}get exportContext(){return{selectedID:this.state.selectedID,result:this.state.result,clipStatus:this.state.clipStatus,videoPlayer:this.videoPlayer,attributeList:this.props.config.attributeList,onSelectedTimeSlice:this.onSelectedTimeSlice,removeTimeSlice:this.removeTimeSlice,updateSelectedSliceTimeProperty:this.updateSelectedSliceTimeProperty}}get valid(){return this.state.valid}get config(){var s;return T((s=this.props.stepInfo)==null?void 0:s.config)}get selectedText(){var s,t;return(t=(s=this.state.result)==null?void 0:s[this.selectedSliceIndex])==null?void 0:t.textAttribute}componentDidMount(){this.setState({loading:!1}),this.setResult(!1),this.props.onMounted(this),window.addEventListener("keydown",this.keyDownEvents)}componentWillUnmount(){this.props.onUnmounted(),window.removeEventListener("keydown",this.keyDownEvents)}shouldComponentUpdate(s,t){const e=s.imgIndex-this.props.imgIndex,i=s.step-this.props.step;return(e!==0||i!==0)&&(this.setResult(!0,s),i!==0&&this.setState({loading:!1})),!0}singleOn(s,t){this.fns.set(s,[t])}on(s,t){this.singleOn(s,t)}unbindAll(s){this.fns.delete(s)}render(){const{selectedID:s,result:t,clipStatus:e,selectedAttribute:i}=this.state;return v.createElement(M,{value:{videoPlayer:this.videoPlayer,result:t,selectedID:s,attributeList:this.props.config.attributeList,clipStatus:e,selectedAttribute:i,contextToCancel:this.contextToCancel}},this.renderMediaContent())}}export{Q as default};
1
+ import{MathUtils as C,CommonToolUtils as F,uuid as A,AttributeUtils as k}from"@labelbee/lb-annotation";import{jsonParser as P}from"../../../utils/index.js";import{precisionAdd as I,precisionMinus as V,isImageValue as R}from"../../../utils/audio.js";import{message as m}from"antd";import b from"lodash";import g from"react";import _ from"./index.module.scss.js";import{VideoClipToolContextProvider as B}from"./VideoClipToolContext.js";import{EClipStatus as o,ETimeSliceType as T,PER_SLICE_CHANGE as v,SLICE_MIN_TIME as x}from"./constant.js";import{VideoPlayer as j}from"../../videoPlayer/index.js";import M from"./components/videoTimeSlicesOverVideo/index.js";import U from"../../../assets/annotation/video/icon_videoCutting.svg.js";import{decimalReserved as L}from"../../videoPlayer/utils.js";class N extends g.Component{constructor(r){super(r);this.fns=new Map,this.throttledUpdateTime=b.throttle(t=>{this.videoPlayer.currentTime=t},100,{trailing:!0}),this.stepInfo=()=>this.props.stepInfo,this.emitEvent=t=>{const e=this.fns.get(t);e&&e.forEach(i=>{i&&i()})},this.setValid=t=>{this.setState({valid:t}),t===!1&&(this.clearResult(),this.updateSidebar())},this.updateSidebar=()=>{this.emitEvent("changeClipSidebar"),this.emitEvent("updateTextAttribute"),this.emitEvent("changeAttributeSidebar")},this.exportData=()=>{var t,e;const i=(e=(t=this.videoRef)==null?void 0:t.duration)!=null?e:0;return[this.state.result.filter(s=>s.end!==null),{valid:this.state.valid,duration:i}]},this.updateSelectedSliceTimeStartByPer=t=>{var e,i;if(this.state.clipStatus===o.Clipping){m.info("\u622A\u53D6\u4E2D\u4E0D\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}if(this.selectedSliceIndex>-1){const s=(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0,{end:l,start:u,type:a}=this.state.result[this.selectedSliceIndex],n=C.withinRange(I(u,t),[0,V(a===T.Time?s:l,v)]);this.updateSelectedSliceTimeProperty(n,"start")}},this.updateSelectedSliceTimeEndByPer=t=>{var e,i;if(this.state.clipStatus===o.Clipping){m.info("\u622A\u53D6\u4E2D\u4E0D\u652F\u6301\u8C03\u6574\u7ED3\u675F\u65F6\u95F4");return}if(this.selectedSliceIndex>-1){const s=this.state.result[this.selectedSliceIndex],l=(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0;if(s.type===T.Time){m.info("\u65F6\u95F4\u70B9\u4EC5\u652F\u6301\u8C03\u6574\u5F00\u59CB\u65F6\u95F4");return}const{end:u,start:a}=s,n=C.withinRange(I(u,t),[I(a,v),l]);this.updateSelectedSliceTimeProperty(n,"end")}},this.updateSelectedSliceTimeProperty=(t,e)=>{if(this.selectedSliceIndex>-1){const{result:i}=this.state;i[this.selectedSliceIndex][e]=t,this.setState({result:b.cloneDeep(i)}),this.updateSidebar()}},this.keyDownEvents=t=>{if(!F.hotkeyFilter(t))return;const e=t.target;switch(e&&(e==null?void 0:e.tag)==="INPUT"&&(e==null?void 0:e.type)==="radio"&&t.preventDefault(),t.key.toLocaleLowerCase()){case"x":this.toggleClipStatus();break;case"e":this.addTime();break;case"escape":this.cancelClipped();break;case"-":this.updateSelectedSliceTimeStartByPer(-v);break;case"=":this.updateSelectedSliceTimeStartByPer(v);break;case"[":this.updateSelectedSliceTimeEndByPer(-v);break;case"]":this.updateSelectedSliceTimeEndByPer(v);break}},this.setVideoError=(t,e,i)=>{if(t){const{clipStatus:s}=this.state;s===o.Clipping&&this.toggleClipStatus(i)}this.setState({videoError:t,loading:!1})},this.clearResult=()=>{this.setState({result:[],selectedID:"",textValue:""}),this.updateSidebar()},this.cancelClipped=()=>{const{result:t,selectedID:e,clipStatus:i}=this.state;if(i!==o.Clipping)return;const s=t.findIndex(l=>l.id===e);s>-1&&(t.splice(s,1),this.setState({result:t,selectedID:"",clipStatus:o.Stop}),this.updateSidebar())},this.toggleClipStatus=t=>{var e,i,s;if(this.disabled)return;const{clipStatus:l,selectedAttribute:u}=this.state,a=l!==o.Clipping;let n=a?o.Clipping:o.Stop,{result:d,selectedID:c,textValue:p}=this.state;const h=b.cloneDeep(d),S=t||((e=this.videoPlayer)==null?void 0:e.currentTime),y=(i=this.videoPlayer)==null?void 0:i.duration;if(y===void 0||S===void 0)return;const w=L(S,2);if(a){const f=A();c=f,h.push({start:w,end:null,attribute:u,textAttribute:this.defaultTextAttribute,duration:y,id:f,type:T.Period}),p=this.defaultTextAttribute}else{const f=h.findIndex(E=>E.id===c),D=h[f];D&&(S-D.start<x?(h.splice(f,1),m.info(`\u622A\u53D6\u7247\u6BB5\u4E0D\u80FD\u77ED\u4E8E${x}s`),n=o.Stop,c="",p=""):(h[f].end=L(S,2),(s=this.videoPlayer)==null||s.pause(),m.success(`\u5DF2\u622A\u53D6\u7247\u6BB5${d.length}`)))}this.setState({clipStatus:n,result:h,selectedID:c,textValue:p}),this.updateSidebar()},this.addTime=()=>{var t,e,i,s;if(this.disabled)return;const{result:l,selectedAttribute:u,selectedID:a}=this.state,n=A(),d=b.cloneDeep(l),c=((t=this.videoPlayer)==null?void 0:t.currentTime)||0;d.push({start:c,end:c,attribute:u,textAttribute:this.defaultTextAttribute,id:n,type:T.Time,duration:(i=(e=this.videoPlayer)==null?void 0:e.duration)!=null?i:0});const p={result:d,selectedID:n,textValue:this.defaultTextAttribute},h=d.find(S=>S.id===a);this.isClipping&&h?(delete p.selectedID,delete p.textValue,m.success(`\u5DF2\u622A\u53D6\u65F6\u95F4\u70B9${d.length-1}`)):(s=this.videoPlayer)==null||s.pause(),this.setState(p),this.updateSidebar()},this.updateCurrentTime=t=>{this.setState({currentTime:t})},this.contextToCancel=t=>{this.state.clipStatus===o.Stop&&(t.preventDefault(),this.setState({selectedID:""}),this.updateSidebar())},this.onTrackResize=(t,e,i)=>{var s,l;const{result:u}=this.state,a=u.find(n=>n.id===t);if(a){const n=a.duration,d=e==="left",c=d?"start":"end",p=d?-n*i:n*i,h=d?[0,Math.max(((s=a.end)!=null?s:0)-x,0)]:[a.start+x,n],S=C.withinRange(p+((l=a==null?void 0:a[c])!=null?l:0),h);a[c]=S,this.throttledUpdateTime(S)}this.setState({result:[...u]}),this.updateSidebar()},this.renderMediaContent=()=>{var t;const{pageForward:e,pageJump:i,pageBackward:s}=this.props,{result:l,videoError:u,valid:a,currentTime:n}=this.state;return g.createElement("div",{className:_.clipContainer},g.createElement(j,{imgIndex:this.props.imgIndex,imgList:this.props.imgList,pageBackward:s,pageForward:e,pageJump:i,valid:a,setVideoRef:d=>{this.videoPlayer=d},showVideoTrack:!u,onTrackResize:this.onTrackResize,drawLayerSlot:this.props.drawLayerSlot,footer:this.props.footer,dataLoaded:this.props.onVideoLoaded,toggleClipStatus:this.toggleClipStatus,addTime:this.addTime,updateCurrentTime:this.updateCurrentTime}),g.createElement(M,{key:(t=this.videoPlayer)==null?void 0:t.currentTime,result:l,currentTime:n,attributeList:this.props.config.attributeList,extraStyle:{top:this.props.drawLayerSlot?40:0}}),this.isClipping&&g.createElement("i",{className:_.clipping,style:{backgroundImage:U}}))},this.onSelectedTimeSlice=t=>{var e;this.isClipping||(this.setState({selectedID:t.id,selectedAttribute:t.attribute,textValue:t.textAttribute,currentTime:t.start}),this.updateSidebar(),(e=this.videoPlayer)==null||e.pause(),this.videoPlayer.currentTime=t.start)},this.removeTimeSlice=t=>{const{result:e}=this.state,i=this.state.selectedID===t.id?"":this.state.selectedID,s=e.findIndex(l=>l.id===t.id);s>-1&&(e.splice(s,1),this.setState({result:[...e],selectedID:i}),this.updateSidebar())},this.setResult=(t=!0,e=this.props)=>{try{const{imgIndex:i,imgList:s}=e;if(!s[i])return;const u=P(s[i].result)[`step_${this.stepInfo().step}`],a=(u==null?void 0:u.result)||[],n=R(s[i].result||"[]");this.setState({result:a,loading:t,selectedID:"",textValue:"",selectedAttribute:"",clipStatus:o.Stop,valid:n},()=>{this.updateSidebar(),n||m.info("\u65E0\u6548\u89C6\u9891\uFF0C\u8BF7\u8DF3\u8FC7")})}catch(i){console.error("\u6570\u636E\u89E3\u6790\u5931\u8D25"),this.setState({result:[],loading:!1,selectedID:"",textValue:"",selectedAttribute:"",valid:!0},()=>{this.updateSidebar()})}},this.setDefaultAttribute=t=>{const{result:e,selectedID:i}=this.state,s=e.find(l=>l.id===i);s&&i&&(s.attribute=t),this.setState({selectedAttribute:t,result:[...e]}),this.updateSidebar()},this.textChange=t=>{const{result:e,selectedID:i}=this.state;if(this.setState({textValue:t}),i){const s=e.find(l=>l.id===i);s&&(s.textAttribute=t,this.setState({result:[...e]}),this.updateSidebar())}},this.state={result:[],selectedAttribute:"",textValue:"",clipStatus:o.Stop,selectedID:"",loading:!1,videoError:!1,remainingTime:0,currentTime:0,configLoading:!1,valid:!0}}get videoUrl(){var r;const{imgIndex:t,imgList:e}=this.props;return((r=e[t])==null?void 0:r.url)||""}get isClipping(){return this.state.clipStatus===o.Clipping}get resultJSON(){const{imgIndex:r,imgList:t}=this.props;return t.length===0||!t[r]?"[]":t[r].result}get disabled(){return!this.state.valid||this.state.videoError}get loading(){return this.state.loading||this.state.configLoading}get defaultTextAttribute(){return k.getTextAttribute(this.state.result,this.props.config.textCheckType)}get defaultAttribute(){return this.state.selectedAttribute}get selectedID(){return this.state.selectedID}get selectedSliceIndex(){return this.state.result.findIndex(r=>r.id===this.state.selectedID)}get exportContext(){return{selectedID:this.state.selectedID,result:this.state.result,clipStatus:this.state.clipStatus,videoPlayer:this.videoPlayer,attributeList:this.props.config.attributeList,onSelectedTimeSlice:this.onSelectedTimeSlice,removeTimeSlice:this.removeTimeSlice,updateSelectedSliceTimeProperty:this.updateSelectedSliceTimeProperty}}get valid(){return this.state.valid}get config(){var r;return P((r=this.props.stepInfo)==null?void 0:r.config)}get selectedText(){var r,t;return(t=(r=this.state.result)==null?void 0:r[this.selectedSliceIndex])==null?void 0:t.textAttribute}componentDidMount(){this.setState({loading:!1}),this.setResult(!1),this.props.onMounted(this),window.addEventListener("keydown",this.keyDownEvents)}componentWillUnmount(){this.props.onUnmounted(),window.removeEventListener("keydown",this.keyDownEvents)}shouldComponentUpdate(r,t){const e=r.imgIndex-this.props.imgIndex,i=r.step-this.props.step;return(e!==0||i!==0)&&(this.setResult(!0,r),i!==0&&this.setState({loading:!1})),!0}singleOn(r,t){this.fns.set(r,[t])}on(r,t){this.singleOn(r,t)}unbindAll(r){this.fns.delete(r)}render(){const{selectedID:r,result:t,clipStatus:e,selectedAttribute:i}=this.state;return g.createElement(B,{value:{videoPlayer:this.videoPlayer,result:t,selectedID:r,attributeList:this.props.config.attributeList,clipStatus:e,selectedAttribute:i,contextToCancel:this.contextToCancel}},this.renderMediaContent())}}export{N as default};
@@ -1 +1 @@
1
- import h from"react";import{TagUtils as p,CommonToolUtils as f,uuid as y}from"@labelbee/lb-annotation";import{jsonParser as c}from"../../../utils/index.js";import{VideoPlayer as L}from"../../videoPlayer/index.js";import{VideoTagLayer as R}from"../../videoPlayer/VideoTagLayer.js";import g from"lodash";import{getKeyCodeNumber as b}from"../../videoPlayer/utils.js";class S extends h.Component{constructor(i){super(i);this.fns={},this.labelSelectedList=[],this.clearResult=(t=!0,e)=>{const l=e?this.state.tagResult.map(s=>((s==null?void 0:s.result[e])&&delete s.result[e],s)):[];this.setState({tagResult:l},()=>this.emitEvent("render"))},this.exportData=()=>{var t,e,l,s,n,o,r;const a=(e=(t=this.videoPlayer)==null?void 0:t.duration)!=null?e:0,d=(l=this.videoPlayer)==null?void 0:l.getVideoPlaybackQuality(),u=d==null?void 0:d.totalVideoFrames,v=(n=(s=this.videoPlayer)==null?void 0:s.videoWidth)!=null?n:0,m=(r=(o=this.videoPlayer)==null?void 0:o.videoHeight)!=null?r:0;return[this.state.tagResult,{valid:this.state.valid,duration:a,frames:u,videoWidth:v,videoHeight:m}]},this.emitEvent=t=>{this.fns[t]&&this.fns[t]()},this.combineResult=(t,e={})=>{var l,s;const{isMulti:n}=t,{key:o,value:r}=t.value;if(n){let a=(s=(l=e[o])==null?void 0:l.split(";"))!=null?s:[];a.includes(r)?a=a.filter(u=>u!==r):a.push(r);const d=new Set(a);return e[o]=Array.from(d).join(";"),g.pickBy(e,u=>u)}return e[o]=e[o]===r?void 0:r,g.pickBy(e,a=>a)},this.setResult=t=>{this.setState({tagResult:t}),this.fns.render&&this.fns.render()},this.setLabel=(t,e)=>{this.setLabelBySelectedList(t,e)},this.keydown=t=>{var e;const l=b(t.keyCode);if(l){const s=l-1;if(((e=this.config.inputList)==null?void 0:e.length)===1){this.labelSelectedList=[0,s],this.setLabel(0,s),setTimeout(()=>{this.labelSelectedList=[],this.emitEvent("render")},500);return}this.labelSelectedList.length===1?(this.labelSelectedList=[this.labelSelectedList[0],s],this.setLabel(this.labelSelectedList[0],s),setTimeout(()=>{this.labelSelectedList=[],this.emitEvent("render")},500)):(this.labelSelectedList=[s],this.emitEvent("expend"))}},this.setValid=t=>{this.setState({valid:t}),t===!1&&this.setState({tagResult:[]}),this.emitEvent("render")},this.setResultFromImgList=t=>{const{imgList:e,imgIndex:l,stepInfo:s}=t;if(!e[l])return;const n=c(e[l].result),o=n[`step_${s.step}`],r=this.getInitResultList();this.setState({tagResult:o?o==null?void 0:o.result:r,valid:(n==null?void 0:n.valid)===void 0?!0:n.valid},()=>this.emitEvent("render"))},this.getInitResultList=()=>{var t;return p.getDefaultTagResult((t=this.config.inputList)!=null?t:[],[])},this.state={tagResult:[],labelSelectedList:[],valid:!0}}get config(){var i;return c((i=this.props.stepInfo)==null?void 0:i.config)}get history(){return{initRecord:()=>{},pushHistory:()=>{}}}get currentTagResult(){var i;return(i=this.state.tagResult[0])!=null?i:{}}get valid(){return this.state.valid}singleOn(i,t){this.fns[i]=t}on(i,t){this.singleOn(i,t)}unbindAll(i){delete this.fns[i]}getTagResultByCode(i,t){var e,l,s;try{const n=(l=(e=this.config)==null?void 0:e.inputList)!=null?l:[],o=(n==null?void 0:n.length)>1,r=t!==void 0?i:0,a=t!==void 0?t:i,d=o?n[r]:n[0],u=((s=d.subSelected)!=null?s:[])[a];if(d&&u)return{value:{key:d.value,value:u.value},isMulti:d.isMulti}}catch(n){return}}setLabelBySelectedList(i,t){var e,l,s,n;const o=this.getTagResultByCode(i,t);if(o){const r=this.combineResult(o,(l=(e=this.state.tagResult[0])==null?void 0:e.result)!=null?l:{}),a=[{sourceID:f.getSourceID(),id:(n=(s=this.currentTagResult)==null?void 0:s.id)!=null?n:y(8,62),result:r}];this.setState({tagResult:a},()=>this.emitEvent("render"))}}componentDidMount(){document.addEventListener("keydown",this.keydown),this.props.onMounted(this),this.setResultFromImgList(this.props)}componentWillUnmount(){document.addEventListener("keydown",this.keydown),this.props.onUnmounted()}shouldComponentUpdate(i){return i.imgIndex!==this.props.imgIndex&&this.setResultFromImgList(i),!0}render(){var i;const{imgIndex:t,imgList:e,pageForward:l,pageJump:s,pageBackward:n}=this.props,{tagResult:o,valid:r}=this.state;return h.createElement("div",{style:{height:"100%",width:"100%",position:"relative",display:"flex",flexDirection:"column"}},h.createElement(L,{imgIndex:t,imgList:e,pageBackward:n,pageForward:l,pageJump:s,valid:r,setVideoRef:a=>{this.videoPlayer=a},drawLayerSlot:this.props.drawLayerSlot,footer:this.props.footer}),h.createElement(R,{result:o,inputList:(i=this.config)==null?void 0:i.inputList,hasPromptLayer:!!this.props.drawLayerSlot}))}}export{S as TagToolInstanceAdaptor};
1
+ import h from"react";import{TagUtils as p,CommonToolUtils as m,uuid as v}from"@labelbee/lb-annotation";import{jsonParser as c}from"../../../utils/index.js";import{VideoPlayer as f}from"../../videoPlayer/index.js";import{VideoTagLayer as y}from"../../videoPlayer/VideoTagLayer.js";import g from"lodash";import{getKeyCodeNumber as L}from"../../videoPlayer/utils.js";class R extends h.Component{constructor(s){super(s);this.fns={},this.labelSelectedList=[],this.clearResult=(t=!0,e)=>{const l=e?this.state.tagResult.map(i=>((i==null?void 0:i.result[e])&&delete i.result[e],i)):[];this.setState({tagResult:l},()=>this.emitEvent("render"))},this.exportData=()=>{var t,e;const l=(e=(t=this.videoPlayer)==null?void 0:t.duration)!=null?e:0;return[this.state.tagResult,{valid:this.state.valid,duration:l}]},this.emitEvent=t=>{this.fns[t]&&this.fns[t]()},this.combineResult=(t,e={})=>{var l,i;const{isMulti:n}=t,{key:o,value:r}=t.value;if(n){let a=(i=(l=e[o])==null?void 0:l.split(";"))!=null?i:[];a.includes(r)?a=a.filter(u=>u!==r):a.push(r);const d=new Set(a);return e[o]=Array.from(d).join(";"),g.pickBy(e,u=>u)}return e[o]=e[o]===r?void 0:r,g.pickBy(e,a=>a)},this.setResult=t=>{this.setState({tagResult:t}),this.fns.render&&this.fns.render()},this.setLabel=(t,e)=>{this.setLabelBySelectedList(t,e)},this.keydown=t=>{var e;const l=L(t.keyCode);if(l){const i=l-1;if(((e=this.config.inputList)==null?void 0:e.length)===1){this.labelSelectedList=[0,i],this.setLabel(0,i),setTimeout(()=>{this.labelSelectedList=[],this.emitEvent("render")},500);return}this.labelSelectedList.length===1?(this.labelSelectedList=[this.labelSelectedList[0],i],this.setLabel(this.labelSelectedList[0],i),setTimeout(()=>{this.labelSelectedList=[],this.emitEvent("render")},500)):(this.labelSelectedList=[i],this.emitEvent("expend"))}},this.setValid=t=>{this.setState({valid:t}),t===!1&&this.setState({tagResult:[]}),this.emitEvent("render")},this.setResultFromImgList=t=>{const{imgList:e,imgIndex:l,stepInfo:i}=t;if(!e[l])return;const n=c(e[l].result),o=n[`step_${i.step}`],r=this.getInitResultList();this.setState({tagResult:o?o==null?void 0:o.result:r,valid:(n==null?void 0:n.valid)===void 0?!0:n.valid},()=>this.emitEvent("render"))},this.getInitResultList=()=>{var t;return p.getDefaultTagResult((t=this.config.inputList)!=null?t:[],[])},this.state={tagResult:[],labelSelectedList:[],valid:!0}}get config(){var s;return c((s=this.props.stepInfo)==null?void 0:s.config)}get history(){return{initRecord:()=>{},pushHistory:()=>{}}}get currentTagResult(){var s;return(s=this.state.tagResult[0])!=null?s:{}}get valid(){return this.state.valid}singleOn(s,t){this.fns[s]=t}on(s,t){this.singleOn(s,t)}unbindAll(s){delete this.fns[s]}getTagResultByCode(s,t){var e,l,i;try{const n=(l=(e=this.config)==null?void 0:e.inputList)!=null?l:[],o=(n==null?void 0:n.length)>1,r=t!==void 0?s:0,a=t!==void 0?t:s,d=o?n[r]:n[0],u=((i=d.subSelected)!=null?i:[])[a];if(d&&u)return{value:{key:d.value,value:u.value},isMulti:d.isMulti}}catch(n){return}}setLabelBySelectedList(s,t){var e,l,i,n;const o=this.getTagResultByCode(s,t);if(o){const r=this.combineResult(o,(l=(e=this.state.tagResult[0])==null?void 0:e.result)!=null?l:{}),a=[{sourceID:m.getSourceID(),id:(n=(i=this.currentTagResult)==null?void 0:i.id)!=null?n:v(8,62),result:r}];this.setState({tagResult:a},()=>this.emitEvent("render"))}}componentDidMount(){document.addEventListener("keydown",this.keydown),this.props.onMounted(this),this.setResultFromImgList(this.props)}componentWillUnmount(){document.addEventListener("keydown",this.keydown),this.props.onUnmounted()}shouldComponentUpdate(s){return s.imgIndex!==this.props.imgIndex&&this.setResultFromImgList(s),!0}render(){var s;const{imgIndex:t,imgList:e,pageForward:l,pageJump:i,pageBackward:n}=this.props,{tagResult:o,valid:r}=this.state;return h.createElement("div",{style:{height:"100%",width:"100%",position:"relative",display:"flex",flexDirection:"column"}},h.createElement(f,{imgIndex:t,imgList:e,pageBackward:n,pageForward:l,pageJump:i,valid:r,setVideoRef:a=>{this.videoPlayer=a},dataLoaded:this.props.onVideoLoaded,drawLayerSlot:this.props.drawLayerSlot,footer:this.props.footer}),h.createElement(y,{result:o,inputList:(s=this.config)==null?void 0:s.inputList,hasPromptLayer:!!this.props.drawLayerSlot}))}}export{R as TagToolInstanceAdaptor};
@@ -1 +1 @@
1
- import u from"react";import{jsonParser as v}from"../../../utils/index.js";import{VideoPlayer as g}from"../../videoPlayer/index.js";import c from"lodash";import{VideoTextLayer as m}from"../../videoPlayer/VideoTextLayer.js";import{toolStyleConverter as y}from"@labelbee/lb-utils";class x extends u.Component{constructor(i){super(i);this.fns={},this.clearResult=(t=!0)=>{this.setState({result:{}},()=>this.updateSidebar())},this.exportData=()=>{var t,e,s,o,r,l,n;const a=(e=(t=this.videoPlayer)==null?void 0:t.duration)!=null?e:0,d=(s=this.videoPlayer)==null?void 0:s.getVideoPlaybackQuality(),h=d==null?void 0:d.totalVideoFrames,p=(r=(o=this.videoPlayer)==null?void 0:o.videoWidth)!=null?r:0,f=(n=(l=this.videoPlayer)==null?void 0:l.videoHeight)!=null?n:0;return[[this.state.result],{valid:this.state.valid,duration:a,frames:h,videoWidth:p,videoHeight:f}]},this.toggleShowText=t=>{this.setState({showText:t})},this.singleOn=(t,e)=>{this.fns[t]=e},this.on=(t,e)=>{this.singleOn(t,e)},this.unbindAll=t=>{delete this.fns[t]},this.emitEvent=t=>{this.fns[t]&&this.fns[t]()},this.updateSidebar=()=>{this.emitEvent("valueUpdated")},this.updateTextValue=(t,e,s,o)=>{var r;const l=c.cloneDeep(o!=null?o:{});l.value=Object.assign((r=l.value)!=null?r:{},{[t]:e}),this.setState({result:l},()=>s&&this.updateSidebar())},this.setResult=t=>{this.setState({result:t}),this.fns.render&&this.fns.render()},this.setValid=t=>{this.setState({valid:t}),t===!1&&this.setState({result:{}}),this.emitEvent("render")},this.setResultFromImgList=t=>{var e,s;const{imgList:o,imgIndex:r,stepInfo:l}=t;if(!o[r])return;const n=v(o[r].result),a=n[`step_${l.step}`],d={value:this.getInitTextValue()};this.setState({result:a?(s=(e=a==null?void 0:a.result)==null?void 0:e[0])!=null?s:{}:d,valid:(n==null?void 0:n.valid)===void 0?!0:n.valid},()=>this.updateSidebar())},this.getInitTextValue=()=>{let t={};return this.config.configList.forEach(e=>{var s;t[e.key]=(s=e.default)!=null?s:""}),t},this.state={result:{},valid:!0,showText:!0}}get config(){var i;return v((i=this.props.stepInfo)==null?void 0:i.config)}get history(){return{initRecord:()=>{},pushHistory:()=>{}}}get valid(){return this.state.valid}get needConfirm(){var i;const{result:t}=this.state;return(i=this.config.configList)==null?void 0:i.some(e=>{var s;return e.required&&!((s=t==null?void 0:t.value)==null?void 0:s[e.key])})}get textList(){return[this.state.result]}getColor(i=this.config,t=""){return y.getColorByConfig({attribute:t,config:i})}componentDidMount(){this.props.onMounted(this),this.setResultFromImgList(this.props)}componentWillUnmount(){this.props.onUnmounted()}shouldComponentUpdate(i){return i.imgIndex!==this.props.imgIndex&&this.setResultFromImgList(i),!0}render(){var i,t;const{imgIndex:e,imgList:s,pageForward:o,pageJump:r,pageBackward:l}=this.props,{result:n,valid:a,showText:d}=this.state;return u.createElement("div",{style:{height:"100%",width:"100%",position:"relative",display:"flex",flexDirection:"column"}},d&&n.value&&u.createElement(m,{value:n.value,toolColor:(t=(i=this.getColor(this.config))==null?void 0:i.valid)==null?void 0:t.fill,configList:this.config.configList,hasPromptLayer:!!this.props.drawLayerSlot}),u.createElement(g,{imgIndex:e,imgList:s,pageBackward:l,pageForward:o,pageJump:r,valid:a,setVideoRef:h=>{this.videoPlayer=h},drawLayerSlot:this.props.drawLayerSlot,footer:this.props.footer}))}}export{x as VideoTextTool};
1
+ import u from"react";import{jsonParser as h}from"../../../utils/index.js";import{VideoPlayer as v}from"../../videoPlayer/index.js";import f from"lodash";import{VideoTextLayer as g}from"../../videoPlayer/VideoTextLayer.js";import{toolStyleConverter as m}from"@labelbee/lb-utils";class c extends u.Component{constructor(s){super(s);this.fns={},this.clearResult=(t=!0)=>{this.setState({result:{}},()=>this.updateSidebar())},this.exportData=()=>{var t,e;const i=(e=(t=this.videoPlayer)==null?void 0:t.duration)!=null?e:0;return[[this.state.result],{valid:this.state.valid,duration:i}]},this.toggleShowText=t=>{this.setState({showText:t})},this.singleOn=(t,e)=>{this.fns[t]=e},this.on=(t,e)=>{this.singleOn(t,e)},this.unbindAll=t=>{delete this.fns[t]},this.emitEvent=t=>{this.fns[t]&&this.fns[t]()},this.updateSidebar=()=>{this.emitEvent("valueUpdated")},this.updateTextValue=(t,e,i,o)=>{var r;const l=f.cloneDeep(o!=null?o:{});l.value=Object.assign((r=l.value)!=null?r:{},{[t]:e}),this.setState({result:l},()=>i&&this.updateSidebar())},this.setResult=t=>{this.setState({result:t}),this.fns.render&&this.fns.render()},this.setValid=t=>{this.setState({valid:t}),t===!1&&this.setState({result:{}}),this.emitEvent("render")},this.setResultFromImgList=t=>{var e,i;const{imgList:o,imgIndex:r,stepInfo:l}=t;if(!o[r])return;const n=h(o[r].result),a=n[`step_${l.step}`],d={value:this.getInitTextValue()};this.setState({result:a?(i=(e=a==null?void 0:a.result)==null?void 0:e[0])!=null?i:{}:d,valid:(n==null?void 0:n.valid)===void 0?!0:n.valid},()=>this.updateSidebar())},this.getInitTextValue=()=>{let t={};return this.config.configList.forEach(e=>{var i;t[e.key]=(i=e.default)!=null?i:""}),t},this.state={result:{},valid:!0,showText:!0}}get config(){var s;return h((s=this.props.stepInfo)==null?void 0:s.config)}get history(){return{initRecord:()=>{},pushHistory:()=>{}}}get valid(){return this.state.valid}get needConfirm(){var s;const{result:t}=this.state;return(s=this.config.configList)==null?void 0:s.some(e=>{var i;return e.required&&!((i=t==null?void 0:t.value)==null?void 0:i[e.key])})}get textList(){return[this.state.result]}getColor(s=this.config,t=""){return m.getColorByConfig({attribute:t,config:s})}componentDidMount(){this.props.onMounted(this),this.setResultFromImgList(this.props)}componentWillUnmount(){this.props.onUnmounted()}shouldComponentUpdate(s){return s.imgIndex!==this.props.imgIndex&&this.setResultFromImgList(s),!0}render(){var s,t;const{imgIndex:e,imgList:i,pageForward:o,pageJump:r,pageBackward:l}=this.props,{result:n,valid:a,showText:d}=this.state;return u.createElement("div",{style:{height:"100%",width:"100%",position:"relative",display:"flex",flexDirection:"column"}},d&&n.value&&u.createElement(g,{value:n.value,toolColor:(t=(s=this.getColor(this.config))==null?void 0:s.valid)==null?void 0:t.fill,configList:this.config.configList,hasPromptLayer:!!this.props.drawLayerSlot}),u.createElement(v,{imgIndex:e,imgList:i,pageBackward:l,pageForward:o,pageJump:r,valid:a,setVideoRef:p=>{this.videoPlayer=p},drawLayerSlot:this.props.drawLayerSlot,footer:this.props.footer,dataLoaded:this.props.onVideoLoaded}))}}export{c as VideoTextTool};
@@ -1 +1 @@
1
- import o from"react";import A from"./components/controller/index.js";import j from"../videoAnnotate/videoClipTool/components/videoTrack/index.js";import{getClassName as l}from"../../utils/dom.js";import{cKeyCode as M}from"@labelbee/lb-annotation";import{decimalReserved as d}from"./utils.js";import z from"../fileException/index.js";const s=M.default,c=o.createContext({isPlay:!1,playPause:()=>{},updateNextPlaybackRate:()=>{},playbackRate:1,currentTime:0,duration:0,buffered:0,setCurrentTime:()=>{},imgList:[],imgIndex:-1,pageBackward:()=>{},pageJump:f=>{},pageForward:()=>{},addTime:()=>{},toggleClipStatus:()=>{}}),U=50,p=.1,n=[.5,1,1.5,2,4,6,8,16];class v extends o.Component{constructor(a){super(a);this.changePlaybackPate=e=>{this.videoElm&&(this.videoElm.playbackRate=e,this.setState({playbackRate:e}))},this.playPause=()=>{var e,t,i;((e=this.videoElm)==null?void 0:e.paused)?(t=this.videoElm)==null||t.play():(i=this.videoElm)==null||i.pause()},this.updateNextPlaybackRate=(e=!0)=>{const t=n.findIndex(r=>r===this.state.playbackRate);let i=e?Math.min(t+1,n.length-1):Math.max(t-1,0);this.changePlaybackPate(n[i])},this.fastForward=()=>{this.videoElm&&this.setCurrentTime(this.videoElm.currentTime+p)},this.rewind=()=>{this.videoElm&&this.setCurrentTime(this.videoElm.currentTime-p)},this.keydown=e=>{e.keyCode===s.Space&&(e.preventDefault(),this.playPause()),e.keyCode===s.Up&&(e.preventDefault(),this.updateNextPlaybackRate()),e.keyCode===s.Down&&(e.preventDefault(),this.updateNextPlaybackRate(!1)),e.keyCode===s.Left&&(e.preventDefault(),this.rewind()),e.keyCode===s.Right&&(e.preventDefault(),this.fastForward())},this.onPlay=()=>{this.setState({isPlay:!0},this.onVideoStart)},this.onPause=()=>{this.onVideoStopped()},this.onTimeUpdate=()=>{var e;this.videoElm&&this.setState({currentTime:d((e=this.videoElm)==null?void 0:e.currentTime,1)})},this.onVideoStopped=()=>{this.setState({isPlay:!1}),this.timeInterval&&(clearInterval(this.timeInterval),this.timeInterval=void 0),this.videoElm&&this.setCurrentTime(this.videoElm.currentTime)},this.onVideoStart=()=>{this.timeInterval=window.setInterval(()=>{var e,t,i;if(this.videoElm)try{if(((e=this.videoElm)==null?void 0:e.buffered.length)>0){const r=(t=this.videoElm)==null?void 0:t.buffered.end(0);this.setState({currentTime:d((i=this.videoElm)==null?void 0:i.currentTime,1),buffered:r})}}catch(r){console.error(r)}},U)},this.resetVideoData=()=>{this.setState({currentTime:0,buffered:0,error:!1,isPlay:!1}),this.videoElm&&(this.videoElm.playbackRate=this.state.playbackRate),this.onVideoStopped()},this.setDuration=()=>{var e,t,i;if(this.videoElm){const r=d((e=this.videoElm)==null?void 0:e.duration,1);(i=(t=this.props).dataLoaded)==null||i.call(t,r),this.setState({duration:r})}},this.setCurrentTime=e=>{var t,i;this.videoElm&&(this.videoElm.currentTime=e,this.setState({currentTime:e}),(i=(t=this.props).updateCurrentTime)==null||i.call(t,e))},this.reload=()=>{var e;(e=this.videoElm)==null||e.load()},this.onError=()=>{this.resetVideoData(),this.setState({error:!0})},this.state={playbackRate:1,currentTime:0,isPlay:!1,duration:0,buffered:0,error:!1},this.videoRef=o.createRef()}get videoElm(){var a;return(a=this.videoRef)==null?void 0:a.current}get videoSrc(){var a,e;const{imgIndex:t,imgList:i}=this.props;return t>-1&&(e=(a=i[t])==null?void 0:a.url)!=null?e:""}componentDidMount(){var a,e;window.addEventListener("keydown",this.keydown),((a=this.videoRef)==null?void 0:a.current)&&this.props.setVideoRef&&this.props.setVideoRef((e=this.videoRef)==null?void 0:e.current)}componentWillUnmount(){window.removeEventListener("keydown",this.keydown)}render(){const{isPlay:a,playbackRate:e,currentTime:t,duration:i,buffered:r,error:E}=this.state,{imgList:y,imgIndex:k,pageBackward:g,pageJump:T,pageForward:R,valid:P,footer:b,drawLayerSlot:h}=this.props,C=isNaN(i)?0:Math.max(d(i,1)-t,0),{playPause:m,updateNextPlaybackRate:w,onPause:x,onPlay:S,onTimeUpdate:_,resetVideoData:V,setDuration:D,setCurrentTime:I,onError:N,videoRef:L,videoSrc:F}=this;return o.createElement(c.Provider,{value:{videoRef:this.videoRef,addTime:this.props.addTime,toggleClipStatus:this.props.toggleClipStatus,isPlay:a,playPause:m,updateNextPlaybackRate:w,playbackRate:e,currentTime:t,duration:i,buffered:r,setCurrentTime:I,imgIndex:k,imgList:y,pageBackward:g,pageJump:T,pageForward:R}},o.createElement(o.Fragment,null,h==null?void 0:h({currentTime:t,remainingTime:C,zoom:1,currentPos:{x:0,y:0}}),o.createElement("div",{className:l("video-wrapper")},o.createElement("div",{className:l("video-container")},o.createElement("video",{ref:L,className:l(this.props.showVideoTrack?"video-track":"video"),src:F,onPause:x,onPlay:S,onTimeUpdate:_,onLoadedMetadata:V,onError:N,onDurationChange:D,width:"100%",height:"100%",onClick:m}),this.props.showVideoTrack&&o.createElement(j,{currentTime:t,onTrackResize:this.props.onTrackResize,onTrackResizeStart:()=>{var u;(u=this.videoElm)==null||u.pause()},readonly:!1}),o.createElement(z,{fileType:"video",errorProps:{reloadImage:this.reload,backgroundColor:"#e2e2e2",ignoreOffsetY:!0,isError:E},invalidProps:{isValid:P}})),o.createElement(A,{footer:b}))))}}export{v as VideoPlayer,c as VideoPlayerCtx,v as default};
1
+ import o from"react";import A from"./components/controller/index.js";import j from"../videoAnnotate/videoClipTool/components/videoTrack/index.js";import{getClassName as l}from"../../utils/dom.js";import{cKeyCode as M}from"@labelbee/lb-annotation";import{decimalReserved as d}from"./utils.js";import z from"../fileException/index.js";const s=M.default,c=o.createContext({isPlay:!1,playPause:()=>{},updateNextPlaybackRate:()=>{},playbackRate:1,currentTime:0,duration:0,buffered:0,setCurrentTime:()=>{},imgList:[],imgIndex:-1,pageBackward:()=>{},pageJump:f=>{},pageForward:()=>{},addTime:()=>{},toggleClipStatus:()=>{}}),U=50,p=.1,n=[.5,1,1.5,2,4,6,8,16];class v extends o.Component{constructor(a){super(a);this.changePlaybackPate=e=>{this.videoElm&&(this.videoElm.playbackRate=e,this.setState({playbackRate:e}))},this.playPause=()=>{var e,t,i;((e=this.videoElm)==null?void 0:e.paused)?(t=this.videoElm)==null||t.play():(i=this.videoElm)==null||i.pause()},this.updateNextPlaybackRate=(e=!0)=>{const t=n.findIndex(r=>r===this.state.playbackRate);let i=e?Math.min(t+1,n.length-1):Math.max(t-1,0);this.changePlaybackPate(n[i])},this.fastForward=()=>{this.videoElm&&this.setCurrentTime(this.videoElm.currentTime+p)},this.rewind=()=>{this.videoElm&&this.setCurrentTime(this.videoElm.currentTime-p)},this.keydown=e=>{e.keyCode===s.Space&&(e.preventDefault(),this.playPause()),e.keyCode===s.Up&&(e.preventDefault(),this.updateNextPlaybackRate()),e.keyCode===s.Down&&(e.preventDefault(),this.updateNextPlaybackRate(!1)),e.keyCode===s.Left&&(e.preventDefault(),this.rewind()),e.keyCode===s.Right&&(e.preventDefault(),this.fastForward())},this.onPlay=()=>{this.setState({isPlay:!0},this.onVideoStart)},this.onPause=()=>{this.onVideoStopped()},this.onTimeUpdate=()=>{var e;this.videoElm&&this.setState({currentTime:d((e=this.videoElm)==null?void 0:e.currentTime,1)})},this.onVideoStopped=()=>{this.setState({isPlay:!1}),this.timeInterval&&(clearInterval(this.timeInterval),this.timeInterval=void 0),this.videoElm&&this.setCurrentTime(this.videoElm.currentTime)},this.onVideoStart=()=>{this.timeInterval=window.setInterval(()=>{var e,t,i;if(this.videoElm)try{if(((e=this.videoElm)==null?void 0:e.buffered.length)>0){const r=(t=this.videoElm)==null?void 0:t.buffered.end(0);this.setState({currentTime:d((i=this.videoElm)==null?void 0:i.currentTime,1),buffered:r})}}catch(r){console.error(r)}},U)},this.resetVideoData=()=>{this.setState({currentTime:0,buffered:0,error:!1,isPlay:!1}),this.videoElm&&(this.videoElm.playbackRate=this.state.playbackRate),this.onVideoStopped()},this.setDuration=()=>{var e,t,i;if(this.videoElm){const r=d((e=this.videoElm)==null?void 0:e.duration,1);(i=(t=this.props).dataLoaded)==null||i.call(t),this.setState({duration:r})}},this.setCurrentTime=e=>{var t,i;this.videoElm&&(this.videoElm.currentTime=e,this.setState({currentTime:e}),(i=(t=this.props).updateCurrentTime)==null||i.call(t,e))},this.reload=()=>{var e;(e=this.videoElm)==null||e.load()},this.onError=()=>{this.resetVideoData(),this.setState({error:!0})},this.state={playbackRate:1,currentTime:0,isPlay:!1,duration:0,buffered:0,error:!1},this.videoRef=o.createRef()}get videoElm(){var a;return(a=this.videoRef)==null?void 0:a.current}get videoSrc(){var a,e;const{imgIndex:t,imgList:i}=this.props;return t>-1&&(e=(a=i[t])==null?void 0:a.url)!=null?e:""}componentDidMount(){var a,e;window.addEventListener("keydown",this.keydown),((a=this.videoRef)==null?void 0:a.current)&&this.props.setVideoRef&&this.props.setVideoRef((e=this.videoRef)==null?void 0:e.current)}componentWillUnmount(){window.removeEventListener("keydown",this.keydown)}render(){const{isPlay:a,playbackRate:e,currentTime:t,duration:i,buffered:r,error:E}=this.state,{imgList:y,imgIndex:k,pageBackward:g,pageJump:T,pageForward:R,valid:P,footer:b,drawLayerSlot:h}=this.props,C=isNaN(i)?0:Math.max(d(i,1)-t,0),{playPause:m,updateNextPlaybackRate:w,onPause:x,onPlay:S,onTimeUpdate:_,resetVideoData:V,setDuration:D,setCurrentTime:I,onError:N,videoRef:L,videoSrc:F}=this;return o.createElement(c.Provider,{value:{videoRef:this.videoRef,addTime:this.props.addTime,toggleClipStatus:this.props.toggleClipStatus,isPlay:a,playPause:m,updateNextPlaybackRate:w,playbackRate:e,currentTime:t,duration:i,buffered:r,setCurrentTime:I,imgIndex:k,imgList:y,pageBackward:g,pageJump:T,pageForward:R}},o.createElement(o.Fragment,null,h==null?void 0:h({currentTime:t,remainingTime:C,zoom:1,currentPos:{x:0,y:0}}),o.createElement("div",{className:l("video-wrapper")},o.createElement("div",{className:l("video-container")},o.createElement("video",{ref:L,className:l(this.props.showVideoTrack?"video-track":"video"),src:F,onPause:x,onPlay:S,onTimeUpdate:_,onLoadedMetadata:V,onError:N,onDurationChange:D,width:"100%",height:"100%",onClick:m}),this.props.showVideoTrack&&o.createElement(j,{currentTime:t,onTrackResize:this.props.onTrackResize,onTrackResizeStart:()=>{var u;(u=this.videoElm)==null||u.pause()},readonly:!1}),o.createElement(z,{fileType:"video",errorProps:{reloadImage:this.reload,backgroundColor:"#e2e2e2",ignoreOffsetY:!0,isError:E},invalidProps:{isValid:P}})),o.createElement(A,{footer:b}))))}}export{v as VideoPlayer,c as VideoPlayerCtx,v as default};
package/es/index.css CHANGED
@@ -2826,7 +2826,7 @@
2826
2826
  margin-bottom: 24px;
2827
2827
  width: 100%;
2828
2828
  }
2829
- .bee-LLMView__tag {
2829
+ .bee-LLMView .bee-LLMView-tag {
2830
2830
  color: #666FFF;
2831
2831
  background: #eeefff;
2832
2832
  height: 20px;
@@ -1 +1 @@
1
- import{getFormatSize as At}from"../../components/customResizeHook/index.js";import{ESubmitType as K}from"../../constant/index.js";import Dt from"../../constant/styleString.js";import{ANNOTATION_ACTIONS as i}from"../Actions.js";import{jsonParser as U}from"../../utils/index.js";import W from"../../utils/AnnotationDataUtils.js";import{ConfigUtils as vt}from"../../utils/ConfigUtils.js";import{composeResultWithBasicImgInfo as rt,composeResult as Y}from"../../utils/data.js";import N from"../../utils/StepUtils.js";import J from"../../utils/ToolUtils.js";import{MathUtils as ut,CommonToolUtils as yt,AnnotationEngine as Rt,ImgUtils as Pt}from"@labelbee/lb-annotation";import{PointCloudUtils as at,i18n as F}from"@labelbee/lb-utils";import{Modal as ct}from"antd";import{message as dt}from"antd/es";import pt from"lodash";import{SetAnnotationLoading as $}from"./actionCreators.js";import{EToolName as _t}from"../../data/enums/ToolType.js";var Ct=Object.defineProperty,ht=Object.defineProperties,Ot=Object.getOwnPropertyDescriptors,gt=Object.getOwnPropertySymbols,bt=Object.prototype.hasOwnProperty,Ut=Object.prototype.propertyIsEnumerable,It=(t,e,r)=>e in t?Ct(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,n=(t,e)=>{for(var r in e||(e={}))bt.call(e,r)&&It(t,r,e[r]);if(gt)for(var r of gt(e))Ut.call(e,r)&&It(t,r,e[r]);return t},l=(t,e)=>ht(t,Ot(e)),mt=(t,e,r)=>new Promise((E,d)=>{var f=m=>{try{A(r.next(m))}catch(y){d(y)}},S=m=>{try{A(r.throw(m))}catch(y){d(y)}},A=m=>m.done?E(m.value):Promise.resolve(m.value).then(f,S);A((r=r.apply(t,e)).next())});const B=(t,e)=>t.find(r=>r.step===e),ft={annotationEngine:null,toolInstance:null,imgList:[],config:"{}",imgIndex:-1,basicIndex:0,imgPageSize:1,step:1,stepList:[],imgNode:new Image,basicResultList:[],resultList:[],stepProgress:0,loading:!1,loadPCDFileLoading:!0,triggerEventAfterIndexChanged:!1,pointCloudLoading:!1,checkMode:!1,predictionResult:[],predictionResultVisible:!1,highlightAttribute:""},Nt=t=>{const{imgList:e,imgPageSize:r}=t;return Math.ceil(e.length/r)},Tt=(t,e)=>t.reduce((r,E)=>{if(E){const d=E.result;if(U(d)[`step_${e}`])return r+1}return r},0)/t.length,Bt=(t,e)=>{const{step:r,stepList:E}=t,d=N.getCurrentStepInfo(r,E),f=vt.jsonParser(d.config);if(J.isVideoTool(d==null?void 0:d.tool)||J.isAudioTool(d==null?void 0:d.tool)||J.isPointCloudTool(d==null?void 0:d.tool)||_t.LLM===(d==null?void 0:d.tool))return;const S=document.getElementById("toolContainer");if(!S)throw"Not exist dom named id-toolContainer";const A=At({width:window.innerWidth,height:window.innerHeight}),m=new Rt({container:S,toolName:d.tool,size:A,imgNode:e,config:f,style:JSON.parse(Dt)});return{toolInstance:m==null?void 0:m.toolInstance,annotationEngine:m}},wt=(t,e)=>(r,E)=>mt(void 0,null,function*(){var d;const{stepList:f,step:S}=E().annotation,A=N.currentToolIsVideo(S,f),m=N.currentToolIsPointCloud(S,f),y=((d=N.getCurrentStepInfo(S,f))==null?void 0:d.tool)===_t.LLM,h=N.currentToolIsAudio(S,f);if($(r,!0),yield r(xt(t)),A||m||y||h){r(Ft(t));return}r(jt(t,e))}),xt=t=>(e,r)=>mt(void 0,null,function*(){const{getFileData:E,imgList:d}=r().annotation;if(E){const f=yield E(d[t],t);e({type:i.SET_FILE_DATA,payload:{fileData:f,index:t}})}}),Ft=t=>e=>{$(e,!1),e({type:i.LOAD_FILE_DATA,payload:{nextIndex:t}})},jt=(t,e)=>(r,E)=>{var d;const{toolInstance:f,imgList:S}=E().annotation,A=(d=S==null?void 0:S[t])==null?void 0:d.url;Pt.load(A).then(m=>{$(r,!1),r({type:i.LOAD_FILE_DATA,payload:{imgNode:m,nextIndex:t,nextBasicIndex:e}})}).catch(()=>{$(r,!1),f==null||f.setErrorImg(),r({type:i.LOAD_FILE_DATA,payload:{nextIndex:t,nextBasicIndex:e}})})},Gt=({toolInstance:t,imgList:e,imgIndex:r,stepList:E,step:d=1})=>{var f,S,A,m;const y=((f=e[r])==null?void 0:f.result)||"",[h,j,G]=(S=t==null?void 0:t.exportData())!=null?S:[],V=(m=(A=t==null?void 0:t.exportCustomData)==null?void 0:A.call(t))!=null?m:{},M=rt(y,j),k=Y(M,{step:d,stepList:E},{rect:h},V);return e.map((w,H)=>H===r?n(l(n({},w),{result:k}),G):n({},w))},Vt=(t=n({},ft),e)=>{var r,E,d,f,S,A,m,y,h,j,G,V,M,k,w,H,X,q,Z,Q,tt,et,ot,nt,st;switch(e.type){case i.INIT_ALL_STATE:return n(n({},t),ft);case i.UPDATE_TOOL_INSTANCE:return l(n({},t),{toolInstance:e.payload.toolInstance});case i.UPDATE_IMG_LIST:return l(n({},t),{imgList:e.payload.imgList});case i.CALC_STEP_PROGRESS:{const{imgList:o,step:s}=t,u=Tt(o,s);return l(n({},t),{stepProgress:u})}case i.SUBMIT_FILE_DATA:{const{imgList:o,imgIndex:s,step:u,stepList:a,toolInstance:p,onSubmit:c,resultList:T}=t;if(!p||!o[s])return t;const g=((r=o[s])==null?void 0:r.result)||"",[,_,I]=(E=p==null?void 0:p.exportData())!=null?E:[],L=(f=(d=p==null?void 0:p.exportCustomData)==null?void 0:d.call(p))!=null?f:{},D=rt(g,_),R=Y(D,{step:u,stepList:a},{rect:T},L),v=t.imgList.map((C,P)=>{if(P===s){const x=W.dataCorrection(R,g,u,a);return n(l(n({},C),{result:x}),I)}return C});if(((S=e.payload)==null?void 0:S.submitType)===K.SyncImgList)return l(n({},t),{imgList:v});c&&c([v[s]],(A=e.payload)==null?void 0:A.submitType,s,v);const O=Tt(v,u);return l(n({},t),{stepProgress:O,imgList:v})}case i.SAVE_RESULT:{const{imgList:o,imgIndex:s,onSave:u}=t;return u==null||u(o[s],s,o),n({},t)}case i.SUBMIT_RESULT:{const{imgList:o,basicIndex:s,resultList:u,toolInstance:a,basicResultList:p}=t;if(!a)return t;const[c]=(m=a==null?void 0:a.exportData())!=null?m:[];let T=c;if((p==null?void 0:p.length)>0){const g=(y=p[s])==null?void 0:y.id,_=c.map(I=>l(n({},I),{sourceID:g}));T=pt.cloneDeep(u).filter(I=>I.sourceID!==g),T.push(..._)}return l(n({},t),{resultList:T,imgList:o})}case i.SET_BASIC_INDEX:{const{toolInstance:o,step:s,imgList:u,imgIndex:a,stepList:p,annotationEngine:c,resultList:T,basicResultList:g}=t;if(!o||!c)return t;const _=e.payload.basicIndex,I=(h=g[_])==null?void 0:h.id,L=U((j=u[a])==null?void 0:j.result),D=(T||[]).filter(x=>x.sourceID===I),R=B(p,s),{dataSourceStep:v,tool:O}=R,C=B(p,v);let P=[];return v&&O&&(P=(G=L[`step_${v}`])==null?void 0:G.result,(P==null?void 0:P.length)>0?(c==null||c.setBasicInfo(C.tool,P[_]),c==null||c.launchOperation()):(c==null||c.setBasicInfo(C.tool),c==null||c.forbidOperation(),dt.info(F.t("NoDependency")))),o==null||o.setResult(D),o==null||o.history.initRecord(D,!0),l(n({},t),{basicIndex:_})}case i.SET_TRIGGER_EVENT_AFTER_INDEX_CHANGED:{const{triggerEventAfterIndexChanged:o}=e.payload;return l(n({},t),{triggerEventAfterIndexChanged:!!o})}case i.LOAD_FILE_DATA:{const{imgList:o,step:s,toolInstance:u,annotationEngine:a,stepList:p}=t;if(!u)return l(n({},t),{imgIndex:e.payload.nextIndex});const c=N.getCurrentStepInfo(s,p),{nextIndex:T,imgNode:g,nextBasicIndex:_,imgError:I}=e.payload,L=_!=null?_:0,D=U((V=o[T])==null?void 0:V.result),R=D[`step_${c.step}`],v=!R,O={rotate:(M=D.rotate)!=null?M:0,valid:(k=D.valid)!=null?k:!0};g&&I!==!0?a==null||a.setImgNode(g,O):u==null||u.setValid(O.valid);const C=B(p,c.step),{dataSourceStep:P,tool:x}=C,lt=B(p,P),it=P&&x,b=(H=(w=D[`step_${P}`])==null?void 0:w.result)!=null?H:[],z=W.getInitialResultList(R==null?void 0:R.result,u,C,b,v);if(a==null||a.launchOperation(),it&&((b==null?void 0:b.length)>0?a==null||a.setBasicInfo(lt.tool,b[L]):(a==null||a.setBasicInfo(lt.tool),a==null||a.forbidOperation(),dt.info(F.t("NoDependency")))),c.tool!=="check"){const Lt=(q=(X=b[L])==null?void 0:X.id)!=null?q:"",Et=it?z.filter(St=>yt.isSameSourceID(St.sourceID,Lt)):z;(Z=u==null?void 0:u.history)==null||Z.initRecord(z,!0),u==null||u.setResult(Et)}return l(n({},t),{imgIndex:T,basicIndex:L,basicResultList:b,resultList:z})}case i.UPDATE_ANNOTATION_CONFIG:return l(n({},t),{config:(Q=e.payload.config)!=null?Q:"{}"});case i.SET_TASK_STEP_LIST:{const{stepList:o}=e.payload;return l(n({},t),{stepList:o})}case i.SET_TASK_CONFIG:{const{stepList:o,step:s}=e.payload;return l(n({},t),{stepList:o,step:s})}case i.INIT_TOOL:{const{imgNode:o}=t,s=Bt(t,o);if(s){const{toolInstance:u,annotationEngine:a}=s;return l(n({},t),{toolInstance:u,annotationEngine:a})}return n({},t)}case i.SET_TOOL:{const o=(tt=e.payload)==null?void 0:tt.instance;return o?l(n({},t),{toolInstance:o}):n({},t)}case i.UPDATE_ON_SUBMIT:return l(n({},t),{onSubmit:e.payload.onSubmit});case i.UPDATE_ON_SAVE:return l(n({},t),{onSave:e.payload.onSave});case i.UPDATE_ON_PAGE_CHANGE:return l(n({},t),{onPageChange:e.payload.onPageChange});case i.SET_PREDICT_RESULT:return l(n({},t),{predictionResult:e.payload.result});case i.SET_PREDICT_RESULT_VISIBLE:return l(n({},t),{predictionResultVisible:e.payload.visible});case i.UPDATE_ON_STEP_CHANGE:return l(n({},t),{onStepChange:e.payload.onStepChange});case i.UPDATE_GET_FILE_DATA:return l(n({},t),{getFileData:e.payload.getFileData});case i.UPDATE_PAGE_SIZE:return l(n({},t),{pageSize:e.payload.pageSize});case i.UPDATE_LOAD_FILE_LIST:return l(n({},t),{loadFileList:e.payload.loadFileList});case i.UPDATE_BEFORE_ROTATE:return l(n({},t),{beforeRotate:e.payload.beforeRotate});case i.UPDATE_PRE_DATA_PROCESS:return l(n({},t),{preDataProcess:e.payload.preDataProcess});case i.SKIP_BEFORE_PAGE_TURNING:return l(n({},t),{skipBeforePageTurning:e.payload.skipBeforePageTurning});case i.SET_FILE_DATA:{const{fileData:o,index:s}=e.payload,{imgList:u}=t,a=[...u];return a[s]=n(n({},a[s]),o),l(n({},t),{imgList:a})}case i.UPDATE_ROTATE:{const{toolInstance:o,beforeRotate:s}=t;return s&&s()===!1||(et=o==null?void 0:o.updateRotate)==null||et.call(o),t}case i.UPDATE_ANNOTATION_VALID:{const{toolInstance:o}=t,s=(ot=o==null?void 0:o.valid)!=null?ot:!0;return ct.destroyAll(),ct.confirm({content:F.t(s?"updateValidFromValidToInValid":"updateValidFromInValidToValid"),onOk:()=>{o==null||o.setValid(!s)},okText:F.t("Confirm"),cancelText:F.t("Cancel")}),t}case i.COPY_BACKWARD_RESULT:{const{toolInstance:o,imgIndex:s,imgList:u,step:a}=t;if(!o)return t;if(s===0||s>=u.length)return console.error("\u65E0\u6CD5\u590D\u5236\u8FB9\u754C\u5916\u7684\u5185\u5BB9"),t;const p=u[s-1].result;if(!p)return t;const c=W.copyResultChange(p,a,(nt=u[s].result)!=null?nt:"");u[s]=l(n({},u[s]),{result:c});const g=U(c)[`step_${a}`],_=(g==null?void 0:g.result)||[];return o==null||o.setResult(_),o==null||o.history.pushHistory(_),(st=o==null?void 0:o.asyncData)==null||st.call(o,u[s]),l(n({},t),{imgList:[...u]})}case i.SET_STEP:{const{stepList:o,annotationEngine:s}=t,{toStep:u}=e.payload;if(!s)return t;const a=B(o,u);return s==null||s.setToolName(a.tool,a.config),l(n({},t),{step:u,toolInstance:s==null?void 0:s.toolInstance})}case i.SET_LOADPCDFILE_LOADING:{const{loadPCDFileLoading:o}=e.payload;return l(n({},t),{loadPCDFileLoading:!!o})}case i.SET_LOADING:{const{loading:o}=e.payload;return l(n({},t),{loading:!!o})}case i.SET_POINT_CLOUD_LOADING:{const{pointCloudLoading:o}=e.payload;return l(n({},t),{pointCloudLoading:!!o})}case i.SET_CHECK_MODE:{const{checkMode:o}=e.payload;return l(n({},t),{checkMode:!!o})}case i.SET_HIGHLIGHT_ATTRIBUTE:{const{attribute:o}=e.payload;return l(n({},t),{highlightAttribute:o})}case i.BATCH_UPDATE_TRACK_ID:{const{id:o,newID:s,rangeIndex:u,imgList:a}=e.payload,{imgIndex:p,onSubmit:c}=t,T=[],g=a.map((_,I)=>{if(ut.isInRange(I,u)){const L=l(n({},_),{result:at.batchUpdateTrackID({id:o,newID:s,result:_.result})});return T.push({imgIndex:I,newInfo:L}),L}return _});return c&&c([g[p]],K.BatchUpdateTrackID,p,g,{updateImgList:T}),l(n({},t),{imgList:g})}case i.BATCH_UPDATE_RESULT_BY_TRACK_ID:{const{id:o,newData:s,rangeIndex:u}=e.payload,{imgList:a,imgIndex:p,onSubmit:c}=t,T=[],g=a.map((_,I)=>{if(ut.isInRange(I,u)){const L=l(n({},_),{result:at.batchUpdateResultByTrackID({id:o,newData:s,result:_.result})});return T.push({imgIndex:I,newInfo:L}),L}return _});return c&&c([g[p]],K.BatchUpdateTrackID,p,g,{updateImgList:T}),l(n({},t),{imgList:g})}case i.BATCH_UPDATE_IMG_LIST_RESULT_BY_PREDICT_RESULT:{const{onSubmit:o,imgList:s,stepList:u,step:a,predictionResult:p}=t,c={};p.forEach(I=>{const{index:L}=I;c[L]=pt.pick(I,["center","width","height","depth","rotation","id","attribute","valid","trackID"])});const T=`step_${a}`,g=[],_=s.map((I,L)=>{if(c[L]){const D=I.result==="{}"?U(Y("",{step:a,stepList:u},{rect:[]},{})):U(I.result);D[T].result.push(c[L]);const R=l(n({},I),{result:JSON.stringify(D)});return g.push({imgIndex:L,newInfo:R}),R}return I});return o==null||o(_,K.BatchUpdateImgList,-1,_,{updateImgList:g}),l(n({},t),{imgList:_})}default:return t}};export{wt as LoadFileAndFileData,Vt as annotationReducer,Gt as composeResultByToolInstance,B as getStepConfig,Nt as getTotalPage};
1
+ import{getFormatSize as St}from"../../components/customResizeHook/index.js";import{ESubmitType as K}from"../../constant/index.js";import Dt from"../../constant/styleString.js";import{ANNOTATION_ACTIONS as l}from"../Actions.js";import{jsonParser as U}from"../../utils/index.js";import W from"../../utils/AnnotationDataUtils.js";import{ConfigUtils as vt}from"../../utils/ConfigUtils.js";import{composeResultWithBasicImgInfo as rt,composeResult as Y}from"../../utils/data.js";import N from"../../utils/StepUtils.js";import J from"../../utils/ToolUtils.js";import{MathUtils as ut,CommonToolUtils as yt,AnnotationEngine as Rt,ImgUtils as Pt}from"@labelbee/lb-annotation";import{PointCloudUtils as at,i18n as F}from"@labelbee/lb-utils";import{Modal as ct}from"antd";import{message as dt}from"antd/es";import pt from"lodash";import{SetAnnotationLoading as $}from"./actionCreators.js";import{EToolName as _t}from"../../data/enums/ToolType.js";var Ct=Object.defineProperty,Ot=Object.defineProperties,ht=Object.getOwnPropertyDescriptors,gt=Object.getOwnPropertySymbols,bt=Object.prototype.hasOwnProperty,Ut=Object.prototype.propertyIsEnumerable,It=(t,e,r)=>e in t?Ct(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,n=(t,e)=>{for(var r in e||(e={}))bt.call(e,r)&&It(t,r,e[r]);if(gt)for(var r of gt(e))Ut.call(e,r)&&It(t,r,e[r]);return t},i=(t,e)=>Ot(t,ht(e)),mt=(t,e,r)=>new Promise((E,d)=>{var f=m=>{try{S(r.next(m))}catch(y){d(y)}},A=m=>{try{S(r.throw(m))}catch(y){d(y)}},S=m=>m.done?E(m.value):Promise.resolve(m.value).then(f,A);S((r=r.apply(t,e)).next())});const B=(t,e)=>t.find(r=>r.step===e),ft={annotationEngine:null,toolInstance:null,imgList:[],config:"{}",imgIndex:-1,basicIndex:0,imgPageSize:1,step:1,stepList:[],imgNode:new Image,basicResultList:[],resultList:[],stepProgress:0,loading:!1,loadPCDFileLoading:!0,triggerEventAfterIndexChanged:!1,pointCloudLoading:!1,checkMode:!1,predictionResult:[],predictionResultVisible:!1,highlightAttribute:""},Nt=t=>{const{imgList:e,imgPageSize:r}=t;return Math.ceil(e.length/r)},Tt=(t,e)=>t.reduce((r,E)=>{if(E){const d=E.result;if(U(d)[`step_${e}`])return r+1}return r},0)/t.length,Bt=(t,e)=>{const{step:r,stepList:E}=t,d=N.getCurrentStepInfo(r,E),f=vt.jsonParser(d.config);if(J.isVideoTool(d==null?void 0:d.tool)||J.isAudioTool(d==null?void 0:d.tool)||J.isPointCloudTool(d==null?void 0:d.tool)||_t.LLM===(d==null?void 0:d.tool))return;const A=document.getElementById("toolContainer");if(!A)throw"Not exist dom named id-toolContainer";const S=St({width:window.innerWidth,height:window.innerHeight}),m=new Rt({container:A,toolName:d.tool,size:S,imgNode:e,config:f,style:JSON.parse(Dt)});return{toolInstance:m==null?void 0:m.toolInstance,annotationEngine:m}},wt=(t,e)=>(r,E)=>mt(void 0,null,function*(){var d;const{stepList:f,step:A}=E().annotation,S=N.currentToolIsVideo(A,f),m=N.currentToolIsPointCloud(A,f),y=((d=N.getCurrentStepInfo(A,f))==null?void 0:d.tool)===_t.LLM,O=N.currentToolIsAudio(A,f);if($(r,!0),yield r(xt(t)),S){r(Ft(t));return}if(m||y||O){r(jt(t));return}r(Gt(t,e))}),xt=t=>(e,r)=>mt(void 0,null,function*(){const{getFileData:E,imgList:d}=r().annotation;if(E){const f=yield E(d[t],t);e({type:l.SET_FILE_DATA,payload:{fileData:f,index:t}})}}),Ft=t=>e=>{e({type:l.LOAD_FILE_DATA,payload:{nextIndex:t}})},jt=t=>e=>{$(e,!1),e({type:l.LOAD_FILE_DATA,payload:{nextIndex:t}})},Gt=(t,e)=>(r,E)=>{var d;const{toolInstance:f,imgList:A}=E().annotation,S=(d=A==null?void 0:A[t])==null?void 0:d.url;Pt.load(S).then(m=>{$(r,!1),r({type:l.LOAD_FILE_DATA,payload:{imgNode:m,nextIndex:t,nextBasicIndex:e}})}).catch(()=>{$(r,!1),f==null||f.setErrorImg(),r({type:l.LOAD_FILE_DATA,payload:{nextIndex:t,nextBasicIndex:e}})})},Vt=({toolInstance:t,imgList:e,imgIndex:r,stepList:E,step:d=1})=>{var f,A,S,m;const y=((f=e[r])==null?void 0:f.result)||"",[O,j,G]=(A=t==null?void 0:t.exportData())!=null?A:[],V=(m=(S=t==null?void 0:t.exportCustomData)==null?void 0:S.call(t))!=null?m:{},M=rt(y,j),k=Y(M,{step:d,stepList:E},{rect:O},V);return e.map((w,H)=>H===r?n(i(n({},w),{result:k}),G):n({},w))},Mt=(t=n({},ft),e)=>{var r,E,d,f,A,S,m,y,O,j,G,V,M,k,w,H,X,q,Z,Q,tt,et,ot,nt,st;switch(e.type){case l.INIT_ALL_STATE:return n(n({},t),ft);case l.UPDATE_TOOL_INSTANCE:return i(n({},t),{toolInstance:e.payload.toolInstance});case l.UPDATE_IMG_LIST:return i(n({},t),{imgList:e.payload.imgList});case l.CALC_STEP_PROGRESS:{const{imgList:o,step:s}=t,u=Tt(o,s);return i(n({},t),{stepProgress:u})}case l.SUBMIT_FILE_DATA:{const{imgList:o,imgIndex:s,step:u,stepList:a,toolInstance:p,onSubmit:c,resultList:T}=t;if(!p||!o[s])return t;const g=((r=o[s])==null?void 0:r.result)||"",[,_,I]=(E=p==null?void 0:p.exportData())!=null?E:[],L=(f=(d=p==null?void 0:p.exportCustomData)==null?void 0:d.call(p))!=null?f:{},D=rt(g,_),R=Y(D,{step:u,stepList:a},{rect:T},L),v=t.imgList.map((C,P)=>{if(P===s){const x=W.dataCorrection(R,g,u,a);return n(i(n({},C),{result:x}),I)}return C});if(((A=e.payload)==null?void 0:A.submitType)===K.SyncImgList)return i(n({},t),{imgList:v});c&&c([v[s]],(S=e.payload)==null?void 0:S.submitType,s,v);const h=Tt(v,u);return i(n({},t),{stepProgress:h,imgList:v})}case l.SAVE_RESULT:{const{imgList:o,imgIndex:s,onSave:u}=t;return u==null||u(o[s],s,o),n({},t)}case l.SUBMIT_RESULT:{const{imgList:o,basicIndex:s,resultList:u,toolInstance:a,basicResultList:p}=t;if(!a)return t;const[c]=(m=a==null?void 0:a.exportData())!=null?m:[];let T=c;if((p==null?void 0:p.length)>0){const g=(y=p[s])==null?void 0:y.id,_=c.map(I=>i(n({},I),{sourceID:g}));T=pt.cloneDeep(u).filter(I=>I.sourceID!==g),T.push(..._)}return i(n({},t),{resultList:T,imgList:o})}case l.SET_BASIC_INDEX:{const{toolInstance:o,step:s,imgList:u,imgIndex:a,stepList:p,annotationEngine:c,resultList:T,basicResultList:g}=t;if(!o||!c)return t;const _=e.payload.basicIndex,I=(O=g[_])==null?void 0:O.id,L=U((j=u[a])==null?void 0:j.result),D=(T||[]).filter(x=>x.sourceID===I),R=B(p,s),{dataSourceStep:v,tool:h}=R,C=B(p,v);let P=[];return v&&h&&(P=(G=L[`step_${v}`])==null?void 0:G.result,(P==null?void 0:P.length)>0?(c==null||c.setBasicInfo(C.tool,P[_]),c==null||c.launchOperation()):(c==null||c.setBasicInfo(C.tool),c==null||c.forbidOperation(),dt.info(F.t("NoDependency")))),o==null||o.setResult(D),o==null||o.history.initRecord(D,!0),i(n({},t),{basicIndex:_})}case l.SET_TRIGGER_EVENT_AFTER_INDEX_CHANGED:{const{triggerEventAfterIndexChanged:o}=e.payload;return i(n({},t),{triggerEventAfterIndexChanged:!!o})}case l.LOAD_FILE_DATA:{const{imgList:o,step:s,toolInstance:u,annotationEngine:a,stepList:p}=t;if(!u)return i(n({},t),{imgIndex:e.payload.nextIndex});const c=N.getCurrentStepInfo(s,p),{nextIndex:T,imgNode:g,nextBasicIndex:_,imgError:I}=e.payload,L=_!=null?_:0,D=U((V=o[T])==null?void 0:V.result),R=D[`step_${c.step}`],v=!R,h={rotate:(M=D.rotate)!=null?M:0,valid:(k=D.valid)!=null?k:!0};g&&I!==!0?a==null||a.setImgNode(g,h):u==null||u.setValid(h.valid);const C=B(p,c.step),{dataSourceStep:P,tool:x}=C,lt=B(p,P),it=P&&x,b=(H=(w=D[`step_${P}`])==null?void 0:w.result)!=null?H:[],z=W.getInitialResultList(R==null?void 0:R.result,u,C,b,v);if(a==null||a.launchOperation(),it&&((b==null?void 0:b.length)>0?a==null||a.setBasicInfo(lt.tool,b[L]):(a==null||a.setBasicInfo(lt.tool),a==null||a.forbidOperation(),dt.info(F.t("NoDependency")))),c.tool!=="check"){const Lt=(q=(X=b[L])==null?void 0:X.id)!=null?q:"",Et=it?z.filter(At=>yt.isSameSourceID(At.sourceID,Lt)):z;(Z=u==null?void 0:u.history)==null||Z.initRecord(z,!0),u==null||u.setResult(Et)}return i(n({},t),{imgIndex:T,basicIndex:L,basicResultList:b,resultList:z})}case l.UPDATE_ANNOTATION_CONFIG:return i(n({},t),{config:(Q=e.payload.config)!=null?Q:"{}"});case l.SET_TASK_STEP_LIST:{const{stepList:o}=e.payload;return i(n({},t),{stepList:o})}case l.SET_TASK_CONFIG:{const{stepList:o,step:s}=e.payload;return i(n({},t),{stepList:o,step:s})}case l.INIT_TOOL:{const{imgNode:o}=t,s=Bt(t,o);if(s){const{toolInstance:u,annotationEngine:a}=s;return i(n({},t),{toolInstance:u,annotationEngine:a})}return n({},t)}case l.SET_TOOL:{const o=(tt=e.payload)==null?void 0:tt.instance;return o?i(n({},t),{toolInstance:o}):n({},t)}case l.UPDATE_ON_SUBMIT:return i(n({},t),{onSubmit:e.payload.onSubmit});case l.UPDATE_ON_SAVE:return i(n({},t),{onSave:e.payload.onSave});case l.UPDATE_ON_PAGE_CHANGE:return i(n({},t),{onPageChange:e.payload.onPageChange});case l.SET_PREDICT_RESULT:return i(n({},t),{predictionResult:e.payload.result});case l.SET_PREDICT_RESULT_VISIBLE:return i(n({},t),{predictionResultVisible:e.payload.visible});case l.UPDATE_ON_STEP_CHANGE:return i(n({},t),{onStepChange:e.payload.onStepChange});case l.UPDATE_GET_FILE_DATA:return i(n({},t),{getFileData:e.payload.getFileData});case l.UPDATE_PAGE_SIZE:return i(n({},t),{pageSize:e.payload.pageSize});case l.UPDATE_LOAD_FILE_LIST:return i(n({},t),{loadFileList:e.payload.loadFileList});case l.UPDATE_BEFORE_ROTATE:return i(n({},t),{beforeRotate:e.payload.beforeRotate});case l.UPDATE_PRE_DATA_PROCESS:return i(n({},t),{preDataProcess:e.payload.preDataProcess});case l.SKIP_BEFORE_PAGE_TURNING:return i(n({},t),{skipBeforePageTurning:e.payload.skipBeforePageTurning});case l.SET_FILE_DATA:{const{fileData:o,index:s}=e.payload,{imgList:u}=t,a=[...u];return a[s]=n(n({},a[s]),o),i(n({},t),{imgList:a})}case l.UPDATE_ROTATE:{const{toolInstance:o,beforeRotate:s}=t;return s&&s()===!1||(et=o==null?void 0:o.updateRotate)==null||et.call(o),t}case l.UPDATE_ANNOTATION_VALID:{const{toolInstance:o}=t,s=(ot=o==null?void 0:o.valid)!=null?ot:!0;return ct.destroyAll(),ct.confirm({content:F.t(s?"updateValidFromValidToInValid":"updateValidFromInValidToValid"),onOk:()=>{o==null||o.setValid(!s)},okText:F.t("Confirm"),cancelText:F.t("Cancel")}),t}case l.COPY_BACKWARD_RESULT:{const{toolInstance:o,imgIndex:s,imgList:u,step:a}=t;if(!o)return t;if(s===0||s>=u.length)return console.error("\u65E0\u6CD5\u590D\u5236\u8FB9\u754C\u5916\u7684\u5185\u5BB9"),t;const p=u[s-1].result;if(!p)return t;const c=W.copyResultChange(p,a,(nt=u[s].result)!=null?nt:"");u[s]=i(n({},u[s]),{result:c});const g=U(c)[`step_${a}`],_=(g==null?void 0:g.result)||[];return o==null||o.setResult(_),o==null||o.history.pushHistory(_),(st=o==null?void 0:o.asyncData)==null||st.call(o,u[s]),i(n({},t),{imgList:[...u]})}case l.SET_STEP:{const{stepList:o,annotationEngine:s}=t,{toStep:u}=e.payload;if(!s)return t;const a=B(o,u);return s==null||s.setToolName(a.tool,a.config),i(n({},t),{step:u,toolInstance:s==null?void 0:s.toolInstance})}case l.SET_LOADPCDFILE_LOADING:{const{loadPCDFileLoading:o}=e.payload;return i(n({},t),{loadPCDFileLoading:!!o})}case l.SET_LOADING:{const{loading:o}=e.payload;return i(n({},t),{loading:!!o})}case l.SET_POINT_CLOUD_LOADING:{const{pointCloudLoading:o}=e.payload;return i(n({},t),{pointCloudLoading:!!o})}case l.SET_CHECK_MODE:{const{checkMode:o}=e.payload;return i(n({},t),{checkMode:!!o})}case l.SET_HIGHLIGHT_ATTRIBUTE:{const{attribute:o}=e.payload;return i(n({},t),{highlightAttribute:o})}case l.BATCH_UPDATE_TRACK_ID:{const{id:o,newID:s,rangeIndex:u,imgList:a}=e.payload,{imgIndex:p,onSubmit:c}=t,T=[],g=a.map((_,I)=>{if(ut.isInRange(I,u)){const L=i(n({},_),{result:at.batchUpdateTrackID({id:o,newID:s,result:_.result})});return T.push({imgIndex:I,newInfo:L}),L}return _});return c&&c([g[p]],K.BatchUpdateTrackID,p,g,{updateImgList:T}),i(n({},t),{imgList:g})}case l.BATCH_UPDATE_RESULT_BY_TRACK_ID:{const{id:o,newData:s,rangeIndex:u}=e.payload,{imgList:a,imgIndex:p,onSubmit:c}=t,T=[],g=a.map((_,I)=>{if(ut.isInRange(I,u)){const L=i(n({},_),{result:at.batchUpdateResultByTrackID({id:o,newData:s,result:_.result})});return T.push({imgIndex:I,newInfo:L}),L}return _});return c&&c([g[p]],K.BatchUpdateTrackID,p,g,{updateImgList:T}),i(n({},t),{imgList:g})}case l.BATCH_UPDATE_IMG_LIST_RESULT_BY_PREDICT_RESULT:{const{onSubmit:o,imgList:s,stepList:u,step:a,predictionResult:p}=t,c={};p.forEach(I=>{const{index:L}=I;c[L]=pt.pick(I,["center","width","height","depth","rotation","id","attribute","valid","trackID"])});const T=`step_${a}`,g=[],_=s.map((I,L)=>{if(c[L]){const D=I.result==="{}"?U(Y("",{step:a,stepList:u},{rect:[]},{})):U(I.result);D[T].result.push(c[L]);const R=i(n({},I),{result:JSON.stringify(D)});return g.push({imgIndex:L,newInfo:R}),R}return I});return o==null||o(_,K.BatchUpdateImgList,-1,_,{updateImgList:g}),i(n({},t),{imgList:_})}default:return t}};export{wt as LoadFileAndFileData,Mt as annotationReducer,Vt as composeResultByToolInstance,B as getStepConfig,Nt as getTotalPage};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@labelbee/lb-components",
3
- "version": "1.21.0-alpha.9",
3
+ "version": "1.21.1",
4
4
  "description": "Provide a complete library of annotation components",
5
5
  "main": "./dist/index.js",
6
6
  "es": "./es/index.js",
@@ -43,8 +43,8 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@ant-design/icons": "^4.6.2",
46
- "@labelbee/lb-annotation": "1.25.0-alpha.2",
47
- "@labelbee/lb-utils": "1.17.0-alpha.1",
46
+ "@labelbee/lb-annotation": "1.25.1",
47
+ "@labelbee/lb-utils": "1.17.0",
48
48
  "@labelbee/wavesurfer": "1.0.0",
49
49
  "@types/react-dom": "^18.2.7",
50
50
  "@types/react-transition-group": "^4.4.9",