1"use strict";(self.webpackChunklightx=self.webpackChunklightx||[]).push([[95],{10095:(S,d,r)=>{r.r(d),r.d(d,{TrainingEntryComponent:()=>b});var t=r(54438),c=r(91916),y=r(79421),h=r(74710),f=r(74983),u=r(16478),I=r(41300),C=r(68010),T=r(84341),P=r(61767);let b=(()=>{var g;class m{constructor(n){this.modelTrainingService=n,this.uploadRestoreSnapshot=null,this.pendingUploadRestore=null,this.hasRestoredEntryState=!1,this.route=(0,t.WQX)(h.nX),this.authService=(0,t.WQX)(C.u),this.router=(0,t.WQX)(h.Ix),this.toastService=(0,t.WQX)(f.f),this.dialogService=(0,t.WQX)(I.g),this.trainingImages={classFiles:{}},this.isUploading=!1,this.isTrainingInProgress=!1,this.trainingStatus=null,this.featureType="resnet",this.hasNavigatedToProgress=!1,this.credit=100,this.type="binary",this.dtype=null,this.classMap={},this.classList=[],this.productImageId=null,this.title="Model training setup",this.inputWidth=0,this.isInputFocused=!1,this.minImagesPerClass=20}ngOnInit(){if(this.modelTrainingService.shouldRestoreTrainingEntryState()){const n=this.modelTrainingService.getTrainingEntryState();n?(this.hasRestoredEntryState=!0,this.applySavedEntryState(n)):this.loadClassList()}else this.loadClassList();this.routeSub=this.route.queryParams.subscribe(()=>{this.hasRestoredEntryState||this.loadClassList()})}applySavedEntryState(n){this.featureType=n.featureType,this.type=n.type,this.dtype=n.dtype,this.productImageId=n.productImageId,this.credit=n.credit,this.title=n.title??this.title,this.classList=n.classList,this.trainingImages=n.trainingImages,this.uploadRestoreSnapshot=n.uploadSnapshot,this.pendingUploadRestore=n.uploadSnapshot,n.trainingInputData&&(this.modelTrainingService.trainingInputData=n.trainingInputData),n.datasetUrl&&(this.modelTrainingService.datasetUrl=n.datasetUrl)}loadClassList(){const n=this.route.snapshot.queryParams;this.featureType=n.featureType??this.featureType,this.type=n.type||this.type,this.dtype=n.dtype||this.dtype,this.productImageId=n.prodImageId??this.productImageId;const e=window.history.state??{};this.classList=this.extractClassList(this.modelTrainingService.trainingInputData??e.trainingInputData,this.type)}persistTrainingEntryState(){const n={...this.route.snapshot.queryParams},e=window.history.state??{},i=this.modelTrainingService.trainingInputData??e.trainingInputData,s=this.uploadImageComponent?.getUploadStateSnapshot()??{classList:this.getClassItems(),sectionImages:Object.keys(this.trainingImages.classFiles||{}).reduce((a,o)=>(a[o]=(this.trainingImages.classFiles?.[o]||[]).map(l=>({file:l,name:l.name,size:l.size,key:`${l.name}-${l.size}-${l.lastModified}`})),a),{})};this.modelTrainingService.setTrainingEntryState({queryParams:n,featureType:this.featureType,type:this.type,dtype:this.dtype,productImageId:this.productImageId,credit:this.credit,title:this.title,classList:this.uploadImageComponent?.getUploadStateSnapshot().classList??this.getClassItems().map(a=>({...a})),trainingImages:{classFiles:Object.keys(this.trainingImages.classFiles||{}).reduce((a,o)=>(a[o]=[...this.trainingImages.classFiles?.[o]||[]],a),{})},uploadSnapshot:s,trainingInputData:i})}navigateToTrainingFailed(){this.persistTrainingEntryState(),this.router.navigate([this.modelTrainingService.routes.failed],{state:{trainingStatus:this.trainingStatus}})}getClassItems(){return Array.isArray(this.classList)?this.classList:Array.isArray(this.classList?.items)?this.classList.items:[]}extractClassList(n,e){return n?Array.isArray(n)?n:n[e]||[]:[]}ngOnDestroy(){this.progressDialogRef?.close?.(),this.routeSub?.unsubscribe()}cancel(){this.modelTrainingService.clearTrainingEntryState(),this.router.navigate(["/model-training/dashboard"],{queryParams:this.dtype?{dtype:this.dtype}:void 0})}onTrainingImagesChange(n){this.trainingImages=n,n.classList&&(this.classList=n.classList.map(e=>({...e})))}get canStartTraining(){if(this.isUploading||this.isTrainingInProgress)return!1;const n=this.getClassItems();if(!n.length)return!!Object.keys(this.trainingImages.classFiles||{}).length;const e=this.trainingImages.classFiles||{};return n.every((i,s)=>{const a=i?.value||i?.id||`class_${s}`;return(e[a]?.length??0)>this.minImagesPerClass})}startTraining(){let n=this.authService.currentUser();if(n&&n.remainingCoins<this.credit)return void this.modelTrainingService.openAICreditPopup(s=>{n=this.authService.currentUser(),n&&n.remainingCoins>=this.credit&&this.startTraining()},this.credit,"training");if(!this.canStartTraining)return;this.persistTrainingEntryState(),this.hasNavigatedToProgress=!1,this.isUploading=!0,this.progressDialogRef=this.dialogService.showProgressEditor(u.b.label.uploadingImage);const e=this.getClassItems();let i=Object.fromEntries(e.map((s,a)=>[a.toString(),s.label]));this.modelTrainingService.uploadModelTraining(this.trainingImages.classFiles,i,s=>{const a={featureType:this.featureType,productImageId:this.productImageId,data:{dataSetUrl:s.contentUrl}},o=this.modelTrainingService.getTrainingEntryState();o&&this.modelTrainingService.setTrainingEntryState({...o,datasetUrl:s.contentUrl,productImageId:this.productImageId}),this.modelTrainingService.startTraining(a,l=>{this.isUploading=!1,this.isTrainingInProgress=!0,this.trainingStatus=l?.body||null,this.modelTrainingService.getTrainingStatus(l?.body,0,_=>{this.isTrainingInProgress=!1,this.trainingStatus=_,this.progressDialogRef?.close?.()},_=>{this.isTrainingInProgress=!1,this.progressDialogRef?.close?.(),this.navigateToTrainingFailed()})},l=>{this.isUploading=!1,this.isTrainingInProgress=!1,this.progressDialogRef?.close?.(),this.navigateToTrainingFailed()})},s=>{this.isUploading=!1,this.isTrainingInProgress=!1,this.toastService.showError(s?.message||u.b.message.somethingWrong),this.progressDialogRef?.close?.()})}ngAfterViewInit(){if(this.pendingUploadRestore&&this.uploadImageComponent){const n=this.pendingUploadRestore;this.pendingUploadRestore=null,setTimeout(()=>{this.uploadImageComponent?.applyUploadStateSnapshot(n)})}setTimeout(()=>{const n=document.querySelector(".text-measure");
1n&&(this.inputWidth=Math.max(n.offsetWidth+16,100))})}onInput(n,e){this.title=n.target.value,this.inputWidth=Math.max(e.offsetWidth+16,100)}}return(g=m).\u0275fac=function(n){return new(n||g)(t.rXU(P.L))},g.\u0275cmp=t.VBU({type:g,selectors:[["training-entry"]],viewQuery:function(n,e){if(1&n&&t.GBs(c.C,5),2&n){let i;t.mGM(i=t.lsd())&&(e.uploadImageComponent=i.first)}},standalone:!0,features:[t.aNF],decls:23,vars:11,consts:[["textMeasure",""],[1,"d-flex","align-items-start","justify-content-start","w-100","flex-column",2,"padding-top","56px"],[1,"entry-header","d-flex","align-items-start","justify-content-start","w-100","flex-column","mt-4","mb-4"],[1,"text-24","text-semi","grey-800","d-flex","align-items-center","justify-content-start","w-100","h-48"],[1,"input-container"],[1,"text-measure"],["type","text","placeholder","Enter Label",1,"text-24","text-semi","grey-800","h-48","border-radius-12","ps-2","pe-2",3,"input","focus","blur","value"],[1,"text-14","grey-600","d-flex","align-items-center","justify-content-start","w-100","mt-1","ps-2"],[1,"entry-upload","w-100",2,"min-height","530px"],[1,"w-100",3,"trainingImagesChange","mode","classList","initialUploadSnapshot"],[1,"entry-footer","d-flex","align-items-center","justify-content-center","w-100","pt-2","pb-2","position-fixed",2,"bottom","0px"],["type","button",1,"btn","btn-outline-primary","btn-h48","text-lg","me-2",2,"min-width","207px",3,"click"],["type","button",1,"btn","btn-primary-gradient","btn-h48","d-flex","align-items-center","justify-content-center",2,"min-width","212px",3,"click","disabled"],[1,"text-lg"],[1,"coin-count","d-inline-flex","align-items-center","justify-content-center","ms-2"],["src","https://static.lightxeditor.com/assets/images/Coin-AI-16.svg","height","16px","width","16px",1,"inable"],["src","https://static.lightxeditor.com/assets/images/Coin-AI-disabled-16.svg","height","16px","width","16px",1,"disable"],[1,"grey-600","text-11","text-semi",2,"padding-left","1px","line-height","normal"]],template:function(n,e){if(1&n){const i=t.RV6();t.j41(0,"div",1)(1,"div",2)(2,"div",3)(3,"div",4)(4,"span",5,0),t.EFF(6),t.k0s(),t.j41(7,"input",6),t.bIt("input",function(a){t.eBV(i);const o=t.sdS(5);return t.Njj(e.onInput(a,o))})("focus",function(){return t.eBV(i),t.Njj(e.isInputFocused=!0)})("blur",function(){return t.eBV(i),t.Njj(e.isInputFocused=!1)}),t.k0s()()(),t.j41(8,"div",7),t.EFF(9," Upload images directly into each one "),t.k0s()(),t.j41(10,"div",8)(11,"app-upload-image",9),t.bIt("trainingImagesChange",function(a){return t.eBV(i),t.Njj(e.onTrainingImagesChange(a))}),t.k0s()(),t.j41(12,"div",10)(13,"button",11),t.bIt("click",function(){return t.eBV(i),t.Njj(e.cancel())}),t.EFF(14,"Cancel"),t.k0s(),t.j41(15,"button",12),t.bIt("click",function(){return t.eBV(i),t.Njj(e.startTraining())}),t.j41(16,"span",13),t.EFF(17),t.k0s(),t.j41(18,"span",14),t.nrm(19,"img",15)(20,"img",16),t.j41(21,"b",17),t.EFF(22,"100"),t.k0s()()()()()}2&n&&(t.R7$(6),t.SpI(" ",e.title||""," "),t.R7$(),t.xc7("width",e.inputWidth,"px"),t.AVh("input-focused",e.isInputFocused),t.Y8G("value",e.title),t.R7$(4),t.Y8G("mode",e.type)("classList",e.getClassItems())("initialUploadSnapshot",e.uploadRestoreSnapshot),t.R7$(4),t.Y8G("disabled",!e.canStartTraining),t.R7$(2),t.JRh(e.isUploading?"Uploading...":"Start Training"))},dependencies:[c.C,y.r,T.YN],styles:[".entry-header[_ngcontent-%COMP%]{padding:0 92px}.entry-footer[_ngcontent-%COMP%]{background:linear-gradient(90deg,#fc5cff0d -4%,#2520f60d);border-top:1px solid rgba(98,106,223,.1);background-color:#fff}.entry-footer[_ngcontent-%COMP%] .inable[_ngcontent-%COMP%]{display:block}.entry-footer[_ngcontent-%COMP%] .disable[_ngcontent-%COMP%]{display:none}.entry-footer[_ngcontent-%COMP%] .btn[_ngcontent-%COMP%]:disabled .coin-count[_ngcontent-%COMP%]{background:#0000001a}.entry-footer[_ngcontent-%COMP%] .btn[_ngcontent-%COMP%]:disabled .coin-count[_ngcontent-%COMP%] b[_ngcontent-%COMP%]{color:#fff!important}.entry-footer[_ngcontent-%COMP%] .btn[_ngcontent-%COMP%]:disabled .inable[_ngcontent-%COMP%]{display:none}.entry-footer[_ngcontent-%COMP%] .btn[_ngcontent-%COMP%]:disabled .disable[_ngcontent-%COMP%]{display:block}.entry-footer[_ngcontent-%COMP%] .coin-count[_ngcontent-%COMP%]{border-radius:48px;background:#0006;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);height:18px;padding:1px 4px 1px 1px}.entry-footer[_ngcontent-%COMP%] .coin-count[_ngcontent-%COMP%] b[_ngcontent-%COMP%]{color:#fff!important}.input-container[_ngcontent-%COMP%]{position:relative;display:inline-flex;overflow:hidden;align-items:center;justify-content:flex-start}
1.input-container[_ngcontent-%COMP%] .text-measure[_ngcontent-%COMP%]{position:absolute;visibility:hidden;white-space:nowrap;font:inherit;opacity:0;padding:0 8px;z-index:-1}.input-container[_ngcontent-%COMP%] input[_ngcontent-%COMP%]{min-width:150px;border:1px solid transparent;outline:0px;background:transparent}.input-container[_ngcontent-%COMP%] input[_ngcontent-%COMP%]:hover{border:1px solid #B0B3BF}.input-container[_ngcontent-%COMP%] input[_ngcontent-%COMP%]::placeholder{color:#959aa7;font-weight:400!important}.input-container[_ngcontent-%COMP%] input.input-focused[_ngcontent-%COMP%]{border:1px solid #4A4F5E!important}.input-container[_ngcontent-%COMP%] input.input-focused[_ngcontent-%COMP%]:hover{border:1px solid #4A4F5E}"]}),m})()}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.