"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7187],{49009:function(e,t,r){r.d(t,{r:function(){return d}});var n=r(51438),a=r(28668),o=r(26042),i=r(69396),l=r(36305),u=r(91224),c=r(32753),s=r(99826),d=function(e){(0,a.Z)(r,e);var t=(0,u.Z)(r);function r(){return(0,n.Z)(this,r),t.apply(this,arguments)}return r}(r(7988).f);d.userCollagesPreviewTake=(0,c.QS)(1),d.userCollagesTake=(0,c.QS)(25),d.createOrUpdateOneCollage=function(e){var t=d.cache.identify({__typename:"Collage",id:e.id});d.cache.writeFragment({id:t,fragment:s.SWO,fragmentName:"fullCollage",data:e,overwrite:!0})},d.deleteOneCollage=function(e){var t=d.cache.identify({__typename:"Collage",id:e});d.cache.evict({id:t}),d.cache.gc()},d.deleteManyCollages=function(e){e.forEach((function(e){var t=d.cache.identify({__typename:"Collage",id:e});d.cache.evict({id:t})})),d.cache.gc()},d.updateOneCollage=function(e){var t=d.cache.identify({__typename:"Collage",id:e.id});d.cache.writeFragment({id:t,fragment:s.SWO,fragmentName:"fullCollage",data:e,overwrite:!0})},d.updateUserCollageQueries=function(e,t){var r=d.cache.identify({__typename:"Collage",id:e}),n=d.cache.readQuery({query:s.c30,variables:{userId:t,take:d.userCollagesTake()}}),a=d.cache.readQuery({query:s.c30,variables:{userId:t,take:d.userCollagesPreviewTake()}});if(r){var u=d.cache.readFragment({fragment:s.SWO,fragmentName:"fullCollage",id:r});if(n&&u){var c=(0,l.Z)(n.userCollages);-1===c.findIndex((function(t){return t.id===e}))&&(c.unshift(u),d.cache.writeQuery({query:s.c30,variables:{userId:t,take:d.userCollagesTake()},data:(0,i.Z)((0,o.Z)({},n),{userCollages:c}),overwrite:!0}))}if(a&&u&&!u.draft){var f=(0,l.Z)(a.userCollages);f.splice(0,f.length,u),d.cache.writeQuery({query:s.c30,variables:{userId:t,take:d.userCollagesPreviewTake()},data:(0,i.Z)((0,o.Z)({},a),{userCollages:f}),overwrite:!0})}}},d.updateAfterCollageDeleted=function(e){d.deleteOneCollage(e)},d.updateAfterDeleteMultipleCollages=function(e){d.deleteManyCollages(e)},d.updateAfterEditCollage=function(e){d.updateOneCollage(e)},d.updateAfterCreateCollage=function(e,t){d.createOrUpdateOneCollage(e),d.updateUserCollageQueries(e.id,t)}},5540:function(e,t,r){r.d(t,{OV:function(){return g},gr:function(){return v}});var n=r(828),a=r(36305),o=r(10972),i=r(52379),l=r.n(i),u=r(97176),c=r(56067),s=r(56990),d=r(57851),f=r(33085),p=r(54799),g=function(e){var t=e.collage,r=e.className,n=e.emptyTileClicked,i=e.allowReordering,l=e.handleReorder,c=e.isFeatured,s=e.allowRemoving,f=e.handleRemove,g=(0,u.useState)([]),v=g[0],h=g[1],b=(0,u.useState)(-1),w=b[0],x=b[1],y=(0,u.useCallback)((function(e){return p.p.GetTileStyle(t.layout,e)}),[t.layout]),k=(0,u.useMemo)((function(){return"grid-rows-3"}),[]),C=function(e){h((function(t){return(0,a.Z)(t).concat([e])}))};(0,u.useEffect)((function(){h((function(e){return e.filter((function(e){return t.products.map((function(e){return e.id})).includes(e)}))}))}),[t]);var _=(0,u.useMemo)((function(){return v.length===t.products.length}),[v,t]),R=(0,u.useMemo)((function(){for(var e=p.p.LayoutItemCount[t.layout],r=[],n=0;n<e;n++)r.push(n);return r}),[t]);return(0,o.jsx)("div",{className:(0,d.m)("grid h-full max-h-full max-w-full select-none grid-flow-col-dense grid-cols-2 grid-rows-3 gap-1.5 lg:gap-2",c?"gap-1 sm:gap-1.5":"",k,r),children:R.map((function(e){for(var r=void 0,a=0;a<t.products.length;a++)if(t.products[a].sortIndex===e){r=t.products[a];break}return(0,o.jsx)(m,{position:e,collageProduct:r,className:(0,d.m)(y(e)),onImageLoaded:C,fullyLoaded:_,onClick:function(){r||null===n||void 0===n||n(e)},allowReordering:i,handleReorder:l,hoverPosition:w,setHoverPosition:x,isFeatured:c,allowRemoving:s,handleRemove:f,animated:0===t.products.length&&0===e},(null===r||void 0===r?void 0:r.id)||"empty-".concat(e))}))})},m=function(e){var t=e.collageProduct,r=e.className,a=e.onImageLoaded,i=e.fullyLoaded,p=e.onClick,g=e.position,m=e.allowReordering,v=e.handleReorder,h=e.hoverPosition,b=e.setHoverPosition,w=e.isFeatured,x=e.handleRemove,y=e.allowRemoving,k=e.animated,C=(0,u.useState)(0),_=C[0],R=C[1],S=(0,u.useState)(0),T=S[0],Z=S[1],F=(0,n.Z)((0,c.c)({type:"collage_product",item:{collageProduct:t},collect:function(e){return m?{isDragging:e.isDragging(),draggedItem:e.getItem()}:{isDragging:!1,draggedItem:void 0}},isDragging:function(e){var t=e.getClientOffset();return R((null===t||void 0===t?void 0:t.x)||0),Z((null===t||void 0===t?void 0:t.y)||0),!0}}),2),E=F[0].draggedItem,L=F[1],O=(0,n.Z)((0,s.L)({accept:"collage_product",hover:function(e,t){if(m){var r=t.isOver({shallow:!0});null===b||void 0===b||b(r?g:-1)}},drop:function(e){m&&(null===v||void 0===v||v(e.collageProduct,g),null===b||void 0===b||b(-1))}}),2)[1],I=(0,u.useMemo)((function(){var e;return E&&(null===(e=E.collageProduct)||void 0===e?void 0:e.id)===(null===t||void 0===t?void 0:t.id)}),[E,t]),G=(0,u.useMemo)((function(){return h===g}),[h,g]);return(0,o.jsxs)(o.Fragment,{children:[I&&(0,o.jsx)("div",{className:"pointer-events-none fixed top-0 z-max h-22 w-22 -translate-x-11 -translate-y-11 overflow-hidden rounded-xs",style:{boxShadow:"0.25rem 0.75rem 2.25rem -0.6rem rgba(0,0,0,0.4)",left:_,top:T},children:(0,o.jsx)(l(),{layout:"fill",unoptimized:!0,src:t.media.url,className:"object-cover"})}),(0,o.jsxs)("div",{className:(0,d.m)("relative h-full w-full",r),children:[(0,o.jsx)("div",{className:(0,d.m)("relative h-full w-full select-none overflow-hidden rounded-xs lg:rounded-sm",i?"opacity-100":"animate-pulse bg-black opacity-20",G&&!I?"border-2 border-dashed border-black/60":"",I?"opacity-50":"",r),ref:O,children:t?(0,o.jsx)("div",{className:(0,d.m)("relative h-full w-full overflow-hidden",m?"cursor-move":""),ref:L,children:(0,o.jsx)(l(),{layout:"fill",unoptimized:!0,src:t.media.url,className:(0,d.m)("pointer-events-none object-cover",G&&!I?"opacity-80":""),onLoadingComplete:function(){null===a||void 0===a||a(t.id)}})}):(0,o.jsx)("button",{className:(0,d.m)("h-full w-full rounded-xs border border-black/10 bg-white bg-opacity-40 flex-center",r),onClick:p,children:(0,o.jsxs)("div",{className:(0,d.m)("relative h-6 w-6","md:h-8 md:w-8",w?"opacity-0":void 0),children:[k?(0,o.jsx)("div",{className:"pointer-events-none absolute -inset-6 z-20 rounded-md border-2 border-white",style:{animation:"locker_ping 2s cubic-bezier(0, 0, 0.2, 1) infinite",boxShadow:"0 0 2rem 0 rgba(255, 255, 255, 1)"}}):null,(0,o.jsx)(l(),{src:f.pO,layout:"fill",objectFit:"contain"})]})})}),t&&y?(0,o.jsx)("button",{className:"absolute -right-2 -top-2 h-7 w-7 rounded-full border border-black/10 bg-redorange p-2 shadow-md shadow-black/20 md:h-8 md:w-8 lg:shadow-lg lg:shadow-black/30",onClick:function(){var e;e=t,null===x||void 0===x||x(e)},children:(0,o.jsx)("div",{className:"relative h-full w-full",children:(0,o.jsx)(l(),{src:f.b0,layout:"fill",objectFit:"contain",className:"invert"})})}):null]})]})},v=function(e){var t=e.background,r=e.className,n=e.solidClassName,a=e.gradientClassName,i=e.socialExport;return(0,u.useMemo)((function(){var e=p.p.Backgrounds[t];return"string"===typeof e&&e.startsWith("#")?(0,o.jsx)("div",{className:(0,d.m)("absolute inset-0",r,n),style:{backgroundColor:e}}):i?(0,o.jsx)("div",{className:(0,d.m)("h-full w-full !bg-cover !bg-center",r,a),style:{background:"url(".concat(e,")")}}):(0,o.jsx)(l(),{src:e,className:(0,d.m)("scale-[101%] bg-center object-cover",r,a),layout:"fill",alt:"Gradient",objectFit:"cover",objectPosition:"center"})}),[t,r,n,a,i])}},93738:function(e,t,r){r.d(t,{LQ:function(){return y},oE:function(){return k}});var n=r(47568),a=r(36305),o=r(72655),i=r.n(o),l=r(29381),u=r(99826),c=r(54799),s=1080,d=1920,f={width:400,height:560},p=[u.lSr.SolidCream,u.lSr.SolidWhite],g=function(){var e=(0,n.Z)(i().mark((function e(t,r){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.save(),e.next=3,r();case 3:t.restore();case 4:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}();function m(e,t){var r=t.x,n=t.y,a=t.width,o=t.height,i=t.cornerRadii,l=t.shadow,u=t.fill,c=t.border,s=i.topLeft,d=i.topRight,f=i.bottomLeft,p=i.bottomRight;e.beginPath(),e.moveTo(r+s,n),e.lineTo(r+a-d,n),d>0&&e.quadraticCurveTo(r+a,n,r+a,n+d),e.lineTo(r+a,n+o-p),p>0&&e.quadraticCurveTo(r+a,n+o,r+a-p,n+o),e.lineTo(r+f,n+o),f>0&&e.quadraticCurveTo(r,n+o,r,n+o-f),e.lineTo(r,n+s),s>0&&e.quadraticCurveTo(r,n,r+s,n),e.closePath(),l&&(e.shadowOffsetX=l.offsetX,e.shadowOffsetY=l.offsetY,e.shadowBlur=l.blur,e.shadowColor=l.color),u&&(u.color?(e.fillStyle=u.color,e.fill()):u.image&&(e.fillStyle=e.createPattern(u.image,"no-repeat"),e.fill())),c&&(e.lineWidth=c.width,e.strokeStyle=c.color,e.stroke())}var v=function(){var e=(0,n.Z)(i().mark((function e(t,r){var n,a,o;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=[u.lSr.Gradient_1,u.lSr.Gradient_2,u.lSr.Gradient_3,u.lSr.Gradient_4,u.lSr.Gradient_5].includes(r),a={x:0,y:0,width:s,height:d,cornerRadii:{topLeft:0,topRight:0,bottomLeft:0,bottomRight:0},fill:{color:c.p.ExportBackgrounds[r]}},!n){e.next=11;break}return(o=new Image).src=c.p.ExportBackgrounds[r],e.next=8,o.decode();case 8:t.drawImage(o,0,0,s,d),e.next=12;break;case 11:m(t,a);case 12:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),h=function(){var e=(0,n.Z)(i().mark((function e(t){var r,a=arguments;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=a.length>1&&void 0!==a[1]&&a[1],e.next=3,g(t,(0,n.Z)(i().mark((function e(){var n;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(n=new Image(s,d)).src="/images/collage/export/locker_collage_social_overlay.webp",e.next=4,n.decode();case 4:t.globalAlpha=r?.05:.3,r&&(t.filter="invert(1)"),t.drawImage(n,0,0,s,d);case 7:case"end":return e.stop()}}),e)}))));case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),b=function(){var e=(0,n.Z)(i().mark((function e(t,r,o,u){var s,d=arguments;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return s=d.length>4&&void 0!==d[4]&&d[4],e.next=3,g(t,(0,n.Z)(i().mark((function e(){var d,f,p,v,h,b;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.translate(u.x,u.y),d=(0,a.Z)(r.products).sort((function(e,t){return e.sortIndex-t.sortIndex})),f=s?16:10,p=(o.width-f)/2,v=0,h=0,b=0;case 7:if(!(b<c.p.LayoutItemCount[r.layout])){e.next=13;break}return e.next=10,g(t,(0,n.Z)(i().mark((function e(){var n,a,u,g,w,x,y,k,C,_;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=v*(p+f),a=h,t.translate(n,a),u=d.find((function(e){return e.sortIndex===b})),g=(o.height-2*f)/3,w=c.p.Layouts[r.layout].tallIndex===b?2*g+f:g,x={topLeft:18,topRight:18,bottomLeft:18,bottomRight:18},!s){e.next=18;break}e.t0=c.p.Layouts[r.layout].roundingIndeces.indexOf(b),e.next=0===e.t0?10:1===e.t0?12:2===e.t0?14:3===e.t0?16:18;break;case 10:return x.topLeft=64,e.abrupt("break",18);case 12:return x.bottomLeft=64,e.abrupt("break",18);case 14:return x.topRight=64,e.abrupt("break",18);case 16:return x.bottomRight=64,e.abrupt("break",18);case 18:if(y={color:"rgba(255,225,255,0.6)"},!u){e.next=31;break}return(k=new Image).crossOrigin="anonymous",k.src="".concat((0,l.Kc)(u),"?locker_collage_cb=").concat((new Date).getTime()),e.next=25,k.decode();case 25:return C=(0,l.CL)(k,{width:p,height:w}),(_=new Image).src=C,e.next=30,_.decode();case 30:y={image:_};case 31:m(t,{x:0,y:0,width:p,height:w,cornerRadii:x,fill:y}),(h+=w+f)>o.height&&(h=0,v++);case 34:case"end":return e.stop()}}),e)}))));case 10:b++,e.next=7;break;case 13:case"end":return e.stop()}}),e)}))));case 3:case"end":return e.stop()}}),e)})));return function(t,r,n,a){return e.apply(this,arguments)}}(),w=function(){var e=(0,n.Z)(i().mark((function e(t,r,a,o){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,g(t,(0,n.Z)(i().mark((function e(){var n;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.translate(a.x,a.y),o){e.next=3;break}throw new Error("Got empty mediaDataUrl for drawProductTilesFromMedia");case 3:return(n=new Image(r.width,r.height)).src=o,e.next=7,n.decode();case 7:t.shadowBlur=62,t.shadowColor="rgba(0,0,0,0.15)",t.shadowOffsetX=0,t.shadowOffsetY=24,t.drawImage(n,0,0,r.width,r.height);case 12:case"end":return e.stop()}}),e)}))));case 2:case"end":return e.stop()}}),e)})));return function(t,r,n,a){return e.apply(this,arguments)}}(),x=function(){var e=(0,n.Z)(i().mark((function e(t,r,a){var o,l,u=arguments;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=u.length>3&&void 0!==u[3]&&u[3],l=p.includes(r.background),e.next=4,g(t,(0,n.Z)(i().mark((function e(){var u,c,d,f,p,m,v,h,b;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,g(t,(function(){t.font="bold 56px TWKEverett",t.textAlign="left",t.textBaseline="top";var e=t.measureText(r.title).width;t.translate(s/2-e/2,1500),t.fillStyle=l?"black":"white",t.fillText(r.title,0,0)}));case 2:return u=36,c=8,t.globalAlpha=.8,t.font="normal 32px TWKEverett",t.textAlign="left",t.textBaseline="top",d=t.measureText("@".concat(a)).width,f=s/2-d/2,o&&(f-=(u+c)/2),p=1580,e.next=14,g(t,(function(){t.translate(f,p),t.fillStyle=l?"black":"white",t.fillText("@".concat(a),0,0)}));case 14:if(!o){e.next=24;break}return m=f+d+c,v=p-4,h=l?"/images/verified_badge_black.webp":"/images/verified_badge_white.webp",(b=new Image(u,u)).src=h,e.next=22,b.decode();case 22:return e.next=24,g(t,(0,n.Z)(i().mark((function e(){return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.translate(m,v),t.drawImage(b,0,0,u,u);case 2:case"end":return e.stop()}}),e)}))));case 24:case"end":return e.stop()}}),e)}))));case 4:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),y=function(){var e=(0,n.Z)(i().mark((function e(t,r){var n,a,o,l,c,f,p,g,m,b,y,C=arguments;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=C.length>2&&void 0!==C[2]&&C[2],a=document.createElement("canvas"),o=new FontFace("TWKEverett","url(/fonts/TWKEverett-Bold.woff2)"),l=new FontFace("TWKEverett","url(/fonts/TWKEverett-Regular.woff2)"),e.next=6,o.load();case 6:return e.next=8,l.load();case 8:if(document.fonts.add(o),document.fonts.add(l),a.style.fontFamily="TWKEverett, Helvetica, Arial, sans-serif",a.width=s,a.height=d,c=a.getContext("2d"),f=null,!c){e.next=36;break}return c.clearRect(0,0,a.width,a.height),e.next=19,v(c,t.background);case 19:return e.next=21,h(c,t.background===u.lSr.SolidCream);case 21:return m=s/2-(g=(p=994)*(5/7))/2,b=d/2-p/2,e.next=28,k(t,{width:g,height:p},!0);case 28:return y=e.sent,e.next=31,w(c,{width:g,height:p},{x:m,y:b},y);case 31:return e.next=33,x(c,t,r,n);case 33:return e.next=35,a.toDataURL();case 35:f=e.sent;case 36:return e.abrupt("return",f);case 37:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),k=function(){var e=(0,n.Z)(i().mark((function e(t,r){var n,a,o,l,u=arguments;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=u.length>2&&void 0!==u[2]&&u[2],(a=document.createElement("canvas")).width=r?r.width:f.width,a.height=r?r.height:f.height,o=a.getContext("2d"),l=null,!o){e.next=13;break}return o.clearRect(0,0,a.width,a.height),e.next=10,b(o,t,r||f,{x:0,y:0},n);case 10:return e.next=12,a.toDataURL();case 12:l=e.sent;case 13:return e.abrupt("return",l);case 14:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}()},54799:function(e,t,r){r.d(t,{p:function(){return p}});var n,a,o,i,l=r(51438),u=r(14924),c=r(26042),s=r(69396),d=r(57851),f=r(99826),p=function(){function e(){(0,l.Z)(this,e)}return e.GetTileSpan=function(e,t){return this.Layouts[e].tallIndex===t?"row-span-2":"row-span-1"},e.GetTileRounding=function(e,t){var r=this.Layouts[e].roundingIndeces.indexOf(t);if(r>-1)return this.CornerClassName[r]},e.GetTileStyle=function(e,t){return(0,d.m)(this.GetTileSpan(e,t),this.GetTileRounding(e,t))},e}();p.Backgrounds=(n={},(0,u.Z)(n,f.lSr.Gradient_1,"/images/Locker_Gradients-01.webp"),(0,u.Z)(n,f.lSr.Gradient_2,"/images/Locker_Gradients-02.webp"),(0,u.Z)(n,f.lSr.Gradient_3,"/images/Locker_Gradients-03.webp"),(0,u.Z)(n,f.lSr.Gradient_4,"/images/Locker_Gradients-04.webp"),(0,u.Z)(n,f.lSr.Gradient_5,"/images/Locker_Gradients-05.webp"),(0,u.Z)(n,f.lSr.SolidBlack,"#000000"),(0,u.Z)(n,f.lSr.SolidWhite,"#FFFFFF"),(0,u.Z)(n,f.lSr.SolidCream,"#F7F5F1"),(0,u.Z)(n,f.lSr.SolidBeige,"#EAE2D7"),(0,u.Z)(n,f.lSr.SolidGold,"#E1B87F"),(0,u.Z)(n,f.lSr.SolidBlue,"#D2DFF1"),(0,u.Z)(n,f.lSr.SolidRedorange,"#FE804F"),n),p.ExportBackgrounds=(0,s.Z)((0,c.Z)({},p.Backgrounds),(a={},(0,u.Z)(a,f.lSr.Gradient_1,"/images/collage/export/Locker_Gradients-01.webp"),(0,u.Z)(a,f.lSr.Gradient_2,"/images/collage/export/Locker_Gradients-02.webp"),(0,u.Z)(a,f.lSr.Gradient_3,"/images/collage/export/Locker_Gradients-03.webp"),(0,u.Z)(a,f.lSr.Gradient_4,"/images/collage/export/Locker_Gradients-04.webp"),(0,u.Z)(a,f.lSr.Gradient_5,"/images/collage/export/Locker_Gradients-05.webp"),a)),p.Layouts=(o={},(0,u.Z)(o,f.OVj.Five_1,{tallIndex:0,roundingIndeces:[0,1,2,4],thumbnail:"/images/collage/Collage_Layout_5-1.svg"}),(0,u.Z)(o,f.OVj.Five_2,{tallIndex:1,roundingIndeces:[0,1,2,4],thumbnail:"/images/collage/Collage_Layout_5-2.svg"}),(0,u.Z)(o,f.OVj.Five_3,{tallIndex:3,roundingIndeces:[0,2,3,4],thumbnail:"/images/collage/Collage_Layout_5-3.svg"}),(0,u.Z)(o,f.OVj.Five_4,{tallIndex:4,roundingIndeces:[0,2,3,4],thumbnail:"/images/collage/Collage_Layout_5-4.svg"}),o),p.LayoutItemCount=(i={},(0,u.Z)(i,f.OVj.Five_1,5),(0,u.Z)(i,f.OVj.Five_2,5),(0,u.Z)(i,f.OVj.Five_3,5),(0,u.Z)(i,f.OVj.Five_4,5),i),p.CornerClassName={0:"rounded-tl-md lg:rounded-tl-lg",1:"rounded-bl-md lg:rounded-bl-lg",2:"rounded-tr-md lg:rounded-tr-lg",3:"rounded-br-md lg:rounded-br-lg"},p.MAX_TITLE_LENGTH=25},45616:function(e,t,r){r.d(t,{E:function(){return F}});var n=r(97176),a=r(62810),o=r(66867),i=r(81872),l=r(90359),u=r(2443),c=r(29726);var s,d=r(99637),f=r(15496),p=r(33139),g=r(66778),m=r(39208),v=r(31802),h=r(18251),b=r(90011),w=r(1866),x=r(595),y=((s=y||{})[s.RegisterOption=0]="RegisterOption",s[s.UnregisterOption=1]="UnregisterOption",s);let k={0(e,t){let r=[...e.options,{id:t.id,element:t.element,propsRef:t.propsRef}];return{...e,options:(0,c.z2)(r,(e=>e.element.current))}},1(e,t){let r=e.options.slice(),n=e.options.findIndex((e=>e.id===t.id));return-1===n?e:(r.splice(n,1),{...e,options:r})}},C=(0,n.createContext)(null);function _(e){let t=(0,n.useContext)(C);if(null===t){let t=new Error(`<${e} /> is missing a parent <RadioGroup /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(t,_),t}return t}function R(e,t){return(0,i.E)(t.type,k,e,t)}C.displayName="RadioGroupContext";let S=(0,a.yV)((function(e,t){let{value:r,defaultValue:i,name:l,onChange:s,by:x=((e,t)=>e===t),disabled:y=!1,...k}=e,_=(0,b.z)("string"==typeof x?(e,t)=>{let r=x;return(null==e?void 0:e[r])===(null==t?void 0:t[r])}:x),[S,T]=(0,n.useReducer)(R,{options:[]}),Z=S.options,[F,E]=(0,d.b)(),[L,O]=(0,f.f)(),I=`headlessui-radiogroup-${(0,o.M)()}`,G=(0,n.useRef)(null),j=(0,g.T)(G,t),[N,P]=(0,w.q)(r,s,i),A=(0,n.useMemo)((()=>Z.find((e=>!e.propsRef.current.disabled))),[Z]),D=(0,n.useMemo)((()=>Z.some((e=>_(e.propsRef.current.value,N)))),[Z,N]),B=(0,b.z)((e=>{var t;if(y||_(e,N))return!1;let r=null==(t=Z.find((t=>_(t.propsRef.current.value,e))))?void 0:t.propsRef.current;return(null==r||!r.disabled)&&(null==P||P(e),!0)}));(0,p.B)({container:G.current,accept:e=>"radio"===e.getAttribute("role")?NodeFilter.FILTER_REJECT:e.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT,walk(e){e.setAttribute("role","none")}});let M=(0,b.z)((e=>{let t=G.current;if(!t)return;let r=(0,h.r)(t),n=Z.filter((e=>!1===e.propsRef.current.disabled)).map((e=>e.element.current));switch(e.key){case u.R.Enter:(0,v.g)(e.currentTarget);break;case u.R.ArrowLeft:case u.R.ArrowUp:if(e.preventDefault(),e.stopPropagation(),(0,c.jA)(n,c.TO.Previous|c.TO.WrapAround)===c.fE.Success){let e=Z.find((e=>e.element.current===(null==r?void 0:r.activeElement)));e&&B(e.propsRef.current.value)}break;case u.R.ArrowRight:case u.R.ArrowDown:if(e.preventDefault(),e.stopPropagation(),(0,c.jA)(n,c.TO.Next|c.TO.WrapAround)===c.fE.Success){let e=Z.find((e=>e.element.current===(null==r?void 0:r.activeElement)));e&&B(e.propsRef.current.value)}break;case u.R.Space:{e.preventDefault(),e.stopPropagation();let t=Z.find((e=>e.element.current===(null==r?void 0:r.activeElement)));t&&B(t.propsRef.current.value)}}})),W=(0,b.z)((e=>(T({type:0,...e}),()=>T({type:1,id:e.id})))),z=(0,n.useMemo)((()=>({registerOption:W,firstOption:A,containsCheckedOption:D,change:B,disabled:y,value:N,compare:_})),[W,A,D,B,y,N,_]),V={ref:j,id:I,role:"radiogroup","aria-labelledby":F,"aria-describedby":L,onKeyDown:M},K=(0,n.useMemo)((()=>({value:N})),[N]);return n.createElement(O,{name:"RadioGroup.Description"},n.createElement(E,{name:"RadioGroup.Label"},n.createElement(C.Provider,{value:z},null!=l&&null!=N&&(0,v.t)({[l]:N}).map((([e,t])=>n.createElement(m._,{features:m.A.Hidden,...(0,a.oA)({key:e,as:"input",type:"radio",checked:null!=t,hidden:!0,readOnly:!0,name:e,value:t})}))),(0,a.sY)({ourProps:V,theirProps:k,slot:K,defaultTag:"div",name:"RadioGroup"}))))}));var T=(e=>(e[e.Empty=1]="Empty",e[e.Active=2]="Active",e))(T||{});let Z=(0,a.yV)((function(e,t){let r=(0,n.useRef)(null),i=(0,g.T)(r,t),u=`headlessui-radiogroup-option-${(0,o.M)()}`,[c,s]=(0,d.b)(),[p,m]=(0,f.f)(),{addFlag:v,removeFlag:h,hasFlag:w}=function(e=0){let[t,r]=(0,n.useState)(e);return{addFlag:(0,n.useCallback)((e=>r((t=>t|e))),[t]),hasFlag:(0,n.useCallback)((e=>Boolean(t&e)),[t]),removeFlag:(0,n.useCallback)((e=>r((t=>t&~e))),[r]),toggleFlag:(0,n.useCallback)((e=>r((t=>t^e))),[r])}}(1),{value:y,disabled:k=!1,...C}=e,R=(0,n.useRef)({value:y,disabled:k});(0,l.e)((()=>{R.current.value=y}),[y,R]),(0,l.e)((()=>{R.current.disabled=k}),[k,R]);let{registerOption:S,disabled:T,change:Z,firstOption:F,containsCheckedOption:E,value:L,compare:O}=_("RadioGroup.Option");(0,l.e)((()=>S({id:u,element:r,propsRef:R})),[u,S,r,e]);let I=(0,b.z)((e=>{var t;if((0,x.P)(e.currentTarget))return e.preventDefault();!Z(y)||(v(2),null==(t=r.current)||t.focus())})),G=(0,b.z)((e=>{if((0,x.P)(e.currentTarget))return e.preventDefault();v(2)})),j=(0,b.z)((()=>h(2))),N=(null==F?void 0:F.id)===u,P=T||k,A=O(L,y),D={ref:i,id:u,role:"radio","aria-checked":A?"true":"false","aria-labelledby":c,"aria-describedby":p,"aria-disabled":!!P||void 0,tabIndex:P?-1:A||!E&&N?0:-1,onClick:P?void 0:I,onFocus:P?void 0:G,onBlur:P?void 0:j},B=(0,n.useMemo)((()=>({checked:A,disabled:P,active:w(2)})),[A,P,w]);return n.createElement(m,{name:"RadioGroup.Description"},n.createElement(s,{name:"RadioGroup.Label"},(0,a.sY)({ourProps:D,theirProps:C,slot:B,defaultTag:"div",name:"RadioGroup.Option"})))})),F=Object.assign(S,{Option:Z,Label:d._,Description:f.d})}}]);