1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="a1513aa4-ee84-4349-86e7-d7e8ca253814",e._sentryDebugIdIdentifier="sentry-dbid-a1513aa4-ee84-4349-86e7-d7e8ca253814")}catch(e){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2880],{40234:function(e,t,l){l.d(t,{PR:function(){return v},wx:function(){return d}});var r=l(52676),a=l(23545),n=l(52890),s=l(7388),i=l(160),o=l(62284),c=l.n(o),u=l(75271);t.ZP=e=>{var t;let{tab:l,tabList:s,cls:i,itemCls:o,activeBlockCls:c,disabled:u,tabItemAlign:d="horizontal",onChangeTab:v}=e;return(0,r.jsxs)("div",{className:(0,n.cn)("z-1 mobile:mx-4 relative flex h-9 min-w-[204px] items-center rounded-[21px] bg-[var(--slider-bg)] backdrop-blur-lg",u&&"opacity-50",i),children:[s.map((e,t)=>(0,r.jsxs)("div",{className:(0,n.cn)("flex h-8 w-1/2 cursor-pointer items-center justify-center gap-1 whitespace-nowrap px-4 text-base font-normal text-[var(--download-text-color)]",l===e.value&&"z-[2] font-semibold text-[var(--normal-text-color)]",o),onClick:()=>{u||v(e.value)},children:[e.value===l?e.activeIcon:e.icon,(0,a.t)(e.label)]},t)),(0,r.jsx)("div",{className:(0,n.cn)("absolute left-0 top-[2px] z-0 h-[calc(100%-4px)] w-[calc(50%-2px)] rounded-[36px] bg-[var(--slider-bg)] transition-transform duration-200",l===(null==s?void 0:null===(t=s[1])||void 0===t?void 0:t.value)?"translate-x-[calc(100%+2px)]":"translate-x-[2px]",c)})]})};let d=e=>{let{tab:t,disabled:l,tabList:o,cls:d,onChangeTab:v}=e,{phase:f,scrollRef:p}=(0,i.v)("x",!0),m=(0,u.useRef)({}).current;return(0,u.useEffect)(()=>{t&&m.current&&Object.entries(m.current).forEach(e=>{let[l,r]=e;l===t&&r.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})})},[t,m]),(0,r.jsx)("div",{className:(0,n.cn)("no-scrollbar relative w-full overflow-y-auto",("end"===f||"both"===f)&&"".concat(c()["scroll-fade-prev"]),("start"===f||"both"===f)&&"".concat(c()["scroll-fade-next"]," ")),children:(0,r.jsx)(s.Z,{ref:p,className:(0,n.cn)("gap-4",d),children:o.map((e,s)=>(0,r.jsx)("div",{ref:t=>{t&&(m.current={...m.current,[e.value]:t})},className:(0,n.cn)("relative flex h-8 cursor-pointer items-center justify-center whitespace-nowrap px-1 text-sm font-normal text-[var(--download-text-color)] hover:text-[var(--theme-color)]",t===e.value&&"font-semibold text-[var(--theme-color)] after:absolute after:bottom-0 after:left-0 after:h-[2px] after:w-full after:rounded-[2px] after:bg-[var(--theme-color)]",l&&"opacity-30"),onClick:()=>{l||v(e.value)},children:(0,a.t)(e.label)},s))})})},v=e=>{let{tab:t,disabled:l,tabList:o,cls:d,itemCls:v,onChangeTab:f}=e,{phase:p,scrollRef:m}=(0,i.v)("x",!0),h=(0,u.useRef)({}).current;return(0,u.useEffect)(()=>{t&&h.current&&Object.entries(h.current).forEach(e=>{let[l,r]=e;l===t&&r.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})})},[t,h]),(0,r.jsx)("div",{className:(0,n.cn)("no-scrollbar relative w-full flex-1 overflow-y-auto",("end"===p||"both"===p)&&"".concat(c()["scroll-fade-prev"]),("start"===p||"both"===p)&&"".concat(c()["scroll-fade-next"]," ")),children:(0,r.jsx)(s.Z,{ref:m,className:(0,n.cn)("gap-4",d),children:o.map((e,s)=>(0,r.jsxs)("div",{ref:t=>{t&&(h.current={...h.current,[e.value]:t})},className:(0,n.cn)("relative flex h-8 shrink-0 cursor-pointer flex-col items-center justify-center rounded-lg",v,t===e.value&&"bg-[var(--content-primary)]",l&&"opacity-30"),onClick:()=>{l||f(e.value)},children:[(0,r.jsx)("div",{className:(0,n.cn)("ease flex h-[30px] w-9 items-center justify-center"),children:"string"==typeof e.icon&&"string"==typeof e.activeIcon?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("img",{src:e.icon,alt:e.label,className:(0,n.cn)("block h-7 w-9",t===e.value&&"hidden")}),(0,r.jsx)("img",{src:e.activeIcon,alt:e.label,className:(0,n.cn)("hidden h-7 w-9",t===e.value&&"block")})]}):e.icon}),(0,r.jsx)("div",{className:(0,n.cn)("max-w-[52px] overflow-hidden text-ellipsis whitespace-nowrap text-center text-[8px] font-medium text-[var(--download-text-color)]",t===e.value&&"text-black"),children:(0,a.t)(e.label)})]},s))})})}},15576:function(e,t,l){l.d(t,{SF:function(){return n},Vl:function(){return a},rq:function(){return s}});var r=l(75271);t.ZP=e=>{let{ref:t,callback:l}=e;(0,r.useEffect)(()=>{let e=new IntersectionObserver(t=>{t.forEach(t=>{t.isIntersecting&&(null==l||l(),e.disconnect())})});return t.current&&e.observe(t.current),()=>{e.disconnect()}},[l,t])};let a=e=>{let t=(0,r.useRef)(new Map),l=(0,r.useCallback)((l,r,a)=>{var n;let s=t.current.get(r);if(null==l){s.observer.disconnect(),s.el=void 0,s.meta=a;return}if(null==s?void 0:s.exposed){s.el=l,s.meta=a;return}let i=null!==(n=null==s?void 0:s.observer)&&void 0!==n?n:new IntersectionObserver(l=>{l.forEach(l=>{let a=t.current.get(r);l.isIntersecting&&!(null==a?void 0:a.exposed)&&(null==e||e(l.target,null==a?void 0:a.meta),i.disconnect(),t.current.get(r)&&(t.current.get(r).exposed=!0))})});(null==s?void 0:s.el)!==l&&((null==s?void 0:s.el)&&i.unobserve(null==s?void 0:s.el),i.observe(l));let o={...s,meta:a,el:l,observer:i};t.current.set(r,o)},[e]);return[t,l]},n=function(e){let t,l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10,r=[];return a=>{r.push(a),void 0===t&&(t=setTimeout(()=>{e(r),r=[],clearInterval(t),t=void 0},l))}},s=(e,t)=>{let l=e.reduce((e,l)=>{var r;let a=t(l),n=a.length+1,s=null!==(r=e[e.length-1])&&void 0!==r?r:{slice:[],count:0};return s.count+n>100?[...e,{slice:[l],count:a.length}]:(s.count+=n,s.slice.push(l),0===e.length?[s]:e)},[]);return l.map(e=>e.slice)}},34457:function(e,t,l){l.r(t),l.d(t,{default:function(){return F}});var r=l(82095),a=l(52676),n=l(75271),s=l(23545),i=l(4814),o=l(76284),c=l(75491),u=l(65051),d=l(83274),v=l(1129),f=l(34758),p=l(76773),m=l(22971),h=l(85793),x=l(41047),b=l(36958),g=l(46653),y=l(6172),_=l(8859),w=l(62284),I=l.n(w),S=l(38820),j=l(75810),k=l(49813),E=l(80097),N=l(36810),M=l.n(N),U=l(40234),C=l(15576),O=l(52890),R=l(5722),T=l(81076),A=l(160),L=l(7388),Z=l(92868),H=l(71477),D=e=>{let{taskMap:t,source:l,uploading:r,hairstyleList:i=[],haircolorList:o=[],sceneId:d}=e,{reportId:v,tab:p,setTab:h,hairstyleId:x,hairColorId:g,curTask:y,setHairColorId:_,setHairstyleId:w,onGenerate:S}=(0,n.useContext)(E.s),{report:j}=(0,c.n)(),k=(0,m.useRouter)(),{locale:N}=k,D=(0,T.ZP)(),{phase:P,scrollRef:B}=(0,A.v)("x",!0),{phase:J,scrollRef:z}=(0,A.v)("x",!0),F=(0,n.useMemo)(()=>(null==y?void 0:y.status)==="pending",[null==y?void 0:y.status]),q=(0,n.useMemo)(()=>F||r,[F,r]),V=(0,n.useMemo)(()=>{var e,t;return null==y?void 0:null===(e=y.result)||void 0===e?void 0:null===(t=e.result)||void 0===t?void 0:t.resultUrl},[null==y?void 0:y.result]),X=(0,n.useMemo)(()=>q||!l||!!V||p===E.O.hairstyle&&!x||p===E.O.haircolor&&!g,[g,x,q,l,V,p]),W=(0,n.useMemo)(()=>(0,C.SF)(e=>{(0,C.rq)(e,e=>
1"".concat(e.prefix,"_").concat(e.id)).forEach(e=>{j(u.B_.MATERIAL_EXPOSURE,{from_tab:f.MU[f.lS.AIHairstyle],task_id:v.current,style_id:e.map(e=>"".concat(e.prefix,"_").concat(e.id)).join(","),scene_id:d})})}),[j,v,d]),G=(0,n.useCallback)((e,t)=>{W(t)},[W]),[Q,$]=(0,C.Vl)(G),K=(0,n.useCallback)(e=>{h(e)},[h]),Y=(0,n.useCallback)(e=>{var l;let r=t.get(e);if(!r)return;let a=(null==r?void 0:null===(l=r.result)||void 0===l?void 0:l.category)===b.ZJ.HairStyle?"hairs_":"hairc_";j(u.B_.RESULT_EXPOSURE,{picture_number:1,from_tab:f.MU[f.lS.AIHairstyle],from_email:0,stage:"full",task_id:v.current,style_id:"".concat(a).concat(e.replace(/\s+/g,"")),scene_id:d})},[j,v,d,t]),ee=(0,n.useCallback)(e=>{e!==x&&(w(e),j(u.B_.MATERIAL_CLICK,{from_tab:f.MU[f.lS.AIHairstyle],task_id:v.current,style_id:"hairs_".concat(e.replace(/\s+/g,"")),scene_id:d}),Y(e))},[x,w,j,v,d,Y]),et=(0,n.useCallback)(e=>{e!==g&&(_(e),j(u.B_.MATERIAL_CLICK,{from_tab:f.MU[f.lS.AIHairstyle],task_id:v.current,style_id:"hairc_".concat(e.replace(/\s+/g,"")),scene_id:d}),Y(e))},[g,_,j,v,d,Y]),el=(0,n.useMemo)(()=>i.map((e,t)=>(0,a.jsxs)("div",{ref:t=>{$(t,e.styleId,{...e,prefix:"hairs"})},className:"relative",children:[(0,a.jsx)("div",{className:(0,O.cn)("mobile:h-[81px] mobile:w-[70px] relative flex h-[99px] w-[86px] flex-shrink-0 cursor-pointer rounded-[8px] border border-transparent p-[2px]",p===E.O.hairstyle&&e.styleId===x&&"border-[var(--theme-color)]"),onClick:()=>ee(e.styleId),children:(0,a.jsx)(M(),{src:(0,Z.sX)(e.url,160,186),width:D?64:80,height:D?75:93,alt:e.name,className:"rounded-[6px]"})}),e.name&&(0,a.jsx)("div",{className:(0,O.cn)("w-full pt-[6px] text-center text-[10px]",!["en"].includes(N)&&"break-all"),children:e.name}),(0,a.jsx)("div",{className:(0,O.cn)("pointer-events-none absolute -right-[0px] -top-[0] z-[3] translate-x-[40%] translate-y-[-50%] scale-[0.4] rounded-2xl bg-[var(--theme-color)] px-2 py-[3.5px]","text-center text-lg font-bold text-black",!e.isNew&&"hidden"),children:(0,s.t)("gen.new")})]},t)),[x,i,D,N,ee,$,p]),er=(0,n.useMemo)(()=>o.map((e,t)=>(0,a.jsxs)("div",{ref:t=>{$(t,e.styleId,{...e,prefix:"hairc"})},className:"relative",children:[(0,a.jsx)("div",{className:(0,O.cn)("mobile:h-[81px] mobile:w-[70px] relative flex h-[99px] w-[86px] flex-shrink-0 cursor-pointer rounded-[8px] border border-transparent p-[2px]",p===E.O.haircolor&&e.styleId===g&&"border-[var(--theme-color)]"),onClick:()=>et(e.styleId),children:(0,a.jsx)(M(),{src:(0,Z.sX)(e.url,160,186),width:D?64:80,height:D?75:93,alt:e.name,className:"rounded-[6px]"})}),e.name&&(0,a.jsx)("div",{className:"w-full break-all pt-[6px] text-center text-[10px]",children:e.name}),(0,a.jsx)("div",{className:(0,O.cn)("pointer-events-none absolute -right-[0px] -top-[0] z-[3] translate-x-[40%] translate-y-[-50%] scale-[0.4] rounded-2xl bg-[var(--theme-color)] px-2 py-[3.5px]","text-center text-lg font-bold text-black",!e.isNew&&"hidden"),children:(0,s.t)("gen.new")})]},t)),[g,o,D,et,$,p]);return(0,a.jsxs)("div",{className:"flex h-full w-full flex-col justify-between gap-4",children:[(0,a.jsxs)("div",{className:"flex h-full flex-1 flex-col justify-between",children:[(0,a.jsx)(U.ZP,{tab:p,cls:"shrink-0",tabList:[{value:E.O.hairstyle,label:"ah.tab.hairstyle"},{value:E.O.haircolor,label:"ah.tab.haircolor"}],onChangeTab:K}),(0,a.jsx)("div",{className:"relative flex-1",children:(0,a.jsxs)("div",{className:"md:absolute md:h-full md:w-full",children:[(0,a.jsx)("div",{className:(0,O.cn)("no-scrollbar relative h-full w-full flex-1 overflow-y-auto","".concat(p===E.O.hairstyle?"block flex-1":"hidden"),D&&("end"===P||"both"===P)&&"".concat(I()["scroll-fade-prev"]),D&&("start"===P||"both"===P)&&"".concat(I()["scroll-fade-next"]," ")),children:D?(0,a.jsx)(L.Z,{ref:B,className:"mobile:px-4 gap-3 pt-4",children:el}):(0,a.jsx)("div",{className:"no-scrollbar w-full overflow-x-auto pt-4 md:grid md:grid-cols-4 md:gap-3 md:px-3",children:el})}),(0,a.jsx)("div",{className:(0,O.cn)("no-scrollbar relative h-full w-full flex-1 overflow-y-auto","".concat(p===E.O.haircolor?"block flex-1":"hidden"),D&&("end"===J||"both"===J)&&"".concat(I()["scroll-fade-prev"]),D&&("start"===J||"both"===J)&&"".concat(I()["scroll-fade-next"]," ")),children:D?(0,a.jsx)(L.Z,{ref:z,className:"mobile:px-4 gap-3 pt-4",children:er}):(0,a.jsx)("div",{className:"no-scrollbar w-full overflow-x-auto pt-4 md:grid md:grid-cols-4 md:gap-3 md:px-3",children:er})})]})})]}),(0,a.jsx)("div",{className:"mobile:px-4 flex w-full shrink-0 flex-col items-center justify-center gap-4",children:(0,a.jsx)(H.z,{disabled:X,onClick:S,variant:"ghost",className:(0,O.cn)("h-[60px] w-full max-w-[330px] gap-[10px] bg-[var(--theme-color)] text-lg font-semibold text-[var(--c-text-intro-upload-btn)]",X&&"opacity-30"),children:(0,a.jsxs)("div",{className:"flex flex-col items-center",children:[(0,a.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,a.jsx)(R.Z,{width:24,height:24}),(0,a.jsx)("div",{className:"mb-[2px] flex items-center justify-center",children:(0,a.jsx)("span",{className:"text-lg font-semibold text-[var(--c-text-intro-upload-btn)]",children:(0,s.t)("gen.generate.button")})})]}),(0,a.jsx)("div",{className:"text-sm font-normal leading-[1.5] tracking-[-0.24px] text-[#1C2A06]",children:(0,a.jsx)("span",{children:(0,s.t)("gen.cost.generate")})})]})})})]})},P=l(17542),B=l(97690);let J=async(e,t)=>{let{data:l}=await (0,b.Fc)(b.Qp.getTaskResult,{args:[e],signal:t,decider:e=>{var t;return["success","error"].includes(null===(t=e.data)||void 0===t?void 0:t.data.status)}});return l};function z(){let e=(0,r._)(["",""]);return z=function(){return e},e}function F(){var e,t,l,r,w,N,M,U;let{report:C}=(0,c.n)(),O=(0,m.useRouter)(),{type:R}=O.query,{source:T,tab:A,hairColorId:L,hairstyleId:Z}=(0,n.useMemo)(()=>{var e;let t,l;let r=new URLSearchParams(window.location.search),a=r.get("charged"),n=null!==(e=r.get("source"))&&void 0!==e?e:void 0,s=E.O.hairstyle;if(a)return sessionStorage.removeItem(k.oy),{source:n,tab:s,hairColorId:t,hairstyleId:l,charged:!!a};let i=sessionStorage.getItem(k.oy);if(!i)return sessionStorage.removeItem(k.oy),{source:n,tab:s,hairColorId:t,hairstyleId:l,charged:!!a};sessionStorage.removeItem(k.oy);let o=JSON.parse(i);return{...o}},[]),[H,F]=(0,v.Z)({modalClassName:"!pointer-events-none"}
1),q=(0,n.useRef)(O.query.rp),[V,X]=(0,n.useState)(!1),[W,G]=(0,n.useState)(),[Q,$]=(0,n.useState)(),[K,Y]=(0,n.useState)(E.O.hairstyle),ee=(0,n.useRef)(null),{taskMap:et,setTaskMap:el,makeTask:er,source:ea,setSource:en,queryTaskResult:es}=function(e,t){var l;let r=(0,m.useRouter)(),{type:a}=r.query,[s,i]=(0,n.useState)(e),[o,d]=(0,n.useState)(new Map),{report:v}=(0,c.n)(),{requestAddCredit:p}=(0,P.t)(),{user:h}=(0,B.useLogin)(),x=(0,n.useRef)(new AbortController);(0,n.useEffect)(()=>{let e=x.current;return()=>{e.abort()}},[]);let y=(0,n.useCallback)(async(e,l)=>{try{var r,n;if(!s)return;let i=Date.now(),o=e===E.O.hairstyle?b.ZJ.HairStyle:b.ZJ.HairColor,c=e===E.O.hairstyle?"hairs_":"hairc_",m=e===E.O.hairstyle?"4.0":"2.0",{data:{data:_,code:w}}=await b.Qp.createTask(o,m,{mode:l,styleId:l,imageUrl:s}),I=null==_?void 0:_.taskId;if(w===b.Q4.INSUFFICIENT_BALANCE){let t=await p({source:f.MU[f.lS.AIHairstyle],styleId:l,isVip:h.isLogin&&(null===(n=h.vipInfo)||void 0===n?void 0:n.isVip)});if(t)return await y(e,l);d(e=>(e.delete(l),new Map(e)));return}if(!I){d(t=>(t.set(l,{status:g.Tr.ERROR,styleId:l,tab:e}),new Map(t)));return}d(t=>(t.set(l,{status:g.Tr.PENDING,taskId:I,styleId:l,tab:e}),new Map(t)));let S="".concat(c).concat(l.replace(/\s+/g,""));v(u.B_.EDIT_FUNC_USE,{edit_func:f.MU[f.lS.AIHairstyle],task_id:t.current,style_id:S,scene_id:a});let j=await J(I,x.current.signal);return v(u.B_.EDIT_FUNC_SUCCESS,{edit_func:f.MU[f.lS.AIHairstyle],loading_time:Date.now()-i,task_id:t.current,style_id:S,scene_id:a}),v(u.B_.RESULT_EXPOSURE,{picture_number:1,from_tab:f.MU[f.lS.AIHairstyle],from_email:0,stage:"full",task_id:t.current,style_id:S,scene_id:a}),v(u.B_.CREDIT_CONSUME,{source:f.MU[f.lS.AIHairstyle],material_id:S,credit_amount:1,order_id:null==j?void 0:null===(r=j.data)||void 0===r?void 0:r.orderId}),j}catch(t){if((0,b.pm)(t))return;d(t=>(t.set(l,{status:g.Tr.ERROR,styleId:l,tab:e}),new Map(t)))}},[v,t,p,s,a,h.isLogin,null===(l=h.vipInfo)||void 0===l?void 0:l.isVip]),_=(0,n.useCallback)((e,t)=>{var l,r,a;if(!(null===(l=o.get(t))||void 0===l?void 0:null===(r=l.result)||void 0===r?void 0:null===(a=r.result)||void 0===a?void 0:a.resultUrl)){let l=y(e,t).then(e=>{e&&d(l=>{var r;return l.set(t,{...l.get(t),status:(null==e?void 0:null===(r=e.data)||void 0===r?void 0:r.status)==="success"?g.Tr.SUCCESS:g.Tr.ERROR,result:null==e?void 0:e.data}),new Map(l)})}).catch(()=>{d(l=>(l.set(t,{...l.get(t),status:g.Tr.ERROR,styleId:t,tab:e}),new Map(l)))});return d(l=>(l.set(t,{status:g.Tr.PENDING,styleId:t,tab:e}),new Map(l))),l}let n=o.get(t);if((null==n?void 0:n.status)===g.Tr.ERROR)return o.delete(t),_(e,t)},[y,o]),w=(0,n.useCallback)(e=>{i(e),d(new Map)},[]),I=(0,n.useCallback)(async e=>{var l;let r=null!==(l=null==e?void 0:e.tab)&&void 0!==l?l:E.O.hairstyle,n=null==e?void 0:e.taskId,s=e.styleId,i=r===E.O.hairstyle?"hairs_":"hairc_",o="".concat(i).concat(s.replace(/\s+/g,"")),c=await J(n,x.current.signal);v(u.B_.EDIT_FUNC_SUCCESS,{edit_func:f.MU[f.lS.AIHairstyle],loading_time:void 0,task_id:t.current,style_id:o,scene_id:a}),v(u.B_.RESULT_EXPOSURE,{picture_number:1,from_tab:f.MU[f.lS.AIHairstyle],from_email:0,stage:"full",task_id:t.current,style_id:o,scene_id:a}),d(e=>{var t;return e.set(s,{...e.get(s),status:(null==c?void 0:null===(t=c.data)||void 0===t?void 0:t.status)==="success"?g.Tr.SUCCESS:g.Tr.ERROR,result:null==c?void 0:c.data}),new Map(e)})},[v,t,a]);return{source:s,setSource:w,taskMap:o,makeTask:_,setTaskMap:d,queryTaskResult:I}}(T,q),[ei,eo]=(0,n.useState)(),{hairstyleList:ec,haircolorList:eu}=(0,j.y)(),{stageRect:ed}=(0,h.D)({conRef:ee,conRatio:k.vm});(0,n.useEffect)(()=>{T&&sessionStorage.setItem(k.bv,JSON.stringify({sourceUrl:T,rp:q.current}))},[T]),(0,n.useEffect)(()=>{A&&Y(A)},[A]),(0,n.useEffect)(()=>{L&&$(L)},[L]),(0,n.useEffect)(()=>{Z&&G(Z)},[Z]),(0,n.useEffect)(()=>{eo(K===E.O.hairstyle&&et.get(W)||K===E.O.haircolor&&et.get(Q))},[Q,W,K,et]);let ev=(0,n.useCallback)(async e=>{X(!0);try{if(el(new Map),sessionStorage.removeItem(k.bv),e){if("string"==typeof e)en(e);else{C(u.B_.IMPORT_MEDIA_START,{from_tab:f.MU[f.lS.AIHairstyle],type:"click",picture_number:1,scene_id:R});let t=Date.now(),l=await (0,d.v)(e),{error:r}=await (0,y.IC)(l,k.sl);if(r){C(u.B_.IMPORT_MEDIA_FAILED,{from_tab:f.MU[f.lS.AIHairstyle],type:"click",reason:(0,s.t)(_.Bc[r]),ori_picture_number:1,picture_number:1,scene_id:R}),H((0,s.t)(_.Bc[r]),3e3),en(void 0),sessionStorage.removeItem(k.bv),X(!1);return}let a=(0,p.rg)();q.current=a,C(u.B_.IMPORT_MEDIA_SUCCESS,{from_tab:f.MU[f.lS.AIHairstyle],type:"click",picture_number:1,task_id:a,uploading_time:Date.now()-t,scene_id:R}),en(l),sessionStorage.setItem(k.bv,JSON.stringify({sourceUrl:l,rp:q.current}))}}else en(void 0)}catch(e){if(C(u.B_.IMPORT_MEDIA_FAILED,{from_tab:f.MU[f.lS.AIHairstyle],reason:"".concat(e),type:"click",picture_number:1,ori_picture_number:1,scene_id:R}),"nsfw content"===e.message){H((0,s.t)("general.popup.upload.det.toast"));return}H((0,s.t)("gen.upload.failed.retry"))}finally{X(!1)}},[C,H,R]);(0,n.useEffect)(()=>
1{if(O.isReady){let t=JSON.parse(sessionStorage.getItem(k.bv));if((null==t?void 0:t.sourceUrl)&&!t.sourceUrl.startsWith("blob:")){var e;en(t.sourceUrl),q.current=t.rp||(0,p.rg)(),(null!==(e=null==t?void 0:t.tasks)&&void 0!==e?e:[]).forEach(e=>{(null==e?void 0:e.resultUrl)?et.set(null==e?void 0:e.resultUrl.request.styleId,{result:{...e.resultUrl},status:g.Tr.SUCCESS}):(null==e?void 0:e.styleId)&&(null==e?void 0:e.taskId)&&(et.set(null==e?void 0:e.styleId,{status:g.Tr.PENDING,...e}),es(e))}),el(new Map(et))}}},[O.isReady]),(0,n.useEffect)(()=>{if(O.isReady){let e=[];Array.from(et.keys()).forEach(t=>{let l=et.get(t);if(null==l?void 0:l.result)e.push({resultUrl:null==l?void 0:l.result});else{let t=null==l?void 0:l.tab,r=null==l?void 0:l.taskId,a=l.styleId;r&&e.push({taskId:r,styleId:a,tab:t})}});let t=JSON.parse(sessionStorage.getItem(k.bv));sessionStorage.setItem(k.bv,JSON.stringify({...t,tasks:e}))}},[et]);let ef=(0,n.useMemo)(()=>(null==ei?void 0:ei.status)==="pending"||V,[null==ei?void 0:ei.status,V]),ep=(0,n.useMemo)(()=>{var e,t;return null==ei?void 0:null===(e=ei.result)||void 0===e?void 0:null===(t=e.result)||void 0===t?void 0:t.resultUrl},[null==ei?void 0:ei.result]),em=(0,n.useMemo)(()=>!ep||ef,[ef,ep]),eh=(0,n.useCallback)(()=>{var e,t,l,r;let a=null==ei?void 0:null===(e=ei.result)||void 0===e?void 0:null===(t=e.result)||void 0===t?void 0:t.resultUrl;if(!a)return;let n=null==ei?void 0:null===(l=ei.result)||void 0===l?void 0:null===(r=l.request)||void 0===r?void 0:r.styleId;return C(u.B_.MEDIA_SAVE,{media_time:0,picture_number:1,edit_func:f.MU[f.lS.AIHairstyle],task_id:q.current,style_id:K===E.O.hairstyle?"hairs_".concat(n):"hairc_".concat(n),scene_id:R}
1),(0,o.LR)(a,f.MU[f.lS.AIHairstyle])},[null==ei?void 0:null===(e=ei.result)||void 0===e?void 0:e.request,R,null==ei?void 0:null===(t=ei.result)||void 0===t?void 0:null===(l=t.result)||void 0===l?void 0:l.resultUrl,C,K]),ex=(0,n.useCallback)(async()=>{var e,t,l,r;let a=K===E.O.hairstyle;if(a){let l=et.get(W);if(null==l?void 0:null===(e=l.result)||void 0===e?void 0:null===(t=e.result)||void 0===t?void 0:t.resultUrl)return}else{let e=et.get(Q);if(null==e?void 0:null===(l=e.result)||void 0===l?void 0:null===(r=l.result)||void 0===r?void 0:r.resultUrl)return}await er(K,a?W:Q)},[Q,W,er,K,et]),eb=(0,n.useMemo)(()=>({reportId:q,source:ea,hairstyleId:W,setHairstyleId:G,hairColorId:Q,setHairColorId:$,tab:K,setTab:Y,curTask:ei,setCurTask:eo,onDownload:eh,onGenerate:ex}),[ea,W,Q,K,ei,eh,ex]);return(0,a.jsxs)("div",{children:[F,(0,a.jsx)(E.s.Provider,{value:eb,children:(0,a.jsx)("div",{className:(0,i.Z)(z(),I().main_1200),children:(0,a.jsxs)("div",{className:"mobile:flex-col xmd:gap-6 mobile:px-0 flex justify-center gap-10 px-6 py-5 md:pb-[60px] md:pt-8",children:[(0,a.jsxs)("div",{className:"mobile:px-4 relative flex w-full flex-1 flex-col gap-3 overflow-hidden md:gap-4",children:[(0,a.jsx)(S.Z,{module:f.lS.AIHairstyle,headerType:S.P.TWO_BTN,upload:{show:!0,enable:!ef,checkSizeAndPixel:!1,setUploading:X,onUpload:ev,onUrl:ev},download:{show:!0,disabled:em,onClick:eh},sceneId:R}),(0,a.jsx)("div",{ref:ee,className:"mobile:h-[322px] relative isolate flex h-full w-full grow select-none items-center justify-center overflow-hidden rounded-[20px] bg-white/10",style:ed?{height:ed.height}:{},children:ed&&(0,a.jsx)(x.ZP,{stageRect:ed,originUrl:ea,result:{resultUrl:null==ei?void 0:null===(r=ei.result)||void 0===r?void 0:null===(w=r.result)||void 0===w?void 0:w.resultUrl,styleId:null==ei?void 0:null===(N=ei.result)||void 0===N?void 0:null===(M=N.request)||void 0===M?void 0:M.styleId,otherParams:{tab:(null==ei?void 0:null===(U=ei.result)||void 0===U?void 0:U.category)===b.ZJ.HairStyle?E.O.hairstyle:E.O.haircolor}},uploading:V,status:null==ei?void 0:ei.status,module:f.lS.AIHairstyle,reportId:q,getStyleId:(e,t)=>({style_id:(null==t?void 0:t.tab)===E.O.hairstyle?"hairs_".concat(e):"hairc_".concat(e)}),sceneId:R})})]}),(0,a.jsx)("div",{className:"mobile:w-full mobile:gap-6 flex w-[380px] flex-col items-center md:mt-[56px] md:gap-10",children:(0,a.jsx)(D,{source:ea,uploading:V,taskMap:et,hairstyleList:ec,haircolorList:eu,sceneId:R})})]})})})]})}},80097:function(e,t,l){l.d(t,{O:function(){return a},s:function(){return s}});var r,a,n=l(75271);(r=a||(a={})).hairstyle="hairstyle",r.haircolor="haircolor";let s=(0,n.createContext)(null)},75810:function(e,t,l){l.d(t,{y:function(){return n}});var r=l(36958),a=l(75271);let n=()=>{let[e,t]=(0,a.useState)([]),[l,n]=(0,a.useState)([]),s=async e=>{try{let{data:{data:t}}=await r.Le.getMaterialList(e.category,e.version,{pageIndex:1,pageSize:100});e.setList(t)}catch(t){e.setList([])}};return(0,a.useEffect)(()=>{[{category:r.ZJ.HairStyle,setList:t,version:"4.0"},{category:r.ZJ.HairColor,setList:n,version:"2.0"}].forEach(e=>{s(e)})},[]),{hairstyleList:e,haircolorList:l}}},5722:function(e,t,l){var r=l(75271);let a=r.forwardRef(function({title:e,titleId:t,...l},a){return r.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:a,"aria-labelledby":t},l),e?r.createElement("title",{id:t},e):null,r.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.813 15.904 9 18.75l-.813-2.846a4.5 4.5 0 0 0-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 0 0 3.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 0 0 3.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 0 0-3.09 3.09ZM18.259 8.715 18 9.75l-.259-1.035a3.375 3.375 0 0 0-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 0 0 2.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 0 0 2.456 2.456L21.75 6l-1.035.259a3.375 3.375 0 0 0-2.456 2.456ZM16.894 20.567 16.5 21.75l-.394-1.183a2.25 2.25 0 0 0-1.423-1.423L13.5 18.75l1.183-.394a2.25 2.25 0 0 0 1.423-1.423l.394-1.183.394 1.183a2.25 2.25 0 0 0 1.423 1.423l1.183.394-1.183.394a2.25 2.25 0 0 0-1.423 1.423Z"}))});t.Z=a},82095:function(e,t,l){l.d(t,{_:function(){return r}});function r(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}},67811:function(e,t,l){l.d(t,{Z:function(){return b}});var r=l(82433),a=l(99615),n=function(){return a.Z.Date.now()},s=/\s/,i=function(e){for(var t=e.length;t--&&s.test(e.charAt(t)););return t},o=/^\s+/,c=l(98111),u=0/0,d=/^[-+]0x[0-9a-f]+$/i,v=/^0b[01]+$/i,f=/^0o[0-7]+$/i,p=parseInt,m=function(e){if("number"==typeof e)return e;if((0,c.Z)(e))return u;if((0,r.Z)(e)){var t,l="function"==typeof e.valueOf?e.valueOf():e;e=(0,r.Z)(l)?l+"":l}if("string"!=typeof e)return 0===e?e:+e;e=(t=e)?t.slice(0,i(t)+1).replace(o,""):t;var a=v.test(e);return a||f.test(e)?p(e.slice(2),a?2:8):d.test(e)?u:+e},h=Math.max,x=Math.min,b=function(e,t,l){var a,s,i,o,c,u,d=0,v=!1,f=!1,p=!0;if("function"!=typeof e)throw TypeError("Expected a function");function b(t){var l=a,r=s;return a=s=void 0,d=t,o=e.apply(r,l)}function g(e){var l=e-u,r=e-d;return void 0===u||l>=t||l<0||f&&r>=i}function y(){var e,l,r,a=n();if(g(a))return _(a);c=setTimeout(y,(e=a-u,l=a-d,r=t-e,f?x(r,i-l):r))}function _(e){return(c=void 0,p&&a)?b(e):(a=s=void 0,o)}function w(){var e,l=n(),r=g(l);
1if(a=arguments,s=this,u=l,r){if(void 0===c)return d=e=u,c=setTimeout(y,t),v?b(e):o;if(f)return clearTimeout(c),c=setTimeout(y,t),b(u)}return void 0===c&&(c=setTimeout(y,t)),o}return t=m(t)||0,(0,r.Z)(l)&&(v=!!l.leading,i=(f="maxWait"in l)?h(m(l.maxWait)||0,t):i,p="trailing"in l?!!l.trailing:p),w.cancel=function(){void 0!==c&&clearTimeout(c),d=0,a=u=s=c=void 0},w.flush=function(){return void 0===c?o:_(n())},w}},98111:function(e,t,l){var r=l(33918),a=l(13795);t.Z=function(e){return"symbol"==typeof e||(0,a.Z)(e)&&"[object Symbol]"==(0,r.Z)(e)}}}]);
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.