PageSourceSearch

https://static.lightxeditor.com/web/1466.814eb97d5e20f211.js

js lightxeditor.com collected 2026-09-24 09:23:32 UTC 826,472 bytes, 1 lines download raw bytes

1(self.webpackChunklightx=self.webpackChunklightx||[]).push([[1466],{91466:(ce,W,m)=>{"use strict";m.r(W),m.d(W,{AiEditorMobileViewModule:()=>zh});var b=m(60177),L=m(21626),P=m(84341),R=m(33391),S=m(34870),x=m(83339),E=m(23679),V=m(79421),O=m(19338),N=m(89818),A=m(74710),w=m(10467),e=m(54438),f=m(16471),y=m(16478),J=m(13435),Oe=m(28567),me=m(3781),z=m(67294),ee=m(80006),Ye=m(24045),ue=m(49449),ae=m(41300),Z=m(94223),q=m(68010),ie=m(55756),ge=m(34183),Q=m(74983),$e=m(65356),Ee=m(72662),Wt=m(82853),H=m(68064),de=m(10634),xe=m(68287),ne=m(630),ze=m(95726);const qt=s=>({"d-none":s});function Kt(s,a){1&s&&e.nrm(0,"pi",13)}function Zt(s,a){1&s&&e.nrm(0,"pi",14)}function Jt(s,a){if(1&s&&e.DNE(0,Kt,1,0,"pi",13)(1,Zt,1,0,"pi",14),2&s){const n=e.XpG(2);e.vxM(n.envService.isMobileView?0:1)}}function Qt(s,a){if(1&s){const n=e.RV6();e.j41(0,"button",15),e.bIt("click",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.upgradePlanDirectPayment())}),e.EFF(1," Unlock Full Credits "),e.k0s()}}function ei(s,a){if(1&s){const n=e.RV6();e.j41(0,"button",15),e.bIt("click",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.addAICredit())}),e.EFF(1," Add Credit "),e.k0s()}}function ti(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",3)(1,"div",4)(2,"div",5),e.nrm(3,"img",6),e.k0s(),e.j41(4,"div",7)(5,"h4",8),e.EFF(6,"Credit Usage Alert"),e.k0s(),e.j41(7,"span",9),e.EFF(8,"You have insufficient Al credits. "),e.DNE(9,Jt,2,1),e.k0s()()(),e.j41(10,"div",10),e.DNE(11,Qt,2,0,"button",11)(12,ei,2,0,"button",11),e.j41(13,"button",12),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.close.emit())}),e.EFF(14," Cancel "),e.k0s()()()}if(2&s){const n=e.XpG();e.R7$(9),e.vxM(n.isInTrialPeriod&&n.isTrialCreditCap?9:-1),e.R7$(2),e.vxM(n.isTrialCreditCap&&n.isInTrialPeriod?11:12)}}function ii(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",16)(1,"div",17)(2,"div",18)(3,"button",19),e.nrm(4,"pi",20),e.k0s()(),e.j41(5,"div",21)(6,"div",22),e.nrm(7,"img",23),e.k0s(),e.j41(8,"div",24)(9,"h4",25),e.EFF(10,"Insufficient AI Credits"),e.k0s(),e.j41(11,"span",26),e.EFF(12,"Get more AI Credits and generate effortlessly"),e.k0s()()(),e.j41(13,"div",10)(14,"button",27),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.addAICredit())}),e.j41(15,"span",28),e.EFF(16,"Buy AI Credits"),e.k0s(),e.j41(17,"span",29),e.EFF(18),e.nI1(19,"currency"),e.k0s()(),e.j41(20,"button",30),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.watchAds())}),e.j41(21,"span",31),e.EFF(22,"Watch an Ad"),e.k0s(),e.j41(23,"span",32),e.EFF(24),e.k0s()()(),e.j41(25,"div",33)(26,"span",34),e.EFF(27,"Sorry! We couldn\u2019t find any ad right now. Try again later."),e.k0s()()()()}if(2&s){const n=e.XpG();e.R7$(18),e.Lme("",null==n.aiCoinPrice?null:n.aiCoinPrice.aiPurchaseCredits," AI Credits @ ",e.ii3(19,5,(null==n.aiCoinPrice?null:n.aiCoinPrice.unitAmount)/100,null==n.aiCoinPrice||null==n.aiCoinPrice.currency?null:n.aiCoinPrice.currency.toUpperCase(),"symbol","1.0-2"),""),e.R7$(2),e.Y8G("disabled",!(null!=n.aiGenService&&n.aiGenService.rewardLoaded)),e.R7$(4),e.SpI("Get ",n.freeCredis," AI Credits for Free"),e.R7$(),e.Y8G("ngClass",e.eq3(10,qt,null==n.aiGenService?null:n.aiGenService.rewardLoaded))}}let pe=(()=>{var s;class a{constructor(t,i,o,r,l){this.authService=t,this.envService=i,this.aiGenService=o,this.paymentService=r,this.subsService=l,this.close=new e.bkB,this.addCredit=new e.bkB,this.crText="",this.msg="",this.consumeCoins=1,this.freeCredis=5,this.proUser=!1,this.step=1,this.isTrialCreditCap=!1,this.isInTrialPeriod=!1,this.updateBehaviorUserAiConis=this.authService.updateBehaviorUserAiConis.subscribe(c=>{this.close.emit()}),this.isTrialCreditCap=!0}upgradePlanDirectPayment(){this.close.emit();let t=this.paymentService?.config?.aiSubscriptionCredits;this.subsService.upgradePlanDirectPayment({isDirectPayment:!0,aiSubscriptionCredits:t})}ngOnInit(){this.authService.currentUser(),setTimeout(()=>{this.getAiPrice()},500);let i=this.authService.getSubscription();this.isInTrialPeriod=i?.upgrade}addAICredit(){this.addCredit.emit()}watchAds(){this.aiGenService.makeRewardedVisible()}
1getAiPrice(){const t=this.paymentService?.config;this.freeCredis=t?.aiDailyFreeCredits||this.freeCredis;let i=this.paymentService?._products?.filter(o=>o.recurring&&"one_time"===o.recurring?.interval||!o.recurring&&"one_time"===o.type);if(i&&i.length){this.aiCoinPrice=i[0];let o=t.creditProducts.filter(r=>this.aiCoinPrice.product===r.skuId);this.aiCoinPrice.aiPurchaseCredits=o&&o.length?o[0].aiPurchaseCredits:0}}ngOnDestroy(){this.updateBehaviorUserAiConis&&this.updateBehaviorUserAiConis.unsubscribe()}}return(s=a).\u0275fac=function(t){return new(t||s)(e.rXU(q.u),e.rXU(xe.L),e.rXU(J.K),e.rXU(de.W),e.rXU(ue.n))},s.\u0275cmp=e.VBU({type:s,selectors:[["add-credit"]],inputs:{consumeCoins:"consumeCoins"},outputs:{close:"close",addCredit:"addCredit"},decls:3,vars:2,consts:[[1,"showpreview-overlay","align-items-center","justify-content-start","position-fixed","d-flex","for-expand-overlay",3,"click"],["class","p-3 pt-9 pb-2 position-fixed bg-white w-100 for-expand","style","bottom: 0px; z-index: 3;border-radius: 20px 20px 0px 0px;",4,"ngIf"],["class","position-fixed w-100 insufficient-section","style","bottom: 0px; z-index: 1002;",4,"ngIf"],[1,"p-3","pt-9","pb-2","position-fixed","bg-white","w-100","for-expand",2,"bottom","0px","z-index","3","border-radius","20px 20px 0px 0px"],[1,"d-flex","align-items-center","justify-content-start","w-100","mt-2"],[1,"d-inline-flex","align-items-center","justify-content-center","icon-box","border-radius-12","me-3"],["src","https://static.lightxeditor.com/assets/images/coin-new.png","height","24px","width","24px"],[1,"d-inline-flex","align-items-start","justify-content-center","flex-column"],[1,"text-lg","grey-800","text-semi","m-0"],[1,"text-13","grey-500","text-regular","mt-1"],[1,"d-flex","align-items-center","justify-content-center","w-100","flex-column","mt-10"],[1,"btn","btn-primary","text-lg","btn-h48","w-100","d-flex","align-items-center","justify-content-center","w-100"],[1,"btn","btn-light","btn-delete","btn-link","btn-h48","text-lg","pl-12","pr-12","d-flex","align-items-center","justify-content-center","w-100","mt-2",3,"click"],["name","infoiconnew","ngbTooltip","Get 20 AI Credits/day during trial period. Get full credits access anytime.","tooltipClass","tooltip-custom-all full-width-mob",1,"ms-1","hw-20","help-icon","f-20","grey-800"],["name","infoiconnew","placement","right","popoverClass","pop-for-tooltip promotion","ngbPopover","Get 20 AI Credits/day during trial period. Get full credits access anytime.","triggers","mouseenter:mouseleave","container","body",1,"ms-1","hw-20","help-icon","f-20","grey-800","position-absolute"],[1,"btn","btn-primary","text-lg","btn-h48","w-100","d-flex","align-items-center","justify-content-center","w-100",3,"click"],[1,"position-fixed","w-100","insufficient-section",2,"bottom","0px","z-index","1002"],[1,"d-flex","align-items-center","justify-content-center","w-100","flex-column","h-100"],[1,"modal-header","border-0","p-0","position-absolute","ads-close"],["type","button","aria-hidden","close",1,"close"],["name","adsclose"],[1,"d-flex","align-items-center","justify-content-center","w-100","flex-column"],[1,"d-flex","align-items-center","justify-content-center","icon-box-large"],["src","https://static.lightxeditor.com/assets/images/coin-lottie-l-anim.gif","height","72px","width","72px"],[1,"d-flex","align-items-center","justify-content-center","flex-column","w-100","mt-3"],[1,"text-xxl","grey-800","text-semi","m-0"],[1,"text-14","grey-800","text-regular","mt-2"],[1,"btn","btn-primary","text-lg","btn-h48","w-100","d-flex","align-items-center","justify-content-center","w-100","flex-column",2,"height","75px","padding","14.5px 24px",3,"click"],[2,"line-height","120%"],[1,"text-white","text-semi","mt-8",2,"opacity","0.8","font-size","12px"],[1,"btn","btn-outline-primary","text-lg","btn-h48","w-100","d-flex","align-items-center","justify-content-center","w-100","flex-column","mt-2","watch-ads",2,"height","68px","padding","12px 24px",3,"click","disabled"],[1,"grey-800",2,"line-height","120%"],[1,"text-semi","mt-8","text-gradient",2,"font-size","12px"],[1,"d-flex","align-items-center","justify-content-center","error-msg",3,"ngClass"],[1,"text-semi","text-white","text-center"]],template:function(t,i){1&t&&(e.j41(0,"div",0),e.bIt("click",function(){return i.close.emit()}),e.k0s(),e.DNE(1,ti,15,2,"div",1)(2,ii,28,12,"div",2)),2&t&&(e.R7$(),e.Y8G("ngIf",1==i.step),e.R7$(),e.Y8G("ngIf",2==i.step))},dependencies:[b.YU,b.bT,H.b,R.ZM,b.oe],styles:[".icon-box[_ngcontent-%COMP%]{background:#626adf0d;height:44px;width:44px}.showpreview-overlay[_ngcontent-%COMP%]{display:block;background:#0003;-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);width:100%;height:100%;top:0;bottom:0;z-index:2}
1.icon-box-large[_ngcontent-%COMP%]{background:linear-gradient(90deg,#fc5cff0d -4%,#2520f60d);height:92px;width:92px;border-radius:20px}.insufficient-section[_ngcontent-%COMP%]{background:#ffffffe6;-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);padding:24px;height:100vh}.error-msg[_ngcontent-%COMP%]{border-radius:360px;background:#4a4f5ecc;padding:11px 16px;height:56px;max-width:270px;position:fixed;bottom:48px}.error-msg[_ngcontent-%COMP%]   span[_ngcontent-%COMP%]{font-size:12px}.text-gradient[_ngcontent-%COMP%]{background:linear-gradient(273deg,#626adf,#a64dff);background-clip:text;-webkit-background-clip:text;-webkit-text-fill-color:transparent}.btn-outline-primary.watch-ads[_ngcontent-%COMP%]:disabled{background:#626adf0d!important;color:#e2e3e9!important;border:1px solid #D5D6DD!important}.btn-outline-primary.watch-ads[_ngcontent-%COMP%]:disabled   span[_ngcontent-%COMP%]{color:#c9cad4!important}.btn-outline-primary.watch-ads[_ngcontent-%COMP%]:disabled   .text-gradient[_ngcontent-%COMP%]{-webkit-text-fill-color:#C9CAD4!important}.ads-close[_ngcontent-%COMP%]{top:24px;right:24px;height:40px;width:40px;z-index:9}.ads-close[_ngcontent-%COMP%]   .close[_ngcontent-%COMP%]{top:0!important;position:relative!important;right:0!important;margin:0!important;background:transparent}"]}),a})();const ni=["cpText"],oi=s=>({"align-items-end":s}),si=s=>({height:s}),ri=s=>({"text-edit-mode":s}),ai=()=>({height:"calc(100% - 340px)"}),li=(s,a)=>({"edit-height":s,"edit-height-keyboard":a}),ci=(s,a,n)=>({"textarea-col-focused":s,"info-red":a,"textarea-height":n}),di=s=>({grayscale:s}),dt=(s,a,n,t)=>({top:s,left:a,width:n,height:t}),hi=(s,a)=>({"show ":s,"active-mask":a}),pi=s=>({item:s}),mi=s=>({"show ":s}),He=s=>({"btn-bottom-active":s}),We=s=>({"disable-btn pe-none":s});function ui(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",34),e.bIt("click",function(i){return e.eBV(n),e.Njj(i.stopPropagation())}),e.j41(1,"div",35),e.bIt("click",function(i){const o=e.eBV(n).item;e.XpG();const r=e.sdS(1),l=e.XpG(3);return l.editBox(i,o),e.Njj(l.togglePopover(r,!1,o))}),e.j41(2,"div",36),e.nrm(3,"pi",37),e.j41(4,"span",38),e.EFF(5,"Replace Text"),e.k0s()(),e.j41(6,"div",39)(7,"span",40),e.nrm(8,"img",41),e.EFF(9),e.k0s()()(),e.j41(10,"div",35),e.bIt("click",function(i){const o=e.eBV(n).item;e.XpG();const r=e.sdS(1),l=e.XpG(3);return l.deleteBox(i,o),e.Njj(l.togglePopover(r,!1,o))}),e.j41(11,"div",36),e.nrm(12,"pi",42),e.j41(13,"span",38),e.EFF(14,"Remove Text"),e.k0s()(),e.j41(15,"div",39)(16,"span",40),e.nrm(17,"img",41),e.EFF(18),e.k0s()()()()}if(2&s){const n=e.XpG(4);e.R7$(9),e.JRh(null==n.config?null:n.config.design_edit),e.R7$(9),e.JRh(null==n.config?null:n.config.design_edit)}}function gi(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",33,1),e.bIt("click",function(i){const o=e.eBV(n).$implicit,r=e.sdS(1);return e.XpG(3).togglePopover(r,!0,o),e.Njj(i.stopPropagation())}),e.DNE(2,ui,19,2,"ng-template",null,2,e.C5r),e.k0s()}if(2&s){const n=a.$implicit,t=e.sdS(3),i=e.XpG(3);e.Y8G("hidden",i.editedItem)("ngStyle",e.ziG(6,dt,n.rect.top,n.rect.left,n.rect.width,n.rect.height))("ngClass",e.l_i(11,hi,(null==n?null:n.label)==(null==i.editedItem?null:i.editedItem.label),null==i.editedItem?null:i.editedItem.isKeyPressed))("ngbPopover",t)("popoverContext",e.eq3(14,pi,n))("autoClose","outside")}}function _i(s,a){if(1&s&&e.nrm(0,"div",43),2&s){const n=a.$implicit,t=e.XpG(3);e.Y8G("hidden",!t.editedItem)("ngStyle",e.ziG(3,dt,n.rect.top,n.rect.left,n.rect.width,n.rect.height))("ngClass",e.eq3(8,mi,(null==n?null:n.label)==(null==t.editedItem?null:t.editedItem.label)))}}function fi(s,a){if(1&s&&(e.qex(0),e.DNE(1,gi,4,16,"div",31)(2,_i,1,10,"div",32),e.bVm()),2&s){const n=e.XpG(2);e.R7$(),e.Y8G("ngForOf",n.imgTexts),e.R7$(),e.Y8G("ngForOf",n.imgTexts)}}function vi(s,a){if(1&s&&(e.j41(0,"div",28),e.nrm(1,"img",29)(2,"img",30),e.DNE(3,fi,3,2,"ng-container",27),e.k0s()),2&s){const n=e.XpG();e.R7$(),e.Y8G("src",null==n.aiPhotoService?null:n.aiPhotoService.inspirationImgUrl,e.B4B)("ngClass",n.isCompare?"d-none":"displayblock"),e.R7$(),e.Y8G("src",null==n.aiPhotoService?null:n.aiPhotoService.compareImageUrl,e.B4B)("ngClass",n.isCompare?"displayblock":"d-none"),e.R7$(),e.Y8G("ngIf",n.imgTexts)}}function bi(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",44),e.bIt("click",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.download(i))}),e.nrm(1,"pi",45),e.k0s()}}function Ci(s,a){if(1&s){const n=e.RV6();e.j41(0,"button",51),e.bIt("touchend",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.isCompare=!1)})("touchend",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.isCompare=!1)})("mouseup",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.isCompare=!1)})("mouseout",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.isCompare=!1)})("touchstart",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.isCompare=!0)})("mousedown",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.isCompare=!0)}),e.nrm(1,"pi",52),e.k0s()}if(2&s){const n=e.XpG(2);e.Y8G("ngClass",e.eq3(1,He,n.isCompare))}}function xi(s,a){if(1&s&&(e.j41(0,"button",53),e.nrm(1,"pi",54),e.k0s()),2&s){const n=e.XpG(2);e.Y8G("ngClass",e.eq3(1,We,!(n.aiPhotoService.isCompareEnable&&n.und
1oable&&n.undoable)))}}function Pi(s,a){if(1&s&&(e.j41(0,"button",53),e.nrm(1,"pi",55),e.k0s()),2&s){const n=e.XpG(2);e.Y8G("ngClass",e.eq3(1,We,!n.undoable))}}function Ii(s,a){if(1&s){const n=e.RV6();e.j41(0,"button",56),e.bIt("click",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.undo())})("mousedown",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.isButtonFocusedundo=!0)})("mouseup",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.mouseupundo())}),e.nrm(1,"pi",57),e.k0s()}if(2&s){const n=e.XpG(2);e.Y8G("ngClass",e.eq3(1,He,n.isButtonFocusedundo))}}function yi(s,a){if(1&s&&(e.j41(0,"button",53),e.nrm(1,"pi",58),e.k0s()),2&s){const n=e.XpG(2);e.Y8G("ngClass",e.eq3(1,We,!n.redoable))}}function wi(s,a){if(1&s){const n=e.RV6();e.j41(0,"button",59),e.bIt("click",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.redo())})("mousedown",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.isButtonFocusedredo=!0)})("mouseup",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.mouseupredo())}),e.nrm(1,"pi",60),e.k0s()}if(2&s){const n=e.XpG(2);e.Y8G("ngClass",e.eq3(1,He,n.isButtonFocusedredo))}}function Si(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",46),e.bIt("click",function(i){return e.eBV(n),e.Njj(i.stopPropagation())}),e.DNE(1,Ci,2,3,"button",47)(2,xi,2,3,"button",48)(3,Pi,2,3,"button",48)(4,Ii,2,3,"button",49)(5,yi,2,3,"button",48)(6,wi,2,3,"button",50),e.k0s()}if(2&s){const n=e.XpG();e.R7$(),e.Y8G("ngIf",n.aiPhotoService.isCompareEnable&&n.undoable),e.R7$(),e.Y8G("ngIf",!n.aiPhotoService.isCompareEnable||!n.undoable),e.R7$(),e.Y8G("ngIf",!n.undoable),e.R7$(),e.Y8G("ngIf",n.undoable),e.R7$(),e.Y8G("ngIf",!n.redoable),e.R7$(),e.Y8G("ngIf",n.redoable)}}function Mi(s,a){if(1&s&&(e.j41(0,"span",61),e.EFF(1),e.k0s()),2&s){const n=e.XpG();e.R7$(),e.SpI("",n.aiPhotoService.InspirationTextPrompt.length,"/450")}}function ki(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",64)(1,"div",65),e.bIt("click",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.selectInspiration("Change"))}),e.EFF(2," Change..."),e.k0s(),e.j41(3,"div",66),e.bIt("click",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.selectInspiration("Add"))}),e.EFF(4,"Add... "),e.k0s(),e.j41(5,"div",66),e.bIt("click",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.selectInspiration("Replace"))}),e.EFF(6," Replace..."),e.k0s()()}}function Ti(s,a){if(1&s&&(e.j41(0,"div",62),e.DNE(1,ki,7,0,"div",63),e.k0s()),2&s){const n=e.XpG();e.R7$(),e.Y8G("ngIf",!n.aiPhotoService.inProgress)}}function Oi(s,a){1&s&&(e.j41(0,"div",67)(1,"span",68),e.EFF(2,"Loading..."),e.k0s()())}function Ei(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",69),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return i.pageClick(),e.Njj(i.isTextEdit=!1)}),e.k0s()}}function ji(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"add-credit",70),e.bIt("close",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.addCredit=!1)})("addCredit",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.addCredits())}),e.k0s(),e.bVm()}if(2&s){const n=e.XpG();e.R7$(),e.Y8G("consumeCoins",null==n.config?null:n.config.design_edit)}}let qe=(()=>{var s;class a{constructor(t,i,o,r,l,c,d,h,p,u,g,_){this.aiGenService=t,this.dialogService=i,this.activeModal=o,this.paymentService=r,this.authService=l,this.subsService=c,this.envService=d,this.createPopupService=h,this.cdr=p,this.downloadService=u,this.toastService=g,this.offcanvasService=_,this.initialViewportHeight=window.visualViewport?.height||window.innerHeight,this.keyBoardCalcHeight=0,this.keyboardHeight=0,this.keyboardVisible=!1,this.step=1,this.changeStep=new e.bkB,this.isFocused=!1,this.isButtonFocusedundo=!1,this.isButtonFocusedredo=!1,this.isCompare=!1,this.activeToolPanel="aidesign",this.returnStep=1,this.inProgress=!1,this.stateHistory=[],this.currentStateIndex=0,this.editedItem=null,this.isTextEdit=!1,this.isLoaded=!1,this.isShowPreview=!1,this.addCredit=!1,this.credit=1,this.user=this.authService.currentUser(),this.loggedInObserver=this.authService.loggedIn.subscribe(v=>{this.user=this.authService.currentUser()}),this.usrPropChangedObserver=this.authService.usrPropChanged.subscribe(v=>{this.user=this.authService.currentUser()})}ngOnInit(){this.setimagewidth(),this.aiPhotoService.InspirationTextPrompt="",this.activeImgObj.imageJson?this.activeImgObj.prompt=this.activeImgObj.imageJson:this.activeImgObj.prompt&&(this.activeImgObj.prompt=this.activeImgObj.prompt),this.stateHistory.push(this.activeImgObj),setTimeout(()=>{this.config=this.paymentService.config?.creditInfo,this.isLoaded=!0}
1,300),window.visualViewport&&(this.initialViewportHeight=window.visualViewport.height)}setimagewidth(){this.loadImage(this.activeImgObj.imgUrl).then(t=>{this.activeImgObj.width=t.width,this.activeImgObj.height=t.height,this.getJsonDataByOcrUrl(this.activeImgObj?.ocrUrl,()=>{this.aiPhotoService.inProgress=!1,this.activeImgObj.ocrUrl||this.detectCaption(this.activeImgObj.imgUrl)})})}loadImage(t){return new Promise((i,o)=>{let r=new Image;r.onload=()=>i(r),r.onerror=o,r.crossOrigin="anonymous",r.src=t})}get undoable(){let t=!1;return this.currentStateIndex>0&&(t=!0),t}get redoable(){let t=!1;return this.currentStateIndex<this.stateHistory.length-1&&(t=!0),t}undo(){this.currentStateIndex>0&&(this.currentStateIndex--,this.restoreState())}redo(){this.currentStateIndex<this.stateHistory.length-1&&(this.currentStateIndex++,this.restoreState())}restoreState(){this.activeImgObj=this.stateHistory[this.currentStateIndex],this.activeImgObj&&setTimeout(()=>{this.aiPhotoService.inspirationImgUrl=this.activeImgObj.imgUrl,this.cdr.detectChanges(),this.getJsonDataByOcrUrl(this.activeImgObj?.ocrUrl,()=>{this.aiPhotoService.inProgress=!1,this.captionData&&!this.activeImgObj.ocrUrl&&(this.imgTexts=this.getData(this.captionData))})},0)}mouseupundo(){setTimeout(()=>{this.isButtonFocusedundo=!1})}mouseupredo(){setTimeout(()=>{this.isButtonFocusedredo=!1})}selectInspiration(t){this.aiPhotoService.InspirationTextPrompt=t}getCredits(){this.aiPhotoService.openAICreditPopup()}addCredits(){this.addCredit=!1,this.subsService.upgradeAiPlanCheckout("","",this.activeTool)}generate(){if(this.user=this.authService.currentUser(),this.aiPhotoService.inProgress)return;if(!this.activeImgObj.imgUrl)return void this.displayErrorMsg("Image Url not Found");const t=this.aiPhotoService.InspirationTextPrompt;if((!t||0!=t.trim().length||"Delete"==this.editedItem.edit)&&this.activeImgObj)if(this.user&&this.user.remainingCoins>=this.config.design_edit){let i=this.aiPhotoService.selectedGuidance.height,o=this.aiPhotoService.selectedGuidance.width;this.aiPhotoService.startGenerationProgress({featureType:f.Fs.Design});const r={featureType:f.Fs.Design,designPrompt:this.aiPhotoService.InspirationTextPrompt?this.aiPhotoService.InspirationTextPrompt:"desigh",...this.activeImgObj.imgUrl&&{imageUrl:this.activeImgObj.imgUrl},...this.editedItem&&{editCoord:this.editedItem.editCoord},...this.editedItem&&"Delete"==this.editedItem.edit&&{designPrompt:"Remove text '"+this.editedItem.label+"'"},...this.editedItem&&"Edit"==this.editedItem.edit&&{designPrompt:"Change text '"+this.editedItem.label+"' to '"+this.aiPhotoService.InspirationTextPrompt+"'"}};this.aiPhotoService.generateImage(r,l=>{l&&l.assetId?(l.toolPrompt=this.activeImgObj.textPrompt||"",l.width=o,l.height=i,l.featureType=f.Fs.Design,l.toolName=y.b.label.aiDesign,l.activeSubTool=f.do.aidesign,l.selectedStyle=this.activeImgObj.displayName,this.aiPhotoService.checkStatusResponsive(l,0,d=>{(this.aiPhotoService.processingProgress.isActive||this.aiPhotoService.inProgress||this.aiPhotoService.inVideoProgress)&&(d&&d.urls&&d.urls.length>0?this.aiPhotoService.completeGenerationProgress(()=>{this.aiPhotoService.inspirationImgUrl="",setTimeout(()=>{this.aiPhotoService.inspirationImgUrl=d.urls[0],this.cdr.detectChanges(),this.currentStateIndex=this.stateHistory.length-1,this.aiPhotoService.isCompareEnable=!0},0),d.selectedTool=f.Fs.Design,this.aiPhotoService.seed=d.seed,this.user.remainingCoins=d.remainingCalls,this.aiPhotoService.isDirty=!0,this.stateHistory.push(d),this.activeImgObj=d,this.activeImgObj.isGenerated=!0,this.editedItem=null,this.aiPhotoService.generateImageFn({assetId:d?.assetId}),setTimeout(()=>{d&&d.urls&&d.urls.length>0&&this.getJsonDataByOcrUrl(this.activeImgObj?.ocrUrl),this.keyboardVisible=!1,this.step=1},300)}):(this.aiPhotoService.clearGenerationProgress(),this.keyboardVisible=!1,this.step=1))},d=>{this.displayErrorMsg(d)})):this.displayErrorMsg(l)},l=>{this.displayErrorMsg(l)})}else setTimeout(()=>{let i=null;this.editedItem&&"Delete"==this.editedItem.edit&&(i=JSON.parse(JSON.stringify(this.editedItem)),this.editedItem=null,this.aiPhotoService.InspirationTextPrompt="",this.onFocusOut()),this.aiPhotoService.loginAndAICredit(o=>{if(i&&!this.editedItem&&(this.editedItem=i),this.user=this.authService.currentUser(),this.user){if(!this.user.remainingCoins||this.user.remainingCoins<this.config.design_edit)return void(this.addCredit=!0);this.addCredit=!1,this.generate()}})},0)}displayErrorMsg(t=null){this.aiPhotoService.clearGenerationProgress();let i=t?.description;this.createPopupService.openWarningDialog("Error",i)}download(t){t.stopPropagation();let i=this.activeImgObj;i.selectedTool=f.Fs.Design;let o=i.imgUrl?i.imgUrl:i.urls[0];o&&this.aiPhotoService.downloadImg(o,()=>{localStorage.getItem("isChecked")||this.downloadService.downloadMsgPopup({msg:y.b.message.download,imgUrl:o})})}onFocusIn(){this.isFocused=!0,this.keyboardVisible=!0}onFocusOut(){this.isFocused=!1,this.cpText?.nativeElement.blur(),setTimeout(()=>{this.editedItem||(this.keyboardVisible=!1)},200)}closeOnEnter(t){this.aiPhotoService.InspirationTextPrompt="",this.editedItem=null,this.keyboardVisible=!1,this.cpText.nativeElement.blur()}
1onViewportResize(){if(!window.visualViewport)return;if(this.keyBoardCalcHeight>0)return void(this.keyboardHeight=this.keyBoardCalcHeight);let t=window.visualViewport.height;t<this.initialViewportHeight&&(this.keyboardHeight=this.initialViewportHeight-t,this.keyBoardCalcHeight=this.keyboardHeight)}getJsonDataByOcrUrl(t,i=null){t?this.aiPhotoService.getJsonDataByOcrUrl(t,o=>{o&&o.labels?setTimeout(()=>{this.imgTexts=this.getData(o),i&&i(o)},1e3):i&&i(o)},o=>{i&&i(o)}):i&&i(null)}detectCaption(t){this.inProgress=!0,this.aiPhotoService.detectCaption({imageUrl:t},i=>{this.inProgress=!1,i&&i?.body?.output&&(this.captionData=i.body.output,setTimeout(()=>{this.imgTexts=this.getData(i.body.output)},1e3))},i=>{this.inProgress=!1,this.aiPhotoService.inProgress=!1,this.toastService.showError(i?.description||y.b.message.somethingWrong)})}getData(t){const i=document.getElementById("inspirationImgUrl");if(!i)return[];const o=i.naturalWidth,r=i.naturalHeight,l=i.getBoundingClientRect(),c=l.width,d=l.height;return o&&r&&c&&d?t.quad_boxes.map((h,p)=>{const u=t.labels?.[p]||"",g=[],_=[],v=c/o,C=d/r;for(let B=0;B<h.length;B+=2)g.push(h[B]*v),_.push(h[B+1]*C);const M=Math.min(...g),k=Math.min(..._),j=Math.max(...g),G=Math.max(..._);return{points:h,editCoord:`${h[0]},${h[1]}|${h[2]},${h[3]}|${h[4]},${h[5]}|${h[6]},${h[7]}`,label:u,rect:{left:M/c*100+"%",top:k/d*100+"%",width:(j-M)/c*100+"%",height:(G-k)/d*100+"%"}}}):(console.warn("Image sizes not ready yet"),[])}editBox(t,i){t.stopPropagation(),this.editedItem||(this.editedItem=i),this.editedItem.edit="Edit",this.aiPhotoService.InspirationTextPrompt=i.label,this.onFocusIn(),setTimeout(()=>{this.cpText?.nativeElement?.focus(),this.cpText?.nativeElement?.select()},100)}deleteBox(t,i){t.stopPropagation(),this.editedItem||(this.editedItem=i),this.editedItem.edit="Delete",this.aiPhotoService.InspirationTextPrompt="",this.generate()}pageClick(){this.aiPhotoService.inProgress||this.editedItem&&(this.editedItem=null,this.isTextEdit=!1,this.aiPhotoService.InspirationTextPrompt="",this.keyboardVisible=!1)}togglePopover(t,i,o){this.popovers&&this.popovers.length&&this.popovers.forEach(r=>{r!==t&&r.close()}),i?(t.isOpen()?(t.close(),setTimeout(()=>{t.open()},50)):t.open(),this.isTextEdit=!0):(t.close(),this.isTextEdit=!1)}ngOnDestroy(){this.loggedInObserver&&this.loggedInObserver.unsubscribe(),this.usrPropChangedObserver&&this.usrPropChangedObserver.unsubscribe(),this.aiPhotoService.clearGenerationProgress()}close(){this.editedItem=null,this.activeImgObj=null;const t=this.aiPhotoService?.queryParams?.from;this.aiPhotoService.queryParams=Object.assign({},this.aiPhotoService.queryParams),this.stateHistory&&this.stateHistory.length<=1&&("ai-generations"==t||"ai-inspiration"==t||"story"==t)?this.changeStep.emit({back:!0,isUpload:!!this.aiPhotoService.queryParams?.isUpload&&this.aiPhotoService.queryParams?.isUpload}):(this.aiPhotoService?.queryParams?.from&&(this.aiPhotoService.queryParams.from="tools"),this.aiPhotoService.aiImages.length>1&&(this.aiPhotoService.mobileImageObj=this.aiPhotoService.aiImages[this.aiPhotoService.aiImages.length-1]),this.aiPhotoService.queryParams.isEd=!0,this.changeStep.emit(this.returnStep))}}return(s=a).\u0275fac=function(t){return new(t||s)(e.rXU(J.K),e.rXU(ae.g),e.rXU(R.Lw),e.rXU(de.W),e.rXU(q.u),e.rXU(ue.n),e.rXU(xe.L),e.rXU(ne.A),e.rXU(e.gRc),e.rXU(ze.s),e.rXU(Q.f),e.rXU(R.RS))},s.\u0275cmp=e.VBU({type:s,selectors:[["inspirations-edit-mobile"]],viewQuery:function(t,i){if(1&t&&(e.GBs(ni,5),e.GBs(R.ZM,5)),2&t){let o;e.mGM(o=e.lsd())&&(i.cpText=o.first),e.mGM(o=e.lsd())&&(i.popovers=o)}},hostBindings:function(t,i){1&t&&e.bIt("resize",function(){return i.onViewportResize()},!1,e.tSv)},inputs:{activeTool:"activeTool",activeToolPanel:"activeToolPanel",aiPhotoService:"aiPhotoService",activeImgObj:"activeImgObj",returnStep:"returnStep"},outputs:{changeStep:"changeStep"},decls:32,vars:39,consts:[["cpText",""],["popover","ngbPopover"],["popTemplate",""],[1,"popup-backdrop",3,"ngClass"],[1,"inspirations-edit-mobile","w-100","bg-white","p-3","pb-0",3,"ngStyle"],[1,"d-flex","align-items-center","justify-content-between","mb-3"],[1,"text-lg","text-semi","text-dark"],["name","previewclose",3,"click","hidden"],[1,"h-100",3,"click","ngClass"],[1,"d-flex","w-100","flex-column","position-relative","h-100"],[1,"d-flex","position-relative","align-items-center","justify-content-center","overflow-hidden","w-100","flex-column","border-radius-12","bg-grey3","aiDesignMobile",3,"ngStyle","ngClass"],["class","d-flex align-items-start justify-content-center overflow-hidden position-relative",4,"ngIf"],["class","d-flex align-items-center justify-content-center position-absolute hw-40 border-radius-50 btn-alpha","style","top: 8px; right: 8px;",3,"click",4,"ngIf"],["class","d-flex justify-content-center mt-3",3,"click",4,"ngIf"],[1,"d-flex","flex-column","justify-content-start","overflow-hidden","w-100","align-items-center","text-area-wrapper",3,"click"],[1,"flex-column","textarea-col","prompt-view","w-100","mt-3",3,"ngClass"],["
1id","cpText","placeholder","Describe your change in image","rows","1",1,"w-100",3,"ngModelChange","focus","keydown.enter","focusout","ngModel","maxlength"],["class","prompt-info text-regular position-relative d-flex align-items-center","style","min-height: 24px; margin-left: 12px;",4,"ngIf"],["class","mt-3 w-100","style","height: 30px;",4,"ngIf"],[1,"d-flex","justify-content-center","w-100","mt-3"],["id","gtm-generate-mob",1,"btn","btn-primary-gradient","text-13","btn-h44","w-100","d-flex","align-items-center","justify-content-center","border-0",3,"click","ngClass"],["class","spinner-border spinner-border-lg me-2 hw-24","role","status",4,"ngIf"],[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",3,"ngClass"],[1,"text-11","text-semi",2,"padding-left","2px"],["class","position-fixed text-edit-overlay",3,"click",4,"ngIf"],[4,"ngIf"],[1,"d-flex","align-items-start","justify-content-center","overflow-hidden","position-relative"],["id","inspirationImgUrl","height","",1,"image-compare","responsive",3,"src","ngClass"],["height","",1,"image-compare","responsive",3,"src","ngClass"],["class","highlight-box","container","body","triggers","manual","placement","auto","popoverClass","popover-text-edit",3,"hidden","ngStyle","ngClass","ngbPopover","popoverContext","autoClose","click",4,"ngFor","ngForOf"],["class","highlight-box-edit",3,"hidden","ngStyle","ngClass",4,"ngFor","ngForOf"],["container","body","triggers","manual","placement","auto","popoverClass","popover-text-edit",1,"highlight-box",3,"click","hidden","ngStyle","ngClass","ngbPopover","popoverContext","autoClose"],[1,"d-flex","align-items-center","justify-content-start","flex-column",3,"click"],[1,"btn-upscale","ps-1","pe-2","d-flex","align-items-center","justify-content-between","w-100",2,"height","40px",3,"click"],[1,"d-inline-flex",2,"height","24px"],["name","replace",1,"f-24","me-2","grey-600"],[1,"grey-800","text-semi","scale-text","text-lg","lh-160"],[1,"coin-box","d-inline-flex"],[1,"coin-item","text-semi","d-flex","align-items-center","justify-content-center"],["height","20px","width","20px","src","https://static.lightxeditor.com/assets/images/coin-new.png",1,"coin-active"],["name","deleteaction",1,"f-24","me-2","grey-600"],[1,"highlight-box-edit",3,"hidden","ngStyle","ngClass"],[1,"d-flex","align-items-center","justify-content-center","position-absolute","hw-40","border-radius-50","btn-alpha",2,"top","8px","right","8px",3,"click"],["name","downloadblack",1,"f-24","text-white"],[1,"d-flex","justify-content-center","mt-3",3,"click"],["class","btn-all btn-bottom mr-8","color","primary","placement","top","ngbTooltip","Compare","tooltipClass","tooltip-custom-all",3,"ngClass","touchend","mouseup","mouseout","touchstart","mousedown",4,"ngIf"],["class","btn-all btn-bottom mr-8","color","primary","placement","bottom",3,"ngClass",4,"ngIf"],["class","btn-all btn-bottom mr-8","color","primary","placement","top","ngbTooltip","Undo","tooltipClass","tooltip-custom-all",3,"ngClass","click","mousedown","mouseup",4,"ngIf"],["class","btn-all btn-bottom mr-8","color","primary","placement","top","ngbTooltip","Redo","tooltipClass","tooltip-custom-all",3,"ngClass","click","mousedown","mouseup",4,"ngIf"],["color","primary","placement","top","ngbTooltip","Compare","tooltipClass","tooltip-custom-all",1,"btn-all","btn-bottom","mr-8",3,"touchend","mouseup","mouseout","touchstart","mousedown","ngClass"],["name","compareactive",1,"f-24","grey-800"],["color","primary","placement","bottom",1,"btn-all","btn-bottom","mr-8",3,"ngClass"],["name","compare",1,"f-24"],["name","undo",1,"f-24",2,"color","#B0B3BF","opacity","0.3"],["color","primary","placement","top","ngbTooltip","Undo","tooltipClass","tooltip-custom-all",1,"btn-all","btn-bottom","mr-8",3,"click","mousedown","mouseup","ngClass"],["name","undoactive",1,"f-24"],["name","redo",1,"f-24",2,"color","#B0B3BF","opacity","0.3"],["color","primary","placement","top","ngbTooltip","Redo","tooltipClass","tooltip-custom-all",1,"btn-all","btn-bottom","mr-8",3,"click","mousedown","mouseup","ngClass"],["name","redoactive",1,"f-24"],[1,"prompt-info","text-regular","position-relative","d-flex","align-items-center",2,"min-height","24px","margin-left","12px"],[1,"mt-3","w-100",2,"height","30px"],["class","d-flex align-items-center justify-content-start",4,"ngIf"],[1,"d-flex","align-items-center","justify-content-start"],[1,"prompt-tab","text-primary",3,"click"],[1,"prompt-tab","text-primary","ms-2",3,"click"],["role","status",1,"spinner-border","spinner-border-lg","me-2","hw-24"],[1,"sr-only","text-nowrap","border-0","position-absolute","overflow-hidden"],[1,"position-fixed","text-edit-overlay",3,"click"],[3,"close","addCredit","consumeCoins"]],template:function(t,i){if(1&t){const o=e.RV6();e.j41(0,"div",3)(1,"div",4)(2,"div",5)(3,"div",6),e.EFF(4),e.k0s(),e.j41(5,"div")(6,"pi",7),e.bIt("click",function(){return e.eBV(o),e.Njj(i.close())}),e.k0s(),e.j41(7,"pi",7),e.bIt("click",function(l){return e.eBV(o),e.Njj(i.closeOnEnter(l))}),e.k0s()()(),e.j41(8,"div",8),e.bIt("click",function(){return e.eBV(o),e.Njj(i.pageClick())}),e.j41(9,"div",9)(10,"div",10),e.DNE(11,vi,4,5,"div",11)(12,bi,2,0,"div",12),e.k0s(),e.DNE(13,Si,7,6,"div",13),e.j41(14,"div",14),e.bIt("click",function(l){return e.eBV(o),e.Njj(l.stopPropagation())}),e.j41(15,"div",15)(16,"textarea",16,0),e.mxI("ngModelChange",function(l){return e.eBV(o),e.DH7(i.aiPhotoService.InspirationTextPrompt,l)||(i.aiPhotoService.InspirationTextPrompt=l),e.Njj(l)}),e.bIt("focus",function(){return e.eBV(o),e.Njj(i.onFocusIn())})("keydown.enter",function(l){return e.eBV(o),e.Njj(i.closeOnEnter(l))})("focusout",function(){return e.eBV(o),e.Njj(i.onFocusOut())}),e.EFF(18,"              "),e.k0s(),e.DNE(19,Mi,2,1,"span",17),e.k0s(),e.DNE(20,Ti,2,1,"div",18),e.j41(21,"div",19)(22,"button",20),e.bIt("click",function(){return e.eBV(o),e.Njj(i.generate())}),e.DNE(23,Oi,3,0,"div",21),e.j41(24,"span",22),e.EFF(25),e.k0s(),e.j41(26,"span",23),e.nrm(27,"img",24),e.j41(28,"b",25),e.EFF(29),e.k0s()()()()(),e.DNE(30,Ei,1,0,"div",26),e.k0s()()()(),e.DNE(31,ji,2,1,"ng-container",27)}2&t&&(e.Y8G("ngClass",e.eq3(23,oi,i.keyboardVisible)),e.R7$(),e.Y8G("ngStyle",e.eq3(25,si,i.keyboardVisible?"calc(100% - "+i.keyboardHeight+"px)":"100%")),e.R7$(3),e.JRh(i.keyboardVisible||i.editedItem?"Enter Prompt":"Change with AI"),e.R7$(2),e.Y8G("hidden",i.keyboardVisible),e.R7$(),e.Y8G("hidden",!i.keyboardVisible),e.R7$(),e.Y8G("ngClass",e.eq3(27,ri,i.keyboardVisible||i.editedItem)),e.R7$(2),e.Y8G("ngStyle",e.lJ4(29,ai))("ngClass",e.l_i(30,li,i.editedItem,i.keyboardVisible&&!i.editedItem)),e.R7$(),e.Y8G("ngIf",!i.aiPhotoService.inProgress),e.R7$(),e.Y8G("ngIf",!i.keyboardVisible),e.R7$(),e.Y8G("ngIf",!i.keyboardVisible),e.R7$(2),e.Y8G("ngClass",e.sMw(33,ci,i.isFocused,i.aiPhotoService.InspirationTextPrompt.length>449,i.editedItem)),e.R7$(),e.R50("ngModel",i.aiPhotoService.InspirationTextPrompt),e.Y8G("maxlength",i.editedItem?100:450),e.R7$(3),e.Y8G("ngIf",i.aiPhotoService.InspirationTextPrompt.length&&i.keyboardVisible&&!i.editedItem),e.R7$(),e.Y8G("ngIf",!i.editedItem),e.R7$(2),e.Y8G("ngClass",i.aiPhotoService.InspirationTextPrompt.length<1||0==i.aiPhotoService.InspirationTextPrompt.trim().length||i.aiPhotoService.inProgress?"btnDisabled pe-none":"btn-primary btn-primary-m pe-auto"),e.R7$(),e.Y8G("ngIf",i.aiPhotoService.inProgress),e.R7$(2),e.JRh(i.editedItem?"Replace Text":"Change with AI"),e.R7$(2),e.Y8G("ngClass",e.eq3(37,di,i.aiPhotoService.InspirationTextPrompt.length<1||0==i.aiPhotoService.InspirationTextPrompt.trim().length||i.aiPhotoService.inProgress)),e.R7$(2),e.JRh(null==i.config?null:i.config.design_edit),e.R7$(),e.Y8G("ngIf",i.isTextEdit),e.R7$(),e.Y8G("ngIf",i.addCredit))},dependencies:[P.me,P.BC,P.tU,P.vS,b.YU,b.Sq,b.bT,b.B3,H.b,R.ZM,pe],styles:[".popup-backdrop[_ngcontent-%COMP%]{position:fixed;top:0;left:0;width:100%;height:100%;-webkit-backdrop-filter:blur(5px);backdrop-filter:blur(5px);background-color:#0000004d;display:flex;align-items:center;justify-content:center;z-index:1;padding-top:20px}.inspirations-edit-mobile[_ngcontent-%COMP%]{border-radius:20px 20px 0 0}.prompt-tab[_ngcontent-%COMP%]{font-size:13px;padding:7px 12px;cursor:pointer;border-radius:16px;background:#626adf0d;box-shadow:inset 0 0 0 1px #626adf1a;line-height:120%}.auto-resize-textarea[_ngcontent-%COMP%]{display:flex;height:110px;border-radius:12px;background:#fff;-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);padding:8px 8px 8px 16px;border:1px solid #C9CAD4}.auto-resize-textarea[_ngcontent-%COMP%]:focus-visible{height:110px;border:1px solid transparent;border-radius:12px;background:linear-gradient(#fff,#fff) padding-box,linear-gradient(90deg,#fc5cff -4%,#2520f6) border-box;outline:none}.btn-bottom[_ngcontent-%COMP%]{width:40px;height:40px;padding:0rem;border-radius:12px;background:transparent}.btn-bottom[_ngcontent-%COMP%]:focus-visible{outline:none}.imageHw[_ngcontent-%COMP%]{max-height:100%;height:100%}.aiDesignMobile[_ngcontent-%COMP%]   img[_ngcontent-%COMP%]{overflow:hidden;object-fit:contain;max-width:100%;max-height:100%}.btn[_ngcontent-%COMP%]:disabled{background:#d5d6dd;border:1px solid #D5D6DD}.btn[_ngcontent-%COMP%]:disabled   .coin-count[_ngcontent-%COMP%]{background:#0000001a}.btn[_ngcontent-%COMP%]:disabled   .coin-count[_ngcontent-%COMP%]   b[_ngcontent-%COMP%]{color:#fff!important}.btn[_ngcontent-%COMP%]:disabled   .inable[_ngcontent-%COMP%]{display:none}.btn[_ngcontent-%COMP%]:disabled   .disable[_ngcontent-%COMP%]{display:block}.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}.coin-count[_ngcontent-%COMP%]   b[_ngcontent-%COMP%]{color:#fff!important}.downloadBtn[_ngcontent-%COMP%]{background:#4a4f5e66}.text-mask[_ngcontent-%COMP%]{border:1px solid #E2E3E9;background:#626adf0d;height:110px;padding:8px 12px}.textarea-col[_ngcontent-%COMP%]{height:110px;border:1.6px solid #C9CAD4;border-radius:12px;background:linear-gradient(90deg,#fc5cff05 -4%,#2520f605)}.textarea-col-focused[_ngcontent-%COMP%]{height:110px;border:1.6px solid transparent;border-radius:12px;background:linear-gradient(90deg,#fc5cff0d -4%,#2520f60d) padding-box,linear-gradient(#fff,#fff) padding-box,linear-gradient(90deg,#fc5cff -4%,#2520f6) border-box}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]{resize:none;outline:none;width:100%;height:76px;padding:8px 12px;font-size:13px;border:0px;background:transparent;border-radius:12px;line-height:18px;scrollbar-width:none}.prompt-text[_ngcontent-%COMP%]{color:#272b34!important}.prompt-info[_ngcontent-%COMP%]{font-size:11px;color:#626adf;line-height:140%}.inProgressScreen[_ngcontent-%COMP%]{border-radius:20px;background:#f8f9f903;-webkit-backdrop-filter:blur(60px);backdrop-filter:blur(60px);width:100%;height:100%;position:absolute;top:0}.btnDisabled[_ngcontent-%COMP%]{background:#dcdbe6!important;border-radius:12px;color:#fff!important}.btnDisabled[_ngcontent-%COMP%]   .btnCoin[_ngcontent-%COMP%]{background:#626adf0d;color:#c9cad4}.btnDisabled[_ngcontent-%COMP%]:active{color:#fff;background-color:#dcdbe6;border-color:transparent}.btnCoin[_ngcontent-%COMP%]{height:24px;border-radius:8px;background:#ffffff1a;padding:0 8px 0 4px}.grayscale[_ngcontent-%COMP%]{filter:grayscale(100%)}.info-up[_ngcontent-%COMP%]{border:1px solid #B0B3BF!important;background:#eeedf3!important}.info-blue[_ngcontent-%COMP%]{border:1px solid #626ADF!important;background:#626adf0d!important}.info-blue[_ngcontent-%COMP%]   span[_ngcontent-%COMP%]{color:#626adf!important}.info-red[_ngcontent-%COMP%]{border:1px solid #F25555!important;background:#626adf0d!important}.info-red[_ngcontent-%COMP%]   span[_ngcontent-%COMP%]{color:#f25555!important}.image-container[_ngcontent-%COMP%]{position:relative;display:inline-block;max-width:100%}.image-container[_ngcontent-%COMP%]   img[_ngcontent-%COMP%]{width:100%;height:auto;display:block}.highlight-box-edit[_ngcontent-%COMP%]{position:absolute;border:1px solid #A400F1;box-shadow:inset 0 0 0 .7px #efcfff;background:#c957ff33;cursor:pointer;box-sizing:border-box;z-index:1;opacity:0}
1.highlight-box-edit.show[_ngcontent-%COMP%]{opacity:1!important;border:2px solid #A400F1;box-shadow:inset 0 0 0 1.4px #efcfff}.highlight-box[_ngcontent-%COMP%]{position:absolute;border:1px solid #A400F1;box-shadow:inset 0 0 0 .7px #efcfff;background:#c957ff33;cursor:pointer;box-sizing:border-box;z-index:1;opacity:0;animation:_ngcontent-%COMP%_blinkFade 1.6s ease-in forwards;animation-delay:.5s}.highlight-box.show[_ngcontent-%COMP%]{opacity:1!important;border:2px solid #A400F1;box-shadow:inset 0 0 0 1.4px #efcfff}.highlight-box[_ngcontent-%COMP%]:hover{opacity:1!important;background-color:#c957ff33;border-color:#a400f1}.actions-upper[_ngcontent-%COMP%]{visibility:hidden;position:absolute;right:-75px;top:50%;transform:translateY(-50%);display:flex;opacity:0;transition:opacity .3s ease,visibility .3s ease;padding-left:6px}.highlight-box.show[_ngcontent-%COMP%]   .actions-upper[_ngcontent-%COMP%], .highlight-box[_ngcontent-%COMP%]:hover   .actions-upper[_ngcontent-%COMP%]{visibility:visible;opacity:1}.actions[_ngcontent-%COMP%]{display:flex;border-radius:8px;background:#ffffffb3}.action-btn[_ngcontent-%COMP%]{width:32px;height:32px;border-radius:8px;background:transparent;border:0;padding:4px!important}.action-btn[_ngcontent-%COMP%]:hover{background:#fff}@keyframes _ngcontent-%COMP%_blinkFade{0%{opacity:0}25%{opacity:1}75%{opacity:1}to{opacity:0}}.text-edit-overlay[_ngcontent-%COMP%]{background:#ffffff03;-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);width:100%;left:0;bottom:0;height:300px}.textarea-height[_ngcontent-%COMP%]{height:58px!important}.text-edit-mode[_ngcontent-%COMP%]   .aiDesignMobile[_ngcontent-%COMP%]{background:transparent;height:100%}.text-edit-mode[_ngcontent-%COMP%]   img[_ngcontent-%COMP%]{border-radius:12px}.text-edit-mode[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]{height:58px}.text-edit-mode[_ngcontent-%COMP%]   .textarea-col-focused1[_ngcontent-%COMP%]{height:58px!important}.text-edit-mode[_ngcontent-%COMP%]   .edit-height[_ngcontent-%COMP%]{max-height:200px!important;height:100%!important}.text-edit-mode[_ngcontent-%COMP%]   .edit-height-keyboard[_ngcontent-%COMP%]{max-height:86px!important;height:100%!important}.report-flag[_ngcontent-%COMP%]{border-radius:100px;background:#60657633;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);right:56px}"]}),a})();var Gi=m(40618),Vi=(m(54321),m(79301)),ht=m(21652),Pe=m(18545);const Ri=["promptTextarea"],Fi=s=>({"d-none":s}),Ai=(s,a,n)=>({"info-up":s,"info-blue":a,"info-red":n});function Bi(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",15),e.bIt("pointerdown",function(){e.eBV(n);const i=e.XpG(3);return e.Njj(i.onPointerDown())})("pointerup",function(){e.eBV(n);const i=e.XpG(3);return e.Njj(i.onPointerUp())})("pointercancel",function(){e.eBV(n);const i=e.XpG(3);return e.Njj(i.onPointerUp())})("pointerleave",function(){e.eBV(n);const i=e.XpG(3);return e.Njj(i.onPointerUp())}),e.nrm(1,"pi",16),e.k0s()}}function Ui(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",10)(1,"div",11)(2,"img",12),e.nI1(3,"safe"),e.bIt("load",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onPreviewImageLoad(i))}),e.k0s(),e.nrm(4,"img",13),e.nI1(5,"safe"),e.k0s(),e.DNE(6,Bi,2,0,"div",14),e.k0s()}if(2&s){const n=e.XpG(2);e.R7$(),e.xc7("--pw",n.previewWidth)("--ph",n.previewHeight),e.R7$(),e.Y8G("src",e.i5U(3,9,n.imgUrl,"url"),e.B4B)("ngClass",e.eq3(15,Fi,n.isCompare)),e.R7$(2),e.Y8G("src",e.i5U(5,12,n.aiPhotoService.compareImageUrl,"url"),e.B4B)("ngClass",n.isCompare?"d-block":"d-none"),e.R7$(2),e.Y8G("ngIf",n.aiPhotoService.isDirty)}}function Di(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",17)(1,"button",18),e.bIt("click",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.download())}),e.EFF(2," Download "),e.k0s()()}}function Ni(s,a){1&s&&(e.j41(0,"div",34),e.EFF(1," Color "),e.k0s())}function Xi(s,a){if(1&s){const n=e.RV6();e.qex(0),e.DNE(1,Ni,2,0,"div",29),e.j41(2,"div",30)(3,"button",31),e.bIt("colorPickerChange",function(i){e.eBV(n);const o=e.XpG(3);return e.Njj(o.onColorPickerDrag(i))})("colorPickerOpen",function(){e.eBV(n);const i=e.XpG(3);return e.Njj(i.onColorPickerOpen())})("colorPickerClose",function(){e.eBV(n);const i=e.XpG(3);return e.Njj(i.onColorPickerClose())})("cpInputChange",function(i){e.eBV(n);const o=e.XpG(3);return e.Njj(o.onColorPickerDrag(i))})("cpSliderDragStart",function(i){e.eBV(n);const o=e.XpG(3);return e.Njj(o.onColorPickerDrag(i))})("cpSliderDragEnd",function(i){e.eBV(n);const o=e.XpG(3);return e.Njj(o.onColorPickerDrag(i))}),e.nrm(4,"pi",32),e.k0s(),e.j41(5,"input",33),e.bIt("blur",function(i){e.eBV(n);const o=e.XpG(3);return e.Njj(o.onColorFocusOut(i))}),e.k0s()(),e.bVm()}if(2&s){const n=e.XpG(3);e.R7$(),e.Y8G("ngIf",null==n.selectedTool||null==n.selectedTool.prompt?null:n.selectedTool.prompt.label),e.R7$(2),e.xc7("background",n.hexColor||"#ffffff"),e.Y8G("colorPicker",n.hexColor||"#ffffff")("cpDialogDisplay","popup")("cpCloseClickOutside",!0)("cpPosition","top")("cpToggle",n.isColorPickerOpen)("cpEyeDropper",!0)("cpOutputFormat","hex")("cpUseRootViewContainer",!0),e.R7$(2),e.Y8G("value",n.hexColor||"#ffffff")}}function Li(s,a){if(1&s&&(e.j41(0,"div",34),e.EFF(1),e.k0s()),2&s){const n=e.XpG(4);e.AVh("d-none",n.hasSlot("color")),e.R7$(),e.SpI(" ",n.selectedTool.prompt.label," ")}}function Yi(s,a){if(1&s){const n=e.RV6();e.qex(0),e.DNE(1,Li,2,3,"div",35),e.j41(2,"div",36),e.bIt("click",function(){e.eBV(n);const i=e.XpG(3);return e.Njj(i.openPromptSheet())}),e.nrm(3,"pi",37),e.j41(4,"input",38),e.bIt("focus",function(){e.eBV(n);const i=e.XpG(3);return e.Njj(i.openPromptSheet())}),e.k0s()(),e.bVm()}if(2&s){const n=e.XpG(3);e.R7$(),e.Y8G("ngIf",null==n.selectedTool||null==n.selectedTool.prompt?null:n.selectedTool.prompt.label),e.R7$(3),e.Y8G("value",n.customPrompt)}}function $i(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"button",39),e.bIt("click",function(){e.eBV(n);const i=e.XpG(3);return e.Njj(i.openAspectSheet())}),e.j41(2,"div",40)(3,"span",41),e.EFF(4),e.k0s()(),e.nrm(5,"pi",42),e.k0s(),e.bVm()}if(2&s){const n=e.XpG(3);e.R7$(4),e.JRh((null==n.selectedAspect?null:n.selectedAspect.name)||"Aspect Ratio")}}function zi(s,a){1&s&&(e.j41(0,"div",43)(1,"span",44),e.EFF(2,"Loa
1ding..."),e.k0s()())}function Hi(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",19),e.DNE(1,Xi,6,12,"ng-container",2)(2,Yi,5,2,"ng-container",2),e.j41(3,"div",20)(4,"div",21),e.DNE(5,$i,6,1,"ng-container",2),e.k0s(),e.j41(6,"div",22)(7,"button",23),e.bIt("click",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.generate())}),e.DNE(8,zi,3,0,"div",24),e.j41(9,"span",25),e.EFF(10,"Generate"),e.k0s(),e.j41(11,"span",26),e.nrm(12,"img",27),e.j41(13,"b",28),e.EFF(14),e.k0s()()()()()()}if(2&s){const n=e.XpG(2);e.R7$(),e.Y8G("ngIf",n.hasSlot("color")),e.R7$(),e.Y8G("ngIf",n.hasSlot("prompt")),e.R7$(2),e.AVh("d-none",n.hasSlot("color")),e.R7$(),e.Y8G("ngIf",n.hasSlot("aspect")),e.R7$(),e.AVh("ms-2",n.hasSlot("aspect")),e.R7$(),e.Y8G("disabled",!n.canGenerate),e.R7$(),e.Y8G("ngIf",n.aiPhotoService.inProgress),e.R7$(6),e.JRh(n.quality)}}function Wi(s,a){if(1&s&&(e.j41(0,"div",4)(1,"div",5)(2,"div",6),e.DNE(3,Ui,7,17,"div",7),e.k0s()(),e.DNE(4,Di,3,0,"div",8)(5,Hi,15,10,"div",9),e.k0s()),2&s){const n=e.XpG();e.R7$(2),e.AVh("color-height",n.hasSlot("color"))("download-height",n.aiPhotoService.isDirty),e.R7$(),e.Y8G("ngIf",n.imgUrl),e.R7$(),e.Y8G("ngIf",n.aiPhotoService.isDirty),e.R7$(),e.Y8G("ngIf",!n.aiPhotoService.isDirty)}}function qi(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",51),e.bIt("click",function(){const i=e.eBV(n).$implicit,o=e.XpG(2);return e.Njj(o.selectAspect(i))}),e.j41(1,"div",52),e.nrm(2,"pi",53),e.j41(3,"span",54),e.EFF(4),e.k0s()()()}if(2&s){const n=a.$implicit;e.R7$(2),e.Y8G("name",n.icon),e.R7$(2),e.JRh(n.name)}}function Ki(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"div",45)(2,"div",46)(3,"h3",47),e.EFF(4," Aspect Ratio "),e.j41(5,"pi",48),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.isAspectSheetOpen=!1)}),e.k0s()()(),e.DNE(6,qi,5,2,"div",49),e.k0s(),e.j41(7,"div",50),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.isAspectSheetOpen=!1)}),e.k0s(),e.bVm()}if(2&s){const n=e.XpG();e.R7$(6),e.Y8G("ngForOf",n.aspectRatios)}}function Zi(s,a){if(1&s&&(e.j41(0,"span",67),e.EFF(1),e.k0s()),2&s){const n=e.XpG(2);e.R7$(),e.Lme("",n.customPrompt.length,"/",n.maxLength,"")}}function Ji(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"div",55)(2,"div",56)(3,"div",57),e.EFF(4),e.k0s(),e.j41(5,"div")(6,"pi",48),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.closePromptSheet())}),e.k0s()()(),e.j41(7,"div",58)(8,"div",59)(9,"div",60)(10,"div",61)(11,"div",62)(12,"textarea",63,0),e.mxI("ngModelChange",function(i){e.eBV(n);const o=e.XpG();return e.DH7(o.customPrompt,i)||(o.customPrompt=i),e.Njj(i)}),e.bIt("focus",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.isFocused=!0)})("blur",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.isFocused=!1)})("keydown.enter",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.onPromptEnter(i))}),e.k0s(),e.DNE(14,Zi,2,2,"span",64),e.k0s()()()()(),e.j41(15,"div",65)(16,"button",66),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.closePromptSheet())}),e.j41(17,"span",25),e.EFF(18,"Done"),e.k0s()()()(),e.j41(19,"div",50),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.closePromptSheet())}),e.k0s(),e.bVm()}if(2&s){const n=e.XpG();e.R7$(4),e.SpI(" ",(null==n.selectedTool||null==n.selectedTool.prompt?null:n.selectedTool.prompt.label)||"Enter Prompt"," "),e.R7$(7),e.Y8G("ngClass",e.sMw(8,Ai,n.customPrompt.length,n.isFocused,n.customPrompt.length>=n.maxLength)),e.R7$(),e.AVh("blue-active",n.isFocused),e.Y8G("maxlength",n.maxLength),e.R50("ngModel",n.customPrompt),e.Y8G("placeholder",(null==n.selectedTool||null==n.selectedTool.prompt?null:n.selectedTool.prompt.placeholder)||"Enter Prompt (Optional)"),e.R7$(2),e.Y8G("ngIf",n.customPrompt.length)}}function Qi(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",50),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.onColorPickerClose())}),e.k0s()}}let en=(()=>{var s;class a{constructor(t,i,o,r,l,c,d,h,p){this.aiPhotoService=t,this.aiUploadImageService=i,this.authService=o,this.paymentService=r,this.toast=l,this.createPopupService=c,this.commonService=d,this.ecommerceAiToolsService=h,this.renderer=p,this.updateImageEvent=ne
1w e.bkB,this.openCloseEvent=new e.bkB,this.quality=1,this.customPrompt="",this.hexColor="#ffffff",this.isColorPickerOpen=!1,this.colorPickerOpenClass="ecom-recolor-mobile-color-picker-open",this.aspectRatios=[],this.selectedAspect=null,this.isAspectSheetOpen=!1,this.isPromptSheetOpen=!1,this.isFocused=!1,this.maxLength=2e3,this.isCompare=!1,this.previewWidth=1,this.previewHeight=1,this.generationRunId=0,this.isComponentDestroyed=!1,this.user=this.authService.currentUser(),this.loggedInObserver=this.authService.loggedIn.subscribe(()=>{this.user=this.authService.currentUser()}),this.paymentServiceSubs=this.paymentService.configUpdated.subscribe(u=>{u&&!this.config&&(this.config=this.paymentService.config,this.setToolQuality())})}get hasSelectedColor(){if(!this.hasSlot("color")||!1===this.selectedTool?.color?.required)return!0;const t=this.hexColor?.startsWith("#")?this.hexColor:`#${this.hexColor||""}`;return!!this.commonService.isValidHexaCode(t)}get canGenerate(){return!!this.imgUrl&&this.hasSelectedColor&&!this.aiPhotoService.inProgress}ngOnInit(){this.config=this.paymentService.config,this.aiPhotoService.inProgress=!1,this.aiPhotoService.isDirty=!1,this.setToolQuality(),this.initToolState()}ngOnChanges(t){if(t.imgUrl&&""!=t.imgUrl.currentValue){const i=this.aiPhotoService.isDirty;this.aiPhotoService.inProgress=!1,this.aiPhotoService.aiImages=[],i||(this.aiPhotoService.compareImageUrl=String(t.imgUrl.currentValue||""))}t.selectedTool&&this.selectedTool&&(this.aiPhotoService.inProgress=!1,this.aiPhotoService.isDirty=!1,this.setToolQuality(),this.initToolState())}ngOnDestroy(){this.isComponentDestroyed=!0,this.generationRunId++,this.onColorPickerClose(),this.loggedInObserver?.unsubscribe(),this.paymentServiceSubs?.unsubscribe(),document.body.classList.remove("overflow-hidden")}hasSlot(t){return this.ecommerceAiToolsService.hasSlot(this.selectedTool,t)}onColorPickerOpen(){this.isColorPickerOpen=!0,this.renderer.addClass(document.body,this.colorPickerOpenClass),setTimeout(()=>{const t=document.querySelector("color-picker .color-picker");t&&(this.renderer.addClass(t,this.colorPickerOpenClass),this.bindColorPickerInputs(t))})}onColorPickerClose(){this.isColorPickerOpen=!1,this.colorPickerInputObserver?.disconnect(),this.colorPickerInputObserver=void 0,this.renderer.removeClass(document.body,this.colorPickerOpenClass),document.querySelectorAll(`color-picker .color-picker.${this.colorPickerOpenClass}`).forEach(t=>{this.renderer.removeClass(t,this.colorPickerOpenClass)})}bindColorPickerInputs(t){this.bindChannelInputs(t,".hsla-text input",[360,100,100,100],"hslBound"),this.bindChannelInputs(t,".rgba-text input",[255,255,255,100],"rgbBound"),this.colorPickerInputObserver||(this.colorPickerInputObserver=new MutationObserver(()=>this.bindColorPickerInputs(t)),this.colorPickerInputObserver.observe(t,{childList:!0,subtree:!0}))}bindChannelInputs(t,i,o,r){t.querySelectorAll(i).forEach((l,c)=>{const d=l;if("true"===d.dataset[r])return;d.dataset[r]="true",d.maxLength=3,d.setAttribute("inputmode","numeric");const h=o[c]??100;d.addEventListener("focus",()=>{d.dataset.prevValue=d.value},!0),d.addEventListener("input",()=>{const _=d.value.replace(/\D/g,"").slice(0,3);if(""===_)return;let v=_;parseInt(v,10)>h&&(v=String(h)),d.value=v}),d.addEventListener("blur",()=>{setTimeout(()=>(()=>{if(""!==d.value.replace(/\D/g,""))return;const v=d.dataset.prevValue;null==v||""===v||(d.value=v,d.dispatchEvent(new Event("input",{bubbles:!0})),d.dispatchEvent(new Event("change",{bubbles:!0})))})(),0)},!0)})}onColorPickerDrag(t){const i=t?.color??t;"string"==typeof i&&(this.hexColor=i)}onColorFocusOut(t){const i=this.commonService.isValidHexaCode(t.target.value);i?this.hexColor=i:t.target.value=this.hexColor}selectAspect(t){this.selectedAspect=t,this.isAspectSheetOpen=!1}openAspectSheet(){this.closePromptSheet(),this.isAspectSheetOpen=!0}openPromptSheet(){this.isAspectSheetOpen=!1,this.isPromptSheetOpen=!0,this.focusPrompt()}closePromptSheet(){this.isPromptSheetOpen=!1,this.isFocused=!1,document.body.classList.remove("overflow-hidden")}focusPrompt(){document.body.classList.add("overflow-hidden"),this.isFocused=!0,setTimeout(()=>{this.promptTextarea?.nativeElement?.focus()},100)}onPromptEnter(t){t.preventDefault(),t.target?.blur()}generate(){if(!this.canGenerate||!this.selectedTool)return;if(this.aiPhotoService.isCancel)return void this.toast.showErrorSingle(y.b.message.uploadNewImage);if(!(this.user&&this.user.remainingCoins>
1=this.quality))return void this.loginAndAICredit();if(!this.aiPhotoService.isDirty){const o=this.imgUrl||this.aiPhotoService.compareImageUrl;o&&(this.aiPhotoService.compareImageUrl=o)}const t=this.selectedTool.featureType,i=this.imgUrl||this.aiPhotoService.compareImageUrl;if(this.closePromptSheet(),this.isAspectSheetOpen=!1,this.aiUploadImageService.isBlobUrl(i)||this.isWebpUrl(i))return this.startProgress(t),this.updateImageEvent.emit(this.aiPhotoService),void this.uploadThenGenerate();this.runGenerate(String(i),t)}download(){this.aiPhotoService.downloadImg(this.imgUrl)}onPointerDown(){clearTimeout(this.compareTimeout),this.compareTimeout=setTimeout(()=>{this.isCompare=!0},50)}onPointerUp(){clearTimeout(this.compareTimeout),this.isCompare=!1}onPreviewImageLoad(t){const i=t.target;!i?.naturalWidth||!i?.naturalHeight||(this.previewWidth=i.naturalWidth,this.previewHeight=i.naturalHeight)}loginAndAICredit(){this.user?this.openCloseEvent.emit({addCredit:!0}):this.aiPhotoService.loginAndAICredit(()=>{this.user=this.authService.currentUser(),this.user&&(this.user.remainingCoins<this.quality?this.openCloseEvent.emit({addCredit:!0}):this.generate())})}uploadThenGenerate(){var t=this;return(0,w.A)(function*(){try{const i=yield t.aiUploadImageService.blobImageUrlToFile(t.imgUrl,"untitled.png");t.aiUploadImageService.aiUploadImage(i,{tab:"aitools",uploadProgress:"none",isStyleRefImage:!0}).then(o=>{o.imgUrl?(t.imgUrl=o.imgUrl,t.runGenerate(o.imgUrl,t.selectedTool.featureType)):t.displayErrorMsg(o)}).catch(o=>{t.displayErrorMsg(o)})}catch(i){t.displayErrorMsg(i)}})()}runGenerate(t,i){const o=++this.generationRunId;this.aiPhotoService.processingProgress?.isActive?this.aiPhotoService.inProgress=!0:this.startProgress(i),this.updateImageEvent.emit(this.aiPhotoService);const r={imageUrl:t,featureType:i,...this.ecommerceAiToolsService.getAspectPayload(this.selectedTool,this.selectedAspect),...this.ecommerceAiToolsService.getTextPromptPayload(this.selectedTool,this.hexColor,this.customPrompt)};this.aiPhotoService.generateImage(r,l=>{this.isCurrentGenerationRun(o)&&(l&&l.assetId?this.aiPhotoService.checkStatus(l,0,c=>{this.isCurrentGenerationRun(o)&&(c?.urls?.length?(this.user.remainingCoins=c.remainingCalls,this.aiPhotoService.isDirty=!0,this.imgUrl=c.urls[0],this.updateImageEvent.emit(c.urls[0]),this.aiPhotoService.generateImageFn?.({isQuickEdit:!0})):this.displayErrorMsg())},c=>{this.displayErrorMsg(c)}):this.displayErrorMsg(l))},l=>{this.displayErrorMsg(l)})}startProgress(t){this.aiPhotoService.startGenerationProgress({featureType:t})}displayErrorMsg(t=null){this.aiPhotoService.clearGenerationProgress(),this.updateImageEvent.emit(this.aiPhotoService),this.createPopupService.openWarningDialog("Error",t?.description)}setToolQuality(){this.quality=this.config?.creditInfo?.[this.selectedTool?.featureType]??1}initToolState(){if(!this.selectedTool)return;this.customPrompt="",this.hexColor="#D1ADEB",this.isAspectSheetOpen=!1,this.isPromptSheetOpen=!1,this.isFocused=!1,this.previewWidth=1,this.previewHeight=1;const t=this.selectedTool.aspect;if(!t?.options?.length)return this.aspectRatios=[],void(this.selectedAspect=null);this.aspectRatios=t.options.map(o=>({...o,icon:this.ecommerceAiToolsService.getAspectIcon(o),ratio:o.value||o.label,name:o.label}));const i=this.aspectRatios.find(o=>o.id===t.default);this.selectedAspect=i||this.aspectRatios[0]}isWebpUrl(t){return!!t&&String(t).split("#")[0].split("?")[0].toLowerCase().endsWith(".webp")}isCurrentGenerationRun(t){return!this.isComponentDestroyed&&t===this.generationRunId}}return(s=a).\u0275fac=function(t){return new(t||s)(e.rXU(Z.s),e.rXU(ee.M),e.rXU(q.u),e.rXU(de.W),e.rXU(Q.f),e.rXU(ne.A),e.rXU(Vi.h),e.rXU(Ee.P),e.rXU(e.sFG))},s.\u0275cmp=e.VBU({type:s,selectors:[["ecommerce-ai-tools-mobile"]],viewQuery:function(t,i){if(1&t&&e.GBs(Ri,5),2&t){let o;e.mGM(o=e.lsd())&&(i.promptTextarea=o.first)}},inputs:{selectedTool:"selectedTool",imgUrl:"imgUrl"},outputs:{updateImageEvent:"updateImageEvent",openCloseEvent:"openCloseEvent"},features:[e.OA$],decls:4,vars:4,consts:[["promptTextarea",""],["class","ecommerce-ai-mobile position-relative",4,"ngIf"],[4,"ngIf"],["class","ecommerce-aspect-overlay d-flex align-items-center justify-content-start position-fixed",3,"click",4,"ngIf"],[1,"ecommerce-ai-mobile","position-relative"],[1,"drawer-elements","ai-drawer-elements"],[1,"d-flex","align-items-center","justify-content-center","overflow-hidden","w-100","flex-column","p-3","text-image-height",2,"height","calc(100dvh - 200px)"],["class","res-round h-100 d-flex align-items-center justify-content-center w-100 bg-grey3 border-radius-12 position-relative",4,"ngIf"],["class","position-fixed ps-3 pe-3 d-flex align-items-center justify-content-center w-100 mb-1 ecommerce-mobile-cta",4,"ngIf"],["class","position-fixed ps-3 pe-3 d-flex flex-column w-100 ecommerce-mobile-cta",4,"ngIf"],[1,"res-round","h-100","d-flex","align-items-center","justify-content-center","w-100","bg-grey3","border-radius-12","position-relative"],[1,"position-relative","ecommerce-preview-frame"],[1,"pe-none",3,"load","src","ngClass"],[1,"pe-none",3,"src","ngClass"],["class","d-flex align-items-center justify-content-center position-absolute hw-40 border-radius-50 btn-alpha","style","bottom: 8px; left: 8px; z-index: 10;",3,"pointerdown","pointerup","pointercancel","pointerleave",4,"ngIf"],[1,"d-flex","align-items-center","justify-content-center","position-absolute","hw-40","border-radius-50","btn-alpha",2,"bottom","8px","left","8px","z-index","10",3,"pointerdown","pointerup","pointercancel","pointerleave"],["name","comparewhite",1,"f-24","text-white"],[1,"position-fixed","ps-3","pe-3","d-flex","align-items-center","justify-content-center","w-100","mb-1","ecommerce-mobile-cta"],["id","gtm-generate-ecommerce-mob-download",1,"btn","btn-primary","btn-primary-m","text-lg","btn-h48","w-100","d-flex","align-items-center","justify-content-center",3,"click"],[1,"position-fixed","ps-3","pe-3","d-flex","flex-column","w-100","ecommerce-mobile-cta"],[1,"d-flex","w-100","justify-content-between","align-items-center"],[1,"d-inline-flex",2,"max-width","75px"],[1,"d-inline-flex","w-100"],["id","gtm-generate-ecommerce-mob",1,"btn","btn-primary-gradient","border-0","btn-primary-m","text-lg","btn-h44","w-100","d-flex","align-items-center","justify-content-center",3,"click","disabled"],["class","spinner-border spinner-border-lg me-2 hw-24","role","status",4,"ngIf"],[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"],[1,"text-11","text-semi",2,"padding-left","2px"],["class","text-semi lh-125 h-32 d-flex align-items-center text-13 grey-800 mb-1",4,"ngIf"],[1,"d-flex","w-100","align-items-center","mb-3"],["type","button",1,"no-style","color","control","p-0","color-box","border-radius-12","me-2","w-100",3,"colorPickerChange","colorPickerOpen","colorPickerClose","cpInputChange","cpSliderDragStart","cpSliderDragEnd","colorPicker","cpDialogDisplay","cpCloseClickOutside","cpPosition","cpToggle","cpEyeDropper","cpOutputFormat","cpUseRootViewContainer"],["name","currentcoloricon",1,"f-24"],["type","text","maxlength","7","placeholder","#ffffff",1,"flex-grow-1","text-semi","grey-800","bg-transparent","border-radius-12","pl-8","pr-8","h-40","color-hex-in
1put","w-100",3,"blur","value"],[1,"text-semi","lh-125","h-32","d-flex","align-items-center","text-13","grey-800","mb-1"],["class","text-semi lh-125 h-32 d-flex align-items-center text-13 grey-800 mb-1",3,"d-none",4,"ngIf"],[1,"ecommerce-prompt-trigger","w-100","d-flex","align-items-center","mb-3",3,"click"],["name","promptedit",1,"f-20","grey-500","me-2"],["type","text","placeholder","Add prompt","readonly","",1,"ecommerce-prompt-input","text-13","text-medium","w-100","border-0","text-truncate",3,"focus","value"],["type","button",1,"d-flex","w-100","justify-content-between","align-items-center","select-button","border-radius-12","pointer",3,"click"],[1,"d-flex","align-items-center"],[1,"text-13","text-black","text-bold","me-1"],["name","chevronaarrow",1,"hw-24","text-black"],["role","status",1,"spinner-border","spinner-border-lg","me-2","hw-24"],[1,"sr-only","text-nowrap","border-0","position-absolute","overflow-hidden"],[1,"d-flex","justify-content-start","align-items-center","ecommerce-aspect-sheet","position-fixed","bg-white","p-3","pt-2","pb-9","flex-column","w-100"],[1,"top-header","d-flex","justify-content-start","align-items-center","w-100","flex-column","mb-1","h-32"],[1,"text-lg","text-semi","grey-800","m-0","w-100","lh-125","d-flex","align-items-center","justify-content-between","h-32"],["name","previewclose",3,"click"],["class","modal-box resolution-modal d-flex justify-content-between align-items-center w-100 border-radius-12 pl-9 pr-9 mb-2 h-48",3,"click",4,"ngFor","ngForOf"],[1,"ecommerce-aspect-overlay","d-flex","align-items-center","justify-content-start","position-fixed",3,"click"],[1,"modal-box","resolution-modal","d-flex","justify-content-between","align-items-center","w-100","border-radius-12","pl-9","pr-9","mb-2","h-48",3,"click"],[1,"d-flex","justify-content-center","align-items-center"],[1,"f-24","grey-600","me-2",3,"name"],[1,"grey-800","text-13","text-semi"],[1,"p-3","pt-9","pb-9","position-fixed","bg-white","w-100","ecommerce-prompt-sheet"],[1,"wp-100","d-flex","align-items-center","justify-content-between"],[1,"text-lg","text-semi","grey-800"],[1,"card","drawer-card","mt-3","mb-0"],[1,"card-body"],[1,"btn-panel"],[1,"card-body","prompt-view"],[1,"textarea-col","position-relative",3,"ngClass"],["name","ecommercePrompt","rows","4",1,"prompt-text",3,"ngModelChange","focus","blur","keydown.enter","maxlength","ngModel","placeholder"],["class","prompt-info text-regular position-relative d-flex align-items-center h-24",4,"ngIf"],[1,"d-flex","align-items-center","justify-content-center","w-100","mt-3"],["type","button",1,"btn","btn-primary-gradient","btn-primary-m","btn-h44","w-100","d-flex","align-items-center","justify-content-center",3,"click"],[1,"prompt-info","text-regular","position-relative","d-flex","align-items-center","h-24"]],template:function(t,i){1&t&&e.DNE(0,Wi,6,7,"div",1)(1,Ki,8,1,"ng-container",2)(2,Ji,20,12,"ng-container",2)(3,Qi,1,0,"div",3),2&t&&(e.Y8G("ngIf",i.selectedTool),e.R7$(),e.Y8G("ngIf",i.isAspectSheetOpen),e.R7$(),e.Y8G("ngIf",i.isPromptSheetOpen),e.R7$(),e.Y8G("ngIf",i.isColorPickerOpen))},dependencies:[b.YU,b.Sq,b.bT,P.me,P.BC,P.tU,P.vS,ht.bk,H.b,Pe.m],styles:['.ecommerce-ai-mobile[_ngcontent-%COMP%]   .res-round[_ngcontent-%COMP%]{container-type:size;min-height:0}.ecommerce-ai-mobile[_ngcontent-%COMP%]   .ecommerce-preview-frame[_ngcontent-%COMP%]{--pw: 1;--ph: 1;width:min(100cqw,100cqh * var(--pw) / var(--ph));height:min(100cqh,100cqw * var(--ph) / var(--pw));overflow:hidden}.ecommerce-ai-mobile[_ngcontent-%COMP%]   .ecommerce-preview-frame[_ngcontent-%COMP%]   img[_ngcontent-%COMP%]{width:100%;height:100%;object-fit:contain;display:block}.ecommerce-ai-mobile[_ngcontent-%COMP%]   .color-box[_ngcontent-%COMP%]{height:40px;border:1px solid #E2E3E9}.ecommerce-ai-mobile[_ngcontent-%COMP%]   .color-hex-input[_ngcontent-%COMP%]{border:1px solid #E2E3E9;max-width:82px}.ecommerce-ai-mobile[_ngcontent-%COMP%]   .ecommerce-prompt-trigger[_ngcontent-%COMP%]{height:40px;border-radius:12px;background:linear-gradient(90deg,#fc5cff05 -4%,#2520f605);border:1px solid #e2e3e9;padding:0 8px 0 4px;text-align:left}.ecommerce-ai-mobile[_ngcontent-%COMP%]   .ecommerce-prompt-input[_ngcontent-%COMP%]{background:transparent;outline:none;cursor:pointer;color:#272b34;padding:0}.ecommerce-ai-mobile[_ngcontent-%COMP%]   .ecommerce-prompt-input[_ngcontent-%COMP%]::placeholder{color:#606576}.ecommerce-ai-mobile[_ngcontent-%COMP%]   .select-button[_ngcontent-%COMP%]{border:1px solid #E2E3E9;background:linear-gradient(0deg,#626adf0d 0% 100%),#fff;height:44px;padding:2px 6px!important}.ecommerce-ai-mobile[_ngcontent-%COMP%]   .select-button[_ngcontent-%COMP%]   .icon-bg[_ngcontent-%COMP%]{background:#626adf1a}.ecommerce-mobile-cta[_ngcontent-%COMP%]{bottom:16px;left:0;z-index:2}.ecommerce-aspect-sheet[_ngcontent-%COMP%]{border-radius:20px 20px 0 0;left:0;bottom:0;z-index:9999}.ecommerce-aspect-sheet[_ngcontent-%COMP%]   .resolution-modal[_ngcontent-%COMP%]{background:#626adf0d;min-height:48px}.ecommerce-aspect-sheet[_ngcontent-%COMP%]   .resolution-modal.is-selected[_ngcontent-%COMP%]{background:#626adf1f}.ecommerce-aspect-overlay[_ngcontent-%COMP%]{left:0;top:0;width:100%;height:100%;background:#0003;-webkit-backdrop-filter:blur(40px);backdrop-filter:blur(40px);z-index:9998}.ecommerce-prompt-sheet[_ngcontent-%COMP%]{border-radius:20px 20px 0 0;left:0;bottom:0;z-index:9999}.ecommerce-prompt-sheet[_ngcontent-%COMP%]   .prompt-view[_ngcontent-%COMP%]   .textarea-col[_ngcontent-%COMP%]{width:100%;height:188px;border-radius:12px;background:#eeedf3;padding:4px;border:0px!important}.ecommerce-prompt-sheet[_ngcontent-%COMP%]   .prompt-view[_ngcontent-%COMP%]   .textarea-col[_ngcontent-%COMP%]:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:12px;padding:.92px;border:none;background:linear-gradient(90deg,#c9cad4 -4% 100%);-webkit-mask:linear-gradient(90deg,#c9cad4 -4%,#c9cad4 100%) content-box,linear-gradient(90deg,#c9cad4 -4%,#c9cad4 100%);-webkit-mask-composite:xor;mask-composite:exclude;z-index:1;pointer-events:none}.ecommerce-prompt-sheet[_ngcontent-%COMP%]   .prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]{resize:none;outline:none;width:100%;height:148px;padding:8px;font-size:13px;color:#272b34;border:0;background:transparent;border-radius:12px;line-height:125%;overflow:auto;position:relative;z-index:2}.ecommerce-prompt-sheet[_ngcontent-%COMP%]   .prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]::-webkit-scrollbar{width:4px;height:4px;border-radius:12px}.ecommerce-prompt-sheet[_ngcontent-%COMP%]   .prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]::-webkit-scrollbar-track{background:#e3e3e3;border-radius:12px;margin-top:8px}.ecommerce-prompt-sheet[_ngcontent-%COMP%]   .prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background:#9a9a9a;border-radius:12px}.ecommerce-prompt-sheet[_ngcontent-%COMP%]   .prompt-view[_ngcontent-%COMP%]   .prompt-info[_ngcontent-%COMP%]{font-size:11px;color:#b0b3bf;padding-left:8px;line-height:140%;z-index:2}.info-up[_ngcontent-%COMP%]{border:1px solid #b0b3bf!important;background:#eeedf3!important}.info-blue[_ngcontent-%COMP%]{background:linear-gradient(90deg,#fc5cff0d -4%,#2520f60d)!important}.info-blue[_ngcontent-%COMP%]:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:12px;padding:.92px;border:none;background:linear-gradient(90deg,#fc5cff -4%,#2520f6)!important;-webkit-mask:linear-gradient(90deg,#fc5cff -4%,#2520f6 100%) content-box,linear-gradient(90deg,#fc5cff -4%,#2520f6 100%)!important;-webkit-mask-composite:xor!important;mask-composite:exclude!important;z-index:1;pointer-events:none}.info-blue[_ngcontent-%COMP%]   span[_ngcontent-%COMP%]{color:#626adf!important}.info-red[_ngcontent-%COMP%]{background:linear-gradient(90deg,#fc5cff0d -4%,#2520f60d)!important}.info-red[_ngcontent-%COMP%]:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:12px;padding:.92px;border:none;background:linear-gradient(90deg,#f25555 -4% 100%)!important;-webkit-mask:linear-gradient(90deg,#f25555 -4%,#f25555 100%) content-box,linear-gradient(90deg,#f25555 -4%,#f25555 100%)!important;-webkit-mask-composite:xor!important;mask-composite:exclude!important;z-index:1;pointer-events:none}.info-red[_ngcontent-%COMP%]   span[_ngcontent-%COMP%]{color:#f25555!important}.btn[_ngcontent-%COMP%]:disabled   .coin-count[_ngcontent-%COMP%]{background:#0000001a}.btn[_ngcontent-%COMP%]:disabled   .coin-count[_ngcontent-%COMP%]   b[_ngcontent-%COMP%]{color:#fff!important}.btn[_ngcontent-%COMP%]:disabled   .inable[_ngcontent-%COMP%]{display:none}.btn[_ngcontent-%COMP%]:disabled   .disable[_ngcontent-%COMP%]{display:block}.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}.coin-count[_ngcontent-%COMP%]   b[_ngcontent-%COMP%]{color:#fff!important}.color-height[_ngcontent-%COMP%]{height:calc(100dvh - 255px)!important}.download-height[_ngcontent-%COMP%]{height:calc(100dvh - 120px)!important}']}),a})();var tn=m(79279),se=m(68465),Ae=m(92452),nn=m(96427),we=m(62261),Ke=m(32764),pt=m(42494),on=m(93391),mt=m(48039),_e=m(36561),sn=m(90811),ut=m(67381),gt=m(4091),_t=m(19567),rn=m(77616);
1const an=["masonryScroll"],ln=["masonryContent"],cn=["vid"];function dn(s,a){1&s&&(e.j41(0,"div",19),e.nrm(1,"div",20),e.k0s())}function hn(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"video",21,3),e.bIt("loadeddata",function(){e.eBV(n);const i=e.sdS(2),o=e.XpG().$implicit,r=e.XpG();return e.Njj(r.onVideoReady(o,i))})("canplay",function(){e.eBV(n);const i=e.sdS(2),o=e.XpG().$implicit,r=e.XpG();return e.Njj(r.onVideoReady(o,i))}),e.k0s(),e.bVm()}if(2&s){const n=e.XpG().$implicit,t=e.XpG();e.R7$(),e.AVh("is-visible",t.isMediaReady(n)),e.BMQ("src",t.shouldLoadVideo(n)?null==n?null:n.videoThumbUrl:null,e.B4B)("poster",(null==n?null:n.hrThumbUrl)||(null==n?null:n.thumbUrl)||(null==n?null:n.imgUrl)||null,e.B4B)}}function pn(s,a){if(1&s){const n=e.RV6();e.j41(0,"picture",22),e.nrm(1,"source",23),e.nI1(2,"imgwebp"),e.j41(3,"img",24),e.bIt("load",function(){e.eBV(n);const i=e.XpG().$implicit,o=e.XpG();return e.Njj(o.markMediaReady(i))})("error",function(i){e.eBV(n);const o=e.XpG().$implicit,r=e.XpG();return e.Njj(r.onImageError(o,i))}),e.k0s()()}if(2&s){const n=e.XpG().$implicit,t=e.XpG();e.AVh("is-visible",t.isMediaReady(n)),e.R7$(),e.FS9("srcset",e.bMT(2,4,(null==n?null:n.hrThumbUrl)||(null==n?null:n.thumbUrl)||(null==n?null:n.imgUrl))),e.R7$(2),e.FS9("srcset",(null==n?null:n.hrThumbUrl)||(null==n?null:n.thumbUrl)||(null==n?null:n.imgUrl))}}function mn(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",16),e.bIt("click",function(){const i=e.eBV(n).$implicit,o=e.XpG();return e.Njj(o.selectTemplate(i))}),e.DNE(1,dn,2,0,"div",17)(2,hn,3,4,"ng-container",18)(3,pn,4,6,"ng-template",null,2,e.C5r),e.k0s()}if(2&s){const n=a.$implicit,t=a.index,i=e.sdS(4),o=e.XpG();e.xc7("width",o.imageWidth,"px")("height",o.calculateHeight(n),"px")("left",null==o.imagePositions[t]?null:o.imagePositions[t].left,"px")("top",null==o.imagePositions[t]?null:o.imagePositions[t].top,"px"),e.AVh("is-media-pending",!o.isMediaReady(n)),e.R7$(),e.Y8G("ngIf",!o.isMediaReady(n)),e.R7$(),e.Y8G("ngIf",o.isVideoItem(n))("ngIfElse",i)}}function un(s,a){if(1&s&&(e.j41(0,"div",26),e.nrm(1,"div",20),e.k0s()),2&s){const n=a.$implicit;e.xc7("width",n.width,"px")("height",n.height,"px")("left",n.left,"px")("top",n.top,"px"),e.R7$(),e.xc7("width",n.width,"px")("height",n.height,"px")}}function gn(s,a){if(1&s&&(e.qex(0),e.DNE(1,un,2,12,"div",25),e.bVm()),2&s){const n=e.XpG();e.R7$(),e.Y8G("ngForOf",n.placeholderPositions)}}let ft=(()=>{var s;class a{get storeProductsWithLoadingPlaceholders(){return this.storeProducts?.length?!this.isLoadingMoreProductsForPlaceholders||this.isProductListEnd?this.storeProducts:(this.storeProducts||[]).concat(this.productLoadingPlaceholders.map(()=>({displayName:"",productId:-1,categoryId:0,isLoadingPlaceholder:!0}))):this.storeProducts}constructor(t,i){this.mediaContentService=t,this.cdr=i,this.categoryId=0,this.previewTitle="Preview",this.prefetchedProducts=[],this.useProductFormatForMedia=!1,this.selectedTemplate=new e.bkB,this.closePreview=new e.bkB,this.storeProducts=[],this.productImages=[],this.productId=0,this.productListPageNumber=0,this.templatePageNumber=0,this.inProgress=!1,this.isProductListEnd=!1,this.isTemplatesEnd=!1,this.isLoadingMoreProductsForPlaceholders=!1,this.isLoadingTemplates=!1,this.imagePositions=[],this.placeholderPositions=[],this.imageWidth=360,this.gap=8,this.columnCount=4,this.columnHeights=[],this.imageLoadingPlaceholders=[0,1],this.initializedFromInputs=!1,this.readyMediaIds=new Set,this.activeVideoIds=new Set,this.maxActiveVideos=3,this.templateRequestSeq=0,this.productListPageSize=50,this.templatePageSize=20,this.productLoadingPlaceholders=[0,1],this.qualityReso={1:1,2:.75,3:1.3333,7:.6641,8:1.5059,9:.5625,10:1.7778,11:1,12:.7556,13:.6667,14:.5333,15:1.3213,16:1.5,17:1.875,18:.5647,19:1.7708,20:.7534,21:1.3273,22:1.5,23:.6667},this.updateColumnCount()}ngOnInit(){if(!this.initializedFromInputs){if(this.prefetchedProducts?.length)return void this.useProducts(this.prefetchedProducts);this.loadCategoryProducts(!0)}}ngOnChanges(t){if(t.prefetchedProducts&&this.prefetchedProducts?.length)return this.initializedFromInputs=!0,void this.useProducts(this.prefetchedProducts);t.categoryId&&!t.categoryId.firstChange&&this.loadCategoryProducts(!0)}ngAfterViewInit(){this.videoRefsChangesSub=this.videoRefs?.changes.subscribe(()=>{this.scheduleVisibleVideoActivation()}),this.scheduleVisibleVideoActivation()}ngOnDestroy(){this.templateRequestSeq++,this.inProgress=!1,this.isLoadingTemplates=!1,this.videoRefsChangesSub?.unsubscribe(),this.clearPendingTimers(),this.disposeVisibleVideos(),this.readyMediaIds.clear(),this.activeVideoIds.clear()}onResize(){this.updateColumnCount(),this.layoutImages()}updateColumnCount(){const t=window.innerWidth-50;if(this.columnCount=t<=480?2:t<=768?3:t<=1024?4:t<=1600?5:7,this.columnHeights=Array(this.columnCount).fill(0),this.imageWidth=(t-this.columnCount*this.gap)/this.columnCount,t<=480){const i=window.innerWidth-40;this.imageWidth=i/this.columnCount}}loadCategoryProducts(t=!0){if(this.inProgress||!t&&this.isProductListEnd||(t&&(this.storeProducts=[],this.productImages=[],this.productId=0,this.productListPageNumber=0,this.templatePageNumber=0,this.isProductListEnd=!1,this.isTemplatesEnd=!1,this.imagePositions=[]),!this.categoryId))return;const i=t?0:this.productListPageNumber+1;this.inProgress=!0,this.isLoadingMoreProductsForPlaceholders=!t,this.mediaContentService.getProductListing(this.categoryId,i,o=>{const r=o?.storeProducts||[];this.productListPageNumber=i,this.isProductListEnd=r.length<this.productListPageSize,t?this.useProducts(r):(r.length&&(this.storeProducts=this.mergeUniqueProducts(this.storeProducts,r)),this.inProgress=!1,this.isLoadingMoreProductsForPlaceholders=!1)},()=>{this.inProgress=!1,this.isLoadingMoreProductsForPlaceholders=!1},void 0,void 0,this.productListPageSize)}useProducts(t=[]){if(this.templateRequestSeq++,this.storeProducts=t||[],this.productImages=[],this.readyMediaIds.clear(),this.activeVideoIds.clear(),this.productListPageNumber=0,this.isProductListEnd=this.storeProducts.length<this.productListPageSize,this.templatePageNumber=0,this.isTemplatesEnd=!1,this.imagePositions=[],this.columnHeights=Array(this.columnCount).fill(0),this.placeholderPositions=[],!this.storeProducts.length)return void(this.inProgress=!1);const i=Number(this.aiPhotoService?.lastInspirationTemplateProductId||0),o=i?this.storeProducts.find(r=>Number(r?.productId)===i):null;this.productId=o?.productId||this.storeProducts[0]?.productId||0,this.loadTemplatesByProduct()}loadTemplatesByProduct(){if(!this.productId||this.isLoadingTemplates||this.isTemplatesEnd)return;this.inProgress=!0,this.isLoadingTemplates=!0,this.updatePlaceholderPositions();const t=++this.templateRequestSeq,i=this.productId;this.mediaContentService.getTemplateByProductV2Id(i,this.templatePageNumber,r=>{if(t!==this.templateRequestSeq||i!==this.productId)return;const l=r?.storeProductImages||[];if(l.length){const c=this.productImages.length;this.productImages=this.mergeUniqueImages(this.productImages,l),this.isTemplatesEnd=l.length<this.templatePageSize||0==this.productImages.length-c}else this.isTemplatesEnd=!0;this.inProgress=!1,this.isLoadingTemplates=!1,this.layoutImages(),this.prefetchIfNotScrollable()},()=>{t!==this.templateRequestSeq||i!==this.productId||(this.inProgress=!1,this.isLoadingTemplates=!1,this.placeholderPositions=[])},null,this.templatePageSize)}getMasonryContentHeight(){if(!this.columnHeights?.length&&!this.placeholderPositions?.length)return 0;const t=this.columnHeights?.length?Math.max(...this.columnHeights,0
1):0,i=this.placeholderPositions.reduce((o,r)=>Math.max(o,(r?.top||0)+(r?.height||0)+this.gap),0);return Math.max(t,i)}updatePlaceholderPositions(){if(this.placeholderPositions=[],!this.isLoadingTemplates||this.isTemplatesEnd)return;const t=[...this.columnHeights?.length?this.columnHeights:Array(this.columnCount).fill(0)],i=this.getSelectedProductPlaceholderHeight();let o=[];if(this.productImages.length)for(o=this.productImages.slice(-this.imageLoadingPlaceholders.length).map(l=>this.calculateHeight(l));o.length<this.imageLoadingPlaceholders.length;)o.push(o[o.length-1]||i);else{const r=Math.max(3*this.columnCount,4);o=Array(r).fill(i)}o.forEach(r=>{const l=t.indexOf(Math.min(...t));this.placeholderPositions.push({left:l*(this.imageWidth+this.gap),top:t[l],width:this.imageWidth,height:r}),t[l]+=r+this.gap})}getSelectedProductPlaceholderHeight(){const t=this.storeProducts.find(o=>Number(o?.productId)===Number(this.productId)),i=Number(t?.format||0);return 1===i?9*this.imageWidth/16:3===i?16*this.imageWidth/9:this.imageWidth}onScrollEnd(t){const i=t.target;i&&(this.scheduleVisibleVideoActivation(),i.scrollTop+i.clientHeight>=i.scrollHeight-120&&!this.isTemplatesEnd&&!this.isLoadingTemplates&&!this.inProgress&&(this.templatePageNumber+=1,this.loadTemplatesByProduct()))}onProductTagsScrollEnd(){this.loadCategoryProducts(!1)}selectProductTag(t){if(t?.isLoadingPlaceholder)return;const i=t?.productId||0;if(i&&i===this.productId&&(this.productImages?.length||this.isLoadingTemplates))return;this.productId=i,this.templateRequestSeq++,this.aiPhotoService&&(this.aiPhotoService.lastInspirationTemplateProductId=this.productId),this.templatePageNumber=0,this.productImages=[],this.readyMediaIds.clear(),this.activeVideoIds.clear(),this.imagePositions=[],this.columnHeights=Array(this.columnCount).fill(0),this.placeholderPositions=[],this.isLoadingTemplates=!1,this.isTemplatesEnd=!1;const o=this.masonryScrollRef?.nativeElement||document.getElementById("masonryScrollDiv");o&&(o.scrollTop=0),this.loadTemplatesByProduct()}mergeUniqueProducts(t=[],i=[]){if(!i.length)return t;const o=new Set(t.map(l=>l?.productId)),r=i.filter(l=>!o.has(l?.productId));return r.length?t.concat(r):t}mergeUniqueImages(t=[],i=[]){if(!i.length)return t;const o=new Set(t.map(l=>l?.productImageId)),r=i.filter(l=>!o.has(l?.productImageId));return r.length?t.concat(r):t}selectTemplate(t){this.clearPendingTimers(),this.disposeVisibleVideos(),this.activeVideoIds.clear(),this.selectedTemplate.emit({...t,productId:t?.productId||this.productId})}isVideoItem(t){return!!t?.videoThumbUrl}shouldLoadVideo(t){return this.activeVideoIds.has(this.getMediaKey(t))}updateActiveVideos(t){const o=Math.max(0,t.scrollTop-120),r=t.scrollTop+t.clientHeight+120,l=this.productImages.filter((h,p)=>{if(!this.isVideoItem(h))return!1;const u=this.imagePositions[p]?.top||0;return u+this.calculateHeight(h)>=o&&u<=r}),c=l.filter(h=>this.isMediaReady(h)).map(h=>this.getMediaKey(h)),d=l.filter(h=>!this.isMediaReady(h)).slice(0,this.maxActiveVideos).map(h=>this.getMediaKey(h));this.activeVideoIds=new Set([...c,...d])}getMediaKey(t){return String((t?.productImageId??t?.videoThumbUrl??t?.thumbUrl??t?.imgUrl)||"")}isMediaReady(t){const i=this.getMediaKey(t);return!!i&&this.readyMediaIds.has(i)}markMediaReady(t){const i=this.getMediaKey(t);!i||this.readyMediaIds.has(i)||(this.readyMediaIds.add(i),this.cdr.markForCheck())}onVideoReady(t,i){if(this.markMediaReady(t),this.masonryScrollRef?.nativeElement&&this.scheduleVisibleVideoActivation(),!i)return;i.muted||(i.muted=!0);const r=i.play();r&&"function"==typeof r.then&&r.catch(()=>{})}onImageError(t,i){this.markMediaReady(t);const o=i?.target||null;o&&"function"==typeof window.errImage&&window.errImage(o)}calculateHeight(t){if(this.useProductFormatForMedia)return this.getSelectedProductPlaceholderHeight();const i=Number(t?.quality||t?.aspect||0),o=this.qualityReso[i];return o?1/o*this.imageWidth:this.imageWidth}layoutImages(){this.columnHeights=Array(this.columnCount).fill(0),this.imagePositions=[],this.productImages.forEach(t=>{const i=this.calculateHeight(t),o=this.columnHeights.indexOf(Math.min(...this.columnHeights));this.imagePositions.push({left:o*(this.imageWidth+this.gap),top:this.columnHeights[o]}),this.columnHeights[o]+=i+this.gap}),this.updatePlaceholderPositions(),this.layoutTimer=window.setTimeout(()=>
1{const t=this.masonryContentRef?.nativeElement;t&&(t.style.height=`${this.getMasonryContentHeight()}px`);const i=this.masonryScrollRef?.nativeElement;i&&(this.updateActiveVideos(i),this.cdr.markForCheck())})}prefetchIfNotScrollable(){this.prefetchTimer=window.setTimeout(()=>{if(this.isTemplatesEnd||this.isLoadingTemplates||this.inProgress)return;const t=this.masonryScrollRef?.nativeElement;t&&t.scrollHeight<=t.clientHeight+120&&(this.templatePageNumber+=1,this.loadTemplatesByProduct())},50)}scheduleVisibleVideoActivation(){this.videoActivationTimer&&clearTimeout(this.videoActivationTimer),this.videoActivationTimer=window.setTimeout(()=>{this.videoActivationTimer=void 0;const t=this.masonryScrollRef?.nativeElement;t&&(this.updateActiveVideos(t),this.cdr.detectChanges(),this.videoRefs?.forEach(i=>{const o=i?.nativeElement;o?.getAttribute("src")&&o.readyState===HTMLMediaElement.HAVE_NOTHING&&o.load()}))})}clearPendingTimers(){this.layoutTimer&&(clearTimeout(this.layoutTimer),this.layoutTimer=void 0),this.prefetchTimer&&(clearTimeout(this.prefetchTimer),this.prefetchTimer=void 0),this.videoActivationTimer&&(clearTimeout(this.videoActivationTimer),this.videoActivationTimer=void 0)}disposeVisibleVideos(){this.videoRefs?.forEach(t=>{const i=t?.nativeElement;if(i){try{i.pause()}catch{}try{const o=i.querySelector("source");o?.hasAttribute("src")&&o.removeAttribute("src"),i.removeAttribute("src"),i.load()}catch{}}})}}return(s=a).\u0275fac=function(t){return new(t||s)(e.rXU(we.Z),e.rXU(e.gRc))},s.\u0275cmp=e.VBU({type:s,selectors:[["inspiration-template-picker"]],viewQuery:function(t,i){if(1&t&&(e.GBs(an,5),e.GBs(ln,5),e.GBs(cn,5)),2&t){let o;e.mGM(o=e.lsd())&&(i.masonryScrollRef=o.first),e.mGM(o=e.lsd())&&(i.masonryContentRef=o.first),e.mGM(o=e.lsd())&&(i.videoRefs=o)}},hostBindings:function(t,i){1&t&&e.bIt("resize",function(){return i.onResize()},!1,e.tSv)},inputs:{categoryId:"categoryId",previewTitle:"previewTitle",aiPhotoService:"aiPhotoService",prefetchedProducts:"prefetchedProducts",useProductFormatForMedia:"useProductFormatForMedia"},outputs:{selectedTemplate:"selectedTemplate",closePreview:"closePreview"},features:[e.OA$],decls:15,vars:9,consts:[["masonryScroll",""],["masonryContent",""],["imageThumb",""],["vid",""],["id","scrollDiv",1,"p-3","po","bg-white","position-absolute","w-100","masonry-preview","overflow-hidden"],[1,"d-flex","align-items-center","justify-content-center","flex-column","position-fixed","bg-white","masnory-header"],[1,"d-flex","align-items-center","justify-content-center","w-100","grey-800","text-lg","text-semi","mb-2","pt-3","position-relative"],["name","previewclose",1,"position-absolute",2,"right","16px",3,"click"],[1,"d-flex","align-items-center","justify-content-start","w-100","pt-3","pb-2"],["id","top-float-btn",1,"top-float-btn","inspirationDialog","w-100"],[1,"m-tab-scroll","tags-listing",3,"selectLayout","scrollEnd","items","type","aiPhotoService","categoryId"],["id","masonryScrollDiv",1,"masonry","position-relative","scroll-hide",2,"top","95px","overflow","auto","height","calc(100% - 80px)",3,"scroll"],[1,"masonry-content","position-relative"],["class","item pointer d-flex border-radius-lg",3,"width","height","left","top","is-media-pending","click",4,"ngFor","ngForOf"],[4,"ngIf"],[1,"showpreview-overlay","align-items-center","justify-content-start","position-fixed","d-flex",2,"left","0px","z-index","9999",3,"click"],[1,"item","pointer","d-flex","border-radius-lg",3,"click"],["class","media-aspect-placeholder","aria-hidden","true",4,"ngIf"],[4,"ngIf","ngIfElse"],["aria-hidden","true",1,"media-aspect-placeholder"],[1,"skeleton-box","border-radius-lg"],["muted","","playsinline","","loop","","autoplay","","preload","none",1,"border-radius-lg","media-content",2,"width","100%","height","100%","object-fit","cover","display","block",3,"loadeddata","canplay"],["loading","lazy",1,"media-content"],["type","image/webp",3,"srcset"],["alt","Thumbnail",1,"border-radius-lg",3,"load","error","srcset"],["class","item placeholder-thumb",3,"width","height","left","top",4,"ngFor","ngForOf"],[1,"item","placeholder-thumb"]],template:function(t,i){if(1&t){const o=e.RV6();e.j41(0,"div",4)(1,"div",5)(2,"div",6),e.EFF(3),e.j41(4,"pi",7),e.bIt("click",function(){return e.eBV(o),e.Njj(i.closePreview.emit())}),e.k0s()(),e.j41(5,"div",8)(6,"div",9)(7,"buttons-scroll-menu",10),e.bIt("selectLayout",function(l){return e.eBV(o),e.Njj(i.selectProductTag(l))})("scrollEnd",function(){return e.eBV(o),e.Njj(i.onProductTagsScrollEnd())}),e.k0s()()()(),e.j41(8,"div",11,0),e.bIt("scroll",function(l){return e.eBV(o),e.Njj(i.onScrollEnd(l))}),e.j41(10,"div",12,1),e.DNE(12,mn,5,13,"div",13)(13,gn,2,1,"ng-container",14),e.k0s()()(),e.j41(14,"div",15),e.bIt("click",function(){return e.eBV(o),e.Njj(i.closePreview.emit())}),e.k0s()}2&t&&(e.R7$(3),e.SpI(" ",i.previewTitle," "),e.R7$(4),e.Y8G("items",i.storeProductsWithLoadingPlaceholders)("type","mobile-ai-editor")("aiPhotoService",i.aiPhotoService)("categoryId",i.productId),e.R7$(3),e.xc7("min-height",i.getMasonryContentHeight(),"px"),e.R7$(2),e.Y8G("ngForOf",i.productImages),e.R7$(),e.Y8G("ngIf",i.isLoadingTemplates&&!i.isTemplatesEnd))},dependencies:[b.Sq,b.bT,H.b,_e.B,rn.m],styles:[".masonry[_ngcontent-%COMP%]{width:100%;margin:0 auto;position:relative;padding:0;box-sizing:border-box;min-height:100px}.item[_ngcontent-%COMP%]{position:absolute;overflow:hidden;background:#f1f2f6}.item[_ngcontent-%COMP%]   img[_ngcontent-%COMP%]{width:100%;height:100%;display:block;object-fit:cover}.media-aspect-placeholder[_ngcontent-%COMP%]{position:absolute;top:0;right:0;bottom:0;left:0;z-index:1;pointer-events:none}.media-aspect-placeholder[_ngcontent-%COMP%]   .skeleton-box[_ngcontent-%COMP%]{width:100%;height:100%;border-radius:12px;background:linear-gradient(90deg,#f1f2f6 25%,#e5e7ef 37%,#f1f2f6 63%);background-size:400% 100%;animation:_ngcontent-%COMP%_inspiration-skeleton-shimmer 1.2s ease-in-out infinite}.media-content[_ngcontent-%COMP%]{position:relative;z-index:0;width:100%;height:100%;display:block;opacity:0;transition:opacity .18s ease}.media-content.is-visible[_ngcontent-%COMP%]{opacity:1}.item.is-media-pending[_ngcontent-%COMP%]   .media-content[_ngcontent-%COMP%]{opacity:0}
1picture.media-content[_ngcontent-%COMP%] > img[_ngcontent-%COMP%]{width:100%;height:100%;display:block;object-fit:cover}@media (max-width: 1024px){.masonry[_ngcontent-%COMP%]{width:750px}}@media (max-width: 768px){.masonry[_ngcontent-%COMP%]{width:500px}}@media (max-width: 480px){.masonry[_ngcontent-%COMP%]{width:100%}}.showpreview-overlay[_ngcontent-%COMP%]{display:none;background:#0003;-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);width:100%;height:100%;top:0;bottom:0;z-index:999}.masonry-preview[_ngcontent-%COMP%]{top:0;z-index:99999;border-radius:20px 20px 0 0;left:0;height:calc(100vh - 48px);overflow:auto}.masonry-preview[_ngcontent-%COMP%]   .masnory-header[_ngcontent-%COMP%]{width:100%;z-index:99;left:0;right:0;top:44px;border-top-left-radius:20px;border-top-right-radius:20px}.scroll-hide[_ngcontent-%COMP%]{-ms-overflow-style:none;scrollbar-width:none}.scroll-hide[_ngcontent-%COMP%]::-webkit-scrollbar{display:none}.placeholder-thumb[_ngcontent-%COMP%]{pointer-events:none;border-radius:16px}.placeholder-thumb[_ngcontent-%COMP%]   .skeleton-box[_ngcontent-%COMP%]{width:100%;height:100%;border-radius:12px;background:linear-gradient(90deg,#f1f2f6 25%,#e5e7ef 37%,#f1f2f6 63%);background-size:400% 100%;animation:_ngcontent-%COMP%_inspiration-skeleton-shimmer 1.2s ease-in-out infinite}@keyframes _ngcontent-%COMP%_inspiration-skeleton-shimmer{0%{background-position:100% 0}to{background-position:0 0}}"]}),a})();var vt=m(94896);const _n=["carousel"],fn=["previewFileInput"],vn=(s,a,n)=>({"hide-arrow":s,isFirst:a,isLast:n}),bn=(s,a,n)=>({"d-flex":s,"d-none":a,"pt-3 ps-3 pe-3":n}),Cn=(s,a)=>({"w-100":s,"h-100":a});function xn(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",3)(1,"div",4)(2,"div",5)(3,"video",6,0),e.bIt("canplay",function(){e.eBV(n);const i=e.sdS(4),o=e.XpG();return e.Njj(o.onVideoCanPlay(i))})("loadedmetadata",function(){e.eBV(n);const i=e.sdS(4),o=e.XpG();return e.Njj(o.onVideoLoadedMetadata(i))})("timeupdate",function(){e.eBV(n);const i=e.sdS(4),o=e.XpG();return e.Njj(o.onVideoTimeUpdate(i))})("ended",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.onVideoEnded())}),e.nrm(5,"source",7),e.nI1(6,"safe"),e.k0s()(),e.j41(7,"a",8),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.downloadVideo())}),e.nrm(8,"pi",9),e.k0s(),e.j41(9,"div",10),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.reportAbuse())}),e.nrm(10,"pi",11),e.k0s(),e.j41(11,"button",12),e.bIt("click",function(){e.eBV(n);const i=e.sdS(4),o=e.XpG();return e.Njj(o.togglePlay(i))}),e.nrm(12,"pi",13),e.k0s(),e.j41(13,"div",14)(14,"span",15),e.EFF(15),e.k0s(),e.EFF(16),e.k0s()(),e.j41(17,"div",16)(18,"div",17)(19,"div",18)(20,"span",19),e.EFF(21,"Prompt"),e.k0s()(),e.j41(22,"div",20),e.EFF(23),e.k0s()()()()}if(2&s){const n=e.sdS(4),t=e.XpG();e.R7$(5),e.Y8G("src",e.i5U(6,5,t.videoUrl,"url"),e.B4B),e.R7$(7),e.Y8G("name",null!=n&&n.paused?"playnew":"pausenew"),e.R7$(3),e.SpI("",t.currentTimeLabel," "),e.R7$(),e.SpI("/ ",t.durationLabel," "),e.R7$(7),e.SpI(" ",t.prompt," ")}}function Pn(s,a){if(1&s){const n=e.RV6();e.j41(0,"video",34,0),e.bIt("canplay",function(){e.eBV(n);const i=e.sdS(1),o=e.XpG(5);return e.Njj(o.onVideoCanPlay(i))}),e.nrm(2,"source",7),e.nI1(3,"safe"),e.k0s()}if(2&s){const n=e.XpG(3).$implicit;e.R7$(2),e.Y8G("src",e.i5U(3,1,n.urls[0],"url"),e.B4B)}}function In(s,a){if(1&s){const n=e.RV6();e.j41(0,"button",12),e.bIt("click",function(i){e.eBV(n),e.XpG(4);const o=e.sdS(14),r=e.XpG();return i.stopPropagation(),e.Njj(r.togglePlay(o))}),e.nrm(1,"pi",13),e.k0s()}if(2&s){e.XpG(4);const n=e.sdS(14);e.R7$(),e.Y8G("name",null!=n&&n.paused?"playnew":"pausenew")}}function yn(s,a){if(1&s&&(e.j41(0,"div",31),e.DNE(1,Pn,4,4,"video",32)(2,In,2,1,"button",33),e.k0s()),2&s){const n=e.XpG(2).$implicit;e.R7$(),e.Y8G("ngIf",n.urls[0]),e.R7$(),e.Y8G("ngIf",n.urls[0])}}function wn(s,a){if(1&s&&(e.nrm(0,"img",36),e.nI1(1,"safe")),2&s){const n=e.XpG(3).$implicit;e.Y8G("src",e.i5U(1,1,n.urls[0],"url"),e.B4B)}}function Sn(s,a){if(1&s&&(e.j41(0,"div",31),e.DNE(1,wn,2,4,"img",35),e.k0s()),2&s){const n=e.XpG(2).$implicit;e.R7$(),e.Y8G("ngIf",n.urls[0])}}function Mn(s,a){if(1&s&&(e.j41(0,"div",29),e.DNE(1,yn,3,2,"div",30)(2,Sn,2,1,"div",30),e.k0s()),2&s){const n=e.XpG().$implicit;e.R7$(),e.Y8G("ngIf",n.isVideo),e.R7$(),e.Y8G("ngIf",!n.isVideo)}}function kn(s,a){if(1&s){const n=e.RV6();e.DNE(0,Mn,3,2,"ng-template",28),e.bIt("slid",function(i){const o=e.eBV(n),r=o.first,l=o.last,c=e.XpG(2);return e.Njj(c.nextSlide(i,r,l))})}2&s&&e.Y8G("id",a.$implicit.assetId)}function Tn(s,a){if(1&s){const n=e.RV6();e.j41(0,"button",37),e.bIt("click",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.changeWithAI())}),e.nrm(1,"pi",38),e.EFF(2,"Change with AI "),e.k0s()}}function On(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",21)(1,"div",22)(2,"ngb-carousel",23,1),e.bIt("slide",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.onSlide(i))}),e.DNE(4,kn,1,1,null,24),e.k0s(),e.DNE(5,Tn,3,0,"button",25),e.j41(6,"div",10),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.reportAbuse())}),e.nrm(7,"pi",11),e.k0s(),e.j41(8,"div",8),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.download())}),e.nrm(9,"pi",9),e.k0s()()(),e.j41(10,"div",26)(11,"div",4)(12,"div",5)(13,"video",6,0),e.bIt("canplay",function(){e.eBV(n);const i=e.sdS(14),o=e.XpG();return e.Njj(o.onVideoCanPlay(i))})("loadedmetadata",function(){e.eBV(n);const i=e.sdS(14),o=e.XpG();return e.Njj(o.onVideoLoadedMetadata(i))})("timeupdate",function(){e.eBV(n);const i=e.sdS(14),o=e.XpG();return e.Njj(o.onVideoTimeUpdate(i))})("ended",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.onVideoEnded())}),e.nrm(15,"source",7),e.nI1(16,"safe"),e.k0s()(),e.j41(17,"div",10),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.reportAbuse())}),e.nrm(18,"pi",11),e.k0s(),e.j41(19,"a",27),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.downloadVideo())}),e.nrm(20,"pi",9),e.k0s(),e.j41(21,"button",12),e.bIt("click",function(){e.eBV(n);const i=e.sdS(14),o=e.XpG();return e.Njj(o.togglePlay(i))}),e.nrm(22,"pi",13),e.k0s(),e.j41(23,"div",14)(24,"span",15),e.EFF(25),e.k0s(),e.EFF(26),e.k0s()(),e.j41(27,"div",16)(28,"div",17)(29,"div",18)(30,"span",19),e.EFF(31,"Prompt"),e.k0s()(),e.j41(32,"div",20),e.EFF(33),e.k0s()()()()}if(2&s){const n=e.sdS(14),t=e.XpG();e.Y8G("ngClass",t.videoUrl?"d-none":"d-flex"),e.R7$(2),e.Y8G("activeId",t.activeId)("wrap",!1)("interval",0)("ngClass",e.sMw(16,vn,(null==t.aiPhotoService?null:t.aiPhotoService.aiImages)&&(null==t.aiPhotoService?null:t.aiPhotoService.aiImages.length)<=1,t.isFirst,t.isLast)),e.R7$(2),e.Y8G("ngForOf",null==t.aiPhotoService?null:t.aiPhotoService.aiImages),e.R7$(),e.Y8G("ngIf","text2image"==t.featureType||"image2image"==t.featureType||"sketch2image"==t.featureType),e.R7$(5),e.Y8G("ngClass",e.sMw(20,bn,t.videoUrl,!t.videoUrl,t.videoPreview)),e.R7$(5),e.Y8G("src",e.i5U(16,13,t.videoUrl,"url"),e.B4B),e.R7$(7),e.Y8G("name",null!=n&&n.paused?"playnew":"pausenew"),e.R7$(3),e.SpI("",t.currentTimeLabel," "),e.R7$(),e.SpI("/ ",t.durationLabel," "),e.R7$(7),e.SpI(" ",t.prompt," ")}}function En(s,a){if(1&s&&(e.j41(0,"div",48)(1,"span"),e.EFF(2,"Your "),e.nrm(3,"br"),e.EFF(4),e.nrm(5,"br"),e.EFF(6,"will be "),e.nrm(7,"br"),e.EFF(8,"displayed "),e.nrm(9,"br"),e.EFF(10,"here"),e.k0s()()),2&s){const n=e.XpG(3);e.R7$(4),e.SpI("",n.featureType?"generations":"input image"," ")}}function jn(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",49)(1,"button",50),e.bIt("click",function(i){e.eBV(n);const o=e.XpG(3);return e.Njj(o.chooseFileFromButton(i))}),e.nrm(2,"pi",51),e.EFF(3,"Upload Image "),e.k0s()()}}function Gn(s,a){if(1&s&&(e.j41(0,"div",31),e.nrm(1,"img",52),e.nI1(2,"safe"),e.k0s()),2&s){const n=e.XpG(4);e.R7$(),e.Y8G("src",e.i5U(2,1,null==n.transientPreviewItem?null:n.transientPreviewItem.urls[0],"url"),e.B4B)}}function Vn(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",46)(1,"div",29),e.DNE(2,Gn,3,4,"div",30),e.j41(3,"a",8),e.bIt("click",function(){e.eBV(n);const i=e.XpG(3);return e.Njj(i.downloadSelectedPreview())}),e.nrm(4,"pi",9),e.k0s()()()}if(2&s){const n=e.XpG(3);e.R7$(2),e.Y8G("ngIf",!(null!=n.transientPreviewItem&&n.transientPreviewItem.isVideo))}}function Rn(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",41)(1,"div",42),e.bIt("click",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(!(null!=i.transientPreviewItem&&null!=i.transientPreviewItem.urls&&i.transientPreviewItem.urls.length)&&i.chooseFile())}),e.DNE(2,En,11,1,"div",43)(3,jn,4,0,"div",44)(4,Vn,5,1,"div",45),e.j41(5,"div",46)(6,"div",29)(7,"img",47),e.nI1(8,"safe"),e.bIt("error",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.onImageError())}),e.k0s(),e.j41(9,"a",8),e.bIt("click",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.downloadIntermediateImage())}),e.nrm(10,"pi",9),e.k0s()()()()()}if(2&s){const n=e.XpG(2);e.AVh("image-preview",n.featureType),e.R7$(),e.AVh("bg-transparent",n.hideImage),e.R7$(),e.Y8G("ngIf",n.checkimg&&!(null!=n.transientPreviewItem&&null!=n.transientPreviewItem.urls&&n.transientPreviewItem.urls.length)&&(!(null!=n.aiPhotoService&&n.aiPhotoService.imgUrl)||n.hideImage)),e.R7$(),e.Y8G("ngIf",!n.checkimg&&!(null!=n.transientPreviewItem&&null!=n.transientPreviewItem.urls&&n.transientPreviewItem.urls.length)&&(!(null!=n.aiPhotoService&&n.aiPhotoService.imgUrl)||n.hideImage)),e.R7$(),e.Y8G("ngIf",null==n.transientPreviewItem||null==n.transientPreviewItem.urls?null:n.transientPreviewItem.urls.length),e.R7$(),e.AVh("d-none",(null==n.transientPreviewItem||null==n.transientPreviewItem.urls?null:n.transientPreviewItem.urls.length)||!(null!=n.aiPhotoService&&n.aiPhotoService.imgUrl)||n.hideImage),e.R7$(2),e.Y8G("src",e.i5U(8,10,null==n.aiPhotoService?null:n.aiPhotoService.imgUrl,"url"),e.B4B)}}function Fn(s,a){if(1&s){const n=e.RV6();
1e.j41(0,"div",55)(1,"video",56,0),e.bIt("canplay",function(){e.eBV(n);const i=e.sdS(2),o=e.XpG(4);return e.Njj(o.onVideoCanPlay(i))})("ended",function(){e.eBV(n);const i=e.XpG(4);return e.Njj(i.onVideoEnded())}),e.nrm(3,"source",7),e.nI1(4,"safe"),e.k0s()()}if(2&s){const n=e.XpG(4);e.R7$(),e.Y8G("ngClass",e.l_i(5,Cn,1==(null==n.transientPreviewItem?null:n.transientPreviewItem.format)||2==(null==n.transientPreviewItem?null:n.transientPreviewItem.format),3==(null==n.transientPreviewItem?null:n.transientPreviewItem.format))),e.R7$(2),e.Y8G("src",e.i5U(4,2,null==n.transientPreviewItem?null:n.transientPreviewItem.urls[0],"url"),e.B4B)}}function An(s,a){if(1&s&&(e.j41(0,"div",46)(1,"div",29),e.DNE(2,Fn,5,8,"div",54),e.k0s()()),2&s){const n=e.XpG(3);e.R7$(2),e.Y8G("ngIf",null==n.transientPreviewItem?null:n.transientPreviewItem.isVideo)}}function Bn(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",41)(1,"div",53),e.bIt("click",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(!(null!=i.transientPreviewItem&&null!=i.transientPreviewItem.urls&&i.transientPreviewItem.urls.length)&&i.chooseFile())}),e.DNE(2,An,3,1,"div",45),e.k0s()()}if(2&s){const n=e.XpG(2);e.AVh("image-preview",n.featureType),e.R7$(),e.AVh("bg-transparent",n.hideImage),e.R7$(),e.Y8G("ngIf",null==n.transientPreviewItem||null==n.transientPreviewItem.urls?null:n.transientPreviewItem.urls.length)}}function Un(s,a){if(1&s){const n=e.RV6();e.j41(0,"input",39,2),e.bIt("change",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.onFileUploaded(i.srcElement.files))})("click",function(){e.eBV(n);const i=e.sdS(1);return e.Njj(i.value="")}),e.k0s(),e.DNE(2,Rn,11,13,"div",40)(3,Bn,3,5,"div",40)}if(2&s){const n=e.XpG();e.Y8G("accept",n.aiUploadImageService.fileImageAccept),e.R7$(2),e.Y8G("ngIf",!(null!=n.transientPreviewItem&&n.transientPreviewItem.isVideo)),e.R7$(),e.Y8G("ngIf",null==n.transientPreviewItem?null:n.transientPreviewItem.isVideo)}}let Ze=(()=>{var s;class a{constructor(t,i,o,r,l,c){var d=this;this.aiPhotoService=t,this.downloadService=i,this.aiUploadImageService=o,this.gtmService=r,this.offcanvasService=l,this.toastService=c,this.chooseFileEvent=new e.bkB,this.uploadFileEvent=new e.bkB,this.imageLoaded=!0,this.isFirst=!1,this.isLast=!0,this.activeId="",this.videoPreview=!1,this.checkimg=!0,this.featureType="",this.layoutVersion="",this.isVideo=!1,this.hideImage=!1,this.isMuted=!0,this.hasAudio=!0,this.currentTimeLabel="00:00",this.durationLabel="00:00",this.videoUrl="",this.prompt="",this.transientPreviewItem=null,this.isNotified=!1,this.isShowPreview=!1,this.generatedVideoResult=null,this.changeWithAIClick=new e.bkB,this.boundGenerateImageFn=function(){var h=(0,w.A)(function*(p,u){d.prevGenerateImageFn?.(p,u),d.generateImage(p)});return function(p,u){return h.apply(this,arguments)}}(),this.prevGenerateImageFn=this.aiPhotoService.generateImageFn,this.aiPhotoService.generateImageFn=this.boundGenerateImageFn}set previewItem(t){if(t?.assetId){if(t?.assetId&&this.transientPreviewItem)return this.transientPreviewItem=null,void setTimeout(()=>this.generateImage(t));this.generateImage(t)}}generateImage(t){if(t&&t?.assetId){if(this.isTemplatePreview(t)&&!this.layoutVersion)return;if(this.activeId=t?.assetId,!this.aiPhotoService?.aiImages?.length&&!this.videoUrl){const i=t?.url||t?.urls?.[0]||"";i&&(this.transientPreviewItem={assetId:t.assetId,isVideo:t?.isVideo??i.includes(".mp4"),urls:[i],format:t?.format})}this.carousel&&this.carousel.select(this.activeId),this.updateNavigationFlags(),setTimeout(()=>{this.updateNavigationFlags(),this.carousel&&this.activeId&&this.carousel.select(this.activeId)},0)}}ngOnChanges(t){t.featureType&&!t.featureType.firstChange&&!this.featureType&&this.clearTemplatePreview(),(t.featureType||t.layoutVersion)&&(this.hideImage="text2image"==this.featureType||"v4"==this.layoutVersion)}ngOnDestroy(){this.aiPhotoService.generateImageFn===this.boundGenerateImageFn&&(this.aiPhotoService.generateImageFn=this.prevGenerateImageFn),this.clearTemplatePreview()}isTemplatePreview(t){return String(t?.assetId||"").startsWith("template-preview-")}clearTemplatePreview(){this.isTemplatePreview(this.transientPreviewItem)&&(this.transientPreviewItem=null,this.activeId="")}changeWithAI(){this.changeWithAIClick.emit(this.carousel?.activeId)}nextSlide(t,i,o){t.isShown&&(i?(this.isLast=!1,this.isFirst=!0):o?(this.isFirst=!1,this.isLast=!0):(this.isLast=!1,this.isFirst=!1))}onSlide(t){const i=this.aiPhotoService?.aiImages?.length?this.aiPhotoService.aiImages:this.transientPreviewItem?[this.transientPreviewItem]:[];if(!t||!i.length)return;const o=t.next??t.current;if(!o)return;const r=i.find(l=>String(l.assetId)===String(o));r&&(this.activeId=r.assetId,this.aiPhotoService.selectedUpscaleImageUrl=r?.urls?.[0]||"",this.updateNavigationFlags(),this.carousel&&this.activeId&&this.carousel.select(this.activeId))}onImageError(){this.aiPhotoService.imgUrl=null}downloadIntermediateImage(){this.gtmService.pushTag({eventName:y.b.gtm.eventname.aiDownloadMob,itemName:"Editor_Intermediate"}),this.fetchImageAsBlob(this.aiPhotoService.imgUrl).then(({blob:i,contentType:o})=>{let r="jpg";o&&o.includes("image/")&&(r=o.split("/")[1]);const l=URL.createObjectURL(i);this.downloadService.download(l,r)}).catch(i=>console.error("Image fetch failed:",i))}fetchImageAsBlob(t){return new Promise((i,o)=>{const r=new XMLHttpRequest;r.open("GET",t),r.responseType="blob",r.onload=function(){if(200===r.
1status){const l=r.response,c=r.getResponseHeader("Content-Type");i({blob:l,contentType:c})}else o(new Error(`HTTP error! Status: ${r.status}`))},r.onerror=function(){o(new Error("Network error while fetching image."))},r.send()})}download(){if(this.carousel?.activeId){const i=(this.aiPhotoService?.aiImages?.length?this.aiPhotoService.aiImages:this.transientPreviewItem?[this.transientPreviewItem]:[]).find(r=>r.assetId===this.carousel?.activeId)?.urls[0];if(this.gtmService.pushTag({eventName:y.b.gtm.eventname.aiDownloadMob,itemName:"Editor_"+this.featureType}),!i)return;this.aiPhotoService.downloadImg(i,()=>{localStorage.getItem("isChecked")||this.downloadService.downloadMsgPopup({msg:y.b.message.download,imgUrl:i})})}}chooseFile(){!this.aiPhotoService?.imgUrl&&!this.featureType&&this.chooseFileEvent.emit(!1)}chooseFileFromButton(t){t?.stopPropagation();const i=this.previewFileInput?.nativeElement;i?i.click():this.chooseFileEvent.emit(!0)}onFileUploaded(t){if(!t?.length)return;const i=t[0];i.isReplace=null!=this.featureType,this.uploadFileEvent.emit(i)}onVideoLoadedMetadata(t){this.hasAudio=this.detectHasAudio(t),this.durationLabel=this.formatTime(t.duration),this.currentTimeLabel=this.formatTime(t.currentTime)}onVideoTimeUpdate(t){this.currentTimeLabel=this.formatTime(t.currentTime),t.duration&&isFinite(t.duration)&&(this.durationLabel=this.formatTime(t.duration))}onVideoEnded(){this.currentTimeLabel="00:00"}onVideoCanPlay(t){if(!t)return;t.muted||(t.muted=!0);const i=t.play();i&&"function"==typeof i.then&&i.catch(()=>{})}detectHasAudio(t){try{if(t.audioTracks&&"number"==typeof t.audioTracks.length)return t.audioTracks.length>0;if("boolean"==typeof t.mozHasAudio)return t.mozHasAudio;if("number"==typeof t.webkitAudioDecodedByteCount)return t.webkitAudioDecodedByteCount>0;if(t.mozAudioTracks&&t.mozAudioTracks.length)return t.mozAudioTracks.length>0}catch{}return!0}togglePlay(t){if(t)if(t.paused||t.ended){const o=t.play();o&&"function"==typeof o.then&&o.catch(()=>{})}else t.pause()}downloadVideo(){this.downloadService.downloadVideo(this.videoUrl)}downloadSelectedPreview(){const t=this.transientPreviewItem?.urls?.[0];t&&this.aiPhotoService.downloadImg(t)}formatTime(t){if(!isFinite(t)||t<0)return"00:00";const i=Math.floor(t),o=Math.floor(i/60),r=i%60;return`${String(o).padStart(2,"0")}:${String(r).padStart(2,"0")}`}updateNavigationFlags(){const t=this.aiPhotoService?.aiImages?.length?this.aiPhotoService.aiImages:this.transientPreviewItem?[this.transientPreviewItem]:[];if(t.length<=1)return this.isFirst=!0,void(this.isLast=!0);const i=t.findIndex(r=>String(r?.assetId)===String(this.activeId)),o=i>=0?i:t.length-1;this.isFirst=0===o,this.isLast=o===t.length-1}reportAbuse(){this.isShowPreview=!1;let t=null,i=[],o=0;if(this.videoPreview&&this.videoUrl)t={featureType:this.featureType,assetId:this.generatedVideoResult?.assetId||"",prompt:this.generatedVideoResult?.prompt||"",inputImgUrl:this.generatedVideoResult?.inputImgUrl||"",presetStyleImgUrl:"",outputImgUrl:this.videoUrl};else{i=this.aiPhotoService?.aiImages||[];const l=this.carousel?.activeId??this.activeId;o=i.findIndex(c=>String(c?.assetId)===String(l)),t=o>-1?i[o]:this.transientPreviewItem}if(!t)return;t.featureType||(t.featureType=this.featureType);const r=this.offcanvasService.open(vt.e,{position:"bottom",backdrop:!0,panelClass:"report-offcanvas",backdropClass:"showpreview-overlay"});r.componentInstance.item=t,r.result.then(l=>{if(l){if(this.videoPreview&&this.videoUrl)this.aiPhotoService.backBtnClick.next({isBack:!0});else if(o>-1)if(i.splice(o,1),i.length){const c=o>=i.length?i.length-1:o;this.activeId=i[c].assetId,this.isFirst=0===c,this.isLast=c===i.length-1}else this.activeId="",this.aiPhotoService.isDirty=!1,this.isFirst=!1,this.isLast=!0;else t===this.transientPreviewItem&&(this.transientPreviewItem=null);this.toastService.showSuccess("Report submitted successfully")}},()=>{})}}return(s=a).\u0275fac=function(t){return new(t||s)(e.rXU(Z.s),e.rXU(ze.s),e.rXU(ee.M),e.rXU(ie.y),e.rXU(R.RS),e.rXU(Q.f))},s.\u0275cmp=e.VBU({type:s,selectors:[["generated-image-preview"]],viewQuery:function(t,i){if(1&t&&(e.GBs(_n,5),e.GBs(fn,5)),2&t){let o;e.mGM(o=e.lsd())&&(i.carousel=o.first),e.mGM(o=e.lsd())&&(i.previewFileInput=o.first)}},inputs:{videoPreview:"videoPreview",checkimg:"checkimg",featureType:"featureType",layoutVersion:"layoutVersion",isVideo:"isVideo",videoUrl:"videoUrl",prompt:"prompt",generatedVideoResult:"generatedVideoResult",previewItem:"previewItem"},outputs:{chooseFileEvent:"chooseFileEvent",uploadFileEvent:"uploadFileEvent",changeWithAIClick:"changeWithAIClick"},features:[e.OA$],decls:3,vars:1,consts:[["vid",""],["carousel",""],["previewFileInput",""],[1,"'d-flex","generation-preview-section","align-items-center","justify-content-center","flex-column","pad-image"],[1,"d-flex","align-items-center","justify-content-center","generation-thumb-preview","overflow-hidden","border-radius-12","mb-4","position-relative","bg-grey3"],[1,"overflow-hidden","h-100"],["height","","width","","muted","","playsinline","","autoplay","","loop","",1,"w-100","h-100",3,"canplay","loadedmetadata","timeupdate","ended"],["type","video/mp4",3,"src"],[1,"d-flex","align-items-center","justify-content-center","position-absolute","hw-40","border-radius-50","btn-alpha",2,"top","8px","right","8px",3,"click"],["name","downloadblack",1,"f-24","text-white"],[1,"d-flex","align-items-center","justify-content-center","position-absolute","hw-40","border-radius-50","report-flag",2,"top","8px",3,"click"],["name","reportabuse",1,"f-24","text-white"],[1,"btn-video-action","btn-play","position-absolute","d-flex","align-items-center","justify-content-center","text-white","pointer","btn-alpha",3,"click"],[1,"f-24",3,"name"],[1,"vid-time","d-inline-flex","align-items-center","justify-content-center","text-13","text-white","text-regular","lh-125","position-absolute"],[2,"min-width","39px"],[1,"generation-thumb-details","d-flex","align-items-center","justify-content-center","w-100","flex-column","mb-2"],[1,"prompt-section","d-flex","align-items-center","justify-content-start","w-100","flex-column"],[1,"d-flex","align-items-center","justify-content-between","w-100","mb-9","h-24"],[1,"text-lg","text-semi","grey-800"],[1,"prompt-textbox","border-radius-12","w-100","mb-3","p-2","grey-600","text-12","lh-160","text-break"],[1,"align-items-center","justify-content-center","overflow-hidde","w-100","flex-column","pb-0","intermediate-sl
1ider",3,"ngClass"],[1,"d-flex","align-items-center","justify-content-start","overflow-hidde","h-100","w-100","ngb-carousel","border-radius-12","bg-grey3","position-relative"],[1,"h-100","border-radius-12","w-100",3,"slide","activeId","wrap","interval","ngClass"],[4,"ngFor","ngForOf"],["class","changeWithAIBtn text-white d-flex align-items-center justify-content-center position-absolute text-13 text-semi","style","right: 8px; bottom: 8px;",3,"click",4,"ngIf"],[1,"generation-preview-section","align-items-center","justify-content-center","flex-column",3,"ngClass"],[1,"d-flex","align-items-center","justify-content-center","position-absolute","bg-white","hw-40","border-radius-50","btn-alpha",2,"top","8px","right","8px",3,"click"],["ngbSlide","",3,"slid","id"],[1,"d-flex","overflow-hidden","w-100","flex-column","align-items-center","justify-content-center","h-100"],["class","res-round h-100",4,"ngIf"],[1,"res-round","h-100"],["class","w-100 h-100","height","","width","","autoplay","","loop","","muted","","playsinline","",3,"canplay",4,"ngIf"],["class","btn-video-action btn-play position-absolute d-flex align-items-center justify-content-center text-white pointer btn-alpha",3,"click",4,"ngIf"],["height","","width","","autoplay","","loop","","muted","","playsinline","",1,"w-100","h-100",3,"canplay"],["class","w-100 h-100","height","","width","",3,"src",4,"ngIf"],["height","","width","",1,"w-100","h-100",3,"src"],[1,"changeWithAIBtn","text-white","d-flex","align-items-center","justify-content-center","position-absolute","text-13","text-semi",2,"right","8px","bottom","8px",3,"click"],["name","remixbutton",1,"f-16","me-1"],["id","previewFileInput","name","previewFileInput","type","file","aria-label","Upload input image",1,"custom-file-input","d-none",3,"change","click","accept"],["class","intermediate-image-area d-flex align-items-center justify-content-center overflow-hidden w-100 flex-column pt-3",3,"image-preview",4,"ngIf"],[1,"intermediate-image-area","d-flex","align-items-center","justify-content-center","overflow-hidden","w-100","flex-column","pt-3"],[1,"d-flex","align-items-start","justify-content-center","overflow-hidden","border-radius-12","position-relative","w-100","bg-grey3","h-100",3,"click"],["class","d-flex justify-content-start w-100 custom-displayed text-bold grey-300 text-40 lh-125 ps-4 h-100 align-items-center",4,"ngIf"],["class","d-flex align-items-center justify-content-center w-100 h-100",4,"ngIf"],["class","d-flex align-items-center justify-content-start overflow-hidden h-100 w-100 border-radius-12 position-relative",4,"ngIf"],[1,"d-flex","align-items-center","justify-content-start","overflow-hidden","h-100","w-100","border-radius-12","position-relative"],[3,"error","src"],[1,"d-flex","justify-content-start","w-100","custom-displayed","text-bold","grey-300","text-40","lh-125","ps-4","h-100","align-items-center"],[1,"d-flex","align-items-center","justify-content-center","w-100","h-100"],[1,"btn-upload","btn-mobile-upload","text-semi","btn","btn-primary","d-flex","align-items-center","justify-content-center","btn-h48","ps-3","pe-3",3,"click"],["name","plussquare",1,"me-2","f-24","text-white"],[1,"w-100","h-100",3,"src"],[1,"d-flex","align-items-start","justify-content-center","overflow-hidden","border-radius-12","position-relative","w-100","h-100",3,"click"],["class","res-round border-radius-12 position-relative",4,"ngIf"],[1,"res-round","border-radius-12","position-relative"],["autoplay","","loop","","muted","","playsinline","",1,"border-radius-12",3,"canplay","ended","ngClass"]],template:function(t,i){1&t&&e.DNE(0,xn,24,8,"div",3)(1,On,34,24)(2,Un,4,3),2&t&&e.vxM(i.videoPreview&&i.videoUrl?0:null!=i.aiPhotoService&&i.aiPhotoService.aiImages&&null!=i.aiPhotoService&&i.aiPhotoService.aiImages.length?1:null==i.aiPhotoService||!i.aiPhotoService.aiImages||null!=i.aiPhotoService&&i.aiPhotoService.aiImages.length?-1:2)},dependencies:[b.YU,b.Sq,b.bT,R.Oj,R.bD,H.b,Pe.m],styles:[".original-image[_ngcontent-%COMP%]   img[_ngcontent-%COMP%]{width:100%;height:100%;overflow:hidden;object-fit:contain}.intermediate-image-area[_ngcontent-%COMP%]{padding-left:1rem;padding-right:1rem;height:100%}.intermediate-image-area[_ngcontent-%COMP%]   img[_ngcontent-%COMP%]{width:100%;height:100%;overflow:hidden;object-fit:contain}.intermediate-image-area.image-preview[_ngcontent-%COMP%]{padding-left:0rem!important;padding-right:0rem!important;padding-top:0!important;height:calc(100vh - 356px)}
1.intermediate-slider[_ngcontent-%COMP%]{height:calc(100vh - 356px)}.res-round[_ngcontent-%COMP%]{overflow:hidden;display:flex;justify-content:center;align-items:center;margin:0 auto}.res-round[_ngcontent-%COMP%]   img[_ngcontent-%COMP%]{width:100%;height:100%;max-width:100%;max-height:100%;object-fit:contain}.generation-preview-section[_ngcontent-%COMP%]   .generation-thumb-preview[_ngcontent-%COMP%]{width:100%;min-width:320px;min-height:424px;max-height:424px;overflow:hidden;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px)}.generation-preview-section[_ngcontent-%COMP%]   .generation-thumb-preview[_ngcontent-%COMP%]   img[_ngcontent-%COMP%], .generation-preview-section[_ngcontent-%COMP%]   .generation-thumb-preview[_ngcontent-%COMP%]   video[_ngcontent-%COMP%]{height:100%;object-fit:contain;width:100%;max-height:424px}.generation-preview-section[_ngcontent-%COMP%]   .generation-thumb-details[_ngcontent-%COMP%]   .prompt-textbox[_ngcontent-%COMP%]{border:1px solid #EEEDF3;background:#eeedf366}.btn-video-action[_ngcontent-%COMP%]{bottom:8px;height:40px;width:40px;border-radius:40px;background:#60657699;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);border:0px}.btn-video-action[_ngcontent-%COMP%]:hover{background:#606576cc}.btn-play[_ngcontent-%COMP%]{left:8px}.btn-audio[_ngcontent-%COMP%]{right:8px}.vid-time[_ngcontent-%COMP%]{border-radius:6px;background:#5f6578b3;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);padding:2px 6px;bottom:18px;left:56px}.report-flag[_ngcontent-%COMP%]{border-radius:100px;background:#60657633;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);right:56px}"]}),a})();var Je=m(41584),Dn=m(77048),Nn=m(88141),bt=m(29615);const Xn=["cpText"],Ln=s=>({"d-flex":s}),Yn=(s,a,n)=>({"info-up":s,"info-blue":a,"info-red":n}),Be=s=>({"d-none":s});function $n(s,a){if(1&s&&(e.j41(0,"span",15),e.EFF(1),e.k0s()),2&s){const n=e.XpG(2);e.R7$(),e.Lme("",n.textPrompt.length,"/",n.maxLength,"")}}function zn(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",16)(1,"buttons-scroll-menu",17),e.bIt("selectLayout",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.selectPrompt(i))}),e.k0s()()}if(2&s){const n=e.XpG(2);e.R7$(),e.Y8G("items",n.prompts)("type","prompt-mobile")}}function Hn(s,a){1&s&&(e.j41(0,"div",20)(1,"div",21),e.EFF(2,"Resolution"),e.k0s()())}function Wn(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",22),e.bIt("click",function(){e.eBV(n);const i=e.XpG(3);return e.Njj(i.isResolution=!0)}),e.j41(1,"div",23)(2,"div",24),e.nrm(3,"pi",25),e.j41(4,"div",26),e.EFF(5),e.k0s(),e.j41(6,"div",27),e.EFF(7),e.k0s()(),e.j41(8,"div",28),e.EFF(9),e.k0s()(),e.j41(10,"div",29),e.nrm(11,"pi",30),e.k0s()()}if(2&s){const n=e.XpG(3);e.R7$(3),e.Y8G("name",null==n.selectedSize?null:n.selectedSize.icon),e.R7$(2),e.SpI(" ",null==n.selectedSize?null:n.selectedSize.name," "),e.R7$(2),e.SpI(" ",null==n.selectedSize?null:n.selectedSize.ratio," "),e.R7$(2),e.SpI(" ",null==n.selectedSize?null:n.selectedSize.size," px ")}}function qn(s,a){if(1&s&&(e.j41(0,"div"),e.DNE(1,Hn,3,0,"div",18)(2,Wn,12,4,"div",19),e.k0s()),2&s){const n=e.XpG(2);e.R7$(),e.Y8G("ngIf",n.resolutionEnabled),e.R7$(),e.Y8G("ngIf",n.resolutionEnabled)}}function Kn(s,a){1&s&&e.nrm(0,"div")}function Zn(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"div",4)(2,"div",5),e.EFF(3,"Enter Prompt "),e.k0s()(),e.j41(4,"div",6)(5,"div",7)(6,"div",8)(7,"div",9)(8,"div",10)(9,"textarea",11,1),e.mxI("ngModelChange",function(i){e.eBV(n);const o=e.XpG();return e.DH7(o.textPrompt,i)||(o.textPrompt=i),e.Njj(i)}),e.bIt("keyup",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.changeTextPrompt())})("paste",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.onPaste(i))})("blur",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.focusOut())})("focus",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.focusIn())})("keydown.enter",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.onEnter(i))}),e.k0s(),e.DNE(11,$n,2,2,"span",12),e.k0s(),e.DNE(12,zn,2,2,"div",13)(13,qn,3,2,"div",2),e.k0s()()()(),e.DNE(14,Kn,1,0,"div",14),e.bVm()}if(2&s){const n=e.XpG(),t=e.sdS(3);e.R7$(8),e.AVh("less-prompt-height",n.resolutionEnabled),e.Y8G("ngClass",e.sMw(11,Yn,n.textPrompt.length,n.isFocused,n.textPrompt.length==n.maxLength)),e.R7$(),e.AVh("blue-active",n.isFocused),e.Y8G("maxlength",n.maxLength),e.R50("ngModel",n.textPrompt),e.R7$(2),e.Y8G("ngIf",n.textPrompt.length),e.R7$(),e.Y8G("ngIf",null==n.prompts?null:n.prompts.length),e.R7$(),e.Y8G("ngIf",n.showResolution),e.R7$(),e.Y8G("ngTemplateOutlet",t)}}function Jn(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",41)(1,"buttons-scroll-menu",17),e.bIt("selectLayout",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.selectPrompt(i))}),e.k0s()()}if(2&s){const n=e.XpG(2);e.R7$(),e.Y8G("items",n.prompts)("type","prompt-mobile")}}function Qn(s,a){1&s&&e.nrm(0,"div")}function eo(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"div",31),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return i.focusIn(),e.Njj(i.openPrompt())}),e.j41(2,"div",32)(3,"span",33),e.EFF(4,"Imagine anything, type it"),e.k0s(),e.j41(5,"span",34),e.EFF(6),e.k0s()()(),e.DNE(7,Jn,2,2,"div",35),e.j41(8,"div",36)(9,"div",37)(10,"model-selection",38),e.bIt("modelChange",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.onModelChange(i))})("modelButtonChange",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.onModelButtonChange(i))}),e.k0s(),e.DNE(11,Qn,1,0,"div",14),e.k0s(),e.j41(12,"div",39),e.nrm(13,"model-selection",40),e.k0s()(),e.bVm()}if(2&s){const n=e.XpG(),t=e.sdS(3);e.R7$(3),e.Y8G("ngClass",e.eq3(12,Be,n.textPrompt&&""!=n.textPrompt)),e.R7$(3),e.JRh(n.textPrompt),e.R7$(),e.Y8G("ngIf",null==n.prompts?null:n.prompts.length),e.R7$(),e.AVh("generate-btn-fixed","v2"==n.version),e.R7$(2),e.Y8G("type","model-dropdown-video")("selectedModel",n.selectedModel)("featureType",n.featureType),e.R7$(),e.Y8G("ngTemplateOutlet",t),e.R7$(2),e.Y8G("type","model-button-video")("selectedModel",n.selectedModel)("featureType",n.featureType)}}function to(s,a){1&s&&(e.j41(0,"div",50)(1,"span",51),e.EFF(2,"Loa
1ding..."),e.k0s()())}function io(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",42)(1,"button",43),e.bIt("keyup.enter",function(){e.eBV(n);const i=e.XpG();return i.focusOut(),e.Njj(i.generate())})("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.generate())}),e.DNE(2,to,3,0,"div",44),e.j41(3,"span",45),e.EFF(4),e.k0s(),e.j41(5,"span",46),e.nrm(6,"img",47)(7,"img",48),e.j41(8,"b",49),e.EFF(9),e.k0s()()()()}if(2&s){const n=e.XpG();e.R7$(),e.Y8G("disabled",n.disabled),e.R7$(),e.Y8G("ngIf",n.isVideo&&n.aiPhotoService.inVideoProgress||n.aiPhotoService.inProgress),e.R7$(2),e.JRh(n.isVideo&&n.aiPhotoService.inVideoProgress||n.aiPhotoService.inProgress?"Processing":"Generate"),e.R7$(),e.Y8G("ngClass",e.eq3(7,Be,n.isVideo&&n.aiPhotoService.inVideoProgress||n.aiPhotoService.inProgress)),e.R7$(),e.Y8G("ngClass",e.eq3(9,Be,n.disabled)),e.R7$(),e.Y8G("ngClass",e.eq3(11,Be,!n.disabled)),e.R7$(2),e.JRh(n.credit)}}function no(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",57),e.bIt("click",function(){const i=e.eBV(n).$implicit,o=e.XpG(2);return e.Njj(o.selectSize(i))}),e.j41(1,"div",58),e.nrm(2,"pi",59),e.j41(3,"span",60),e.EFF(4),e.k0s(),e.j41(5,"span",61),e.EFF(6),e.k0s()(),e.j41(7,"div",58)(8,"span",62),e.EFF(9),e.k0s()()()}if(2&s){const n=a.$implicit;e.R7$(2),e.FS9("name",n.icon),e.R7$(2),e.JRh(n.name),e.R7$(2),e.JRh(n.ratio),e.R7$(3),e.SpI("",n.size," px")}}function oo(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"div",52),e.bIt("close",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.isResolution=!1)}),e.j41(2,"div",53)(3,"h3",54),e.EFF(4," Resolution"),e.j41(5,"pi",55),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.isResolution=!1)}),e.k0s()()(),e.DNE(6,no,10,4,"div",56),e.k0s(),e.bVm()}if(2&s){const n=e.XpG();e.R7$(6),e.Y8G("ngForOf",n.resolutions)}}let so=(()=>{var s;class a{constructor(t){this.aiPhotoService=t,this.isVideo=!1,this.prompts=[],this.textPrompt="",this.resolutionEnabled=!1,this.changePrompt=new e.bkB,this.generateClick=new e.bkB,this.selectModel=new e.bkB,this.changeResolution=new e.bkB,this.openPromptClick=new e.bkB,this.maxLength=2e3,this.isFocused=!1,this.intervalSub=null,this.placeholder="Imagine anything, type it",this.credit=1,this.disabled=!1,this.version="v1",this.resolutions=[],this.quality=0,this.autoFocusOnOpen=!1,this.isResolution=!1,this.selectedModel=null,this.showResolution=!1}ngOnInit(){}ngOnChanges(t){this.resolutionEnabled&&setTimeout(()=>{this.showResolution=!0},350),t.autoFocusOnOpen?.currentValue&&!t.autoFocusOnOpen?.previousValue&&(this.focusIn(),setTimeout(()=>{this.cpText?.nativeElement?.focus()},100))}ngAfterViewInit(){this.resolutions=this.aiPhotoService.getResolutionDesignEditor("Standard"),this.selectedSize=this.resolutions.find(t=>t.qType==this.quality)||this.resolutions[0]}generate(){this.resolutionEnabled&&setTimeout(()=>{this.changeResolution.emit(this.selectedSize.qType)},3e3),this.changePrompt.emit(this.textPrompt),this.generateClick.emit()}selectPrompt(t){this.textPrompt=t.prompt,this.changePrompt.emit(this.textPrompt)}changeTextPrompt(){this.changePrompt.emit(this.textPrompt)}onPaste(t){this.textPrompt=t.target.value,this.changePrompt.emit(this.textPrompt)}onEnter(t){this.changePrompt.emit(this.textPrompt),this.cpText.nativeElement.blur()}focusIn(){document.body.classList.add("overflow-hidden"),this.isFocused=!0,this.intervalSub&&this.intervalSub.unsubscribe();const t=(i=0)=>{setTimeout(()=>{this.cpText&&(this.cpText.nativeElement.placeholder=""),i<2&&this?.cpText?.nativeElement?.placeholder&&(i++,t(i))},500)};t()}focusOut(){document.body.classList.remove("overflow-hidden"),this.isFocused=!1,this.intervalSub&&this.intervalSub.unsubscribe(),!this.textPrompt&&"v1"==this.version&&this.prompts?.length&&setTimeout(()=>{this.cpText.nativeElement.placeholder=this.prompts&&this.prompts.length?this.prompts[0].prompt:"",this.textAnimation()},500)}textAnimation(){this.intervalSub&&this.intervalSub.unsubscribe();let t=0;const i=()=>{if(t==this.prompts.length)return void this.focusOut();const o=this.prompts[t].prompt;let r=0;this.intervalSub=(0,Je.O)(0,75).pipe((0,Dn.v)(()=>r<o.length,!0),(0,Nn.M)(()=>{r<o.length?(this.cpText.nativeElement.placeholder+=o[r],r++):(this.intervalSub.unsubscribe(),this.intervalSub=(0,Je.O)(1e3).subscribe(()=>{this.cpText.nativeElement.placeholder="",t++,(0,Je.O)(500).subscribe(i)}))})).subscribe()};i()}openPrompt(){this.openPromptClick.emit(!0),this.focusIn()}selectSize(t){this.selectedSize=t,this.isResolution=!1,this.changeResolution.emit(this.selectedSize.qType)}ngOnDestroy(){this.intervalSub&&this.intervalSub.unsubscribe()}onModelChange(t){this.updateModelSelection(t)}onModelButtonChange(t){this.updateModelSelection(t)}updateModelSelection(t){t&&(this.selectedModel=t,this.selectModel.emit(t))}}return(s=a).\u0275fac=function(t){return new(t||s)(e.rXU(Z.s))},s.\u0275cmp=e.VBU({type:s,selectors:[["text-prompt-mobile"]],viewQuery:function(t,i){if(1&t&&e.GBs(Xn,5),2&t){let o;e.mGM(o=e.lsd())&&(i.cpText=o.first)}},inputs:{isVideo:"isVideo",prompts:"prompts",textPrompt:"textPrompt",resolutionEnabled:"resolutionEnabled",maxLength:"maxLength",credit:"credit",disabled:"disabled",version:"version",quality:"quality",autoF
1ocusOnOpen:"autoFocusOnOpen",featureType:"featureType"},outputs:{changePrompt:"changePrompt",generateClick:"generateClick",selectModel:"selectModel",changeResolution:"changeResolution",openPromptClick:"openPromptClick"},features:[e.OA$],decls:6,vars:6,consts:[["generateButton",""],["cpText",""],[4,"ngIf"],[1,"showpreview-overlay","align-items-center","justify-content-start","position-fixed",2,"left","0px",3,"click","ngClass"],[1,"wp-100","d-flex","align-items-center","justify-content-between","mb-2"],[1,"text-lg","text-semi","grey-800"],[1,"card","drawer-card","mb-3","mt-0"],[1,"card-body"],[1,"btn-panel"],[1,"card-body","prompt-view"],[1,"textarea-col","position-relative",3,"ngClass"],["id","cprompt","name","cprompt","rows","4","cols","50",1,"prompt-text",3,"ngModelChange","keyup","paste","blur","focus","keydown.enter","maxlength","ngModel"],["class","prompt-info text-regular position-relative d-flex align-items-center",4,"ngIf"],["class","d-flex mt-3 mobile-prompt",4,"ngIf"],[4,"ngTemplateOutlet"],[1,"prompt-info","text-regular","position-relative","d-flex","align-items-center"],[1,"d-flex","mt-3","mobile-prompt"],[2,"max-width","-webkit-fill-available",3,"selectLayout","items","type"],["class","d-flex align-items-center h-32 mb-1 mt-10",4,"ngIf"],["class","d-flex w-100 justify-content-between align-items-center resolution-custom p-1 pl-9 pr-9 border-radius-12 pointer",3,"click",4,"ngIf"],[1,"d-flex","align-items-center","h-32","mb-1","mt-10"],[1,"text-lg","text-dark","text-semi","lh-125"],[1,"d-flex","w-100","justify-content-between","align-items-center","resolution-custom","p-1","pl-9","pr-9","border-radius-12","pointer",3,"click"],[1,"d-flex","align-items-center","justify-content-between","option-with-icon"],[1,"d-inline-flex","align-items-center","justify-content-center"],[1,"right-sign","hw-24","me-2","d-inline-flex","align-items-center","justify-content-center","f-24","grey-600",3,"name"],[1,"d-inline-flex","f-13","text-medium","me-1","text-13","text-black"],[1,"d-inline-flex","me-1","item-ratio","text-semi","align-items-center","justify-content-center","grey-600","text-12","p-1","h-24","lh-normal"],[1,"d-inline-flex","text-medium","align-items-center","justify-content-center","text-black","text-13","mr-9",2,"white-space","nowrap"],[1,"arrow-img","d-inline-flex","align-items-center","justify-content-centerme-2",2,"margin-left","-3px"],["name","chevronaarrow",1,"hw-24"],[1,"d-flex","align-items-center","justify-content-start","mb-3","mt-0","ps-3","pe-3",3,"click"],[1,"d-flex","align-items-start","justify-content-start","text-mask","border-radius-12","text-13","text-regular","grey-800","w-100","overflow-hidden","position-relative"],[1,"grey-500",3,"ngClass"],[2,"overflow","hidden"],["class","d-flex mobile-prompt ps-3 mb-3",4,"ngIf"],[1,"d-flex","w-100","flex-column","generate-btn"],[1,"d-flex","w-100"],[1,"mt-2",3,"modelChange","modelButtonChange","type","selectedModel","featureType"],[1,"d-flex","w-100","align-items-center","justify-content-center"],[1,"mt-1",3,"type","selectedModel","featureType"],[1,"d-flex","mobile-prompt","ps-3","mb-3"],[1,"d-flex","align-items-center","justify-content-center","w-100","ps-3","pe-3","mt-2","flex-column","when-model"],["id","gtm-generate-mob",1,"btn","btn-primary-gradient","btn-primary-m","text-13","btn-h44","w-100","d-flex","align-items-center","justify-content-center",3,"keyup.enter","click","disabled"],["class","spinner-border spinner-border-lg me-2 hw-24","role","status",4,"ngIf"],[1,"text-lg"],[1,"coin-count","d-inline-flex","align-items-center","justify-content-center","ms-2",3,"ngClass"],["src","https://static.lightxeditor.com/assets/images/Coin-AI-16.svg","height","16px","width","16px",1,"inable",3,"ngClass"],["src","https://static.lightxeditor.com/assets/images/Coin-AI-disabled-16.svg","height","16px","width","16px",1,"disable",3,"ngClass"],[1,"text-11","text-semi",2,"padding-left","2px"],["role","status",1,"spinner-border","spinner-border-lg","me-2","hw-24"],[1,"sr-only","text-nowrap","border-0","position-absolute","overflow-hidden"],[1,"d-flex","justify-content-start","align-items-center","bottom-container","position-fixed","bg-white","p-3","pt-2","pb-9","flex-column","w-100",2,"bottom","0px","z-index","9999","transition","all 3s ease-in-out","left","0px",3,"close"],[1,"top-header","d-flex","justify-content-start","align-items-center","w-100","flex-column","mb-1","h-32"],[1,"text-lg","text-semi","grey-800","m-0","w-100","lh-125","w-100","d-flex","align-items-center","justify-content-between","h-32"],["name","previewclose",3,"click"],["class","modal-box resolution-modal d-flex justify-content-between align-items-center w-100 border-radius-12 pl-9 pr-9 mb-2 h-48",3,"click",4,"ngFor","ngForOf"],[1,"modal-box","resolution-modal","d-flex","justify-content-between","align-items-center","w-100","border-radius-12","pl-9","pr-9","mb-2","h-48",3,"click"],[1,"d-flex","justify-content-center","align-items-center"],[1,"f-24","grey-600","me-2",3,"name"],[1,"grey-800","text-13","text-semi"],[1,"grey-600","text-12","text-semi","ms-1","p-1","ratio-box","d-inline-flex","align-items-center","justify-content-center","lh-normal"],[1,"grey-600","text-semi","text-13"]],template:function(t,i){if(1&t){const o=e.RV6();e.DNE(0,Zn,15,15,"ng-container",2)(1,eo,14,14,"ng-container",2)(2,io,10,13,"ng-template",null,0,e.C5r)(4,oo,7,1,"ng-container",2),e.j41(5,"div",3),e.bIt("click",function(){return e.eBV(o),e.Njj(i.isResolution=!1)}),e.k0s()}2&t&&(e.Y8G("ngIf","v1"==i.version),e.R7$(),e.Y8G("ngIf","v2"==i.version),e.R7$(3),e.Y8G("ngIf",i.isResolution),e.R7$(),e.Y8G("ngClass",e.eq3(4,Ln,i.isResolution)))},dependencies:[b.YU,b.Sq,b.bT,b.T3,P.me,P.BC,P.tU,P.vS,H.b,_e.B,bt.x],styles:['.prompt-view[_ngcontent-%COMP%]   .textarea-col[_ngcontent-%COMP%]{width:100%;height:188px;border-radius:12px;border:0px!important;background:linear-gradient(90deg,#fc5cff05 -4%,#2520f605);padding:0 4px 4px}.prompt-view[_ngcontent-%COMP%]   .textarea-col[_ngcontent-%COMP%]:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:12px;padding:.9px;border:none;background:linear-gradient(90deg,#c9cad4 -4% 100%);-webkit-mask:linear-gradient(90deg,#C9CAD4 -4%,#C9CAD4 100%) content-box,linear-gradient(90deg,#C9CAD4 -4%,#C9CAD4 100%);-webkit-mask-composite:xor;mask-composite:exclude;z-index:1}.prompt-view[_ngcontent-%COMP%]   .textarea-col[_ngcontent-%COMP%]:hover:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:12px;padding:.9px;border:none;background:linear-gradient(90deg,#606576 -4% 100%);-webkit-mask:linear-gradient(90deg,#606576 -4%,#606576 100%) content-box,linear-gradient(90deg,#606576 -4%,#606576 100%);-webkit-mask-composite:xor;mask-composite:exclude;z-index:1}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]{resize:none;outline:none;width:100%;height:162px;padding:8px;font-size:12px;color:#b0b3bf;border:0px;background:transparent;border-radius:12px;line-height:18px;position:relative;z-index:2}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]::-webkit-scrollbar{width:4px;height:4px;border-radius:12px}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]::-webkit-scrollbar-track{background:#e3e3e3;border-radius:12px;margin-top:8px}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background:#9a9a9a;border-radius:12px}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]::-webkit-scrollbar-thumb:hover{background:#555}.prompt-view[_ngcontent-%COMP%]   .prompt-info[_ngcontent-%COMP%]{font-size:11px;color:#b0b3bf;margin-top:0;padding-left:8px;line-height:10px;min-height:8px}.info-up[_ngcontent-%COMP%]:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:12px;padding:.9px;border:none;background:linear-gradient(90deg,#c9cad4 -4% 100%)!important;-webkit-mask:linear-gradient(90deg,#C9CAD4 -4%,#C9CAD4 100%) content-box,linear-gradient(90deg,#C9CAD4 -4%,#C9CAD4 100%)!important;-webkit-mask-composite:xor!important;mask-composite:exclude!important;z-index:1}.info-blue[_ngcontent-%COMP%]{background:linear-gradient(90deg,#fc5cff0d -4%,#2520f60d)!important}.info-blue[_ngcontent-%COMP%]:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:12px;padding:.92px;border:none;background:linear-gradient(90deg,#fc5cff -4%,#2520f6)!important;-webkit-mask:linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%) content-box,linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%)!important;-webkit-mask-composite:xor!important;mask-composite:exclude!important;z-index:1}.info-blue[_ngcontent-%COMP%]   span[_ngcontent-%COMP%]{color:#626adf!important}.info-red[_ngcontent-%COMP%]{background:linear-gradient(90deg,#fc5cff0d -4%,#2520f60d)!important}.info-red[_ngcontent-%COMP%]:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:12px;padding:.92px;border:none;background:linear-gradient(90deg,#f25555 -4% 100%)!important;-webkit-mask:linear-gradient(90deg,#F25555 -4%,#F25555 100%) content-box,linear-gradient(90deg,#F25555 -4%,#F25555 100%)!important;-webkit-mask-composite:xor!important;mask-composite:exclude!important;z-index:1}.info-red[_ngcontent-%COMP%]   span[_ngcontent-%COMP%]{color:#f25555!important}.prompt-text[_ngcontent-%COMP%]{color:#272b34!important}.text-mask[_ngcontent-%COMP%]{border:1px solid #C9CAD4;background:linear-gradient(90deg,#fc5cff05 -4%,#2520f605);height:110px;padding:8px 12px}.resolution-custom[_ngcontent-%COMP%]{border:1px solid #E2E3E9;background:#626adf0d;height:48px}.resolution-custom[_ngcontent-%COMP%]   .option-with-icon[_ngcontent-%COMP%]{justify-content:start}.resolution-custom[_ngcontent-%COMP%]   .option-with-icon[_ngcontent-%COMP%]   pi[_ngcontent-%COMP%]{color:#c9cad4}.resolution-custom[_ngcontent-%COMP%]   .option-with-icon[_ngcontent-%COMP%]   .icon[_ngcontent-%COMP%]{display:none}.resolution-custom[_ngcontent-%COMP%]   .option-with-icon[_ngcontent-%COMP%]   .item-ratio[_ngcontent-%COMP%]{border-radius:6px;background:var(--colors-newgrey-transparent-primary-10, rgba(98, 106, 223, .1));letter-spacing:.26px}.resolution-custom[_ngcontent-%COMP%]   .option-with-icon[_ngcontent-%COMP%]   .arrow-img[_ngcontent-%COMP%]   pi[_ngcontent-%COMP%]{color:#272b34}.resolution-custom[_ngcontent-%COMP%]:hover{background:#626adf1a}.bottom-container[_ngcontent-%COMP%]{border-radius:20px 20px 0 0}
1.bottom-container[_ngcontent-%COMP%]   .modal-box[_ngcontent-%COMP%]{background:#626adf0d;position:relative}.bottom-container[_ngcontent-%COMP%]   .modal-box[_ngcontent-%COMP%]   .icon-box[_ngcontent-%COMP%]{border-radius:6px;background:#626adf1a}.bottom-container[_ngcontent-%COMP%]   .modal-box[_ngcontent-%COMP%]   .coin-box[_ngcontent-%COMP%]{border:1px solid #C9CAD4;padding:0 6px 0 4px;min-height:24px;min-width:42px}.bottom-container[_ngcontent-%COMP%]   .resolution-modal[_ngcontent-%COMP%]{min-height:40px}.bottom-container[_ngcontent-%COMP%]   .resolution-modal[_ngcontent-%COMP%]   .ratio-box[_ngcontent-%COMP%]{border-radius:6px;background:#626adf1a;min-height:25px}.bottom-container[_ngcontent-%COMP%]   .active-modal[_ngcontent-%COMP%], .bottom-container[_ngcontent-%COMP%]   .active-resolution[_ngcontent-%COMP%]{position:relative}.bottom-container[_ngcontent-%COMP%]   .active-modal[_ngcontent-%COMP%]   .icon-box[_ngcontent-%COMP%], .bottom-container[_ngcontent-%COMP%]   .active-modal[_ngcontent-%COMP%]   .ratio-box[_ngcontent-%COMP%], .bottom-container[_ngcontent-%COMP%]   .active-resolution[_ngcontent-%COMP%]   .icon-box[_ngcontent-%COMP%], .bottom-container[_ngcontent-%COMP%]   .active-resolution[_ngcontent-%COMP%]   .ratio-box[_ngcontent-%COMP%]{background:linear-gradient(90deg,#fc5cff1a -4%,#2520f61a)}.bottom-container[_ngcontent-%COMP%]   .active-modal[_ngcontent-%COMP%]   .coin-box[_ngcontent-%COMP%], .bottom-container[_ngcontent-%COMP%]   .active-resolution[_ngcontent-%COMP%]   .coin-box[_ngcontent-%COMP%]{position:relative;border:0px}.bottom-container[_ngcontent-%COMP%]   .active-modal[_ngcontent-%COMP%]   .coin-box[_ngcontent-%COMP%]:after, .bottom-container[_ngcontent-%COMP%]   .active-resolution[_ngcontent-%COMP%]   .coin-box[_ngcontent-%COMP%]:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:12px;padding:.9px;border:0px;background:linear-gradient(90deg,#fc5cff -4%,#2520f6);-webkit-mask:linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%) content-box,linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%);-webkit-mask-composite:xor;mask-composite:exclude}.bottom-container[_ngcontent-%COMP%]   .active-modal[_ngcontent-%COMP%]:after, .bottom-container[_ngcontent-%COMP%]   .active-resolution[_ngcontent-%COMP%]:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:12px;padding:1.3px;border:none;background:linear-gradient(90deg,#fc5cff -4%,#2520f6);-webkit-mask:linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%) content-box,linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%);-webkit-mask-composite:xor;mask-composite:exclude}.bottom-container[_ngcontent-%COMP%]   .modal-box[_ngcontent-%COMP%]:last-child{margin-bottom:0!important}.showpreview-overlay[_ngcontent-%COMP%]{display:none;background:#0003;-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);width:100%;height:100%;top:0;bottom:0;z-index:999}.textarea-col.less-prompt-height[_ngcontent-%COMP%]{height:110px!important}.textarea-col.less-prompt-height[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]{height:88px!important}.btn[_ngcontent-%COMP%]:disabled   .coin-count[_ngcontent-%COMP%]{background:#0000001a}.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}.coin-count[_ngcontent-%COMP%]   b[_ngcontent-%COMP%]{color:#fff!important}']}),a})();var fe=m(43695);const je=s=>({"ai-thumb-active":s});function ro(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",22),e.bIt("click",function(){e.eBV(n),e.XpG();const i=e.sdS(18),o=e.XpG();return e.Njj(o.addStyleImage(i))}),e.j41(1,"div",23)(2,"div"),e.nrm(3,"pi",24),e.k0s(),e.j41(4,"span",25),e.EFF(5," Tap to upload image here "),e.k0s()(),e.j41(6,"span",14),e.EFF(7,"Custom"),e.k0s()()}}function ao(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",26)(1,"div",27),e.bIt("click",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.selectUploadStyle())}),e.j41(2,"div",28),e.nrm(3,"img",29),e.k0s(),e.j41(4,"span",30),e.EFF(5,"Custom"),e.k0s()(),e.j41(6,"div",31)(7,"button",32),e.bIt("click",function(){e.eBV(n),e.XpG();const i=e.sdS(18),o=e.XpG();return e.Njj(o.addStyleImage(i))}),e.nrm(8,"pi",33),e.EFF(9,"Replace Image "),e.k0s(),e.j41(10,"button",34),e.bIt("click",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.removetUploadStyle())}),e.nrm(11,"pi",35),e.EFF(12,"Remove Image "),e.k0s()()()}if(2&s){const n=e.XpG(2);e.R7$(),e.Y8G("ngClass",e.eq3(2,je,"Custom"==(null==n.selectedStyle?null:n.selectedStyle.displayName))),e.R7$(2),e.Y8G("src",n.thumbUrl,e.B4B)}}function lo(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",42),e.bIt("click",function(){const i=e.eBV(n).$implicit,o=e.XpG().$implicit,r=e.XpG(3);return e.Njj(r.selectStyle(i,o))}),e.j41(1,"div",28),e.nrm(2,"img",43),e.k0s(),e.j41(3,"span",30),e.EFF(4),e.k0s()()}if(2&s){const n=a.$implicit,t=e.XpG(4);e.Y8G("ngClass",e.eq3(3,je,n.productImageId==(null==t.selectedStyle?null:t.selectedStyle.productImageId))),e.R7$(2),e.Y8G("src",n.thumbUrl,e.B4B),e.R7$(2),e.JRh(n.displayName)}}function co(s,a){if(1&s&&(e.j41(0,"div",38)(1,"h5",39),e.EFF(2),e.k0s(),e.j41(3,"div",40),e.DNE(4,lo,5,5,"div",41),e.k0s()()),2&s){const n=a.$implicit;e.R7$(2),e.JRh(n.displayName),e.R7$(2),e.Y8G("ngForOf",n.storeProductImages)}}function ho(s,a){if(1&s&&(e.j41(0,"div",36),e.DNE(1,co,5,2,"div",37),e.k0s()),2&s){const n=e.XpG(2);e.R7$(),e.Y8G("ngForOf",n.products)}}function po(s,a){1&s&&(e.qex(0),e.nrm(1,"element-placeholder",44),e.bVm()),2&s&&(e.R7$(),e.Y8G("view","AiPatterns"))}function mo(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",2)(1,"div",3)(2,"span",4),e.EFF(3," Presets"),e.j41(4,"pi",5),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.close.emit())}),e.k0s()(),e.j41(5,"span",6),e.EFF(6," Choose a style of generated images. Available with SDXL model only. "),e.k0s()(),e.j41(7,"div",7)(8,"div",8)(9,"div",9)(10,"div",10)(11,"div",11),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.selectStyle())}),e.j41(12,"div",12),e.nrm(13,"pi",13),e.k0s()(),e.j41(14,"span",14),e.EFF(15,"None"),e.k0s()()(),e.j41(16,"div",15)(17,"input",16,0),e.bIt("change",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.onFileUploaded(i.srcElement.files))})("click",function(){e.eBV(n);const i=e.sdS(18);return e.Njj(i.value="")}
1),e.k0s(),e.DNE(19,ro,8,0,"div",17)(20,ao,13,4,"div",18),e.k0s()(),e.j41(21,"div",19),e.DNE(22,ho,2,1,"div",20),e.k0s(),e.DNE(23,po,2,1,"ng-container",21),e.k0s()()}if(2&s){const n=e.XpG();e.R7$(10),e.Y8G("ngClass",e.eq3(6,je,"None"==(null==n.selectedStyle?null:n.selectedStyle.displayName))),e.R7$(7),e.Y8G("accept",n.aiUploadImageService.fileImageAccept),e.R7$(2),e.Y8G("ngIf",!n.thumbUrl),e.R7$(),e.Y8G("ngIf",n.thumbUrl),e.R7$(2),e.Y8G("ngIf",n.products.length),e.R7$(),e.Y8G("ngIf",!n.products)}}function uo(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",50)(1,"div",28)(2,"img",51),e.bIt("click",function(){const i=e.eBV(n).$implicit,o=e.XpG(2);return e.Njj(o.selectStyle(i,o.products))}),e.k0s()(),e.j41(3,"span",30),e.EFF(4),e.k0s()()}if(2&s){const n=a.$implicit,t=e.XpG(2);e.Y8G("ngClass",e.eq3(3,je,n.productImageId==t.productImageId)),e.R7$(2),e.Y8G("src",n.thumbUrl,e.B4B),e.R7$(2),e.JRh(n.displayName)}}function go(s,a){1&s&&(e.j41(0,"div",53),e.nrm(1,"div",54)(2,"span",55),e.k0s())}function _o(s,a){if(1&s&&(e.qex(0),e.DNE(1,go,3,0,"div",52),e.bVm()),2&s){const n=e.XpG(2);e.R7$(),e.Y8G("ngForOf",n.loadingPlaceholders)}}function fo(s,a){1&s&&(e.qex(0),e.nrm(1,"element-placeholder",44),e.bVm()),2&s&&(e.R7$(),e.Y8G("view","AiPatterns"))}function vo(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",2)(1,"div",3)(2,"span",4),e.EFF(3," Presets"),e.j41(4,"pi",5),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.close.emit())}),e.k0s()(),e.j41(5,"span",6),e.EFF(6," Select a style for your generations. "),e.k0s()(),e.j41(7,"div",45),e.bIt("scroll",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.onStyleListScroll(i))}),e.j41(8,"div",46),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.selectStyle("",""))}),e.j41(9,"div",47)(10,"div",12),e.nrm(11,"pi",48),e.k0s()(),e.j41(12,"span",14),e.EFF(13,"None"),e.k0s()(),e.DNE(14,uo,5,5,"div",49)(15,_o,2,1,"ng-container",21)(16,fo,2,1,"ng-container",21),e.k0s()()}if(2&s){const n=e.XpG();e.R7$(8),e.Y8G("ngClass",e.eq3(4,je,0==n.productImageId||-1==n.productImageId||!n.productImageId)),e.R7$(6),e.Y8G("ngForOf",null==n.products?null:n.products.storeProductImages),e.R7$(),e.Y8G("ngIf",n.isImagesLoading&&!n.isImagesEnd),e.R7$(),e.Y8G("ngIf",!n.products)}}let Qe=(()=>{var s;class a{constructor(t){this.aiUploadImageService=t,this.products=[],this.selectStyleEvent=new e.bkB,this.styleScrollEnd=new e.bkB,this.close=new e.bkB,this.styleImgUrl="",this.thumbUrl="",this.editorType="",this.productImageId=-1,this.isImagesLoading=!1,this.isImagesEnd=!1,this.loadingPlaceholders=[0,1]}ngOnInit(){this.selectedStyle?this.selectedStyle.styleImgUrl&&(this.styleImgUrl=this.selectedStyle?.styleImgUrl||"",this.thumbUrl=this.selectedStyle?.thumbUrl||""):this.selectedStyle={displayName:"None",styleImgUrl:"",thumbUrl:""}}selectStyle(t=null,i=null){this.selectedStyle={productImageId:t?.productImageId||0,displayName:t?.displayName||"None",imgUrl:t?.imgUrl||"",productId:i?.productId||0,modelTypeId:i?.modelTypeId||0,thumbUrl:this.thumbUrl,styleImgUrl:this.styleImgUrl,imageJson:t?.imageJson||""},this.selectStyleEvent.emit(this.selectedStyle),t&&this.close.emit()}onStyleListScroll(t){const i=t?.target;!i||this.isImagesLoading||this.isImagesEnd||(i.scrollHeight>i.clientHeight+2?i.scrollHeight-(i.scrollTop+i.clientHeight):i.scrollWidth-(i.scrollLeft+i.clientWidth))<=120&&this.styleScrollEnd.emit()}addStyleImage(t){t.click()}selectUploadStyle(){this.selectedStyle.displayName="Custom",this.selectedStyle.isCustom=!0,this.selectStyleEvent.emit(this.selectedStyle)}removetUploadStyle(){this.styleImgUrl="",this.thumbUrl="",this.selectedStyle={displayName:"Custom",styleImgUrl:"",thumbUrl:""},this.selectStyleEvent.emit(this.selectedStyle)}onFileUploaded(t){if(!t)return;const i=t[0];this.getThumbUrl(i),this.aiUploadImageService.aiUploadImage(i,{tab:"text2image",isStyleRefImage:!0}).then(r=>{r&&(this.styleImgUrl=r?.imgUrl,this.selectedStyle={displayName:"Custom",styleImgUrl:this.styleImgUrl,thumbUrl:this.thumbUrl,isCustom:!0},this.selectStyleEvent.emit(this.selectedStyle))})}getThumbUrl(t){const i=URL.createObjectURL(t);return new Promise((o,r)=>{this.aiUploadImageService.loadImage(i).then(l=>{fe.k.checkAndResizeImage(l,(c,d,h)=>{this.thumbUrl=c.src},240,240,"image/jpeg")}).catch(()=>{r()})})}}return(s=a).\u0275fac=function(t){return new(t||s)(e.rXU(ee.M))},s.\u0275cmp=e.VBU({type:s,selectors:[["choose-style"]],inputs:{products:"products",selectedStyle:"selectedStyle",editorType:"editorType",productImageId:"productImageId",isImagesLoading:"isImagesLoading",isImagesEnd:"isImagesEnd",loadingPlaceholders:"loadingPlaceholders"},outputs:{selectStyleEvent:"selectStyleEvent",styleScrollEnd:"styleScrollEnd",close:"close"},decls:2,vars:2,consts:[["file",""],["class","d-flex w-100 flex-column",4,"ngIf"],[1,"d-flex","w-100","flex-column"],[1,"d-flex","align-items-center","justify-content-start","w-100","ps-3","pe-3","flex-column",2,"min-height","20px"],[1,"text-lg","text-semi","grey-800","m-0","w-100","lh-125","w-100","d-flex","align-items-center","justify-content-between","mb-3"],["name","previewclose",3,"click"],[1,"text-13","grey-500","w-100","mt-1","mb-3","lh-160","w-100","d-none"],[1,"d-flex","w-100","ai-thumb-list","perfect-list","ch-style","overflow-scroll","new-scroll-behave",2,"max-height","calc(100vh - 230px)"],[1,"d-flex","align-items-center","w-100","style-ref-top","ps-3","pe-3"],[1,"style-ref-left","d-flex","align-items-center","justify-content-center","me-2"],[1,"ai-thumb-col","d-flex","align-items-center","flex-column","ai-thumb-active",3,"ngClass"],[1,"w-100","mb-1","none-column",3,"click"],[1,"d-flex","align-items-center","justify-content-center","none-variation"],["name","nonemobile",1,"f-24","grey-500"],[1,"text","w-100","text-center"],[1,"style-ref-right","d-flex","align-items-center","justify-content-center","flex-column","mb-3"],["id","fileInputId","name","fileInputId","type","file",1,"custom-file-input","d-none",3,"change","click","accept"],["class","step-1 w-100 d-flex flex-column ",3,"click",4,"ngIf"],["class","step-2 w-100 d-flex",4,"ngIf"],[1,"d-flex","backgound-content","w-100"],["class","d-flex w-100 ai-thumb-list perfect-list ch-style",4,"ngIf"],[4,"ngIf"],[1,"step-1","w-100","d-flex","flex-column",3,"click"],[1,"upload-style-box","mb-1","w-100","d-flex","align-items-center","justify-content-center","flex-column","pointer"],["name","uploadimage",1,"f-24","grey-600"],[1,"grey-800","mt-2"],[1,"step-2","w-100","d-flex"],[1,"ai-thumb-col","d-flex","align-items-center","flex-column","mb-0","me-2",3,"click","ngClass"],[1,"img-col","d-flex","align-items-center","border-radius-12","mb-1"],["width","100%","height","100%",2,"min-height","100%",3,"src"],[1,"w-100","text-center"],[1,"style-btn-col"],[1,"btn","btn-white","text-13","btn-h36","mb-1","w-100","grey-600",3,"click"],["name","replace",1,"f-24","me-2","text-dark"],[1,"btn","btn-white","text-13","btn-h36","w-100","grey-600",3,"click"],["name","deleteoth",1,"f-24","me-2","text-dark"],[1,"d-flex","w-100","ai-thumb-list","perfect-list","ch-style"],["class","d-flex justify-content-start w-100 flex-column",4,"ngFor","ngForOf"],[1,"d-flex","justify-content-start","w-100","flex-column"],[1,"m-0","text-13","text-semi","grey-800","mb-9","lh-125","ps-3","pe-3"],[1,"d-flex","justify-content-start","w-100","new-scroll-behave","overflow-scroll","ps-3","pe-3"],["class","ai-thumb-col d-flex align-items-center flex-column border-radius-12 me-2",3,"ngClass","click",4,"ngFor","ngForOf"],[1,"ai-thumb-col","d-flex","align-items-center","flex-column","border-radius-12","me-2",3,"click","ngClass"],["width","92px","height","92px",1,"border-radius-12",3,"src"],[3,"view"],[1,"d-flex","w-100","ai-thumb-list","justify-content-start","perfect-list","ch-style","design-style","overflow-scroll","new-scroll-behave","ps-3","pe-3",2,"max-height","calc(100vh - 206px
1)",3,"scroll"],[1,"ai-thumb-col","d-inline-flex","align-items-center","flex-column",3,"click","ngClass"],[1,"w-100","mb-1","none-column",2,"transform","none","min-height","104px","min-width","104px"],["name","noneicon1",1,"f-40"],["class","ai-thumb-col d-inline-flex align-items-center flex-column",3,"ngClass",4,"ngFor","ngForOf"],[1,"ai-thumb-col","d-inline-flex","align-items-center","flex-column",3,"ngClass"],["width","115px","height","115px",1,"border-radius-12",3,"click","src"],["class","ai-thumb-col d-inline-flex align-items-center flex-column placeholder-thumb",4,"ngFor","ngForOf"],[1,"ai-thumb-col","d-inline-flex","align-items-center","flex-column","placeholder-thumb"],[1,"img-col","d-flex","align-items-center","border-radius-12","mb-1","skeleton-box"],[1,"skeleton-line"]],template:function(t,i){1&t&&e.DNE(0,mo,24,8,"div",1)(1,vo,17,6,"div",1),2&t&&(e.Y8G("ngIf",i.products&&"design"!=i.editorType),e.R7$(),e.Y8G("ngIf",i.products&&"design"==i.editorType))},dependencies:[b.YU,b.Sq,b.bT,mt.n,H.b],styles:[".ai-thumb-view[_ngcontent-%COMP%]{background:url(https://static.lightxeditor.com/assets/images/tranparent.png);height:134px;position:relative;overflow:hidden;-webkit-user-select:none;user-select:none}.ai-thumb-view[_ngcontent-%COMP%]   img[_ngcontent-%COMP%]{height:100%;width:auto;object-fit:contain;overflow:hidden}.ai-thumb-view[_ngcontent-%COMP%]:hover   .replace-btn[_ngcontent-%COMP%]{display:flex;z-index:99;position:absolute;background:#0006;align-items:center;justify-content:center;height:100%;width:100%;flex-direction:column}.ai-thumb-view[_ngcontent-%COMP%]   .replace-btn[_ngcontent-%COMP%]{display:none}.ai-thumb-view[_ngcontent-%COMP%]   .replace-btn[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]{background:#fff!important;border:0px!important;color:#272b34!important;min-width:124px}.ai-thumb-view[_ngcontent-%COMP%]   .replace-btn[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]:hover{background:linear-gradient(0deg,#626adf0d 0% 100%),#fff!important;color:#272b34}.ai-thumb-view[_ngcontent-%COMP%]   .add-on-404[_ngcontent-%COMP%]{display:flex;z-index:99;position:absolute;background:#0000001a;align-items:center;justify-content:center;height:100%;width:100%;flex-direction:column}.deleteBtn[_ngcontent-%COMP%]{background:none;border-radius:12px;width:40px;height:40px;cursor:pointer;display:flex;align-items:center;justify-content:center}.deleteBtn[_ngcontent-%COMP%]:hover{background:#626adf0d}.form-control[_ngcontent-%COMP%]:disabled{color:#b0b3bf!important;border:1px solid #E2E3E9!important}.opacity-3[_ngcontent-%COMP%]{opacity:.3}.placeholder-thumb[_ngcontent-%COMP%]   .skeleton-box[_ngcontent-%COMP%]{width:104px;height:104px;border-radius:12px;background:linear-gradient(90deg,#f1f2f6 25%,#e5e7ef 37%,#f1f2f6 63%);background-size:400% 100%;animation:_ngcontent-%COMP%_choose-style-skeleton-shimmer 1.2s ease-in-out infinite}.placeholder-thumb[_ngcontent-%COMP%]   .skeleton-line[_ngcontent-%COMP%]{width:72px;height:12px;border-radius:8px;background:linear-gradient(90deg,#f1f2f6 25%,#e5e7ef 37%,#f1f2f6 63%);background-size:400% 100%;animation:_ngcontent-%COMP%_choose-style-skeleton-shimmer 1.2s ease-in-out infinite}@keyframes _ngcontent-%COMP%_choose-style-skeleton-shimmer{0%{background-position:100% 0}to{background-position:0 0}}.popContentBox[_ngcontent-%COMP%]{max-height:349px;overflow:auto;height:100%}@media (min-height: 500px){.popContentBox[_ngcontent-%COMP%]{max-height:200px}}[_ngcontent-%COMP%]::-webkit-scrollbar{width:4px}[_ngcontent-%COMP%]::-webkit-scrollbar-track{box-shadow:inset 0 0 5px #e2e3e9;border-radius:12px;margin-top:5px;margin-bottom:5px}[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background:#626adf;border-radius:12px}[_ngcontent-%COMP%]::-webkit-scrollbar-thumb:hover{background:#626adf}"]}),a})();const bo=s=>({"d-flex":s});function Co(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",10),e.bIt("click",function(){const i=e.eBV(n).$implicit,o=e.XpG(2);return e.Njj(o.selectSize(i))}),e.j41(1,"div",11),e.nrm(2,"pi",12),e.j41(3,"span",13),e.EFF(4),e.k0s(),e.j41(5,"span",14),e.EFF(6),e.k0s()()()}if(2&s){const n=a.$implicit;e.R7$(2),e.FS9("name",n.icon),e.R7$(2),e.JRh(n.name),e.R7$(2),e.JRh(n.ratio)}}function xo(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"div",5),e.bIt("close",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.changeStep(0))}),e.j41(2,"div",6)(3,"h3",7),e.EFF(4," Resolution"),e.j41(5,"pi",8),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.closeModal())}),e.k0s()()(),e.DNE(6,Co,7,3,"div",9),e.k0s(),e.bVm()}if(2&s){const n=e.XpG();e.R7$(6),e.Y8G("ngForOf",n.resolutions)}}function Po(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"div",15),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.changeStep(0))}),e.k0s(),e.j41(2,"div",16),e.bIt("scroll",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.onStylePanelScroll(i))}),e.j41(3,"div",17)(4,"choose-style",18),e.bIt("styleScrollEnd",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.closeChangeEvent.emit({type:"styleScrollEnd"}))})("close",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.changeStep(0))})("selectStyleEvent",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.selectStyle(i))}),e.k0s()()(),e.bVm()}if(2&s){const n=e.XpG();e.R7$(),e.AVh("mobile-sheet-overlay--open",n.stylePanelOpen),e.R7$(),e.AVh("mobile-sheet-anim--open",n.stylePanelOpen),e.R7$(2),e.Y8G("products",n.selectedProduct||n.storeProducts[0])("editorType","design")("productImageId",n.productImageId)("isImagesLoading",n.isStyleImagesLoading)("isImagesEnd",n.isStyleImagesEnd)("loadingPlaceholders",n.styleLoadingPlaceholders)("selectedStyle",n.selectedStyle)}}let Io=(()=>{var s;class a{constructor(t,i){this.aiPhotoService=t,this.renderer=i,this.closeChangeEvent=ne
1w e.bkB,this.storeProducts=[],this.selectedProduct=null,this.layoutVersion="",this.productImageId=-1,this.quality=0,this.step=0,this.isStyleImagesLoading=!1,this.isStyleImagesEnd=!1,this.styleLoadingPlaceholders=[0,1],this.resolutions=[],this.stylePanelMounted=!1,this.stylePanelOpen=!1,this.stylePanelAnimToken=0}ngOnInit(){this.getResolution();const t=this.selectedProduct||this.storeProducts?.[0];this.productImageId&&t?.storeProductImages?.length&&(this.selectedStyle=t.storeProductImages.find(i=>i.productImageId==this.productImageId))}getResolution(){this.resolutions=this.aiPhotoService.getResolutionDesignEditor("v4"==this.layoutVersion?"Video":"Standard"),this.selectedSize=this.resolutions.find(t=>t.qType==this.quality)||this.resolutions[0]}selectSize(t){this.selectedSize=t,this.changeStep(0),this.closeChangeEvent.emit({type:"size",quality:this.selectedSize?.qType})}selectStyle(t){this.selectedStyle=t,this.changeStep(0),this.closeChangeEvent.emit({type:"style",selectedStyle:this.selectedStyle})}onStylePanelScroll(t){if(!this.stylePanelOpen||this.isStyleImagesLoading||this.isStyleImagesEnd)return;const i=t?.target;i&&i.scrollHeight-(i.scrollTop+i.clientHeight)<=120&&this.closeChangeEvent.emit({type:"styleScrollEnd"})}closeModal(){this.changeStep(0),this.closeChangeEvent.emit({type:"size",quality:this.selectedSize?.qType}),this.closeChangeEvent.emit({type:"style",selectedStyle:this.selectedStyle})}changeStep(t){if(this.renderer.removeClass(document.body,`step-overlay${this.step}`),2===t){const i=++this.stylePanelAnimToken,o=!this.stylePanelMounted;return this.stylePanelMounted=!0,this.renderer.addClass(document.body,"step-overlay2"),o?(this.stylePanelOpen=!1,void requestAnimationFrame(()=>{requestAnimationFrame(()=>{i===this.stylePanelAnimToken&&(this.stylePanelOpen=!0)})})):void(this.stylePanelOpen=!0)}this.stylePanelMounted?(this.stylePanelAnimToken++,this.stylePanelOpen=!1,this.renderer.removeClass(document.body,"step-overlay2"),this.step=t):this.step=t,1===t&&this.renderer.addClass(document.body,"step-overlay1")}}return(s=a).\u0275fac=function(t){return new(t||s)(e.rXU(Z.s),e.rXU(e.sFG))},s.\u0275cmp=e.VBU({type:s,selectors:[["app-dropdown-lists"]],inputs:{storeProducts:"storeProducts",selectedProduct:"selectedProduct",layoutVersion:"layoutVersion",productImageId:"productImageId",quality:"quality",step:"step",isStyleImagesLoading:"isStyleImagesLoading",isStyleImagesEnd:"isStyleImagesEnd",styleLoadingPlaceholders:"styleLoadingPlaceholders"},outputs:{closeChangeEvent:"closeChangeEvent"},decls:8,vars:6,consts:[[1,"wp-100","d-flex","align-items-center","justify-content-start","mb-0","styles-options","overflow-scroll","new-scroll-behave","ps-3","pe-3"],[1,"btn","btn-primary","text-13","pt-2","pb-2","pl-9","pr-9","me-3","grey-600","text-regular",3,"click"],[1,"text-semi","text-primary","d-inline-flex"],[4,"ngIf"],[1,"showpreview-overlay","align-items-center","justify-content-start","position-fixed",3,"click","ngClass"],[1,"d-flex","justify-content-start","align-items-center","bottom-container","position-fixed","bg-white","p-3","pt-2","pb-9","flex-column","w-100",2,"bottom","0px","z-index","9999","transition","all 3s ease-in-out",3,"close"],[1,"top-header","d-flex","justify-content-start","align-items-center","w-100","flex-column","mb-1","h-32"],[1,"text-lg","text-semi","grey-800","m-0","w-100","lh-125","w-100","d-flex","align-items-center","justify-content-between","h-32"],["name","previewclose",3,"click"],["class","modal-box resolution-modal d-flex justify-content-between align-items-center w-100 border-radius-12 pl-9 pr-9 mb-2 h-48",3,"click",4,"ngFor","ngForOf"],[1,"modal-box","resolution-modal","d-flex","justify-content-between","align-items-center","w-100","border-radius-12","pl-9","pr-9","mb-2","h-48",3,"click"],[1,"d-flex","justify-content-center","align-items-center"],[1,"f-24","grey-600","me-2",3,"name"],[1,"grey-800","text-13","text-semi"],[1,"grey-600","text-12","text-semi","ms-1","p-1","ratio-box","d-inline-flex","align-items-center","justify-content-center","lh-normal"],[1,"showpreview-overlay","mobile-sheet-overlay","position-fixed",3,"click"],[1,"mobile-model-panel","mobile-style-container","mobile-sheet-anim","dropdown-style-panel",3,"scroll"],[1,"d-flex","justify-content-start","align-items-center","bottom-container","bg-white","p-3","pt-10","pb-9","flex-column","w-100","background-prompt","background-style","background-prompt-mobile"],[1,"w-100",3,"styleScrollEnd","close","selectStyleEvent","products","editorType","productImageId","isImagesLoading","isImagesEnd","loadingPlaceholders","selectedStyle"]],template:function(t,i){1&t&&(e.j41(0,"div",0)(1,"button",1),e.bIt("click",function(){return i.changeStep(2)}),e.EFF(2,"Style"),e.j41(3,"span",2),e.EFF(4),e.k0s()()(),e.DNE(5,xo,7,1,"ng-container",3)(6,Po,5,11,"ng-container",3),e.j41(7,"div",4),e.bIt("click",function(){return i.changeStep(0)}),e.k0s()),2&t&&(e.R7$(4),e.SpI("\xa0",(null==i.selectedStyle?null:i.selectedStyle.displayName)||"None",""),e.R7$(),e.Y8G("ngIf",1==i.step),e.R7$(),e.Y8G("ngIf",i.stylePanelMounted),e.R7$(),e.Y8G("ngClass",e.eq3(4,bo,1==i.step)))},dependencies:[b.YU,b.Sq,b.bT,H.b,Qe],styles:['.styles-options[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]{border:0px;border-radius:320px;background:linear-gradient(90deg,#fc5cff0d -4%,#2520f60d);position:relative;height:32px;display:flex;line-height:17px;justify-content:center;white-space:nowrap}.styles-options[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]:disabled{background:#d5d6dd;border:1px solid #D5D6DD;color:#b0b3bf!important}.styles-options[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]:disabled:before{display:none;padding:0}.styles-options[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]:disabled   .text-primary[_ngcontent-%COMP%]{color:#b0b3bf!important}.styles-options[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]:before{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:320px;padding:1px;border:none;background:linear-gradient(90deg,#fc5cff -4%,#2520f6);-webkit-mask:linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%) content-box,linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%);-webkit-mask-composite:xor;mask-composite:exclude}.bottom-container[_ngcontent-%COMP%]{border-radius:20px 20px 0 0}
1.bottom-container[_ngcontent-%COMP%]   .modal-box[_ngcontent-%COMP%]{background:#626adf0d;position:relative}.bottom-container[_ngcontent-%COMP%]   .modal-box[_ngcontent-%COMP%]   .icon-box[_ngcontent-%COMP%]{border-radius:6px;background:#626adf1a}.bottom-container[_ngcontent-%COMP%]   .modal-box[_ngcontent-%COMP%]   .coin-box[_ngcontent-%COMP%]{border:1px solid #C9CAD4;padding:0 6px 0 4px;min-height:24px;min-width:42px}.bottom-container[_ngcontent-%COMP%]   .resolution-modal[_ngcontent-%COMP%]{min-height:40px}.bottom-container[_ngcontent-%COMP%]   .resolution-modal[_ngcontent-%COMP%]   .ratio-box[_ngcontent-%COMP%]{border-radius:6px;background:#626adf1a;min-height:25px}.bottom-container[_ngcontent-%COMP%]   .active-modal[_ngcontent-%COMP%], .bottom-container[_ngcontent-%COMP%]   .active-resolution[_ngcontent-%COMP%]{position:relative}.bottom-container[_ngcontent-%COMP%]   .active-modal[_ngcontent-%COMP%]   .icon-box[_ngcontent-%COMP%], .bottom-container[_ngcontent-%COMP%]   .active-modal[_ngcontent-%COMP%]   .ratio-box[_ngcontent-%COMP%], .bottom-container[_ngcontent-%COMP%]   .active-resolution[_ngcontent-%COMP%]   .icon-box[_ngcontent-%COMP%], .bottom-container[_ngcontent-%COMP%]   .active-resolution[_ngcontent-%COMP%]   .ratio-box[_ngcontent-%COMP%]{background:linear-gradient(90deg,#fc5cff1a -4%,#2520f61a)}.bottom-container[_ngcontent-%COMP%]   .active-modal[_ngcontent-%COMP%]   .coin-box[_ngcontent-%COMP%], .bottom-container[_ngcontent-%COMP%]   .active-resolution[_ngcontent-%COMP%]   .coin-box[_ngcontent-%COMP%]{position:relative;border:0px}.bottom-container[_ngcontent-%COMP%]   .active-modal[_ngcontent-%COMP%]   .coin-box[_ngcontent-%COMP%]:after, .bottom-container[_ngcontent-%COMP%]   .active-resolution[_ngcontent-%COMP%]   .coin-box[_ngcontent-%COMP%]:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:12px;padding:.9px;border:0px;background:linear-gradient(90deg,#fc5cff -4%,#2520f6);-webkit-mask:linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%) content-box,linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%);-webkit-mask-composite:xor;mask-composite:exclude}.bottom-container[_ngcontent-%COMP%]   .active-modal[_ngcontent-%COMP%]:after, .bottom-container[_ngcontent-%COMP%]   .active-resolution[_ngcontent-%COMP%]:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:12px;padding:1.3px;border:none;background:linear-gradient(90deg,#fc5cff -4%,#2520f6);-webkit-mask:linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%) content-box,linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%);-webkit-mask-composite:xor;mask-composite:exclude}.bottom-container[_ngcontent-%COMP%]   .modal-box[_ngcontent-%COMP%]:last-child{margin-bottom:0!important}.showpreview-overlay[_ngcontent-%COMP%]{display:none;background:#0003;-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);width:100%;height:100%;top:0;bottom:0;z-index:999}.mobile-style-container[_ngcontent-%COMP%]{position:fixed;left:0;right:0;bottom:0;z-index:3;background:#fff;border-radius:20px 20px 0 0;height:auto;min-height:0;max-height:90vh;overflow-y:auto}.dropdown-style-panel[_ngcontent-%COMP%]{z-index:1000}.mobile-sheet-overlay[_ngcontent-%COMP%]{opacity:0;pointer-events:none;transition:opacity .24s ease;display:block;z-index:999}.mobile-sheet-overlay.mobile-sheet-overlay--open[_ngcontent-%COMP%]{opacity:1;pointer-events:auto}.mobile-sheet-anim[_ngcontent-%COMP%]{transform:translate3d(0,100dvh,0);will-change:transform;-webkit-backface-visibility:hidden;backface-visibility:hidden;pointer-events:none;transition:transform .72s cubic-bezier(.22,.61,.36,1)}.mobile-sheet-anim.mobile-sheet-anim--open[_ngcontent-%COMP%]{transform:translateZ(0);pointer-events:auto;transition:transform .52s cubic-bezier(.2,.9,.2,1)}']}),a})();const et=s=>({"d-none":s}),yo=s=>({"flex-column":s}),Ct=s=>({"justify-content-center":s}),wo=(s,a)=>({"justify-content-center":s,"d-none":a}),So=s=>({"m-h-advertisement":s}),Mo=(s,a,n)=>({"justify-content-center":s,"isrecent-add":a,"justify-content-between":n}),ko=(s,a,n)=>({"ai-thumb-active":s,"d-none":a,aiduoshoot:n}),To=(s,a)=>({"flex-column":s,"d-none-imp":a}),Oo=s=>({"ai-thumb-active":!1,"me-0":s}),Eo=s=>({"ai-thumb-active":!1,"":s}),jo=s=>({"ai-thumb-active":s}),Go=(s,a,n)=>({"pb-0":s,"pb-3":a,"remove-btn":n});function Vo(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"inspiration-template-picker",22),e.bIt("selectedTemplate",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.onVideoTemplateSelected(i))})("closePreview",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.closeVideoTemplatePicker())}),e.k0s(),e.bVm()}if(2&s){const n=e.XpG();e.R7$(),e.Y8G("categoryId",n.categoryId)("prefetchedProducts",n.storeProducts)("useProductFormatForMedia",!0)("aiPhotoService",n.aiPhotoService)("previewTitle",n.getVideoTemplatePickerTitle())}}function Ro(s,a){1&s&&(e.qex(0),e.j41(1,"div",23)(2,"div",24)(3,"span",25),e.EFF(4,"Loading..."),e.k0s()()(),e.bVm())}function Fo(s,a){1&s&&e.eu8(0)}function Ao(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"add-credit",26),e.bIt("close",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.step=1)})("addCredit",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.addCredit())}),e.k0s(),e.bVm()}if(2&s){const n=e.XpG();e.R7$(),e.Y8G("consumeCoins",n.creditConfig)}}function Bo(s,a){1&s&&e.nrm(0,"div")}function Uo(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",14)(1,"div",27)(2,"workflow-ui",28),e.mxI("productC
1onfigChange",function(i){e.eBV(n);const o=e.XpG();return e.DH7(o.productConfig,i)||(o.productConfig=i),e.Njj(i)}),e.bIt("productConfigChange",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.productConfigChange(i))}),e.k0s()(),e.j41(3,"div",29),e.DNE(4,Bo,1,0,"div",10),e.k0s()()}if(2&s){const n=e.XpG(),t=e.sdS(16);e.R7$(2),e.R50("productConfig",n.productConfig),e.Y8G("workflowList",n.workflowList)("inProgress",n.aiPhotoService.inProgress),e.R7$(2),e.Y8G("ngTemplateOutlet",t)}}function Do(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",15)(1,"button",30),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.closeTemplateVideoPreview())}),e.nrm(2,"pi",31),e.k0s(),e.j41(3,"div",32)(4,"video",33,4),e.bIt("play",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.previewIsPlaying=!0)})("pause",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.previewIsPlaying=!1)})("loadedmetadata",function(){e.eBV(n);const i=e.sdS(5),o=e.XpG();return e.Njj(o.onTemplatePreviewMetadata(i))})("timeupdate",function(){e.eBV(n);const i=e.sdS(5),o=e.XpG();return e.Njj(o.onTemplatePreviewTimeUpdate(i))})("ended",function(){e.eBV(n);const i=e.sdS(5),o=e.XpG();return e.Njj(o.onTemplatePreviewEnded(i))}),e.k0s(),e.j41(6,"button",34),e.bIt("click",function(){e.eBV(n);const i=e.sdS(5),o=e.XpG();return e.Njj(o.toggleTemplatePreviewPlay(i))}),e.nrm(7,"pi",35),e.k0s(),e.j41(8,"div",36)(9,"span",37),e.EFF(10),e.k0s(),e.EFF(11),e.k0s()()()}if(2&s){const n=e.XpG();e.R7$(4),e.Y8G("src",n.getTemplatePreviewVideoUrl(),e.B4B),e.R7$(3),e.Y8G("name",n.previewIsPlaying?"pausenew":"playnew"),e.R7$(3),e.JRh(n.previewCurrentTime),e.R7$(),e.SpI("\xa0/ ",n.previewDuration," ")}}function No(s,a){1&s&&(e.j41(0,"span",45),e.EFF(1," Upload a photo and enter a prompt to make your still image into a dynamic video. "),e.k0s())}function Xo(s,a){1&s&&(e.j41(0,"span",45),e.EFF(1," Upload two separate photos and merge them into one photo. "),e.k0s())}function Lo(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",49)(1,"div",50),e.EFF(2,"Enable 2nd Image"),e.k0s(),e.j41(3,"div",51)(4,"toggle-switch",52),e.bIt("changeT",function(i){e.eBV(n);const o=e.XpG(5);return e.Njj(o.toggleSecondImage(i))}),e.k0s()()()}if(2&s){const n=e.XpG(5);e.R7$(3),e.AVh("pe-none",n.isVideo&&n.aiPhotoService.inVideoProgress||n.aiPhotoService.inProgress),e.R7$(),e.Y8G("selected",n.switchToggle)}}function Yo(s,a){if(1&s&&(e.qex(0),e.j41(1,"div",41)(2,"div",42)(3,"div",43)(4,"div",44),e.EFF(5,"Upload Image"),e.k0s(),e.DNE(6,No,2,0,"span",45)(7,Xo,2,0,"span",45),e.k0s(),e.j41(8,"div",46),e.nrm(9,"app-file-upload",47),e.DNE(10,Lo,5,3,"div",48),e.k0s()()(),e.bVm()),2&s){const n=e.XpG().$implicit,t=e.XpG(3);e.R7$(6),e.vxM("v3"===t.layoutVersion?6:7),e.R7$(2),e.Y8G("ngClass",e.eq3(5,yo,"v1"==(null==n.config?null:n.config.uploadVersion)&&(null==n.config?null:n.config.switchToggle))),e.R7$(),e.Y8G("toolName",t.featureType)("version",t.switchToggle?"v3":(null==n.config?null:n.config.uploadVersion)||"v1"),e.R7$(),e.Y8G("ngIf","v1"==(null==n.config?null:n.config.uploadVersion)&&(null==n.config?null:n.config.switchToggle)&&!t.isDuoVideoShootFeatureType())}}function $o(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"div",55)(2,"app-dropdown-lists",56),e.bIt("closeChangeEvent",function(i){e.eBV(n);const o=e.XpG(5);return e.Njj(o.closeChangeEvent(i))}),e.k0s()(),e.bVm()}if(2&s){const n=e.XpG(5);e.R7$(2),e.Y8G("storeProducts",n.storeProducts)("layoutVersion",n.layoutVersion)("selectedProduct",n.selectedProduct)("isStyleImagesLoading",n.isLoadingMoreSelectedProductImages)("isStyleImagesEnd",n.isSelectedProductImagesEnd)("styleLoadingPlaceholders",n.imageLoadingPlaceholders)("productImageId",null==n.selectedPreset?null:n.selectedPreset.productImageId)("quality",n.quality)}}function zo(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"div",53),e.DNE(2,$o,3,8,"ng-container",9),e.j41(3,"text-prompt-mobile",54),e.bIt("changePrompt",function(i){e.eBV(n);const o=e.XpG(4);return e.Njj(o.changePrompt(i))})("generateClick",function(){e.eBV(n);const i=e.XpG(4);return e.Njj(i.generate())})("openPromptClick",function(i){e.eBV(n);const o=e.XpG(4);return e.Njj(o.openPrompt(i))})("changeResolution",function(i){e.eBV(n);const o=e.XpG(4);return e.Njj(o.changeResolution(i))})("selectModel",function(i){e.eBV(n);const o=e.XpG(4);return e.Njj(o.selectModel(i))}),e.k0s()(),e.bVm()}if(2&s){const n=e.XpG(4);e.R7$(2),e.Y8G("ngIf","v4"==n.layoutVersion),e.R7$(),e.Y8G("prompts",n.prompts)("textPrompt",n.customPrompt)("isVideo",n.isVideo)("maxLength",
1n.maxLength)("disabled",!n.isDisabled())("credit",n.creditConfig)("version","v2")("resolutionEnabled",null==n.layout?null:n.layout.isResolution)("quality",n.quality)("featureType",n.featureType)}}function Ho(s,a){if(1&s&&(e.j41(0,"ng-option",67),e.EFF(1),e.k0s()),2&s){const n=a.$implicit;e.Y8G("value",null==n?null:n.categoryId),e.R7$(),e.SpI(" ",n.displayName," ")}}function Wo(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",63)(1,"ng-select",65),e.mxI("ngModelChange",function(i){e.eBV(n);const o=e.XpG(6);return e.DH7(o.categoryId,i)||(o.categoryId=i),e.Njj(i)}),e.bIt("change",function(i){e.eBV(n);const o=e.XpG(6);return e.Njj(o.selectCategory(i,!0))})("open",function(){e.eBV(n);const i=e.XpG(6);return e.Njj(i.onDropdownOpen())})("close",function(){e.eBV(n);const i=e.XpG(6);return e.Njj(i.onDropdownClose())}),e.DNE(2,Ho,2,2,"ng-option",66),e.k0s()()}if(2&s){const n=e.XpG(6);e.R7$(),e.Y8G("searchable",!1)("clearable",!1),e.R50("ngModel",n.categoryId),e.Y8G("dropdownPosition","top"),e.R7$(),e.Y8G("ngForOf",n.categories)}}function qo(s,a){if(1&s){const n=e.RV6();e.j41(0,"buttons-scroll-menu",68),e.bIt("selectLayout",function(i){e.eBV(n);const o=e.XpG(6);return e.Njj(o.selectCategory(i))}),e.k0s()}if(2&s){const n=e.XpG(6);e.Y8G("items",n.categories)("type","mobile-ai-editor")("categoryId",n.categoryId)}}function Ko(s,a){if(1&s&&(e.j41(0,"div",62),e.DNE(1,Wo,3,5,"div",63)(2,qo,1,3,"buttons-scroll-menu",64),e.k0s()),2&s){const n=e.XpG(2).$implicit,t=e.XpG(3);e.Y8G("ngClass",e.eq3(2,Ct,(null==t.categories?null:t.categories.length)<=4||"dropdown"==(null==n||null==n.config?null:n.config.mViewType))),e.R7$(),e.vxM("dropdown"==(null==n.config?null:n.config.mViewType)?1:2)}}function Zo(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",69)(1,"buttons-scroll-menu",70),e.bIt("selectLayout",function(i){e.eBV(n);const o=e.XpG(5);return e.Njj(o.selectCategory(i))})("scrollEnd",function(){e.eBV(n);const i=e.XpG(5);return e.Njj(i.onProductListScrollEnd())}),e.k0s()()}if(2&s){const n=e.XpG(5);e.Y8G("ngClass",e.l_i(4,wo,(null==n.storeProducts?null:n.storeProducts.length)<=3,!(null!=n.storeProducts&&n.storeProducts.length))),e.R7$(),e.Y8G("items",n.storeProductsWithLoadingPlaceholders)("type","mobile-ai-editor")("categoryId",n.catId?n.catId:n.productId)}}function Jo(s,a){1&s&&e.nrm(0,"div",77)}function Qo(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",78)(1,"div",79),e.bIt("click",function(){const i=e.eBV(n).$implicit,o=e.XpG(7);return e.Njj(o.selectStyle(i))}),e.nrm(2,"img",80)(3,"pi",81),e.k0s(),e.j41(4,"span",82),e.EFF(5),e.k0s()()}if(2&s){const n=a.$implicit,t=e.XpG(7);e.Y8G("ngClass",e.sMw(3,ko,!t.isRecent&&(!t.isAvatar&&(null==t.selectedPreset?null:t.selectedPreset.productImageId)==n.productImageId||t.isAvatar&&(null==t.selectedPreset?null:t.selectedPreset.productId)==n.productId)||"v2"==t.layoutVersion&&t.aiPhotoService.aiImages.length&&(null==t.selectedPreset?null:t.selectedPreset.productImageId)==n.productImageId,t.isCustom,"v2"==t.layoutVersion&&!t.aiPhotoService.aiImages.length)),e.R7$(2),e.Y8G("src",n.thumbUrl,e.B4B),e.R7$(3),e.JRh(n.displayName)}}function es(s,a){1&s&&(e.j41(0,"div",84),e.nrm(1,"div",85)(2,"span",86),e.k0s())}function ts(s,a){if(1&s&&(e.qex(0),e.DNE(1,es,3,0,"div",83),e.bVm()),2&s){const n=e.XpG(7);e.R7$(),e.Y8G("ngForOf",n.imageLoadingPlaceholders)}}function is(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",73)(1,"div",74,5),e.bIt("scroll",function(i){e.eBV(n);const o=e.XpG(6);return e.Njj(o.onStyleListScroll(i))}),e.DNE(3,Jo,1,0,"div",75)(4,Qo,6,7,"div",76)(5,ts,2,1,"ng-container",9),e.k0s()()}if(2&s){const n=e.XpG(6),t=e.sdS(14);e.R7$(),e.Y8G("ngClass",e.sMw(4,Mo,n.isCustom||!n.isCustom&&((null==n.selectedProduct||null==n.selectedProduct.storeProductImages?null:n.selectedProduct.storeProductImages.length)||0)<=3,n.rData&&(n.isCustom||n.isCustomStyle)&&n.layout.customUpload,n.isLoadingMoreSelectedProductImages&&!n.isSelectedProductImagesEnd&&!n.isCustom)),e.R7$(2),e.Y8G("ngTemplateOutlet",t),e.R7$(),e.Y8G("ngForOf",n.selectedProduct.storeProductImages),e.R7$(),e.Y8G("ngIf",n.isLoadingMoreSelectedProductImages&&!n.isSelectedProductImagesEnd&&!n.isCustom)}}function ns(s,a){1&s&&e.nrm(0,"div",77)}function os(s,a){if(1&s&&(e.j41(0,"div",73)(1,"div",88,5),e.DNE(3,ns,1,0,"div",75),e.k0s()()),2&s){const n=e.XpG(7),t=e.sdS(14);e.R7$(),e.Y8G("ngClass",e.eq3(2,Ct,n.isCustom)),e.R7$(2),e.Y8G("ngTemplateOutlet",t)}}function ss(s,a){1&s&&(e.j41(0,"div",89),e.nrm(1,"div",90)(2,"span",82),e.k0s())}function rs(s,a){if(1&s&&(e.qex(0),e.DNE(1,os,4,4,"div",87)(2,ss,3,0,"ng-template",null,6,e.C5r),e.bVm()),2&s){const n=e.sdS(3),t=e.XpG(6);e.R7$(),e.Y8G("ngIf",!t.isWorkflowLoading)("ngIfElse",n)}}function as(s,a){1&s&&(e.qex(0),e.nrm(1,"element-placeholder",91),e.bVm()),2&s&&(e.R7$(),e.Y8G("view","AiPatterns-new"))}function ls(s,a){if(1&s&&(e.j41(0,"div",71),e.DNE(1,is,6,8,"div",72)(2,rs,4,2,"ng-container",9)(3,as,2,1,"ng-container",9),e.k0s()),2&s){const n=e.XpG(5);e.Y8G("ngClass",e.eq3(4,So,!(null!=n.selectedProduct&&n.selectedProduct.storeProductImages))),e.R7$(),e.Y8G("ngIf",n.selectedProduct),e.R7$(),e.Y8G("ngIf",!(null!=n.selectedProduct&&n.selectedProduct.storeProductImages)),e.R7$(),e.Y8G("ngIf",!n.selectedProduct&&!n.isLoaded)}}function cs(s,a){1&s&&e.nrm(0,"div")}function ds(s,a){if(1&s&&(e.qex(0),e.DNE(1,cs,1,0,"div",10),e.bVm()),2&s){e.XpG(5);const n=e.sdS(16);e.R7$(),e.Y8G("ngTemplateOutlet",n)}}function hs(s,a){1&s&&e.nrm(0,"div",92)}function ps(s,a){if(1&s&&(e.qex(0),e.j41(1,"div",57),e.DNE(2,Ko,3,4,"div",58)(3,Zo,2,7,"div",59)(4,ls,4,6,"div",60)(5,ds,2,1,"ng-container",9)(6,hs,1,0,"div",61),e.k0s(),e.bVm()),2&s){const n=e.XpG().$implicit,t=e.XpG(3);e.R7$(2),e.Y8G("ngIf",(null==t.categories?null:t.categories.length)&&("filter-product"==n.type||"filter-category"==n.type)),e.R7$(),e.Y8G("ngIf","filter-product"==n.type||"filter-category"==n.type),e.R7$(),e.Y8G("ngIf","filter-product"==n.type||"filter-category"==n.type),e.R7$(),e.Y8G("ngIf",!t.isCustom&&"v2"==t.layoutVersion&&!t.aiPhotoService.aiImages.length),e.R7$(),e.Y8G("ngIf",t.isCustom&&"v2"==t.layoutVersion&&!t.aiPhotoService.aiImages.length)}}function ms(s,a){if(1&s&&e.nrm(0,"img",107),2&s){const n=e.XpG(6);e.Y8G("src",null==n.selectedPreset?null:n.selectedPreset.thumbUrl,e.B4B)}}function us(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",99)(1,"label",100),e.EFF(2,"Template"),e.k0s(),e.j41(3,"div",101)(4,"div",102),e.bIt("click",function(i){e.eBV(n);const o=e.XpG(5);return e.Njj(o.changeTemplateClick(i))}),e.j41(5,"div",103),e.DNE(6,ms,1,1,"img",104),e.k0s(),e.j41(7,"div",105),e.EFF(8," Change Template "),e.k0s()(),e.j41(9,"button",106),e.bIt("click",function(i){return e.eBV(n),e.XpG(5).openTemplateVideoPreview(),e.Njj(i.stopPropagation())}),e.EFF(10," Preview "),e.k0s()()()}if(2&s){const n=e.XpG(5);e.R7$(6),e.Y8G("ngIf",null==n.selectedPreset?null:n.selectedPreset.thumbUrl),e.R7$(3),e.Y8G("disabled",!n.getTemplatePreviewVideoUrl())}}function gs(s,a){1&s&&(e.j41(0,"span",110),e.EFF(1,"*"),e.k0s())}function _s(s,a){if(1&s&&(e.j41(0,"label",108),e.EFF(1),e.DNE(2,gs,2,0,"span",109),e.k0s()),2&s){const n=e.XpG(5);e.R7$(),e.JRh(null!=n.dynamicFields&&n.dynamicFields.input_display_name?null==n.dynamicFields?null:n.dynamicFields.input_display_name:"Upload Image"),e.R7$(),e.Y8G("ngIf",!(null!=n.imageFields&&n.imageFields.length))}}function fs(s,a){if(1&s&&e.nrm(0,"app-dynamic-fields",111),2&s){const n=e.XpG(5);e.Y8G("dynamicFields",n.dynamicFields)}}function vs(s,a){1&s&&e.nrm(0,"div")}function bs(s,a){if(1&s&&(e.qex(0),e.j41(1,"div",93)(2,"div",94),e.DNE(3,us,11,2,"div",95),e.j41(4,"div",46),e.DNE(5,_s,3,2,"label",96),e.nrm(6,"app-file-upload",97),e.k0s(),e.DNE(7,fs,1,1,"app-dynamic-fields",98),e.k0s()(),e.j41(8,"div",57),e.DNE(9,vs,1,0,"div",10),e.k0s(),e.bVm()),2&s){const n=e.XpG().$implicit,t=e.XpG(3),i=e.sdS(16);e.R7$(2),e.AVh("pb-13",t.dynamicFields)("mb-2",t.productCreditConfig)("has-dynamic-fields",t.dynamicFields),e.R7$(),e.Y8G("ngIf",t.dynamicFields),e.R7$(),e.Y8G("ngClass",e.l_i(16,To,"v1"==(null==n.config?null:n.config.uploadVersion)&&(null==n.config?null:n.config.switchToggle)||t.dynamicFields,1==(null==t.dynamicFields?null:t.dynamicFields.can_skip_image))),e.R7$(),e.Y8G("ngIf",t.dynamicFields),e.R7$(),e.AVh("d-none",null==t.imageFields?null:t.imageFields.length),e.Y8G("toolName",t.featureType)("version",(null==n.config?null:n.config.uploadVersion)||"v1")("input_url",null==t.dynamicFields?null:t.dynamicFields.input_url),e.R7$(),e.Y8G("ngIf",t.dynamicFields),e.R7$(2),e.Y8G("ngTemplateOutlet",i)}}function Cs(s,a){if(1&s&&(e.qex(0),e.DNE(1,Yo,11,7,"ng-container",9)(2,zo,4,11,"ng-container",9)(3,ps,7,5,"ng-container",9)(4,bs,10,19,"ng-container",9),e.bVm()),2&s){const n=a.$implicit,t=e.XpG(3);e.R7$(),e.Y8G("ngIf",("v2"==t.layoutVersion||"v3"==t.layoutVersion)&&!t.isGenerated&&"file-upload"==n.type),e.R7$(),e.Y8G("ngIf",("v3"==t.layoutVersion&&!t.isGenerated||"v4"==t.layoutVersion&&!t.isGenerated)&&"prompt-panel"==n.type),e.R7$(),e.Y8G("ngIf",!("v1"!=t.layoutVersion&&"v2"!=t.layoutVersion||"filter-product"!=n.type&&"filter-category"!=n.type&&"fixed-footer"!=n.type)),e.R7$(),e.Y8G("ngIf",!t.isGenerated&&"v5"==t.layoutVersion&&"file-upload"==n.type)}}function xs(s,a){if(1&s&&(e.qex(0),e.DNE(1,Cs,5,4,"ng-container",40),e.bVm()),2&s){const n=e.XpG(2);e.R7$(),e.Y8G("ngForOf",n.rows)}}function Ps(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",38)(1,"generated-image-preview",39),e.bIt("uploadFileEvent",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.uploadFileEvent.emit(i))}),e.k0s()(),e.DNE(2,xs,2,1,"ng-container",9)}if(2&s){const n=e.XpG();
1e.AVh("cover-space",!(null!=n.categories&&n.categories.length))("text-video","v4"==n.layoutVersion)("cover-space-full",null==n.categories?null:n.categories.length)("video-cover-space","v5"==n.layoutVersion)("has-dynamic-fields","v5"==n.layoutVersion&&n.dynamicFields)("adviertise-cover-space","v1"==n.layoutVersion&&!(null!=n.selectedProduct&&n.selectedProduct.storeProductImages))("d-none",!n.isLoaded||n.showVideoTemplatePicker||n.isVideoTemplateTransitioning||!n.isGenerated&&("v3"==n.layoutVersion||"v2"==n.layoutVersion||"v5"==n.layoutVersion&&n.dynamicFields)),e.R7$(),e.Y8G("featureType",n.featureType)("layoutVersion",n.layoutVersion)("isVideo","video-tools"==n.activeTab&&n.isGenerated)("videoUrl",n.videoUrl)("prompt",n.prompt)("videoPreview",n.videoPreview)("generatedVideoResult",n.generatedVideoResult)("checkimg",n.checkimg)("previewItem",n.templatePreviewItem),e.R7$(),e.Y8G("ngIf",!n.isVideoTemplateTransitioning)}}function Is(s,a){1&s&&e.nrm(0,"pi",120)}function ys(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"div",117),e.bIt("click",function(){e.eBV(n);const i=e.XpG(3),o=e.sdS(25);return e.Njj(i.customFileClick(o))}),e.j41(2,"div",90),e.nrm(3,"pi",118),e.k0s(),e.j41(4,"span",82),e.EFF(5),e.k0s()(),e.DNE(6,Is,1,0,"pi",119),e.bVm()}if(2&s){const n=e.XpG(2).row,t=e.XpG();e.R7$(5),e.JRh((null==n?null:n.mTitle)||"Upload Image"),e.R7$(),e.Y8G("ngIf",t.layout.isPrompt)}}function ws(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"div",121),e.bIt("click",function(){e.eBV(n);const i=e.XpG(3);return e.Njj(i.workflowClick())}),e.j41(2,"div",90),e.nrm(3,"pi",122),e.k0s(),e.j41(4,"span",82),e.EFF(5),e.k0s()(),e.bVm()}if(2&s){const n=e.XpG(2).row,t=e.XpG();e.R7$(),e.Y8G("ngClass",e.eq3(2,Oo,t.rData&&(t.isCustom||t.isCustomStyle))),e.R7$(4),e.JRh((null==n?null:n.mTitle)||"Workflow")}}function Ss(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",121),e.bIt("click",function(){e.eBV(n);const i=e.XpG(3);return e.Njj(i.customClick())}),e.j41(1,"div",90),e.nrm(2,"pi",123),e.k0s(),e.j41(3,"span",82),e.EFF(4),e.k0s()()}if(2&s){const n=e.XpG(2).row,t=e.XpG();e.Y8G("ngClass",e.eq3(2,Eo,t.rData&&(t.isCustom||t.isCustomStyle))),e.R7$(4),e.JRh((null==n?null:n.mTitle)||"Prompt")}}function Ms(s,a){1&s&&e.nrm(0,"pi",124)}function ks(s,a){if(1&s&&(e.j41(0,"div",114),e.DNE(1,ys,7,2,"ng-container",9)(2,ws,6,4,"ng-container",9)(3,Ss,5,4,"div",115)(4,Ms,1,0,"pi",116),e.k0s()),2&s){const n=e.XpG(2);e.R7$(),e.Y8G("ngIf",n.layout.customUpload),e.R7$(),e.Y8G("ngIf",n.layout.isWorkflow&&n.productC
1onfig),e.R7$(),e.Y8G("ngIf",n.layout.isPrompt),e.R7$(),e.Y8G("ngIf",n.rData&&n.isGenerated&&!n.isCustomStyle||n.isCustomStyle&&!n.isGenerated)}}function Ts(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",125)(1,"div",126),e.bIt("click",function(){e.eBV(n);const i=e.XpG(2);return i.generate(i.rData),e.Njj(i.isRecent=!0)}),e.j41(2,"div",127),e.nrm(3,"img",128)(4,"pi",81),e.k0s(),e.j41(5,"span",82),e.EFF(6,"Recent"),e.k0s()(),e.nrm(7,"pi",129),e.k0s()}if(2&s){const n=e.XpG(2);e.R7$(),e.Y8G("ngClass",e.eq3(3,jo,n.isRecent)),e.R7$(2),e.Y8G("src",n.thumbUrl,e.B4B),e.R7$(4),e.Y8G("ngClass",e.eq3(5,et,n.isCustom||n.isCustomStyle&&!n.isGenerated))}}function Os(s,a){if(1&s&&e.DNE(0,ks,5,4,"div",112)(1,Ts,8,7,"div",113),2&s){const n=e.XpG();e.Y8G("ngIf",n.isCustom||n.isCustomStyle),e.R7$(),e.Y8G("ngIf",n.rData&&(n.isCustom||n.isCustomStyle))}}function Es(s,a){if(1&s){const n=e.RV6();e.j41(0,"app-video-generation-settings",143),e.bIt("selectionChange",function(i){e.eBV(n);const o=e.XpG(3);return e.Njj(o.selectionChange(i))}),e.k0s()}if(2&s){const n=e.XpG(3);e.Y8G("productCreditConfig",n.productCreditConfig)("selection",n.videoSettings)}}function js(s,a){if(1&s){const n=e.RV6();e.j41(0,"button",144),e.bIt("click",function(){e.eBV(n);const i=e.XpG(3);return e.Njj(i.openResolutionPanel())}),e.j41(1,"span",145),e.EFF(2),e.k0s(),e.nrm(3,"pi",146),e.k0s()}if(2&s){const n=e.XpG(3);e.R7$(2),e.JRh(null==n.selectedSize?null:n.selectedSize.ratio)}}function Gs(s,a){if(1&s&&(e.j41(0,"div",140),e.DNE(1,Es,1,2,"app-video-generation-settings",141)(2,js,4,1,"button",142),e.k0s()),2&s){const n=e.XpG(2);e.R7$(),e.vxM(n.productCreditConfig?1:2)}}function Vs(s,a){1&s&&(e.j41(0,"div",147)(1,"span",148),e.EFF(2,"Loading..."),e.k0s()())}function Rs(s,a){if(1&s&&(e.j41(0,"div",139),e.nrm(1,"app-video-generation-settings",149),e.k0s()),2&s){const n=e.XpG(2);e.R7$(),e.Y8G("productCreditConfig",n.productCreditConfig)("selection",n.videoSettings)}}function Fs(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",130),e.DNE(1,Gs,3,1,"div",131),e.j41(2,"button",132),e.bIt("keyup.enter",function(){e.eBV(n);const i=e.XpG();return i.generate(),e.Njj(i.isRecent=!0)})("click",function(){e.eBV(n);const i=e.XpG();return i.generate(),e.Njj(i.isRecent=!0)}),e.DNE(3,Vs,3,0,"div",133),e.j41(4,"span",134),e.EFF(5),e.k0s(),e.j41(6,"span",135),e.nrm(7,"img",136)(8,"img",137),e.j41(9,"b",138),e.EFF(10),e.k0s()()()(),e.DNE(11,Rs,2,2,"div",139)}if(2&s){const n=e.XpG();e.Y8G("ngClass",e.sMw(7,Go,n.productCreditConfig,!n.productCreditConfig,n.isCustom&&!n.aiPhotoService.isWorkflow)),e.R7$(),e.Y8G("ngIf","v5"==n.layoutVersion&&n.layout.isResolution),e.R7$(),e.Y8G("disabled",!n.isDisabled()),e.R7$(),e.Y8G("ngIf",n.aiPhotoService.inProgress||n.isVideo&&n.aiPhotoService.inVideoProgress),e.R7$(2),e.JRh(n.aiPhotoService.inProgress||n.isVideo&&n.aiPhotoService.inVideoProgress?"Processing":"Generate"),e.R7$(5),e.JRh(n.creditConfig),e.R7$(),e.vxM(n.productCreditConfig?11:-1)}}function As(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",150),e.bIt("click",function(){const i=e.eBV(n).$implicit,o=e.XpG();return e.Njj(o.selectSize(i))}),e.j41(1,"div",151),e.nrm(2,"pi",152),e.j41(3,"span",153),e.EFF(4),e.k0s(),e.j41(5,"span",154),e.EFF(6),e.k0s()()()}if(2&s){const n=a.$implicit;e.R7$(2),e.FS9("name",n.icon),e.R7$(2),e.JRh(n.name),e.R7$(2),e.JRh(n.ratio)}}let Bs=(()=>{var s;class a{get storeProductsWithLoadingPlaceholders(){return this.storeProducts?.length?!this.isLoadingMoreProductsForPlaceholders||this.isProductsEnd?this.storeProducts:(this.storeProducts||[]).concat(this.productLoadingPlaceholders.map(()=>({displayName:"",productId:-1,categoryId:0,isLoadingPlaceholder:!0}))):this.storeProducts}constructor(t,i,o,r,l,c,d,h,p,u,g,_,v,C,M){this.mediaContentService=t,this.document=i,this.aiPhotoService=o,this.dialogService=r,this.authService=l,this.createPopupService=c,this.aiUploadImageService=d,this.gtmService=h,this.aiGenService=p,this.paymentService=u,this.templateService=g,this.toast=_,this.workflowUIService=v,this.renderer=C,this.modalService=M,this.step=1,this.isLogin=!1,this.isAvatar=!1,this.productId=0,this.changeStep=new e.bkB,this.uploadFileEvent=ne
1w e.bkB,this.disabled=!1,this.storeProducts=[],this.prompts=[],this.customPrompt="",this.isFocused=!1,this.isCustom=!1,this.isCustomStyle=!1,this.isRecent=!1,this.isProUser=!1,this.creditConfig=1,this.pageNumber=0,this.checkimg=!0,this.chooseFileEvent=new e.bkB,this.selectedModel=null,this.PANEL_ID={prompt:"prompt-panel",presets:"presets-panel",workflow:"workflow-panel",customUpload:"custom-upload-panel"},this.layoutVersion="v1",this.switchToggle=!1,this.isPromptOpen=!1,this.quality=0,this.maxLength=2e3,this.backBtnSub=[],this.isGenerated=!1,this.showVideoTemplatePicker=!1,this.hasOpenedVideoTemplatePicker=!1,this.templatePreviewItem=null,this.isVideoTemplateTransitioning=!1,this.hasPreselectedTemplateFromQuery=!1,this.preselectedProductImageIdFromQuery=0,this.isResolvingPreselectedTemplate=!1,this.isVideoTemplateBaseDataReady=!1,this.generationRequestSeq=0,this.isVideo=!1,this.videoUrl="",this.videoPreview=!1,this.workflowList=[],this.isWorkflowLoading=!1,this.resolutions=[],this.selectedProductImagePageNumber=0,this.isLoadingMoreSelectedProductImages=!1,this.isSelectedProductImagesEnd=!1,this.productListPageNumber=0,this.isLoadingMoreProducts=!1,this.isProductsEnd=!1,this.isLoadingMoreProductsForPlaceholders=!1,this.productLoadingPlaceholders=[0,1],this.productListingCategoryId=0,this.imageLoadingPlaceholders=[0,1,2,3],this.productCreditConfig=null,this.videoSettings=null,this.dynamicFields=null,this.imageFields=null,this.showTemplateVideoPreview=!1,this.previewIsPlaying=!1,this.previewCurrentTime="00:00",this.previewDuration="00:00",this.changeTemplate=!1,this.user=this.authService.currentUser(),this.loggedInObserver=this.authService.loggedIn.subscribe(k=>{this.user=this.authService.currentUser(),this.isProUser=this.aiPhotoService.isProUser()}),this.usrPropChangedObserver=this.authService.usrPropChanged.subscribe(k=>{this.user=this.authService.currentUser(),this.isProUser=this.aiPhotoService.isProUser()}),this.updateBehaviorUserAiConis=this.authService.updateBehaviorUserAiConis.subscribe(k=>{this.user=this.authService.currentUser(),this.isProUser=this.aiPhotoService.isProUser()}),this.backBtnSub.push(this.aiPhotoService.backBtnClick.subscribe(k=>{this.showTemplateVideoPreview?this.closeTemplateVideoPreview():(k?.isNotified&&(this.isGenerated=!1),(k?.isBack||k?.backBtnEnabled&&this.videoPreview)&&(this.isGenerated=!1,this.videoUrl="",this.prompt="",this.videoPreview=!1,this.isRecent=!1,this.aiPhotoService.isWorkflow=!1),k?.backBtnEnabled&&!this.isGenerated&&(this.isGenerated=!0))})),this.paymentServiceSubs=this.paymentService.configUpdated.subscribe(k=>{k&&this.updateCreditConfig()}),this.resolutions=this.aiPhotoService.getResolutionDesignEditor("Video"),this.selectedSize=this.resolutions[0],this.quality=this.selectedSize?.qType?this.selectedSize?.qType:0}ngOnInit(){this.isVideo=this.activeTab==z.sv.AI_VIDEO_TOOLS,this.toolName=this.featureType,this.isVideoTemplateTransitioning=this.isV5TemplateFlowRequested(),this.updateCreditConfig(),this.loadLayoutConfig(()=>{this.updateCreditConfig(),(this.toolName==f.Fs.Avatar||this.toolName==f.Fs.Portrait)&&(this.maxLength=450),this.toolName==f.Fs.Avatar?this.getAvatarCategoryDetails():(this.isDuoTemplateFlow()&&(this.switchToggle=!0),this.isVideoTemplateTransitioning=this.isVideoShootV5Layout(),this.resolvePreselectedVideoTemplate(),this.getCategories(()=>{this.isLoaded=!0;const t=this.rows.find(o=>o.type==f.T6.PromptPanel)?.config?.prompts;!this.prompts?.length&&t?.length&&(this.prompts=t);const i=this.rows.filter(o=>1===o.isAccordion);i.length&&this.setCustomArr(),this.openVideoTemplatePickerIfNeeded(),this.isVideoTemplateBaseDataReady=!0,this.finishVideoTemplateTransitionIfReady(),this.layout.isPrompt&&1==i.length&&this.selectedMode==f.y9.Custom&&!this.customPrompt.trim()&&!this.categories?.length&&(this.step=2,this.disabled=!0)}),this.getWorkflows())})}selectCategory(t,i=!1){if(i&&t&&(t=this.categories.find(c=>c.categoryId==this.categoryId)),t?.isLoadingPlaceholder)return;const o=Number(t?.productId||0),r=o>0||!!t?.isAvatar,l=!(!t?.categoryId||r);if((!r||o!==Number(this.productId||0)||!this.selectedProduct||Number(this.selectedProduct.productId||0)!==o||this.isCu
1stom||t?.isAvatar&&!this.isAvatar)&&(!l||t.categoryId!==this.productListingCategoryId||!this.isLoadingMoreProducts&&!this.storeProducts?.length))if(this.activePanelId="",this.isCustom=t?.isCustom||!1,this.selectedMode=this.isCustom?f.y9.Custom:f.y9.Presets,this.isCustom||(this.isRecent=!1),this.checkimg&&(this.customPrompt=""),this.quality=0,l)this.categoryId=t.categoryId,this.modelTypeId=t.modelTypeId?t.modelTypeId:this.modelTypeId,this.getProductDetails(this.categoryId,()=>{this.getPrompts(0),this.rows.filter(d=>1===d.isAccordion).length&&this.setCustomArr(),this.getWorkflows()});else if(r){this.isAvatar=!!t?.isAvatar,this.featureType==f.Fs.Avatar&&(this.isCustomStyle=!this.isAvatar),this.selectedProduct=t,this.productId=this.selectedProduct.productId,this.modelTypeId=this.selectedProduct.modelTypeId;const c=this.selectedProduct?.storeProductImages?.[0];c&&(this.imageJson=c.imageJson,this.productImageId=c.productImageId),this.isAvatar||(this.resetSelectedProductImagePagination(this.selectedProduct?.productId),this.loadSelectedProductImages(this.selectedProduct,!0)),this.isCustomStyle&&this.getPrompts(this.productId)}}selectStyle(t){this.activePanelId="",this.isRecent=!1,this.isCustomStyle&&this.checkimg&&(this.customPrompt=""),this.selectedPreset=t,("v1"==this.layoutVersion||"v2"==this.layoutVersion&&this.aiPhotoService.aiImages.length)&&this.generate()}getCategoryProductDetails(t,i=null,o=!1,r=!0){this.loadProductListingPage({categoryId:t,reset:r,init:o,selectOnReset:!1,onLoaded:()=>{if(r&&this.storeProducts?.length){if(this.productId){const l=this.storeProducts.findIndex(d=>d.productId==this.productId);if(-1!=l&&o){let d=this.storeProducts[l];this.storeProducts.splice(l,1),this.storeProducts.splice(0,0,d)}const c=this.storeProducts.filter(d=>d.productId==this.productId);this.productStyles=c.length>0?c[0]:this.storeProducts[0],this.productId=this.productStyles?.productId}else this.productStyles=this.storeProducts[0],this.productId=this.productStyles?.productId;this.productStyles?.modelTypeId&&(this.modelTypeId=this.productStyles.modelTypeId),this.productId>0&&this.getPrompts(this.productId)}i&&i()},onError:()=>{this.isLoaded=!0}})}getCategoryDetails(t,i=null){this.mediaContentService.getCategoryDetails(t,Ae.i.Main,o=>{i&&i(o?.storeCategory?.subCategoryList||[])},o=>{})}generate(t=null){if(this.user=this.authService.currentUser(),"v4"!=this.layoutVersion&&this.quality>0&&(this.quality=0),this.isProUser=this.aiPhotoService.isProUser(),this.aiPhotoService.isCancel)return void this.toast.showErrorSingle(y.b.message.uploadNewImage);if(this.aiPhotoService.inProgress||this.isVideo&&this.aiPhotoService.inVideoProgress)return;if(this.dynamicFields&&(this.aiPhotoService.imgUrl=this.dynamicFields?.input_url),!this.aiPhotoService.imgUrl&&"v4"!==this.layoutVersion)return void this.toast.showErrorSingleNew("Upload input image to use tool");let i=this.step;if(this.aiPhotoService.imgUrl||"v4"==this.layoutVersion)if(this.user&&this.user.remainingCoins>=this.creditConfig){const o=t||this.prepareInputData();this.step=1,this.aiPhotoService.startGenerationProgress({featureType:this.featureType,isVideo:this.isVideo});const r=new Date;this.clearTimeInterval();const l=++this.generationRequestSeq;this.aiPhotoService.generateImage(o,c=>{l===this.generationRequestSeq&&(c&&c.assetId?(this.isVideo&&this.aiPhotoService.checkStatusSub.next({isVideo:!0,urls:null}),this.aiPhotoService.checkStatusResponsive(c,0,h=>{l===this.generationRequestSeq&&(this.isVideo||this.aiPhotoService.processingProgress.isActive||this.aiPhotoService.inProgress||this.aiPhotoService.inVideoProgress)&&this.outputResult(h,i,t,o,r)},h=>{l===this.generationRequestSeq&&(h.rData=t,h.step=i,h.data=o,this.displayErrorMsg(h,r))},this.isVideo)):this.displayErrorMsg(c,r))},c=>{this.displayErrorMsg(c,r)},this.isVideo)}else this.step=1,this.aiPhotoService.loginAndAICredit(o=>{this.user&&(o?.isFreeUser?this.isLogin=!0:this.user.remainingCoins<this.creditConfig?this.step=3:this.generate())})}closeProgress(t){this.aiPhotoService.completeGenerationProgress()}showNotify(){this.aiPhotoService.completeGenerationProgress(()=>{this.isGenerated=!1,this.aiPhotoService.backBtnClick.next({isNotified:!0})})}displayErrorMsg(t=null,i){this.aiPhotoService.clearGenerationProgress(),this.createPopupService.openWarningDialog("Error",t?.description)}getPrompts(t,i=null){const o=this.rows.find(l=>l.type==f.T6.Product||l.type==f.T6.Category);let r=o?.config?.aiType;o?.config?.items?.length&&(r=o?.config?.items.find(l=>l.categoryId==this.categoryId)?.aiType||r,t=0),r&&this.mediaContentService.getPrompts(r,l=>{l&&(this.prompts=l?.prompts||[]),i&&i()},l=>{i&&i()},t)}setCustomArr(){if("v1"!=this.layoutVersion||this.featureType!=f.Fs.Avatar&&this.featureType!=f.Fs.Filter){if("v1"==this.layoutVersion||"v2"==this.layoutVersion){let t=this.storeProducts[0],i=t?JSON.parse(JSON.stringify(t)):Object.assign({});this.storeProducts.find(r=>0==r.productId&&r.isCustom)||(i.displayName="Custom",i.productId=0,i.isCustom=!0,i.storeProductImages=[],this.storeProducts.length?this.storeProducts.unshift(i):this.isCu
1stom=!0)}}else this.isCustomStyle=!0}prepareInputData(){let t={featureType:this.featureType,isCustomPrompt:this.isCustom&&this.customPrompt&&this.customPrompt.trim()?1:0,...this.aiPhotoService.imgUrl&&{imageUrl:this.aiPhotoService.imgUrl},...this.isDuoImageUploaded()&&{imageUrlSecond:this.aiPhotoService.originalImageUrlDuo},...(this.selectedPreset?.productId||this.productId>0)&&{productId:this.selectedPreset?.productId||this.productId},...this.selectedPreset?.productImageId&&{productImageId:this.selectedPreset?.productImageId},...this.modelTypeId&&{model:this.modelTypeId},...this.productCreditConfig&&this.videoSettings&&{duration:this.videoSettings.duration,ratio:this.videoSettings.aspectRatio,resolution:this.videoSettings.resolution,data:{mediaCreditType:2}},...this.layout?.config?.segmentationType&&!this.productCreditConfig&&{segmentationType:this.selectedSize.qType},...this.customPrompt&&this.customPrompt.trim()&&{textPrompt:this.customPrompt,isCustomPrompt:1},...this.quality&&!this.productCreditConfig&&{quality:this.quality},...this.productConfig&&this.aiPhotoService.isWorkflow&&{isCustomPrompt:0,...this.productConfig?.modelTypeId&&{model:this.productConfig.modelTypeId},...this.aiPhotoService.originalImageUrlCustom&&{imageUrl:this.aiPhotoService.originalImageUrlCustom},worksFlow:{...this.workflowUIService.getInputWorkflowData(this.productConfig,this.aiPhotoService.originalImageUrlCustom),...this.productConfig?.workflowId&&{workflowId:this.productConfig.workflowId},...this.productConfig?.enhancePrompt&&{enhancePrompt:this.productConfig.enhancePrompt}}}};this.featureType==f.Fs.Avatar?this.selectedPreset?.productImageIds?(this.productImageId=this.aiPhotoService.getRandomItem(this.selectedPreset?.productImageIds),this.productImageId&&(t.productImageId=this.productImageId)):t.featureType=f.Fs.Avatarify:this.featureType==f.Fs.AIVirtualTryOn?(t={...t,isCustomPrompt:0,imageUrlSecond:this.activePanelId==this.PANEL_ID.customUpload&&this.aiPhotoService.originalImageUrlCustom?this.aiPhotoService.originalImageUrlCustom:this.selectedPreset?.imgUrl||""},this.activePanelId==this.PANEL_ID.customUpload&&delete t.productImageId):this.activePanelId==this.PANEL_ID.customUpload&&this.aiPhotoService.originalImageUrlCustom?t={...t,imageUrlSecond:this.aiPhotoService.originalImageUrlCustom}:"v4"==this.layoutVersion?(delete t.imageUrl,delete t.productId,delete t.productImageId,delete t.quality,t={...t,...this.selectedPreset?.imageJson&&{substyle:this.selectedPreset?.imageJson},...this.aiPhotoService.getVideoModelOptions(this.selectedModel)}):"v3"==this.layoutVersion?t={...t,...this.aiPhotoService.getVideoModelOptions(this.selectedModel),...this.isDuoImageUploaded()&&{featureType:f.Fs.Frameinterpolation}}:this.aiPhotoService.isWorkflow&&this.productConfig&&delete t.textPrompt;const i=this.dynamicFields;return i&&(t.data=i,t.data.mediaCreditType=2),t}customClick(){this.step=2,this.selectedPreset=null}changePrompt(t){this.customPrompt=t}updateCreditConfig(){const t=this.paymentService?.config?.creditInfo;this.creditConfig=t?.[this.featureType]||1}ngOnDestroy(){this.closeTemplateVideoPreview(),this.generationRequestSeq++,document.body.classList.remove("overflow-hidden"),this.paymentServiceSubs&&this.paymentServiceSubs.unsubscribe(),this.loggedInObserver&&this.loggedInObserver.unsubscribe(),this.usrPropChangedObserver&&this.usrPropChangedObserver.unsubscribe(),this.backBtnSub.length&&this.backBtnSub.forEach(t=>{t.unsubscribe()}),this.aiPhotoService.originalImageUrlCustom="",this.clearTimeInterval(),this.aiPhotoService.clearGenerationProgress()}clearTimeInterval(){this.interValId&&clearInterval(this.interValId),this.interValId1&&clearInterval(this.interValId1)}addCredit(){this.step=1,this.aiGenService.aiCreditPlanCheckout({toolName:this.toolName},()=>{})}retryCheckStatus(t){this.aiPhotoService.startGenerationProgress({featureType:this.featureType,isVideo:this.isVideo});const o=new Date,r=++this.generationRequestSeq;this.aiPhotoService.checkStatusResponsive(t,0,l=>{r===this.generationRequestSeq&&(this.aiPhotoService.processingProgress.isActive||this.aiPhotoService.inProgress||this.aiPhotoService.inVideoProgress?this.outputResult(l,t.step,t.rData,t.data,o):(this.aiPhotoService.clearGenerationProgress(),this.aiPhotoService.aiImages=[]))},l=>{r===this.generationRequestSeq&&this.displayErrorMsg(l,o)})}outputResult(t,i,o,r,l){const c=this.generationRequestSeq;t&&t.urls&&t.urls.length>0?this.aiPhotoService.completeGenerationProgress(()=>{c===this.generationRequestSeq&&(this.isGenerated=!0,(2==i||o||this.isCu
1stom&&(this.activePanelId==this.PANEL_ID.customUpload||this.activePanelId==this.PANEL_ID.workflow))&&(this.rData=r,this.thumbUrl=t.thumbUrl||t.urls[0],this.isRecent=!0,this.step=1),this.user.remainingCoins=t.remainingCalls,"v1"!=this.layoutVersion&&this.aiPhotoService.backBtnClick.next(t.isVideo?{backBtnEnabled:!0,videoPreview:!0}:{backBtnEnabled:!0}),this.aiPhotoService.isWorkflow&&(this.aiPhotoService.backBtnClick.next({isBack:!0}),this.aiPhotoService.isWorkflow=!1,setTimeout(()=>{this.isGenerated=!0,this.isRecent=!0})),t.isVideo?(this.videoUrl=t.urls[0],this.prompt=t?.prompt,this.videoPreview=!0,this.generatedVideoResult=t):this.aiPhotoService.generateImageFn(t),this.aiPhotoService.isDirty=!0,this.selectedPreset?.productImageIds&&(this.aiPhotoService.deleteItem(this.selectedPreset?.productImageIds,this.productImageId),this.productImageId=0),this.gtmService.pushTag({eventName:y.b.gtm.eventname.aiGenerateMob,itemName:this.toolName,itemValue:this.toolName+"_"+(1==i?this.selectedPreset?.displayName||"Other":"Prompt")}))}):(this.aiPhotoService.clearGenerationProgress(),this.isGenerated=!1)}loadLayoutConfig(t=null){this.getDynamicToolConfig(o=>{if(o){this.layout=o;const r=this.layout.config;this.rows=this.layout.rows,r&&(this.selectedMode=r.defaultMode||f.y9.Presets,this.layoutVersion=r?.mobLayoutVersion?r?.mobLayoutVersion:this.layoutVersion),this.rows&&(this.maxLength=this.rows.find(l=>l.type==f.T6.PromptPanel)?.content?.maxLength||this.maxLength,this.layout.isResolution=!!this.rows.find(l=>l.type==f.T6.ResolutionPanel),this.layout.isFileUpload=!!this.rows.find(l=>l.type==f.T6.FileUpload),this.layout.customUpload=!!this.rows.find(l=>l.type==f.T6.CustomUpload),this.layout.isPreset=!!this.rows.find(l=>l.type==f.T6.PresetsPanel),this.layout.isPrompt=!!this.rows.find(l=>l.type==f.T6.PromptPanel),this.layout.isWorkflow=!!this.rows.find(l=>l.type==f.T6.WorkflowPanel)),t&&t()}else this.toast.showErrorSingle(y.b.message.uiConfigNotFound),this.isLoaded=!0});const i=this.aiPhotoService.queryParams;i?.productId&&(this.productId=Number(i.productId)),i?.prodImageId&&(this.productImageId=Number(i.prodImageId),this.hasPreselectedTemplateFromQuery=!0,this.preselectedProductImageIdFromQuery=this.productImageId),i?.catId&&(this.categoryId=Number(i.catId)),i?.tp&&(this.customPrompt=i.tp)}getDynamicToolConfig(t=null){this.featureType&&this.aiPhotoService.getDymanicToolConfig(this.featureType,i=>{i&&i.body&&i.body.dynamicToolConfig?t&&t(i.body.dynamicToolConfig):t&&t(null)},i=>{t&&t(null)})}getCategories(t=null){let o=this.layout?.config?.parentCategoryId||0;const r=this.rows.find(c=>c.type==f.T6.Category||c.type==f.T6.Product);let l=[];r&&(r.config?.categoryId&&!this.categoryId&&(this.categoryId=r.config?.categoryId),l=r.config?.items||[],l.length&&(this.categories=l,this.catId&&(this.categoryId=this.categories.find(c=>c.categoryId==this.catId)?.categoryId),this.categoryId=this.categories.find(c=>c.categoryId==this.categoryId)?.categoryId||this.categories[0]?.categoryId||0)),o&&!l.length?this.templateService.getProductCategoryListing(o,this.pageNumber,c=>{c&&c.storeCategories&&c.storeCategories.length>0?(this.categories=c.storeCategories[0]?.subCategoryList||[],this.categories.forEach(d=>{d?.displayName||(d.displayName=d.gaName)}),this.catId&&(this.categoryId=this.categories.find(d=>d.categoryId==this.catId)?.categoryId),this.categoryId=this.categories.find(d=>d.categoryId==this.categoryId)?.categoryId||this.categories[0]?.categoryId||0,this.categoryId?this.getProductDetails(this.categoryId,()=>{t&&t()},!0):t&&t()):t&&t()},c=>{t&&t()},1,Ae.i.Main):this.categoryId?this.getProductDetails(this.categoryId,()=>{t&&t()},!0):t&&t()}getProductDetails(t,i=null,o=!1,r=!0){this.loadProductListingPage({categoryId:t,reset:r,init:o,selectOnReset:!0,onLoaded:()=>{this.isLoaded=!0,i&&i()},onError:()=>{this.isLoaded=!0}})}onProductListScrollEnd(){const t=this.productListingCategoryId||this.categoryId||this.rows?.find(i=>i.type==f.T6.Product||i.type==f.T6.Category)?.config?.categoryId;if(t){if(this.featureType==f.Fs.Avatar)return void this.getCategoryProductDetails(t,null,!1,!1);this.getProductDetails(t,null,!1,!1)}}loadProductListingPage({categoryId:t,reset:i,init:o=!1,selectOnReset:r=!0,onLoaded:l=null,onError:c=null}){if(!t||this.isLoadingMoreProducts||!i&&this.isProductsEnd)return void(l&&l());const d=i?0:this.productListPageNumber+1;this.isLoadingMoreProducts=!0,this.isLoadingMoreProductsForPlaceholders=!i,this.productListingCategoryId=t,i&&
1(this.productListPageNumber=0,this.isProductsEnd=!1),this.mediaContentService.getProductListing(t,d,h=>{const p=h?.storeProducts||[];if(i){if(this.selectedProduct=r?null:this.selectedProduct,this.storeProducts=p,o&&this.productId){const u=this.storeProducts.findIndex(g=>g.productId==this.productId);if(-1!=u){let g=this.storeProducts[u];this.storeProducts.splice(u,1),this.storeProducts.splice(0,0,g)}}}else p.length&&(this.storeProducts=this.mergeUniqueProducts(this.storeProducts,p));this.productListPageNumber=d,this.isProductsEnd=p.length<a.MOBILE_PRODUCT_LIST_PAGE_SIZE,this.isLoadingMoreProducts=!1,this.isLoadingMoreProductsForPlaceholders=!1,i&&r&&this.storeProducts.length&&(this.selectProduct(this.storeProducts),this.selectedProduct&&!this.selectedProduct?.isAvatar&&(this.resetSelectedProductImagePagination(this.selectedProduct?.productId),this.isVideoShootV5Layout()||this.loadSelectedProductImages(this.selectedProduct,!0))),l&&l()},()=>{this.isLoadingMoreProducts=!1,this.isLoadingMoreProductsForPlaceholders=!1,c&&c()},null,Ae.i.Main,a.MOBILE_PRODUCT_LIST_PAGE_SIZE)}mergeUniqueProducts(t=[],i=[]){if(!i?.length)return t||[];const o=new Set((t||[]).map(l=>l?.productId)),r=i.filter(l=>!o.has(l?.productId));return r.length?(t||[]).concat(r):t||[]}resetSelectedProductImagePagination(t=0){this.selectedProductImagePageNumber=0,this.isLoadingMoreSelectedProductImages=!1,this.isSelectedProductImagesEnd=!t}onStyleListScroll(t){if(!this.selectedProduct?.productId||this.isAvatar||this.isCustom)return;const i=t?.target;i&&i.scrollWidth-(i.scrollLeft+i.clientWidth)<=24&&this.loadSelectedProductImages(this.selectedProduct,!1)}loadSelectedProductImages(t,i=!1){if(!t?.productId||t?.isAvatar||this.isLoadingMoreSelectedProductImages||!i&&this.isSelectedProductImagesEnd)return;const o=i?0:this.selectedProductImagePageNumber+1,r=i?Number(this.productImageId||0):0;if(i){const l=this.storeProducts.find(c=>c.productId==t.productId);l&&(l.storeProductImages=[]),this.productImageId=0,this.selectedPreset=null}this.isLoadingMoreSelectedProductImages=!0,this.mediaContentService.getTemplateByProductId(t.productId,o,l=>{const c=this.storeProducts.find(h=>h.productId==t.productId);let d=!1;if(c){const h=l?.storeProductImages||[];if(i)c.storeProductImages=h,this.movePreferredImageToFront(c.storeProductImages,r);else if(h.length){const g=c.storeProductImages||[],_=new Set(g.map(v=>v.productImageId));c.storeProductImages=g.concat(h.filter(v=>!_.has(v.productImageId)))}this.selectedProductImagePageNumber=o,this.isSelectedProductImagesEnd=h.length<a.MOBILE_PRODUCT_IMAGE_PAGE_SIZE,d="v4"==this.layoutVersion&&!this.isSelectedProductImagesEnd&&(c.storeProductImages?.length||0)<a.MOBILE_V4_MIN_IMAGES_FOR_SCROLL&&this.selectedProduct?.productId==t.productId,i&&this.selectedProduct?.productId==t.productId&&this.selectProduct(this.storeProducts)}this.isLoadingMoreSelectedProductImages=!1,d&&setTimeout(()=>{this.loadSelectedProductImages(t,!1)})},()=>{this.isLoadingMoreSelectedProductImages=!1},null,a.MOBILE_PRODUCT_IMAGE_PAGE_SIZE)}movePreferredImageToFront(t=[],i=0){if(!i||!t?.length)return;let o=t.findIndex(r=>r?.productImageId==i);if(o<0&&(o=t.findIndex(r=>r?.productId==i)),o>0){const r=t[o];t.splice(o,1),t.unshift(r)}}selectProduct(t,i=null){const o=t.find(r=>r.productId==this.productId);if(this.selectedProduct=o||t[0],this.selectedProduct){this.productId=this.selectedProduct?.productId,this.modelTypeId=this.selectedProduct?.modelTypeId,this.productCreditConfig=this.selectedProduct?.productCreditConfig||null;let r=this.selectedProduct?.storeProductImages?.find(c=>c.productImageId==this.productImageId);if(r||(r=this.selectedProduct?.storeProductImages?.[0]),r)if(this.productImageId=r.productImageId,this.imageJson=r.imageJson,this.hasPreselectedTemplateFromQuery&&this.isVideoShootV5Layout()&&this.preselectedProductImageIdFromQuery&&r.productImageId==this.preselectedProductImageIdFromQuery?(this.selectedPreset={...r,productId:this.productId},this.hasOpenedVideoTemplatePicker=!0,this.showVideoTemplatePicker=!1,this.setVideoTemplatePreview(this.selectedPreset)):"v2"==this.layoutVersion&&(this.selectedPreset=r),this.productCreditConfig)this.productCreditConfig.videoDuration=Number(this.selectedPreset?.duration);else{const c=this.paymentService?.config?.creditInfo;this.creditConfig=c?.[this.featureType]||1,this.videoSettings=null}this.getPrompts(i==f.T6.Product||this.featureType==f.Fs.Filter?this.productId:0)}}getAvatarCategoryDetails(){this.aiType=se.Jl.avatarify;const t=this.rows.find(o=>o.type==f.T6.Product||o.type==f.T6.Category)?.config?.categoryId||se.KK.AIAvatarify,i=this.aiPhotoService.queryParams;this.getCategoryProductDetails(t,()=>{this.getCategoryDetails(se.KK.AIAvatar,o=>{let r=[];const l=this.storeProducts?.[0]||{storeProductImages:[]};
1if(o.forEach((d,h)=>{if(d){let p=JSON.parse(JSON.stringify(l));p.displayName="Preset "+ ++h,p.productId=-++h,p.categoryId=d.categoryId,p.isAvatar=!0,p.storeProductImages=JSON.parse(JSON.stringify(d.storeProducts||[])),r.push(p)}}),this.catId=i?.catId?Number(i?.catId):r[0]?.categoryId,this.storeProducts.find(d=>d.productId==i?.productId)){this.isAvatar=!1,this.catId=0,this.productId=Number(i?.productId);const d=this.storeProducts.findIndex(h=>h.productId==this.productId);if(-1!=d){let h=this.storeProducts[d];this.storeProducts.splice(d,1),this.storeProducts.splice(0,0,h)}this.storeProducts=r.concat(this.storeProducts),this.selectProduct(this.storeProducts),this.selectedProduct&&!this.selectedProduct?.isAvatar&&(this.resetSelectedProductImagePagination(this.selectedProduct?.productId),this.loadSelectedProductImages(this.selectedProduct,!0))}else{this.storeProducts=r.concat(this.storeProducts),this.selectedProduct=this.storeProducts.find(h=>h.categoryId==this.catId),this.isAvatar=!0;const d=Number(i?.prodImageId||i?.productId||this.productImageId||0);this.movePreferredImageToFront(this.selectedProduct?.storeProductImages,d)}this.isLoaded=!0})})}openPrompt(t){this.step=2,this.isPromptOpen=t}isDisabled(){if(this.productConfig&&this.aiPhotoService.isWorkflow)return!this.workflowUIService.isDisabled(this.productConfig,this.disabled);const t=this.rows?.find(i=>i?.type==f.T6.FileUpload)?.config;return"v1"==this.layoutVersion?2==this.step&&this.customPrompt?.trim()&&this.customPrompt?.trim().length>1:this.isVideoShootV5Layout()?this.isDuoTemplateFlow()?!!this.aiPhotoService?.imgUrl&&!!this.aiPhotoService?.originalImageUrlDuo&&!!this.selectedPreset?.productImageId:this.dynamicFields?this.aiPhotoService.hasDynamicFieldsValue(this.dynamicFields):!!this.aiPhotoService?.imgUrl&&!!this.selectedPreset?.productImageId:"v2"==this.layoutVersion?2==this.step?this.customPrompt?.trim()&&this.customPrompt.trim().length>1&&this.aiPhotoService?.originalImageUrlDuo:this.selectedPreset&&this.aiPhotoService?.originalImageUrlDuo:"v4"==this.layoutVersion?this.customPrompt?.trim()&&this.customPrompt?.trim().length>1:"v3"==this.layoutVersion?this.switchToggle?!!(this.customPrompt?.trim()&&this.customPrompt?.trim().length>1&&this.aiPhotoService?.imgUrl&&this.aiPhotoService?.originalImageUrlDuo):!!(this.customPrompt?.trim()&&this.customPrompt?.trim().length>1&&this.aiPhotoService?.imgUrl):t?.uploadVersion==f.up.Version2||t?.uploadVersion==f.up.Version3||!(!t?.switchToggle||t?.uploadVersion!=f.up.Version1)&&this.switchToggle}isDuoImageUploaded(){const t=this.rows?.find(i=>i?.type==f.T6.FileUpload)?.config;return(t?.uploadVersion==f.up.Version2||t?.uploadVersion==f.up.Version3||!(!t?.switchToggle||t?.uploadVersion!=f.up.Version1)&&this.switchToggle)&&this.aiPhotoService?.originalImageUrlDuo}closeChangeEvent(t){"size"==t.type?this.quality=t.quality:"style"==t.type&&t.selectedStyle?this.selectedPreset=t.selectedStyle:"styleScrollEnd"==t.type&&"v4"==this.layoutVersion&&this.selectedProduct&&this.loadSelectedProductImages(this.selectedProduct,!1)}closeOverlay(){this.showVideoTemplatePicker?this.closeVideoTemplatePicker():(this.step=1,this.isPromptOpen=!1,this.disabled=!this.customPrompt?.trim())}isVideoShootFeatureType(){return this.featureType==f.Fs.ImageToAnimate||this.featureType==f.Fs.Videoshoot||this.featureType==f.Fs.DuoVideoshoot||"duoimageanimate"==this.featureType}isDuoVideoShootFeatureType(){return this.featureType==f.Fs.DuoVideoshoot||"duoimageanimate"==this.featureType}isDuoTemplateFlow(){if(this.isDuoVideoShootFeatureType()||1==this.aiPhotoService?.queryParams?.duo||"1"==this.aiPhotoService?.queryParams?.duo)return!0;const t=this.selectedPreset?.modelTypeId,i=this.selectedProduct?.modelTypeId;return 74==t||74==i||74==this.modelTypeId}isV5TemplateFlowRequested(){return"v5"==this.aiPhotoService?.queryParams?.lv||this.isVideoShootFeatureType()}getVideoTemplatePickerTitle(){const i=this.aiPhotoService.getToolByName(this.featureType,this.activeTab||this.aiPhotoService?.queryParams?.tab||z.sv.AI_IMAGE_TOOLS),o=(i?.text||i?.metadata?.title||i?.metadata?.displayName||i?.metadata?.name||"").trim();if(o)return`${o} Templates`;const r=(this.toolName||this.featureType||"").trim();return r?`${r} Templates`:"Templates"}isVideoShootV5Layout(){return"v5"==this.layoutVersion}openVideoTemplatePickerIfNeeded(){if(!this.hasOpenedVideoTemplatePicker&&this.isVideoShootV5Layout()&&!this.isResolvingPreselectedTemplate){if(this.hasPreselectedTemplateFromQuery&&this.selectedPreset?.productImageId)return this.hasOpenedVideoTemplatePicker=!0,void(this.showVideoTemplatePicker=!1);this.categoryId||(this.categoryId=this.categories?.[0]?.categoryId||0),this.categoryId&&(this.resetGeneratedVideoView(),this.hasOpenedVideoTemplatePicker=!0,this.showVideoTemplatePicker=!0)}}resolvePreselectedVideoTemplate(){!this.isVideoShootV5Layout()||!this.hasPreselectedTemplateFromQuery||!this.preselectedProductImageIdFromQuery||(this.isResolvingPreselectedTemplate=!0,this.templateService.getDesign(this.preselectedProductImageIdFromQuery,t=>{const i=t?.storeProductImage;if(this.isResolvingPreselectedTemplate=!1,this.finishVideoTemplateTransitionIfReady(),!i?.productImageId)return void this.openVideoTemplatePickerIfNeeded();this.selectedPreset={...i,productId:i?.productId||this.productId},this.productId=this.selectedPreset.productId||this.productId,this.productImageId=this.selectedPreset.productImageId,this.imageJson=this.selectedPreset?.imageJson||this.imageJson,this.hasOpenedVideoTemplatePicker=!0,this.showVideoTemplatePicker=!1,this.setVideoTemplatePreview(this.selectedPreset),this.dynamicFields=this.aiPhotoService.parseMeta(i?.meta)||null;const o=this.dynamicFields?.i2i_fields?.filter(l=>"image"===l.type)||[],r=this.dynamicFields?.i2v_fields?.filter(l=>"image"===l.type)||[];this.imageFields=[...o,...r]},()=>{this.isResolvingPreselectedTemplate=!1,this.finishVideoTemplateTransitionIfReady(),this.openVideoTemplatePickerIfNeeded()}))}finishVideoTemplateTransitionIfReady(){this.isVideoTemplateBaseDataReady&&!this.isResolvingPreselectedTemplate&&(this.isVideoTemplateTransitioning=!1)}closeVideoTemplatePicker(){this.showVideoTemplatePicker=!1,this.isVideoTemplateTransitioning=!1,this.changeTemplate||this.changeStep.emit
1({resetToIntermediate:!0}),this.changeTemplate=!1}onVideoTemplateSelected(t){if(t){if(this.dynamicFields=null,this.selectedPreset=t,this.productId=t?.productId||this.productId,this.productImageId=t?.productImageId||this.productImageId,this.imageJson=t?.imageJson||this.imageJson,this.storeProducts?.length&&this.productId){const i=this.storeProducts.find(o=>o.productId==this.productId);if(i){this.selectedProduct=i,this.modelTypeId=i?.modelTypeId||this.modelTypeId,this.productCreditConfig=i?.productCreditConfig||null,this.dynamicFields=this.aiPhotoService.parseMeta(t?.meta)||null;const o=this.dynamicFields?.i2i_fields?.filter(l=>"image"===l.type)||[],r=this.dynamicFields?.i2v_fields?.filter(l=>"image"===l.type)||[];if(this.imageFields=[...o,...r],this.imageFields?.length&&this.aiPhotoService.imgUrl&&(this.dynamicFields.input_url=this.aiPhotoService.imgUrl),this.videoSettings=null,this.productCreditConfig)this.productCreditConfig.videoDuration=Number(t?.duration);else{const l=this.paymentService?.config?.creditInfo;this.creditConfig=l?.[this.featureType]||1}}}this.showVideoTemplatePicker=!1,this.setVideoTemplatePreview(t)}}resetGeneratedVideoView(){this.isGenerated=!1,this.videoPreview=!1,this.videoUrl="",this.prompt="",this.generatedVideoResult=null,this.aiPhotoService.backBtnClick.next({isBack:!0})}setVideoTemplatePreview(t){this.resetGeneratedVideoView();const i=t?.imgUrl||t?.videoThumbUrl||t?.thumbUrl||"";this.templatePreviewItem=i?{assetId:`template-preview-${t?.productImageId||this.productImageId||Date.now()}`,isVideo:!!t?.videoThumbUrl,urls:[i],format:t?.format}:null}getTemplatePreviewVideoUrl(){return this.selectedPreset?.imgUrl||this.selectedPreset?.videoThumbUrl||""}openTemplateVideoPreview(){this.getTemplatePreviewVideoUrl()&&(this.previewCurrentTime="00:00",this.previewDuration="00:00",this.previewIsPlaying=!1,this.showTemplateVideoPreview=!0,this.renderer.addClass(this.document.body,"overflow-hidden"))}closeTemplateVideoPreview(){this.showTemplateVideoPreview&&(this.showTemplateVideoPreview=!1,this.previewIsPlaying=!1,this.previewCurrentTime="00:00",this.previewDuration="00:00",this.renderer.removeClass(this.document.body,"overflow-hidden"))}toggleTemplatePreviewPlay(t){if(!t)return;if(!t.paused&&!t.ended)return void t.pause();const i=t.play();i&&"function"==typeof i.then&&i.catch(()=>{})}onTemplatePreviewMetadata(t){t&&(this.previewDuration=this.formatPreviewTime(t.duration),this.previewCurrentTime=this.formatPreviewTime(t.currentTime))}onTemplatePreviewTimeUpdate(t){t&&(this.previewCurrentTime=this.formatPreviewTime(t.currentTime),t.duration&&isFinite(t.duration)&&(this.previewDuration=this.formatPreviewTime(t.duration)))}onTemplatePreviewEnded(t){this.previewIsPlaying=!1,this.previewCurrentTime="00:00",t&&(t.currentTime=0)}formatPreviewTime(t){if(!isFinite(t)||t<0)return"00:00";const i=Math.floor(t),o=Math.floor(i/60),r=i%60;return`${String(o).padStart(2,"0")}:${String(r).padStart(2,"0")}`}onFileUploaded(t){if(!t)return;const i=t[0];this.activePanelId=this.PANEL_ID.customUpload,this.layout.customUpload&&(this.aiPhotoService.startProcessingProgress({featureType:this.featureType,indeterminate:!0}),this.aiUploadImageService.aiUploadImage(i,{tab:this.activeTab,toolName:this.featureType,uploadProgress:"none",isStyleRefImage:!0}).then(o=>{"cancel"!=o?(this.aiPhotoService.originalImageUrlCustom=o.imgUrl,this.aiPhotoService.clearGenerationProgress(),this.generate()):this.aiPhotoService.clearGenerationProgress()},o=>{this.aiPhotoService.clearGenerationProgress()}))}customFileClick(t){if(this.featureType==f.Fs.AIVirtualTryOn)if("true"!=localStorage.getItem("doNotShowTryOn")){const o=this.modalService.open(nn.I,{centered:!0,size:"md",backdrop:"static",windowClass:"tryon-upload-popup"});o.componentInstance.PopUpType="tryon-upload-popup",o.result.then(r=>{r&&t.click()})}else t.click();else t.click()}workflowClick(){this.selectedPreset=null,this.activePanelId=this.PANEL_ID.workflow,this.aiPhotoService.isWorkflow=!0,this.aiPhotoService.backBtnClick.next({backBtnEnabled:!0})}productConfigChange(t){this.productConfig=t}
1getWorkflows(t=null){this.productConfig=null,this.categoryId&&this.layout.isWorkflow&&(this.isWorkflowLoading=!0,this.mediaContentService.getWorkflows(this.categoryId,i=>{i?(this.workflowList=i?.productConfig||[],this.workflowList?.length&&(this.productConfig=JSON.parse(JSON.stringify(this.workflowList[0])),this.workflowUIService.setFieldsValue(this.productConfig)),t&&t(),this.isWorkflowLoading=!1):(t&&t(),this.isWorkflowLoading=!1)},i=>{this.isWorkflowLoading=!1}))}toggleSecondImage(t){if(this.switchToggle=t,"v3"==this.layoutVersion){const i=this.paymentService?.config?.creditInfo;this.creditConfig=this.switchToggle?i?.[f.Fs.Frameinterpolation]:i?.[this.featureType]}}changeResolution(t){this.quality=t}selectSize(t){this.selectedSize=t,this.step=1}openResolutionPanel(){this.step=4}onDropdownOpen(){requestAnimationFrame(()=>{const t=document.querySelector(".ng-dropdown-panel");this.selectedProduct?.storeProductImages||this.renderer.addClass(t,"advertisement-top")})}selectModel(t){const i=Number(t?.credits);!Number.isNaN(i)&&i>0&&(this.creditConfig=i),this.selectedModel=t}onDropdownClose(){const t=document.querySelector(".ng-dropdown-panel");t&&this.renderer.removeClass(t,"advertisement-top")}selectionChange(t){this.videoSettings={...t},Number.isFinite(t.creditValue)&&(this.creditConfig=t.creditValue)}changeTemplateClick(t){this.showVideoTemplatePicker=!0,this.changeTemplate=!0}}return(s=a).MOBILE_PRODUCT_LIST_PAGE_SIZE=50,s.MOBILE_PRODUCT_IMAGE_PAGE_SIZE=20,s.MOBILE_V4_MIN_IMAGES_FOR_SCROLL=12,s.\u0275fac=function(t){return new(t||s)(e.rXU(we.Z),e.rXU(b.qQ),e.rXU(Z.s),e.rXU(ae.g),e.rXU(q.u),e.rXU(ne.A),e.rXU(ee.M),e.rXU(ie.y),e.rXU(J.K),e.rXU(de.W),e.rXU(Ke.I),e.rXU(Q.f),e.rXU(pt.b),e.rXU(e.sFG),e.rXU(R.Bq))},s.\u0275cmp=e.VBU({type:s,selectors:[["ai-generate-v1"]],inputs:{activeTab:"activeTab",featureType:"featureType",checkimg:"checkimg"},outputs:{changeStep:"changeStep",uploadFileEvent:"uploadFileEvent",chooseFileEvent:"chooseFileEvent"},decls:26,vars:31,consts:[["DynamicToolVersion1",""],["customTemplate",""],["generateButton",""],["inputFile",""],["templatePreviewVid",""],["styleList",""],["loadingTemplate",""],[1,"position-relative",2,"height","max-content",3,"ngClass"],[1,"drawer-elements","ai-drawer-elements",3,"ngClass"],[4,"ngIf"],[4,"ngTemplateOutlet"],[1,"p-3","pt-9","pb-9","position-fixed","bg-white","w-100","fixed-prompt","mobile-sheet-anim",2,"bottom","0px","z-index","9999","border-radius","20px 20px 0px 0px"],[3,"changePrompt","generateClick","changeResolution","prompts","textPrompt","isVideo","maxLength","autoFocusOnOpen","disabled","credit","resolutionEnabled","quality"],[1,"showpreview-overlay","align-items-center","justify-content-start","position-fixed","mobile-sheet-overlay",3,"click"],[1,"workflow-overlay","position-fixed","w-100"],[1,"template-video-preview","position-fixed","w-100","h-100","d-flex","align-items-center","justify-content-center"],[1,"d-flex","justify-content-start","align-items-center","bottom-container","position-fixed","bg-white","p-3","pb-9","pt-2","flex-column","w-100","mobile-sheet-anim",2,"bottom","0px","z-index","9999",3,"close"],[1,"top-header","d-flex","justify-content-start","align-items-center","w-100","flex-column","mb-1","h-32"],[1,"text-lg","text-semi","grey-800","m-0","w-100","lh-125","w-100","d-flex","align-items-center","justify-content-between","h-32"],["name","previewclose",3,"click"],["class","modal-box resolution-modal d-flex justify-content-between align-items-center w-100 border-radius-12 ps-2 pe-2 mb-2 h-48",3,"click",4,"ngFor","ngForOf"],["id","inputFile","name","inputFile","type","file",1,"custom-file-input","d-none",3,"change","click","accept"],[3,"selectedTemplate","closePreview","categoryId","prefetchedProducts","useProductFormatForMedia","aiPhotoService","previewTitle"],[1,"position-fixed","d-flex","align-items-center","justify-content-center","w-100","h-100",2,"left","0","top","0","z-index","100001","background","rgba(248, 249, 249, 0.92)"],["role","status",1,"spinner-border","spinner-border-lg","hw-60"],[1,"sr-only","d-none"],[3,"close","addCredit","consumeCoins"],[1,"workflow-scroll-area","h-100","overflow-auto","p-3"],[3,"productC
1onfigChange","productConfig","workflowList","inProgress"],[1,"position-fixed","w-100","workflow-generate-bar"],["type","button",1,"template-video-preview__close","position-absolute","d-flex","align-items-center","justify-content-center","text-white","pointer",3,"click"],["name","close",1,"f-24","text-white"],[1,"template-video-preview__player","position-relative","w-100"],["playsinline","","autoplay","","loop","","muted","",1,"w-100","h-100",3,"play","pause","loadedmetadata","timeupdate","ended","src"],["type","button",1,"btn-video-action","btn-play","position-absolute","d-flex","align-items-center","justify-content-center","text-white","pointer",3,"click"],[1,"f-24",3,"name"],[1,"vid-time","d-inline-flex","align-items-center","justify-content-center","text-13","text-white","text-regular","lh-125","position-absolute"],[2,"min-width","39px"],[1,"align-items-center","justify-content-center","overflow-hidden","w-100","flex-column","p-3","pb-0"],[3,"uploadFileEvent","featureType","layoutVersion","isVideo","videoUrl","prompt","videoPreview","generatedVideoResult","checkimg","previewItem"],[4,"ngFor","ngForOf"],[1,"d-flex","align-items-center","justify-content-center","overflow-hidden","w-100","flex-column","p-3","pb-0"],[1,"d-flex","align-items-start","justify-content-center","overflow-hidden","duophotoshoot","flex-column","w-100"],[1,"w-100","d-flex","flex-row","align-items-start","justify-content-center","flex-column","mb-3","w-100"],[1,"text-lg","text-semi","grey-800","mb-2","lh-125","mt-2"],[1,"text-14","grey-400","lh-125"],[1,"d-flex","w-100","align-items-center","justify-content-center","w-100",3,"ngClass"],[3,"toolName","version"],["class","d-flex align-items-center justify-content-end mb-3 w-100","style","margin-top: -8px;",4,"ngIf"],[1,"d-flex","align-items-center","justify-content-end","mb-3","w-100",2,"margin-top","-8px"],[1,"text-13","lh-140","text-black"],[1,"editor-toggle","ms-2"],[1,"d-flex","align-items-center",3,"changeT","selected"],[1,"pt-2","pb-9","position-fixed","gray-100","w-100","modal-container","fixed-prompt",2,"bottom","0px","z-index","2"],[3,"changePrompt","generateClick","openPromptClick","changeResolution","selectModel","prompts","textPrompt","isVideo","maxLength","disabled","credit","ver
1sion","resolutionEnabled","quality","featureType"],[1,"wp-100","d-flex","align-items-center","justify-content-start","mb-9","styles-options","overflow-scroll","new-scroll-behave"],[3,"closeChangeEvent","storeProducts","layoutVersion","selectedProduct","isStyleImagesLoading","isStyleImagesEnd","styleLoadingPlaceholders","productImageId","quality"],[1,"editor-tool-panel","m-editor-tool-panel","position-fixed","w-100"],["class","d-flex w-100 mb-10 selectcategory new-scroll-behave mx-auto",3,"ngClass",4,"ngIf"],["class","d-flex w-100 mb-3 storeproducts",3,"ngClass",4,"ngIf"],["class","d-flex w-100 flex-column",3,"ngClass",4,"ngIf"],["style","height: 64px;",4,"ngIf"],[1,"d-flex","w-100","mb-10","selectcategory","new-scroll-behave","mx-auto",3,"ngClass"],[1,"dropdown-top","bg-grey3","d-inline-flex","align-items-center","justify-content-center"],[2,"margin","0px 16px",3,"items","type","categoryId"],["appendTo","body","placeholder","Select Category",1,"select-menu","show-on-top",2,"min-width","128px",3,"ngModelChange","change","open","close","searchable","clearable","ngModel","dropdownPosition"],[3,"value",4,"ngFor","ngForOf"],[3,"value"],[2,"margin","0px 16px",3,"selectLayout","items","type","categoryId"],[1,"d-flex","w-100","mb-3","storeproducts",3,"ngClass"],[2,"max-width","-webkit-fill-available",3,"selectLayout","scrollEnd","items","type","categoryId"],[1,"d-flex","w-100","flex-column",3,"ngClass"],["class","d-flex w-100 flex-column overflow-hidden",4,"ngIf"],[1,"d-flex","w-100","flex-column","overflow-hidden"],[1,"ai-thumb-list","d-flex","align-items-center","overflow-scroll","ps-3","pe-3",2,"flex-flow","row","column-gap","12px","scrollbar-width","none","justify-content","space-between",3,"scroll","ngClass"],["context","{row: row}",4,"ngTemplateOutlet"],["class","ai-thumb-col d-flex align-items-center flex-column",3,"ngClass",4,"ngFor","ngForOf"],["context","{row: row}"],[1,"ai-thumb-col","d-flex","align-items-center","flex-column",3,"ngClass"],[1,"img-col","d-flex","align-items-center","border-radius-12","mb-1",3,"click"],["width","92px","height","92px",3,"src"],["name","suffle"],[1,"w-100","text-center","grey-500",2,"min-height","28px"],["class","ai-thumb-col d-flex align-items-center justify-content-center flex-column placeholder-thumb","style","min-height: 124px;",4,"ngFor","ngForOf"],[1,"ai-thumb-col","d-flex","align-items-center","justify-content-center","flex-column","placeholder-thumb",2,"min-height","124px"],[1,"img-col","d-flex","align-items-center","border-radius-12","mb-1","skeleton-box"],[1,"skeleton-line"],["class","d-flex w-100 flex-column overflow-hidden",4,"ngIf","ngIfElse"],[1,"ai-thumb-list","d-flex","align-items-center","overflow-scroll","ps-3","pe-3",2,"flex-flow","row","column-gap","12px","scrollbar-width","none","justify-content","space-between",3,"ngClass"],[1,"ai-thumb-col","d-flex","align-items-center","flex-column",2,"height","92px","width","92px"],[1,"img-col","d-flex","align-items-center","justify-content-center","border-radius-12","mb-1","custom-text","position-relative"],[3,"view"],[2,"height","64px"],[1,"d-flex","align-items-center","justify-content-center","w-100","flex-column","p-3","pb-0"],[1,"d-flex","align-items-start","justify-content-start","duophotoshoot","flex-column","w-100","video-app-upload","new-scroll-behave"],["class","d-flex align-items-start justify-content-start w-100 mb-3 d-lg-none flex-column ps-3 pe-3",4,"ngIf"],["class","d-inline-flex text-13 text-semi grey-800 lh-125 mb-1 w-100 align-items-center ps-3 pe-3","style","min-height: 32px;",4,"ngIf"],[3,"toolName","version","input_url"],["class","mt-3 w-100 ps-3 pe-3",3,"dynamicFields",4,"ngIf"],[1,"d-flex","align-items-start","justify-content-start","w-100","mb-3","d-lg-none","flex-column","ps-3","pe-3"],[1,"d-inline-flex","text-13","text-semi","grey-800","lh-125","mb-1","w-100","align-items-center",2,"min-height","32px"],[1,"d-flex","w-100","justify-content-between","align-items-center","custom-AI-modal","border-radius-12","pointer","ps-1","pe-2","position-relative"],[1,"d-inline-flex","align-items-center","justify-content-between",3,"click"],[1,"thumb
1-box","d-inline-flex","align-items-center","justify-content-center","pe-0","overflow-hidden","position-relative"],["width","40px","height","40px",3,"src",4,"ngIf"],[1,"grey-800","text-13","ms-2","me-2","d-inline-flex","align-items-center","lh-125","inline-content","selected-item-text"],["type","button",1,"btn-remove","d-flex","align-items-center","justify-content-center","text-12","text-medium","text-dark",3,"click","disabled"],["width","40px","height","40px",3,"src"],[1,"d-inline-flex","text-13","text-semi","grey-800","lh-125","mb-1","w-100","align-items-center","ps-3","pe-3",2,"min-height","32px"],["class","text-danger",4,"ngIf"],[1,"text-danger"],[1,"mt-3","w-100","ps-3","pe-3",3,"dynamicFields"],["class","d-flex align-items-center justify-content-center","style","column-gap: 20px;",4,"ngIf"],["class","d-flex align-items-center justify-content-center",4,"ngIf"],[1,"d-flex","align-items-center","justify-content-center",2,"column-gap","20px"],["class","ai-thumb-col d-flex align-items-center flex-column",3,"ngClass","click",4,"ngIf"],["name","sepratepipe","style","margin-right: -12.2px;margin-top: -20px; margin-left: -20px;",4,"ngIf"],[1,"ai-thumb-col","d-flex","align-items-center","flex-column","pointer",3,"click"],["name","uploadmediaNew",1,"f-24","grey-500","d-inline-flex"],["name","sepratepipe","style","margin-right: -20px;margin-left: -20px; margin-top: -20px;",4,"ngIf"],["name","sepratepipe",2,"margin-right","-20px","margin-left","-20px","margin-top","-20px"],[1,"ai-thumb-col","d-flex","align-items-center","flex-column",3,"click","ngClass"],["name","workflowicon",1,"grey-500"],["name","customtext",1,"grey-500"],["name","sepratepipe",2,"margin-right","-12.2px","margin-top","-20px","margin-left","-20px"],[1,"d-flex","align-items-center","justify-content-center"],[1,"ai-thumb-col","d-flex","align-items-center","flex-column","recent-col",3,"click","ngClass"],[1,"img-col","d-flex","align-items-center","border-radius-12","mb-1","overflow-hidden"],["width","92px","height","92px",2,"max-height","92px","object-fit","cover",3,"src"],["name","sepratepipe",2,"margin-right","-12.2px","margin-top","-20px",3,"ngClass"],[1,"d-flex","align-items-center","justify-content-center","w-100","p-3","pt-2","gray-100",3,"ngClass"],["class","d-inline-flex align-items-center justify-content-center me-2",4,"ngIf"],["id","gtm-generate-mob",1,"btn","btn-primary-gradient","btn-primary-m","text-13","btn-h44","w-100","d-flex","align-items-center","justify-content-center",3,"keyup.enter","click","disabled"],["class","spinner-border spinner-border-lg me-2 hw-24","role","status",4,"ngIf"],[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,"text-11","text-semi",2,"padding-left","2px"],[1,"d-flex","align-items-center","justify-content-center","w-100","p-3","pt-1","pb-1","gray-100"],[1,"d-inline-flex","align-items-center","justify-content-center","me-2"],[3,"productCreditConfig","selection"],[1,"btn","btn-resolution","text-13","d-flex","align-items-center","ps-2","pe-2","justify-content-center"],[3,"selectionChange","productCreditConfig","selection"],[1,"btn","btn-resolution","text-13","d-flex","align-items-center","ps-2","pe-2","justify-content-center",3,"click"],[1,"resolution-text","text-black","text-bold","text-13","hw-32","d-inline-flex","align-items-center","justify-content-center","lh-160"],["name","chevronaarrow",1,"hw-24","ms-1"],["role","status",1,"spinner-border","spinner-border-lg","me-2","hw-24"],[1,"sr-only","text-nowrap","border-0","position-absolute","overflow-hidden"],["type","summary",3,"productCreditConfig","selection"],[1,"modal-box","resolution-modal","d-flex","justify-content-between","align-items-center","w-100","border-radius-12","ps-2","pe-2","mb-2","h-48",3,"click"],[1,"d-flex","justify-content-center","align-items-center"],[1,"f-24","grey-600","me-2",3,"name"],[1,"text-black","text-13","text-medium","lh-160"],[1,"grey-600","text-12","text-semi","ms-1","p-1","ratio-box","d-inline-flex","align-items-center","justify-content-center","lh-normal"]],template:function(t,i){if(1&t){const o=e.RV6();e.j41(0,"div",7)(1,"div",8),e.DNE(2,Vo,2,5,"ng-container",9)(3,Ro,5,0,"ng-container",9)(4,Fo,1,0,"ng-container",10),e.j41(5,"div",11)(6,"text-prompt-mobile",12),e.bIt("changePrompt",function(l){return e.eBV(o),e.Njj(i.changePrompt(l))})("generateClick",function(){return e.eBV(o),e.Njj(i.generate())})("changeResolution",function(l){return e.eBV(o),e.Njj(i.changeResolution(l))}),e.k0s()(),e.j41(7,"div",13),e.bIt("click",function(){return e.eBV(o),e.Njj(i.closeOverlay())}),e.k0s(),e.DNE(8,Ao,2,1,"ng-container",9),e.k0s(),e.DNE(9,Uo,5,4,"div",14),e.k0s(),e.DNE(10,Do,12,4,"div",15)(11,Ps,3,24,"ng-template",null,0,e.C5r)(13,Os,2,2,"ng-template",null,1,e.C5r)(15,Fs,12,11,"ng-template",null,2,e.C5r),e.j41(17,"div",16),e.bIt("close",function(){return e.eBV(o),e.Njj(i.step=1)}),e.j41(18,"div",17)(19,"h3",18),e.EFF(20," Aspect Ratio"),e.j41(21,"pi",19),e.bIt("click",function(){return e.eBV(o),e.Njj(i.step=1)}),e.k0s()()(),e.DNE(22,As,7,3,"div",20),e.k0s(),e.j41(23,"div",13),e.bIt("click",function(){return e.eBV(o),e.Njj(i.closeOverlay())}),e.k0s(),e.j41(24,"input",21,3),e.bIt("change",function(l){return e.eBV(o),e.Njj(i.onFileUploaded(l.target.files))})("click",function(){e.eBV(o);const l=e.sdS(25);return e.Njj(l.value="")}
1),e.k0s()}if(2&t){const o=e.sdS(12);e.Y8G("ngClass",e.eq3(27,et,i.isLogin)),e.R7$(),e.Y8G("ngClass",e.eq3(29,et,i.aiPhotoService.isWorkflow&&3!=i.step)),e.R7$(),e.Y8G("ngIf",i.showVideoTemplatePicker&&i.isVideoShootV5Layout()&&!i.isVideoTemplateTransitioning),e.R7$(),e.Y8G("ngIf",i.isVideoTemplateTransitioning&&i.isV5TemplateFlowRequested()),e.R7$(),e.Y8G("ngTemplateOutlet",o),e.R7$(),e.AVh("mobile-sheet-anim--open",2==i.step),e.R7$(),e.Y8G("prompts",i.prompts)("textPrompt",i.customPrompt)("isVideo",i.isVideo)("maxLength",i.maxLength)("autoFocusOnOpen",2==i.step)("disabled",!i.isDisabled())("credit",i.creditConfig)("resolutionEnabled",null==i.layout?null:i.layout.isResolution)("quality",i.quality),e.R7$(),e.AVh("mobile-sheet-overlay--open",2==i.step),e.R7$(),e.Y8G("ngIf",3==i.step),e.R7$(),e.vxM(i.aiPhotoService.isWorkflow?9:-1),e.R7$(),e.vxM(i.showTemplateVideoPreview?10:-1),e.R7$(7),e.AVh("mobile-sheet-anim--open",4==i.step),e.R7$(5),e.Y8G("ngForOf",i.resolutions),e.R7$(),e.AVh("mobile-sheet-overlay--open",4==i.step),e.R7$(),e.Y8G("accept",i.aiUploadImageService.fileImageAccept)}},dependencies:[b.YU,b.Sq,b.bT,b.T3,on.C,mt.n,P.BC,P.vS,H.b,_e.B,pe,sn.P,N.vr,N.xt,ut.G,gt.S,_t.d,ft,Ze,so,Io],styles:['.ai-thumb-list[_ngcontent-%COMP%]{flex-flow:wrap}.ai-thumb-list[_ngcontent-%COMP%]   .ai-thumb-col[_ngcontent-%COMP%]{height:100%;width:92px;border-radius:12px;margin-bottom:0;cursor:pointer;min-height:92px;min-width:92px;-webkit-user-select:none;user-select:none}.ai-thumb-list[_ngcontent-%COMP%]   .ai-thumb-col[_ngcontent-%COMP%]   .img-col[_ngcontent-%COMP%]{transition:transform .2s;min-height:92px;min-width:92px}.ai-thumb-list[_ngcontent-%COMP%]   .ai-thumb-col[_ngcontent-%COMP%]   .img-col[_ngcontent-%COMP%]   pi[_ngcontent-%COMP%]{display:none}.ai-thumb-list[_ngcontent-%COMP%]   .ai-thumb-col[_ngcontent-%COMP%]   .img-col[_ngcontent-%COMP%]   img[_ngcontent-%COMP%]{width:100%;height:100%;border-radius:12px}.ai-thumb-list[_ngcontent-%COMP%]   .ai-thumb-col[_ngcontent-%COMP%]   span[_ngcontent-%COMP%]{color:#272b34;font-size:12px;min-height:16px;line-height:14px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.ai-thumb-list[_ngcontent-%COMP%]   .ai-thumb-col[_ngcontent-%COMP%]   .custom-text[_ngcontent-%COMP%]{border:1px solid #E2E3E9;background:#eeedf3}.ai-thumb-list[_ngcontent-%COMP%]   .ai-thumb-col[_ngcontent-%COMP%]   .custom-text[_ngcontent-%COMP%]   pi[_ngcontent-%COMP%]{display:block!important}.ai-thumb-list[_ngcontent-%COMP%]   .ai-thumb-active[_ngcontent-%COMP%]{min-height:92px;min-width:92px}.ai-thumb-list[_ngcontent-%COMP%]   .ai-thumb-active[_ngcontent-%COMP%]   .img-col[_ngcontent-%COMP%]{position:relative;border:2px solid #626ADF}.ai-thumb-list[_ngcontent-%COMP%]   .ai-thumb-active[_ngcontent-%COMP%]   .img-col[_ngcontent-%COMP%]:hover{transform:none}.ai-thumb-list[_ngcontent-%COMP%]   .ai-thumb-active[_ngcontent-%COMP%]   .img-col[_ngcontent-%COMP%]   pi[_ngcontent-%COMP%]{display:block;position:absolute;left:calc(50% - 12px);top:calc(50% - 12px)}.ai-thumb-list[_ngcontent-%COMP%]   .ai-thumb-active[_ngcontent-%COMP%]   .img-col[_ngcontent-%COMP%]:before{position:absolute;background:#626adfb3;content:"";left:2.5px;height:calc(100% - 5.5px);width:calc(100% - 5.5px);border-radius:8px}.ai-thumb-list[_ngcontent-%COMP%]   .ai-thumb-active[_ngcontent-%COMP%]   img[_ngcontent-%COMP%]{border-radius:11px!important;border:3px solid #fff}.ai-thumb-list[_ngcontent-%COMP%]   .ai-thumb-active[_ngcontent-%COMP%]   span[_ngcontent-%COMP%]{color:#626adf!important;font-weight:600}.ai-thumb-list[_ngcontent-%COMP%]   .ai-thumb-col.ai-thumb-active.aiduoshoot[_ngcontent-%COMP%]   .img-col[_ngcontent-%COMP%]   pi[_ngcontent-%COMP%]{display:none}.ai-thumb-list[_ngcontent-%COMP%]   .ai-thumb-col.ai-thumb-active.aiduoshoot[_ngcontent-%COMP%]   .img-col[_ngcontent-%COMP%]:before{display:none}.placeholder-thumb[_ngcontent-%COMP%]   .skeleton-box[_ngcontent-%COMP%]{width:92px;height:92px;border-radius:12px;background:linear-gradient(90deg,#f1f2f6 25%,#e5e7ef 37%,#f1f2f6 63%);background-size:400% 100%;animation:_ngcontent-%COMP%_mobile-drawer-skeleton-shimmer 1.2s ease-in-out infinite}.placeholder-thumb[_ngcontent-%COMP%]   .skeleton-line[_ngcontent-%COMP%]{width:68px;height:12px;border-radius:8px;background:linear-gradient(90deg,#f1f2f6 25%,#e5e7ef 37%,#f1f2f6 63%);background-size:400% 100%;animation:_ngcontent-%COMP%_mobile-drawer-skeleton-shimmer 1.2s ease-in-out infinite}@keyframes _ngcontent-%COMP%_mobile-drawer-skeleton-shimmer{0%{background-position:100% 0}to{background-position:0 0}}.m-editor-tool-panel[_ngcontent-%COMP%]{bottom:0;max-width:-webkit-fill-available}.m-editor-tool-panel[_ngcontent-%COMP%]   buttons-scroll-menu[_ngcontent-%COMP%]   .menu-resizeSocial.color-tab[_ngcontent-%COMP%]{max-width:none!important}.workflow-overlay[_ngcontent-%COMP%]{background:#fff;height:calc(100% - 100px)!important;z-index:1}.workflow-generate-bar[_ngcontent-%COMP%]{left:0;bottom:0}.showpreview-overlay[_ngcontent-%COMP%]{display:none;background:#0003;-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);width:100%;height:100%;top:0;bottom:0;z-index:999}.mobile-sheet-overlay[_ngcontent-%COMP%]{display:block;opacity:0;pointer-events:none;transition:opacity .24s ease}.mobile-sheet-overlay.mobile-sheet-overlay--open[_ngcontent-%COMP%]{opacity:1;pointer-events:auto}.mobile-sheet-anim[_ngcontent-%COMP%]{transform:translate3d(0,100dvh,0);will-change:transform;-webkit-backface-visibility:hidden;backface-visibility:hidden;pointer-events:none;transition:transform .72s cubic-bezier(.22,.61,.36,1)}.mobile-sheet-anim.mobile-sheet-anim--open[_ngcontent-%COMP%]{transform:translateZ(0);pointer-events:auto;transition:transform .52s cubic-bezier(.2,.9,.2,1)}.mobile-congratulations[_ngcontent-%COMP%]{height:100vh;z-index:9999;top:0;bottom:0}.res-round[_ngcontent-%COMP%]{overflow:hidden;display:flex;justify-content:center;align-items:center;margin:0 auto}.res-round[_ngcontent-%COMP%]   img[_ngcontent-%COMP%]{width:100%;height:100%;max-width:100%;max-height:100%;object-fit:contain}.recent-col[_ngcontent-%COMP%]   .img-col[_ngcontent-%COMP%]{background:#ebebeb}.recent-col.ai-thumb-active[_ngcontent-%COMP%]   .img-col[_ngcontent-%COMP%]{background:#fff}.recent-col.ai-thumb-active[_ngcontent-%COMP%]   .img-col[_ngcontent-%COMP%]:before{left:3px!important;width:calc(100% - 6px)!important}.inable[_ngcontent-%COMP%]{display:block}.disable[_ngcontent-%COMP%]{display:none}.btn[_ngcontent-%COMP%]:disabled{background:#d5d6dd;border:1px solid #D5D6DD}.btn[_ngcontent-%COMP%]:disabled   .coin-count[_ngcontent-%COMP%]{background:#0000001a}.btn[_ngcontent-%COMP%]:disabled   .coin-count[_ngcontent-%COMP%]   b[_ngcontent-%COMP%]{color:#fff!important}.btn[_ngcontent-%COMP%]:disabled   .inable[_ngcontent-%COMP%]{display:none}.btn[_ngcontent-%COMP%]:disabled   .disable[_ngcontent-%COMP%]{display:block}.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}.coin-count[_ngcontent-%COMP%]   b[_ngcontent-%COMP%]{color:#fff!important}
1.duophotoshoot[_ngcontent-%COMP%]   .upload-column[_ngcontent-%COMP%]{background:#efeef2;height:187px;max-height:187px}.duophotoshoot[_ngcontent-%COMP%]   .upload-column[_ngcontent-%COMP%]   img[_ngcontent-%COMP%]{height:100%;width:100%;object-fit:contain}.duophotoshoot[_ngcontent-%COMP%]   .replace-overlay[_ngcontent-%COMP%]{background:#0006;left:0;top:0;z-index:1}.justify-content-center.justify-content-start[_ngcontent-%COMP%]{justify-content:start!important}.remove-btn[_ngcontent-%COMP%]{min-height:80px}.remove-btn[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]{display:none!important}.new-scroll-behave[_ngcontent-%COMP%]{-ms-overflow-style:none;scrollbar-width:none}.new-scroll-behave[_ngcontent-%COMP%]::-webkit-scrollbar{display:none}.new-scroll-behave[_ngcontent-%COMP%]{overflow-x:auto}.cover-space[_ngcontent-%COMP%]   .intermediate-image-area.image-preview[_ngcontent-%COMP%]{height:calc(100vh - 255px)!important}.btn-resolution[_ngcontent-%COMP%]{border-radius:12px;border:1px solid #E2E3E9;background:linear-gradient(0deg,#626adf0d,#626adf0d) 100%,#fff;height:44px;outline:none}.btn-resolution[_ngcontent-%COMP%]:active{border:1px solid #E2E3E9}.resolution-text[_ngcontent-%COMP%]{border-radius:8px}.bottom-container[_ngcontent-%COMP%]{border-radius:20px 20px 0 0}.bottom-container[_ngcontent-%COMP%]   .modal-box[_ngcontent-%COMP%]{background:#626adf0d;position:relative}.bottom-container[_ngcontent-%COMP%]   .modal-box[_ngcontent-%COMP%]   .icon-box[_ngcontent-%COMP%]{border-radius:6px;background:#626adf1a}.bottom-container[_ngcontent-%COMP%]   .modal-box[_ngcontent-%COMP%]   .coin-box[_ngcontent-%COMP%]{border:1px solid #C9CAD4;padding:0 6px 0 4px;min-height:24px;min-width:42px}.bottom-container[_ngcontent-%COMP%]   .resolution-modal[_ngcontent-%COMP%]   .ratio-box[_ngcontent-%COMP%]{border-radius:6px;background:#626adf1a;min-height:25px}.bottom-container[_ngcontent-%COMP%]   .modal-box[_ngcontent-%COMP%]:last-child{margin-bottom:0!important}.m-h-advertisement[_ngcontent-%COMP%]{min-height:124px}.m-h-advertisement[_ngcontent-%COMP%]   .ai-thumb-list[_ngcontent-%COMP%]   .ai-thumb-col[_ngcontent-%COMP%]:last-child{margin-right:0!important}.isrecent-add[_ngcontent-%COMP%]{justify-content:start!important}.custom-AI-modal[_ngcontent-%COMP%]{border:1px solid #E2E3E9;background:#626adf0d;height:48px}.custom-AI-modal[_ngcontent-%COMP%]   .thumb-box[_ngcontent-%COMP%]{height:40px;width:40px;border-radius:8px;min-width:40px}.custom-AI-modal[_ngcontent-%COMP%]   .thumb-box[_ngcontent-%COMP%]   .none-item[_ngcontent-%COMP%]{width:34px;height:34px;border-radius:8px;border:1px solid #E2E3E9;background:#fff}.custom-AI-modal[_ngcontent-%COMP%]   .thumb-box[_ngcontent-%COMP%]   .none-item[_ngcontent-%COMP%]   .blank-icon[_ngcontent-%COMP%]{border-radius:4px;background:#f25555;width:24px;height:2px;transform:rotate(-45deg)}.custom-AI-modal[_ngcontent-%COMP%]   .inline-content[_ngcontent-%COMP%]{display:-webkit-box!important;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;text-overflow:ellipsis;word-break:break-all}.custom-AI-modal[_ngcontent-%COMP%]   .add-border[_ngcontent-%COMP%]{border:1px solid #E2E3E9}.custom-AI-modal[_ngcontent-%COMP%]   .remove-border[_ngcontent-%COMP%]{border:0px solid #E2E3E9}.custom-AI-modal[_ngcontent-%COMP%]   .btn-remove[_ngcontent-%COMP%]{border-radius:50px;background:#e2e3e9;border:0;padding:8px 10px}.custom-AI-modal[_ngcontent-%COMP%]   .btn-remove[_ngcontent-%COMP%]:disabled{opacity:.5}.custom-AI-modal[_ngcontent-%COMP%]:hover{background:var(--colors-newgrey-transparent-primary-10, rgba(98, 106, 223, .1))}.template-video-preview[_ngcontent-%COMP%]{top:0;right:0;bottom:0;left:0;z-index:100002;background:#000}.template-video-preview__close[_ngcontent-%COMP%]{top:16px;left:16px;width:40px;height:40px;border:0;border-radius:40px;background:#fff3;z-index:2}.template-video-preview__player[_ngcontent-%COMP%]   video[_ngcontent-%COMP%]{display:block;max-height:100vh;object-fit:contain;background:#000}.template-video-preview[_ngcontent-%COMP%]   .btn-video-action[_ngcontent-%COMP%]{bottom:8px;left:8px;height:40px;width:40px;border-radius:40px;background:#60657699;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);border:0}
1.template-video-preview[_ngcontent-%COMP%]   .vid-time[_ngcontent-%COMP%]{border-radius:8px;background:#5f6578b3;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);padding:8px 10px;bottom:8px;left:56px;min-height:40px}.d-none-imp[_ngcontent-%COMP%]{display:none!important}']}),a})();var xt=m(40605),Pt=m(22154),Se=m(23486);const Us=["cpText"],Ds=["carousel"],tt=s=>({"d-none":s}),It=s=>({"magic-disable":s}),Ns=(s,a)=>({"info-blue":s,"info-red":a}),Xs=(s,a,n)=>({"info-up":s,"info-blue":a,"info-red":n}),Ls=s=>({"active-modal":s});function Ys(s,a){1&s&&e.nrm(0,"ei",42)}function $s(s,a){1&s&&e.nrm(0,"ei",43)}function zs(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",38)(1,"button",39),e.bIt("click",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.getMagicPrompt())}),e.DNE(2,Ys,1,0,"ei",40)(3,$s,1,0,"ei",41),e.EFF(4," Magic Prompt "),e.k0s()()}if(2&s){const n=e.XpG(2);e.R7$(),e.Y8G("ngClass",e.eq3(3,It,n.aiPhotoService.textPrompt.length<10||n.aiPhotoService.textPrompt.length>100)),e.R7$(),e.Y8G("ngIf",n.aiPhotoService.textPrompt.length>=10&&n.aiPhotoService.textPrompt.length<=100),e.R7$(),e.Y8G("ngIf",n.aiPhotoService.textPrompt.length<10||n.aiPhotoService.textPrompt.length>100)}}function Hs(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",44)(1,"buttons-scroll-menu",17),e.bIt("selectLayout",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.selectPrompt(i))}),e.k0s()()}if(2&s){const n=e.XpG(2);e.R7$(),e.Y8G("items",n.prompts)("type","prompt-mobile")}}function Ws(s,a){1&s&&(e.j41(0,"div",45)(1,"span",46),e.EFF(2,"Loading..."),e.k0s()())}function qs(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"div",27)(2,"div",28),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return i.step=2,e.Njj(i.focusIn())}),e.j41(3,"div",29)(4,"span",30),e.EFF(5,"Imagine anything, type it"),e.k0s(),e.j41(6,"span",31),e.EFF(7),e.k0s(),e.DNE(8,zs,5,5,"div",32),e.k0s()(),e.DNE(9,Hs,2,2,"div",33),e.j41(10,"div",34)(11,"div",35)(12,"model-selection",36),e.bIt("modelChange",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.onModelChange(i))})("modelButtonChange",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.onModelButtonChange(i))}),e.k0s(),e.j41(13,"div",37)(14,"button",19),e.bIt("keyup.enter",function(){e.eBV(n);const i=e.XpG();return i.focusOut(),e.Njj(i.generate())})("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.generate())}),e.DNE(15,Ws,3,0,"div",20),e.j41(16,"span",21),e.EFF(17,"Generate"),e.k0s(),e.j41(18,"span",22),e.nrm(19,"img",23)(20,"img",24),e.j41(21,"b",25),e.EFF(22),e.k0s()()()()()()(),e.bVm()}if(2&s){const n=e.XpG();e.R7$(),e.Y8G("ngClass",e.eq3(13,tt,1!=n.step)),e.R7$(3),e.Y8G("ngClass",e.eq3(15,tt,n.aiPhotoService.textPrompt&&""!=n.aiPhotoService.textPrompt)),e.R7$(3),e.JRh(n.aiPhotoService.textPrompt),e.R7$(),e.Y8G("ngIf",n.toolName==n.tooName.TextToImage),e.R7$(),e.Y8G("ngIf","text2image"!=n.featureType),e.R7$(3),e.AVh("d-none","sketch2image"==n.toolName),e.Y8G("type","model-dropdown-image")("selectedModel",n.selectedModel)("featureType",n.featureType),e.R7$(2),e.Y8G("disabled",n.disabled),e.R7$(),e.Y8G("ngIf",n.aiPhotoService.inProgress),e.R7$(7),e.JRh(n.credit)}}function Ks(s,a){1&s&&e.nrm(0,"ei",54)}function Zs(s,a){1&s&&e.nrm(0,"ei",43)}function Js(s,a){if(1&s){const n=e.RV6();e.j41(0,"span",51)(1,"span",52),e.EFF(2),e.k0s(),e.j41(3,"button",39),e.bIt("click",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.getMagicPrompt())}),e.DNE(4,Ks,1,0,"ei",53)(5,Zs,1,0,"ei",41),e.EFF(6," Magic Prompt "),e.k0s()()}if(2&s){const n=e.XpG(2);e.R7$(2),e.Lme(" ",n.aiPhotoService.textPrompt.length,"/",n.maxLenght,""),e.R7$(),e.Y8G("ngClass",e.eq3(5,It,n.aiPhotoService.textPrompt.length<10||n.aiPhotoService.textPrompt.length>100)),e.R7$(),e.Y8G("ngIf",n.aiPhotoService.textPrompt.length>=10&&n.aiPhotoService.textPrompt.length<=100),e.R7$(),e.Y8G("ngIf",n.aiPhotoService.textPrompt.length<10||n.aiPhotoService.textPrompt.length>100)}}function Qs(s,a){1&s&&(e.j41(0,"div",55),e.nrm(1,"img",56),e.k0s())}function er(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",47)(1,"textarea",48,0),e.mxI("ngModelChange",function(i){e.eBV(n);const o=e.XpG();return e.DH7(o.aiPhotoService.textPrompt,i)||(o.aiPhotoService.textPrompt=i),e.Njj(i)}),e.bIt("keyup",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.changePrompt())})("paste",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.onPaste(i))})("keydown.enter",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.onEnter(i))}),e.k0s(),e.DNE(3,Js,7,7,"span",49)(4,Qs,2,0,"div",50),e.k0s()}if(2&s){const n=e.XpG();e.Y8G("ngClass",e.l_i(7,Ns,n.isFocused,n.aiPhotoService.textPrompt.length>n.maxLenght-1)),e.R7$(),e.AVh("blue-active",n.isFocused),e.Y8G("maxlength",n.maxLenght),e.R50("ngModel",n.aiPhotoService.textPrompt),e.R7$(2),e.Y8G("ngIf",n.aiPhotoService.textPrompt.length),e.R7$(),e.Y8G("ngIf",n.ismagicPrompt)}}function tr(s,a){if(1&s&&(e.j41(0,"span",59),e.EFF(1),e.k0s()),2&s){const n=e.XpG(2);e.R7$(),e.Lme("",n.aiPhotoService.textPrompt.length,"/",n.maxLenght," ")}}function ir(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",13)(1,"div",57)(2,"textarea",48,0),e.mxI("ngModelChange",function(i){e.eBV(n);const o=e.XpG();return e.DH7(o.aiPhotoService.textPrompt,i)||(o.aiPhotoService.textPrompt=i),e.Njj(i)}),e.bIt("keyup",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.changePrompt())})("paste",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.onPaste(i))})("keydown.enter",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.onEnter(i))}),e.k0s(),e.DNE(4,tr,2,2,"span",58),e.k0s()()}if(2&s){const n=e.XpG();e.R7$(),e.Y8G("ngClass",e.sMw(6,Xs,n.aiPhotoService.textPrompt.length,n.isFocused,n.aiPhotoService.textPrompt.length>n.maxLenght-1)),e.R7$(),e.AVh("blue-active",n.isFocused),e.Y8G("maxlength",n.maxLenght),e.R50("ngModel",n.aiPhotoService.textPrompt),e.R7$(2),e.Y8G("ngIf",n.aiPhotoService.textPrompt.length)}}function nr(s,a){1&s&&(e.j41(0,"div",45)(1,"span",46),e.EFF(2,"Loa
1ding..."),e.k0s()())}function or(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",65),e.bIt("click",function(){const i=e.eBV(n).$implicit,o=e.XpG(2);return e.Njj(o.selectModel(i))}),e.j41(1,"div",66)(2,"div")(3,"div",67),e.nrm(4,"img",68),e.k0s(),e.j41(5,"span",69),e.EFF(6),e.k0s()(),e.j41(7,"div",70)(8,"span",71),e.EFF(9),e.k0s()()(),e.j41(10,"div",72),e.nrm(11,"img",73),e.j41(12,"span",74),e.EFF(13),e.k0s()()()}if(2&s){const n=a.$implicit,t=e.XpG(2);e.Y8G("ngClass",e.eq3(8,Ls,n.id==(null==t.selectedModel?null:t.selectedModel.id))),e.R7$(2),e.ZvI("d-flex align-items-center justify-content-start w-100 ",n.class," mb-1"),e.R7$(2),e.FS9("src",n.icon,e.B4B),e.R7$(2),e.JRh(n.displayName),e.R7$(3),e.JRh(n.desc),e.R7$(4),e.JRh(t.credit)}}function sr(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"div",60),e.bIt("close",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.step=1)}),e.j41(2,"div",61)(3,"h3",62),e.EFF(4," Choose Model "),e.j41(5,"pi",9),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.step=1)}),e.k0s()(),e.j41(6,"span",63),e.EFF(7,"Select an AI image generation model that suit your results."),e.k0s()(),e.DNE(8,or,14,10,"div",64),e.k0s(),e.bVm()}if(2&s){const n=e.XpG();e.R7$(8),e.Y8G("ngForOf",n.models)}}function rr(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",79),e.bIt("click",function(){const i=e.eBV(n).$implicit,o=e.XpG(2);return e.Njj(o.selectSize(i))}),e.j41(1,"div",80),e.nrm(2,"pi",81),e.j41(3,"span",82),e.EFF(4),e.k0s(),e.j41(5,"span",83),e.EFF(6),e.k0s()(),e.j41(7,"div",80)(8,"span",84),e.EFF(9),e.k0s()()()}if(2&s){const n=a.$implicit;e.R7$(2),e.FS9("name",n.icon),e.R7$(2),e.JRh(n.name),e.R7$(2),e.JRh(n.ratio),e.R7$(3),e.SpI("",n.size," px")}}function ar(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"div",75),e.bIt("close",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.step=1)}),e.j41(2,"div",76)(3,"h3",77),e.EFF(4," Resolution"),e.j41(5,"pi",9),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.step=1)}),e.k0s()()(),e.DNE(6,rr,10,4,"div",78),e.k0s(),e.bVm()}if(2&s){const n=e.XpG();e.R7$(6),e.Y8G("ngForOf",n.resolutions)}}function lr(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"div",85)(2,"choose-style",86),e.bIt("close",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.step=1)})("selectStyleEvent",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.selectStyle(i))}),e.k0s()(),e.bVm()}if(2&s){const n=e.XpG();e.R7$(2),e.Y8G("products",n.storeProducts)("editorType",n.toolName)("selectedStyle",n.selectedStyle)}}function cr(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"add-credit",87),e.bIt("close",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.step=1)})("addCredit",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.addCredit())}),e.k0s(),e.bVm()}if(2&s){const n=e.XpG();e.R7$(),e.Y8G("consumeCoins",n.credit)}}function dr(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"div",88),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return i.step=1,e.Njj(i.focusOut())}),e.k0s(),e.bVm()}}function hr(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"inspirations-edit-mobile",89),e.bIt("changeStep",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.changeStep(i))}),e.k0s(),e.bVm()}if(2&s){const n=e.XpG();e.R7$(),e.Y8G("aiPhotoService",n.aiPhotoService)("isMobile",!0)("activeImgObj",n.activeImage)}}let pr=(()=>{var s;class a{constructor(t,i,o,r,l,c,d,h,p,u,g,_){this.mediaContentService=t,this.aiPhotoService=i,this.dialogService=o,this.authService=r,this.createPopupService=l,this.aiUploadImageService=c,this.gtmService=d,this.toast=h,this.configService=p,this.aiGenService=u,this.paymentService=g,this.document=_,this.step=1,this.isLogin=!1,this.isLoaded=!0,this.selectedStyle={displayName:"None"},this.showAds=!1,this.enableAds=0,this.disabled=!1,this.storeProducts=[],this.prompts=[],this.customPrompt="",this.isFocused=!1,this.previewUrl="",this.index=0,this.isFirst=!1,this.isLast=!1,this.resolutions=[],this.models=[],this.isProUser=!1,this.tooName=f.Fs,this.editInspiration=!1,this.activeId=0,this.checkimg=!0,this.chooseFileEvent=new e.bkB,this.uploadFileEvent=new e.bkB,this.maxLenght=2e3,this.ismagicPrompt=!1,this.credit=1,this.user=this.authService.currentUser(),this.loggedInObserver=this.authService.loggedIn.subscribe(v=>{this.user=this.authService.currentUser(),this.isProUser=this.aiPhotoService.isProUser(),this.checkAds()}),this.usrPropChangedObserver=this.authService.usrPropChanged.subscribe(v=>{this.user=this.authService.currentUser(),this.isProUser=this.aiPhotoService.isProUser(),this.checkAds()}),this.updateBehaviorUserAiConis=this.authService.updateBehaviorUserAiConis.subscribe(v=>{this.user=this.authService.currentUser(),this.isProUser=this.aiPhotoService.isProUser(),v&&this.checkAds()}),this.settingsUpdateObserver=this.configService.updateAds.subscribe(v=>{v&&(this.enableAds=this.configService.showMobileAds,this.checkAds())}),this.paymentServiceSubs=this.paymentService.configUpdated.subscribe(v=>{v&&!this.config&&this.getModels()})}chooseFile(){this.chooseFileEvent.emit(!1)}ngOnInit(){if(this.toolName=this.featureType,(this.toolName===f.Fs.ImageToImage||this.toolName===f.Fs.SketchToImage)&&(this.step=1,this.config&&this.toolName===f.Fs.SketchToImage)){const t=this.config;this.credit=t.creditInfo?.image2image_gpt?t.creditInfo?.image2image_gpt:2}this.getPrompts(),this.changePrompt(),(this.toolName==f.Fs.Avatar||this.toolName==f.Fs.Portrait)&&(this.maxLenght=450),this.toolName==f.Fs.TextToImage&&!this.aiPhotoService?.textPrompt.trim()&&(this.step=1,this.isFocused=!1,document.body.classList.remove("overflow-hidden"))}selectModel(t){this.selectedModel=t,this.step=1}selectSize(t){this.selectedSize=t,this.step=1}selectStyle(t){this.selectedStyle=t}generate(){if(this.user=this.authService.currentUser(),this.isProUser=this.aiPhotoService.isProUser(),this.aiPhotoService.isCancel)this.toast.showErrorSingle(y.b.message.uploadNewImage);else if(!this.aiPhotoService.inProgress){if(!this.aiPhotoService.textPrompt||!this.aiPhotoService.textPrompt.trim())return void(this.step=2);if((this.toolName===f.Fs.ImageToImage||this.toolName===f.Fs.SketchToImage)&&!this.aiPhotoService.imgUrl)return void this.toast.showErrorSingleNew("Upload input image to use tool");if(this.step=1,this.user&&this.user.remainingCoins>=this.credit){const t=this.prepareInputData();this.aiPhotoService.startGenerationProgress({featureType:this.featureType||this.toolName});const i=new Date;this.clearTimeInterval(),this.aiPhotoService.generateImage(t,o=>{o&&o.assetId?this.aiPhotoService.checkStatusResponsive(o,0,l=>{(this.aiPhotoService.processingProgress.isActive||this.aiPhotoService.inProgress||this.aiPhotoService.inVideoProgress)&&this.outputResult(l,i)},l=>{this.displayErrorMsg(l,i)}):this.displayErrorMsg(o,i)},o=>{this.displayErrorMsg(o,i)})}else this.aiPhotoService.loginAndAICredit(t=>{this.user=this.authService.currentUser(),this.isProUser=this.aiPhotoService.isProUser(),this.user&&(t?.isFreeUser?this.isLogin=!0:!this.user.remainingCoins||this.user.remainingCoins<this.credit?this.step=6:this.generate())})}}closeProgress(t){this.aiPhotoService.completeGenerationProgress()}displayErrorMsg(t=null,i){this.aiPhotoService.clearGenerationProgress(),this.createPopupService.openWarningDialog("Error",t?.description)}getPrompts(t=null){this.prompts=[],this.featureType==f.Fs.TextToImage?this.aiType=se.Jl.TextToImage:this.featureType==f.Fs.ImageToImage?this.aiType=se.Jl.ImageToImage:this.featureType==f.Fs.SketchToImage&&(this.aiType=se.Jl.SketchToImage),this.mediaContentService.getPrompts(this.aiType,i=>{i&&(this.prompts=i.prompts),t&&t()},i=>{})}selectPrompt(t){this.step=1,this.aiPhotoService.textPrompt=t.prompt,this.disabled=!1}changePrompt(){this.disabled=!this.aiPhotoService.textPrompt.trim()}onPaste(t){setTimeout(()=>{this.aiPhotoService.textPrompt=t.target.value,this.changePrompt()},0)}focusIn(){document.body.classList.add("overflow-hidden"),this.isFocused=!0,setTimeout(()=>{this.cpText&&this.cpText.nativeElement.focus()},100),this.intervalSub&&this.intervalSub.unsubscribe();const t=(i=0)=>{setTimeout(()=>{this.cpText&&(this.cpText.nativeElement.placeholder=""),i<2&&(i++,t(i))},500)};t()}focusOut(){document.body.classList.remove("overflow-hidden"),this.isFocused=!1,this.intervalSub&&this.intervalSub.unsubscribe(),2==this.step&&!this.aiPhotoService.textPrompt&&this.prompts?.length&&setTimeout(()=>{this.cpText&&(this.cpText.nativeElement.placeholder=this.prompts&&this.prompts.length?this.prompts[0].prompt:"")},500)}prepareInputData(){return this.toolName==f.Fs.TextToImage||this.toolName==f.Fs.ImageToImage?{featureType:this.toolName,isCustomPrompt:1,...this.aiPhotoService.imgUrl&&this.toolName==f.Fs.ImageToImage&&{imageUrl:this.aiPhotoService.imgUrl},...this.aiPhotoService?.textPrompt&&this.aiPhotoService.textPrompt.trim()&&{textPrompt:this.aiPhotoService.textPrompt},...this.aiPhotoService.getImageModelOptions(this.selectedModel)}:{imageUrl:this.aiPhotoService.imgUrl,featureType:this.toolName,subFeatureType:"gpt",...this.aiPhotoService.textPrompt&&this.aiPhotoService.textPrompt.trim()&&{textPrompt:this.aiPhotoService.textPrompt},...this.toolName==f.Fs.SketchToImage&&{featureType:f.Fs.ImageToImage,toolName:f.Fs.SketchToImage}}}ngOnDestroy(){this.aiPhotoService.textPrompt="",document.body.classList.remove("overflow-hidden"),this.loggedInObserver&&this.loggedInObserver.unsubscribe(),this.usrPropChangedObserver&&this.usrPropChangedObserver.unsubscribe(),this.clearTimeInterval(),this.aiPhotoService.clearGenerationProgress()}clearTimeInterval(){this.interValId&&clearInterval(this.interValId),this.interValId1&&clearInterval(this.interValId1)}onSlide(t){if(t){const i=Number(t.prev.split("-")[2]);this.activeImage=this.aiPhotoService.aiImages[i],this.aiPhotoService.generateImageFn(this.activeImage)}}textAnimation(t){let i;const o=this.cpText&&this.cpText?.nativeElement,r=()=>{var c=1;this.intervalSub=(0,xt.Y)(4500).subscribe(d=>{c===t.length&&(c=0,this.intervalSub&&this.intervalSub.unsubscribe(),r()),c<t.length&&(o.placeholder="",i&&clearTimeout(i),l(o,t[c].prompt)),c++})},l=(c,d)=>{let p=d.split("");c.placeholder="";let u=0;i=setTimeout(function g(){c.placeholder=c.placeholder+p[u],u++,u<p.length&&(i=setTimeout(g,70))},500)};r()}onEnter(t){this.cpText.nativeElement.blur()}checkAds(){this.showAds=!(!this.enableAds||this.user&&(this.user.subscribed||this.user.creditPurchased))}getModels(){this.config=this.paymentService.config,this.aiPhotoService.textPrompt=this.aiPhotoService?.queryParams?.tp||""}addCredit(){this.step=1,this.aiGenService.aiCreditPlanCheckout({toolName:this.toolName},()=>{this.isProUser=this.aiPhotoService.isProUser()})}
1retryCheckStatus(t){this.aiPhotoService.startGenerationProgress({featureType:this.featureType||this.toolName});const o=new Date;this.aiPhotoService.checkStatusResponsive(t,0,r=>{(this.aiPhotoService.processingProgress.isActive||this.aiPhotoService.inProgress||this.aiPhotoService.inVideoProgress)&&this.outputResult(r,o)},r=>{this.displayErrorMsg(r,o)})}outputResult(t,i=null){t&&t.urls&&t.urls.length>0?this.aiPhotoService.completeGenerationProgress(()=>{this.thumbUrl=t.thumbUrl||t.urls[0],this.index=0,this.previewUrl=t.urls[0],this.activeImage=this.aiPhotoService.aiImages[0],this.index=this.aiPhotoService.aiImages.length-1,this.user.remainingCoins=t.remainingCalls,this.aiPhotoService.generateImageFn(t),this.aiPhotoService.isDirty=!0,this.gtmService.pushTag({eventName:y.b.gtm.eventname.aiGenerateMob,itemName:this.toolName,itemValue:this.toolName+"_"+this.selectedStyle?.displayName}),this.carousel&&setTimeout(()=>{this.carousel.animation=!1,this.carousel.select(t.assetId),setTimeout(()=>{this.carousel.animation=!0},100)},50)}):this.aiPhotoService.clearGenerationProgress()}getMagicPrompt(){this.ismagicPrompt=!0,this.aiPhotoService.getMagicPrompts(this.aiPhotoService.textPrompt,f.Fs.TextToImage,t=>{t?(this.aiPhotoService.textPrompt=t?.textPrompt,setTimeout(()=>{this.ismagicPrompt=!1},200)):this.ismagicPrompt=!1},t=>{this.ismagicPrompt=!1})}changePromptTextToImage(t=""){this.aiPhotoService.textPrompt=t,this.disabled=!(this.aiPhotoService.textPrompt&&this.aiPhotoService.textPrompt.trim().length>1||this.aiPhotoService.selectedGuidance.thumbUrl)}onFocusOut(t){this.isFocused=t}changeWithAIClick(t){this.activeImage=this.aiPhotoService?.aiImages.find(i=>i.assetId===t),this.activeImage.imgUrl=this.activeImage.urls[0]?this.activeImage.urls[0]:this.aiPhotoService.imgUrl,this.aiPhotoService.compareImageUrl=this.activeImage.imgUrl,this.aiPhotoService.inspirationImgUrl=this.activeImage.imgUrl,this.editInspiration=!0}changeStep(t){this.editInspiration=!1}onModelChange(t){this.updateModelSelection(t)}onModelButtonChange(t){this.updateModelSelection(t)}updateModelSelection(t){if(!t)return;const i=Number(t?.credits);!Number.isNaN(i)&&i>0&&(this.credit=i),this.selectedModel=t}}return(s=a).\u0275fac=function(t){return new(t||s)(e.rXU(we.Z),e.rXU(Z.s),e.rXU(ae.g),e.rXU(q.u),e.rXU(ne.A),e.rXU(ee.M),e.rXU(ie.y),e.rXU(Q.f),e.rXU(Pt.w),e.rXU(J.K),e.rXU(de.W),e.rXU(b.qQ))},s.\u0275cmp=e.VBU({type:s,selectors:[["ai-generate-v2"]],viewQuery:function(t,i){if(1&t&&(e.GBs(Us,5),e.GBs(Ds,5)),2&t){let o;e.mGM(o=e.lsd())&&(i.cpText=o.first),e.mGM(o=e.lsd())&&(i.carousel=o.first)}},inputs:{featureType:"featureType",checkimg:"checkimg"},outputs:{chooseFileEvent:"chooseFileEvent",uploadFileEvent:"uploadFileEvent"},decls:36,vars:23,consts:[["cpText",""],[1,"position-relative",2,"height","max-content",3,"ngClass"],[1,"drawer-elements","ai-drawer-elements"],[1,"ps-3","pe-3","pt-3"],[3,"uploadFileEvent","changeWithAIClick","featureType","checkimg"],[4,"ngIf"],[1,"p-3","pt-9","pb-9","position-fixed","bg-white","w-100","mobile-sheet-anim",2,"bottom","0px","z-index","9999","border-radius","20px 20px 0px 0px"],[1,"wp-100","d-flex","align-items-center","justify-content-between"],[1,"text-lg","text-semi","grey-800"],["name","previewclose",3,"click"],[1,"card","drawer-card","mt-3","mb-0"],[1,"card-body"],[1,"btn-panel"],[1,"card-body","prompt-view"],["class","textarea-col position-relative",3,"ngClass",4,"ngIf"],["class","card-body prompt-view",4,"ngIf"],[1,"d-flex","mt-3","mobile-prompt"],[2,"max-width","-webkit-fill-available",3,"selectLayout","items","type"],[1,"d-flex","align-items-center","justify-content-center","w-100","mt-3"],["id","gtm-generate-mob",1,"btn","btn-primary-gradient","btn-primary-m","text-13","btn-h44","w-100","d-flex","align-items-center","justify-content-center",3,"keyup.enter","click","disabled"],["class","spinner-border spinner-border-lg me-2 hw-24","role","status",4,"ngIf"],[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,"text-11","text-semi",2,"padding-left","2px"],[1,"showpreview-overlay","align-items-center","justify-content-start","position-fixed","mobile-sheet-overlay",3,"click"],[1,"pt-2","pb-9","position-fixed","gray-100","w-100","modal-container","fixed-prompt",2,"bottom","4px",3,"ngClass"],[1,"d-flex","align-items-center","justify-content-start","mb-3","mt-0","ps-3","pe-3",3,"click"],[1,"d-flex","align-items-start","justify-content-start","text-mask","border-radius-12","text-13","text-regular","grey-800","w-100","overflow-hidden","position-relative"],[1,"grey-500",3,"ngClass"],[2,"max-height","68px","overflow","hidden"],["class","position-absolute","style","right: 4px; bottom: 4px;",4,"ngIf"],["class","d-flex mt-3 mobile-prompt ps-3",4,"ngIf"],[1,"d-flex","w-100","flex-column","generate-btn","generate-btn-fixed"],[1,"d-flex","w-100"],[1,"mt-3",3,"modelChange","modelButtonChange","type","selectedModel","featureType"],[1,"d-flex","align-items-center","justify-content-center","w-100","ps-3","pe-3","mt-3","when-model"],[1,"position-absolute",2,"right","4px","bottom","4px"],["type","button",1,"btn","magic-btn","text-10","border-radius-8","text-semi","d-inline-flex","align-items-center","grey-800","border-0",3,"click","ngClass"],["name","magicpromptnew","class","me-1",4,"ngIf"],["name","magicdisable","class","me-1",4,"ngIf"],["name","magicpromptnew",1,"me-1"],["name","magicdisable",1,"me-1"],[1,"d-flex","mt-3","mobile-prompt","ps-3"],["role","status",1,"spinner-border","spinner-border-lg","me-2","hw-24"],[1,"sr-only","d-none"],[1,"textarea-col","position-relative",3,"ngClass"],["
1id","cprompt","name","cprompt","rows","4","cols","50",1,"prompt-text",3,"ngModelChange","keyup","paste","keydown.enter","maxlength","ngModel"],["class","text-regular position-absolute d-flex align-items-center justify-content-between w-100","style","padding: 0 9px 0 0;",4,"ngIf"],["class","magicprompt-overlay position-absolute w-100 h-100 d-flex align-items-center justify-content-center border-radius-12",4,"ngIf"],[1,"text-regular","position-absolute","d-flex","align-items-center","justify-content-between","w-100",2,"padding","0 9px 0 0"],[1,"prompt-info","d-inline-flex","align-items-center","justify-content-start"],["name","magicprompt","class","me-1",4,"ngIf"],["name","magicprompt",1,"me-1"],[1,"magicprompt-overlay","position-absolute","w-100","h-100","d-flex","align-items-center","justify-content-center","border-radius-12"],["src","https://static.lightxeditor.com/assets/images/LoadingBar.png","height","32px","width","32px",1,"rotate-loader"],[1,"textarea-col",3,"ngClass"],["class","prompt-info prompt-info-span text-regular position-relative d-flex align-items-center h-24",4,"ngIf"],[1,"prompt-info","prompt-info-span","text-regular","position-relative","d-flex","align-items-center","h-24"],[1,"d-flex","justify-content-start","align-items-center","bottom-container","position-fixed","bg-white","p-3","pt-10","pb-9","flex-column","w-100",2,"bottom","0px","z-index","9999",3,"close"],[1,"top-header","d-flex","justify-content-start","align-items-center","w-100","flex-column"],[1,"text-lg","text-semi","grey-800","m-0","w-100","lh-125","w-100","d-flex","align-items-center","justify-content-between"],[1,"text-13","grey-500","w-100","mt-1","mb-3","lh-160"],["class","modal-box d-flex justify-content-between align-items-center w-100 border-radius-12 p-9 mb-2",3,"ngClass","click",4,"ngFor","ngForOf"],[1,"modal-box","d-flex","justify-content-between","align-items-center","w-100","border-radius-12","p-9","mb-2",3,"click","ngClass"],[1,"d-inline-flex","align-items-center","justify-content-start","flex-column"],[1,"icon-box","hw-24","d-inline-flex","align-items-center","justify-content-center","me-2"],["height","16px","width","16px",3,"src"],[1,"grey-800","text-13","text-semi","d-inline-flex"],[1,"w-100","pe-2"],[1,"grey-500","text-sm",2,"line-height","19px"],[1,"d-inline-flex","align-items-center","justify-content-center","coin-box","border-radius-12"],["src","https://static.lightxeditor.com/assets/images/coin-new.png","height","20px","width","20px"],[1,"grey-600","text-12","text-semi",2,"padding-left","2px"],[1,"d-flex","justify-content-start","align-items-center","bottom-container","position-fixed","bg-white","p-3","pt-2","pb-9","flex-column","w-100",2,"bottom","0px","z-index","9999","transition","all 3s ease-in-out",3,"close"],[1,"top-header","d-flex","justify-content-start","align-items-center","w-100","flex-column","mb-1","h-32"],[1,"text-lg","text-semi","grey-800","m-0","w-100","lh-125","w-100","d-flex","align-items-center","justify-content-between","h-32"],["class","modal-box resolution-modal d-flex justify-content-between align-items-center w-100 border-radius-12 pl-9 pr-9 mb-2 h-48",3,"click",4,"ngFor","ngForOf"],[1,"modal-box","resolution-modal","d-flex","justify-content-between","align-items-center","w-100","border-radius-12","pl-9","pr-9","mb-2","h-48",3,"click"],[1,"d-flex","justify-content-center","align-items-center"],[1,"f-24","grey-600","me-2",3,"name"],[1,"grey-800","text-13","text-semi"],[1,"grey-600","text-12","text-semi","ms-1","p-1","ratio-box","d-inline-flex","align-items-center","justify-content-center","lh-normal"],[1,"grey-600","text-semi","text-13"],[1,"d-flex","justify-content-start","align-items-center","bottom-container","position-fixed","bg-white","p-3","pt-10","pb-9","flex-column","w-100","background-prompt","background-style","background-prompt-mobile",2,"bottom","0px","z-index","1000","height","calc(100vh - 130px)"],[1,"w-100",3,"close","selectStyleEvent","products","editorType","selectedStyle"],[3,"close","addCredit","consumeCoins"],[1,"showpreview-overlay","align-items-center","justify-content-start","position-fixed","d-flex",3,"click"],[3,"changeStep","aiPhotoService","isMobile","activeImgObj"]],template:function(t,i){1&t&&(e.j41(0,"div",1)(1,"div",2)(2,"div",3)(3,"generated-image-preview",4),e.bIt("uploadFileEvent",function(r){return i.uploadFileEvent.emit(r)})("changeWithAIClick",function(r){return i.changeWithAIClick(r)}),e.k0s()(),e.DNE(4,qs,23,17,"ng-container",5),e.j41(5,"div",6)(6,"div",7)(7,"div",8),e.
1EFF(8," Enter Prompt "),e.k0s(),e.j41(9,"div")(10,"pi",9),e.bIt("click",function(){return i.step=1}),e.k0s()()(),e.j41(11,"div",10)(12,"div",11)(13,"div",12)(14,"div",13),e.DNE(15,er,5,10,"div",14),e.k0s(),e.DNE(16,ir,5,10,"div",15),e.k0s()()(),e.j41(17,"div",16)(18,"buttons-scroll-menu",17),e.bIt("selectLayout",function(r){return i.selectPrompt(r)}),e.k0s()(),e.j41(19,"div",18)(20,"button",19),e.bIt("keyup.enter",function(){return i.focusOut(),i.generate()})("click",function(){return i.generate()}),e.DNE(21,nr,3,0,"div",20),e.j41(22,"span",21),e.EFF(23,"Generate"),e.k0s(),e.j41(24,"span",22),e.nrm(25,"img",23)(26,"img",24),e.j41(27,"b",25),e.EFF(28),e.k0s()()()()(),e.j41(29,"div",26),e.bIt("click",function(){return i.step=1,i.focusOut()}),e.k0s(),e.DNE(30,sr,9,1,"ng-container",5)(31,ar,7,1,"ng-container",5)(32,lr,3,3,"ng-container",5)(33,cr,2,1,"ng-container",5)(34,dr,2,0,"ng-container",5),e.k0s()(),e.DNE(35,hr,2,3,"ng-container",5)),2&t&&(e.Y8G("ngClass",e.eq3(21,tt,i.isLogin)),e.R7$(3),e.Y8G("featureType",i.featureType)("checkimg",i.checkimg),e.R7$(),e.Y8G("ngIf",i.isLoaded),e.R7$(),e.AVh("mobile-sheet-anim--open",2==i.step),e.R7$(10),e.Y8G("ngIf",i.toolName==i.tooName.TextToImage),e.R7$(),e.Y8G("ngIf",i.toolName!=i.tooName.TextToImage),e.R7$(2),e.Y8G("items",i.prompts)("type","prompt-mobile"),e.R7$(2),e.Y8G("disabled",i.disabled),e.R7$(),e.Y8G("ngIf",i.aiPhotoService.inProgress),e.R7$(7),e.JRh(i.credit),e.R7$(),e.AVh("mobile-sheet-overlay--open",2==i.step),e.R7$(),e.Y8G("ngIf",3==i.step),e.R7$(),e.Y8G("ngIf",4==i.step),e.R7$(),e.Y8G("ngIf",5==i.step),e.R7$(),e.Y8G("ngIf",6==i.step),e.R7$(),e.Y8G("ngIf",1!=i.step&&2!=i.step&&6!=i.step),e.R7$(),e.Y8G("ngIf",i.editInspiration))},dependencies:[b.YU,b.Sq,b.bT,P.me,P.BC,P.tU,P.vS,H.b,_e.B,qe,pe,Se.KK,bt.x,Qe,Ze],styles:['.prompt-text[_ngcontent-%COMP%]{color:#272b34!important}.showpreview-overlay[_ngcontent-%COMP%]{display:none;background:#0003;-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);width:100%;height:100%;top:0;bottom:0;z-index:999}.mobile-sheet-overlay[_ngcontent-%COMP%]{display:block;opacity:0;pointer-events:none;transition:opacity .24s ease}.mobile-sheet-overlay.mobile-sheet-overlay--open[_ngcontent-%COMP%]{opacity:1;pointer-events:auto}.mobile-sheet-anim[_ngcontent-%COMP%]{transform:translate3d(0,100dvh,0);will-change:transform;-webkit-backface-visibility:hidden;backface-visibility:hidden;pointer-events:none;transition:transform .72s cubic-bezier(.22,.61,.36,1)}.mobile-sheet-anim.mobile-sheet-anim--open[_ngcontent-%COMP%]{transform:translateZ(0);pointer-events:auto;transition:transform .52s cubic-bezier(.2,.9,.2,1)}.mobile-congratulations[_ngcontent-%COMP%]{height:100vh;z-index:9999;top:0;bottom:0}.res-round[_ngcontent-%COMP%]{overflow:hidden;display:flex;justify-content:center;align-items:center;margin:0 auto}.res-round[_ngcontent-%COMP%]   img[_ngcontent-%COMP%]{width:100%;height:100%;max-width:100%;max-height:100%;object-fit:contain}.inable[_ngcontent-%COMP%]{display:block}.disable[_ngcontent-%COMP%]{display:none}.btn[_ngcontent-%COMP%]:disabled{background:#d5d6dd;border:1px solid #D5D6DD}.btn[_ngcontent-%COMP%]:disabled   .coin-count[_ngcontent-%COMP%]{background:#0000001a}.btn[_ngcontent-%COMP%]:disabled   .coin-count[_ngcontent-%COMP%]   b[_ngcontent-%COMP%]{color:#fff!important}.btn[_ngcontent-%COMP%]:disabled   .inable[_ngcontent-%COMP%]{display:none}.btn[_ngcontent-%COMP%]:disabled   .disable[_ngcontent-%COMP%]{display:block}.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}.coin-count[_ngcontent-%COMP%]   b[_ngcontent-%COMP%]{color:#fff!important}.bottom-container[_ngcontent-%COMP%]{border-radius:20px 20px 0 0}.bottom-container[_ngcontent-%COMP%]   .modal-box[_ngcontent-%COMP%]{background:#626adf0d;position:relative}.bottom-container[_ngcontent-%COMP%]   .modal-box[_ngcontent-%COMP%]   .icon-box[_ngcontent-%COMP%]{border-radius:6px;background:#626adf1a}.bottom-container[_ngcontent-%COMP%]   .modal-box[_ngcontent-%COMP%]   .coin-box[_ngcontent-%COMP%]{border:1px solid #C9CAD4;padding:0 6px 0 4px;min-height:24px;min-width:42px}.bottom-container[_ngcontent-%COMP%]   .resolution-modal[_ngcontent-%COMP%]{min-height:40px}.bottom-container[_ngcontent-%COMP%]   .resolution-modal[_ngcontent-%COMP%]   .ratio-box[_ngcontent-%COMP%]{border-radius:6px;background:#626adf1a;min-height:25px}.bottom-container[_ngcontent-%COMP%]   .active-modal[_ngcontent-%COMP%], .bottom-container[_ngcontent-%COMP%]   .active-resolution[_ngcontent-%COMP%]{position:relative}.bottom-container[_ngcontent-%COMP%]   .active-modal[_ngcontent-%COMP%]   .icon-box[_ngcontent-%COMP%], .bottom-container[_ngcontent-%COMP%]   .active-modal[_ngcontent-%COMP%]   .ratio-box[_ngcontent-%COMP%], .bottom-container[_ngcontent-%COMP%]   .active-resolution[_ngcontent-%COMP%]   .icon-box[_ngcontent-%COMP%], .bottom-container[_ngcontent-%COMP%]   .active-resolution[_ngcontent-%COMP%]   .ratio-box[_ngcontent-%COMP%]{background:linear-gradient(90deg,#fc5cff1a -4%,#2520f61a)}.bottom-container[_ngcontent-%COMP%]   .active-modal[_ngcontent-%COMP%]   .coin-box[_ngcontent-%COMP%], .bottom-container[_ngcontent-%COMP%]   .active-resolution[_ngcontent-%COMP%]   .coin-box[_ngcontent-%COMP%]{position:relative;border:0px}.bottom-container[_ngcontent-%COMP%]   .active-modal[_ngcontent-%COMP%]   .coin-box[_ngcontent-%COMP%]:after, .bottom-container[_ngcontent-%COMP%]   .active-resolution[_ngcontent-%COMP%]   .coin-box[_ngcontent-%COMP%]:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:12px;padding:.9px;border:0px;background:linear-gradient(90deg,#fc5cff -4%,#2520f6);-webkit-mask:linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%) content-box,linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%);-webkit-mask-composite:xor;mask-composite:exclude}.bottom-container[_ngcontent-%COMP%]   .active-modal[_ngcontent-%COMP%]:after, .bottom-container[_ngcontent-%COMP%]   .active-resolution[_ngcontent-%COMP%]:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:12px;padding:1.3px;border:none;background:linear-gradient(90deg,#fc5cff -4%,#2520f6);-webkit-mask:linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%) content-box,linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%);-webkit-mask-composite:xor;mask-composite:exclude}
1.bottom-container[_ngcontent-%COMP%]   .modal-box[_ngcontent-%COMP%]:last-child{margin-bottom:0!important}.new-scroll-behave[_ngcontent-%COMP%]{-ms-overflow-style:none;scrollbar-width:none}.new-scroll-behave[_ngcontent-%COMP%]::-webkit-scrollbar{display:none}.styles-options[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]{border:0px;border-radius:320px;background:linear-gradient(90deg,#fc5cff0d -4%,#2520f60d);position:relative;height:32px;display:flex;line-height:17px;justify-content:center;white-space:nowrap}.styles-options[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]:disabled{background:#d5d6dd;border:1px solid #D5D6DD;color:#b0b3bf!important}.styles-options[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]:disabled:before{display:none;padding:0}.styles-options[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]:disabled   .text-primary[_ngcontent-%COMP%]{color:#b0b3bf!important}.styles-options[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]:before{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:320px;padding:1px;border:none;background:linear-gradient(90deg,#fc5cff -4%,#2520f6);-webkit-mask:linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%) content-box,linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%);-webkit-mask-composite:xor;mask-composite:exclude}.text-mask[_ngcontent-%COMP%]{border:1px solid #C9CAD4;background:linear-gradient(90deg,#fc5cff05 -4%,#2520f605);height:110px;padding:8px 12px}@media screen and (max-height: 740px){.text-56[_ngcontent-%COMP%]{font-size:48px!important;line-height:58px!important}}@media screen and (max-height: 640px){.text-56[_ngcontent-%COMP%]{font-size:40px!important;line-height:50px!important}}@media screen and (max-height: 540px){.text-56[_ngcontent-%COMP%]{font-size:30px!important;line-height:40px!important}}.magic-btn[_ngcontent-%COMP%]{background:#9f42fb1a;padding:0 6.5px 0 4.5px;height:24px;line-height:normal;z-index:2}.magic-btn[_ngcontent-%COMP%]:hover, .magic-btn[_ngcontent-%COMP%]:focus{background:#9f42fb1a;outline:none}.magic-btn.magic-disable[_ngcontent-%COMP%]{background:#9f42fb0a;pointer-events:none;color:#d9d9d9!important}.magic-btn.magic-disable[_ngcontent-%COMP%]:hover, .magic-btn.magic-disable[_ngcontent-%COMP%]:focus{background:#9f42fb0a;outline:none}.magicprompt-overlay[_ngcontent-%COMP%]{background:#ffffffb3;left:0;top:0;z-index:99}.magicprompt-overlay[_ngcontent-%COMP%]   .rotate-loader[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_rotation 1.5s infinite linear}@keyframes _ngcontent-%COMP%_rotation{0%{transform:rotate(0)}to{transform:rotate(359deg)}}.prompt-view[_ngcontent-%COMP%]   .textarea-col[_ngcontent-%COMP%]{width:100%;height:188px;border-radius:12px;background:#eeedf3;padding:4px;border:0px!important}.prompt-view[_ngcontent-%COMP%]   .textarea-col[_ngcontent-%COMP%]:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:12px;padding:.92px;border:none;background:linear-gradient(90deg,#c9cad4 -4% 100%);-webkit-mask:linear-gradient(90deg,#C9CAD4 -4%,#C9CAD4 100%) content-box,linear-gradient(90deg,#C9CAD4 -4%,#C9CAD4 100%);-webkit-mask-composite:xor;mask-composite:exclude;z-index:1}.prompt-view[_ngcontent-%COMP%]   .textarea-col[_ngcontent-%COMP%]:hover{border:1px solid #B0B3BF}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]{resize:none;outline:none;width:100%;height:148px;padding:8px;font-size:13px;color:#b0b3bf;border:0px;background:transparent;border-radius:12px;line-height:18px;overflow:auto;position:relative;z-index:2;line-height:125%}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]::-webkit-scrollbar{width:4px;height:4px;border-radius:12px}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]::-webkit-scrollbar-track{background:#e3e3e3;border-radius:12px;margin-top:8px}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background:#9a9a9a;border-radius:12px}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]::-webkit-scrollbar-thumb:hover{background:#555}.prompt-view[_ngcontent-%COMP%]   .prompt-info[_ngcontent-%COMP%]{font-size:11px;color:#b0b3bf;margin-top:0;padding-left:8px;line-height:140%}.info-up[_ngcontent-%COMP%]{border:1px solid #B0B3BF!important;background:#eeedf3!important}.info-blue[_ngcontent-%COMP%]{background:linear-gradient(90deg,#fc5cff0d -4%,#2520f60d)!important}.info-blue[_ngcontent-%COMP%]:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:12px;padding:.92px;border:none;background:linear-gradient(90deg,#fc5cff -4%,#2520f6)!important;-webkit-mask:linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%) content-box,linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%)!important;-webkit-mask-composite:xor!important;mask-composite:exclude!important;z-index:1}.info-blue[_ngcontent-%COMP%]   span[_ngcontent-%COMP%]{color:#626adf!important}.info-red[_ngcontent-%COMP%]{background:linear-gradient(90deg,#fc5cff0d -4%,#2520f60d)!important}.info-red[_ngcontent-%COMP%]:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:12px;padding:.92px;border:none;background:linear-gradient(90deg,#f25555 -4% 100%)!important;-webkit-mask:linear-gradient(90deg,#F25555 -4%,#F25555 100%) content-box,linear-gradient(90deg,#F25555 -4%,#F25555 100%)!important;-webkit-mask-composite:xor!important;mask-composite:exclude!important;z-index:1}.info-red[_ngcontent-%COMP%]   span[_ngcontent-%COMP%]{color:#f25555!important}']}),a})();var he=m(39762),Ie=m(94449),yt=(m(17314),m(49868),m(31611),m(16447),m(86535),m(54777),m(89334)),I=m(93552);m(14890);let it=(()=>{var s;class a{constructor(){}setActionController(t){this.adjustment=t}init(){}changeBrightness(t,i){this.adjustment.updateBrightness(t),this.brightness=Math.round(100*this.adjustment.imageAdjust.brightness)}changeIntensity(t,i){this.adjustment.updateIntensity(t),this.intensity=Math.round(100*this.adjustment.imageAdjust.intensity)}changeContrast(t,i){this.adjustment.updateContrast(t),this.contrast=Math.round(100*this.adjustment.imageAdjust.contrast)}changeHue(t,i){this.adjustment.updateHue(t),this.hue=Math.round(100*this.adjustment.imageAdjust.hue)}changeSaturation(t,i){this.adjustment.updateSaturation(t),this.saturation=Math.round(100*this.adjustment.imageAdjust.saturation)}changeGamma(t,i){this.adjustment.updateGamma(t),this.gamma=Math.round(100*this.adjustment.imageAdjust.gamma)}updateAdjustmentValues(){let t=this.adjustment.imageAdjust;this.brightness=Math.round(100*t.brightness),this.intensity=Math.round(100*t.intensity),this.contrast=Math.round(100*t.contrast),this.hue=Math.round(100*t.hue),this.saturation=Math.round(100*t.saturation),this.gamma=Math.round(100*t.gamma)}resetAll(t){this.brightness=0,this.intensity=100,this.contrast=0,this.hue=0,this.saturation=0,this.gamma=0,this.resetBrightness(this.brightness),this.resetIntensity(this.intensity),this.resetContrast(this.contrast),this.resetHue(this.hue),this.resetSaturation(this.saturation),this.resetGamma(this.gamma),t&&t()}resetBrightness(t){this.changeBrightness(t,!1)}resetIntensity(t){this.changeIntensity(t,!1)}resetContrast(t){this.changeContrast(t,!1)}resetHue(t){this.changeHue(t,!1)}resetSaturation(t){this.changeSaturation(t,!1)}resetGamma(t){this.changeGamma(t,!1)}}return(s=a).\u0275fac=function(t){return new(t||s)},s.\u0275prov=e.jDH({token:s,factory:s.\u0275fac}),a})();var $=m(25880);class wt{constructor(){this.initialMinLevel=0,this.initialMaxLevel=1,this.updatedMinLevel=0,this.updatedMaxLevel=1,this.maxDisplacement=.3,this.RLUM=.3,this.GLUM=.59,this.BLUM=.11,this.init()}init(){this.imageAdjust={contrast:0,brightness:0,red:0,green:0,blue:0,hue:0,saturation:0,exposure:0,tint:0,temperature:0,gamma:0,blur:.2,shadows:0,highlights:0,hueIntensity:0,intensity:1},this.adjustedValues={brightness:this.getBrightness(),intensity:this.getIntensity(),exposure:this.getExposure(),contrast:this.getContrast(),blur:this.getBlur(),tint:this.getTint(),temperature:this.getTemperature(),shadows:this.getShadows(),highlights:this.getHighlights(),saturation:this.getSaturation(),hue:this.getHue(),min:[0,0,0],mid:[1,1,1],max:[1,1,1],minOutput:[
10,0,0],maxOutput:[1,1,1],rgbCompositeCurve:[],redCurve:[],blueCurve:[],greenCurve:[],colorMatrix:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]};let a=[new $.b(0,0),new $.b(.5,.5),new $.b(1,1)];this.mRgbCompositeControlPoints=a,this.mRedControlPoints=a,this.mGreenControlPoints=a,this.mBlueControlPoints=a,this.setRgbCompositeControlPoints(this.mRgbCompositeControlPoints),this.setRedControlPoints(this.mRedControlPoints),this.setGreenControlPoints(this.mGreenControlPoints),this.setBlueControlPoints(this.mBlueControlPoints),this.mColorMat1D=new Array(16),this.mIdentityMatrix=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],this.mColorMat=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]]}updateBrightness(a){this.imageAdjust.brightness=a/100,this.adjustedValues.brightness=this.getBrightness()}updateIntensity(a){this.imageAdjust.intensity=a/100,this.adjustedValues.intensity=this.getIntensity()}updateContrast(a){this.imageAdjust.contrast=a/100,this.adjustedValues.contrast=this.getContrast()}updateExposure(a){this.imageAdjust.exposure=a/100,this.adjustedValues.exposure=this.getExposure()}updateBlur(a){this.imageAdjust.blur=a/100,this.adjustedValues.blur=this.getBlur()}updateTemperature(a){this.imageAdjust.temperature=a/100,this.adjustedValues.temperature=this.getTemperature()}updateTint(a){this.imageAdjust.tint=a/100,this.adjustedValues.tint=this.getTint()}updateShadows(a){this.imageAdjust.shadows=a/100,this.adjustedValues.shadows=this.getShadows(),this.updateGamma(100*this.imageAdjust.gamma)}updateHighlights(a){this.imageAdjust.highlights=a/100,this.adjustedValues.highlights=this.getHighlights(),this.updateGamma(100*this.imageAdjust.gamma)}updateHue(a){this.imageAdjust.hue=a/100,this.adjustedValues.hue=this.getHue()}getHueIntensity(){let a=this.imageAdjust.hueIntensity;return a>0?1+a/2:1+a}updateSaturation(a){this.imageAdjust.saturation=a/100,this.adjustedValues.saturation=this.getSaturation()}updateHueIntensity(a){this.imageAdjust.hueIntensity=a/100,this.calculateColorMat()}calculateColorMat(){this.resetColorMat(),this.huerotatemat(this.mColorMat,100*this.imageAdjust.hue),this.saturatemat(this.mColorMat,2*(100+100*this.imageAdjust.saturation)/200);const n=this.getHueIntensity();this.cscalemat(this.mColorMat,n,n,n),this.updateColorMatrix()}resetColorMat(){for(let a=0;a<4;a++)for(let n=0;n<4;n++)this.mColorMat[a][n]=this.mIdentityMatrix[a][n];this.updateColorMatrix()}updateColorMatrix(){let a,n;for(a=0;a<4;a++)for(n=0;n<4;n++)this.mColorMat1D[4*a+n]=this.mColorMat[n][a];this.adjustedValues.colorMatrix=this.mColorMat1D}updateGamma(a){this.imageAdjust.gamma=a/100,this.setMin(this.updatedMinLevel,this.getGamma(),this.updatedMaxLevel,this.initialMinLevel,this.initialMaxLevel)}updateRed(a){this.imageAdjust.red=a/100,this.initCurveValues(),this.updateRGBValues()}updateGreen(a){this.imageAdjust.green=a/100,this.initCurveValues(),this.updateRGBValues()}updateBlue(a){this.imageAdjust.blue=a/100,this.initCurveValues(),this.updateRGBValues()}getShadows(){let a=this.imageAdjust.shadows;return this.updatedMinLevel=a<0?this.maxDisplacement*Math.abs(a):0,a}getHighlights(){let a=this.imageAdjust.highlights;return a>0?(this.updatedMaxLevel=1-this.maxDisplacement*a,a=1):(this.updatedMaxLevel=1,a=1+a),a}getBrightness(){let a=this.imageAdjust.brightness;return a*=.5,a}getIntensity(){return this.imageAdjust.intensity}getExposure(){return this.imageAdjust.exposure}getBlur(){return this.imageAdjust.blur}getContrast(){let a=this.imageAdjust.contrast;return a=1+a,a}getSaturation(){let a=this.imageAdjust.saturation;return a=1+a,a}getHue(){return 2*(1-this.imageAdjust.hue)*Math.PI}getTemperature(){let a=this.imageAdjust.temperature;return a=a<0?5e3+1e3*a:5e3+2e3*a,a=a<5e3?4e-4*(a-5e3):6e-5*(a-5e3),a}getTint(){return 2*this.imageAdjust.tint}getGamma(){let a=this.imageAdjust.gamma;return a=.8-.3*a,a}setMin(a,n,t,i,o){this.setRedMin(a,n,t,i,o,!1),this.setGreenMin(a,n,t,i,o,!1),this.setBlueMin(a,n,t,i,o,!1)}setRedMin(a,n,t,i,o,r){this.adjustedValues.min[0]=a,this.adjustedValues.mid[0]=n,this.adjustedValues.max[0]=t,this.adjustedValues.minOutput[0]=i,this.adjustedValues.maxOutput[0]=o}setGreenMin(a,n,t,i,o,r){this.adjustedValues.min[1]=a,this.adjustedValues.mid[1]=n,this.adjustedValues.max[1]=t,this.adjustedValues.minOutput[1]=i,this.adjustedValues.maxOutput[1]=o}setBlueMin(a,n,t,i,o,r){this.adjustedValues.min[2]=a,this.adjustedValues.mid[2]=n,this.adjustedValues.max[2]=t,this.adjustedValues.minOutput[2]=i,this.adjustedValues.maxOutput[2]=o}getR(){return this.imageAdjust.red}getG(){return this.imageAdjust.green}getB(){return this.imageAdjust.blue}initCurveValues(){if(this.getR()>0){let a=.5-this.maxDisplacement*this.getR()*Math.cos(Math.PI/4),n=.5+this.maxDisplacement*this.getR()*Math.sin(Math.PI/4);this.mRedControlPoints=[new $.b(0,0),new $.b(1,1),new $.b(a,n)]}else{let a=.5+this.maxDisplacement*Math.abs(this.getR())*Math.cos(Math.PI/4),n=.5-this.maxDisplacement*Math.abs(this.getR())*Math.sin(Math.PI/4);this.mRedControlPoints=[new $.b(0,0),new $.b(1,1),new $.b(a,n)]}if(this.getG()>0){let a=.5-this.maxDisplacement*this.getG()*Math.cos(Math.PI/4),n=.5+this.maxDisplacement*this.getG()*Math.sin(Math.PI/4);this.mGreenControlPoints=[new $.b(0,0),new $.b(1,1),new $.b(a,n)]}else{let a=.5+this.maxDisplacement*Math.abs(this.getG())*Math.cos(Math.PI/4),n=.5-this.maxDisplacement*Math.abs(this.getG())*Math.sin(Math.PI/4);this.mGreenControlPoints=[new $.b(0,0),new $.b(1,1),new $.b(a,n)]}if(this.getB()>
10){let a=.5-this.maxDisplacement*this.getB()*Math.cos(Math.PI/4),n=.5+this.maxDisplacement*this.getB()*Math.sin(Math.PI/4);this.mBlueControlPoints=[new $.b(0,0),new $.b(1,1),new $.b(a,n)]}else{let a=.5+this.maxDisplacement*Math.abs(this.getB())*Math.cos(Math.PI/4),n=.5-this.maxDisplacement*Math.abs(this.getB())*Math.sin(Math.PI/4);this.mBlueControlPoints=[new $.b(0,0),new $.b(1,1),new $.b(a,n)]}}updateRGBValues(){this.adjustedValues.redCurve=this.createSplineCurve(this.mRedControlPoints),this.adjustedValues.greenCurve=this.createSplineCurve(this.mGreenControlPoints),this.adjustedValues.blueCurve=this.createSplineCurve(this.mBlueControlPoints)}setRgbCompositeControlPoints(a){this.mRgbCompositeControlPoints=a,this.adjustedValues.rgbCompositeCurve=this.createSplineCurve(this.mRgbCompositeControlPoints)}setRedControlPoints(a){this.mRedControlPoints=a,this.adjustedValues.redCurve=this.createSplineCurve(this.mRedControlPoints)}setGreenControlPoints(a){this.mGreenControlPoints=a,this.adjustedValues.greenCurve=this.createSplineCurve(this.mGreenControlPoints)}setBlueControlPoints(a){this.mBlueControlPoints=a,this.adjustedValues.blueCurve=this.createSplineCurve(this.mBlueControlPoints)}createSplineCurve(a){if(null==a||a.length<=0)return null;let n=[...a];n.sort(function(c,d){return c.x-d.x});let t=[];for(let c=0;c<a.length;c++){let d=n[c];t.push(new $.b(255*d.x,255*d.y))}let i=this.createSplineCurve2(t),o=i[0];if(o.x>0)for(let c=o.x;c>=0;c--)i[0]=new $.b(c,0);let r=i[i.length-1];if(r.x<255)for(let c=r.x+1;c<=255;c++)i.push(new $.b(c,255));let l=[];for(let c=0;c<i.length;c++){let d=i[c],h=new $.b(d.x,d.x),p=Math.sqrt(Math.pow(h.x-d.x,2)+Math.pow(h.y-d.y,2));h.y>d.y&&(p=-p),l.push(p)}return l}createSplineCurve2(a){let n=this.createSecondDerivative(a),t=n.length;if(t<1)return null;let i=new Array(t);for(let r=0;r<t;r++)i[r]=n[r];let o=[];for(let r=0;r<t-1;r++){let l=a[r],c=a[r+1];for(let d=l.x;d<c.x;d++){let h=(d-l.x)/(c.x-l.x),p=1-h,g=c.x-l.x,_=p*l.y+h*c.y+g*g/6*((p*p*p-p)*i[r]+(h*h*h-h)*i[r+1]);_>255?_=255:_<0&&(_=0),o.push(new $.b(d,Math.round(_)))}}return 255==o.length&&o.push(a[a.length-1]),o}createSecondDerivative(a){let n=a.length;if(n<=1)return null;let t=new Array(n).fill(0).map(()=>new Array(3).fill(0)),i=new Array(n);t[0][1]=1,t[0][0]=0,t[0][2]=0;for(let r=1;r<n-1;r++){let l=a[r-1],c=a[r],d=a[r+1];t[r][0]=(c.x-l.x)/6,t[r][1]=(d.x-l.x)/3,t[r][2]=(d.x-c.x)/6,i[r]=(d.y-c.y)/(d.x-c.x)-(c.y-l.y)/(c.x-l.x)}i[0]=0,i[n-1]=0,t[n-1][1]=1,t[n-1][0]=0,t[n-1][2]=0;for(let r=1;r<n;r++){let l=t[r][0]/t[r-1][1];t[r][1]-=l*t[r-1][2],t[r][0]=0,i[r]-=l*i[r-1]}for(let r=n-2;r>=0;r--){let l=t[r][2]/t[r+1][1];t[r][1]-=l*t[r+1][0],t[r][2]=0,i[r]-=l*i[r+1]}let o=[];for(let r=0;r<n;r++)o.push(i[r]/t[r][1]);return o}saturatemat(a,n){let i,o,r,l,c,d,h,p,u,g,_,v,t=new Array(4).fill(0).map(()=>new Array(4).fill(0));g=this.RLUM,_=this.GLUM,v=this.BLUM,i=(1-n)*g+n,o=(1-n)*g,r=(1-n)*g,l=(1-n)*_,c=(1-n)*_+n,d=(1-n)*_,h=(1-n)*v,p=(1-n)*v,u=(1-n)*v+n,t[0][0]=i,t[0][1]=o,t[0][2]=r,t[0][3]=0,t[1][0]=l,t[1][1]=c,t[1][2]=d,t[1][3]=0,t[2][0]=h,t[2][1]=p,t[2][2]=u,t[2][3]=0,t[3][0]=0,t[3][1]=0,t[3][2]=0,t[3][3]=1,this.matrixmult(t,a,a)}matrixmult(a,n,t){let i=0,o=0,r=new Array(4).fill(0).map(()=>new Array(4).fill(0));for(o=0;o<4;o++)for(i=0;i<4;i++)r[o][i]=n[o][0]*a[0][i]+n[o][1]*a[1][i]+n[o][2]*a[2][i]+n[o][3]*a[3][i];for(o=0;o<4;o++)for(i=0;i<4;i++)t[o][i]=r[o][i]}huerotatemat(a,n){let i,o,r,l,c,d,h,p,u,t=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];i=Math.sqrt(2),o=1/i,r=1/i,this.xrotatemat(t,o,r),i=Math.sqrt(3),l=-1/i,c=Math.sqrt(2)/i,this.yrotatemat(t,l,c),this.xformpnt(t,this.RLUM,this.GLUM,this.BLUM),p=this.lx/this.lz,u=this.ly/this.lz,this.zshearmat(t,p,u),d=Math.sin(n*Math.PI/180),h=Math.cos(n*Math.PI/180),this.zrotatemat(t,d,h),this.zshearmat(t,-p,-u),this.yrotatemat(t,-l,c),this.xrotatemat(t,-o,r),this.matrixmult(t,a,a)}xformpnt(a,n,t,i){this.lx=n*a[0][0]+t*a[1][0]+i*a[2][0]+a[3][0],this.ly=n*a[0][1]+t*a[1][1]+i*a[2][1]+a[3][1],this.lz=n*a[0][2]+t*a[1][2]+i*a[2][2]+a[3][2]}xrotatemat(a,n,t){let i=new Array(4).fill(0).map(()=>new Array(4).fill(0));i[0][0]=1,i[0][1]=0,i[0][2]=0,i[0][3]=0,i[1][0]=0,i[1][1]=t,i[1][2]=n,i[1][3]=0,i[2][0]=0,i[2][1]=-n,i[2][2]=t,i[2][3]=0,i[3][0]=0,i[3][1]=0,i[3][2]=0,i[3][3]=1,this.matrixmult(i,a,a)}yrotatemat(a,n,t){let i=new Array(4).fill(0).map(()=>new Array(4).fill(0));i[0][0]=t,i[0][1]=0,i[0][2]=-n,i[0][3]=0,i[1][0]=0,i[1][1]=1,i[1][2]=0,i[1][3]=0,i[2][0]=n,i[2][1]=0,i[2][2]=t,i[2][3]=0,i[3][0]=0,i[3][1]=0,i[3][2]=0,i[3][3]=1,this.matrixmult(i,a,a)}zrotatemat(a,n,t){let i=new Array(4).fill(0).map(()=>new Array(4).fill(0));i[0][0]=t,i[0][1]=n,i[0][2]=0,i[0][3]=0,i[1][0]=-n,i[1][1]=t,i[1][2]=0,i[1][3]=0,i[2][0]=0,i[2][1]=0,i[2][2]=1,i[2][3]=0,i[3][0]=0,i[3][1]=0,i[3][2]=0,i[3][3]=1,this.matrixmult(i,a,a)}zshearmat(a,n,t){let i=new Array(4).fill(0).map(()=>new Array(4).fill(0));i[0][0]=1,i[0][1]=0,i[0][2]=n,i[0][3]=0,i[1][0]=0,i[1][1]=1,i[1][2]=t,i[1][3]=0,i[2][0]=0,i[2][1]=0,i[2][2]=1,i[2][3]=0,i[3][0]=0,i[3][1]=0,i[3][2]=0,i[3][3]=1,this.matrixmult(i,a,a)}cscalemat(a,n,t,i){let o=new Array(4).fill(0).map(()=>new Array(4).fill(0));o[0][0]=n,o[0][1]=0,o[0][2]=0,o[0][3]=0,o[1][0]=0,o[1][1]=t,o[1][2]=0,o[1][3]=0,o[2][0]=0,o[2][1]=0,o[2][2]=i,o[2][3]=0,o[3][0]=0,o[3][1]=0,o[3][2]=0,o[3][3]=1,this.matrixmult(o,a,a)}copy(a){return{contrast:a.contrast,brightness:a.brightness,red:a.red,green:a.green,blue:a.blue,hue:a.hue,saturation:a.saturation,exposure:a.exposure,tint:a.tint,temperature:a.temperature,gamma:a.gamma,blur:a.blur,shadows:a.shadows,highlights:a.highlights,hueIntensity:a.hueIntensity,intensity:a.intensity}}setImageAdjust(a){this.imageAdjust=this.copy(a),this.updateBrightness(100*this.imageAdjust.brightness),this.updateIntensity(100*this.imageAdjust.intensity),this.updateContrast(100*this.imageAdjust.contrast),this.updateExposure(100*this.imageAdjust.exposure),this.updateRed(100*this.imageAdjust.red),this.updateGreen(100*this.imageAdjust.green),this.updateBlue(100*this.imageAdjust.blue),this.updateGamma(100*this.imageAdjust.gamma),this.updateHue(100*this.imageAdjust.hue),this.updateSaturation(100*this.imageAdjust.saturation),this.updateTint(100*this.imageAdjust.tint),this.updateTemperature(100*this.imageAdjust.temperature),this.updateBlur(100*this.imageAdjust.blur),this.updateShadows(100*this.imageAdjust.shadows),this.updateHighlights(100*this.imageAdjust.highlights)}}var Ge=m(20753),mr=m(85188);function ur(s,a){if(1&s){const n=e.RV6();e.j41(0,"div")(1,"div",1)(2,"div",2)(3,"div",3)(4,"span",4),e.EFF(5,"Brightness"),e.k0s(),e.j41(6,"button",5),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.resetAll())}),e.EFF(7,"Reset all"),e.k0s()(),e.j41(8,"div",6)(9,"div",7)(10,"mv-slider",8),e.bIt("change",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.inputBrightness(i))})("slideStop",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.changeBrightness(i,!0))})("slideStart",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.onSlideStart(i))}),e.k0s()(),e.j41(11,"div",9)(12,"input",10),e.bIt("change",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.changeBrightness(i,!1))}),e.k0s()()()(),e.j41(13,"div",2)(14,"span",4),e.EFF(15,"Contrast"),e.k0s(),e.j41(16,"div",6)(17,"div",7)(18,"mv-slider",8),e.bIt("change",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.inputContrast(i))})("slideStop",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.changeContrast(i,!0))})("slideStart",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.onSlideStart(i))}),e.k0s()(),e.j41(19,"div",9)(20,"input",10),e.bIt("change",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.changeContrast(i,!1))}),e.k0s()()()(),e.j41(21,"div",2)(22,"span",4),e.EFF(23,"Saturation"),e.k0s(),e.j41(24,"div",6)(25,"div",7)(26,"mv-sl
1ider",8),e.bIt("change",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.inputSaturation(i))})("slideStop",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.changeSaturation(i,!0))})("slideStart",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.onSlideStart(i))}),e.k0s()(),e.j41(27,"div",9)(28,"input",10),e.bIt("change",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.changeSaturation(i,!1))}),e.k0s()()()(),e.j41(29,"div",2)(30,"span",4),e.EFF(31,"Hue"),e.k0s(),e.j41(32,"div",6)(33,"div",7)(34,"mv-slider",8),e.bIt("change",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.inputHue(i))})("slideStop",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.changeHue(i,!0))})("slideStart",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.onSlideStart(i))}),e.k0s()(),e.j41(35,"div",9)(36,"input",10),e.bIt("change",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.changeHue(i,!1))}),e.k0s()()()(),e.j41(37,"div",2)(38,"span",4),e.EFF(39,"Gamma"),e.k0s(),e.j41(40,"div",6)(41,"div",7)(42,"mv-slider",8),e.bIt("change",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.inputGamma(i))})("slideStop",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.changeGamma(i,!0))})("slideStart",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.onSlideStart(i))}),e.k0s()(),e.j41(43,"div",9)(44,"input",10),e.bIt("change",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.changeGamma(i,!1))}),e.k0s()()()(),e.j41(45,"div",11)(46,"span",4),e.EFF(47,"Intensity"),e.k0s(),e.j41(48,"div",6)(49,"div",7)(50,"mv-slider",8),e.bIt("change",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.inputIntensity(i))})("slideStop",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.changeIntensity(i,!0))})("slideStart",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.onSlideStart(i))}),e.k0s()(),e.j41(51,"div",9)(52,"input",10),e.bIt("change",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.changeIntensity(i,!1))}),e.k0s()()()()()()}if(2&s){const n=e.XpG();e.R7$(6),e.Y8G("disabled",!n.isAllEdit),e.R7$(4),e.Y8G("value",n.colorService.brightness)("min",-100)("max",100)("step",1),e.R7$(2),e.Y8G("min",-100)("max",100)("ngModel",n.colorService.brightness),e.R7$(6),e.Y8G("value",n.colorService.contrast)("min",-100)("max",100)("step",1),e.R7$(2),e.Y8G("min",-100)("max",100)("ngModel",n.colorService.contrast),e.R7$(6),e.Y8G("value",n.colorService.saturation)("min",-100)("max",100)("step",1),e.R7$(2),e.Y8G("min",-100)("max",100)("ngModel",n.colorService.saturation),e.R7$(6),e.Y8G("value",n.colorService.hue)("min",-100)("max",100)("step",1),e.R7$(2),e.Y8G("min",-100)("max",100)("ngModel",n.colorService.hue),e.R7$(6),e.Y8G("value",n.colorService.gamma)("min",-100)("max",100)("step",1),e.R7$(2),e.Y8G("min",-100)("max",100)("ngModel",n.colorService.gamma),e.R7$(6),e.Y8G("value",n.colorService.intensity)("min",0)("max",100)("step",1),e.R7$(2),e.Y8G("min",0)("max",100)("ngModel",n.colorService.intensity)}}m(14096);let gr=(()=>{var s;class a{constructor(t){this.colorService=t,this.toolName="",this.isAllEdit=!1,this.onChange=new e.bkB,this.onSlide=new e.bkB}ngOnInit(){this.initialized=!0}emitChange(){this.onChange.emit(!0)}inputBrightness(t){this.changeBrightness(t.newValue,!0)}inputContrast(t){this.changeContrast(t.newValue,!0)}inputSaturation(t){this.changeSaturation(t.newValue,!0)}inputHue(t){this.changeHue(t.newValue,!0)}inputGamma(t){this.changeGamma(t.newValue,!0)}inputIntensity(t){this.changeIntensity(t.newValue,!0)}changeBrightness(t,i){(t=i?t:t.target.value)<101&&t>-101&&(i||(this.onSlide.emit(!0),this.isAllEdit=!0),this.colorService.changeBrightness(t,i),this.emitChange())}changeContrast(t,i){(t=i?t:t.target.value)<101&&t>-101&&(i||(this.onSlide.emit(!0),this.isAllEdit=!0),this.colorService.changeContrast(t,i),this.emitChange())}changeSaturation(t,i){(t=i?t:t.target.value)<101&&t>-101&&(i||(this.onSlide.emit(!0),this.isAllEdit=!0),this.colorService.changeSaturation(t,i),this.emitChange())}changeHue(t,i){(t=i?t:t.target.value)<101&&t>-101&&(i||(this.onSlide.emit(!0),this.isAllEdit=!0),this.colorService.changeHue(t,i),this.emitChange())}changeGamma(t,i){(t=i?t:t.target.value)<101&&t>-101&&(i||(this.onSlide.emit(!0),this.isAllEdit=!0),this.colorService.changeGamma(t,i),this.emitChange())}changeIntensity(t,i){(t=i?t:t.target.value)<101&&t>-101&&(i||(this.onSlide.emit(!0),this.isAllEdit=!0),this.colorService.changeIntensity(t,i),this.emitChange())}onSlideStart(t){this.onSlide.emit(!0),this.isAllEdit=!0}resetAll(){this.colorService.resetAll(()=>{this.emitChange(),this.isAllEdit=!1})}}return(s=a).\u0275fac=function(t){return new(t||s)(e.rXU(it))},s.\u0275cmp=e.VBU({type:s,selectors:[["retouch-adjustment-lips"]],inputs:{toolName:"toolName"},outputs:{onChange:"onChange",onSlide:"onSlide"},decls:1,vars:1,consts:[[4,"ngIf"],[1,"pt-9"],[1,"card-body","mb-9"],[1,"d-flex","align-items-center","w-100","justify-content-between","position-relative"],[1,"text-13","grey-800","text-semi"],[1,"btn-all","reset-all","text-semi","position-absolute","d-flex","align-items-center","justify-content-center",2,"right","-8px","top","-20px",3,"click","disabled"],[1,"d-flex"],[1,"wp-100","d-flex","align-items-center"],[1,"opacity-slider",2,"width","100%",3,"change","slideStop","slideStart","value","min","max","step"],[1,"ms-3"],["type","text","numberSettings","",1,"form-control","form-input-sm","text-normal","text-black","float-end",3,"change","min","max","ngModel"],[1,"card-body"]],template:function(t,i){1&t&&e.DNE(0,ur,53,43,"div",0),2&t&&e.Y8G("ngIf","Lips"==i.toolName)},dependencies:[b.bT,P.me,P.BC,P.vS,Ge.I,O.d1],styles:["label[_ngcontent-%COMP%]{font-size:14px;color:#272b34}
1.reset-all[_ngcontent-%COMP%]{font-size:12px;line-height:16px;color:#626adf;border-radius:8px;padding:7px;height:32px}.reset-all[_ngcontent-%COMP%]:disabled{background-color:transparent!important;color:#b0b3bf!important;pointer-events:none}.reset-all[_ngcontent-%COMP%]:hover{background:#626adf0d;color:#626adf}"]}),a})();function _r(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",10)(1,"span",4),e.EFF(2,"Intensity"),e.k0s(),e.j41(3,"div",11)(4,"div",12)(5,"mv-slider",13),e.bIt("change",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.inputIntensity(i))})("slideStop",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.changeIntensity(i,!0))}),e.k0s()(),e.j41(6,"div",14)(7,"input",15,0),e.bIt("ngModelChange",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.changeIntensity(i,!0))}),e.k0s()()()()}if(2&s){const n=e.XpG();e.R7$(5),e.Y8G("value",n.changeColorService.intensity)("min",0)("max",100)("step",1),e.R7$(2),e.Y8G("min",0)("max",180)("ngModel",n.changeColorService.intensity)("allowNegativeNumbers",!0)}}function fr(s,a){if(1&s){const n=e.RV6();e.j41(0,"retouch-adjustment-lips",16),e.bIt("onChange",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.renderAll())})("onSlide",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.onSlideStart(i))}),e.k0s()}if(2&s){const n=e.XpG();e.Y8G("toolName",n.toolName)}}let vr=(()=>{var s;class a{constructor(t,i,o,r,l){this.faceRetouchService=t,this.changeColorService=i,this.authService=o,this.env=r,this.subsService=l,this.toolName="Lips",this.filterIndex=5,this.selectedColorObj=null,this.adjustment=!1,this.colors=[],this.isAllEdit=!1,this.selectLayout=new e.bkB,this.loggedInObserver=this.authService.loggedIn.subscribe(c=>{this.user=this.authService.currentUser()}),this.usrPropChangedObserver=this.authService.usrPropChanged.subscribe(c=>{this.user=this.authService.currentUser()})}ngOnInit(){var t=this;return(0,w.A)(function*(){if(!t.env.isMobileView){yield t.getRetouchColors(),t.adjustmentObj=new wt,t.changeColorService.setActionController(t.adjustmentObj),t.changeColorService.updateAdjustmentValues();const i=t.colors[1].obj;t.selectedColorObj=t.colors[1],t.changeColorService.changeBrightness(i.brightnessValue,!1),t.changeColorService.changeContrast(i.contrastValue,!1),t.changeColorService.changeSaturation(i.exposureValue,!1),t.changeColorService.changeHue(i.hueValue,!1),t.changeColorService.changeGamma(i.gammaValue,!1),t.changeColorService.changeIntensity(i.intensityValue,!1)}})()}ngOnChanges(t){t.active&&this.inputImage&&(!this.adjustmentObj&&this.env.isMobileView?this.applyShadeAdjusmentValueMobile():this.applyFilter())}applyFilter(){if(this.active){const t=this.faceRetouchService.getMask(this.toolName);t&&(this.filter=new I.fabric.Image.filters.AdjustmentLips({image:t,adjustment:this.adjustmentObj.adjustedValues,adztOn:"1.0"}),this.inputImage.filters[this.filterIndex]=this.filter,this.inputImage.applyFilters(),this.inputImage.canvas.requestRenderAll())}else this.inputImage.filters[this.filterIndex]=null,this.inputImage.applyFilters(),this.inputImage.canvas.requestRenderAll()}renderAll(){this.inputImage.applyFilters(),this.inputImage.canvas.requestRenderAll()}onSlideStart(t){}applyShadeAdjusmentValue(t){this.changeColorService.changeBrightness(t.brightnessValue,!1),this.changeColorService.changeContrast(t.contrastValue,!1),this.changeColorService.changeSaturation(t.exposureValue,!1),this.changeColorService.changeHue(t.hueValue,!1),this.changeColorService.changeGamma(t.gammaValue,!1),this.changeColorService.changeIntensity(t.intensityValue,!1),this.inputImage.applyFilters(),this.inputImage.canvas.requestRenderAll()}selectTab(t){this.selectLayout.emit(t);const i=()=>{this.selectedColorObj=t,1==t.id?this.adjustment=!0:(this.adjustment=!1,this.applyShadeAdjusmentValue(t.obj))};Number(t.pro)&&(!this.user||this.user&&!this.user.subscribed)?this.subsService.loginWithUpgrade(()=>{this.user=this.authService.currentUser(),this.user&&this.user.subscribed&&i()},{coinSectionHide:this.env.isMobileView}):i(),this.isAllEdit||(this.isAllEdit=!0)}getRetouchColors(){var t=this;return(0,w.A)(function*(){t.colors=yield t.faceRetouchService.getLipShadsColor()})()}inputIntensity(t){this.changeIntensity(t.newValue,!0)}changeIntensity(t,i){(t=i?t:t?.target.value)<101&&t>-101&&(this.changeColorService.changeIntensity(t,i),this.inputImage.applyFilters(),this.inputImage.canvas.requestRenderAll())}ngAfterViewInit(){this.uploadImageServiceAfterImageLoadSub=this.uploadImageService.afterImageLoad.subscribe(t=>{t&&this.reset()})}reset(){this.ngOnInit(),this.adjustment=!1,this.inputImage&&(this.inputImage.filters[this.filterIndex]=null)}applyShadeAdjusmentValueMobile(){var t=this;return(0,w.A)(function*(){t.getRetouchColors().then(()=>{t.adjustmentObj=new wt,t.changeColorService.setActionController(t.adjustmentObj),t.changeColorService.updateAdjustmentValues(),t.selectedColorObj=t.colors[0],t.applyFilter()})})()}ngOnDestroy(){this.loggedInObserver&&this.loggedInObserver.unsubscribe(),this.usrPropChangedObserver&&this.usrPropChangedObserver.unsubscribe()}}return(s=a).\u0275fac=function(t){return new(t||s)(e.rXU(he.V),e.rXU(it),e.rXU(q.u),e.rXU(xe.L),e.rXU(ue.n))},s.\u0275cmp=e.VBU({type:s,selectors:[["shade-tool"]],inputs:{toolName:"toolName",active:"active",inputImage:"inputImage",uploadImageService:"uploadImageService"},outputs:{selectLayout:"selectLayout"},features:[e.Jv_([it]),e.OA$],decls:10,vars:6,consts:[["xDirInput",""],[1,"common-container","mt-2","mb-3"],[1,"card-body"],[1,"d-flex","align-items-center","w-100","justify-content-between","mb-3"],[1,"text-13","grey-800","text-semi"],[1,"d-flex","mb-3"],[1,"colors-bg","sticker-buttons-scroll","face-retouch-background"],[3,"selectLayout","items","type","categoryId","user"],["class","card-body mb-0",4,"ngIf"],[3,"toolName","onChange","onSlide",4,"ngIf"],[1,"card-body","mb-0"],[1,"d-flex","mt-1"],[1,"wp-100","d-flex","align-items-center"],[1,"opacity-slider",2,"width","100%",3,"change","slideStop","value","min","max","step"],[1,"ms-3"],["type","text","numberSettings","","maxlength","4","mask","separator.2","separatorLimit","100",1,"form-control","form-input-sm","text-normal","text-black",3,"ngModelChange","min","max","ngModel","allowNegativeNumbers"],[3,"onChange","onSlide","toolName"]],template:function(t,i){1&t&&(e.j41(0,"div",1)(1,"div",2)(2,"div",3)(3,"span",4),e.EFF(4,"Shade"),e.k0s()(),e.j41(5,"div",5)(6,"div",6)(7,"buttons-scroll-menu",7),e.bIt("selectLayout",function(r){return i.selectTab(r)}),e.k0s()()()(),e.DNE(8,_r,9,8,"div",8)(9,fr,1,1,"retouch-adjustment-lips",9),e.k0s()),2&t&&(e.R7$(7),e.Y8G("items",i.colors)("type","airetouchcolors")("categoryId",null==i.selectedColorObj?null:i.selectedColorObj.id)("user",i.user),e.R7$(),e.Y8G("ngIf",!i.adjustment&&-1!=(null==i.selectedColorObj?null:i.selectedColorObj.id)),e.R7$(),e.Y8G("ngIf",i.adjustment))},dependencies:[b.bT,P.me,P.BC,P.tU,P.vS,_e.B,Ge.I,O.d1,mr.Zr,gr],styles:[".reset-all[_ng
1content-%COMP%]{font-size:12px;line-height:16px;color:#626adf;border-radius:8px;padding:.5rem}.reset-all[_ngcontent-%COMP%]:disabled{background-color:transparent!important;color:#b0b3bf!important}.reset-all[_ngcontent-%COMP%]:hover{background:#626adf0d;color:#626adf}"]}),a})();var St=m(58426),Mt=m(60655),kt=m(95854),T=m(75243),br=m(57786),Tt=m(33726),Ot=m(70152),nt=m(64511);let ve=(()=>{var s;class a{attachPinchPanHandlers(t,i,o){const r=o.maxScale??2,l=o.centerWhenSmaller??!0,c=o.enablePan??!0,d=i.getElement();t.style.touchAction=t!==d?"manipulation":"none";const h=new nt(t,{touchAction:"manipulation"});h.get("pinch").set({enable:!0}),h.get("pan").set({enable:c});let p=1,u=!1,g={x:0,y:0};return h.on("pinchstart",()=>{p=o.getScale()}),h.on("pinchend",()=>{p=o.getScale()}),h.on("pinch",_=>{_.preventDefault();const v=p*_.scale,C=Math.max(o.getInitialScale(),Math.min(v,r)),M=d.getBoundingClientRect(),G=new I.fabric.Point(_.center.x-M.left,_.center.y-M.top);i.zoomToPoint(G,C),this.clampPan(i,l),o.setScale(i.getZoom())}),c&&(h.on("panstart",()=>{u=!0}),h.on("panend",()=>{u=!1,g={x:0,y:0}}),h.on("panmove",_=>{u&&(i.relativePan(new I.fabric.Point(_.deltaX-g.x,_.deltaY-g.y)),g={x:_.deltaX,y:_.deltaY},this.clampPan(i,l))})),h}clampPan(t,i=!0){const o=t.getZoom?t.getZoom():1,r=t.getWidth(),l=t.getHeight(),c=t.viewportTransform,d=t.getObjects("image")[0];if(!d)return;const h=(d.width||0)*(d.scaleX||1)*o,p=(d.height||0)*(d.scaleY||1)*o;let u=c[4],g=c[5];u=i&&h<=r?(r-h)/2:Math.min(0,Math.max(r-h,u)),g=i&&p<=l?(l-p)/2:Math.min(0,Math.max(l-p,g)),c[4]=u,c[5]=g,t.setViewportTransform(c)}exportCanvasIgnoringViewport(t){const i=t.getObjects("image"),o=i&&i.length?i.reduce((v,C)=>{const M=(v?.width||0)*(v?.height||0);return(C?.width||0)*(C?.height||0)>M?C:v},i[0]):null;if(!o)return null;const r=o.getElement&&o.getElement(),l=r&&(r.naturalWidth||r.width)||o.width||t.getWidth(),c=r&&(r.naturalHeight||r.height)||o.height||t.getHeight(),d=t.viewportTransform?[...t.viewportTransform]:[1,0,0,1,0,0],h=t.getZoom?t.getZoom():1,p=t.getWidth(),u=t.getHeight(),g=t.clipPath;t.setViewportTransform([1,0,0,1,0,0]),t.setZoom&&t.setZoom(1),t.clipPath=void 0,t.setWidth(l),t.setHeight(c),t.requestRenderAll();const _=t.toDataURL({multiplier:1});return t.setWidth(p),t.setHeight(u),t.setViewportTransform(d),t.setZoom&&t.setZoom(h),t.clipPath=g,t.requestRenderAll(),_}}return(s=a).\u0275fac=function(t){return new(t||s)},s.\u0275prov=e.jDH({token:s,factory:s.\u0275fac}),a})(),re=(()=>{var s;class a{constructor(t,i,o,r,l){this.removeBgService=t,this.env=i,this.aiUploadImageService=o,this.faceRetouchService=r,this.gestureService=l,this.array=["Skin","Hair","Lips","Eyes","Eyebrows","Teeth"],this.isDirty=!1,this.maxWidth=T.lL,this.maxHeight=T.iB,this.suspendAutoFit=!1,this.registerResizeHandler()}loadInputImage(t,i,o=null,r=null,l=T.lL,c=T.iB,d=!1,h=!1,p=!1){this.maxWidth=l,this.maxHeight=c,fe.k.loadImageElement(t,u=>{fe.k.checkAndResizeImage(u,(g,_)=>{this.theOriginalOriginalImage=_,g?(this.originalImage=g,this.initCanvas(g,i,o,d,h,p)):r({err:"failed"})},l,c)})}reloadImage(t,i=null,o=!1,r=!1){if(!this.mainCanvas)return void console.warn("Canvas not initialized.");this.inputImage&&this.mainCanvas.remove(this.inputImage);const l=c=>{this.inputImage=new I.fabric.Image(c),this.inputImage.set({selectable:!1,evented:r,objectCaching:!r,noScaleCache:r}),this.fitToScreen(o),this.mainCanvas.add(this.inputImage),this.mainCanvas.renderAll(),i&&i()};"string"==typeof t?fe.k.loadImageElement(t,c=>{fe.k.checkAndResizeImage(c,(d,h)=>{this.theOriginalOriginalImage=h,this.originalImage=c,l(c)})}):(this.originalImage=t,l(t))}initCanvas(t,i,o=null,r=!1,l=!1,c=!1){if(this.mainCanvas){try{this.mainCanvas.dispose()}catch{}this.mainCanvas=null}c&&(this.suspendAutoFit=!0),this.mainCanvas=l?new I.fabric.Canvas(i,{selection:!1,uniScaleKey:null,altActionKey:null}):new I.fabric.StaticCanvas(i),this.inputImage=new I.fabric.Image(t),this.inputImage.set({selectable:!1,evented:!0,objectCaching:!1,noScaleCache:!0}),this.fitToScreen(r,c),i&&(this.mainCanvas.add(this.inputImage),c||this.mainCanvas.renderAll()),o&&o()}enableAutoFit(){this.suspendAutoFit=!1}getMaskFromRemote(t,i=null){this.removeBgService.prepareInputImageRemoteBg(this.originalImage).then(o=>{this.aiUploadImageService.uploadImage(o,t,r=>{r&&"FAIL"!==r.status&&i&&i(r)})})}registerResizeHandler(){if(typeof window>"u")return;
1const t=(0,br.h)((0,Tt.R)(window,"resize"),(0,Tt.R)(window,"orientationchange"));this.resizeSubscription=t.pipe((0,Ot.B)(200)).subscribe(()=>{this.suspendAutoFit||this.fitToScreen()})}destroy(){this.resizeSubscription&&this.resizeSubscription.unsubscribe()}fitToScreen(t=!1,i=!1){const o=document.getElementById("canvasWrapper");if(!o||!this.mainCanvas||!this.inputImage)return;const r=o.getBoundingClientRect();if(t){const l=Math.min(r.height/this.inputImage.height,r.width/this.inputImage.width);this.mainCanvas.setZoom(l),this.mainCanvas.setHeight(this.inputImage.height*l),this.mainCanvas.setWidth(this.inputImage.width*l)}else{const l=r.width,c=r.height;this.mainCanvas.setWidth(l),this.mainCanvas.setHeight(c);const d=Math.min(l/this.inputImage.width,c/this.inputImage.height);this.mainCanvas.setViewportTransform([d,0,0,d,(l-this.inputImage.width*d)/2,(c-this.inputImage.height*d)/2]),i||this.mainCanvas.requestRenderAll()}}calcWrapperSize(){const t=document.getElementById("canvasWrapper");if(t){const i=t.getBoundingClientRect();return{width:i.width,height:i.height}}return{width:100,height:100}}restoreResolution(){var t=this;return(0,w.A)(function*(){const i=I.fabric.perfLimitSizeTotal;I.fabric.perfLimitSizeTotal=16777216;const o=T.lL,r=T.iB,l=yield new Promise((_,v)=>{fe.k.checkAndResizeImage(t.theOriginalOriginalImage,(C,M,k)=>{_(C)},o,r)}),u=(new he.V(null,null),t.faceRetouchService.getAllmaskFabricImage(),new I.fabric.Image(l));return u.filters=t.inputImage.filters,u.set({scaleX:t.inputImage.scaleX||1,scaleY:t.inputImage.scaleY||1,left:"number"==typeof t.inputImage.left?t.inputImage.left:0,top:"number"==typeof t.inputImage.top?t.inputImage.top:0}),u.applyFilters(),t.mainCanvas.remove(t.inputImage),t.mainCanvas.add(u),t.mainCanvas.renderAll(),()=>{I.fabric.perfLimitSizeTotal=i,t.inputImage.filters=u.filters,u.filters=[],t.inputImage.applyFilters(),t.mainCanvas.remove(u),t.mainCanvas.add(t.inputImage),t.mainCanvas.renderAll()}})()}loadApiResultImage(t){var i=this;return(0,w.A)(function*(){const o=i.originalImage,r=o.width,l=o.height,c=new Promise((p,u)=>{I.fabric.Image.fromURL(t.urls[0],_=>{i.faceRetouchService.setAllmaskFabricImage(_),i.removeBgService.processOutputImageRemote(r,l,_).then(v=>{let C=v.scaledImageData;const M=I.fabric.util.createCanvasElement();M.width=C.width,M.height=C.height,M.getContext("2d").putImageData(C,0,0);const k=new I.fabric.Image(M);i.faceRetouchService.setAllmaskFabricImage(k),p()})},{crossOrigin:"Anonymous"})}),d=new Promise((p,u)=>{I.fabric.Image.fromURL(t.maskUrl,g=>{const _=new I.fabric.Image.filters.Blur({blur:.2});g.filters.push(_),g.applyFilters(),i.removeBgService.processOutputImageRemote(r,l,g).then(v=>{i.faceRetouchService.setHairMaskImageData(v.scaledImageData),p()})},{crossOrigin:"Anonymous"})}),h=new Promise((p,u)=>{t.maskSkinUrl?I.fabric.Image.fromURL(t.maskSkinUrl,g=>{const _=new I.fabric.Image.filters.Blur({blur:.2});g.filters.push(_),g.applyFilters(),i.removeBgService.processOutputImageRemote(r,l,g).then(v=>{i.faceRetouchService.setSkinMaskImageData(v.scaledImageData),p()})},{crossOrigin:"Anonymous"}):p()});return Promise.all([c,d,h])})()}download(){var t=this;return(0,w.A)(function*(i="png",o=null,r=y.b.label.blankProjectName,l=null){l||(l=t.mainCanvas.toDataURL({multiplier:t.originalImage.width/t.mainCanvas.width,format:i}));const c=document.createElement("a");c.href=l,c.download=r+"."+i,document.body.appendChild(c),c.style="display: none",c.click(),c.remove()}).apply(this,arguments)}}return(s=a).\u0275fac=function(t){return new(t||s)(e.KVO(Ie.r,8),e.KVO(xe.L),e.KVO(ee.M),e.KVO(he.V),e.KVO(ve))},s.\u0275prov=e.jDH({token:s,factory:s.\u0275fac}),a})();var Ue=m(6755),Cr=m(79774),xr=m(51789),Et=m(45975);let be=(()=>{var s;class a{constructor(t,i,o,r,l){this.modalService=t,this.authService=i,this.uploadService=o,this.gestureService=r,this.document=l,this.projectName=y.b.label.blankProjectName}applyToSave(t,i,o=null,r=!0,l=null){const c=this.authService.currentUser();this.getImageFromCanvas(t.width,t.height,i,r).then(d=>{c&&this.checkStorage(d.uri,(h,p)=>{h&&p&&this._saveImage(d.image,p,l)}),o&&o(d)})}saveImageUrlToPhotoEdits(t){var i=this;return(0,w.A)(function*(){if(!i.authService.currentUser()||!t)return!1;try{const o=yield i.loadXHR(t);if(o.name=i.projectName,!(yield new Promise(c=>{i.uploadService.checkStorage(o,d=>c(!!d?.status))})))return i.showStorageLimitError(),!1;const l=yield i.loadImageFromBlob(o);return i._saveImage(l,o),!0}catch{return!1}})()}getImageFromCanvas(t,i,o,r=!0){let l=this.document.createElement("canvas");return new Promise((c,d)=>{l.width=t,l.height=i;const h=l.getContext("2d"),p=r?o.toDataURL({multiplier:1/o.getZoom(),format:"png"}):this.gestureService.exportCanvasIgnoringViewport(o);var u=new Image;u.onload=function(){h.drawImage(u,0,0,t,i);let g=l.toDataURL(),_=new Image;_.addEventListener("load",()=>{setTimeout(()=>{c({uri:g,image:_})})},!1),_.src=g},u.src=p})}checkStorage(t=null,i=null){this.loadXHR(t).then(o=>{o.name=this.projectName,this.uploadService.checkStorage(o,r=>{r.status||this.showStorageLimitError(),i&&i(r.status,o)})})}_saveImage(t,i,o=null){i.name=this.projectName,this.uploadService.addImageFile(i,t,r=>{},Cr.P.IMG_EDITS,null,o)}loadXHR(t){return new Promise(function(i,o){try{var r=new XMLHttpRequest;r.open("GET",t),r.responseType="blob",r.onerror=function(){o("Network error.")},r.onload=function(){200===r.status?i(r.response):o("Loading error:"+r.statusText)},r.send()}catch(l){o(l.message)}})}loadImageFromBlob(t){return new Promise((i,o)=>{const r=URL.createObjectURL(t),l=new Image;l.onload=()=>{URL.revokeObjectURL(r),i(l)},l.onerror=()=>{URL.revokeObjectURL(r),o(new Error("Unable to load image"))},l.src=r})}showStorageLimitError(){this.modalService.open(xr.I,{centered:!1,size:"sm",backdrop:!0,windowClass:"storage-limit-error",backdropClass:"transparent-backdrop"}).componentInstance.message=y.b.message.dataLimitPhotoEditor}}return(s=a).\u0275fac=function(t){return new(t||s)(e.KVO(R.Bq),e.KVO(q.u),e.KVO(Et.B),e.KVO(ve),e.KVO(b.qQ))},s.\u0275prov=e.jDH({token:s,factory:s.\u0275fac}),a})();var Me=m(60004);const Pr=["contentBox"],Ir=["mainCanvas"],yr=["originalImg"],wr=["compareContainer"],Sr=s=>({"d-none":s}),Mr=s=>({btnTabActive:s});function kr(s,a){if(1&s&&e.nrm(0,"img",16,2),2&s){const n=e.XpG();e.Y8G("src",n.photoEditorMobService.originalImage.src,e.B4B)}}function Tr(s,a){1&s&&(e.j41(0,"button",20),e.nrm(1,"pi",21),e.k0s())}function Or(s,a){if(1&s){const n=e.RV6();e.j41(0,"button",22),e.bIt("pointerdown",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.onPointerDown())})("pointerup",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.onPointerUp())})("pointercancel",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.onPointerUp())})("pointerleave",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.onPointerUp())}),e.nrm(1,"pi",23),e.k0s()}}function Er(s,a){if(1&s&&(e.j41(0,"div",17),e.DNE(1,Tr,2,0,"button",18)(2,Or,2,0,"button",19),e.k0s()),2&s){const n=e.XpG();e.R7$(),e.Y8G("ngIf",!(null!=n.skintoolComponent&&n.skintoolComponent.isAllReset||null!=n.skintoolComponent&&n.skintoolComponent.isAllEdit||null!=n.shadeToolHairComponent&&n.shadeToolHairComponent.isAllEdit||n.faceRetouchService.isAllEdit||null!=n.shadeToolComponent&&n.shadeToolComponent.isAllEdit||null!=n.shadeToolLipsComponent&&n.shadeToolLipsComponent.isAllEdit)),e.R7$(),e.Y8G("ngIf",(null==n.skintoolComponent?null:n.skintoolComponent.isAllReset)||(null==n.skintoolComponent?null:n.skintoolComponent.isAllEdit)||(null==n.shadeToolHairComponent?null:n.shadeToolHairComponent.isAllEdit)||n.faceRetouchService.isAllEdit||(null==n.shadeToolComponent?null:n.shadeToolComponent.isAllEdit)||(null==n.shadeToolLipsComponent?null:n.shadeToolLipsComponent.isAllEdit))}}function jr(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",24),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.download())}),e.nrm(1,"pi",25),e.k0s()}}function Gr(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",34)(1,"div",35)(2,"button",36)(3,"div",37),e.bIt("click",function(){const i=e.eBV(n).$implicit,o=e.XpG(2);return e.Njj(o.getActiveKey(i))}),e.EFF(4),e.k0s()()()()}if(2&s){const n=a.$implicit,t=e.XpG(2);e.FS9("id","face-retouch-"+n),e.R7$(2),e.Y8G("ngClass",e.eq3(3,Mr,t.activeKey==n)),e.R7$(2),e.JRh(n)}}function Vr(s,a){if(1&s&&e.nrm(0,"skin-tool",38),2&s){const n=e.XpG(2);e.Y8G("ngClass","Skin"==n.activeKey?"d-block":"d-none")("active",n.toolToggleMap.get(n.activeKey))("inputImage",n.inputImage)("originalImage",null==n.photoEditorMobService?null:n.photoEditorMobService.theOriginalOriginalImage)}}function Rr(s,a){if(1&s){const n=e.RV6();e.j41(0,"shade-tool-lips",39),e.bIt("selectLayout",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.selectTab(i))}),e.k0s()}if(2&s){const n=e.XpG(2);e.Y8G("ngClass","Lips"==n.activeKey?"d-block":"d-none")("active",n.toolToggleMap.get(n.activeKey))("inputImage",n.inputImage)("uploadImageService",n.uploadImageService)}}function Fr(s,a){if(1&s){const n=e.RV6();e.j41(0,"shade-tool-hair",40),e.bIt("selectLayout",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.selectTab(i))}),e.k0s()}if(2&s){const n=e.XpG(2);e.Y8G("ngClass","Hair"==n.activeKey?"d-block":"d-none")("active",n.toolToggleMap.get(n.activeKey))("inputImage",n.inputImage)}}function Ar(s,a){if(1&s&&e.nrm(0,"single-tool",41),2&s){const n=e.XpG(2);e.Y8G("ngClass","Eyes"==n.activeKey?"d-block":"d-none")("toolName","Eyes")("active",n.toolToggleMap.get(n.activeKey))("inputImage",n.inputImage)("uploadImageService",n.uploadImageService)}}function Br(s,a){if(1&s&&e.nrm(0,"single-tool",41),2&s){const n=e.XpG(2);e.Y8G("ngClass","Eyebrows"==n.activeKey?"d-block":"d-none")("toolName","Eyebrows")("active",n.toolToggleMap.get(n.activeKey))("inputImage",n.inputImage)("uploadImageService",n.uploadImageService)}}function Ur(s,a){if(1&s&&e.nrm(0,"single-tool",41),2&s){const n=e.XpG(2);e.Y8G("ngClass","Teeth"==n.activeKey?"d-block":"d-none")("toolName","Teeth")("active",n.toolToggleMap.get(n.activeKey))("inputImage",n.inputImage)("uploadImageService",n.uploadImageService)}}function Dr(s,a){if(1&s&&(e.qex(0),e.j41(1,"div",26)(2,"div",27),e.DNE(3,Gr,5,5,"div",28),e.k0s(),e.j41(4,"div",29,3),e.DNE(6,Vr,1,4,"skin-tool",30)(7,Rr,1,4,"shade-tool-lips",31)(8,Fr,1,3,"shade-tool-hair",32)(9,Ar,1,5,"single-tool",33)(10,Br,1,5,"single-tool",33)(11,Ur,1,5,"single-tool",33),e.k0s()(),e.bVm()),2&s){const n=e.XpG();e.R7$(3),e.Y8G("ngForOf",n.array),e.R7$(),e.Y8G("ngClass",n.animationState),e.R7$(2),e.Y8G("ngIf",n.toolToggleMap.get("Skin")),e.R7$(),e.Y8G("ngIf",n.toolToggleMap.get("Lips")),e.R7$(),e.Y8G("ngIf",n.toolToggleMap.get("Hair")),e.R7$(),e.Y8G("ngIf",n.toolToggleMap.get("Eyes")),e.R7$(),e.Y8G("ngIf",n.toolToggleMap.get("Eyebrows")),e.R7$(),e.Y8G("ngIf",n.toolToggleMap.get("Teeth"))}}let Nr=(()=>{var s;class a{constructor(t,i,o,r,l,c,d,h,p,u,g,_,v){var C=this;this.aiPhotoService=t,this.authService=i,this.aiUploadImageService=o,this.uploadImageService=r,this.photoEditorSahredService=l,this.gtmService=c,this.location=d,this.toastService=h,this.createPopupService=p,this.photoEditorMobService=u,this.gestureService=g,this.faceRetouchService=_,this.renderer=v,this.changeStep=new e.bkB,this.disabled=!1,this.isProUser=!1,this.array=["Skin","Hair","Lips","Eyes","Eyebrows","Teeth"],this.toolToggleMap=new Map(this.array.map(M=>[M,!1])),this.activeKey="Skin",this.animationState="",this.isCompare=!1,this.scale=1,this.initialScale=0,this.pinchStartScale=1,this.lastZoom=1,this.lastPan={x:0,y:0},this.isPanning=!1,this.user=this.authService.currentUser(),this.loggedInObserver=this.authService.loggedIn.subscribe(M=>{this.user=this.authService.currentUser(),this.isProUser=this.aiPhotoService.isProUser()}),this.usrPropChangedObserver=this.authService.usrPropChanged.subscribe(M=>{this.user=this.authService.currentUser(),this.isProUser=this.aiPhotoService.isProUser()}),this.updateBehaviorUserAiConis=this.authService.updateBehaviorUserAiConis.subscribe(M=>{this.user=this.authService.currentUser(),this.isProUser=this.aiPhotoService.isProUser()}),this.aiPhotoService.applyToSaveFn=(0,w.A)(function*(){C.resetImage();const M=yield C.photoEditorMobService.restoreResolution();return new Promise(k=>{C.photoEditorSahredService.applyToSave(C.photoEditorMobService.theOriginalOriginalImage,C.photoEditorMobService.mainCanvas,j=>{C.aiPhotoService.imgUrl=j.uri,C.aiPhotoService.queryParams.imgUrl=j.uri,M(),k()},!1,{activeTool:f.z6.Portrait,activeSubTool:f.Fs.FaceRetouch})})})}setScaleVar(){const i=document.getElementById("canvasWrapper").getBoundingClientRect(),o=Math.min(i.height/this.inputImage.height,i.width/this.inputImage.width);this.scale=o,this.initialScale=o,this.initialViewport=[...this.photoEditorMobService.mainCanvas.viewportTransform],this.originalImg.nativeElement.style.width=`${this.inputImage.width}px`,this.originalImg.nativeElement.style.height=`${this.inputImage.height}px`,this.originalImg.nativeElement.style.transformOrigin="0 0",this.compareContainer.nativeElement.style.width=`${this.photoEditorMobService.mainCanvas.width}px`,this.compareContainer.nativeElement.style.height=`${this.photoEditorMobService.mainCanvas.height}px`}ngOnInit(){this.toolName=this.aiPhotoService?.queryParams?.tab;const t=this.aiPhotoService.imgUrl;this.aiPhotoService.isSaveInProgress=!1;const i={tab:"airetouch",fileName:"untitled.jpg"},o=this.mainCanvas.nativeElement;this.aiPhotoService.startProcessingProgress({featureType:f.Fs.FaceRetouch,indeterminate:!0}),this.photoEditorMobService.loadInputImage(t,o,()=>{this.isLoaded=!0,this.inputImage=this.photoEditorMobService.inputImage,this.photoEditorMobService.getMaskFromRemote(i,r=>{r&&r.contentUrl?this.generate(r.contentUrl):this.aiPhotoService.clearGenerationProgress(),this.setScaleVar(),this.hammer=this.gestureService.attachPinchPanHandlers(this.mainCanvas.nativeElement,this.photoEditorMobService.mainCanvas,{getScale:()=>this.scale,setScale:l=>{this.scale=l},getInitialScale:()=>this.initialScale,maxScale:2,centerWhenSmaller:!0})})},()=>{this.aiPhotoService.clearGenerationProgress(),this.toastService.showError(y.b.message.somethingWrong),this.location.back()},T.ms,T.HI,!1)}clampPan(){const t=this.photoEditorMobService.mainCanvas.getZoom(),i=this.photoEditorMobService.mainCanvas.getWidth(),o=this.photoEditorMobService.mainCanvas.getHeight(),r=this.photoEditorMobService.mainCanvas.viewportTransform,l=this.photoEditorMobService.mainCanvas.getObjects("image")[0];if(!l)return;let h=r[4],p=r[5];const _=o-l.height*l.scaleY*t;h=Math.min(0,Math.max(i-l.width*l.scaleX*t,h)),p=Math.min(0,Math.max(_,p)),r[4]=h,r[5]=p,this.photoEditorMobService.mainCanvas.setViewportTransform(r)}ngAfterViewInit(){setTimeout(()=>{const t=this.contentBox.nativeElement;this.mutationObserver=new MutationObserver(()=>{this.checkOverflow(t)}),this.mutationObserver.observe(t,{childList:!0,characterData:!0,subtree:!0}),this.checkOverflow(t)},500)}selectTab(t){const i=this.contentBox.nativeElement;this.animationState="out",i.classList.add("opacity-0"),i.style.transition="",setTimeout(()=>{this.animationState="in",i.classList.remove("opacity-0"),i.style.transition="opacity 0.4s ease, transform 0.4s ease",this.checkOverflow(this.contentBox.nativeElement)},400)}checkOverflow(t){const i=t.scrollWidth>t.clientWidth||t.scrollHeight>t.clientHeight,o=this.contentBox.nativeElement;o.classList.remove("animate-items"),i?(o.classList.add("justify-content-start"),o.classList.remove("justify-content-center"),o.classList.add("animate-items")):(o.classList.add("justify-content-center"),o.classList.remove("justify-content-start"),o.classList.add("animate-items"))}generate(t=null){const i={imageUrl:t,featureType:f.Fs.FaceRetouch};this.aiPhotoService.startGenerationProgress({featureType:f.Fs.FaceRetouch,deductsCredits:!1,indeterminate:!0}),this.aiPhotoService.generateImage(i,o=>{o&&o.assetId?(o.featureType=f.Fs.FaceRetouch,this.aiPhotoService.checkStatusResponsive(o,0,l=>{l&&l?.urls?this.photoEditorMobService.loadApiResultImage(l).then(()=>{this.toolToggleMap=new Map(this.array.map(d=>[d,!0])),this.aiPhotoService.completeGenerationProgress(),this.aiPhotoService.aiImages.length&&this.aiPhotoService.aiImages.pop(),this.gtmService.pushTag({eventName:y.b.gtm.eventname.faceRetouchClick,itemName:"Face Retouch - Finish"})}):(this.aiPhotoService.clearGenerationProgress(),this.changeStep.emit
1({step:2,error:!0}))},l=>{this.displayErrorMsg(l)})):this.displayErrorMsg(o)},o=>{this.displayErrorMsg(o)})}displayErrorMsg(t=null){this.aiPhotoService.clearGenerationProgress();let i=t?.description;this.createPopupService.openWarningDialog("Error",i).then(()=>{this.changeStep.emit({resetToIntermediate:!0})})}ngOnDestroy(){document.body.classList.remove("overflow-hidden"),this.loggedInObserver&&this.loggedInObserver.unsubscribe(),this.usrPropChangedObserver&&this.usrPropChangedObserver.unsubscribe(),this.mutationObserver&&this.mutationObserver.disconnect(),this.hammer&&this.hammer.destroy(),this.resetImage();try{this.photoEditorMobService.destroy()}catch{}}resetImage(){this.photoEditorMobService.mainCanvas.getObjects("image")[0]&&(this.initialViewport&&(this.photoEditorMobService.mainCanvas.setViewportTransform([...this.initialViewport]),this.scale=this.photoEditorMobService.mainCanvas.getZoom()),this.photoEditorMobService.mainCanvas.requestRenderAll())}getActiveKey(t){this.animationState="out",this.activeKey=t,setTimeout(()=>{this.animationState="in",this.checkOverflow(this.contentBox.nativeElement),this.faceRetouchService.tabChange.next("Teeth"==t)},100)}touchstart(){this.isCompare=!0}touchend(){this.isCompare=!1}onPointerDown(){clearTimeout(this.compareTimeout),this.compareTimeout=setTimeout(()=>{this.isCompare=!0,this.updateOriginalImageTransform()},50)}updateOriginalImageTransform(){const t=this.photoEditorMobService.mainCanvas.getZoom(),i=this.photoEditorMobService.mainCanvas.viewportTransform;this.originalImg.nativeElement.style.transform=`matrix(${t}, 0, 0, ${t}, ${i[4]}, ${i[5]})`}onPointerUp(){clearTimeout(this.compareTimeout),this.isCompare=!1}download(){fetch(this.aiPhotoService.imgUrl).then(t=>{let i="jpg";const o=t.headers.get("Content-Type");o&&o.includes("image/")&&(i=o.split("/")[1]),this.photoEditorMobService.restoreResolution().then(r=>{const l=this.gestureService.exportCanvasIgnoringViewport(this.photoEditorMobService.mainCanvas);this.photoEditorMobService.download(i,f.Fs.FaceRetouch,"untitled",l),this.gtmService.pushTag({eventName:y.b.gtm.eventname.aiDownloadMob,itemName:"Editor_FaceRetouch"}),r&&r()})})}}return(s=a).\u0275fac=function(t){return new(t||s)(e.rXU(Z.s),e.rXU(q.u),e.rXU(ee.M),e.rXU(Ue.A),e.rXU(be),e.rXU(ie.y),e.rXU(b.aZ),e.rXU(Q.f),e.rXU(ne.A),e.rXU(re),e.rXU(ve),e.rXU(he.V),e.rXU(e.sFG))},s.\u0275cmp=e.VBU({type:s,selectors:[["ai-generate-v3"]],viewQuery:function(t,i){if(1&t&&(e.GBs(Pr,5),e.GBs(Ir,7),e.GBs(yt.R,5),e.GBs(vr,5),e.GBs(kt.H,5),e.GBs(St.O,5),e.GBs(Mt.J,5),e.GBs(yr,5),e.GBs(wr,5)),2&t){let o;e.mGM(o=e.lsd())&&(i.contentBox=o.first),e.mGM(o=e.lsd())&&(i.mainCanvas=o.first),e.mGM(o=e.lsd())&&(i.skintoolComponent=o.first),e.mGM(o=e.lsd())&&(i.shadeToolComponent=o.first),e.mGM(o=e.lsd())&&(i.shadeToolLipsComponent=o.first),e.mGM(o=e.lsd())&&(i.singleToolComponent=o.first),e.mGM(o=e.lsd())&&(i.shadeToolHairComponent=o.first),e.mGM(o=e.lsd())&&(i.originalImg=o.first),e.mGM(o=e.lsd())&&(i.compareContainer=o.first)}},inputs:{featureType:"featureType"},outputs:{changeStep:"changeStep"},features:[e.Jv_([he.V,re,Ie.r])],decls:15,vars:8,consts:[["mainCanvas",""],["compareContainer",""],["originalImg",""],["contentBox",""],[1,"mobileRetouch","overflow-hidden"],[1,"drawer-elements","ai-drawer-elements","overflow-hidden"],[1,"d-flex","align-items-center","justify-content-center","overflow-hidden","w-100","flex-column","pt-3","ps-3","pe-3","border-radius-12","position-relative",2,"height","calc(100vh - 410px
1)"],["id","canvasWrapper",1,"d-flex","align-items-center","justify-content-center","overflow-hidden","w-100","flex-column","h-100"],[1,"d-flex","align-items-center","justify-content-center","overflow-hidden","border-radius-12","position-relative","h-100","bg-grey3","w-100",2,"overflow","hidden","touch-action","none"],["id","vmx-canvas","height","100%","width","100%","disableRC","",1,"position-relative",3,"ngClass"],[1,"mw-100","mh-100",2,"overflow","hidden",3,"ngClass"],["disableRC","",3,"src",4,"ngIf"],["class","d-flex align-items-center justify-content-center position-absolute hw-40 border-radius-50","style","bottom: 8px; left: 8px; background: rgba(255, 255, 255, 0.4);",4,"ngIf"],["class","d-flex align-items-center justify-content-center position-absolute hw-40 border-radius-50 btn-alpha","style","top: 8px; right: 8px;",3,"click",4,"ngIf"],[1,"mt-3","tabPanelBox"],[4,"ngIf"],["disableRC","",3,"src"],[1,"d-flex","align-items-center","justify-content-center","position-absolute","hw-40","border-radius-50",2,"bottom","8px","left","8px","background","rgba(255, 255, 255, 0.4)"],["disableRC","","class","btn d-flex align-items-center justify-content-center border-0 disable-btn pe-none",4,"ngIf"],["class","btn d-flex align-items-center justify-content-center border-0",3,"pointerdown","pointerup","pointercancel","pointerleave",4,"ngIf"],["disableRC","",1,"btn","d-flex","align-items-center","justify-content-center","border-0","disable-btn","pe-none"],["name","compare",1,"f-24"],[1,"btn","d-flex","align-items-center","justify-content-center","border-0",3,"pointerdown","pointerup","pointercancel","pointerleave"],["name","compareactive",1,"f-24"],[1,"d-flex","align-items-center","justify-content-center","position-absolute","hw-40","border-radius-50","btn-alpha",2,"top","8px","right","8px",3,"click"],["name","downloadblack",1,"f-24","text-white"],[1,"",2,"height","calc(100% - 16px)"],[1,"d-flex","overflow-auto","new-scroll-behave","pb-2"],["class","ms-2",3,"id",4,"ngFor","ngForOf"],[1,"d-flex","flex-column","w-100","mobileRetouchStyle","pt-2",2,"height","calc(100% - 105px)",3,"ngClass"],[3,"ngClass","active","inputImage","originalImage",4,"ngIf"],[3,"ngClass","active","inputImage","uploadImageService","selectLayout",4,"ngIf"],[3,"ngClass","active","inputImage","selectLayout",4,"ngIf"],[3,"ngClass","toolName","active","inputImage","uploadImageService",4,"ngIf"],[1,"ms-2",3,"id"],[1,"d-flex","align-items-center","wp-100"],[1,"btn-acc-title","btnTab",3,"ngClass"],[1,"m-0","text-13","text-semi",3,"click"],[3,"ngClass","active","inputImage","originalImage"],[3,"selectLayout","ngClass","active","inputImage","uploadImageService"],[3,"selectLayout","ngClass","active","inputImage"],[3,"ngClass","toolName","active","inputImage","uploadImageService"]],template:function(t,i){1&t&&(e.j41(0,"div",4)(1,"div",5)(2,"div",6)(3,"div",7)(4,"div",8)(5,"canvas",9,0),e.EFF(7," Your browser does not support the HTML5 canvas tag. "),e.k0s(),e.j41(8,"div",10,1),e.DNE(10,kr,2,1,"img",11),e.k0s(),e.DNE(11,Er,3,2,"div",12)(12,jr,2,0,"div",13),e.k0s()()(),e.j41(13,"div",14),e.DNE(14,Dr,12,8,"ng-container",15),e.k0s()()()),2&t&&(e.R7$(5),e.Y8G("ngClass",e.eq3(6,Sr,i.isCompare)),e.R7$(3),e.Y8G("ngClass",i.isCompare?"d-flex":"d-none"),e.R7$(2),e.Y8G("ngIf",i.photoEditorMobService.originalImage),e.R7$(),e.Y8G("ngIf",i.isLoaded),e.R7$(),e.Y8G("ngIf",i.isLoaded),e.R7$(2),e.Y8G("ngIf",i.isLoaded))},dependencies:[b.YU,b.Sq,b.bT,Me.G,H.b,yt.R,St.O,Mt.J,kt.H],styles:[".prompt-view[_ngcontent-%COMP%]   .textarea-col[_ngcontent-%COMP%]{width:100%;height:204px;border-radius:12px;border:1px solid #E2E3E9;background:#eeedf3;padding:4px}.prompt-view[_ngcontent-%COMP%]   .textarea-col[_ngcontent-%COMP%]:hover{border:1px solid #B0B3BF}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]{resize:none;outline:none;width:100%;height:178px;padding:8px;font-size:12px;color:#b0b3bf;border:0px;background:transparent;border-radius:12px;line-height:18px;overflow:hidden}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]::-webkit-scrollbar{width:4px;height:4px;border-radius:12px}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]::-webkit-scrollbar-track{background:#e3e3e3;border-radius:12px}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background:#9a9a9a;border-radius:12px}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]::-webkit-scrollbar-thumb:hover{background:#555}.prompt-view[_ngcontent-%COMP%]   .prompt-info[_ngcontent-%COMP%]{font-size:11px;color:#b0b3bf;margin-top:0;padding-left:8px;line-height:10px}.btn[_ngcontent-%COMP%]:disabled{background:#d5d6dd;border:1px solid #D5D6DD}.btn[_ngcontent-%COMP%]:disabled   .coin-count[_ngcontent-%COMP%]   b[_ngcontent-%COMP%]{color:#fff!important}.new-scroll-behave[_ngcontent-%COMP%]{-ms-overflow-style:none;scrollbar-width:none}.new-scroll-behave[_ngcontent-%COMP%]::-webkit-scrollbar{display:none}.btnTab[_ngcontent-%COMP%]{border-radius:8px;border:1px solid #E2E3E9;background:#efeef2;padding:8px 16px;color:#272b34;width:100%!important;height:32px!important;line-height:normal}.btnTabActive[_ngcontent-%COMP%]{border:1px solid transparent;background:#626adf;color:#fff}#face-retouch-Skin[_ngcontent-%COMP%]{padding-left:8px}#face-retouch-Teeth[_ngcontent-%COMP%]{margin-right:16px}.mobileRetouchStyle[_ngcontent-%COMP%]{display:flex;transition:justify-content .4s ease}"]}),a})();var Y=m(79358),Xr=m(1408),Lr=(m(57942),m(65485),m(21413)),jt=m(28068),Yr=m(18050);const $r=["mainCanvas"],zr=(s,a)=>({height:s,width:a}),ot=s=>({"pe-none opacity-3":s}),Hr=s=>({btnTabActive:s});function Wr(s,a){if(1&s&&e.nrm(0,"img",16),2&s){const n=e.XpG();e.Y8G("ngStyle",e.l_i(2,zr,(null==n.photoEditorMobService||null==n.photoEditorMobService.mainCanvas?null:n.photoEditorMobService.mainCanvas.height)+"px",(null==n.photoEditorMobService||null==n.photoEditorMobService.mainCanvas?null:n.photoEditorMobService.mainCanvas.width)+"px"))("src",n.photoEditorMobService.originalImage.src,e.B4B)}}function qr(s,a){if(1&s&&e.nrm(0,"app-body-expander",19),2&s){const n=e.XpG(2);e.Y8G("mainCanvas",null==n.photoEditorMobService?null:n.photoEditorMobService.mainCanvas)("controlSize","sm")("mainCanvasNative",n.mainCanvasNative)("hidden",n.isCompare)("isRoundInstance2",!0)}}function Kr(s,a){if(1&s&&(e.qex(0),e.nrm(1,"app-body-expander",17),e.DNE(2,qr,1,5,"app-body-expander",18),e.bVm()),2&s){const n=e.XpG();e.R7$(),e.Y8G("mainCanvas",null==n.photoEditorMobService?null:n.photoEditorMobService.mainCanvas)("controlSize","sm")("mainCanvasNative",n.mainCanvasNative)("hidden",n.isCompare),e.R7$(),e.Y8G("ngIf",3==(null==n.activeKey?null:n.activeKey.type))}}function Zr(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",20),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.download())}),e.nrm(1,"pi",21),e.k0s()}}function Jr(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",22)(1,"div",23)(2,"button",24),e.bIt("pointerdown",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.isCompare=!0)})("pointerup",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.isCompare=!1)})("pointercancel",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.isCompare=!1)})("pointerleave",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.isCompare=!1)}),e.nrm(3,"ei",25),e.k0s()(),e.j41(4,"div",26),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.undoClicked())}),e.j41(5,"button",27),e.nrm(6,"pi",28),e.k0s()(),e.j41(7,"div",26),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.redoClicked())}),e.j41(8,"button",27),e.nrm(9,"pi",29),e.k0s()()()}if(2&s){const n=e.XpG();e.R7$(),e.Y8G("ngClass",e.eq3(3,ot,!n.isEdited)),e.R7$(3),e.Y8G("ngClass",e.eq3(5,ot,!n.isUndoable())),e.R7$(3),e.Y8G("ngClass",e.eq3(7,ot,!n.isRedoable()))}}function Qr(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",34)(1,"div",35)(2,"button",36)(3,"div",37),e.bIt("click",function(){const i=e.eBV(n).$implicit,o=e.XpG(2);return e.Njj(o.getActiveKey(i))}),e.EFF(4),e.k0s()()()()}if(2&s){const n=a.$implicit,t=e.XpG(2);e.FS9("id","body-reshape-"+n.name),e.R7$(2),e.Y8G("ngClass",e.eq3(3,Hr,(null==t.activeKey?null:t.activeKey.name)==n.name)),e.R7$(2),e.JRh(n.name)}}function ea(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",38,2)(2,"div",39)(3,"div",40)(4,"span",41),e.EFF(5,"Intensity"),e.k0s(),e.j41(6,"div",42)(7,"div",43)(8,"mv-slider",44),e.bIt("slideStop",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.stopIntensity(i))})("change",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.changeIntensity(i))}),e.k0s()(),e.j41(9,"div",45),e.nrm(10,"input",46),e.k0s()()()()()}if(2&s){const n=e.XpG(2);e.Y8G("ngClass",n.animationState),e.R7$(8),e.Y8G("min",n.activeKey.min)("max",n.activeKey.max)("step",1)("value",n.activeKey.val),e.R7$(2),e.Y8G("min",-100)("max",100)("ngModel",n.activeKey.val)}}function ta(s,a){if(1&s&&(e.qex(0),e.j41(1,"div",30)(2,"div",31),e.DNE(3,Qr,5,5,"div",32),e.k0s(),e.DNE(4,ea,11,8,"div",33),e.k0s(),e.bVm()),2&s){const n=e.XpG();e.R7$(3),e.Y8G("ngForOf",n.array),e.R7$(),e.Y8G("ngIf",n.activeKey)}}let ia=(()=>{var s;class a{constructor(t,i,o,r,l,c,d,h,p,u,g,_,v,C,M){var k=this;this.injector=t,this.uploadService=i,this.document=o,this.route=l,this.aiPhotoService=c,this.bodyReshapeService=d,this.uploadImageService=h,this.photoEditorMobService=p,this.photoEditorSahredService=u,this.location=g,this.toastService=_,this.authService=v,this.undoRedoProcessService=C,this.gtmService=M,this.restAndApplyEvent=new e.bkB,this.array=[{name:"Tall",val:0,min:-100,max:100,type:Y.J.Tall},{name:"Slim",val:0,min:-100,max:100,type:Y.J.Slim},{name:"Head",val:0,min:-100,max:100,type:Y.J.Head},{name:"Breast",val:0,min:-100,max:100,type:Y.J.Breast},{name:"Belly",val:0,min:-100,max:100,type:Y.J.Belly},{name:"Waist",val:0,min:0,max:100,type:Y.J.Waist}],this.isCompare=!1,this.originalWidth=0,this.originalHeight=0,this.stateHistory=[],this.currentStateIndex=-1,this.expandWidth=0,this.expandHeight=0,this.activePanels="panel1",this.imageScaleFactor=.85,this.stopIntensityFlag=!1,this.isIntensityDebouncePending=!1,this.original={width:0,height:0},this.isEdited=!1,this.sliderChangeIntencity=new Lr.B,r.closeOthers=!0,this.user=this.authService.currentUser(),this.loggedInObserver=this.authService.loggedIn.subscribe(j=>{this.user=this.authService.currentUser()}),this.onChangeObserv=this.bodyReshapeService.onChange.subscribe(j=>{(j&&"startResize"===j.name||j&&"startDrag"===j.name)&&(this.resetValues(),this.applyImage())}),this.uploadImageServiceAfterImageLoadSub=this.uploadImageService.afterImageLoad.subscribe(j=>{j&&(this.bodyReshapeService.setOnChange("bodyPartType",{type:-1}),this.resetUndoRedo(),this.resetValues(),setTimeout(()=>{this.ngOnInit()},0))}),this.aiPhotoService.applyToSaveFn=(0,w.A)(function*(){k.photoEditorSahredService.applyToSave(k.photoEditorMobService.originalImage,k.photoEditorMobService.mainCanvas,j=>{k.aiPhotoService.imgUrl=j.uri,k.aiPhotoService.queryParams.imgUrl=j.uri},!0,{activeTool:f.z6.Portrait,activeSubTool:f.Fs.BodyReshape})})}ngOnInit(){const t=this.aiPhotoService.imgUrl,i=this.mainCanvas.nativeElement;this.mainCanvasNative=this.mainCanvas,this.aiPhotoService.startProcessingProgress({featureType:"aireshape",indeterminate:!0}),this.photoEditorMobService.mainCanvas&&this.photoEditorMobService.mainCanvas.clear(),this.photoEditorMobService.loadInputImage(t,i,(
1)=>{this.isLoaded=!0,this.inputImage=this.photoEditorMobService.inputImage,!this.originalHeight&&this.inputImage&&(this.originalHeight=this.inputImage.height,this.originalWidth=this.inputImage.width),this.setOriginalImageWH(this.inputImage.width,this.inputImage.height),this.recordState(this.inputImage.getElement().src)},()=>{this.aiPhotoService.clearGenerationProgress(),this.toastService.showError(y.b.message.oppsSomethingWrong),this.location.back()},1024,1024,!0),this.subscriptions=this.sliderChangeIntencity.pipe((0,Ot.B)(30)).subscribe(o=>{this.inputIntensity(o.val,o),this.isIntensityDebouncePending=!1,this.stopIntensityFlag&&(this.stopIntensityFlag=!1,this.bakeFiltersAndReplaceImage())})}ngAfterViewInit(){setTimeout(()=>{this.aiPhotoService.completeGenerationProgress(),this.getActiveKey(this.array[0])},2e3)}resetValues(){for(let t=0;t<this.array.length;t++)this.array[t].val=0}resetUndoRedo(){this.stateHistory=[],this.currentStateIndex=-1}onPanelChange(t){var i=this;return(0,w.A)(function*(){let o=-1;switch(yield i.applyImage(),t){case"Tall":o=Y.J.Tall,i.fitToScreenByPercent(15);break;case"Slim":o=Y.J.Slim,i.fitToScreenByPercent(15);break;case"Head":o=Y.J.Head,i.makeFit();break;case"Breast":o=Y.J.Breast,i.makeFit();break;case"Belly":o=Y.J.Belly,i.makeFit();break;case"Waist":o=Y.J.Waist,i.makeFit();break;default:o=Y.J.None,i.makeFit()}i.controlType=o,setTimeout(()=>{i.bodyReshapeService.setOnChange("bodyPartType",{type:o})}),i.resetValues()})()}makeFit(){this.setOriginalImageWH(),this.fitToScreen(!1)}changeZoom(){}inputIntensity(t,i){this.isEdited=!0;let o=t;o=t/100,o=-o/10,"Slim"===i.name?this.refreshSlim(t/400*((1-this.imageScaleFactor)*this.originalWidth)):"Tall"===i.name?this.refreshTall(t/400*((1-this.imageScaleFactor)*this.originalHeight)):(this.inputImage.filters&&this.inputImage.filters.length>0?"Waist"===i.name?this.inputImage.filters[0].radiusInput&&(this.inputImage.filters=[],this.addShader(i)):this.inputImage.filters[0].warpScale&&(this.inputImage.filters=[],this.addShader(i)):this.addShader(i),this.refreshShader(i,o))}addShader(t){t.type===Y.J.Head?this.addHeadShader():t.type===Y.J.Breast?this.addHeadShader(!0):t.type===Y.J.Belly?this.addHeadShader():t.type===Y.J.Waist&&this.addWaistShader()}refreshShader(t,i){t.type===Y.J.Head?this.refreshHeadShader(i):t.type===Y.J.Breast?this.refreshHeadShader(i,!0):t.type===Y.J.Belly?this.refreshHeadShader(i):t.type===Y.J.Waist&&this.refreshWaistShader(i)}ngOnDestroy(){this.onChangeObserv&&this.onChangeObserv.unsubscribe(),this.uploadImageServiceAfterImageLoadSub&&this.uploadImageServiceAfterImageLoadSub.unsubscribe(),this.loggedInObserver&&this.loggedInObserver.unsubscribe(),this.subscriptions&&this.subscriptions.unsubscribe();try{this.photoEditorMobService.destroy()}catch{}}isUndoable(){return this.currentStateIndex>0}isRedoable(){return this.currentStateIndex<this.stateHistory.length-1}addAndRemoveImage(t,i=null){I.fabric.Image.fromURL(t,o=>{let r=o.height,l=o.width,c=this.photoEditorMobService.mainCanvas;c.setHeight(r*c.getZoom()),c.setWidth(l*c.getZoom());let d=this.inputImage;c.clear(),c.remove(d),o.set({selectable:!1,evented:!1}),c.add(o),this.inputImage=o,c.renderAll(),this.setOriginalImageWH(l,r),this.bodyReshapeService.setOnChange("setPos",{}),this.resetValues()},{crossOrigin:"anonymous"})}undoClicked(){this.undoRedoProcessService.executeSyncWithProtection(()=>(this.currentStateIndex>0&&(this.currentStateIndex--,this.addAndRemoveImage(this.stateHistory[this.currentStateIndex]),this.slimOrTallImage=null,this.bodyReshapeService.setOnUndoRedo()),!0))}redoClicked(){this.undoRedoProcessService.executeSyncWithProtection(()=>(this.currentStateIndex<this.stateHistory.length-1&&(this.currentStateIndex++,this.addAndRemoveImage(this.stateHistory[this.currentStateIndex]),this.slimOrTallImage=null,this.bodyReshapeService.setOnUndoRedo()),!0))}resetAll(){}bakeFiltersAndReplaceImage(){if(this.controlType===Y.J.Slim||this.controlType===Y.J.Tall){const t=this.photoEditorMobService.mainCanvas;let i=t.getZoom();const r=1*t.height/i;1*t.width/i>T.lL?i=t.width/T.lL:r>T.iB&&(i=t.height/T.iB);const l=t.toDataURL({multiplier:1/i});this.recordState(l)}else{const t=this.photoEditorMobService.mainCanvas,i=t.toDataURL({multiplier:1/t.getZoom()});this.recordState(i),I.fabric.Image.fromURL(i,o=>{this.slimOrTallImage=o})}}recordState(t){t&&(this.currentStateIndex<this.stateHistory.length-1&&(this.stateHistory=this.stateHistory.slice(0,this.currentStateIndex+1)),this.currentStateIndex++,this.stateHistory.push(t))}stopIntensity(t){let i=this.activeKey;("Slim"===i.name||"Tall"===i.name)&&this.bodyReshapeService.setOnChange("visibility",{type:this.controlType}),this.isIntensityDebouncePending?this.stopIntensityFlag=!0:this.bakeFiltersAnd
1ReplaceImage()}applyImage(){var t=this;return(0,w.A)(function*(){if(t.slimOrTallImage){const i=t.slimOrTallImage.getElement();(i.width>T.lL||i.height>T.iB)&&(t.slimOrTallImage=yield new Promise((r,l)=>{fe.k.checkAndResizeImage(i,h=>{r(new I.fabric.Image(h))},T.lL,T.iB)}));let o=t.photoEditorMobService.mainCanvas.width/t.slimOrTallImage.width;o=t.slimOrTallImage.width>t.slimOrTallImage.height?t.photoEditorMobService.mainCanvas.width/t.slimOrTallImage.width:t.photoEditorMobService.mainCanvas.height/t.slimOrTallImage.height,t.photoEditorMobService.mainCanvas.setZoom(o),t.photoEditorMobService.mainCanvas.remove(t.inputImage),t.inputImage=t.slimOrTallImage,t.slimOrTallImage=null,t.setOriginalImageWH(),t.inputImage.set({selectable:!1,evented:!1}),t.photoEditorMobService.mainCanvas.add(t.inputImage),t.photoEditorMobService.mainCanvas.requestRenderAll()}})()}setOriginalImageWH(t=this.inputImage.width,i=this.inputImage.height){this.original.width=t,this.original.height=i}changeIntensity(t){let l,c,i=this.activeKey;("Slim"===i.name||"Tall"===i.name)&&this.bodyReshapeService.setOnChange("visibility",{type:-1}),t.hasOwnProperty("newValue")?(l=t.newValue,c=!1):(l=t,c=!0),""!==l&&!Number.isNaN(Number(l))&&(l>100?(i.val=100,this.isIntensityDebouncePending=!0,this.sliderChangeIntencity.next(i)):l<-100?(i.val=-100,this.isIntensityDebouncePending=!0,this.sliderChangeIntencity.next(i)):(i.val=l,this.isIntensityDebouncePending=!0,this.sliderChangeIntencity.next(i)))}addHeadShader(t=!1){var i=new I.fabric.Image.filters.FaceReshape({radiusInput:.3,centreX:.5,centreY:.5,radiusInput2:.3,centreX2:.7,centreY2:.5,width:this.inputImage.width,height:this.inputImage.height,alphaVal:0,brightness:0,breastMode:0});this.inputImage.filters.push(i),this.inputImage.applyFilters(),this.inputImage.canvas.renderAll()}addWaistShader(){var t=new I.fabric.Image.filters.WaistReshape({originx:0,originy:0,rectWidth:1,rectHeight:1,warpScale:-200});this.inputImage.filters.push(t),this.inputImage.applyFilters(),this.inputImage.canvas.renderAll()}addTallShader(){var t=new I.fabric.Image.filters.HeightReshape({u_y1:0,u_y2:.5,u_stretch_factor:1.2});this.inputImage.filters.push(t),this.inputImage.applyFilters(),this.inputImage.canvas.renderAll()}refreshWaistShader(t){let i=this.bodyReshapeService.clientRectangle,o=(i.left-32/this.photoEditorMobService.mainCanvas.getZoom())/this.inputImage.width,r=i.top/this.inputImage.height,l=(i.right-i.left+64/this.photoEditorMobService.mainCanvas.getZoom())/this.inputImage.width,c=(i.bottom-i.top)/this.inputImage.height;this.inputImage.filters[0].warpScale=.2*t,this.inputImage.filters[0].originx=o,this.inputImage.filters[0].originy=r,this.inputImage.filters[0].rectWidth=l,this.inputImage.filters[0].rectHeight=c,this.inputImage.applyFilters(),this.inputImage.canvas.renderAll()}refreshHeadShader(t,i=!1){let o=this.bodyReshapeService.clientRectangle,r=o.centerX/this.inputImage.width,l=o.centerY/this.inputImage.height,c=Math.max(this.inputImage.width,this.inputImage.height),d=o.radius/c;if(this.inputImage.filters[0].alphaVal=t,this.inputImage.filters[0].centreX=r,this.inputImage.filters[0].centreY=l,this.inputImage.filters[0].radiusInput=d,i){let h=o.centerX2/this.inputImage.width,p=o.centerY2/this.inputImage.height,u=Math.max(this.inputImage.width,this.inputImage.height),g=o.radius2/u;this.inputImage.filters[0].centreX2=h,this.inputImage.filters[0].centreY2=p,this.inputImage.filters[0].radiusInput2=g,this.inputImage.filters[0].breastMode=1}else this.inputImage.filters[0].breastMode=0;this.inputImage.applyFilters(),this.inputImage.canvas.renderAll()}refreshSlim(t){this.originalHeight=this.inputImage.height,this.originalWidth=this.inputImage.width;let i=this.photoEditorMobService.mainCanvas;i.setWidth((this.originalWidth+t)*i.getZoom()),i.remove(this.inputImage),i.clear();const r=this.getSlimImage(t);this.slimOrTallImage=r,r&&(i.add(r),i.renderAll())}refreshTall(t){this.originalHeight=this.inputImage.height,this.originalWidth=this.inputImage.width;let i=this.photoEditorMobService.mainCanvas;i.setHeight((this.originalHeight+t)*i.getZoom()),i.remove(this.inputImage),i.clear();const r=this.getTallImage(t);this.slimOrTallImage=r,r&&(i.add(r),i.renderAll())}getSlimImage(t){let i=this.bodyReshapeService.clientRectangle,o=i.left,r=i.right,l=this.originalWidth,c=this.originalHeight,d=this.inputImage;if(!this.inputImage)return;const h=l+t,p=this.document.createElement("canvas");p.width=h,p.height=c;const u=p.getContext("2d");u.drawImage(d.getElement(),0,0,o,c,0,0,o,c);const g=r+1-o,_=g+t;return u.drawImage(d.getElement(),o,0,g,c,o,0,_,c),u.drawImage(d.getElement(),r,0,l-r,c,r+t,0,l-r,c),new I.fabric.Image(p,{left:0,top:0,selectable:!1})}getActiveKey(t){this.animationState="out",this.activeKey=t,setTimeout(()=>{this.animationState="in"},100),this.onPanelChange(t.name)}getTallImage(t){if(!this.inputImage)return;const i=this.originalHeight+t;let o=this.bodyReshapeService.clientRectangle;const r=document.createElement("canvas");r.width=this.originalWidth,r.height=i;const l=r.getContext("2d");let c=this.inputImage,d=this.originalWidth,h=this.originalHeight,p=o.top,u=o.bottom;l.drawImage(c.getElement(),0,0,d,p,0,0,d,p);const g=u+1-p,_=g+t;return l.drawImage(c.getElement(),0,p,d,g,0,p,d,_),l.drawImage(c.getElement(),0,u,d,h-u,0,u+t,d,h-u),new I.fabric.Image(r,{left:0,top:0,selectable:!1})}download(){fetch(this.aiPhotoService.imgUrl).then(t=>{let i="jpg";const o=t.headers.get("Content-Type");o&&o.includes("image/")&&(i=o.split("/")[1]),this.photoEditorMobService.download(i),this.gtmService.pushTag({eventName:y.b.gtm.eventname.aiDownloadMob,itemName:"Editor_BodyReshape"})})}
1calcWrapperSize(){const t=document.getElementById("canvasWrapper");if(t){const i=t.getBoundingClientRect();return{width:i.width,height:i.height}}return{width:100,height:100}}fitToScreen(t=null){const i=this.calcWrapperSize();let o,r,l;i.width>768?(o=i.width-200,r=i.height-20):(o=i.width,r=i.height),l=this.original?Math.min(r/this.original.height,o/this.original.width):1,this.set(l,!0)}fitToScreenByPercent(t,i=null){const o=this.calcWrapperSize();let r,l,c;o.width>768?(r=o.width-200,l=o.height-20):(r=o.width,l=o.height),c=this.original?Math.min(l/this.original.height,r/this.original.width):1,c-=15*c/100,this.set(c,!0)}set(t,i=!0){const o=this.original.width*t,r=this.original.height*t;this.photoEditorMobService.mainCanvas.setZoom(t),i&&(this.photoEditorMobService.mainCanvas.setHeight(r),this.photoEditorMobService.mainCanvas.setWidth(o))}}return(s=a).\u0275fac=function(t){return new(t||s)(e.rXU(e.zZn),e.rXU(Et.B),e.rXU(b.qQ),e.rXU(R.iM),e.rXU(A.nX),e.rXU(Z.s),e.rXU(Y.E),e.rXU(Ue.A),e.rXU(re),e.rXU(be),e.rXU(b.aZ),e.rXU(Q.f),e.rXU(q.u),e.rXU(jt.V),e.rXU(ie.y))},s.\u0275cmp=e.VBU({type:s,selectors:[["body-reshape"]],viewQuery:function(t,i){if(1&t&&e.GBs($r,7),2&t){let o;e.mGM(o=e.lsd())&&(i.mainCanvas=o.first)}},outputs:{restAndApplyEvent:"restAndApplyEvent"},features:[e.Jv_([R.iM,Y.E,Xr.x,re,Ie.r,he.V,jt.V])],decls:17,vars:7,consts:[["mainCanvas",""],["compareContainer",""],["contentBox",""],[1,"mobileRetouch","overflow-hidden"],[1,"drawer-elements","ai-drawer-elements","overflow-hidden"],[1,"d-flex","align-items-center","justify-content-center","overflow-hidden","w-100","flex-column","pt-3","ps-3","pe-3","border-radius-12","position-relative",2,"height","calc(100vh - 300px)"],["id","canvasWrapper",1,"d-flex","align-items-center","justify-content-center","overflow-hidden","w-100","flex-column","h-100"],[1,"d-flex","align-items-center","justify-content-center","overflow-hidden","border-radius-12","position-relative","h-100","bg-grey3","w-100",2,"overflow","hidden","touch-action","none"],[1,"position-relative","d-flex"],["id","vmx-canvas","height","100%","width","100%","disableRC","",1,"position-relative",3,"hidden"],[1,"mw-100","mh-100","w-100","compare-stack",2,"overflow","hidden",3,"hidden"],["class","","disableRC","",3,"ngStyle","src",4,"ngIf"],[4,"ngIf"],["class","d-flex align-items-center justify-content-center position-absolute hw-40 border-radius-50 btn-alpha","style","top: 24px; right: 24px; z-index: 10;",3,"click",4,"ngIf"],["class","d-flex align-items-center ps-3 pe-3 mt-8",4,"ngIf"],[1,"mt-3","tabPanelBox","h-100"],["disableRC","",1,"",3,"ngStyle","src"],[3,"mainCanvas","controlSize","mainCanvasNative","hidden"],[3,"mainCanvas","controlSize","mainCanvasNative","hidden","isRoundInstance2",4,"ngIf"],[3,"mainCanvas","controlSize","mainCanvasNative","hidden","isRoundInstance2"],[1,"d-flex","align-items-center","justify-content-center","position-absolute","hw-40","border-radius-50","btn-alpha",2,"top","24px","right","24px","z-index","10",3,"click"],["name","downloadblack",1,"f-24","text-white"],[1,"d-flex","align-items-center","ps-3","pe-3","mt-8"],[1,"d-flex","align-items-center","justify-content-center","hw-32","border-radius-50","btn-alpha","p-1",3,"ngClass"],[1,"btn","d-flex","align-items-center","justify-content-center","border-0","bg-transparent","p-0",3,"pointerdown","pointerup","pointercancel","pointerleave"],["name","comparenew",1,"f-24","text-white"],[1,"d-flex","align-items-center","justify-content-center","hw-32","border-radius-50","ms-2","btn-alpha","p-1",3,"click","ngClass"],[1,"btn","d-flex","align-items-center","justify-content-center","border-0","bg-transparent","p-0"],["name","undo",1,"f-24","text-white"],["name","redo",1,"f-24","text-white"],[1,"",2,"height","calc(100%)"],[1,"d-flex","overflow-auto","new-scroll-behave","mb-2",2,"height","32px"],["class","ms-2",3,"id",4,"ngFor","ngForOf"],["class","d-flex flex-column w-100 mobileRetouchStyle pt-2",3,"ngClass",4,"ngIf"],[1,"ms-2",3,"id"],[1,"d-flex","align-items-center","wp-100"],[1,"btn-acc-title","btnTab",3,"ngClass"],[1,"m-0","text-13","text-semi",3,"click"],[1,"d-flex","flex-column","w-100","mobileRetouchStyle","pt-2",3,"ngClass"],[1,"common-container"],[1,"card-body"],[1,"text-13","grey-800","text-semi"],[1,"d-flex"],[1,"wp-100","d-flex","align-items-center"],[1,"opacity-slider",2,"width","100%",3,"slideStop","change","min","max","step","value"],[1,"ms-3"],["type","text","numberSettings","","maxlength","4","disabled","","mask","separator.2","separatorLimit","100",1,"form-control","form-input-sm","text-normal","text-black",2,"pointer-events","none",3,"min","max","ngModel"]],template:function(t,i){1&t&&(e.j41(0,"div",3)(1,"div",4)(2,"div",5)(3,"div",6)(4,"div",7)(5,"div",8)(6,"canvas",9,0),e.EFF(8," Your browser does not support the HTML5 canvas tag. "),e.k0s(),e.j41(9,"div",10,1),e.DNE(11,Wr,1,5,"img",11),e.k0s(),e.DNE(12,Kr,3,5,"ng-container",12),e.k0s()(),e.DNE(13,Zr,2,0,"div",13),e.k0s()(),e.DNE(14,Jr,10,9,"div",14),e.j41(15,"div",15),e.DNE(16,ta,5,2,"ng-container",12),e.k0s()()()),2&t&&(e.R7$(6),e.Y8G("hidden",i.isCompare),e.R7$(3),e.Y8G("hidden",!i.isCompare),e.R7$(2),e.Y8G("ngIf",i.photoEditorMobService.originalImage),e.R7$(),e.Y8G("ngIf",i.isLoaded),e.R7$(),e.Y8G("ngIf",i.isLoaded),e.R7$(),e.Y8G("ngIf",i.isLoaded),e.R7$(2),e.Y8G("ngIf",i.isLoaded))},dependencies:[b.YU,b.Sq,b.bT,b.B3,Me.G,Ge.I,P.me,P.BC,P.tU,P.vS,H.b,O.d1,Yr.y,Se.KK],styles:[".btn[_ngcontent-%COMP%]:disabled{background:#d5d6dd;border:1px solid #D5D6DD}.btn[_ngcontent-%COMP%]:disabled   .coin-count[_ngcontent-%COMP%]{background:#0000001a}.btn[_ngcontent-%COMP%]:disabled   .coin-count[_ngcontent-%COMP%]   b[_ngcontent-%COMP%]{color:#fff!important}.btn[_ngcontent-%COMP%]:disabled   .inable[_ngcontent-%COMP%]{display:none}.btn[_ngcontent-%COMP%]:disabled   .disable[_ngcontent-%COMP%]{display:block}.new-scroll-behave[_ngcontent-%COMP%]{-ms-overflow-style:none;scrollbar-width:none}.new-scroll-behave[_ngcontent-%COMP%]::-webkit-scrollbar{display:none}.btnTab[_ngcontent-%COMP%]{border-radius:8px;border:1px solid #E2E3E9;background:#efeef2;padding:0 16px;color:#272b34;width:100%!important;height:32px!important;line-height:normal;justify-content:center}.btnTabActive[_ngcontent-%COMP%]{border:1px solid transparent;background:#626adf;color:#fff}#face-retouch-Skin[_ngcontent-%COMP%]{padding-left:8px}#face-retouch-Teeth[_ngcontent-%COMP%]{margin-right:16px}.mobileRetouchStyle[_ngcontent-%COMP%]{display:flex;transition:justify-content .4s ease}#body-reshape-Tall[_ngcontent-%COMP%]{margin-left:16px!important}#body-reshape-Waist[_ngcontent-%COMP%]{margin-right:16px}.icon-stack[_ngcontent-%COMP%]{background:#0000001a}.icon-stack[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]{color:#272b34!important}.icon-stack[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]:disabled{color:#b0b3bf!important}.icon-stack[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]:disabled   pi[_ngcontent-%COMP%]{color:#b0b3bf!important}.compare-stack[_ngcontent-%COMP%]   img[_ngcontent-%COMP%]{object-fit:contain;height:100%;width:100%}"]}),a})();var st=m(18770),Gt=m(19282),rt=m(12658),Ce=m(95894),Vt=m(41067);const na=["contentBox"],oa=["file"],sa=["mainCanvas"],ra=["originalImg"],aa=["compareContainer"],la=s=>({"d-none":s}),Rt=s=>({"pe-none reseticon-none":s}),ca=s=>({btnTabActive:s}),da=s=>({height:s});function ha(s,a){if(1&s&&e.nrm(0,"img",18,3),2&s){const n=e.XpG();e.Y8G("src",n.photoEditorMobService.originalImage.src,e.B4B)}}function pa(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",19)(1,"button",20),e.bIt("pointerdown",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.onPointerDown())})("pointerup",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.onPointerUp())})("pointercancel",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.onPointerUp())})("pointerleave",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.onPointerUp())}),e.nrm(2,"pi",21),e.k0s()()}if(2&s){const n=e.XpG();e.Y8G("ngClass",e.eq3(1,Rt,!n.isEdit))}}function ma(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",22),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.resetAll())}),e.j41(1,"button",23),e.nrm(2,"ei",24),e.k0s()()}if(2&s){const n=e.XpG();e.Y8G("ngClass",e.eq3(1,Rt,!n.isEdit))}}function ua(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",25),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.download())}),e.nrm(1,"pi",26),e.k0s()}}function ga(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",32)(1,"div",33)(2,"buttons-scroll-menu",34),e.bIt("selectMenu",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.selectFaceImg(i))}),e.k0s()()()}if(2&s){const n=e.XpG(2);e.R7$(2),e.Y8G("type","faceExpression")("categoryId",null==n.selectedFace?null:n.selectedFace.id)("items",n.faceDataList)}}function _a(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",35)(1,"div",36)(2,"button",37)(3,"div",38),e.bIt("click",function(){const i=e.eBV(n).$implicit,o=e.XpG(2);return e.Njj(o.activeTool=i)}),e.EFF(4),e.k0s()()()()}if(2&s){const n=a.$implicit,t=e.XpG(2);e.FS9("id","face-retouch-"+n.toolName),e.R7$(2),e.Y8G("ngClass",e.eq3(3,ca,(null==t.activeTool?null:t.activeTool.toolName)==n.toolName)),e.R7$(2),e.JRh(n.toolName)}}function fa(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",42)(1,"span",43),e.EFF(2),e.nrm(3,"pei",44),e.k0s(),e.j41(4,"div",45)(5,"div",46)(6,"mv-slider",47),e.bIt("slideStop",function(i){const o=e.eBV(n).$implicit,r=e.XpG(3);return e.Njj(r.stopIntensity(i,o))})("change",function(i){const o=e.eBV(n).$implicit,r=e.XpG(3);return e.Njj(r.changeIntensity(i,o))})("slideStart",function(i){const o=e.eBV(n).$implicit,r=e.XpG(3);return e.Njj(r.slideStart(i,o))}),e.k0s()(),e.j41(7,"div",48),e.nrm(8,"input",49),e.k0s()()()}if(2&s){const n=a.$implicit,t=e.XpG(3);e.R7$(2),e.JRh(n.toolName),e.R7$(),e.FS9("name",n.icon),e.R7$(3),e.Y8G("min",n.min)("max",n.max)("step",1)("value",null==t.selectedFace?null:t.selectedFace.toolValues.get(n.subToolId)
1),e.R7$(2),e.Y8G("min",n.min)("max",n.max)("ngModel",null==t.selectedFace?null:t.selectedFace.toolValues.get(n.subToolId))}}function va(s,a){if(1&s&&(e.j41(0,"div",39)(1,"div",40),e.DNE(2,fa,9,9,"div",41),e.k0s()()),2&s){const n=e.XpG(2);e.Y8G("ngStyle",e.eq3(2,da,(null==n.faceDataList?null:n.faceDataList.length)>1?"calc(100% - 150px)":"calc(100% - 60px)")),e.R7$(2),e.Y8G("ngForOf",null==n.activeTool?null:n.activeTool.subToolArray)}}function ba(s,a){if(1&s&&(e.qex(0),e.DNE(1,ga,3,3,"div",27),e.j41(2,"div",28)(3,"div",29),e.DNE(4,_a,5,5,"div",30),e.k0s(),e.DNE(5,va,3,4,"div",31),e.k0s(),e.bVm()),2&s){const n=e.XpG();e.R7$(),e.Y8G("ngIf",(null==n.faceDataList?null:n.faceDataList.length)>1),e.R7$(3),e.Y8G("ngForOf",n.faceExpressionTools),e.R7$(),e.Y8G("ngIf",n.activeTool)}}let Ca=(()=>{var s;class a{constructor(t,i,o,r,l,c,d,h,p,u,g,_,v,C,M,k){var j=this;this.aiPhotoService=t,this.authService=i,this.aiUploadImageService=o,this.uploadImageService=r,this.photoEditorSahredService=l,this.location=c,this.toastService=d,this.createPopupService=h,this.photoEditorMobService=p,this.faceRetouchService=u,this.faceExpressionService=g,this.stateService=_,this.dialogService=v,this.zoomService=C,this.gtmService=M,this.gestureService=k,this.changeStep=new e.bkB,this.disabled=!1,this.isProUser=!1,this.isCompare=!1,this.subToolId=null,this.subToolValue=null,this.updateCounter=0,this.selectedFace=null,this.detectionsResult=null,this.uploadImageScaleFactor=2,this.containerId="canvas-mask-wrapper",this.ismodel=!1,this.isSliderstart=!1,this.faceDataList=[],this.faceExpressionTools=Gt.zp,this.faceExpressionSubToolMap=new Map,this.isEdit=!1,this.scale=1,this.initialScale=0,this.pinchStartScale=1,this.lastZoom=1,this.lastPan={x:0,y:0},this.isPanning=!1,this.oldValue=null,this.user=this.authService.currentUser(),this.faceExpressionService.setServices(this.zoomService),this.faceExpressionTools.forEach(G=>{G.subToolArray.forEach(U=>{this.faceExpressionSubToolMap.set(U.subToolId,U)})}),this.loggedInObserver=this.authService.loggedIn.subscribe(G=>{this.user=this.authService.currentUser(),this.isProUser=this.aiPhotoService.isProUser()}),this.usrPropChangedObserver=this.authService.usrPropChanged.subscribe(G=>{this.user=this.authService.currentUser(),this.isProUser=this.aiPhotoService.isProUser()}),this.updateBehaviorUserAiConis=this.authService.updateBehaviorUserAiConis.subscribe(G=>{this.user=this.authService.currentUser(),this.isProUser=this.aiPhotoService.isProUser()}),this.aiPhotoService.applyToSaveFn=(0,w.A)(function*(){j.faceBoundingBox&&j.photoEditorMobService.mainCanvas.remove(j.faceBoundingBox),j.resetImage(),j.photoEditorSahredService.applyToSave(j.photoEditorMobService.originalImage,j.photoEditorMobService.mainCanvas,G=>{j.aiPhotoService.imgUrl=G.uri,j.aiPhotoService.queryParams.imgUrl=G.uri,j.faceExpressionService.checkandupdateFaceBoundingBox(),j.faceBoundingBox=j.faceExpressionService.faceBoundingBox},!1,{activeTool:f.z6.Portrait,activeSubTool:f.Fs.FaceExpression})})}ngOnInit(){this.toolName=this.aiPhotoService?.queryParams?.tab,this.isLoaded=!0,this.aiPhotoService.startProcessingProgress({featureType:"expression",indeterminate:!0}),this.loadInputImage()}loadInputImage(){this.photoEditorMobService.mainCanvas&&(this.photoEditorMobService.mainCanvas.clear(),this.photoEditorMobService.mainCanvas.renderAll()),this.photoEditorMobService.loadInputImage(this.aiPhotoService.imgUrl,this.mainCanvas.nativeElement,()=>{this.inputImage=this.photoEditorMobService.inputImage;const t=document.getElementById("canvasWrapper");this.zoomService.setCanvas(this.photoEditorMobService.mainCanvas,t),this.photoEditorMobService.mainCanvas&&this.photoEditorMobService.mainCanvas.viewportTransform&&(this.initialViewport=[...this.photoEditorMobService.mainCanvas.viewportTransform]),this.detectFaces().then(()=>{this.setScaleVar()})},()=>{this.aiPhotoService.clearGenerationProgress(),this.toastService.showError(y.b.message.somethingWrong),this.location.back()},T.ms,T.HI,!1)}detectFaces(){var t=this;return(0,w.A)(function*(i=!0){yield function(){var r=(0,w.A)(function*(){try{let l=t.photoEditorMobService.originalImage;yield t.faceExpressionService.loadModels();let c=yield t.faceExpressionService.detectFacesFaceApi(l),d=c.detections;t.detectionsResult=d,i&&(t.faceDataList=[],t.faceDataList=yield t.faceExpressionService.createFaceList(d,t.photoEditorMobService.originalImage,t.uploadImageScaleFactor));const h=t.photoEditorMobService.calcWrapperSize();t.faceDataList.length>0?(t.faceExpressionService.mainCanvas=t.photoEditorMobService.mainCanvas,yield t.faceExpressionService.getBiggestFace(c,t.containerId,h),t.selectedFace=t.faceExpressionService.selectedFace,t.faceBoundingBox=t.faceExpressionService.faceBoundingBox,t.activeTool=t.faceExpressionTools[0],t.aiPhotoService.completeGenerationProgress(),t.isNewSelection=!0):t.displayErrorMsg({description:y.b.message.faceNotFound}),t.setZoomPinch()}catch(l){t.aiPhotoService.clearGenerationProgress(),t.toastService.showError("Face detection failed: "+l.message)}});return function(){return r.apply(this,arguments)}}()()}).apply(this,arguments)}inputIntensity(t,i){var o=this;return(0,w.A)(function*(){o.isEdit=!0,o.selectedFace.toolValues.set(i.subToolId,t),o.faceBoundingBox&&o.photoEditorMobService.mainCanvas.remove(o.faceBoundingBox),yield o.uploadAndGenrate(i),o.faceBoundingBox&&o.photoEditorMobService.mainCanvas.remove(o.faceBoundingBox),o.faceDataList.length>1&&o.isNewSelection&&(o.isNewSelection=!1,yield o.faceExpressionService.cutlatestfaces(!0)),yield o.faceExpressionService.putImageOnCanvas(),o.faceExpressionService.getFacesWithNonZeroToolValues(),o.faceDataList.length>1&&o.faceExpressionService.putlatestfacesoncanvas(),o.photoEditorMobService.mainCanvas.renderAll(),o.faceExpressionService.checkandupdateFaceBoundingBox()})()}changeIntensity(t,i=null){if(t.hasOwnProperty("oldValue")&&!this.isSliderstart){let d=t.oldValue;this.isSliderstart=!0,this.selectedFace.toolpreviousValues.set(i.subToolId,d)}let l,c;t.hasOwnProperty("newValue")?(l=t.newValue,c=!1):(l=t,c=!0),""!==l&&!Number.isNaN(Number(l))&&(l>100?l=100:l<-100&&(l=-100),this.selectedFace.toolValues.set(i.subToolId,l))}stopIntensity(t,i){let l,c;if(t.hasOwnProperty("newValue")?(l=t.newValue,c=!1):(l=t,c=!0),this.oldValue!==l){if(this.oldValue=null,this.isSliderstart=!1,!this.user||this.user&&!this.user.subscribed){let d=sessionStorage.getItem("ImgsubComponenttime");const h=d?new Date(d):new Date,p=new Date(h.setHours(h.getHours()+24));(!d||d&&p<new Date)&&(this.updateCounter=0,sessionStorage.setItem("ImgsubComponenttime",(new Date).toString()),localStorage.removeItem("ImgsubComponent"));const g=localStorage.getItem("ImgsubComponent");if(null!==g&&g||this.updateCounter>=5)return localStorage.setItem("ImgsubComponent","true"),this.openSubscriptionPopup(t,i),void setTimeout(()=>{this.ismodel=!1},200)}""!==l&&!Number.isNaN(Number(l))&&(l>100?l=100:l<-100&&(l=-100),setTimeout(()=>{this.inputIntensity(l,i)},0),this.user?this.user&&!this.user.subscribed&&this.updateCounter++:this.updateCounter++)}else this.oldValue=null}slideStart(t,i){this.oldValue=this.selectedFace.toolValues.get(i.subToolId)}uploadAndGenrate(t=null){var i=this;return new Promise(function(){var o=(0,w.A)(function*(r,l){if(i.selectedFace.uploadedFileUrl)try{yield i.generate(t),r()}catch(c){l(c)}else i.aiPhotoService.startProcessingProgress({featureType:"expression",indeterminate:!0}),i.aiUploadImageService.uploadImage(i.selectedFace.uploadBlob,{tab:"expression",fileName:"untitled.jpeg"},function(){var c=(0,w.A)(function*(d){if(d&&"FAIL"!==d.status){i.selectedFace.uploadedFileUrl=d.contentUrl;
1try{yield i.generate(t),r()}catch(h){l(h)}}else i.aiPhotoService.clearGenerationProgress(),i.toastService.showError(y.b.message.somethingWrong),r()});return function(d){return c.apply(this,arguments)}}())});return function(r,l){return o.apply(this,arguments)}}())}generate(){var t=this;return(0,w.A)(function*(i=null){return new Promise((o,r)=>{const l=t.selectedFace;let c="",d=0;for(const p of t.faceExpressionService.toolkeys){const u=t.faceExpressionSubToolMap.get(p),_=t.faceExpressionService.mapValue(l.toolValues.get(p)/100,u.min/100,u.max/100,u.minValue,u.maxValue).toFixed(4);d>0&&d<t.faceExpressionService.toolkeys.length&&(c+="|"),c+=_,d++}const h={imageUrl:l.uploadedFileUrl,featureType:"expression",expression:c};t.aiPhotoService.startGenerationProgress({featureType:"expression",deductsCredits:!1,indeterminate:!0}),t.aiPhotoService.generateImage(h,p=>{p&&p.assetId?(p.featureType="airetouch",t.aiPhotoService.checkStatus(p,0,function(){var g=(0,w.A)(function*(_){if(_&&_.urls&&_.urls.length>0)t.aiPhotoService.aiImages=[],t.user&&(t.user.remainingCoins=_.remainingCalls),l.resultFace=_.urls[0],t.aiPhotoService.completeGenerationProgress(()=>{o()});else{if(i){const v=t.selectedFace.toolpreviousValues.get(i.subToolId);t.selectedFace.toolValues.set(i.subToolId,v)}t.aiPhotoService.clearGenerationProgress(),r()}});return function(_){return g.apply(this,arguments)}}(),g=>{t.displayErrorMsg(g),r()})):(t.displayErrorMsg(p),r())},p=>{t.displayErrorMsg(p),r()})})}).apply(this,arguments)}openSubscriptionPopup(t,i){if(!this.ismodel)if(this.subToolId=null,this.subToolValue=null,!this.user||this.user&&!this.user.subscribed){const o=this.faceExpressionService.showSubscriptionModal();this.ismodel=!0,this.subToolId=i.subToolId,this.subToolValue=i.value,o.result.then(r=>{if(this.ismodel=!1,"sucess"===r)this.selectedFace.toolpreviousValues.get(i.subToolId),setTimeout(()=>{this.inputIntensity(t,i)},0);else{const l=this.selectedFace.toolpreviousValues.get(i.subToolId);this.selectedFace.toolValues.set(i.subToolId,l)}})}else this.user&&this.user.subscribed&&(this.updateCounter=0,localStorage.removeItem("ImgsubComponent"))}selectFaceImg(t,i=!1){let o;if(o=t.hasOwnProperty("product")?t.product:t,this.isNewSelection=!0,this.selectedFace=o,this.faceExpressionService.selectedFace=this.selectedFace,this.faceExpressionService.checkandupdateFaceBoundingBox(),this.faceBoundingBox=this.faceExpressionService.faceBoundingBox,!i){const r=this.photoEditorMobService.calcWrapperSize();this.focusOnSelectedFace(r)}}focusOnSelectedFace(t){if(!this.selectedFace||!this.mainCanvas)return;const i=this.photoEditorMobService.mainCanvas,o=i.getWidth(),r=i.getHeight(),d=Math.min(.4*o/this.selectedFace.width,.4*r/this.selectedFace.height,2),h=this.selectedFace.originX+this.selectedFace.width/2,p=this.selectedFace.originY+this.selectedFace.height/2,u=[...i.viewportTransform||[1,0,0,1,0,0]];u[0]=d,u[3]=d,u[4]=o/2-h*d,u[5]=r/2-p*d,i.setViewportTransform(u),i.requestRenderAll(),this.scale=d,this.clampPan()}displayErrorMsg(t=null){this.aiPhotoService.clearGenerationProgress();let i=t?.description;this.createPopupService.openWarningDialog("Error",i).then(r=>{this.changeStep.emit({resetToIntermediate:!0})})}ngOnDestroy(){this.loggedInObserver&&this.loggedInObserver.unsubscribe(),this.usrPropChangedObserver&&this.usrPropChangedObserver.unsubscribe(),this.hammer&&this.hammer.destroy(),this.resetImage();try{this.photoEditorMobService.destroy()}catch{}}touchstart(){this.isCompare=!0}touchend(){this.isCompare=!1}onPointerDown(){clearTimeout(this.compareTimeout),this.compareTimeout=setTimeout(()=>{this.isCompare=!0,this.updateOriginalImageTransform()},50)}onPointerUp(){clearTimeout(this.compareTimeout),this.isCompare=!1}download(){fetch(this.aiPhotoService.imgUrl).then(t=>{let i="jpg";const o=t.headers.get("Content-Type");o&&o.includes("image/")&&(i=o.split("/")[1]),this.faceBoundingBox&&this.photoEditorMobService.mainCanvas.remove(this.faceBoundingBox);const r=this.gestureService.exportCanvasIgnoringViewport(this.photoEditorMobService.mainCanvas);r?this.photoEditorMobService.download(i,f.Fs.FaceExpression,"untitled",r).then(()=>{this.faceExpressionService.checkandupdateFaceBoundingBox()}):this.faceExpressionService.checkandupdateFaceBoundingBox(),this.gtmService.pushTag({eventName:y.b.gtm.eventname.aiDownloadMob,itemName:"Editor_FaceExpression"})})}resetAll(){const t=()=>{this.isEdit=!1,this.faceDataList.length>0&&this.faceDataList.forEach(o=>
1{o.isEdited=!1,this.faceExpressionTools.forEach(r=>{r.subToolArray.forEach(l=>{o.toolValues.set(l.subToolId,0),o.toolpreviousValues.set(l.subToolId,0)})})}),this.initialViewport&&(this.photoEditorMobService.mainCanvas.setViewportTransform([...this.initialViewport]),this.photoEditorMobService.mainCanvas.requestRenderAll()),this.photoEditorMobService.mainCanvas.clear(),this.photoEditorMobService.mainCanvas.renderAll(),this.aiPhotoService.startProcessingProgress({featureType:"expression",indeterminate:!0}),this.photoEditorMobService.reloadImage(this.photoEditorMobService.originalImage,()=>{this.detectFaces(!1)},!1)};this.dialogService.confirmDialog({title:y.b.message.resetAllMessage,okButtonText:"Reset All",cancelButtonText:"Cancel"}).result.then(o=>{"ok"==o&&t()})}setScaleVar(){const i=document.getElementById("canvasWrapper").getBoundingClientRect(),o=Math.min(i.height/this.inputImage.height,i.width/this.inputImage.width);this.scale=o,this.initialScale=o,this.originalImg.nativeElement.style.width=`${this.inputImage.width}px`,this.originalImg.nativeElement.style.height=`${this.inputImage.height}px`,this.originalImg.nativeElement.style.transformOrigin="0 0",this.compareContainer.nativeElement.style.width=`${this.photoEditorMobService.mainCanvas.width}px`,this.compareContainer.nativeElement.style.height=`${this.photoEditorMobService.mainCanvas.height}px`}clampPan(){const t=this.photoEditorMobService.mainCanvas.getZoom(),i=this.photoEditorMobService.mainCanvas.getWidth(),o=this.photoEditorMobService.mainCanvas.getHeight(),r=this.photoEditorMobService.mainCanvas.viewportTransform,l=this.photoEditorMobService.mainCanvas.getObjects("image")[0];if(!l)return;const c=l.width*l.scaleX*t,d=l.height*l.scaleY*t;let h=r[4],p=r[5];h=c<=i?(i-c)/2:Math.min(0,Math.max(i-c,h)),p=d<=o?(o-d)/2:Math.min(0,Math.max(o-d,p)),r[4]=h,r[5]=p,this.photoEditorMobService.mainCanvas.setViewportTransform(r)}setZoomPinch(){this.hammer=this.gestureService.attachPinchPanHandlers(this.mainCanvas.nativeElement,this.photoEditorMobService.mainCanvas,{getScale:()=>this.scale,setScale:t=>{this.scale=t},getInitialScale:()=>this.initialScale,maxScale:2,centerWhenSmaller:!0})}onFileUploaded(t){if(!t.length)return;const i=t[0];i.type.includes("image")&&(this.resetImage(),this.aiPhotoService.imgUrl=URL.createObjectURL(i),this.photoEditorMobService.mainCanvas.clear(),this.photoEditorMobService.mainCanvas.renderAll(),this.aiPhotoService.startProcessingProgress({featureType:"expression",indeterminate:!0}),this.loadInputImage())}resetImage(){this.photoEditorMobService.mainCanvas&&this.faceDataList.length>1&&this.photoEditorMobService.mainCanvas.getObjects("image")[0]&&(this.initialViewport&&(this.photoEditorMobService.mainCanvas.setViewportTransform([...this.initialViewport]),this.scale=this.photoEditorMobService.mainCanvas.getZoom()),this.photoEditorMobService.mainCanvas.requestRenderAll())}updateOriginalImageTransform(){const t=this.photoEditorMobService.mainCanvas.getZoom(),i=this.photoEditorMobService.mainCanvas.viewportTransform;this.originalImg.nativeElement.style.transform=`matrix(${t}, 0, 0, ${t}, ${i[4]}, ${i[5]})`}}return(s=a).\u0275fac=function(t){return new(t||s)(e.rXU(Z.s),e.rXU(q.u),e.rXU(ee.M),e.rXU(Ue.A),e.rXU(be),e.rXU(b.aZ),e.rXU(Q.f),e.rXU(ne.A),e.rXU(re),e.rXU(he.V),e.rXU(st.z),e.rXU(me.X),e.rXU(ae.g),e.rXU(Ce.u),e.rXU(ie.y),e.rXU(ve))},s.\u0275cmp=e.VBU({type:s,selectors:[["face-expression"]],viewQuery:function(t,i){if(1&t&&(e.GBs(na,5),e.GBs(oa,5),e.GBs(sa,7),e.GBs(ra,5),e.GBs(aa,5)),2&t){let o;e.mGM(o=e.lsd())&&(i.contentBox=o.first),e.mGM(o=e.lsd())&&(i.fileInput=o.first),e.mGM(o=e.lsd())&&(i.mainCanvas=o.first),e.mGM(o=e.lsd())&&(i.originalImg=o.first),e.mGM(o=e.lsd())&&(i.compareContainer=o.first)}},outputs:{changeStep:"changeStep"},features:[e.Jv_([Ce.u,re,st.z,Ie.r,he.V,rt.g])],decls:18,vars:11,consts:[["mainCanvas",""],["compareContainer",""],["file",""],["originalImg",""],[1,"mobileRetouch","overflow-hidden"],[1,"drawer-elements","ai-drawer-elements","overflow-hidden"],[1,"d-flex","align-items-center","justify-content-center","overflow-hidden","w-100","flex-column","pt-3","ps-3","pe-3","border-radius-12","position-relative",2,"height","calc(100vh - 410px
1)"],["id","canvasWrapper",1,"d-flex","align-items-center","justify-content-center","overflow-hidden","w-100","flex-column","h-100"],["id","canvas-mask-wrapper",1,"d-flex","align-items-center","justify-content-center","overflow-hidden","border-radius-12","position-relative","h-100","bg-grey3","w-100",2,"overflow","auto"],["id","vmx-canvas","height","100%","width","100%","disableRC","",1,"position-relative",3,"ngClass"],[1,"mw-100","mh-100",2,"overflow","hidden",3,"ngClass"],["disableRC","",3,"src",4,"ngIf"],["class","d-flex align-items-center justify-content-center position-absolute hw-40 border-radius-50 btn-alpha","style","bottom: 8px; left: 24px;",3,"ngClass",4,"ngIf"],["class","d-flex align-items-center justify-content-center position-absolute hw-40 border-radius-50 btn-alpha","style","bottom: 8px; right: 24px;",3,"ngClass","click",4,"ngIf"],["class","d-flex align-items-center justify-content-center position-absolute hw-40 border-radius-50 btn-alpha","style","top: 24px; right: 24px;",3,"click",4,"ngIf"],[1,"mt-3","tabPanelBox"],[4,"ngIf"],["id","fileInput","name","fileInput","type","file",1,"custom-file-input","n-show","d-none",3,"click","change","accept","multiple"],["disableRC","",3,"src"],[1,"d-flex","align-items-center","justify-content-center","position-absolute","hw-40","border-radius-50","btn-alpha",2,"bottom","8px","left","24px",3,"ngClass"],[1,"btn","d-flex","align-items-center","justify-content-center","border-0",3,"pointerdown","pointerup","pointercancel","pointerleave"],["name","comparewhite",1,"f-24","text-white"],[1,"d-flex","align-items-center","justify-content-center","position-absolute","hw-40","border-radius-50","btn-alpha",2,"bottom","8px","right","24px",3,"click","ngClass"],[1,"btn","d-flex","align-items-center","justify-content-center","border-0"],["name","reseticon",1,"f-24","text-white"],[1,"d-flex","align-items-center","justify-content-center","position-absolute","hw-40","border-radius-50","btn-alpha",2,"top","24px","right","24px",3,"click"],["name","downloadblack",1,"f-24","text-white"],["class","filter-category mt-1 mb-2 faceExpression-face ps-3",4,"ngIf"],[1,"",2,"height","calc(100% - 16px)"],[1,"d-flex","overflow-auto","new-scroll-behave","pb-2","p-3","pt-0","ps-1"],["class","ms-2","style","flex: 1 1 100%;",3,"id",4,"ngFor","ngForOf"],["class","d-flex flex-column w-100 mobileRetouchStyle pt-2",3,"ngStyle",4,"ngIf"],[1,"filter-category","mt-1","mb-2","faceExpression-face","ps-3"],[1,"sticker-buttons-scroll","scrollWidth-300"],[3,"selectMenu","type","categoryId","items"],[1,"ms-2",2,"flex","1 1 100%",3,"id"],[1,"d-flex","align-items-center","wp-100"],[1,"btn-acc-title","btnTab","justify-content-center",3,"ngClass"],[1,"m-0","text-13","text-semi",3,"click"],[1,"d-flex","flex-column","w-100","mobileRetouchStyle","pt-2",3,"ngStyle"],[1,"common-container","mb-3"],["class","card-body pt-2",4,"ngFor","ngForOf"],[1,"card-body","pt-2"],[1,"text-13","grey-800","text-semi"],[1,"ms-1",3,"name"],[1,"d-flex"],[1,"wp-100","d-flex","align-items-center"],[1,"opacity-slider",2,"width","100%",3,"slideStop","change","slideStart","min","max","step","value"],[1,"ms-3"],["type","text","numberSettings","","maxlength","4","disabled","","mask","separator.2","separatorLimit","100",1,"form-control","form-input-sm","text-normal","text-black",2,"pointer-events","none",3,"min","max","ngModel"]],template:function(t,i){if(1&t){const o=e.RV6();e.j41(0,"div",4)(1,"div",5)(2,"div",6)(3,"div",7)(4,"div",8)(5,"canvas",9,0),e.EFF(7," Your browser does not support the HTML5 canvas tag. "),e.k0s(),e.j41(8,"div",10,1),e.DNE(10,ha,2,1,"img",11),e.k0s()(),e.DNE(11,pa,3,3,"div",12)(12,ma,3,3,"div",13)(13,ua,2,0,"div",14),e.k0s()(),e.j41(14,"div",15),e.DNE(15,ba,6,3,"ng-container",16),e.k0s()()(),e.j41(16,"input",17,2),e.bIt("click",function(){e.eBV(o);const l=e.sdS(17);return e.Njj(l.value="")})("change",function(l){return e.eBV(o),e.Njj(i.onFileUploaded(l.srcElement.files))}),e.k0s()}2&t&&(e.R7$(5),e.Y8G("ngClass",e.eq3(9,la,i.isCompare)),e.R7$(3),e.Y8G("ngClass",i.isCompare?"d-flex":"d-none"),e.R7$(2),e.Y8G("ngIf",i.photoEditorMobService.originalImage),e.R7$(),e.Y8G("ngIf",i.isLoaded),e.R7$(),e.Y8G("ngIf",i.isLoaded),e.R7$(),e.Y8G("ngIf",i.isLoaded),e.R7$(2),e.Y8G("ngIf",i.isLoaded),e.R7$(),e.Y8G("accept","image/*")("multiple",!1))},dependencies:[b.YU,b.Sq,b.bT,b.B3,Me.G,Ge.I,P.me,P.BC,P.tU,P.vS,H.b,O.d1,_e.B,Se.KK,Vt.LR],styles:[".compare-stack[_ngcontent-%COMP%]   img[_ngcontent-%COMP%]{width:100%;object-fit:contain}@media screen and (max-height: 740px){.text-56[_ngcontent-%COMP%]{font-size:48px!important;line-height:58px!important}}@media screen and (max-height: 640px){.text-56[_ngcontent-%COMP%]{font-size:40px!important;line-height:50px!important}}@media screen and (max-height: 540px){.text-56[_ngcontent-%COMP%]{font-size:30px!important;line-height:40px!important}}.btnTab[_ngcontent-%COMP%]{border-radius:8px;border:1px solid #E2E3E9;background:#efeef2;padding:8px 16px;color:#272b34;width:100%!important;height:32px!important;line-height:normal}.btnTabActive[_ngcontent-%COMP%]{border:1px solid transparent;background:#626adf;color:#fff}#face-retouch-Skin[_ngcontent-%COMP%]{padding-left:8px}#face-retouch-Teeth[_ngcontent-%COMP%]{margin-right:16px}.content-box[_ngcontent-%COMP%]{transition:opacity .5s ease,transform .5s ease}.content-box.in[_ngcontent-%COMP%]{opacity:1;transform:translate(0)}.content-box.out[_ngcontent-%COMP%]{opacity:0;transform:translate(-50px)}.full-screen-container[_ngcontent-%COMP%]{display:flex;height:100vh}.left-column[_ngcontent-%COMP%], .right-column[_ngcontent-%COMP%]{flex:1;height:100%;overflow:auto}.left-column[_ngcontent-%COMP%]{background-color:#f5f5f5}.right-column[_ngcontent-%COMP%]{background-color:#e0e0e0}.mobileRetouchStyle[_ngcontent-%COMP%]{display:flex;transition:justify-content .4s ease}.animate-items[_ngcontent-%COMP%] > *[_ngcontent-%COMP%]{opacity:0;transform:translateY(10px);animation:_ngcontent-%COMP%_fadeInUp .4s ease forwards}.animate-items[_ngcontent-%COMP%] > *[_ngcontent-%COMP%]:nth-child(1){animation-delay:.1s}.animate-items[_ngcontent-%COMP%] > *[_ngcontent-%COMP%]:nth-child(2){animation-delay:.2s}.animate-items[_ngcontent-%COMP%] > *[_ngcontent-%COMP%]:nth-child(3){animation-delay:.3s}.animate-items[_ngcontent-%COMP%] > *[_ngcontent-%COMP%]:nth-child(4){animation-delay:.4s}.animate-items[_ngcontent-%COMP%] > *[_ngcontent-%COMP%]:nth-child(5){animation-delay:.5s}.animate-items[_ngcontent-%COMP%] > *[_ngcontent-%COMP%]:nth-child(6){animation-delay:.6s}@keyframes _ngcontent-%COMP%_fadeInUp{to{opacity:1;transform:translateY(0)}}.reseticon-none[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]{opacity:.3}"]}),a})();var ye=m(7259),xa=m(96710),at=m(40580),Pa=m(41783),Ia=m(83316),ya=m(16966),wa=m(87502),Sa=m(96408),Ma=m(57160),ka=m(25693),Ta=m(62922),D=m(10235),Ft=(m(74972),m(37535),m(786),m(31284),m(98081));let At=(()=>{var s;class a{constructor(t,i){this.landmarkService=t,this.multiFaceService=i,this.faceList=[],this.selectedFaceId=null,this.uploadImageScaleFactor=1.3,this.faceBoundingBox=null,this.faceDataModel=null,this.faceReshapeTools=[],this.baseToolsTemplate=JSON.parse(JSON.stringify(ye.Jy)),this.perFaceTools={},this.selectedTool=null,this.selectedSubTool=null,this.selectedSideOption="Both"}
1loadMediaPipeScripts(){return(0,w.A)(function*(){if(!(window.FilesetResolver&&window.FaceLandmarker&&window.FaceDetector))return new Promise((t,i)=>{const o=document.createElement("script");o.type="module",o.textContent="\n        import { FilesetResolver, FaceLandmarker, FaceDetector } from 'https://cdn.jsdelivr.net/npm/@mediapipe/[email protected]';\n        window.FilesetResolver = FilesetResolver;\n        window.FaceLandmarker = FaceLandmarker;\n        window.FaceDetector = FaceDetector;\n        window.dispatchEvent(new CustomEvent('mediapipe-loaded'));\n      ";const r=()=>{window.removeEventListener("mediapipe-loaded",r),t()};window.addEventListener("mediapipe-loaded",r),o.onerror=l=>i(l),document.head.appendChild(o)})})()}updateEditedFlagForFace(t){const i=t||this.selectedFaceId;if(!i)return;const o=this.perFaceTools&&this.perFaceTools[i]?this.perFaceTools[i]:this.faceReshapeTools;let r=!1;if(o&&o.length)e:for(const c of o)if(c?.subtools)for(const d of c.subtools)if(0!==(d?.values?.both?.current||0)||0!==(d?.values?.left?.current||0)||0!==(d?.values?.right?.current||0)){r=!0;break e}const l=(this.faceList||[]).find(c=>c?.id===i);l&&(l.isEdited=r)}setCanvas(t){this.mainCanvas=t}setInputImage(t){this.inputImage=t}initializeModels(){var t=this;return(0,w.A)(function*(){yield t.loadMediaPipeScripts(),yield t.landmarkService.initialize(),yield t.multiFaceService.loadModels()})()}detectFaces(t){var i=this;return(0,w.A)(function*(){const{detections:o}=yield i.multiFaceService.detectFacesFaceApi(t);o?.detections?.length?(i.faceList=yield i.multiFaceService.createFaceList(o,t,i.uploadImageScaleFactor),i.selectedFaceId=i.faceList[0]?.id||null,(i.faceList||[]).forEach(r=>{r?.id&&!i.perFaceTools[r.id]&&(i.perFaceTools[r.id]=JSON.parse(JSON.stringify(i.baseToolsTemplate)))}),i.faceReshapeTools=i.perFaceTools[i.selectedFaceId]||JSON.parse(JSON.stringify(i.baseToolsTemplate))):(i.faceList=[],i.selectedFaceId=null)})()}selectFace(t){this.selectedFaceId=t,this.perFaceTools[t]||(this.perFaceTools[t]=JSON.parse(JSON.stringify(this.baseToolsTemplate))),this.faceReshapeTools=this.perFaceTools[t],this.selectedTool=null,this.selectedSubTool=null}checkAndUpdateFaceBoundingBox(){try{if(!this.mainCanvas)return;if(!this.faceList||this.faceList.length<=1)return void(this.faceBoundingBox&&(this.mainCanvas.remove(this.faceBoundingBox),this.faceBoundingBox=null,this.mainCanvas.renderAll()));this.faceBoundingBox&&(this.mainCanvas.remove(this.faceBoundingBox),this.faceBoundingBox=null);const t=(this.faceList||[]).find(h=>h?.id===this.selectedFaceId);if(!t)return void this.mainCanvas.renderAll();const i=t,o=Math.max(0,Math.floor(i.originX||i.x||0)),r=Math.max(0,Math.floor(i.originY||i.y||0)),l=Math.floor(i.width||0),c=Math.floor(i.height||0),d=new Gt.jj({left:o,top:r,width:l,height:c,objectCaching:!1});this.faceBoundingBox=d,this.mainCanvas.add(d),this.mainCanvas.bringToFront(d),this.mainCanvas.renderAll()}catch{}}detectLandmarksForSelectedFace(t){var i=this;return(0,w.A)(function*(o,r=!1){if(!i.selectedFaceId)return;const l=(i.faceList||[]).find(X=>X?.id===i.selectedFaceId);if(!l)return;const c=l.cropParam||{boundedMinX:0,boundedMinY:0,boundedMaxX:0,boundedMaxY:0},d=Math.max(0,Math.floor(c.boundedMinX||0)),h=Math.max(0,Math.floor(c.boundedMinY||0)),p=Math.max(d+1,Math.floor(c.boundedMaxX||0)),u=Math.max(h+1,Math.floor(c.boundedMaxY||0)),g=p-d,_=u-h,v=yield i.multiFaceService.cropFaceForLatestFaces(o,d,h,g,_);let M=v?.getElement?v.getElement():v;const G=yield i.landmarkService.getLandmarks(M);if(!G||!G.length||!G[0])return;const U=o.width,F=o.height,B=G[0].map(X=>({x:(d+X.x*g)/U,y:(h+X.y*_)/F,z:X.z})),Ve=at.k.calculateDistanceA(B[152],B[10])*F,Re=at.k.calculateAngle(B[152],B[10]),Fe=at.k.calculateAngle(B[234],B[454]);i.faceDataModel=new Pa.t(B,U,F,null,Fe,Re,Ve),r||i.setupTriangleMaskWarpFilter()}).apply(this,arguments)}selectTool(t){this.selectedSideOption="Both",this.selectedTool=t,this.selectSubTool(t.subtools[0])}selectSubTool(t){this.selectedSubTool=t;const i=new xa.o;this.algo=i,i.setFrameLength(80);const o=this.inputImage?.getElement?.();
1if(i.setImageSize({width:o&&(o.naturalWidth||o.videoWidth)||this.inputImage?.width||0,height:o&&(o.naturalHeight||o.videoHeight)||this.inputImage?.height||0}),!this.faceDataModel)return;let c=0;"Left"===this.selectedSideOption?c=1:"Right"===this.selectedSideOption&&(c=2);let d={staticPointArray:null,startPointArray:null,endPointArray:null};switch(this.selectedTool?.type){case ye.IX.SHAPE:d=(new Ia.y).updatePointsForSelection(this.faceDataModel,this.selectedSubTool.type);break;case ye.IX.RATIO:d=(new ya.g).updatePointsForSelection(this.faceDataModel,this.selectedSubTool.type);break;case ye.IX.EYEBROWS:d=(new wa.i).updatePointsForSelection(this.faceDataModel,this.selectedSubTool.type,c);break;case ye.IX.EYES:d=(new Sa.o).updatePointsForSelection(this.faceDataModel,this.selectedSubTool.type,c);break;case ye.IX.NOSE:d=(new Ma.g).updatePointsForSelection(this.faceDataModel,this.selectedSubTool.type);break;case ye.IX.LIPS:d=(new ka.b).updatePointsForSelection(this.faceDataModel,this.selectedSubTool.type)}d?.staticPointArray&&d?.startPointArray&&d?.endPointArray&&(i.addStaticPointArray(d.staticPointArray),i.addDynamicPointArray(d.startPointArray,d.endPointArray),i.applyDelaunayForFrame(0),this.setupTriangleMaskWarpFilter())}setSideOption(t){this.selectedSideOption=t,this.selectedSubTool&&this.selectSubTool(this.selectedSubTool)}onScaleChange(t){!this.selectedSubTool||!this.algo||(t>100?t=100:t<-100&&(t=-100),this.applyScaleTransformation(t))}setupTriangleMaskWarpFilter(){const t=this.inputImage;if(!t)return;let i=I.fabric.Image.filters.TriangleMaskWarp;if(!i)return;const o=document.createElement("canvas");o.width=1,o.height=1;const r=o.getContext("2d");r.fillStyle="rgba(0,0,0,0)",r.fillRect(0,0,1,1),this.maskWarpFilter=new i({maskImage:o,triLUTImage:o,triCount:0,isAnimating:0}),t.filters=t.filters||[],t.filters.push(this.maskWarpFilter);const l=t.getElement();this.maskWarpFilter&&(this.maskWarpFilter.imageWidth=l&&(l.naturalWidth||l.videoWidth)||t.width,this.maskWarpFilter.imageHeight=l&&(l.naturalHeight||l.videoHeight)||t.height),t.applyFilters(),this.mainCanvas?.renderAll()}buildTriangleLUTArrayCV(t){const i=t?.length||0,o=new Float32Array(6*i);for(let r=0;r<i;r++){const l=t[r];if(!l)continue;const c=l[0],d=l[1],h=l[2],p=l[3]||l[0],u=l[4]||l[1],g=l[5]||l[2];try{const _=Ta.s.computeAffineFromTriangles(c,d,h,p,u,g),v=6*r;o[v+0]=_[0],o[v+1]=_[1],o[v+2]=_[2],o[v+3]=_[3],o[v+4]=_[4],o[v+5]=_[5]}catch{const v=6*r;o[v+0]=1,o[v+1]=0,o[v+2]=0,o[v+3]=0,o[v+4]=1,o[v+5]=0}}return o}updateTriangleMaskWarpFilterWithArray(t,i,o){if(!this.maskWarpFilter||!this.inputImage)return;this.maskWarpFilter.maskImage=t||this.maskWarpFilter.maskImage,this.maskWarpFilter.triLUTImage=null,this.maskWarpFilter.triLUTArray=i,this.maskWarpFilter.triCount=o,this.maskWarpFilter.isAnimating=1;const r=this.inputImage.getElement();this.maskWarpFilter.imageWidth=r&&(r.naturalWidth||r.videoWidth)||this.inputImage.width,this.maskWarpFilter.imageHeight=r&&(r.naturalHeight||r.videoHeight)||this.inputImage.height,this.inputImage.applyFilters(),this.mainCanvas?.renderAll()}interpolateValue(t,i,o,r,l){return o===i?r:r+(t-i)/(o-i)*(l-r)}getLastProgress(){try{const t=(this.selectedSideOption||"Both").toLowerCase(),i=this.selectedSubTool?.values?.[t];return i&&"number"==typeof i.previous?i.previous:0}catch{return 0}}getProgressFactor(t){let i=2*(t/100+1),o=i,r=2*(this.getLastProgress()/100+1);switch(this.selectedSubTool.type){case D.I.EYEBROW_LIFT:i=4-i,r=4-r;case D.I.EYE_LIFT:case D.I.EYE_DISTANCE:o=this.interpolateValue(i,0,4,1.5,2.5),r=this.interpolateValue(r,0,4,1.5,2.5);break;case D.I.EYE_HEIGHT:case D.I.NOSE_WIDTH:case D.I.NOSE_TIP:o=this.interpolateValue(i,0,4,1.75,2.25),r=this.interpolateValue(r,0,4,1.75,2.25);break;case D.I.EYE_SIZE:i=4-i,r=4-r,o=this.interpolateValue(i,0,4,1.85,2.15),r=this.interpolateValue(r,0,4,1.85,2.15);break;case D.I.EYEBROW_PEAK:o=this.interpolateValue(i,0,4,1.5,2.5),r=this.interpolateValue(r,0,4,1.5,2.5);break;case D.I.EYEBROW_TILT:case D.I.EYE_TILT:o=this.interpolateValue(i,0,4,1.85,2.15),r=this.interpolateValue(r,0,4,1.85,2.15);break;case D.I.NOSE_WING:case D.I.RATIO_MIDDLE:o=this.interpolateValue(i,0,4,1.6,2.4),r=this.interpolateValue(r,0,4,1.6,2.4);break;case D.I.NOSE_BRIDGE:o=this.interpolateValue(i,0,4,1,3),r=this.interpolateValue(r,0,4,1,3);break;case D.I.NOSE_LIFT:i=4-i,r=4-r,o=this.interpolateValue(i,0,4,1.75,2.25),r=this.interpolateValue(r,0,4,1.75,2.25);break;case D.I.NOSE_SIZE:o=this.interpolateValue(i,0,4,1.5,2.5),r=this.interpolateValue(r,0,4,1.5,2.5);break;case D.I.RATIO_TOP:i=4-i,r=4-r,o=this.interpolateValue(i,0,4,1.85,2.15),r=this.interpolateValue(r,0,4,1.85,2.15);break;case D.I.RATIO_UPPER:o=this.interpolateValue(i,0,4,1.6,2.4),r=this.interpolateValue(r,0,4,1.6,2.4);break;case D.I.RATIO_LOWER:case D.I.SHAPE_CHIN:case D.I.SHAPE_VSHAPE:case D.I.SHAPE_SLIM:o=this.interpolateValue(i,0,4,1.8,2.2),r=this.interpolateValue(r,0,4,1.8,2.2);break;case D.I.EYEBROW_LENGTH:case D.I.EYEBROW_DISTANCE:o=this.interpolateValue(i,0,4,1.25,2.75),r=this.interpolateValue(r,0,4,1.25,2.75);break;case D.I.EYE_WIDTH:o=this.interpolateValue(i,0,4,1.5,2.5),r=this.interpolateValue(r,0,4,1.5,2.5);break;case D.I.EYEBROW_THICKNESS:i=4-i,r=4-r,o=this.interpolateValue(i,0,4,1.6,2.4),r=this.interpolateValue(r,0,4,1.6,2.4);break;case D.I.LIP_SMILE:case D.I.SHAPE_JAW:case D.I.SHAPE_FOREHEAD:case D.I.SHAPE_CHEEKBONE:o=this.interpolateValue(i,0,4,1.75,2.25),r=this.interpolateValue(r,0,4,1.75,2.25);break;case D.I.LIP_UPPER:case D.I.LIP_LOWER:case D.I.LIP_SIZE:o=this.interpolateValue(i,0,4,1.5,2.5),r=this.interpolateValue(r,0,4,1.5,2.5);break;case D.I.SHAPE_WIDTH:case D.I.SHAPE_TEMPLES:o=this.interpolateValue(i,0,4,1.75,2.25),r=this.interpolateValue(r,0,4,1.75,2.25);break;default:o=this.interpolateValue(i,0,4,1,3),r=this.interpolateValue(r,0,4,1,3)}return r>2?this.interpolateValue(o,0,r,0,2):this.interpolateValue(o,r,4,2,4)}getSideKey(){const t=(this.selectedSideOption||"Both").toLowerCase();return["left","right"].includes(t)?t:"both"}applyScaleTransformation(t){const i=this.getSideKey();this.selectedSubTool.values[i].current=t;const o=this.getProgressFactor(t),r=Math.round(80*o/4),l=this.algo;if(!l)return;l.applyDelaunayForFrame(r);const c=l.getDynamicTriangles(),d=l.buildTriangleMaskCanvas(this.inputImage),h=this.buildTriangleLUTArrayCV(c);this.updateTriangleMaskWarpFilterWithArray(d,h,c.length),this.updateEditedFlagForFace(this.selectedFaceId)}
1resetAll(){try{try{(this.faceList||[]).forEach(t=>{t&&(t.isEdited=!1)})}catch{}if(this.faceBoundingBox&&this.mainCanvas)try{this.mainCanvas.remove(this.faceBoundingBox),this.mainCanvas.renderAll()}catch{}this.faceBoundingBox=null;try{if(this.inputImage&&this.maskWarpFilter){const t=this.inputImage.filters||[],i=t.indexOf(this.maskWarpFilter);i>=0&&(t.splice(i,1),this.inputImage.filters=t,this.inputImage.applyFilters())}}catch{}this.maskWarpFilter=null,this.triangleLUTCanvas=null,this.algo=null,this.faceList=[],this.selectedFaceId=null,this.faceDataModel=null,this.selectedTool=null,this.selectedSubTool=null,this.selectedSideOption="Both",this.perFaceTools={};try{this.faceReshapeTools=JSON.parse(JSON.stringify(this.baseToolsTemplate))}catch{this.faceReshapeTools=[]}this.mainCanvas?.renderAll?.()}catch{}}}return(s=a).\u0275fac=function(t){return new(t||s)(e.KVO(Ft.x),e.KVO(rt.g))},s.\u0275prov=e.jDH({token:s,factory:s.\u0275fac}),a})();const Oa=["mainCanvas"],Ea=["originalImg"],ja=["compareContainer"],Ga=["file"],Va=["canvasWrapperParent"],Ra=s=>({"d-none":s}),Bt=s=>({"pe-none reseticon-none":s}),Fa=s=>({btnTabActive:s});function Aa(s,a){if(1&s&&e.nrm(0,"img",19,4),2&s){const n=e.XpG();e.Y8G("src",n.photoEditorMobService.originalImage.src,e.B4B)}}function Ba(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",20)(1,"button",21),e.bIt("pointerdown",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.onPointerDown())})("pointerup",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.onPointerUp())})("pointercancel",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.onPointerUp())})("pointerleave",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.onPointerUp())}),e.nrm(2,"pi",22),e.k0s()()}if(2&s){const n=e.XpG();e.Y8G("ngClass",e.eq3(1,Bt,!n.isEdit))}}function Ua(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",23),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.download())}),e.nrm(1,"pi",24),e.k0s()}}function Da(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",25),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.resetAll())}),e.j41(1,"button",26),e.nrm(2,"ei",27),e.k0s()()}if(2&s){const n=e.XpG();e.Y8G("ngClass",e.eq3(1,Bt,!n.isEdit))}}function Na(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",33)(1,"div",34)(2,"buttons-scroll-menu",35),e.bIt("selectMenu",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.selectFace(i))}),e.k0s()()()}if(2&s){const n=e.XpG(2);e.R7$(2),e.Y8G("type","faceExpression")("categoryId",n.faceReshapeService.selectedFaceId)("items",n.faceReshapeService.faceList)}}function Xa(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",36)(1,"div",37)(2,"button",38)(3,"div",39),e.bIt("click",function(){const i=e.eBV(n).$implicit,o=e.XpG(2);return e.Njj(o.onSelectTool({id:i.type}))}),e.EFF(4),e.k0s()()()()}if(2&s){const n=a.$implicit,t=e.XpG(2);e.R7$(2),e.Y8G("ngClass",e.eq3(2,Fa,(null==t.faceReshapeService.selectedTool?null:t.faceReshapeService.selectedTool.type)==n.type)),e.R7$(2),e.JRh(n.name)}}function La(s,a){1&s&&(e.j41(0,"span",59),e.nrm(1,"pi",60),e.k0s())}function Ya(s,a){if(1&s&&(e.j41(0,"div",56)(1,"span",57),e.EFF(2),e.k0s(),e.DNE(3,La,2,0,"span",58),e.k0s()),2&s){const n=a.item,t=e.XpG(4);e.R7$(2),e.JRh(n.value),e.R7$(),e.Y8G("ngIf",n.pro&&!(null!=t.user&&t.user.subscribed))}}function $a(s,a){if(1&s){const n=e.RV6();e.j41(0,"ng-select",54),e.mxI("ngModelChange",function(i){e.eBV(n);const o=e.XpG(3);return e.DH7(o.selectedSideOption,i)||(o.selectedSideOption=i),e.Njj(i)}),e.bIt("ngModelChange",function(i){e.eBV(n);const o=e.XpG(3);return e.Njj(o.onSideOptionChange(i))}),e.DNE(1,Ya,4,2,"ng-template",55),e.k0s()}if(2&s){const n=e.XpG(3);e.Y8G("items",n.sideOptionList),e.R50("ngModel",n.selectedSideOption),e.Y8G("searchable",!1)("clearable",!1)}}function za(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",40)(1,"div",41)(2,"div",42)(3,"span",43),e.EFF(4,"Style"),e.k0s(),e.DNE(5,$a,2,4,"ng-select",44),e.k0s(),e.j41(6,"div",45)(7,"buttons-scroll-menu",46),e.bIt("selectMenu",function(i){const o=e.eBV(n).ngIf,r=e.XpG(2);return e.Njj(r.onSelectSubtool(o,i))}),e.k0s()(),e.j41(8,"div",47)(9,"span",48),e.EFF(10,"Scale"),e.k0s(),e.j41(11,"div",49)(12,"div",50)(13,"mv-slider",51),e.bIt("slideStop",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onScaleChange(i))})("change",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onScaleChange(i))}),e.k0s()(),e.j41(14,"div",52),e.nrm(15,"input",53),e.k0s()()()()()}if(2&s){const n=a.ngIf,t=e.XpG(2);e.R7$(5),e.Y8G("ngIf","Eyes"===(null==t.faceReshapeService.selectedTool?null:t.faceReshapeService.selectedTool.type)||"Eyebrows"===(null==t.faceReshapeService.selectedTool?null:t.faceReshapeService.selectedTool.type)),e.R7$(2),e.Y8G("type","faceReshapeSubtools")("user",t.user)("categoryId",null==t.faceReshapeService.selectedSubTool?null:t.faceReshapeService.selectedSubTool.type)("sideKey",(null==t.selectedSideOption||null==t.selectedSideOption.toLowerCase?null:t.selectedSideOption.toLowerCase())||"both")("items",n.subtools),e.R7$(6),e.Y8G("min",-100)("max",100)("step",1)("value",t.scaleValue),e.R7$(2),e.Y8G("min",-100)("max",100)("ngModel",t.scaleValue)}}function Ha(s,a){if(1&s&&(e.qex(0),e.DNE(1,Na,3,3,"div",28),e.j41(2,"div",29)(3,"div",30),e.DNE(4,Xa,5,4,"div",31),e.k0s(),e.DNE(5,za,16,13,"div",32),e.k0s(),e.bVm()),2&s){const n=e.XpG();e.R7$(),e.Y8G("ngIf",(null==n.faceReshapeService.faceList?null:n.faceReshapeService.faceList.length)>1),e.R7$(3),e.Y8G("ngForOf",n.tools),e.R7$(),e.Y8G("ngIf",n.faceReshapeService.selectedTool)}}let Wa=(()=>{var s;class a{constructor(t,i,o,r,l,c,d,h,p,u,g,_,v,C,M,k){this.createPopupService=t,this.aiPhotoService=i,this.authService=o,this.uploadImageService=r,this.photoEditorMobService=l,this.toastService=c,this.zoomService=d,this.faceReshapeService=h,this.gestureService=p,this.photoEditorSahredService=u,this.subsService=g,this.env=_,this.dialogService=v,this.location=C,this.renderer=M,this.gtmService=k,this.changeStep=new e.bkB,this.isLoaded=!1,this.scaleValue=0,this.containerId="canvas-mask-wrapper",this.isCompare=!1,this.scale=1,this.initialScale=0,this.isProUser=!1,this.fitToScreen=!1,this.isEdit=!1,this.selectedSideOption="Both",this.previousSideOption="Both",this.sideOptionList=[{key:"Both",value:"Both Sides",pro:!1},{key:"Left",value:"Left Side",pro:!0},{key:"Right",value:"Right Side",pro:!0}]}ngOnInit(){var t=this;window.scrollTo(0,0),this.renderer.addClass(document.body,"overflow-hidden"),this.isLoaded=!0,this.user=this.authService.currentUser(),this.isProUser=this.aiPhotoService.isProUser(),this.loggedInObserver=this.authService.loggedIn.subscribe(i=>{this.user=this.authService.currentUser(),this.isProUser=this.aiPhotoService.isProUser()}),this.usrPropChangedObserver=this.authService.usrPropChanged.subscribe(i=>{this.user=this.authService.currentUser(),this.isProUser=this.aiPhotoService.isProUser()}),this.aiPhotoService.applyToSaveFn=(0,w.A)(function*(){t.faceReshapeService.faceBoundingBox&&t.photoEditorMobService.mainCanvas.remove(t.faceReshapeService.faceBoundingBox),t.photoEditorSahredService.applyToSave(t.photoEditorMobService.originalImage,t.photoEditorMobService.mainCanvas,i=>{t.aiPhotoService.imgUrl=i.uri,t.aiPhotoService.queryParams.imgUrl=i.uri,t.faceReshapeService.checkAndUpdateFaceBoundingBox()}
1,!1,{activeTool:f.z6.Portrait,activeSubTool:f.Fs.FaceReshape})}),this.aiPhotoService.startProcessingProgress({featureType:"facereshape",indeterminate:!0}),this.loadInputImage()}fitCanvasAfterFacedetect(){setTimeout(()=>{const t=this.canvasWrapperParent?.nativeElement||document.querySelector(".drawer-elements .flex-column");t&&t.classList.contains("multiple-face")?this.photoEditorMobService.fitToScreen():(clearTimeout(this._fitToScreenTimeout),this._fitToScreenTimeout=setTimeout(()=>{this.photoEditorMobService.fitToScreen()},100)),this.photoEditorMobService.fitToScreen()},0)}loadInputImage(){var t=this;this.photoEditorMobService.mainCanvas&&(this.photoEditorMobService.mainCanvas.clear(),this.photoEditorMobService.mainCanvas.renderAll()),this.photoEditorMobService.loadInputImage(this.aiPhotoService.imgUrl,this.mainCanvas.nativeElement,(0,w.A)(function*(){const i=t.photoEditorMobService.inputImage,o=document.getElementById("canvasWrapper");t.zoomService.setCanvas(t.photoEditorMobService.mainCanvas,o),t.photoEditorMobService.mainCanvas&&t.photoEditorMobService.mainCanvas.viewportTransform&&(t.initialViewport=[...t.photoEditorMobService.mainCanvas.viewportTransform]),t.faceReshapeService.setCanvas(t.photoEditorMobService.mainCanvas),t.faceReshapeService.setInputImage(i);try{if(yield t.faceReshapeService.initializeModels(),yield t.faceReshapeService.detectFaces(t.photoEditorMobService.originalImage),!t.faceReshapeService.selectedFaceId)return void t.faceNotDetected({description:y.b.message.faceNotFound});if(t.faceReshapeService.faceList?.length>1&&t.fitCanvasAfterFacedetect(),yield t.faceReshapeService.detectLandmarksForSelectedFace(t.photoEditorMobService.originalImage),!t.faceReshapeService.faceDataModel)return void t.faceNotDetected({description:y.b.message.faceNotFound});t.faceReshapeService.checkAndUpdateFaceBoundingBox();const r=(t.faceReshapeService.faceReshapeTools||[]).find(l=>"Shape"===l.type)||(t.faceReshapeService.faceReshapeTools||[])[0];r&&(t.faceReshapeService.selectTool(r),t.scaleValue=0),t.setScaleVar(),t.setZoomPinch(),t.aiPhotoService.completeGenerationProgress()}catch{t.aiPhotoService.clearGenerationProgress(),t.toastService.showError("Failed to initialize face reshape.")}}),()=>{this.aiPhotoService.clearGenerationProgress(),this.toastService.showError(y.b.message.somethingWrong),this.location.back()},2048,2048)}faceNotDetected(t=null){this.aiPhotoService.clearGenerationProgress();let i=t?.description;this.createPopupService.openWarningDialog("Error",i).then(r=>{this.changeStep.emit({resetToIntermediate:!0})})}onFileUploaded(t){if(!t?.length)return;const i=t[0];if(i.type.includes("image")){try{this.faceReshapeService.resetAll()}catch{}this.photoEditorMobService.mainCanvas.clear(),this.photoEditorMobService.mainCanvas.renderAll(),this.aiPhotoService.imgUrl=URL.createObjectURL(i),this.aiPhotoService.startProcessingProgress({featureType:"facereshape",indeterminate:!0}),this.loadInputImage()}}selectFace(t){var i=this;return(0,w.A)(function*(){i.isCurrentSubtoolEdited()&&(yield i.recaptureAndRelandmark(),i.setPrevEqualsCurrent()),i.selectedSideOption="Both",i.previousSideOption="Both";const o=t?.product?.id||t?.id||t;if(!o)return;i.faceReshapeService.selectFace(o),i.faceReshapeService.checkAndUpdateFaceBoundingBox();try{if(i.aiPhotoService.startProcessingProgress({featureType:"facereshape",indeterminate:!0}),yield i.faceReshapeService.detectLandmarksForSelectedFace(i.photoEditorMobService.originalImage),!i.faceReshapeService.faceDataModel)return void i.faceNotDetected({description:y.b.message.faceNotFound});i.aiPhotoService.completeGenerationProgress()}catch{i.aiPhotoService.clearGenerationProgress()}const r=i.faceReshapeService.faceReshapeTools||[],l=r.find(d=>"Shape"===d.type)||r[0];if(l){i.faceReshapeService.selectTool(l);const d=i.faceReshapeService.selectedSubTool,h=(i.selectedSideOption||"Both").toLowerCase();console.log(d,h),i.scaleValue=d&&d.values&&d.values[h]&&d.values[h].current||0}const c=i.photoEditorMobService.calcWrapperSize();i.focusOnSelectedFace(c)})()}get tools(){return this.faceReshapeService.faceReshapeTools||[]}get toolMenuItems(){return(this.tools||[]).map(i=>({id:i.type,title:i.name}))}onSelectTool(t){var i=this;return(0,w.A)(function*(){const o=t?.id??t?.product?.id;if(null==o)return;const r=(i.tools||[]).find(d=>d.type===o);if(!r||i.faceReshapeService.selectedTool==r)return;i.isCurrentSubtoolEdited()&&(yield i.recaptureAndRelandmark(),i.setPrevEqualsCurrent()),i.faceReshapeService.selectTool(r),i.selectedSideOption="Both",i.previousSideOption="Both";const l=(i.selectedSideOption||"Both").toLowerCase(),c=i.faceReshapeService.selectedSubTool;i.scaleValue=c&&c.values&&c.values[l]&&c.values[l].current||0})()}getSubtoolMenuItems(t){return t?.subtools?t.subtools.map(o=>({id:o.type,title:o.name,iconName:o.iconName||null,pro:o.pro,isEdited:0!==(o.values.both?.current||0)})):[]}onSelectSubtool(t,i){var o=this;const r=i?.type??i?.product?.type;if(null==r)return;const l=t?.subtools?.find(d=>d.type===r);if(!l||this.faceReshapeService.selectedSubTool==l)return;const c=function(){var d=(0,w.A)(function*(){o.isCurrentSubtoolEdited()&&(yield o.recaptureAndRelandmark(),o.setPrevEqualsCurrent()),o.faceReshapeService.selectSubTool(l);const h=(o.selectedSideOption||"Both").toLowerCase(),p=l.values;o.scaleValue=p&&p[h]&&p[h].current||0});return function(){return d.apply(this,arguments)}}();!Number(l.pro)||this.user&&(!this.user||this.user.subscribed)?c():this.subsService.loginWithUpgrade(()=>{this.user=this.authService.currentUser(),this.isProUser=this.aiPhotoService.isProUser(),this.user&&this.user.subscribed&&
1c()},{coinSectionHide:this.env.isMobileView},!0)}onScaleChange(t){let i;i=t&&t.hasOwnProperty("newValue")?t.newValue:t,this.scaleValue=i,this.faceReshapeService.onScaleChange(i),this.isEdit=!0}isCurrentSubtoolEdited(){const t=this.faceReshapeService.selectedSubTool;if(!t||!t.values)return!1;const i=(this.selectedSideOption||"Both").toLowerCase(),o=t.values[i];return!!o&&(o.current||0)!==(o.previous||0)}setPrevEqualsCurrent(){try{const t=this.faceReshapeService.selectedSubTool;if(!t||!t.values)return;const i=(this.selectedSideOption||"Both").toLowerCase(),o=t.values[i];o&&(o.previous=o.current)}catch{}}recaptureAndRelandmark(){var t=this;return(0,w.A)(function*(){try{if(t.aiPhotoService.startProcessingProgress({featureType:"facereshape",indeterminate:!0}),t.faceReshapeService.faceBoundingBox&&t.photoEditorMobService?.mainCanvas)try{t.photoEditorMobService.mainCanvas.remove(t.faceReshapeService.faceBoundingBox)}catch{}const o=t.gestureService.exportCanvasIgnoringViewport(t.photoEditorMobService.mainCanvas);if(!o)return t.faceReshapeService.checkAndUpdateFaceBoundingBox(),void t.aiPhotoService.clearGenerationProgress();const r=yield new Promise((d,h)=>{const p=new Image;p.onload=()=>d(p),p.onerror=h,p.src=o}),l=new I.fabric.Image(r);l.set({selectable:!1}),t.photoEditorMobService.inputImage=l;const c=t.photoEditorMobService.mainCanvas;if(c&&(c.clear(),c.add(l),c.requestRenderAll()),t.faceReshapeService.setInputImage(l),yield t.faceReshapeService.detectLandmarksForSelectedFace(t.photoEditorMobService.originalImage),!t.faceReshapeService.faceDataModel)return void t.faceNotDetected({description:y.b.message.faceNotFound});t.faceReshapeService.checkAndUpdateFaceBoundingBox(),t.aiPhotoService.completeGenerationProgress()}catch{try{t.faceReshapeService.checkAndUpdateFaceBoundingBox()}catch{}t.aiPhotoService.clearGenerationProgress()}})()}onSideOptionChange(t){var i=this;return(0,w.A)(function*(){i.isCurrentSubtoolEdited()&&(yield i.recaptureAndRelandmark(),i.setPrevEqualsCurrent());const o=t||i.selectedSideOption,l=!!(i.sideOptionList||[]).find(d=>d.key===o)?.pro,c=()=>{i.previousSideOption=o,i.selectedSideOption=o,i.faceReshapeService.setSideOption(o);try{const d=(o||"Both").toLowerCase(),h=i.faceReshapeService.selectedSubTool,p=h&&h.values&&h.values[d];i.scaleValue=p&&"number"==typeof p.current?p.current:0}catch{}};!l||i.user&&(!i.user||i.user.subscribed)?c():i.subsService.loginWithUpgrade(()=>{i.user=i.authService.currentUser(),i.isProUser=i.aiPhotoService.isProUser(),i.user&&i.user.subscribed?c():setTimeout(()=>{i.selectedSideOption=i.previousSideOption},0)},{coinSectionHide:i.env.isMobileView},!0)})()}onPointerDown(){this.isCompare=!0,this.updateOriginalImageTransform()}onPointerUp(){this.isCompare=!1}updateOriginalImageTransform(){if(!this.photoEditorMobService.mainCanvas)return;const t=this.photoEditorMobService.mainCanvas.getZoom(),i=this.photoEditorMobService.mainCanvas.viewportTransform,l=`matrix(${t}, 0, 0, ${t}, ${i[4]}, ${i[5]})`;this.originalImg?.nativeElement&&(this.originalImg.nativeElement.style.transform=l)}focusOnSelectedFace(t){try{const i=(this.faceReshapeService.faceList||[]).find(_=>_?.id===this.faceReshapeService.selectedFaceId),o=this.photoEditorMobService.mainCanvas;if(!i||!o)return;const r=o.getWidth(),l=o.getHeight(),h=Math.min(.4*r/i.width,.4*l/i.height,2),p=i.originX+i.width/2,u=i.originY+i.height/2,g=[...o.viewportTransform||[1,0,0,1,0,0]];g[0]=h,g[3]=h,g[4]=r/2-p*h,g[5]=l/2-u*h,o.setViewportTransform(g),o.requestRenderAll(),this.scale=h,this.gestureService.clampPan(o,!0)}catch{}}resetAll(){var t=this;const i=()=>{this.aiPhotoService.startProcessingProgress({featureType:"facereshape",indeterminate:!0});try{this.faceReshapeService.resetAll()}catch{}this.scaleValue=0,this.isEdit=!1,this.selectedSideOption="Both",this.previousSideOption="Both",this.photoEditorMobService.mainCanvas.clear(),this.photoEditorMobService.mainCanvas.renderAll(),this.photoEditorMobService.reloadImage(this.photoEditorMobService.originalImage,(0,w.A)(function*(){try{t.faceReshapeService.setInputImage(t.photoEditorMobService.inputImage)}catch{}try{if(yield t.faceReshapeService.detectFaces(t.photoEditorMobService.originalImage),t.faceReshapeService.selectedFaceId){if(yield t.faceReshapeService.detectLandmarksForSelectedFace(t.photoEditorMobService.originalImage),!t.faceReshapeService.faceDataModel)return void t.faceNotDetected({description:y.b.message.faceNotFound});t.faceReshapeService.checkAndUpdateFaceBoundingBox();const r=(t.faceReshapeService.faceReshapeTools||[]).find(l=>"Shape"===l.type)||(t.faceReshapeService.faceReshapeTools||[])[0];r&&(t.faceReshapeService.selectTool(r),t.scaleValue=0)}t.aiPhotoService.completeGenerationProgress()}catch{t.aiPhotoService.clearGenerationProgress()}}))};this.dialogService.confirmDialog({title:y.b.message.resetAllMessage,okButtonText:"Reset All",cancelButtonText:"Cancel"}).result.then(r=>{"ok"==r&&i()})}download(){this.gtmService.pushTag({eventName:y.b.gtm.eventname.aiDownloadMob,itemName:"Editor_FaceReshape"}),fetch(this.aiPhotoService.imgUrl).then(i=>{let o="jpg";const r=i.headers.get("Content-Type");r&&r.includes("image/")&&(o=r.split("/")[1]),this.faceReshapeService.faceBoundingBox&&this.photoEditorMobService.mainCanvas.remove(this.faceReshapeService.faceBoundingBox);const l=this.gestureService.exportCanvasIgnoringViewport(this.photoEditorMobService.mainCanvas);l?this.photoEditorMobService.download(o,null,"untitled",l).then(()=>{this.faceReshapeService.checkAndUpdateFaceBoundingBox()}):this.faceReshapeService.checkAndUpdateFaceBoundingBox()})}setScaleVar(){const t=document.getElementById("canvasWrapper");if(!t||!this.photoEditorMobService?.inputImage)return;const i=t.getBoundingClientRect(),o=this.photoEditorMobService.inputImage,r=Math.min(i.height/o.height,i.width/o.width);
1this.scale=r,this.initialScale=r,this.originalImg?.nativeElement&&(this.originalImg.nativeElement.style.width=`${o.width}px`,this.originalImg.nativeElement.style.height=`${o.height}px`,this.originalImg.nativeElement.style.transformOrigin="0 0"),this.compareContainer?.nativeElement&&(this.compareContainer.nativeElement.style.width=`${this.photoEditorMobService.mainCanvas.width}px`,this.compareContainer.nativeElement.style.height=`${this.photoEditorMobService.mainCanvas.height}px`)}setZoomPinch(){this.gestureService.attachPinchPanHandlers(this.mainCanvas.nativeElement,this.photoEditorMobService.mainCanvas,{getScale:()=>this.scale,setScale:t=>{this.scale=t},getInitialScale:()=>this.initialScale,maxScale:2,centerWhenSmaller:!0})}ngOnDestroy(){this.renderer.removeClass(document.body,"overflow-hidden"),this.loggedInObserver&&this.loggedInObserver.unsubscribe(),this.usrPropChangedObserver&&this.usrPropChangedObserver.unsubscribe();try{this.photoEditorMobService.destroy()}catch{}}}return(s=a).\u0275fac=function(t){return new(t||s)(e.rXU(ne.A),e.rXU(Z.s),e.rXU(q.u),e.rXU(Ue.A),e.rXU(re),e.rXU(Q.f),e.rXU(Ce.u),e.rXU(At),e.rXU(ve),e.rXU(be),e.rXU(ue.n),e.rXU(xe.L),e.rXU(ae.g),e.rXU(b.aZ),e.rXU(e.sFG),e.rXU(ie.y))},s.\u0275cmp=e.VBU({type:s,selectors:[["face-reshape-mobile"]],viewQuery:function(t,i){if(1&t&&(e.GBs(Oa,7),e.GBs(Ea,5),e.GBs(ja,5),e.GBs(Ga,5),e.GBs(Va,5)),2&t){let o;e.mGM(o=e.lsd())&&(i.mainCanvas=o.first),e.mGM(o=e.lsd())&&(i.originalImg=o.first),e.mGM(o=e.lsd())&&(i.compareContainer=o.first),e.mGM(o=e.lsd())&&(i.fileInput=o.first),e.mGM(o=e.lsd())&&(i.canvasWrapperParent=o.first)}},outputs:{changeStep:"changeStep"},features:[e.Jv_([Ce.u,re,At,rt.g,Ft.x,he.V,Ie.r,st.z,R.iM])],decls:19,vars:11,consts:[["canvasWrapperParent",""],["file",""],["mainCanvas",""],["compareContainer",""],["originalImg",""],[1,"mobileRetouch","overflow-hidden"],[1,"drawer-elements","ai-drawer-elements","overflow-hidden"],[1,"d-flex","align-items-center","justify-content-center","overflow-hidden","w-100","flex-column","pt-3","ps-3","pe-3","border-radius-12","position-relative",3,"ngClass"],["type","file","accept","image/*",1,"d-none",3,"change"],["id","canvasWrapper",1,"d-flex","align-items-center","justify-content-center","overflow-hidden","w-100","flex-column","h-100"],["id","canvas-mask-wrapper",1,"d-flex","align-items-center","justify-content-center","overflow-hidden","border-radius-12","position-relative","h-100","bg-grey3","w-100",2,"overflow","auto"],["id","vmx-canvas","height","100%","width","100%","disableRC","",1,"position-relative",3,"ngClass"],[1,"mw-100","mh-100",2,"overflow","hidden",3,"ngClass"],["disableRC","",3,"src",4,"ngIf"],["class","d-flex align-items-center justify-content-center position-absolute hw-40 border-radius-50 btn-alpha","style","bottom: 8px; left: 24px;",3,"ngClass",4,"ngIf"],["class","d-flex align-items-center justify-content-center position-absolute hw-40 border-radius-50 btn-alpha","style","top: 24px; right: 24px;",3,"click",4,"ngIf"],["class","d-flex align-items-center justify-content-center position-absolute hw-40 border-radius-50 btn-alpha","style","bottom: 8px; right: 24px;",3,"ngClass","click",4,"ngIf"],[1,"",3,"ngClass"],[4,"ngIf"],["disableRC","",3,"src"],[1,"d-flex","align-items-center","justify-content-center","position-absolute","hw-40","border-radius-50","btn-alpha",2,"bottom","8px","left","24px",3,"ngClass"],[1,"btn","d-flex","align-items-center","justify-content-center","border-0",3,"pointerdown","pointerup","pointercancel","pointerleave"],["name","comparewhite",1,"f-24","text-white"],[1,"d-flex","align-items-center","justify-content-center","position-absolute","hw-40","border-radius-50","btn-alpha",2,"top","24px","right","24px",3,"click"],["name","downloadblack",1,"f-24","text-white"],[1,"d-flex","align-items-center","justify-content-center","position-absolute","hw-40","border-radius-50","btn-alpha",2,"bottom","8px","right","24px",3,"click","ngClass"],[1,"btn","d-flex","align-items-center","justify-content-center","border-0"],["name","reseticon",1,"f-24","text-white"],["class","filter-category mb-2 faceExpression-face ps-3",4,"ngIf"],[1,"mt-1"],[1,"d-flex","overflow-auto","new-scroll-behave","pb-2","pt-0","ps-3","pe-2"],["class","me-2","style","flex: 1 1 100%;",4,"ngFor","ngForOf"],["class","d-flex flex-column w-100 mobileRetouchStyle pt-2 overflow-hidden",4,"ngIf"],[1,"filter-category","mb-2","faceExpression-face","ps-3"],[1,"sticker-buttons-scroll","scrollWidth-300"],[3,"selectMenu","type","categoryId","items"],[1,"me-2",2,"flex","1 1 100%"],[1,"d-flex","align-items-center","wp-100"],[1,"btn-acc-title","btnTab","justify-content-center",3,"ngClass"],[1,"m-0","text-13","text-semi",3,"click"],[1,"d-flex","flex-column","w-100","mobileRetouchStyle","pt-2","overflow-hidden"],[1,"common-container","mb-0"],[1,"d-flex","align-items-center","justify-content-between","w-100",2,"min-height","28px"],[1,"text-13","grey-800","text-semi","d-inline-flex","w-100"],["bindLabel","value","bindValue","key","class","select-menu resize-popup both-sides","dropdownPosition","bottom",3,"items","ngModel","searchable","clearable","ngModelChange",4,"ngIf"],[1,"colors-bg","sticker-buttons-scroll","scrollWidth-268","text-highlight-style","prompt-menu","mb-0"],[3,"selectMenu","type","user","categoryId","sideKey","items"],[1,"card-body"],[1,"text-13","grey-800","text-semi"],[1,"d-flex","mt-2"],[1,"wp-100","d-flex","align-items-center"],[1,"opacity-slider",2,"width","100%",3,"slideStop","change","min","max","step","value"],[1,"ms-3"],["type","text","numberSettings","","maxlength","4","disabled","","mask","separator.2","separatorLimit","100",1,"form-control","form-input-sm","text-normal","text-black",2,"pointer-events","none",3,"min","max","ngModel"],["bindLabel","value","bindValue","key","dropdownPosition","bottom",1,"select-menu","resize-popup","both-sides",3,"ngModelChange","items","ngModel","searchable","clearable"],["ng-option-tmp",""],[1,"d-flex","align-items-center","justify-content-between","w-100"],[1,"d-inline-flex","f-12","text-semi","grey-800","align-items-center"],["class","d-inline-flex",4,"ngIf"],[1,"d-inline-flex"],["name","proicon",2,"line-height","normal"]],template:function(t,i){if(1&t){const o=e.RV6();e.j41(0,"div",5)(1,"div",6)(2,"div",7,0)(4,"input",8,1),e.bIt("change",function(l){return e.eBV(o),e.Njj(i.onFileUploaded(l.target.files))}),e.k0s(),e.j41(6,"div",9)(7,"div",10)(8,"canvas",11,2),e.EFF(10," Your browser does not support the HTML5 canvas tag. "),e.k0s(),e.j41(11,"div",12,3),e.DNE(13,Aa,2,1,"img",13),e.k0s()(),e.DNE(14,Ba,3,3,"div",14)(15,Ua,2,0,"div",15)(16,Da,3,3,"div",16),e.k0s()(),e.j41(17,"div",17),e.DNE(18,Ha,6,3,"ng-container",18),e.k0s()()()}2&t&&(e.R7$(2),e.Y8G("ngClass",(null==i.faceReshapeService.faceList?null:i.faceReshapeService.faceList.length)<=1?"single-face":"multiple-face"),e.R7$(6),e.Y8G("ngClass",e.eq3(9,Ra,i.isCompare)),e.R7$(3),e.Y8G("ngClass",i.isCompare?"d-flex":"d-none"),e.R7$(2),e.Y8G("ngIf",i.photoEditorMobService.originalImage),e.R7$(),e.Y8G("ngIf",i.isLoaded),e.R7$(),e.Y8G("ngIf",i.isLoaded),e.R7$(),e.Y8G("ngIf",i.isLoaded),e.R7$(),e.Y8G("ngClass",(null==i.faceReshapeService.faceList?null:i.faceReshapeService.faceList.length)<=1?"tabPanelBox-height mt-3":"tabPanelBox-height-multiple mt-2"),e.R7$(),e.Y8G("ngIf",i.isLoaded))},dependencies:[b.YU,b.Sq,b.bT,Me.G,Ge.I,P.me,P.BC,P.tU,P.vS,H.b,O.d1,_e.B,Se.KK,N.vr,N.Uq],styles:[".compare-stack[_ngcontent-%COMP%]   img[_ngcontent-%COMP%]{width:100%;object-fit:contain}@media screen and (max-height: 740px){.text-56[_ngcontent-%COMP%]{font-size:48px!important;line-height:58px!important}}@media screen and (max-height: 640px){.text-56[_ngcontent-%COMP%]{font-size:40px!important;line-height:50px!important}}@media screen and (max-height: 540px){.text-56[_ngcontent-%COMP%]{font-size:30px!important;line-height:40px!important}}.btnTab[_ngcontent-%COMP%]{border-radius:8px;border:1px solid #E2E3E9;background:#efeef2;padding:8px 16px;color:#272b34;width:100%!important;height:32px!important;line-height:normal}.btnTabActive[_ngcontent-%COMP%]{border:1px solid transparent;background:#626adf;color:#fff}#face-retouch-Skin[_ngcontent-%COMP%]{padding-left:8px}#face-retouch-Teeth[_ngcontent-%COMP%]{margin-right:16px}.content-box[_ngcontent-%COMP%]{transition:opacity .5s ease,transform .5s ease}.content-box.in[_ngcontent-%COMP%]{opacity:1;transform:translate(0)}.content-box.out[_ngcontent-%COMP%]{opacity:0;transform:translate(-50px)}.full-screen-container[_ngcontent-%COMP%]{display:flex;height:100vh}.left-column[_ngcontent-%COMP%], .right-column[_ngcontent-%COMP%]{flex:1;height:100%;overflow:auto}.left-column[_ngcontent-%COMP%]{background-color:#f5f5f5}.right-column[_ngcontent-%COMP%]{background-color:#e0e0e0}.mobileRetouchStyle[_ngcontent-%COMP%]{display:flex;transition:justify-content .4s ease}.animate-items[_ngcontent-%COMP%] > *[_ngcontent-%COMP%]{opacity:0;transform:translateY(10px);animation:_ngcontent-%COMP%_fadeInUp .4s ease forwards}.animate-items[_ngcontent-%COMP%] > *[_ngcontent-%COMP%]:nth-child(1){animation-delay:.1s}.animate-items[_ngcontent-%COMP%] > *[_ngcontent-%COMP%]:nth-child(2){animation-delay:.2s}.animate-items[_ngcontent-%COMP%] > *[_ngcontent-%COMP%]:nth-child(3){animation-delay:.3s}.animate-items[_ngcontent-%COMP%] > *[_ngcontent-%COMP%]:nth-child(4){animation-delay:.4s}.animate-items[_ngcontent-%COMP%] > *[_ngcontent-%COMP%]:nth-child(5){animation-delay:.5s}.animate-items[_ngcontent-%COMP%] > *[_ngcontent-%COMP%]:nth-child(6){animation-delay:.6s}@keyframes _ngcontent-%COMP%_fadeInUp{to{opacity:1;transform:translateY(0)}}.reseticon-none[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]{opacity:.3}.new-scroll-behave[_ngcontent-%COMP%]{-ms-overflow-style:none;scrollbar-width:none}.new-scroll-behave[_ngcontent-%COMP%]::-webkit-scrollbar{display:none}.multiple-face[_ngcontent-%COMP%]{height:calc(100dvh - 365px)}.single-face[_ngcontent-%COMP%]{height:calc(100dvh - 310px)!important}.tabPanelBox-height[_ngcontent-%COMP%]{max-height:230px!important}.tabPanelBox-height-multiple[_ngcontent-%COMP%]{max-height:290px!important}"]}),a})();function qa(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"inspiration-template-picker",3),e.bIt("selectedTemplate",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.openInsprrationsEditDialog(i))})("closePreview",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.focusOut())}),e.k0s(),e.bVm()}if(2&s){const n=e.XpG(2);e.R7$(),e.Y8G("categoryId",n.previewCategoryId)("aiPhotoService",n.aiPhotoService)("previewTitle","Preview")}}function Ka(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"inspirations-edit-mobile",4),e.bIt("changeStep",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.changeStepInp(i))}),e.k0s(),e.bVm()}if(2&s){const n=e.XpG(2);e.R7$(),e.Y8G("aiPhotoService",n.aiPhotoService)("isMobile",!0)("activeImgObj",n.activeImgObj)}}function Za(s,a){if(1&s&&(e.j41(0,"div",2),e.DNE(1,qa,2,3,"ng-container",1),e.j41(2,"div"),e.DNE(3,Ka,2,3,"ng-container",1),e.k0s()()),2&s){const n=e.XpG();e.R7$(),e.Y8G("ngIf",4!=n.step),e.R7$(2),e.Y8G("ngIf",4==n.step)}}function Ja(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",18),e.bIt("click",function(){const i=e.eBV(n).$implicit,o=e.XpG(2);return e.Njj(o.openTool(i))}),e.j41(1,"div",19)(2,"h3",20),e.EFF(3),e.k0s()(),e.j41(4,"div",21),e.nrm(5,"img",22),e.k0s()()}if(2&s){const n=a.$implicit;e.R7$(3),e.JRh(n.displayName),e.R7$(2),e.Y8G("src",n.thumbUrl,e.B4B)}}function Qa(s,a){if(1&s){const n=e.RV6();e.j41(0,"div")(1,"div",5)(2,"div",6)(3,"h2",7),e.EFF(4,"AI Design"),e.k0s(),e.j41(5,"button",8),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return i.isInspiration=!0,e.Njj(i.enableInspiration())}),e.nrm(6,"ei",9),e.j41(7,"span",10),e.EFF(8,"Inspirations"),e.k0s()()(),e.j41(9,"div",11),e.DNE(10,Ja,6,2,"div",12),e.k0s()(),e.j41(11,"div",13),e.nrm(12,"div",14),e.j41(13,"div",15)(14,"button",16),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.getGenericCategoryDesignDetails())}),e.EFF(15," Describe what you want to create"),e.nrm(16,"ei",17),e.k0s()()()()}if(2&s){const n=e.XpG();e.R7$(5),e.AVh("expanded",n.expanded),e.R7$(5),e.Y8G("ngForOf",n.storeProducts)}}let el=(()=>{var s;
1class a{emitChangeStep(t){this.changeStep.emit(t)}constructor(t,i){this.renderer=t,this.mediaContentService=i,this.changeStep=new e.bkB,this.changeInspirationStep=new e.bkB,this.isFocused=!1,this.productId=0,this.pageNumber=0,this.trackByIndex=(o,r)=>o,this.expanded=!1,this.previewCategoryId=se.KK.AIDesign,this.isInspiration=!1,this.activeToolPanel="aidesign",this.isLoaded=!1,this.storeProducts=[],this.productName="",this.step=1}ngOnInit(){this.getCategoryDesignDetails(),setTimeout(()=>{this.expanded=!0},1e3)}getCategoryDesignDetails(){this.mediaContentService.getProductListing(se.KK.AIDesign,this.pageNumber,t=>{this.isLoaded=!0;const i=t?.storeProducts||[];this.storeProducts=i,(!this.productId||this.productId<=0)&&i.length&&(this.productId=i[0].productId||0,this.activeProductObj=i[0])},t=>{this.isLoaded=!0},null)}openInsprrationsEditDialog(t){this.aiPhotoService.queryParams=Object.assign({},this.aiPhotoService.queryParams),t.productId=t.productId?t.productId:this.productId,this.step=4,this.aiPhotoService.queryParams.from="ai-inspiration",this.activeImgObj=t,this.aiPhotoService.inspirationImgUrl=t.imgUrl,this.aiPhotoService.compareImageUrl=t.imgUrl}openTool(t){this.changeStep.emit(t)}changeStepInp(t){t?.back?(this.step=1,this.isInspiration=!0):(this.step=t,this.openTool(this.activeProductObj))}focusOut(){document.body.classList.remove("overflow-hidden"),this.renderer.removeClass(document.body,"overflow-hidden"),this.isFocused=!1,1==this.isInspiration&&(this.isInspiration=!1)}getGenericCategoryDesignDetails(){this.isLoaded=!1,this.mediaContentService.getProductListing(se.KK.AIDesignGeneric,0,t=>{const i=t?.storeProducts||[];this.storeProducts=i,i.length>0&&(this.activeProductObj=i[0]||null,this.productId=0,this.openTool({productId:0})),this.isLoaded=!0},t=>{this.isLoaded=!0},null)}enableInspiration(){this.isInspiration=!0,this.renderer.addClass(document.body,"overflow-hidden")}}return(s=a).\u0275fac=function(t){return new(t||s)(e.rXU(e.sFG),e.rXU(we.Z))},s.\u0275cmp=e.VBU({type:s,selectors:[["inspiration-mobile"]],inputs:{productId:"productId",isInspiration:"isInspiration",activeTool:"activeTool",activeToolPanel:"activeToolPanel",aiPhotoService:"aiPhotoService",activeImgObj:"activeImgObj",activeProductObj:"activeProductObj",storeProducts:"storeProducts"},outputs:{changeStep:"changeStep",changeInspirationStep:"changeInspirationStep"},decls:2,vars:2,consts:[["class","container-fluid p-0 position-relative",4,"ngIf"],[4,"ngIf"],[1,"container-fluid","p-0","position-relative"],[3,"selectedTemplate","closePreview","categoryId","aiPhotoService","previewTitle"],[3,"changeStep","aiPhotoService","isMobile","activeImgObj"],[1,"container-fluid","p-0"],[1,"d-flex","align-items-center","justify-content-between","Inspiration-header","gray-100","p-3","pt-8","pb-8","position-fixed"],[1,"text-lg","text-semi","grey-900","m-0","lh-160"],[1,"btn","btnInspiration","d-flex","align-items-center","grey-600","border-0","ps-0","pe-0",3,"click"],["name","inspiration",1,"ms-1","me-1"],[1,"me-2"],[1,"templates-thumbs-list-modal","p-3","position-relative"],["class","design-tools-item border-radius-12 d-inline-flex align-items-center justify-content-between pointer",3,"click",4,"ngFor","ngForOf"],[1,"d-flex","align-items-center","justify-content-center","w-100","position-fixed","describe-section","flex-column"],[1,"top-gredient","d-flex","w-100"],[1,"d-flex","align-items-center","justify-content-center","gray-100","pt-1","w-100","ps-2","pe-2"],[1,"btn","text-14","grey-700","text-semi","describe-btn","w-100","mb-2","d-flex","align-items-center","justify-content-center",3,"click"],["name","describeprompt",1,"ms-2","f-28"],[1,"design-tools-item","border-radius-12","d-inline-flex","align-items-center","justify-content-between","pointer",3,"click"],[1,"d-inline-flex","align-items-center","justify-content-start","pl-9"],[1,"text-13","text-semi","grey-800","lh-140","mb-0"],[1,"d-inline-flex","align-items-center","overflow-hidden","item-image"],["height","100px","width","100px",1,"responsive",2,"left","0","position","inherit !important",3,"src"]],template:function(t,i){1&t&&e.DNE(0,Za,4,2,"div",0)(1,Qa,17,3,"div",1),2&t&&(e.Y8G("ngIf",i.isInspiration),e.R7$(),e.Y8G("ngIf",!i.isInspiration))},dependencies:[b.Sq,b.bT,qe,Se.KK,ft],styles:[".inspiration-mobile-container[_ngcontent-%COMP%]{padding:16px;text-align:center}.masonry[_ngcontent-%COMP%]{width:100%;margin:0 auto;position:relative;padding:0;box-sizing:border-box;min-height:100px}.item[_ngcontent-%COMP%]{position:absolute;overflow:hidden}.item[_ngcontent-%COMP%]   img[_ngcontent-%COMP%]{width:100%;height:auto;display:block;object-fit:cover}.remixBtnDiv[_ngcontent-%COMP%]{opacity:0;transition:opacity .3s ease;background:#00000080}.item[_ngcontent-%COMP%]:hover   .remixBtnDiv[_ngcontent-%COMP%]{opacity:1}@media (max-width: 1024px){.masonry[_ngcontent-%COMP%]{width:750px}}@media (max-width: 768px){.masonry[_ngcontent-%COMP%]{width:500px}}@media (max-width: 480px){.masonry[_ngcontent-%COMP%]{width:100%}}.Inspiration-header[_ngcontent-%COMP%]{height:48px;left:0;top:48px;width:100%}.templates-thumbs-list-modal[_ngcontent-%COMP%]{display:grid;grid-template-columns:1fr 1fr;gap:.5rem;width:100%;top:48px;padding-bottom:80px!important}.templates-thumbs-list-modal[_ngcontent-%COMP%]   .design-tools-item[_ngcontent-%COMP%]{background:#626adf0d;max-height:74px;overflow:hidden}.templates-thumbs-list-modal[_ngcontent-%COMP%]   .design-tools-item[_ngcontent-%COMP%]   .item-image[_ngcontent-%COMP%]{min-width:66px;max-width:66px;height:74px;padding-top:22px;position:relative;padding-left:6px;overflow:hidden}.templates-thumbs-list-modal[_ngcontent-%COMP%]   .design-tools-item[_ngcontent-%COMP%]   .item-image[_ngcontent-%COMP%]   img[_ngcontent-%COMP%]{width:60px;height:60px;transform:rotate(-6deg);aspect-ratio:60/60;border-radius:10.87px}.templates-thumbs-list-modal[_ngcontent-%COMP%]   .design-tools-item[_ngcontent-%COMP%]:hover{background:#626adf0d}.btnInspiration[_ngcontent-%COMP%]{border-radius:8px;background:linear-gradient(90deg,#fc5cff1a -4%,#2520f61a),#fff;width:28px;height:28px;color:#4a4f5e;font-size:11px;line-height:140%;white-space:nowrap;overflow:hidden;transition:width .3s ease-in-out}.btnInspiration[_ngcontent-%COMP%]   .text[_ngcontent-%COMP%]{opacity:0;transition:opacity .3s ease-in-out}.expanded[_ngcontent-%COMP%]{width:99px}.expanded[_ngcontent-%COMP%]   .text[_ngcontent-%COMP%]{opacity:1}.describe-section[_ngcontent-%COMP%]{bottom:0}
1.describe-section[_ngcontent-%COMP%]   .top-gredient[_ngcontent-%COMP%]{height:20px;background:linear-gradient(0deg,#f8f9f9 12.5%,#f8f9f900)}.describe-section[_ngcontent-%COMP%]   .describe-btn[_ngcontent-%COMP%]{border-radius:60px;border:1px solid #E2E3E9;background:linear-gradient(90deg,#fc5cff1a -4%,#2520f61a);outline:none;height:52px}.showpreview-overlay[_ngcontent-%COMP%]{display:none;background:#0003;-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);width:100%;height:100%;top:0;bottom:0;z-index:999}.masonry-preview[_ngcontent-%COMP%]{top:0;z-index:99999;border-radius:20px 20px 0 0;left:0;height:calc(100vh - 48px);overflow:auto}.masonry-preview[_ngcontent-%COMP%]   .masnory-header[_ngcontent-%COMP%]{width:100%;z-index:99;left:0;right:0;top:44px;border-top-left-radius:20px;border-top-right-radius:20px}.masonry-preview[_ngcontent-%COMP%]{-ms-overflow-style:none;scrollbar-width:none}.masonry-preview[_ngcontent-%COMP%]::-webkit-scrollbar{display:none}[_nghost-%COMP%]     .masonry-preview{height:calc(100vh - 104px)!important}[_nghost-%COMP%]     .masonry{height:calc(100% - 84px)!important}"]}),a})();const tl=["cpText"],il=["carousel"],De=s=>({"d-none":s}),nl=(s,a)=>({"d-none":s,"workflow-generation":a}),ol=(s,a,n)=>({"info-up":s,"info-blue":a,"info-red":n}),Ut=s=>({"btn-tab-active":s}),sl=(s,a,n)=>({"hide-arrow":s,isFirst:a,isLast:n}),rl=s=>({"active-modal":s});function al(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"div",26)(2,"ul",27)(3,"li",28),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.selectTab("workflow"))}),e.j41(4,"a",29),e.EFF(5,"Workflow"),e.k0s()(),e.j41(6,"li",28),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.selectTab("prompt"))}),e.j41(7,"a",29),e.EFF(8,"Prompt"),e.k0s()()()(),e.bVm()}if(2&s){const n=e.XpG();e.R7$(3),e.Y8G("ngClass",e.eq3(2,Ut,"workflow"==n.selectedTab)),e.R7$(3),e.Y8G("ngClass",e.eq3(4,Ut,"prompt"==n.selectedTab))}}function ll(s,a){if(1&s&&(e.nrm(0,"img",43),e.nI1(1,"safe")),2&s){const n=e.XpG(2).$implicit;e.Y8G("src",e.i5U(1,1,n.urls[0],"url"),e.B4B)}}function cl(s,a){if(1&s&&(e.j41(0,"div",40)(1,"div",41),e.DNE(2,ll,2,4,"img",42),e.k0s()()),2&s){const n=e.XpG().$implicit;e.R7$(2),e.Y8G("ngIf",n.urls[0])}}function dl(s,a){if(1&s){const n=e.RV6();e.DNE(0,cl,3,1,"ng-template",39),e.bIt("slid",function(i){const o=e.eBV(n),r=o.first,l=o.last,c=e.XpG(2);return e.Njj(c.nextSlide(i,r,l))})}2&s&&e.Y8G("id",a.$implicit.assetId)}function hl(s,a){if(1&s){const n=e.RV6();e.j41(0,"ng-contianer",30)(1,"ngb-carousel",31,3),e.bIt("slide",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.onSlide(i))}),e.DNE(3,dl,1,1,null,32),e.k0s(),e.j41(4,"button",33),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.GotoRemix(i.index))}),e.nrm(5,"pi",34),e.EFF(6,"Change with AI "),e.k0s(),e.j41(7,"div",35),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.reportAbuse())}),e.nrm(8,"pi",36),e.k0s(),e.j41(9,"div",37),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.download())}),e.nrm(10,"pi",38),e.k0s()()}if(2&s){const n=e.XpG();e.R7$(),e.Y8G("activeId",n.activeId)("wrap",!1)("interval",0)("ngClass",e.sMw(5,sl,(null==n.aiPhotoService?null:n.aiPhotoService.aiImages)&&(null==n.aiPhotoService?null:n.aiPhotoService.aiImages.length)<=1,n.isFirst,n.isLast)),e.R7$(2),e.Y8G("ngForOf",null==n.aiPhotoService?null:n.aiPhotoService.aiImages)}}function pl(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",48),e.bIt("click",function(){const i=e.eBV(n).$implicit,o=e.XpG(2);return e.Njj(o.selectPrompt(i))}),e.j41(1,"div",49),e.EFF(2),e.k0s()()}if(2&s){const n=a.$implicit;e.R7$(2),e.JRh(n.prompt)}}function ml(s,a){if(1&s&&(e.j41(0,"ng-contianer",44)(1,"h3",45),e.EFF(2,"Prompt Examples"),e.k0s(),e.j41(3,"p",46),e.EFF(4,"Take suggestions for quick edits"),e.k0s(),e.DNE(5,pl,3,1,"div",47),e.k0s()),2&s){const n=e.XpG();e.R7$(5),e.Y8G("ngForOf",n.prompts)}}function ul(s,a){1&s&&e.eu8(0)}function gl(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"div",50)(2,"div",51)(3,"button",52),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.openStylePanel())}),e.EFF(4,"Style"),e.j41(5,"span",53),e.EFF(6),e.k0s()()(),e.j41(7,"div",54),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return i.step=2,e.Njj(i.focusIn())}),e.j41(8,"div",55)(9,"span",56),e.EFF(10,"Imagine anything, type it"),e.k0s(),e.EFF(11),e.k0s()(),e.j41(12,"div",57),e.DNE(13,ul,1,0,"ng-container",24),e.k0s()(),e.bVm()}if(2&s){const n=e.XpG(),t=e.sdS(35);e.R7$(),e.Y8G("ngClass",e.eq3(5,De,1!=n.step)),e.R7$(5),e.SpI("\xa0",null==n.selectedStyle?null:n.selectedStyle.displayName,""),e.R7$(3),e.Y8G("ngClass",e.eq3(7,De,n.customPrompt&&""!=n.customPrompt)),e.R7$(2),e.JRh(n.customPrompt),e.R7$(2),e.Y8G("ngTemplateOutlet",t)}}function _l(s,a){if(1&s&&(e.j41(0,"span",58),e.EFF(1),e.k0s()),2&s){const n=e.XpG();e.R7$(),e.Lme("",n.customPrompt.length,"/",n.maxLenght,"")}}function fl(s,a){1&s&&e.eu8(0)}function vl(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",64),e.bIt("click",function(){const i=e.eBV(n).$implicit,o=e.XpG(2);return e.Njj(o.selectModel(i))}),e.j41(1,"div",65)(2,"div",66)(3,"div",67),e.nrm(4,"img",68),e.k0s(),e.j41(5,"span",69),e.EFF(6),e.k0s()(),e.j41(7,"div",70)(8,"span",71),e.EFF(9),e.k0s()()(),e.j41(10,"div",72),e.nrm(11,"img",73),e.j41(12,"span",74),e.EFF(13),e.k0s()()()}if(2&s){const n=a.$implicit,t=e.XpG(2);e.Y8G("ngClass",e.eq3(5,rl,n.id==(null==t.selectedModel?null:t.selectedModel.id))),e.R7$(4),e.FS9("src",n.icon,e.B4B),e.R7$(2),e.JRh(n.displayName),e.R7$(3),e.JRh(n.desc),e.R7$(4),e.JRh(n.dCoin)}}function bl(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"div",59),e.bIt("close",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.step=1)}),e.j41(2,"div",60)(3,"h3",61),e.EFF(4,"AI Model "),e.j41(5,"pi",13),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.step=1)}),e.k0s()(),e.j41(6,"span",62),e.EFF(7,"Select an AI image generation model that suit your results."),e.k0s()(),e.DNE(8,vl,14,7,"div",63),e.k0s(),e.bVm()}if(2&s){const n=e.XpG();e.R7$(8),e.Y8G("ngForOf",n.models)}}function Cl(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",81),e.bIt("click",function(){const i=e.eBV(n).$implicit,o=e.XpG(2);return e.Njj(o.selectSize(i))}),e.j41(1,"div",82),e.nrm(2,"pi",83),e.j41(3,"span",84),e.EFF(4),e.k0s(),e.j41(5,"span",85),e.EFF(6),e.k0s()(),e.j41(7,"div",82)(8,"span",86),e.EFF(9),e.k0s()()()}if(2&s){const n=a.$implicit;e.R7$(2),e.FS9("name",n.icon),e.R7$(2),e.JRh(n.name),e.R7$(2),e.JRh(n.ratio),e.R7$(3),e.SpI("",n.size," px")}}function xl(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"div",75),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.closeResolutionPanel())}),e.k0s(),e.j41(2,"div",76)(3,"div",77)(4,"div",78)(5,"h3",79),e.EFF(6,"Resolution"),e.j41(7,"pi",13),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.closeResolutionPanel())}),e.k0s()()(),e.DNE(8,Cl,10,4,"div",80),e.k0s()(),e.bVm()}if(2&s){const n=e.XpG();e.R7$(),e.AVh("mobile-sheet-overlay--open",n.resolutionPanelOpen),e.R7$(),e.AVh("mobile-sheet-anim--open",n.resolutionPanelOpen),e.R7$(6),e.Y8G("ngForOf",n.resolutions)}}function Pl(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"div",75),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.closeStylePanel())}),e.k0s(),e.j41(2,"div",87)(3,"div",88)(4,"choose-style",89),e.bIt("close",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.closeStylePanel())})("styleScrollEnd",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.onStyleScrollEnd())})("selectStyleEvent",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.selectStyle(i))}),e.k0s()()(),e.bVm()}if(2&s){const n=e.XpG();e.R7$(),e.AVh("mobile-sheet-overlay--open",n.stylePanelOpen),e.R7$(),e.AVh("mobile-sheet-anim--open",n.stylePanelOpen),e.R7$(2),e.Y8G("products",n.storeProducts)("editorType",n.toolName)("productImageId",n.productImageId)("isImagesLoading",n.isLoadingMoreStyleImages)("isImagesEnd",n.isStyleImagesEnd)("loadingPlaceholders",n.styleLoadingPlaceholders)("selectedStyle",n.selectedStyle)}}function Il(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"add-credit",90),e.bIt("close",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.step=1)})("addCredit",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.addCredit())}),e.k0s(),e.bVm()}if(2&s){const n=e.XpG();e.R7$(),e.Y8G("consumeCoins",null==n.selectedModel?null:n.selectedModel.dCoin)}}function yl(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"div",91),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return i.step=1,e.Njj(i.focusOut())}),e.k0s(),e.bVm()}}function wl(s,a){1&s&&e.eu8(0)}function Sl(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"div",92)(2,"div",93)(3,"workflow-ui",94),e.mxI("productC
1onfigChange",function(i){e.eBV(n);const o=e.XpG();return e.DH7(o.productConfig,i)||(o.productConfig=i),e.Njj(i)}),e.bIt("productConfigChange",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.productConfigChange(i))}),e.k0s()(),e.j41(4,"div",95)(5,"button",96),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.editWorkflow())}),e.EFF(6,"Edit Workflow"),e.k0s()(),e.j41(7,"div",97),e.DNE(8,wl,1,0,"ng-container",24),e.k0s()(),e.bVm()}if(2&s){const n=e.XpG(),t=e.sdS(35);e.R7$(),e.xc7("height",0===(null==n.aiPhotoService||null==n.aiPhotoService.aiImages?null:n.aiPhotoService.aiImages.length)&&n.productConfig?"calc(100dvh - 175px)":"calc(100dvh - 90px)"),e.R7$(),e.AVh("d-none",!n.aiPhotoService.isWorkflow&&(null==n.aiPhotoService?null:n.aiPhotoService.aiImages)&&(null==n.aiPhotoService?null:n.aiPhotoService.aiImages.length)),e.R7$(),e.R50("productConfig",n.productConfig),e.Y8G("workflowList",n.workflowList)("inProgress",n.aiPhotoService.inProgress),e.R7$(),e.Y8G("ngClass",n.aiPhotoService.isWorkflow?"d-none":"d-flex"),e.R7$(4),e.Y8G("ngTemplateOutlet",t)}}function Ml(s,a){1&s&&e.nrm(0,"div")}function kl(s,a){if(1&s&&(e.qex(0),e.DNE(1,Ml,1,0,"div",24),e.bVm()),2&s){e.XpG();const n=e.sdS(33);e.R7$(),e.Y8G("ngTemplateOutlet",n)}}function Tl(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",98),e.nrm(1,"img",99),e.j41(2,"div",100)(3,"h4",101),e.EFF(4,"Congratulations!"),e.k0s(),e.j41(5,"span",102),e.EFF(6),e.k0s()(),e.j41(7,"div",103)(8,"span",104),e.EFF(9,"1 generation ="),e.k0s(),e.j41(10,"span",105),e.nrm(11,"img",106),e.k0s(),e.j41(12,"span",104),e.EFF(13),e.k0s()(),e.j41(14,"button",107),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return i.isLogin=!1,e.Njj(i.generate())}),e.EFF(15,"Got it"),e.k0s()()}if(2&s){const n=e.XpG();e.R7$(6),e.SpI(" You now have ",null==n.user?null:n.user.remainingCoins," free AI credits everyday. "),e.R7$(7),e.SpI("",null==n.selectedModel?null:n.selectedModel.dCoin," credit")}}function Ol(s,a){1&s&&(e.j41(0,"div",118)(1,"span",119),e.EFF(2,"Loading..."),e.k0s()())}function El(s,a){if(1&s){const n=e.RV6();e.j41(0,"button",108),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.openResolutionPanel())}),e.j41(1,"span",109),e.EFF(2),e.k0s(),e.nrm(3,"pi",110),e.k0s(),e.j41(4,"button",111),e.bIt("keyup.enter",function(){e.eBV(n);const i=e.XpG();return i.focusOut(),e.Njj(i.generate())})("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.generate())}),e.DNE(5,Ol,3,0,"div",112),e.j41(6,"span",113),e.EFF(7),e.k0s(),e.j41(8,"span",114),e.nrm(9,"img",115)(10,"img",116),e.j41(11,"b",117),e.EFF(12),e.k0s()()()}if(2&s){const n=e.XpG();e.Y8G("ngClass",e.eq3(6,De,1!=n.step||"workflow"==n.selectedTab&&!n.aiPhotoService.isWorkflow)),e.R7$(2),e.JRh(null==n.selectedSize?null:n.selectedSize.ratio),e.R7$(2),e.Y8G("disabled",n.disabled||"prompt"==n.selectedTab&&(null==n.customPrompt?null:n.customPrompt.length)<=0),e.R7$(),e.Y8G("ngIf",n.aiPhotoService.inProgress),e.R7$(2),e.JRh(null!=n.aiPhotoService.aiImages&&n.aiPhotoService.aiImages.length&&!n.aiPhotoService.isWorkflow?"Generate More":"Generate"),e.R7$(5),e.JRh(null==n.selectedModel?null:n.selectedModel.dCoin)}}let jl=(()=>{var s;class a{constructor(t,i,o,r,l,c,d,h,p,u,g,_,v,C,M,k){this.mediaContentService=t,this.document=i,this.aiPhotoService=o,this.dialogService=r,this.authService=l,this.createPopupService=c,this.aiUploadImageService=d,this.gtmService=h,this.toast=p,this.configService=u,this.aiGenService=g,this.paymentService=_,this.templateService=v,this.downloadService=C,this.offcanvasService=M,this.workflowUIService=k,this.changeStep=new e.bkB,this.step=1,this.isLogin=!1,this.selectedStyle={displayName:"None"},this.showAds=!1,this.enableAds=0,this.disabled=!1,this.storeProducts=[],this.prompts=[],this.customPrompt="",this.isFocused=!1,this.previewUrl="",this.index=0,this.isFirst=!1,this.isLast=!0,this.resolutions=[],this.models=[],this.isProUser=!1,this.changeInspiration=new e.bkB,this.activeId=0,this.productImageId=-1,this.productId=0,this.styleProductId=0,this.styleImageUrl="",this.selectedTab="",this.productConfig=null,this.workflowList=[],this.isShowPreview=!1,this.PANEL_ID={prompt:"prompt",workflow:"workflow"},this.maxLenght=2e3,this.resolutionPanelMounted=!1,this.resolutionPanelOpen=!1,this.resolutionPanelCloseTimer=null,this.stylePanelMounted=!1,this.stylePanelOpen=!1,this.stylePanelCloseTimer=null,this.styleImagePageNumber=0,this.isLoadingMoreStyleImages=!1,this.isStyleImagesEnd=!1,this.styleLoadingPlaceholders=[0,1],this.backBtnSub=[],this.user=this.authService.currentUser(),this.loggedInObserver=this.authService.loggedIn.subscribe(G=>{this.user=this.authService.currentUser(),this.isProUser=this.aiPhotoService.isProUser(),this.checkAds()}),this.usrPropChangedObserver=this.authService.usrPropChanged.subscribe(G=>{this.user=this.authService.currentUser(),this.isProUser=this.aiPhotoService.isProUser(),this.checkAds()}),this.updateBehaviorUserAiConis=this.authService.updateBehaviorUserAiConis.subscribe(G=>{this.user=this.authService.currentUser(),this.isProUser=this.aiPhotoService.isProUser(),G&&this.checkAds()}),this.settingsUpdateObserver=this.configService.updateAds.subscribe(G=>{G&&(this.enableAds=this.configService.showMobileAds,this.checkAds())}),this.paymentServiceSubs=this.paymentService.configUpdated.subscribe(G=>{G&&!this.config&&this.getModels()}),this.changeWorkflowObserver=this.workflowUIService.changeWorkflowSubject.subscribe(G=>
1{this.disabled=this.workflowUIService.isDisabled(this.productConfig,this.disabled)});const j=this;j.aiPhotoService.generateImageFn=function(){var G=(0,w.A)(function*(U,F){U?.assetId&&j?.carousel&&!U?.urls&&(j.activeId=U.assetId,j.carousel.select(U.assetId))});return function(U,F){return G.apply(this,arguments)}}(),this.backBtnSub.push(this.aiPhotoService.backBtnClick.subscribe(G=>{G?.isBack&&!this.aiPhotoService.isWorkflow&&this.selectedTab==j.PANEL_ID.workflow&&(this.aiPhotoService.isWorkflow=!0)}))}ngOnInit(){if(this.toolName=this.featureType,this.isLoaded=!0,this.productId>0?this.getCategoryDesignDetails():(this.selectedTab=this.PANEL_ID.prompt,this.getGenericCategoryDesignDetails()),this.aiPhotoService?.aiImages&&this.aiPhotoService?.aiImages.length>0&&this.aiPhotoService.mobileImageObj){let t=this.aiPhotoService?.aiImages.find(o=>o.assetId===this.aiPhotoService.mobileImageObj.assetId),i=this.aiPhotoService?.aiImages.findIndex(o=>o.assetId===this.aiPhotoService.mobileImageObj.assetId);i>=this.aiPhotoService.aiImages.length-1&&(this.isLast=!0),0==i&&(this.isFirst=!0),this.activeId=t?t.assetId:this.aiPhotoService?.aiImages[0].assetId}}getCategoryDesignDetails(){this.mediaContentService.getProductListing(se.KK.AIDesign,0,t=>{if(this.isProUser=this.aiPhotoService.isProUser(),this.isLoaded=!0,t&&(this.storeProducts=t.storeProducts,this.storeProducts.length&&this.productId))if(this.selectedFilters=this.storeProducts.filter(i=>i.productId==this.productId)[0],this.selectedFilters){let i;this.productConfig=this.selectedFilters?.productConfig||null,this.selectedTab=this.productConfig?this.PANEL_ID.workflow:this.PANEL_ID.prompt,this.aiPhotoService.isWorkflow="workflow"==this.selectedTab&&!this.aiPhotoService.aiImages?.length,this.aiPhotoService.isWorkflow?(this.step=1,this.disabled=this.workflowUIService.isDisabled(this.productConfig,this.disabled)):this.selectedTab=this.PANEL_ID.prompt,this.getPrompts(),this.styleProductId=this.selectedFilters&&this.selectedFilters.styleProduct&&this.selectedFilters.styleProduct.styleProductId?this.selectedFilters.styleProduct.styleProductId:this.productId,this.get
1StyleCategoryDetails();const o=this.selectedFilters&&this.selectedFilters.storeProductImages&&this.selectedFilters.storeProductImages.length>0?this.selectedFilters.storeProductImages:[];if(o&&o.length>0)if(this.productImageId){const r=o.findIndex(c=>c.productImageId==this.productImageId);i=o.find(c=>c.productImageId==this.productImageId)||o[0],this.productImageId=i.productImageId,i&&-1!=r&&(o.splice(r,1),o.splice(0,0,i))}else i=this.selectedFilters&&this.selectedFilters.storeProductImages&&this.selectedFilters.storeProductImages.length>0?this.selectedFilters.storeProductImages[0]:null,this.productImageId=i&&i.productImageId?i.productImageId:-1}else this.productId=0,this.selectedTab=this.PANEL_ID.prompt,this.getGenericCategoryDesignDetails()},t=>{this.isLoaded=!0},null)}getGenericCategoryDesignDetails(){this.mediaContentService.getProductListing(se.KK.AIDesignGeneric,0,t=>{if(t){let i=t.storeProducts;if(i.length>0){let o=i[0];(!this.productId||this.productId<=0)&&(this.productId=o.productId?o.productId:0,this.styleProductId=o&&o.styleProduct&&o.styleProduct.styleProductId?o.styleProduct.styleProductId:0,this.getPrompts(),this.getStyleCategoryDetails())}}},t=>{this.isLoaded=!0},null)}getStyleCategoryDetails(t=!0){if(!this.styleProductId||this.isLoadingMoreStyleImages||!t&&this.isStyleImagesEnd)return;const i=t?0:this.styleImagePageNumber+1;t&&(this.styleImagePageNumber=0,this.isStyleImagesEnd=!1,this.storeProducts?.storeProductImages&&(this.storeProducts.storeProductImages=[])),this.isLoadingMoreStyleImages=!0,this.templateService.getTemplateByProductIdCenter(this.styleProductId,i,o=>{this.isLoaded=!0;const r=o?.storeProductImages||[];if((t||!this.storeProducts?.storeProductImages)&&(this.storeProducts={...o||{},storeProductImages:[]}),r.length){const c=this.storeProducts.storeProductImages||[],d=new Set(c.map(p=>p.productImageId)),h=r.filter(p=>!d.has(p.productImageId));this.storeProducts.storeProductImages=c.concat(h),this.isStyleImagesEnd=r.length<a.STYLE_IMAGE_PAGE_SIZE||0===h.length}else this.isStyleImagesEnd=!0;this.styleImagePageNumber=i,this.isLoadingMoreStyleImages=!1,t&&this.applyInitialStyleSelection(),!this.isStyleImagesEnd&&(this.storeProducts?.storeProductImages?.length||0)<a.STYLE_MIN_IMAGES_FOR_SCROLL&&setTimeout(()=>this.getStyleCategoryDetails(!1))},o=>{this.isLoaded=!0,this.isLoadingMoreStyleImages=!1},null,void 0,a.STYLE_IMAGE_PAGE_SIZE)}onStyleScrollEnd(){this.getStyleCategoryDetails(!1)}applyInitialStyleSelection(){if(this.selectedStyle?.productImageId)return this.productImageId=this.selectedStyle.productImageId,void(this.styleImageUrl=this.selectedStyle?.imgUrl?this.selectedStyle.imgUrl:"");if(this.selectedStyle={productImageId:-1,imageJson:"",isGenerated:!1,id:1,displayName:"None"},this.aiPhotoService.queryParams?.productId&&"aidesign"==this.aiPhotoService.queryParams?.tab){const i=(this.storeProducts?.storeProductImages||[]).find(o=>o.productImageId==this.aiPhotoService.queryParams?.productImageId);i&&(this.selectedStyle=i,this.productImageId=this.selectedStyle?.productImageId)}}selectModel(t){this.selectedModel=t,this.selectedModel.dCoin=this.config.creditInfo?.design?this.config.creditInfo?.design:this.selectedModel.dCoin,this.getResolution(),this.selectedSize=this.resolutions[0],this.step=1}selectSize(t){this.selectedSize=t,this.closeResolutionPanel()}openResolutionPanel(){this.getResolution(),this.resolutionPanelCloseTimer&&(clearTimeout(this.resolutionPanelCloseTimer),this.resolutionPanelCloseTimer=null),this.step=4,this.resolutionPanelMounted=!0,this.resolutionPanelOpen=!1,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.resolutionPanelOpen=!0})})}closeResolutionPanel(){this.resolutionPanelOpen=!1,this.step=1,this.resolutionPanelCloseTimer&&clearTimeout(this.resolutionPanelCloseTimer),this.resolutionPanelCloseTimer=setTimeout(()=>{this.resolutionPanelMounted=!1,this.resolutionPanelCloseTimer=null},760)}openStylePanel(){this.stylePanelCloseTimer&&(clearTimeout(this.stylePanelCloseTimer),this.stylePanelCloseTimer=null),this.step=5,this.stylePanelMounted=!0,this.stylePanelOpen=!1,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.stylePanelOpen=!0})})}closeStylePanel(){this.stylePanelOpen=!1,this.step=1,this.stylePanelCloseTimer&&clearTimeout(this.stylePanelCloseTimer),this.stylePanelCloseTimer=setTimeout(()=>{this.stylePanelMounted=!1,this.stylePanelCloseTimer=null},760)}selectStyle(t){this.selectedStyle=t,this.productImageId=t?.productImageId&&t.productImageId>0?t.productImageId:-1}getCategoryProductDetails(t,i=null){this.storeProducts=null,this.mediaContentService.getCategoryProductDetails(t,0,o=>{o&&o.body&&(this.storeProducts=o.body.storeProducts,this.getPrompts()),i&&i()},o=>{this.isLoaded=!0})}getCategoryDetails(t,i=null){this.mediaContentService.getCategoryDetails(t,Ae.i.Main,o=>{i&&i(o?.storeCategory?.subCategoryList||[])},o=>{})}nextSlide(t,i,o){t.isShown&&(i?(this.isLast=!1,this.isFirst=!0):o?(this.isFirst=!1,this.isLast=!0):(this.isLast=!1,this.isFirst=!1))}generate(){if(this.user=this.authService.currentUser(),this.isProUser=this.aiPhotoService.isProUser(),this.aiPhotoService.isCancel)this.toast.showErrorSingle(y.b.message.uploadNewImage);else if(!this.aiPhotoService.inProgress){if(!(this.customPrompt&&this.customPrompt.trim()||this.selectedTab!=this.PANEL_ID.prompt))return this.step=2,void this.focusIn();if(this.step=1,this.user&&this.user.remainingCoins>=this.selectedModel?.dCoin){const t=this.prepareInputData();this.aiPhotoService.startGenerationProgress({featureType:this.featureType||this.toolName});const i=new Date;this.clearTimeInterval(),this.aiPhotoService.generateImage(t,o=>{o&&o.assetId?this.aiPhotoService.checkStatusResponsive(o,0,l=>{(this.aiPhotoService.processingProgress.isActive||this.aiPhotoService.inProgress||this.aiPhotoService.inVideoProgress)&&this.outputResult(l,i)},l=>{this.displayErrorMsg(l,i)}):this.displayErrorMsg(o,i)},o=>{this.displayErrorMsg(o,i)})}else this.aiPhotoService.loginAndAICredit(t=>{this.user=this.authService.currentUser(),this.isProUser=this.aiPhotoService.isProUser(),this.user&&(t?.isFreeUser?this.isLogin=!0:!this.user.remainingCoins||this.user.remainingCoins<this.selectedModel?.dCoin?this.step=6:this.generate())})}}closeProgress(t){this.aiPhotoService.completeGenerationProgress()}displayErrorMsg(t=null,i){this.aiPhotoService.clearGenerationProgress(),this.createPopupService.openWarningDialog("Error",t?.description)}getPrompts(t=null){this.mediaContentService.getPrompts(se.Jl.AiDesign,i=>{if(i){const o=i.prompts;this.prompts=o&&o.length>=3?this.getRandomValues(o,3):o}t&&t()},i=>{},this.productId)}getRandomValues(t,i){return[...t].sort(()=>Math.random()-.5).slice(0,i)}selectPrompt(t){this.step=1,this.customPrompt=t.prompt,this.disabled=!1}changePrompt(){this.disabled=!this.customPrompt.trim()}focusIn(){document.body.classList.add("overflow-hidden"),this.isFocused=!0,setTimeout(()=>{this.cpText&&this.cpText.nativeElement.focus()},100),this.intervalSub&&this.intervalSub.unsubscribe();const t=(i=0)=>{setTimeout(()=>{this.cpText&&(this.cpText.nativeElement.placeholder=""),i<2&&(i++,t(i))},500)};t()}focusOut(){document.body.classList.remove("overflow-hidden"),this.isFocused=!1,this.intervalSub&&this.intervalSub.unsubscribe(),2==this.step&&!this.customPrompt&&this.prompts?.length&&setTimeout(()=>{this.cpText&&(this.cpText.nativeElement.placeholder=this.prompts&&this.prompts.length?this.prompts[0].prompt:""),this.textAnimation(this.prompts)},500)}prepareInputData(){return{featureType:f.Fs.Design,quality:this.selectedSize.qType,...this.selectedTab==this.PANEL_ID.prompt&&{...this.customPrompt&&this.customPrompt.trim()&&{textPrompt:this.customPrompt},...this.selectedStyle.productImageId&&this.selectedStyle.productImageId>0&&{productImageId:this.selectedStyle.productImageId},productId:this.productId?this.productId:this.selectedStyle.productId}
1,...this.productConfig&&this.selectedTab==this.PANEL_ID.workflow&&{...this.productConfig?.modelTypeId&&{model:this.productConfig.modelTypeId},worksFlow:{...this.workflowUIService.getInputWorkflowData(this.productConfig,this.aiPhotoService.originalImageUrlCustom),...this.productConfig?.workflowId&&{workflowId:this.productConfig.workflowId},...this.productConfig?.enhancePrompt&&{enhancePrompt:this.productConfig.enhancePrompt}}}}}ngOnDestroy(){this.backBtnSub.forEach(t=>t.unsubscribe()),this.aiPhotoService.isWorkflow=!1,document.body.classList.remove("overflow-hidden"),this.loggedInObserver&&this.loggedInObserver.unsubscribe(),this.usrPropChangedObserver&&this.usrPropChangedObserver.unsubscribe(),this.changeWorkflowObserver&&this.changeWorkflowObserver.unsubscribe(),this.resolutionPanelCloseTimer&&(clearTimeout(this.resolutionPanelCloseTimer),this.resolutionPanelCloseTimer=null),this.stylePanelCloseTimer&&(clearTimeout(this.stylePanelCloseTimer),this.stylePanelCloseTimer=null),this.clearTimeInterval(),this.aiPhotoService.clearGenerationProgress()}clearTimeInterval(){this.interValId&&clearInterval(this.interValId),this.interValId1&&clearInterval(this.interValId1)}onSlide(t){const i=this.aiPhotoService?.aiImages?.length?this.aiPhotoService.aiImages:[];if(!t||!i.length)return;const o=t.current??t.next;if(!o)return;const r=i.find(l=>String(l.assetId)===String(o));r&&(this.activeId=r.assetId,this.carousel&&this.activeId&&this.carousel.select(this.activeId))}textAnimation(t){let i;const o=this.cpText&&this.cpText?.nativeElement,r=()=>{var c=1;this.intervalSub=(0,xt.Y)(4500).subscribe(d=>{c===t.length&&(c=0,this.intervalSub&&this.intervalSub.unsubscribe(),r()),c<t.length&&(o.placeholder="",i&&clearTimeout(i),l(o,t[c].prompt)),c++})},l=(c,d)=>{let p=d.split("");c.placeholder="";let u=0;i=setTimeout(function g(){c.placeholder=c.placeholder+p[u],u++,u<p.length&&(i=setTimeout(g,70))},500)};r()}onEnter(t){this.cpText.nativeElement.blur()}checkAds(){this.showAds=!(!this.enableAds||this.user&&(this.user.subscribed||this.user.creditPurchased))}getResolution(){this.resolutions=this.aiPhotoService.getResolution(this.selectedModel.subFeatureType)}getModels(){this.config=this.paymentService.config,this.models=this.aiPhotoService.getModels(this.config);const t=this.aiPhotoService?.queryParams?.model;if(t){const i=this.models.filter(o=>o.subFeatureType==t);i&&i.length&&(this.selectedModel=i[0],this.selectedModel.dCoin=this.config.creditInfo?.design?this.config.creditInfo?.design:this.selectedModel.dCoin)}else this.selectedModel=this.models[0],this.selectedModel.dCoin=this.config.creditInfo?.design?this.config.creditInfo?.design:this.selectedModel.dCoin;this.resolutions=this.aiPhotoService.getResolution(this.selectedModel.subFeatureType),this.selectedSize=this.resolutions[0],this.customPrompt=this.aiPhotoService?.queryParams?.tp||"",!this.customPrompt&&!this.aiPhotoService?.queryParams?.isEd&&"prompt"==this.selectedTab&&(this.step=2,this.focusIn())}addCredit(){this.step=1,this.aiGenService.aiCreditPlanCheckout({toolName:this.toolName},()=>{this.isProUser=this.aiPhotoService.isProUser()})}retryCheckStatus(t){this.aiPhotoService.startGenerationProgress({featureType:this.featureType||this.toolName});const o=new Date;this.aiPhotoService.checkStatusResponsive(t,0,r=>{(this.aiPhotoService.processingProgress.isActive||this.aiPhotoService.inProgress||this.aiPhotoService.inVideoProgress)&&this.outputResult(r,o)},r=>{this.displayErrorMsg(r,o)})}outputResult(t,i=null){t&&t.urls&&t.urls.length>0?this.aiPhotoService.completeGenerationProgress(()=>{this.thumbUrl=t.thumbUrl||t.urls[0],this.index=0,this.previewUrl=t.urls[0],this.activeImage=this.aiPhotoService.aiImages[0],this.index=this.aiPhotoService.aiImages.length-1,this.user.remainingCoins=t.remainingCalls,this.aiPhotoService.generateImageFn(t),this.aiPhotoService.isDirty=!0,"workflow"==this.selectedTab&&(this.aiPhotoService.isWorkflow=!1),this.aiPhotoService.backBtnClick.next({backBtnEnabled:!0}),this.gtmService.pushTag({eventName:y.b.gtm.eventname.aiGenerateMob,itemName:this.toolName,itemValue:this.toolName+"_"+this.selectedStyle?.displayName}),this.carousel&&setTimeout(()=>{this.carousel.animation=!1,this.carousel.select(t.assetId),setTimeout(()=>{this.carousel.animation=!0},100)},50)}):this.aiPhotoService.clearGenerationProgress()}GotoRemix(t){let i=this.carousel.activeId,o=this.aiPhotoService?.aiImages.find(r=>r.assetId===i);this.aiPhotoService.mobileImageObj=o,this.aiPhotoService.queryParams=Object.assign({},this.aiPhotoService.queryParams),this.aiPhotoService.queryParams&&(this.aiPhotoService.queryParams.tp=null,this.aiPhotoService.textPrompt=this.customPrompt),this.aiPhotoService.queryParams.productId=this.productId,o.productId=this.productId,this.aiPhotoService.queryParams.from="tool",this.changeInspiration.emit(o)}onPaste(t){setTimeout(()=>{this.aiPhotoService.textPrompt=t.target.value,this.changePrompt()},100)}download(){const t=this.carousel?.activeId??this.activeId,i=this.aiPhotoService?.aiImages?.find(l=>l.assetId===t)?.urls?.[0]||"";i&&(this.gtmService.pushTag({eventName:y.b.gtm.eventname.aiDownloadMob,itemName:"Editor_"+this.featureType+"_"+(this.selectedTab==this.PANEL_ID.workflow?"Workflow":"Prompt")}),this.aiPhotoService.downloadImg(i,()=>{localStorage.getItem("isChecked")||this.downloadService.downloadMsgPopup({msg:y.b.message.download,imgUrl:i})}))}
1productConfigChange(t){this.productConfig=t}selectTab(t){this.selectedTab=t,this.aiPhotoService.isWorkflow=this.selectedTab==this.PANEL_ID.workflow,this.aiPhotoService.isWorkflow?this.disabled=this.workflowUIService.isDisabled(this.productConfig,this.disabled):this.changePrompt()}editWorkflow(){this.aiPhotoService.isWorkflow=!0}reportAbuse(){this.isShowPreview=!1;const t=this.aiPhotoService?.aiImages||[],i=this.carousel?.activeId??this.activeId,o=t.findIndex(c=>String(c?.assetId)===String(i)),r=o>-1?t[o]:null;if(!r)return;const l=this.offcanvasService.open(vt.e,{position:"bottom",backdrop:!0,panelClass:"report-offcanvas",backdropClass:"showpreview-overlay"});l.componentInstance.item=r,l.result.then(c=>{if(c)if(t.splice(o,1),t.length){const d=o>=t.length?t.length-1:o;this.activeId=t[d].assetId,this.isFirst=0===d,this.isLast=d===t.length-1}else this.activeId=0,this.aiPhotoService.isDirty=!1,this.isFirst=!1,this.isLast=!0,!this.aiPhotoService.isWorkflow&&this.selectedTab==this.PANEL_ID.workflow&&(this.aiPhotoService.isWorkflow=!0)},()=>{})}}return(s=a).STYLE_IMAGE_PAGE_SIZE=20,s.STYLE_MIN_IMAGES_FOR_SCROLL=12,s.\u0275fac=function(t){return new(t||s)(e.rXU(we.Z),e.rXU(b.qQ),e.rXU(Z.s),e.rXU(ae.g),e.rXU(q.u),e.rXU(ne.A),e.rXU(ee.M),e.rXU(ie.y),e.rXU(Q.f),e.rXU(Pt.w),e.rXU(J.K),e.rXU(de.W),e.rXU(Ke.I),e.rXU(ze.s),e.rXU(R.RS),e.rXU(pt.b))},s.\u0275cmp=e.VBU({type:s,selectors:[["ai-generate-v4"]],viewQuery:function(t,i){if(1&t&&(e.GBs(tl,5),e.GBs(il,5)),2&t){let o;e.mGM(o=e.lsd())&&(i.cpText=o.first),e.mGM(o=e.lsd())&&(i.carousel=o.first)}},inputs:{featureType:"featureType",productId:"productId"},outputs:{changeStep:"changeStep",changeInspiration:"changeInspiration"},decls:36,vars:35,consts:[["cpText",""],["login",""],["generateButton",""],["carousel",""],[1,"position-relative",2,"height","max-content",3,"ngClass"],[1,"drawer-elements","ai-drawer-elements"],[4,"ngIf"],[1,"d-flex","align-items-center","overflow-hidde","w-100","flex-column","p-3","pb-0","text-image-height",2,"height","calc(100dvh - 294px)",3,"ngClass"],["class","d-flex align-items-center justify-content-start overflow-hidde h-100 w-100 ngb-carousel border-radius-12 bg-grey3 position-relative",4,"ngIf"],["class","d-flex align-items-start justify-content-start overflow-hidden flex-column w-100",4,"ngIf"],[1,"p-3","pt-9","pb-9","position-fixed","bg-white","w-100","mobile-sheet-anim",2,"bottom","0px","z-index","99999","border-radius","20px 20px 0px 0px","left","0px"],[1,"wp-100","d-flex","align-items-center","justify-content-between","mb-2"],[1,"text-lg","text-semi","grey-800","w-100","d-flex","align-items-center","justify-content-between"],["name","previewclose",3,"click"],[1,"card","drawer-card","mb-3","mt-0"],[1,"card-body"],[1,"btn-panel"],[1,"card-body","prompt-view"],[1,"textarea-col","position-relative",3,"ngClass"],["id","cprompt","name","cprompt","rows","4","cols","50",1,"prompt-text",3,"ngModelChange","keyup","paste","keydown.enter","maxlength","ngModel"],["class","prompt-info text-regular position-relative d-flex align-items-center","style","min-height: 24px;",4,"ngIf"],[1,"d-flex","mt-3","mobile-prompt"],[2,"max-width","-webkit-fill-available",3,"selectLayout","items","type"],[1,"d-flex","align-items-center","justify-content-center","w-100"],[4,"ngTemplateOutlet"],[1,"showpreview-overlay","align-items-center","justify-content-start","position-fixed","mobile-sheet-overlay",3,"click"],[1,"align-items-start","justify-content-start","w-100","d-flex","align-items-center","justify-content-center","mt-3","mb-2"],["role","tablist",1,"nav","nav-pills","tab-bg-home","d-inline-flex","align-items-center","justify-content-center","border-radius-lg"],[1,"nav-item","btn-tab-home","d-flex","align-items-center","justify-content-center","border-radius-12","h-40","border-0","bg-transparent","text-dark","text-13",3,"click","ngClass"],["role","tab",1,"d-flex","align-items-center","justify-content-center","w-100","h-100"],[1,"d-flex","align-items-center","justify-content-start","overflow-hidde","h-100","w-100","ngb-carousel","border-radius-12","bg-grey3","position-relative"],[1,"h-100","border-radius-12","w-100",3,"slide","activeId","wrap","interval","ngClass"],[4,"ngFor","ngForOf"],[1,"changeWithAIBtn","text-white","d-flex","align-items-center","justify-content-center","position-absolute","text-13","text-semi",2,"right","8px","bottom","8px",3,"click"],["name","remixbutton",1,"f-16","me-1"],[1,"d-flex","align-items-center","justify-content-center","position-absolute","hw-40","border-radius-50","report-flag",2,"top","8px",3,"click"],["name","reportabuse",1,"f-24","text-white"],[1,"d-flex","align-items-center","justify-content-center","position-absolute","hw-40","border-radius-50","btn-alpha",2,"top","8px","right","8px",3,"click"],["name","downloadblack",1,"f-24","text-white"],["ngbSlide","",3,"slid","id"],[1,"d-flex","overflow-hidden","w-100","flex-column","align-items-center","justify-content-center","h-100"],[1,"res-round","h-100"],["class","","height","","width","",3,"src",4,"ngIf"],["height","","width","",1,"",3,"src"],[1,"d-flex","align-items-start","justify-content-start","overflow-hidden","flex-column","w-100"],[1,"text-lg","text-semi","grey-800","m-0","lh-125","mb-2"],[1,"text-14","grey-400","m-0","p-0","mb-3","lh-125"],["class","d-inline-flex align-items-center justify-content-center prompt-example-item border-radius-12 mb-2",3,"click",4,"ngFor","ngForOf"],[1,"d-inline-flex","align-items-center","justify-content-center","prompt-example-item","border-radius-12","mb-2",3,"click"],[1,"text-14","text-primary","lh-160"],[1,"pt-2","pb-9","position-fixed","gray-100","w-100","modal-container",2,"bottom","0px",3,"ngClass"],[1,"wp-100","d-flex","align-items-center","justify-content-start","mb-9","styles-options","overflow-scroll","new-scroll-behave","ps-3","pe-3"],[1,"btn","btn-primary","text-13","pt-2","pb-2","pl-9","pr-9","me-3","grey-600","text-regular",3,"click"],[1,"text-semi","text-primary","d-inline-flex"],[1,"d-flex","align-items-center","justify-content-start","mb-3","mt-0","ps-3","pe-3",3,"click"],["id","cprompt",1,"d-flex","align-items-start","justify-content-start","text-mask","border-radius-12","text-13","text-regular","grey-800","w-100","overflow-hidden"],[1,"grey-500",3,"ngClass"],[1,"d-flex","align-items-center","justify-content-center","w-100","ps-3","pe-3"],[1,"prompt-info","text-regular","position-relative","d-flex","align-items-center",2,"min-height","24px"],[1,"d-flex","justify-content-start","align-items-center","bottom-container","position-fixed","bg-white","p-3","pt-10","pb-9","flex-column","w-100",2,"bottom","0px","z-index","9999",3,"close"],[1,"top-header","d-flex","justify-content-start","align-items-center","w-100","flex-column"],[1,"text-lg","text-semi","grey-800","m-0","w-100","lh-125","w-100","d-flex","align-items-center","justify-content-between"],[1,"text-13","grey-500","w-100","mt-1","mb-3","lh-160"],["class","modal-box d-flex justify-content-between align-items-center w-100 border-radius-12 p-9 mb-2",3,"ngClass","click",4,"ngFor","ngForOf"],[1,"modal-box","d-flex","justify-content-between","align-items-center","w-100","border-radius-12","p-9","mb-2",3,"click","ngClass"],[1,"d-inline-flex","align-items-center","justify-content-start","flex-column"],[1,"d-flex","align-items-center","justify-content-start","w-100","mb-1"],[1,"icon-box","hw-24","d-inline-flex","align-items-center","justify-content-center","me-2"],["height","16px","width","16px",3,"src"],[1,"grey-800","text-13","text-semi","d-inline-flex"],[1,"w-100","pe-2"],[1,"grey-500","text-sm",2,"line-height","19px"],[1,"d-inline-flex","align-items-center","justify-content-center","coin-box","border-radius-12"],["src","https://static.lightxeditor.com/assets/images/coin-new.png","height","20px","width","20px"],[1,"grey-600","text-12","text-semi",2,"padding-left","2px"],[1,"showpreview-overlay","mobile-sheet-overlay","position-fixed",3,"click"],[1,"mobile-style-panel","mobile-sheet-anim","resolution-sheet-panel"],[1,"d-flex","justify-content-start","align-items-center","bottom-container","bg-white","p-3","pt-2","pb-9","flex-column","w-100"],[1,"top-header","d-flex","justify-content-start","align-items-center","w-100","flex-column","mb-1","h-32"],[1,"text-lg","text-semi","grey-800","m-0","w-100","lh-125","w-100","d-flex","align-items-center","justify-content-between","h-32"],["class","modal-box resolution-modal d-flex justify-content-between align-items-center w-100 border-radius-12 pl-9 pr-9 mb-2 h-48",3,"click",4,"ngFor","ngForOf"],[1,"modal-box","resolution-modal","d-flex","justify-content-between","align-items-center","w-100","border-radius-12","pl-9","pr-9","mb-2","h-48",3,"click"],[1,"d-flex","justify-content-center","align-items-center"],[1,"f-24","grey-600","me-2",3,"name"],[1,"grey-800","text-13","text-semi"],[1,"grey-600","text-12","text-semi","ms-1","p-1","ratio-box","d-inline-flex","align-items-center","justify-content-center","lh-normal"],[1,"grey-600","text-semi","text-13"],[1,"mobile-style-container","mobile-sheet-anim","style-sheet-panel"],[1,"d-flex","justify-content-start","align-items-center","bottom-container","bg-white","p-3","pt-10","pb-9","flex-column","w-100","background-prompt","background-style","background-prompt-mobile",2,"height","calc(100vh - 130px)"],[1,"w-100",3,"close","styleScrollEnd","selectStyleEvent","products","editorType","productImageId","isImagesLoading","isImagesEnd","loadingPlaceholders","selectedStyle"],[3,"close","addCredit","consumeCoins"],[1,"showpreview-overlay","align-items-center","justify-content-start","position-fixed","d-flex",3,"click"],[1,"workflow-overlay","position-fixed","w-100"],[1,"workflow-scroll-area","h-100","overflow-auto","p-3"],[3,"productC
1onfigChange","productConfig","workflowList","inProgress"],[1,"align-items-center","justify-content-center","w-100","bottom-0","p-3","pt-0","pb-0","bg-white","position-fixed",2,"bottom","69px !important",3,"ngClass"],[1,"btn","btn-primary","btn-h48","w-100",3,"click"],["Style","z-index: 2;",1,"d-flex","align-items-center","justify-content-center","w-100","position-fixed","bottom-0","p-3","pt-2","pb-9","gray-100"],[1,"position-fixed","d-flex","align-items-center","justify-content-center","flex-column","w-100","mobile-congratulations","gray-100"],["src","https://static.lightxeditor.com/assets/images/mobile-congratulations.png","height","244px","width","232.272px","alt","Mobile Congratulations",1,"mb-14"],[1,"d-flex","align-items-center","justify-content-center","text-center","flex-column","w-100","mb-14"],[1,"grey-900","text-semi","text-28","mb-0"],[1,"grey-500","text-lg","text-semi","mt-9","ps-5","pe-5",2,"line-height","normal"],[1,"credit-description","d-flex","align-items-center","justify-content-center","w-100","d-none"],[1,"text-lg","grey-400","text-semi","d-inline-flex"],[1,"ms-2","me-2","d-inline-flex"],["src","https://static.lightxeditor.com/assets/images/coin-lottie-s-anim.gif","width","24px","height","24px","alt","Coin Lottie"],[1,"btn","btn-primary","btn-h48","mt-3",2,"width","169px",3,"click"],[1,"btn","btn-resolution","text-13","d-flex","align-items-center","ps-2","pe-2","justify-content-center","me-2",3,"click","ngClass"],[1,"resolution-text","text-black","text-bold","text-13","hw-32","d-inline-flex","align-items-center","justify-content-center","lh-160"],["name","chevronaarrow",1,"hw-24","ms-1"],["id","gtm-generate-mob",1,"btn","btn-primary-gradient","btn-primary-m","text-13","btn-h44","w-100","d-flex","align-items-center","justify-content-center",3,"keyup.enter","click","disabled"],["class","spinner-border spinner-border-lg me-2 hw-24","role","status",4,"ngIf"],[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,"text-11","text-semi",2,"padding-left","2px"],["role","status",1,"spinner-border","spinner-border-lg","me-2","hw-24"],[1,"sr-only","text-nowrap","border-0","position-absolute","overflow-hidden"]],template:function(t,i){if(1&t){const o=e.RV6();e.j41(0,"div",4)(1,"div",5),e.DNE(2,al,9,6,"ng-container",6),e.j41(3,"div",7),e.DNE(4,hl,11,9,"ng-contianer",8)(5,ml,6,1,"ng-contianer",9),e.k0s(),e.DNE(6,gl,14,9,"ng-container",6),e.j41(7,"div",10)(8,"div",11)(9,"div",12),e.EFF(10," Enter Prompt "),e.j41(11,"pi",13),e.bIt("click",function(){return e.eBV(o),e.Njj(i.step=1)}),e.k0s()()(),e.j41(12,"div",14)(13,"div",15)(14,"div",16)(15,"div",17)(16,"div",18)(17,"textarea",19,0),e.mxI("ngModelChange",function(l){return e.eBV(o),e.DH7(i.customPrompt,l)||(i.customPrompt=l),e.Njj(l)}),e.bIt("keyup",function(){return e.eBV(o),e.Njj(i.changePrompt())})("paste",function(l){return e.eBV(o),e.Njj(i.onPaste(l))})("keydown.enter",function(l){return e.eBV(o),e.Njj(i.onEnter(l))}),e.k0s(),e.DNE(19,_l,2,2,"span",20),e.k0s(),e.j41(20,"div",21)(21,"buttons-scroll-menu",22),e.bIt("selectLayout",function(l){return e.eBV(o),e.Njj(i.selectPrompt(l))}),e.k0s()()()()()(),e.j41(22,"div",23),e.DNE(23,fl,1,0,"ng-container",24),e.k0s()(),e.j41(24,"div",25),e.bIt("click",function(){return e.eBV(o),i.step=1,e.Njj(i.focusOut())}),e.k0s(),e.DNE(25,bl,9,1,"ng-container",6)(26,xl,9,5,"ng-container",6)(27,Pl,5,11,"ng-container",6)(28,Il,2,1,"ng-container",6)(29,yl,2,0,"ng-container",6)(30,Sl,9,9,"ng-container",6),e.k0s()(),e.DNE(31,kl,2,1,"ng-container",6)(32,Tl,16,2,"ng-template",null,1,e.C5r)(34,El,13,8,"ng-template",null,2,e.C5r)}if(2&t){const o=e.sdS(35);e.Y8G("ngClass",e.eq3(26,De,i.isLogin)),e.R7$(2),e.Y8G("ngIf",(null==i.aiPhotoService?null:i.aiPhotoService.aiImages)&&!(null!=i.aiPhotoService&&i.aiPhotoService.aiImages.length)&&i.productC
1onfig),e.R7$(),e.Y8G("ngClass",e.l_i(28,nl,"workflow"==i.selectedTab&&i.aiPhotoService.isWorkflow||"prompt"==i.selectedTab&&!(null!=i.aiPhotoService&&i.aiPhotoService.aiImages)&&!(null!=i.aiPhotoService&&i.aiPhotoService.aiImages.length),"workflow"==i.selectedTab&&(null==i.aiPhotoService?null:i.aiPhotoService.aiImages.length))),e.R7$(),e.Y8G("ngIf",(null==i.aiPhotoService?null:i.aiPhotoService.aiImages)&&(null==i.aiPhotoService?null:i.aiPhotoService.aiImages.length)),e.R7$(),e.Y8G("ngIf",(null==i.aiPhotoService?null:i.aiPhotoService.aiImages)&&!(null!=i.aiPhotoService&&i.aiPhotoService.aiImages.length)&&"prompt"==i.selectedTab),e.R7$(),e.Y8G("ngIf",i.isLoaded&&"prompt"==i.selectedTab),e.R7$(),e.AVh("mobile-sheet-anim--open",2==i.step),e.R7$(9),e.Y8G("ngClass",e.sMw(31,ol,i.customPrompt.length,i.isFocused,i.customPrompt.length>i.maxLenght)),e.R7$(),e.AVh("blue-active",i.isFocused),e.Y8G("maxlength",i.maxLenght),e.R50("ngModel",i.customPrompt),e.R7$(2),e.Y8G("ngIf",i.customPrompt.length),e.R7$(2),e.Y8G("items",i.prompts)("type","prompt-mobile"),e.R7$(2),e.Y8G("ngTemplateOutlet",o),e.R7$(),e.AVh("mobile-sheet-overlay--open",2==i.step),e.R7$(),e.Y8G("ngIf",3==i.step),e.R7$(),e.Y8G("ngIf",i.resolutionPanelMounted),e.R7$(),e.Y8G("ngIf",i.stylePanelMounted),e.R7$(),e.Y8G("ngIf",6==i.step),e.R7$(),e.Y8G("ngIf",1!=i.step&&2!=i.step&&6!=i.step&&!i.resolutionPanelMounted&&!i.stylePanelMounted),e.R7$(),e.Y8G("ngIf","workflow"==i.selectedTab),e.R7$(),e.Y8G("ngIf",i.isLogin)}},dependencies:[b.YU,b.Sq,b.bT,b.T3,R.Oj,R.bD,P.me,P.BC,P.tU,P.vS,H.b,_e.B,pe,_t.d,Qe,Pe.m],styles:['.prompt-view[_ngcontent-%COMP%]   .textarea-col[_ngcontent-%COMP%]{width:100%;height:178px;border-radius:12px;background:#eeedf3;padding:4px;border:0px!important}.prompt-view[_ngcontent-%COMP%]   .textarea-col[_ngcontent-%COMP%]:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:12px;padding:.92px;border:none;background:linear-gradient(90deg,#c9cad4 -4% 100%);-webkit-mask:linear-gradient(90deg,#C9CAD4 -4%,#C9CAD4 100%) content-box,linear-gradient(90deg,#C9CAD4 -4%,#C9CAD4 100%);-webkit-mask-composite:xor;mask-composite:exclude;z-index:1}.prompt-view[_ngcontent-%COMP%]   .textarea-col[_ngcontent-%COMP%]:hover{border:1px solid #B0B3BF}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]{resize:none;outline:none;width:100%;height:144px;padding:8px;font-size:13px;color:#b0b3bf;border:0px;background:transparent;border-radius:12px;line-height:18px;position:relative;z-index:2}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]::-webkit-scrollbar{width:4px;height:4px;border-radius:12px}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]::-webkit-scrollbar-track{background:#e3e3e3;border-radius:12px;margin-top:8px}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background:#9a9a9a;border-radius:12px}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]::-webkit-scrollbar-thumb:hover{background:#555}.prompt-view[_ngcontent-%COMP%]   .prompt-info[_ngcontent-%COMP%]{font-size:11px;color:#b0b3bf;margin-top:0;padding-left:8px;line-height:10px}.info-up[_ngcontent-%COMP%]{border:1px solid #B0B3BF!important;background:#eeedf3!important}.info-blue[_ngcontent-%COMP%]{background:linear-gradient(90deg,#fc5cff0d -4%,#2520f60d)!important}.info-blue[_ngcontent-%COMP%]:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:12px;padding:.92px;border:none;background:linear-gradient(90deg,#fc5cff -4%,#2520f6)!important;-webkit-mask:linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%) content-box,linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%)!important;-webkit-mask-composite:xor!important;mask-composite:exclude!important;z-index:1}.info-blue[_ngcontent-%COMP%]   span[_ngcontent-%COMP%]{color:#626adf!important}.info-red[_ngcontent-%COMP%]{background:linear-gradient(90deg,#fc5cff0d -4%,#2520f60d)!important}.info-red[_ngcontent-%COMP%]:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:12px;padding:.92px;border:none;background:linear-gradient(90deg,#f25555 -4% 100%)!important;-webkit-mask:linear-gradient(90deg,#F25555 -4%,#F25555 100%) content-box,linear-gradient(90deg,#F25555 -4%,#F25555 100%)!important;-webkit-mask-composite:xor!important;mask-composite:exclude!important;z-index:1}.info-red[_ngcontent-%COMP%]   span[_ngcontent-%COMP%]{color:#f25555!important}.prompt-text[_ngcontent-%COMP%]{color:#272b34!important}.m-editor-tool-panel[_ngcontent-%COMP%]{bottom:0;z-index:999;max-width:-webkit-fill-available}.m-editor-tool-panel[_ngcontent-%COMP%]   buttons-scroll-menu[_ngcontent-%COMP%]   .menu-resizeSocial.color-tab[_ngcontent-%COMP%]{max-width:none!important}.showpreview-overlay[_ngcontent-%COMP%]{display:none;background:#0003;-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);width:100%;height:100%;top:0;bottom:0;z-index:999}.mobile-style-panel[_ngcontent-%COMP%], .mobile-style-container[_ngcontent-%COMP%]{position:fixed;left:0;right:0;bottom:0;z-index:3;background:#fff;border-radius:20px 20px 0 0;height:auto;min-height:0;max-height:90vh;overflow-y:auto}.resolution-sheet-panel[_ngcontent-%COMP%]{z-index:9999}.style-sheet-panel[_ngcontent-%COMP%]{z-index:1000}.mobile-sheet-overlay[_ngcontent-%COMP%]{opacity:0;pointer-events:none;transition:opacity .24s ease;display:block}.mobile-sheet-overlay.mobile-sheet-overlay--open[_ngcontent-%COMP%]{opacity:1;pointer-events:auto}.mobile-sheet-anim[_ngcontent-%COMP%]{transform:translate3d(0,100dvh,0);will-change:transform;-webkit-backface-visibility:hidden;backface-visibility:hidden;pointer-events:none;transition:transform .72s cubic-bezier(.22,.61,.36,1)}.mobile-sheet-anim.mobile-sheet-anim--open[_ngcontent-%COMP%]{transform:translateZ(0);pointer-events:auto;transition:transform .52s cubic-bezier(.2,.9,.2,1)}.mobile-congratulations[_ngcontent-%COMP%]{height:100vh;z-index:9999;top:0;bottom:0}.res-round[_ngcontent-%COMP%]{overflow:hidden;display:flex;justify-content:center;align-items:center;margin:0 auto}.res-round[_ngcontent-%COMP%]   img[_ngcontent-%COMP%]{width:100%;height:100%;max-width:100%;max-height:100%;object-fit:contain}.recent-col[_ngcontent-%COMP%]   .img-col[_ngcontent-%COMP%]{background:#ebebeb}.recent-col.ai-thumb-active[_ngcontent-%COMP%]   .img-col[_ngcontent-%COMP%]{background:#fff}.recent-col.ai-thumb-active[_ngcontent-%COMP%]   .img-col[_ngcontent-%COMP%]:before{left:3px!important;width:calc(100% - 6px)!important}.inable[_ngcontent-%COMP%]{display:block}.disable[_ngcontent-%COMP%]{display:none}.btn[_ngcontent-%COMP%]:disabled{background:#d5d6dd;border:1px solid #D5D6DD}.btn[_ngcontent-%COMP%]:disabled   .coin-count[_ngcontent-%COMP%]{background:#0000001a}.btn[_ngcontent-%COMP%]:disabled   .coin-count[_ngcontent-%COMP%]   b[_ngcontent-%COMP%]{color:#fff!important}.btn[_ngcontent-%COMP%]:disabled   .inable[_ngcontent-%COMP%]{display:none}.btn[_ngcontent-%COMP%]:disabled   .disable[_ngcontent-%COMP%]{display:block}.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}.coin-count[_ngcontent-%COMP%]   b[_ngcontent-%COMP%]{color:#fff!important}.bottom-container[_ngcontent-%COMP%]{border-radius:20px 20px 0 0}
1.bottom-container[_ngcontent-%COMP%]   .modal-box[_ngcontent-%COMP%]{background:#626adf0d;position:relative}.bottom-container[_ngcontent-%COMP%]   .modal-box[_ngcontent-%COMP%]   .icon-box[_ngcontent-%COMP%]{border-radius:6px;background:#626adf1a}.bottom-container[_ngcontent-%COMP%]   .modal-box[_ngcontent-%COMP%]   .coin-box[_ngcontent-%COMP%]{border:1px solid #C9CAD4;padding:0 6px 0 4px;min-height:24px;min-width:42px}.bottom-container[_ngcontent-%COMP%]   .resolution-modal[_ngcontent-%COMP%]{min-height:40px}.bottom-container[_ngcontent-%COMP%]   .resolution-modal[_ngcontent-%COMP%]   .ratio-box[_ngcontent-%COMP%]{border-radius:6px;background:#626adf1a;min-height:25px}.bottom-container[_ngcontent-%COMP%]   .active-modal[_ngcontent-%COMP%], .bottom-container[_ngcontent-%COMP%]   .active-resolution[_ngcontent-%COMP%]{position:relative}.bottom-container[_ngcontent-%COMP%]   .active-modal[_ngcontent-%COMP%]   .icon-box[_ngcontent-%COMP%], .bottom-container[_ngcontent-%COMP%]   .active-modal[_ngcontent-%COMP%]   .ratio-box[_ngcontent-%COMP%], .bottom-container[_ngcontent-%COMP%]   .active-resolution[_ngcontent-%COMP%]   .icon-box[_ngcontent-%COMP%], .bottom-container[_ngcontent-%COMP%]   .active-resolution[_ngcontent-%COMP%]   .ratio-box[_ngcontent-%COMP%]{background:linear-gradient(90deg,#fc5cff1a -4%,#2520f61a)}.bottom-container[_ngcontent-%COMP%]   .active-modal[_ngcontent-%COMP%]   .new_item[_ngcontent-%COMP%]   .icon-box[_ngcontent-%COMP%]   img[_ngcontent-%COMP%], .bottom-container[_ngcontent-%COMP%]   .active-resolution[_ngcontent-%COMP%]   .new_item[_ngcontent-%COMP%]   .icon-box[_ngcontent-%COMP%]   img[_ngcontent-%COMP%]{height:24px!important;width:24px!important}.bottom-container[_ngcontent-%COMP%]   .active-modal[_ngcontent-%COMP%]   .coin-box[_ngcontent-%COMP%], .bottom-container[_ngcontent-%COMP%]   .active-resolution[_ngcontent-%COMP%]   .coin-box[_ngcontent-%COMP%]{position:relative;border:0px}.bottom-container[_ngcontent-%COMP%]   .active-modal[_ngcontent-%COMP%]   .coin-box[_ngcontent-%COMP%]:after, .bottom-container[_ngcontent-%COMP%]   .active-resolution[_ngcontent-%COMP%]   .coin-box[_ngcontent-%COMP%]:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:12px;padding:.9px;border:0px;background:linear-gradient(90deg,#fc5cff -4%,#2520f6);-webkit-mask:linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%) content-box,linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%);-webkit-mask-composite:xor;mask-composite:exclude}.bottom-container[_ngcontent-%COMP%]   .active-modal[_ngcontent-%COMP%]:after, .bottom-container[_ngcontent-%COMP%]   .active-resolution[_ngcontent-%COMP%]:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:12px;padding:1.3px;border:none;background:linear-gradient(90deg,#fc5cff -4%,#2520f6);-webkit-mask:linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%) content-box,linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%);-webkit-mask-composite:xor;mask-composite:exclude}.bottom-container[_ngcontent-%COMP%]   .modal-box[_ngcontent-%COMP%]:last-child{margin-bottom:0!important}.new-scroll-behave[_ngcontent-%COMP%]{-ms-overflow-style:none;scrollbar-width:none}.new-scroll-behave[_ngcontent-%COMP%]::-webkit-scrollbar{display:none}.styles-options[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]{border:0px;border-radius:320px;background:linear-gradient(90deg,#fc5cff0d -4%,#2520f60d);position:relative;height:32px;display:flex;line-height:17px;justify-content:center;white-space:nowrap}.styles-options[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]:disabled{background:#d5d6dd;border:1px solid #D5D6DD;color:#b0b3bf!important}.styles-options[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]:disabled:before{display:none;padding:0}.styles-options[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]:disabled   .text-primary[_ngcontent-%COMP%]{color:#b0b3bf!important}.styles-options[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]:before{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:320px;padding:1px;border:none;background:linear-gradient(90deg,#fc5cff -4%,#2520f6);-webkit-mask:linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%) content-box,linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%);-webkit-mask-composite:xor;mask-composite:exclude}.text-mask[_ngcontent-%COMP%]{border:1px solid #E2E3E9;background:#626adf0d;height:110px;padding:8px 12px;overflow:auto;word-break:break-all}.text-mask[_ngcontent-%COMP%]::-webkit-scrollbar{width:4px;height:4px;border-radius:12px}.text-mask[_ngcontent-%COMP%]::-webkit-scrollbar-track{background:#e3e3e3;border-radius:12px;margin-top:8px;margin-bottom:8px;padding-right:18px}.text-mask[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background:#9a9a9a;border-radius:12px}.text-mask[_ngcontent-%COMP%]::-webkit-scrollbar-thumb:hover{background:#555}.auto-prompt[_ngcontent-%COMP%]{top:32px;left:16px;right:16px;width:calc(100% - 32px)!important}.prompt-example-item[_ngcontent-%COMP%]{border:1px solid rgba(98,106,223,.1);background:#626adf0d;padding:6px 12px;min-height:35px}.tab-bg-home[_ngcontent-%COMP%], .btn-tab-home[_ngcontent-%COMP%]{border:1px solid #E2E3E9}.btn-tab-home[_ngcontent-%COMP%]   a[_ngcontent-%COMP%]{padding:0 35px!important}.btn-tab-home[_ngcontent-%COMP%]:hover{background:transparent!important;color:unset!important}.btn-tab-active[_ngcontent-%COMP%]{background:#626adf!important;color:#fff}.btn-tab-active[_ngcontent-%COMP%]:hover{background:#626adf!important;color:#fff!important}.workflow-overlay[_ngcontent-%COMP%]{z-index:1}.btn-resolution[_ngcontent-%COMP%]{border-radius:12px;border:1px solid #E2E3E9;background:linear-gradient(0deg,#626adf0d,#626adf0d) 100%,#fff;height:44px}.btn-resolution[_ngcontent-%COMP%]:active{border:1px solid #E2E3E9}.resolution-text[_ngcontent-%COMP%]{border-radius:8px}.text-image-height.workflow-generation[_ngcontent-%COMP%]{height:calc(100dvh - 185px)!important}.report-flag[_ngcontent-%COMP%]{border-radius:100px;background:#60657633;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);right:56px}']}),a})();var Gl=m(91367);const Vl=()=>["/"],Rl=(s,a)=>({"no-credit-item":s,"d-none":a}),Fl=(s,a)=>({"disable-right pe-none":s,"d-none":a});function Al(s,a){if(1&s){const n=e.RV6();e.j41(0,"pi",14),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.close())}),e.k0s()}}function Bl(s,a){if(1&s){const n=e.RV6();e.j41(0,"pi",15),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.close())}),e.k0s()}}function Ul(s,a){if(1&s){const n=e.RV6();e.j41(0,"button",16),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.logIn())}),e.EFF(1,"Log in "),e.k0s()}}function Dl(s,a){if(1&s&&(e.j41(0,"span"),e.EFF(1),e.k0s()),2&s){const n=e.XpG(2);e.R7$(),e.JRh(null==n.user?null:n.user.remainingCoins)}}function Nl(s,a){1&s&&(e.j41(0,"span"),e.EFF(1,"00"),e.k0s())}function Xl(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",17),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.addCredits())}),e.nrm(1,"img",18),e.DNE(2,Dl,2,1,"span",19)(3,Nl,2,0,"span",19),e.k0s()}if(2&s){const n=e.XpG();e.Y8G("ngClass",e.l_i(3,Rl,!(null!=n.user&&n.user.remainingCoins),n.featureType&&"face-body-tools"==n.activeTab)),e.R7$(2),e.Y8G("ngIf",(null==n.user?null:n.user.remainingCoins)>0),e.R7$(),e.Y8G("ngIf",!(null!=n.user&&n.user.remainingCoins))}}function Ll(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",20)(1,"a",21),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.openGenerations())}),e.nrm(2,"pi",22),e.k0s()()}}function Yl(s,a){if(1&s){const n=e.RV6();e.j41(0,"pi",23),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.toggleHelp())}),e.k0s()}}function $l(s,a){if(1&s){const n=e.RV6();e.j41(0,"pi",24),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.apply())}),e.k0s()}if(2&s){const n=e.XpG();e.Y8G("ngClass",e.l_i(1,Fl,n.isApplyDisabled,n.hideApplyBtn||(null==n.aiPhotoService?null:n.aiPhotoService.isWorkflow)||"video-tools"==n.activeTab))}}function zl(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",25)(1,"pi",26),e.bIt("click",function(){e.eBV(n);const i=e.XpG(),o=e.sdS(13);return e.Njj(i.chooseFile(o))}),e.k0s()()}}function Hl(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",27),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.closeHelp())}),e.j41(1,"div",28),e.bIt("click",function(i){return e.eBV(n),e.Njj(i.stopPropagation())}),e.j41(2,"div",29),e.EFF(3,"Customise with Workflow"),e.k0s(),e.j41(4,"div",30),e.EFF(5," Cho
1ose different settings and options to guide the Al in creating your image. Each selection helps control the style, appearance, and overall result. "),e.k0s(),e.j41(6,"div",31)(7,"button",32),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.closeHelp())}),e.EFF(8,"Got It"),e.k0s()()()()}}let Wl=(()=>{var s;class a{constructor(t,i,o,r,l,c,d,h){var p=this;this.aiUploadImageService=t,this.aiPhotoService=i,this.photoEditorSahredService=o,this.loginService=r,this.authService=l,this.router=c,this.document=d,this.location=h,this.closeEvent=new e.bkB,this.loginEvent=new e.bkB,this.addCreditEvent=new e.bkB,this.uploadFileEvent=new e.bkB,this.isHelpOpen=!1,this.hideApplyBtn=!1,this.featureType=null,this.activeTab=null,this.checkimg=!0,this.isApply=!1,this.applyedFeatures=[f.Fs.FaceRetouch,f.Fs.BodyReshape,f.Fs.FaceExpression,f.Fs.FaceReshape],this.photoEditsSaveTools=[f.Fs.cleanup,f.Fs.replace,f.Fs.Upscale,f.Fs.ChangeCameraAngle,f.Fs.ChangeLighting],this.backBtnEnabled=!1,this.videoPreview=!1,this.aiPhotoService.generateImageFn=function(){var u=(0,w.A)(function*(g,_){g.isQuickEdit&&(p.isApply=!0)});return function(g,_){return u.apply(this,arguments)}}(),this.backBtnSub=this.aiPhotoService.backBtnClick.subscribe(u=>{u?.backBtnEnabled&&(this.backBtnEnabled=!0,this.videoPreview=u?.videoPreview),u?.isBack&&(this.backBtnEnabled=!1)})}ngOnInit(){}ngOnChanges(t){t.featureType&&(this.isApply=this.applyedFeatures.includes(this.featureType))}get isApplyDisabled(){return this.featureType==f.Fs.Upscale&&!this.aiPhotoService?.selectedUpscaleImageUrl||!(this.featureType==f.Fs.Upscale||this.aiPhotoService?.aiImages?.length||this.isApply||this.activeTab==z.sv.AI_QUICK_EDIT_TOOL&&this.aiPhotoService?.isDirty)}onFileUploaded(t){t&&(this.file=t[0],this.aiPhotoService.imgUrl=window.URL.createObjectURL(this.file),this.file.isReplace=null!==this.featureType,this.uploadFileEvent.emit(this.file))}chooseFile(t){t&&t.click()}openGenerations(){this.aiPhotoService.activeTool=this.activeTab,this.user?this.navigateToGenerations():this.loginService.openLoginDialog(()=>{this.authService.currentUser()&&this.navigateToGenerations()})}navigateToGenerations(){this.router.navigate(["/my/ai-generations"],{queryParams:{tab:this.generationsLandingTab}})}get generationsLandingTab(){return[z.sv.AI_PHOTO_EDITING_TOOLS,z.sv.FACE_BODY_TOOLS].includes(this.activeTab)?"photo-edits":"generations"}apply(){var t=this;return(0,w.A)(function*(){let i=0;if(t.activeTab==z.sv.FACE_BODY_TOOLS)t.aiPhotoService.isSaveInProgress=!0,t.aiPhotoService.startProcessingProgress({indeterminate:!0}),yield Promise.resolve(t.aiPhotoService.applyToSaveFn?.()),i=250;else if(t.activeTab==z.sv.AI_QUICK_EDIT_TOOL){const o=t.applyQuickEdit();o&&(yield t.photoEditorSahredService.saveImageUrlToPhotoEdits(o))}else if(t.featureType==f.Fs.Upscale||t.activeTab==z.sv.AI_PHOTO_EDITING_TOOLS){const o=t.applyPhotoEditingResult();o&&t.photoEditsSaveTools.includes(t.featureType)&&(yield t.photoEditorSahredService.saveImageUrlToPhotoEdits(o))}else t.updateImgUrl();setTimeout(()=>{t.closeEvent.emit({type:"apply"}),t.backBtnEnabled=!1,t.aiPhotoService.isSaveInProgress=!1,t.aiPhotoService.clearGenerationProgress()},i)})()}addCredits(){this.addCreditEvent.emit()}logIn(){this.loginEvent.emit()}toggleHelp(){this.isHelpOpen=!this.isHelpOpen}closeHelp(){this.isHelpOpen=!1}close(){if(this.backBtnEnabled)return this.closeEvent.emit({type:"back",videoPreview:this.videoPreview}),void(this.featureType!=f.Fs.Design&&this.aiPhotoService.aiImages.length&&(this.backBtnEnabled=!1));this.featureType?this.closeEvent.emit({type:"close"}):this.location.back(),this.aiPhotoService.originalImageUrlCustom=""}applyQuickEdit(){const t=this.aiPhotoService?.aiImages?.length>0?this.aiPhotoService.aiImages[this.aiPhotoService.aiImages.length-1].urls[0]:this.aiPhotoService.imgUrl;return this.aiPhotoService.imgUrl=t,this.aiPhotoService.compareImageUrl=JSON.parse(JSON.stringify(t)),this.aiPhotoService.originalImgUrl=t,this.aiPhotoService?.isDirty?t:""}updateImgUrl(){let t="";const i=this.document.querySelectorAll(".carousel-item.active");if(i?.length){const o=i[1].querySelector("img");o?.src&&(t=o.src)}else this.aiPhotoService?.aiImages?.length&&(t=this.aiPhotoService.aiImages[this.aiPhotoService.aiImages.length-1]?.urls?.[0]||"");t||(t=this.aiPhotoService.imgUrl||""),t&&(this.aiPhotoService.imgUrl=t,this.aiPhotoService.originalImgUrl=t,this.aiPhotoService.aiImages=[])}applyPhotoEditingResult(){const i=this.aiPhotoService.selectedUpscaleImageUrl||this.aiPhotoService.imgUrl||(this.aiPhotoService.aiImages?.length?this.aiPhotoService.aiImages[this.aiPhotoService.aiImages.length-1]?.urls?.[0]:"")||"";return i?(this.aiPhotoService.imgUrl=i,this.aiPhotoService.originalImgUrl=i,this.aiPhotoService.aiImages=[],i):""}
1ngOnDestroy(){this.backBtnSub&&this.backBtnSub.unsubscribe()}}return(s=a).\u0275fac=function(t){return new(t||s)(e.rXU(ee.M),e.rXU(Z.s),e.rXU(be),e.rXU(Gl.H),e.rXU(q.u),e.rXU(A.Ix),e.rXU(b.qQ),e.rXU(b.aZ))},s.\u0275cmp=e.VBU({type:s,selectors:[["editor-header"]],inputs:{hideApplyBtn:"hideApplyBtn",featureType:"featureType",activeTab:"activeTab",user:"user",checkimg:"checkimg"},outputs:{closeEvent:"closeEvent",loginEvent:"loginEvent",addCreditEvent:"addCreditEvent",uploadFileEvent:"uploadFileEvent"},features:[e.OA$],decls:15,vars:12,consts:[["file",""],[1,"top-editor-header","d-flex","align-items-center","justify-content-between","w-100","position-fixed","ps-2","pe-2","gray-100"],["name","backarrow",3,"click",4,"ngIf"],["name","previewclose",3,"click",4,"ngIf"],[1,"pointer",3,"routerLink"],["src","https://static.lightxeditor.com/assets/images/LightxEditor-Mobile.svg","alt","LightX Editor","width","","height","32px"],["class","btn btn-primary btn-h34 f-14 border-radius-50",3,"click",4,"ngIf"],["class","d-inline-flex credit-coin align-items-center justify-content-center text-semi text-14 text-primary",3,"ngClass","click",4,"ngIf"],["id","photo-edits-nav-icon","class","d-inline-flex align-items-center justify-content-center hw-32 photo-edits-nav-icon",4,"ngIf"],["name","helpicon","class","f-32 pointer",3,"click",4,"ngIf"],["class","grey-600","name","rightsign",3,"ngClass","click",4,"ngIf"],["class","d-inline-flex align-items-center justify-content-center hw-32",4,"ngIf"],["id","fileInputId","name","fileInputId","type","file",1,"custom-file-input","d-none",3,"change","click","accept"],["class","mobile-help-overlay d-flex align-items-center justify-content-center position-fixed p-4",3,"click",4,"ngIf"],["name","backarrow",3,"click"],["name","previewclose",3,"click"],[1,"btn","btn-primary","btn-h34","f-14","border-radius-50",3,"click"],[1,"d-inline-flex","credit-coin","align-items-center","justify-content-center","text-semi","text-14","text-primary",3,"click","ngClass"],["src","https://static.lightxeditor.com/assets/images/coin-lottie-s-anim.gif","height","24px","width","24px",1,"me-1"],[4,"ngIf"],["id","photo-edits-nav-icon",1,"d-inline-flex","align-items-center","justify-content-center","hw-32","photo-edits-nav-icon"],[1,"pointer",3,"click"],["name","generationview",1,"f-32"],["name","helpicon",1,"f-32","pointer",3,"click"],["name","rightsign",1,"grey-600",3,"click","ngClass"],[1,"d-inline-flex","align-items-center","justify-content-center","hw-32"],["name","mobileaddimage",1,"hw-32","f-32",3,"click"],[1,"mobile-help-overlay","d-flex","align-items-center","justify-content-center","position-fixed","p-4",3,"click"],[1,"border-radius-20","bg-white","pt-4","ps-3","pe-3","pb-3",3,"click"],[1,"text-xxl","text-semi","text-dark","lh-125","text-center"],[1,"text-lg","text-dark","lh-160","mt-8","text-center"],[1,"mt-10"],[1,"btn","btn-primary","btn-h40","w-100",3,"click"]],template:function(t,i){if(1&t){const o=e.RV6();e.j41(0,"div",1),e.DNE(1,Al,1,0,"pi",2)(2,Bl,1,0,"pi",3),e.j41(3,"span")(4,"a",4),e.nrm(5,"img",5),e.k0s()(),e.DNE(6,Ul,2,0,"button",6)(7,Xl,4,6,"div",7)(8,Ll,3,0,"div",8)(9,Yl,1,0,"pi",9)(10,$l,1,4,"pi",10)(11,zl,2,0,"div",11),e.j41(12,"input",12,0),e.bIt("change",function(l){return e.eBV(o),e.Njj(i.onFileUploaded(l.srcElement.files))})("click",function(){e.eBV(o);const l=e.sdS(13);return e.Njj(l.value="")}),e.k0s()(),e.DNE(14,Hl,9,0,"div",13)}2&t&&(e.R7$(),e.Y8G("ngIf",!i.featureType||i.backBtnEnabled),e.R7$(),e.Y8G("ngIf",i.featureType&&!i.backBtnEnabled),e.R7$(2),e.Y8G("routerLink",e.lJ4(11,Vl)),e.R7$(2),e.Y8G("ngIf",!i.user),e.R7$(),e.Y8G("ngIf",i.user),e.R7$(),e.Y8G("ngIf",!i.featureType),e.R7$(),e.Y8G("ngIf",i.featureType&&(null==i.aiPhotoService?null:i.aiPhotoService.isWorkflow)),e.R7$(),e.Y8G("ngIf",i.featureType),e.R7$(),e.Y8G("ngIf",!i.featureType),e.R7$(),e.Y8G("accept",i.aiUploadImageService.fileImageAccept),e.R7$(2),e.Y8G("ngIf",i.isHelpOpen))},dependencies:[b.YU,b.bT,A.Wk,H.b],styles:[".top-editor-header[_ngcontent-%COMP%]{height:48px;border-bottom:1px solid rgba(98,106,223,.1)}.top-editor-header[_ngcontent-%COMP%]   .credit-coin[_ngcontent-%COMP%]{height:32px;padding:4px 10px 4px 6px;border-radius:24px;background:linear-gradient(90deg,#fc5cff1a -4%,#2520f61a)}.top-editor-header[_ngcontent-%COMP%]   .download-rounded[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]{border-radius:360px;width:40px;border:0px!important}.top-editor-header[_ngcontent-%COMP%]   .download-rounded[_ngcontent-%COMP%]   button.btn-disable[_ngcontent-%COMP%]{border-radius:360px;width:40px;background:#c0bfc4}.disable-right[_ngcontent-%COMP%]{color:#d9d9d9!important}.mobile-help-overlay[_ngcontent-%COMP%]{top:0;right:0;bottom:0;left:0;background:#00000059;-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);z-index:2}"]}),a})();var Dt=m(99152);const ql=["viewport"],Kl=["contentEl"],Zl=["imageEl"];function Jl(s,a){if(1&s&&(e.nrm(0,"img",7),e.nI1(1,"safe")),2&s){const n=e.XpG();e.AVh("is-visible",n.isComparing),e.Y8G("src",e.i5U(1,4,n.compareImageUrl,"url"),e.B4B)("alt","Compare image")}}let Ql=(()=>{var s;class a{constructor(){this.imageUrl="",this.compareImageUrl="",this.isComparing=!1,this.alt="Preview image",this.maxScale=3,this.hammer=null,this.scale=1,this.fillScale=1,this.translateX=0,this.translateY=0,this.pinchStartScale=1,this.panOriginX=0,this.panOriginY=0,this.naturalWi
1dth=0,this.naturalHeight=0}ngAfterViewInit(){this.attachGestures(),this.resetTransform()}ngOnChanges(t){(t.imageUrl&&!t.imageUrl.firstChange||t.compareImageUrl&&!t.compareImageUrl.firstChange)&&(this.naturalWidth=0,this.naturalHeight=0,setTimeout(()=>this.resetTransform()))}ngOnDestroy(){this.hammer&&(this.hammer.destroy(),this.hammer=null)}attachGestures(){const t=this.viewportRef?.nativeElement;!t||this.hammer||(t.style.touchAction="none",this.hammer=new nt(t),this.hammer.get("pinch").set({enable:!0}),this.hammer.get("pan").set({enable:!0,direction:nt.DIRECTION_ALL,threshold:0}),this.hammer.on("pinchstart",()=>{this.pinchStartScale=this.scale}),this.hammer.on("pinchmove",i=>{this.scale=this.clamp(this.pinchStartScale*i.scale,1,Math.max(this.maxScale||3,this.fillScale)),this.clampTranslation(),this.applyTransform()}),this.hammer.on("panstart",()=>{this.panOriginX=this.translateX,this.panOriginY=this.translateY}),this.hammer.on("panmove",i=>{this.scale<=this.fillScale||(this.translateX=this.panOriginX+i.deltaX,this.translateY=this.panOriginY+i.deltaY,this.clampTranslation(),this.applyTransform())}),this.hammer.on("doubletap",()=>{this.resetTransform()}))}resetTransform(){this.scale=1,this.fillScale=this.calculateFillScale(),this.translateX=0,this.translateY=0,this.applyTransform()}onImageLoad(){const t=this.imageElRef?.nativeElement;t&&(this.naturalWidth=t.naturalWidth||t.width||0,this.naturalHeight=t.naturalHeight||t.height||0,this.resetTransform())}clampTranslation(){const t=this.viewportRef?.nativeElement;if(!t||this.scale<=this.fillScale)return this.translateX=0,void(this.translateY=0);const i=this.getContainedSize(),r=i.height*this.scale,l=Math.max(0,(i.width*this.scale-t.clientWidth)/2),c=Math.max(0,(r-t.clientHeight)/2);this.translateX=this.clamp(this.translateX,-l,l),this.translateY=this.clamp(this.translateY,-c,c)}applyTransform(){const t=this.contentElRef?.nativeElement;t&&(t.style.transform=`translate3d(${this.translateX}px, ${this.translateY}px, 0) scale(${this.scale})`)}clamp(t,i,o){return Math.min(o,Math.max(i,t))}calculateFillScale(){const t=this.viewportRef?.nativeElement,i=this.getContainedSize();return t&&i.width&&i.height?Math.max(t.clientWidth/i.width,t.clientHeight/i.height,1):1}getContainedSize(){const t=this.viewportRef?.nativeElement;if(!t)return{width:0,height:0};const i=t.clientWidth,o=t.clientHeight,r=this.naturalWidth||i,l=this.naturalHeight||o;if(!(r&&l&&i&&o))return{width:i,height:o};const c=Math.min(i/r,o/l);return{width:r*c,height:l*c}}}return(s=a).\u0275fac=function(t){return new(t||s)},s.\u0275cmp=e.VBU({type:s,selectors:[["mobile-zoom-preview"]],viewQuery:function(t,i){if(1&t&&(e.GBs(ql,7),e.GBs(Kl,7),e.GBs(Zl,7)),2&t){let o;e.mGM(o=e.lsd())&&(i.viewportRef=o.first),e.mGM(o=e.lsd())&&(i.contentElRef=o.first),e.mGM(o=e.lsd())&&(i.imageElRef=o.first)}},inputs:{imageUrl:"imageUrl",compareImageUrl:"compareImageUrl",isComparing:"isComparing",alt:"alt",maxScale:"maxScale"},features:[e.OA$],decls:8,vars:6,consts:[["viewport",""],["contentEl",""],["imageEl",""],[1,"zoom-preview-viewport","border-radius-12"],[1,"zoom-preview-content"],[1,"preview-layer",3,"load","src","alt"],["class","preview-layer compare-layer",3,"is-visible","src","alt",4,"ngIf"],[1,"preview-layer","compare-layer",3,"src","alt"]],template:function(t,i){if(1&t){const o=e.RV6();e.j41(0,"div",3,0)(2,"div",4,1)(4,"img",5,2),e.nI1(6,"safe"),e.bIt("load",function(){return e.eBV(o),e.Njj(i.onImageLoad())}),e.k0s(),e.DNE(7,Jl,2,7,"img",6),e.k0s()()}2&t&&(e.R7$(4),e.Y8G("src",e.i5U(6,3,i.imageUrl,"url"),e.B4B)("alt",i.alt),e.R7$(3),e.Y8G("ngIf",i.compareImageUrl))},dependencies:[b.bT,Pe.m],styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%}.zoom-preview-viewport[_ngcontent-%COMP%]{width:100%;height:100%;overflow:hidden;touch-action:none;position:relative}.zoom-preview-content[_ngcontent-%COMP%]{width:100%;height:100%;position:relative;transform-origin:center center;will-change:transform}.preview-layer[_ngcontent-%COMP%]{position:absolute;top:0;right:0;bottom:0;left:0;width:100%;height:100%;object-fit:contain;-webkit-user-select:none;user-select:none;-webkit-user-drag:none}.compare-layer[_ngcontent-%COMP%]{opacity:0;transition:opacity .08s linear}.compare-layer.is-visible[_ngcontent-%COMP%]{opacity:1}"]}
1),a})();const ec=(s,a)=>({"is-placeholder":s,"has-image":a}),Nt=s=>({"is-selected":s});function tc(s,a){if(1&s&&e.nrm(0,"mobile-zoom-preview",13),2&s){const n=e.XpG();e.Y8G("imageUrl",n.activePreviewUrl)("alt","Upscale preview image")("compareImageUrl",n.canCompare?n.imageUrl:"")("isComparing",n.isComparing&&n.canCompare)}}function ic(s,a){if(1&s){const n=e.RV6();e.j41(0,"button",14),e.bIt("contextmenu",function(i){return e.eBV(n),e.Njj(i.preventDefault())})("pointerdown",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.onCompareStart())})("pointerup",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.onCompareEnd())})("pointercancel",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.onCompareEnd())})("pointerleave",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.onCompareEnd())}),e.nrm(1,"pi",15),e.k0s()}if(2&s){const n=e.XpG();e.Y8G("disabled",n.aiPhotoService.inProgress)}}function nc(s,a){if(1&s&&(e.j41(0,"div",16)(1,"span",17),e.EFF(2),e.k0s(),e.j41(3,"span",18),e.EFF(4),e.k0s()()),2&s){const n=e.XpG();e.R7$(2),e.SpI("",n.selectedOptionLabel," \u2022"),e.R7$(2),e.JRh(n.selectedOutputResolution)}}function oc(s,a){1&s&&e.nrm(0,"pi",19)}function sc(s,a){1&s&&e.nrm(0,"pi",19)}function rc(s,a){1&s&&(e.j41(0,"div",27)(1,"span",28),e.EFF(2,"Loading..."),e.k0s()())}function ac(s,a){if(1&s){const n=e.RV6();e.j41(0,"button",20),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.onActionClick())}),e.DNE(1,rc,3,0,"div",21),e.j41(2,"span",22),e.EFF(3,"Generate"),e.k0s(),e.j41(4,"span",23),e.nrm(5,"img",24)(6,"img",25),e.j41(7,"b",26),e.EFF(8),e.nI1(9,"number"),e.k0s()()()}if(2&s){const n=e.XpG();e.Y8G("disabled",n.isActionDisabled),e.R7$(),e.Y8G("ngIf",n.aiPhotoService.inProgress),e.R7$(7),e.JRh(e.i5U(9,3,n.selectedCredits,"2.0"))}}function lc(s,a){if(1&s){const n=e.RV6();e.j41(0,"button",29),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.onActionClick())}),e.EFF(1," Download "),e.k0s()}}function cc(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"add-credit",30),e.bIt("close",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.step=1)})("addCredit",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.addCredit())}),e.k0s(),e.bVm()}if(2&s){const n=e.XpG();e.R7$(),e.Y8G("consumeCoins",n.selectedCredits)}}let dc=(()=>{var s;class a{constructor(t,i,o,r,l,c,d){this.aiUpscaleService=t,this.aiPhotoService=i,this.authService=o,this.aiGenService=r,this.toastService=l,this.gtmService=c,this.createPopupService=d,this.imageUrl="",this.step=1,this.imageWidth=0,this.imageHeight=0,this.selectedOptionId=null,this.generatedOutputByOption={},this.isComparing=!1,this.errorMsg="",this.requestErrorMsg="",this.user=this.authService.currentUser()}ngOnChanges(t){t.imageUrl&&(this.step=1,this.generatedOutputByOption={},this.isComparing=!1,this.requestErrorMsg="",this.aiPhotoService.selectedUpscaleImageUrl="",this.syncImageDimensions()),t.imageUrl&&this.evaluateSelection()}selectOption(t){this.step=1,this.selectedOptionId=t,this.requestErrorMsg="",this.isComparing=!1,this.evaluateSelection(!0),this.syncSelectedUpscaleOutput()}onActionClick(){this.showDownloadCta?this.downloadSelectedOutput():this.errorMsg?this.toastService.showErrorUpscale(this.errorMsg):!this.canGenerate||!this.selectedOptionId||this.generateUpscale(this.selectedOptionId)}ngOnDestroy(){this.clearTimeInterval(),this.aiPhotoService.clearGenerationProgress(),this.aiPhotoService.selectedUpscaleImageUrl=""}get selectedCredits(){return this.selectedOptionId?this.aiUpscaleService.getRequiredCredits(this.selectedOptionId):1}get canGenerate(){return!!this.imageUrl&&!!this.selectedOptionId&&this.imageWidth>0&&this.imageHeight>0&&!this.errorMsg&&!this.aiPhotoService.inProgress}get showDownloadCta(){return!!this.selectedOutputUrl}get activePreviewUrl(){return this.selectedOutputUrl||this.imageUrl}get selectedOutputUrl(){return this.selectedOptionId&&this.generatedOutputByOption[this.selectedOptionId]?.url||""}get canCompare(){return!!this.selectedOutputUrl}get showResolutionBadge(){return!!this.selectedOutputUrl&&!this.isComparing&&!!this.selectedOutputResolution}get selectedOptionLabel(){return this.selectedOptionId&&this.aiUpscaleService.getOptionById(this.selectedOptionId)?.label||""}get selectedOutputResolution(){if(!this.selectedOptionId)return"";const t=this.generatedOutputByOption[this.selectedOptionId];return t?.width&&t?.height?`${t.width} x ${t.height}`:""}get isActionDisabled(){return this.showDownloadCta?!this.selectedOutputUrl||this.aiPhotoService.inProgress:!this.canGenerate}hasGeneratedOutput(t){return!!this.generatedOutputByOption[t]?.url}onCompareStart(){this.canCompare&&(this.isComparing=!0)}onCompareEnd(){this.isComparing=!1}suppressLongPressDefaults(t){t.preventDefault(),t.stopPropagation()}evaluateSelection(t=!1){if(this.errorMsg="",!this.selectedOptionId||this.imageWidth<=0||this.imageHeight<=0)return;const i=this.aiUpscaleService.validateDimensions(this.imageWidth,this.imageHeight,this.selectedOptionId);this.errorMsg=i.isValid?"":i.errorMsg,!i.isValid&&t&&i.errorMsg&&this.toastService.showErrorUpscale(i.errorMsg)}generateUpscale(t){const i=this.aiUpscaleService.buildGeneratePayload(this.imageUrl,t);if(!i)return;if(this.user=this.authService.currentUser(),!this.user||!this.aiUpscaleService.hasEnoughCredits(this.user.remainingCoins,t))return this.step=1,void this.aiPhotoService.loginAndAICredit(()=>{this.user=this.authService.currentUser(),this.user&&this.aiUpscaleService.hasEnoughCredits(this.user.remainingCoins,t)?this.generateUpscale(t):this.user&&(this.step=3)});this.requestErrorMsg="",this.clearTimeInterval(),this.aiPhotoService.startGenerationProgress({featureType:"upscale"});const o=new Date;this.aiPhotoService.generateImage(i,r=>{r&&r.assetId?this.aiPhotoService.checkStatusResponsive(r,0,l=>{(this.aiPhotoService.processingProgress.isActive||this.aiPhotoService.inProgress||this.aiPhotoService.inVideoProgress)&&this.outputResult(l,t,o)},l=>this.displayErrorMsg(l,o,t,r)):this.displayErrorMsg(r,o,t)},r=>this.displayErrorMsg(r,o,t))}outputResult(t,i,o){t&&t.urls&&t.urls.length>0?this.aiPhotoService.completeGenerationProgress(()=>{this.generatedOutputByOption[i]={url:t.urls[0],response:t},this.syncOutputDimensions(i,t.urls[0]),this.isComparing=!1,this.requestErrorMsg="",this.syncSelectedUpscaleOutput(),this.user&&(this.user.remainingCoins=t.remainingCalls),this.aiPhotoService.isDirty=!0,this.aiPhotoService.generateImageFn?.({...t,featureType:"upscale",selectedTool:"upscale",toolName:"Upscale",upscale:"4x"===i?4:2})}):this.displayErrorMsg({description:"Upscale generation failed. Please try again."},o,i)}closeProgress(t){this.aiPhotoService.completeGenerationProgress()}displayErrorMsg(t,i,o,r=null){this.aiPhotoService.clearGenerationProgress(),this.requestErrorMsg=t?.description||"Something went wrong. Please try again.",this.createPopupService.openWarningDialog("Error",this.requestErrorMsg)}retryCheckStatus(t,i){this.aiPhotoService.startGenerationProgress({featureType:"upscale"});const r=new Date;this.aiPhotoService.checkStatusResponsive(t,0,l=>{(this.aiPhotoService.processingProgress.isActive||this.aiPhotoService.inProgress||this.aiPhotoService.inVideoProgress)&&this.outputResult(l,i,r)},l=>{this.displayErrorMsg(l,r,i,t)})}clearTimeInterval(){this.interValId&&clearInterval(this.interValId),this.interValId1&&clearInterval(this.interValId1)}downloadSelectedOutput(){this.selectedOutputUrl&&(this.aiPhotoService.downloadImg(this.selectedOutputUrl),this.gtmService.pushTag({eventName:y.b.gtm.eventname.aiDownloadMob,itemName:"Editor_Upscale_"+this.selectedOptionLabel}))}syncSelectedUpscaleOutput(){this.aiPhotoService.selectedUpscaleImageUrl=this.selectedOutputUrl||""}syncOutputDimensions(t,i){i&&this.aiPhotoService.getImageDimensions(i).then(o=>{const r=this.generatedOutputByOption[t];!r||r.url!==i||(r.width=o?.width||0,r.height=o?.height||0,this.generatedOutputByOption={...this.generatedOutputByOption})}).catch(()=>{})}syncImageDimensions(){this.imageWidth=0,this.imageHeight=0,this.imageUrl&&this.aiPhotoService.getImageDimensions(this.imageUrl).then(t=>{this.imageWidth=t?.width||0,this.imageHeight=t?.height||0,this.evaluateSelection()}).catch(()=>{this.imageWidth=0,this.imageHeight=0,this.evaluateSelection()})}addCredit(){this.step=1,this.aiGenService.aiCreditPlanCheckout({toolName:"upscale"},()=>{})}}return(s=a).\u0275fac=function(t){return new(t||s)(e.rXU(Dt.D),e.rXU(Z.s),e.rXU(q.u),e.rXU(J.K),e.rXU(Q.f),e.rXU(ie.y),e.rXU(ne.A))},s.\u0275cmp=e.VBU({type:s,selectors:[["ai-upscale-editor-mobile"]],inputs:{imageUrl:"imageUrl"},features:[e.Jv_([Dt.D]),e.OA$],decls:17,vars:17,consts:[[1,"d-flex","align-items-center","justify-content-center","overflow-hidden","w-100","flex-column","p-3","pb-10",2,"height","calc(100dvh - 174px)"],[1,"preview-image","position-relative","bg-grey3","border-radius-12","w-100",3,"ngClass"],[3,"imageUrl","alt","compareImageUrl","isComparing",4,"ngIf"],["class","d-flex align-items-center justify-content-center position-absolute hw-40 border-radius-50 border-0 btn-alpha","style","bottom: 8px; left: 8px;z-index: 10;","type","button",3,"disabled","contextmenu","pointerdown","pointerup","pointercancel","pointerleave",4,"ngIf"],["class","d-flex align-items-center justify-content-center position-absolute border-radius-24 resolution-bar ps-3 pe-3","style","bottom: 8px; right: 8px;",4,"ngIf"],[1,"position-fixed","ps-3","pe-3","d-flex","align-items-center","justify-content-center","w-100","flex-column"],[1,"d-flex","mb-3","w-100","align-items-center","justify-content-center",2,"gap","8px"],["type","button",1,"btn","btn-editor-primary","text-13","text-semi","grey-600","position-relative",2,"flex","1",3,"click","ngClass"],["name","tickicon","class","f-16 grey-800 position-absolute","style","left: 12px;top: calc(50% - 8px);",4,"ngIf"],[1,"d-flex","align-items-center","justify-content-center","w-100"],["id","gtm-generate-mob",1,"btn","btn-primary-gradient","btn-primary-m","text-13","btn-h44","w-100","d-flex","align-items-center","justify-content-center",3,"disabled"],[1,"btn","btn-primary","btn-primary-m","text-lg","btn-h48","w-100","d-flex","align-items-center","justify-content-center"],[4,"ngIf"],[3,"imageUrl","alt","compareImageUrl","isComparing"],["type","button",1,"d-flex","align-items-center","justify-content-center","position-absolute","hw-40","border-radius-50","border-0","btn-alpha",2,"bottom","8px","left","8px","z-index","10",3,"contextmenu","pointerdown","pointerup","pointercancel","pointerleave","disabled"],["name","comparewhite",1,"f-24","text-white"],[1,"d-flex","align-items-center","justify-content-center","position-absolute","border-radius-24","resolution-bar","ps-3","pe-3",2,"bottom","8px","right","8px"],[1,"text-11","text-white","text-semi","lh-140"],[1,"ms-1","text-11","grey-100","lh-140"],["name","tickicon",1,"f-16","grey-800","position-absolute",2,"left","12px","top","calc(50% - 8px)"],["id","gtm-generate-mob",1,"btn","btn-primary-gradient","btn-primary-m","text-13","btn-h44","w-100","d-flex","align-items-center","justify-content-center",3,"click","disabled"],["class","spinner-border spinner-border-lg me-2 hw-24","role","status",4,"ngIf"],[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,"text-11","text-semi",2,"padding-left","2px"],["role","status",1,"spinner-border","spinner-border-lg","me-2","hw-24"],[1,"sr-only","text-nowrap","border-0","position-absolute","overflow-hidden"],[1,"btn","btn-primary","btn-primary-m","text-lg","btn-h48","w-100","d-flex","align-items-center","justify-content-center",3,"click"],[3,"close","addCredit","consumeCoins"]],template:function(t,i){1&t&&(e.j41(0,"div",0)(1,"div",1),e.DNE(2,tc,1,4,"mobile-zoom-preview",2)(3,ic,2,1,"button",3)(4,nc,5,2,"div",4),e.k0s()(),e.j41(5,"div",5)(6,"div",6)(7,"button",7),e.bIt("click",function(){return i.selectOption("2x")}),e.DNE(8,oc,1,0,"pi",8),e.EFF(9,"2X "),e.k0s(),e.j41(10,"button",7),e.bIt("click",function(){return i.selectOption("4x")}),e.DNE(11,sc,1,0,"pi",8),e.EFF(12,"4X "),e.k0s()(),e.j41(13,"div",9),e.DNE(14,ac,10,6,"button",10)(15,lc,2,0,"button",11),e.k0s()(),e.DNE(16,cc,2,1,"ng-container",12)),2&t&&(e.R7$(),e.Y8G("ngClass",e.l_i(10,ec,!i.activePreviewUrl,!!i.activePreviewUrl)),e.R7$(),e.Y8G("ngIf",i.activePreviewUrl),e.R7$(),e.Y8G("ngIf",i.canCompare),e.R7$(),e.Y8G("ngIf",i.showResolutionBadge),e.R7$(3),e.Y8G("ngClass",e.eq3(13,Nt,"2x"===i.selectedOptionId)),e.R7$(),e.Y8G("ngIf",i.hasGeneratedOutput("2x")),e.R7$(2),e.Y8G("ngClass",e.eq3(15,Nt,"4x"===i.selectedOptionId)),e.R7$(),e.Y8G("ngIf",i.hasGeneratedOutput("4x")),e.R7$(3),e.vxM(i.showDownloadCta?15:14),e.R7$(2),e.Y8G("ngIf",3==i.step))},dependencies:[b.YU,b.bT,H.b,pe,Ql,b.QX],styles:[".preview-image[_ngcontent-%COMP%]{width:100%;height:100%;display:flex;align-items:center;justify-content:center}.preview-image[_ngcontent-%COMP%]   mobile-zoom-preview[_ngcontent-%COMP%]{width:100%;height:100%;display:block}.btn-editor-primary.is-selected[_ngcontent-%COMP%]{border-color:#626adf!important;background:#626adf0d;color:#626adf!important}.btn-editor-primary.is-selected[_ngcontent-%COMP%]   pi[_ngcontent-%COMP%]{color:#626adf!important}.inable[_ngcontent-%COMP%]{display:block}.disable[_ngcontent-%COMP%]{display:none}.btn[_ngcontent-%COMP%]:disabled{background:#d5d6dd;border:1px solid #D5D6DD}.btn[_ngcontent-%COMP%]:disabled   .coin-count[_ngcontent-%COMP%]{background:#0000001a}.btn[_ngcontent-%COMP%]:disabled   .coin-count[_ngcontent-%COMP%]   b[_ngcontent-%COMP%]{color:#fff!important}.btn[_ngcontent-%COMP%]:disabled   .inable[_ngcontent-%COMP%]{display:none}.btn[_ngcontent-%COMP%]:disabled   .disable[_ngcontent-%COMP%]{display:block}.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}.coin-count[_ngcontent-%COMP%]   b[_ngcontent-%COMP%]{color:#fff!important}
1.resolution-bar[_ngcontent-%COMP%]{border-radius:24px;background:#5f6578b3;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);height:32px}.showpreview-overlay[_ngcontent-%COMP%]{position:fixed;right:0;left:0;background:#0003;-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);z-index:2;width:100%;height:100%;top:0;bottom:0}"]}),a})();var hc=m(57593);const pc=["carousel"],mc=(s,a,n)=>({"hide-arrow":s,isFirst:a,isLast:n});function uc(s,a){if(1&s&&(e.nrm(0,"img",17),e.nI1(1,"safe")),2&s){const n=e.XpG(4);e.AVh("is-visible",n.isComparing),e.Y8G("src",e.i5U(1,3,n.sourceImageUrl,"url"),e.B4B)}}function gc(s,a){if(1&s&&(e.j41(0,"div",13)(1,"div",14),e.nrm(2,"img",15),e.nI1(3,"safe"),e.DNE(4,uc,2,6,"img",16),e.k0s()()),2&s){const n=e.XpG().$implicit,t=e.XpG(2);e.R7$(2),e.AVh("is-hidden",t.isComparing),e.Y8G("src",e.i5U(3,4,(null==n||null==n.urls?null:n.urls[0])||"","url"),e.B4B),e.R7$(2),e.Y8G("ngIf",t.sourceImageUrl)}}function _c(s,a){1&s&&e.DNE(0,gc,5,7,"ng-template",12),2&s&&e.Y8G("id",""+a.$implicit.assetId)}function fc(s,a){if(1&s){const n=e.RV6();e.j41(0,"button",18),e.bIt("contextmenu",function(i){return e.eBV(n),e.Njj(i.preventDefault())})("mousedown",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.onCompareStart())})("mouseup",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.onCompareEnd())})("pointerdown",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.onCompareStart())})("pointerup",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.onCompareEnd())})("pointercancel",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.onCompareEnd())})("pointerleave",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.onCompareEnd())})("touchstart",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.onCompareStart())})("touchend",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.onCompareEnd())})("touchcancel",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.onCompareEnd())}),e.nrm(1,"pi",19),e.k0s()}if(2&s){const n=e.XpG(2);e.Y8G("disabled",n.inProgress)}}function vc(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"div",5)(2,"div",6)(3,"ngb-carousel",7,1),e.bIt("slide",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.onSlide(i))}),e.DNE(5,_c,1,1,null,8),e.k0s(),e.j41(6,"button",9),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.downloadCurrentPreview())}),e.nrm(7,"pi",10),e.k0s(),e.DNE(8,fc,2,1,"button",11),e.k0s()(),e.bVm()}if(2&s){const n=e.XpG();e.R7$(3),e.Y8G("activeId",n.activeId)("wrap",!1)("interval",0)("ngClass",e.sMw(6,mc,n.generatedImages.length<=1,n.isFirst,n.isLast)),e.R7$(2),e.Y8G("ngForOf",n.generatedImages),e.R7$(3),e.Y8G("ngIf",n.canCompare)}}function bc(s,a){if(1&s&&(e.nrm(0,"img",23),e.nI1(1,"safe")),2&s){const n=e.XpG(2);e.Y8G("src",e.i5U(1,1,n.fallbackPreviewUrl||"","url"),e.B4B)}}function Cc(s,a){1&s&&(e.j41(0,"div",24)(1,"span"),e.EFF(2,"Your generations will be displayed here"),e.k0s()())}function xc(s,a){if(1&s){const n=e.RV6();e.j41(0,"button",25),e.bIt("click",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.downloadCurrentPreview())}),e.nrm(1,"pi",10),e.k0s()}}function Pc(s,a){if(1&s&&(e.j41(0,"div",20),e.DNE(1,bc,2,4,"img",21)(2,Cc,3,0,"ng-template",null,2,e.C5r)(4,xc,2,0,"button",22),e.k0s()),2&s){const n=e.sdS(3),t=e.XpG();e.R7$(),e.Y8G("ngIf",t.fallbackPreviewUrl)("ngIfElse",n),e.R7$(3),e.Y8G("ngIf",t.fallbackPreviewUrl)}}let Xt=(()=>{var s;class a{constructor(t,i){this.offcanvasService=t,this.toastService=i,this.images=[],this.sourceImageUrl="",this.fallbackImageUrl="",this.inProgress=!1,this.focusAssetId="",this.activeImageUrlChange=new e.bkB,this.downloadRequested=new e.bkB,this.isShowPreview=!1,this.activeId="",this.isFirst=!1,this.isLast=!0,this.isComparing=!1,this.lastImageCount=0}ngOnChanges(t){(t.images||t.focusAssetId)&&(this.lastImageCount=this.generatedImages.length,this.syncActiveSlide(),this.carousel&&this.activeId&&this.carousel.select(this.activeId),this.updateNavigationFlags(),this.isComparing=!1,this.emitActiveImageUrl())}ngDoCheck(){const t=this.generatedImages.length;t!==this.lastImageCount&&(this.lastImageCount=t,this.syncActiveSlide(),this.carousel&&this.activeId&&this.carousel.select(this.activeId),this.updateNavigationFlags(),this.emitActiveImageUrl())}get generatedImages(){return this.images||[]}get hasGeneratedImages(){return this.generatedImages.length>0}get canCompare(){return!!this.currentGeneratedUrl&&!!this.sourceImageUrl}get currentGeneratedUrl(){return this.hasGeneratedImages&&(this.generatedImages.find(i=>String(i.assetId)===String(this.activeId))?.urls?.[0]||this.generatedImages[this.generatedImages.length-1]?.urls?.[0])||""}get fallbackPreviewUrl(){return this.fallbackImageUrl||this.sourceImageUrl||""}onSlide(t){if(!t||!this.generatedImages.length)return;const i=t.next??t.current;if(!i)return;const o=this.generatedImages.find(r=>String(r.assetId)===String(i));o&&(this.activeId=o.assetId,this.updateNavigationFlags(),this.emitActiveImageUrl(o?.urls?.[0]||""),this.isComparing=!1,this.carousel&&this.activeId&&this.carousel.select(this.activeId))}onCompareStart(){!this.canCompare||this.inProgress||(this.isComparing=!0)}onCompareEnd(){this.isComparing=!1}downloadCurrentPreview(){const t=this.currentGeneratedUrl||this.fallbackPreviewUrl;t&&this.downloadRequested.emit(t)}syncActiveSlide(){if(!this.generatedImages.length)return this.activeId="",void this.updateNavigationFlags();const t=String(this.focusAssetId||"");if(t&&this.generatedImages.some(i=>String(i.assetId)===t))this.activeId=t;else if(!this.activeId||!this.generatedImages.some(i=>String(i.assetId)===String(this.activeId))){const i=this.generatedImages[this.generatedImages.length-1];this.activeId=String(i?.assetId||this.generatedImages[0]?.assetId||"")}this.updateNavigationFlags()}updateNavigationFlags(){if(this.generatedImages.length<=1)return this.isFirst=!0,void(this.isLast=!0);const t=this.generatedImages.findIndex(o=>String(o.assetId)===String(this.activeId)),i=t>=0?t:this.generatedImages.length-1;this.isFirst=0===i,this.isLast=i===this.generatedImages.length-1}emitActiveImageUrl(t=""){this.activeImageUrlChange.emit(t||this.currentGeneratedUrl||"")}}return(s=a).\u0275fac=function(t){return new(t||s)(e.rXU(R.RS),e.rXU(Q.f))},s.\u0275cmp=e.VBU({type:s,selectors:[["mobile-generated-compare-preview"],["change-variation-generated-preview-mobile"]],viewQuery:function(t,i){if(1&t&&e.GBs(pc,5),2&t){let o;e.mGM(o=e.lsd())&&(i.carousel=o.first)}},inputs:{images:"images",sourceImageUrl:"sourceImageUrl",fallbackImageUrl:"fallbackImageUrl",inProgress:"inProgress",focusAssetId:"focusAssetId"},outputs:{activeImageUrlChange:"activeImageUrlChange",downloadRequested:"downloadRequested"},features:[e.OA$],decls:4,vars:2,consts:[["fallbackPreview",""],["carousel",""],["placeholderText",""],[1,"w-100","h-100"],[4,"ngIf","ngIfElse"],[1,"align-items-center","justify-content-center","overflow-hidde","w-100","flex-column","pb-0","intermediate-sl
1ider","d-flex"],[1,"d-flex","align-items-center","justify-content-start","overflow-hidde","h-100","w-100","ngb-carousel","border-radius-12","bg-grey3","position-relative"],[1,"h-100","w-100",3,"slide","activeId","wrap","interval","ngClass"],[4,"ngFor","ngForOf"],["type","button",1,"d-flex","align-items-center","justify-content-center","position-absolute","hw-40","border-radius-50","border-0","downloadBtn","preview-action-btn","btn-alpha",3,"click"],["name","downloadblack",1,"f-24","text-white"],["class","d-flex align-items-center justify-content-center position-absolute hw-40 border-radius-50 border-0 preview-action-btn compare-action-btn btn-alpha","type","button",3,"disabled","contextmenu","mousedown","mouseup","pointerdown","pointerup","pointercancel","pointerleave","touchstart","touchend","touchcancel",4,"ngIf"],["ngbSlide","",3,"id"],[1,"d-flex","overflow-hidden","w-100","flex-column","align-items-center","justify-content-center","h-100"],[1,"h-100","w-100","position-relative"],["alt","Generated preview image",1,"w-100","h-100","preview-contain","generated-layer",3,"src"],["class","w-100 h-100 position-absolute compare-layer preview-contain","alt","Compare image",3,"is-visible","src",4,"ngIf"],["alt","Compare image",1,"w-100","h-100","position-absolute","compare-layer","preview-contain",3,"src"],["type","button",1,"d-flex","align-items-center","justify-content-center","position-absolute","hw-40","border-radius-50","border-0","preview-action-btn","compare-action-btn","btn-alpha",3,"contextmenu","mousedown","mouseup","pointerdown","pointerup","pointercancel","pointerleave","touchstart","touchend","touchcancel","disabled"],["name","comparewhite",1,"f-24","text-white"],[1,"d-flex","align-items-center","justify-content-center","overflow-hidden","border-radius-12","position-relative","w-100","h-100","bg-grey3"],["class","w-100 h-100 preview-contain","alt","Input preview image",3,"src",4,"ngIf","ngIfElse"],["class","d-flex align-items-center justify-content-center position-absolute hw-40 border-radius-50 border-0 preview-action-btn btn-alpha","type","button",3,"click",4,"ngIf"],["alt","Input preview image",1,"w-100","h-100","preview-contain",3,"src"],[1,"text-center"],["type","button",1,"d-flex","align-items-center","justify-content-center","position-absolute","hw-40","border-radius-50","border-0","preview-action-btn","btn-alpha",3,"click"]],template:function(t,i){if(1&t&&(e.j41(0,"div",3),e.DNE(1,vc,9,10,"ng-container",4)(2,Pc,5,3,"ng-template",null,0,e.C5r),e.k0s()),2&t){const o=e.sdS(3);e.R7$(),e.Y8G("ngIf",i.hasGeneratedImages)("ngIfElse",o)}},dependencies:[b.YU,b.Sq,b.bT,R.Oj,R.bD,H.b,Pe.m],styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%}.intermediate-slider[_ngcontent-%COMP%]{height:100%}.preview-contain[_ngcontent-%COMP%]{object-fit:contain}.preview-action-btn[_ngcontent-%COMP%]{top:8px;right:8px;z-index:2;background:#60657699;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px)}.compare-action-btn[_ngcontent-%COMP%]{top:auto;right:auto;bottom:8px;left:8px}.compare-layer[_ngcontent-%COMP%]{top:0;right:0;bottom:0;left:0;opacity:0;transition:opacity .08s linear;z-index:1}.compare-layer.is-visible[_ngcontent-%COMP%]{opacity:1}.generated-layer[_ngcontent-%COMP%]{opacity:1;transition:opacity .08s linear}.generated-layer.is-hidden[_ngcontent-%COMP%]{opacity:0}[_nghost-%COMP%]     ngb-carousel{height:100%}[_nghost-%COMP%]     .carousel-inner, [_nghost-%COMP%]     .carousel-item, [_nghost-%COMP%]     .carousel-item.active, [_nghost-%COMP%]     .carousel-item-next, [_nghost-%COMP%]     .carousel-item-prev{height:100%}[_nghost-%COMP%]     .carousel-item>div{height:100%}.report-flag[_ngcontent-%COMP%]{border-radius:100px;background:#60657633;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);right:56px}"]}),a})();const Ic=s=>({"has-thumb":s}),yc=s=>({"is-active":s});function wc(s,a){if(1&s&&e.nrm(0,"img",18),2&s){const n=e.XpG();e.Y8G("src",null==n.customStyleField?null:n.customStyleField.thumbUrl,e.B4B)}}function Sc(s,a){1&s&&e.nrm(0,"span",19)}function Mc(s,a){1&s&&(e.j41(0,"span",20),e.nrm(1,"pi",21),e.k0s())}function kc(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",22)(1,"div",23)(2,"custom-style",24),e.bIt("closePopover",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.closeStyleSheet())})("valueChanged",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.onCustomStyleValueChanged())}),e.k0s()()(),e.j41(3,"div",25),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.closeStyleSheet())}),e.k0s()}if(2&s){const n=e.XpG();e.R7$(2),e.Y8G("field",n.customStyleField)("closeOnStyleSelect",!0)}}function Tc(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"add-credit",26),e.bIt("close",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.step=1)})("addCredit",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.addCredit())}),e.k0s(),e.bVm()}if(2&s){const n=e.XpG();e.R7$(),e.Y8G("consumeCoins",n.qualityType)}}let Oc=(()=>{var s;class a{constructor(t,i,o,r,l,c,d){this.aiPhotoService=t,this.authService=i,this.paymentService=o,this.mediaContentService=r,this.aiGenService=l,this.createPopupService=c,this.envService=d,this.featureType=f.Fs.ChangeCameraAngle,this.imageUrl="",this.step=1,this.customStyleField=null,this.isStyleSheetOpen=!1,this.qual
1ityType=1,this.activePreviewAssetId="",this.successfulProductImageIds=new Set,this.successfulInputTexts=new Set,this.defaultCustomStyleField={type:"product",displayName:"Style",productId:0,modelTypeId:0,productImageId:0,productName:"",inputText:"",value:"",thumbUrl:"",innerPage:{displayName:"Choose Style",inputType:{type:"textbox",inputTextEnable:!0,placeholder:"Describe style",suggestedPrompt:[]}}},this.user=this.authService.currentUser(),this.paymentSub=this.paymentService.configUpdated.subscribe(()=>{this.qualityType=this.getQualityTypeFromConfig()})}ngOnInit(){this.qualityType=this.getQualityTypeFromConfig(),this.resetGeneratedState(),this.loadWorkflowField()}ngOnChanges(t){t.featureType&&!t.featureType.firstChange&&(this.resetGeneratedState(),this.qualityType=this.getQualityTypeFromConfig(),this.loadWorkflowField()),t.imageUrl&&!t.imageUrl.firstChange&&this.resetGeneratedState()}ngOnDestroy(){this.clearTimeInterval(),this.aiPhotoService.clearGenerationProgress(),this.paymentSub&&this.paymentSub.unsubscribe()}get title(){return this.isLightingTool?"Change Lighting":"Change Camera"}get styleSheetTitle(){return this.isLightingTool?"Lighting":"Camera View"}get selectorPlaceholder(){return this.isLightingTool?"Select Lighting":"Select Camera View"}get selectedStyleLabel(){return this.customStyleField?.inputText||this.customStyleField?.productName||this.selectorPlaceholder}get canGenerate(){return!!this.imageUrl&&!!(this.customStyleField?.thumbUrl||this.customStyleField?.inputText||this.customStyleField?.productName)&&!this.aiPhotoService.inProgress}get hasGeneratedResult(){return!!this.aiPhotoService?.aiImages?.length}get shouldShowGenerateMore(){if(!this.hasGeneratedResult)return!1;const t=this.getNormalizedInputText(this.customStyleField?.inputText);if(t)return this.successfulInputTexts.has(t);const i=Number(this.customStyleField?.productImageId)||0;return i>0&&this.successfulProductImageIds.has(i)}get isLightingTool(){return this.featureType===f.Fs.ChangeLighting}openStyleSheet(){this.customStyleField&&(this.isStyleSheetOpen=!0)}closeStyleSheet(){this.isStyleSheetOpen=!1}onCustomStyleValueChanged(){}generate(){if(!this.canGenerate)return;if(this.step=1,this.user=this.authService.currentUser(),!this.user||this.user.remainingCoins<this.qualityType)return void this.aiPhotoService.loginAndAICredit(()=>{this.user=this.authService.currentUser(),this.user&&this.user.remainingCoins>=this.qualityType?this.generate():this.user&&(this.step=3)});this.clearTimeInterval(),this.aiPhotoService.startGenerationProgress({featureType:this.featureType});const t=new Date,i=this.buildGeneratePayload(),o=this.buildSuccessfulGenerationMarker(i);this.aiPhotoService.generateImage(i,r=>{r&&r.assetId?this.aiPhotoService.checkStatusResponsive(r,0,l=>{(this.aiPhotoService.processingProgress.isActive||this.aiPhotoService.inProgress||this.aiPhotoService.inVideoProgress)&&this.outputResult(l,t,o)},l=>this.displayErrorMsg(l,t,r,o)):this.displayErrorMsg(r,t,null,o)},r=>this.displayErrorMsg(r,t,null,o))}buildGeneratePayload(){const t=(this.customStyleField?.inputText||"").trim(),i=!!t,o=this.customStyleField?.modelTypeId||0;return{imageUrl:this.imageUrl,featureType:this.featureType,...!i&&this.customStyleField?.productId&&{productId:this.customStyleField.productId},...o>0&&{model:o},...this.customStyleField?.productImageId&&{productImageId:this.customStyleField.productImageId},...i&&{textPrompt:t}}}outputResult(t,i,o){t?.urls?.length?this.aiPhotoService.completeGenerationProgress(()=>{this.syncSelectedOutput(t.urls[0]||"");const l=this.aiPhotoService?.aiImages?.[this.aiPhotoService.aiImages.length-1];l?.assetId&&(this.activePreviewAssetId=String(l.assetId)),this.user&&(this.user.remainingCoins=t.remainingCalls),this.markSuccessfulGeneration(o),this.aiPhotoService.isDirty=!0}):this.displayErrorMsg({description:"Generation failed. Please try again."},i)}syncSelectedOutput(t){t&&(this.aiPhotoService.selectedUpscaleImageUrl=t)}resetGeneratedState(){this.aiPhotoService.selectedUpscaleImageUrl="",this.aiPhotoService.aiImages=[],this.activePreviewAssetId="",this.successfulProductImageIds.clear(),this.successfulInputTexts.clear()}onPreviewImageChange(t){this.syncSelectedOutput(t)}onPreviewDownload(t){t&&this.aiPhotoService.downloadImg(t)}
1getNormalizedInputText(t){return String(t||"").trim()}buildSuccessfulGenerationMarker(t){return{inputText:this.getNormalizedInputText(t?.textPrompt),productImageId:Number(t?.productImageId)||0}}markSuccessfulGeneration(t){const i=this.getNormalizedInputText(t?.inputText);if(i)return void this.successfulInputTexts.add(i);const o=Number(t?.productImageId)||0;o>0&&this.successfulProductImageIds.add(o)}loadWorkflowField(){this.customStyleField=JSON.parse(JSON.stringify(this.defaultCustomStyleField)),this.customStyleField.innerPage.inputType.suggestedPrompt=this.getSuggestedPrompts(),this.mediaContentService.getWorkflows(this.isLightingTool?350:351,i=>{const r=(i?.productConfig||i?.body?.productConfig||[])?.[0],l=r?.fields?.[0];l&&(this.customStyleField=Object.assign({},JSON.parse(JSON.stringify(this.defaultCustomStyleField)),JSON.parse(JSON.stringify(l))),!this.customStyleField?.productId&&r?.productId&&(this.customStyleField.productId=r.productId),this.customStyleField.modelTypeId=r?.modelTypeId||0,this.customStyleField.popoverOpen=!1)},()=>{})}getSuggestedPrompts(){return this.isLightingTool?[{prompt:"Soft front light"},{prompt:"Natural window glow"},{prompt:"Studio shadow tone"},{prompt:"Bright high key"}]:[{prompt:"Close-up view"},{prompt:"High angle view"},{prompt:"Low angle view"},{prompt:"Front left quarter"}]}getQualityTypeFromConfig(){return this.paymentService?.config?.creditInfo?.[this.featureType]||1}closeProgress(t){this.aiPhotoService.completeGenerationProgress()}displayErrorMsg(t,i,o=null,r=null){this.aiPhotoService.clearGenerationProgress(),this.createPopupService.openWarningDialog("Error",t?.description||"Something went wrong")}retryCheckStatus(t,i){this.aiPhotoService.startGenerationProgress({featureType:this.featureType});const o=new Date;this.aiPhotoService.checkStatusResponsive(t,0,r=>{(this.aiPhotoService.processingProgress.isActive||this.aiPhotoService.inProgress||this.aiPhotoService.inVideoProgress)&&this.outputResult(r,o,i)},r=>this.displayErrorMsg(r,o,t,i))}clearTimeInterval(){this.interValId&&clearInterval(this.interValId),this.interValId1&&clearInterval(this.interValId1)}addCredit(){this.step=1,this.aiGenService.aiCreditPlanCheckout({toolName:this.featureType||"change_variation"},()=>{})}}return(s=a).\u0275fac=function(t){return new(t||s)(e.rXU(Z.s),e.rXU(q.u),e.rXU(de.W),e.rXU(we.Z),e.rXU(J.K),e.rXU(ne.A),e.rXU(xe.L))},s.\u0275cmp=e.VBU({type:s,selectors:[["ai-change-variation-mobile"]],inputs:{featureType:"featureType",imageUrl:"imageUrl"},features:[e.OA$],decls:22,vars:21,consts:[[1,"ai-change-variation-mobile"],[1,"preview-shell",2,"overflow","inherit !important"],[1,"w-100","h-100","d-block",3,"activeImageUrlChange","downloadRequested","images","sourceImageUrl","fallbackImageUrl","inProgress","focusAssetId"],[1,"variation-controls"],["type","button",1,"style-selector",3,"click","disabled"],[1,"style-thumb",3,"ngClass"],["alt","",3,"src",4,"ngIf"],["class","blank-icon",4,"ngIf"],["class","prompt-edit d-flex align-items-center justify-content-center",4,"ngIf"],[1,"style-label"],["name","chevronaarrow",1,"f-24"],["type","button",1,"btn","btn-primary-gradient","btn-primary-m","text-13","btn-h44","w-100","d-flex","align-items-center","justify-content-center",3,"click","ngClass","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,"text-11","text-semi",2,"padding-left","2px"],[4,"ngIf"],["alt","",3,"src"],[1,"blank-icon"],[1,"prompt-edit","d-flex","align-items-center","justify-content-center"],["name","promptedit",1,"f-24"],[1,"mobile-style-panel"],[1,"mobile-style-body"],[3,"closePopover","valueChanged","field","closeOnStyleSelect"],[1,"showpreview-overlay",3,"click"],[3,"close","addCredit","consumeCoins"]],template:function(t,i){1&t&&(e.j41(0,"div",0)(1,"div",1)(2,"mobile-generated-compare-preview",2),e.bIt("activeImageUrlChange",function(r){return i.onPreviewImageChange(r)})("downloadRequested",function(r){return i.onPreviewDownload(r)}),e.k0s()(),e.j41(3,"div",3)(4,"button",4),e.bIt("click",function(){return i.openStyleSheet()}),e.j41(5,"span",5),e.DNE(6,wc,1,1,"img",6)(7,Sc,1,0,"span",7)(8,Mc,2,0,"span",8),e.k0s(),e.j41(9,"span",9),e.EFF(10),e.k0s(),e.nrm(11,"pi",10),e.k0s(),e.j41(12,"button",11),e.bIt("click",function(){return i.generate()}),e.j41(13,"span",12),e.EFF(14),e.k0s(),e.j41(15,"span",13),e.nrm(16,"img",14)(17,"img",15),e.j41(18,"b",16),e.EFF(19),e.k0s()()()()(),e.DNE(20,kc,4,2)(21,Tc,2,1,"ng-container",17)),2&t&&(e.R7$(2),e.Y8G("images",i.aiPhotoService.aiImages)("sourceImageUrl",i.imageUrl)("fallbackImageUrl",i.imageUrl)("inProgress",i.aiPhotoService.inProgress)("focusAssetId",i.activePreviewAssetId),e.R7$(2),e.Y8G("disabled",i.aiPhotoService.inProgress),e.R7$(),e.Y8G("ngClass",e.eq3(17,Ic,(null==i.customStyleField?null:i.customStyleField.thumbUrl)||(null==i.customStyleField?null:i.customStyleField.inputText))),e.R7$(),e.Y8G("ngIf",null==i.customStyleField?null:i.customStyleField.thumbUrl),e.R7$(),e.Y8G("ngIf",!(null!=i.customStyleField&&i.customStyleField.thumbUrl||null!=i.customStyleField&&i.customStyleField.inputText)),e.R7$(),e.Y8G("ngIf",null==i.customStyleField?null:i.customStyleField.inputText),e.R7$(2),e.JRh(i.selectedStyleLabel),e.R7$(2),e.Y8G("ngClass",e.eq3(19,yc,i.canGenerate))("disabled",!i.canGenerate),e.R7$(2),e.JRh(i.aiPhotoService.inProgress?"Processing":i.shouldShowGenerateMore?"Generate More":"Generate"),e.R7$(5),e.JRh(i.qual
1ityType),e.R7$(),e.vxM(i.envService.isMobileView&&i.customStyleField&&i.isStyleSheetOpen?20:-1),e.R7$(),e.Y8G("ngIf",3==i.step))},dependencies:[b.YU,b.bT,H.b,pe,hc.G,Xt],styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%}.ai-change-variation-mobile[_ngcontent-%COMP%]{display:flex;flex-direction:column;height:100%;min-height:0;padding:12px 16px 4px;background:#f8f9f9;box-sizing:border-box;position:relative}.preview-shell[_ngcontent-%COMP%]{flex:1;min-height:0;border-radius:12px;overflow:hidden;background:#efeef2;margin-bottom:20px;position:relative}.preview-image[_ngcontent-%COMP%]{width:100%;height:100%;display:flex;align-items:center;justify-content:center}.preview-image[_ngcontent-%COMP%]   mobile-zoom-preview[_ngcontent-%COMP%]{width:100%;height:100%;display:block}.placeholder-text[_ngcontent-%COMP%]{max-width:240px;text-align:center;color:#b0b3bf;font-size:32px;font-weight:700;line-height:1.25}.download-fab[_ngcontent-%COMP%]{position:absolute;top:8px;right:8px;z-index:2;display:inline-flex;align-items:center;justify-content:center;width:40px;height:40px;border:0;border-radius:50%;background:#ffffffd9;color:#272b34;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px)}.variation-controls[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:16px;margin-top:auto}.style-selector[_ngcontent-%COMP%]{display:flex;align-items:center;gap:8px;width:100%;height:48px;padding:7px 8px 7px 0;border:1px solid #e2e3e9;border-radius:12px;background:#626adf0d;color:#272b34;text-align:left}.style-thumb[_ngcontent-%COMP%]{display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;min-width:34px;border:1px solid #e2e3e9;border-radius:8px;background:#fff;color:#272b34;overflow:hidden;margin-left:7px}.style-thumb[_ngcontent-%COMP%]   img[_ngcontent-%COMP%]{width:100%;height:100%;object-fit:cover}.has-thumb[_ngcontent-%COMP%]{width:40px;height:40px;border-radius:8px;border:1px solid #E2E3E9;margin-left:4px}.style-label[_ngcontent-%COMP%]{flex:1;min-width:0;overflow:hidden;color:#272b34;font-size:13px;line-height:1.25;text-overflow:ellipsis;white-space:nowrap}.generated-strip[_ngcontent-%COMP%]{display:flex;gap:8px;overflow-x:auto;scrollbar-width:none}.generated-strip[_ngcontent-%COMP%]::-webkit-scrollbar{display:none}.generated-thumb[_ngcontent-%COMP%]{width:64px;height:64px;min-width:64px;padding:2px;border:2px solid transparent;border-radius:12px;background:transparent;overflow:hidden}.generated-thumb[_ngcontent-%COMP%]   img[_ngcontent-%COMP%]{width:100%;height:100%;border-radius:8px;object-fit:cover}.generated-thumb.is-selected[_ngcontent-%COMP%]{border-color:#626adf}.generate-btn[_ngcontent-%COMP%]{height:48px;width:100%;border:0;border-radius:12px;background:#d9d9d9;color:#fff;font-size:16px;font-weight:600;display:inline-flex;align-items:center;justify-content:center;gap:8px}.generate-btn.is-active[_ngcontent-%COMP%]{background:linear-gradient(90deg,#fc5cff,#2520f6)}.generate-btn[_ngcontent-%COMP%]:disabled{cursor:not-allowed;opacity:.9}.credit-chip[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:2px;min-width:42px;height:24px;padding:0 6px 0 4px;border-radius:8px;background:#ffffff1a;font-size:13px;line-height:1.25}.credit-count[_ngcontent-%COMP%]{min-width:12px;text-align:center;color:#fff}.mobile-style-panel[_ngcontent-%COMP%]{position:fixed;left:0;right:0;bottom:0;z-index:3;background:#fff;border-radius:18px 18px 0 0;max-height:90vh;overflow:auto;height:100%}.showpreview-overlay[_ngcontent-%COMP%]{position:fixed;right:0;left:0;background:#0003;-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);z-index:2;width:100%;height:100%;top:0;bottom:0}.blank-icon[_ngcontent-%COMP%]{border-radius:4px;background:#f25555;width:24px;height:2px;transform:rotate(-45deg)}.prompt-edit[_ngcontent-%COMP%]{border-radius:8px;border:1px solid #E2E3E9;background:linear-gradient(137deg,#df61ff33 5.65%,#3ad0ff33 96.38%);width:40px;height:40px}[_nghost-%COMP%]     .intermediate-slider{height:100%}[_nghost-%COMP%]     .intermediate-image-area{height:100%!important}[_nghost-%COMP%]     .res-round{height:auto!important}[_nghost-%COMP%]     .downloadBtn{z-index:1!important}.inable[_ngcontent-%COMP%]{display:block}.disable[_ngcontent-%COMP%]{display:none}.generate-btn[_ngcontent-%COMP%]:disabled{background:#d5d6dd;border:1px solid #D5D6DD}.generate-btn[_ngcontent-%COMP%]:disabled   .coin-count[_ngcontent-%COMP%]{background:#0000001a}.generate-btn[_ngcontent-%COMP%]:disabled   .coin-count[_ngcontent-%COMP%]   b[_ngcontent-%COMP%]{color:#fff!important}.generate-btn[_ngcontent-%COMP%]:disabled   .inable[_ngcontent-%COMP%]{display:none}.generate-btn[_ngcontent-%COMP%]:disabled   .disable[_ngcontent-%COMP%]{display:block}.prompt-edit[_ngcontent-%COMP%]{border-radius:8px;border:1px solid var(--colors-NEW-GREY-Opaque-100, #E2E3E9);background:linear-gradient(137deg,#df61ff33 5.65%,#3ad0ff33 96.38%);width:40px;height:40px}.btn[_ngcontent-%COMP%]:disabled{background:#d5d6dd;border:1px solid #D5D6DD}.btn[_ngcontent-%COMP%]:disabled   .coin-count[_ngcontent-%COMP%]{background:#0000001a}.btn[_ngcontent-%COMP%]:disabled   .coin-count[_ngcontent-%COMP%]   b[_ngcontent-%COMP%]{color:#fff!important}.btn[_ngcontent-%COMP%]:disabled   .inable[_ngcontent-%COMP%]{display:none}.btn[_ngcontent-%COMP%]:disabled   .disable[_ngcontent-%COMP%]{display:block}.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}.coin-count[_ngcontent-%COMP%]   b[_ngcontent-%COMP%]{color:#fff!important}"]}),a})();var Ne=m(79829),Lt=m(8071),Xe=m(78582),Yt=m(34110),ke=m(45312),Te=m(90369);const Ec=["lensCanvas"];let Le=(()=>{var s;class a{constructor(t){this.changeDetector=t,this.diameter=80,this.zoomDeltaMultiplier=1.5,this.visible=!1,this.side="left",this.brushCe
1nterX=38,this.brushCenterY=38,this.brushDiameter=20,this.borderWidth=2,this.pendingFrame=null,this.renderFrameId=null,this.outputContext=null,this.outputSize=0}show(t){this.visible=!0,this.resolveSide(t),this.render(t),this.changeDetector.markForCheck()}update(t){this.resolveSide(t),this.pendingFrame=t,this.changeDetector.markForCheck(),null===this.renderFrameId&&(this.renderFrameId=requestAnimationFrame(()=>{this.renderFrameId=null;const i=this.pendingFrame;this.pendingFrame=null,i&&this.visible&&this.render(i)}))}resolveSide(t){const i=t.viewportHeight||0;i>0&&t.clientY>=t.viewportTop+i/2||(this.side=t.clientX>=t.viewportLeft+t.viewportWidth/2?"left":"right")}hide(){!this.visible&&!this.pendingFrame&&null===this.renderFrameId||(this.visible=!1,this.pendingFrame=null,null!==this.renderFrameId&&(cancelAnimationFrame(this.renderFrameId),this.renderFrameId=null),this.changeDetector.markForCheck())}ngOnDestroy(){this.hide(),this.outputContext=null}render(t){const i=t.sourceImage,o=Number(i.width)||0,r=Number(i.height)||0;if(!o||!r)return;const l=Math.max(1,this.diameter-2*this.borderWidth),c=this.lensCanvas.nativeElement,d=Math.min(window.devicePixelRatio||1,2),h=Math.round(l*d);(c.width!==h||c.height!==h||!this.outputContext)&&(c.width=h,c.height=h,this.outputSize=h,this.outputContext=c.getContext("2d",{alpha:!1}));const p=this.outputContext;if(!p)return;const u=t.baselineZoom>0?t.baselineZoom:t.currentZoom,g=Math.max(1,t.currentZoom/Math.max(u,1e-4)),_=1+(g-1)*this.zoomDeltaMultiplier,v=Math.max(t.imageScaleX,1e-4),C=Math.max(1,l/(v*u)/_),M=this.clamp(t.imageX-C/2,0,o-C),k=this.clamp(t.imageY-C/2,0,r-C);p.clearRect(0,0,h,h);try{p.drawImage(i,M,k,C,C,0,0,h,h)}catch{return}this.brushCenterX=(t.imageX-M)/C*l,this.brushCenterY=(t.imageY-k)/C*l,this.brushDiameter=this.clamp(t.brushDiameter*(_/g),6,l-8)}clamp(t,i,o){return o<i?i:Math.max(i,Math.min(o,t))}}return(s=a).\u0275fac=function(t){return new(t||s)(e.rXU(e.gRc))},s.\u0275cmp=e.VBU({type:s,selectors:[["mobile-mask-magnifier"]],viewQuery:function(t,i){if(1&t&&e.GBs(Ec,7),2&t){let o;e.mGM(o=e.lsd())&&(i.lensCanvas=o.first)}},inputs:{diameter:"diameter",zoomDeltaMultiplier:"zoomDeltaMultiplier"},decls:4,vars:16,consts:[["lensCanvas",""],[1,"mobile-mask-magnifier"],[1,"mobile-mask-magnifier__canvas"],[1,"mobile-mask-magnifier__brush"]],template:function(t,i){1&t&&(e.j41(0,"div",1),e.nrm(1,"canvas",2,0)(3,"span",3),e.k0s()),2&t&&(e.xc7("width",i.diameter,"px")("height",i.diameter,"px"),e.AVh("mobile-mask-magnifier--visible",i.visible)("mobile-mask-magnifier--right","right"===i.side),e.R7$(3),e.xc7("left",i.brushCenterX,"px")("top",i.brushCenterY,"px")("width",i.brushDiameter,"px")("height",i.brushDiameter,"px"))},styles:["[_nghost-%COMP%]{position:absolute;top:0;right:0;bottom:0;left:0;z-index:7;pointer-events:none}.mobile-mask-magnifier[_ngcontent-%COMP%]{position:absolute;top:8px;left:8px;overflow:hidden;box-sizing:border-box;border:2px solid #fff;border-radius:50%;background:#efeef2;box-shadow:0 8px 24px #00000026;opacity:0;visibility:hidden}.mobile-mask-magnifier--right[_ngcontent-%COMP%]{right:8px;left:auto}.mobile-mask-magnifier--visible[_ngcontent-%COMP%]{opacity:1;visibility:visible}.mobile-mask-magnifier__canvas[_ngcontent-%COMP%]{display:block;width:100%;height:100%}.mobile-mask-magnifier__brush[_ngcontent-%COMP%]{position:absolute;box-sizing:border-box;border:2px solid #fff;border-radius:50%;box-shadow:0 1px 3px #00000059;transform:translate(-50%,-50%)}"],changeDetection:0}),a})();var $t=m(28199);const jc=["contentBox"],Gc=["file"],Vc=["mainCanvas"],Rc=["originalImg"],Fc=["compareContainer"],Ac=["originalPreviewImg"],Bc=["comparePreviewContainer"],lt=s=>({"d-none":s}),Uc=s=>({"--brush-inner-size":s}),zt=s=>({"replace-tool-btn--active":s});function Dc(s,a){if(1&s&&e.nrm(0,"img",32,4),2&s){const n=e.XpG();e.Y8G("src",n.photoEditorMobService.originalImage.src,e.B4B)}}function Nc(s,a){if(1&s&&e.nrm(0,"div",33),2&s){const n=e.XpG();e.AVh("replace-brush-cursor--brush",n.selectMaskVal===n.CONST_INDEX_MANUAL_BRUSH)("replace-brush-cursor--erase",n.selectMaskVal===n.CONST_INDEX_MANUAL_ERASE),e.Y8G("ngStyle",e.eq3(5,Uc,n.brushCursorPreviewSize+"px"))}}function Xc(s,a){1&s&&(e.j41(0,"div",34),e.nrm(1,"pi",35),e.j41(2,"span"),e.EFF(3,"Pinch in/out to zoom image"),e.k0s()())}function Lc(s,a){if(1&s){const n=e.RV6();e.j41(0,"mv-slider",48),e.bIt("change",function(i){e.eBV(n);const o=e.XpG(3);return e.Njj(o.onBrushSlide(i))})("slideStart",function(){e.eBV(n);const i=e.XpG(3);return e.Njj(i.onBrushSliderMouseDown())})("slideStop",function(i){e.eBV(n);const o=e.XpG(3);return e.Njj(o.onBrushSlideStop(i))}),e.k0s()}if(2&s){const n=e.XpG(3);e.Y8G("min",5)("max",100)("step",1)("value",n.brushSliderValue)}}function Yc(s,a){if(1&s){const n=e.RV6();e.j41(0,"input",49),e.bIt("input",function(i){e.eBV(n);const o=e.XpG(3);return e.Njj(o.onBrushSlide(i))})("change",function(i){e.eBV(n);const o=e.XpG(3);return e.Njj(o.onBrushSlide(i))})("touchstart",function(){e.eBV(n);const i=e.XpG(3);return e.Njj(i.onBrushSliderMouseDown())})("touchend",function(){e.eBV(n);const i=e.XpG(3);return e.Njj(i.onBrushSliderMouseUp())}),e.k0s()}if(2&s){const n=e.XpG(3);e.Y8G("value",n.brushSliderValue)}}function $c(s,a){1&s&&(e.j41(0,"div",50)(1,"div",51)(2,"div"),e.EFF(3,"Move your finger on"),e.k0s(),e.j41(4,"div"),e.EFF(5,"canvas area to sketch your idea."),e.k0s()()())}function zc(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"div",52)(2,"div",41)(3,"button",53),e.bIt("click",function(){e.eBV(n);const i=e.XpG(3);return e.Njj(i.onMaskTypeChange(i.CONST_INDEX_MANUAL_BRUSH))}),e.j41(4,"div",51),e.nrm(5,"pi",54),e.j41(6,"span",55),e.EFF(7,"Brush"),e.k0s()()(),e.j41(8,"button",56),e.bIt("click",function(){e.eBV(n);const i=e.XpG(3);return e.Njj(i.onMaskTypeChange(i.CONST_INDEX_MANUAL_ERASE))}),e.j41(9,"div",51),e.nrm(10,"pi",57),e.j41(11,"span",55),e.EFF(12,"Erase"),e.k0s()()()()(),e.j41(13,"div",58)(14,"button",59),e.bIt("click",function(){e.eBV(n);const i=e.XpG(3);return e.Njj(i.applyImage())}),e.EFF(15,"Remove"),e.k0s()(),e.bVm()}if(2&s){const n=e.XpG(3);e.R7$(3),e.Y8G("ngClass",e.eq3(3,zt,n.selectMaskVal===n.CONST_INDEX_MANUAL_BRUSH)),e.R7$(5),e.Y8G("ngClass",e.eq3(5,zt,n.selectMaskVal===n.CONST_INDEX_MANUAL_ERASE)),e.R7$(6),e.Y8G("disabled",!n.canRemove)}}function Hc(s,a){if(1&s&&(e.qex(0),e.j41(1,"div",37)(2,"div",38)(3,"div",39)(4,"span",40),e.EFF(5,"Brush Size"),e.k0s(),e.j41(6,"div",41)(7,"div",42),e.DNE(8,Lc,1,4,"mv-slider",43)(9,Yc,1,1,"input",44),e.k0s(),e.j41(10,"div",45),e.nrm(11,"input",46),e.k0s()()(),e.DNE(12,$c,6,0,"div",47)(13,zc,16,7,"ng-container",30),e.k0s()(),e.bVm()),2&s){const n=e.XpG(2);e.R7$(8),e.Y8G("ngIf",n.isEditorScriptsReady),e.R7$(),e.Y8G("ngIf",!n.isEditorScriptsReady),e.R7$(2),e.Y8G("ngModel",n.brushSliderValue),e.R7$(),e.Y8G("ngIf",!n.showCleanupActions),e.R7$(),e.Y8G("ngIf",n.showCleanupActions)}}function Wc(s,a){if(1&s&&(e.j41(0,"div",36),e.DNE(1,Hc,14,5,"ng-container",30),e.k0s()),2&s){const n=e.XpG();e.R7$(),e.Y8G("ngIf",n.isLoaded)}}function qc(s,a){if(1&s&&(e.nrm(0,"img",60),e.nI1(1,"safe")),2&s){const n=e.XpG();e.Y8G("src",e.i5U(1,1,n.aiPhotoService.imgUrl,"url"),e.B4B)}}function Kc(s,a){if(1&s&&e.nrm(0,"img",61,5),2&s){const n=e.XpG();e.Y8G("src",n.photoEditorMobService.originalImage.src,e.B4B)}}function Zc(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",62)(1,"button",63),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.download())}),e.EFF(2,"Download"),e.k0s()()}}
1function Jc(s,a){1&s&&e.nrm(0,"pi",77)}function Qc(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"div",64),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.closeDownloadPanel())}),e.k0s(),e.j41(2,"div",65)(3,"div",66)(4,"div",67)(5,"h3",68),e.EFF(6," Download"),e.j41(7,"pi",69),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.closeDownloadPanel())}),e.k0s()()(),e.j41(8,"button",70),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.downloadHD())}),e.nrm(9,"pi",71),e.j41(10,"span",72),e.EFF(11,"Download HD"),e.k0s(),e.DNE(12,Jc,1,0,"pi",73),e.k0s(),e.j41(13,"span",74),e.EFF(14,"Resolution upto 4096 \xd7 4096 px"),e.k0s(),e.j41(15,"button",75),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.downloadStandard())}),e.nrm(16,"pi",76),e.j41(17,"span",72),e.EFF(18,"Download Standard"),e.k0s()(),e.j41(19,"span",74),e.EFF(20,"Resolution upto 720 \xd7 720 px"),e.k0s()()(),e.bVm()}if(2&s){const n=e.XpG();e.R7$(),e.AVh("mobile-sheet-overlay--open",n.downloadPanelOpen),e.R7$(),e.AVh("mobile-sheet-anim--open",n.downloadPanelOpen),e.R7$(10),e.Y8G("ngIf",n.user&&!n.user.subscribed)}}let ed=(()=>{var s;class a{constructor(t,i,o,r,l,c,d,h,p,u,g,_,v,C,M,k,j,G,U,F){var K=this;this.aiPhotoService=t,this.authService=i,this.photoEditorSahredService=o,this.location=r,this.toastService=l,this.photoEditorMobService=c,this.photoEditorService=d,this.stateService=h,this.dialogService=p,this.zoomService=u,this.gtmService=g,this.gestureService=_,this.cssGuard=v,this.aiUploadImageService=C,this.createPopupService=M,this.aiGenService=k,this.paymentService=j,this.subsService=G,this.env=U,this.ngZone=F,this.featureType=f.Fs.cleanup,this.imageUrl="",this.changeStep=new e.bkB,this.isProUser=!1,this.disabled=!1,this.isCompare=!1,this.isEdit=!1,this.showCleanupActions=!1,this.hasValidMask=!1,this.isGenerationCompleted=!1,this.downloadPanelMounted=!1,this.downloadPanelOpen=!1,this.downloadPanelCloseTimer=null,this.downloadStandardRes={w:720,h:720},this.downloadHdRes={w:T.lL,h:T.iB},this.scale=1,this.initialScale=0,this.minZoom=1,this.maxZoom=5,this.pinchStartScale=1,this.pinchStartDistance=0,this.pinchCenterCanvas=null,this.lastPinchCenter=null,this.touchInteractionState="idle",this.activeTouchCount=0,this.activeTouchPointerIds=new Set,this.suppressMaskDrawing=!1,this.touchDrawVerificationTimer=null,this.pendingTouchDraw=null,this.touchDrawVerifyMs=150,this.lastStrokePoint=null,this.rafGestureId=null,this.pendingGestureFrame=null,this.preGenerationCanvasUrl="",this.preGenerationUploadedImg="",this.sourceImageType="jpg",this.sourceImageTypePromise=null,this.savedMaskEditorState=null,this.objEraseResizedUploaedImg=null,this.firstImageLoaded=!1,this.initialLoadId=0,this.isInitialLoading=!1,this.pendingMaskReady=!1,this.pendingUploadReady=!1,this.currentMaskImageData=null,this.compareImageUrl="",this.selectMaskVal=T.l4,this.brushSliderValue=50,this.brushCursorPreviewVisible=!1,this.brushCursorPreviewSize=0,this.isEditorScriptsReady=!1,this.showPresetHint=!1,this.hasShownPresetHint=!1,this.presetHintTimeoutId=null,this.hoverCursor=null,this.canvasResizeObserver=null,this.CONST_INDEX_MANUAL_BRUSH=T.l4,this.CONST_INDEX_MANUAL_ERASE=T.lh,this.f=I.fabric.Image.filters,this.maskMouseDown=!1,this.maskDrawIndex=0,this.previewMode=!1,this.maskEventsConfigured=!1,this.wasmInitPromise=null,this.qualityType=1,this.maskPointerDownHandler=B=>this.onMaskPointerDown(B),this.maskPointerMoveHandler=B=>this.onMaskPointerMove(B),this.maskPointerUpHandler=B=>this.onMaskPointerUp(B),this.maskPointerHoverHandler=B=>this.onCanvasPointerHover(B),this.maskPointerLeaveHandler=()=>{this.hideBrushCursor(),this.hideMaskMagnifier()},this.touchStartHandler=B=>this.onTouchStart(B),this.touchMoveHandler=B=>this.onTouchMove(B),this.touchEndHandler=B=>this.onTouchEnd(B),this.user=this.authService.currentUser(),this.isProUser=this.aiPhotoService.isProUser(),this.loggedInObserver=this.authService.loggedIn.subscribe(B=>{this.user=this.authService.currentUser(),this.isProUser=this.aiPhotoService.isProUser()}),this.usrPropChangedObserver=this.authService.usrPropChanged.subscribe(B=>{this.user=this.authService.currentUser(),this.isProUser=this.aiPhotoService.isProUser()}),this.aiPhotoService.applyToSaveFn=(0,w.A)(function*(){K.resetImage(),K.photoEditorSahredService.applyToSave(K.photoEditorMobService.originalImage,K.photoEditorMobService.mainCanvas,B=>{K.aiPhotoService.imgUrl=B.uri,K.aiPhotoService.queryParams.imgUrl=B.uri},!1)}),this.backBtnSub=this.aiPhotoService.backBtnClick.subscribe(B=>{B?.isBack&&this.isGenerationCompleted&&this.restoreCanvasFromPreview()}),this.paymentSub=this.paymentService.configUpdated.subscribe(()=>
1{this.qualityType=this.getQualityTypeFromConfig()})}restoreCanvasFromPreview(){if(this.preGenerationCanvasUrl&&(this.aiPhotoService.imgUrl=this.preGenerationCanvasUrl,this.photoEditorService.downloadImgUrl=this.preGenerationCanvasUrl),this.preGenerationUploadedImg&&(this.objEraseResizedUploaedImg=this.preGenerationUploadedImg),this.aiPhotoService.aiImages=[],this.setGenerationPreview(!1),!(this.actionController?.getCutout()&&this.photoEditorMobService.inputImage&&this.photoEditorMobService.mainCanvas))return this.clearSavedMaskEditorState(),void this.loadInputImage();this.restoreSavedMaskEditorState()}saveMaskEditorStateBeforeApply(){const t=this.photoEditorMobService.mainCanvas;this.preGenerationCanvasUrl=this.aiPhotoService.imgUrl||this.preGenerationCanvasUrl,this.preGenerationUploadedImg=this.objEraseResizedUploaedImg||this.preGenerationUploadedImg,this.savedMaskEditorState={hasValidMask:this.hasValidMask,showCleanupActions:this.showCleanupActions,isEdit:this.isEdit,selectMaskVal:this.selectMaskVal,brushSliderValue:this.brushSliderValue,viewport:t?.viewportTransform?[...t.viewportTransform]:null,zoom:t?.getZoom?.()??this.scale}}restoreSavedMaskEditorState(){const t=this.savedMaskEditorState,i=this.photoEditorMobService.mainCanvas,o=this.photoEditorMobService.inputImage;t&&(this.selectMaskVal=t.selectMaskVal,this.brushSliderValue=t.brushSliderValue,t.viewport&&i&&(i.setViewportTransform([...t.viewport]),this.scale=t.zoom)),(!this.baseFilter||!o.filters?.length||o.filters[0]!==this.baseFilter)&&this.addMaskFilter(!0),this.processResult(),this.hasValidMask=this.hasValidMask||!!t?.hasValidMask,this.showCleanupActions=this.hasValidMask||!!t?.showCleanupActions,this.isEdit=this.showCleanupActions||!!t?.isEdit,this.actionController?.getCutout()&&(this.setMask(this.selectMaskVal),this.setBrushSize(this.brushSliderValue,this.selectMaskVal),this.actionController.getCutout()&&(this.actionController.getCutout().selectedOption=this.selectMaskVal,this.applyCutoutBrushSize(this.brushSliderValue))),this.updateBrushCursorSize(),this.updateOriginalImageTransform(),i?.requestRenderAll(),this.clearSavedMaskEditorState()}clearSavedMaskEditorState(){this.savedMaskEditorState=null}setGenerationPreview(t){this.isGenerationCompleted=t,this.aiPhotoService.backBtnClick.next(t?{backBtnEnabled:!0}:{isBack:!0})}ngOnInit(){this.qualityType=this.getQualityTypeFromConfig(),this.isEditorScriptsReady=typeof window.Slider<"u",this.editorScriptsSub=this.cssGuard.editorScriptsLoaded$.subscribe(t=>{t&&(this.isEditorScriptsReady=!0)}),this.toolName=this.aiPhotoService?.queryParams?.tab,this.isLoaded=!0,this.resolveWasmModule().catch(()=>{}),this.preGenerationCanvasUrl=this.aiPhotoService.imgUrl||"",this.sourceImageTypePromise=this.resolveSourceImageType(this.aiPhotoService.imgUrl).then(t=>(this.sourceImageType=t,t)),this.loadInputImage()}get canRemove(){return this.hasValidMask}beginInitialLoading(){const t=++this.initialLoadId;return this.isInitialLoading=!0,this.pendingMaskReady=!1,this.pendingUploadReady=!1,this.setInProgress(!0),t}markInitialMaskReady(t){t===this.initialLoadId&&(this.pendingMaskReady=!0,this.tryCompleteInitialLoading())}markInitialUploadReady(t){t===this.initialLoadId&&(this.pendingUploadReady=!0,this.tryCompleteInitialLoading())}tryCompleteInitialLoading(){!this.isInitialLoading||!this.pendingMaskReady||!this.pendingUploadReady||(this.isInitialLoading=!1,requestAnimationFrame(()=>{this.isInitialLoading||this.setInProgress(!1)}))}failInitialLoading(t){t===this.initialLoadId&&(this.isInitialLoading=!1,this.setInProgress(!1))}setInProgress(t){this.ngZone.run(()=>{t?this.aiPhotoService.startProcessingProgress({featureType:this.featureType,indeterminate:!0}):this.aiPhotoService.completeGenerationProgress()})}loadInputImage(){this.showCleanupActions=!1,this.hasValidMask=!1,this.hidePresetPanZoomHint(),this.hasShownPresetHint=!1;const t=this.beginInitialLoading();console.log("loadInputImage",this.aiPhotoService.imgUrl),this.photoEditorMobService.loadInputImage(this.aiPhotoService.imgUrl,this.mainCanvas.nativeElement,()=>{if(t!==this.initialLoadId)return;this.inputImage=this.photoEditorMobService.inputImage;const i=document.getElementById("canvasWrapper");this.zoomService.setCanvas(this.photoEditorMobService.mainCanvas,i),this.photoEditorMobService.mainCanvas&&this.photoEditorMobService.mainCanvas.viewportTransform&&(this.initialViewport=[...this.photoEditorMobService.mainCanvas.viewportTransform]),this.setScaleVar(),this.setZoomPinch(),this.initMaskDrawing(t),this.observeCanvasResize(),this.uploadCleanupImage(t)},()=>{this.failInitialLoading(t),this.toastService.showError(y.b.message.somethingWrong),this.location.back()},T.ms,T.HI,!1,!0,!0)}changeBruceSize(t){this.photoEditorService.brushSizeDisable=t}get showBrushCursorPreview(){return this.brushCursorPreviewVisible&&this.brushCursorPreviewSize>0&&!this.isCompare&&(this.selectMaskVal===T.l4||this.selectMaskVal===T.lh)}onMaskTypeChange(t){this.changeTools({name:"mask",value:t,selectedOption:t}),(t===T.l4||t===T.lh)&&this.changeTools({name:"size",value:this.brushSliderValue||50,selectedOption:t})}onBrushSlide(t){const i=this.parseBrushSize(t);this.brushSliderValue=i,this.brushCursorPreviewVisible=!0,this.brushCursorPreviewSize=this.calculateBrushCursorPreviewSize(i),this.hideBrushCursor(),this.setBrushSize(i,this.selectMaskVal),this.actionController?.getCutout()&&(this.actionController.getCutout().selectedOption=this.selectMaskVal,this.applyCutoutBrushSize(i))}onBrushSlideStop(t){this.onBrushSlide(t),this.onBrushSliderMouseUp()}parseBrushSize(t){let i;return i=t&&Object.prototype.hasOwnProperty.call(t,"newValue")?t.newValue:Number(void 0!==t?.target?.value?t.target.value:t),Number.isNaN(i)?this.brushSliderValue:Math.min(100,Math.max(5,i))}onBrushSliderMouseDown(){this.changeBruceSize({value:!0,selectedErase:this.selectMaskVal===T.lh}),this.brushCursorPreviewVisible=!0,this.brushCursorPreviewSize=this.calculateBrushCursorPreviewSize(this.brushSliderValue),this.hideBrushCursor()}onBrushSliderMouseUp(){this.changeBruceSize({value:!1,selectedErase:this.selectMaskVal===T.lh}),this.brushCursorPreviewVisible=!1}changeTools(t){if("mask"===t.name)this.selectMaskVal=t.value,this.isEdit=!0,this.setMask(t.value),this.removeBrushCursor(),this.setBrushSize(this.brushSliderValue,t.selectedOption??this.selectMaskVal),(t.value===T.l4||t.value===T.lh)&&this.updateBrushCursorSize();else if("size"===t.name){this.brushSliderValue=t.value;const i=t.selectedOption??this.selectMaskVal;this.actionController?.getCutout()&&(this.actionController.getCutout().selectedOption=i,this.applyCutoutBrushSize(t.value)),this.setBrushSize(t.value,i)}}initBrushTools(){this.photoEditorService.originalImage=this.photoEditorMobService.originalImage,this.changeTools({name:"size",value:this.brushSliderValue,selectedOption:T.l4}),this.changeTools({name:"mask",value:T.l4,selectedOption:T.l4})}setBrushSize(t,i){if(t<=0)return;const o=t>5?t:5,r=this.photoEditorMobService.originalImage;if(!r)return;const c=.05*Math.max(r.width,r.height)/2,d=this.getNativeBrushSize(o);let h=Math.floor(d/5*c/4);h*=this.getZoomBrushCompensationRatio(),h=Math.max(1,h),h/=2,this.photoEditorService.slidersize=h,this.brushCursorPreviewVisible?this.brushCursorPreviewSize=this.calculateBrushCursorPreviewSize(
1o):this.updateBrushCursorSize(o)}getNativeBrushSize(t){const i=Math.min(100,Math.max(5,t||5)),o=this.photoEditorMobService.originalImage,r=this.photoEditorMobService.mainCanvas;if(!o||!r)return i;const l=r.getZoom()||this.scale||1;if(l<=0)return i;const c=Number(this.initialViewport?.[0])||this.initialScale||l,d=Math.min(l,c),u=.05*Math.max(o.width,o.height)/2;if(u<=0)return i;let g=Math.floor(i/5*u/4);g=g<5?5:g;const _=2*g*d,v=typeof window<"u"&&window.devicePixelRatio?window.devicePixelRatio:1,C=Math.max(8,3*Math.min(v,3));if(_>=C)return i;const k=Math.ceil(C/(2*d)*20/u);return Math.min(100,Math.max(i,k))}applyCutoutBrushSize(t=this.brushSliderValue){const i=this.actionController?.getCutout();if(!i)return;const o=this.getNativeBrushSize(t),r=Math.max(1,o*this.getZoomBrushCompensationRatio());i.setBrushSize(r)}calculateBrushCursorPreviewSize(t){const i=this.photoEditorMobService.mainCanvas,o=this.photoEditorMobService.originalImage;if(!i||!o)return this.mapBrushSliderToCursorPx(t);const r=i.getObjects("image")[0];if(!r)return this.mapBrushSliderToCursorPx(t);const l=i.getZoom()||this.scale||1,c=Number(this.initialViewport?.[0])||this.initialScale||l,h=.05*Math.max(o.width,o.height)/2,p=this.getNativeBrushSize(t);let u=Math.floor(p/5*h/4);return u=Math.max(u,5)/2,Math.max(1,Math.round(2*u*(r.scaleX*c)))}mapBrushSliderToCursorPx(t){const c=Math.min(100,Math.max(5,t));return Math.round(41+(c-5)/95*99)}calculateBrushRadius(t){const i=this.getNativeBrushSize(t>5?t:5),o=this.photoEditorMobService.originalImage;if(!o)return 0;const l=.05*Math.max(o.width,o.height)/2;let c=Math.floor(i/5*l/4);return c*=this.getZoomBrushCompensationRatio(),c=c<1?1:c,c/2}getZoomBrushCompensationRatio(){const t=this.photoEditorMobService.mainCanvas;if(!t)return 1;const i=t.getZoom()||this.scale||1;if(i<=0)return 1;const o=Number(this.initialViewport?.[0])||this.initialScale||i;return o<=0?1:o/i}getCanvasZoom(){return this.photoEditorMobService.mainCanvas?.getZoom()||this.scale||1}shouldShowBrushCursor(){return!(this.brushCursorPreviewVisible||this.isCompare||this.maskMouseDown||"verifying"===this.touchInteractionState||this.aiPhotoService.inProgress||this.selectMaskVal!==T.l4&&this.selectMaskVal!==T.lh)}updateBrushCursorSize(t){const o=this.calculateBrushRadius(t??this.brushSliderValue);if(!this.shouldShowBrushCursor()||o<=0)return void this.removeBrushCursor();if(!this.hoverCursor)return void this.addBrushCursor(o);const l=2/this.getCanvasZoom(),c=Math.max(o-l,0),d=this.hoverCursor.getObjects();for(const h of d)"circle"===h.type&&"white"===h.stroke&&h.set({radius:o,strokeWidth:l}),"circle"===h.type&&"black"===h.stroke&&h.set({radius:c,strokeWidth:l}),"text"===h.type&&h.set({fontSize:o});this.hoverCursor.radius=o,this.hoverCursor.addWithUpdate(),this.hoverCursor.bringToFront(),this.photoEditorMobService.mainCanvas?.requestRenderAll()}addBrushCursor(t){if(this.hoverCursor||t<=0)return;const i=this.photoEditorMobService.mainCanvas;if(!i)return;const r=2/this.getCanvasZoom(),l=Math.max(t-r,0),c=this.selectMaskVal===T.lh?"-":"+",d=new I.fabric.Circle({radius:t,fill:"transparent",stroke:"white",strokeWidth:r,originX:"center",originY:"center"}),h=new I.fabric.Circle({radius:l,fill:"transparent",stroke:"black",strokeWidth:r,originX:"center",originY:"center"}),p=new I.fabric.Text(c,{fontFamily:"sans-serif",fontSize:t,stroke:"white",textAlign:"center",originX:"center",originY:"center",left:0,top:0});this.hoverCursor=new I.fabric.Group([d,h,p],{left:-100,top:-100,originX:"center",originY:"center",selectable:!1,evented:!1}),this.hoverCursor.radius=t,i.add(this.hoverCursor);const u=i;u.hoverCursor="none",u.defaultCursor="none",this.hoverCursor.bringToFront(),i.requestRenderAll()}removeBrushCursor(){const t=this.photoEditorMobService.mainCanvas;if(this.hoverCursor&&t){t.remove(this.hoverCursor),this.hoverCursor=null;const i=t;i.hoverCursor="default",i.defaultCursor="default",t.requestRenderAll()}}hideBrushCursor(){this.hoverCursor&&(this.hoverCursor.set({left:-100,top:-100}).setCoords(),this.photoEditorMobService.mainCanvas?.requestRenderAll())}
1positionBrushCursor(t,i){this.hoverCursor&&(this.hoverCursor.set({left:t,top:i}).setCoords(),this.hoverCursor.bringToFront(),this.photoEditorMobService.mainCanvas?.requestRenderAll())}updateMaskMagnifier(t,i,o=!1){const r=this.photoEditorMobService.mainCanvas,l=this.photoEditorMobService.originalImage,c=this.photoEditorMobService.theOriginalOriginalImage||l;if(!(r&&l&&c&&this.maskMagnifier))return;const d=r.getObjects("image")[0];if(!d?.scaleX)return;const h=r.getElement().getBoundingClientRect(),p=this.screenToCanvasCoordinates(t,i),u=r.getZoom()||this.scale||1,g=Number(this.initialViewport?.[0])||this.initialScale||u,_=c.width/Math.max(1,l.width),v=c.height/Math.max(1,l.height),C={sourceImage:c,imageX:p.x*_,imageY:p.y*v,clientX:t,clientY:i,viewportLeft:h.left,viewportTop:h.top,viewportWidth:h.width,viewportHeight:h.height,currentZoom:u,baselineZoom:g,imageScaleX:d.scaleX/_,brushDiameter:this.calculateBrushCursorPreviewSize(this.brushSliderValue)};o||!this.maskMagnifier.visible?this.maskMagnifier.show(C):this.maskMagnifier.update(C)}hideMaskMagnifier(){this.maskMagnifier?.hide()}screenToCanvasCoordinates(t,i){const o=this.photoEditorMobService.mainCanvas;if(!o)return{x:0,y:0};const r=o.getElement().getBoundingClientRect(),l=new I.fabric.Point(t-r.left,i-r.top),d=I.fabric.util.invertTransform(o.viewportTransform||[1,0,0,1,0,0]),h=I.fabric.util.transformPoint(l,d),p=this.photoEditorMobService.originalImage;return p?{x:Math.max(0,Math.min(p.width,h.x)),y:Math.max(0,Math.min(p.height,h.y))}:{x:h.x,y:h.y}}getCanvasPointerFromEvent(t){return this.screenToCanvasCoordinates(t.clientX,t.clientY)}calculatePinchDistance(t,i){const o=t.clientX-i.clientX,r=t.clientY-i.clientY;return Math.sqrt(o*o+r*r)}calculatePinchCenter(t,i){return{x:(t.clientX+i.clientX)/2,y:(t.clientY+i.clientY)/2}}clampPan(){const t=this.photoEditorMobService.mainCanvas;if(!t)return;const i=t.getZoom(),o=t.getWidth(),r=t.getHeight(),l=t.viewportTransform,c=t.getObjects("image")[0];if(!c)return;const d=c.width*c.scaleX*i,h=c.height*c.scaleY*i;let p=l[4],u=l[5];p=d<=o?(o-d)/2:Math.min(0,Math.max(o-d,p)),u=h<=r?(r-h)/2:Math.min(0,Math.max(r-h,u)),l[4]=p,l[5]=u,t.setViewportTransform(l)}applyZoom(t){const i=this.photoEditorMobService.mainCanvas;if(!i||!this.pinchCenterCanvas)return;const o=Math.max(this.minZoom*this.initialScale,Math.min(t,this.maxZoom*this.initialScale));i.zoomToPoint(this.pinchCenterCanvas,o),this.clampPan(),this.scale=i.getZoom(),this.updateBrushCursorSize(),this.brushCursorPreviewVisible&&(this.brushCursorPreviewSize=this.calculateBrushCursorPreviewSize(this.brushSliderValue))}applyPan(t,i){const o=this.photoEditorMobService.mainCanvas;o&&(o.relativePan(new I.fabric.Point(t,i)),this.clampPan(),this.updateBrushCursorSize())}isTouchPointerEvent(t){return!t||"touch"===t.pointerType}canAcceptDrawingInput(t){return!this.isTouchPointerEvent(t)||!(this.suppressMaskDrawing||"pinching"===this.touchInteractionState||this.activeTouchCount>=2||this.activeTouchPointerIds.size>=2)}cancelActiveDrawing(){this.cancelPendingTouchDraw(),this.lastStrokePoint=null,this.hideMaskMagnifier(),this.maskMouseDown&&this.onMaskMouseUp()}clearPendingTouchDrawTimer(){this.touchDrawVerificationTimer&&(clearTimeout(this.touchDrawVerificationTimer),this.touchDrawVerificationTimer=null)}cancelPendingTouchDraw(){this.clearPendingTouchDrawTimer(),this.pendingTouchDraw=null,"verifying"===this.touchInteractionState&&(this.touchInteractionState="idle",this.hideMaskMagnifier())}beginMaskDrawingAt(t){this.maskMouseDown=!0,this.maskDrawIndex=0,this.hideBrushCursor(),this.isEdit=!0,this.photoEditorMobService.isDirty=!0,this.lastStrokePoint=null,this.addInterpolatedMaskPoint(t.x,t.y),this.processResult()}getStrokeStepDistance(){const t=this.photoEditorMobService.originalImage,i=this.getNativeBrushSize(Math.max(5,this.brushSliderValue||5));if(!t)return Math.max(1,.1*i);const l=.05*Math.max(t.width,t.height)/2;let c=Math.floor(i/5*l/4);return c*=this.getZoomBrushCompensationRatio(),c=c<1?1:c,Math.max(1,.5*c)}addInterpolatedMaskPoint(t,i){if(!this.actionController)return;if(!this.lastStrokePoint)return this.actionController.addPoint(t,i),void(this.lastStrokePoint={x:t,y:i});const o=t-this.lastStrokePoint.x,r=i-this.lastStrokePoint.y,l=Math.hypot(o,r);if(l<.01)return;const c=this.getStrokeStepDistance();if(l<=c)return this.actionController.addPoint(t,i),void(this.lastStrokePoint={x:t,y:i});const d=Math.ceil(l/c);for(let h=1;h<=d;
1h++){const p=h/d;this.actionController.addPoint(this.lastStrokePoint.x+o*p,this.lastStrokePoint.y+r*p)}this.lastStrokePoint={x:t,y:i}}scheduleTouchDrawVerification(t){this.cancelPendingTouchDraw(),this.touchInteractionState="verifying",this.pendingTouchDraw={pointerId:t.pointerId,clientX:t.clientX,clientY:t.clientY},this.updateMaskMagnifier(t.clientX,t.clientY,!0);try{t.target?.setPointerCapture?.(t.pointerId)}catch{}this.touchDrawVerificationTimer=setTimeout(()=>{this.touchDrawVerificationTimer=null,this.commitPendingTouchDraw()},this.touchDrawVerifyMs)}commitPendingTouchDraw(){if(!this.pendingTouchDraw||"verifying"!==this.touchInteractionState)return;if(this.suppressMaskDrawing||this.activeTouchCount>=2||this.activeTouchPointerIds.size>=2||!this.canDrawMask())return void this.cancelPendingTouchDraw();const t=this.pendingTouchDraw;this.pendingTouchDraw=null,this.touchInteractionState="drawing";const i=this.screenToCanvasCoordinates(t.clientX,t.clientY);this.beginMaskDrawingAt(i),this.showCleanupActions=!0,this.updateMaskMagnifier(t.clientX,t.clientY)}blockMaskDrawingForMultiTouch(){this.touchInteractionState="pinching",this.suppressMaskDrawing=!0,this.cancelActiveDrawing(),this.hideBrushCursor()}trackTouchPointerDown(t){return"touch"!==t.pointerType||(this.activeTouchPointerIds.add(t.pointerId),!(this.activeTouchPointerIds.size>=2&&(this.blockMaskDrawingForMultiTouch(),1)))}trackTouchPointerUp(t){if("touch"===t.pointerType){if(this.activeTouchPointerIds.delete(t.pointerId),0===this.activeTouchPointerIds.size)return void this.resetTouchInteraction();(this.suppressMaskDrawing||"pinching"===this.touchInteractionState)&&this.cancelActiveDrawing()}}releasePointerCaptureSafe(t){try{t.target?.releasePointerCapture?.(t.pointerId)}catch{}}enterPinchMode(t){if(t.touches.length<2)return;const[i,o]=[t.touches[0],t.touches[1]];this.blockMaskDrawingForMultiTouch(),this.pinchStartScale=this.photoEditorMobService.mainCanvas?.getZoom()||this.scale||this.initialScale,this.pinchStartDistance=this.calculatePinchDistance(i,o);const r=this.calculatePinchCenter(i,o);this.pinchCenterCanvas=new I.fabric.Point(r.x,r.y),this.lastPinchCenter=r}resetTouchInteraction(){this.cancelPendingTouchDraw(),this.hideMaskMagnifier(),this.touchInteractionState="idle",this.activeTouchCount=0,this.activeTouchPointerIds.clear(),this.suppressMaskDrawing=!1,this.pinchStartDistance=0,this.pinchCenterCanvas=null,this.lastPinchCenter=null,this.applyCutoutBrushSize(),this.updateBrushCursorSize()}onTouchStart(t){if(this.activeTouchCount=t.touches.length,t.touches.length>=2)return this.enterPinchMode(t),void t.preventDefault();1===t.touches.length&&"pinching"===this.touchInteractionState&&t.preventDefault()}onTouchMove(t){if(this.activeTouchCount=t.touches.length,t.touches.length>=2){"pinching"!==this.touchInteractionState&&this.enterPinchMode(t);const[i,o]=[t.touches[0],t.touches[1]],r=this.calculatePinchDistance(i,o);this.pinchStartDistance||(this.pinchStartDistance=r);const l=this.calculatePinchCenter(i,o),c=r/this.pinchStartDistance;let d=0,h=0;return this.lastPinchCenter&&(d=l.x-this.lastPinchCenter.x,h=l.y-this.lastPinchCenter.y),this.pinchCenterCanvas=new I.fabric.Point(l.x,l.y),this.lastPinchCenter=l,this.pendingGestureFrame={type:"zoomPan",scale:this.pinchStartScale*c,dx:d,dy:h},this.scheduleGestureFrame(),void t.preventDefault()}"pinching"===this.touchInteractionState&&t.preventDefault()}onTouchEnd(t){if(this.activeTouchCount=t.touches.length,!(t.touches.length>=2))return 1===t.touches.length?(this.blockMaskDrawingForMultiTouch(),this.pinchStartDistance=0,this.pinchCenterCanvas=null,this.lastPinchCenter=null,void t.preventDefault()):(this.activeTouchPointerIds.clear(),void this.resetTouchInteraction());t.preventDefault()}scheduleGestureFrame(){null===this.rafGestureId&&(this.rafGestureId=requestAnimationFrame(()=>{const t=this.pendingGestureFrame;this.pendingGestureFrame=null,this.rafGestureId=null,t&&("zoom"===t.type&&"number"==typeof t.scale?this.applyZoom(t.scale):"pan"===t.type&&"number"==typeof t.dx&&"number"==typeof t.dy?this.applyPan(t.dx,t.dy):"zoomPan"===t.type&&"number"==typeof t.scale&&(this.applyZoom(t.scale),(t.dx||t.dy)&&this.applyPan(t.dx,t.dy))
1)}))}onCanvasPointerHover(t){if(!this.canAcceptDrawingInput(t))return void this.hideBrushCursor();if(!this.shouldShowBrushCursor())return void this.hideBrushCursor();if(this.hoverCursor||this.updateBrushCursorSize(),!this.hoverCursor)return;const i=this.getCanvasPointerFromEvent(t);this.positionBrushCursor(i.x,i.y)}observeCanvasResize(){this.disconnectCanvasResizeObserver();const t=document.getElementById("canvas-mask-wrapper");!t||typeof ResizeObserver>"u"||(this.canvasResizeObserver=new ResizeObserver(()=>{this.updateBrushCursorSize()}),this.canvasResizeObserver.observe(t))}disconnectCanvasResizeObserver(){this.canvasResizeObserver&&(this.canvasResizeObserver.disconnect(),this.canvasResizeObserver=null)}initMaskDrawing(t){const i=this.photoEditorMobService.originalImage;i?this.resolveWasmModule().then(o=>{if(null!=t&&t!==this.initialLoadId)return;if(!this.photoEditorMobService.inputImage||!this.photoEditorMobService.mainCanvas)return void(null!=t&&this.failInitialLoading(t));this.resolvedModule=o,this.actionController=new Lt.ZX;const r=this.getImageDataFromImg(i);if(this.actionController.createCutout(o,r,r.width,r.height),!this.actionController.getCutout())throw new Error("Cutout not created");this.ensureWebGLFilterBackend(i),this.addMaskFilter(!0),this.processResult(!0),this.photoEditorMobService.mainCanvas.renderAll(),this.photoEditorMobService.enableAutoFit(),this.configureMaskCanvasEvents(),this.initBrushTools(),null!=t?this.markInitialMaskReady(t):this.isInitialLoading||this.setInProgress(!1),this.showPresetPanZoomHint()}).catch(()=>{this.photoEditorMobService.enableAutoFit(),null!=t?this.failInitialLoading(t):this.setInProgress(!1),this.toastService.showError("Failed to initialize mask tools")}):null!=t&&this.failInitialLoading(t)}ensureWebGLFilterBackend(t){const i=I.fabric,o=Math.max(t.width,t.height);o>I.fabric.textureSize&&(I.fabric.textureSize=o),i.filterBackend||(i.filterBackend=i.initFilterBackend?.())}resolveWasmModule(){return this.photoEditorService.resolvedModule?Promise.resolve(this.photoEditorService.resolvedModule):(this.wasmInitPromise||(this.wasmInitPromise=this.loadWasmModule()),this.wasmInitPromise)}loadWasmModule(){return(0,Yt.f7)("lightxOpenCVModule",`${ke.c.wasmAssetsPath}/cvlightx.js`,()=>{}).then(()=>window.lightxOpenCVModule({locateFile:o=>`${ke.c.wasmAssetsPath}/${o}?ver=${ke.c.lightXWasmVersion}`})).then(i=>new Promise((o,r)=>{const l=i.addFunction(c=>{1===c?(this.photoEditorService.resolvedModule=i,o(i)):r(new Error("WASM init failed"))},"vi");i.cwrap("initWasm",null,["number"])(l)}))}getImageDataFromImg(t){const i=document.createElement("canvas");i.width=t.width,i.height=t.height;const o=i.getContext("2d");return o.drawImage(t,0,0,t.width,t.height),o.getImageData(0,0,t.width,t.height)}
1addMaskFilter(t=!1){const i=new Xe.Y;this.baseFilter=new this.f.CutoutFilter({image:null,adjustment:i.adjustedValues});const o=this.photoEditorMobService.inputImage;o.set({objectCaching:!1,noScaleCache:!0,evented:!0}),o.filters=[this.baseFilter],o.applyFilters(),t||this.photoEditorMobService.mainCanvas.requestRenderAll()}configureMaskCanvasEvents(){const i=this.mainCanvas.nativeElement;!this.photoEditorMobService.mainCanvas||this.maskEventsConfigured||(i.addEventListener("pointerdown",this.maskPointerDownHandler,{passive:!1}),i.addEventListener("pointermove",this.maskPointerMoveHandler,{passive:!1}),i.addEventListener("pointerup",this.maskPointerUpHandler,{passive:!1}),i.addEventListener("pointercancel",this.maskPointerUpHandler,{passive:!1}),i.addEventListener("pointerleave",this.maskPointerLeaveHandler,{passive:!0}),i.addEventListener("touchstart",this.touchStartHandler,{passive:!1}),i.addEventListener("touchmove",this.touchMoveHandler,{passive:!1}),i.addEventListener("touchend",this.touchEndHandler,{passive:!1}),i.addEventListener("touchcancel",this.touchEndHandler,{passive:!1}),this.maskEventsConfigured=!0)}unconfigureMaskCanvasEvents(){const t=this.photoEditorMobService.mainCanvas,i=this.mainCanvas?.nativeElement;!t||!this.maskEventsConfigured||(i&&(i.removeEventListener("pointerdown",this.maskPointerDownHandler),i.removeEventListener("pointermove",this.maskPointerMoveHandler),i.removeEventListener("pointerup",this.maskPointerUpHandler),i.removeEventListener("pointercancel",this.maskPointerUpHandler),i.removeEventListener("pointerleave",this.maskPointerLeaveHandler),i.removeEventListener("touchstart",this.touchStartHandler),i.removeEventListener("touchmove",this.touchMoveHandler),i.removeEventListener("touchend",this.touchEndHandler),i.removeEventListener("touchcancel",this.touchEndHandler)),this.removeBrushCursor(),this.maskEventsConfigured=!1)}setMask(t){this.selectMaskVal=t,this.actionController?.getCutout()&&this.actionController.getCutout().setSelectedOption(t)}isPathMode(){return this.actionController?.getCutout()?.isPathMode()??!1}shouldRenderOnMove(){return this.maskDrawIndex%2==0&&!this.isPathMode()}canDrawMask(){return!(this.isCompare||this.aiPhotoService.inProgress||this.photoEditorService.brushSizeDisable?.value||!this.actionController?.getCutout())}onMaskPointerDown(t){if(this.trackTouchPointerDown(t)&&this.canAcceptDrawingInput(t)&&this.canDrawMask()){if(t.preventDefault(),"touch"===t.pointerType)return void this.scheduleTouchDrawVerification(t);this.touchInteractionState="drawing",this.beginMaskDrawingAt(this.getCanvasPointerFromEvent(t)),"pen"===t.pointerType&&this.updateMaskMagnifier(t.clientX,t.clientY,!0);try{t.target?.setPointerCapture?.(t.pointerId)}catch{}}}onMaskPointerMove(t){if("verifying"===this.touchInteractionState&&"touch"===t.pointerType)return this.pendingTouchDraw?.pointerId===t.pointerId&&(this.pendingTouchDraw.clientX=t.clientX,this.pendingTouchDraw.clientY=t.clientY,this.updateMaskMagnifier(t.clientX,t.clientY)),void(this.canAcceptDrawingInput(t)||(this.cancelPendingTouchDraw(),this.blockMaskDrawingForMultiTouch()));if(!this.canAcceptDrawingInput(t))return this.hideBrushCursor(),void(this.maskMouseDown&&"touch"===t.pointerType&&this.cancelActiveDrawing());if(this.onCanvasPointerHover(t),!this.maskMouseDown||!this.canDrawMask())return;t.preventDefault(),this.showCleanupActions=!0;const i=this.getCanvasPointerFromEvent(t);this.addInterpolatedMaskPoint(i.x,i.y),this.processResultOnMove(),("touch"===t.pointerType||"pen"===t.pointerType)&&this.updateMaskMagnifier(t.clientX,t.clientY)}onMaskPointerUp(t){if(this.hideMaskMagnifier(),"verifying"===this.touchInteractionState&&"touch"===t.pointerType&&this.pendingTouchDraw?.pointerId===t.pointerId)return this.cancelPendingTouchDraw(),this.trackTouchPointerUp(t),void this.releasePointerCaptureSafe(t);this.maskMouseDown&&("touch"===t.pointerType&&(this.suppressMaskDrawing||this.activeTouchCount>=2||this.activeTouchPointerIds.size>=2)?this.cancelActiveDrawing():(t.preventDefault(),this.onMaskMouseUp(),"touch"===t.pointerType&&0===this.activeTouchCount&&this.activeTouchPointerIds.size<=1&&(this.touchInteractionState="idle"))),this.trackTouchPointerUp(t),this.releasePointerCaptureSafe(t)}onMaskMouseUp(){this.maskMouseDown&&(this.maskMouseDown=!1,this.lastStrokePoint=null,this.actionController.onMouseUp(),this.processResult())}drawOutputImage(t,i=!1){if(!this.baseFilter||!this.photoEditorMobService.inputImage)return;this.baseFilter.image=t,this.baseFilter.previewMode=this.previewMode?1:0,this.baseFilter.invertMask=0,this.photoEditorService.maskForDownload=t;const o=this.photoEditorMobService.inputImage;o.dirty=!0,o.applyFilters(),i||this.photoEditorMobService.mainCanvas.requestRenderAll(),this.hoverCurs
1or?.bringToFront(),this.updateHasValidMask(t)}processResult(t=!1){const i=this.actionController?.getCutout()?.getSmoothMaskMat();i?.image?this.drawOutputImage(i.image,t):this.hasValidMask=!1}processResultOnMove(){if(this.shouldRenderOnMove()){const t=this.actionController.getCutout().getMaskMat();t?.image&&this.drawOutputImage(t.image)}else if(this.selectMaskVal===T.lh){const t=this.actionController.getCutout().getMaskMat();t?.image&&this.updateHasValidMask(t.image)}this.maskDrawIndex++}updateHasValidMask(t){this.hasValidMask=this.hasMaskContent(t)}hasMaskContent(t){if(!t?.data?.length)return!1;const i=t.data;for(let o=0;o<i.length;o+=4)if(i[o]>0)return!0;return!1}resetMaskDrawing(){this.hideMaskMagnifier(),this.unconfigureMaskCanvasEvents(),this.disconnectCanvasResizeObserver(),this.actionController&&(this.actionController.reset(),this.actionController.delete(),this.actionController=null),this.baseFilter=null,this.maskMouseDown=!1,this.hasValidMask=!1}getQualityTypeFromConfig(){return this.paymentService?.config?.creditInfo?.[this.featureType]||1}onUserPointerAction(){this.hidePresetPanZoomHint()}onUserKeyAction(){this.hidePresetPanZoomHint()}onUserWheelAction(){this.hidePresetPanZoomHint()}showPresetPanZoomHint(){this.hasShownPresetHint||this.isGenerationCompleted||(this.hasShownPresetHint=!0,this.showPresetHint=!0,this.clearPresetHintTimer(),this.presetHintTimeoutId=setTimeout(()=>{this.showPresetHint=!1,this.presetHintTimeoutId=null},5e3))}hidePresetPanZoomHint(){this.showPresetHint&&(this.showPresetHint=!1,this.clearPresetHintTimer())}clearPresetHintTimer(){this.presetHintTimeoutId&&(clearTimeout(this.presetHintTimeoutId),this.presetHintTimeoutId=null)}ngOnDestroy(){this.hideMaskMagnifier(),this.clearTimeInterval(),this.clearPresetHintTimer(),this.clearPendingTouchDrawTimer(),this.progress&&(this.progress.close(),this.progress=null),this.aiPhotoService.clearGenerationProgress(),this.loggedInObserver&&this.loggedInObserver.unsubscribe(),this.usrPropChangedObserver&&this.usrPropChangedObserver.unsubscribe(),this.editorScriptsSub&&this.editorScriptsSub.unsubscribe(),this.backBtnSub&&this.backBtnSub.unsubscribe(),this.paymentSub&&this.paymentSub.unsubscribe(),this.downloadPanelCloseTimer&&(clearTimeout(this.downloadPanelCloseTimer),this.downloadPanelCloseTimer=null),null!==this.rafGestureId&&(cancelAnimationFrame(this.rafGestureId),this.rafGestureId=null),this.disconnectCanvasResizeObserver(),this.removeBrushCursor(),this.resetMaskDrawing(),this.clearSavedMaskEditorState(),this.resetImage();try{this.photoEditorMobService.destroy()}catch{}}touchstart(){this.isCompare=!0,this.hideBrushCursor(),this.hideMaskMagnifier()}touchend(){this.isCompare=!1}onPointerDown(){clearTimeout(this.compareTimeout),this.compareTimeout=setTimeout(()=>{this.isCompare=!0,this.hideBrushCursor(),this.isGenerationCompleted||this.updateOriginalImageTransform()},50)}onPointerUp(){clearTimeout(this.compareTimeout),this.isCompare=!1}openDownloadPanel(){this.downloadPanelCloseTimer&&(clearTimeout(this.downloadPanelCloseTimer),this.downloadPanelCloseTimer=null),this.downloadPanelMounted=!0,this.downloadPanelOpen=!1,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.downloadPanelOpen=!0})})}closeDownloadPanel(){this.downloadPanelOpen=!1,this.downloadPanelCloseTimer&&clearTimeout(this.downloadPanelCloseTimer),this.downloadPanelCloseTimer=setTimeout(()=>{this.downloadPanelMounted=!1,this.downloadPanelCloseTimer=null},760)}downloadStandard(){this.closeDownloadPanel(),this.downloadWithResolution(this.downloadStandardRes)}downloadHD(){if(this.isProUser=this.aiPhotoService.isProUser(),this.user&&(!this.user||this.user.subscribed))return this.user?.subscribed?(this.closeDownloadPanel(),void this.downloadWithResolution(this.downloadHdRes)):void 0;this.subsService.loginWithUpgrade(()=>{this.user=this.authService.currentUser(),this.user&&this.user.subscribed&&(this.closeDownloadPanel(),this.downloadWithResolution(this.downloadHdRes))},{coinSectionHide:this.env.isMobileView})}download(){this.openDownloadPanel()}downloadWithResolution(t){if(this.gtmService.pushTag({eventName:y.b.gtm.eventname.aiDownloadMob,itemName:"Editor_Cleanup"}),this.isGenerationCompleted){const o=this.photoEditorService.downloadImgUrl||this.aiPhotoService.imgUrl;if(!o)return;
1this.downloadImageFromUrlWithResolution(o,t)}else this.getDownloadImageType().then(o=>{const r=this.gestureService.exportCanvasIgnoringViewport(this.photoEditorMobService.mainCanvas);r&&Te.HtmlCanvasUtil.loadImageElement(r,l=>{l?Te.HtmlCanvasUtil.checkAndResizeImage(l,c=>{this.photoEditorMobService.download(o,f.Fs.cleanup,"untitled",c?.src||r)},t.w,t.h,this.getMimeTypeForDownload(o)):this.photoEditorMobService.download(o,f.Fs.cleanup,"untitled",r)})})}downloadImageFromUrlWithResolution(t,i){this.getDownloadImageType().then(o=>{const r=l=>{Te.HtmlCanvasUtil.loadImageElement(l,c=>{c?Te.HtmlCanvasUtil.checkAndResizeImage(c,d=>{this.photoEditorMobService.download(o,f.Fs.cleanup,"untitled",d?.src||l)},i.w,i.h,this.getMimeTypeForDownload(o)):this.photoEditorMobService.download(o,f.Fs.cleanup,"untitled",l)})};t.startsWith("data:")||t.startsWith("blob:")?r(t):fetch(t).then(l=>l.blob()).then(l=>{const c=URL.createObjectURL(l);r(c),setTimeout(()=>URL.revokeObjectURL(c),1e3)}).catch(l=>{console.error("Error downloading image:",l)})})}getDownloadImageType(){return this.sourceImageTypePromise?this.sourceImageTypePromise:Promise.resolve(this.sourceImageType||"jpg")}resolveSourceImageType(t){var i=this;return(0,w.A)(function*(){const o=i.getImageTypeFromUrl(t);if(o)return o;if(!t)return"jpg";try{if(t.startsWith("data:image/"))return i.normalizeImageType(t)||"jpg";if(t.startsWith("blob:")){const c=yield fetch(t).then(d=>d.blob());return i.normalizeImageType(c?.type)||"jpg"}const l=(yield fetch(t,{method:"HEAD"})).headers.get("Content-Type");return i.normalizeImageType(l)||"jpg"}catch{return"jpg"}})()}getImageTypeFromUrl(t){if(!t)return null;if(t.startsWith("data:image/")){const o=/^data:image\/([^;]+)/i.exec(t);return o?.[1]?this.normalizeImageType(o[1]):null}try{const o=new URL(t,window.location.href).pathname.toLowerCase();if(o.endsWith(".png"))return"png";if(o.endsWith(".jpg")||o.endsWith(".jpeg"))return"jpg"}catch{}const i=t.toLowerCase();return i.endsWith(".png")?"png":i.endsWith(".jpg")||i.endsWith(".jpeg")?"jpg":null}normalizeImageType(t){const i=(t||"").toLowerCase();return i?i.includes("png")?"png":i.includes("jpeg")||i.includes("jpg")?"
1jpg":null:null}getMimeTypeForDownload(t){return"png"===this.normalizeImageType(t)?"image/png":"image/jpeg"}setScaleVar(){if(!this.inputImage||!this.photoEditorMobService.mainCanvas)return;const t=document.getElementById("canvasWrapper");if(!t)return;const i=t.getBoundingClientRect(),o=Math.min(i.height/this.inputImage.height,i.width/this.inputImage.width);this.scale=o,this.initialScale=o,this.originalImg?.nativeElement&&(this.originalImg.nativeElement.style.width=`${this.inputImage.width}px`,this.originalImg.nativeElement.style.height=`${this.inputImage.height}px`,this.originalImg.nativeElement.style.transformOrigin="0 0"),this.compareContainer?.nativeElement&&(this.compareContainer.nativeElement.style.width=`${this.photoEditorMobService.mainCanvas.width}px`,this.compareContainer.nativeElement.style.height=`${this.photoEditorMobService.mainCanvas.height}px`),this.comparePreviewContainer?.nativeElement&&(this.comparePreviewContainer.nativeElement.style.width="100%",this.comparePreviewContainer.nativeElement.style.height="100%"),this.updateBrushCursorSize()}setZoomPinch(){const t=document.getElementById("canvas-mask-wrapper");!t||!this.mainCanvas?.nativeElement||(t.style.touchAction="none",this.mainCanvas.nativeElement.style.touchAction="none")}onFileUploaded(t){if(!t.length)return;const i=t[0];i.type.includes("image")&&(this.resetMaskDrawing(),this.clearSavedMaskEditorState(),this.preGenerationCanvasUrl="",this.preGenerationUploadedImg="",this.resetImage(),this.firstImageLoaded=!1,this.objEraseResizedUploaedImg=null,this.sourceImageType=this.normalizeImageType(i.type)||this.getImageTypeFromUrl(i.name)||"jpg",this.sourceImageTypePromise=Promise.resolve(this.sourceImageType),this.aiPhotoService.imgUrl=URL.createObjectURL(i),this.loadInputImage())}resetImage(){this.photoEditorMobService.mainCanvas&&this.initialViewport&&(this.photoEditorMobService.mainCanvas.setViewportTransform([...this.initialViewport]),this.scale=this.photoEditorMobService.mainCanvas.getZoom(),this.photoEditorMobService.mainCanvas.requestRenderAll())}updateOriginalImageTransform(){const t=this.photoEditorMobService.mainCanvas.getZoom(),i=this.photoEditorMobService.mainCanvas.viewportTransform,l=`matrix(${t}, 0, 0, ${t}, ${i[4]}, ${i[5]})`;this.originalImg?.nativeElement&&(this.originalImg.nativeElement.style.transform=l),this.originalPreviewImg?.nativeElement&&(this.originalPreviewImg.nativeElement.style.transform="none")}get undoable(){return!!this.actionController?.isUndoModeAvailable()}applyImage(){var t=this;if(!this.hasValidMask)return void this.toastService.showError("Please draw a mask on the image before removing.");this.saveMaskEditorStateBeforeApply();const i=this.actionController.getCutout().getSmoothMaskMat();this.photoEditorService.isFreeTool=!1,this.setGenerationPreview(!1),this.aiPhotoService.startProcessingProgress({featureType:this.featureType,indeterminate:!0}),"aieraser"!==this.photoEditorService.activeSubTool&&(this.photoEditorService.activeSubTool="aieraser"),this.imageDataToBlobWithScale(i.image,this.objEraseResizedUploaedImg).then(o=>{this.aiUploadImageService.generateImageWithMask(this.objEraseResizedUploaedImg,o,r=>{r&&r.assetId?this.checkStatus(r,0,c=>{(this.aiPhotoService.processingProgress.isActive||this.aiPhotoService.inProgress||this.aiPhotoService.inVideoProgress)&&(c.urls&&c.urls.length>0?this.getObjectRemovedImage(c.imgUrl).then(function(){var d=(0,w.A)(function*(h){t.user=t.authService.currentUser();const p=t.user&&t.user.subscribed?t.downloadHdRes:t.downloadStandardRes;let u=h;try{u=yield t.resizeImageUrlToResolution(h,p)}catch{u=h}t.aiPhotoService.completeGenerationProgress(()=>{t.actionController.createUndoImageState(t.aiPhotoService.imgUrl,t.objEraseResizedUploaedImg),t.objEraseResizedUploaedImg=c.imgUrl,t.aiPhotoService.imgUrl=u,t.photoEditorService.downloadImgUrl=u,t.aiPhotoService.isDirty=!0,t.photoEditorService.isCompareEnable=!0,t.showCleanupActions=!1,t.isEdit=!1,t.aiPhotoService.aiImages||(t.aiPhotoService.aiImages=[]),t.aiPhotoService.aiImages.push({assetId:r.assetId,urls:[u],thumbUrl:u,outputImgUrl:u}),t.setGenerationPreview(!0)})});return function(h){return d.apply(this,arguments)}}()).catch(()=>{this.setGenerationPreview(!1),this.displayErrorMsg({description:y.b.message.somethingWrong})}):(this.setGenerationPreview(!1),this.displayErrorMsg({description:y.b.message.somethingWrong})))},c=>{this.setGenerationPreview(!1),this.displayErrorMsg(c)}):(this.setGenerationPreview(!1),this.displayErrorMsg(r))})}).catch(()=>{this.setGenerationPreview(!1),this.displayErrorMsg(null)})}uploadCleanupImage(t){!this.firstImageLoaded&&this.photoEditorMobService.originalImage?this.aiUploadImageService.aierUploadImage(this.photoEditorMobService.originalImage).then(i=>
1{null!=t&&t!==this.initialLoadId||(this.objEraseResizedUploaedImg=String(i),this.firstImageLoaded=!0,this.compareImageUrl=String(i),null!=t?this.markInitialUploadReady(t):this.isInitialLoading||this.setInProgress(!1))}).catch(i=>{null!=t?this.failInitialLoading(t):this.setInProgress(!1),this.displayErrorMsg(i),this.location.back()}):null!=t?this.markInitialUploadReady(t):this.isInitialLoading||this.setInProgress(!1)}imageDataToBlobWithScale(t,i){return new Promise((o,r)=>{this.aiUploadImageService.loadImage(i).then(l=>{const c=l.width,d=l.height,h=I.fabric.util.createCanvasElement(),p=h.getContext("2d");h.width=c,h.height=d,p.putImageData(t,0,0);let g,_,u=1;t.width>t.height?(g=c,_=d,u=c/t.width):(_=d,g=c,u=d/t.height),p.scale(u,u),p.drawImage(h,0,0);const v=this.currentMaskImageData=p.getImageData(0,0,g,_),C=document.createElement("canvas");C.width=v.width,C.height=v.height,C.getContext("2d").putImageData(v,0,0),C.toBlob(k=>{k?o(k):r(new Error("Failed to create mask blob"))})}).catch(r)})}getObjectRemovedImage(t){return new Promise((i,o)=>{I.fabric.Image.fromURL(t,r=>{const l=new Xe.Y,c=new this.f.CutoutFilter({image:null,adjustment:l.adjustedValues});c.image=this.currentMaskImageData,c.previewMode=1,c.invertMask=0,r.filters.push(c);const d=this.photoEditorMobService.theOriginalOriginalImage||this.photoEditorMobService.originalImage,h=d.width,p=d.height,u=I.fabric.util.createCanvasElement();u.width=h,u.height=p;const g=new I.fabric.Image(d);r.set({scaleX:h/r.width,scaleY:p/r.height});const _=new I.fabric.StaticCanvas(u,{enableRetinaScaling:!1});_.add(g),_.add(r),r.applyFilters(),_.renderAll(),u.toBlob(v=>{v?i(URL.createObjectURL(v)):o(new Error("Failed to merge cleanup result"))},"image/png")},{crossOrigin:"anonymous"})})}resizeImageUrlToResolution(t,i){return new Promise(o=>{Te.HtmlCanvasUtil.loadImageElement(t,r=>{r?Te.HtmlCanvasUtil.checkAndResizeImage(r,l=>{o(l?.src||t)},i.w,i.h):o(t)})})}checkStatus(t,i=0,o=null,r=null){const l=t.avgResponseTimeInSec/t.maxRetriesAllowed*1e3;this.aiUploadImageService.checkStatus(t.assetId,c=>{const d=c.body;d&&"active"===d.status?(this.authService.updateUserAiConis("20"),o?.(d)):d&&"init"===d.status?i<t.maxRetriesAllowed?setTimeout(()=>{this.checkStatus(t,++i,o,r)},l):(d.inQueue=!0,this.displayQueueMsg(()=>{this.checkStatus(t,0,o,r)})):d&&("failed"===d.status||"fail"===d.status.toLowerCase())&&r?.(d)},c=>{r?.(c)})}displayQueueMsg(t=null){this.dialogService.open({okButtonText:y.b.message.okTryAgainButtonText,title:y.b.message.aiCreationInQueueLabel,message:y.b.message.aiCreationInQueueMsg},()=>{t?.()},()=>{})}closeProgress(t){this.aiPhotoService.completeGenerationProgress()}clearTimeInterval(){this.interValId&&clearInterval(this.interValId),this.interValId1&&clearInterval(this.interValId1)}displayErrorMsg(t=null,i=null){const o=t?.description||y.b.message.somethingWrong;this.aiPhotoService.clearGenerationProgress(),this.createPopupService.openWarningDialog("Error",o)}}return(s=a).\u0275fac=function(t){return new(t||s)(e.rXU(Z.s),e.rXU(q.u),e.rXU(be),e.rXU(b.aZ),e.rXU(Q.f),e.rXU(re),e.rXU(Ne.p),e.rXU(me.X),e.rXU(ae.g),e.rXU(Ce.u),e.rXU(ie.y),e.rXU(ve),e.rXU($t.n),e.rXU(ee.M),e.rXU(ne.A),e.rXU(J.K),e.rXU(de.W),e.rXU(ue.n),e.rXU(xe.L),e.rXU(e.SKi))},s.\u0275cmp=e.VBU({type:s,selectors:[["ai-cleanup"]],viewQuery:function(t,i){if(1&t&&(e.GBs(jc,5),e.GBs(Gc,5),e.GBs(Vc,7),e.GBs(Le,7),e.GBs(Rc,5),e.GBs(Fc,5),e.GBs(Ac,5),e.GBs(Bc,5)),2&t){let o;e.mGM(o=e.lsd())&&(i.contentBox=o.first),e.mGM(o=e.lsd())&&(i.fileInput=o.first),e.mGM(o=e.lsd())&&(i.mainCanvas=o.first),e.mGM(o=e.lsd())&&(i.maskMagnifier=o.first),e.mGM(o=e.lsd())&&(i.originalImg=o.first),e.mGM(o=e.lsd())&&(i.compareContainer=o.first),e.mGM(o=e.lsd())&&(i.originalPreviewImg=o.first),e.mGM(o=e.lsd())&&(i.comparePreviewContainer=o.first)}},hostBindings:function(t,i){1&t&&e.bIt("pointerdown",function(){return i.onUserPointerAction()},!1,e.EBC)("keydown",function(){return i.onUserKeyAction()},!1,e.EBC)("wheel",function(){return i.onUserWheelAction()},!1,e.EBC)},inputs:{featureType:"featureType",imageUrl:"imageUrl",minZoom:"minZoom",maxZoom:"maxZoom"},outputs:{changeStep:"changeStep"},features:[e.Jv_([Ce.u,re,Ie.r,Ne.p])],decls:31,vars:23,consts:[["mainCanvas",""],["compareContainer",""],["comparePreviewContainer",""],["file",""],["originalImg",""],["originalPreviewImg",""],[1,"mobileRetouch","overflow-hidden","d-flex","flex-column","h-100"],[1,"drawer-elements","ai-drawer-elements","overflow-hidden","d-flex","flex-column","flex-grow-1","h-100","min-h-0"],[1,"d-flex","align-items-center","justify-content-center","overflow-hidden","w-100","flex-column","pt-9","ps-3","pe-3","border-radius-12","position-relative","replace-canvas-area","flex-grow-1",3,"ngClass"],["
1id","canvasWrapper",1,"d-flex","align-items-center","justify-content-center","overflow-hidden","w-100","flex-column","h-100"],["id","canvas-mask-wrapper",1,"d-flex","align-items-center","justify-content-center","overflow-hidden","border-radius-12","position-relative","h-100","bg-grey3","w-100",2,"overflow","auto"],["id","vmx-canvas","height","100%","width","100%","disableRC","",1,"position-relative",3,"ngClass"],[1,"mw-100","mh-100",2,"overflow","hidden",3,"ngClass"],["disableRC","",3,"src",4,"ngIf"],["class","replace-brush-cursor",3,"replace-brush-cursor--brush","replace-brush-cursor--erase","ngStyle",4,"ngIf"],[3,"diameter","zoomDeltaMultiplier"],["class","preset-pan-zoom-hint text-12 text-semi text-white bg-primary position-absolute border-radius-20 d-inline-flex align-items-center",4,"ngIf"],["class","flex-shrink-0",4,"ngIf"],[1,"d-flex","align-items-center","justify-content-center","overflow-hidden","w-100","flex-column","pt-3","ps-3","pe-3","border-radius-12","position-relative","replace-canvas-area","flex-grow-1",3,"ngClass"],[1,"d-flex","align-items-center","justify-content-start","overflow-hidden","h-100","w-100","border-radius-12","bg-grey3","position-relative"],[1,"d-flex","overflow-hidden","w-100","flex-column","align-items-center","justify-content-center","h-100"],[1,"res-round","h-100"],["class","w-100 h-100",3,"src",4,"ngIf"],[1,"mw-100","mh-100","w-100","h-100","position-absolute","top-0","start-0",2,"overflow","hidden",3,"ngClass"],[1,"res-round","h-100","w-100"],["disableRC","","class","w-100 h-100",3,"src",4,"ngIf"],[1,"d-flex","align-items-center","justify-content-center","position-absolute","hw-40","border-radius-50","btn-alpha",2,"bottom","8px","left","24px"],[1,"btn","d-flex","align-items-center","justify-content-center","border-0",3,"pointerdown","pointerup","pointercancel","pointerleave"],["name","comparewhite",1,"f-24","text-white"],["class","w-100 pt-3 ps-3 pe-3 flex-shrink-0",4,"ngIf"],[4,"ngIf"],["id","fileInput","name","fileInput","type","file",1,"custom-file-input","n-show","d-none",3,"click","change","accept","multiple"],["disableRC","",3,"src"],[1,"replace-brush-cursor",3,"ngStyle"],[1,"preset-pan-zoom-hint","text-12","text-semi","text-white","bg-primary","position-absolute","border-radius-20","d-inline-flex","align-items-center"],["name","dragImageOpen",1,"f-24"],[1,"flex-shrink-0"],[1,"replace-mask-tools","w-100","cleanup-bottom-content"],[1,"d-flex","flex-column","w-100","mobileRetouchStyle"],[1,"card-body","pt-10","ps-3","pe-3"],[1,"text-13","grey-800","text-semi"],[1,"d-flex"],[1,"wp-100","d-flex","align-items-center"],["style","width:100%","class","opacity-slider",3,"min","max","step","value","change","slideStart","slideStop",4,"ngIf"],["type","range","class","replace-brush-range w-100","min","5","max","100","step","1",3,"value","input","change","touchstart","touchend",4,"ngIf"],[1,"ms-3"],["type","text","maxlength","3","disabled","",1,"form-control","form-input-sm","text-normal","text-black",2,"pointer-events","none",3,"ngModel"],["class","d-flex flex-column align-items-center justify-content-center text-normal text-dark lh-125 cleanup-hint-area",4,"ngIf"],[1,"opacity-slider",2,"width","100%",3,"change","slideStart","slideStop","min","max","step","value"],["type","range","min","5","max","100","step","1",1,"replace-brush-range","w-100",3,"input","change","touchstart","touchend","value"],[1,"d-flex","flex-column","align-items-center","justify-content-center","text-normal","text-dark","lh-125","cleanup-hint-area"],[1,"d-flex","flex-column","align-items-center","justify-content-center"],[1,"d-flex","flex-column","align-items-center","justify-content-center","cleanup-tools-area","w-100","ps-3","pe-3","pt-3"],["type","button",1,"replace-tool-btn","border-0","bg-transparent",3,"click","ngClass"],["name","dooledraw",1,"f-24"],[1,"text-12","text-semi","mt-1"],["type","button",1,"replace-tool-btn","border-0","bg-transparent","ms-4",3,"click","ngClass"],["name","dooleerase",1,"f-24"],[1,"w-100","pt-3","ps-3","pe-3"],[1,"btn","btn-primary","btn-h44","w-100","d-flex","align-items-center","justify-content-center",3,"click","disabled"],[1,"w-100","h-100",3,"src"],["disableRC","",1,"w-100","h-100",3,"src"],[1,"w-100","pt-3","ps-3","pe-3","flex-shrink-0"],[1,"btn","btn-primary","btn-h48","w-100","d-flex","align-items-center","justify-content-center",3,"click"],[1,"showpreview-overlay","mobile-sheet-overlay","position-fixed",3,"click"],[1,"mobile-style-panel","mobile-sheet-anim","download-sheet-panel"],[1,"d-flex","justify-content-start","align-items-center","bottom-container","bg-white","p-3","flex-column","w-100"],[1,"top-header","d-flex","justify-content-start","align-items-center","w-100","flex-column","mb-3","h-32"],[1,"text-lg","text-semi","grey-800","m-0","w-100","lh-125","d-flex","align-items-center","justify-content-between","h-32"],["name","previewclose",3,"click"],["type","button",1,"btn","btn-primary","btn-h48","w-100","position-relative",3,"click"],["name","downloadwhite",1,"f-24","me-2"],[1,"flex-grow-1","text-center"],["name","prousernew","class","f-24 position-absolute","style","right: 8px;",4,"ngIf"],[1,"text-normal","grey-600","text-center","w-100","mt-2"],["type","button",1,"btn-all","btn-outline-primary","btn-h48","w-100","mt-4",3,"click"],["name","download",1,"f-24","me-2"],["name","prousernew",1,"f-24","position-absolute",2,"right","8px"]],template:function(t,i){if(1&t){const o=e.RV6();e.j41(0,"div",6)(1,"div",7)(2,"div",8)(3,"div",9)(4,"div",10)(5,"canvas",11,0),e.EFF(7," Your browser does not support the HTML5 canvas tag. "),e.k0s(),e.j41(8,"div",12,1),e.DNE(10,Dc,2,1,"img",13),e.k0s(),e.DNE(11,Nc,1,7,"div",14),e.nrm(12,"mobile-mask-magnifier",15),e.k0s()(),e.DNE(13,Xc,4,0,"div",16),e.k0s(),e.DNE(14,Wc,2,1,"div",17),e.j41(15,"div",18)(16,"div",19)(17,"div",20)(18,"div",21),e.DNE(19,qc,2,4,"img",22),e.k0s()(),e.j41(20,"div",23,2)(22,"div",24),e.DNE(23,Kc,2,1,"img",25),e.k0s()()(),e.j41(24,"div",26)(25,"button",27),e.bIt("pointerdown",function(){return e.eBV(o),e.Njj(i.onPointerDown())})("pointerup",function(){return e.eBV(o),e.Njj(i.onPointerUp())})("pointercancel",function(){return e.eBV(o),e.Njj(i.onPointerUp())})("pointerleave",function(){return e.eBV(o),e.Njj(i.onPointerUp())}),e.nrm(26,"pi",28),e.k0s()()(),e.DNE(27,Zc,3,0,"div",29),e.k0s()(),e.DNE(28,Qc,21,5,"ng-container",30),e.j41(29,"input",31,3),e.bIt("click",function(){e.eBV(o);const l=e.sdS(30);return e.Njj(l.value="")}
1)("change",function(l){return e.eBV(o),e.Njj(i.onFileUploaded(l.srcElement.files))}),e.k0s()}2&t&&(e.R7$(2),e.Y8G("ngClass",e.eq3(17,lt,i.isGenerationCompleted)),e.R7$(3),e.Y8G("ngClass",e.eq3(19,lt,i.isCompare)),e.R7$(3),e.Y8G("ngClass",i.isCompare?"d-flex":"d-none"),e.R7$(2),e.Y8G("ngIf",i.photoEditorMobService.originalImage),e.R7$(),e.Y8G("ngIf",i.showBrushCursorPreview),e.R7$(),e.Y8G("diameter",80)("zoomDeltaMultiplier",1.5),e.R7$(),e.Y8G("ngIf",i.showPresetHint),e.R7$(),e.Y8G("ngIf",!i.isGenerationCompleted),e.R7$(),e.Y8G("ngClass",e.eq3(21,lt,!i.isGenerationCompleted)),e.R7$(4),e.Y8G("ngIf",i.aiPhotoService.imgUrl),e.R7$(),e.Y8G("ngClass",i.isCompare?"d-flex":"d-none"),e.R7$(3),e.Y8G("ngIf",i.photoEditorMobService.originalImage),e.R7$(4),e.Y8G("ngIf",i.isGenerationCompleted&&!i.aiPhotoService.inProgress),e.R7$(),e.Y8G("ngIf",i.downloadPanelMounted),e.R7$(),e.Y8G("accept","image/*")("multiple",!1))},dependencies:[b.YU,b.bT,b.B3,Me.G,P.me,P.BC,P.tU,P.vS,H.b,O.d1,Le,Pe.m],styles:['.compare-stack[_ngcontent-%COMP%]   img[_ngcontent-%COMP%]{width:100%;object-fit:contain}.mobileRetouch[_ngcontent-%COMP%]{position:relative;flex:1 1 auto;height:100%;min-height:0;overflow:hidden;padding-bottom:4px}
1.drawer-elements[_ngcontent-%COMP%]{flex:1 1 auto;min-height:0}.replace-canvas-area[_ngcontent-%COMP%]{flex:1 1 0;min-height:0}.res-round[_ngcontent-%COMP%]{overflow:hidden;display:flex;justify-content:center;align-items:center;margin:0 auto}.res-round[_ngcontent-%COMP%]   img[_ngcontent-%COMP%]{width:100%;height:100%;max-width:100%;max-height:100%;object-fit:contain}.replace-mobile-layout[_ngcontent-%COMP%]{height:calc(100vh - 52px);height:calc(100dvh - 52px)}.showpreview-overlay[_ngcontent-%COMP%]{background:#0003;-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);width:100%;height:100%;top:0;bottom:0;z-index:999}.mobile-style-panel[_ngcontent-%COMP%]{position:fixed;left:0;right:0;bottom:0;z-index:3;background:#fff;border-radius:20px 20px 0 0;height:auto;min-height:0;max-height:90vh;overflow-y:auto}.download-sheet-panel[_ngcontent-%COMP%]{z-index:999}.mobile-sheet-overlay[_ngcontent-%COMP%]{opacity:0;pointer-events:none;transition:opacity .24s ease;display:block}.mobile-sheet-overlay.mobile-sheet-overlay--open[_ngcontent-%COMP%]{opacity:1;pointer-events:auto}.mobile-sheet-anim[_ngcontent-%COMP%]{transform:translate3d(0,100dvh,0);will-change:transform;-webkit-backface-visibility:hidden;backface-visibility:hidden;pointer-events:none;transition:transform .72s cubic-bezier(.22,.61,.36,1)}.mobile-sheet-anim.mobile-sheet-anim--open[_ngcontent-%COMP%]{transform:translateZ(0);pointer-events:auto;transition:transform .52s cubic-bezier(.2,.9,.2,1)}.download-hd-btn[_ngcontent-%COMP%], .download-standard-btn[_ngcontent-%COMP%]{gap:8px}.preset-pan-zoom-hint[_ngcontent-%COMP%]{left:50%;top:calc(50% - 22px);transform:translate(-50%);padding:8px 12px 8px 8px;z-index:6;gap:8px;white-space:nowrap}#canvas-mask-wrapper[_ngcontent-%COMP%]   .replace-brush-cursor[_ngcontent-%COMP%]{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);pointer-events:none;z-index:5;width:102px;height:102px;border-radius:16px;box-sizing:border-box;transition:background-color .15s ease,border-color .15s ease;display:flex;align-items:center;justify-content:center;flex-shrink:0}#canvas-mask-wrapper[_ngcontent-%COMP%]   .replace-brush-cursor[_ngcontent-%COMP%]:after{content:"";width:var(--brush-inner-size, 12px);height:var(--brush-inner-size, 12px);border-radius:99px}#canvas-mask-wrapper[_ngcontent-%COMP%]   .replace-brush-cursor--brush[_ngcontent-%COMP%]{background:#ffffffb3;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px)}#canvas-mask-wrapper[_ngcontent-%COMP%]   .replace-brush-cursor--brush[_ngcontent-%COMP%]:after{background:#f75b5b}#canvas-mask-wrapper[_ngcontent-%COMP%]   .replace-brush-cursor--erase[_ngcontent-%COMP%]{background:#ffffffb3;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px)}#canvas-mask-wrapper[_ngcontent-%COMP%]   .replace-brush-cursor--erase[_ngcontent-%COMP%]:after{background:#f75b5b}.replace-bottom-panel[_ngcontent-%COMP%]{flex:0 0 auto;width:100%;padding-top:12px;padding-bottom:12px}.cleanup-bottom-content[_ngcontent-%COMP%]{flex:0 0 auto}.cleanup-hint-area[_ngcontent-%COMP%]{height:138px}.replace-mask-tools[_ngcontent-%COMP%]   .mobileRetouchStyle[_ngcontent-%COMP%]{display:flex;width:100%}.replace-mask-tools[_ngcontent-%COMP%]   .opacity-slider[_ngcontent-%COMP%]{width:100%;min-height:24px;display:block}.replace-mask-tools[_ngcontent-%COMP%]   .opacity-slider[_ngcontent-%COMP%]   .slider[_ngcontent-%COMP%]{width:100%!important}.replace-mask-tools[_ngcontent-%COMP%]   .opacity-slider[_ngcontent-%COMP%]   .slider-horizontal[_ngcontent-%COMP%]{width:100%!important;height:20px}.replace-mask-tools[_ngcontent-%COMP%]   .replace-brush-range[_ngcontent-%COMP%]{height:20px;accent-color:#626ADF}.replace-tool-btn[_ngcontent-%COMP%]{width:62px;height:62px;border-radius:12px;color:#959aa7;padding:0}.replace-tool-btn[_ngcontent-%COMP%]   span[_ngcontent-%COMP%]{color:#959aa7}.replace-tool-btn--active[_ngcontent-%COMP%]{color:#626adf;background:#626adf1a}.replace-tool-btn--active[_ngcontent-%COMP%]   span[_ngcontent-%COMP%]{color:#626adf}.replace-prompt-trigger[_ngcontent-%COMP%]{height:40px;border-radius:12px;background:linear-gradient(90deg,#fc5cff05 -4%,#2520f605);border:1px solid #E2E3E9!important;padding:0 8px 0 4px;text-align:left}.replace-prompt-input-field[_ngcontent-%COMP%]{background:transparent;outline:none;cursor:pointer;color:#272b34}.replace-prompt-input-field[_ngcontent-%COMP%]::placeholder{color:#606576}@media screen and (max-height: 740px){.text-56[_ngcontent-%COMP%]{font-size:48px!important;line-height:58px!important}}@media screen and (max-height: 640px){.text-56[_ngcontent-%COMP%]{font-size:40px!important;line-height:50px!important}}@media screen and (max-height: 540px){.text-56[_ngcontent-%COMP%]{font-size:30px!important;line-height:40px!important}}.content-box[_ngcontent-%COMP%]{transition:opacity .5s ease,transform .5s ease}.content-box.in[_ngcontent-%COMP%]{opacity:1;transform:translate(0)}.content-box.out[_ngcontent-%COMP%]{opacity:0;transform:translate(-50px)}.full-screen-container[_ngcontent-%COMP%]{display:flex;height:100vh}.left-column[_ngcontent-%COMP%], .right-column[_ngcontent-%COMP%]{flex:1;height:100%;overflow:auto}.left-column[_ngcontent-%COMP%]{background-color:#f5f5f5}.right-column[_ngcontent-%COMP%]{background-color:#e0e0e0}.reseticon-none[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]{opacity:.3}.prompt-view[_ngcontent-%COMP%]   .textarea-col[_ngcontent-%COMP%]{width:100%;height:188px;border-radius:12px;background:#eeedf3;padding:4px;border:0px!important}.prompt-view[_ngcontent-%COMP%]   .textarea-col[_ngcontent-%COMP%]:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:12px;padding:.92px;border:none;background:linear-gradient(90deg,#c9cad4 -4% 100%);-webkit-mask:linear-gradient(90deg,#C9CAD4 -4%,#C9CAD4 100%) content-box,linear-gradient(90deg,#C9CAD4 -4%,#C9CAD4 100%);-webkit-mask-composite:xor;mask-composite:exclude;z-index:1}.prompt-view[_ngcontent-%COMP%]   .textarea-col[_ngcontent-%COMP%]:hover{border:1px solid #B0B3BF}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]{resize:none;outline:none;width:100%;height:148px;padding:8px;font-size:13px;color:#b0b3bf;border:0px;background:transparent;border-radius:12px;line-height:18px;overflow:auto;position:relative;z-index:2;line-height:125%}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]::-webkit-scrollbar{width:4px;height:4px;border-radius:12px}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]::-webkit-scrollbar-track{background:#e3e3e3;border-radius:12px;margin-top:8px}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background:#9a9a9a;border-radius:12px}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]::-webkit-scrollbar-thumb:hover{background:#555}.prompt-view[_ngcontent-%COMP%]   .prompt-info[_ngcontent-%COMP%]{font-size:11px;color:#b0b3bf;margin-top:0;padding-left:8px;line-height:140%}.prompt-text[_ngcontent-%COMP%]{color:#272b34!important}.info-up[_ngcontent-%COMP%]{border:1px solid #B0B3BF!important;background:#eeedf3!important}.info-blue[_ngcontent-%COMP%]{background:linear-gradient(90deg,#fc5cff0d -4%,#2520f60d)!important}.info-blue[_ngcontent-%COMP%]:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:12px;padding:.92px;border:none;background:linear-gradient(90deg,#fc5cff -4%,#2520f6)!important;-webkit-mask:linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%) content-box,linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%)!important;-webkit-mask-composite:xor!important;mask-composite:exclude!important;z-index:1}.info-blue[_ngcontent-%COMP%]   span[_ngcontent-%COMP%]{color:#626adf!important}.info-red[_ngcontent-%COMP%]{background:linear-gradient(90deg,#fc5cff0d -4%,#2520f60d)!important}.info-red[_ngcontent-%COMP%]:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:12px;padding:.92px;border:none;background:linear-gradient(90deg,#f25555 -4% 100%)!important;-webkit-mask:linear-gradient(90deg,#F25555 -4%,#F25555 100%) content-box,linear-gradient(90deg,#F25555 -4%,#F25555 100%)!important;-webkit-mask-composite:xor!important;mask-composite:exclude!important;z-index:1}.info-red[_ngcontent-%COMP%]   span[_ngcontent-%COMP%]{color:#f25555!important}']}),a})();const td=["cpText"],id=["contentBox"],nd=["file"],od=["mainCanvas"],sd=["originalImg"],rd=["compareContainer"],ad=["originalPreviewImg"],ld=["comparePreviewContainer"],cd=["carousel"],ct=s=>({"d-none":s}),dd=(s,a,n)=>({"hide-arrow":s,isFirst:a,isLast:n}),hd=s=>({"--brush-inner-size":s}),Ht=s=>({"replace-tool-btn--active":s}),pd=(s,a,n)=>({"info-up":s,"info-blue":a,"info-red":n});function md(s,a){if(1&s&&e.nrm(0,"div",30),2&s){const n=e.XpG();e.AVh("replace-brush-cursor--brush",n.selectMaskVal===n.CONST_INDEX_MANUAL_BRUSH)("replace-brush-cursor--erase",n.selectMaskVal===n.CONST_INDEX_MANUAL_ERASE),e.Y8G("ngStyle",e.eq3(5,hd,n.brushCursorPreviewSize+"px"))}}function ud(s,a){1&s&&(e.j41(0,"div",31),e.nrm(1,"pi",32),e.j41(2,"span"),e.EFF(3,"Pinch in/out to zoom image"),e.k0s()())}function gd(s,a){if(1&s){const n=e.RV6();e.j41(0,"mv-slider",45),e.bIt("change",function(i){e.eBV(n);const o=e.XpG(3);return e.Njj(o.onBrushSlide(i))})("slideStart",function(){e.eBV(n);const i=e.XpG(3);return e.Njj(i.onBrushSliderMouseDown())})("slideStop",function(i){e.eBV(n);const o=e.XpG(3);return e.Njj(o.onBrushSlideStop(i))}),e.k0s()}if(2&s){const n=e.XpG(3);e.Y8G("min",5)("max",100)("step",1)("value",n.brushSliderValue)}}function _d(s,a){if(1&s){const n=e.RV6();e.j41(0,"input",46),e.bIt("input",function(i){e.eBV(n);const o=e.XpG(3);return e.Njj(o.onBrushSlide(i))})("change",function(i){e.eBV(n);const o=e.XpG(3);return e.Njj(o.onBrushSlide(i))})("touchstart",function(){e.eBV(n);const i=e.XpG(3);return e.Njj(i.onBrushSliderMouseDown())})("touchend",function(){e.eBV(n);const i=e.XpG(3);return e.Njj(i.onBrushSliderMouseUp())}),e.k0s()}if(2&s){const n=e.XpG(3);e.Y8G("value",n.brushSliderValue)}}function fd(s,a){1&s&&(e.j41(0,"div",47)(1,"div",48)(2,"div"),e.EFF(3,"Swipe finger over the image to select "),e.k0s(),e.j41(4,"div"),e.EFF(5,"the area for replacement"),e.k0s()()())}function vd(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"div",49)(2,"div",38)(3,"button",50),e.bIt("click",function(){e.eBV(n);const i=e.XpG(3);return e.Njj(i.onMaskTypeChange(i.CONST_INDEX_MANUAL_BRUSH))}),e.j41(4,"div",48),e.nrm(5,"pi",51),e.j41(6,"span",52),e.EFF(7,"Brush"),e.k0s()()(),e.j41(8,"button",53),e.bIt("click",function(){e.eBV(n);const i=e.XpG(3);return e.Njj(i.onMaskTypeChange(i.CONST_INDEX_MANUAL_ERASE))}),e.j41(9,"div",48),e.nrm(10,"pi",54),e.j41(11,"span",52),e.EFF(12,"Erase"),e.k0s()()()(),e.j41(13,"div",55)(14,"div",56),e.bIt("click",function(){e.eBV(n);const i=e.XpG(3);return i.step=2,e.Njj(i.focusIn())}),e.nrm(15,"pi",57),e.j41(16,"input",58),e.bIt("focus",function(){e.eBV(n);const i=e.XpG(3);return i.step=2,e.Njj(i.focusIn())}),e.k0s()()()(),e.j41(17,"div",59)(18,"button",60),e.bIt("click",function(){e.eBV(n);const i=e.XpG(3);return e.Njj(i.applyImage())}),e.j41(19,"span",61),e.EFF(20,"Generate"),e.k0s(),e.j41(21,"span",62),e.nrm(22,"img",63)(23,"img",64),e.j41(24,"b",65),e.EFF(25),e.k0s()()()(),e.bVm()}if(2&s){const n=e.XpG(3);e.R7$(3),e.Y8G("ngClass",e.eq3(5,Ht,n.selectMaskVal===n.CONST_INDEX_MANUAL_BRUSH)),e.R7$(5),e.Y8G("ngClass",e.eq3(7,Ht,n.selectMaskVal===n.CONST_INDEX_MANUAL_ERASE)),e.R7$(8),e.Y8G("value",n.aiPhotoService.textPrompt||""),e.R7$(2),e.Y8G("disabled",!n.canGenerate),e.R7$(7),e.JRh(n.qual
1ityType)}}function bd(s,a){if(1&s&&(e.qex(0),e.j41(1,"div",34)(2,"div",35)(3,"div",36)(4,"span",37),e.EFF(5,"Brush Size"),e.k0s(),e.j41(6,"div",38)(7,"div",39),e.DNE(8,gd,1,4,"mv-slider",40)(9,_d,1,1,"input",41),e.k0s(),e.j41(10,"div",42),e.nrm(11,"input",43),e.k0s()()(),e.DNE(12,fd,6,0,"div",44)(13,vd,26,9,"ng-container",28),e.k0s()(),e.bVm()),2&s){const n=e.XpG(2);e.R7$(8),e.Y8G("ngIf",n.isEditorScriptsReady),e.R7$(),e.Y8G("ngIf",!n.isEditorScriptsReady),e.R7$(2),e.Y8G("ngModel",n.brushSliderValue),e.R7$(),e.Y8G("ngIf",!n.showReplaceActions),e.R7$(),e.Y8G("ngIf",n.showReplaceActions)}}function Cd(s,a){if(1&s&&(e.j41(0,"div",33),e.DNE(1,bd,14,5,"ng-container",28),e.k0s()),2&s){const n=e.XpG();e.R7$(),e.Y8G("ngIf",n.isLoaded)}}function xd(s,a){if(1&s&&(e.nrm(0,"img",70),e.nI1(1,"safe")),2&s){const n=e.XpG(2).$implicit;e.Y8G("src",e.i5U(1,1,n.urls[0],"url"),e.B4B)}}function Pd(s,a){if(1&s&&(e.j41(0,"div",67)(1,"div",68),e.DNE(2,xd,2,4,"img",69),e.k0s()()),2&s){const n=e.XpG().$implicit;e.R7$(2),e.Y8G("ngIf",n.urls[0])}}function Id(s,a){if(1&s){const n=e.RV6();e.DNE(0,Pd,3,1,"ng-template",66),e.bIt("slid",function(i){const o=e.eBV(n),r=o.first,l=o.last,c=e.XpG();return e.Njj(c.nextSlide(i,r,l))})}2&s&&e.Y8G("id",a.$implicit.assetId)}function yd(s,a){if(1&s&&e.nrm(0,"img",71,4),2&s){const n=e.XpG();e.Y8G("src",n.photoEditorMobService.originalImage.src,e.B4B)}}function wd(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",72),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.download())}),e.nrm(1,"pi",73),e.k0s()}}function Sd(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",74)(1,"button",60),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.applyImage())}),e.EFF(2,"Generate More "),e.j41(3,"span",62),e.nrm(4,"img",63)(5,"img",64),e.j41(6,"b",65),e.EFF(7),e.k0s()()()()}if(2&s){const n=e.XpG();e.R7$(),e.Y8G("disabled",!n.canGenerate),e.R7$(6),e.JRh(n.qualityType)}}function Md(s,a){if(1&s&&(e.j41(0,"span",88),e.EFF(1),e.k0s()),2&s){const n=e.XpG(2);e.R7$(),e.Lme("",n.aiPhotoService.textPrompt.length,"/",n.maxLenght," ")}}function kd(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"div",75)(2,"div",76)(3,"div",77),e.EFF(4," Enter Prompt "),e.k0s(),e.j41(5,"div")(6,"pi",78),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return i.focusOut(),e.Njj(i.step=1)}),e.k0s()()(),e.j41(7,"div",79)(8,"div",80)(9,"div",81)(10,"div",82)(11,"div",83)(12,"textarea",84,5),e.mxI("ngModelChange",function(i){e.eBV(n);const o=e.XpG();return e.DH7(o.aiPhotoService.textPrompt,i)||(o.aiPhotoService.textPrompt=i),e.Njj(i)}),e.bIt("keyup",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.changePrompt())})("paste",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.onPaste(i))})("focus",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.focusIn())})("blur",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.focusOut())})("keydown.enter",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.onEnter(i))}),e.k0s(),e.DNE(14,Md,2,2,"span",85),e.k0s()()()()(),e.j41(15,"div",86)(16,"button",60),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return i.focusOut(),e.Njj(i.step=1)}),e.j41(17,"span",61),e.EFF(18,"Done"),e.k0s()()()(),e.j41(19,"div",87),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return i.step=1,e.Njj(i.focusOut())}),e.k0s(),e.bVm()}if(2&s){const n=e.XpG();e.R7$(11),e.Y8G("ngClass",e.sMw(7,pd,n.aiPhotoService.textPrompt.length,n.isFocused,n.aiPhotoService.textPrompt.length>n.maxLenght-1)),e.R7$(),e.AVh("blue-active",n.isFocused),e.Y8G("maxlength",n.maxLenght),e.R50("ngModel",n.aiPhotoService.textPrompt),e.R7$(2),e.Y8G("ngIf",n.aiPhotoService.textPrompt.length),e.R7$(2),e.Y8G("disabled",n.disabled)}}function Td(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"add-credit",89),e.bIt("close",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.step=1)})("addCredit",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.addCredit())}),e.k0s(),e.bVm()}if(2&s){const n=e.XpG();e.R7$(),e.Y8G("consumeCoins",n.qualityType)}}let Od=(()=>{var s;class a{constructor(t,i,o,r,l,c,d,h,p,u,g,_,v,C,M,k,j,G){var U=this;this.aiPhotoService=t,this.authService=i,this.photoEditorSahredService=o,this.location=r,this.toastService=l,this.photoEditorMobService=c,this.photoEditorService=d,this.stateService=h,this.dialogService=p,this.zoomService=u,this.gtmService=g,this.gestureService=_,this.cssGuard=v,this.aiUploadImageService=C,this.createPopupService=M,this.aiGenService=k,this.paymentService=j,this.ngZone=G,this.prompts=[],this.step=1,this.isFocused=!1,this.maxLenght=450,this.featureType="aireplace",this.imageUrl="",this.changeStep=new e.bkB,this.disabled=!1,this.isCompare=!1,this.isEdit=!1,this.showReplaceActions=!1,this.hasValidMask=!1,this.isGenerationCompleted=!1,this.isImageLoading=!1,this.activeId="",this.isFirst=!1,this.isLast=!0,this.videoUrl="",this.preGenerationCanvasUrl="",this.savedMaskEditorState=null,this.scale=1,this.initialScale=0,this.minZoom=1,this.maxZoom=5,this.pinchStartScale=1,this.pinchStartDistance=0,this.pinchCenterCanvas=null,this.lastPinchCenter=null,this.touchInteractionState="idle",this.activeTouchCount=0,this.activeTouchPointerIds=new Set,this.suppressMaskDrawing=!1,this.touchDrawVerificationTimer=null,this.pendingTouchDraw=null,this.touchDrawVerifyMs=150,this.lastStrokePoint=null,this.rafGestureId=null,this.pendingGestureFrame=null,this.initialLoadId=0,this.isInitialLoading=!1,this.selectMaskVal=T.l4,this.brushSliderValue=50,this.brushCursorPreviewVisible=!1,this.brushCursorPreviewSize=0,this.isEditorScriptsReady=!1,this.showPresetHint=!1,this.hasShownPresetHint=!1,this.presetHintTimeoutId=null,this.hoverCurs
1or=null,this.canvasResizeObserver=null,this.CONST_INDEX_MANUAL_BRUSH=T.l4,this.CONST_INDEX_MANUAL_ERASE=T.lh,this.f=I.fabric.Image.filters,this.maskMouseDown=!1,this.maskDrawIndex=0,this.previewMode=!1,this.maskEventsConfigured=!1,this.wasmInitPromise=null,this.newMaskImageData=null,this.inputs=null,this.qualityType=1,this.maskPointerDownHandler=F=>this.onMaskPointerDown(F),this.maskPointerMoveHandler=F=>this.onMaskPointerMove(F),this.maskPointerUpHandler=F=>this.onMaskPointerUp(F),this.maskPointerHoverHandler=F=>this.onCanvasPointerHover(F),this.maskPointerLeaveHandler=()=>{this.hideBrushCursor(),this.hideMaskMagnifier()},this.touchStartHandler=F=>this.onTouchStart(F),this.touchMoveHandler=F=>this.onTouchMove(F),this.touchEndHandler=F=>this.onTouchEnd(F),this.user=this.authService.currentUser(),this.loggedInObserver=this.authService.loggedIn.subscribe(F=>{this.user=this.authService.currentUser()}),this.usrPropChangedObserver=this.authService.usrPropChanged.subscribe(F=>{this.user=this.authService.currentUser()}),this.aiPhotoService.applyToSaveFn=(0,w.A)(function*(){U.resetImage(),U.photoEditorSahredService.applyToSave(U.photoEditorMobService.originalImage,U.photoEditorMobService.mainCanvas,F=>{U.aiPhotoService.imgUrl=F.uri,U.aiPhotoService.queryParams.imgUrl=F.uri},!1)}),this.backBtnSub=this.aiPhotoService.backBtnClick.subscribe(F=>{F?.isBack&&this.isGenerationCompleted&&this.restoreCanvasFromPreview()}),this.paymentSub=this.paymentService.configUpdated.subscribe(()=>{this.qualityType=this.getQualityTypeFromConfig()})}restoreCanvasFromPreview(){if(this.preGenerationCanvasUrl&&(this.aiPhotoService.imgUrl=this.preGenerationCanvasUrl,this.photoEditorService.downloadImgUrl=this.preGenerationCanvasUrl),this.setGenerationPreview(!1),!(this.actionController?.getCutout()&&this.photoEditorMobService.inputImage&&this.photoEditorMobService.mainCanvas))return this.clearSavedMaskEditorState(),void this.loadInputImage();this.restoreSavedMaskEditorState()}saveMaskEditorStateBeforeApply(){const t=this.photoEditorMobService.mainCanvas;this.preGenerationCanvasUrl=this.aiPhotoService.imgUrl||this.preGenerationCanvasUrl,this.savedMaskEditorState={hasValidMask:this.hasValidMask,showReplaceActions:this.showReplaceActions,isEdit:this.isEdit,selectMaskVal:this.selectMaskVal,brushSliderValue:this.brushSliderValue,viewport:t?.viewportTransform?[...t.viewportTransform]:null,zoom:t?.getZoom?.()??this.scale}}restoreSavedMaskEditorState(){const t=this.savedMaskEditorState,i=this.photoEditorMobService.mainCanvas,o=this.photoEditorMobService.inputImage;t&&(this.selectMaskVal=t.selectMaskVal,this.brushSliderValue=t.brushSliderValue,t.viewport&&i&&(i.setViewportTransform([...t.viewport]),this.scale=t.zoom)),(!this.baseFilter||!o.filters?.length||o.filters[0]!==this.baseFilter)&&this.addMaskFilter(!0),this.processResult(),this.hasValidMask=this.hasValidMask||!!t?.hasValidMask,this.showReplaceActions=this.hasValidMask||!!t?.showReplaceActions,this.isEdit=this.showReplaceActions||!!t?.isEdit,this.actionController?.getCutout()&&(this.setMask(this.selectMaskVal),this.setBrushSize(this.brushSliderValue,this.selectMaskVal),this.actionController.getCutout()&&(this.actionController.getCutout().selectedOption=this.selectMaskVal,this.applyCutoutBrushSize(this.brushSliderValue))),this.updateBrushCursorSize(),this.updateOriginalImageTransform(),i?.requestRenderAll(),this.clearSavedMaskEditorState()}clearSavedMaskEditorState(){this.savedMaskEditorState=null}setGenerationPreview(t){this.isGenerationCompleted=t,this.aiPhotoService.backBtnClick.next(t?{backBtnEnabled:!0}:{isBack:!0})}ngOnInit(){this.qualityType=this.getQualityTypeFromConfig(),this.isEditorScriptsReady=typeof window.Slider<"u",this.editorScriptsSub=this.cssGuard.editorScriptsLoaded$.subscribe(t=>{t&&(this.isEditorScriptsReady=!0)}),this.toolName=this.aiPhotoService?.queryParams?.tab,this.isLoaded=!0,this.resolveWasmModule().catch(()=>{}),this.preGenerationCanvasUrl=this.aiPhotoService.imgUrl||"",this.loadInputImage()}get canGenerate(){return this.hasValidMask&&!!(this.aiPhotoService.textPrompt||"").trim()}beginInitialLoading(){const t=++this.initialLoadId;return this.isInitialLoading=!0,this.isImageLoading=!0,this.aiPhotoService.startProcessingProgress({featureType:this.featureType,indeterminate:!0}),t}
1endImageLoading(t){null!=t&&t!==this.initialLoadId||(this.isInitialLoading=!1,this.ngZone.run(()=>{this.isImageLoading=!1,this.aiPhotoService.completeGenerationProgress()}))}loadInputImage(){this.showReplaceActions=!1,this.hasValidMask=!1,this.hidePresetPanZoomHint(),this.hasShownPresetHint=!1;const t=this.beginInitialLoading();this.photoEditorMobService.loadInputImage(this.aiPhotoService.imgUrl,this.mainCanvas.nativeElement,()=>{if(t!==this.initialLoadId)return;this.inputImage=this.photoEditorMobService.inputImage;const i=document.getElementById("canvasWrapper");this.zoomService.setCanvas(this.photoEditorMobService.mainCanvas,i),this.photoEditorMobService.mainCanvas&&this.photoEditorMobService.mainCanvas.viewportTransform&&(this.initialViewport=[...this.photoEditorMobService.mainCanvas.viewportTransform]),this.setScaleVar(),this.setZoomPinch(),this.initMaskDrawing(t),this.observeCanvasResize()},()=>{this.endImageLoading(t),this.toastService.showError(y.b.message.somethingWrong),this.location.back()},T.ms,T.HI,!1,!0,!0)}changeBruceSize(t){this.photoEditorService.brushSizeDisable=t}get showBrushCursorPreview(){return this.brushCursorPreviewVisible&&this.brushCursorPreviewSize>0&&!this.isCompare&&(this.selectMaskVal===T.l4||this.selectMaskVal===T.lh)}onMaskTypeChange(t){this.changeTools({name:"mask",value:t,selectedOption:t}),(t===T.l4||t===T.lh)&&this.changeTools({name:"size",value:this.brushSliderValue||50,selectedOption:t})}onBrushSlide(t){const i=this.parseBrushSize(t);this.brushSliderValue=i,this.brushCursorPreviewVisible=!0,this.brushCursorPreviewSize=this.calculateBrushCursorPreviewSize(i),this.hideBrushCursor(),this.setBrushSize(i,this.selectMaskVal),this.actionController?.getCutout()&&(this.actionController.getCutout().selectedOption=this.selectMaskVal,this.applyCutoutBrushSize(i))}onBrushSlideStop(t){this.onBrushSlide(t),this.onBrushSliderMouseUp()}parseBrushSize(t){let i;return i=t&&Object.prototype.hasOwnProperty.call(t,"newValue")?t.newValue:Number(void 0!==t?.target?.value?t.target.value:t),Number.isNaN(i)?this.brushSliderValue:Math.min(100,Math.max(5,i))}onBrushSliderMouseDown(){this.changeBruceSize({value:!0,selectedErase:this.selectMaskVal===T.lh}),this.brushCursorPreviewVisible=!0,this.brushCursorPreviewSize=this.calculateBrushCursorPreviewSize(this.brushSliderValue),this.hideBrushCursor()}onBrushSliderMouseUp(){this.changeBruceSize({value:!1,selectedErase:this.selectMaskVal===T.lh}),this.brushCursorPreviewVisible=!1}changeTools(t){if("mask"===t.name)this.selectMaskVal=t.value,this.isEdit=!0,this.setMask(t.value),this.removeBrushCursor(),this.setBrushSize(this.brushSliderValue,t.selectedOption??this.selectMaskVal),(t.value===T.l4||t.value===T.lh)&&this.updateBrushCursorSize();else if("size"===t.name){this.brushSliderValue=t.value;const i=t.selectedOption??this.selectMaskVal;this.actionController?.getCutout()&&(this.actionController.getCutout().selectedOption=i,this.applyCutoutBrushSize(t.value)),this.setBrushSize(t.value,i)}}initBrushTools(){this.photoEditorService.originalImage=this.photoEditorMobService.originalImage,this.changeTools({name:"size",value:this.brushSliderValue,selectedOption:T.l4}),this.changeTools({name:"mask",value:T.l4,selectedOption:T.l4})}setBrushSize(t,i){if(t<=0)return;const o=t>5?t:5,r=this.photoEditorMobService.originalImage;if(!r)return;const c=.05*Math.max(r.width,r.height)/2,d=this.getNativeBrushSize(o);let h=Math.floor(d/5*c/4);h*=this.getZoomBrushCompensationRatio(),h=Math.max(1,h),h/=2,this.photoEditorService.slidersize=h,this.brushCursorPreviewVisible?this.brushCursorPreviewSize=this.calculateBrushCursorPreviewSize(o):this.updateBrushCursorSize(o)}getNativeBrushSize(t){const i=Math.min(100,Math.max(5,t||5)),o=this.photoEditorMobService.originalImage,r=this.photoEditorMobService.mainCanvas;if(!o||!r)return i;const l=r.getZoom()||this.scale||1;if(l<=0)return i;const c=Number(this.initialViewport?.[0])||this.initialScale||l,d=Math.min(l,c),u=.05*Math.max(o.width,o.height)/2;if(u<=0)return i;let g=Math.floor(i/5*u/4);g=g<5?5:g;const _=2*g*d,v=typeof window<"u"&&window.devicePixelRatio?window.devicePixelRatio:1,C=Math.max(8,3*Math.min(v,3));if(_>=C)return i;const k=Math.ceil(C/(2*d)*20/u);return Math.min(100,Math.max(i,k))}applyCutoutBrushSize(t=this.brushSliderValue){const i=this.actionController?.getCutout();if(!i)return;const o=this.getNativeBrushSize(t),r=Math.max(1,o*this.getZoomBrushCompensationRatio());i.setBrushSize(r)}calculateBrushCursorPreviewSize(t){const i=this.photoEditorMobService.mainCanvas,o=this.photoEditorMobService.originalImage;if(!i||!o)return this.mapBrushSliderToCursorPx(t);const r=i.getObjects("image")[0];if(!r)return this.mapBrushSliderToCursorPx(t);const l=i.getZoom()||this.scale||1,c=Number(this.initialViewport?.[0])||this.initialScale||l,h=.05*Math.max(o.width,o.height)/2,p=this.getNativeBrushSize(t);let u=Math.floor(p/5*h/4);return u=Math.max(u,5)/2,Math.max(1,Math.round(2*u*(r.scaleX*c)))}mapBrushSliderToCursorPx(t){const c=Math.min(100,Math.max(5,t));return Math.round(41+(c-5)/95*99)}calculateBrushRadius(t){const i=this.getNativeBrushSize(t>5?t:5),o=this.photoEditorMobService.originalImage;if(!o)return 0;const l=.05*Math.max(o.width,o.height)/2;let c=Math.floor(i/5*l/4);return c*=this.getZoomBrushCompensationRatio(),c=c<1?1:c,c/2}getZoomBrushCompensationRatio(){const t=this.photoEditorMobService.mainCanvas;if(!t)return 1;const i=t.getZoom()||this.scale||1;if(i<=0)return 1;const o=Number(this.initialViewport?.[0])||this.initialScale||i;return o<=0?1:o/i}getCanvasZoom(){return this.photoEditorMobService.mainCanvas?.getZoom()||this.scale||1}shouldShowBrushCursor(){return!(this.brushCursorPreviewVisible||this.isCompare||this.maskMouseDown||"verifying"===this.touchInteractionState||this.aiPhotoService.inProgress||this.selectMaskVal!==T.l4&&this.selectMaskVal!==T.lh)}updateBrushCursorSize(t){const o=this.calculateBrushRadius(t??this.brushSliderValue);if(!this.shouldShowBrushCursor()||o<=0)return void this.removeBrushCursor();
1if(!this.hoverCursor)return void this.addBrushCursor(o);const l=2/this.getCanvasZoom(),c=Math.max(o-l,0),d=this.hoverCursor.getObjects();for(const h of d)"circle"===h.type&&"white"===h.stroke&&h.set({radius:o,strokeWidth:l}),"circle"===h.type&&"black"===h.stroke&&h.set({radius:c,strokeWidth:l}),"text"===h.type&&h.set({fontSize:o});this.hoverCursor.radius=o,this.hoverCursor.addWithUpdate(),this.hoverCursor.bringToFront(),this.photoEditorMobService.mainCanvas?.requestRenderAll()}addBrushCursor(t){if(this.hoverCursor||t<=0)return;const i=this.photoEditorMobService.mainCanvas;if(!i)return;const r=2/this.getCanvasZoom(),l=Math.max(t-r,0),c=this.selectMaskVal===T.lh?"-":"+",d=new I.fabric.Circle({radius:t,fill:"transparent",stroke:"white",strokeWidth:r,originX:"center",originY:"center"}),h=new I.fabric.Circle({radius:l,fill:"transparent",stroke:"black",strokeWidth:r,originX:"center",originY:"center"}),p=new I.fabric.Text(c,{fontFamily:"sans-serif",fontSize:t,stroke:"white",textAlign:"center",originX:"center",originY:"center",left:0,top:0});this.hoverCursor=new I.fabric.Group([d,h,p],{left:-100,top:-100,originX:"center",originY:"center",selectable:!1,evented:!1}),this.hoverCursor.radius=t,i.add(this.hoverCursor);const u=i;u.hoverCursor="none",u.defaultCursor="none",this.hoverCursor.bringToFront(),i.requestRenderAll()}removeBrushCursor(){const t=this.photoEditorMobService.mainCanvas;if(this.hoverCursor&&t){t.remove(this.hoverCursor),this.hoverCursor=null;const i=t;i.hoverCursor="default",i.defaultCursor="default",t.requestRenderAll()}}hideBrushCursor(){this.hoverCursor&&(this.hoverCursor.set({left:-100,top:-100}).setCoords(),this.photoEditorMobService.mainCanvas?.requestRenderAll())}positionBrushCursor(t,i){this.hoverCursor&&(this.hoverCursor.set({left:t,top:i}).setCoords(),this.hoverCursor.bringToFront(),this.photoEditorMobService.mainCanvas?.requestRenderAll())}updateMaskMagnifier(t,i,o=!1){const r=this.photoEditorMobService.mainCanvas,l=this.photoEditorMobService.originalImage,c=this.photoEditorMobService.theOriginalOriginalImage||l;if(!(r&&l&&c&&this.maskMagnifier))return;const d=r.getObjects("image")[0];if(!d?.scaleX)return;const h=r.getElement().getBoundingClientRect(),p=this.screenToCanvasCoordinates(t,i),u=r.getZoom()||this.scale||1,g=Number(this.initialViewport?.[0])||this.initialScale||u,_=c.width/Math.max(1,l.width),v=c.height/Math.max(1,l.height),C={sourceImage:c,imageX:p.x*_,imageY:p.y*v,clientX:t,clientY:i,viewportLeft:h.left,viewportTop:h.top,viewportWidth:h.width,viewportHeight:h.height,currentZoom:u,baselineZoom:g,imageScaleX:d.scaleX/_,brushDiameter:this.calculateBrushCursorPreviewSize(this.brushSliderValue)};o||!this.maskMagnifier.visible?this.maskMagnifier.show(C):this.maskMagnifier.update(C)}hideMaskMagnifier(){this.maskMagnifier?.hide()}screenToCanvasCoordinates(t,i){const o=this.photoEditorMobService.mainCanvas;if(!o)return{x:0,y:0};const r=o.getElement().getBoundingClientRect(),l=new I.fabric.Point(t-r.left,i-r.top),d=I.fabric.util.invertTransform(o.viewportTransform||[1,0,0,1,0,0]),h=I.fabric.util.transformPoint(l,d),p=this.photoEditorMobService.originalImage;return p?{x:Math.max(0,Math.min(p.width,h.x)),y:Math.max(0,Math.min(p.height,h.y))}:{x:h.x,y:h.y}}getCanvasPointerFromEvent(t){return this.screenToCanvasCoordinates(t.clientX,t.clientY)}calculatePinchDistance(t,i){const o=t.clientX-i.clientX,r=t.clientY-i.clientY;return Math.sqrt(o*o+r*r)}calculatePinchCenter(t,i){return{x:(t.clientX+i.clientX)/2,y:(t.clientY+i.clientY)/2}}applyZoom(t){const i=this.photoEditorMobService.mainCanvas;if(!i||!this.pinchCenterCanvas)return;const o=Math.max(this.minZoom*this.initialScale,Math.min(t,this.maxZoom*this.initialScale));i.zoomToPoint(this.pinchCenterCanvas,o),this.clampPan(),this.scale=i.getZoom(),this.updateBrushCursorSize(),this.brushCursorPreviewVisible&&(this.brushCursorPreviewSize=this.calculateBrushCursorPreviewSize(this.brushSliderValue))}applyPan(t,i){const o=this.photoEditorMobService.mainCanvas;o&&(o.relativePan(new I.fabric.Point(t,i)),this.clampPan(),this.updateBrushCursorSize())}isTouchPointerEvent(t){return!t||"touch"===t.pointerType}canAcceptDrawingInput(t){return!this.isTouchPointerEvent(t)||!(this.suppressMaskDrawing||"pinching"===this.touchInteractionState||this.activeTouchCount>=2||this.activeTouchPointerIds.size>=2)}cancelActiveDrawing(){this.cancelPendingTouchDraw(),this.lastStrokePoint=null,this.hideMaskMagnifier(),this.maskMouseDown&&this.onMaskMouseUp()}clearPendingTouchDrawTimer(){this.touchDrawVerificationTimer&&(clearTimeout(this.touchDrawVerificationTimer),this.touchDrawVerificationTimer=null)}cancelPendingTouchDraw(){this.clearPendingTouchDrawTimer(),this.pendingTouchDraw=null,"verifying"===this.touchInteractionState&&(this.touchInteractionState="idle",this.hideMaskMagnifier())}beginMaskDrawingAt(t){this.maskMouseDown=!0,this.maskDrawIndex=0,this.hideBrushCursor(),this.isEdit=!0,this.photoEditorMobService.isDirty=!0,this.lastStrokePoint=null,this.addInterpolatedMaskPoint(t.x,t.y),this.processResult()}getStrokeStepDistance(){const t=this.photoEditorMobService.originalImage,i=this.getNativeBrushSize(Math.max(5,this.brushSliderValue||5));if(!t)return Math.max(1,.1*i);const l=.05*Math.max(t.width,t.height)/2;let c=Math.floor(i/5*l/4);return c*=this.getZoomBrushCompensationRatio(),c=c<1?1:c,Math.max(1,.5*c)}addInterpolatedMaskPoint(t,i){if(!this.actionController)return;if(!this.lastStrokePoint)return this.actionController.addPoint(t,i),void(this.lastStrokePoint={x:t,y:i});const o=t-this.lastStrokePoint.x,r=i-this.lastStrokePoint.y,l=Math.hypot(o,r);if(l<.01)return;const c=this.getStrokeStepDistance();if(l<=c)return this.actionController.addPoint(t,i),void(this.lastStrokePoint={x:t,y:i});const d=Math.ceil(l/c);for(let h=1;h<=d;
1h++){const p=h/d;this.actionController.addPoint(this.lastStrokePoint.x+o*p,this.lastStrokePoint.y+r*p)}this.lastStrokePoint={x:t,y:i}}scheduleTouchDrawVerification(t){this.cancelPendingTouchDraw(),this.touchInteractionState="verifying",this.pendingTouchDraw={pointerId:t.pointerId,clientX:t.clientX,clientY:t.clientY},this.updateMaskMagnifier(t.clientX,t.clientY,!0);try{t.target?.setPointerCapture?.(t.pointerId)}catch{}this.touchDrawVerificationTimer=setTimeout(()=>{this.touchDrawVerificationTimer=null,this.commitPendingTouchDraw()},this.touchDrawVerifyMs)}commitPendingTouchDraw(){if(!this.pendingTouchDraw||"verifying"!==this.touchInteractionState)return;if(this.suppressMaskDrawing||this.activeTouchCount>=2||this.activeTouchPointerIds.size>=2||!this.canDrawMask())return void this.cancelPendingTouchDraw();const t=this.pendingTouchDraw;this.pendingTouchDraw=null,this.touchInteractionState="drawing";const i=this.screenToCanvasCoordinates(t.clientX,t.clientY);this.beginMaskDrawingAt(i),this.showReplaceActions=!0,this.updateMaskMagnifier(t.clientX,t.clientY)}blockMaskDrawingForMultiTouch(){this.touchInteractionState="pinching",this.suppressMaskDrawing=!0,this.cancelActiveDrawing(),this.hideBrushCursor()}trackTouchPointerDown(t){return"touch"!==t.pointerType||(this.activeTouchPointerIds.add(t.pointerId),!(this.activeTouchPointerIds.size>=2&&(this.blockMaskDrawingForMultiTouch(),1)))}trackTouchPointerUp(t){if("touch"===t.pointerType){if(this.activeTouchPointerIds.delete(t.pointerId),0===this.activeTouchPointerIds.size)return void this.resetTouchInteraction();(this.suppressMaskDrawing||"pinching"===this.touchInteractionState)&&this.cancelActiveDrawing()}}releasePointerCaptureSafe(t){try{t.target?.releasePointerCapture?.(t.pointerId)}catch{}}enterPinchMode(t){if(t.touches.length<2)return;const[i,o]=[t.touches[0],t.touches[1]];this.blockMaskDrawingForMultiTouch(),this.pinchStartScale=this.photoEditorMobService.mainCanvas?.getZoom()||this.scale||this.initialScale,this.pinchStartDistance=this.calculatePinchDistance(i,o);const r=this.calculatePinchCenter(i,o);this.pinchCenterCanvas=new I.fabric.Point(r.x,r.y),this.lastPinchCenter=r}resetTouchInteraction(){this.cancelPendingTouchDraw(),this.hideMaskMagnifier(),this.touchInteractionState="idle",this.activeTouchCount=0,this.activeTouchPointerIds.clear(),this.suppressMaskDrawing=!1,this.pinchStartDistance=0,this.pinchCenterCanvas=null,this.lastPinchCenter=null,this.applyCutoutBrushSize(),this.updateBrushCursorSize()}onTouchStart(t){if(this.activeTouchCount=t.touches.length,t.touches.length>=2)return this.enterPinchMode(t),void t.preventDefault();1===t.touches.length&&"pinching"===this.touchInteractionState&&t.preventDefault()}onTouchMove(t){if(this.activeTouchCount=t.touches.length,t.touches.length>=2){"pinching"!==this.touchInteractionState&&this.enterPinchMode(t);const[i,o]=[t.touches[0],t.touches[1]],r=this.calculatePinchDistance(i,o);this.pinchStartDistance||(this.pinchStartDistance=r);const l=this.calculatePinchCenter(i,o),c=r/this.pinchStartDistance;let d=0,h=0;return this.lastPinchCenter&&(d=l.x-this.lastPinchCenter.x,h=l.y-this.lastPinchCenter.y),this.pinchCenterCanvas=new I.fabric.Point(l.x,l.y),this.lastPinchCenter=l,this.pendingGestureFrame={type:"zoomPan",scale:this.pinchStartScale*c,dx:d,dy:h},this.scheduleGestureFrame(),void t.preventDefault()}"pinching"===this.touchInteractionState&&t.preventDefault()}onTouchEnd(t){if(this.activeTouchCount=t.touches.length,!(t.touches.length>=2))return 1===t.touches.length?(this.blockMaskDrawingForMultiTouch(),this.pinchStartDistance=0,this.pinchCenterCanvas=null,this.lastPinchCenter=null,void t.preventDefault()):(this.activeTouchPointerIds.clear(),void this.resetTouchInteraction());t.preventDefault()}scheduleGestureFrame(){null===this.rafGestureId&&(this.rafGestureId=requestAnimationFrame(()=>{const t=this.pendingGestureFrame;this.pendingGestureFrame=null,this.rafGestureId=null,t&&("zoom"===t.type&&"number"==typeof t.scale?this.applyZoom(t.scale):"pan"===t.type&&"number"==typeof t.dx&&"number"==typeof t.dy?this.applyPan(t.dx,t.dy):"zoomPan"===t.type&&"number"==typeof t.scale&&(this.applyZoom(t.scale),(t.dx||t.dy)&&this.applyPan(t.dx,t.dy))
1)}))}onCanvasPointerHover(t){if(!this.canAcceptDrawingInput(t))return void this.hideBrushCursor();if(!this.shouldShowBrushCursor())return void this.hideBrushCursor();if(this.hoverCursor||this.updateBrushCursorSize(),!this.hoverCursor)return;const i=this.getCanvasPointerFromEvent(t);this.positionBrushCursor(i.x,i.y)}observeCanvasResize(){this.disconnectCanvasResizeObserver();const t=document.getElementById("canvas-mask-wrapper");!t||typeof ResizeObserver>"u"||(this.canvasResizeObserver=new ResizeObserver(()=>{this.updateBrushCursorSize()}),this.canvasResizeObserver.observe(t))}disconnectCanvasResizeObserver(){this.canvasResizeObserver&&(this.canvasResizeObserver.disconnect(),this.canvasResizeObserver=null)}initMaskDrawing(t){const i=this.photoEditorMobService.originalImage;i?this.resolveWasmModule().then(o=>{if(null==t||t===this.initialLoadId)try{if(!this.photoEditorMobService.inputImage||!this.photoEditorMobService.mainCanvas)throw new Error("Canvas not ready");this.resolvedModule=o,this.actionController=new Lt.ZX;const r=this.getImageDataFromImg(i);if(this.actionController.createCutout(o,r,r.width,r.height),!this.actionController.getCutout())throw new Error("Cutout not created");this.ensureWebGLFilterBackend(i),this.addMaskFilter(!0),this.processResult(!0),this.photoEditorMobService.mainCanvas.renderAll(),this.photoEditorMobService.enableAutoFit(),this.configureMaskCanvasEvents(),this.initBrushTools(),this.showPresetPanZoomHint()}finally{this.endImageLoading(t)}}).catch(()=>{this.photoEditorMobService.enableAutoFit(),this.endImageLoading(t),this.toastService.showError("Failed to initialize mask tools")}):this.endImageLoading(t)}ensureWebGLFilterBackend(t){const i=I.fabric,o=Math.max(t.width,t.height);o>I.fabric.textureSize&&(I.fabric.textureSize=o),i.filterBackend||(i.filterBackend=i.initFilterBackend?.())}resolveWasmModule(){return this.photoEditorService.resolvedModule?Promise.resolve(this.photoEditorService.resolvedModule):(this.wasmInitPromise||(this.wasmInitPromise=this.loadWasmModule().catch(t=>{throw this.wasmInitPromise=null,t})),this.wasmInitPromise)}loadWasmModule(){return(0,Yt.f7)("lightxOpenCVModule",`${ke.c.wasmAssetsPath}/cvlightx.js`,()=>{}).then(()=>window.lightxOpenCVModule({locateFile:o=>`${ke.c.wasmAssetsPath}/${o}?ver=${ke.c.lightXWasmVersion}`})).then(i=>new Promise((o,r)=>{const l=i.addFunction(c=>{1===c?(this.photoEditorService.resolvedModule=i,o(i)):r(new Error("WASM init failed"))},"vi");i.cwrap("initWasm",null,["number"])(l)}))}getImageDataFromImg(t){const i=document.createElement("canvas");i.width=t.width,i.height=t.height;const o=i.getContext("2d");return o.drawImage(t,0,0,t.width,t.height),o.getImageData(0,0,t.width,t.height)}
1addMaskFilter(t=!1){const i=new Xe.Y;this.baseFilter=new this.f.CutoutFilter({image:null,adjustment:i.adjustedValues});const o=this.photoEditorMobService.inputImage;o.set({objectCaching:!1,noScaleCache:!0,evented:!0}),o.filters=[this.baseFilter],o.applyFilters(),t||this.photoEditorMobService.mainCanvas.requestRenderAll()}configureMaskCanvasEvents(){const i=this.mainCanvas.nativeElement;!this.photoEditorMobService.mainCanvas||this.maskEventsConfigured||(i.addEventListener("pointerdown",this.maskPointerDownHandler,{passive:!1}),i.addEventListener("pointermove",this.maskPointerMoveHandler,{passive:!1}),i.addEventListener("pointerup",this.maskPointerUpHandler,{passive:!1}),i.addEventListener("pointercancel",this.maskPointerUpHandler,{passive:!1}),i.addEventListener("pointerleave",this.maskPointerLeaveHandler,{passive:!0}),i.addEventListener("touchstart",this.touchStartHandler,{passive:!1}),i.addEventListener("touchmove",this.touchMoveHandler,{passive:!1}),i.addEventListener("touchend",this.touchEndHandler,{passive:!1}),i.addEventListener("touchcancel",this.touchEndHandler,{passive:!1}),this.maskEventsConfigured=!0)}unconfigureMaskCanvasEvents(){const t=this.photoEditorMobService.mainCanvas,i=this.mainCanvas?.nativeElement;!t||!this.maskEventsConfigured||(i&&(i.removeEventListener("pointerdown",this.maskPointerDownHandler),i.removeEventListener("pointermove",this.maskPointerMoveHandler),i.removeEventListener("pointerup",this.maskPointerUpHandler),i.removeEventListener("pointercancel",this.maskPointerUpHandler),i.removeEventListener("pointerleave",this.maskPointerLeaveHandler),i.removeEventListener("touchstart",this.touchStartHandler),i.removeEventListener("touchmove",this.touchMoveHandler),i.removeEventListener("touchend",this.touchEndHandler),i.removeEventListener("touchcancel",this.touchEndHandler)),this.removeBrushCursor(),this.maskEventsConfigured=!1)}setMask(t){this.selectMaskVal=t,this.actionController?.getCutout()&&this.actionController.getCutout().setSelectedOption(t)}isPathMode(){return this.actionController?.getCutout()?.isPathMode()??!1}shouldRenderOnMove(){return this.maskDrawIndex%2==0&&!this.isPathMode()}canDrawMask(){return!(this.isCompare||this.aiPhotoService.inProgress||this.photoEditorService.brushSizeDisable?.value||!this.actionController?.getCutout())}onMaskPointerDown(t){if(this.trackTouchPointerDown(t)&&this.canAcceptDrawingInput(t)&&this.canDrawMask()){if(t.preventDefault(),"touch"===t.pointerType)return void this.scheduleTouchDrawVerification(t);this.touchInteractionState="drawing",this.beginMaskDrawingAt(this.getCanvasPointerFromEvent(t)),"pen"===t.pointerType&&this.updateMaskMagnifier(t.clientX,t.clientY,!0);try{t.target?.setPointerCapture?.(t.pointerId)}catch{}}}onMaskPointerMove(t){if("verifying"===this.touchInteractionState&&"touch"===t.pointerType)return this.pendingTouchDraw?.pointerId===t.pointerId&&(this.pendingTouchDraw.clientX=t.clientX,this.pendingTouchDraw.clientY=t.clientY,this.updateMaskMagnifier(t.clientX,t.clientY)),void(this.canAcceptDrawingInput(t)||(this.cancelPendingTouchDraw(),this.blockMaskDrawingForMultiTouch()));if(!this.canAcceptDrawingInput(t))return this.hideBrushCursor(),void(this.maskMouseDown&&"touch"===t.pointerType&&this.cancelActiveDrawing());if(this.onCanvasPointerHover(t),!this.maskMouseDown||!this.canDrawMask())return;t.preventDefault(),this.showReplaceActions=!0;const i=this.getCanvasPointerFromEvent(t);this.addInterpolatedMaskPoint(i.x,i.y),this.processResultOnMove(),("touch"===t.pointerType||"pen"===t.pointerType)&&this.updateMaskMagnifier(t.clientX,t.clientY)}onMaskPointerUp(t){if(this.hideMaskMagnifier(),"verifying"===this.touchInteractionState&&"touch"===t.pointerType&&this.pendingTouchDraw?.pointerId===t.pointerId)return this.cancelPendingTouchDraw(),this.trackTouchPointerUp(t),void this.releasePointerCaptureSafe(t);this.maskMouseDown&&("touch"===t.pointerType&&(this.suppressMaskDrawing||this.activeTouchCount>=2||this.activeTouchPointerIds.size>=2)?this.cancelActiveDrawing():(t.preventDefault(),this.onMaskMouseUp(),"touch"===t.pointerType&&0===this.activeTouchCount&&this.activeTouchPointerIds.size<=1&&(this.touchInteractionState="idle"))),this.trackTouchPointerUp(t),this.releasePointerCaptureSafe(t)}onMaskMouseUp(){this.maskMouseDown&&(this.maskMouseDown=!1,this.lastStrokePoint=null,this.actionController.onMouseUp(),this.processResult())}drawOutputImage(t,i=!1){if(!this.baseFilter||!this.photoEditorMobService.inputImage)return;this.baseFilter.image=t,this.baseFilter.previewMode=this.previewMode?1:0,this.baseFilter.invertMask=0,this.photoEditorService.maskForDownload=t;const o=this.photoEditorMobService.inputImage;o.dirty=!0,o.applyFilters(),i||this.photoEditorMobService.mainCanvas.requestRenderAll(),this.hoverCurs
1or?.bringToFront(),this.updateHasValidMask(t)}processResult(t=!1){const i=this.actionController?.getCutout()?.getSmoothMaskMat();i?.image?this.drawOutputImage(i.image,t):this.hasValidMask=!1}processResultOnMove(){if(this.shouldRenderOnMove()){const t=this.actionController.getCutout().getMaskMat();t?.image&&this.drawOutputImage(t.image)}else if(this.selectMaskVal===T.lh){const t=this.actionController.getCutout().getMaskMat();t?.image&&this.updateHasValidMask(t.image)}this.maskDrawIndex++}updateHasValidMask(t){this.hasValidMask=this.hasMaskContent(t)}hasMaskContent(t){if(!t?.data?.length)return!1;const i=t.data;for(let o=0;o<i.length;o+=4)if(i[o]>0)return!0;return!1}resetMaskDrawing(){this.hideMaskMagnifier(),this.unconfigureMaskCanvasEvents(),this.disconnectCanvasResizeObserver(),this.actionController&&(this.actionController.reset(),this.actionController.delete(),this.actionController=null),this.baseFilter=null,this.maskMouseDown=!1,this.hasValidMask=!1}getQualityTypeFromConfig(){return this.paymentService?.config?.creditInfo?.aireplace||1}onUserPointerAction(){this.hidePresetPanZoomHint()}onUserKeyAction(){this.hidePresetPanZoomHint()}onUserWheelAction(){this.hidePresetPanZoomHint()}showPresetPanZoomHint(){this.hasShownPresetHint||this.isGenerationCompleted||(this.hasShownPresetHint=!0,this.showPresetHint=!0,this.clearPresetHintTimer(),this.presetHintTimeoutId=setTimeout(()=>{this.showPresetHint=!1,this.presetHintTimeoutId=null},5e3))}hidePresetPanZoomHint(){this.showPresetHint&&(this.showPresetHint=!1,this.clearPresetHintTimer())}clearPresetHintTimer(){this.presetHintTimeoutId&&(clearTimeout(this.presetHintTimeoutId),this.presetHintTimeoutId=null)}ngOnDestroy(){this.hideMaskMagnifier(),this.clearTimeInterval(),this.clearPresetHintTimer(),this.clearPendingTouchDrawTimer(),this.progress&&(this.progress.close(),this.progress=null),this.aiPhotoService.clearGenerationProgress(),this.loggedInObserver&&this.loggedInObserver.unsubscribe(),this.usrPropChangedObserver&&this.usrPropChangedObserver.unsubscribe(),this.editorScriptsSub&&this.editorScriptsSub.unsubscribe(),this.backBtnSub&&this.backBtnSub.unsubscribe(),this.paymentSub&&this.paymentSub.unsubscribe(),null!==this.rafGestureId&&(cancelAnimationFrame(this.rafGestureId),this.rafGestureId=null),this.disconnectCanvasResizeObserver(),this.removeBrushCursor(),this.resetMaskDrawing(),this.clearSavedMaskEditorState(),this.resetImage();try{this.photoEditorMobService.destroy()}catch{}this.aiPhotoService.textPrompt=""}touchstart(){this.isCompare=!0,this.hideBrushCursor(),this.hideMaskMagnifier()}touchend(){this.isCompare=!1}onPointerDown(){clearTimeout(this.compareTimeout),this.compareTimeout=setTimeout(()=>{this.isCompare=!0,this.hideBrushCursor(),this.isGenerationCompleted||this.updateOriginalImageTransform()},50)}onPointerUp(){clearTimeout(this.compareTimeout),this.isCompare=!1}nextSlide(t,i,o){t.isShown&&(i?(this.isLast=!1,this.isFirst=!0):o?(this.isFirst=!1,this.isLast=!0):(this.isLast=!1,this.isFirst=!1))}updateCarouselNavigationFlags(){const t=this.aiPhotoService?.aiImages||[];if(t.length<=1)return this.isFirst=!0,void(this.isLast=!0);const i=t.findIndex(r=>String(r.assetId)===String(this.activeId)),o=i>=0?i:t.length-1;this.isFirst=0===o,this.isLast=o===t.length-1}onSlide(t){const i=this.aiPhotoService?.aiImages||[];if(!t||!i.length)return;const o=t.next??t.current;if(!o)return;const r=i.find(l=>String(l.assetId)===String(o));r&&(this.activeId=r.assetId,this.aiPhotoService.imgUrl=r?.urls?.[0]||"",this.photoEditorService.downloadImgUrl=r?.urls?.[0]||"",this.updateCarouselNavigationFlags(),this.carousel&&this.activeId&&this.carousel.select(this.activeId))}download(){if(this.gtmService.pushTag({eventName:y.b.gtm.eventname.aiDownloadMob,itemName:"Editor_Replace"}),this.isGenerationCompleted){const i=this.getActiveDownloadUrl(
1);if(!i)return;this.downloadImageFromUrl(i)}else fetch(this.aiPhotoService.imgUrl).then(i=>{let o="jpg";const r=i.headers.get("Content-Type");r&&r.includes("image/")&&(o=r.split("/")[1]);const l=this.gestureService.exportCanvasIgnoringViewport(this.photoEditorMobService.mainCanvas);l&&this.photoEditorMobService.download(o,f.Fs.replace,"untitled",l)}).catch(i=>{console.error("Error downloading image:",i)})}getActiveDownloadUrl(){if(this.carousel?.activeId){const t=this.aiPhotoService?.aiImages?.find(i=>String(i.assetId)===String(this.carousel.activeId));if(t?.urls?.[0])return t.urls[0]}return this.photoEditorService.downloadImgUrl||this.aiPhotoService.imgUrl||""}downloadImageFromUrl(t){t.startsWith("data:")||t.startsWith("blob:")?this.photoEditorMobService.download("jpg",f.Fs.replace,"untitled",t):fetch(t).then(i=>{let o="jpg";const r=i.headers.get("Content-Type");return r&&r.includes("image/")&&(o=r.split("/")[1]),i.blob().then(l=>({blob:l,imgType:o}))}).then(({blob:i,imgType:o})=>{const r=URL.createObjectURL(i);this.photoEditorMobService.download(o,f.Fs.replace,"untitled",r),setTimeout(()=>URL.revokeObjectURL(r),1e3)}).catch(i=>{console.error("Error downloading image:",i)})}setScaleVar(){if(!this.inputImage||!this.photoEditorMobService.mainCanvas)return;const t=document.getElementById("canvasWrapper");if(!t)return;const i=t.getBoundingClientRect(),o=Math.min(i.height/this.inputImage.height,i.width/this.inputImage.width);this.scale=o,this.initialScale=o,this.originalImg?.nativeElement&&(this.originalImg.nativeElement.style.width=`${this.inputImage.width}px`,this.originalImg.nativeElement.style.height=`${this.inputImage.height}px`,this.originalImg.nativeElement.style.transformOrigin="0 0"),this.compareContainer?.nativeElement&&(this.compareContainer.nativeElement.style.width=`${this.photoEditorMobService.mainCanvas.width}px`,this.compareContainer.nativeElement.style.height=`${this.photoEditorMobService.mainCanvas.height}px`),this.comparePreviewContainer?.nativeElement&&(this.comparePreviewContainer.nativeElement.style.width="100%",this.comparePreviewContainer.nativeElement.style.height="100%"),this.updateBrushCursorSize()}clampPan(){const t=this.photoEditorMobService.mainCanvas.getZoom(),i=this.photoEditorMobService.mainCanvas.getWidth(),o=this.photoEditorMobService.mainCanvas.getHeight(),r=this.photoEditorMobService.mainCanvas.viewportTransform,l=this.photoEditorMobService.mainCanvas.getObjects("image")[0];if(!l)return;const c=l.width*l.scaleX*t,d=l.height*l.scaleY*t;let h=r[4],p=r[5];h=c<=i?(i-c)/2:Math.min(0,Math.max(i-c,h)),p=d<=o?(o-d)/2:Math.min(0,Math.max(o-d,p)),r[4]=h,r[5]=p,this.photoEditorMobService.mainCanvas.setViewportTransform(r)}setZoomPinch(){const t=document.getElementById("canvas-mask-wrapper");!t||!this.mainCanvas?.nativeElement||(t.style.touchAction="none",this.mainCanvas.nativeElement.style.touchAction="none")}onFileUploaded(t){if(!t.length)return;const i=t[0];i.type.includes("image")&&(this.resetMaskDrawing(),this.clearSavedMaskEditorState(),this.resetImage(),this.aiPhotoService.imgUrl=URL.createObjectURL(i),this.preGenerationCanvasUrl=this.aiPhotoService.imgUrl,this.loadInputImage())}resetImage(){this.photoEditorMobService.mainCanvas&&this.initialViewport&&(this.photoEditorMobService.mainCanvas.setViewportTransform([...this.initialViewport]),this.scale=this.photoEditorMobService.mainCanvas.getZoom(),this.photoEditorMobService.mainCanvas.requestRenderAll())}updateOriginalImageTransform(){const t=this.photoEditorMobService.mainCanvas.getZoom(),i=this.photoEditorMobService.mainCanvas.viewportTransform,l=`matrix(${t}, 0, 0, ${t}, ${i[4]}, ${i[5]})`;this.originalImg?.nativeElement&&(this.originalImg.nativeElement.style.transform=l),this.originalPreviewImg?.nativeElement&&(this.originalPreviewImg.nativeElement.style.transform="none")}focusIn(){document.body.classList.add("overflow-hidden"),this.isFocused=!0,setTimeout(()=>{this.cpText&&this.cpText.nativeElement.focus()},100),this.intervalSub&&this.intervalSub.unsubscribe();const t=(i=0)=>{setTimeout(()=>{this.cpText&&(this.cpText.nativeElement.placeholder=""),i<2&&(i++,t(i))},500)};t()}focusOut(){document.body.classList.remove("overflow-hidden"),this.isFocused=!1,this.intervalSub&&this.intervalSub.unsubscribe(),2==this.step&&!this.aiPhotoService.textPrompt&&this.prompts?.length&&setTimeout(()=>{this.cpText&&(this.cpText.nativeElement.placeholder=this.prompts&&this.prompts.length?this.prompts[0].prompt:"")},500)}onEnter(t){this.cpText.nativeElement.blur()}changePrompt(){this.disabled=!this.aiPhotoService.textPrompt.trim()}onPaste(t){setTimeout(()=>{this.aiPhotoService.textPrompt=t.target.value,this.changePrompt()},0)}applyImage(){if(this.aiPhotoService.textPrompt=this.cpText?.nativeElement?.value??this.aiPhotoService.textPrompt,this.changePrompt(),this.aiPhotoService.textPrompt?.trim()){if(!this.hasValidMask)return void this.toastService.showError("Please draw a mask on the image before generating.");if(!(this.user&&this.user.remainingCoins>
1=this.qualityType))return this.step=1,void this.aiPhotoService.loginAndAICredit(()=>{this.user=this.authService.currentUser(),this.user&&this.user.remainingCoins>=this.qualityType?this.applyImage():this.user&&(this.step=3)});this.runApplyImage()}}runApplyImage(){var t=this;return(0,w.A)(function*(){t.clearTimeInterval(),t.aiPhotoService.startGenerationProgress({featureType:t.featureType});const i=new Date;try{t.saveMaskEditorStateBeforeApply(),t.setGenerationPreview(!1),t.inputs?.mask||(yield t.prepareMaskAndUpload()),t.aiUploadImageService.generateImageWithMaskReplace(t.inputImageUrl,t.inputs.mask,t.aiPhotoService.textPrompt,t.qualityType,o=>{o&&o.assetId?t.checkStatus(o,0,function(){var r=(0,w.A)(function*(l){if(t.aiPhotoService.processingProgress.isActive||t.aiPhotoService.inProgress||t.aiPhotoService.inVideoProgress)if(l.urls&&l.urls.length>0){const c=[];for(let d=0;d<l.urls.length;d++){const h=yield t.mergeOutput(t.inputs.param,l.urls[d],t.inputs.maskImageData);c.push({assetId:l.urls.length>1?`${o.assetId}-${d}`:o.assetId,urls:[h],thumbUrl:h,outputImgUrl:h,prompt:t.aiPhotoService.textPrompt})}t.aiPhotoService.completeGenerationProgress(()=>{const d=c[c.length-1].urls[0];t.aiPhotoService.imgUrl=d,t.photoEditorService.downloadImgUrl=d,t.user&&(t.user.remainingCoins=l.remainingCalls),t.aiPhotoService.aiImages||(t.aiPhotoService.aiImages=[]),t.aiPhotoService.aiImages.push(...c),t.activeId=c[c.length-1].assetId,t.updateCarouselNavigationFlags(),t.setGenerationPreview(!0),t.aiPhotoService.isDirty=!0,setTimeout(()=>{t.carousel&&t.activeId&&t.carousel.select(t.activeId),t.updateCarouselNavigationFlags()},0)})}else t.setGenerationPreview(!1),t.displayErrorMsg({description:y.b.message.somethingWrong},i)});return function(l){return r.apply(this,arguments)}}(),r=>{t.setGenerationPreview(!1),t.displayErrorMsg(r,i)}):(t.setGenerationPreview(!1),t.displayErrorMsg(o,i))},t.inputs.scaleFActor)}catch{t.setGenerationPreview(!1),t.displayErrorMsg(null,i)}})()}prepareMaskAndUpload(){var t=this;return(0,w.A)(function*(){const o=t.actionController.getCutout().getSmoothMaskMat().image,r=t.photoEditorMobService.theOriginalOriginalImage;if(!r)throw new Error("Original image not loaded");t.theOriginal2KImageParam=t.resizeImageInResolution(r);const l=t.theOriginal2KImageParam.scaledWidth;if(t.newMaskImageData=t.photoEditorService.upScaleByResizeFilter(l,t.theOriginal2KImageParam.scaledHeight,l/o.width,o),t.inputs=yield t.prepareAPIInputImage(),!t.inputs?.mask||!t.inputs?.inputImage)throw new Error("Invalid mask region");t.inputImageUrl=yield t.aiUploadImageService.aiReplaeUploadImage(t.inputs.inputImage)})()}prepareAPIInputImage(){var t=this;return(0,w.A)(function*(){const i=t.newMaskImageData,o=t.trimCanvas(i,i.width,i.height,!0);let r=i.width<o.oneSide?o.oneSide:i.width,l=i.height<o.oneSide?o.oneSide:i.height;o.left+o.oneSide>i.width&&(o.left=i.width-o.oneSide),o.left<0&&(o.left=0),o.top+o.oneSide>i.height&&(o.top=i.height-o.oneSide),o.top<0&&(o.top=0);const c=I.fabric.util.createCanvasElement(),d=c.getContext("2d");if(c.width=r,c.height=l,d.fillRect(0,0,r,l),d.putImageData(i,0,0),o.oneSide<=0&&o.left<=0&&o.top<=0)return{mask:null,inputImage:null,scaleFActor:1,param:{left:0,top:0,oneSide:1},maskImageData:null};const h=d.getImageData(o.left,o.top,o.oneSide,o.oneSide),p=yield t.imageDataToBlob(h,"image/png"),u=I.fabric.util.createCanvasElement(),g=t.theOriginal2KImageParam.scaledWidth,_=t.theOriginal2KImageParam.scaledHeight;u.width=g,u.height=_;const v=new I.fabric.StaticCanvas(u,{enableRetinaScaling:!1}),C=t.photoEditorMobService.theOriginalOriginalImage,M=new I.fabric.Image(C);M.set({scaleX:g/C.width,scaleY:_/C.height}),v.add(M),v.renderAll();const k=v.getContext().getImageData(o.left,o.top,o.oneSide,o.oneSide);return{mask:p,inputImage:yield t.imageDataToBlob(k,"image/jpeg"),scaleFActor:k.width/512,param:o,maskImageData:h}})()}imageDataToBlob(t,i){return new Promise(o=>{const r=I.fabric.util.createCanvasElement(),l=r.getContext("2d");r.width=t.width,r.height=t.height,l.putImageData(t,0,0);const c=I.fabric.util.createCanvasElement();let d=0,h=0;r.width<512?(d=512,h=512):r.width>1024?(d=1024,h=1024):(d=r.width,h=r.height),c.width=d,c.height=h;const p=new I.fabric.StaticCanvas(c,{enableRetinaScaling:!1}),u=new I.fabric.Image(r);u.set({scaleX:d/r.width,scaleY:h/r.height}),p.add(u),p.renderAll(),c.toBlob(g=>{o(g)},i)})}
1mergeOutput(t,i,o){return new Promise(r=>{I.fabric.Image.fromURL(i,l=>{const c=new Xe.Y,d=new this.f.CutoutFilter({image:null,adjustment:c.adjustedValues}),h=this.imageResize(l,o.width);d.image=o,d.previewMode=1,d.invertMask=0,h.filters.push(d),h.set({left:t.left,top:t.top});const p=this.theOriginal2KImageParam.scaledWidth,u=this.theOriginal2KImageParam.scaledHeight,g=I.fabric.util.createCanvasElement();g.width=p,g.height=u;const _=this.photoEditorMobService.theOriginalOriginalImage,v=new I.fabric.Image(_,{scaleX:p/_.width,scaleY:u/_.height}),C=new I.fabric.StaticCanvas(g,{enableRetinaScaling:!1});C.add(v),C.add(h),h.applyFilters(),C.renderAll(),g.toBlob(M=>{r(URL.createObjectURL(M))},"image/png")},{crossOrigin:"anonymous"})})}imageResize(t,i){const o=I.fabric.util.createCanvasElement();o.width=i,o.height=i;const r=new I.fabric.StaticCanvas(o,{enableRetinaScaling:!1});return t.set({left:0,top:0,scaleX:i/t.width,scaleY:i/t.height}),r.add(t),r.renderAll(),new I.fabric.Image(o,{left:0,top:0})}trimCanvas(t,i,o,r=!1){const l=t.data.length,c={top:null,left:null,right:null,bottom:null};let d=0,h=!1,p=0,u=0,g=!1,_=0;const v=i/T.ms,C=o/T.HI,k=5*(v>C?v:C);let j=0,G=0,U=!1,F=!1;for(let oe=r?-1:0;oe<l;oe+=4){const le=oe/4%i,te=~~(oe/4/i);j!==te&&(j=te,F=!1),t.data[oe+3]>128?(G!==te?(G=te,U=!0):U=!1,F=!0,null===c.top?(c.top=te,u=1):!g&&U&&(c.top+u!==te?(c.top=te,u=1):u>
1=k?g=!0:u++),null===c.left||le<c.left?(c.left=le,d=1):h||(c.left+d!==le?(c.left=le,d=1):d>=k?h=!0:d++),null===c.right?(c.right=le,p=1):(c.right<le&&p>=k&&(c.right=le),p++),null===c.bottom||c.bottom<te&&_>=k&&U?(c.bottom=te,_++):U&&_++):(p=0,le-1===i&&!F&&(_=0))}const B=c.bottom-c.top,Ve=c.right-c.left;let Re=0,Fe=0,X=0;if(B>Ve){X=B;let oe=.2*X;if(X+=oe,X>512&&X<1024){const te=8-X%8;X+=te,oe+=te}Fe=c.top-oe/2,Re=c.left+Ve/2-X/2}else{X=Ve;let oe=.2*X;if(X+=oe,X>512&&X<1024){const te=8-X%8;X+=te,oe+=te}Re=c.left-oe/2,Fe=c.top+B/2-X/2}return{left:Math.floor(Re),top:Math.floor(Fe),oneSide:Math.floor(X)}}checkStatus(t,i=0,o=null,r=null){const l=t.avgResponseTimeInSec/t.maxRetriesAllowed*1e3;this.aiUploadImageService.checkStatus(t.assetId,c=>{const d=c.body;d&&"active"===d.status?(this.authService.updateUserAiConis("20"),o&&o(d)):d&&"init"===d.status?i<t.maxRetriesAllowed?setTimeout(()=>{this.checkStatus(t,++i,o,r)},l):(d.inQueue=!0,this.displayQueueMsg(()=>{this.checkStatus(t,0,o,r)})):d&&("failed"===d.status||"fail"===d.status.toLowerCase())&&r&&r(d)},c=>{r&&r(c)})}displayQueueMsg(t=null){this.dialogService.open({okButtonText:y.b.message.okTryAgainButtonText,title:y.b.message.aiCreationInQueueLabel,message:y.b.message.aiCreationInQueueMsg},()=>{t&&t()},()=>{})}closeProgress(t){this.aiPhotoService.completeGenerationProgress()}clearTimeInterval(){this.interValId&&clearInterval(this.interValId),this.interValId1&&clearInterval(this.interValId1)}displayErrorMsg(t=null,i=null){const o=t?.description||y.b.message.somethingWrong;this.aiPhotoService.clearGenerationProgress(),this.createPopupService.openWarningDialog("Error",o)}resizeImageInResolution(t,i=2073600){const r=Math.sqrt(t.width*t.height/i);let l=t.width,c=t.height;return r>1&&(l=Math.floor(l/r),c=Math.floor(c/r)),l=l%2==1?l-1:l,c=c%2==1?c-1:c,{scaledWidth:l,scaledHeight:c}}addCredit(){this.step=1,this.aiGenService.aiCreditPlanCheckout({toolName:"replace"},()=>{})}}return(s=a).\u0275fac=function(t){return new(t||s)(e.rXU(Z.s),e.rXU(q.u),e.rXU(be),e.rXU(b.aZ),e.rXU(Q.f),e.rXU(re),e.rXU(Ne.p),e.rXU(me.X),e.rXU(ae.g),e.rXU(Ce.u),e.rXU(ie.y),e.rXU(ve),e.rXU($t.n),e.rXU(ee.M),e.rXU(ne.A),e.rXU(J.K),e.rXU(de.W),e.rXU(e.SKi))},s.\u0275cmp=e.VBU({type:s,selectors:[["ai-replace"]],viewQuery:function(t,i){if(1&t&&(e.GBs(td,5),e.GBs(id,5),e.GBs(nd,5),e.GBs(od,7),e.GBs(Le,7),e.GBs(sd,5),e.GBs(rd,5),e.GBs(ad,5),e.GBs(ld,5),e.GBs(cd,5)),2&t){let o;e.mGM(o=e.lsd())&&(i.cpText=o.first),e.mGM(o=e.lsd())&&(i.contentBox=o.first),e.mGM(o=e.lsd())&&(i.fileInput=o.first),e.mGM(o=e.lsd())&&(i.mainCanvas=o.first),e.mGM(o=e.lsd())&&(i.maskMagnifier=o.first),e.mGM(o=e.lsd())&&(i.originalImg=o.first),e.mGM(o=e.lsd())&&(i.compareContainer=o.first),e.mGM(o=e.lsd())&&(i.originalPreviewImg=o.first),e.mGM(o=e.lsd())&&(i.comparePreviewContainer=o.first),e.mGM(o=e.lsd())&&(i.carousel=o.first)}},hostBindings:function(t,i){1&t&&e.bIt("pointerdown",function(){return i.onUserPointerAction()},!1,e.EBC)("keydown",function(){return i.onUserKeyAction()},!1,e.EBC)("wheel",function(){return i.onUserWheelAction()},!1,e.EBC)},inputs:{featureType:"featureType",imageUrl:"imageUrl",minZoom:"minZoom",maxZoom:"maxZoom"},outputs:{changeStep:"changeStep"},features:[e.Jv_([Ce.u,re,Ie.r,Ne.p])],decls:30,vars:31,consts:[["mainCanvas",""],["carousel",""],["comparePreviewContainer",""],["file",""],["originalPreviewImg",""],["cpText",""],[1,"mobileRetouch","overflow-hidden","d-flex","flex-column","h-100"],[1,"drawer-elements","ai-drawer-elements","overflow-hidden","d-flex","flex-column","flex-grow-1","h-100","min-h-0"],[1,"d-flex","align-items-center","justify-content-center","overflow-hidden","w-100","flex-column","pt-9","ps-3","pe-3","border-radius-12","position-relative","replace-canvas-area","flex-grow-1",3,"ngClass"],["id","canvasWrapper",1,"d-flex","align-items-center","justify-content-center","overflow-hidden","w-100","flex-column","h-100"],["id","canvas-mask-wrapper",1,"d-flex","align-items-center","justify-content-center","overflow-hidden","border-radius-12","position-relative","h-100","bg-grey3","w-100",2,"overflow","auto"],["
1id","vmx-canvas","height","100%","width","100%","disableRC","",1,"position-relative",3,"ngClass"],["class","replace-brush-cursor",3,"replace-brush-cursor--brush","replace-brush-cursor--erase","ngStyle",4,"ngIf"],[3,"diameter","zoomDeltaMultiplier"],["class","preset-pan-zoom-hint text-12 text-semi text-white bg-primary position-absolute border-radius-20 d-inline-flex align-items-center",4,"ngIf"],["class","flex-shrink-0",4,"ngIf"],[1,"d-flex","align-items-center","justify-content-center","overflow-hidde","w-100","flex-column","pt-3","ps-3","pe-3","border-radius-12","position-relative","replace-canvas-area","flex-grow-1",3,"ngClass"],[1,"d-flex","align-items-center","justify-content-start","overflow-hidde","h-100","w-100","ngb-carousel","border-radius-12","bg-grey3","position-relative"],[1,"h-100","border-radius-12","w-100",3,"slide","activeId","wrap","interval","ngClass"],[4,"ngFor","ngForOf"],[1,"mw-100","mh-100","w-100","h-100","position-absolute","top-0","start-0",2,"overflow","hidden",3,"ngClass"],[1,"res-round","h-100","w-100"],["disableRC","","class","w-100 h-100",3,"src",4,"ngIf"],["class","d-flex align-items-center justify-content-center position-absolute hw-40 border-radius-50 btn-alpha","style","top: 8px; right: 8px;z-index: 99;",3,"click",4,"ngIf"],[1,"d-flex","align-items-center","justify-content-center","position-absolute","hw-40","border-radius-50","btn-alpha",2,"bottom","8px","left","24px","z-index","99"],[1,"btn","d-flex","align-items-center","justify-content-center","border-0",3,"pointerdown","pointerup","pointercancel","pointerleave"],["name","comparewhite",1,"f-24","text-white"],["class","w-100 pt-3 ps-3 pe-3 flex-shrink-0",4,"ngIf"],[4,"ngIf"],["id","fileInput","name","fileInput","type","file",1,"custom-file-input","n-show","d-none",3,"click","change","accept","multiple"],[1,"replace-brush-cursor",3,"ngStyle"],[1,"preset-pan-zoom-hint","text-12","text-semi","text-white","bg-primary","position-absolute","border-radius-20","d-inline-flex","align-items-center"],["name","dragImageOpen",1,"f-24"],[1,"flex-shrink-0"],[1,"replace-mask-tools","w-100","replace-bottom-content"],[1,"d-flex","flex-column","w-100","mobileRetouchStyle"],[1,"card-body","pt-10","ps-3","pe-3"],[1,"text-13","grey-800","text-semi"],[1,"d-flex"],[1,"wp-100","d-flex","align-items-center"],["style","width:100%","class","opacity-slider",3,"min","max","step","value","change","slideStart","slideStop",4,"ngIf"],["type","range","class","replace-brush-range w-100","min","5","max","100","step","1",3,"value","input","change","touchstart","touchend",4,"ngIf"],[1,"ms-3"],["type","text","maxlength","3","disabled","",1,"form-control","form-input-sm","text-normal","text-black",2,"pointer-events","none",3,"ngModel"],["class","d-flex flex-column align-items-center justify-content-center text-normal text-dark lh-125 replace-hint-area",4,"ngIf"],[1,"opacity-slider",2,"width","100%",3,"change","slideStart","slideStop","min","max","step","value"],["type","range","min","5","max","100","step","1",1,"replace-brush-range","w-100",3,"input","change","touchstart","touchend","value"],[1,"d-flex","flex-column","align-items-center","justify-content-center","text-normal","text-dark","lh-125","replace-hint-area"],[1,"d-flex","flex-column","align-items-center","justify-content-center"],[1,"d-flex","flex-column","align-items-center","justify-content-center","replace-tools-area","w-100","ps-3","pe-3","pt-3"],["type","button",1,"replace-tool-btn","border-0","bg-transparent",3,"click","ngClass"],["name","dooledraw",1,"f-24"],[1,"text-12","text-semi","mt-1"],["type","button",1,"replace-tool-btn","border-0","bg-transparent","ms-4",3,"click","ngClass"],["name","dooleerase",1,"f-24"],[1,"w-100","pt-3"],[1,"replace-prompt-trigger","w-100","d-flex","align-items-center",3,"click"],["name","promptedit",1,"f-20","grey-500","me-2"],["type","text","placeholder","Add prompt","readonly","",1,"replace-prompt-input-field","text-13","text-medium","w-100","border-0","text-truncate",3,"focus","value"],[1,"w-100","pt-3","ps-3","pe-3"],[1,"btn","btn-primary-gradient","btn-primary-m","btn-h44","w-100","d-flex","align-items-center","justify-content-center",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,"text-11","text-semi",2,"padding-left","2px"],["ngbSlide","",3,"slid","id"],[1,"d-flex","overflow-hidden","w-100","flex-column","align-items-center","justify-content-center","h-100"],[1,"res-round","h-100"],["class","w-100 h-100","height","","width","",3,"src",4,"ngIf"],["height","","width","",1,"w-100","h-100",3,"src"],["disableRC","",1,"w-100","h-100",3,"src"],[1,"d-flex","align-items-center","justify-content-center","position-absolute","hw-40","border-radius-50","btn-alpha",2,"top","8px","right","8px","z-index","99",3,"click"],["name","downloadblack",1,"f-24","text-white"],[1,"w-100","pt-3","ps-3","pe-3","flex-shrink-0"],[1,"p-3","pt-9","pb-9","position-fixed","bg-white","w-100","replace-prompt-sheet",2,"bottom","0px","z-index","9999","border-radius","20px 20px 0px 0px"],[1,"wp-100","d-flex","align-items-center","justify-content-between"],[1,"text-lg","text-semi","grey-800"],["name","previewclose",3,"click"],[1,"card","drawer-card","mt-3","mb-0"],[1,"card-body"],[1,"btn-panel"],[1,"card-body","prompt-view"],[1,"textarea-col",3,"ngClass"],["
1id","cprompt","name","cprompt","rows","4","cols","50",1,"prompt-text",3,"ngModelChange","keyup","paste","focus","blur","keydown.enter","maxlength","ngModel"],["class","prompt-info prompt-info-span text-regular position-relative d-flex align-items-center h-24",4,"ngIf"],[1,"d-flex","align-items-center","justify-content-center","w-100","mt-3"],[1,"showpreview-overlay","align-items-center","justify-content-start","position-fixed","d-flex",3,"click"],[1,"prompt-info","prompt-info-span","text-regular","position-relative","d-flex","align-items-center","h-24"],[3,"close","addCredit","consumeCoins"]],template:function(t,i){if(1&t){const o=e.RV6();e.j41(0,"div",6)(1,"div",7)(2,"div",8)(3,"div",9)(4,"div",10)(5,"canvas",11,0),e.EFF(7," Your browser does not support the HTML5 canvas tag. "),e.k0s(),e.DNE(8,md,1,7,"div",12),e.nrm(9,"mobile-mask-magnifier",13),e.k0s()(),e.DNE(10,ud,4,0,"div",14),e.k0s(),e.DNE(11,Cd,2,1,"div",15),e.j41(12,"div",16)(13,"div",17)(14,"ngb-carousel",18,1),e.bIt("slide",function(l){return e.eBV(o),e.Njj(i.onSlide(l))}),e.DNE(16,Id,1,1,null,19),e.k0s(),e.j41(17,"div",20,2)(19,"div",21),e.DNE(20,yd,2,1,"img",22),e.k0s()(),e.DNE(21,wd,2,0,"div",23),e.k0s(),e.j41(22,"div",24)(23,"button",25),e.bIt("pointerdown",function(){return e.eBV(o),e.Njj(i.onPointerDown())})("pointerup",function(){return e.eBV(o),e.Njj(i.onPointerUp())})("pointercancel",function(){return e.eBV(o),e.Njj(i.onPointerUp())})("pointerleave",function(){return e.eBV(o),e.Njj(i.onPointerUp())}),e.nrm(24,"pi",26),e.k0s()()(),e.DNE(25,Sd,8,2,"div",27),e.k0s()(),e.DNE(26,kd,20,11,"ng-container",28)(27,Td,2,1,"ng-container",28),e.j41(28,"input",29,3),e.bIt("click",function(){e.eBV(o);const l=e.sdS(29);return e.Njj(l.value="")})("change",function(l){return e.eBV(o),e.Njj(i.onFileUploaded(l.srcElement.files))}),e.k0s()}2&t&&(e.R7$(2),e.Y8G("ngClass",e.eq3(21,ct,i.isGenerationCompleted)),e.R7$(3),e.Y8G("ngClass",e.eq3(23,ct,i.isCompare)),e.R7$(3),e.Y8G("ngIf",i.showBrushCursorPreview),e.R7$(),e.Y8G("diameter",80)("zoomDeltaMultiplier",1.5),e.R7$(),e.Y8G("ngIf",i.showPresetHint),e.R7$(),e.Y8G("ngIf",!i.isGenerationCompleted),e.R7$(),e.Y8G("ngClass",e.eq3(25,ct,!i.isGenerationCompleted)),e.R7$(2),e.Y8G("activeId",i.activeId)("wrap",!1)("interval",0)("ngClass",e.sMw(27,dd,(null==i.aiPhotoService?null:i.aiPhotoService.aiImages)&&(null==i.aiPhotoService?null:i.aiPhotoService.aiImages.length)<=1,i.isFirst,i.isLast)),e.R7$(2),e.Y8G("ngForOf",null==i.aiPhotoService?null:i.aiPhotoService.aiImages),e.R7$(),e.Y8G("ngClass",i.isCompare?"d-flex":"d-none"),e.R7$(3),e.Y8G("ngIf",i.photoEditorMobService.originalImage),e.R7$(),e.Y8G("ngIf",i.isLoaded&&i.isGenerationCompleted),e.R7$(4),e.Y8G("ngIf",i.isGenerationCompleted&&!i.aiPhotoService.inProgress),e.R7$(),e.Y8G("ngIf",2==i.step),e.R7$(),e.Y8G("ngIf",3==i.step),e.R7$(),e.Y8G("accept","image/*")("multiple",!1))},dependencies:[b.YU,b.Sq,b.bT,b.B3,Me.G,R.Oj,R.bD,P.me,P.BC,P.tU,P.vS,H.b,O.d1,pe,Le,Pe.m],styles:['.compare-stack[_ngcontent-%COMP%]   img[_ngcontent-%COMP%]{width:100%;object-fit:contain}.mobileRetouch[_ngcontent-%COMP%]{flex:1 1 auto;height:100%;min-height:0;overflow:hidden;padding-bottom:4px}
1.drawer-elements[_ngcontent-%COMP%]{flex:1 1 auto;min-height:0}.res-round[_ngcontent-%COMP%]{overflow:hidden;display:flex;justify-content:center;align-items:center;margin:0 auto}.res-round[_ngcontent-%COMP%]   img[_ngcontent-%COMP%]{width:100%;height:100%;max-width:100%;max-height:100%;object-fit:contain}.replace-mobile-layout[_ngcontent-%COMP%]{height:calc(100vh - 52px);height:calc(100dvh - 52px)}.replace-canvas-area[_ngcontent-%COMP%]{flex:1 1 0;min-height:0}.replace-bottom-content[_ngcontent-%COMP%]{flex:0 0 auto}.replace-hint-area[_ngcontent-%COMP%]{height:194px}.preset-pan-zoom-hint[_ngcontent-%COMP%]{left:50%;top:calc(50% - 22px);transform:translate(-50%);padding:8px 12px 8px 8px;z-index:6;gap:8px;white-space:nowrap}.hint-icon[_ngcontent-%COMP%]{width:20px;height:20px;border-radius:50%;background:#ffffff29;font-size:16px;font-weight:700}#canvas-mask-wrapper[_ngcontent-%COMP%]   .replace-brush-cursor[_ngcontent-%COMP%]{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);pointer-events:none;z-index:5;width:102px;height:102px;border-radius:16px;box-sizing:border-box;transition:background-color .15s ease,border-color .15s ease;display:flex;align-items:center;justify-content:center;flex-shrink:0}#canvas-mask-wrapper[_ngcontent-%COMP%]   .replace-brush-cursor[_ngcontent-%COMP%]:after{content:"";width:var(--brush-inner-size);height:var(--brush-inner-size);border-radius:99px}#canvas-mask-wrapper[_ngcontent-%COMP%]   .replace-brush-cursor--brush[_ngcontent-%COMP%]{background:#ffffffb3;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px)}#canvas-mask-wrapper[_ngcontent-%COMP%]   .replace-brush-cursor--brush[_ngcontent-%COMP%]:after{background:#f75b5b}#canvas-mask-wrapper[_ngcontent-%COMP%]   .replace-brush-cursor--erase[_ngcontent-%COMP%]{background:#ffffffb3;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px)}#canvas-mask-wrapper[_ngcontent-%COMP%]   .replace-brush-cursor--erase[_ngcontent-%COMP%]:after{background:#f75b5b}.replace-bottom-panel[_ngcontent-%COMP%]{flex:0 0 auto;width:100%;padding-top:12px;padding-bottom:12px}.replace-mask-tools[_ngcontent-%COMP%]   .mobileRetouchStyle[_ngcontent-%COMP%]{display:flex;width:100%}.replace-mask-tools[_ngcontent-%COMP%]   .opacity-slider[_ngcontent-%COMP%]{width:100%;min-height:24px;display:block}.replace-mask-tools[_ngcontent-%COMP%]   .opacity-slider[_ngcontent-%COMP%]   .slider[_ngcontent-%COMP%]{width:100%!important}.replace-mask-tools[_ngcontent-%COMP%]   .opacity-slider[_ngcontent-%COMP%]   .slider-horizontal[_ngcontent-%COMP%]{width:100%!important;height:20px}.replace-mask-tools[_ngcontent-%COMP%]   .replace-brush-range[_ngcontent-%COMP%]{height:20px;accent-color:#626ADF}.replace-tool-btn[_ngcontent-%COMP%]{width:62px;height:62px;border-radius:12px;color:#959aa7;padding:0}.replace-tool-btn[_ngcontent-%COMP%]   span[_ngcontent-%COMP%]{color:#959aa7}.replace-tool-btn--active[_ngcontent-%COMP%]{color:#626adf;background:#626adf1a}.replace-tool-btn--active[_ngcontent-%COMP%]   span[_ngcontent-%COMP%]{color:#626adf}.replace-prompt-trigger[_ngcontent-%COMP%]{height:40px;border-radius:12px;background:linear-gradient(90deg,#fc5cff05 -4%,#2520f605);border:1px solid #E2E3E9!important;padding:0 8px 0 4px;text-align:left}.replace-prompt-input-field[_ngcontent-%COMP%]{background:transparent;outline:none;cursor:pointer;color:#272b34}.replace-prompt-input-field[_ngcontent-%COMP%]::placeholder{color:#606576}.disable[_ngcontent-%COMP%]{display:none}.btn[_ngcontent-%COMP%]:disabled   .coin-count[_ngcontent-%COMP%]{background:#0000001a}.btn[_ngcontent-%COMP%]:disabled   .coin-count[_ngcontent-%COMP%]   b[_ngcontent-%COMP%]{color:#fff!important}.btn[_ngcontent-%COMP%]:disabled   .inable[_ngcontent-%COMP%]{display:none}.btn[_ngcontent-%COMP%]:disabled   .disable[_ngcontent-%COMP%]{display:block}.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}.coin-count[_ngcontent-%COMP%]   b[_ngcontent-%COMP%]{color:#fff!important}@media screen and (max-height: 740px){.text-56[_ngcontent-%COMP%]{font-size:48px!important;line-height:58px!important}}@media screen and (max-height: 640px){.text-56[_ngcontent-%COMP%]{font-size:40px!important;line-height:50px!important}}@media screen and (max-height: 540px){.text-56[_ngcontent-%COMP%]{font-size:30px!important;line-height:40px!important}}.content-box[_ngcontent-%COMP%]{transition:opacity .5s ease,transform .5s ease}.content-box.in[_ngcontent-%COMP%]{opacity:1;transform:translate(0)}.content-box.out[_ngcontent-%COMP%]{opacity:0;transform:translate(-50px)}.full-screen-container[_ngcontent-%COMP%]{display:flex;height:100vh}.left-column[_ngcontent-%COMP%], .right-column[_ngcontent-%COMP%]{flex:1;height:100%;overflow:auto}.left-column[_ngcontent-%COMP%]{background-color:#f5f5f5}.right-column[_ngcontent-%COMP%]{background-color:#e0e0e0}.reseticon-none[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]{opacity:.3}.showpreview-overlay[_ngcontent-%COMP%]{position:fixed;right:0;left:0;background:#0003;-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);z-index:2;width:100%;height:100%;top:0;bottom:0}.prompt-view[_ngcontent-%COMP%]   .textarea-col[_ngcontent-%COMP%]{width:100%;height:188px;border-radius:12px;background:#eeedf3;padding:4px;border:0px!important}.prompt-view[_ngcontent-%COMP%]   .textarea-col[_ngcontent-%COMP%]:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:12px;padding:.92px;border:none;background:linear-gradient(90deg,#c9cad4 -4% 100%);-webkit-mask:linear-gradient(90deg,#C9CAD4 -4%,#C9CAD4 100%) content-box,linear-gradient(90deg,#C9CAD4 -4%,#C9CAD4 100%);-webkit-mask-composite:xor;mask-composite:exclude;z-index:1}.prompt-view[_ngcontent-%COMP%]   .textarea-col[_ngcontent-%COMP%]:hover{border:1px solid #B0B3BF}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]{resize:none;outline:none;width:100%;height:148px;padding:8px;font-size:13px;color:#b0b3bf;border:0px;background:transparent;border-radius:12px;line-height:18px;overflow:auto;position:relative;z-index:2;line-height:125%}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]::-webkit-scrollbar{width:4px;height:4px;border-radius:12px}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]::-webkit-scrollbar-track{background:#e3e3e3;border-radius:12px;margin-top:8px}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background:#9a9a9a;border-radius:12px}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]::-webkit-scrollbar-thumb:hover{background:#555}.prompt-view[_ngcontent-%COMP%]   .prompt-info[_ngcontent-%COMP%]{font-size:11px;color:#b0b3bf;margin-top:0;padding-left:8px;line-height:140%}.prompt-text[_ngcontent-%COMP%]{color:#272b34!important}.info-up[_ngcontent-%COMP%]{border:1px solid #B0B3BF!important;background:#eeedf3!important}.info-blue[_ngcontent-%COMP%]{background:linear-gradient(90deg,#fc5cff0d -4%,#2520f60d)!important}.info-blue[_ngcontent-%COMP%]:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:12px;padding:.92px;border:none;background:linear-gradient(90deg,#fc5cff -4%,#2520f6)!important;-webkit-mask:linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%) content-box,linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%)!important;-webkit-mask-composite:xor!important;mask-composite:exclude!important;z-index:1}.info-blue[_ngcontent-%COMP%]   span[_ngcontent-%COMP%]{color:#626adf!important}.info-red[_ngcontent-%COMP%]{background:linear-gradient(90deg,#fc5cff0d -4%,#2520f60d)!important}.info-red[_ngcontent-%COMP%]:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:12px;padding:.92px;border:none;background:linear-gradient(90deg,#f25555 -4% 100%)!important;-webkit-mask:linear-gradient(90deg,#F25555 -4%,#F25555 100%) content-box,linear-gradient(90deg,#F25555 -4%,#F25555 100%)!important;-webkit-mask-composite:xor!important;mask-composite:exclude!important;z-index:1}.info-red[_ngcontent-%COMP%]   span[_ngcontent-%COMP%]{color:#f25555!important}']}),a})();function Ed(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",3),e.bIt("pointerdown",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onPreviewPointerDown(i))})("pointermove",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onPreviewPointerMove(i))})("pointerup",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onPreviewPointerUp(i))})("pointercancel",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onPreviewPointerUp(i))}),e.nrm(1,"div",4),e.j41(2,"div",5)(3,"img",6),e.bIt("load",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onPreviewImageLoad(i))}),e.k0s()()()}if(2&s){const n=e.XpG(2);e.xc7("width",n.aspectFrameWidth,"px")("height",n.aspectFrameHeight,"px"),e.AVh("can-pan",n.canPanPreview)("is-dragging",n.isDraggingPreview),e.R7$(2),e.xc7("transform",n.previewPanTransform),e.R7$(),e.xc7("width",n.renderImageWidth||1,"px")("height",n.renderImageHeight||1,"px"),e.AVh("is-hidden",!(n.renderImageWidth&&n.renderImageHeight)),e.Y8G("src",n.imageUrl,e.B4B)}}
1function jd(s,a){if(1&s&&e.nrm(0,"img",2),2&s){const n=e.XpG(2);e.Y8G("src",n.imageUrl,e.B4B)}}function Gd(s,a){if(1&s&&e.DNE(0,Ed,4,17,"div",1)(1,jd,1,1,"img",2),2&s){const n=e.XpG();e.vxM(n.enableAspectFrame?0:1)}}function Vd(s,a){1&s&&(e.j41(0,"div",0),e.EFF(1," Your image preview will appear here "),e.k0s())}let Rd=(()=>{var s;class a{constructor(t){this.hostRef=t,this.imageUrl="",this.enableAspectFrame=!1,this.ratioWidth=1,this.ratioHeight=1,this.layoutKey="",this.stateChange=new e.bkB,this.aspectFrameWidth=0,this.aspectFrameHeight=0,this.renderImageWidth=0,this.renderImageHeight=0,this.panX=0,this.panY=0,this.isDraggingPreview=!1,this.zoomLevel=1,this.imageNaturalWidth=0,this.imageNaturalHeight=0,this.dragStartX=0,this.dragStartY=0,this.dragStartPanX=0,this.dragStartPanY=0,this.activePointers=new Map,this.pinchStartDistance=0,this.pinchStartZoom=1,this.desktopMarginPercent=15,this.desktopMatchingAspectMaxScale=1.25,this.aspectMatchTolerance=.06,this.frameBorderWidth=2}ngAfterViewInit(){this.setupPreviewResizeObserver(),this.updateAspectFrame(!1)}ngOnChanges(){if(!this.enableAspectFrame)return this.panX=0,this.panY=0,void this.emitEmptyState();this.updateAspectFrame(!0)}ngOnDestroy(){this.previewResizeObserver?.disconnect()}onPreviewImageLoad(t){const i=t.target;this.imageNaturalWidth=i.naturalWidth||0,this.imageNaturalHeight=i.naturalHeight||0,this.zoomLevel=this.getInitialZoomForLayout(),this.updateRenderedImage(!0)}onPreviewPointerDown(t){t.currentTarget.setPointerCapture(t.pointerId),this.activePointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),1===this.activePointers.size?(this.isDraggingPreview=this.canPanPreview,this.dragStartX=t.clientX,this.dragStartY=t.clientY,this.dragStartPanX=this.panX,this.dragStartPanY=this.panY):2===this.activePointers.size&&(this.isDraggingPreview=!1,this.pinchStartDistance=this.getPointerDistance(),this.pinchStartZoom=this.zoomLevel),t.preventDefault()}onPreviewPointerMove(t){if(!this.activePointers.has(t.pointerId))return;if(this.activePointers.set(t.pointerId,{x:t.clientX,y:t.clientY}),this.activePointers.size>=2){const r=this.getPointerDistance();return void(this.pinchStartDistance>0&&r>0&&(this.zoomLevel=this.clampZoom(this.pinchStartZoom*(r/this.pinchStartDistance)),this.updateRenderedImage(!1)))}if(!this.isDraggingPreview||!this.canPanPreview)return;const o=t.clientY-this.dragStartY;this.panX=this.clampPanX(this.dragStartPanX+(t.clientX-this.dragStartX)),this.panY=this.clampPanY(this.dragStartPanY+o),this.emitPreviewState()}onPreviewPointerUp(t){if(t.currentTarget.hasPointerCapture(t.pointerId)&&t.currentTarget.releasePointerCapture(t.pointerId),this.activePointers.delete(t.pointerId),this.activePointers.size<2&&(this.pinchStartDistance=0),1===this.activePointers.size){const i=Array.from(this.activePointers.values())[0];this.isDraggingPreview=this.canPanPreview,this.dragStartX=i.x,this.dragStartY=i.y,this.dragStartPanX=this.panX,this.dragStartPanY=this.panY}else this.isDraggingPreview=!1;this.emitPreviewState()}get previewPanTransform(){return`translate(${this.panX}px, ${this.panY}px)`}get canPanPreview(){return Math.abs(this.renderImageWidth-this.aspectFrameWidth)>1||Math.abs(this.renderImageHeight-this.aspectFrameHeight)>1}setupPreviewResizeObserver(){const t=this.hostRef.nativeElement;!t||typeof ResizeObserver>"u"||(this.previewResizeObserver=new ResizeObserver(()=>{this.updateAspectFrame(!1)}),this.previewResizeObserver.observe(t))}updateAspectFrame(t){if(!this.enableAspectFrame)return;const i=this.hostRef.nativeElement;if(!i)return;const o=i.clientWidth,r=i.clientHeight;if(!o||!r)return;const l=2*this.frameBorderWidth,c=Math.max(1,o-l),d=Math.max(1,r-l),h=Math.max(1,this.ratioWidth),p=Math.max(1,this.ratioHeight),u=h/p;let C,M,g=c,_=g/u,v=!1;_>d&&(_=d,g=_*u,v=!0),v?(M=Math.max(1,Math.round(_)),C=Math.max(1,Math.round(M*h/p))):(C=Math.max(1,Math.round(g)),M=Math.max(1,Math.round(C*p/h))),this.aspectFrameWidth=C+l,this.aspectFrameHeight=M+l,this.zoomLevel=t?this.getInitialZoomForLayout():this.clampZoom(this.zoomLevel),this.updateRenderedImage(t)}updateRenderedImage(t){if(!(this.aspectFrameWidth&&this.aspectFrameHeight&&this.imageNaturalWi
1dth&&this.imageNaturalHeight))return;const o=Math.min(this.frameContentWidth/this.imageNaturalWidth,this.frameContentHeight/this.imageNaturalHeight)*this.zoomLevel;this.renderImageWidth=Math.max(1,Math.round(this.imageNaturalWidth*o)),this.renderImageHeight=Math.max(1,Math.round(this.imageNaturalHeight*o)),t?(this.panX=0,this.panY=0):(this.panX=this.clampPanX(this.panX),this.panY=this.clampPanY(this.panY)),this.emitPreviewState()}clampPanX(t){const i=Math.max(0,(this.frameContentWidth-this.renderImageWidth)/2);return Math.max(-i,Math.min(i,t))}clampPanY(t){const i=Math.max(0,(this.frameContentHeight-this.renderImageHeight)/2);return Math.max(-i,Math.min(i,t))}getPointerDistance(){if(this.activePointers.size<2)return 0;const t=Array.from(this.activePointers.values()),i=t[0].x-t[1].x,o=t[0].y-t[1].y;return Math.sqrt(i*i+o*o)}clampZoom(t){if(!(this.aspectFrameWidth&&this.aspectFrameHeight&&this.imageNaturalWidth&&this.imageNaturalHeight))return 1;const i=1+2*this.desktopMarginPercent/100,o=1/i,r=this.hasMatchingAspect()?this.desktopMatchingAspectMaxScale/i:1;return Math.max(o,Math.min(r,t))}getInitialZoomForLayout(){return this.imageNaturalWidth&&this.imageNaturalHeight&&this.ratioWidth&&this.ratioHeight&&this.hasMatchingAspect()?1/(1+2*this.desktopMarginPercent/100):1}hasMatchingAspect(){return!!(this.imageNaturalWidth&&this.imageNaturalHeight&&this.ratioWidth&&this.ratioHeight)&&Math.abs(this.ratioHeight/this.ratioWidth-this.imageNaturalHeight/this.imageNaturalWidth)<this.aspectMatchTolerance}emitPreviewState(){if(!(this.imageNaturalWidth&&this.imageNaturalHeight&&this.aspectFrameWidth&&this.aspectFrameHeight&&this.renderImageWidth&&this.renderImageHeight))return void this.emitEmptyState();const t=Math.min(this.frameContentWidth/this.imageNaturalWidth,this.frameContentHeight/this.imageNaturalHeight)*this.zoomLevel;if(t<=0)return void this.emitEmptyState();const i=this.imageNaturalWidth*t,o=this.imageNaturalHeight*t,r=Math.max(0,(this.frameContentWidth-i)/2+this.panX),l=Math.max(0,(this.frameContentWidth-i)/2-this.panX),c=Math.max(0,(this.frameContentHeight-o)/2+this.panY),d=Math.max(0,(this.frameContentHeight-o)/2-this.panY);this.stateChange.emit({leftPadding:Math.max(0,Math.round(r/t)),rightPadding:Math.max(0,Math.round(l/t)),topPadding:Math.max(0,Math.round(c/t)),bottomPadding:Math.max(0,Math.round(d/t))})}emitEmptyState(){this.stateChange.emit({leftPadding:0,rightPadding:0,topPadding:0,bottomPadding:0})}get frameContentWidth(){return Math.max(1,this.aspectFrameWidth-2*this.frameBorderWidth)}get frameContentHeight(){return Math.max(1,this.aspectFrameHeight-2*this.frameBorderWidth)}}return(s=a).\u0275fac=function(t){return new(t||s)(e.rXU(e.aKT))},s.\u0275cmp=e.VBU({type:s,selectors:[["ai-expand-preview"]],inputs:{imageUrl:"imageUrl",enableAspectFrame:"enableAspectFrame",ratioWidth:"ratioWidth",ratioHeight:"ratioHeight",layoutKey:"layoutKey"},outputs:{stateChange:"stateChange"},features:[e.OA$],decls:2,vars:1,consts:[[1,"placeholder","text-13","grey-500","text-center"],[1,"aspect-preview-frame",3,"can-pan","is-dragging","width","height"],["alt","AI Expand preview",1,"fallback-preview-image",3,"src"],[1,"aspect-preview-frame",3,"pointerdown","pointermove","pointerup","pointercancel"],[1,"checker-bg"],[1,"aspect-preview-image-layer"],["alt","AI Expand preview",1,"aspect-preview-image",3,"load","src"]],template:function(t,i){1&t&&e.DNE(0,Gd,2,1)(1,Vd,2,0,"div",0),2&t&&e.vxM(i.imageUrl?0:1)},styles:["[_nghost-%COMP%]{display:flex;align-items:center;justify-content:center;width:100%;height:100%;min-height:0;box-sizing:border-box;overflow:hidden;position:relative;background:transparent}.fallback-preview-image[_ngcontent-%COMP%]{width:100%;height:100%;object-fit:contain}.aspect-preview-frame[_ngcontent-%COMP%]{position:relative;display:flex;align-items:center;justify-content:center;flex-shrink:0;overflow:hidden;box-sizing:border-box;border-radius:0;border:2px solid #626adf;touch-action:none;-webkit-user-select:none;user-select:none;background:transparent}.aspect-preview-frame.can-pan[_ngcontent-%COMP%]{cursor:grab}.aspect-preview-frame.is-dragging[_ngcontent-%COMP%]{cursor:grabbing}.checker-bg[_ngcontent-%COMP%]{position:absolute;top:0;right:0;bottom:0;left:0;z-index:1;background-color:#f3f4f7;background-size:20px 20px;background-position:0 0,0 10px,10px -10px,-10px 0;background:url(https://static.lightxeditor.com/assets/images/tranparent.png)}.aspect-preview-image-layer[_ngcontent-%COMP%]{position:relative;z-index:2;display:flex;align-items:center;justify-content:center;will-change:transform}.aspect-preview-image[_ngcontent-%COMP%]{display:block;max-width:none;max-height:none}.aspect-preview-image.is-hidden[_ngcontent-%COMP%]{opacity:0}
1.placeholder[_ngcontent-%COMP%]{width:100%;height:100%;display:flex;align-items:center;justify-content:center}"]}),a})();function Fd(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",2),e.nrm(1,"div",3),e.k0s(),e.j41(2,"div",4)(3,"button",5),e.bIt("pointerdown",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onHandlePointerDown(i,"nw"))})("pointermove",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onHandlePointerMove(i))})("pointerup",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onHandlePointerUp(i))})("pointercancel",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onHandlePointerUp(i))}),e.k0s(),e.j41(4,"button",6),e.bIt("pointerdown",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onHandlePointerDown(i,"n"))})("pointermove",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onHandlePointerMove(i))})("pointerup",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onHandlePointerUp(i))})("pointercancel",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onHandlePointerUp(i))}),e.k0s(),e.j41(5,"button",7),e.bIt("pointerdown",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onHandlePointerDown(i,"ne"))})("pointermove",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onHandlePointerMove(i))})("pointerup",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onHandlePointerUp(i))})("pointercancel",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onHandlePointerUp(i))}),e.k0s(),e.j41(6,"button",8),e.bIt("pointerdown",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onHandlePointerDown(i,"e"))})("pointermove",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onHandlePointerMove(i))})("pointerup",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onHandlePointerUp(i))})("pointercancel",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onHandlePointerUp(i))}),e.k0s(),e.j41(7,"button",9),e.bIt("pointerdown",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onHandlePointerDown(i,"se"))})("pointermove",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onHandlePointerMove(i))})("pointerup",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onHandlePointerUp(i))})("pointercancel",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onHandlePointerUp(i))}),e.k0s(),e.j41(8,"button",10),e.bIt("pointerdown",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onHandlePointerDown(i,"s"))})("pointermove",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onHandlePointerMove(i))})("pointerup",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onHandlePointerUp(i))})("pointercancel",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onHandlePointerUp(i))}),e.k0s(),e.j41(9,"button",11),e.bIt("pointerdown",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onHandlePointerDown(i,"sw"))})("pointermove",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onHandlePointerMove(i))})("pointerup",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onHandlePointerUp(i))})("pointercancel",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onHandlePointerUp(i))}),e.k0s(),e.j41(10,"button",12),e.bIt("pointerdown",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onHandlePointerDown(i,"w"))})("pointermove",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onHandlePointerMove(i))})("pointerup",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onHandlePointerUp(i))})("pointercancel",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onHandlePointerUp(i))}),e.k0s()()}if(2&s){const n=e.XpG(2);e.xc7("clip-path",n.checkerClipPath)("-webkit-clip-path",n.checkerClipPath),e.R7$(2),e.xc7("left",n.frameLeft,"px")("top",n.frameTop,"px")("width",n.frameWidth,"px")("height",n.frameHeight,"px")}}function Ad(s,a){if(1&s){const n=e.RV6();e.j41(0,"img",1),e.bIt("load",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.onImageLoad(i))}),e.k0s(),e.DNE(1,Fd,11,12)}if(2&s){const n=e.XpG();e.xc7("width",n.renderImageWidth||1,"px")("height",n.renderImageHeight||1,"px")("left",n.imageLeft,"px")("top",n.imageTop,"px"),e.AVh("is-hidden",!(n.renderImageWidth&&n.renderImageHeight)),e.Y8G("src",n.imageUrl,e.B4B),e.R7$(),e.vxM(n.frameWidth&&n.frameHeight?1:-1)}}function Bd(s,a){1&s&&e.nrm(0,"div",0)}let Ud=(()=>{var s;class a{constructor(t){this.hostRef=t,this.imageUrl="",this.stateChange=new e.bkB,this.renderImageWidth=0,this.renderImageHeight=0,this.imageLeft=0,this.imageTop=0,this.frameLeft=0,this.frameTop=0,this.frameWidth=0,this.frameHeight=0,this.stageWidth=0,this.stageHeight=0,this.imageNaturalWi
1dth=0,this.imageNaturalHeight=0,this.initialScale=.7,this.minFrameSize=96,this.handleInset=0,this.minFrameWidth=0,this.minFrameHeight=0,this.maxFrameWidth=0,this.maxFrameHeight=0,this.minLeftBound=0,this.maxRightBound=0,this.minTopBound=0,this.maxBottomBound=0,this.resizePointerId=null,this.activeHandle=null,this.startX=0,this.startY=0,this.startLeft=0,this.startTop=0,this.startRight=0,this.startBottom=0}ngAfterViewInit(){this.setupResizeObserver(),this.updateLayout(!1)}ngOnChanges(){this.imageUrl?this.updateLayout(!0):this.emitEmptyState()}ngOnDestroy(){this.resizeObserver?.disconnect()}onImageLoad(t){const i=t.target;this.imageNaturalWidth=i.naturalWidth||0,this.imageNaturalHeight=i.naturalHeight||0,this.updateLayout(!0)}onHandlePointerDown(t,i){this.hostRef.nativeElement&&(t.stopPropagation(),t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),this.resizePointerId=t.pointerId,this.activeHandle=i,this.startX=t.clientX,this.startY=t.clientY,this.startLeft=this.frameLeft,this.startTop=this.frameTop,this.startRight=this.frameLeft+this.frameWidth,this.startBottom=this.frameTop+this.frameHeight)}onHandlePointerMove(t){if(!this.activeHandle||this.resizePointerId!==t.pointerId)return;t.stopPropagation(),t.preventDefault();const i=this.hostRef.nativeElement;if(!i)return;const r=this.handleInset,l=i.clientWidth-this.handleInset,c=i.clientHeight-this.handleInset,d=Math.max(this.minLeftBound,this.handleInset),h=Math.min(this.maxRightBound,l),p=Math.max(this.minTopBound,r),u=Math.min(this.maxBottomBound,c),g=this.imageLeft,_=this.imageLeft+this.renderImageWidth,v=this.imageTop,C=this.imageTop+this.renderImageHeight,M=t.clientX-this.startX,k=t.clientY-this.startY;let j=this.startLeft,G=this.startRight,U=this.startTop,F=this.startBottom;if(this.activeHandle.includes("e")){const K=Math.max(this.startLeft+this.minFrameWidth,_);G=this.clamp(this.startRight+M,K,h)}else if(this.activeHandle.includes("w")){const K=Math.min(this.startRight-this.minFrameWidth,g);j=this.clamp(this.startLeft+M,d,K)}if(this.activeHandle.includes("s")){const K=Math.max(this.startTop+this.minFrameHeight,C);F=this.clamp(this.startBottom+k,K,u)}else if(this.activeHandle.includes("n")){const K=Math.min(this.startBottom-this.minFrameHeight,v);U=this.clamp(this.startTop+k,p,K)}this.frameLeft=j,this.frameTop=U,this.frameWidth=Math.max(this.minFrameWidth,G-j),this.frameHeight=Math.max(this.minFrameHeight,F-U),this.emitState()}onHandlePointerUp(t){if(this.resizePointerId!==t.pointerId)return;const i=t.currentTarget;i.hasPointerCapture(t.pointerId)&&i.releasePointerCapture(t.pointerId),this.resizePointerId=null,this.activeHandle=null}get checkerClipPath(){if(!(this.frameWidth&&this.frameHeight&&this.stageWidth&&this.stageHeight))return"inset(100%)";const t=Math.max(0,this.frameTop),i=Math.max(0,this.frameLeft);return`inset(${t}px ${Math.max(0,this.stageWidth-this.frameLeft-this.frameWidth)}px ${Math.max(0,this.stageHeight-this.frameTop-this.frameHeight)}px ${i}px)`}setupResizeObserver(){const t=this.hostRef.nativeElement;!t||typeof ResizeObserver>"u"||(this.resizeObserver=new ResizeObserver(()=>this.updateLayout(!1)),this.resizeObserver.observe(t))}updateLayout(t){const i=this.hostRef.nativeElement;if(!i||!this.imageNaturalWidth||!this.imageNaturalHeight)return;this.stageWidth=i.clientWidth,this.stageHeight=i.clientHeight;const o=Math.max(this.minFrameSize,i.clientWidth),r=Math.max(this.minFrameSize,i.clientHeight),l=Math.min(o/this.imageNaturalWidth,r/this.imageNaturalHeight),c=Math.max(this.minFrameSize,Math.round(this.imageNaturalWidth*l)),d=Math.max(this.minFrameSize,Math.round(this.imageNaturalHeight*l)),h=Math.max(this.minFrameSize,Math.round(c*this.initialScale)),p=Math.max(this.minFrameSize,Math.round(d*this.initialScale));this.renderImageWidth=h,this.renderImageHeight=p,this.imageLeft=Math.round((i.clientWidth-this.renderImageWidth)/2),this.imageTop=Math.round((i.clientHeight-this.renderImageHeight)/2),this.minFrameWidth=h,this.minFrameHeight=p,this.maxFrameWidth=Math.min(o,c),this.maxFrameHeight=Math.min(r,d);const u=Math.round(.15*this.renderImageWidth),g=Math.round(.15*this.renderImageHeight);if(this.minLeftBound=this.imageLeft-u,this.maxRightBound=this.imageLeft+this.renderImageWidth+u,this.minTopBound=this.imageTop-g,this.maxBottomBound=this.imageTop+this.renderImageHeight+g,t||!this.frameWidth||!this.frameHeight)return this.frameWidth=h,this.frameHeight=p,this.frameLeft=this.imageLeft,this.frameTop=this.imageTop,void this.emitState();const _=this.frameLeft+this.frameWidth,v=this.frameTop+this.frameHeight,C=this.handleInset,M=this.handleInset,k=i.clientWidth-this.handleInset,j=i.clientHeight-this.handleInset;this.frameWidth=this.clamp(this.frameWidth,this.minFrameWidth,this.maxFrameWidth),this.frameHeight=this.clamp(this.frameHeight,this.minFrameHeight,this.maxFrameHeight),this.frameLeft=this.clamp(this.frameLeft,C,k-this.frameWidth),this.frameTop=this.clamp(this.frameTop,M,j-this.frameHeight);const G=this.imageLeft+this.renderImageWidth,U=this.imageTop+this.renderImageHeight,F=this.frameLeft+this.frameWidth,K=this.frameTop+this.frameHeight;this.frameLeft>this.imageLeft&&(this.frameLeft=this.imageLeft),this.frameTop>this.imageTop&&(this.frameTop=this.imageTop),F<G&&(this.frameLeft=G-this.frameWidth),K<U&&(this.frameTop=U-this.frameHeight),_>this.frameLeft+this.frameWidth&&(this.frameLeft=_-this.frameWidth),v>this.frameTop+this.frameHeight&&(this.frameTop=v-this.frameHeight),this.frameLeft=this.clamp(this.frameLeft,C,k-this.frameWidth),this.frameTop=this.clamp(this.frameTop,M,j-this.frameHeight),this.emitState()}emitState(){if(!(this.renderImageWidth&&this.renderImageHeight&&this.imageNaturalWi
1dth&&this.imageNaturalHeight))return void this.emitEmptyState();const t=this.imageLeft+this.renderImageWidth,i=this.imageTop+this.renderImageHeight,o=this.frameLeft+this.frameWidth,r=this.frameTop+this.frameHeight,l=Math.max(0,this.imageLeft-this.frameLeft),c=Math.max(0,o-t),d=Math.max(0,this.imageTop-this.frameTop),h=Math.max(0,r-i),p=this.imageNaturalWidth/this.renderImageWidth,u=this.imageNaturalHeight/this.renderImageHeight;this.stateChange.emit({leftPadding:Math.max(0,Math.round(l*p)),rightPadding:Math.max(0,Math.round(c*p)),topPadding:Math.max(0,Math.round(d*u)),bottomPadding:Math.max(0,Math.round(h*u))})}emitEmptyState(){this.stateChange.emit({leftPadding:0,rightPadding:0,topPadding:0,bottomPadding:0})}clamp(t,i,o){return Math.max(i,Math.min(o,t))}}return(s=a).\u0275fac=function(t){return new(t||s)(e.rXU(e.aKT))},s.\u0275cmp=e.VBU({type:s,selectors:[["ai-expand-freeform-preview"]],inputs:{imageUrl:"imageUrl"},outputs:{stateChange:"stateChange"},features:[e.OA$],decls:2,vars:1,consts:[[1,"placeholder","text-13","bg-transparent","text-center"],["alt","AI Expand freeform",1,"freeform-image",3,"load","src"],[1,"freeform-checker-frame"],[1,"checker-bg"],[1,"freeform-frame"],["type","button",1,"resize-handle","handle-nw",3,"pointerdown","pointermove","pointerup","pointercancel"],["type","button",1,"resize-handle","handle-n",3,"pointerdown","pointermove","pointerup","pointercancel"],["type","button",1,"resize-handle","handle-ne",3,"pointerdown","pointermove","pointerup","pointercancel"],["type","button",1,"resize-handle","handle-e",3,"pointerdown","pointermove","pointerup","pointercancel"],["type","button",1,"resize-handle","handle-se",3,"pointerdown","pointermove","pointerup","pointercancel"],["type","button",1,"resize-handle","handle-s",3,"pointerdown","pointermove","pointerup","pointercancel"],["type","button",1,"resize-handle","handle-sw",3,"pointerdown","pointermove","pointerup","pointercancel"],["type","button",1,"resize-handle","handle-w",3,"pointerdown","pointermove","pointerup","pointercancel"]],template:function(t,i){1&t&&e.DNE(0,Ad,2,12)(1,Bd,1,0,"div",0),2&t&&e.vxM(i.imageUrl?0:1)},styles:["[_nghost-%COMP%]{display:block;width:100%;height:100%;min-height:0;box-sizing:border-box;position:relative;overflow:hidden}.freeform-checker-frame[_ngcontent-%COMP%]{position:absolute;top:0;right:0;bottom:0;left:0;z-index:2;pointer-events:none}.checker-bg[_ngcontent-%COMP%]{position:absolute;top:0;right:0;bottom:0;left:0;background-color:#f3f4f7;background-size:20px 20px;background-position:0 0,0 10px,10px -10px,-10px 0;background:url(https://static.lightxeditor.com/assets/images/tranparent.png)}.freeform-image[_ngcontent-%COMP%]{position:absolute;object-fit:contain;pointer-events:none;z-index:3}.freeform-image.is-hidden[_ngcontent-%COMP%]{opacity:0}.freeform-frame[_ngcontent-%COMP%]{position:absolute;z-index:4;border:2px dashed #626adf}.resize-handle[_ngcontent-%COMP%]{position:absolute;border:0;border-radius:99px;background:#fff;box-shadow:inset 0 0 0 2px #626adf;z-index:5;touch-action:none}.handle-n[_ngcontent-%COMP%], .handle-s[_ngcontent-%COMP%]{width:22px;height:8px;left:50%;transform:translate(-50%)}.handle-e[_ngcontent-%COMP%], .handle-w[_ngcontent-%COMP%]{width:22px;height:8px;top:50%;transform:translateY(-50%) rotate(90deg)}.handle-n[_ngcontent-%COMP%]{top:-5px}.handle-s[_ngcontent-%COMP%]{bottom:-5px}.handle-e[_ngcontent-%COMP%]{right:-11px}.handle-w[_ngcontent-%COMP%]{left:-11px}.handle-nw[_ngcontent-%COMP%]{top:-9px;left:-9px}.handle-ne[_ngcontent-%COMP%]{top:-9px;right:-9px}.handle-se[_ngcontent-%COMP%]{bottom:-9px;right:-9px}.handle-sw[_ngcontent-%COMP%]{bottom:-9px;left:-9px}.handle-nw[_ngcontent-%COMP%], .handle-ne[_ngcontent-%COMP%], .handle-se[_ngcontent-%COMP%], .handle-sw[_ngcontent-%COMP%]{width:16px;height:16px}.placeholder[_ngcontent-%COMP%]{width:100%;height:100%;display:flex;align-items:center;justify-content:center}"]}),a})();const Dd=["presetStrip"],Nd=["cpText"],Xd=(s,a)=>a.id,Ld=(s,a,n)=>({"info-up":s,"info-blue":a,"info-red":n});function Yd(s,a){if(1&s){const n=e.RV6();e.j41(0,"ai-expand-freeform-preview",30),e.bIt("stateChange",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onPreviewStateChange(i))}),e.k0s()}if(2&s){const n=e.XpG(2);e.Y8G("imageUrl",n.previewImageUrl)}}function $d(s,a){if(1&s){const n=e.RV6();e.j41(0,"ai-expand-preview",31),e.bIt("stateChange",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onPreviewStateChange(i))}),e.k0s()}if(2&s){const n=e.XpG(2);e.Y8G("imageUrl",n.previewImageUrl)("enableAspectFrame",n.hasAspectPreview)("ratioWidth",(null==n.selectedLayout?null:n.selectedLayout.ratioWidth)||1)("ratioHeight",(null==n.selectedLayout?null:n.selectedLayout.ratioHeight)||1)("layoutKey",n.selectedCategory+":"+n.selectedPresetId)}}function zd(s,a){1&s&&(e.j41(0,"div",9),e.nrm(1,"pi",32),e.j41(2,"span"),e.EFF(3,"Drag/pinch image to pan/zoom"),e.k0s()())}function Hd(s,a){if(1&s){const n=e.RV6();e.j41(0,"button",34),e.bIt("click",function(){const i=e.eBV(n).$implicit,o=e.XpG(3);return e.Njj(o.selectPreset(i))}),e.j41(1,"div",35)(2,"div",36),e.nrm(3,"pi",37),e.k0s()(),e.j41(4,"span",38),e.EFF(5),e.k0s(),e.j41(6,"span",39),e.EFF(7),e.k0s()()}if(2&s){let n;const t=a.$implicit,i=e.XpG(3);e.AVh("active",t.id===i.selectedPresetId),e.R7$(2),e.xc7("width",t.previewBoxWidth,"px")("height",t.previewBoxHeight,"px"),e.R7$(),e.Y8G("name",null!==(n=t.iconName)&&void 0!==n?n:"instagram"),e.R7$(),e.AVh("preset-text-active",t.id===i.selectedPresetId),e.R7$(),e.JRh(t.shortName),e.R7$(),e.AVh("preset-ratio-active",t.id===i.selectedPresetId),e.R7$(),e.JRh(t.ratio)}}function Wd(s,a){if(1&s&&(e.j41(0,"div",21,0),e.Z7z(2,Hd,8,13,"button",33,Xd),e.k0s()),2&s){const n=e.XpG(2);e.R7$(2),e.Dyx(n.selectedLayouts)}}function qd(s,a){1&s&&(e.j41(0,"div",22),e.EFF(1," Drag the handles over canvas to create your desired frame and expand image. "),e.k0s())}function Kd(s,a){if(1&s){const n=e.RV6();
1e.j41(0,"div",3)(1,"div",6),e.DNE(2,Yd,1,1,"ai-expand-freeform-preview",7)(3,$d,1,5,"ai-expand-preview",8)(4,zd,4,0,"div",9),e.k0s(),e.j41(5,"div",10)(6,"div",11)(7,"div",12)(8,"div",13)(9,"button",14),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.selectCategory("socialmedia"))}),e.EFF(10," Social Media "),e.nrm(11,"span",15),e.k0s(),e.j41(12,"button",14),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.selectCategory("standard"))}),e.EFF(13," Standard "),e.nrm(14,"span",15),e.k0s(),e.j41(15,"button",14),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.selectCategory("custom"))}),e.EFF(16," Freeform "),e.k0s()()(),e.j41(17,"div",16)(18,"div",17),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.openPromptEditor())}),e.nrm(19,"pi",18),e.j41(20,"input",19),e.bIt("focus",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.openPromptEditor())}),e.k0s()()(),e.j41(21,"div",20),e.DNE(22,Wd,4,0,"div",21)(23,qd,2,0,"div",22),e.k0s()(),e.j41(24,"div",23)(25,"button",24),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.generate())}),e.j41(26,"span",25),e.EFF(27,"Generate"),e.k0s(),e.j41(28,"span",26),e.nrm(29,"img",27)(30,"img",28),e.j41(31,"b",29),e.EFF(32),e.k0s()()()()()()}if(2&s){const n=e.XpG();e.R7$(2),e.vxM(n.isCustomCategory?2:3),e.R7$(2),e.vxM(n.showPresetHint&&!n.isCustomCategory?4:-1),e.R7$(2),e.AVh("custom-mode",n.isCustomCategory),e.R7$(3),e.AVh("is-selected","socialmedia"===n.selectedCategory)("text-semi","socialmedia"===n.selectedCategory),e.R7$(2),e.AVh("is-hidden","custom"!==n.selectedCategory),e.R7$(),e.AVh("is-selected","standard"===n.selectedCategory)("text-semi","standard"===n.selectedCategory),e.R7$(2),e.AVh("is-hidden","standard"===n.selectedCategory||"custom"===n.selectedCategory),e.R7$(),e.AVh("is-selected","custom"===n.selectedCategory)("text-semi","custom"===n.selectedCategory),e.R7$(5),e.Y8G("value",n.prompt||""),e.R7$(2),e.vxM(n.isCustomCategory?23:22),e.R7$(3),e.Y8G("disabled",n.isGenerateDisabled),e.R7$(7),e.JRh(n.creditLabel)}}function Zd(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",4)(1,"div",40)(2,"mobile-generated-compare-preview",41),e.bIt("activeImageUrlChange",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.onResultPreviewImageChange(i))})("downloadRequested",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.onResultPreviewDownload(i))}),e.k0s()(),e.j41(3,"div",42)(4,"button",43),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.generateMore())}),e.j41(5,"span"),e.EFF(6),e.k0s(),e.j41(7,"span",44),e.nrm(8,"img",45)(9,"img",46),e.j41(10,"span",47),e.EFF(11),e.k0s()()()()()}if(2&s){const n=e.XpG();e.R7$(2),e.Y8G("images",n.aiPhotoService.aiImages)("sourceImageUrl",n.previewImageUrl)("fallbackImageUrl",n.previewImageUrl)("inProgress",n.aiPhotoService.inProgress)("focusAssetId",n.activePreviewAssetId),e.R7$(2),e.AVh("is-active",!n.isGenerateDisabled),e.Y8G("disabled",n.isGenerateDisabled),e.R7$(2),e.JRh(n.aiPhotoService.inProgress?"Processing":"Generate More"),e.R7$(5),e.JRh(n.creditLabel)}}function Jd(s,a){if(1&s&&(e.j41(0,"span",62),e.EFF(1),e.k0s()),2&s){const n=e.XpG(2);e.R7$(),e.Lme("",(n.prompt||"").length,"/",n.promptMaxLength," ")}}function Qd(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",48)(1,"div",49)(2,"div",50),e.EFF(3," Prompt (Optional) "),e.k0s(),e.j41(4,"div")(5,"pi",51),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.closePromptEditor())}),e.k0s()()(),e.j41(6,"div",52)(7,"div",53)(8,"div",54)(9,"div",55)(10,"div",56)(11,"textarea",57,1),e.mxI("ngModelChange",function(i){e.eBV(n);const o=e.XpG();return e.DH7(o.prompt,i)||(o.prompt=i),e.Njj(i)}),e.bIt("keyup",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.changePrompt())})("paste",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.onPaste(i))})("focus",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.focusIn())})("blur",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.focusOut())})("keydown.enter",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.onEnter(i))}),e.k0s(),e.DNE(13,Jd,2,2,"span",58),e.k0s()()()()(),e.j41(14,"div",59)(15,"button",60),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.closePromptEditor())}),e.j41(16,"span",25),e.EFF(17,"Done"),e.k0s()()()(),e.j41(18,"div",61),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.closePromptEditor())}),e.k0s()}if(2&s){const n=e.XpG();e.R7$(10),e.Y8G("ngClass",e.sMw(6,Ld,(n.prompt||"").length,n.isFocused,(n.prompt||"").length>n.promptMaxLength-1)),e.R7$(),e.AVh("blue-active",n.isFocused),e.Y8G("maxlength",n.promptMaxLength),e.R50("ngModel",n.prompt),e.R7$(2),e.Y8G("ngIf",(n.prompt||"").length)}}function eh(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"add-credit",63),e.bIt("close",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.step=1)})("addCredit",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.addCredit())}),e.k0s(),e.bVm()}if(2&s){const n=e.XpG();e.R7$(),e.Y8G("consumeCoins",n.qualityType)}}let th=(()=>{var s;class a{constructor(t,i,o,r,l,c,d){this.aiPhotoService=t,this.templateService=i,this.authService=o,this.paymentService=r,this.createPopupService=l,this.aiUploadImageService=c,this.aiGenService=d,this.imageUrl="",this.inputImageUnavailable=new e.bkB,this.selectedCategory="custom",this.step=1,this.prompt="",this.promptMaxLength=450,this.selectedPresetId="",this.selectedLayout=null,this.selectedLayouts=[],this.layoutsByCategory={socialmedia:[],standard:[],custom:[]}
1,this.previewState={leftPadding:0,rightPadding:0,topPadding:0,bottomPadding:0},this.qualityType=1,this.user=null,this.isResultView=!1,this.isPromptEditorOpen=!1,this.isFocused=!1,this.showPresetHint=!1,this.hasShownPresetHint=!1,this.activePreviewAssetId="",this.lastGeneratePayload=null,this.isLoaded=!1,this.presetHintTimeoutId=null,this.generationCancelled=!1,this.previewImageUrl="",this.preparedInputBlob=null,this.preparedImageObjectUrl="",this.reusableServerInputUrl="",this.inputPreparation=null,this.inputPreparationError=null,this.inputPreparationId=0,this.isInputPreparing=!1}ngOnInit(){this.aiPhotoService.aiImages=[],this.aiPhotoService.selectedUpscaleImageUrl="",this.user=this.authService.currentUser(),this.qualityType=this.paymentService?.config?.creditInfo?.outpaint||1,this.configSubs=this.paymentService.configUpdated.subscribe(()=>{this.qualityType=this.paymentService?.config?.creditInfo?.outpaint||1,this.user=this.authService.currentUser()}),this.backBtnSub=this.aiPhotoService.backBtnClick.subscribe(t=>{t?.isBack&&this.isResultView&&this.exitResultView()}),this.loadResizeContent()}ngOnChanges(t){t.imageUrl&&this.imageUrl&&this.prepareInputImage()}ngOnDestroy(){this.inputPreparationId++,this.configSubs?.unsubscribe(),this.backBtnSub?.unsubscribe(),this.clearTimeInterval(),this.aiPhotoService.clearGenerationProgress(),this.clearPresetHintTimer(),this.revokePreparedImageUrl(),document.body.classList.remove("overflow-hidden")}selectCategory(t){this.selectedCategory!==t&&(this.selectedCategory=t,this.setLayoutsForCategory(),this.resetPresetStripScroll())}selectPreset(t){this.selectedLayout=t,this.selectedPresetId=String(t?.id||""),this.previewState=this.getEmptyPreviewState(),this.showPresetPanZoomHint()}onPreviewStateChange(t){this.previewState=t||this.getEmptyPreviewState()}openPromptEditor(){this.isPromptEditorOpen=!0,this.focusIn()}closePromptEditor(){this.prompt=this.cpText?.nativeElement?.value??this.prompt,this.isPromptEditorOpen=!1,this.focusOut()}focusIn(){document.body.classList.add("overflow-hidden"),this.isFocused=!0,setTimeout(()=>{this.cpText?.nativeElement?.focus()},100)}focusOut(){document.body.classList.remove("overflow-hidden"),this.isFocused=!1}changePrompt(){this.prompt=this.cpText?.nativeElement?.value??this.prompt}onPaste(t){setTimeout(()=>{this.prompt=t.target.value,this.changePrompt()},0)}onEnter(t){this.cpText?.nativeElement?.blur()}loadResizeContent(){this.templateService.getCreateFromScratchData(1,!0,t=>{const o=(t?.body?.socialPlatformsList||[]).concat(this.getCustomLayouts()).map(r=>({...r,title:r.socialLabelType.replace(" ","").toLowerCase()}));this.layoutsByCategory=this.buildLayoutsByCategory(o),this.setLayoutsForCategory(),this.isLoaded=!0},()=>{this.isLoaded=!0})}setLayoutsForCategory(){if(this.selectedPresetId="",this.selectedLayout=null,this.selectedCategory===f.zu.Custom)return this.selectedLayouts=[],void this.hidePresetPanZoomHint();this.selectedLayouts=this.layoutsByCategory[this.selectedCategory]||[],this.selectedLayouts.length&&this.selectPreset(this.selectedLayouts[0])}getCustomLayouts(){return[{socialLabelType:"Custom",parentMediaType:"1",socialPlatformFormats:[{title:"custom",shortName:"Freeform",format:0,wratio:0,hratio:0,width:0,height:0,socialPlatformId:26}]}]}buildLayoutsByCategory(t){const i={socialmedia:[],standard:[],custom:[]};let o=1;return t.forEach(r=>{const l=r.title;if(!(l in i)||l===f.zu.Custom)return;const c=Array.isArray(r.socialPlatformFormats)?r.socialPlatformFormats:[],d=this.mapLayouts(c,o);o+=c.length,i[l]=i[l].concat(d)}),i}mapLayouts(t,i){return t.map((o,r)=>{const l=this.resolveRatio(o,"w"),c=this.resolveRatio(o,"h"),d=this.getPreviewBox(l,c);return{id:this.getLayoutId(o,i+r),iconName:o.iconName||"instagram",socialPlatform:o.socialPlatform,shortName:o.webappShortName||o.socialPlatform||"Format",label:o.short_name||o.shortName||o.socialPlatform||"Format",ratio:this.formatRatio(l,c),ratioWidth:l,ratioHeight:c,previewBoxWidth:d.width,previewBoxHeight:d.height}})}resolveRatio(t,i){const o="w"===i?["wratio","wRatio","width"]:["hratio","hRatio","height"];for(const r of o){const l=Number(t?.[r]);if(Number.isFinite(l)&&l>0)return l}return 1}getPreviewBox(t,i){return t>=i?{width:82,height:Math.max(18,Math.round(82*i/t))}:{width:Math.max(18,Math.round(82*t/i)),height:82}}
1getLayoutId(t,i){const o=[t.socialPlatformId,t.short_name||t.shortName||t.socialPlatform,t.wratio??t.wRatio??t.width,t.hratio??t.hRatio??t.height].filter(Boolean);return o.length?o.join("-"):String(i)}formatRatio(t,i){return`${t} : ${i}`}resetPresetStripScroll(){setTimeout(()=>{requestAnimationFrame(()=>{this.presetStripRef?.nativeElement.scrollTo({left:0,behavior:"smooth"})})})}onUserPointerAction(){this.hidePresetPanZoomHint()}onUserKeyAction(){this.hidePresetPanZoomHint()}onUserWheelAction(){this.hidePresetPanZoomHint()}get isCustomCategory(){return this.selectedCategory===f.zu.Custom}get hasAspectPreview(){return this.isCustomCategory?!!this.previewImageUrl:!!this.selectedLayout}get creditLabel(){return String(this.qualityType||1).padStart(2,"0")}get isGenerateDisabled(){return this.isResultView?this.aiPhotoService.inProgress||!this.lastGeneratePayload:!(!this.aiPhotoService.inProgress&&!this.isInputPreparing&&this.previewImageUrl&&(this.isCustomCategory||this.selectedLayout)&&this.hasPositivePadding())}generate(){var t=this;return(0,w.A)(function*(){if(t.isResultView)return void(yield t.generateMore());if(t.aiPhotoService.inProgress||t.isInputPreparing||!t.previewImageUrl||!t.isCustomCategory&&!t.selectedLayout)return;if(!t.hasPositivePadding())return void t.createPopupService.openWarningDialog("Error",y.b.message.expandPaddingZero);if(t.user=t.authService.currentUser(),!t.hasSufficientCredits())return t.step=1,void t.aiPhotoService.loginAndAICredit(()=>{t.user=t.authService.currentUser(),t.hasSufficientCredits()?t.generate():t.user&&(t.step=3)});t.generationCancelled=!1,t.aiPhotoService.startGenerationProgress({featureType:"outpaint"});const i=new Date;try{const o=yield t.prepareInputForOutpaint(),r=t.buildOutpaintPayload(o);t.lastGeneratePayload={...r},t.runGeneration(r,i)}catch(o){t.displayErrorMsg({description:o?.message||y.b.message.somethingWrong},i)}})()}generateMore(){var t=this;return(0,w.A)(function*(){if(!t.aiPhotoService.inProgress&&t.lastGeneratePayload){if(t.user=t.authService.currentUser(),!t.hasSufficientCredits())return t.step=1,void t.aiPhotoService.loginAndAICredit(()=>{t.user=t.authService.currentUser(),t.hasSufficientCredits()?t.generateMore():t.user&&(t.step=3)});t.generationCancelled=!1,t.aiPhotoService.startGenerationProgress({featureType:"outpaint"}),t.runGeneration({...t.lastGeneratePayload},new Date)}})()}onResultPreviewImageChange(t){t&&(this.aiPhotoService.selectedUpscaleImageUrl=t)}onResultPreviewDownload(t){t&&this.aiPhotoService.downloadImg(t)}runGeneration(t,i){this.aiPhotoService.generateImage(t,o=>{if(!this.generationCancelled){if(!o?.assetId)return void this.displayErrorMsg(o,i);this.aiPhotoService.checkStatusResponsive(o,0,r=>{if(!this.generationCancelled&&r){if(this.aiPhotoService.processingProgress.isActive||this.aiPhotoService.inProgress||this.aiPhotoService.inVideoProgress){if(r?.urls?.length)return void this.aiPhotoService.completeGenerationProgress(()=>{this.user=this.authService.currentUser(),this.user&&void 0!==r.remainingCalls&&(this.user.remainingCoins=r.remainingCalls),this.aiPhotoService.generateImageFn?.(r);const l=this.aiPhotoService.aiImages[this.aiPhotoService.aiImages.length-1];this.aiPhotoService.selectedUpscaleImageUrl=l?.urls?.[0]||r.urls[0]||"",this.activePreviewAssetId=String(l?.assetId||r.assetId||""),this.enterResultView(),this.aiPhotoService.isDirty=!0});this.displayErrorMsg({description:y.b.message.somethingWrong},i,o)}}else this.aiPhotoService.clearGenerationProgress()},r=>{this.generationCancelled||this.displayErrorMsg(r,i,o)})}},o=>{this.generationCancelled||this.displayErrorMsg(o,i)})}displayErrorMsg(t,i,o=null){this.generationCancelled?this.aiPhotoService.clearGenerationProgress():(this.aiPhotoService.clearGenerationProgress(),this.createPopupService.openWarningDialog("Error",t?.description||y.b.message.somethingWrong))}retryCheckStatus(t){this.generationCancelled=!1,this.aiPhotoService.startGenerationProgress({featureType:"outpaint"});const i=new Date;this.aiPhotoService.checkStatusResponsive(t,0,o=>{if(!this.generationCancelled&&o&&(this.aiPhotoService.processingProgress.isActive||this.aiPhotoService.inProgress||this.aiPhotoService.inVideoProgress)){if(o?.urls?.length)return void this.aiPhotoService.completeGenerationProgress(()=>{this.user=this.authService.currentUser(),this.user&&void 0!==o.remainingCalls&&(this.user.remainingCoins=o.remainingCalls),this.aiPhotoService.generateImageFn?.(o);const r=this.aiPhotoService.aiImages[this.aiPhotoService.aiImages.length-1];this.aiPhotoService.selectedUpscaleImageUrl=r?.urls?.[0]||o.urls[0]||"",this.activePreviewAssetId=String(r?.assetId||o.assetId||""),this.enterResultView(),this.aiPhotoService.isDirty=!0});this.displayErrorMsg({description:y.b.message.somethingWrong},i,t)}},o=>{this.generationCancelled||this.displayErrorMsg(o,i,t)})}enterResultView(){this.isResultView=!0,this.aiPhotoService.backBtnClick.next({backBtnEnabled:!0})}exitResultView(){this.isResultView=!1,this.activePreviewAssetId="",this.scrollSelectedPresetIntoView()}
1scrollSelectedPresetIntoView(){this.isCustomCategory||!this.selectedPresetId||setTimeout(()=>{requestAnimationFrame(()=>{const t=this.presetStripRef?.nativeElement;t&&t.querySelector(".preset-item.active")?.scrollIntoView({behavior:"smooth",inline:"center",block:"nearest"})})})}hasPositivePadding(){return!this.isCustomCategory||this.previewState.leftPadding>0||this.previewState.rightPadding>0||this.previewState.topPadding>0||this.previewState.bottomPadding>0}hasSufficientCredits(){return!!this.user&&this.user.remainingCoins>=this.qualityType}buildOutpaintPayload(t){const i=this.toMultipleOfEight(this.previewState.leftPadding),o=this.toMultipleOfEight(this.previewState.rightPadding),r=this.toMultipleOfEight(this.previewState.topPadding),l=this.toMultipleOfEight(this.previewState.bottomPadding);return{featureType:"outpaint",imageUrl:t,textPrompt:this.prompt?this.prompt.trim():"",isCustomPrompt:1,segmentationType:0,leftPadding:i,rightPadding:o,topPadding:r,bottomPadding:l}}toMultipleOfEight(t){return 8*Math.floor(Math.max(0,t)/8)}prepareInputForOutpaint(){var t=this;return(0,w.A)(function*(){if(yield t.inputPreparation,t.inputPreparationError)throw t.inputPreparationError;if(t.reusableServerInputUrl)return t.reusableServerInputUrl;if(!t.preparedInputBlob)throw new Error("Failed to prepare input image.");const i=new File([t.preparedInputBlob],"expand-input.png",{type:t.preparedInputBlob.type||"image/png"});return t.uploadImageFile(i)})()}prepareInputImage(){var t=this;const i=this.imageUrl,o=++this.inputPreparationId;this.isInputPreparing=!0,this.inputPreparationError=null,this.preparedInputBlob=null,this.reusableServerInputUrl="",this.previewImageUrl="",this.revokePreparedImageUrl(),this.inputPreparation=this.loadImageElement(i).then(function(){var r=(0,w.A)(function*(l){return t.canReuseServerImage(i,l)?{blob:null,serverUrl:i}:{blob:yield t.createPreparedImageBlob(l),serverUrl:""}});return function(l){return r.apply(this,arguments)}}()).then(({blob:r,serverUrl:l})=>{o===this.inputPreparationId&&(this.reusableServerInputUrl=l,r?(this.preparedInputBlob=r,this.preparedImageObjectUrl=URL.createObjectURL(r),this.previewImageUrl=this.preparedImageObjectUrl):this.previewImageUrl=i)}).catch(r=>{o===this.inputPreparationId&&(this.inputPreparationError=r instanceof Error?r:new Error("Failed to prepare input image."),this.inputImageUnavailable.emit())}).finally(()=>{o===this.inputPreparationId&&(this.isInputPreparing=!1)})}canReuseServerImage(t,i){if(!t||t.startsWith("blob:")||t.startsWith("data:"))return!1;const o=i.naturalWidth||i.width,r=i.naturalHeight||i.height;return o>0&&r>0&&o<=768&&r<=768&&o%2==0&&r%2==0}loadImageElement(t){return new Promise((i,o)=>{fe.k.loadImageElement(t,r=>{r?i(r):o(new Error("Failed to load input image."))})})}createPreparedImageBlob(t){return new Promise((i,o)=>{const r=t.naturalWidth||t.width,l=t.naturalHeight||t.height;if(!r||!l)return void o(new Error("Failed to read input image dimensions."));const c=Math.min(1,768/r,768/l),d=Math.max(2,2*Math.floor(r*c/2)),h=Math.max(2,2*Math.floor(l*c/2)),p=document.createElement("canvas");p.width=d,p.height=h;const u=p.getContext("2d");u?(u.imageSmoothingEnabled=!0,u.imageSmoothingQuality="high",u.drawImage(t,0,0,d,h),p.toBlob(g=>{g?i(g):o(new Error("Failed to create resized input image."))},"image/png",.9)):o(new Error("Failed to prepare input image."))})}revokePreparedImageUrl(){this.preparedImageObjectUrl&&(URL.revokeObjectURL(this.preparedImageObjectUrl),this.preparedImageObjectUrl="")}uploadImageFile(t){return new Promise((i,o)=>{this.aiUploadImageService.uploadImage(t,{tab:"outpaint"},r=>{r?.contentUrl?i(r.contentUrl):o(new Error(r?.description||"Failed to upload resized image."))})})}getEmptyPreviewState(){return{leftPadding:0,rightPadding:0,topPadding:0,bottomPadding:0}}openProgress(){this.clearTimeInterval(),this.aiPhotoService.startGenerationProgress({featureType:"outpaint"})}closeProgress(t){this.aiPhotoService.completeGenerationProgress()}closeProgressImmediate(){this.clearTimeInterval(),this.aiPhotoService.clearGenerationProgress()}clearTimeInterval(){this.interValId&&(clearInterval(this.interValId),this.interValId=null),this.interValId1&&(clearInterval(this.interValId1),this.interValId1=null)}
1showPresetPanZoomHint(){this.isCustomCategory||!this.selectedLayout||this.hasShownPresetHint||(this.hasShownPresetHint=!0,this.showPresetHint=!0,this.clearPresetHintTimer(),this.presetHintTimeoutId=setTimeout(()=>{this.showPresetHint=!1,this.presetHintTimeoutId=null},5e3))}hidePresetPanZoomHint(){this.showPresetHint&&(this.showPresetHint=!1,this.clearPresetHintTimer())}clearPresetHintTimer(){this.presetHintTimeoutId&&(clearTimeout(this.presetHintTimeoutId),this.presetHintTimeoutId=null)}addCredit(){this.step=1,this.aiGenService.aiCreditPlanCheckout({toolName:"outpaint"},()=>{})}}return(s=a).\u0275fac=function(t){return new(t||s)(e.rXU(Z.s),e.rXU(Ke.I),e.rXU(q.u),e.rXU(de.W),e.rXU(ne.A),e.rXU(ee.M),e.rXU(J.K))},s.\u0275cmp=e.VBU({type:s,selectors:[["ai-expand-mobile"]],viewQuery:function(t,i){if(1&t&&(e.GBs(Dd,5),e.GBs(Nd,5)),2&t){let o;e.mGM(o=e.lsd())&&(i.presetStripRef=o.first),e.mGM(o=e.lsd())&&(i.cpText=o.first)}},hostBindings:function(t,i){1&t&&e.bIt("pointerdown",function(){return i.onUserPointerAction()},!1,e.EBC)("keydown",function(){return i.onUserKeyAction()},!1,e.EBC)("wheel",function(){return i.onUserWheelAction()},!1,e.EBC)},inputs:{imageUrl:"imageUrl"},outputs:{inputImageUnavailable:"inputImageUnavailable"},features:[e.OA$],decls:5,vars:5,consts:[["presetStrip",""],["cpText",""],[1,"d-flex","w-100","flex-column","ai-expand-mobile"],[1,"ai-expand-editor-mobile"],[1,"ai-expand-result-mobile"],[4,"ngIf"],[1,"expand-preview-shell","position-relative","ps-3","pe-3"],[1,"expand-preview-host",3,"imageUrl"],[1,"expand-preview-host",3,"imageUrl","enableAspectFrame","ratioWidth","ratioHeight","layoutKey"],[1,"preset-pan-zoom-hint","text-12","text-semi","text-white","bg-primary","position-absolute","border-radius-20","d-inline-flex","align-items-center"],[1,"expand-controls-wrapper"],[1,"expand-controls-scroll"],[1,"ps-3","pe-3"],[1,"mode-switch","d-flex","align-items-center","justify-content-center","h-32"],["type","button",1,"btn","text-13","text-dark","d-flex","align-items-center","justify-content-center","w-100","mode-tab",3,"click"],[1,"mode-separator"],[1,"prompt-row","d-flex","align-items-center","mt-10","ps-3","pe-3"],[1,"expand-prompt-trigger","w-100","d-flex","align-items-center",3,"click"],["name","promptedit",1,"f-20","grey-500","me-2"],["type","text","placeholder","Add prompt (Optional)","readonly","",1,"expand-prompt-input-field","text-13","text-medium","w-100","border-0","text-truncate",3,"focus","value"],[1,"expand-controls-body","mt-3"],[1,"preset-strip","d-flex","ps-3"],[1,"freeform-info","d-flex","align-items-center","justify-content-center","text-normal","grey-800","text-center"],[1,"generate-wrap","d-flex","align-items-center","justify-content-center","w-100","ps-3","pe-3"],["type","button",1,"btn","btn-primary-gradient","btn-primary-m","btn-h44","w-100","d-flex","align-items-center","justify-content-center",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,"text-11","text-semi",2,"padding-left","2px"],[1,"expand-preview-host",3,"stateChange","imageUrl"],[1,"expand-preview-host",3,"stateChange","imageUrl","enableAspectFrame","ratioWidth","ratioHeight","layoutKey"],["name","dragImageOpen",1,"f-24"],["type","button",1,"preset-item","border-0","bg-transparent","d-flex","flex-column","text-center","me-3",3,"active"],["type","button",1,"preset-item","border-0","bg-transparent","d-flex","flex-column","text-center","me-3",3,"click"],[1,"preset-thumb","border-radius-12","d-flex","align-items-center","justify-content-center"],[1,"preset-ratio-box","d-flex","align-items-center","justify-content-center"],[1,"f-24","grey-500",3,"name"],[1,"text-12","text-medium","grey-600","mt-2"],[1,"text-12","text-medium","grey-600"],[1,"preview-shell",2,"overflow","inherit !important"],[1,"w-100","h-100","d-block",3,"activeImageUrlChange","downloadRequested","images","sourceImageUrl","fallbackImageUrl","inProgress","focusAssetId"],[1,"variation-controls"],["type","button",1,"generate-btn",3,"click","disabled"],[1,"credit-chip"],["src","https://static.lightxeditor.com/assets/images/coin-new.png","height","20px","width","20px",1,"inable"],["src","https://static.lightxeditor.com/assets/images/coin-new-disabled.png","height","20px","width","20px",1,"disable"],[1,"credit-count"],[1,"p-3","pt-9","pb-9","position-fixed","bg-white","w-100",2,"bottom","0px","z-index","9999","border-radius","20px 20px 0px 0px"],[1,"wp-100","d-flex","align-items-center","justify-content-between"],[1,"text-lg","text-semi","grey-800"],["name","previewclose",3,"click"],[1,"card","drawer-card","mt-3","mb-0"],[1,"card-body"],[1,"btn-panel"],[1,"card-body","prompt-view"],[1,"textarea-col",3,"ngClass"],["
1id","expandPrompt","name","expandPrompt","rows","4","cols","50",1,"prompt-text",3,"ngModelChange","keyup","paste","focus","blur","keydown.enter","maxlength","ngModel"],["class","prompt-info prompt-info-span text-regular position-relative d-flex align-items-center h-24",4,"ngIf"],[1,"d-flex","align-items-center","justify-content-center","w-100","mt-3"],["type","button",1,"btn","btn-primary-gradient","btn-primary-m","btn-h44","w-100","d-flex","align-items-center","justify-content-center",3,"click"],[1,"showpreview-overlay","align-items-center","justify-content-start","position-fixed","d-flex",3,"click"],[1,"prompt-info","prompt-info-span","text-regular","position-relative","d-flex","align-items-center","h-24"],[3,"close","addCredit","consumeCoins"]],template:function(t,i){1&t&&(e.j41(0,"div",2),e.DNE(1,Kd,33,24,"div",3)(2,Zd,12,10,"div",4),e.k0s(),e.DNE(3,Qd,19,10)(4,eh,2,1,"ng-container",5)),2&t&&(e.AVh("result-mode",i.isResultView),e.R7$(),e.vxM(i.isResultView?2:1),e.R7$(2),e.vxM(i.isPromptEditorOpen?3:-1),e.R7$(),e.Y8G("ngIf",3==i.step))},dependencies:[b.YU,b.bT,P.me,P.BC,P.tU,P.vS,H.b,pe,Xt,Rd,Ud],styles:['[_nghost-%COMP%]{display:block;width:100%;height:100%}.ai-expand-mobile[_ngcontent-%COMP%]{display:flex;flex-direction:column;height:100%;min-height:0;padding:12px 0 4px;background:#f8f9f9;box-sizing:border-box;position:relative}.ai-expand-editor-mobile[_ngcontent-%COMP%]{display:flex;flex-direction:column;flex:1;min-height:0}.expand-preview-shell[_ngcontent-%COMP%]{flex:1 1 auto;min-height:0;overflow:hidden;background:transparent;margin-bottom:20px;position:relative}.expand-preview-shell[_ngcontent-%COMP%]   .expand-preview-host[_ngcontent-%COMP%]{display:flex;width:100%;height:100%;min-height:0}.expand-controls-wrapper[_ngcontent-%COMP%]{display:flex;flex-direction:column;flex:0 0 auto;flex-shrink:0;gap:12px}.expand-controls-scroll[_ngcontent-%COMP%]{flex:0 0 auto;overflow:visible}.expand-controls-scroll[_ngcontent-%COMP%]::-webkit-scrollbar{display:none}.expand-controls-scroll.custom-mode[_ngcontent-%COMP%]{display:block}.preset-pan-zoom-hint[_ngcontent-%COMP%]{left:50%;top:calc(50% - 22px);transform:translate(-50%);padding:8px 12px 8px 8px;z-index:6;gap:8px;white-space:nowrap}.mode-switch[_ngcontent-%COMP%]{background:#efeef2;border-radius:99px;padding:0 2px;margin:0 18px}.mode-switch[_ngcontent-%COMP%]   .btn[_ngcontent-%COMP%], .mode-switch[_ngcontent-%COMP%]   .mode-tab[_ngcontent-%COMP%]{position:relative;white-space:nowrap;border-radius:99px;height:28px;background:transparent}.mode-switch[_ngcontent-%COMP%]   .btn[_ngcontent-%COMP%]:active, .mode-switch[_ngcontent-%COMP%]   .btn[_ngcontent-%COMP%]:focus-visible, .mode-switch[_ngcontent-%COMP%]   .btn[_ngcontent-%COMP%]:focus, .mode-switch[_ngcontent-%COMP%]   .mode-tab[_ngcontent-%COMP%]:active, .mode-switch[_ngcontent-%COMP%]   .mode-tab[_ngcontent-%COMP%]:focus-visible, .mode-switch[_ngcontent-%COMP%]   .mode-tab[_ngcontent-%COMP%]:focus{border:none}.mode-switch[_ngcontent-%COMP%]   .btn.is-selected[_ngcontent-%COMP%]{background:#fff!important;border:.5px solid rgba(0,0,0,.04)}
1.mode-separator[_ngcontent-%COMP%]{position:absolute;top:50%;right:-1px;z-index:1;width:1px;height:12px;background-color:#959aa7;opacity:.3;border-radius:.5px;transform:translateY(-50%);pointer-events:none}.mode-separator.is-hidden[_ngcontent-%COMP%]{display:none}.expand-prompt-trigger[_ngcontent-%COMP%]{height:40px;border-radius:12px;background:linear-gradient(90deg,#fc5cff05 -4%,#2520f605);border:1px solid #E2E3E9!important;padding:0 8px 0 4px;text-align:left}.expand-prompt-input-field[_ngcontent-%COMP%]{background:transparent;outline:none;cursor:pointer;color:#272b34}.expand-prompt-input-field[_ngcontent-%COMP%]::placeholder{color:#606576}.showpreview-overlay[_ngcontent-%COMP%]{position:fixed;right:0;left:0;background:#0003;-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);z-index:2;width:100%;height:100%;top:0;bottom:0}.prompt-view[_ngcontent-%COMP%]   .textarea-col[_ngcontent-%COMP%]{width:100%;height:188px;border-radius:12px;background:#eeedf3;padding:4px;border:0px!important}.prompt-view[_ngcontent-%COMP%]   .textarea-col[_ngcontent-%COMP%]:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:12px;padding:.92px;border:none;background:linear-gradient(90deg,#c9cad4 -4% 100%);-webkit-mask:linear-gradient(90deg,#C9CAD4 -4%,#C9CAD4 100%) content-box,linear-gradient(90deg,#C9CAD4 -4%,#C9CAD4 100%);-webkit-mask-composite:xor;mask-composite:exclude;z-index:1}.prompt-view[_ngcontent-%COMP%]   .textarea-col[_ngcontent-%COMP%]:hover{border:1px solid #B0B3BF}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]{resize:none;outline:none;width:100%;height:148px;padding:8px;font-size:13px;color:#b0b3bf;border:0px;background:transparent;border-radius:12px;line-height:18px;overflow:auto;position:relative;z-index:2;line-height:125%}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]::-webkit-scrollbar{width:4px;height:4px;border-radius:12px}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]::-webkit-scrollbar-track{background:#e3e3e3;border-radius:12px;margin-top:8px}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background:#9a9a9a;border-radius:12px}.prompt-view[_ngcontent-%COMP%]   textarea[_ngcontent-%COMP%]::-webkit-scrollbar-thumb:hover{background:#555}.prompt-view[_ngcontent-%COMP%]   .prompt-info[_ngcontent-%COMP%]{font-size:11px;color:#b0b3bf;margin-top:0;padding-left:8px;line-height:140%}.prompt-text[_ngcontent-%COMP%]{color:#272b34!important}.info-up[_ngcontent-%COMP%]{border:1px solid #B0B3BF!important;background:#eeedf3!important}.info-blue[_ngcontent-%COMP%]{background:linear-gradient(90deg,#fc5cff0d -4%,#2520f60d)!important}.info-blue[_ngcontent-%COMP%]:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:12px;padding:.92px;border:none;background:linear-gradient(90deg,#fc5cff -4%,#2520f6)!important;-webkit-mask:linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%) content-box,linear-gradient(90deg,#FC5CFF -4%,#2520F6 100%)!important;-webkit-mask-composite:xor!important;mask-composite:exclude!important;z-index:1}.info-blue[_ngcontent-%COMP%]   span[_ngcontent-%COMP%]{color:#626adf!important}.info-red[_ngcontent-%COMP%]{background:linear-gradient(90deg,#fc5cff0d -4%,#2520f60d)!important}.info-red[_ngcontent-%COMP%]:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:12px;padding:.92px;border:none;background:linear-gradient(90deg,#f25555 -4% 100%)!important;-webkit-mask:linear-gradient(90deg,#F25555 -4%,#F25555 100%) content-box,linear-gradient(90deg,#F25555 -4%,#F25555 100%)!important;-webkit-mask-composite:xor!important;mask-composite:exclude!important;z-index:1}.info-red[_ngcontent-%COMP%]   span[_ngcontent-%COMP%]{color:#f25555!important}.expand-controls-body[_ngcontent-%COMP%]{flex:0 0 auto;height:136px;min-height:136px;overflow:hidden}.preset-strip[_ngcontent-%COMP%]{scrollbar-width:none;height:100%;min-height:0;padding-left:2px;overflow-x:auto;overflow-y:hidden}.preset-item[_ngcontent-%COMP%]{width:92px;min-width:92px;padding:0}.preset-thumb[_ngcontent-%COMP%]{width:92px;height:92px;background:#f2f3f7;border:1px solid transparent}.preset-ratio-box[_ngcontent-%COMP%]{border-radius:7px;background:#e2e3e9}.preset-item.active[_ngcontent-%COMP%]   .preset-thumb[_ngcontent-%COMP%]{border-color:#626adf;box-shadow:inset 0 0 0 1px #626adf}.preset-text-active[_ngcontent-%COMP%], .preset-ratio-active[_ngcontent-%COMP%]{color:#626adf!important}.preset-text-active[_ngcontent-%COMP%]{font-weight:600}.freeform-info[_ngcontent-%COMP%]{height:100%;min-height:0;padding:0 8px}.generate-wrap[_ngcontent-%COMP%]{flex:0 0 auto;margin-top:0}.btn[_ngcontent-%COMP%]:disabled   .coin-count[_ngcontent-%COMP%]{background:#0000001a}.btn[_ngcontent-%COMP%]:disabled   .coin-count[_ngcontent-%COMP%]   b[_ngcontent-%COMP%]{color:#fff!important}.btn[_ngcontent-%COMP%]:disabled   .inable[_ngcontent-%COMP%]{display:none}.btn[_ngcontent-%COMP%]:disabled   .disable[_ngcontent-%COMP%]{display:block}.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}.coin-count[_ngcontent-%COMP%]   b[_ngcontent-%COMP%]{color:#fff!important}.ai-expand-result-mobile[_ngcontent-%COMP%]{display:flex;flex-direction:column;height:calc(100dvh - 48px);min-height:0;padding:12px 16px 4px;background:#f8f9f9;box-sizing:border-box;position:relative}.preview-shell[_ngcontent-%COMP%]{flex:1;min-height:0;border-radius:12px;overflow:hidden;background:#efeef2;margin-bottom:20px;position:relative}.variation-controls[_ngcontent-%COMP%]{display:flex;flex-direction:column;gap:16px;margin-top:auto}.generate-btn[_ngcontent-%COMP%]{height:48px;width:100%;border:0;border-radius:12px;background:#d9d9d9;color:#fff;font-size:16px;font-weight:600;display:inline-flex;align-items:center;justify-content:center;gap:8px}.generate-btn.is-active[_ngcontent-%COMP%]{background:linear-gradient(90deg,#fc5cff,#2520f6)}.generate-btn[_ngcontent-%COMP%]:disabled{background:#d5d6dd;border:1px solid #d5d6dd;cursor:not-allowed;opacity:.9}.credit-chip[_ngcontent-%COMP%]{display:inline-flex;align-items:center;gap:2px;min-width:42px;height:24px;padding:0 6px 0 4px;border-radius:8px;background:#ffffff1a;font-size:13px;line-height:1.25}.credit-count[_ngcontent-%COMP%]{min-width:12px;text-align:center;color:#fff}.inable[_ngcontent-%COMP%]{display:block}.disable[_ngcontent-%COMP%]{display:none}.generate-btn[_ngcontent-%COMP%]:disabled   .inable[_ngcontent-%COMP%]{display:none}.generate-btn[_ngcontent-%COMP%]:disabled   .disable[_ngcontent-%COMP%]{display:block}
1[_nghost-%COMP%]     .intermediate-slider{height:100%}[_nghost-%COMP%]     .intermediate-image-area{height:100%!important}[_nghost-%COMP%]     .res-round{height:auto!important}[_nghost-%COMP%]     .downloadBtn{z-index:1!important}']}),a})();const ih=["inputFile"],nh=["file"],oh=(s,a)=>({mobileRetouchHeight:s,mobileExpressionHeight:a});function sh(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",16)(1,"tool-list-drawer",17),e.bIt("selectToolEvent",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.selectTool(i))}),e.k0s()()}if(2&s){const n=e.XpG();e.R7$(),e.Y8G("activeTab",n.activeTab)("selectedFeatureType",n.featureType)("isToolListVisible",!n.featureType)}}function rh(s,a){if(1&s&&(e.j41(0,"div",18)(1,"div",19),e.nrm(2,"app-ai-processing-bar",20),e.k0s(),e.j41(3,"div",21)(4,"div",22),e.nrm(5,"div",23)(6,"div",24)(7,"div",25),e.k0s()()()),2&s){const n=e.XpG();e.R7$(2),e.Y8G("progress",0)("message",n.GlobalConstants.label.processingImage)("indeterminate",!0)}}function ah(s,a){if(1&s&&e.nrm(0,"body-reshape",38),2&s){const n=e.XpG(2);e.Y8G("checkimg",n.checkimg)}}function lh(s,a){if(1&s){const n=e.RV6();e.j41(0,"face-expression",39),e.bIt("changeStep",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onGenerateV1Step(i))}),e.k0s()}if(2&s){const n=e.XpG(2);e.Y8G("checkimg",n.checkimg)}}function ch(s,a){if(1&s){const n=e.RV6();e.j41(0,"face-reshape-mobile",39),e.bIt("changeStep",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onGenerateV1Step(i))}),e.k0s()}if(2&s){const n=e.XpG(2);e.Y8G("checkimg",n.checkimg)}}function dh(s,a){if(1&s&&(e.j41(0,"div",40),e.nrm(1,"ai-upscale-editor-mobile",41),e.k0s()),2&s){const n=e.XpG(2);e.R7$(),e.Y8G("imageUrl",n.aiPhotoService.imgUrl)}}function hh(s,a){if(1&s&&(e.j41(0,"div",42),e.nrm(1,"ai-change-variation-mobile",43),e.k0s()),2&s){const n=e.XpG(2);e.R7$(),e.Y8G("featureType",n.featureType)("imageUrl",n.aiPhotoService.imgUrl)}}function ph(s,a){if(1&s){const n=e.RV6();e.j41(0,"ai-generate-v3",39),e.bIt("changeStep",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onGenerateV1Step(i))}),e.k0s()}if(2&s){const n=e.XpG(2);e.Y8G("checkimg",n.checkimg)}}function mh(s,a){if(1&s){const n=e.RV6();e.j41(0,"quick-edits",44),e.bIt("openCloseEvent",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.changequckedit(i))})("updateImageEvent",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.updateImageEvent(i))}),e.k0s()}if(2&s){const n=e.XpG(2);e.Y8G("selectedTool",n.selectedTool)("imgUrl",n.aiPhotoService.imgUrl)("step",2)}}function uh(s,a){if(1&s){const n=e.RV6();e.j41(0,"ecommerce-ai-tools-mobile",45),e.bIt("openCloseEvent",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.changequckedit(i))})("updateImageEvent",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.updateImageEvent(i))}),e.k0s()}if(2&s){const n=e.XpG(2);e.Y8G("selectedTool",n.ecommerceSelectedTool)("imgUrl",n.aiPhotoService.imgUrl)}}function gh(s,a){if(1&s){const n=e.RV6();e.j41(0,"ai-generate-v1",46),e.bIt("changeStep",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.onGenerateV1Step(i))})("uploadFileEvent",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.uploadFile(i))}),e.k0s()}if(2&s){const n=e.XpG(2);e.Y8G("featureType",n.featureType)("activeTab",n.activeTab)("checkimg",n.checkimg)}}function _h(s,a){if(1&s){const n=e.RV6();e.j41(0,"ai-generate-v2",47),e.bIt("uploadFileEvent",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.uploadFile(i))}),e.k0s()}if(2&s){const n=e.XpG(2);e.Y8G("featureType",n.featureType)("checkimg",n.checkimg)}}function fh(s,a){if(1&s){const n=e.RV6();e.j41(0,"ai-generate-v4",48),e.bIt("changeInspiration",function(i){e.eBV(n);const o=e.XpG(2);return e.Njj(o.changeInspiration(i))}),e.k0s()}if(2&s){const n=e.XpG(2);e.Y8G("featureType",n.featureType)("productId",n.productId)}}function vh(s,a){if(1&s&&(e.j41(0,"div",49),e.nrm(1,"ai-cleanup",41),e.k0s()),2&s){const n=e.XpG(2);e.R7$(),e.Y8G("imageUrl",n.aiPhotoService.imgUrl)}}function bh(s,a){if(1&s&&(e.j41(0,"div",49),e.nrm(1,"ai-replace",41),e.k0s()),2&s){const n=e.XpG(2);e.R7$(),e.Y8G("imageUrl",n.aiPhotoService.imgUrl)}}function Ch(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",49)(1,"ai-expand-mobile",50),e.bIt("inputImageUnavailable",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.handleMissingExpandImage())}),e.k0s()()}if(2&s){const n=e.XpG(2);e.R7$(),e.Y8G("imageUrl",n.aiPhotoService.imgUrl)}}function xh(s,a){1&s&&e.nrm(0,"div")}function Ph(s,a){if(1&s&&(e.qex(0),e.DNE(1,xh,1,0,"div",13),e.bVm()),2&s){e.XpG(2);const n=e.sdS(16);e.R7$(),e.Y8G("ngTemplateOutlet",n)}}function Ih(s,a){if(1&s){const n=e.RV6();e.qex(0),e.j41(1,"add-credit",51),e.bIt("close",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.addCredit=!1)})("addCredit",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.addCredits())}),e.k0s(),e.bVm()}}function yh(s,a){if(1&s&&(e.j41(0,"div"),e.DNE(1,ah,1,1,"body-reshape",26)(2,lh,1,1,"face-expression",27)(3,ch,1,1,"face-reshape-mobile",27)(4,dh,2,1,"div",28)(5,hh,2,2,"div",29)(6,ph,1,1,"ai-generate-v3",27)(7,mh,1,3,"quick-edits",30)(8,uh,1,2,"ecommerce-ai-tools-mobile",31),e.qex(9,32),e.DNE(10,gh,1,3,"ai-generate-v1",33)(11,_h,1,2,"ai-generate-v2",34)(12,fh,1,2,"ai-generate-v4",35),e.bVm(),e.DNE(13,vh,2,1,"div",36)(14,bh,2,1,"div",36)(15,Ch,2,1,"div",36)(16,Ph,2,1,"ng-container",37)(17,Ih,2,0,"ng-container",37),e.k0s()),2&s){const n=e.XpG();e.AVh("d-none",n.videoPreview),e.R7$(),e.Y8G("ngIf","aireshape"==n.featureType),e.R7$(),e.Y8G("ngIf","expression"==n.featureType),e.R7$(),e.Y8G("ngIf","facereshape"==n.featureType),e.R7$(),e.Y8G("ngIf","upscale"==n.featureType&&n.activeTab==n.navigationPanelName.AI_PHOTO_EDITING_TOOLS),e.R7$(),e.Y8G("ngIf",("changecameraangle"==n.featureType||"changelighting"==n.featureType)&&n.activeTab==n.navigationPanelName.AI_PHOTO_EDITING_TOOLS),e.R7$(),e.Y8G("ngIf","airetouch"==n.featureType),e.R7$(),e.Y8G("ngIf","quick-edit-tools"==n.activeTab&&!n.isEcommerceFeature()),e.R7$(),e.Y8G("ngIf",n.isEcommerceFeature()),e.R7$(),e.Y8G("ngSwitch",n.version),e.R7$(),e.Y8G("ngSwitchCase","v1"),e.R7$(),e.Y8G("ngSwitchCase","v2"),e.R7$(),e.Y8G("ngSwitchCase","v4"),e.R7$(),e.Y8G("ngIf","eraser"==n.featureType),e.R7$(),e.Y8G("ngIf","replace"==n.featureType),e.R7$(),e.Y8G("ngIf","expand"==n.featureType),e.R7$(),e.Y8G("ngIf",n.isLogin),e.R7$(),e.Y8G("ngIf",n.addCredit)}}function wh(s,a){if(1&s){const n=e.RV6();e.j41(0,"div")(1,"inspiration-mobile",52),e.bIt("changeStep",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.changeInspirationStep(i))}),e.k0s()()}if(2&s){const n=e.XpG();e.AVh("d-none",n.videoPreview),e.R7$(),e.Y8G("aiPhotoService",n.aiPhotoService)("activeImgObj",n.activeImgObj)("productId",null==n.aiPhotoService||null==n.aiPhotoService.queryParams?null:n.aiPhotoService.queryParams.productId)}}function Sh(s,a){if(1&s){const n=e.RV6();e.j41(0,"div")(1,"inspirations-edit-mobile",53),e.bIt("changeStep",function(i){e.eBV(n);const o=e.XpG();return e.Njj(o.changeStep(i))}),e.k0s()()}if(2&s){const n=e.XpG();e.AVh("d-none",n.videoPreview),e.R7$(),e.Y8G("aiPhotoService",n.aiPhotoService)("returnStep",n.returnStep)("isMobile",!0)("activeImgObj",n.activeImgObj)}}function Mh(s,a){1&s&&e.nrm(0,"div")}function kh(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",56)(1,"span",57),e.EFF(2,' Once completed, find your generated video under "AI Generations". '),e.k0s(),e.j41(3,"button",58),e.bIt("click",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.goToAiGenerations())}),e.EFF(4," Go to AI Generations "),e.k0s(),e.j41(5,"button",59),e.bIt("click",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.notifyWhenVideoDone())}),e.EFF(6," Notify When Done "),e.k0s()()}}function Th(s,a){if(1&s&&(e.j41(0,"div",54)(1,"div",19),e.nrm(2,"app-ai-processing-bar",20),e.k0s(),e.j41(3,"div",21)(4,"div",22),e.nrm(5,"div",23)(6,"div",24)(7,"div",25),e.k0s()(),e.DNE(8,kh,7,0,"div",55),e.k0s()),2&s){const n=e.XpG();e.R7$(2),e.Y8G("progress",n.processingProgress.progressPercent)("message",n.processingProgress.isActive?n.processingProgress.progressMessage:n.GlobalConstants.label.processingImage)("indeterminate",!n.processingProgress.isActive||n.processingProgress.indeterminate),e.R7$(6),e.Y8G("ngIf",n.aiPhotoService.inVideoProgress||n.processingProgress.isVideo)}}function Oh(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",60),e.nrm(1,"img",61),e.j41(2,"div",62)(3,"h4",63),e.EFF(4,"Congratulations!"),e.k0s(),e.j41(5,"span",64),e.EFF(6),e.k0s()(),e.j41(7,"div",65)(8,"span",66),e.EFF(9,"1 generation ="),e.k0s(),e.j41(10,"span",67),e.nrm(11,"img",68),e.k0s(),e.j41(12,"span",66),e.EFF(13,"1 credit"),e.k0s()(),e.j41(14,"button",69),e.bIt("click",function(){e.eBV(n);const i=e.XpG();return e.Njj(i.isLogin=!1)}),e.EFF(15,"Got it"),e.k0s()()}if(2&s){const n=e.XpG();e.R7$(6),e.SpI(" You now have ",null==n.user?null:n.user.remainingCoins," free AI credits everyday. ")}}function Eh(s,a){1&s&&(e.j41(0,"div",70)(1,"div",71)(2,"div",72)(3,"div",73)(4,"div",74),e.nrm(5,"pi",75),e.k0s(),e.j41(6,"div",76)(7,"h6",77),e.EFF(8,"Video generation in progress\u2026"),e.k0s(),e.j41(9,"span",78),e.EFF(10,"This usually takes 1-3 minutes. We'll notify you when it's done. "),e.k0s()()()()()())}function jh(s,a){if(1&s){const n=e.RV6();e.j41(0,"div",79),e.bIt("click",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.aiPhotoService.isVideoNotified=!1)}),e.j41(1,"div",71)(2,"div",72)(3,"div",80)(4,"button",81),e.bIt("click",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.closeModal())}),e.nrm(5,"pi",82),e.k0s(),e.j41(6,"div")(7,"div",74),e.nrm(8,"pi",83),e.k0s(),e.j41(9,"div",76)(10,"h6",84),e.EFF(11,"Done! Your video is ready"),e.k0s()()(),e.j41(12,"button",85),e.bIt("click",function(){e.eBV(n);const i=e.XpG(2);return e.Njj(i.goTo(1))}),e.EFF(13,"View Now"),e.k0s()()()()()}}function Gh(s,a){if(1&s&&e.DNE(0,Eh,11,0,"div",70)(1,jh,14,0,"div",70),2&s){const n=e.XpG();e.vxM(n.isNotifyRegistered?0:n.aiPhotoService.isVideoNotified&&n.result?1:-1)}}const Vh=[{path:"",redirectTo:"edit",pathMatch:"full"},{path:"edit",component:(()=>{var s;class a{constructor(t,i,o,r,l,c,d,h,p,u,g,_,v,C,M,k,j){this.aiUploadImageService=t,this.route=i,this.router=o,this.seoService=r,this.subsService=l,this.dialogService=c,this.aiPhotoService=d,this.authService=h,this.location=u,this.gtmService=g,this.modalService=_,this.aiGenService=v,this.storyPageService=C,this.toastService=M,this.processingProgress=k,this.ecommerceAiToolsService=j,this.GlobalConstants=y.b,this.close=new e.bkB,this.link="/",this.step=1,this.editorType=f._Y.AIPhoto,this.isLoaded=!1,this.isLogin=!1,this.showAds=!1,this.enableAds=0,this.addCredit=!1,this.intermediateView=!0,this.v1Tools=["avatar","selfie","photoshoot","aifilter"],this.isInspiration=!1,this.returnStep=1,this.quickeditTool=null,this.isProUser=!1,this.isOpeningTool=!1,this.photoEditorTools=[f.Fs.FaceRetouch,f.Fs.BodyReshape,f.Fs.FaceExpression,f.Fs.FaceRe
1shape],this.photoEditingTools=[f.Fs.Upscale,f.Fs.cleanup,f.Fs.replace,f.Fs.Expand,f.Fs.ChangeCameraAngle,f.Fs.ChangeLighting],this.navigationPanelName=z.sv,this.editInspiration=!1,this.productId=0,this.isOpenFile=!0,this.isNotifyRegistered=!1,this.subscriptions=[],this.videoPreview=!1,this.prompt="",this.videoUrl="",this.checkimg=!0,this.user=this.authService.currentUser(),this.loggedInObserver=this.authService.loggedIn.subscribe(G=>{this.user=this.authService.currentUser()}),this.usrPropChangedObserver=this.authService.usrPropChanged.subscribe(G=>{this.user=this.authService.currentUser()}),this.updateBehaviorUserAiConis=this.authService.updateBehaviorUserAiConis.subscribe(G=>{this.user=this.authService.currentUser()}),this.user&&this.authService.updateUserAiConis("loggedIn"),p.onPopState(()=>{this.modalService.hasOpenModals()&&this.modalService.dismissAll("")}),this.subscriptions.push(this.aiPhotoService.backBtnClick.subscribe(G=>{G?.isNotified&&(this.isNotifyRegistered=!0,this.aiPhotoService.isVideoNotified=!0,setTimeout(()=>{this.isNotifyRegistered=!1},5e3))})),this.subscriptions.push(this.aiPhotoService.checkStatusSub.subscribe(G=>{G?.urls&&G?.isVideo&&this.aiPhotoService.isVideoNotified?this.result=G:G?.isVideo&&!G?.urls&&(this.result=null,this.aiPhotoService.isVideoNotified=!1,this.videoPreview=!1)}))}ngOnInit(){"true"===sessionStorage.getItem("isBack")&&(sessionStorage.removeItem("isBack"),this.location.back()),"true"==this.aiPhotoService?.queryParams?.isBack&&this.aiPhotoService?.queryParams?.imgUrl&&this.aiPhotoService.activeTool==z.sv.FACE_BODY_TOOLS?(this.aiPhotoService.imgUrl=this.aiPhotoService.originalImgUrl=this.aiPhotoService?.queryParams?.imgUrl,this.aiPhotoService.queryParams.isBack=null):this.aiPhotoService.imgUrl="",this.aiPhotoService.queryParams=Object.assign({},this.route.snapshot.queryParams),this.checkimg="false"!==this.aiPhotoService?.queryParams?.checkimg,this.aiPhotoService.imgUrl=this.aiPhotoService.originalImgUrl=this.aiPhotoService.queryParams.imgUrl=this.aiPhotoService.imgUrl||this.aiPhotoService?.queryParams?.imgUrl||"",this.aiPhotoService.originalImageUrlDuo=this.aiPhotoService?.queryParams?.imgUrl2||"",this.productId=this.aiPhotoService?.queryParams?.productId||0;const i=this.aiPhotoService?.queryParams?.tab||z.sv.AI_IMAGE_TOOLS,o=this.aiPhotoService?.queryParams?.toolName||"";this.activeTab=this.getNormalizedActiveTab(i,o),this.aiPhotoService.queryParams.tab=this.activeTab,this.aiPhotoService.activeTool=this.activeTab;const r=o;this.aiPhotoService.textPrompt=this.aiPhotoService?.queryParams?.tp||"",r&&this.requiresBlobUploadBeforeOpen(r)?(this.isOpeningTool=!0,this.aiPhotoService.inProgress=!0):this.featureType=r,document.body.classList.add("m-h-auto"),this.getStoryPageContent(()=>{if(r){const l=this.aiPhotoService.getToolByName(r,this.activeTab)||{metadata:{featureType:r}};l&&this.selectTool(l,!0)}}),this.subsService.handleBlogPromotionCheckout(this.aiPhotoService.queryParams),this.seoService.blockZoomOut()}selectTool(t,i=!1){if(this.selectedTool=t,this.version="",i||this.toastService.suspendPhotoEditsSuccess(),this.selectedTool){if(i&&t?.metadata?.featureType==f.Fs.Expand&&!this.aiPhotoService.imgUrl)return void this.handleMissingExpandImage();this.isNotFileTool()||this.shouldOpenWithoutInputImage(t,i)?(this.isOpeningTool=!1,this.featureType=t?.metadata?.featureType,this.activeTab=t?.metadata?.activeTab?t?.metadata?.activeTab:this.activeTab,this.getVersion(i)):this.aiPhotoService.imgUrl&&this.aiPhotoService.isValidBlobUrl(this.aiPhotoService.imgUrl)?this.openTool():(this.isOpeningTool=!1,this.aiPhotoService.inProgress=!1,t?.metadata?.featureType==f.Fs.AIVirtualTryOn?this.aiGenService.customFileClick(this.inputFile.nativeElement,"tryon-custom-popup"):this.chooseFile()),this.aiPhotoService.activeTool=this.activeTab}}handleMissingExpandImage(){this.featureType=null,this.selectedTool=null,this.version="",this.file=null,this.isOpeningTool=!1,this.aiPhotoService.inProgress=!1,this.aiPhotoService.imgUrl="",this.aiPhotoService.originalImgUrl="",this.aiPhotoService.queryParams={...this.aiPhotoService.queryParams||{}},delete this.aiPhotoService.queryParams.imgUrl,delete this.aiPhotoService.queryParams.toolName,this.router.navigate([],{queryParams:{toolName:null,imgUrl:null},queryParamsHandling:"merge",replaceUrl:!0}),this.toastService.showErrorSingle(y.b.message.uploadNewImage)}openTool(){var t=this;return(0,w.A)(function*(){const i=t.selectedTool?.metadata?.featureType,o=t.selectedTool?.metadata?.activeTab;if(t.aiPhotoService.isValidImageDataUrl(t.aiPhotoService.imgUrl)&&(t.file=t.aiPhotoService.imageDataURLtoFile(t.aiPhotoService.imgUrl,"untitled.png"),t.aiPhotoService.imgUrl=URL.createObjectURL(t.file)),(t.photoEditorTools.includes(i)||i==f.Fs.cleanup||i==f.Fs.replace||i==f.Fs.Expand||t.isQuickEditFlow(i,o)||t.ecommerceAiToolsService.isEcommerceFeatureType(i))&&(t.aiPhotoService.imgUrl||t.aiPhotoService.imgUrl&&t.aiPhotoService.isValidBlobUrl(t.aiPhotoService.imgUrl)))return t.isOpeningTool=!1,t.featureType=i,t.activeTab=o||t.activeTab,void t.getVersion();if(t.aiPhotoService.imgUrl&&t.aiPhotoService.isValidBlobUrl(t.aiPhotoService.imgUrl)){t.isOpeningTool=!0;const l={toolName:i,from:"tools",tab:i==f.Fs.Upscale?"upscale":t.activeTab,uploadProgress:!0,fromEditor:"header"};t.file?(t.aiPhotoService.startProcessingProgress({featureType:i,indeterminate:!0,message:y.b.label.uploadingImageProgress}),t.aiUploadImageService.aiUploadImage(t.file,l).then(c=>{if(t.file=null,"cancel"==c)return t.aiPhotoService.isCancel=!0,t.aiPhotoService.clearGenerationProgress(),t.isOpeningTool=!1,t.aiPhotoService.imgUrl=null,t.aiPhotoService.originalImgUrl=null,void(t.featureType=null);t.aiPhotoService.clearGenerationProgress(),t.aiPhotoService.imgUrl=c.imgUrl,t.aiPhotoService.originalImgUrl=c.imgUrl,t.featureType=i,t.activeTab=t.selectedTool?.metadata?.activeTab?t.selectedTool?.metadata?.activeTab:t.activeTab,t.isOpeningTool=!1,t.getVersion()}).catch(()=>{t.isOpeningTool=!1,t.aiPhotoService.clearGenerationProgress()})):fetch(t.aiPhotoService.imgUrl).then(function(){var c=(0,w.A)(function*(d){return yield d.blob()});return function(d){return c.apply(this,arguments)}}()).then(c=>{t.file=new File([c],"untitled.png",{type:c.type}),t.file&&t.openTool()}).catch(()=>{t.isOpeningTool=!1,t.aiPhotoService.inProgress=!1})}})()}ngOnDestroy(){this.seoService.removeZoomOut(),localStorage.removeItem("isChecked"),this.aiPhotoService.isCancel=!1,this.aiPhotoService.isBrowserRefresh=!1,this.aiPhotoService.isDirty=!1,this.aiPhotoService.selectedUpscaleImageUrl="",this.aiPhotoService.imgUrl=null,this.aiPhotoService.originalImgUrl=null,this.aiPhotoService.aiImages=[],this.aiPhotoService.mobileImageObj=null,this.aiPhotoService.isWorkflow=!1,document.body.classList.remove("overflow-hidden"),document.body.classList.remove("m-h-auto"),this.loggedInObserver&&this.loggedInObserver.unsubscribe(),this.usrPropChangedObserver&&this.usrPropChangedObserver.unsubscribe(),this.updateBehaviorUserAiConis&&this.updateBehaviorUserAiConis.unsubscribe(),this.subscriptions.forEach(t=>t?.unsubscribe())}logIn(){this.addCredit=!1,this.aiPhotoService.loginAndAICredit(t=>{this.user=this.authService.currentUser(),this.user&&t?.isFreeUser?this.isLogin=!0:this.user.remainingCoins||(this.addCredit=!0)})}changeStep(t){this.editInspiration=!1,t?.error?(this.step=t.step,this.file=null):t?.back?this.location.back():this.step=t}onGenerateV1Step(t){if(t?.resetToIntermediate)return this.isStoryTemplatePickerFlow()?void this.location.back():(this.featureType=null,this.selectedTool=null,this.version="",this.isOpeningTool=!1,this.aiPhotoService.selectedUpscaleImageUrl="",this.aiPhotoService.aiImages=[],this.aiPhotoService.mobileImageObj=null,this.toastService.resumePhotoEditsSuccess(),this.aiPhotoService.queryParams={...this.aiPhotoService.queryParams||{}},delete this.aiPhotoService.queryParams.productId,delete this.aiPhotoService.queryParams.prodImageId,delete this.aiPhotoService.queryParams.catId,void this.router.navigate([],{queryParams:{toolName:null,productId:null,prodImageId:null,catId:null},queryParamsHandling:"merge",replaceUrl:!0}))}changeInspiration(t,i=!1){if(!this.aiPhotoService.queryParams){const o={...this.route.
1snapshot.queryParams};this.aiPhotoService.queryParams=o}this.productId=t.productId&&!i?t.productId:0,this.aiPhotoService.queryParams.productId=this.productId,t.imgUrl=t.imgUrl?t.imgUrl:t.urls[0]?t.urls[0]:this.aiPhotoService.imgUrl,this.activeImgObj=t,this.aiPhotoService.compareImageUrl=t.imgUrl,this.aiPhotoService.inspirationImgUrl=t.imgUrl,this.editInspiration=!0}changeInspirationStep(t){this.productId=t?.productId?t?.productId:0,this.getVersion()}closeEditor(t){if(this.checkimg=!0,this.aiPhotoService?.queryParams?.toolName==f.Fs.Design&&("story"==this.aiPhotoService?.queryParams?.from||"explore"==this.aiPhotoService?.queryParams?.from)&&this.aiPhotoService.aiImages&&this.aiPhotoService.aiImages.length<=0)return this.aiPhotoService.aiImages=[],this.aiPhotoService.mobileImageObj=null,void this.location.back();if(this.aiPhotoService.isWorkflow&&this.aiPhotoService.aiImages.length>0)return void(this.aiPhotoService.isWorkflow=!1);const i=()=>{if(this.videoPreview||(this.aiPhotoService.aiImages=[]),this.videoPreview=!1,"back"==t?.type)return void this.aiPhotoService.backBtnClick.next({isBack:!0});if("apply"!=t?.type&&this.restoreImageOnCancel(),"story"==this.aiPhotoService?.queryParams?.from&&this.isTemplatePickerFlow(this.featureType||this.aiPhotoService?.queryParams?.toolName))return void this.location.back();this.featureType=null,this.aiPhotoService.isWorkflow=!1,this.step=0,this.version=null,this.isOpeningTool=!1,this.aiPhotoService.selectedUpscaleImageUrl="",this.isInspiration=!1,this.editInspiration=!1,this.videoUrl=null,this.toastService.resumePhotoEditsSuccess(),this.prompt=null,this.aiPhotoService.queryParams={...this.aiPhotoService.queryParams||{}},delete this.aiPhotoService.queryParams.productId,delete this.aiPhotoService.queryParams.prodImageId,delete this.aiPhotoService.queryParams.catId;const c={toolName:null,productId:null,prodImageId:null,catId:null};"apply"==t?.type&&(c.imgUrl=this.aiPhotoService.imgUrl),this.router.navigate([],{queryParams:c,queryParamsHandling:"merge",replaceUrl:!0})},o=()=>{"back"===t?.type&&this.aiPhotoService.backBtnClick.next({backBtnEnabled:!0,videoPreview:!!t?.videoPreview})};if((this.aiPhotoService.aiImages.length||this.videoPreview||t?.videoPreview)&&"apply"!=t?.type){const r={message:y.b.message.warningAiLostMessage,okButtonText:"Okay",cancelButtonText:"Cancel"};if("eraser"==this.featureType||"replace"==this.featureType)return void i();this.dialogService.confirmDialog(r).result.then(l=>{"ok"!=l?o():i()}).catch(()=>{o()})}else i()}addCredits(){this.addCredit=!1,this.subsService.upgradeAiPlanCheckout("","","Mob Editor AI Add Credits")}handleBeforeUnload(t){this.aiPhotoService.isDownloading||(4==this.step&&"v6"==this.version?sessionStorage.setItem("isBack","true"):sessionStorage.setItem("isBack","false"),t.preventDefault(),t.returnValue="")}updateImageEvent(t){if(t?.error)return this.aiPhotoService.clearGenerationProgress(),this.progress?.close(),this.progress=null,void this.toastService.showErrorSingle(t.error||y.b.message.somethingWrong);"string"!=typeof t?t?.hasOwnProperty?.("inProgress")||t===this.aiPhotoService||this.aiPhotoService.completeGenerationProgress(()=>{this.progress?.close(),this.progress=null}):this.aiPhotoService.completeGenerationProgress(()=>{this.progress?.close(),this.progress=null,this.aiPhotoService.imgUrl=t})}changequckedit(t){t?.addCredit?this.addCredit=!0:t?.isQuickEditOpen?this.aiPhotoService.imgUrl?(this.step=1,this.openTool()):(this.step=1,this.fileInput.nativeElement.click()):t?.isCancel&&(this.step=2)}getStoryPageContent(t=null){this.storyPageService.getStoryPageContent(y.b.slug.aiEditorTools,y.b.slug.aiEditorTools,y.b.slug.aiEditorTools,i=>{const o=i.body.storyPage;o&&o.sections&&o.sections.length>0&&(this.aiPhotoService.toolList=o.sections.find(r=>r.type==y.b.slug.aiEditorTools).steps,this.aiPhotoService.toolList.length>0&&this.aiPhotoService.toolList.forEach(r=>{r.links.forEach((l,c)=>{l.id=`${l.metadata.featureType}-${c+1}`})})),t&&t()},i=>{this.isLoaded=!0,console.log(i),t&&t()},"en")}uploadFile(t){if(this.file=t,this.file.isReplace)return this.aiPhotoService.imgUrl=window.URL.createObjectURL(this.file),void this.openTool()}onFileUploaded(t){t&&(this.file=t[0],this.aiPhotoService.imgUrl=window.URL.createObjectURL(this.file),this.isOpenFile&&this.openTool())}isEcommerceFeature(){return this.ecommerceAiToolsService.isEcommerceFeatureType(this.featureType)}restoreImageOnCancel(){if(!this.ecommerceAiToolsService.isEcommerceFeatureType(this.featureType))return;const t=this.aiPhotoService.compareImageUrl||this.aiPhotoService.originalImgUrl;t&&(this.aiPhotoService.imgUrl=t,this.aiPhotoService.isDirty=!1)}get ecommerceSelectedTool(){return this.ecommerceAiToolsService.getToolByFeatureType(this.featureType)}getVersion(t=!1){this.isOpenFile=!0,this.isEcommerceFeature()?(this.activeTab=z.sv.AI_QUICK_EDIT_TOOL,this.version=""):this.featureType==f.Fs.TextToImage||this.featureType==f.Fs.ImageToImage||this.featureType==f.Fs.SketchToImage?this.version="v2":this.featureType==f.Fs.Design?this.openAIDesignTool(t):this.isPhotoEditingTool(this.featureType,this.activeTab)?(this.activeTab=z.sv.AI_PHOTO_EDITING_TOOLS,this.version=""):this.version=this.activeTab==z.sv.AI_QUICK_EDIT_TOOL||this.activeTab==z.sv.FACE_BODY_TOOLS?"":"v1",t?setTimeout(()=>{this.aiPhotoService.deleteQueryParams(!1)},3e3):(this.activeTab==z.sv.AI_PHOTO_EDITING_TOOLS&&(this.aiPhotoService.inProgress=!1),this.router.navigate([],{queryParams:{toolName:this.featureType,tab:this.activeTab,subTool:this.featureType,imgUrl:this.aiPhotoService.imgUrl||""},replaceUrl:!0}))}chooseFile(t=!0){this.isOpenFile=t;const i=this.inputFile.nativeElement;i&&i.click()}isNotFileTool(){const t=this.selectedTool?.metadata?.featureType,i=this.aiPhotoService.imgUrl||"",o=i.startsWith("blob:")||i.startsWith("data:");return t==f.Fs.Design||t==f.Fs.TextToImage||t==f.Fs.TextToVideo||i&&!o||o&&(this.isQuickEditFlow(t,this.selectedTool?.metadata?.activeTab||this.activeTab)||this.ecommerceAiToolsService.isEcommerceFeatureType(t))}shouldOpenWithoutInputImage(t,i=!1){if(!i)return!1;const o=this.aiPhotoService?.queryParams||{},r=t?.metadata?.featureType;return"false"===o?.checkimg?(delete this.aiPhotoService?.queryParams?.checkimg,!0):this.isTemplatePickerFlow(r)&&!!o?.prodImageId}isTemplatePickerFlow(t){return"v5"==this.aiPhotoService?.queryParams?.lv||t==f.Fs.ImageToAnimate||t==f.Fs.Videoshoot||t==f.Fs.DuoVideoshoot||"duoimageanimate"==t}isPhotoEditingTool(t,i){return i==z.sv.AI_PHOTO_EDITING_TOOLS||this.photoEditingTools.includes(t)}requiresBlobUploadBeforeOpen(t){if(!t||!this.aiPhotoService.imgUrl||this.photoEditorTools.includes(t)||t==f.Fs.Expand||t==f.Fs.cleanup||t==f.Fs.replace||this.isQuickEditFlow(t,this.activeTab)||this.ecommerceAiToolsService.isEcommerceFeatureType(t))return!1;const i=this.aiPhotoService.imgUrl;return(i.startsWith("blob:")||i.startsWith("data:"))&&this.isPhotoEditingTool(t,this.activeTab)}isQuickEditFlow(t,i=this.activeTab){return i===z.sv.AI_QUICK_EDIT_TOOL||this.aiPhotoService?.queryParams?.tab===z.sv.AI_QUICK_EDIT_TOOL||!!(t&&this.aiPhotoService.quickEditTools?.length&&this.aiPhotoService.quickEditTools.some(o=>o.featureType===t))}getNormalizedActiveTab(t,i){return this.ecommerceAiToolsService.isEcommerceFeatureType(i)?z.sv.AI_QUICK_EDIT_TOOL:t==z.sv.AI_QUICK_EDIT_TOOL&&this.photoEditingTools.includes(i)?z.sv.AI_PHOTO_EDITING_TOOLS:t}isStoryTemplatePickerFlow(){return"story"==this.aiPhotoService?.queryParams?.from&&this.isTemplatePickerFlow(this.featureType||this.aiPhotoService?.queryParams?.toolName)}openAIDesignTool(t){const i=this.aiPhotoService.queryParams?.from,o=this.aiPhotoService.queryParams?.isEd;if(t&&("ai-generations"==i||"story"==i)&&o){if(this.version="v4",!this.aiPhotoService.mobileImageObj)return void this.location.back();this.editInspiration=!0,this.changeInspiration(this.aiPhotoService.mobileImageObj,t)}else this.isInspiration||t?(this.version="v4",this.editInspiration=!1,this.isInspiration=!1):this.isInspiration=!0}goTo(t){if(1===t){const i=this.result;if(!i)return;this.aiPhotoService.isVideoNotified=!1,this.aiPhotoService.backBtnClick.next({backBtnEnabled:!0}),i?.isVideo&&(this.videoPreview=!0,this.prompt=i?.prompt,this.videoUrl=i?.urls?.[0]),this.result=null,this.modalService.dismissAll()}}goToAiGenerations(){this.aiPhotoService.clearGenerationProgress(),this.videoPreview=!1,this.videoUrl=null,this.prompt=null,this.result=null,this.modalService.dismissAll(),this.router.navigate(["/my/ai-generations"])}notifyWhenVideoDone(){this.aiPhotoService.completeGenerationProgress(()=>{this.aiPhotoService.backBtnClick.next({isNotified:!0})})}closeModal(){this.aiPhotoService.isVideoNotified=!1,this.result=null,this.close.emit({notify:!0})}}return(s=a).\u0275fac=function(t){return new(t||s)(e.rXU(ee.M),e.rXU(A.nX),e.rXU(A.Ix),e.rXU(Ye.F),e.rXU(ue.n),e.rXU(ae.g),e.rXU(Z.s),e.rXU(q.u),e.rXU(b.Vw),e.rXU(b.aZ),e.rXU(ie.y),e.rXU(R.Bq),e.rXU(J.K),e.rXU(ge.K),e.rXU(Q.f),e.rXU($e.M),e.rXU(Ee.P))},s.\u0275cmp=e.VBU({type:s,selectors:[["app-ai-editor-mobile-view"]],viewQuery:function(t,i){if(1&t&&(e.GBs(ih,5),e.GBs(nh,5)),2&t){let o;e.mGM(o=e.lsd())&&(i.inputFile=o.first),e.mGM(o=e.lsd())&&(i.fileInput=o.first)}},hostBindings:function(t,i){1&t&&e.bIt("beforeunload",function(r){return i.handleBeforeUnload(r)},!1,e.tSv)},outputs:{close:"close"},features:[e.Jv_([J.K,me.X,{provide:Oe.n,useClass:Oe.B}])],decls:21,vars:25,consts:[["page",""],["login",""],["videoNotification",""],["inputFile",""],[1,"editor-tool-panel","hide-mobile-adds","mobileRetouch"],["id","editor-view",1,"ai-editor-view","d-flex","flex-column","w-100"],[3,"closeEvent","loginEvent","addCreditEvent","uploadFileEvent","user","checkimg","version","hideApplyBtn","featureType","activeTab"],[1,"d-flex","w-100","mobile-editor-area","gray-100","flex-column",3,"ngClass"],[1,"d-flex","w-100","intermediate-preview-height"],[1,"w-100",3,"chooseFileEvent","uploadFileEvent","featureType","videoPreview","checkimg","videoUrl","prompt"],["class","d-flex w-100 selectcategory",4,"ngIf"],["class","canvas-progress circle-animation remove-bg-animation",4,"ngIf"],[3,"d-none",4,"ngIf"],[4,"ngTemplateOutlet"],["class","canvas-progress circle-animation mobile-bg-animation",4,"ngIf"],["id","inputFile","name","inputFile","type","file",1,"custom-file-input","d-none",3,"change","click","accept"],[1,"d-flex","w-100","selectcategory"],[1,"overflow-hidden",3,"selectToolEvent","activeTab","selectedFeatureType","isToolListVisible"],[1,"canvas-progress","circle-animation","remove-bg-animation"],[1,"inner"],["size","lg",3,"progress","message","indeterminate"],[1,"canvas"],[1,"aurora-bg"],[1,"blob","blob-1"],[1,"blob","blob-2"],[1,"blob","blob-3"],[3,"checkimg",4,"ngIf"],[3,"checkimg","changeStep",4,"ngIf"],["class","",4,"ngIf"],["class","upscale-editor-wrapper",4,"ngIf"],[3,"selectedTool","imgUrl","step","openCloseEvent","updateImageEvent",4,"ngIf"],[3,"selectedTool","imgUrl","openCloseEvent","updateImageEvent",4,"ngIf"],[3,"ngSwitch"],[3,"featureType","activeTab","checkimg","changeStep","uploadFileEvent",4,"ngSwitchCase"],[3,"featureType","checkimg","uploadFileEvent",4,"ngSwitchCase"],[3,"featureType","productId","changeInspiration",4,"ngSwitchCase"],["class","ai-mobile-tool-screen",4,"ngIf"],[4,"ngIf"],[3,"checkimg"],[3,"changeStep","checkimg"],[1,""],[1,"w-100","h-100","d-block",3,"imageUrl"],[1,"upscale-editor-wrapper"],[1,"w-100","h-100","d-block",3,"featureType","imageUrl"],[3,"openCloseEvent","updateImageEvent","selectedTool","imgUrl","step"],[3,"openCloseEvent","updateImageEvent","selectedTool","imgUrl"],[3,"changeStep","uploadFileEvent","featureType","activeTab","checkimg"],[3,"uploadFileEvent","featureType","checkimg"],[3,"changeInspiration","featureType","productId"],[1,"ai-mobile-tool-screen"],[1,"w-100","h-100","d-block",3,"inputImageUnavailable","imageUrl"],[3,"close","addCredit"],[3,"changeStep","aiPhotoService","activeImgObj","productId"],[3,"changeStep","aiPhotoService","returnStep","isMobile","activeImgObj"],[1,"canvas-progress","circle-animation","mobile-bg-animation"],["class","ai-mobile-video-actions d-flex align-items-center justify-content-center flex-column w-100 ps-3 pe-3 pb-9 text-center",4,"ngIf"],[1,"ai-mobile-video-actions","d-flex","align-items-center","justify-content-center","flex-column","w-100","ps-3","pe-3","pb-9","text-center"],[1,"text-13","grey-500","text-medium","lh-160","text-regular","mb-3"],["type","button",1,"btn","btn-primary","btn-h48","text-lg","w-100",3,"click"],["type","button",1,"btn","btn-outline-primary","btn-h48","text-lg","w-100","mt-2",3,"click"],[1,"position-fixed","d-flex","align-items-center","justify-content-center","flex-column","w-100","mobile-congratulations","gray-100"],["src","https://static.lightxeditor.com/assets/images/mobile-congratulations.png","height","244px","width","232.272px","alt","Mobile Congratulations",1,"mb-14"],[1,"d-flex","align-items-center","justify-content-center","text-center","flex-column","w-100","mb-14"],[1,"grey-900","text-semi","text-28","mb-0"],[1,"grey-500","text-lg","text-semi","mt-9","ps-5","pe-5",2,"line-height","normal"],[1,"credit-description","d-flex","align-items-center","justify-content-center","w-100"],[1,"text-lg","grey-400","text-semi","d-inline-flex"],[1,"ms-2","me-2","d-inline-flex"],["src","https://static.lightxeditor.com/assets/images/coin-lottie-s-anim.gif","width","24px","height","24px","alt","Coin Lottie"],[1,"btn","btn-primary","btn-h48","mt-3",2,"width","169px",3,"click"],[1,"position-relative",2,"height","max-content"],[1,"drawer-elements","ai-drawer-elements"],[1,"align-items-center","justify-content-center","overflow-hidden","w-100","flex-column","p-3","pb-0"],[1,"video-in-progress","pt-9","pb-9","ps-3","pe-3","position-fixed","w-100","d-flex","align-items-start","border-radius-lg","overflow-hidden"],[1,"d-inline-flex","hw-24"],["name","rendering",1,"f-24","hw-24",2,"color","#FFB703"],[1,"d-inline-flex","align-items-start","justify-content-start","flex-column","ms-2",2,"width","calc(100% - 32px)"],[1,"text-14","text-semi","lh-160","text-white","mb-1"],[1,"text-13","text-reggular","lh-160","text-white"],[1,"position-relative",2,"height","max-content",3,"click"],[1,"video-in-progress","p-3","position-fixed","w-100","d-flex","align-items-start","border-radius-lg","overflow-hidden","flex-column"],["type","button",1,"close","bg-transparent","hw-40","border-0","hw-40","position-absolute",2,"opacity","0.7","top","0px","right","0px",3,"click"],["name","close14",1,"f-14"],["name","rendering",1,"f-24","hw-24",2,"color","#33B44F"],[1,"text-14","text-semi","lh-160","text-white","mb-0"],[1,"btn","btn-white","btn-h40","border-0","m-btn-white","text-13","grey-800","border-radius-12","mt-3","w-100",3,"click"]],template:function(t,i){if(1&t){const o=e.RV6();e.j41(0,"div",4,0)(2,"div",5)(3,"editor-header",6),e.bIt("closeEvent",function(l){return e.eBV(o),e.Njj(i.closeEditor(l))})("loginEvent",function(){return e.eBV(o),e.Njj(i.logIn())})("addCreditEvent",function(){return e.eBV(o),e.Njj(i.addCredits())})("uploadFileEvent",function(l){return e.eBV(o),e.Njj(i.uploadFile(l))}),e.k0s(),e.j41(4,"div",7)(5,"div")(6,"div",8)(7,"generated-image-preview",9),e.bIt("chooseFileEvent",function(l){return e.eBV(o),e.Njj(i.chooseFile(l))})("uploadFileEvent",function(l){return e.eBV(o),e.Njj(i.uploadFile(l))}),e.k0s()(),e.DNE(8,sh,2,3,"div",10),e.k0s(),e.DNE(9,rh,8,3,"div",11)(10,yh,18,19,"div",12)(11,wh,2,5,"div",12)(12,Sh,2,6,"div",12)(13,Mh,1,0,"div",13),e.k0s(),e.DNE(14,Th,9,4,"div",14),e.k0s()(),e.DNE(15,Oh,16,1,"ng-template",null,1,e.C5r)(17,Gh,2,1,"ng-template",null,2,e.C5r),e.j41(19,"input",15,3),e.bIt("change",function(l){return e.eBV(o),e.Njj(i.onFileUploaded(l.srcElement.files))})("click",function(){e.eBV(o);const l=e.sdS(20);return e.Njj(l.value="")}
1),e.k0s()}if(2&t){const o=e.sdS(18);e.R7$(3),e.Y8G("user",i.user)("checkimg",i.checkimg)("version",i.version)("hideApplyBtn",i.isInspiration||i.videoPreview)("featureType",i.featureType)("activeTab",i.activeTab),e.R7$(),e.Y8G("ngClass",e.l_i(22,oh,"v3"==i.version,"v5"==i.version)),e.R7$(),e.AVh("d-none",(i.featureType||i.isOpeningTool)&&!i.videoPreview),e.R7$(2),e.Y8G("featureType",i.featureType)("videoPreview",i.videoPreview)("checkimg",i.checkimg)("videoUrl",i.videoUrl)("prompt",i.prompt),e.R7$(),e.Y8G("ngIf",i.activeTab&&!i.videoPreview),e.R7$(),e.Y8G("ngIf",i.isOpeningTool&&!i.featureType&&!i.processingProgress.isActive),e.R7$(),e.Y8G("ngIf",i.featureType),e.R7$(),e.Y8G("ngIf",i.isInspiration),e.R7$(),e.Y8G("ngIf",i.editInspiration),e.R7$(),e.Y8G("ngTemplateOutlet",o),e.R7$(),e.Y8G("ngIf",i.aiPhotoService.inProgress||i.aiPhotoService.inVideoProgress||i.processingProgress.isActive),e.R7$(5),e.Y8G("accept",i.aiUploadImageService.fileImageAccept)}},dependencies:[b.YU,b.bT,b.T3,b.ux,b.e1,Wt.g,H.b,qe,pe,Gi.s,en,tn.F,Bs,pr,Nr,ia,Ca,Wa,el,jl,Ze,Wl,dc,Oc,ed,Od,th],styles:[".loaded[_ngcontent-%COMP%]{box-shadow:0 0 12px #0000001a}.editor-view[_ngcontent-%COMP%]{min-width:920px}.btn-play[_ngcontent-%COMP%]{border-radius:50%;padding:10px;background:url(https://static.lightxeditor.com/assets/icons/play.svg) no-repeat}.canvas-loader[_ngcontent-%COMP%], .scene-preview-back[_ngcontent-%COMP%]{position:fixed;width:100%;height:100%;top:0;left:0;background:#000c;z-index:10000}.bottom-panel-wrapper[_ngcontent-%COMP%]{background:#fff;border-radius:12px 12px 0 0;box-shadow:0 0 12px #0000001a}.collapse-header[_ngcontent-%COMP%]{padding:1rem;border-bottom:solid 2px #e2e2e6}.timeline-canvas-wrapper[_ngcontent-%COMP%]{width:calc(100% - 51px);height:200px;overflow-x:auto}.timeline[_ngcontent-%COMP%]{width:100%}.bottom-panel[_ngcontent-%COMP%]{width:100%;display:block;background:#fff;overflow:hidden}.time-duration-container[_ngcontent-%COMP%]{border-radius:6px;width:118px;height:40px;background-color:#fff;border:solid 2px #475ae7}.time-duration-container[_ngcontent-%COMP%]   .btn[_ngcontent-%COMP%]{padding:0rem .5rem}.time-duration-container[_ngcontent-%COMP%]   .btn.textblue[_ngcontent-%COMP%]{color:#475ae7}.layer-text[_ngcontent-%COMP%]{position:absolute;margin-top:64px}.collapse-header[_ngcontent-%COMP%]{padding:11px;border-bottom:1px solid #E2E3E9}.canvas-mask-wrapper[_ngcontent-%COMP%]{display:inline-flex;overflow:auto}.widthAdded[_ngcontent-%COMP%]{width:5.4rem}.widthRemoved[_ngcontent-%COMP%]{width:calc(100% - 5.4rem)}.widthRemoved.ps-0[_ngcontent-%COMP%]{padding-left:0!important}.layers-on[_ngcontent-%COMP%]   .widthRemoved[_ngcontent-%COMP%]{width:calc(100% - 14.5rem)}.active[_ngcontent-%COMP%]{background:#626adf!important;border-radius:16px!important;color:#fff!important}.opacityactive[_ngcontent-%COMP%]{background:#626adf1a!important;color:#626adf!important;border-radius:16px!important}.opacitytext[_ngcontent-%COMP%], .nav-title-text[_ngcontent-%COMP%]{color:#626adf!important}.btn-bottom[_ngcontent-%COMP%]{width:40px;height:40px;padding:0rem;border-radius:12px;background:transparent}.dl-progress[_ngcontent-%COMP%]{width:320px;margin:auto;position:relative;background:#fff;opacity:.95}.pi-overlay-backdrop[_ngcontent-%COMP%]{position:fixed;height:100%;width:100%;top:0;left:0;background:#000c}.canvas-wrapper[_ngcontent-%COMP%]{position:relative}.audio-des[_ngcontent-%COMP%]   .audio-n[_ngcontent-%COMP%]{font-size:16px;line-height:22px}.audio-des[_ngcontent-%COMP%]   .audio-t[_ngcontent-%COMP%]{font-size:14px;line-height:19px;color:#000}.ai-editor-view[_ngcontent-%COMP%]{background:#f4f3f9}.ai-editor-view[_ngcontent-%COMP%]   .left-panel[_ngcontent-%COMP%]{width:23.75rem;background:#fff;border-radius:0 16px 0 0;padding:0}.ai-editor-view[_ngcontent-%COMP%]   .left-panel[_ngcontent-%COMP%]   .top-section[_ngcontent-%COMP%]{height:56px;z-index:99;-webkit-user-select:none;user-select:none}.ai-editor-view[_ngcontent-%COMP%]   .left-panel[_ngcontent-%COMP%]   .top-section[_ngcontent-%COMP%]   a[_ngcontent-%COMP%]{font-size:14px!important;color:#272b34;line-height:19.07px}.ai-editor-view[_ngcontent-%COMP%]   .left-panel[_ngcontent-%COMP%]   .middle-drawer[_ngcontent-%COMP%]{padding-top:56px;user-select:none;-webkit-user-select:none;height:calc(100% - 80px)}.ai-editor-view[_ngcontent-%COMP%]   .left-panel[_ngcontent-%COMP%]   .middle-drawer[_ngcontent-%COMP%]   .ai-thumb-view[_ngcontent-%COMP%]{border-radius:12px;background:#eeedf3;height:134px;position:relative;overflow:hidden;-webkit-user-select:none;user-select:none}.ai-editor-view[_ngcontent-%COMP%]   .left-panel[_ngcontent-%COMP%]   .middle-drawer[_ngcontent-%COMP%]   .ai-thumb-view[_ngcontent-%COMP%]   img[_ngcontent-%COMP%]{height:100%;width:auto;object-fit:contain;overflow:hidden}.ai-editor-view[_ngcontent-%COMP%]   .left-panel[_ngcontent-%COMP%]   .middle-drawer[_ngcontent-%COMP%]   .ai-thumb-view[_ngcontent-%COMP%]:hover   .replace-btn[_ngcontent-%COMP%]{display:flex;z-index:99;position:absolute;background:#0006;align-items:center;justify-content:center;height:100%;width:100%;border-radius:12px;flex-direction:column}.ai-editor-view[_ngcontent-%COMP%]   .left-panel[_ngcontent-%COMP%]   .middle-drawer[_ngcontent-%COMP%]   .ai-thumb-view[_ngcontent-%COMP%]   .replace-btn[_ngcontent-%COMP%]{display:none}.ai-editor-view[_ngcontent-%COMP%]   .left-panel[_ngcontent-%COMP%]   .middle-drawer[_ngcontent-%COMP%]   .ai-thumb-view[_ngcontent-%COMP%]   .replace-btn[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]{background:#fff!important;border:0px!important;color:#272b34!important;min-width:124px}.ai-editor-view[_ngcontent-%COMP%]   .left-panel[_ngcontent-%COMP%]   .middle-drawer[_ngcontent-%COMP%]   .ai-thumb-view[_ngcontent-%COMP%]   .replace-btn[_ngcontent-%COMP%]   button[_ngcontent-%COMP%]:hover{background:linear-gradient(0deg,#626adf0d 0% 100%),#fff!important;color:#272b34}.ai-editor-view[_ngcontent-%COMP%]   .left-panel[_ngcontent-%COMP%]   .middle-drawer[_ngcontent-%COMP%]   .ai-thumb-view[_ngcontent-%COMP%]   .add-on-404[_ngcontent-%COMP%]{display:flex;z-index:99;position:absolute;background:#0000001a;align-items:center;justify-content:center;height:100%;width:100%;border-radius:12px;flex-direction:column}.ai-editor-view[_ngcontent-%COMP%]   .left-panel[_ngcontent-%COMP%]   .middle-drawer[_ngcontent-%COMP%]   .bg-white[_ngcontent-%COMP%]{background:#fff!important}.ai-editor-view[_ngcontent-%COMP%]   .left-panel[_ngcontent-%COMP%]   .middle-drawer[_ngcontent-%COMP%]   .drawer-scroll[_ngcontent-%COMP%]::-webkit-scrollbar{width:4px;height:4px}.ai-editor-view[_ngcontent-%COMP%]   .left-panel[_ngcontent-%COMP%]   .middle-drawer[_ngcontent-%COMP%]   .drawer-scroll[_ngcontent-%COMP%]::-webkit-scrollbar-track{background:#e8e8e8;border-radius:12px;opacity:.6;-webkit-transition:width .2s linear,opacity .2s linear,background-color .2s linear;transition:width .2s linear,opacity .2s linear,background-color .2s linear}.ai-editor-view[_ngcontent-%COMP%]   .left-panel[_ngcontent-%COMP%]   .middle-drawer[_ngcontent-%COMP%]   .drawer-scroll[_ngcontent-%COMP%]::-webkit-scrollbar-thumb{background:#aaa;border-radius:6px}.ai-editor-view[_ngcontent-%COMP%]   .left-panel[_ngcontent-%COMP%]   .middle-drawer[_ngcontent-%COMP%]   .drawer-scroll[_ngcontent-%COMP%]::-webkit-scrollbar-thumb:hover{background:#999}.ai-editor-view[_ngcontent-%COMP%]   .left-panel[_ngcontent-%COMP%]   .middle-drawer.photoshoot-drawer[_ngcontent-%COMP%]{padding-top:112px!important}.ai-editor-view[_ngcontent-%COMP%]   .left-panel[_ngcontent-%COMP%]   .credit-description[_ngcontent-%COMP%]   span[_ngcontent-%COMP%]{display:inline-flex;color:#272b34;font-size:12px}.ai-editor-view[_ngcontent-%COMP%]   .wrapper-for-timeline[_ngcontent-%COMP%]   .main-content[_ngcontent-%COMP%]   .blank-section[_ngcontent-%COMP%]{flex-direction:column;-webkit-user-select:none;user-select:none}.ai-editor-view[_ngcontent-%COMP%]   .wrapper-for-timeline[_ngcontent-%COMP%]   .main-content[_ngcontent-%COMP%]   .blank-section[_ngcontent-%COMP%]   span[_ngcontent-%COMP%]{font-size:14px;color:#272b34}.bottom-btn[_ngcontent-%COMP%]   .middle-drawer[_ngcontent-%COMP%]{padding-bottom:0!important}.bottom-btn[_ngcontent-%COMP%]   .position-absolute.fixed-bottom[_ngcontent-%COMP%]{display:none}.bottom-btn[_ngcontent-%COMP%]   .refine-btn[_ngcontent-%COMP%]{display:block!important}.bottom-btn.bottom-fil[_ngcontent-%COMP%]   .refine-btn[_ngcontent-%COMP%]{display:none!important}.ai-editor-view[_ngcontent-%COMP%]   .left-panel[_ngcontent-%COMP%]   .filter-drawer[_ngcontent-%COMP%]   .middle-drawer[_ngcontent-%COMP%]{padding-top:112px!important;height:calc(100% - 80px)}@media (max-width: 1599.98px){.ai-editor-view[_ngcontent-%COMP%]   .wrapper-for-timeline[_ngcontent-%COMP%]{width:calc(100% - 24rem)}.ai-editor-view[_ngcontent-%COMP%]   .wrapper-for-timeline[_ngcontent-%COMP%]   .main-content[_ngcontent-%COMP%]{height:100%}}@media (max-width: 2600px){.ai-editor-view[_ngcontent-%COMP%]   .wrapper-for-timeline[_ngcontent-%COMP%]{width:calc(100% - 24rem)}.ai-editor-view[_ngcontent-%COMP%]   .wrapper-for-timeline[_ngcontent-%COMP%]   .main-content[_ngcontent-%COMP%]{height:100%}}.bg-f-refine[_ngcontent-%COMP%]{background:transparent url(https://static.lightxeditor.com/assets/images/tranparent.png) left top repeat!important}.photoshoot-replace-none[_ngcontent-%COMP%]{display:none!important}.photoshoot-replace-active[_ngcontent-%COMP%]{display:block!important}.display-ads-section[_ngcontent-%COMP%]{border-top:1px solid #EEEDF3;background:#fff;padding-top:5px;justify-content:space-evenly}.display-ads-section[_ngcontent-%COMP%]   .leaderboard-area[_ngcontent-%COMP%]{width:730px;height:90px;background:#d9d9d9;margin-left:16.5%}.display-ads-section[_ngcontent-%COMP%]   .button-col[_ngcontent-%COMP%]   .btn-h32[_ngcontent-%COMP%]{height:32px;background:transparent!important}.display-ads-section[_ngcontent-%COMP%]   .button-col[_ngcontent-%COMP%]   .btn-h32[_ngcontent-%COMP%]:hover{background:#626adf0d!important}.ai-mobile-video-actions[_ngcontent-%COMP%]{position:absolute;
1left:0;right:0;bottom:0;z-index:3}.mobile-editor-area[_ngcontent-%COMP%]{margin-top:48px;position:relative}.ai-mobile-tool-screen[_ngcontent-%COMP%]{height:calc(100vh - 65px);height:calc(100dvh - 65px);overflow:hidden}.intermediate-preview-height[_ngcontent-%COMP%]{height:calc(100vh - 248px);height:calc(100dvh - 248px);min-height:0;overflow:hidden;touch-action:none}.intermediate-tools-view[_ngcontent-%COMP%]   .intermediate-image-area[_ngcontent-%COMP%]{height:calc(100vh - 244px)}.intermediate-tools-view[_ngcontent-%COMP%]   .intermediate-image-area[_ngcontent-%COMP%]   img[_ngcontent-%COMP%]{width:100%;height:100%;overflow:hidden;object-fit:contain}.intermediate-tools-view[_ngcontent-%COMP%]   .intermediate-tool-area[_ngcontent-%COMP%]{min-height:62px;white-space:nowrap;margin:32px 0}.intermediate-tools-view[_ngcontent-%COMP%]   .intermediate-tool-area[_ngcontent-%COMP%]   .new-scroll-behave[_ngcontent-%COMP%]{-ms-overflow-style:none;scrollbar-width:none}.intermediate-tools-view[_ngcontent-%COMP%]   .intermediate-tool-area[_ngcontent-%COMP%]   .new-scroll-behave[_ngcontent-%COMP%]::-webkit-scrollbar{display:none}.intermediate-tools-view[_ngcontent-%COMP%]   .intermediate-tool-area[_ngcontent-%COMP%]   .tool-box[_ngcontent-%COMP%]{min-width:28.5%;white-space:normal}.intermediate-tools-view[_ngcontent-%COMP%]   .intermediate-tool-area[_ngcontent-%COMP%]   .tool-box[_ngcontent-%COMP%]   span[_ngcontent-%COMP%]{line-height:18px}.mobile-congratulations[_ngcontent-%COMP%]{height:100vh;z-index:9999;top:0;bottom:0}.display-mobile-adds[_ngcontent-%COMP%]{min-height:70px;max-height:70px;left:0;bottom:0}.display-mobile-adds[_ngcontent-%COMP%]   .leaderboard-area[_ngcontent-%COMP%]{width:100%;height:70px;background-color:#d9d9d9}.tool-box-item[_ngcontent-%COMP%]{border-radius:20px;border:1px solid #E2E3E9;background:#f6f6f8}.showpreview-overlay[_ngcontent-%COMP%]{display:none;background:#0003;-webkit-backdrop-filter:blur(20px);backdrop-filter:blur(20px);width:100%;height:100%;top:0;bottom:0;z-index:999}.mobileRetouchHeight[_ngcontent-%COMP%]{overflow:hidden;height:calc(100vh - 108px)}.mobileExpressionHeight[_ngcontent-%COMP%]{overflow:hidden;height:calc(100vh - 60px)}.upscale-editor-wrapper[_ngcontent-%COMP%]{height:calc(100vh - 64px);height:calc(100dvh - 64px)}.popup-item[_ngcontent-%COMP%]{padding:55px 0!important;border-radius:12px;background:linear-gradient(270deg,#626adf00,#626adf1a),#efeef2}.popup-new.new_item[_ngcontent-%COMP%]:after{position:absolute;top:-8px;padding-left:0;right:-22px}.video-in-progress[_ngcontent-%COMP%]{max-width:288px;background:#272b34;box-shadow:0 4px 16px #00000014;top:56px;z-index:99;left:50%;transform:translate(-50%)}"]}),a})(),canDeactivate:[]}];let Rh=(()=>{var s;class a{}return(s=a).\u0275fac=function(t){return new(t||s)},s.\u0275mod=e.$C({type:s}),s.\u0275inj=e.G2t({imports:[A.iI.forChild(Vh),A.iI]}),a})();var Fh=m(7060),Ah=m(22703),Bh=m(85217),Uh=m(49893),Dh=m(27263),Nh=m(50173);let Xh=(()=>{var s;class a{}return(s=a).\u0275fac=function(t){return new(t||s)},s.\u0275mod=e.$C({type:s}),s.\u0275inj=e.G2t({providers:[Ee.P],imports:[b.MD,P.YN,ht.YG,V.r,E.Y]}),a})();var Lh=m(97858),Yh=m(16888),$h=m(6093);let zh=(()=>{var s;class a{}return(s=a).\u0275fac=function(t){return new(t||s)},s.\u0275mod=e.$C({type:s}),s.\u0275inj=e.G2t({providers:[{provide:L.a7,useClass:S.z,multi:!0},he.V,ve,be,(0,L.$R)((0,L.Sx)())],imports:[b.MD,x.G,R.UN,P.YN,P.X1,Rh,V.r,E.Y,O.di,Fh.U,Ah.q,Bh.I,Uh.v,Dh.O,Se.v9,Vt.EO,R.J0,Nh.x,Xh,Lh.r,Yh.T,N.MQ,ut.G,gt.S,$h._]}),a})()},50173:(ce,W,m)=>{"use strict";m.d(W,{x:()=>V});var b=m(60177),L=m(84341),P=m(74710),R=m(23679),S=m(79421),x=m(33391),E=m(54438);let V=(()=>{var O;class N{}return(O=N).\u0275fac=function(w){return new(w||O)},O.\u0275mod=E.$C({type:O}),O.\u0275inj=E.G2t({imports:[b.MD,S.r,R.Y,P.iI,L.X1,x.J0]}),N})()},49893:(ce,W,m)=>{"use strict";m.d(W,{v:()=>x});var b=m(60177),L=m(79421),P=m(74710),R=m(33391),S=m(54438);let x=(()=>{var E;class V{}return(E=V).\u0275fac=function(N){return new(N||E)},E.\u0275mod=S.$C({type:E}),E.\u0275inj=S.G2t({imports:[b.MD,L.r,P.iI,R._f]}),V})()},85217:(ce,W,m)=>{"use strict";m.d(W,{I:()=>w});var b=m(60177),L=m(84341),P=m(33391),R=m(79421),S=m(7060),x=m(83339),E=m(19338),V=m(85188),O=m(21652),N=m(90866),A=m(54438);let w=(()=>{var e;class f{}return(e=f).\u0275fac=function(J){return new(J||e)},e.\u0275mod=A.$C({type:e}),e.\u0275inj=A.G2t({imports:[b.MD,P.UN,L.YN,L.X1,R.r,S.U,x.G,N.R,O.YG,E.di,V.mB.forRoot()]}),f})()},16888:(ce,W,m)=>{"use strict";m.d(W,{T:()=>V});var b=m(60177),L=m(84341),P=m(33391),R=m(83339),S=m(79421),x=m(7060),E=m(54438);let V=(()=>{var O;class N{}return(O=N).\u0275fac=function(w){return new(w||O)},O.\u0275mod=E.$C({type:O}),O.\u0275inj=E.G2t({imports:[b.MD,L.YN,P.UN,R.G,x.U,S.r]}),N})()},99152:(ce,W,m)=>{"use strict";m.d(W,{D:()=>L});var b=m(54438);let L=(()=>{var P;class R{constructor(){this.options=[{id:"2x",quality:2,label:"2X",credits:1}
1,{id:"4x",quality:4,label:"4X",credits:2}]}getOptionById(x){return this.options.find(E=>E.id===x)||null}buildGeneratePayload(x,E){const V=this.getOptionById(E);return V?{imageUrl:x,featureType:"upscale",quality:V.quality}:null}getRequiredCredits(x){const E=this.getOptionById(x);return E?E.credits:0}hasEnoughCredits(x,E,V=!1){const O=this.getRequiredCredits(E);return V?x>O:x>=O}validateDimensions(x,E,V){return x>2048||E>2048?{isValid:!1,errorMsg:"2x"===V?"Image larger than 2048 x 2048 px are not eligible to upscale.":"Image larger than 1024 x 1024 px are not eligible to upscale."}:(x>1024&&x<=2048||E>1024&&E<=2048)&&"4x"===V?{isValid:!1,errorMsg:"Image larger than 1024 x 1024 px are not eligible to upscale."}:{isValid:!0,errorMsg:""}}}return(P=R).\u0275fac=function(x){return new(x||P)},P.\u0275prov=b.jDH({token:P,factory:P.\u0275fac}),R})()},32594:(ce,W,m)=>{"use strict";m.d(W,{d:()=>R});var b=m(16471),L=m(54438),P=m(32764);let R=(()=>{var S;class x{constructor(V){this.templateService=V,this.templateType=1}getResizeContent(V=null){this.templateService.getCreateFromScratchData(this.templateType,!0,O=>{const A=(O.body.socialPlatformsList||[]).concat(this.getCustomLayouts());A&&A.forEach(w=>{w.title=w.socialLabelType.replace(" ","").toLowerCase();let e=[];w.title===b.zu.SocialMedia&&(w.socialPlatformFormats.forEach((f,y)=>{const J=f.socialPlatform.split(" ")[0];-1===e.findIndex(me=>me.title===J.toLowerCase())&&e.push({id:++y,title:J.toLowerCase(),socialPlatform:f.socialPlatform,iconName:f.iconName})}),w.socialMediaLayout=e)}),this.setBoxWidthHeight(A),V&&V(A)},O=>{console.log(O)})}getCustomLayouts(){return[{socialLabelType:"Custom",parentMediaType:"1",socialPlatformFormats:[{title:"custom",shortName:"Custom",format:0,wRatio:0,hRatio:0,width:0,height:0,socialPlatformId:26,thumbUrl:"https://d2v5dzhdg4zhx3.cloudfront.net/provideo-web-banner/travel.png"}]}]}setBoxWidthHeight(V){let O=1;V&&V.forEach(N=>{N.socialPlatformFormats.forEach(A=>{A.id=O++,A.width>A.height?(A.boxHeight=Math.round(70*A.height/A.width),A.boxWidth=70):(A.boxWidth=Math.round(70*A.width/A.height),A.boxHeight=70)})})}}return(S=x).\u0275fac=function(V){return new(V||S)(L.KVO(P.I))},S.\u0275prov=L.jDH({token:S,factory:S.\u0275fac}),x})()},74343:(ce,W,m)=>{"use strict";m.d(W,{_:()=>x});var b=m(16478),L=m(54438),P=m(74710),R=m(74983),S=m(55349);let x=(()=>{var E;class V{constructor(N,A,w,e){this._router=N,this.route=A,this.toastService=w,this.editoruiservice=e}saveProject(N,A,w,e=null){w.isSaving||this.toastService.showProcess("Saving...",{});let f=!w.design.assetId;w.isUserQuotaFull=!1,w.save(N.systemRefKey,y=>{this.toastService.removeAll(),this.toastService.showSuccess(b.b.message.saveSuccess),f&&w.design.assetId&&this._router.navigate([],{replaceUrl:!0,relativeTo:this.route,queryParams:{action:"",project_id:w.design.assetId},queryParamsHandling:""}),A&&A()},y=>{this.toastService.removeAll(),w.isUserQuotaFull&&this.editoruiservice.showStorageLimitError(),e&&e()})}isSaved(N){return N.isSaved()}}return(E=V).\u0275fac=function(N){return new(N||E)(L.KVO(P.Ix),L.KVO(P.nX),L.KVO(R.f),L.KVO(S.f))},E.\u0275prov=L.jDH({token:E,factory:E.\u0275fac}),V})()},90866:(ce,W,m)=>{"use strict";m.d(W,{R:()=>ie});var b=m(60177),L=m(84341),P=m(83339),R=m(48928),S=m(21626),x=m(33391),E=m(72913),V=m(89818),O=m(19338),N=m(85188),A=m(21652),w=m(43387),e=m(55349),f=m(74710),y=m(74343),J=m(79421),Oe=m(24269),me=m(90521),z=m(8708),ee=m(23486),Ye=m(23679),ue=m(7060),ae=m(32594),Z=m(86820),q=m(54438);let ie=(()=>{var ge;class Q{}return(ge=Q).\u0275fac=function(Ee){return new(Ee||ge)},ge.\u0275mod=q.$C({type:ge}),ge.\u0275inj=q.G2t({providers:[e.f,y._,me.K,ae.d,(0,S.$R)((0,S.Sx)())],imports:[b.MD,P.G,x.UN,x._f,L.YN,f.iI,L.X1,E.s,R.RI,V.MQ,O.di,N.mB.forRoot(),A.YG,w.y,z.vo,J.r,Oe.S,ee.v9,Ye.Y,ue.U,Z.e]}),Q})()},43387:(ce,W,m)=>{"use strict";m.d(W,{y:()=>L});var b=m(54438);let L=(()=>{var P;class R{}return(P=R).\u0275fac=function(x){return new(x||P)},P.\u0275mod=b.$C({type:P}),P.\u0275inj=b.G2t({}),R})()},14096:(ce,W)=>{var m=window.fabric;!function(){"use strict";var P=m.Image.filters;P.AdjustmentLips=(0,m.util.createClass)(P.BaseFilter,{type:"AdjustmentLips",cleanCacheEverytime:1,vertexSource:"attribute vec2 aPosition;\nvarying vec2 vTexCoord;\nvarying vec2 vTexCoord2;\nuniform mat3 uTransformMatrix;\nvoid main() {\nvTexCoord = aPosition;
1\nvTexCoord2 = (uTransformMatrix * vec3(aPosition, 1.0)).xy;\ngl_Position = vec4(aPosition * 2.0 - 1.0, 0.0, 1.0);\n}",fragmentSource:"precision lowp float;\nprecision lowp int;\nvarying vec2 vTexCoord;\nuniform sampler2D uTexture;\nuniform sampler2D uImage;\nuniform lowp float brightness;\nuniform lowp float contrast;\nuniform lowp float saturation;\nuniform lowp float hue;\nuniform lowp float intensity;\nuniform mediump vec3 levelMinimum;\nuniform mediump vec3 levelMiddle;\nuniform mediump vec3 levelMaximum;\nuniform mediump vec3 minOutput;\nuniform mediump vec3 maxOutput;\nuniform mediump mat4 colorMatrix;\nconst float PI = 3.1415927;\n// Custom atan(x) using polynomial approximation (faster and avoids recursion)\nfloat my_atan(float x) {\n   // Approximation based on a polynomial fit\n   float abs_x = abs(x);\n   float t = abs_x / (1.0 + 0.28 * abs_x); // Approximate atan shape\n   float atan_approx = t * (PI / 4.0); // Scale to [0, PI/4]\n   // Adjust for input sign\n   return (x < 0.0) ? -atan_approx : atan_approx;\n}\n// Custom atan2(y, x) using quadrant adjustments\nfloat my_atan2(float y, float x) {\n    if (x > 0.0) {\n        return my_atan(y / x);\n    } else if (x < 0.0 && y >= 0.0) {\n        return my_atan(y / x) + PI;\n    } else if (x < 0.0 && y < 0.0) {\n        return my_atan(y / x) - PI;\n    } else if (x == 0.0 && y > 0.0) {\n        return PI / 2.0;\n    } else if (x == 0.0 && y < 0.0) {\n        return -PI / 2.0;\n    }\n}\nvec3 RGBtoYIQ(vec4 color) {\n    float Y = 0.299 * color.r + 0.587 * color.g + 0.114 * color.b;\n    float I = 0.596 * color.r - 0.274 * color.g - 0.322 * color.b;\n    float Q = 0.211 * color.r - 0.523 * color.g + 0.312 * color.b;\n    return vec3(Y, I, Q);\n}\nvec3 YIQtoRGB(vec3 yiq) {\n    float r = yiq.x + 0.956 * yiq.y + 0.621 * yiq.z;\n    float g = yiq.x - 0.272 * yiq.y - 0.647 * yiq.z;\n    float b = yiq.x - 1.106 * yiq.y + 1.703 * yiq.z;\n    return vec3(r, g, b);\n}\nvoid main() {\n   highp vec4 textureColor = texture2D(uTexture, vTexCoord);\n   highp vec4 foregroundMask = texture2D(uImage, vTexCoord);\n   highp vec4 adjustedColor = textureColor;\n\n            // brightness\n  if(adjustedColor.a != 0.0)\n     adjustedColor = vec4((adjustedColor.rgb + vec3(brightness)), adjustedColor.w);\n\n  if(adjustedColor.a != 0.0)\n     adjustedColor = vec4(((adjustedColor.rgb - vec3(0.5)) * contrast + vec3(0.5)), adjustedColor.w);\n\n   vec3 saturationweighting = vec3(0.2125, 0.7154, 0.0721);\n   vec3 greyScaleColor = vec3(dot(adjustedColor.rgb, saturationweighting));\n   vec4 outColor = vec4(mix(greyScaleColor, adjustedColor.rgb, saturation), adjustedColor.a);\n   adjustedColor = outColor;\n\n   // Convert to YIQ\n   vec3 yiq = RGBtoYIQ(adjustedColor);\n\n   // Apply hue shift (rotate I and Q components)\n   float cosHue = cos(hue);\n   float sinHue = sin(hue);\n   float I_new = yiq.y * cosHue - yiq.z * sinHue;\n   float Q_new = yiq.y * sinHue + yiq.z * cosHue;\n\n   // Convert back to RGB\n   vec3 hueColor = YIQtoRGB(vec3(yiq.x, I_new, Q_new));\n   adjustedColor = vec4(hueColor, adjustedColor.a);\n\n   adjustedColor = vec4(mix(minOutput, maxOutput, pow(min(max(adjustedColor.rgb - levelMinimum, vec3(0.0)) / (levelMaximum - levelMinimum), vec3(1.0)), 1.0 / levelMiddle)), textureColor.a);\n   adjustedColor = (intensity * adjustedColor) + ((1.0 - intensity) * textureColor);\n  \n  // MaskAdjustment changes\n  mediump vec4 overlayer = adjustedColor;\n  highp vec4 startColor = textureColor;\n  highp vec4 endColor = adjustedColor;\n  overlayer = endColor * foregroundMask.r + startColor * (1.0 - foregroundMask.r);\n  adjustedColor = overlayer;\n  gl_FragColor = vec4(adjustedColor.rgb, textureColor.a);\n}\n",image:null,adjustment:null,adztOn:0,toneCurveByteArray:new Uint8Array(1024),retrieveShader:function(S){var x=this.type+"_"+this.mode,E=this.fragmentSource[this.mode];return S.programCache.hasOwnProperty(x)||(S.programCache[x]=this.createProgram(S.context,E)),S.programCache[x]},applyToWebGL:function(S){var x=S.context,E=this.createTexture(S.filterBackend,this.image);this.bindAdditionalTexture(x,E,x.TEXTURE1);var V=S.filterBackend.getUnCachedToneCurveTexture(256,1);if(x.activeTexture(x.TEXTURE2),x.bindTexture(x.TEXTURE_2D,V),this.adjustment.redCurve.length>=256&&this.adjustment.greenCurve.length>=256&&this.adjustment.blueCurve.length>=256&&this.adjustment.rgbCompositeCurve.length>=256){for(let O=0;O<256;O++)this.toneCurveByteArray[4*O+2]=255&Math.min(Math.max(O+this.adjustment.blueCurve[O]+this.adjustment.rgbCompositeCurve[O],0),255),this.toneCurveByteArray[4*O+1]=255&Math.min(Math.max(O+this.adjustment.greenCurve[O]+this.adjustment.rgbCompositeCurve[O],0),255),this.toneCurveByteArray[4*O]=255&Math.min(Math.max(O+this.adjustment.redCurve[O]+this.adjustment.rgbCompositeCurve[O],0),255),this.toneCurveByteArray[4*O+3]=255;x.texImage2D(x.TEXTURE_2D,0,x.RGBA,256,1,0,x.RGBA,x.UNSIGNED_BYTE,this.toneCurveByteArray)}this.bindAdditionalTexture(x,V,x.TEXTURE2),this.callSuper("applyToWebGL",S),this.unbindAdditionalTexture(x,x.TEXTURE1),this.unbindAdditionalTexture(x,x.TEXTURE2)},createTexture:function(S,x){return 1===this.cleanCacheEverytime?S.getUnCachedTexture(x):S.getCachedTexture(x.cacheKey,x)},applyTo2d:function(S){if(0!==this.adjustment.brightness){var V,E=S.imageData.data,O=E.length,N=Math.round(255*this.adjutsment.brightness);for(V=0;V<O;V+=4)E[V]=E[V]+N,E[V+1]=E[V+1]+N,E[V+2]=E[V+2]+N}},calculateMatrix:function(){return[1,0,0,0,1,0,0,0,1]},getUniformLocations:function(S,x){return{uTransformMatrix:S.getUniformLocation(x,"uTransformMatrix"),uImage:S.getUniformLocation(x,"uImage"),brightness:S.getUniformLocation(x,"brightness"),contrast:S.getUniformLocation(x,"contrast"),saturation:S.getUniformLocation(x,"saturation"),hue:S.getUniformLocation(x,"hue"),intensity:S.getUniformLocation(x,"intensity"),levelMinimum:S.getUniformLocation(x,"levelMinimum"),levelMiddle:S.getUniformLocation(x,"levelMiddle"),levelMaximum:S.getUniformLocation(x,"levelMaximum"),minOutput:S.getUniformLocation(x,"minOutput"),maxOutput:S.getUniformLocation(x,"maxOutput")}},sendUniformData:function(S,x){var E=this.calculateMatrix();S.uniform1i(x.uImage,1),S.uniformMatrix3fv(x.uTransformMatrix,!1,E),S.uniform1f(x.adztOn,this.adztOn),S.uniform1f(x.brightness,this.adjustment.brightness),S.uniform1f(x.contrast,this.adjustment.contrast),S.uniform1f(x.saturation,this.adjustment.saturation),S.uniform1f(x.hue,this.adjustment.hue),S.uniform1f(x.intensity,this.adjustment.intensity),S.uniform3f(x.levelMinimum,this.adjustment.min[0],this.adjustment.min[1],this.adjustment.min[2]),S.uniform3f(x.levelMiddle,this.adjustment.mid[0],this.adjustment.mid[
11],this.adjustment.mid[2]),S.uniform3f(x.levelMaximum,this.adjustment.max[0],this.adjustment.max[1],this.adjustment.max[2]),S.uniform3f(x.minOutput,this.adjustment.minOutput[0],this.adjustment.minOutput[1],this.adjustment.minOutput[2]),S.uniform3f(x.maxOutput,this.adjustment.maxOutput[0],this.adjustment.maxOutput[1],this.adjustment.maxOutput[2])}}),m.Image.filters.AdjustmentLips.fromObject=m.Image.filters.BaseFilter.fromObject}()}}]);

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.